1
- import { $TSContext , LocalEnvInfo } from '@aws-amplify/amplify-cli-core' ;
1
+ import { $TSContext , AmplifyError , LocalEnvInfo , stateManager } from '@aws-amplify/amplify-cli-core' ;
2
2
import { constructInputParams } from '../amplify-service-helper' ;
3
3
import { Context } from '../domain/context' ;
4
4
import { raisePostEnvAddEvent } from '../execution-manager' ;
@@ -10,6 +10,7 @@ import { initProviders } from '../init-steps/s2-initProviders';
10
10
import { scaffoldProjectHeadless } from '../init-steps/s8-scaffoldHeadless' ;
11
11
import { onHeadlessSuccess , onSuccess } from '../init-steps/s9-onSuccess' ;
12
12
import { checkForNestedProject } from './helpers/projectUtils' ;
13
+ import { getAmplifyAppId } from '../extensions/amplify-helpers/get-amplify-appId' ;
13
14
14
15
const constructExeInfo = ( context : $TSContext ) : void => {
15
16
context . exeInfo = {
@@ -32,6 +33,18 @@ export const run = async (context: $TSContext): Promise<void> => {
32
33
constructExeInfo ( context ) ;
33
34
checkForNestedProject ( ) ;
34
35
36
+ const projectPath = process . cwd ( ) ;
37
+ if ( stateManager . metaFileExists ( projectPath ) ) {
38
+ const inputAppId = context . exeInfo ?. inputParams ?. amplify ?. appId ;
39
+ const appId = getAmplifyAppId ( ) ;
40
+ if ( inputAppId && appId && inputAppId !== appId ) {
41
+ throw new AmplifyError ( 'InvalidAmplifyAppIdError' , {
42
+ message : `Amplify appId mismatch.` ,
43
+ resolution : `You are currently working in the amplify project with Id ${ appId } ` ,
44
+ } ) ;
45
+ }
46
+ }
47
+
35
48
const steps = runStrategy ( ! ! context ?. parameters ?. options ?. quickstart ) ;
36
49
for ( const step of steps ) {
37
50
await step ( context ) ;
0 commit comments