@hubspot/cli 7.5.4-experimental.0 → 7.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/migrate.d.ts +14 -4
- package/api/migrate.js +16 -2
- package/bin/cli.js +100 -95
- package/commands/account/auth.d.ts +5 -7
- package/commands/account/auth.js +87 -80
- 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 +5 -6
- package/commands/app/migrate.js +60 -44
- 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 -10
- package/commands/auth.d.ts +5 -7
- package/commands/auth.js +35 -35
- 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 -16
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +23 -13
- 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 -75
- package/commands/customObject/create.d.ts +4 -9
- package/commands/customObject/create.js +17 -10
- package/commands/customObject/schema/create.d.ts +4 -9
- package/commands/customObject/schema/create.js +18 -11
- package/commands/customObject/schema/delete.d.ts +4 -9
- package/commands/customObject/schema/delete.js +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 +20 -48
- package/commands/doctor.d.ts +6 -8
- package/commands/doctor.js +30 -22
- package/commands/feedback.d.ts +4 -1
- package/commands/feedback.js +38 -48
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -34
- package/commands/filemanager/fetch.d.ts +4 -9
- package/commands/filemanager/fetch.js +18 -11
- package/commands/filemanager/upload.d.ts +4 -9
- package/commands/filemanager/upload.js +17 -11
- package/commands/filemanager.d.ts +3 -4
- package/commands/filemanager.js +18 -42
- package/commands/function/deploy.d.ts +6 -1
- package/commands/function/deploy.js +70 -50
- package/commands/function/list.d.ts +6 -1
- package/commands/function/list.js +44 -32
- package/commands/function/server.d.ts +10 -1
- package/commands/function/server.js +49 -38
- package/commands/function.d.ts +5 -1
- package/commands/function.js +22 -11
- 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 +21 -15
- package/commands/hubdb/create.d.ts +4 -9
- package/commands/hubdb/create.js +23 -17
- package/commands/hubdb/delete.d.ts +4 -9
- package/commands/hubdb/delete.js +24 -16
- package/commands/hubdb/fetch.d.ts +4 -9
- package/commands/hubdb/fetch.js +20 -14
- package/commands/hubdb/list.d.ts +4 -0
- package/commands/hubdb/list.js +83 -0
- package/commands/hubdb.d.ts +3 -2
- package/commands/hubdb.js +24 -47
- package/commands/init.d.ts +3 -7
- package/commands/init.js +25 -17
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +42 -44
- package/commands/list.d.ts +3 -7
- package/commands/list.js +21 -16
- package/commands/logs.d.ts +10 -1
- package/commands/logs.js +53 -45
- package/commands/mcp/setup.d.ts +7 -0
- package/commands/mcp/setup.js +50 -0
- package/commands/mcp/start.d.ts +3 -0
- package/commands/mcp/start.js +75 -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 -30
- package/commands/module.d.ts +3 -1
- package/commands/module.js +23 -12
- package/commands/mv.d.ts +3 -7
- package/commands/mv.js +20 -15
- package/commands/open.d.ts +3 -7
- package/commands/open.js +20 -15
- package/commands/project/add.d.ts +8 -9
- package/commands/project/add.js +53 -85
- package/commands/project/cloneApp.d.ts +6 -8
- package/commands/project/cloneApp.js +51 -47
- package/commands/project/create.d.ts +4 -1
- package/commands/project/create.js +132 -81
- package/commands/project/deploy.d.ts +5 -6
- package/commands/project/deploy.js +93 -37
- package/commands/project/dev/deprecatedFlow.d.ts +8 -2
- package/commands/project/dev/deprecatedFlow.js +41 -26
- package/commands/project/dev/index.d.ts +4 -5
- package/commands/project/dev/index.js +103 -33
- package/commands/project/dev/unifiedFlow.d.ts +11 -2
- package/commands/project/dev/unifiedFlow.js +85 -46
- package/commands/project/download.d.ts +3 -7
- package/commands/project/download.js +18 -19
- package/commands/project/installDeps.d.ts +6 -1
- package/commands/project/installDeps.js +48 -32
- package/commands/project/listBuilds.d.ts +3 -7
- package/commands/project/listBuilds.js +32 -30
- package/commands/project/logs.d.ts +10 -1
- package/commands/project/logs.js +73 -65
- package/commands/project/migrate.d.ts +7 -0
- package/commands/project/migrate.js +71 -0
- package/commands/project/migrateApp.d.ts +3 -8
- package/commands/project/migrateApp.js +23 -20
- package/commands/project/open.d.ts +3 -7
- package/commands/project/open.js +29 -21
- package/commands/project/profile/add.d.ts +7 -0
- package/commands/project/profile/add.js +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 +10 -1
- package/commands/project/upload.js +94 -56
- package/commands/project/validate.d.ts +6 -0
- package/commands/project/validate.js +82 -0
- package/commands/project/watch.d.ts +6 -1
- package/commands/project/watch.js +95 -61
- package/commands/project.d.ts +3 -1
- package/commands/project.js +49 -35
- package/commands/remove.d.ts +3 -7
- package/commands/remove.js +22 -20
- package/commands/sandbox/create.d.ts +4 -9
- package/commands/sandbox/create.js +27 -21
- package/commands/sandbox/delete.d.ts +4 -9
- package/commands/sandbox/delete.js +35 -29
- package/commands/sandbox.d.ts +3 -4
- package/commands/sandbox.js +18 -44
- package/commands/secret/addSecret.d.ts +4 -9
- package/commands/secret/addSecret.js +21 -15
- package/commands/secret/deleteSecret.d.ts +4 -9
- package/commands/secret/deleteSecret.js +28 -18
- package/commands/secret/listSecret.d.ts +4 -9
- package/commands/secret/listSecret.js +19 -13
- package/commands/secret/updateSecret.d.ts +4 -9
- package/commands/secret/updateSecret.js +25 -17
- package/commands/secret.d.ts +3 -4
- package/commands/secret.js +23 -49
- package/commands/theme/generate-selectors.d.ts +3 -7
- package/commands/theme/generate-selectors.js +20 -16
- package/commands/theme/marketplace-validate.d.ts +4 -9
- package/commands/theme/marketplace-validate.js +22 -18
- package/commands/theme/preview.d.ts +4 -9
- package/commands/theme/preview.js +36 -30
- package/commands/theme.d.ts +3 -4
- package/commands/theme.js +22 -48
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +116 -135
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +74 -76
- package/lang/en.d.ts +3217 -0
- package/lang/en.js +3074 -3318
- package/lang/en.lyaml +41 -246
- package/lib/accountTypes.d.ts +1 -0
- package/lib/accountTypes.js +11 -0
- package/lib/app/migrate.d.ts +33 -4
- package/lib/app/migrate.js +232 -99
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/app/migrate_legacy.js +16 -13
- package/lib/app/urls.d.ts +16 -0
- package/lib/app/urls.js +16 -0
- package/lib/buildAccount.d.ts +1 -2
- package/lib/buildAccount.js +11 -10
- package/lib/commonOpts.d.ts +4 -7
- package/lib/commonOpts.js +47 -19
- package/lib/configMigrate.d.ts +2 -2
- package/lib/configMigrate.js +39 -60
- package/lib/configOptions.d.ts +4 -0
- package/lib/configOptions.js +41 -45
- package/lib/constants.d.ts +33 -0
- package/lib/constants.js +34 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +14 -40
- package/lib/doctor/Diagnosis.js +10 -11
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +10 -10
- package/lib/doctor/Doctor.js +45 -49
- package/lib/errorHandlers/index.js +13 -7
- package/lib/errorHandlers/suppressError.js +18 -26
- package/lib/filesystem.d.ts +1 -1
- package/lib/generateSelectors.js +3 -6
- package/lib/hasFeature.d.ts +3 -1
- 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/__test__/yargsChecksMiddleware.test.js +3 -3
- package/lib/middleware/autoUpdateMiddleware.d.ts +1 -0
- package/lib/middleware/autoUpdateMiddleware.js +89 -0
- package/lib/middleware/configMiddleware.js +32 -2
- package/lib/middleware/fireAlarmMiddleware.d.ts +2 -2
- package/lib/middleware/fireAlarmMiddleware.js +12 -24
- package/lib/middleware/yargsChecksMiddleware.js +2 -2
- package/lib/npm.d.ts +9 -0
- package/lib/npm.js +36 -0
- package/lib/oauth.js +1 -2
- package/lib/process.js +1 -2
- package/lib/projectProfiles.d.ts +7 -0
- package/lib/projectProfiles.js +83 -0
- package/lib/projects/ProjectLogsManager.d.ts +1 -1
- package/lib/projects/ProjectLogsManager.js +16 -21
- 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 +46 -42
- package/lib/projects/components.d.ts +2 -0
- package/lib/projects/components.js +82 -0
- package/lib/projects/config.d.ts +9 -0
- package/lib/projects/config.js +79 -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} +23 -15
- package/lib/projects/create/v3.d.ts +27 -0
- package/lib/projects/create/v3.js +158 -0
- package/lib/projects/ensureProjectExists.d.ts +11 -0
- package/lib/projects/ensureProjectExists.js +97 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +30 -0
- package/lib/projects/localDev/AppDevModeInterface.js +215 -0
- package/lib/{DevServerManager.d.ts → projects/localDev/DevServerManager.d.ts} +1 -1
- package/lib/{DevServerManager.js → projects/localDev/DevServerManager.js} +6 -6
- package/lib/projects/localDev/DevServerManagerV2.d.ts +22 -0
- package/lib/{DevServerManagerV2.js → projects/localDev/DevServerManagerV2.js} +22 -19
- package/lib/projects/localDev/LocalDevLogger.d.ts +30 -0
- package/lib/projects/localDev/LocalDevLogger.js +159 -0
- package/lib/{LocalDevManager.d.ts → projects/localDev/LocalDevManager.d.ts} +1 -1
- package/lib/{LocalDevManager.js → projects/localDev/LocalDevManager.js} +57 -83
- package/lib/projects/localDev/LocalDevProcess.d.ts +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/{localDev.d.ts → projects/localDev/helpers.d.ts} +6 -4
- package/lib/{localDev.js → projects/localDev/helpers.js} +127 -114
- package/lib/projects/ui.d.ts +1 -0
- package/lib/projects/ui.js +15 -0
- package/lib/projects/upload.d.ts +17 -2
- package/lib/projects/upload.js +74 -50
- package/lib/projects/urls.d.ts +4 -0
- package/lib/projects/urls.js +23 -1
- package/lib/projects/watch.d.ts +1 -1
- package/lib/projects/watch.js +21 -18
- package/lib/prompts/accountNamePrompt.js +16 -13
- package/lib/prompts/accountsPrompt.js +1 -2
- package/lib/prompts/cmsFieldPrompt.js +1 -2
- package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
- package/lib/prompts/createApiSamplePrompt.js +4 -5
- package/lib/prompts/createFunctionPrompt.js +13 -14
- package/lib/prompts/createModulePrompt.js +8 -9
- package/lib/prompts/createProjectPrompt.d.ts +20 -4
- package/lib/prompts/createProjectPrompt.js +43 -13
- package/lib/prompts/createTemplatePrompt.d.ts +22 -4
- package/lib/prompts/createTemplatePrompt.js +1 -2
- package/lib/prompts/downloadProjectPrompt.js +3 -4
- package/lib/prompts/installAppPrompt.d.ts +2 -0
- package/lib/prompts/installAppPrompt.js +45 -0
- package/lib/prompts/personalAccessKeyPrompt.js +35 -25
- package/lib/prompts/previewPrompt.js +5 -6
- package/lib/prompts/projectAddPrompt.d.ts +5 -1
- package/lib/prompts/projectAddPrompt.js +35 -8
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +15 -16
- package/lib/prompts/projectNamePrompt.js +5 -6
- package/lib/prompts/projectsLogsPrompt.js +3 -2
- package/lib/prompts/promptUtils.d.ts +4 -2
- package/lib/prompts/promptUtils.js +3 -1
- package/lib/prompts/sandboxesPrompt.js +5 -6
- package/lib/prompts/secretPrompt.js +2 -3
- package/lib/prompts/selectAppPrompt.d.ts +2 -0
- package/lib/prompts/selectAppPrompt.js +40 -0
- package/lib/prompts/selectHubDBTablePrompt.js +11 -8
- package/lib/prompts/{selectPublicAppPrompt.d.ts → selectPublicAppForMigrationPrompt.d.ts} +1 -1
- package/lib/prompts/{selectPublicAppPrompt.js → selectPublicAppForMigrationPrompt.js} +8 -9
- package/lib/prompts/setAsDefaultAccountPrompt.js +11 -2
- package/lib/prompts/uploadPrompt.js +4 -5
- package/lib/sandboxSync.js +15 -14
- package/lib/sandboxes.js +12 -13
- package/lib/serverlessLogs.js +4 -6
- package/lib/testUtils.d.ts +3 -3
- package/lib/testUtils.js +8 -9
- package/lib/ui/boxen.d.ts +5 -0
- package/lib/ui/boxen.js +30 -0
- package/lib/ui/git.js +8 -9
- package/lib/ui/index.d.ts +3 -2
- package/lib/ui/index.js +15 -17
- package/lib/ui/logger.d.ts +10 -0
- package/lib/ui/logger.js +15 -0
- package/lib/ui/serverlessFunctionLogs.js +2 -3
- package/lib/upload.d.ts +1 -1
- package/lib/validation.js +4 -5
- package/lib/yargsUtils.d.ts +5 -1
- package/lib/yargsUtils.js +6 -0
- package/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 +25 -17
- 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 +14 -11
- package/lib/DevServerManagerV2.d.ts +0 -33
- package/lib/LocalDevManagerV2.d.ts +0 -64
- package/lib/LocalDevManagerV2.js +0 -377
- package/lib/projects/create.d.ts +0 -5
- package/lib/projects/index.d.ts +0 -20
- package/lib/projects/index.js +0 -194
- package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
- package/lib/prompts/installPublicAppPrompt.js +0 -40
|
@@ -8,16 +8,17 @@ exports.useV3Api = useV3Api;
|
|
|
8
8
|
exports.displayWarnLogs = displayWarnLogs;
|
|
9
9
|
exports.pollProjectBuildAndDeploy = pollProjectBuildAndDeploy;
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
12
11
|
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
13
12
|
const constants_1 = require("../constants");
|
|
14
13
|
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
15
|
-
const lang_1 = require("../lang");
|
|
16
14
|
const errorHandlers_1 = require("../errorHandlers");
|
|
17
15
|
const ui_1 = require("../ui");
|
|
18
16
|
const urls_1 = require("./urls");
|
|
19
17
|
const exitCodes_1 = require("../enums/exitCodes");
|
|
20
|
-
const
|
|
18
|
+
const en_1 = require("../../lang/en");
|
|
19
|
+
const logger_1 = require("../ui/logger");
|
|
20
|
+
const constants_2 = require("@hubspot/project-parsing-lib/src/lib/constants");
|
|
21
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
21
22
|
const SPINNER_STATUS = {
|
|
22
23
|
SPINNING: 'spinning',
|
|
23
24
|
};
|
|
@@ -50,19 +51,14 @@ function getSubtaskType(task) {
|
|
|
50
51
|
return task.deployType;
|
|
51
52
|
}
|
|
52
53
|
function handleTaskStatusError(statusText) {
|
|
53
|
-
logger_1.
|
|
54
|
-
taskType: statusText.TYPE_KEY === constants_1.PROJECT_BUILD_TEXT.TYPE_KEY
|
|
55
|
-
? 'build'
|
|
56
|
-
: 'deploy',
|
|
57
|
-
openCommand: (0, ui_1.uiCommandReference)('hs project open'),
|
|
58
|
-
}));
|
|
54
|
+
logger_1.uiLogger.error(en_1.lib.projectBuildAndDeploy.makePollTaskStatusFunc.errorFetchingTaskStatus(statusText.TYPE_KEY === constants_1.PROJECT_BUILD_TEXT.TYPE_KEY ? 'build' : 'deploy'));
|
|
59
55
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
60
56
|
}
|
|
61
57
|
function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrings, linkToHubSpot, }) {
|
|
62
58
|
return async function (accountId, taskName, taskId, deployedBuildId, silenceLogs = false) {
|
|
63
59
|
const displayId = deployedBuildId || taskId;
|
|
64
60
|
if (linkToHubSpot && !silenceLogs) {
|
|
65
|
-
logger_1.
|
|
61
|
+
logger_1.uiLogger.log(`\n${linkToHubSpot(accountId, taskName, taskId, deployedBuildId)}\n`);
|
|
66
62
|
}
|
|
67
63
|
SpinniesManager_1.default.init();
|
|
68
64
|
const overallTaskSpinniesKey = `overallTaskStatus-${statusText.STATUS_TEXT}`;
|
|
@@ -77,14 +73,27 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
|
|
|
77
73
|
structureFn(accountId, taskName, taskId),
|
|
78
74
|
]);
|
|
79
75
|
const subtasks = getSubtasks(initialTaskStatus);
|
|
80
|
-
const
|
|
76
|
+
const hiddenComponentBuildIds = [];
|
|
77
|
+
const tasksById = subtasks
|
|
78
|
+
.filter(subtask => {
|
|
79
|
+
// TODO: Remove this filtering logic when visible=false for SERVERLESS_PACKAGE
|
|
80
|
+
const shouldBeVisible = getSubtaskType(subtask) !== (0, project_parsing_lib_1.mapToInternalType)(constants_2.AppFunctionsPackageKey);
|
|
81
|
+
if (!shouldBeVisible) {
|
|
82
|
+
hiddenComponentBuildIds.push(subtask.id);
|
|
83
|
+
}
|
|
84
|
+
return shouldBeVisible;
|
|
85
|
+
})
|
|
86
|
+
.reduce((acc, subtask) => {
|
|
81
87
|
const { id, visible } = subtask;
|
|
82
88
|
if (visible) {
|
|
83
89
|
acc[id] = subtask;
|
|
84
90
|
}
|
|
85
91
|
return acc;
|
|
86
92
|
}, {});
|
|
87
|
-
const structuredTasks = Object.keys(taskStructure)
|
|
93
|
+
const structuredTasks = Object.keys(taskStructure)
|
|
94
|
+
// TODO: Remove this filtering logic when visible=false for SERVERLESS_PACKAGE
|
|
95
|
+
.filter(buildId => !hiddenComponentBuildIds.includes(buildId))
|
|
96
|
+
.map(key => {
|
|
88
97
|
return {
|
|
89
98
|
...tasksById[key],
|
|
90
99
|
subtasks: taskStructure[key]
|
|
@@ -95,9 +104,10 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
|
|
|
95
104
|
const numComponents = structuredTasks.length;
|
|
96
105
|
const componentCountText = silenceLogs
|
|
97
106
|
? ''
|
|
98
|
-
:
|
|
99
|
-
?
|
|
100
|
-
|
|
107
|
+
: numComponents === 1
|
|
108
|
+
? en_1.lib.projectBuildAndDeploy.makePollTaskStatusFunc
|
|
109
|
+
.componentCountSingular
|
|
110
|
+
: en_1.lib.projectBuildAndDeploy.makePollTaskStatusFunc.componentCount(numComponents);
|
|
101
111
|
SpinniesManager_1.default.update(overallTaskSpinniesKey, {
|
|
102
112
|
text: `${statusStrings.INITIALIZE(taskName, displayId)}\n${componentCountText}`,
|
|
103
113
|
});
|
|
@@ -129,7 +139,7 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
|
|
|
129
139
|
taskStatus = data;
|
|
130
140
|
}
|
|
131
141
|
catch (e) {
|
|
132
|
-
logger_1.
|
|
142
|
+
logger_1.uiLogger.debug(e);
|
|
133
143
|
(0, errorHandlers_1.logError)(e, new errorHandlers_1.ApiErrorContext({
|
|
134
144
|
accountId,
|
|
135
145
|
projectName: taskName,
|
|
@@ -152,8 +162,10 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
|
|
|
152
162
|
if (status === statusText.STATES.SUCCESS ||
|
|
153
163
|
status === statusText.STATES.FAILURE) {
|
|
154
164
|
const taskStatusText = subtask.status === statusText.STATES.SUCCESS
|
|
155
|
-
?
|
|
156
|
-
|
|
165
|
+
? en_1.lib.projectBuildAndDeploy.makePollTaskStatusFunc
|
|
166
|
+
.successStatusText
|
|
167
|
+
: en_1.lib.projectBuildAndDeploy.makePollTaskStatusFunc
|
|
168
|
+
.failedStatusText;
|
|
157
169
|
const hasNewline = spinner?.text?.includes('\n') || Boolean(topLevelTask);
|
|
158
170
|
const updatedText = `${spinner?.text?.replace('\n', '')} ${taskStatusText}${hasNewline ? '\n' : ''}`;
|
|
159
171
|
if (status === statusText.STATES.SUCCESS) {
|
|
@@ -181,23 +193,23 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
|
|
|
181
193
|
if (!silenceLogs) {
|
|
182
194
|
const failedSubtasks = subtasks.filter(subtask => subtask.status === 'FAILURE');
|
|
183
195
|
(0, ui_1.uiLine)();
|
|
184
|
-
logger_1.
|
|
196
|
+
logger_1.uiLogger.log(`${statusStrings.SUBTASK_FAIL(failedSubtasks.length === 1
|
|
185
197
|
? getSubtaskName(failedSubtasks[0])
|
|
186
198
|
: failedSubtasks.length + ' components', displayId)}\n`);
|
|
187
|
-
logger_1.
|
|
199
|
+
logger_1.uiLogger.log(en_1.lib.projectBuildAndDeploy.makePollTaskStatusFunc.errorSummary);
|
|
188
200
|
(0, ui_1.uiLine)();
|
|
189
201
|
const displayErrors = failedSubtasks.filter(subtask => subtask?.standardError?.subCategory !==
|
|
190
202
|
constants_1.PROJECT_ERROR_TYPES.SUBBUILD_FAILED &&
|
|
191
203
|
subtask?.standardError?.subCategory !==
|
|
192
204
|
constants_1.PROJECT_ERROR_TYPES.SUBDEPLOY_FAILED);
|
|
193
205
|
displayErrors.forEach(subTask => {
|
|
194
|
-
logger_1.
|
|
195
|
-
logger_1.
|
|
206
|
+
logger_1.uiLogger.log(`\n--- ${chalk_1.default.bold(getSubtaskName(subTask))} failed with the following error ---`);
|
|
207
|
+
logger_1.uiLogger.error(subTask.errorMessage);
|
|
196
208
|
// Log nested errors
|
|
197
209
|
if (subTask.standardError && subTask.standardError.errors) {
|
|
198
|
-
logger_1.
|
|
210
|
+
logger_1.uiLogger.log('');
|
|
199
211
|
subTask.standardError.errors.forEach(error => {
|
|
200
|
-
logger_1.
|
|
212
|
+
logger_1.uiLogger.log(error.message);
|
|
201
213
|
});
|
|
202
214
|
}
|
|
203
215
|
});
|
|
@@ -216,7 +228,7 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
|
|
|
216
228
|
}
|
|
217
229
|
function pollBuildAutodeployStatus(accountId, taskName, buildId) {
|
|
218
230
|
return new Promise((resolve, reject) => {
|
|
219
|
-
let maxIntervals = (
|
|
231
|
+
let maxIntervals = (15 * 1000) / constants_1.DEFAULT_POLLING_DELAY; // Num of intervals in ~15s
|
|
220
232
|
const pollInterval = setInterval(async () => {
|
|
221
233
|
let build;
|
|
222
234
|
try {
|
|
@@ -224,11 +236,11 @@ function pollBuildAutodeployStatus(accountId, taskName, buildId) {
|
|
|
224
236
|
build = response.data;
|
|
225
237
|
}
|
|
226
238
|
catch (e) {
|
|
227
|
-
logger_1.
|
|
228
|
-
return reject(new Error(
|
|
239
|
+
logger_1.uiLogger.debug(e);
|
|
240
|
+
return reject(new Error(en_1.lib.projectBuildAndDeploy.pollBuildAutodeployStatusError(buildId)));
|
|
229
241
|
}
|
|
230
242
|
if (!build || !build.status) {
|
|
231
|
-
return reject(new Error(
|
|
243
|
+
return reject(new Error(en_1.lib.projectBuildAndDeploy.pollBuildAutodeployStatusError(buildId)));
|
|
232
244
|
}
|
|
233
245
|
if (build.deployStatusTaskLocator || maxIntervals <= 0) {
|
|
234
246
|
clearInterval(pollInterval);
|
|
@@ -287,9 +299,9 @@ async function displayWarnLogs(accountId, projectName, taskId, isDeploy = false)
|
|
|
287
299
|
if (result && result.logs) {
|
|
288
300
|
const logLength = result.logs.length;
|
|
289
301
|
result.logs.forEach((log, i) => {
|
|
290
|
-
logger_1.
|
|
302
|
+
logger_1.uiLogger.warn(log.message);
|
|
291
303
|
if (i < logLength - 1) {
|
|
292
|
-
logger_1.
|
|
304
|
+
logger_1.uiLogger.log('');
|
|
293
305
|
}
|
|
294
306
|
});
|
|
295
307
|
}
|
|
@@ -311,10 +323,7 @@ async function pollProjectBuildAndDeploy(accountId, projectConfig, tempFile, bui
|
|
|
311
323
|
}
|
|
312
324
|
else if (buildStatus.isAutoDeployEnabled) {
|
|
313
325
|
if (!silenceLogs) {
|
|
314
|
-
logger_1.
|
|
315
|
-
accountIdentifier: (0, ui_1.uiAccountDescription)(accountId),
|
|
316
|
-
buildId,
|
|
317
|
-
}));
|
|
326
|
+
logger_1.uiLogger.log(en_1.lib.projectBuildAndDeploy.pollProjectBuildAndDeploy.buildSucceededAutomaticallyDeploying(buildId, (0, ui_1.uiAccountDescription)(accountId)));
|
|
318
327
|
await displayWarnLogs(accountId, projectConfig.name, buildId);
|
|
319
328
|
}
|
|
320
329
|
// autoDeployId of 0 indicates a skipped deploy
|
|
@@ -331,22 +340,17 @@ async function pollProjectBuildAndDeploy(accountId, projectConfig, tempFile, bui
|
|
|
331
340
|
}
|
|
332
341
|
}
|
|
333
342
|
else if (!silenceLogs) {
|
|
334
|
-
logger_1.
|
|
335
|
-
buildId,
|
|
336
|
-
viewDeploysLink: (0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.pollProjectBuildAndDeploy.viewDeploys`), (0, urls_1.getProjectActivityUrl)(projectConfig.name, accountId)),
|
|
337
|
-
}));
|
|
343
|
+
logger_1.uiLogger.log(en_1.lib.projectBuildAndDeploy.pollProjectBuildAndDeploy.unableToFindAutodeployStatus(buildId, (0, ui_1.uiLink)(en_1.lib.projectBuildAndDeploy.pollProjectBuildAndDeploy.viewDeploys, (0, urls_1.getProjectActivityUrl)(projectConfig.name, accountId))));
|
|
338
344
|
}
|
|
339
345
|
}
|
|
340
346
|
try {
|
|
341
347
|
if (tempFile) {
|
|
342
348
|
tempFile.removeCallback();
|
|
343
|
-
logger_1.
|
|
344
|
-
path: tempFile.name,
|
|
345
|
-
}));
|
|
349
|
+
logger_1.uiLogger.debug(en_1.lib.projectBuildAndDeploy.pollProjectBuildAndDeploy.cleanedUpTempFile(tempFile.name));
|
|
346
350
|
}
|
|
347
351
|
}
|
|
348
352
|
catch (e) {
|
|
349
|
-
|
|
353
|
+
(0, errorHandlers_1.logError)(e);
|
|
350
354
|
}
|
|
351
355
|
if (result && result.deployResult) {
|
|
352
356
|
await displayWarnLogs(accountId, projectConfig.name, result.deployResult.deployId, true);
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
exports.handleComponentCollision = handleComponentCollision;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
10
|
+
// Handles a collision between component source files
|
|
11
|
+
function handleComponentCollision({ dest, src, collisions }) {
|
|
12
|
+
const hsMetaFiles = [];
|
|
13
|
+
const packageJsonFiles = [];
|
|
14
|
+
const sourceFiles = [];
|
|
15
|
+
collisions.forEach(collision => {
|
|
16
|
+
if (collision.endsWith(project_parsing_lib_1.metafileExtension)) {
|
|
17
|
+
hsMetaFiles.push(collision);
|
|
18
|
+
}
|
|
19
|
+
else if (path_1.default.parse(collision).base === 'package.json') {
|
|
20
|
+
packageJsonFiles.push(collision);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
sourceFiles.push(collision);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const sourceFilenameMapping = sourceFiles.reduce((acc, filename) => {
|
|
27
|
+
const { name, ext, dir } = path_1.default.parse(filename);
|
|
28
|
+
return {
|
|
29
|
+
...acc,
|
|
30
|
+
[filename]: path_1.default.join(dir, `${name}-${Date.now()}${ext}`),
|
|
31
|
+
};
|
|
32
|
+
}, {});
|
|
33
|
+
const metafileExtensionPrefix = path_1.default.parse(project_parsing_lib_1.metafileExtension).name;
|
|
34
|
+
const metaFilenameMapping = hsMetaFiles.reduce((acc, filename) => {
|
|
35
|
+
const { name, dir } = path_1.default.parse(filename);
|
|
36
|
+
return {
|
|
37
|
+
...acc,
|
|
38
|
+
[filename]: path_1.default.join(dir, `${name.replace(metafileExtensionPrefix, '')}-${Date.now()}${project_parsing_lib_1.metafileExtension}`),
|
|
39
|
+
};
|
|
40
|
+
}, {});
|
|
41
|
+
// Update the metafiles that might contain references to the old filenames
|
|
42
|
+
hsMetaFiles.forEach(file => {
|
|
43
|
+
updateMetaFile({
|
|
44
|
+
dest,
|
|
45
|
+
src,
|
|
46
|
+
file,
|
|
47
|
+
sourceFilenameMapping,
|
|
48
|
+
metaFilenameMapping,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
// Copy the renamed files into their new destination location
|
|
52
|
+
Object.entries(sourceFilenameMapping).forEach(([key, value]) => {
|
|
53
|
+
fs_1.default.copyFileSync(path_1.default.join(src, key), path_1.default.join(dest, value));
|
|
54
|
+
});
|
|
55
|
+
if (packageJsonFiles.length) {
|
|
56
|
+
handlePackageJsonCollisions(dest, src, packageJsonFiles);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function updateMetaFile({ dest, src, file, sourceFilenameMapping, metaFilenameMapping, }) {
|
|
60
|
+
let text = fs_1.default.readFileSync(path_1.default.join(src, file), 'utf-8');
|
|
61
|
+
Object.entries(sourceFilenameMapping).forEach(([key, value]) => {
|
|
62
|
+
const { base: oldFileName } = path_1.default.parse(key);
|
|
63
|
+
const { base: newFileName } = path_1.default.parse(value);
|
|
64
|
+
text = text.replace(oldFileName, newFileName);
|
|
65
|
+
});
|
|
66
|
+
fs_1.default.writeFileSync(path_1.default.join(dest, metaFilenameMapping[file]), text);
|
|
67
|
+
}
|
|
68
|
+
function handlePackageJsonCollisions(dest, src, packageJsonFiles) {
|
|
69
|
+
packageJsonFiles.forEach(file => {
|
|
70
|
+
const existingPackageJsonContents = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dest, file), 'utf-8'));
|
|
71
|
+
const newPackageJsonContents = JSON.parse(fs_1.default.readFileSync(path_1.default.join(src, file), 'utf-8'));
|
|
72
|
+
existingPackageJsonContents.dependencies = {
|
|
73
|
+
...newPackageJsonContents.dependencies,
|
|
74
|
+
...existingPackageJsonContents.dependencies,
|
|
75
|
+
};
|
|
76
|
+
existingPackageJsonContents.devDependencies = {
|
|
77
|
+
...newPackageJsonContents.devDependencies,
|
|
78
|
+
...existingPackageJsonContents.devDependencies,
|
|
79
|
+
};
|
|
80
|
+
fs_1.default.writeFileSync(path_1.default.join(dest, file), JSON.stringify(existingPackageJsonContents, null, 2));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ProjectConfig } from '../../types/Projects';
|
|
2
|
+
export declare function writeProjectConfig(configPath: string, config: ProjectConfig): boolean;
|
|
3
|
+
export declare function getIsInProject(dir?: string): boolean;
|
|
4
|
+
export interface LoadedProjectConfig {
|
|
5
|
+
projectDir: string | null;
|
|
6
|
+
projectConfig: ProjectConfig | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function getProjectConfig(dir?: string): Promise<LoadedProjectConfig>;
|
|
9
|
+
export declare function validateProjectConfig(projectConfig: ProjectConfig | null, projectDir: string | null): asserts projectConfig is ProjectConfig;
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
exports.writeProjectConfig = writeProjectConfig;
|
|
7
|
+
exports.getIsInProject = getIsInProject;
|
|
8
|
+
exports.getProjectConfig = getProjectConfig;
|
|
9
|
+
exports.validateProjectConfig = validateProjectConfig;
|
|
10
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const findup_sync_1 = __importDefault(require("findup-sync"));
|
|
13
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const en_1 = require("../../lang/en");
|
|
16
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
17
|
+
const logger_1 = require("../ui/logger");
|
|
18
|
+
function writeProjectConfig(configPath, config) {
|
|
19
|
+
try {
|
|
20
|
+
fs_extra_1.default.ensureFileSync(configPath);
|
|
21
|
+
fs_extra_1.default.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
22
|
+
logger_1.uiLogger.debug(`Wrote project config at ${configPath}`);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
logger_1.uiLogger.debug(e);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
function getIsInProject(dir) {
|
|
31
|
+
const configPath = getProjectConfigPath(dir);
|
|
32
|
+
return !!configPath;
|
|
33
|
+
}
|
|
34
|
+
function getProjectConfigPath(dir) {
|
|
35
|
+
const projectDir = dir ? (0, path_2.getAbsoluteFilePath)(dir) : (0, path_2.getCwd)();
|
|
36
|
+
const configPath = (0, findup_sync_1.default)(constants_1.PROJECT_CONFIG_FILE, {
|
|
37
|
+
cwd: projectDir,
|
|
38
|
+
nocase: true,
|
|
39
|
+
});
|
|
40
|
+
return configPath;
|
|
41
|
+
}
|
|
42
|
+
async function getProjectConfig(dir) {
|
|
43
|
+
const configPath = getProjectConfigPath(dir);
|
|
44
|
+
if (!configPath) {
|
|
45
|
+
return { projectConfig: null, projectDir: null };
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const config = fs_extra_1.default.readFileSync(configPath);
|
|
49
|
+
const projectConfig = JSON.parse(config.toString());
|
|
50
|
+
return {
|
|
51
|
+
projectDir: path_1.default.dirname(configPath),
|
|
52
|
+
projectConfig,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
logger_1.uiLogger.error(en_1.lib.projects.getProjectConfig.error);
|
|
57
|
+
return { projectConfig: null, projectDir: null };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function validateProjectConfig(projectConfig, projectDir) {
|
|
61
|
+
if (!projectConfig || !projectDir) {
|
|
62
|
+
logger_1.uiLogger.error(en_1.lib.projects.validateProjectConfig.configNotFound);
|
|
63
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
64
|
+
}
|
|
65
|
+
if (!projectConfig.name || !projectConfig.srcDir) {
|
|
66
|
+
logger_1.uiLogger.error(en_1.lib.projects.validateProjectConfig.configMissingFields);
|
|
67
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
68
|
+
}
|
|
69
|
+
const resolvedPath = path_1.default.resolve(projectDir, projectConfig.srcDir);
|
|
70
|
+
if (!resolvedPath.startsWith(projectDir)) {
|
|
71
|
+
const projectConfigFile = path_1.default.relative('.', path_1.default.join(projectDir, constants_1.PROJECT_CONFIG_FILE));
|
|
72
|
+
logger_1.uiLogger.error(en_1.lib.projects.validateProjectConfig.srcOutsideProjectDir(projectConfigFile, projectConfig.srcDir));
|
|
73
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
74
|
+
}
|
|
75
|
+
if (!fs_extra_1.default.existsSync(resolvedPath)) {
|
|
76
|
+
logger_1.uiLogger.error(en_1.lib.projects.validateProjectConfig.srcDirNotFound(projectConfig.srcDir, projectDir));
|
|
77
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { ProjectTemplateRepoConfig } from '../../../types/Projects';
|
|
3
|
+
import { CreateProjectPromptResponse } from '../../prompts/createProjectPrompt';
|
|
4
|
+
import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs } from '../../../types/Yargs';
|
|
5
|
+
import { RepoPath } from '@hubspot/local-dev-lib/types/Github';
|
|
6
|
+
export type ProjectCreateArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
7
|
+
name?: string;
|
|
8
|
+
dest?: string;
|
|
9
|
+
templateSource?: RepoPath;
|
|
10
|
+
template?: string;
|
|
11
|
+
features?: string[];
|
|
12
|
+
platformVersion: string;
|
|
13
|
+
projectBase?: string;
|
|
14
|
+
auth?: string;
|
|
15
|
+
distribution?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function handleProjectCreationFlow(args: ArgumentsCamelCase<ProjectCreateArgs>): Promise<{
|
|
18
|
+
authType?: string;
|
|
19
|
+
distribution?: string;
|
|
20
|
+
repoConfig?: ProjectTemplateRepoConfig;
|
|
21
|
+
projectContents?: string;
|
|
22
|
+
createProjectPromptResponse: CreateProjectPromptResponse;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleProjectCreationFlow = handleProjectCreationFlow;
|
|
4
|
+
const createProjectPrompt_1 = require("../../prompts/createProjectPrompt");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const buildAndDeploy_1 = require("../buildAndDeploy");
|
|
7
|
+
const v3_1 = require("./v3");
|
|
8
|
+
const legacy_1 = require("./legacy");
|
|
9
|
+
const logger_1 = require("../../ui/logger");
|
|
10
|
+
const en_1 = require("../../../lang/en");
|
|
11
|
+
const exitCodes_1 = require("../../enums/exitCodes");
|
|
12
|
+
async function handleProjectCreationFlow(args) {
|
|
13
|
+
const { platformVersion, templateSource, projectBase, auth: providedAuth, distribution: providedDistribution, } = args;
|
|
14
|
+
const repo = templateSource || constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH;
|
|
15
|
+
if ((0, buildAndDeploy_1.useV3Api)(platformVersion)) {
|
|
16
|
+
const { componentTemplateChoices, authType, distribution, repoConfig, projectContents, } = await (0, v3_1.v3ComponentFlow)(platformVersion, projectBase, providedAuth, providedDistribution);
|
|
17
|
+
const createProjectPromptResponse = await (0, createProjectPrompt_1.createProjectPrompt)(args, undefined, projectContents !== v3_1.EMPTY_PROJECT ? componentTemplateChoices : undefined);
|
|
18
|
+
return {
|
|
19
|
+
authType,
|
|
20
|
+
distribution,
|
|
21
|
+
repoConfig,
|
|
22
|
+
projectContents,
|
|
23
|
+
createProjectPromptResponse,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const projectTemplates = await (0, legacy_1.getProjectTemplateListFromRepo)(repo, 'main');
|
|
27
|
+
if (!projectTemplates.length) {
|
|
28
|
+
logger_1.uiLogger.error(en_1.commands.project.create.errors.failedToFetchProjectList);
|
|
29
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
|
+
}
|
|
31
|
+
const createProjectPromptResponse = await (0, createProjectPrompt_1.createProjectPrompt)(args, projectTemplates);
|
|
32
|
+
return { createProjectPromptResponse };
|
|
33
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RepoPath } from '@hubspot/local-dev-lib/types/Github';
|
|
2
|
+
import { ProjectTemplate, ComponentTemplate, ProjectTemplateRepoConfig } from '../../../types/Projects';
|
|
3
|
+
export declare const EMPTY_PROJECT_TEMPLATE_NAME = "no-template";
|
|
4
|
+
export declare function getConfigForPlatformVersion(platformVersion: string): Promise<ProjectTemplateRepoConfig> | never;
|
|
5
|
+
export declare function getProjectComponentListFromRepo(platformVersion: string): Promise<ComponentTemplate[]>;
|
|
6
|
+
export declare function getProjectTemplateListFromRepo(templateSource: RepoPath, githubRef: string): Promise<ProjectTemplate[]>;
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EMPTY_PROJECT_TEMPLATE_NAME = void 0;
|
|
4
|
+
exports.getConfigForPlatformVersion = getConfigForPlatformVersion;
|
|
4
5
|
exports.getProjectComponentListFromRepo = getProjectComponentListFromRepo;
|
|
5
6
|
exports.getProjectTemplateListFromRepo = getProjectTemplateListFromRepo;
|
|
6
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
7
|
const github_1 = require("@hubspot/local-dev-lib/api/github");
|
|
8
|
-
const constants_1 = require("
|
|
9
|
-
const exitCodes_1 = require("
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
const exitCodes_1 = require("../../enums/exitCodes");
|
|
10
|
+
const errorHandlers_1 = require("../../errorHandlers");
|
|
11
|
+
const logger_1 = require("../../ui/logger");
|
|
12
|
+
const buildAndDeploy_1 = require("../buildAndDeploy");
|
|
13
|
+
const en_1 = require("../../../lang/en");
|
|
14
|
+
const PROJECT_TEMPLATE_PROPERTIES = ['name', 'label', 'path'];
|
|
13
15
|
exports.EMPTY_PROJECT_TEMPLATE_NAME = 'no-template';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
async function getConfigForPlatformVersion(platformVersion) {
|
|
17
|
+
let path = '';
|
|
18
|
+
if ((0, buildAndDeploy_1.useV3Api)(platformVersion)) {
|
|
19
|
+
path = `${platformVersion}/`;
|
|
20
|
+
}
|
|
21
|
+
const { data } = await (0, github_1.fetchRepoFile)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, `${path}config.json`, 'main');
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
async function getProjectComponentListFromRepo(platformVersion) {
|
|
16
25
|
let config;
|
|
17
26
|
try {
|
|
18
|
-
|
|
19
|
-
config = data;
|
|
27
|
+
config = await getConfigForPlatformVersion(platformVersion);
|
|
20
28
|
}
|
|
21
29
|
catch (err) {
|
|
22
|
-
(0,
|
|
30
|
+
(0, errorHandlers_1.debugError)(err);
|
|
23
31
|
}
|
|
24
32
|
if (config) {
|
|
25
33
|
return config[constants_1.PROJECT_COMPONENT_TYPES.COMPONENTS] || [];
|
|
@@ -33,18 +41,18 @@ async function getProjectTemplateListFromRepo(templateSource, githubRef) {
|
|
|
33
41
|
config = data;
|
|
34
42
|
}
|
|
35
43
|
catch (e) {
|
|
36
|
-
(0,
|
|
37
|
-
logger_1.
|
|
44
|
+
(0, errorHandlers_1.debugError)(e);
|
|
45
|
+
logger_1.uiLogger.error(en_1.lib.projects.create.errors.missingConfigFileTemplateSource);
|
|
38
46
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
39
47
|
}
|
|
40
48
|
if (!config || !config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS]) {
|
|
41
|
-
logger_1.
|
|
49
|
+
logger_1.uiLogger.error(en_1.lib.projects.create.errors.noProjectsInConfig);
|
|
42
50
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
43
51
|
}
|
|
44
52
|
const templates = config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS];
|
|
45
53
|
const templatesContainAllProperties = templates.every(config => PROJECT_TEMPLATE_PROPERTIES.every(p => Object.prototype.hasOwnProperty.call(config, p)));
|
|
46
54
|
if (!templatesContainAllProperties) {
|
|
47
|
-
logger_1.
|
|
55
|
+
logger_1.uiLogger.error(en_1.lib.projects.create.errors.missingPropertiesInConfig);
|
|
48
56
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
49
57
|
}
|
|
50
58
|
return templates;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ComponentTemplate, ComponentTemplateChoice, ProjectTemplateRepoConfig } from '../../../types/Projects';
|
|
2
|
+
import { ProjectMetadata } from '@hubspot/project-parsing-lib/src/lib/project';
|
|
3
|
+
import { CreateProjectPromptResponse } from '../../prompts/createProjectPrompt';
|
|
4
|
+
export declare const EMPTY_PROJECT = "empty";
|
|
5
|
+
export declare const PROJECT_WITH_APP = "app";
|
|
6
|
+
export declare function createV3App(providedAuth: string | undefined, providedDistribution: string | undefined): Promise<{
|
|
7
|
+
authType: string;
|
|
8
|
+
distribution: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function calculateComponentTemplateChoices(components: ComponentTemplate[], authType: string | undefined, distribution: string | undefined, projectMetadata?: ProjectMetadata): ComponentTemplateChoice[];
|
|
11
|
+
type V3ComponentInfo = {
|
|
12
|
+
authType?: string;
|
|
13
|
+
distribution?: string;
|
|
14
|
+
repoConfig?: ProjectTemplateRepoConfig;
|
|
15
|
+
projectContents?: string;
|
|
16
|
+
componentTemplateChoices?: ComponentTemplateChoice[];
|
|
17
|
+
};
|
|
18
|
+
export declare function v3ComponentFlow(platformVersion: string, projectBase: string | undefined, providedAuth: string | undefined, providedDistribution: string | undefined): Promise<V3ComponentInfo>;
|
|
19
|
+
export declare function generateComponentPaths({ createProjectPromptResponse, platformVersion, repoConfig, projectContents, authType, distribution, }: {
|
|
20
|
+
createProjectPromptResponse: CreateProjectPromptResponse;
|
|
21
|
+
platformVersion: string;
|
|
22
|
+
repoConfig?: ProjectTemplateRepoConfig;
|
|
23
|
+
projectContents?: string;
|
|
24
|
+
authType?: string;
|
|
25
|
+
distribution?: string;
|
|
26
|
+
}): string[];
|
|
27
|
+
export {};
|