Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { $TSContext, AmplifyError } from '@aws-amplify/amplify-cli-core';
import { printer } from '@aws-amplify/amplify-prompts';
import { DescribeChangeSetOutput } from '@aws-sdk/client-cloudformation';
import { STATEFUL_RESOURCES } from './stateful-resources';
import execa from 'execa';

export class AmplifyGen2MigrationValidations {
constructor(private readonly context: $TSContext) {}
Expand All @@ -12,7 +13,28 @@ export class AmplifyGen2MigrationValidations {
}

public async validateWorkingDirectory(): Promise<void> {
printer.warn('Not implemented');
const { stdout: statusOutput } = await execa('git', ['status', '--porcelain']);
if (statusOutput.trim()) {
throw new AmplifyError('MigrationError', {
message: 'Working directory has uncommitted changes',
resolution: 'Commit or stash your changes before proceeding with migration.',
});
}

try {
const { stdout: unpushedOutput } = await execa('git', ['log', '@{u}..', '--oneline']);
if (unpushedOutput.trim()) {
throw new AmplifyError('MigrationError', {
message: 'Local branch has unpushed commits',
resolution: 'Push your commits before proceeding with migration.',
});
}
} catch (err: any) {
if (err instanceof AmplifyError) throw err;
if (!err.message?.includes('no upstream') && !err.stderr?.includes('no upstream')) {
throw err;
}
}
}

public async validateDeploymentStatus(): Promise<void> {
Expand Down
Loading