@hubspot/cli 7.4.9-experimental.0 → 7.4.10-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/migrate.d.ts +14 -4
- package/api/migrate.js +16 -2
- package/bin/cli.js +9 -187
- package/commands/account/auth.d.ts +6 -0
- package/commands/account/auth.js +198 -0
- package/commands/account/clean.d.ts +3 -7
- package/commands/account/clean.js +54 -14
- package/commands/account/createOverride.d.ts +6 -0
- package/commands/account/createOverride.js +121 -0
- package/commands/account/info.d.ts +3 -7
- package/commands/account/info.js +51 -9
- package/commands/account/list.d.ts +3 -7
- package/commands/account/list.js +38 -13
- package/commands/account/remove.d.ts +3 -7
- package/commands/account/remove.js +57 -11
- package/commands/account/removeOverride.d.ts +6 -0
- package/commands/account/removeOverride.js +93 -0
- package/commands/account/rename.d.ts +3 -7
- package/commands/account/rename.js +16 -9
- package/commands/account/use.d.ts +5 -9
- package/commands/account/use.js +39 -9
- package/commands/account.d.ts +3 -4
- package/commands/account.js +35 -53
- package/commands/app/migrate.d.ts +5 -6
- package/commands/app/migrate.js +60 -44
- package/commands/app.d.ts +2 -5
- package/commands/app.js +9 -9
- package/commands/auth.d.ts +3 -7
- package/commands/auth.js +25 -15
- package/commands/cms/convertFields.d.ts +7 -1
- package/commands/cms/convertFields.js +57 -41
- package/commands/cms/getReactModule.d.ts +7 -1
- package/commands/cms/getReactModule.js +52 -34
- package/commands/cms/lighthouseScore.d.ts +8 -1
- package/commands/cms/lighthouseScore.js +133 -100
- package/commands/cms.d.ts +3 -1
- package/commands/cms.js +24 -16
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +25 -13
- package/commands/config/migrate.d.ts +6 -0
- package/commands/config/migrate.js +94 -0
- package/commands/config/set.d.ts +10 -1
- package/commands/config/set.js +61 -32
- package/commands/config.d.ts +3 -1
- package/commands/config.js +21 -11
- package/commands/create/api-sample.d.ts +3 -1
- package/commands/create/api-sample.js +34 -36
- package/commands/create/app.d.ts +3 -1
- package/commands/create/app.js +9 -7
- package/commands/create/function.d.ts +3 -1
- package/commands/create/function.js +11 -10
- package/commands/create/index.d.ts +5 -1
- package/commands/create/index.js +23 -11
- package/commands/create/module.d.ts +3 -1
- package/commands/create/module.js +14 -13
- package/commands/create/react-app.d.ts +3 -1
- package/commands/create/react-app.js +10 -7
- package/commands/create/template.d.ts +3 -1
- package/commands/create/template.js +14 -14
- package/commands/create/vue-app.d.ts +3 -1
- package/commands/create/vue-app.js +10 -7
- package/commands/create/webpack-serverless.d.ts +3 -1
- package/commands/create/webpack-serverless.js +10 -7
- package/commands/create/website-theme.d.ts +3 -1
- package/commands/create/website-theme.js +10 -9
- package/commands/create.d.ts +4 -24
- package/commands/create.js +64 -75
- package/commands/customObject/create.d.ts +4 -9
- package/commands/customObject/create.js +17 -10
- package/commands/customObject/schema/create.d.ts +4 -9
- package/commands/customObject/schema/create.js +18 -11
- package/commands/customObject/schema/delete.d.ts +4 -9
- package/commands/customObject/schema/delete.js +21 -11
- package/commands/customObject/schema/fetch-all.d.ts +4 -9
- package/commands/customObject/schema/fetch-all.js +19 -11
- package/commands/customObject/schema/fetch.d.ts +4 -9
- package/commands/customObject/schema/fetch.js +19 -11
- package/commands/customObject/schema/list.d.ts +4 -8
- package/commands/customObject/schema/list.js +17 -10
- package/commands/customObject/schema/update.d.ts +4 -9
- package/commands/customObject/schema/update.js +18 -11
- package/commands/customObject/schema.d.ts +3 -5
- package/commands/customObject/schema.js +27 -54
- package/commands/customObject.d.ts +3 -4
- package/commands/customObject.js +22 -48
- package/commands/doctor.d.ts +6 -8
- package/commands/doctor.js +32 -22
- package/commands/feedback.d.ts +4 -1
- package/commands/feedback.js +40 -48
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -34
- package/commands/filemanager/fetch.d.ts +4 -9
- package/commands/filemanager/fetch.js +18 -11
- package/commands/filemanager/upload.d.ts +4 -9
- package/commands/filemanager/upload.js +17 -11
- package/commands/filemanager.d.ts +3 -4
- package/commands/filemanager.js +20 -42
- package/commands/function/deploy.d.ts +6 -1
- package/commands/function/deploy.js +70 -50
- package/commands/function/list.d.ts +6 -1
- package/commands/function/list.js +44 -32
- package/commands/function/server.d.ts +10 -1
- package/commands/function/server.js +49 -38
- package/commands/function.d.ts +5 -1
- package/commands/function.js +24 -11
- package/commands/hubdb/clear.d.ts +4 -9
- package/commands/hubdb/clear.js +21 -15
- package/commands/hubdb/create.d.ts +4 -9
- package/commands/hubdb/create.js +23 -17
- package/commands/hubdb/delete.d.ts +4 -9
- package/commands/hubdb/delete.js +24 -16
- package/commands/hubdb/fetch.d.ts +4 -9
- package/commands/hubdb/fetch.js +20 -14
- package/commands/hubdb.d.ts +3 -2
- package/commands/hubdb.js +24 -47
- package/commands/init.d.ts +3 -7
- package/commands/init.js +28 -23
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +44 -44
- package/commands/list.d.ts +3 -7
- package/commands/list.js +23 -16
- package/commands/logs.d.ts +10 -1
- package/commands/logs.js +53 -45
- package/commands/module/marketplace-validate.d.ts +6 -1
- package/commands/module/marketplace-validate.js +39 -28
- package/commands/module.d.ts +3 -1
- package/commands/module.js +22 -12
- package/commands/mv.d.ts +3 -7
- package/commands/mv.js +22 -15
- package/commands/open.d.ts +3 -7
- package/commands/open.js +22 -15
- package/commands/project/add.d.ts +3 -7
- package/commands/project/add.js +28 -23
- package/commands/project/cloneApp.d.ts +6 -8
- package/commands/project/cloneApp.js +49 -45
- package/commands/project/create.d.ts +10 -1
- package/commands/project/create.js +85 -63
- package/commands/project/deploy.d.ts +4 -6
- package/commands/project/deploy.js +66 -36
- package/commands/project/dev/deprecatedFlow.js +32 -25
- package/commands/project/dev/index.d.ts +4 -5
- package/commands/project/dev/index.js +70 -25
- package/commands/project/dev/unifiedFlow.d.ts +2 -1
- package/commands/project/dev/unifiedFlow.js +58 -27
- package/commands/project/download.d.ts +3 -7
- package/commands/project/download.js +18 -19
- package/commands/project/installDeps.d.ts +6 -1
- package/commands/project/installDeps.js +48 -32
- package/commands/project/listBuilds.d.ts +3 -7
- package/commands/project/listBuilds.js +32 -27
- package/commands/project/logs.d.ts +10 -1
- package/commands/project/logs.js +73 -65
- package/commands/project/migrate.d.ts +7 -0
- package/commands/project/migrate.js +71 -0
- package/commands/project/migrateApp.d.ts +3 -8
- package/commands/project/migrateApp.js +23 -20
- package/commands/project/open.d.ts +3 -7
- package/commands/project/open.js +29 -21
- package/commands/project/profile/add.d.ts +7 -0
- package/commands/project/profile/add.js +190 -0
- package/commands/project/profile/remove.d.ts +6 -0
- package/commands/project/profile/remove.js +119 -0
- package/commands/project/profile.d.ts +3 -0
- package/commands/project/profile.js +25 -0
- package/commands/project/upload.d.ts +10 -1
- package/commands/project/upload.js +110 -56
- package/commands/project/watch.d.ts +6 -1
- package/commands/project/watch.js +95 -61
- package/commands/project.d.ts +3 -1
- package/commands/project.js +49 -35
- package/commands/remove.d.ts +3 -7
- package/commands/remove.js +25 -15
- package/commands/sandbox/create.d.ts +4 -9
- package/commands/sandbox/create.js +27 -21
- package/commands/sandbox/delete.d.ts +4 -9
- package/commands/sandbox/delete.js +35 -29
- package/commands/sandbox.d.ts +3 -4
- package/commands/sandbox.js +20 -44
- package/commands/secret/addSecret.d.ts +4 -9
- package/commands/secret/addSecret.js +21 -15
- package/commands/secret/deleteSecret.d.ts +4 -9
- package/commands/secret/deleteSecret.js +28 -18
- package/commands/secret/listSecret.d.ts +4 -9
- package/commands/secret/listSecret.js +19 -13
- package/commands/secret/updateSecret.d.ts +4 -9
- package/commands/secret/updateSecret.js +25 -17
- package/commands/secret.d.ts +3 -4
- package/commands/secret.js +25 -49
- package/commands/theme/generate-selectors.d.ts +3 -7
- package/commands/theme/generate-selectors.js +18 -11
- package/commands/theme/marketplace-validate.d.ts +4 -9
- package/commands/theme/marketplace-validate.js +21 -15
- package/commands/theme/preview.d.ts +4 -9
- package/commands/theme/preview.js +31 -24
- package/commands/theme.d.ts +3 -4
- package/commands/theme.js +23 -47
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +118 -98
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +76 -66
- package/lang/en.d.ts +2932 -0
- package/lang/en.js +2796 -3318
- package/lang/en.lyaml +120 -58
- package/lib/accountTypes.d.ts +1 -0
- package/lib/accountTypes.js +12 -0
- package/lib/app/migrate.d.ts +33 -4
- package/lib/app/migrate.js +218 -93
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/app/migrate_legacy.js +15 -12
- package/lib/app/urls.d.ts +16 -0
- package/lib/app/urls.js +16 -0
- package/lib/buildAccount.d.ts +1 -2
- package/lib/buildAccount.js +11 -10
- package/lib/commonOpts.d.ts +3 -4
- package/lib/commonOpts.js +46 -18
- package/lib/configMigrate.d.ts +2 -0
- package/lib/configMigrate.js +118 -0
- package/lib/configOptions.d.ts +4 -0
- package/lib/configOptions.js +41 -45
- package/lib/constants.d.ts +10 -0
- package/lib/constants.js +11 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +14 -40
- package/lib/doctor/Diagnosis.d.ts +1 -2
- package/lib/doctor/Diagnosis.js +19 -16
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +2 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +10 -9
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +59 -45
- package/lib/errorHandlers/index.js +6 -7
- package/lib/errorHandlers/suppressError.js +18 -26
- package/lib/filesystem.d.ts +1 -1
- package/lib/generateSelectors.js +1 -2
- package/lib/hasFeature.d.ts +3 -1
- package/lib/interpolation.d.ts +2 -3
- package/lib/lang.d.ts +2 -3
- package/lib/middleware/__test__/configMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/configMiddleware.test.js +194 -0
- package/lib/middleware/__test__/gitMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/gitMiddleware.test.js +76 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.js +10 -0
- package/lib/middleware/__test__/requestMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/requestMiddleware.test.js +20 -0
- package/lib/middleware/__test__/utils.test.d.ts +1 -0
- package/lib/middleware/__test__/utils.test.js +53 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +81 -0
- package/lib/middleware/autoUpdateMiddleware.d.ts +1 -0
- package/lib/middleware/autoUpdateMiddleware.js +89 -0
- package/lib/middleware/configMiddleware.d.ts +13 -0
- package/lib/middleware/configMiddleware.js +124 -0
- package/lib/middleware/fireAlarmMiddleware.d.ts +4 -0
- package/lib/middleware/fireAlarmMiddleware.js +123 -0
- package/lib/middleware/gitMiddleware.d.ts +2 -0
- package/lib/middleware/gitMiddleware.js +14 -0
- package/lib/middleware/notificationsMiddleware.d.ts +1 -0
- package/lib/middleware/notificationsMiddleware.js +38 -0
- package/lib/middleware/requestMiddleware.d.ts +1 -0
- package/lib/middleware/requestMiddleware.js +11 -0
- package/lib/middleware/utils.d.ts +8 -0
- package/lib/middleware/utils.js +17 -0
- package/lib/middleware/yargsChecksMiddleware.d.ts +4 -0
- package/lib/middleware/yargsChecksMiddleware.js +24 -0
- package/lib/npm.d.ts +9 -0
- package/lib/npm.js +36 -0
- package/lib/oauth.js +1 -2
- package/lib/process.js +1 -2
- package/lib/projectProfiles.d.ts +6 -0
- package/lib/projectProfiles.js +65 -0
- package/lib/projects/ProjectLogsManager.d.ts +1 -1
- package/lib/projects/ProjectLogsManager.js +16 -21
- package/lib/projects/buildAndDeploy.js +45 -41
- package/lib/projects/config.d.ts +9 -0
- package/lib/projects/config.js +79 -0
- package/lib/projects/create.js +5 -6
- package/lib/projects/ensureProjectExists.d.ts +11 -0
- package/lib/projects/ensureProjectExists.js +97 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +26 -0
- package/lib/projects/localDev/AppDevModeInterface.js +156 -0
- package/lib/{DevServerManager.d.ts → projects/localDev/DevServerManager.d.ts} +1 -1
- package/lib/{DevServerManager.js → projects/localDev/DevServerManager.js} +6 -6
- package/lib/projects/localDev/DevServerManagerV2.d.ts +22 -0
- package/lib/{DevServerManagerV2.js → projects/localDev/DevServerManagerV2.js} +22 -19
- package/lib/projects/localDev/LocalDevLogger.d.ts +30 -0
- package/lib/projects/localDev/LocalDevLogger.js +158 -0
- package/lib/{LocalDevManager.d.ts → projects/localDev/LocalDevManager.d.ts} +1 -1
- package/lib/{LocalDevManager.js → projects/localDev/LocalDevManager.js} +57 -83
- package/lib/projects/localDev/LocalDevProcess.d.ts +27 -0
- package/lib/projects/localDev/LocalDevProcess.js +171 -0
- package/lib/projects/localDev/LocalDevState.d.ts +37 -0
- package/lib/projects/localDev/LocalDevState.js +78 -0
- package/lib/projects/localDev/LocalDevWatcher.d.ts +10 -0
- package/lib/projects/localDev/LocalDevWatcher.js +56 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +17 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +92 -0
- package/lib/{localDev.d.ts → projects/localDev/helpers.d.ts} +5 -4
- package/lib/{localDev.js → projects/localDev/helpers.js} +98 -114
- package/lib/projects/ui.d.ts +1 -0
- package/lib/projects/ui.js +15 -0
- package/lib/projects/upload.d.ts +14 -2
- package/lib/projects/upload.js +19 -35
- package/lib/projects/urls.d.ts +1 -0
- package/lib/projects/urls.js +6 -0
- package/lib/projects/watch.d.ts +1 -1
- package/lib/projects/watch.js +21 -18
- package/lib/prompts/accountNamePrompt.js +16 -13
- package/lib/prompts/accountsPrompt.js +1 -2
- package/lib/prompts/cmsFieldPrompt.js +1 -2
- package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
- package/lib/prompts/createApiSamplePrompt.js +4 -5
- package/lib/prompts/createFunctionPrompt.js +13 -14
- package/lib/prompts/createModulePrompt.js +8 -9
- package/lib/prompts/createProjectPrompt.d.ts +11 -4
- package/lib/prompts/createProjectPrompt.js +14 -9
- package/lib/prompts/createTemplatePrompt.d.ts +22 -4
- package/lib/prompts/createTemplatePrompt.js +1 -2
- package/lib/prompts/downloadProjectPrompt.js +3 -4
- package/lib/prompts/installAppPrompt.d.ts +1 -0
- package/lib/prompts/installAppPrompt.js +35 -0
- package/lib/prompts/personalAccessKeyPrompt.js +17 -18
- package/lib/prompts/previewPrompt.js +5 -6
- package/lib/prompts/projectAddPrompt.js +4 -5
- package/lib/prompts/projectDevTargetAccountPrompt.js +18 -12
- package/lib/prompts/projectNamePrompt.js +5 -6
- package/lib/prompts/projectsLogsPrompt.js +3 -2
- package/lib/prompts/promptUtils.d.ts +3 -2
- package/lib/prompts/promptUtils.js +2 -1
- package/lib/prompts/sandboxesPrompt.js +5 -6
- package/lib/prompts/secretPrompt.js +2 -3
- package/lib/prompts/selectHubDBTablePrompt.js +11 -8
- package/lib/prompts/selectPublicAppPrompt.js +6 -7
- package/lib/prompts/setAsDefaultAccountPrompt.js +1 -2
- package/lib/prompts/uploadPrompt.js +4 -5
- package/lib/sandboxSync.js +15 -14
- package/lib/sandboxes.js +12 -13
- package/lib/serverlessLogs.js +4 -6
- package/lib/testUtils.d.ts +3 -3
- package/lib/testUtils.js +8 -9
- package/lib/ui/SpinniesManager.d.ts +1 -1
- package/lib/ui/boxen.d.ts +5 -0
- package/lib/ui/boxen.js +30 -0
- package/lib/ui/git.js +8 -9
- package/lib/ui/index.d.ts +4 -2
- package/lib/ui/index.js +20 -17
- package/lib/ui/logger.d.ts +10 -0
- package/lib/ui/logger.js +15 -0
- package/lib/ui/serverlessFunctionLogs.js +2 -3
- package/lib/ui/spinniesUtils.d.ts +5 -5
- package/lib/upload.d.ts +1 -1
- package/lib/validation.js +4 -5
- package/lib/yargsUtils.d.ts +5 -1
- package/lib/yargsUtils.js +6 -0
- package/package.json +10 -6
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +24 -0
- package/types/LocalDev.js +2 -0
- package/types/Yargs.d.ts +12 -11
- package/lib/DevServerManagerV2.d.ts +0 -33
- package/lib/LocalDevManagerV2.d.ts +0 -64
- package/lib/LocalDevManagerV2.js +0 -377
- package/lib/projects/index.d.ts +0 -20
- package/lib/projects/index.js +0 -194
- package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
- package/lib/prompts/installPublicAppPrompt.js +0 -40
|
@@ -1,89 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
exports.handler = async (options) => {
|
|
24
|
-
const { derivedAccountId } = options;
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
+
const github_1 = require("@hubspot/local-dev-lib/github");
|
|
11
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
12
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
13
|
+
const createProjectPrompt_1 = require("../../lib/prompts/createProjectPrompt");
|
|
14
|
+
const config_1 = require("../../lib/projects/config");
|
|
15
|
+
const create_1 = require("../../lib/projects/create");
|
|
16
|
+
const lang_1 = require("../../lib/lang");
|
|
17
|
+
const ui_1 = require("../../lib/ui");
|
|
18
|
+
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
19
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
20
|
+
const constants_1 = require("../../lib/constants");
|
|
21
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
22
|
+
const command = 'create';
|
|
23
|
+
const describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`commands.project.subcommands.create.describe`), false);
|
|
24
|
+
async function handler(args) {
|
|
25
|
+
const { derivedAccountId } = args;
|
|
25
26
|
let latestRepoReleaseTag;
|
|
26
|
-
let templateSource =
|
|
27
|
+
let templateSource = args.templateSource;
|
|
27
28
|
if (!templateSource) {
|
|
28
|
-
templateSource = HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH;
|
|
29
|
+
templateSource = constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH;
|
|
29
30
|
try {
|
|
30
|
-
const releaseData = await fetchReleaseData(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH);
|
|
31
|
+
const releaseData = await (0, github_1.fetchReleaseData)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH);
|
|
31
32
|
if (releaseData) {
|
|
32
33
|
latestRepoReleaseTag = releaseData.tag_name;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
catch (err) {
|
|
36
|
-
logger.error(i18n(
|
|
37
|
-
process.exit(EXIT_CODES.ERROR);
|
|
37
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.create.errors.failedToFetchProjectList`));
|
|
38
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
+
if (!templateSource || !templateSource.includes('/')) {
|
|
42
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.create.errors.invalidTemplateSource`));
|
|
43
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
44
|
+
}
|
|
45
|
+
const projectTemplates = await (0, create_1.getProjectTemplateListFromRepo)(templateSource, latestRepoReleaseTag || constants_1.DEFAULT_PROJECT_TEMPLATE_BRANCH);
|
|
41
46
|
if (!projectTemplates.length) {
|
|
42
|
-
logger.error(i18n(
|
|
43
|
-
process.exit(EXIT_CODES.ERROR);
|
|
47
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.create.errors.failedToFetchProjectList`));
|
|
48
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
44
49
|
}
|
|
45
|
-
const createProjectPromptResponse = await createProjectPrompt(
|
|
46
|
-
const projectDest =
|
|
47
|
-
trackCommandUsage('project-create', { type: createProjectPromptResponse.projectTemplate.name }, derivedAccountId);
|
|
48
|
-
const { projectConfig: existingProjectConfig, projectDir: existingProjectDir, } = await getProjectConfig(projectDest);
|
|
50
|
+
const createProjectPromptResponse = await (0, createProjectPrompt_1.createProjectPrompt)(args, projectTemplates);
|
|
51
|
+
const projectDest = path_1.default.resolve((0, path_2.getCwd)(), createProjectPromptResponse.dest);
|
|
52
|
+
(0, usageTracking_1.trackCommandUsage)('project-create', { type: createProjectPromptResponse.projectTemplate.name }, derivedAccountId);
|
|
53
|
+
const { projectConfig: existingProjectConfig, projectDir: existingProjectDir, } = await (0, config_1.getProjectConfig)(projectDest);
|
|
49
54
|
// Exit if the target destination is within an existing project
|
|
50
|
-
if (existingProjectConfig &&
|
|
51
|
-
|
|
55
|
+
if (existingProjectConfig &&
|
|
56
|
+
existingProjectDir &&
|
|
57
|
+
projectDest.startsWith(existingProjectDir)) {
|
|
58
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.create.errors.cannotNestProjects`, {
|
|
52
59
|
projectDir: existingProjectDir,
|
|
53
60
|
}));
|
|
54
|
-
process.exit(EXIT_CODES.ERROR);
|
|
61
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
55
62
|
}
|
|
56
63
|
try {
|
|
57
|
-
await cloneGithubRepo(templateSource, projectDest, {
|
|
64
|
+
await (0, github_1.cloneGithubRepo)(templateSource, projectDest, {
|
|
58
65
|
sourceDir: createProjectPromptResponse.projectTemplate.path,
|
|
59
66
|
tag: latestRepoReleaseTag,
|
|
60
67
|
hideLogs: true,
|
|
61
68
|
});
|
|
62
69
|
}
|
|
63
70
|
catch (err) {
|
|
64
|
-
debugError(err);
|
|
65
|
-
logger.error(i18n(
|
|
66
|
-
process.exit(EXIT_CODES.ERROR);
|
|
71
|
+
(0, errorHandlers_1.debugError)(err);
|
|
72
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.create.errors.failedToDownloadProject`));
|
|
73
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
67
74
|
}
|
|
68
|
-
const projectConfigPath =
|
|
69
|
-
const parsedConfigFile = JSON.parse(
|
|
70
|
-
writeProjectConfig(projectConfigPath, {
|
|
75
|
+
const projectConfigPath = path_1.default.join(projectDest, constants_1.PROJECT_CONFIG_FILE);
|
|
76
|
+
const parsedConfigFile = JSON.parse(fs_extra_1.default.readFileSync(projectConfigPath).toString());
|
|
77
|
+
(0, config_1.writeProjectConfig)(projectConfigPath, {
|
|
71
78
|
...parsedConfigFile,
|
|
72
79
|
name: createProjectPromptResponse.name,
|
|
73
80
|
});
|
|
74
81
|
// If the template is 'no-template', we need to manually create a src directory
|
|
75
82
|
if (createProjectPromptResponse.projectTemplate.name ===
|
|
76
|
-
EMPTY_PROJECT_TEMPLATE_NAME) {
|
|
77
|
-
|
|
83
|
+
create_1.EMPTY_PROJECT_TEMPLATE_NAME) {
|
|
84
|
+
fs_extra_1.default.ensureDirSync(path_1.default.join(projectDest, 'src'));
|
|
78
85
|
}
|
|
79
|
-
logger.log('');
|
|
80
|
-
logger.success(i18n(
|
|
86
|
+
logger_1.logger.log('');
|
|
87
|
+
logger_1.logger.success((0, lang_1.i18n)(`commands.project.subcommands.create.logs.success`, {
|
|
81
88
|
projectName: createProjectPromptResponse.name,
|
|
82
89
|
projectDest,
|
|
83
90
|
}));
|
|
84
|
-
logger.log('');
|
|
85
|
-
logger.log(
|
|
86
|
-
uiFeatureHighlight([
|
|
91
|
+
logger_1.logger.log('');
|
|
92
|
+
logger_1.logger.log(chalk_1.default.bold((0, lang_1.i18n)(`commands.project.subcommands.create.logs.welcomeMessage`)));
|
|
93
|
+
(0, ui_1.uiFeatureHighlight)([
|
|
87
94
|
'projectCommandTip',
|
|
88
95
|
'projectUploadCommand',
|
|
89
96
|
'projectDevCommand',
|
|
@@ -92,36 +99,51 @@ exports.handler = async (options) => {
|
|
|
92
99
|
'feedbackCommand',
|
|
93
100
|
'sampleProjects',
|
|
94
101
|
]);
|
|
95
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
96
|
-
}
|
|
97
|
-
|
|
102
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
103
|
+
}
|
|
104
|
+
function projectCreateBuilder(yargs) {
|
|
98
105
|
yargs.options({
|
|
99
106
|
name: {
|
|
100
|
-
describe: i18n(
|
|
107
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.create.options.name.describe`),
|
|
101
108
|
type: 'string',
|
|
102
109
|
},
|
|
103
110
|
dest: {
|
|
104
|
-
describe: i18n(
|
|
111
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.create.options.dest.describe`),
|
|
105
112
|
type: 'string',
|
|
106
113
|
},
|
|
107
114
|
template: {
|
|
108
|
-
describe: i18n(
|
|
115
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.create.options.template.describe`),
|
|
109
116
|
type: 'string',
|
|
110
117
|
},
|
|
111
118
|
'template-source': {
|
|
112
|
-
describe: i18n(
|
|
119
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.create.options.templateSource.describe`),
|
|
113
120
|
type: 'string',
|
|
114
121
|
},
|
|
115
122
|
});
|
|
116
|
-
yargs.example([
|
|
123
|
+
yargs.example([
|
|
124
|
+
[
|
|
125
|
+
'$0 project create',
|
|
126
|
+
(0, lang_1.i18n)(`commands.project.subcommands.create.examples.default`),
|
|
127
|
+
],
|
|
128
|
+
]);
|
|
117
129
|
yargs.example([
|
|
118
130
|
[
|
|
119
131
|
'$0 project create --template-source HubSpot/ui-extensions-examples',
|
|
120
|
-
i18n(
|
|
132
|
+
(0, lang_1.i18n)(`commands.project.subcommands.create.examples.templateSource`),
|
|
121
133
|
],
|
|
122
134
|
]);
|
|
123
|
-
addConfigOptions(yargs);
|
|
124
|
-
addAccountOptions(yargs);
|
|
125
|
-
addUseEnvironmentOptions(yargs);
|
|
126
135
|
return yargs;
|
|
136
|
+
}
|
|
137
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(projectCreateBuilder, command, describe, {
|
|
138
|
+
useGlobalOptions: true,
|
|
139
|
+
useAccountOptions: true,
|
|
140
|
+
useConfigOptions: true,
|
|
141
|
+
useEnvironmentOptions: true,
|
|
142
|
+
});
|
|
143
|
+
const projectCreateCommand = {
|
|
144
|
+
command,
|
|
145
|
+
describe,
|
|
146
|
+
handler,
|
|
147
|
+
builder,
|
|
127
148
|
};
|
|
149
|
+
exports.default = projectCreateCommand;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs } from '../../types/Yargs';
|
|
3
|
-
export declare const command = "deploy";
|
|
4
|
-
export declare const describe: string;
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule } from '../../types/Yargs';
|
|
5
2
|
export type ProjectDeployArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
6
3
|
project?: string;
|
|
7
4
|
build?: number;
|
|
8
5
|
buildId?: number;
|
|
6
|
+
profile?: string;
|
|
9
7
|
};
|
|
10
|
-
|
|
11
|
-
export
|
|
8
|
+
declare const projectDeployCommand: YargsCommandModule<unknown, ProjectDeployArgs>;
|
|
9
|
+
export default projectDeployCommand;
|
|
@@ -3,8 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.builder = exports.describe = exports.command = void 0;
|
|
7
|
-
exports.handler = handler;
|
|
8
6
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
7
|
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
10
8
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
@@ -13,7 +11,7 @@ const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
|
13
11
|
const buildAndDeploy_1 = require("../../lib/projects/buildAndDeploy");
|
|
14
12
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
15
13
|
const index_2 = require("../../lib/errorHandlers/index");
|
|
16
|
-
const
|
|
14
|
+
const config_2 = require("../../lib/projects/config");
|
|
17
15
|
const buildAndDeploy_2 = require("../../lib/projects/buildAndDeploy");
|
|
18
16
|
const urls_1 = require("../../lib/projects/urls");
|
|
19
17
|
const projectNamePrompt_1 = require("../../lib/prompts/projectNamePrompt");
|
|
@@ -23,49 +21,68 @@ const ui_1 = require("../../lib/ui");
|
|
|
23
21
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
24
22
|
const ui_2 = require("../../lib/ui");
|
|
25
23
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const projectProfiles_1 = require("../../lib/projectProfiles");
|
|
25
|
+
const command = 'deploy';
|
|
26
|
+
const describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`commands.project.subcommands.deploy.describe`), false);
|
|
29
27
|
function validateBuildId(buildId, deployedBuildId, latestBuildId, projectName, accountId) {
|
|
30
28
|
if (Number(buildId) > latestBuildId) {
|
|
31
|
-
return (0, lang_1.i18n)(
|
|
29
|
+
return (0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.buildIdDoesNotExist`, {
|
|
32
30
|
buildId: buildId,
|
|
33
31
|
projectName: projectName,
|
|
34
|
-
linkToProject: (0, ui_1.uiLink)((0, lang_1.i18n)(
|
|
32
|
+
linkToProject: (0, ui_1.uiLink)((0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.viewProjectsBuilds`), (0, urls_1.getProjectDetailUrl)(projectName, accountId)),
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
if (Number(buildId) === deployedBuildId) {
|
|
38
|
-
return (0, lang_1.i18n)(
|
|
36
|
+
return (0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.buildAlreadyDeployed`, {
|
|
39
37
|
buildId: buildId,
|
|
40
|
-
linkToProject: (0, ui_1.uiLink)((0, lang_1.i18n)(
|
|
38
|
+
linkToProject: (0, ui_1.uiLink)((0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.viewProjectsBuilds`), (0, urls_1.getProjectDetailUrl)(projectName, accountId)),
|
|
41
39
|
});
|
|
42
40
|
}
|
|
43
41
|
return true;
|
|
44
42
|
}
|
|
45
43
|
async function handler(args) {
|
|
46
|
-
const { derivedAccountId } = args;
|
|
44
|
+
const { derivedAccountId, project: projectOption, buildId: buildIdOption, } = args;
|
|
47
45
|
const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
48
|
-
const { project: projectOption, buildId: buildIdOption } = args;
|
|
49
46
|
const accountType = accountConfig && accountConfig.accountType;
|
|
50
|
-
|
|
51
|
-
const { projectConfig } = await (0,
|
|
47
|
+
let targetAccountId;
|
|
48
|
+
const { projectConfig, projectDir } = await (0, config_2.getProjectConfig)();
|
|
49
|
+
if ((0, buildAndDeploy_1.useV3Api)(projectConfig?.platformVersion)) {
|
|
50
|
+
if (args.profile) {
|
|
51
|
+
(0, projectProfiles_1.logProfileHeader)(args.profile);
|
|
52
|
+
const profile = (0, projectProfiles_1.loadProfile)(projectConfig, projectDir, args.profile);
|
|
53
|
+
if (!profile) {
|
|
54
|
+
(0, ui_1.uiLine)();
|
|
55
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
56
|
+
}
|
|
57
|
+
targetAccountId = profile.accountId;
|
|
58
|
+
(0, projectProfiles_1.logProfileFooter)(profile);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// A profile must be specified if this project has profiles configured
|
|
62
|
+
await (0, projectProfiles_1.exitIfUsingProfiles)(projectConfig, projectDir);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!targetAccountId) {
|
|
66
|
+
targetAccountId = derivedAccountId;
|
|
67
|
+
}
|
|
68
|
+
(0, usageTracking_1.trackCommandUsage)('project-deploy', accountType ? { type: accountType } : undefined, targetAccountId);
|
|
52
69
|
let projectName = projectOption;
|
|
53
70
|
if (!projectOption && projectConfig) {
|
|
54
71
|
projectName = projectConfig.name;
|
|
55
72
|
}
|
|
56
|
-
const namePromptResponse = await (0, projectNamePrompt_1.projectNamePrompt)(
|
|
73
|
+
const namePromptResponse = await (0, projectNamePrompt_1.projectNamePrompt)(targetAccountId, {
|
|
57
74
|
project: projectName,
|
|
58
75
|
});
|
|
59
76
|
projectName = namePromptResponse.projectName;
|
|
60
77
|
let buildIdToDeploy = buildIdOption;
|
|
61
78
|
try {
|
|
62
|
-
const { data: { latestBuild, deployedBuildId }, } = await (0, projects_1.fetchProject)(
|
|
79
|
+
const { data: { latestBuild, deployedBuildId }, } = await (0, projects_1.fetchProject)(targetAccountId, projectName);
|
|
63
80
|
if (!latestBuild || !latestBuild.buildId) {
|
|
64
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
81
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.noBuilds`));
|
|
65
82
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
66
83
|
}
|
|
67
84
|
if (buildIdToDeploy) {
|
|
68
|
-
const validationResult = validateBuildId(buildIdToDeploy, deployedBuildId, latestBuild.buildId, projectName,
|
|
85
|
+
const validationResult = validateBuildId(buildIdToDeploy, deployedBuildId, latestBuild.buildId, projectName, targetAccountId);
|
|
69
86
|
if (validationResult !== true) {
|
|
70
87
|
logger_1.logger.error(validationResult);
|
|
71
88
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
@@ -74,30 +91,30 @@ async function handler(args) {
|
|
|
74
91
|
else {
|
|
75
92
|
const deployBuildIdPromptResponse = await (0, promptUtils_1.promptUser)({
|
|
76
93
|
name: 'buildId',
|
|
77
|
-
message: (0, lang_1.i18n)(
|
|
94
|
+
message: (0, lang_1.i18n)(`commands.project.subcommands.deploy.deployBuildIdPrompt`),
|
|
78
95
|
default: latestBuild.buildId === deployedBuildId
|
|
79
96
|
? undefined
|
|
80
97
|
: latestBuild.buildId,
|
|
81
|
-
validate: buildId => validateBuildId(buildId, deployedBuildId, latestBuild.buildId, projectName,
|
|
98
|
+
validate: buildId => validateBuildId(buildId, deployedBuildId, latestBuild.buildId, projectName, targetAccountId),
|
|
82
99
|
});
|
|
83
100
|
buildIdToDeploy = deployBuildIdPromptResponse.buildId;
|
|
84
101
|
}
|
|
85
102
|
if (!buildIdToDeploy) {
|
|
86
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
103
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.noBuildId`));
|
|
87
104
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
88
105
|
}
|
|
89
|
-
const { data: deployResp } = await (0, projects_1.deployProject)(
|
|
106
|
+
const { data: deployResp } = await (0, projects_1.deployProject)(targetAccountId, projectName, buildIdToDeploy, (0, buildAndDeploy_1.useV3Api)(projectConfig?.platformVersion));
|
|
90
107
|
if (!deployResp) {
|
|
91
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
108
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.deploy`));
|
|
92
109
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
93
110
|
}
|
|
94
|
-
await (0, buildAndDeploy_2.pollDeployStatus)(
|
|
111
|
+
await (0, buildAndDeploy_2.pollDeployStatus)(targetAccountId, projectName, Number(deployResp.id), buildIdToDeploy);
|
|
95
112
|
}
|
|
96
113
|
catch (e) {
|
|
97
114
|
if ((0, index_1.isHubSpotHttpError)(e) && e.status === 404) {
|
|
98
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
115
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.deploy.errors.projectNotFound`, {
|
|
99
116
|
projectName: chalk_1.default.bold(projectName),
|
|
100
|
-
accountIdentifier: (0, ui_2.uiAccountDescription)(
|
|
117
|
+
accountIdentifier: (0, ui_2.uiAccountDescription)(targetAccountId),
|
|
101
118
|
command: (0, ui_2.uiCommandReference)('hs project upload'),
|
|
102
119
|
}));
|
|
103
120
|
}
|
|
@@ -106,7 +123,7 @@ async function handler(args) {
|
|
|
106
123
|
}
|
|
107
124
|
else {
|
|
108
125
|
(0, index_2.logError)(e, new index_2.ApiErrorContext({
|
|
109
|
-
accountId:
|
|
126
|
+
accountId: targetAccountId,
|
|
110
127
|
request: 'project deploy',
|
|
111
128
|
}));
|
|
112
129
|
}
|
|
@@ -116,32 +133,45 @@ async function handler(args) {
|
|
|
116
133
|
function projectDeployBuilder(yargs) {
|
|
117
134
|
yargs.options({
|
|
118
135
|
project: {
|
|
119
|
-
describe: (0, lang_1.i18n)(
|
|
136
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.deploy.options.project.describe`),
|
|
120
137
|
type: 'string',
|
|
121
138
|
},
|
|
122
139
|
build: {
|
|
123
140
|
alias: ['build-id'],
|
|
124
|
-
describe: (0, lang_1.i18n)(
|
|
141
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.deploy.options.build.describe`),
|
|
125
142
|
type: 'number',
|
|
126
143
|
},
|
|
144
|
+
profile: {
|
|
145
|
+
alias: ['p'],
|
|
146
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.deploy.options.profile.describe`),
|
|
147
|
+
type: 'string',
|
|
148
|
+
hidden: true,
|
|
149
|
+
},
|
|
127
150
|
});
|
|
151
|
+
yargs.conflicts('profile', 'project');
|
|
152
|
+
yargs.conflicts('profile', 'account');
|
|
128
153
|
yargs.example([
|
|
129
|
-
[
|
|
154
|
+
[
|
|
155
|
+
'$0 project deploy',
|
|
156
|
+
(0, lang_1.i18n)(`commands.project.subcommands.deploy.examples.default`),
|
|
157
|
+
],
|
|
130
158
|
[
|
|
131
159
|
'$0 project deploy --project="my-project" --build=5',
|
|
132
|
-
(0, lang_1.i18n)(
|
|
160
|
+
(0, lang_1.i18n)(`commands.project.subcommands.deploy.examples.withOptions`),
|
|
133
161
|
],
|
|
134
162
|
]);
|
|
135
163
|
return yargs;
|
|
136
164
|
}
|
|
137
|
-
|
|
165
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(projectDeployBuilder, command, describe, {
|
|
166
|
+
useGlobalOptions: true,
|
|
138
167
|
useConfigOptions: true,
|
|
139
168
|
useAccountOptions: true,
|
|
140
169
|
useEnvironmentOptions: true,
|
|
141
170
|
});
|
|
142
|
-
|
|
143
|
-
command
|
|
144
|
-
describe
|
|
145
|
-
builder
|
|
171
|
+
const projectDeployCommand = {
|
|
172
|
+
command,
|
|
173
|
+
describe,
|
|
174
|
+
builder,
|
|
146
175
|
handler,
|
|
147
176
|
};
|
|
177
|
+
exports.default = projectDeployCommand;
|
|
@@ -13,12 +13,11 @@ const lang_1 = require("../../../lib/lang");
|
|
|
13
13
|
const exitCodes_1 = require("../../../lib/enums/exitCodes");
|
|
14
14
|
const ui_1 = require("../../../lib/ui");
|
|
15
15
|
const SpinniesManager_1 = __importDefault(require("../../../lib/ui/SpinniesManager"));
|
|
16
|
-
const LocalDevManager_1 = __importDefault(require("../../../lib/LocalDevManager"));
|
|
17
|
-
const
|
|
16
|
+
const LocalDevManager_1 = __importDefault(require("../../../lib/projects/localDev/LocalDevManager"));
|
|
17
|
+
const helpers_1 = require("../../../lib/projects/localDev/helpers");
|
|
18
18
|
const process_1 = require("../../../lib/process");
|
|
19
19
|
const accountTypes_1 = require("../../../lib/accountTypes");
|
|
20
|
-
const
|
|
21
|
-
const i18nKey = 'commands.project.subcommands.dev';
|
|
20
|
+
const ensureProjectExists_1 = require("../../../lib/projects/ensureProjectExists");
|
|
22
21
|
async function deprecatedProjectDevFlow(args, accountConfig, projectConfig, projectDir) {
|
|
23
22
|
const { providedAccountId, derivedAccountId } = args;
|
|
24
23
|
const env = (0, environment_1.getValidEnv)((0, config_1.getEnv)(derivedAccountId));
|
|
@@ -28,25 +27,34 @@ async function deprecatedProjectDevFlow(args, accountConfig, projectConfig, proj
|
|
|
28
27
|
const hasPrivateApps = !!componentTypes[Projects_1.ComponentTypes.PrivateApp];
|
|
29
28
|
const hasPublicApps = !!componentTypes[Projects_1.ComponentTypes.PublicApp];
|
|
30
29
|
if (runnableComponents.length === 0) {
|
|
31
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
30
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.noRunnableComponents`, {
|
|
32
31
|
projectDir,
|
|
33
32
|
command: (0, ui_1.uiCommandReference)('hs project add'),
|
|
34
33
|
}));
|
|
35
34
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
36
35
|
}
|
|
37
36
|
else if (hasPrivateApps && hasPublicApps) {
|
|
38
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
37
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.invalidProjectComponents`));
|
|
39
38
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
40
39
|
}
|
|
41
40
|
const accounts = (0, config_1.getConfigAccounts)();
|
|
42
41
|
if (!accounts) {
|
|
43
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
42
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.noAccountsInConfig`, {
|
|
44
43
|
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
45
44
|
}));
|
|
46
45
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
let bypassRecommendedAccountPrompt = false;
|
|
48
|
+
if ((0, accountTypes_1.isDeveloperTestAccount)(accountConfig)) {
|
|
49
|
+
bypassRecommendedAccountPrompt = true;
|
|
50
|
+
}
|
|
51
|
+
else if (!hasPublicApps && (0, accountTypes_1.isSandbox)(accountConfig)) {
|
|
52
|
+
bypassRecommendedAccountPrompt = true;
|
|
53
|
+
}
|
|
54
|
+
else if (!hasPublicApps) {
|
|
55
|
+
const defaultAccountHasSandboxes = await (0, helpers_1.hasSandboxes)(accountConfig);
|
|
56
|
+
bypassRecommendedAccountPrompt = !defaultAccountHasSandboxes;
|
|
57
|
+
}
|
|
50
58
|
// targetProjectAccountId and targetTestingAccountId are set to null if --account flag is not provided.
|
|
51
59
|
// By setting them to null, we can later check if they need to be assigned based on the default account configuration and the type of app.
|
|
52
60
|
let targetProjectAccountId = providedAccountId ? derivedAccountId : null;
|
|
@@ -54,20 +62,20 @@ async function deprecatedProjectDevFlow(args, accountConfig, projectConfig, proj
|
|
|
54
62
|
let targetTestingAccountId = providedAccountId ? derivedAccountId : null;
|
|
55
63
|
// Check that the default account or flag option is valid for the type of app in this project
|
|
56
64
|
if (providedAccountId) {
|
|
57
|
-
(0,
|
|
65
|
+
(0, helpers_1.checkIfAccountFlagIsSupported)(accountConfig, hasPublicApps);
|
|
58
66
|
if (hasPublicApps) {
|
|
59
67
|
targetProjectAccountId = accountConfig.parentAccountId || null;
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
else {
|
|
63
|
-
(0,
|
|
71
|
+
await (0, helpers_1.checkIfDefaultAccountIsSupported)(accountConfig, hasPublicApps);
|
|
64
72
|
}
|
|
65
73
|
// The user is targeting an account type that we recommend developing on
|
|
66
|
-
if (!targetProjectAccountId &&
|
|
74
|
+
if (!targetProjectAccountId && bypassRecommendedAccountPrompt) {
|
|
67
75
|
targetTestingAccountId = derivedAccountId;
|
|
68
|
-
await (0,
|
|
76
|
+
await (0, helpers_1.confirmDefaultAccountIsTarget)(accountConfig);
|
|
69
77
|
if (hasPublicApps) {
|
|
70
|
-
(0,
|
|
78
|
+
(0, helpers_1.checkIfParentAccountIsAuthed)(accountConfig);
|
|
71
79
|
targetProjectAccountId = accountConfig.parentAccountId || null;
|
|
72
80
|
}
|
|
73
81
|
else {
|
|
@@ -77,34 +85,33 @@ async function deprecatedProjectDevFlow(args, accountConfig, projectConfig, proj
|
|
|
77
85
|
let createNewSandbox = false;
|
|
78
86
|
let createNewDeveloperTestAccount = false;
|
|
79
87
|
if (!targetProjectAccountId) {
|
|
80
|
-
const { targetAccountId, parentAccountId, createNestedAccount, notInConfigAccount, } = await (0,
|
|
88
|
+
const { targetAccountId, parentAccountId, createNestedAccount, notInConfigAccount, } = await (0, helpers_1.suggestRecommendedNestedAccount)(accounts, accountConfig, hasPublicApps);
|
|
81
89
|
targetProjectAccountId = hasPublicApps
|
|
82
90
|
? parentAccountId || null
|
|
83
91
|
: targetAccountId;
|
|
84
92
|
targetTestingAccountId = targetAccountId;
|
|
85
93
|
// Only used for developer test accounts that are not yet in the config
|
|
86
94
|
if (notInConfigAccount) {
|
|
87
|
-
await (0,
|
|
95
|
+
await (0, helpers_1.useExistingDevTestAccount)(env, notInConfigAccount);
|
|
88
96
|
}
|
|
89
|
-
createNewSandbox =
|
|
90
|
-
createNewDeveloperTestAccount =
|
|
91
|
-
(0, accountTypes_1.isAppDeveloperAccount)(accountConfig) && createNestedAccount;
|
|
97
|
+
createNewSandbox = hasPrivateApps && createNestedAccount;
|
|
98
|
+
createNewDeveloperTestAccount = hasPublicApps && createNestedAccount;
|
|
92
99
|
}
|
|
93
100
|
if (createNewSandbox) {
|
|
94
|
-
targetProjectAccountId = await (0,
|
|
101
|
+
targetProjectAccountId = await (0, helpers_1.createSandboxForLocalDev)(derivedAccountId, accountConfig, env);
|
|
95
102
|
// We will be running our tests against this new sandbox account
|
|
96
103
|
targetTestingAccountId = targetProjectAccountId;
|
|
97
104
|
}
|
|
98
105
|
if (createNewDeveloperTestAccount) {
|
|
99
|
-
targetTestingAccountId = await (0,
|
|
106
|
+
targetTestingAccountId = await (0, helpers_1.createDeveloperTestAccountForLocalDev)(derivedAccountId, accountConfig, env);
|
|
100
107
|
targetProjectAccountId = derivedAccountId;
|
|
101
108
|
}
|
|
102
109
|
if (!targetProjectAccountId || !targetTestingAccountId) {
|
|
103
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
110
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.noAccount`));
|
|
104
111
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
105
112
|
}
|
|
106
113
|
// eslint-disable-next-line prefer-const
|
|
107
|
-
let { projectExists, project } = await (0,
|
|
114
|
+
let { projectExists, project } = await (0, ensureProjectExists_1.ensureProjectExists)(targetProjectAccountId, projectConfig.name, {
|
|
108
115
|
allowCreate: false,
|
|
109
116
|
noLogs: true,
|
|
110
117
|
withPolling: createNewSandbox,
|
|
@@ -117,8 +124,8 @@ async function deprecatedProjectDevFlow(args, accountConfig, projectConfig, proj
|
|
|
117
124
|
isGithubLinked = Boolean(project.sourceIntegration && project.sourceIntegration.source === 'GITHUB');
|
|
118
125
|
}
|
|
119
126
|
else {
|
|
120
|
-
project = await (0,
|
|
121
|
-
deployedBuild = await (0,
|
|
127
|
+
project = await (0, helpers_1.createNewProjectForLocalDev)(projectConfig, targetProjectAccountId, createNewSandbox, hasPublicApps);
|
|
128
|
+
deployedBuild = await (0, helpers_1.createInitialBuildForNewProject)(projectConfig, projectDir, targetProjectAccountId);
|
|
122
129
|
}
|
|
123
130
|
const LocalDev = new LocalDevManager_1.default({
|
|
124
131
|
runnableComponents,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Argv, CommandModule } from 'yargs';
|
|
2
2
|
import { ProjectDevArgs } from '../../../types/Yargs';
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export declare function builder(yargs: Argv): Argv<ProjectDevArgs>;
|
|
3
|
+
export declare const builder: (yargs: Argv) => Promise<Argv<ProjectDevArgs>>;
|
|
4
|
+
declare const projectDevCommand: CommandModule<unknown, ProjectDevArgs>;
|
|
5
|
+
export default projectDevCommand;
|