UNPKG

@aws-amplify/cli-internal

Version:
53 lines 3.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.run = void 0; const amplify_cli_core_1 = require("@aws-amplify/amplify-cli-core"); const amplify_service_helper_1 = require("../amplify-service-helper"); const execution_manager_1 = require("../execution-manager"); const postInitSetup_1 = require("../init-steps/postInitSetup"); const preInitSetup_1 = require("../init-steps/preInitSetup"); const s0_analyzeProject_1 = require("../init-steps/s0-analyzeProject"); const s1_initFrontend_1 = require("../init-steps/s1-initFrontend"); const s2_initProviders_1 = require("../init-steps/s2-initProviders"); const s8_scaffoldHeadless_1 = require("../init-steps/s8-scaffoldHeadless"); const s9_onSuccess_1 = require("../init-steps/s9-onSuccess"); const projectUtils_1 = require("./helpers/projectUtils"); const get_amplify_appId_1 = require("../extensions/amplify-helpers/get-amplify-appId"); const constructExeInfo = (context) => { context.exeInfo = { inputParams: (0, amplify_service_helper_1.constructInputParams)(context), localEnvInfo: {}, }; }; const recommendGen2 = true; const runStrategy = (quickstart) => quickstart ? [(0, preInitSetup_1.getPreInitSetup)(!recommendGen2), s0_analyzeProject_1.analyzeProjectHeadless, s8_scaffoldHeadless_1.scaffoldProjectHeadless, s9_onSuccess_1.onHeadlessSuccess] : [(0, preInitSetup_1.getPreInitSetup)(recommendGen2), s0_analyzeProject_1.analyzeProject, s1_initFrontend_1.initFrontend, s2_initProviders_1.initProviders, s9_onSuccess_1.onSuccess, postInitSetup_1.postInitSetup]; const run = async (context) => { var _a, _b, _c, _d, _e; constructExeInfo(context); (0, projectUtils_1.checkForNestedProject)(); const { AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK } = process.env; if (AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK !== 'true') { const projectPath = process.cwd(); if (amplify_cli_core_1.stateManager.metaFileExists(projectPath)) { const inputAppId = (_c = (_b = (_a = context.exeInfo) === null || _a === void 0 ? void 0 : _a.inputParams) === null || _b === void 0 ? void 0 : _b.amplify) === null || _c === void 0 ? void 0 : _c.appId; const appId = (0, get_amplify_appId_1.getAmplifyAppId)(); if (inputAppId && appId && inputAppId !== appId) { throw new amplify_cli_core_1.AmplifyError('InvalidAmplifyAppIdError', { message: `Amplify appId mismatch.`, resolution: `You are currently working in the amplify project with Id ${appId}. If this is intentional, you may bypass this protection by setting the environment variable AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK to true.`, }); } } } const steps = runStrategy(!!((_e = (_d = context === null || context === void 0 ? void 0 : context.parameters) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.quickstart)); for (const step of steps) { await step(context); } if (context.exeInfo.sourceEnvName && context.exeInfo.localEnvInfo.envName) { await (0, execution_manager_1.raisePostEnvAddEvent)(context, context.exeInfo.sourceEnvName, context.exeInfo.localEnvInfo.envName); } }; exports.run = run; //# sourceMappingURL=init.js.map