@hubspot/cli 6.2.0 → 6.2.2-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/README.md +12 -95
- package/bin/cli.d.ts +2 -0
- package/bin/cli.js +107 -128
- package/commands/accounts/clean.d.ts +1 -0
- package/commands/accounts/clean.js +82 -116
- package/commands/accounts/info.d.ts +1 -0
- package/commands/accounts/info.js +32 -43
- package/commands/accounts/list.d.ts +1 -0
- package/commands/accounts/list.js +65 -92
- package/commands/accounts/remove.d.ts +1 -0
- package/commands/accounts/remove.js +43 -73
- package/commands/accounts/rename.d.ts +1 -0
- package/commands/accounts/rename.js +26 -41
- package/commands/accounts/use.d.ts +1 -0
- package/commands/accounts/use.js +36 -57
- package/commands/accounts.d.ts +1 -0
- package/commands/accounts.js +16 -18
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +133 -200
- package/commands/cms/convertFields.d.ts +1 -0
- package/commands/cms/convertFields.js +66 -81
- package/commands/cms/lighthouseScore.d.ts +1 -0
- package/commands/cms/lighthouseScore.js +236 -298
- package/commands/cms/reactModules.d.ts +1 -0
- package/commands/cms/reactModules.js +46 -53
- package/commands/cms.d.ts +1 -0
- package/commands/cms.js +11 -13
- package/commands/config/set.d.ts +1 -0
- package/commands/config/set.js +64 -79
- package/commands/config.d.ts +1 -0
- package/commands/config.js +7 -9
- package/commands/create/api-sample.d.ts +1 -0
- package/commands/create/api-sample.js +54 -74
- package/commands/create/app.d.ts +1 -0
- package/commands/create/app.js +8 -7
- package/commands/create/function.d.ts +1 -0
- package/commands/create/function.js +15 -14
- package/commands/create/index.d.ts +1 -0
- package/commands/create/index.js +12 -9
- package/commands/create/module.d.ts +1 -0
- package/commands/create/module.js +21 -19
- package/commands/create/react-app.d.ts +1 -0
- package/commands/create/react-app.js +7 -6
- package/commands/create/template.d.ts +1 -0
- package/commands/create/template.js +23 -24
- package/commands/create/vue-app.d.ts +1 -0
- package/commands/create/vue-app.js +7 -6
- package/commands/create/webpack-serverless.d.ts +1 -0
- package/commands/create/webpack-serverless.js +7 -6
- package/commands/create/website-theme.d.ts +1 -0
- package/commands/create/website-theme.js +15 -15
- package/commands/create.d.ts +24 -0
- package/commands/create.js +65 -80
- package/commands/customObject/create.d.ts +1 -0
- package/commands/customObject/create.js +33 -47
- package/commands/customObject/schema/create.d.ts +1 -0
- package/commands/customObject/schema/create.js +42 -67
- package/commands/customObject/schema/delete.d.ts +1 -0
- package/commands/customObject/schema/delete.js +28 -39
- package/commands/customObject/schema/fetch-all.d.ts +1 -0
- package/commands/customObject/schema/fetch-all.js +30 -39
- package/commands/customObject/schema/fetch.d.ts +1 -0
- package/commands/customObject/schema/fetch.js +48 -63
- package/commands/customObject/schema/list.d.ts +1 -0
- package/commands/customObject/schema/list.js +14 -17
- package/commands/customObject/schema/update.d.ts +1 -0
- package/commands/customObject/schema/update.js +46 -72
- package/commands/customObject/schema.d.ts +1 -0
- package/commands/customObject/schema.js +12 -12
- package/commands/customObject.d.ts +1 -0
- package/commands/customObject.js +14 -22
- package/commands/feedback.d.ts +1 -0
- package/commands/feedback.js +25 -33
- package/commands/fetch.d.ts +1 -0
- package/commands/fetch.js +53 -78
- package/commands/filemanager/fetch.d.ts +1 -0
- package/commands/filemanager/fetch.js +38 -56
- package/commands/filemanager/upload.d.ts +1 -0
- package/commands/filemanager/upload.js +88 -128
- package/commands/filemanager.d.ts +1 -0
- package/commands/filemanager.js +12 -18
- package/commands/functions/deploy.d.ts +1 -0
- package/commands/functions/deploy.js +76 -99
- package/commands/functions/list.d.ts +1 -0
- package/commands/functions/list.js +41 -48
- package/commands/functions/server.d.ts +1 -0
- package/commands/functions/server.js +50 -65
- package/commands/functions.d.ts +1 -0
- package/commands/functions.js +13 -15
- package/commands/hubdb/clear.d.ts +1 -0
- package/commands/hubdb/clear.js +37 -56
- package/commands/hubdb/create.d.ts +1 -0
- package/commands/hubdb/create.js +34 -57
- package/commands/hubdb/delete.d.ts +1 -0
- package/commands/hubdb/delete.js +29 -44
- package/commands/hubdb/fetch.d.ts +1 -0
- package/commands/hubdb/fetch.js +30 -46
- package/commands/hubdb.d.ts +1 -0
- package/commands/hubdb.js +12 -14
- package/commands/init.d.ts +1 -0
- package/commands/init.js +103 -160
- package/commands/lint.d.ts +1 -0
- package/commands/lint.js +34 -45
- package/commands/list.d.ts +1 -0
- package/commands/list.js +74 -101
- package/commands/logs.d.ts +1 -0
- package/commands/logs.js +98 -121
- package/commands/module/marketplace-validate.d.ts +1 -0
- package/commands/module/marketplace-validate.js +32 -57
- package/commands/module.d.ts +1 -0
- package/commands/module.js +7 -9
- package/commands/mv.d.ts +1 -0
- package/commands/mv.js +53 -71
- package/commands/open.d.ts +1 -0
- package/commands/open.js +48 -62
- package/commands/project/add.d.ts +1 -0
- package/commands/project/add.js +47 -70
- package/commands/project/cloneApp.d.ts +1 -0
- package/commands/project/cloneApp.js +119 -180
- package/commands/project/create.d.ts +1 -0
- package/commands/project/create.js +49 -81
- package/commands/project/deploy.d.ts +1 -0
- package/commands/project/deploy.js +105 -182
- package/commands/project/dev.d.ts +1 -0
- package/commands/project/dev.js +126 -227
- package/commands/project/download.d.ts +1 -0
- package/commands/project/download.js +73 -123
- package/commands/project/installDeps.d.ts +1 -0
- package/commands/project/installDeps.js +52 -59
- package/commands/project/listBuilds.d.ts +1 -0
- package/commands/project/listBuilds.js +97 -139
- package/commands/project/logs.d.ts +1 -0
- package/commands/project/logs.js +86 -128
- package/commands/project/migrateApp.d.ts +1 -0
- package/commands/project/migrateApp.js +158 -248
- package/commands/project/open.d.ts +1 -0
- package/commands/project/open.js +44 -68
- package/commands/project/upload.d.ts +1 -0
- package/commands/project/upload.js +72 -116
- package/commands/project/watch.d.ts +1 -0
- package/commands/project/watch.js +94 -152
- package/commands/project.d.ts +1 -0
- package/commands/project.js +21 -23
- package/commands/remove.d.ts +1 -0
- package/commands/remove.js +28 -43
- package/commands/sandbox/create.d.ts +1 -0
- package/commands/sandbox/create.js +143 -187
- package/commands/sandbox/delete.d.ts +1 -0
- package/commands/sandbox/delete.js +166 -221
- package/commands/sandbox.d.ts +1 -0
- package/commands/sandbox.js +10 -12
- package/commands/secrets/addSecret.d.ts +1 -0
- package/commands/secrets/addSecret.js +34 -52
- package/commands/secrets/deleteSecret.d.ts +1 -0
- package/commands/secrets/deleteSecret.js +33 -50
- package/commands/secrets/listSecrets.d.ts +1 -0
- package/commands/secrets/listSecrets.js +28 -42
- package/commands/secrets/updateSecret.d.ts +1 -0
- package/commands/secrets/updateSecret.js +35 -53
- package/commands/secrets.d.ts +1 -0
- package/commands/secrets.js +12 -13
- package/commands/theme/generate-selectors.d.ts +1 -0
- package/commands/theme/generate-selectors.js +129 -192
- package/commands/theme/marketplace-validate.d.ts +1 -0
- package/commands/theme/marketplace-validate.js +32 -57
- package/commands/theme/preview.d.ts +1 -0
- package/commands/theme/preview.js +170 -195
- package/commands/theme.d.ts +1 -0
- package/commands/theme.js +9 -11
- package/commands/upload.d.ts +1 -0
- package/commands/upload.js +199 -287
- package/commands/watch.d.ts +1 -0
- package/commands/watch.js +128 -172
- package/lang/en.lyaml +2 -3
- package/lib/DevServerManager.d.ts +1 -0
- package/lib/DevServerManager.js +99 -124
- package/lib/LocalDevManager.d.ts +1 -0
- package/lib/LocalDevManager.js +322 -490
- package/lib/accountTypes.d.ts +7 -0
- package/lib/accountTypes.js +32 -34
- package/lib/buildAccount.d.ts +1 -0
- package/lib/buildAccount.js +132 -179
- package/lib/commonOpts.d.ts +1 -0
- package/lib/commonOpts.js +60 -91
- package/lib/configOptions.d.ts +1 -0
- package/lib/configOptions.js +110 -0
- package/lib/constants.d.ts +84 -0
- package/lib/constants.js +64 -91
- package/lib/debugInfo.d.ts +1 -0
- package/lib/debugInfo.js +14 -13
- package/lib/dependencyManagement.d.ts +1 -0
- package/lib/dependencyManagement.js +92 -132
- package/lib/developerTestAccounts.d.ts +1 -0
- package/lib/developerTestAccounts.js +67 -91
- package/lib/enums/exitCodes.d.ts +5 -0
- package/lib/enums/exitCodes.js +7 -8
- package/lib/environment.d.ts +1 -0
- package/lib/environment.js +13 -14
- package/lib/errorHandlers/index.d.ts +1 -0
- package/lib/errorHandlers/index.js +66 -80
- package/lib/errorHandlers/suppressError.d.ts +1 -0
- package/lib/errorHandlers/suppressError.js +66 -106
- package/lib/filesystem.d.ts +2 -0
- package/lib/filesystem.js +22 -28
- package/lib/generate-selectors.d.ts +1 -0
- package/lib/generate-selectors.js +102 -138
- package/lib/hasFeature.d.ts +1 -0
- package/lib/hasFeature.js +8 -15
- package/lib/hasFlag.d.ts +1 -0
- package/lib/hasFlag.js +13 -13
- package/lib/hublValidate.d.ts +2 -0
- package/lib/hublValidate.js +28 -28
- package/lib/interpolation.d.ts +1 -0
- package/lib/interpolation.js +50 -92
- package/lib/interpolationHelpers.d.ts +10 -0
- package/lib/interpolationHelpers.js +30 -22
- package/lib/lang.d.ts +1 -0
- package/lib/lang.js +52 -78
- package/lib/links.d.ts +1 -0
- package/lib/links.js +94 -114
- package/lib/localDev.d.ts +1 -0
- package/lib/localDev.js +285 -433
- package/lib/marketplace-validate.d.ts +1 -0
- package/lib/marketplace-validate.js +105 -126
- package/lib/oauth.d.ts +1 -0
- package/lib/oauth.js +64 -78
- package/lib/polling.d.ts +1 -0
- package/lib/polling.js +26 -26
- package/lib/process.d.ts +1 -0
- package/lib/process.js +41 -53
- package/lib/projectLogsManager.d.ts +1 -0
- package/lib/projectLogsManager.js +78 -130
- package/lib/projectStructure.d.ts +1 -0
- package/lib/projectStructure.js +89 -109
- package/lib/projects.d.ts +1 -0
- package/lib/projects.js +595 -958
- package/lib/projectsWatch.d.ts +1 -0
- package/lib/projectsWatch.js +127 -228
- package/lib/prompts/accountNamePrompt.d.ts +1 -0
- package/lib/prompts/accountNamePrompt.js +60 -65
- package/lib/prompts/accountsPrompt.d.ts +1 -0
- package/lib/prompts/accountsPrompt.js +33 -37
- package/lib/prompts/activeInstallConfirmationPrompt.d.ts +1 -0
- package/lib/prompts/activeInstallConfirmationPrompt.js +13 -13
- package/lib/prompts/cleanUploadPrompt.d.ts +1 -0
- package/lib/prompts/cleanUploadPrompt.js +13 -13
- package/lib/prompts/cmsFieldPrompt.d.ts +1 -0
- package/lib/prompts/cmsFieldPrompt.js +37 -39
- package/lib/prompts/createApiSamplePrompt.d.ts +1 -0
- package/lib/prompts/createApiSamplePrompt.js +49 -52
- package/lib/prompts/createFunctionPrompt.d.ts +1 -0
- package/lib/prompts/createFunctionPrompt.js +57 -56
- package/lib/prompts/createModulePrompt.d.ts +1 -0
- package/lib/prompts/createModulePrompt.js +47 -50
- package/lib/prompts/createProjectPrompt.d.ts +1 -0
- package/lib/prompts/createProjectPrompt.js +95 -129
- package/lib/prompts/createTemplatePrompt.d.ts +1 -0
- package/lib/prompts/createTemplatePrompt.js +18 -19
- package/lib/prompts/deployBuildIdPrompt.d.ts +1 -0
- package/lib/prompts/deployBuildIdPrompt.js +15 -15
- package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
- package/lib/prompts/downloadProjectPrompt.js +39 -41
- package/lib/prompts/feedbackPrompt.d.ts +1 -0
- package/lib/prompts/feedbackPrompt.js +29 -30
- package/lib/prompts/folderOverwritePrompt.d.ts +1 -0
- package/lib/prompts/folderOverwritePrompt.js +10 -10
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -0
- package/lib/prompts/installPublicAppPrompt.js +29 -42
- package/lib/prompts/personalAccessKeyPrompt.d.ts +1 -0
- package/lib/prompts/personalAccessKeyPrompt.js +104 -110
- package/lib/prompts/previewPrompt.d.ts +1 -0
- package/lib/prompts/previewPrompt.js +46 -47
- package/lib/prompts/projectAddPrompt.d.ts +1 -0
- package/lib/prompts/projectAddPrompt.js +37 -38
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +1 -0
- package/lib/prompts/projectDevTargetAccountPrompt.js +150 -193
- package/lib/prompts/projectNamePrompt.d.ts +1 -0
- package/lib/prompts/projectNamePrompt.js +25 -25
- package/lib/prompts/projectsLogsPrompt.d.ts +1 -0
- package/lib/prompts/projectsLogsPrompt.js +21 -27
- package/lib/prompts/promptUtils.d.ts +1 -0
- package/lib/prompts/promptUtils.js +17 -17
- package/lib/prompts/sandboxesPrompt.d.ts +1 -0
- package/lib/prompts/sandboxesPrompt.js +50 -59
- package/lib/prompts/secretPrompt.d.ts +1 -0
- package/lib/prompts/secretPrompt.js +15 -16
- package/lib/prompts/selectPublicAppPrompt.d.ts +1 -0
- package/lib/prompts/selectPublicAppPrompt.js +58 -82
- package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -0
- package/lib/prompts/setAsDefaultAccountPrompt.js +19 -24
- package/lib/prompts/uploadPrompt.d.ts +1 -0
- package/lib/prompts/uploadPrompt.js +30 -30
- package/lib/regex.d.ts +1 -0
- package/lib/regex.js +4 -5
- package/lib/sandboxSync.d.ts +1 -0
- package/lib/sandboxSync.js +100 -166
- package/lib/sandboxes.d.ts +1 -0
- package/lib/sandboxes.js +201 -316
- package/lib/schema.d.ts +3 -0
- package/lib/schema.js +29 -33
- package/lib/serverlessLogs.d.ts +1 -0
- package/lib/serverlessLogs.js +131 -173
- package/lib/ui/SpinniesManager.d.ts +1 -0
- package/lib/ui/SpinniesManager.js +198 -254
- package/lib/ui/git.d.ts +1 -0
- package/lib/ui/git.js +20 -19
- package/lib/ui/index.d.ts +1 -0
- package/lib/ui/index.js +117 -167
- package/lib/ui/serverlessFunctionLogs.d.ts +1 -0
- package/lib/ui/serverlessFunctionLogs.js +53 -70
- package/lib/ui/spinniesUtils.d.ts +1 -0
- package/lib/ui/spinniesUtils.js +111 -133
- package/lib/ui/supportHyperlinks.d.ts +1 -0
- package/lib/ui/supportHyperlinks.js +49 -62
- package/lib/ui/supportsColor.d.ts +1 -0
- package/lib/ui/supportsColor.js +81 -109
- package/lib/ui/table.d.ts +1 -0
- package/lib/ui/table.js +49 -55
- package/lib/upload.d.ts +1 -0
- package/lib/upload.js +40 -43
- package/lib/usageTracking.d.ts +1 -0
- package/lib/usageTracking.js +133 -155
- package/lib/validation.d.ts +1 -0
- package/lib/validation.js +144 -203
- package/package.json +84 -48
- package/CHANGELOG.md +0 -16
- package/commands/__tests__/projects.test.js +0 -105
- package/commands/config/set/allowUsageTracking.js +0 -52
- package/commands/config/set/defaultMode.js +0 -59
- package/commands/config/set/httpTimeout.js +0 -42
- package/commands/project/__tests__/deploy.test.js +0 -443
- package/commands/project/__tests__/installDeps.test.js +0 -168
- package/commands/project/__tests__/logs.test.js +0 -304
- package/hubspot.sample.config.yml +0 -28
- package/jest.config.js +0 -4
- package/lib/__tests__/commonOpts.test.js +0 -83
- package/lib/__tests__/dependencyManagement.test.js +0 -243
- package/lib/__tests__/downloadProjectPrompt.test.js +0 -31
- package/lib/__tests__/projectLogsManager.test.js +0 -212
- package/lib/__tests__/projects.test.js +0 -140
- package/lib/__tests__/serverlessLogs.test.js +0 -162
- package/lib/__tests__/validation.test.js +0 -140
- package/lib/getFunctionArrays.js +0 -18
- package/lib/prompts/__tests__/projectsLogsPrompt.test.js +0 -46
package/lib/localDev.js
CHANGED
|
@@ -1,485 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// @ts-nocheck
|
|
1
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
|
|
4
|
-
HUBSPOT_ACCOUNT_TYPE_STRINGS,
|
|
5
|
-
} = require('@hubspot/local-dev-lib/constants/config');
|
|
6
|
-
const {
|
|
7
|
-
isMissingScopeError,
|
|
8
|
-
isSpecifiedError,
|
|
9
|
-
} = require('@hubspot/local-dev-lib/errors/index');
|
|
5
|
+
const { HUBSPOT_ACCOUNT_TYPES, HUBSPOT_ACCOUNT_TYPE_STRINGS, } = require('@hubspot/local-dev-lib/constants/config');
|
|
6
|
+
const { isMissingScopeError, isSpecifiedError, } = require('@hubspot/local-dev-lib/errors/index');
|
|
10
7
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
11
8
|
const { getAccountConfig, getEnv } = require('@hubspot/local-dev-lib/config');
|
|
12
9
|
const { createProject } = require('@hubspot/local-dev-lib/api/projects');
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
} = require('@hubspot/local-dev-lib/constants/environments');
|
|
16
|
-
const {
|
|
17
|
-
confirmDefaultAccountPrompt,
|
|
18
|
-
selectSandboxTargetAccountPrompt,
|
|
19
|
-
selectDeveloperTestTargetAccountPrompt,
|
|
20
|
-
confirmUseExistingDeveloperTestAccountPrompt,
|
|
21
|
-
} = require('./prompts/projectDevTargetAccountPrompt');
|
|
10
|
+
const { ENVIRONMENTS, } = require('@hubspot/local-dev-lib/constants/environments');
|
|
11
|
+
const { confirmDefaultAccountPrompt, selectSandboxTargetAccountPrompt, selectDeveloperTestTargetAccountPrompt, confirmUseExistingDeveloperTestAccountPrompt, } = require('./prompts/projectDevTargetAccountPrompt');
|
|
22
12
|
const { confirmPrompt } = require('./prompts/promptUtils');
|
|
23
|
-
const {
|
|
24
|
-
validateSandboxUsageLimits,
|
|
25
|
-
getAvailableSyncTypes,
|
|
26
|
-
} = require('./sandboxes');
|
|
13
|
+
const { validateSandboxUsageLimits, getAvailableSyncTypes, } = require('./sandboxes');
|
|
27
14
|
const { syncSandbox } = require('./sandboxSync');
|
|
28
|
-
const {
|
|
29
|
-
validateDevTestAccountUsageLimits,
|
|
30
|
-
} = require('./developerTestAccounts');
|
|
15
|
+
const { validateDevTestAccountUsageLimits, } = require('./developerTestAccounts');
|
|
31
16
|
const { uiCommandReference, uiLine, uiAccountDescription } = require('./ui');
|
|
32
17
|
const SpinniesManager = require('./ui/SpinniesManager');
|
|
33
18
|
const { i18n } = require('./lang');
|
|
34
19
|
const { EXIT_CODES } = require('./enums/exitCodes');
|
|
35
20
|
const { trackCommandMetadataUsage } = require('./usageTracking');
|
|
36
|
-
const {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} = require('./accountTypes');
|
|
40
|
-
const {
|
|
41
|
-
handleProjectUpload,
|
|
42
|
-
pollProjectBuildAndDeploy,
|
|
43
|
-
} = require('./projects');
|
|
44
|
-
const {
|
|
45
|
-
PROJECT_ERROR_TYPES,
|
|
46
|
-
PROJECT_BUILD_TEXT,
|
|
47
|
-
PROJECT_DEPLOY_TEXT,
|
|
48
|
-
} = require('./constants');
|
|
21
|
+
const { isAppDeveloperAccount, isDeveloperTestAccount, } = require('./accountTypes');
|
|
22
|
+
const { handleProjectUpload, pollProjectBuildAndDeploy, } = require('./projects');
|
|
23
|
+
const { PROJECT_ERROR_TYPES, PROJECT_BUILD_TEXT, PROJECT_DEPLOY_TEXT, } = require('./constants');
|
|
49
24
|
const { logError, ApiErrorContext } = require('./errorHandlers/index');
|
|
50
|
-
const {
|
|
51
|
-
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
52
|
-
} = require('@hubspot/local-dev-lib/constants/auth');
|
|
25
|
+
const { PERSONAL_ACCESS_KEY_AUTH_METHOD, } = require('@hubspot/local-dev-lib/constants/auth');
|
|
53
26
|
const { buildNewAccount, saveAccountToConfig } = require('./buildAccount');
|
|
54
27
|
const { hubspotAccountNamePrompt } = require('./prompts/accountNamePrompt');
|
|
55
|
-
|
|
56
28
|
const i18nKey = 'lib.localDev';
|
|
57
|
-
|
|
58
29
|
// If the user passed in the --account flag, confirm they want to use that account as
|
|
59
30
|
// their target account, otherwise exit
|
|
60
|
-
const confirmDefaultAccountIsTarget = async accountConfig => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
`${i18nKey}.confirmDefaultAccountIsTarget.declineDefaultAccountExplanation`,
|
|
71
|
-
{
|
|
72
|
-
useCommand: uiCommandReference('hs accounts use'),
|
|
73
|
-
devCommand: uiCommandReference('hs project dev'),
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
);
|
|
77
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
78
|
-
}
|
|
31
|
+
const confirmDefaultAccountIsTarget = async (accountConfig) => {
|
|
32
|
+
logger.log();
|
|
33
|
+
const useDefaultAccount = await confirmDefaultAccountPrompt(accountConfig.name, HUBSPOT_ACCOUNT_TYPE_STRINGS[accountConfig.accountType]);
|
|
34
|
+
if (!useDefaultAccount) {
|
|
35
|
+
logger.log(i18n(`${i18nKey}.confirmDefaultAccountIsTarget.declineDefaultAccountExplanation`, {
|
|
36
|
+
useCommand: uiCommandReference('hs accounts use'),
|
|
37
|
+
devCommand: uiCommandReference('hs project dev'),
|
|
38
|
+
}));
|
|
39
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
40
|
+
}
|
|
79
41
|
};
|
|
80
|
-
|
|
81
42
|
// Confirm the default account is supported for the type of apps being developed
|
|
82
43
|
const checkIfDefaultAccountIsSupported = (accountConfig, hasPublicApps) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
44
|
+
if (hasPublicApps &&
|
|
45
|
+
!(isAppDeveloperAccount(accountConfig) ||
|
|
46
|
+
isDeveloperTestAccount(accountConfig))) {
|
|
47
|
+
logger.error(i18n(`${i18nKey}.checkIfDefaultAccountIsSupported.publicApp`, {
|
|
48
|
+
useCommand: uiCommandReference('hs accounts use'),
|
|
49
|
+
authCommand: uiCommandReference('hs auth'),
|
|
50
|
+
}));
|
|
51
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
52
|
+
}
|
|
53
|
+
else if (!hasPublicApps && isAppDeveloperAccount(accountConfig)) {
|
|
54
|
+
logger.error(i18n(`${i18nKey}.checkIfDefaultAccountIsSupported.privateApp`, {
|
|
55
|
+
useCommand: uiCommandReference('hs accounts use'),
|
|
56
|
+
authCommand: uiCommandReference('hs auth'),
|
|
57
|
+
}));
|
|
58
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
59
|
+
}
|
|
100
60
|
};
|
|
101
|
-
|
|
102
61
|
const checkIfParentAccountIsAuthed = accountConfig => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
);
|
|
113
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
114
|
-
}
|
|
62
|
+
if (!getAccountConfig(accountConfig.parentAccountId)) {
|
|
63
|
+
logger.error(i18n(`${i18nKey}.checkIfParentAccountIsAuthed.notAuthedError`, {
|
|
64
|
+
accountId: accountConfig.parentAccountId,
|
|
65
|
+
accountIdentifier: uiAccountDescription(accountConfig.portalId),
|
|
66
|
+
authCommand: uiCommandReference(`hs auth --account=${accountConfig.parentAccountId}`),
|
|
67
|
+
}));
|
|
68
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
69
|
+
}
|
|
115
70
|
};
|
|
116
|
-
|
|
117
71
|
// Confirm the default account is a developer account if developing public apps
|
|
118
72
|
const checkIfAccountFlagIsSupported = (accountConfig, hasPublicApps) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
73
|
+
if (hasPublicApps) {
|
|
74
|
+
if (!isDeveloperTestAccount) {
|
|
75
|
+
logger.error(i18n(`${i18nKey}.validateAccountOption.invalidPublicAppAccount`, {
|
|
76
|
+
useCommand: uiCommandReference('hs accounts use'),
|
|
77
|
+
devCommand: uiCommandReference('hs project dev'),
|
|
78
|
+
}));
|
|
79
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
80
|
+
}
|
|
81
|
+
checkIfParentAccountIsAuthed(accountConfig);
|
|
82
|
+
}
|
|
83
|
+
else if (isAppDeveloperAccount(accountConfig)) {
|
|
84
|
+
logger.error(i18n(`${i18nKey}.validateAccountOption.invalidPrivateAppAccount`, {
|
|
85
|
+
useCommand: uiCommandReference('hs accounts use'),
|
|
86
|
+
}));
|
|
87
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
128
88
|
}
|
|
129
|
-
checkIfParentAccountIsAuthed(accountConfig);
|
|
130
|
-
} else if (isAppDeveloperAccount(accountConfig)) {
|
|
131
|
-
logger.error(
|
|
132
|
-
i18n(`${i18nKey}.validateAccountOption.invalidPrivateAppAccount`, {
|
|
133
|
-
useCommand: uiCommandReference('hs accounts use'),
|
|
134
|
-
})
|
|
135
|
-
);
|
|
136
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
137
|
-
}
|
|
138
89
|
};
|
|
139
|
-
|
|
140
90
|
// If the user isn't using the recommended account type, prompt them to use or create one
|
|
141
|
-
const suggestRecommendedNestedAccount = async (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
uiLine();
|
|
158
|
-
logger.log();
|
|
159
|
-
|
|
160
|
-
const targetAccountPrompt = isAppDeveloperAccount(accountConfig)
|
|
161
|
-
? selectDeveloperTestTargetAccountPrompt
|
|
162
|
-
: selectSandboxTargetAccountPrompt;
|
|
163
|
-
|
|
164
|
-
return targetAccountPrompt(accounts, accountConfig, hasPublicApps);
|
|
91
|
+
const suggestRecommendedNestedAccount = async (accounts, accountConfig, hasPublicApps) => {
|
|
92
|
+
logger.log();
|
|
93
|
+
uiLine();
|
|
94
|
+
if (hasPublicApps) {
|
|
95
|
+
logger.log(i18n(`${i18nKey}.validateAccountOption.publicAppNonDeveloperTestAccountWarning`));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
logger.log(i18n(`${i18nKey}.validateAccountOption.nonSandboxWarning`));
|
|
99
|
+
}
|
|
100
|
+
uiLine();
|
|
101
|
+
logger.log();
|
|
102
|
+
const targetAccountPrompt = isAppDeveloperAccount(accountConfig)
|
|
103
|
+
? selectDeveloperTestTargetAccountPrompt
|
|
104
|
+
: selectSandboxTargetAccountPrompt;
|
|
105
|
+
return targetAccountPrompt(accounts, accountConfig, hasPublicApps);
|
|
165
106
|
};
|
|
166
|
-
|
|
167
107
|
// Create a new sandbox and return its accountId
|
|
168
108
|
const createSandboxForLocalDev = async (accountId, accountConfig, env) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
109
|
+
try {
|
|
110
|
+
await validateSandboxUsageLimits(accountConfig, HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX, env);
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
if (isMissingScopeError(err)) {
|
|
114
|
+
logger.error(i18n('lib.sandbox.create.failure.scopes.message', {
|
|
115
|
+
accountName: accountConfig.name || accountId,
|
|
116
|
+
}));
|
|
117
|
+
const websiteOrigin = getHubSpotWebsiteOrigin(env);
|
|
118
|
+
const url = `${websiteOrigin}/personal-access-key/${accountId}`;
|
|
119
|
+
logger.info(i18n('lib.sandbox.create.failure.scopes.instructions', {
|
|
120
|
+
accountName: accountConfig.name || accountId,
|
|
121
|
+
url,
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
logError(err);
|
|
126
|
+
}
|
|
127
|
+
process.exit(EXIT_CODES.ERROR);
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const { name } = await hubspotAccountNamePrompt({
|
|
131
|
+
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
132
|
+
});
|
|
133
|
+
trackCommandMetadataUsage('sandbox-create', { step: 'project-dev' }, accountId);
|
|
134
|
+
const { result } = await buildNewAccount({
|
|
135
|
+
name,
|
|
136
|
+
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
137
|
+
accountConfig,
|
|
138
|
+
env,
|
|
139
|
+
});
|
|
140
|
+
const targetAccountId = result.sandbox.sandboxHubId;
|
|
141
|
+
const sandboxAccountConfig = getAccountConfig(result.sandbox.sandboxHubId);
|
|
142
|
+
const syncTasks = await getAvailableSyncTypes(accountConfig, sandboxAccountConfig);
|
|
143
|
+
// For v1 sandboxes, keep sync here. Once we migrate to v2, this will be handled by BE automatically
|
|
144
|
+
await syncSandbox({
|
|
145
|
+
accountConfig: sandboxAccountConfig,
|
|
146
|
+
parentAccountConfig: accountConfig,
|
|
147
|
+
env,
|
|
148
|
+
syncTasks,
|
|
149
|
+
slimInfoMessage: true,
|
|
150
|
+
});
|
|
151
|
+
return targetAccountId;
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
logError(err);
|
|
155
|
+
process.exit(EXIT_CODES.ERROR);
|
|
192
156
|
}
|
|
193
|
-
process.exit(EXIT_CODES.ERROR);
|
|
194
|
-
}
|
|
195
|
-
try {
|
|
196
|
-
const { name } = await hubspotAccountNamePrompt({
|
|
197
|
-
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
trackCommandMetadataUsage(
|
|
201
|
-
'sandbox-create',
|
|
202
|
-
{ step: 'project-dev' },
|
|
203
|
-
accountId
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
const { result } = await buildNewAccount({
|
|
207
|
-
name,
|
|
208
|
-
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
209
|
-
accountConfig,
|
|
210
|
-
env,
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
const targetAccountId = result.sandbox.sandboxHubId;
|
|
214
|
-
|
|
215
|
-
const sandboxAccountConfig = getAccountConfig(result.sandbox.sandboxHubId);
|
|
216
|
-
const syncTasks = await getAvailableSyncTypes(
|
|
217
|
-
accountConfig,
|
|
218
|
-
sandboxAccountConfig
|
|
219
|
-
);
|
|
220
|
-
// For v1 sandboxes, keep sync here. Once we migrate to v2, this will be handled by BE automatically
|
|
221
|
-
await syncSandbox({
|
|
222
|
-
accountConfig: sandboxAccountConfig,
|
|
223
|
-
parentAccountConfig: accountConfig,
|
|
224
|
-
env,
|
|
225
|
-
syncTasks,
|
|
226
|
-
slimInfoMessage: true,
|
|
227
|
-
});
|
|
228
|
-
return targetAccountId;
|
|
229
|
-
} catch (err) {
|
|
230
|
-
logError(err);
|
|
231
|
-
process.exit(EXIT_CODES.ERROR);
|
|
232
|
-
}
|
|
233
157
|
};
|
|
234
|
-
|
|
235
158
|
// Create a developer test account and return its accountId
|
|
236
|
-
const createDeveloperTestAccountForLocalDev = async (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (validateResult) {
|
|
248
|
-
currentPortalCount = validateResult.results
|
|
249
|
-
? validateResult.results.length
|
|
250
|
-
: 0;
|
|
251
|
-
maxTestPortals = validateResult.maxTestPortals;
|
|
159
|
+
const createDeveloperTestAccountForLocalDev = async (accountId, accountConfig, env) => {
|
|
160
|
+
let currentPortalCount = 0;
|
|
161
|
+
let maxTestPortals = 10;
|
|
162
|
+
try {
|
|
163
|
+
const validateResult = await validateDevTestAccountUsageLimits(accountConfig);
|
|
164
|
+
if (validateResult) {
|
|
165
|
+
currentPortalCount = validateResult.results
|
|
166
|
+
? validateResult.results.length
|
|
167
|
+
: 0;
|
|
168
|
+
maxTestPortals = validateResult.maxTestPortals;
|
|
169
|
+
}
|
|
252
170
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
171
|
+
catch (err) {
|
|
172
|
+
if (isMissingScopeError(err)) {
|
|
173
|
+
logger.error(i18n('lib.developerTestAccount.create.failure.scopes.message', {
|
|
174
|
+
accountName: accountConfig.name || accountId,
|
|
175
|
+
}));
|
|
176
|
+
const websiteOrigin = getHubSpotWebsiteOrigin(env);
|
|
177
|
+
const url = `${websiteOrigin}/personal-access-key/${accountId}`;
|
|
178
|
+
logger.info(i18n('lib.developerTestAccount.create.failure.scopes.instructions', {
|
|
179
|
+
accountName: accountConfig.name || accountId,
|
|
180
|
+
url,
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
logError(err);
|
|
185
|
+
}
|
|
186
|
+
process.exit(EXIT_CODES.ERROR);
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const { name } = await hubspotAccountNamePrompt({
|
|
190
|
+
currentPortalCount,
|
|
191
|
+
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
|
|
192
|
+
});
|
|
193
|
+
trackCommandMetadataUsage('developer-test-account-create', { step: 'project-dev' }, accountId);
|
|
194
|
+
const { result } = await buildNewAccount({
|
|
195
|
+
name,
|
|
196
|
+
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
|
|
197
|
+
accountConfig,
|
|
198
|
+
env,
|
|
199
|
+
portalLimit: maxTestPortals,
|
|
200
|
+
});
|
|
201
|
+
return result.id;
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
logError(err);
|
|
205
|
+
process.exit(EXIT_CODES.ERROR);
|
|
270
206
|
}
|
|
271
|
-
process.exit(EXIT_CODES.ERROR);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
try {
|
|
275
|
-
const { name } = await hubspotAccountNamePrompt({
|
|
276
|
-
currentPortalCount,
|
|
277
|
-
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
|
|
278
|
-
});
|
|
279
|
-
trackCommandMetadataUsage(
|
|
280
|
-
'developer-test-account-create',
|
|
281
|
-
{ step: 'project-dev' },
|
|
282
|
-
accountId
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
const { result } = await buildNewAccount({
|
|
286
|
-
name,
|
|
287
|
-
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
|
|
288
|
-
accountConfig,
|
|
289
|
-
env,
|
|
290
|
-
portalLimit: maxTestPortals,
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
return result.id;
|
|
294
|
-
} catch (err) {
|
|
295
|
-
logError(err);
|
|
296
|
-
process.exit(EXIT_CODES.ERROR);
|
|
297
|
-
}
|
|
298
207
|
};
|
|
299
|
-
|
|
300
208
|
// Prompt user to confirm usage of an existing developer test account that is not currently in the config
|
|
301
209
|
const useExistingDevTestAccount = async (env, account) => {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
accountName: account.accountName,
|
|
322
|
-
accountId: account.id,
|
|
323
|
-
});
|
|
324
|
-
logger.success(
|
|
325
|
-
i18n(`lib.developerTestAccount.create.success.configFileUpdated`, {
|
|
326
|
-
accountName: devTestAcctConfigName,
|
|
327
|
-
authType: PERSONAL_ACCESS_KEY_AUTH_METHOD.name,
|
|
328
|
-
})
|
|
329
|
-
);
|
|
210
|
+
const useExistingDevTestAcct = await confirmUseExistingDeveloperTestAccountPrompt(account);
|
|
211
|
+
if (!useExistingDevTestAcct) {
|
|
212
|
+
logger.log('');
|
|
213
|
+
logger.log(i18n(`${i18nKey}.confirmDefaultAccountIsTarget.declineDefaultAccountExplanation`, {
|
|
214
|
+
useCommand: uiCommandReference('hs accounts use'),
|
|
215
|
+
devCommand: uiCommandReference('hs project dev'),
|
|
216
|
+
}));
|
|
217
|
+
logger.log('');
|
|
218
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
219
|
+
}
|
|
220
|
+
const devTestAcctConfigName = await saveAccountToConfig({
|
|
221
|
+
env,
|
|
222
|
+
accountName: account.accountName,
|
|
223
|
+
accountId: account.id,
|
|
224
|
+
});
|
|
225
|
+
logger.success(i18n(`lib.developerTestAccount.create.success.configFileUpdated`, {
|
|
226
|
+
accountName: devTestAcctConfigName,
|
|
227
|
+
authType: PERSONAL_ACCESS_KEY_AUTH_METHOD.name,
|
|
228
|
+
}));
|
|
330
229
|
};
|
|
331
|
-
|
|
332
230
|
// Prompt the user to create a new project if one doesn't exist on their target account
|
|
333
|
-
const createNewProjectForLocalDev = async (
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
projectName: projectConfig.name,
|
|
382
|
-
}),
|
|
383
|
-
succeedColor: 'white',
|
|
384
|
-
});
|
|
385
|
-
return project;
|
|
386
|
-
} catch (err) {
|
|
387
|
-
SpinniesManager.fail('createProject');
|
|
388
|
-
logger.log(
|
|
389
|
-
i18n(`${i18nKey}.createNewProjectForLocalDev.failedToCreateProject`)
|
|
390
|
-
);
|
|
391
|
-
process.exit(EXIT_CODES.ERROR);
|
|
231
|
+
const createNewProjectForLocalDev = async (projectConfig, targetAccountId, shouldCreateWithoutConfirmation, hasPublicApps) => {
|
|
232
|
+
// Create the project without prompting if this is a newly created sandbox
|
|
233
|
+
let shouldCreateProject = shouldCreateWithoutConfirmation;
|
|
234
|
+
if (!shouldCreateProject) {
|
|
235
|
+
const explanationString = i18n(hasPublicApps
|
|
236
|
+
? `${i18nKey}.createNewProjectForLocalDev.publicAppProjectMustExistExplanation`
|
|
237
|
+
: `${i18nKey}.createNewProjectForLocalDev.projectMustExistExplanation`, {
|
|
238
|
+
accountIdentifier: uiAccountDescription(targetAccountId),
|
|
239
|
+
projectName: projectConfig.name,
|
|
240
|
+
});
|
|
241
|
+
logger.log();
|
|
242
|
+
uiLine();
|
|
243
|
+
logger.log(explanationString);
|
|
244
|
+
uiLine();
|
|
245
|
+
shouldCreateProject = await confirmPrompt(i18n(`${i18nKey}.createNewProjectForLocalDev.createProject`, {
|
|
246
|
+
accountIdentifier: uiAccountDescription(targetAccountId),
|
|
247
|
+
projectName: projectConfig.name,
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
if (shouldCreateProject) {
|
|
251
|
+
SpinniesManager.add('createProject', {
|
|
252
|
+
text: i18n(`${i18nKey}.createNewProjectForLocalDev.creatingProject`, {
|
|
253
|
+
accountIdentifier: uiAccountDescription(targetAccountId),
|
|
254
|
+
projectName: projectConfig.name,
|
|
255
|
+
}),
|
|
256
|
+
});
|
|
257
|
+
try {
|
|
258
|
+
const { data: project } = await createProject(targetAccountId, projectConfig.name);
|
|
259
|
+
SpinniesManager.succeed('createProject', {
|
|
260
|
+
text: i18n(`${i18nKey}.createNewProjectForLocalDev.createdProject`, {
|
|
261
|
+
accountIdentifier: uiAccountDescription(targetAccountId),
|
|
262
|
+
projectName: projectConfig.name,
|
|
263
|
+
}),
|
|
264
|
+
succeedColor: 'white',
|
|
265
|
+
});
|
|
266
|
+
return project;
|
|
267
|
+
}
|
|
268
|
+
catch (err) {
|
|
269
|
+
SpinniesManager.fail('createProject');
|
|
270
|
+
logger.log(i18n(`${i18nKey}.createNewProjectForLocalDev.failedToCreateProject`));
|
|
271
|
+
process.exit(EXIT_CODES.ERROR);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
// We cannot continue if the project does not exist in the target account
|
|
276
|
+
logger.log();
|
|
277
|
+
logger.log(i18n(`${i18nKey}.createNewProjectForLocalDev.choseNotToCreateProject`));
|
|
278
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
392
279
|
}
|
|
393
|
-
} else {
|
|
394
|
-
// We cannot continue if the project does not exist in the target account
|
|
395
|
-
logger.log();
|
|
396
|
-
logger.log(
|
|
397
|
-
i18n(`${i18nKey}.createNewProjectForLocalDev.choseNotToCreateProject`)
|
|
398
|
-
);
|
|
399
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
400
|
-
}
|
|
401
280
|
};
|
|
402
|
-
|
|
403
281
|
// Create an initial build if the project was newly created in the account
|
|
404
282
|
// Return the newly deployed build
|
|
405
|
-
const createInitialBuildForNewProject = async (
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
})
|
|
423
|
-
) {
|
|
424
|
-
logger.log();
|
|
425
|
-
logger.error(
|
|
426
|
-
i18n(`${i18nKey}.createInitialBuildForNewProject.projectLockedError`)
|
|
427
|
-
);
|
|
428
|
-
logger.log();
|
|
429
|
-
} else {
|
|
430
|
-
logError(
|
|
431
|
-
initialUploadResult.uploadError,
|
|
432
|
-
new ApiErrorContext({
|
|
433
|
-
accountId: targetAccountId,
|
|
434
|
-
projectName: projectConfig.name,
|
|
435
|
-
})
|
|
436
|
-
);
|
|
283
|
+
const createInitialBuildForNewProject = async (projectConfig, projectDir, targetAccountId) => {
|
|
284
|
+
const initialUploadResult = await handleProjectUpload(targetAccountId, projectConfig, projectDir, (...args) => pollProjectBuildAndDeploy(...args, true), i18n(`${i18nKey}.createInitialBuildForNewProject.initialUploadMessage`));
|
|
285
|
+
if (initialUploadResult.uploadError) {
|
|
286
|
+
if (isSpecifiedError(initialUploadResult.uploadError, {
|
|
287
|
+
subCategory: PROJECT_ERROR_TYPES.PROJECT_LOCKED,
|
|
288
|
+
})) {
|
|
289
|
+
logger.log();
|
|
290
|
+
logger.error(i18n(`${i18nKey}.createInitialBuildForNewProject.projectLockedError`));
|
|
291
|
+
logger.log();
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
logError(initialUploadResult.uploadError, new ApiErrorContext({
|
|
295
|
+
accountId: targetAccountId,
|
|
296
|
+
projectName: projectConfig.name,
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
process.exit(EXIT_CODES.ERROR);
|
|
437
300
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
301
|
+
if (!initialUploadResult.succeeded) {
|
|
302
|
+
let subTasks = [];
|
|
303
|
+
if (initialUploadResult.buildResult.status === 'FAILURE') {
|
|
304
|
+
subTasks =
|
|
305
|
+
initialUploadResult.buildResult[PROJECT_BUILD_TEXT.SUBTASK_KEY];
|
|
306
|
+
}
|
|
307
|
+
else if (initialUploadResult.deployResult.status === 'FAILURE') {
|
|
308
|
+
subTasks =
|
|
309
|
+
initialUploadResult.deployResult[PROJECT_DEPLOY_TEXT.SUBTASK_KEY];
|
|
310
|
+
}
|
|
311
|
+
const failedSubTasks = subTasks.filter(task => task.status === 'FAILURE');
|
|
312
|
+
logger.log();
|
|
313
|
+
failedSubTasks.forEach(failedSubTask => {
|
|
314
|
+
logger.error(failedSubTask.errorMessage);
|
|
315
|
+
});
|
|
316
|
+
logger.log();
|
|
317
|
+
process.exit(EXIT_CODES.ERROR);
|
|
450
318
|
}
|
|
451
|
-
|
|
452
|
-
const failedSubTasks = subTasks.filter(task => task.status === 'FAILURE');
|
|
453
|
-
|
|
454
|
-
logger.log();
|
|
455
|
-
failedSubTasks.forEach(failedSubTask => {
|
|
456
|
-
logger.error(failedSubTask.errorMessage);
|
|
457
|
-
});
|
|
458
|
-
logger.log();
|
|
459
|
-
|
|
460
|
-
process.exit(EXIT_CODES.ERROR);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
return initialUploadResult.buildResult;
|
|
319
|
+
return initialUploadResult.buildResult;
|
|
464
320
|
};
|
|
465
|
-
|
|
466
321
|
const getAccountHomeUrl = accountId => {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
);
|
|
470
|
-
return `${baseUrl}/home?portalId=${accountId}`;
|
|
322
|
+
const baseUrl = getHubSpotWebsiteOrigin(getEnv(accountId) === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD);
|
|
323
|
+
return `${baseUrl}/home?portalId=${accountId}`;
|
|
471
324
|
};
|
|
472
|
-
|
|
473
325
|
module.exports = {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
326
|
+
confirmDefaultAccountIsTarget,
|
|
327
|
+
checkIfDefaultAccountIsSupported,
|
|
328
|
+
checkIfAccountFlagIsSupported,
|
|
329
|
+
suggestRecommendedNestedAccount,
|
|
330
|
+
createSandboxForLocalDev,
|
|
331
|
+
createDeveloperTestAccountForLocalDev,
|
|
332
|
+
useExistingDevTestAccount,
|
|
333
|
+
createNewProjectForLocalDev,
|
|
334
|
+
createInitialBuildForNewProject,
|
|
335
|
+
getAccountHomeUrl,
|
|
336
|
+
checkIfParentAccountIsAuthed,
|
|
485
337
|
};
|