@hubspot/cli 7.8.0-experimental.0 → 7.8.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/bin/cli.js +31 -27
- package/commands/__tests__/auth.test.js +5 -0
- package/commands/__tests__/doctor.test.js +16 -16
- package/commands/__tests__/getStarted.test.js +2 -2
- package/commands/__tests__/mcp.test.js +1 -1
- package/commands/__tests__/project.test.js +2 -3
- package/commands/account/auth.js +1 -0
- package/commands/account/clean.js +18 -27
- package/commands/account/createOverride.js +13 -31
- package/commands/account/info.js +20 -31
- package/commands/account/list.js +16 -22
- package/commands/account/remove.js +12 -20
- package/commands/account/removeOverride.js +11 -21
- package/commands/account/rename.js +6 -9
- package/commands/account/use.js +12 -26
- package/commands/account.js +2 -2
- package/commands/app/__tests__/migrate.test.js +5 -6
- package/commands/app/migrate.js +13 -19
- package/commands/app/secret/add.js +2 -1
- package/commands/app/secret/delete.js +2 -1
- package/commands/app/secret/list.js +2 -1
- package/commands/app/secret/update.js +2 -1
- package/commands/app/secret.js +2 -1
- package/commands/app.js +2 -2
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +17 -7
- package/commands/cms/convertFields.js +7 -9
- package/commands/cms/getReactModule.js +9 -14
- package/commands/cms/lighthouseScore.js +33 -36
- package/commands/cms.js +2 -2
- package/commands/completion.js +3 -3
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +64 -37
- package/commands/config.js +2 -2
- package/commands/create.js +2 -2
- package/commands/customObject/create.js +10 -12
- package/commands/customObject/schema/create.js +9 -11
- package/commands/customObject/schema/delete.js +16 -16
- package/commands/customObject/schema/fetch-all.js +12 -11
- package/commands/customObject/schema/fetch.js +15 -15
- package/commands/customObject/schema/list.js +4 -4
- package/commands/customObject/schema/update.js +13 -13
- package/commands/customObject/schema.js +2 -2
- package/commands/customObject.js +6 -7
- package/commands/doctor.js +8 -11
- package/commands/feedback.js +8 -13
- package/commands/fetch.js +8 -8
- package/commands/filemanager/fetch.js +7 -7
- package/commands/filemanager/upload.js +15 -34
- package/commands/filemanager.js +2 -2
- package/commands/function/deploy.js +11 -29
- package/commands/function/list.js +8 -8
- package/commands/function/server.js +9 -11
- package/commands/function.d.ts +1 -1
- package/commands/function.js +2 -2
- package/commands/getStarted.d.ts +1 -3
- package/commands/getStarted.js +68 -20
- package/commands/hubdb/clear.js +7 -15
- package/commands/hubdb/create.js +9 -15
- package/commands/hubdb/delete.js +8 -15
- package/commands/hubdb/fetch.js +6 -9
- package/commands/hubdb.d.ts +1 -1
- package/commands/hubdb.js +2 -2
- package/commands/init.js +2 -3
- package/commands/lint.js +16 -16
- package/commands/list.js +8 -14
- package/commands/logs.js +14 -20
- package/commands/mcp/__tests__/setup.test.js +2 -2
- package/commands/mcp/setup.js +11 -2
- package/commands/mcp.js +3 -3
- package/commands/mv.js +6 -17
- package/commands/open.js +5 -5
- package/commands/project/__tests__/add.test.js +15 -13
- package/commands/project/__tests__/create.test.js +6 -6
- package/commands/project/__tests__/deploy.test.js +3 -7
- package/commands/project/__tests__/devUnifiedFlow.test.js +2 -4
- package/commands/project/__tests__/installDeps.test.js +8 -8
- package/commands/project/__tests__/list.test.js +31 -0
- package/commands/project/__tests__/logs.test.js +1 -4
- package/commands/project/__tests__/migrate.test.js +7 -7
- package/commands/project/__tests__/migrateApp.test.js +3 -7
- package/commands/project/__tests__/profile.test.js +1 -1
- package/commands/project/__tests__/validate.test.js +98 -0
- package/commands/project/add.d.ts +2 -2
- package/commands/project/add.js +7 -10
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +4 -11
- package/commands/project/deploy.js +5 -5
- package/commands/project/dev/deprecatedFlow.js +9 -18
- package/commands/project/dev/index.js +21 -18
- package/commands/project/dev/unifiedFlow.js +15 -8
- package/commands/project/download.js +15 -16
- package/commands/project/installDeps.d.ts +2 -2
- package/commands/project/installDeps.js +9 -9
- package/commands/project/list.d.ts +4 -0
- package/commands/project/list.js +62 -0
- package/commands/project/listBuilds.js +12 -21
- package/commands/project/logs.js +21 -24
- package/commands/project/migrate.js +33 -12
- package/commands/project/migrateApp.js +10 -17
- package/commands/project/open.js +6 -14
- package/commands/project/profile/add.js +3 -3
- package/commands/project/profile/delete.js +1 -2
- package/commands/project/profile.js +2 -3
- package/commands/project/upload.js +16 -25
- package/commands/project/validate.js +7 -7
- package/commands/project/watch.js +13 -22
- package/commands/project.js +4 -3
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +39 -64
- package/commands/sandbox.js +2 -2
- package/commands/secret/addSecret.js +7 -17
- package/commands/secret/deleteSecret.js +10 -20
- package/commands/secret/listSecret.js +8 -10
- package/commands/secret/updateSecret.js +9 -17
- package/commands/secret.js +2 -2
- package/commands/testAccount/__tests__/delete.test.js +2 -4
- package/commands/testAccount/create.js +2 -2
- package/commands/testAccount/delete.d.ts +4 -3
- package/commands/testAccount/delete.js +155 -14
- package/commands/testAccount/importData.d.ts +1 -1
- package/commands/testAccount/importData.js +1 -1
- package/commands/testAccount.js +1 -1
- package/commands/theme/preview.js +1 -4
- package/lang/en.d.ts +365 -111
- package/lang/en.js +409 -158
- package/lang/en.lyaml +4 -4
- package/lib/__tests__/buildAccount.test.js +4 -3
- package/lib/__tests__/commonOpts.test.js +1 -1
- package/lib/__tests__/dependencyManagement.test.js +1 -1
- package/lib/__tests__/developerTestAccounts.test.js +3 -3
- package/lib/__tests__/hasFeature.test.js +145 -7
- package/lib/__tests__/npm.test.js +1 -1
- package/lib/__tests__/oauth.test.js +4 -4
- package/lib/__tests__/process.test.js +10 -5
- package/lib/__tests__/sandboxSync.test.js +8 -8
- package/lib/__tests__/sandboxes.test.js +8 -8
- package/lib/__tests__/serverlessLogs.test.js +1 -1
- package/lib/__tests__/usageTracking.test.js +5 -5
- package/lib/__tests__/validation.test.js +2 -1
- package/lib/__tests__/yargsUtils.test.js +83 -9
- package/lib/app/__tests__/migrate.test.js +19 -56
- package/lib/app/__tests__/migrate_legacy.test.js +1 -1
- package/lib/app/migrate.d.ts +2 -8
- package/lib/app/migrate.js +6 -81
- package/lib/app/migrate_legacy.js +20 -24
- package/lib/buildAccount.d.ts +2 -2
- package/lib/buildAccount.js +32 -64
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +25 -22
- package/lib/configMigrate.js +88 -9
- package/lib/configOptions.js +7 -0
- package/lib/constants.d.ts +22 -1
- package/lib/constants.js +26 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +9 -36
- package/lib/developerTestAccounts.js +9 -23
- package/lib/doctor/Diagnosis.js +11 -23
- package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
- package/lib/doctor/Doctor.js +42 -90
- package/lib/doctor/__tests__/Doctor.test.js +4 -4
- package/lib/errorHandlers/index.js +12 -20
- package/lib/errorHandlers/suppressError.js +11 -18
- package/lib/hasFeature.js +6 -0
- package/lib/lang.js +6 -5
- package/lib/links.d.ts +1 -0
- package/lib/links.js +14 -7
- package/lib/mcp/setup.js +1 -1
- package/lib/middleware/__test__/commandTargetingUtils.test.js +99 -0
- package/lib/middleware/__test__/configMiddleware.test.js +11 -11
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +6 -8
- package/lib/middleware/commandTargetingUtils.d.ts +8 -0
- package/lib/middleware/commandTargetingUtils.js +74 -0
- package/lib/middleware/configMiddleware.d.ts +1 -1
- package/lib/middleware/configMiddleware.js +21 -81
- package/lib/middleware/fireAlarmMiddleware.js +15 -5
- package/lib/middleware/gitMiddleware.js +5 -1
- package/lib/middleware/notificationsMiddleware.js +5 -11
- package/lib/middleware/yargsChecksMiddleware.js +6 -9
- package/lib/npm.js +2 -2
- package/lib/oauth.js +5 -5
- package/lib/process.js +5 -4
- package/lib/projects/__tests__/AppDevModeInterface.test.js +87 -90
- package/lib/projects/__tests__/LocalDevProcess.test.js +231 -19
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +89 -63
- package/lib/projects/__tests__/deploy.test.js +73 -8
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +6 -2
- package/lib/projects/__tests__/platformVersion.test.js +8 -8
- package/lib/projects/__tests__/projects.test.js +12 -12
- package/lib/projects/__tests__/structure.test.js +3 -3
- package/lib/projects/__tests__/upload.test.d.ts +1 -0
- package/lib/projects/__tests__/upload.test.js +82 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
- package/lib/projects/add/__tests__/v2AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/{v3AddComponent.test.js → v2AddComponent.test.js} +39 -39
- package/lib/projects/add/{v3AddComponent.d.ts → v2AddComponent.d.ts} +1 -1
- package/lib/projects/add/{v3AddComponent.js → v2AddComponent.js} +5 -5
- package/lib/projects/create/__tests__/legacy.test.js +5 -5
- package/lib/projects/create/__tests__/v2.test.d.ts +1 -0
- package/lib/projects/create/__tests__/{v3.test.js → v2.test.js} +82 -7
- package/lib/projects/create/index.js +4 -4
- package/lib/projects/create/legacy.js +2 -2
- package/lib/projects/create/{v3.d.ts → v2.d.ts} +3 -3
- package/lib/projects/create/{v3.js → v2.js} +16 -13
- package/lib/projects/deploy.d.ts +1 -1
- package/lib/projects/deploy.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +10 -1
- package/lib/projects/localDev/AppDevModeInterface.js +118 -89
- package/lib/projects/localDev/DevServerManager.d.ts +11 -29
- package/lib/projects/localDev/DevServerManager.js +19 -61
- package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +40 -0
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +120 -0
- package/lib/projects/localDev/LocalDevLogger.d.ts +4 -0
- package/lib/projects/localDev/LocalDevLogger.js +27 -6
- package/lib/projects/localDev/{LocalDevManager.js → LocalDevManager_DEPRECATED.js} +10 -11
- package/lib/projects/localDev/LocalDevProcess.d.ts +7 -5
- package/lib/projects/localDev/LocalDevProcess.js +93 -21
- package/lib/projects/localDev/LocalDevState.d.ts +12 -8
- package/lib/projects/localDev/LocalDevState.js +27 -17
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +6 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +94 -33
- package/lib/projects/localDev/helpers/account.d.ts +1 -1
- package/lib/projects/localDev/helpers/account.js +2 -2
- package/lib/projects/localDev/helpers/project.d.ts +3 -2
- package/lib/projects/localDev/helpers/project.js +49 -10
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +7 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +19 -0
- package/lib/projects/platformVersion.d.ts +1 -1
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/pollProjectBuildAndDeploy.js +4 -4
- package/lib/projects/structure.js +6 -6
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +17 -8
- package/lib/projects/urls.d.ts +0 -1
- package/lib/projects/urls.js +0 -3
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +1 -0
- package/lib/prompts/__tests__/projectAddPrompt.test.js +10 -10
- package/lib/prompts/accountNamePrompt.js +14 -19
- package/lib/prompts/accountsPrompt.js +2 -2
- package/lib/prompts/cmsFieldPrompt.js +2 -2
- package/lib/prompts/createApiSamplePrompt.js +5 -5
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
- package/lib/prompts/createFunctionPrompt.js +14 -14
- package/lib/prompts/createModulePrompt.js +9 -9
- package/lib/prompts/createTemplatePrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.js +5 -8
- package/lib/prompts/installAppPrompt.d.ts +1 -6
- package/lib/prompts/installAppPrompt.js +1 -6
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +6 -6
- package/lib/prompts/projectAddPrompt.d.ts +2 -2
- package/lib/prompts/projectAddPrompt.js +9 -2
- package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
- package/lib/prompts/projectNamePrompt.js +4 -8
- package/lib/prompts/projectsLogsPrompt.js +2 -4
- package/lib/prompts/promptUtils.js +30 -9
- package/lib/prompts/sandboxesPrompt.js +7 -7
- package/lib/prompts/secretPrompt.js +3 -3
- package/lib/prompts/selectAppPrompt.js +3 -3
- package/lib/prompts/selectHubDBTablePrompt.js +9 -13
- package/lib/prompts/selectProjectTemplatePrompt.js +2 -0
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
- package/lib/prompts/uploadPrompt.js +5 -5
- package/lib/sandboxSync.js +24 -41
- package/lib/sandboxes.js +19 -47
- package/lib/schema.js +3 -3
- package/lib/serverlessLogs.js +11 -13
- package/lib/theme/__tests__/migrate.test.d.ts +1 -0
- package/lib/theme/__tests__/migrate.test.js +233 -0
- package/lib/theme/migrate.d.ts +13 -0
- package/lib/theme/migrate.js +90 -0
- package/lib/ui/SpinniesManager.d.ts +2 -0
- package/lib/ui/SpinniesManager.js +112 -8
- package/lib/ui/boxen.js +1 -2
- package/lib/ui/git.js +13 -10
- package/lib/ui/index.d.ts +4 -0
- package/lib/ui/index.js +47 -38
- package/lib/ui/serverlessFunctionLogs.js +9 -7
- package/lib/ui/uiMessages.d.ts +72 -0
- package/lib/ui/uiMessages.js +75 -0
- package/lib/usageTracking.js +8 -8
- package/lib/validation.js +20 -23
- package/lib/yargsUtils.d.ts +1 -1
- package/lib/yargsUtils.js +12 -5
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +1 -1
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/cms/HsCreateModuleTool.js +1 -1
- package/mcp-server/tools/cms/HsCreateTemplateTool.js +1 -1
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +2 -2
- package/mcp-server/tools/cms/HsListFunctionsTool.js +1 -1
- package/mcp-server/tools/cms/HsListTool.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.js +2 -2
- package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsListTool.test.js +1 -1
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +3 -3
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +3 -3
- package/mcp-server/tools/project/CreateProjectTool.d.ts +3 -3
- package/mcp-server/tools/project/CreateProjectTool.js +5 -5
- package/mcp-server/tools/project/DeployProjectTool.js +1 -1
- package/mcp-server/tools/project/DocFetchTool.js +2 -2
- package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
- package/mcp-server/tools/project/DocsSearchTool.js +7 -7
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
- package/mcp-server/tools/project/GetConfigValuesTool.d.ts +4 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +13 -7
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +1 -1
- package/mcp-server/tools/project/UploadProjectTools.js +2 -2
- package/mcp-server/tools/project/ValidateProjectTool.js +1 -1
- package/mcp-server/tools/project/__tests__/AddFeatureToProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +2 -2
- package/mcp-server/tools/project/__tests__/DeployProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +2 -2
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +14 -12
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
- package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +9 -8
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +1 -1
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +1 -1
- package/mcp-server/tools/project/constants.d.ts +1 -1
- package/mcp-server/tools/project/constants.js +9 -3
- package/mcp-server/utils/__tests__/cliConfig.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/cliConfig.test.js +110 -0
- package/mcp-server/utils/cliConfig.d.ts +1 -0
- package/mcp-server/utils/cliConfig.js +12 -0
- package/mcp-server/utils/toolUsageTracking.js +2 -2
- package/package.json +8 -12
- package/types/LocalDev.d.ts +19 -3
- package/ui/components/HorizontalSelectPrompt.js +1 -1
- package/ui/index.js +1 -1
- package/commands/getStartedV2.d.ts +0 -9
- package/commands/getStartedV2.js +0 -39
- package/lib/middleware/__test__/utils.test.js +0 -51
- package/lib/middleware/utils.d.ts +0 -8
- package/lib/middleware/utils.js +0 -14
- package/lib/projects/localDev/DevServerManagerV2.d.ts +0 -22
- package/lib/projects/localDev/DevServerManagerV2.js +0 -81
- package/ui/components/Ascii.d.ts +0 -10
- package/ui/components/Ascii.js +0 -11
- package/ui/views/GetStarted.d.ts +0 -7
- package/ui/views/GetStarted.js +0 -157
- /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/list.test.d.ts} +0 -0
- /package/{lib/projects/add/__tests__/v3AddComponent.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
- /package/lib/{projects/create/__tests__/v3.test.d.ts → middleware/__test__/commandTargetingUtils.test.d.ts} +0 -0
- /package/lib/projects/localDev/{LocalDevManager.d.ts → LocalDevManager_DEPRECATED.d.ts} +0 -0
package/lib/buildAccount.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { getAccessToken, updateConfigWithAccessToken, } from '@hubspot/local-dev-lib/personalAccessKey';
|
|
2
2
|
import { accountNameExistsInConfig, updateAccountConfig, writeConfig, getAccountId, } from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
|
|
4
|
-
import {
|
|
4
|
+
import { uiLogger } from './ui/logger.js';
|
|
5
5
|
import { createDeveloperTestAccount, fetchDeveloperTestAccountGateSyncStatus, generateDeveloperTestAccountPersonalAccessKey, } from '@hubspot/local-dev-lib/api/developerTestAccounts';
|
|
6
6
|
import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
|
|
7
7
|
import { createSandbox, createV2Sandbox, getSandboxPersonalAccessKey, } from '@hubspot/local-dev-lib/api/sandboxHubs';
|
|
8
8
|
import { personalAccessKeyPrompt } from './prompts/personalAccessKeyPrompt.js';
|
|
9
9
|
import { createDeveloperTestAccountConfigPrompt } from './prompts/createDeveloperTestAccountConfigPrompt.js';
|
|
10
|
-
import { i18n } from './lang.js';
|
|
11
10
|
import { cliAccountNamePrompt } from './prompts/accountNamePrompt.js';
|
|
12
11
|
import SpinniesManager from './ui/SpinniesManager.js';
|
|
13
12
|
import { debugError, logError } from './errorHandlers/index.js';
|
|
@@ -32,10 +31,8 @@ export async function saveAccountToConfig(accountId, accountName, env, personalA
|
|
|
32
31
|
const invalidAccountName = accountNameExistsInConfig(nameForConfig);
|
|
33
32
|
if (invalidAccountName) {
|
|
34
33
|
if (!force) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
name: nameForConfig,
|
|
38
|
-
}));
|
|
34
|
+
uiLogger.log('');
|
|
35
|
+
uiLogger.warn(lib.prompts.accountNamePrompt.errors.accountNameExists(nameForConfig));
|
|
39
36
|
const { name: promptName } = await cliAccountNamePrompt(nameForConfig + `_${accountId}`);
|
|
40
37
|
validName = promptName;
|
|
41
38
|
}
|
|
@@ -52,10 +49,10 @@ export async function saveAccountToConfig(accountId, accountName, env, personalA
|
|
|
52
49
|
name: validName,
|
|
53
50
|
});
|
|
54
51
|
writeConfig();
|
|
55
|
-
|
|
52
|
+
uiLogger.log('');
|
|
56
53
|
return validName;
|
|
57
54
|
}
|
|
58
|
-
export async function
|
|
55
|
+
export async function createDeveloperTestAccountV2(parentAccountId, testAccountConfig) {
|
|
59
56
|
const result = {
|
|
60
57
|
accountName: testAccountConfig.accountName,
|
|
61
58
|
};
|
|
@@ -69,7 +66,7 @@ export async function createDeveloperTestAccountV3(parentAccountId, testAccountC
|
|
|
69
66
|
}
|
|
70
67
|
catch (err) {
|
|
71
68
|
debugError(err);
|
|
72
|
-
throw new Error(lib.buildAccount.
|
|
69
|
+
throw new Error(lib.buildAccount.createDeveloperTestAccountV2.syncFailure);
|
|
73
70
|
}
|
|
74
71
|
// HACK: The status endpoint sometimes returns an early success status.
|
|
75
72
|
// Sleep for an extra 5 seconds to make sure the sync is actually complete.
|
|
@@ -81,20 +78,20 @@ export async function createDeveloperTestAccountV3(parentAccountId, testAccountC
|
|
|
81
78
|
}
|
|
82
79
|
catch (err) {
|
|
83
80
|
debugError(err);
|
|
84
|
-
throw new Error(lib.buildAccount.
|
|
81
|
+
throw new Error(lib.buildAccount.createDeveloperTestAccountV2.pakFailure);
|
|
85
82
|
}
|
|
86
83
|
return result;
|
|
87
84
|
}
|
|
88
|
-
export async function buildDeveloperTestAccount(testAccountName, parentAccountConfig, env, portalLimit,
|
|
85
|
+
export async function buildDeveloperTestAccount(testAccountName, parentAccountConfig, env, portalLimit, useV2 = false) {
|
|
89
86
|
const id = getAccountIdentifier(parentAccountConfig);
|
|
90
87
|
const parentAccountId = getAccountId(id);
|
|
91
88
|
let testAccountConfig = {
|
|
92
89
|
accountName: testAccountName,
|
|
93
90
|
};
|
|
94
91
|
if (!parentAccountId) {
|
|
95
|
-
throw new Error(
|
|
92
|
+
throw new Error(lib.developerTestAccount.create.loading.fail(''));
|
|
96
93
|
}
|
|
97
|
-
if (
|
|
94
|
+
if (useV2) {
|
|
98
95
|
testAccountConfig = await createDeveloperTestAccountConfigPrompt({
|
|
99
96
|
name: testAccountConfig.accountName,
|
|
100
97
|
description: 'Test Account created by the HubSpot CLI',
|
|
@@ -103,17 +100,15 @@ export async function buildDeveloperTestAccount(testAccountName, parentAccountCo
|
|
|
103
100
|
SpinniesManager.init({
|
|
104
101
|
succeedColor: 'white',
|
|
105
102
|
});
|
|
106
|
-
|
|
103
|
+
uiLogger.log('');
|
|
107
104
|
SpinniesManager.add('buildDeveloperTestAccount', {
|
|
108
|
-
text:
|
|
109
|
-
accountName: testAccountName,
|
|
110
|
-
}),
|
|
105
|
+
text: lib.developerTestAccount.create.loading.add(testAccountName),
|
|
111
106
|
});
|
|
112
107
|
let developerTestAccountId;
|
|
113
108
|
let developerTestAccountPersonalAccessKey;
|
|
114
109
|
try {
|
|
115
|
-
if (
|
|
116
|
-
const result = await
|
|
110
|
+
if (useV2) {
|
|
111
|
+
const result = await createDeveloperTestAccountV2(parentAccountId, testAccountConfig);
|
|
117
112
|
developerTestAccountId = result.accountId;
|
|
118
113
|
developerTestAccountPersonalAccessKey = result.personalAccessKey;
|
|
119
114
|
}
|
|
@@ -123,18 +118,13 @@ export async function buildDeveloperTestAccount(testAccountName, parentAccountCo
|
|
|
123
118
|
developerTestAccountPersonalAccessKey = data.personalAccessKey;
|
|
124
119
|
}
|
|
125
120
|
SpinniesManager.succeed('buildDeveloperTestAccount', {
|
|
126
|
-
text:
|
|
127
|
-
accountName: testAccountName,
|
|
128
|
-
accountId: developerTestAccountId,
|
|
129
|
-
}),
|
|
121
|
+
text: lib.developerTestAccount.create.loading.succeed(testAccountName, developerTestAccountId.toString()),
|
|
130
122
|
});
|
|
131
123
|
}
|
|
132
124
|
catch (e) {
|
|
133
125
|
debugError(e);
|
|
134
126
|
SpinniesManager.fail('buildDeveloperTestAccount', {
|
|
135
|
-
text:
|
|
136
|
-
accountName: testAccountName,
|
|
137
|
-
}),
|
|
127
|
+
text: lib.developerTestAccount.create.loading.fail(testAccountName),
|
|
138
128
|
});
|
|
139
129
|
handleDeveloperTestAccountCreateError(e, parentAccountId, env, portalLimit);
|
|
140
130
|
}
|
|
@@ -148,26 +138,20 @@ export async function buildDeveloperTestAccount(testAccountName, parentAccountCo
|
|
|
148
138
|
return developerTestAccountId;
|
|
149
139
|
}
|
|
150
140
|
export async function buildSandbox(sandboxName, parentAccountConfig, sandboxType, env, force = false) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
i18nKey = 'lib.sandbox.create.loading.developer';
|
|
157
|
-
}
|
|
141
|
+
const sandboxTypeKey = sandboxType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX
|
|
142
|
+
? 'standard'
|
|
143
|
+
: 'developer';
|
|
158
144
|
const id = getAccountIdentifier(parentAccountConfig);
|
|
159
145
|
const parentAccountId = getAccountId(id);
|
|
160
146
|
if (!parentAccountId) {
|
|
161
|
-
throw new Error(
|
|
147
|
+
throw new Error(lib.sandbox.create[sandboxTypeKey].loading.fail(''));
|
|
162
148
|
}
|
|
163
149
|
SpinniesManager.init({
|
|
164
150
|
succeedColor: 'white',
|
|
165
151
|
});
|
|
166
|
-
|
|
152
|
+
uiLogger.log('');
|
|
167
153
|
SpinniesManager.add('buildSandbox', {
|
|
168
|
-
text:
|
|
169
|
-
accountName: sandboxName,
|
|
170
|
-
}),
|
|
154
|
+
text: lib.sandbox.create[sandboxTypeKey].loading.add(sandboxName),
|
|
171
155
|
});
|
|
172
156
|
let sandbox;
|
|
173
157
|
try {
|
|
@@ -175,18 +159,13 @@ export async function buildSandbox(sandboxName, parentAccountConfig, sandboxType
|
|
|
175
159
|
const { data } = await createSandbox(parentAccountId, sandboxName, sandboxApiType);
|
|
176
160
|
sandbox = { name: sandboxName, ...data };
|
|
177
161
|
SpinniesManager.succeed('buildSandbox', {
|
|
178
|
-
text:
|
|
179
|
-
accountName: sandboxName,
|
|
180
|
-
accountId: sandbox.sandbox.sandboxHubId,
|
|
181
|
-
}),
|
|
162
|
+
text: lib.sandbox.create[sandboxTypeKey].loading.succeed(sandboxName, sandbox.sandbox.sandboxHubId.toString()),
|
|
182
163
|
});
|
|
183
164
|
}
|
|
184
165
|
catch (e) {
|
|
185
166
|
debugError(e);
|
|
186
167
|
SpinniesManager.fail('buildSandbox', {
|
|
187
|
-
text:
|
|
188
|
-
accountName: sandboxName,
|
|
189
|
-
}),
|
|
168
|
+
text: lib.sandbox.create[sandboxTypeKey].loading.fail(sandboxName),
|
|
190
169
|
});
|
|
191
170
|
handleSandboxCreateError(e, env, sandboxName, parentAccountId);
|
|
192
171
|
}
|
|
@@ -200,26 +179,20 @@ export async function buildSandbox(sandboxName, parentAccountConfig, sandboxType
|
|
|
200
179
|
return sandbox;
|
|
201
180
|
}
|
|
202
181
|
export async function buildV2Sandbox(sandboxName, parentAccountConfig, sandboxType, syncObjectRecords, env, force = false) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
i18nKey = 'lib.sandbox.create.loading.developer';
|
|
209
|
-
}
|
|
182
|
+
const sandboxTypeKey = sandboxType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX
|
|
183
|
+
? 'standard'
|
|
184
|
+
: 'developer';
|
|
210
185
|
const id = getAccountIdentifier(parentAccountConfig);
|
|
211
186
|
const parentAccountId = getAccountId(id);
|
|
212
187
|
if (!parentAccountId) {
|
|
213
|
-
throw new Error(
|
|
188
|
+
throw new Error(lib.sandbox.create[sandboxTypeKey].loading.fail(''));
|
|
214
189
|
}
|
|
215
190
|
SpinniesManager.init({
|
|
216
191
|
succeedColor: 'white',
|
|
217
192
|
});
|
|
218
|
-
|
|
193
|
+
uiLogger.log('');
|
|
219
194
|
SpinniesManager.add('buildV2Sandbox', {
|
|
220
|
-
text:
|
|
221
|
-
accountName: sandboxName,
|
|
222
|
-
}),
|
|
195
|
+
text: lib.sandbox.create[sandboxTypeKey].loading.add(sandboxName),
|
|
223
196
|
});
|
|
224
197
|
let sandbox;
|
|
225
198
|
let pak;
|
|
@@ -230,18 +203,13 @@ export async function buildV2Sandbox(sandboxName, parentAccountConfig, sandboxTy
|
|
|
230
203
|
const { data: { personalAccessKey }, } = await getSandboxPersonalAccessKey(parentAccountId, sandbox.sandboxHubId);
|
|
231
204
|
pak = personalAccessKey.encodedOAuthRefreshToken;
|
|
232
205
|
SpinniesManager.succeed('buildV2Sandbox', {
|
|
233
|
-
text:
|
|
234
|
-
accountName: sandboxName,
|
|
235
|
-
accountId: sandbox.sandboxHubId,
|
|
236
|
-
}),
|
|
206
|
+
text: lib.sandbox.create[sandboxTypeKey].loading.succeed(sandboxName, sandbox.sandboxHubId.toString()),
|
|
237
207
|
});
|
|
238
208
|
}
|
|
239
209
|
catch (e) {
|
|
240
210
|
debugError(e);
|
|
241
211
|
SpinniesManager.fail('buildV2Sandbox', {
|
|
242
|
-
text:
|
|
243
|
-
accountName: sandboxName,
|
|
244
|
-
}),
|
|
212
|
+
text: lib.sandbox.create[sandboxTypeKey].loading.fail(sandboxName),
|
|
245
213
|
});
|
|
246
214
|
handleSandboxCreateError(e, env, sandboxName, parentAccountId);
|
|
247
215
|
}
|
package/lib/commonOpts.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare function addTestingOptions(yargs: Argv): Argv;
|
|
|
13
13
|
export declare function addUseEnvironmentOptions(yargs: Argv): Argv;
|
|
14
14
|
export declare function addJSONOutputOptions(yargs: Argv): Argv;
|
|
15
15
|
export declare function addCustomHelpOutput(yargs: Argv, command: string | string[], describe?: string): Promise<void>;
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function setCLILogLevel(options: Arguments<{
|
|
17
17
|
debug?: boolean;
|
|
18
18
|
networkDebug?: boolean;
|
|
19
19
|
json?: boolean;
|
package/lib/commonOpts.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import yargsParser from 'yargs-parser';
|
|
3
|
-
import { LOG_LEVEL,
|
|
3
|
+
import { LOG_LEVEL, setLogLevel } from '@hubspot/local-dev-lib/logger';
|
|
4
|
+
import { uiLogger } from './ui/logger.js';
|
|
4
5
|
import { DEFAULT_CMS_PUBLISH_MODE, CMS_PUBLISH_MODE, } from '@hubspot/local-dev-lib/constants/files';
|
|
5
6
|
import { getAccountConfig, getAndLoadConfigIfNeeded, } from '@hubspot/local-dev-lib/config';
|
|
6
7
|
import { debugError } from './errorHandlers/index.js';
|
|
7
8
|
import { EXIT_CODES } from './enums/exitCodes.js';
|
|
8
9
|
import { uiCommandReference } from './ui/index.js';
|
|
9
|
-
import {
|
|
10
|
+
import { lib } from '../lang/en.js';
|
|
10
11
|
import { getTerminalUISupport, UI_COLORS } from './ui/index.js';
|
|
12
|
+
import SpinniesManager from './ui/SpinniesManager.js';
|
|
11
13
|
export function addGlobalOptions(yargs) {
|
|
12
14
|
yargs.version(false);
|
|
13
15
|
yargs.option('debug', {
|
|
14
16
|
alias: 'd',
|
|
15
17
|
default: false,
|
|
16
|
-
describe:
|
|
18
|
+
describe: lib.commonOpts.options.debug,
|
|
17
19
|
type: 'boolean',
|
|
18
20
|
});
|
|
19
21
|
yargs.option('network-debug', {
|
|
@@ -26,21 +28,21 @@ export function addGlobalOptions(yargs) {
|
|
|
26
28
|
export function addAccountOptions(yargs) {
|
|
27
29
|
return yargs.option('account', {
|
|
28
30
|
alias: 'a',
|
|
29
|
-
describe:
|
|
31
|
+
describe: lib.commonOpts.options.account,
|
|
30
32
|
type: 'string',
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
export function addConfigOptions(yargs) {
|
|
34
36
|
return yargs.option('config', {
|
|
35
37
|
alias: 'c',
|
|
36
|
-
describe:
|
|
38
|
+
describe: lib.commonOpts.options.config,
|
|
37
39
|
type: 'string',
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
export function addOverwriteOptions(yargs) {
|
|
41
43
|
return yargs.option('overwrite', {
|
|
42
44
|
alias: 'o',
|
|
43
|
-
describe:
|
|
45
|
+
describe: lib.commonOpts.options.overwrite,
|
|
44
46
|
type: 'boolean',
|
|
45
47
|
default: false,
|
|
46
48
|
});
|
|
@@ -49,13 +51,13 @@ export function addCmsPublishModeOptions(yargs, { read, write }) {
|
|
|
49
51
|
const cmsPublishModes = `<${Object.values(CMS_PUBLISH_MODE).join(' | ')}>`;
|
|
50
52
|
return yargs.option('cms-publish-mode', {
|
|
51
53
|
alias: 'm',
|
|
52
|
-
describe:
|
|
54
|
+
describe: lib.commonOpts.options.modes[read ? 'read' : write ? 'write' : 'default'](cmsPublishModes),
|
|
53
55
|
type: 'string',
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
58
|
export function addTestingOptions(yargs) {
|
|
57
59
|
return yargs.option('qa', {
|
|
58
|
-
describe:
|
|
60
|
+
describe: lib.commonOpts.options.qa,
|
|
59
61
|
type: 'boolean',
|
|
60
62
|
default: false,
|
|
61
63
|
hidden: true,
|
|
@@ -63,7 +65,7 @@ export function addTestingOptions(yargs) {
|
|
|
63
65
|
}
|
|
64
66
|
export function addUseEnvironmentOptions(yargs) {
|
|
65
67
|
yargs.option('use-env', {
|
|
66
|
-
describe:
|
|
68
|
+
describe: lib.commonOpts.options.useEnv,
|
|
67
69
|
type: 'boolean',
|
|
68
70
|
});
|
|
69
71
|
yargs.conflicts('use-env', 'account');
|
|
@@ -72,7 +74,7 @@ export function addUseEnvironmentOptions(yargs) {
|
|
|
72
74
|
export function addJSONOutputOptions(yargs) {
|
|
73
75
|
return yargs.option('json', {
|
|
74
76
|
alias: 'format-output-as-json',
|
|
75
|
-
describe:
|
|
77
|
+
describe: lib.commonOpts.options.jsonOutput,
|
|
76
78
|
type: 'boolean',
|
|
77
79
|
hidden: true,
|
|
78
80
|
});
|
|
@@ -80,27 +82,27 @@ export function addJSONOutputOptions(yargs) {
|
|
|
80
82
|
// Remove this once we've upgraded to yargs 18.0.0
|
|
81
83
|
function uiBetaTagWithColor(message) {
|
|
82
84
|
const terminalUISupport = getTerminalUISupport();
|
|
83
|
-
const tag =
|
|
85
|
+
const tag = lib.ui.betaTagWithStyle;
|
|
84
86
|
const result = `${terminalUISupport.color ? chalk.hex(UI_COLORS.SORBET)(tag) : tag} ${message}`;
|
|
85
87
|
return result;
|
|
86
88
|
}
|
|
87
89
|
// Remove this once we've upgraded to yargs 18.0.0
|
|
88
90
|
function uiDeprecatedTagWithColor(message) {
|
|
89
91
|
const terminalUISupport = getTerminalUISupport();
|
|
90
|
-
const tag =
|
|
92
|
+
const tag = lib.ui.deprecatedTagWithStyle;
|
|
91
93
|
const result = `${terminalUISupport.color ? chalk.yellow(tag) : tag} ${message}`;
|
|
92
94
|
return result;
|
|
93
95
|
}
|
|
94
96
|
export async function addCustomHelpOutput(yargs, command, describe) {
|
|
95
97
|
try {
|
|
96
98
|
// Remove this once we've upgraded to yargs 18.0.0
|
|
97
|
-
if (describe && describe.includes(
|
|
98
|
-
describe = describe.replace(
|
|
99
|
+
if (describe && describe.includes(lib.ui.betaTag)) {
|
|
100
|
+
describe = describe.replace(lib.ui.betaTag + ' ', '');
|
|
99
101
|
describe = uiBetaTagWithColor(describe);
|
|
100
102
|
}
|
|
101
103
|
// Remove this once we've upgraded to yargs 18.0.0
|
|
102
|
-
if (describe && describe.includes(
|
|
103
|
-
describe = describe.replace(
|
|
104
|
+
if (describe && describe.includes(lib.ui.deprecatedTag)) {
|
|
105
|
+
describe = describe.replace(lib.ui.deprecatedTag + ' ', '');
|
|
104
106
|
describe = uiDeprecatedTagWithColor(describe);
|
|
105
107
|
}
|
|
106
108
|
const parsedArgv = yargsParser(process.argv.slice(2));
|
|
@@ -132,7 +134,7 @@ export async function addCustomHelpOutput(yargs, command, describe) {
|
|
|
132
134
|
if (commandHelp.startsWith('\n')) {
|
|
133
135
|
commandHelp = commandHelp.slice(1);
|
|
134
136
|
}
|
|
135
|
-
|
|
137
|
+
uiLogger.log(`${uiCommandReference(fullCommand, false)}\n\n${describe ? `${describe}\n\n` : ''}${commandHelp}`);
|
|
136
138
|
process.exit(EXIT_CODES.SUCCESS);
|
|
137
139
|
}
|
|
138
140
|
}
|
|
@@ -141,20 +143,21 @@ export async function addCustomHelpOutput(yargs, command, describe) {
|
|
|
141
143
|
debugError(e);
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
|
-
export function
|
|
146
|
+
export function setCLILogLevel(options) {
|
|
145
147
|
const { debug, networkDebug, json } = options;
|
|
146
148
|
if (json) {
|
|
147
|
-
|
|
149
|
+
setLogLevel(LOG_LEVEL.ERROR);
|
|
150
|
+
SpinniesManager.setDisableOutput(true);
|
|
148
151
|
}
|
|
149
152
|
else if (debug) {
|
|
150
|
-
|
|
153
|
+
setLogLevel(LOG_LEVEL.DEBUG);
|
|
151
154
|
}
|
|
152
155
|
else {
|
|
153
|
-
|
|
156
|
+
setLogLevel(LOG_LEVEL.LOG);
|
|
154
157
|
}
|
|
155
158
|
if (networkDebug) {
|
|
156
159
|
process.env.HUBSPOT_NETWORK_LOGGING = 'true';
|
|
157
|
-
|
|
160
|
+
setLogLevel(LOG_LEVEL.DEBUG);
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
163
|
export function getCommandName(argv) {
|
package/lib/configMigrate.js
CHANGED
|
@@ -3,6 +3,37 @@ import { ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME } from '@hubspot/local-dev-lib/c
|
|
|
3
3
|
import { promptUser } from './prompts/promptUtils.js';
|
|
4
4
|
import { lib } from '../lang/en.js';
|
|
5
5
|
import { uiLogger } from './ui/logger.js';
|
|
6
|
+
async function promptRenameOrOmitAccount(accountName, accountId) {
|
|
7
|
+
const { shouldRename } = await promptUser({
|
|
8
|
+
name: 'shouldRename',
|
|
9
|
+
type: 'confirm',
|
|
10
|
+
message: lib.configMigrate.handleAccountNameConflicts.prompts.renameOrOmitAccountPrompt(accountName, accountId),
|
|
11
|
+
});
|
|
12
|
+
return shouldRename;
|
|
13
|
+
}
|
|
14
|
+
async function promptNewAccountName(account, globalConfig, renamedAccounts) {
|
|
15
|
+
const { newAccountName } = await promptUser({
|
|
16
|
+
name: 'newAccountName',
|
|
17
|
+
type: 'input',
|
|
18
|
+
default: `${account.name}_${account.portalId}`,
|
|
19
|
+
message: lib.configMigrate.handleAccountNameConflicts.prompts.newAccountNamePrompt(account.name, account.portalId),
|
|
20
|
+
validate: value => {
|
|
21
|
+
if (!value) {
|
|
22
|
+
return lib.configMigrate.handleAccountNameConflicts.errors.nameRequired;
|
|
23
|
+
}
|
|
24
|
+
if (value === account.name) {
|
|
25
|
+
return lib.configMigrate.handleAccountNameConflicts.errors.sameName;
|
|
26
|
+
}
|
|
27
|
+
const existingAccount = globalConfig.accounts.some(acc => acc.name === value);
|
|
28
|
+
const renamedAccount = renamedAccounts.some(acc => acc.name === value);
|
|
29
|
+
if (existingAccount || renamedAccount) {
|
|
30
|
+
return lib.configMigrate.handleAccountNameConflicts.errors.nameAlreadyInConfig(value);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return newAccountName;
|
|
36
|
+
}
|
|
6
37
|
export async function handleMigration(deprecatedConfigPath, hideWarning) {
|
|
7
38
|
if (!hideWarning) {
|
|
8
39
|
uiLogger.warn(lib.configMigrate.deprecatedConfigWarning(deprecatedConfigPath || getConfigPath(undefined, false)));
|
|
@@ -47,20 +78,67 @@ async function handleMergeConfigProperties(globalConfig, deprecatedConfig, force
|
|
|
47
78
|
}
|
|
48
79
|
return initialConfig;
|
|
49
80
|
}
|
|
81
|
+
async function handleAccountNameConflicts(globalConfig, deprecatedConfig, force) {
|
|
82
|
+
if (!deprecatedConfig.portals?.length || !globalConfig.accounts?.length) {
|
|
83
|
+
return deprecatedConfig;
|
|
84
|
+
}
|
|
85
|
+
const accountsWithConflictsToRemove = new Set();
|
|
86
|
+
const renamedAccounts = [];
|
|
87
|
+
const accountsNotYetInGlobal = deprecatedConfig.portals.filter(portal => portal.portalId &&
|
|
88
|
+
!globalConfig.accounts.some(acc => acc.accountId === portal.portalId));
|
|
89
|
+
const accountsWithConflicts = accountsNotYetInGlobal.filter(localAccount => globalConfig.accounts.some(globalAccount => globalAccount.name === localAccount.name));
|
|
90
|
+
if (accountsWithConflicts.length > 0) {
|
|
91
|
+
uiLogger.log('');
|
|
92
|
+
uiLogger.warn(lib.configMigrate.handleAccountNameConflicts.warnings.accountNameConflictMessage(accountsWithConflicts.length));
|
|
93
|
+
if (force) {
|
|
94
|
+
const renameDetails = [];
|
|
95
|
+
for (const account of accountsWithConflicts) {
|
|
96
|
+
accountsWithConflictsToRemove.add(account);
|
|
97
|
+
const newAccountName = `${account.name}_${account.portalId}`;
|
|
98
|
+
renamedAccounts.push({
|
|
99
|
+
...account,
|
|
100
|
+
name: newAccountName,
|
|
101
|
+
});
|
|
102
|
+
renameDetails.push(` "${account.name}" → "${newAccountName}" (ID: ${account.portalId})`);
|
|
103
|
+
}
|
|
104
|
+
uiLogger.warn(lib.configMigrate.handleAccountNameConflicts.warnings.forceFlagDetected(accountsWithConflicts.length, renameDetails.join('\n')));
|
|
105
|
+
uiLogger.log('');
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
for (const account of accountsWithConflicts) {
|
|
109
|
+
uiLogger.log('');
|
|
110
|
+
const shouldRename = await promptRenameOrOmitAccount(account.name, account.portalId);
|
|
111
|
+
accountsWithConflictsToRemove.add(account);
|
|
112
|
+
if (shouldRename) {
|
|
113
|
+
const newAccountName = await promptNewAccountName(account, globalConfig, renamedAccounts);
|
|
114
|
+
renamedAccounts.push({
|
|
115
|
+
...account,
|
|
116
|
+
name: newAccountName,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
deprecatedConfig.portals.push(...renamedAccounts);
|
|
122
|
+
}
|
|
123
|
+
const cleanedPortals = deprecatedConfig.portals.filter(portal => !accountsWithConflictsToRemove.has(portal));
|
|
124
|
+
return { ...deprecatedConfig, portals: cleanedPortals };
|
|
125
|
+
}
|
|
50
126
|
export async function handleMerge(deprecatedConfigPath, force, hideWarning) {
|
|
51
127
|
if (!hideWarning) {
|
|
52
128
|
uiLogger.warn(lib.configMigrate.deprecatedConfigWarning(deprecatedConfigPath || getConfigPath(undefined, false)));
|
|
53
129
|
uiLogger.log('');
|
|
54
130
|
}
|
|
55
131
|
uiLogger.log(lib.configMigrate.handleMerge.description(ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME));
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
132
|
+
if (!force) {
|
|
133
|
+
uiLogger.log('');
|
|
134
|
+
const { shouldMergeConfigs } = await promptUser({
|
|
135
|
+
name: 'shouldMergeConfigs',
|
|
136
|
+
type: 'confirm',
|
|
137
|
+
message: lib.configMigrate.handleMerge.confirmPrompt,
|
|
138
|
+
});
|
|
139
|
+
if (shouldMergeConfigs === false) {
|
|
140
|
+
return true; // exit with "true" so the user is shown a success message instead of an error
|
|
141
|
+
}
|
|
64
142
|
}
|
|
65
143
|
const deprecatedConfig = getDeprecatedConfig(deprecatedConfigPath);
|
|
66
144
|
const globalConfig = getGlobalConfig();
|
|
@@ -68,7 +146,8 @@ export async function handleMerge(deprecatedConfigPath, force, hideWarning) {
|
|
|
68
146
|
return true;
|
|
69
147
|
}
|
|
70
148
|
const mergedConfig = await handleMergeConfigProperties(globalConfig, deprecatedConfig, force);
|
|
71
|
-
const
|
|
149
|
+
const cleanedDeprecatedConfig = await handleAccountNameConflicts(mergedConfig, deprecatedConfig, force);
|
|
150
|
+
const { skippedAccountIds } = mergeExistingConfigs(mergedConfig, cleanedDeprecatedConfig);
|
|
72
151
|
if (skippedAccountIds.length > 0) {
|
|
73
152
|
uiLogger.log('');
|
|
74
153
|
uiLogger.log(lib.configMigrate.handleMerge.skippedExistingAccounts(skippedAccountIds));
|
package/lib/configOptions.js
CHANGED
|
@@ -79,6 +79,13 @@ async function enterTimeout() {
|
|
|
79
79
|
message: lib.configOptions.setHttpTimeout.promptMessage,
|
|
80
80
|
type: 'input',
|
|
81
81
|
default: 30000,
|
|
82
|
+
validate: (timeout) => {
|
|
83
|
+
const timeoutNum = parseInt(timeout, 10);
|
|
84
|
+
if (isNaN(timeoutNum) || timeoutNum < 3000) {
|
|
85
|
+
return lib.configOptions.setHttpTimeout.error(timeout);
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
},
|
|
82
89
|
},
|
|
83
90
|
]);
|
|
84
91
|
return timeout;
|
package/lib/constants.d.ts
CHANGED
|
@@ -76,28 +76,40 @@ export declare const APP_AUTH_TYPES: {
|
|
|
76
76
|
readonly STATIC: "static";
|
|
77
77
|
};
|
|
78
78
|
export declare const FEATURES: {
|
|
79
|
-
readonly UNIFIED_THEME_PREVIEW: "cms:react:unifiedThemePreview";
|
|
80
79
|
readonly UNIFIED_APPS: "Developers:UnifiedApps:PrivateBeta";
|
|
81
80
|
readonly SANDBOXES_V2: "sandboxes:v2:enabled";
|
|
82
81
|
readonly SANDBOXES_V2_CLI: "sandboxes:v2:cliEnabled";
|
|
83
82
|
readonly APP_EVENTS: "Developers:UnifiedApps:AppEventsAccess";
|
|
83
|
+
readonly APPS_HOME: "UIE:AppHome";
|
|
84
|
+
readonly MCP_ACCESS: "Developers:CLIMCPAccess";
|
|
85
|
+
readonly THEME_MIGRATION_2025_2: "Developers:ProjectThemeMigrations:2025.2";
|
|
86
|
+
readonly AGENT_TOOLS: "ThirdPartyAgentTools";
|
|
84
87
|
};
|
|
85
88
|
export declare const LOCAL_DEV_UI_MESSAGE_SEND_TYPES: {
|
|
86
89
|
UPLOAD_SUCCESS: string;
|
|
87
90
|
UPLOAD_FAILURE: string;
|
|
91
|
+
DEPLOY_SUCCESS: string;
|
|
92
|
+
DEPLOY_FAILURE: string;
|
|
88
93
|
UPDATE_PROJECT_NODES: string;
|
|
89
94
|
UPDATE_APP_DATA: string;
|
|
90
95
|
UPDATE_PROJECT_DATA: string;
|
|
91
96
|
UPDATE_UPLOAD_WARNINGS: string;
|
|
97
|
+
CLI_METADATA: string;
|
|
98
|
+
DEV_SERVERS_STARTED: string;
|
|
92
99
|
};
|
|
93
100
|
export declare const LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES: {
|
|
94
101
|
UPLOAD: string;
|
|
102
|
+
DEPLOY: string;
|
|
95
103
|
VIEWED_WELCOME_SCREEN: string;
|
|
104
|
+
APP_INSTALL_SUCCESS: string;
|
|
105
|
+
APP_INSTALL_INITIATED: string;
|
|
106
|
+
APP_INSTALL_FAILURE: string;
|
|
96
107
|
};
|
|
97
108
|
export declare const APP_INSTALLATION_STATES: {
|
|
98
109
|
readonly NOT_INSTALLED: "NOT_INSTALLED";
|
|
99
110
|
readonly INSTALLED: "INSTALLED";
|
|
100
111
|
readonly INSTALLED_WITH_OUTDATED_SCOPES: "INSTALLED_WITH_OUTDATED_SCOPES";
|
|
112
|
+
readonly UNKNOWN: "UNKNOWN";
|
|
101
113
|
};
|
|
102
114
|
export declare const staticAuth = "static";
|
|
103
115
|
export declare const oAuth = "oauth";
|
|
@@ -111,9 +123,18 @@ export declare const GET_STARTED_OPTIONS: {
|
|
|
111
123
|
export declare const LOCAL_DEV_SERVER_MESSAGE_TYPES: {
|
|
112
124
|
readonly INITIAL: "INITIAL";
|
|
113
125
|
readonly WEBSOCKET_SERVER_CONNECTED: "WEBSOCKET_SERVER_CONNECTED";
|
|
126
|
+
readonly STATIC_AUTH_APP_INSTALL_SUCCESS: "APP_INSTALL_SUCCESS";
|
|
127
|
+
readonly STATIC_AUTH_APP_INSTALL_FAILURE: "APP_INSTALL_FAILURE";
|
|
128
|
+
readonly OAUTH_APP_INSTALL_INITIATED: "APP_INSTALL_INITIATED";
|
|
114
129
|
};
|
|
115
130
|
export declare const CONFIG_LOCAL_STATE_FLAGS: {
|
|
116
131
|
readonly LOCAL_DEV_UI_WELCOME: "LOCAL_DEV_UI_WELCOME";
|
|
117
132
|
};
|
|
118
133
|
export declare const EMPTY_PROJECT = "empty";
|
|
119
134
|
export declare const PROJECT_WITH_APP = "app";
|
|
135
|
+
export declare const LEGACY_SERVERLESS_FILE = "serverless.json";
|
|
136
|
+
export declare const LEGACY_PUBLIC_APP_FILE = "public-app.json";
|
|
137
|
+
export declare const LEGACY_PRIVATE_APP_FILE = "app.json";
|
|
138
|
+
export declare const THEME_FILE = "theme.json";
|
|
139
|
+
export declare const CMS_ASSETS_FILE = "cms-assets.json";
|
|
140
|
+
export declare const LEGACY_CONFIG_FILES: string[];
|
package/lib/constants.js
CHANGED
|
@@ -68,28 +68,40 @@ export const APP_AUTH_TYPES = {
|
|
|
68
68
|
STATIC: 'static',
|
|
69
69
|
};
|
|
70
70
|
export const FEATURES = {
|
|
71
|
-
UNIFIED_THEME_PREVIEW: 'cms:react:unifiedThemePreview',
|
|
72
71
|
UNIFIED_APPS: 'Developers:UnifiedApps:PrivateBeta',
|
|
73
72
|
SANDBOXES_V2: 'sandboxes:v2:enabled',
|
|
74
73
|
SANDBOXES_V2_CLI: 'sandboxes:v2:cliEnabled',
|
|
75
74
|
APP_EVENTS: 'Developers:UnifiedApps:AppEventsAccess',
|
|
75
|
+
APPS_HOME: 'UIE:AppHome',
|
|
76
|
+
MCP_ACCESS: 'Developers:CLIMCPAccess',
|
|
77
|
+
THEME_MIGRATION_2025_2: 'Developers:ProjectThemeMigrations:2025.2',
|
|
78
|
+
AGENT_TOOLS: 'ThirdPartyAgentTools',
|
|
76
79
|
};
|
|
77
80
|
export const LOCAL_DEV_UI_MESSAGE_SEND_TYPES = {
|
|
78
81
|
UPLOAD_SUCCESS: 'server:uploadSuccess',
|
|
79
82
|
UPLOAD_FAILURE: 'server:uploadFailure',
|
|
83
|
+
DEPLOY_SUCCESS: 'server:deploySuccess',
|
|
84
|
+
DEPLOY_FAILURE: 'server:deployFailure',
|
|
80
85
|
UPDATE_PROJECT_NODES: 'server:updateProjectNodes',
|
|
81
86
|
UPDATE_APP_DATA: 'server:updateAppData',
|
|
82
87
|
UPDATE_PROJECT_DATA: 'server:updateProjectData',
|
|
83
88
|
UPDATE_UPLOAD_WARNINGS: 'server:updateUploadWarnings',
|
|
89
|
+
CLI_METADATA: 'server:cliMetadata',
|
|
90
|
+
DEV_SERVERS_STARTED: 'server:devServersStarted',
|
|
84
91
|
};
|
|
85
92
|
export const LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES = {
|
|
86
93
|
UPLOAD: 'client:upload',
|
|
94
|
+
DEPLOY: 'client:deploy',
|
|
87
95
|
VIEWED_WELCOME_SCREEN: 'client:viewedWelcomeScreen',
|
|
96
|
+
APP_INSTALL_SUCCESS: 'client:installSuccess',
|
|
97
|
+
APP_INSTALL_INITIATED: 'client:installInitiated',
|
|
98
|
+
APP_INSTALL_FAILURE: 'client:installFailure',
|
|
88
99
|
};
|
|
89
100
|
export const APP_INSTALLATION_STATES = {
|
|
90
101
|
NOT_INSTALLED: 'NOT_INSTALLED',
|
|
91
102
|
INSTALLED: 'INSTALLED',
|
|
92
103
|
INSTALLED_WITH_OUTDATED_SCOPES: 'INSTALLED_WITH_OUTDATED_SCOPES',
|
|
104
|
+
UNKNOWN: 'UNKNOWN',
|
|
93
105
|
};
|
|
94
106
|
export const staticAuth = 'static';
|
|
95
107
|
export const oAuth = 'oauth';
|
|
@@ -103,9 +115,22 @@ export const GET_STARTED_OPTIONS = {
|
|
|
103
115
|
export const LOCAL_DEV_SERVER_MESSAGE_TYPES = {
|
|
104
116
|
INITIAL: 'INITIAL',
|
|
105
117
|
WEBSOCKET_SERVER_CONNECTED: 'WEBSOCKET_SERVER_CONNECTED',
|
|
118
|
+
STATIC_AUTH_APP_INSTALL_SUCCESS: 'APP_INSTALL_SUCCESS',
|
|
119
|
+
STATIC_AUTH_APP_INSTALL_FAILURE: 'APP_INSTALL_FAILURE',
|
|
120
|
+
OAUTH_APP_INSTALL_INITIATED: 'APP_INSTALL_INITIATED',
|
|
106
121
|
};
|
|
107
122
|
export const CONFIG_LOCAL_STATE_FLAGS = {
|
|
108
123
|
LOCAL_DEV_UI_WELCOME: 'LOCAL_DEV_UI_WELCOME',
|
|
109
124
|
};
|
|
110
125
|
export const EMPTY_PROJECT = 'empty';
|
|
111
126
|
export const PROJECT_WITH_APP = 'app';
|
|
127
|
+
export const LEGACY_SERVERLESS_FILE = 'serverless.json';
|
|
128
|
+
export const LEGACY_PUBLIC_APP_FILE = 'public-app.json';
|
|
129
|
+
export const LEGACY_PRIVATE_APP_FILE = 'app.json';
|
|
130
|
+
export const THEME_FILE = 'theme.json';
|
|
131
|
+
export const CMS_ASSETS_FILE = 'cms-assets.json';
|
|
132
|
+
export const LEGACY_CONFIG_FILES = [
|
|
133
|
+
LEGACY_SERVERLESS_FILE,
|
|
134
|
+
LEGACY_PRIVATE_APP_FILE,
|
|
135
|
+
LEGACY_PUBLIC_APP_FILE,
|
|
136
|
+
];
|
|
@@ -2,10 +2,5 @@ export declare function installPackages({ packages, installLocations, }: {
|
|
|
2
2
|
packages?: string[];
|
|
3
3
|
installLocations?: string[];
|
|
4
4
|
}): Promise<void>;
|
|
5
|
-
export declare function installPackagesV2({ packages, installLocations, }: {
|
|
6
|
-
packages?: string[];
|
|
7
|
-
installLocations?: string[];
|
|
8
|
-
}): Promise<void>;
|
|
9
|
-
export declare function installPackagesInDirectoryV2(directory: string, packages?: string[]): Promise<void>;
|
|
10
5
|
export declare function getProjectPackageJsonLocations(dir?: string): Promise<string[]>;
|
|
11
6
|
export declare function hasMissingPackages(directory: string): Promise<boolean>;
|