@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
|
@@ -40,10 +40,17 @@ async function injectAccountIdMiddleware(argv) {
|
|
|
40
40
|
const SKIP_CONFIG_VALIDATION = {
|
|
41
41
|
init: { target: true },
|
|
42
42
|
auth: { target: true },
|
|
43
|
+
mcp: {
|
|
44
|
+
target: false,
|
|
45
|
+
subCommands: {
|
|
46
|
+
setup: { target: true },
|
|
47
|
+
start: { target: true },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
43
50
|
};
|
|
44
51
|
async function loadConfigMiddleware(argv) {
|
|
45
52
|
// Skip this when no command is provided
|
|
46
|
-
if (!argv._.length) {
|
|
53
|
+
if (!argv._.length || argv.help) {
|
|
47
54
|
return;
|
|
48
55
|
}
|
|
49
56
|
const maybeValidateConfig = () => {
|
|
@@ -52,6 +59,13 @@ async function loadConfigMiddleware(argv) {
|
|
|
52
59
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
53
60
|
}
|
|
54
61
|
};
|
|
62
|
+
if (!(0, config_1.configFileExists)(true) &&
|
|
63
|
+
(0, utils_1.isTargetedCommand)(argv._, {
|
|
64
|
+
account: { target: false, subCommands: { auth: { target: true } } },
|
|
65
|
+
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
66
|
+
})) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
55
69
|
if ((0, config_1.configFileExists)(true) &&
|
|
56
70
|
argv.config &&
|
|
57
71
|
!(0, utils_1.isTargetedCommand)(argv._, {
|
|
@@ -75,10 +89,12 @@ async function loadConfigMiddleware(argv) {
|
|
|
75
89
|
const accountsSubCommands = {
|
|
76
90
|
target: false,
|
|
77
91
|
subCommands: {
|
|
92
|
+
auth: { target: true },
|
|
78
93
|
clean: { target: true },
|
|
79
94
|
list: { target: true },
|
|
80
95
|
ls: { target: true },
|
|
81
96
|
remove: { target: true },
|
|
97
|
+
use: { target: true },
|
|
82
98
|
},
|
|
83
99
|
};
|
|
84
100
|
const sandboxesSubCommands = {
|
|
@@ -87,17 +103,31 @@ const sandboxesSubCommands = {
|
|
|
87
103
|
delete: { target: true },
|
|
88
104
|
},
|
|
89
105
|
};
|
|
106
|
+
const configSubCommands = {
|
|
107
|
+
target: false,
|
|
108
|
+
subCommands: {
|
|
109
|
+
migrate: { target: true },
|
|
110
|
+
},
|
|
111
|
+
};
|
|
90
112
|
const SKIP_ACCOUNT_VALIDATION = {
|
|
91
113
|
init: { target: true },
|
|
92
114
|
auth: { target: true },
|
|
115
|
+
mcp: {
|
|
116
|
+
target: false,
|
|
117
|
+
subCommands: {
|
|
118
|
+
setup: { target: true },
|
|
119
|
+
start: { target: true },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
93
122
|
account: accountsSubCommands,
|
|
94
123
|
accounts: accountsSubCommands,
|
|
95
124
|
sandbox: sandboxesSubCommands,
|
|
96
125
|
sandboxes: sandboxesSubCommands,
|
|
126
|
+
config: configSubCommands,
|
|
97
127
|
};
|
|
98
128
|
async function validateAccountOptions(argv) {
|
|
99
129
|
// Skip this when no command is provided
|
|
100
|
-
if (argv._.length) {
|
|
130
|
+
if (argv._.length && !argv.help) {
|
|
101
131
|
let validAccount = true;
|
|
102
132
|
if (!(0, utils_1.isTargetedCommand)(argv._, SKIP_ACCOUNT_VALIDATION)) {
|
|
103
133
|
validAccount = await (0, validation_1.validateAccount)(argv);
|
|
@@ -6,11 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.checkFireAlarms = checkFireAlarms;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const fireAlarm_1 = require("@hubspot/local-dev-lib/api/fireAlarm");
|
|
9
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
9
|
const errorHandlers_1 = require("../errorHandlers");
|
|
11
10
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
12
|
-
const
|
|
13
|
-
const lang_1 = require("../lang");
|
|
11
|
+
const boxen_1 = require("../ui/boxen");
|
|
14
12
|
/*
|
|
15
13
|
* Versions can be formatted like this:
|
|
16
14
|
* =7.2.2 -> targets the exact version 7.2.2
|
|
@@ -106,30 +104,20 @@ async function logFireAlarms(accountId, command, version) {
|
|
|
106
104
|
}
|
|
107
105
|
return acc;
|
|
108
106
|
}, '');
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
logger_1.logger.debug(`${(0, lang_1.i18n)('lib.middleware.fireAlarm.failedToLoadBoxen')}`);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
logger_1.logger.log(boxen(notifications, {
|
|
119
|
-
title: 'Notifications',
|
|
120
|
-
titleAlignment: 'left',
|
|
121
|
-
borderColor: ui_1.UI_COLORS.MARIGOLD,
|
|
122
|
-
margin: 1,
|
|
123
|
-
padding: 1,
|
|
124
|
-
textAlignment: 'left',
|
|
125
|
-
borderStyle: 'round',
|
|
126
|
-
}));
|
|
107
|
+
await (0, boxen_1.logInBox)({
|
|
108
|
+
contents: notifications,
|
|
109
|
+
options: {
|
|
110
|
+
title: 'Notifications',
|
|
111
|
+
},
|
|
112
|
+
});
|
|
127
113
|
}
|
|
128
114
|
}
|
|
129
|
-
async function checkFireAlarms(
|
|
130
|
-
const { derivedAccountId } =
|
|
115
|
+
async function checkFireAlarms(argv) {
|
|
116
|
+
const { derivedAccountId } = argv;
|
|
131
117
|
try {
|
|
132
|
-
|
|
118
|
+
if (derivedAccountId) {
|
|
119
|
+
await logFireAlarms(derivedAccountId, argv._.join(' '), package_json_1.default.version);
|
|
120
|
+
}
|
|
133
121
|
}
|
|
134
122
|
catch (error) {
|
|
135
123
|
(0, errorHandlers_1.debugError)(error);
|
|
@@ -4,7 +4,7 @@ exports.performChecks = performChecks;
|
|
|
4
4
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
5
5
|
const exitCodes_1 = require("../enums/exitCodes");
|
|
6
6
|
const lang_1 = require("../lang");
|
|
7
|
-
const
|
|
7
|
+
const config_1 = require("../projects/config");
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
const UPLOAD_AND_WATCH_COMMANDS = {
|
|
10
10
|
upload: { target: true },
|
|
@@ -13,7 +13,7 @@ const UPLOAD_AND_WATCH_COMMANDS = {
|
|
|
13
13
|
function performChecks(argv) {
|
|
14
14
|
// Require "project" command when running upload/watch inside of a project
|
|
15
15
|
if ((0, utils_1.isTargetedCommand)(argv._, UPLOAD_AND_WATCH_COMMANDS) &&
|
|
16
|
-
(0,
|
|
16
|
+
(0, config_1.getIsInProject)(argv.src)) {
|
|
17
17
|
logger_1.logger.error((0, lang_1.i18n)(`commands.generalErrors.srcIsProject`, {
|
|
18
18
|
src: argv.src || './',
|
|
19
19
|
command: argv._.join(' '),
|
package/lib/npm.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const DEFAULT_PACKAGE_MANAGER = "npm";
|
|
2
|
+
export declare function isGloballyInstalled(packageName: string): Promise<boolean>;
|
|
3
|
+
export declare function getLatestCliVersion(): Promise<{
|
|
4
|
+
latest: string;
|
|
5
|
+
next: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function executeInstall(packages?: string[], flags?: string | null, options?: {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}): Promise<void>;
|
package/lib/npm.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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.DEFAULT_PACKAGE_MANAGER = void 0;
|
|
7
|
+
exports.isGloballyInstalled = isGloballyInstalled;
|
|
8
|
+
exports.getLatestCliVersion = getLatestCliVersion;
|
|
9
|
+
exports.executeInstall = executeInstall;
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const util_1 = __importDefault(require("util"));
|
|
12
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
13
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
14
|
+
exports.DEFAULT_PACKAGE_MANAGER = 'npm';
|
|
15
|
+
async function isGloballyInstalled(packageName) {
|
|
16
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
17
|
+
try {
|
|
18
|
+
await exec(`${packageName} --version`);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function getLatestCliVersion() {
|
|
26
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
27
|
+
const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
|
|
28
|
+
const { latest, next } = JSON.parse(stdout);
|
|
29
|
+
return { latest, next };
|
|
30
|
+
}
|
|
31
|
+
async function executeInstall(packages = [], flags, options) {
|
|
32
|
+
const installCommand = `${exports.DEFAULT_PACKAGE_MANAGER} install${flags ? ` ${flags}` : ''} ${packages.join(' ')}`;
|
|
33
|
+
logger_1.logger.debug('Running ', installCommand);
|
|
34
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
35
|
+
await exec(installCommand, options);
|
|
36
|
+
}
|
package/lib/oauth.js
CHANGED
|
@@ -19,13 +19,12 @@ const lang_1 = require("./lang");
|
|
|
19
19
|
const exitCodes_1 = require("./enums/exitCodes");
|
|
20
20
|
const PORT = 3000;
|
|
21
21
|
const redirectUri = `http://localhost:${PORT}/oauth-callback`;
|
|
22
|
-
const i18nKey = 'lib.oauth';
|
|
23
22
|
function buildAuthUrl(oauthManager) {
|
|
24
23
|
const { env: accountEnv, clientId, scopes: accountScopes, } = oauthManager.account;
|
|
25
24
|
const env = accountEnv || environments_1.ENVIRONMENTS.PROD;
|
|
26
25
|
const scopes = accountScopes || auth_1.DEFAULT_OAUTH_SCOPES;
|
|
27
26
|
if (!clientId) {
|
|
28
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
27
|
+
logger_1.logger.error((0, lang_1.i18n)(`lib.oauth.missingClientId`));
|
|
29
28
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
29
|
}
|
|
31
30
|
return (`${(0, urls_1.getHubSpotWebsiteOrigin)(env)}/oauth/${oauthManager.account.accountId}/authorize` +
|
package/lib/process.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.handleKeypress = handleKeypress;
|
|
|
9
9
|
const readline_1 = __importDefault(require("readline"));
|
|
10
10
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
11
11
|
const lang_1 = require("./lang");
|
|
12
|
-
const i18nKey = 'lib.process';
|
|
13
12
|
exports.TERMINATION_SIGNALS = [
|
|
14
13
|
'beforeExit',
|
|
15
14
|
'SIGINT', // Terminal trying to interrupt (Ctrl + C)
|
|
@@ -32,7 +31,7 @@ function handleExit(callback) {
|
|
|
32
31
|
if (isSIGHUP) {
|
|
33
32
|
(0, logger_1.setLogLevel)(logger_1.LOG_LEVEL.NONE);
|
|
34
33
|
}
|
|
35
|
-
logger_1.logger.debug((0, lang_1.i18n)(
|
|
34
|
+
logger_1.logger.debug((0, lang_1.i18n)(`lib.process.exitDebug`, { signal }));
|
|
36
35
|
await callback({ isSIGHUP });
|
|
37
36
|
}
|
|
38
37
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HsProfileFile } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
2
|
+
import { ProjectConfig } from '../types/Projects';
|
|
3
|
+
export declare function logProfileHeader(profileName: string): void;
|
|
4
|
+
export declare function logProfileFooter(profile: HsProfileFile, includeVariables?: boolean): void;
|
|
5
|
+
export declare function loadProfile(projectConfig: ProjectConfig | null, projectDir: string | null, profileName: string): HsProfileFile | undefined;
|
|
6
|
+
export declare function exitIfUsingProfiles(projectConfig: ProjectConfig | null, projectDir: string | null): Promise<void>;
|
|
7
|
+
export declare function loadAndValidateProfile(projectConfig: ProjectConfig | null, projectDir: string | null, argsProfile: string | undefined): Promise<number | undefined>;
|
|
@@ -0,0 +1,83 @@
|
|
|
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.logProfileHeader = logProfileHeader;
|
|
7
|
+
exports.logProfileFooter = logProfileFooter;
|
|
8
|
+
exports.loadProfile = loadProfile;
|
|
9
|
+
exports.exitIfUsingProfiles = exitIfUsingProfiles;
|
|
10
|
+
exports.loadAndValidateProfile = loadAndValidateProfile;
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
13
|
+
const en_1 = require("../lang/en");
|
|
14
|
+
const ui_1 = require("./ui");
|
|
15
|
+
const logger_1 = require("./ui/logger");
|
|
16
|
+
const exitCodes_1 = require("./enums/exitCodes");
|
|
17
|
+
function logProfileHeader(profileName) {
|
|
18
|
+
(0, ui_1.uiLine)();
|
|
19
|
+
(0, ui_1.uiBetaTag)(en_1.lib.projectProfiles.logs.usingProfile((0, project_parsing_lib_1.getHsProfileFilename)(profileName)));
|
|
20
|
+
logger_1.uiLogger.log('');
|
|
21
|
+
}
|
|
22
|
+
function logProfileFooter(profile, includeVariables = false) {
|
|
23
|
+
logger_1.uiLogger.log(en_1.lib.projectProfiles.logs.profileTargetAccount(profile.accountId));
|
|
24
|
+
if (includeVariables) {
|
|
25
|
+
logger_1.uiLogger.log('');
|
|
26
|
+
logger_1.uiLogger.log(en_1.lib.projectProfiles.logs.profileVariables);
|
|
27
|
+
Object.entries(profile.variables ?? {}).forEach(([key, value]) => {
|
|
28
|
+
logger_1.uiLogger.log(` ${key}: ${value}`);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
(0, ui_1.uiLine)();
|
|
32
|
+
logger_1.uiLogger.log('');
|
|
33
|
+
}
|
|
34
|
+
function loadProfile(projectConfig, projectDir, profileName) {
|
|
35
|
+
if (!projectConfig || !projectDir) {
|
|
36
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.noProjectConfig);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const projectSourceDir = path_1.default.join(projectDir, projectConfig.srcDir);
|
|
40
|
+
const profileFilename = (0, project_parsing_lib_1.getHsProfileFilename)(profileName);
|
|
41
|
+
try {
|
|
42
|
+
const profile = (0, project_parsing_lib_1.loadHsProfileFile)(projectSourceDir, profileName);
|
|
43
|
+
if (!profile) {
|
|
44
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.profileNotFound(profileFilename));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!profile.accountId) {
|
|
48
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.missingAccountId(profileFilename));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
return profile;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.failedToLoadProfile(profileFilename));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function exitIfUsingProfiles(projectConfig, projectDir) {
|
|
59
|
+
if (projectConfig && projectDir) {
|
|
60
|
+
const existingProfiles = await (0, project_parsing_lib_1.getAllHsProfiles)(path_1.default.join(projectDir, projectConfig.srcDir));
|
|
61
|
+
if (existingProfiles.length > 0) {
|
|
62
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.exitIfUsingProfiles.errors.noProfileSpecified);
|
|
63
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function loadAndValidateProfile(projectConfig, projectDir, argsProfile) {
|
|
68
|
+
if (argsProfile) {
|
|
69
|
+
logProfileHeader(argsProfile);
|
|
70
|
+
const profile = loadProfile(projectConfig, projectDir, argsProfile);
|
|
71
|
+
if (!profile) {
|
|
72
|
+
(0, ui_1.uiLine)();
|
|
73
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
74
|
+
}
|
|
75
|
+
logProfileFooter(profile, true);
|
|
76
|
+
return profile.accountId;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// A profile must be specified if this project has profiles configured
|
|
80
|
+
await exitIfUsingProfiles(projectConfig, projectDir);
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
@@ -14,7 +14,7 @@ declare class _ProjectLogsManager {
|
|
|
14
14
|
init(accountId: number): Promise<void>;
|
|
15
15
|
fetchFunctionDetails(): Promise<void>;
|
|
16
16
|
getFunctionNames(): string[];
|
|
17
|
-
setFunction(functionName
|
|
17
|
+
setFunction(functionName?: string): void;
|
|
18
18
|
}
|
|
19
19
|
export declare const ProjectLogsManager: _ProjectLogsManager;
|
|
20
20
|
export {};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProjectLogsManager = void 0;
|
|
4
|
-
const
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const ensureProjectExists_1 = require("./ensureProjectExists");
|
|
5
6
|
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
6
|
-
const logger_1 = require("
|
|
7
|
-
const
|
|
8
|
-
const ui_1 = require("../ui");
|
|
9
|
-
const i18nKey = 'commands.project.subcommands.logs';
|
|
7
|
+
const logger_1 = require("../ui/logger");
|
|
8
|
+
const en_1 = require("../../lang/en");
|
|
10
9
|
class _ProjectLogsManager {
|
|
11
10
|
projectName;
|
|
12
11
|
projectId;
|
|
@@ -32,32 +31,32 @@ class _ProjectLogsManager {
|
|
|
32
31
|
this.functions = [];
|
|
33
32
|
}
|
|
34
33
|
async init(accountId) {
|
|
35
|
-
const { projectConfig } = await (0,
|
|
34
|
+
const { projectConfig } = await (0, config_1.getProjectConfig)();
|
|
36
35
|
if (!projectConfig || !projectConfig.name) {
|
|
37
|
-
throw new Error(
|
|
36
|
+
throw new Error(en_1.commands.project.logs.errors.noProjectConfig);
|
|
38
37
|
}
|
|
39
38
|
const { name: projectName } = projectConfig;
|
|
40
39
|
this.projectName = projectName;
|
|
41
40
|
this.accountId = accountId;
|
|
42
41
|
this.functions = [];
|
|
43
|
-
const { project } = await (0,
|
|
42
|
+
const { project } = await (0, ensureProjectExists_1.ensureProjectExists)(this.accountId, this.projectName, {
|
|
44
43
|
allowCreate: false,
|
|
45
44
|
});
|
|
46
45
|
if (!project ||
|
|
47
46
|
!project.deployedBuild ||
|
|
48
47
|
!project.deployedBuild.subbuildStatuses) {
|
|
49
|
-
throw new Error(
|
|
48
|
+
throw new Error(en_1.commands.project.logs.errors.failedToFetchProjectDetails);
|
|
50
49
|
}
|
|
51
50
|
this.projectId = project.id;
|
|
52
51
|
await this.fetchFunctionDetails();
|
|
53
52
|
}
|
|
54
53
|
async fetchFunctionDetails() {
|
|
55
54
|
if (!this.projectId) {
|
|
56
|
-
throw new Error(
|
|
55
|
+
throw new Error(en_1.commands.project.logs.errors.noProjectConfig);
|
|
57
56
|
}
|
|
58
57
|
if (!this.accountId) {
|
|
59
|
-
logger_1.
|
|
60
|
-
throw new Error(
|
|
58
|
+
logger_1.uiLogger.debug(en_1.commands.project.logs.errors.projectLogsManagerNotInitialized);
|
|
59
|
+
throw new Error(en_1.commands.project.logs.errors.generic);
|
|
61
60
|
}
|
|
62
61
|
const { data: { topLevelComponentMetadata }, } = await (0, projects_1.fetchProjectComponentsMetadata)(this.accountId, this.projectId);
|
|
63
62
|
const apps = topLevelComponentMetadata.filter(componentMetadata => {
|
|
@@ -70,27 +69,23 @@ class _ProjectLogsManager {
|
|
|
70
69
|
...app.featureComponents.filter(component => component.type.name === 'APP_FUNCTION'));
|
|
71
70
|
});
|
|
72
71
|
if (this.functions.length === 0) {
|
|
73
|
-
throw new Error(
|
|
74
|
-
link: (0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.errors.noFunctionsLinkText`), 'https://developers.hubspot.com/docs/platform/serverless-functions'),
|
|
75
|
-
}));
|
|
72
|
+
throw new Error(en_1.commands.project.logs.errors.noFunctionsInProject);
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
getFunctionNames() {
|
|
79
76
|
return this.functions.map(serverlessFunction => serverlessFunction.componentName);
|
|
80
77
|
}
|
|
81
78
|
setFunction(functionName) {
|
|
82
|
-
if (!
|
|
83
|
-
throw new Error(
|
|
84
|
-
link: (0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.errors.noFunctionsLinkText`), 'https://developers.hubspot.com/docs/platform/serverless-functions'),
|
|
85
|
-
}));
|
|
79
|
+
if (!functionName || this.functions.length === 0) {
|
|
80
|
+
throw new Error(en_1.commands.project.logs.errors.noFunctionsInProject);
|
|
86
81
|
}
|
|
87
82
|
this.selectedFunction = this.functions.find(serverlessFunction => serverlessFunction.componentName === functionName);
|
|
88
83
|
if (!this.selectedFunction) {
|
|
89
|
-
throw new Error(
|
|
84
|
+
throw new Error(en_1.commands.project.logs.errors.noFunctionWithName(functionName));
|
|
90
85
|
}
|
|
91
86
|
this.functionName = functionName;
|
|
92
87
|
if (!this.selectedFunction.deployOutput) {
|
|
93
|
-
throw new Error(
|
|
88
|
+
throw new Error(en_1.commands.project.logs.errors.functionNotDeployed(functionName));
|
|
94
89
|
}
|
|
95
90
|
this.appId = this.selectedFunction.deployOutput.appId;
|
|
96
91
|
if (this.selectedFunction.deployOutput.endpoint) {
|
|
@@ -0,0 +1,48 @@
|
|
|
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.legacyAddComponent = legacyAddComponent;
|
|
7
|
+
const Projects_1 = require("../../../types/Projects");
|
|
8
|
+
const structure_1 = require("../structure");
|
|
9
|
+
const errorHandlers_1 = require("../../errorHandlers");
|
|
10
|
+
const en_1 = require("../../../lang/en");
|
|
11
|
+
const legacy_1 = require("../create/legacy");
|
|
12
|
+
const projectAddPrompt_1 = require("../../prompts/projectAddPrompt");
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
15
|
+
const github_1 = require("@hubspot/local-dev-lib/github");
|
|
16
|
+
const logger_1 = require("../../ui/logger");
|
|
17
|
+
async function legacyAddComponent(args, projectDir, projectConfig) {
|
|
18
|
+
// We currently only support adding private apps to projects
|
|
19
|
+
let projectContainsPublicApp = false;
|
|
20
|
+
try {
|
|
21
|
+
const components = await (0, structure_1.findProjectComponents)(projectDir);
|
|
22
|
+
projectContainsPublicApp = components.some(c => c.type === Projects_1.ComponentTypes.PublicApp);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
(0, errorHandlers_1.debugError)(err);
|
|
26
|
+
}
|
|
27
|
+
if (projectContainsPublicApp) {
|
|
28
|
+
throw new Error(en_1.commands.project.add.error.projectContainsPublicApp);
|
|
29
|
+
}
|
|
30
|
+
logger_1.uiLogger.log(en_1.commands.project.add.creatingComponent(projectConfig.name));
|
|
31
|
+
const components = await (0, legacy_1.getProjectComponentListFromRepo)(projectConfig.platformVersion);
|
|
32
|
+
if (!components || !components.length) {
|
|
33
|
+
throw new Error(en_1.commands.project.add.error.failedToFetchComponentList);
|
|
34
|
+
}
|
|
35
|
+
const projectAddPromptResponse = await (0, projectAddPrompt_1.projectAddPrompt)(components, args);
|
|
36
|
+
try {
|
|
37
|
+
const componentPath = path_1.default.join(projectDir, projectConfig.srcDir, projectAddPromptResponse.name);
|
|
38
|
+
await (0, github_1.cloneGithubRepo)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, componentPath, {
|
|
39
|
+
sourceDir: projectAddPromptResponse.componentTemplate.path,
|
|
40
|
+
branch: 'main',
|
|
41
|
+
hideLogs: true,
|
|
42
|
+
});
|
|
43
|
+
logger_1.uiLogger.success(en_1.commands.project.add.success(projectAddPromptResponse.name));
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new Error(en_1.commands.project.add.error.failedToDownloadComponent);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ProjectConfig } from '../../../types/Projects';
|
|
2
|
+
export declare function v3AddComponent(args: {
|
|
3
|
+
name?: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
features?: string[];
|
|
6
|
+
auth?: string;
|
|
7
|
+
distribution?: string;
|
|
8
|
+
}, projectDir: string, projectConfig: ProjectConfig): Promise<void>;
|
|
@@ -0,0 +1,85 @@
|
|
|
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.v3AddComponent = v3AddComponent;
|
|
7
|
+
const en_1 = require("../../../lang/en");
|
|
8
|
+
const legacy_1 = require("../create/legacy");
|
|
9
|
+
const v3_1 = require("../create/v3");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const projectAddPrompt_1 = require("../../prompts/projectAddPrompt");
|
|
13
|
+
const constants_1 = require("../../constants");
|
|
14
|
+
const components_1 = require("../components");
|
|
15
|
+
const project_1 = require("@hubspot/project-parsing-lib/src/lib/project");
|
|
16
|
+
const constants_2 = require("@hubspot/project-parsing-lib/src/lib/constants");
|
|
17
|
+
const github_1 = require("@hubspot/local-dev-lib/github");
|
|
18
|
+
const errorHandlers_1 = require("../../errorHandlers");
|
|
19
|
+
const logger_1 = require("../../ui/logger");
|
|
20
|
+
async function v3AddComponent(args, projectDir, projectConfig) {
|
|
21
|
+
logger_1.uiLogger.log(en_1.commands.project.add.creatingComponent(projectConfig.name));
|
|
22
|
+
const config = await (0, legacy_1.getConfigForPlatformVersion)(projectConfig.platformVersion);
|
|
23
|
+
const { components, parentComponents } = config;
|
|
24
|
+
if (!components || !components.length) {
|
|
25
|
+
throw new Error(en_1.commands.project.add.error.failedToFetchComponentList);
|
|
26
|
+
}
|
|
27
|
+
const projectSrcDirectory = path_1.default.join(projectDir, projectConfig.srcDir);
|
|
28
|
+
const projectMetadata = await (0, project_1.getProjectMetadata)(projectSrcDirectory);
|
|
29
|
+
let derivedAuthType;
|
|
30
|
+
let derivedDistribution;
|
|
31
|
+
const appsMetadata = projectMetadata.components[constants_2.AppKey];
|
|
32
|
+
const shouldCreateApp = appsMetadata.count === 0;
|
|
33
|
+
if (shouldCreateApp) {
|
|
34
|
+
const { authType, distribution } = await (0, v3_1.createV3App)(args.auth, args.distribution);
|
|
35
|
+
derivedDistribution = distribution;
|
|
36
|
+
derivedAuthType = authType;
|
|
37
|
+
}
|
|
38
|
+
else if (appsMetadata.count > appsMetadata.maxCount) {
|
|
39
|
+
throw new Error(en_1.lib.projects.create.errors.exceededMaxNumberOfApps(appsMetadata.maxCount));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const apps = appsMetadata.hsMetaFiles.map(appLoc => {
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(fs_1.default.readFileSync(appLoc, 'utf8'));
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
throw new Error(en_1.lib.projects.create.errors.unableToParseAppConfig(appLoc));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
derivedDistribution = apps[0].config?.distribution;
|
|
51
|
+
derivedAuthType = apps[0].config?.auth?.type;
|
|
52
|
+
}
|
|
53
|
+
const componentTemplateChoices = (0, v3_1.calculateComponentTemplateChoices)(components, derivedAuthType, derivedDistribution, projectMetadata);
|
|
54
|
+
const projectAddPromptResponse = await (0, projectAddPrompt_1.projectAddPromptV3)(componentTemplateChoices, args.features);
|
|
55
|
+
try {
|
|
56
|
+
const components = projectAddPromptResponse.componentTemplate?.map((componentTemplate) => {
|
|
57
|
+
return path_1.default.join(projectConfig.platformVersion, componentTemplate.path);
|
|
58
|
+
}) || [];
|
|
59
|
+
if (shouldCreateApp) {
|
|
60
|
+
const parentComponent = parentComponents?.find(possibleParent => {
|
|
61
|
+
return (possibleParent.type === v3_1.PROJECT_WITH_APP &&
|
|
62
|
+
possibleParent.authType === derivedAuthType &&
|
|
63
|
+
possibleParent.distribution === derivedDistribution);
|
|
64
|
+
});
|
|
65
|
+
if (parentComponent) {
|
|
66
|
+
components.push(path_1.default.join(projectConfig.platformVersion, parentComponent.path));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
await (0, github_1.cloneGithubRepo)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, projectDir, {
|
|
70
|
+
sourceDir: components,
|
|
71
|
+
hideLogs: true,
|
|
72
|
+
branch: 'main',
|
|
73
|
+
handleCollision: components_1.handleComponentCollision,
|
|
74
|
+
});
|
|
75
|
+
logger_1.uiLogger.success(en_1.commands.project.add.success(projectAddPromptResponse.componentTemplate
|
|
76
|
+
.map(template => `'${template.label}'`)
|
|
77
|
+
.join(', '), projectAddPromptResponse.componentTemplate.length > 1));
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
(0, errorHandlers_1.debugError)(error);
|
|
81
|
+
throw new Error(en_1.commands.project.add.error.failedToDownloadComponent, {
|
|
82
|
+
cause: error,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|