@hubspot/cli 7.5.11-experimental.0 → 7.6.0-beta.1
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 +102 -95
- package/commands/account/auth.d.ts +5 -7
- package/commands/account/auth.js +74 -87
- package/commands/account/clean.d.ts +3 -7
- package/commands/account/clean.js +16 -9
- package/commands/account/createOverride.d.ts +3 -7
- package/commands/account/createOverride.js +23 -6
- package/commands/account/info.d.ts +3 -7
- package/commands/account/info.js +13 -5
- package/commands/account/list.d.ts +3 -7
- package/commands/account/list.js +15 -8
- package/commands/account/remove.d.ts +3 -7
- package/commands/account/remove.js +21 -9
- package/commands/account/removeOverride.d.ts +3 -7
- package/commands/account/removeOverride.js +23 -6
- package/commands/account/rename.d.ts +3 -7
- package/commands/account/rename.js +16 -9
- package/commands/account/use.d.ts +5 -9
- package/commands/account/use.js +14 -6
- package/commands/account.d.ts +3 -4
- package/commands/account.js +33 -58
- package/commands/app/migrate.d.ts +1 -2
- package/commands/app/migrate.js +7 -8
- package/commands/app/secret/add.d.ts +7 -0
- package/commands/app/secret/add.js +64 -0
- package/commands/app/secret/delete.d.ts +8 -0
- package/commands/app/secret/delete.js +87 -0
- package/commands/app/secret/list.d.ts +6 -0
- package/commands/app/secret/list.js +64 -0
- package/commands/app/secret/update.d.ts +7 -0
- package/commands/app/secret/update.js +77 -0
- package/commands/app/secret.d.ts +3 -0
- package/commands/app/secret.js +30 -0
- package/commands/app.d.ts +2 -5
- package/commands/app.js +10 -8
- package/commands/auth.d.ts +5 -7
- package/commands/auth.js +29 -28
- package/commands/cms/convertFields.d.ts +7 -1
- package/commands/cms/convertFields.js +57 -41
- package/commands/cms/getReactModule.d.ts +7 -1
- package/commands/cms/getReactModule.js +52 -34
- package/commands/cms/lighthouseScore.d.ts +8 -1
- package/commands/cms/lighthouseScore.js +129 -100
- package/commands/cms.d.ts +3 -1
- package/commands/cms.js +22 -15
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +23 -12
- package/commands/config/migrate.d.ts +3 -7
- package/commands/config/migrate.js +37 -46
- package/commands/config/set.d.ts +5 -6
- package/commands/config/set.js +38 -14
- package/commands/config.d.ts +3 -4
- package/commands/config.js +18 -44
- package/commands/create/api-sample.d.ts +3 -1
- package/commands/create/api-sample.js +34 -38
- package/commands/create/app.d.ts +3 -1
- package/commands/create/app.js +9 -7
- package/commands/create/function.d.ts +3 -1
- package/commands/create/function.js +11 -10
- package/commands/create/index.d.ts +5 -1
- package/commands/create/index.js +23 -11
- package/commands/create/module.d.ts +3 -1
- package/commands/create/module.js +14 -13
- package/commands/create/react-app.d.ts +3 -1
- package/commands/create/react-app.js +10 -7
- package/commands/create/template.d.ts +3 -1
- package/commands/create/template.js +14 -14
- package/commands/create/vue-app.d.ts +3 -1
- package/commands/create/vue-app.js +10 -7
- package/commands/create/webpack-serverless.d.ts +3 -1
- package/commands/create/webpack-serverless.js +10 -7
- package/commands/create/website-theme.d.ts +3 -1
- package/commands/create/website-theme.js +10 -9
- package/commands/create.d.ts +4 -24
- package/commands/create.js +62 -74
- package/commands/customObject/create.d.ts +4 -9
- package/commands/customObject/create.js +17 -10
- package/commands/customObject/schema/create.d.ts +4 -9
- package/commands/customObject/schema/create.js +18 -11
- package/commands/customObject/schema/delete.d.ts +4 -9
- package/commands/customObject/schema/delete.js +17 -10
- package/commands/customObject/schema/fetch-all.d.ts +4 -9
- package/commands/customObject/schema/fetch-all.js +17 -10
- package/commands/customObject/schema/fetch.d.ts +4 -9
- package/commands/customObject/schema/fetch.js +17 -10
- package/commands/customObject/schema/list.d.ts +4 -8
- package/commands/customObject/schema/list.js +17 -10
- package/commands/customObject/schema/update.d.ts +4 -9
- package/commands/customObject/schema/update.js +18 -11
- package/commands/customObject/schema.d.ts +3 -5
- package/commands/customObject/schema.js +27 -54
- package/commands/customObject.d.ts +3 -4
- package/commands/customObject.js +18 -45
- package/commands/doctor.d.ts +6 -8
- package/commands/doctor.js +30 -21
- package/commands/feedback.d.ts +4 -1
- package/commands/feedback.js +38 -47
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -33
- package/commands/filemanager/fetch.d.ts +4 -9
- package/commands/filemanager/fetch.js +18 -11
- package/commands/filemanager/upload.d.ts +4 -9
- package/commands/filemanager/upload.js +17 -11
- package/commands/filemanager.d.ts +3 -4
- package/commands/filemanager.js +18 -41
- package/commands/function/deploy.d.ts +6 -1
- package/commands/function/deploy.js +70 -50
- package/commands/function/list.d.ts +6 -1
- package/commands/function/list.js +44 -32
- package/commands/function/server.d.ts +10 -1
- package/commands/function/server.js +49 -38
- package/commands/function.d.ts +5 -1
- package/commands/function.js +22 -10
- package/commands/getStarted.d.ts +9 -0
- package/commands/getStarted.js +227 -0
- package/commands/hubdb/clear.d.ts +4 -9
- package/commands/hubdb/clear.js +17 -10
- package/commands/hubdb/create.d.ts +4 -9
- package/commands/hubdb/create.js +17 -10
- package/commands/hubdb/delete.d.ts +4 -9
- package/commands/hubdb/delete.js +17 -10
- package/commands/hubdb/fetch.d.ts +4 -9
- package/commands/hubdb/fetch.js +17 -10
- package/commands/hubdb/list.d.ts +4 -0
- package/commands/hubdb/list.js +83 -0
- package/commands/hubdb.d.ts +3 -2
- package/commands/hubdb.js +23 -45
- package/commands/init.d.ts +3 -7
- package/commands/init.js +17 -8
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +42 -43
- package/commands/list.d.ts +3 -7
- package/commands/list.js +17 -11
- package/commands/logs.d.ts +10 -1
- package/commands/logs.js +53 -44
- package/commands/mcp/setup.d.ts +7 -0
- package/commands/mcp/setup.js +52 -0
- package/commands/mcp/start.d.ts +3 -0
- package/commands/mcp/start.js +77 -0
- package/commands/mcp.d.ts +3 -0
- package/commands/mcp.js +26 -0
- package/commands/module/marketplace-validate.d.ts +6 -1
- package/commands/module/marketplace-validate.js +39 -29
- package/commands/module.d.ts +3 -1
- package/commands/module.js +23 -10
- package/commands/mv.d.ts +3 -7
- package/commands/mv.js +17 -11
- package/commands/open.d.ts +3 -7
- package/commands/open.js +17 -11
- package/commands/project/add.d.ts +5 -2
- package/commands/project/add.js +43 -80
- package/commands/project/cloneApp.d.ts +1 -1
- package/commands/project/cloneApp.js +2 -2
- package/commands/project/create.d.ts +2 -8
- package/commands/project/create.js +84 -55
- package/commands/project/deploy.d.ts +2 -0
- package/commands/project/deploy.js +67 -13
- package/commands/project/dev/deprecatedFlow.d.ts +8 -2
- package/commands/project/dev/deprecatedFlow.js +9 -1
- package/commands/project/dev/index.d.ts +1 -4
- package/commands/project/dev/index.js +88 -31
- package/commands/project/dev/unifiedFlow.d.ts +11 -2
- package/commands/project/dev/unifiedFlow.js +81 -41
- package/commands/project/listBuilds.js +2 -5
- package/commands/project/migrate.d.ts +1 -0
- package/commands/project/profile/add.d.ts +7 -0
- package/commands/project/profile/add.js +209 -0
- package/commands/project/profile/delete.d.ts +6 -0
- package/commands/project/profile/delete.js +123 -0
- package/commands/project/profile.d.ts +3 -0
- package/commands/project/profile.js +25 -0
- package/commands/project/upload.d.ts +1 -0
- package/commands/project/upload.js +22 -8
- package/commands/project/validate.d.ts +6 -0
- package/commands/project/validate.js +82 -0
- package/commands/project.js +4 -2
- package/commands/remove.d.ts +3 -7
- package/commands/remove.js +22 -22
- package/commands/sandbox/create.d.ts +4 -9
- package/commands/sandbox/create.js +18 -11
- package/commands/sandbox/delete.d.ts +4 -9
- package/commands/sandbox/delete.js +18 -11
- package/commands/sandbox.d.ts +3 -4
- package/commands/sandbox.js +18 -43
- package/commands/secret/addSecret.d.ts +4 -9
- package/commands/secret/addSecret.js +17 -10
- package/commands/secret/deleteSecret.d.ts +4 -9
- package/commands/secret/deleteSecret.js +17 -10
- package/commands/secret/listSecret.d.ts +4 -9
- package/commands/secret/listSecret.js +17 -10
- package/commands/secret/updateSecret.d.ts +4 -9
- package/commands/secret/updateSecret.js +17 -10
- package/commands/secret.d.ts +3 -4
- package/commands/secret.js +23 -48
- package/commands/testAccount/create.d.ts +6 -0
- package/commands/testAccount/create.js +100 -0
- package/commands/testAccount/createConfig.d.ts +10 -0
- package/commands/testAccount/createConfig.js +98 -0
- package/commands/testAccount/delete.d.ts +6 -0
- package/commands/testAccount/delete.js +48 -0
- package/commands/testAccount.d.ts +3 -0
- package/commands/testAccount.js +28 -0
- package/commands/theme/generate-selectors.d.ts +3 -7
- package/commands/theme/generate-selectors.js +20 -15
- package/commands/theme/marketplace-validate.d.ts +4 -9
- package/commands/theme/marketplace-validate.js +22 -17
- package/commands/theme/preview.d.ts +4 -9
- package/commands/theme/preview.js +32 -26
- package/commands/theme.d.ts +3 -4
- package/commands/theme.js +22 -47
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +116 -134
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +74 -75
- package/lang/en.d.ts +1135 -660
- package/lang/en.js +935 -471
- package/lang/en.lyaml +30 -213
- package/lib/accountTypes.js +1 -2
- package/lib/app/migrate.d.ts +23 -0
- package/lib/app/migrate.js +29 -6
- package/lib/app/migrate_legacy.js +7 -7
- package/lib/app/urls.d.ts +16 -0
- package/lib/app/urls.js +16 -0
- package/lib/commonOpts.d.ts +1 -3
- package/lib/commonOpts.js +1 -1
- package/lib/configMigrate.d.ts +2 -2
- package/lib/configMigrate.js +34 -55
- package/lib/configOptions.d.ts +4 -0
- package/lib/configOptions.js +41 -46
- package/lib/constants.d.ts +29 -0
- package/lib/constants.js +30 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +13 -39
- package/lib/doctor/Doctor.js +3 -2
- package/lib/errorHandlers/index.js +7 -0
- package/lib/filesystem.d.ts +1 -1
- package/lib/generateSelectors.js +3 -5
- package/lib/interpolation.d.ts +2 -3
- package/lib/lang.d.ts +2 -3
- package/lib/marketplaceValidate.d.ts +12 -2
- package/lib/marketplaceValidate.js +22 -29
- package/lib/mcp/setup.d.ts +21 -0
- package/lib/mcp/setup.js +218 -0
- package/lib/middleware/autoUpdateMiddleware.d.ts +1 -0
- package/lib/middleware/autoUpdateMiddleware.js +89 -0
- package/lib/middleware/configMiddleware.js +23 -0
- package/lib/middleware/fireAlarmMiddleware.d.ts +2 -2
- package/lib/middleware/fireAlarmMiddleware.js +5 -3
- package/lib/npm.d.ts +9 -0
- package/lib/npm.js +36 -0
- package/lib/projectProfiles.d.ts +7 -0
- package/lib/projectProfiles.js +83 -0
- package/lib/projects/add/legacyAddComponent.d.ts +5 -0
- package/lib/projects/add/legacyAddComponent.js +48 -0
- package/lib/projects/add/v3AddComponent.d.ts +8 -0
- package/lib/projects/add/v3AddComponent.js +85 -0
- package/lib/projects/buildAndDeploy.js +18 -3
- package/lib/projects/components.d.ts +2 -0
- package/lib/projects/components.js +82 -0
- package/lib/projects/create/index.d.ts +23 -0
- package/lib/projects/create/index.js +33 -0
- package/lib/projects/create/legacy.d.ts +6 -0
- package/lib/projects/{create.js → create/legacy.js} +20 -11
- package/lib/projects/create/v3.d.ts +27 -0
- package/lib/projects/create/v3.js +158 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +30 -0
- package/lib/projects/localDev/AppDevModeInterface.js +215 -0
- package/lib/projects/localDev/DevServerManagerV2.d.ts +11 -22
- package/lib/projects/localDev/DevServerManagerV2.js +19 -15
- package/lib/projects/localDev/LocalDevLogger.d.ts +30 -0
- package/lib/projects/localDev/LocalDevLogger.js +159 -0
- package/lib/projects/localDev/LocalDevManager.js +12 -5
- package/lib/projects/localDev/LocalDevProcess.d.ts +34 -0
- package/lib/projects/localDev/LocalDevProcess.js +201 -0
- package/lib/projects/localDev/LocalDevState.d.ts +50 -0
- package/lib/projects/localDev/LocalDevState.js +119 -0
- package/lib/projects/localDev/LocalDevWatcher.d.ts +10 -0
- package/lib/projects/localDev/LocalDevWatcher.js +53 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +20 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +131 -0
- package/lib/projects/localDev/helpers.d.ts +3 -2
- package/lib/projects/localDev/helpers.js +32 -2
- package/lib/projects/upload.d.ts +5 -1
- package/lib/projects/upload.js +60 -20
- package/lib/projects/urls.d.ts +3 -0
- package/lib/projects/urls.js +17 -1
- package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +17 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +96 -0
- package/lib/prompts/createProjectPrompt.d.ts +14 -5
- package/lib/prompts/createProjectPrompt.js +38 -13
- package/lib/prompts/createTemplatePrompt.d.ts +22 -4
- package/lib/prompts/installAppPrompt.d.ts +2 -0
- package/lib/prompts/installAppPrompt.js +45 -0
- package/lib/prompts/personalAccessKeyPrompt.js +35 -24
- package/lib/prompts/projectAddPrompt.d.ts +5 -1
- package/lib/prompts/projectAddPrompt.js +35 -7
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +6 -6
- package/lib/prompts/promptUtils.d.ts +4 -1
- package/lib/prompts/promptUtils.js +5 -1
- package/lib/prompts/selectAppPrompt.d.ts +2 -0
- package/lib/prompts/selectAppPrompt.js +40 -0
- package/lib/prompts/{selectPublicAppPrompt.d.ts → selectPublicAppForMigrationPrompt.d.ts} +1 -1
- package/lib/prompts/{selectPublicAppPrompt.js → selectPublicAppForMigrationPrompt.js} +8 -8
- package/lib/prompts/setAsDefaultAccountPrompt.js +10 -0
- package/lib/testUtils.d.ts +3 -3
- package/lib/testUtils.js +8 -9
- package/lib/ui/index.js +4 -1
- package/lib/upload.d.ts +1 -1
- package/lib/validation.js +4 -5
- package/lib/yargsUtils.d.ts +4 -0
- package/lib/yargsUtils.js +6 -0
- package/mcp-server/server.d.ts +1 -0
- package/mcp-server/server.js +18 -0
- package/mcp-server/tools/index.d.ts +2 -0
- package/mcp-server/tools/index.js +19 -0
- package/mcp-server/tools/project/AddFeatureToProject.d.ts +29 -0
- package/mcp-server/tools/project/AddFeatureToProject.js +85 -0
- package/mcp-server/tools/project/CreateProjectTool.d.ts +35 -0
- package/mcp-server/tools/project/CreateProjectTool.js +104 -0
- package/mcp-server/tools/project/DeployProject.d.ts +20 -0
- package/mcp-server/tools/project/DeployProject.js +50 -0
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +17 -0
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +58 -0
- package/mcp-server/tools/project/UploadProjectTools.d.ts +17 -0
- package/mcp-server/tools/project/UploadProjectTools.js +35 -0
- package/mcp-server/tools/project/ValidateProjectTool.d.ts +17 -0
- package/mcp-server/tools/project/ValidateProjectTool.js +35 -0
- package/mcp-server/tools/project/constants.d.ts +3 -0
- package/mcp-server/tools/project/constants.js +13 -0
- package/mcp-server/types.d.ts +14 -0
- package/mcp-server/types.js +17 -0
- package/mcp-server/utils/command.d.ts +3 -0
- package/mcp-server/utils/command.js +16 -0
- package/mcp-server/utils/content.d.ts +3 -0
- package/mcp-server/utils/content.js +21 -0
- package/mcp-server/utils/project.d.ts +5 -0
- package/mcp-server/utils/project.js +17 -0
- package/package.json +24 -16
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +35 -0
- package/types/LocalDev.js +2 -0
- package/types/Projects.d.ts +19 -2
- package/types/Prompts.d.ts +0 -7
- package/types/Yargs.d.ts +10 -1
- package/lib/projects/create.d.ts +0 -5
- package/lib/projects/localDev/LocalDevManagerV2.d.ts +0 -64
- package/lib/projects/localDev/LocalDevManagerV2.js +0 -345
- package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
- package/lib/prompts/installPublicAppPrompt.js +0 -41
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.unifiedProjectDevFlow = unifiedProjectDevFlow;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const util_1 = __importDefault(require("util"));
|
|
9
|
-
const
|
|
9
|
+
const config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
10
10
|
const errors_1 = require("@hubspot/project-parsing-lib/src/lib/errors");
|
|
11
11
|
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
12
|
-
const
|
|
12
|
+
const config_2 = require("@hubspot/local-dev-lib/config");
|
|
13
13
|
const environment_1 = require("@hubspot/local-dev-lib/environment");
|
|
14
14
|
const errorHandlers_1 = require("../../../lib/errorHandlers");
|
|
15
15
|
const exitCodes_1 = require("../../../lib/enums/exitCodes");
|
|
@@ -17,15 +17,16 @@ const ensureProjectExists_1 = require("../../../lib/projects/ensureProjectExists
|
|
|
17
17
|
const helpers_1 = require("../../../lib/projects/localDev/helpers");
|
|
18
18
|
const projectDevTargetAccountPrompt_1 = require("../../../lib/prompts/projectDevTargetAccountPrompt");
|
|
19
19
|
const SpinniesManager_1 = __importDefault(require("../../../lib/ui/SpinniesManager"));
|
|
20
|
-
const
|
|
20
|
+
const LocalDevProcess_1 = __importDefault(require("../../../lib/projects/localDev/LocalDevProcess"));
|
|
21
|
+
const LocalDevWatcher_1 = __importDefault(require("../../../lib/projects/localDev/LocalDevWatcher"));
|
|
21
22
|
const process_1 = require("../../../lib/process");
|
|
22
23
|
const accountTypes_1 = require("../../../lib/accountTypes");
|
|
23
24
|
const ui_1 = require("../../../lib/ui");
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const env = (0, environment_1.getValidEnv)((0,
|
|
25
|
+
const logger_1 = require("../../../lib/ui/logger");
|
|
26
|
+
const en_1 = require("../../../lang/en");
|
|
27
|
+
const LocalDevWebsocketServer_1 = __importDefault(require("../../../lib/projects/localDev/LocalDevWebsocketServer"));
|
|
28
|
+
async function unifiedProjectDevFlow({ args, targetProjectAccountId, providedTargetTestingAccountId, projectConfig, projectDir, profileConfig, }) {
|
|
29
|
+
const env = (0, environment_1.getValidEnv)((0, config_2.getEnv)(targetProjectAccountId));
|
|
29
30
|
let projectNodes;
|
|
30
31
|
// Get IR
|
|
31
32
|
try {
|
|
@@ -33,49 +34,69 @@ async function unifiedProjectDevFlow(args, accountConfig, projectConfig, project
|
|
|
33
34
|
projectSourceDir: path_1.default.join(projectDir, projectConfig.srcDir),
|
|
34
35
|
platformVersion: projectConfig.platformVersion,
|
|
35
36
|
accountId: targetProjectAccountId,
|
|
36
|
-
});
|
|
37
|
+
}, { profile: args.profile });
|
|
37
38
|
projectNodes = intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
38
|
-
logger_1.
|
|
39
|
+
logger_1.uiLogger.debug(util_1.default.inspect(projectNodes, false, null, true));
|
|
39
40
|
}
|
|
40
41
|
catch (e) {
|
|
41
42
|
if ((0, errors_1.isTranslationError)(e)) {
|
|
42
|
-
logger_1.
|
|
43
|
+
logger_1.uiLogger.error(e.toString());
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
(0, errorHandlers_1.logError)(e);
|
|
46
47
|
}
|
|
47
48
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
48
49
|
}
|
|
49
|
-
// @TODO Do we need to do more than this or leave it to the dev servers?
|
|
50
50
|
if (!Object.keys(projectNodes).length) {
|
|
51
|
-
logger_1.
|
|
52
|
-
projectDir,
|
|
53
|
-
command: (0, ui_1.uiCommandReference)('hs project add'),
|
|
54
|
-
}));
|
|
51
|
+
logger_1.uiLogger.error(en_1.commands.project.dev.errors.noRunnableComponents);
|
|
55
52
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
56
53
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const derivedAccountIsRecommendedType = (0, accountTypes_1.isAppDeveloperAccount)(accountConfig) || (0, accountTypes_1.isStandardAccount)(accountConfig);
|
|
62
|
-
if (!derivedAccountIsRecommendedType) {
|
|
63
|
-
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.dev.errors.invalidUnifiedAppsAccount`), {
|
|
64
|
-
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
65
|
-
});
|
|
66
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
54
|
+
const targetProjectAccountConfig = (0, config_2.getAccountConfig)(targetProjectAccountId);
|
|
55
|
+
if (!targetProjectAccountConfig) {
|
|
56
|
+
logger_1.uiLogger.error(en_1.commands.project.dev.errors.noAccount(targetProjectAccountId));
|
|
57
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
67
58
|
}
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// Walk the user through adding the account's PAK to the config
|
|
74
|
-
await (0, helpers_1.useExistingDevTestAccount)(env, devAccountPromptResponse.notInConfigAccount);
|
|
59
|
+
const accounts = (0, config_2.getConfigAccounts)();
|
|
60
|
+
const accountIsCombined = await (0, accountTypes_1.isUnifiedAccount)(targetProjectAccountConfig);
|
|
61
|
+
if (!accountIsCombined && !profileConfig) {
|
|
62
|
+
logger_1.uiLogger.error(en_1.commands.project.dev.errors.accountNotCombined);
|
|
63
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
75
64
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
let targetTestingAccountId = providedTargetTestingAccountId;
|
|
66
|
+
if (profileConfig) {
|
|
67
|
+
// Bypass the prompt for the testing account if the user has a profile configured
|
|
68
|
+
targetTestingAccountId = profileConfig.accountId;
|
|
69
|
+
}
|
|
70
|
+
else if (!targetTestingAccountId) {
|
|
71
|
+
logger_1.uiLogger.log('');
|
|
72
|
+
(0, ui_1.uiLine)();
|
|
73
|
+
logger_1.uiLogger.log(en_1.commands.project.dev.logs.accountTypeInformation);
|
|
74
|
+
logger_1.uiLogger.log(en_1.commands.project.dev.logs.learnMoreMessage);
|
|
75
|
+
(0, ui_1.uiLine)();
|
|
76
|
+
logger_1.uiLogger.log('');
|
|
77
|
+
const accountType = await (0, helpers_1.selectAccountTypePrompt)(targetProjectAccountConfig);
|
|
78
|
+
if (accountType === config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST) {
|
|
79
|
+
const devAccountPromptResponse = await (0, projectDevTargetAccountPrompt_1.selectDeveloperTestTargetAccountPrompt)(accounts, targetProjectAccountConfig);
|
|
80
|
+
targetTestingAccountId =
|
|
81
|
+
devAccountPromptResponse.targetAccountId || undefined;
|
|
82
|
+
if (!!devAccountPromptResponse.notInConfigAccount) {
|
|
83
|
+
// When the developer test account isn't configured in the CLI config yet
|
|
84
|
+
// Walk the user through adding the account's PAK to the config
|
|
85
|
+
await (0, helpers_1.useExistingDevTestAccount)(env, devAccountPromptResponse.notInConfigAccount);
|
|
86
|
+
}
|
|
87
|
+
else if (devAccountPromptResponse.createNestedAccount) {
|
|
88
|
+
// Create a new developer test account and automatically add it to the CLI config
|
|
89
|
+
targetTestingAccountId = await (0, helpers_1.createDeveloperTestAccountForLocalDev)(targetProjectAccountId, targetProjectAccountConfig, env);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (accountType === config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
|
|
93
|
+
const sandboxAccountPromptResponse = await (0, projectDevTargetAccountPrompt_1.selectSandboxTargetAccountPrompt)(accounts, targetProjectAccountConfig);
|
|
94
|
+
targetTestingAccountId =
|
|
95
|
+
sandboxAccountPromptResponse.targetAccountId || undefined;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
targetTestingAccountId = targetProjectAccountId;
|
|
99
|
+
}
|
|
79
100
|
}
|
|
80
101
|
// Check if project exists in HubSpot
|
|
81
102
|
const { projectExists, project: uploadedProject } = await (0, ensureProjectExists_1.ensureProjectExists)(targetProjectAccountId, projectConfig.name, {
|
|
@@ -92,10 +113,11 @@ async function unifiedProjectDevFlow(args, accountConfig, projectConfig, project
|
|
|
92
113
|
}
|
|
93
114
|
else {
|
|
94
115
|
project = await (0, helpers_1.createNewProjectForLocalDev)(projectConfig, targetProjectAccountId, false, false);
|
|
95
|
-
deployedBuild = await (0, helpers_1.createInitialBuildForNewProject)(projectConfig, projectDir, targetProjectAccountId, true);
|
|
116
|
+
deployedBuild = await (0, helpers_1.createInitialBuildForNewProject)(projectConfig, projectDir, targetProjectAccountId, true, args.profile);
|
|
96
117
|
}
|
|
97
|
-
|
|
98
|
-
|
|
118
|
+
// End setup, start local dev process
|
|
119
|
+
const localDevProcess = new LocalDevProcess_1.default({
|
|
120
|
+
initialProjectNodes: projectNodes,
|
|
99
121
|
debug: args.debug,
|
|
100
122
|
deployedBuild,
|
|
101
123
|
isGithubLinked,
|
|
@@ -103,9 +125,27 @@ async function unifiedProjectDevFlow(args, accountConfig, projectConfig, project
|
|
|
103
125
|
targetTestingAccountId: targetTestingAccountId,
|
|
104
126
|
projectConfig,
|
|
105
127
|
projectDir,
|
|
128
|
+
projectName: project.name,
|
|
106
129
|
projectId: project.id,
|
|
107
130
|
env,
|
|
108
131
|
});
|
|
109
|
-
await
|
|
110
|
-
|
|
132
|
+
await localDevProcess.start();
|
|
133
|
+
const watcher = new LocalDevWatcher_1.default(localDevProcess);
|
|
134
|
+
watcher.start();
|
|
135
|
+
const websocketServer = new LocalDevWebsocketServer_1.default(localDevProcess, args.debug);
|
|
136
|
+
await websocketServer.start();
|
|
137
|
+
(0, process_1.handleKeypress)(async (key) => {
|
|
138
|
+
if ((key.ctrl && key.name === 'c') || key.name === 'q') {
|
|
139
|
+
await Promise.all([
|
|
140
|
+
localDevProcess.stop(),
|
|
141
|
+
watcher.stop(),
|
|
142
|
+
websocketServer.shutdown(),
|
|
143
|
+
]);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
(0, process_1.handleExit)(({ isSIGHUP }) => {
|
|
147
|
+
localDevProcess.stop(!isSIGHUP);
|
|
148
|
+
watcher.stop();
|
|
149
|
+
websocketServer.shutdown();
|
|
150
|
+
});
|
|
111
151
|
}
|
|
@@ -17,6 +17,7 @@ const lang_1 = require("../../lib/lang");
|
|
|
17
17
|
const index_2 = require("../../lib/errorHandlers/index");
|
|
18
18
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
19
19
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
20
|
+
const en_1 = require("../../lang/en");
|
|
20
21
|
const command = 'list-builds';
|
|
21
22
|
const describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`commands.project.subcommands.listBuilds.describe`), false);
|
|
22
23
|
async function fetchAndDisplayBuilds(accountId, project, options) {
|
|
@@ -29,11 +30,7 @@ async function fetchAndDisplayBuilds(accountId, project, options) {
|
|
|
29
30
|
}));
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
32
|
-
logger_1.logger.log((0,
|
|
33
|
-
count: results.length,
|
|
34
|
-
projectName: project.name,
|
|
35
|
-
viewBuildsLink: (0, ui_1.uiLink)((0, lang_1.i18n)(`commands.project.subcommands.listBuilds.logs.viewAllBuildsLink`), (0, urls_1.getProjectDetailUrl)(project.name, accountId)),
|
|
36
|
-
}));
|
|
33
|
+
logger_1.logger.log(en_1.commands.project.listBuilds.showingRecentBuilds(results.length, project.name, (0, ui_1.uiLink)(en_1.commands.project.listBuilds.viewAllBuildsLink, (0, urls_1.getProjectDetailUrl)(project.name, accountId))));
|
|
37
34
|
}
|
|
38
35
|
if (results.length === 0) {
|
|
39
36
|
logger_1.logger.log((0, lang_1.i18n)(`commands.project.subcommands.listBuilds.errors.noBuilds`));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs, YargsCommandModule } from '../../types/Yargs';
|
|
2
2
|
export type ProjectMigrateArgs = CommonArgs & AccountArgs & EnvironmentArgs & ConfigArgs & {
|
|
3
3
|
platformVersion: string;
|
|
4
|
+
unstable: boolean;
|
|
4
5
|
};
|
|
5
6
|
declare const migrateCommand: YargsCommandModule<unknown, ProjectMigrateArgs>;
|
|
6
7
|
export default migrateCommand;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { YargsCommandModule, CommonArgs } from '../../../types/Yargs';
|
|
2
|
+
type ProjectProfileAddArgs = CommonArgs & {
|
|
3
|
+
name?: string;
|
|
4
|
+
targetAccount?: number;
|
|
5
|
+
};
|
|
6
|
+
declare const projectProfileAddCommand: YargsCommandModule<unknown, ProjectProfileAddArgs>;
|
|
7
|
+
export default projectProfileAddCommand;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
9
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
10
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
11
|
+
const usageTracking_1 = require("../../../lib/usageTracking");
|
|
12
|
+
const config_2 = require("../../../lib/projects/config");
|
|
13
|
+
const ui_1 = require("../../../lib/ui");
|
|
14
|
+
const logger_1 = require("../../../lib/ui/logger");
|
|
15
|
+
const exitCodes_1 = require("../../../lib/enums/exitCodes");
|
|
16
|
+
const yargsUtils_1 = require("../../../lib/yargsUtils");
|
|
17
|
+
const en_1 = require("../../../lang/en");
|
|
18
|
+
const promptUtils_1 = require("../../../lib/prompts/promptUtils");
|
|
19
|
+
const validation_1 = require("../../../lib/validation");
|
|
20
|
+
const errorHandlers_1 = require("../../../lib/errorHandlers");
|
|
21
|
+
const command = 'add [name]';
|
|
22
|
+
const describe = (0, ui_1.uiBetaTag)(en_1.commands.project.profile.add.describe, false);
|
|
23
|
+
const verboseDescribe = (0, ui_1.uiBetaTag)(en_1.commands.project.profile.add.verboseDescribe, false);
|
|
24
|
+
async function selectProfileToCopyVariablesFrom(existingProfiles) {
|
|
25
|
+
let profileToCopyVariablesFrom;
|
|
26
|
+
if (existingProfiles.length == 1) {
|
|
27
|
+
logger_1.uiLogger.log('');
|
|
28
|
+
logger_1.uiLogger.log(en_1.commands.project.profile.add.logs.copyExistingProfile((0, project_parsing_lib_1.getHsProfileFilename)(existingProfiles[0])));
|
|
29
|
+
const shouldCopyVariables = await (0, promptUtils_1.confirmPrompt)('Copy profile variables?', {
|
|
30
|
+
defaultAnswer: true,
|
|
31
|
+
});
|
|
32
|
+
if (shouldCopyVariables) {
|
|
33
|
+
profileToCopyVariablesFrom = existingProfiles[0];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if (existingProfiles.length > 1) {
|
|
37
|
+
logger_1.uiLogger.log('');
|
|
38
|
+
logger_1.uiLogger.log(en_1.commands.project.profile.add.logs.copyExistingProfiles);
|
|
39
|
+
const emptyChoice = {
|
|
40
|
+
name: en_1.commands.project.profile.add.prompts.copyExistingProfilePromptEmpty,
|
|
41
|
+
value: undefined,
|
|
42
|
+
};
|
|
43
|
+
const promptResponse = await (0, promptUtils_1.listPrompt)(en_1.commands.project.profile.add.prompts.copyExistingProfilePrompt, {
|
|
44
|
+
choices: [
|
|
45
|
+
...existingProfiles.map(profile => ({
|
|
46
|
+
name: (0, project_parsing_lib_1.getHsProfileFilename)(profile),
|
|
47
|
+
value: profile,
|
|
48
|
+
})),
|
|
49
|
+
emptyChoice,
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
if (promptResponse) {
|
|
53
|
+
profileToCopyVariablesFrom = promptResponse;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return profileToCopyVariablesFrom;
|
|
57
|
+
}
|
|
58
|
+
async function handler(args) {
|
|
59
|
+
const { derivedAccountId } = args;
|
|
60
|
+
(0, usageTracking_1.trackCommandUsage)('project-profile-add', undefined, derivedAccountId);
|
|
61
|
+
const { projectConfig, projectDir } = await (0, config_2.getProjectConfig)();
|
|
62
|
+
if (!projectConfig || !projectDir) {
|
|
63
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.add.errors.noProjectConfig);
|
|
64
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
65
|
+
}
|
|
66
|
+
const projectSourceDir = path_1.default.join(projectDir, projectConfig.srcDir);
|
|
67
|
+
let profileName = args.name;
|
|
68
|
+
let targetAccountId = args.targetAccount;
|
|
69
|
+
function checkIfProfileExists(profileName) {
|
|
70
|
+
return (0, validation_1.fileExists)(path_1.default.join(projectSourceDir, (0, project_parsing_lib_1.getHsProfileFilename)(profileName)));
|
|
71
|
+
}
|
|
72
|
+
function isValidProfileName(profileName) {
|
|
73
|
+
const trimmedProfileName = profileName.trim();
|
|
74
|
+
if (trimmedProfileName === '') {
|
|
75
|
+
return en_1.commands.project.profile.add.prompts.emptyName;
|
|
76
|
+
}
|
|
77
|
+
if (!/^[a-zA-Z0-9]+$/.test(trimmedProfileName)) {
|
|
78
|
+
return en_1.commands.project.profile.add.prompts.invalidProfileName;
|
|
79
|
+
}
|
|
80
|
+
if (checkIfProfileExists(trimmedProfileName)) {
|
|
81
|
+
return en_1.commands.project.profile.add.errors.profileExists(trimmedProfileName);
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (profileName) {
|
|
86
|
+
if (checkIfProfileExists(profileName)) {
|
|
87
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.add.errors.profileExists((0, project_parsing_lib_1.getHsProfileFilename)(profileName)));
|
|
88
|
+
logger_1.uiLogger.log('');
|
|
89
|
+
profileName = undefined;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const validationResult = isValidProfileName(profileName);
|
|
93
|
+
if (validationResult !== true) {
|
|
94
|
+
logger_1.uiLogger.error(validationResult);
|
|
95
|
+
logger_1.uiLogger.log('');
|
|
96
|
+
profileName = undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!profileName) {
|
|
101
|
+
const promptResponse = await (0, promptUtils_1.promptUser)({
|
|
102
|
+
type: 'input',
|
|
103
|
+
name: 'name',
|
|
104
|
+
message: en_1.commands.project.profile.add.prompts.namePrompt,
|
|
105
|
+
validate: isValidProfileName,
|
|
106
|
+
});
|
|
107
|
+
profileName = promptResponse.name;
|
|
108
|
+
}
|
|
109
|
+
if (targetAccountId) {
|
|
110
|
+
const accountId = (0, config_1.getAccountId)(targetAccountId);
|
|
111
|
+
if (accountId) {
|
|
112
|
+
targetAccountId = accountId;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.add.errors.invalidTargetAccount);
|
|
116
|
+
logger_1.uiLogger.log('');
|
|
117
|
+
targetAccountId = undefined;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (!targetAccountId) {
|
|
121
|
+
const configuredAccounts = (0, config_1.getConfigAccounts)();
|
|
122
|
+
if (!configuredAccounts || !configuredAccounts.length) {
|
|
123
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.add.errors.noAccountsConfigured);
|
|
124
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
125
|
+
}
|
|
126
|
+
const promptResponse = await (0, promptUtils_1.listPrompt)(en_1.commands.project.profile.add.prompts.targetAccountPrompt, {
|
|
127
|
+
choices: configuredAccounts.map(account => {
|
|
128
|
+
const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(account);
|
|
129
|
+
return {
|
|
130
|
+
name: (0, ui_1.uiAccountDescription)(accountId),
|
|
131
|
+
value: accountId,
|
|
132
|
+
};
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
if (promptResponse) {
|
|
136
|
+
targetAccountId = promptResponse;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const existingProfiles = await (0, project_parsing_lib_1.getAllHsProfiles)(projectSourceDir);
|
|
140
|
+
let existingTargetAccountIdSelected = false;
|
|
141
|
+
for (const profile of existingProfiles) {
|
|
142
|
+
try {
|
|
143
|
+
const loadedProfile = (0, project_parsing_lib_1.loadHsProfileFile)(projectSourceDir, profile);
|
|
144
|
+
if (loadedProfile?.accountId === targetAccountId) {
|
|
145
|
+
existingTargetAccountIdSelected = true;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
// Skip profiles that can't be loaded
|
|
151
|
+
(0, errorHandlers_1.debugError)(err);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (existingTargetAccountIdSelected) {
|
|
155
|
+
logger_1.uiLogger.log('');
|
|
156
|
+
logger_1.uiLogger.warn(en_1.commands.project.profile.add.warnings.duplicateTargetAccount(targetAccountId));
|
|
157
|
+
}
|
|
158
|
+
const profileFileContent = {
|
|
159
|
+
accountId: targetAccountId,
|
|
160
|
+
variables: {},
|
|
161
|
+
};
|
|
162
|
+
const profileToCopyVariablesFrom = await selectProfileToCopyVariablesFrom(existingProfiles);
|
|
163
|
+
if (profileToCopyVariablesFrom) {
|
|
164
|
+
try {
|
|
165
|
+
const profileToCopyFileContent = (0, project_parsing_lib_1.loadHsProfileFile)(projectSourceDir, profileToCopyVariablesFrom);
|
|
166
|
+
if (profileToCopyFileContent?.variables) {
|
|
167
|
+
profileFileContent.variables = profileToCopyFileContent.variables;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.add.errors.failedToLoadProfile(profileToCopyVariablesFrom));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const profileFilename = (0, project_parsing_lib_1.getHsProfileFilename)(profileName);
|
|
175
|
+
try {
|
|
176
|
+
fs_1.default.writeFileSync(path_1.default.join(projectSourceDir, profileFilename), JSON.stringify(profileFileContent, null, 2), 'utf8');
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.add.errors.failedToCreateProfile);
|
|
180
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
181
|
+
}
|
|
182
|
+
logger_1.uiLogger.log('');
|
|
183
|
+
logger_1.uiLogger.log(en_1.commands.project.profile.add.logs.profileAdded(profileFilename));
|
|
184
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
185
|
+
}
|
|
186
|
+
function projectProfileAddBuilder(yargs) {
|
|
187
|
+
yargs.positional('name', {
|
|
188
|
+
describe: en_1.commands.project.profile.add.positionals.name,
|
|
189
|
+
type: 'string',
|
|
190
|
+
});
|
|
191
|
+
yargs.option('target-account', {
|
|
192
|
+
describe: en_1.commands.project.profile.add.options.targetAccount,
|
|
193
|
+
type: 'number',
|
|
194
|
+
});
|
|
195
|
+
yargs.example([
|
|
196
|
+
['$0 project profile add qa', en_1.commands.project.profile.add.example],
|
|
197
|
+
]);
|
|
198
|
+
return yargs;
|
|
199
|
+
}
|
|
200
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(projectProfileAddBuilder, command, verboseDescribe, {
|
|
201
|
+
useGlobalOptions: true,
|
|
202
|
+
});
|
|
203
|
+
const projectProfileAddCommand = {
|
|
204
|
+
command,
|
|
205
|
+
describe,
|
|
206
|
+
handler,
|
|
207
|
+
builder,
|
|
208
|
+
};
|
|
209
|
+
exports.default = projectProfileAddCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { YargsCommandModule, CommonArgs } from '../../../types/Yargs';
|
|
2
|
+
type ProjectProfileDeleteArgs = CommonArgs & {
|
|
3
|
+
name?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const projectProfileDeleteCommand: YargsCommandModule<unknown, ProjectProfileDeleteArgs>;
|
|
6
|
+
export default projectProfileDeleteCommand;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
9
|
+
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
10
|
+
const projects_2 = require("@hubspot/local-dev-lib/api/projects");
|
|
11
|
+
const usageTracking_1 = require("../../../lib/usageTracking");
|
|
12
|
+
const config_1 = require("../../../lib/projects/config");
|
|
13
|
+
const ui_1 = require("../../../lib/ui");
|
|
14
|
+
const logger_1 = require("../../../lib/ui/logger");
|
|
15
|
+
const exitCodes_1 = require("../../../lib/enums/exitCodes");
|
|
16
|
+
const yargsUtils_1 = require("../../../lib/yargsUtils");
|
|
17
|
+
const en_1 = require("../../../lang/en");
|
|
18
|
+
const promptUtils_1 = require("../../../lib/prompts/promptUtils");
|
|
19
|
+
const validation_1 = require("../../../lib/validation");
|
|
20
|
+
const errorHandlers_1 = require("../../../lib/errorHandlers");
|
|
21
|
+
const command = 'delete [name]';
|
|
22
|
+
const describe = (0, ui_1.uiBetaTag)(en_1.commands.project.profile.delete.describe, false);
|
|
23
|
+
async function handler(args) {
|
|
24
|
+
const { derivedAccountId } = args;
|
|
25
|
+
(0, usageTracking_1.trackCommandUsage)('project-profile-delete', undefined, derivedAccountId);
|
|
26
|
+
const { projectConfig, projectDir } = await (0, config_1.getProjectConfig)();
|
|
27
|
+
if (!projectConfig || !projectDir) {
|
|
28
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.delete.errors.noProjectConfig);
|
|
29
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
|
+
}
|
|
31
|
+
const projectSourceDir = path_1.default.join(projectDir, projectConfig.srcDir);
|
|
32
|
+
let profileName = undefined;
|
|
33
|
+
if (args.name) {
|
|
34
|
+
profileName = args.name;
|
|
35
|
+
const profileFilename = (0, project_parsing_lib_1.getHsProfileFilename)(profileName);
|
|
36
|
+
if (!(0, validation_1.fileExists)(path_1.default.join(projectSourceDir, profileFilename))) {
|
|
37
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.delete.errors.noProfileFound(profileFilename));
|
|
38
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const existingProfiles = await (0, project_parsing_lib_1.getAllHsProfiles)(projectSourceDir);
|
|
43
|
+
if (existingProfiles.length === 0) {
|
|
44
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.delete.errors.noProfilesFound);
|
|
45
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
46
|
+
}
|
|
47
|
+
const promptResponse = await (0, promptUtils_1.listPrompt)(en_1.commands.project.profile.delete.prompts.deleteProfilePrompt, {
|
|
48
|
+
choices: existingProfiles.map(profile => ({
|
|
49
|
+
name: (0, project_parsing_lib_1.getHsProfileFilename)(profile),
|
|
50
|
+
value: profile,
|
|
51
|
+
})),
|
|
52
|
+
});
|
|
53
|
+
if (promptResponse) {
|
|
54
|
+
profileName = promptResponse;
|
|
55
|
+
}
|
|
56
|
+
logger_1.uiLogger.log('');
|
|
57
|
+
}
|
|
58
|
+
// This should never happen
|
|
59
|
+
if (!profileName) {
|
|
60
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
61
|
+
}
|
|
62
|
+
let targetAccountId;
|
|
63
|
+
try {
|
|
64
|
+
const profileToDelete = (0, project_parsing_lib_1.loadHsProfileFile)(projectSourceDir, profileName);
|
|
65
|
+
targetAccountId = profileToDelete?.accountId;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
logger_1.uiLogger.debug(en_1.commands.project.profile.delete.debug.failedToLoadProfile(profileName));
|
|
69
|
+
}
|
|
70
|
+
if (targetAccountId) {
|
|
71
|
+
let projectExists = false;
|
|
72
|
+
try {
|
|
73
|
+
const fetchProjectResponse = await (0, projects_1.fetchProject)(targetAccountId, projectConfig.name);
|
|
74
|
+
projectExists = !!fetchProjectResponse.data;
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
(0, errorHandlers_1.debugError)(err);
|
|
78
|
+
}
|
|
79
|
+
if (projectExists) {
|
|
80
|
+
const confirmResponse = await (0, promptUtils_1.confirmPrompt)(en_1.commands.project.profile.delete.prompts.deleteProjectPrompt(targetAccountId), {
|
|
81
|
+
defaultAnswer: false,
|
|
82
|
+
});
|
|
83
|
+
if (confirmResponse) {
|
|
84
|
+
await (0, projects_2.deleteProject)(targetAccountId, projectConfig.name);
|
|
85
|
+
logger_1.uiLogger.log(en_1.commands.project.profile.delete.logs.deletedProject(targetAccountId));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
logger_1.uiLogger.log(en_1.commands.project.profile.delete.logs.didNotDeleteProject(targetAccountId));
|
|
89
|
+
}
|
|
90
|
+
logger_1.uiLogger.log('');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const profileFilename = (0, project_parsing_lib_1.getHsProfileFilename)(profileName);
|
|
94
|
+
try {
|
|
95
|
+
fs_1.default.unlinkSync(path_1.default.join(projectSourceDir, profileFilename));
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
logger_1.uiLogger.error(en_1.commands.project.profile.delete.errors.failedToDeleteProfile(profileFilename));
|
|
99
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
100
|
+
}
|
|
101
|
+
logger_1.uiLogger.log(en_1.commands.project.profile.delete.logs.profileDeleted(profileFilename));
|
|
102
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
103
|
+
}
|
|
104
|
+
function projectProfileDeleteBuilder(yargs) {
|
|
105
|
+
yargs.positional('name', {
|
|
106
|
+
describe: en_1.commands.project.profile.delete.positionals.name,
|
|
107
|
+
type: 'string',
|
|
108
|
+
});
|
|
109
|
+
yargs.example([
|
|
110
|
+
['$0 project profile delete qa', en_1.commands.project.profile.delete.example],
|
|
111
|
+
]);
|
|
112
|
+
return yargs;
|
|
113
|
+
}
|
|
114
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(projectProfileDeleteBuilder, command, describe, {
|
|
115
|
+
useGlobalOptions: true,
|
|
116
|
+
});
|
|
117
|
+
const projectProfileDeleteCommand = {
|
|
118
|
+
command,
|
|
119
|
+
describe,
|
|
120
|
+
handler,
|
|
121
|
+
builder,
|
|
122
|
+
};
|
|
123
|
+
exports.default = projectProfileDeleteCommand;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ui_1 = require("../../lib/ui");
|
|
7
|
+
const add_1 = __importDefault(require("./profile/add"));
|
|
8
|
+
const delete_1 = __importDefault(require("./profile/delete"));
|
|
9
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
10
|
+
const en_1 = require("../../lang/en");
|
|
11
|
+
const command = ['profile', 'profiles'];
|
|
12
|
+
const describe = undefined; // uiBetaTag(commands.project.profile.describe, false);
|
|
13
|
+
const verboseDescribe = (0, ui_1.uiBetaTag)(en_1.commands.project.profile.verboseDescribe, false);
|
|
14
|
+
function projectProfileBuilder(yargs) {
|
|
15
|
+
yargs.command(add_1.default).command(delete_1.default).demandCommand(1, '');
|
|
16
|
+
return yargs;
|
|
17
|
+
}
|
|
18
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(projectProfileBuilder, command, verboseDescribe);
|
|
19
|
+
const projectProfileCommand = {
|
|
20
|
+
command,
|
|
21
|
+
describe,
|
|
22
|
+
builder,
|
|
23
|
+
handler: () => { },
|
|
24
|
+
};
|
|
25
|
+
exports.default = projectProfileCommand;
|