UNPKG

@aws-amplify/cli-internal

Version:
96 lines 4.45 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.run = void 0; const amplify_prompts_1 = require("@aws-amplify/amplify-prompts"); const c0_analyzeProject_1 = require("../config-steps/c0-analyzeProject"); const c1_configFrontend_1 = require("../config-steps/c1-configFrontend"); const c2_configProviders_1 = require("../config-steps/c2-configProviders"); const configure_new_user_1 = require("../configure-new-user"); const c9_onFailure_1 = require("../config-steps/c9-onFailure"); const c9_onSuccess_1 = require("../config-steps/c9-onSuccess"); const input_params_manager_1 = require("../input-params-manager"); const app_config_1 = require("../app-config"); const debug_config_1 = require("../app-config/debug-config"); const run = async (context) => { var _a; var _b; if (context.parameters.options['usage-data-off']) { (0, app_config_1.write)(context, { usageDataConfig: { isUsageTrackingEnabled: false } }); amplify_prompts_1.printer.success('Usage Data has been turned off'); return; } if (context.parameters.options['usage-data-on']) { (0, app_config_1.write)(context, { usageDataConfig: { isUsageTrackingEnabled: true } }); amplify_prompts_1.printer.success('Usage Data has been turned on'); return; } if (context.parameters.options['share-project-config-off']) { debug_config_1.DebugConfig.Instance.setAndWriteShareProject(false); amplify_prompts_1.printer.success('Share Project Config has been turned off'); return; } if (context.parameters.options['share-project-config-on']) { debug_config_1.DebugConfig.Instance.setAndWriteShareProject(true); amplify_prompts_1.printer.success('Share Project Config has been turned on'); return; } const { appId, envName } = ((_b = context === null || context === void 0 ? void 0 : context.parameters) === null || _b === void 0 ? void 0 : _b.options) || {}; if (appId && envName) { try { const providerPlugin = await (_a = context.amplify.getProviderPlugins(context).awscloudformation, Promise.resolve().then(() => __importStar(require(_a)))); await providerPlugin.adminLoginFlow(context, appId, envName); } catch (e) { amplify_prompts_1.printer.error(`Failed to authenticate: ${e.message || 'Unknown error occurred.'}`); await context.usageData.emitError(e); process.exit(1); } return; } if (!context.parameters.first) { await (0, configure_new_user_1.configureNewUser)(context); } if (context.parameters.first === 'project') { constructExeInfo(context); try { await (0, c0_analyzeProject_1.analyzeProject)(context); await (0, c1_configFrontend_1.configFrontendHandler)(context); await (0, c2_configProviders_1.configProviders)(context); await (0, c9_onSuccess_1.onSuccess)(context); } catch (e) { void context.usageData.emitError(e); (0, c9_onFailure_1.onFailure)(e); process.exitCode = 1; } } }; exports.run = run; function constructExeInfo(context) { context.exeInfo = context.amplify.getProjectDetails(); context.exeInfo.inputParams = (0, input_params_manager_1.normalizeInputParams)(context); } //# sourceMappingURL=configure.js.map