Skip to content

Commit

Permalink
chore: add opt-out for appId mismatch during init via environment var…
Browse files Browse the repository at this point in the history
…iable
  • Loading branch information
awsluja committed Nov 12, 2024
1 parent b40e8e8 commit 07f64ae
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/amplify-cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ export const run = async (context: $TSContext): Promise<void> => {
constructExeInfo(context);
checkForNestedProject();

const projectPath = process.cwd();
if (stateManager.metaFileExists(projectPath)) {
const inputAppId = context.exeInfo?.inputParams?.amplify?.appId;
const appId = getAmplifyAppId();
if (inputAppId && appId && inputAppId !== appId) {
throw new AmplifyError('InvalidAmplifyAppIdError', {
message: `Amplify appId mismatch.`,
resolution: `You are currently working in the amplify project with Id ${appId}`,
});
// Opt-out mechanism for customers that are using old app backend environments with existing apps intentionally
const { AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK } = process.env;
if (AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK !== 'true') {
// check for appId mismatch
const projectPath = process.cwd();
if (stateManager.metaFileExists(projectPath)) {
const inputAppId = context.exeInfo?.inputParams?.amplify?.appId;
const appId = getAmplifyAppId();
if (inputAppId && appId && inputAppId !== appId) {
throw new AmplifyError('InvalidAmplifyAppIdError', {
message: `Amplify appId mismatch.`,
resolution: `You are currently working in the amplify project with Id ${appId}`,
});
}
}
}

Expand Down

0 comments on commit 07f64ae

Please sign in to comment.