@hubspot/cli 7.5.1-experimental.0 → 7.5.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/migrate.d.ts +12 -3
- package/api/migrate.js +9 -2
- package/bin/cli.js +96 -93
- package/commands/account/auth.d.ts +6 -0
- package/commands/account/auth.js +167 -0
- package/commands/account/clean.d.ts +3 -7
- package/commands/account/clean.js +54 -14
- package/commands/account/createOverride.d.ts +6 -0
- package/commands/account/createOverride.js +121 -0
- package/commands/account/info.d.ts +3 -7
- package/commands/account/info.js +51 -9
- package/commands/account/list.d.ts +3 -7
- package/commands/account/list.js +38 -13
- package/commands/account/remove.d.ts +3 -7
- package/commands/account/remove.js +57 -11
- package/commands/account/removeOverride.d.ts +6 -0
- package/commands/account/removeOverride.js +93 -0
- 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 +39 -9
- package/commands/account.d.ts +3 -4
- package/commands/account.js +33 -53
- 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 +3 -7
- package/commands/auth.js +20 -25
- 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 +133 -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 +6 -0
- package/commands/config/migrate.js +75 -0
- package/commands/config/set.d.ts +10 -1
- package/commands/config/set.js +61 -32
- package/commands/config.d.ts +3 -1
- package/commands/config.js +19 -11
- package/commands/create/api-sample.d.ts +3 -1
- package/commands/create/api-sample.js +34 -36
- 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 +21 -11
- package/commands/customObject/schema/fetch-all.d.ts +4 -9
- package/commands/customObject/schema/fetch-all.js +19 -11
- package/commands/customObject/schema/fetch.d.ts +4 -9
- package/commands/customObject/schema/fetch.js +19 -11
- 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/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 -23
- 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/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 +4 -6
- package/commands/project/deploy.js +66 -36
- 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 -27
- package/commands/project/logs.d.ts +10 -1
- package/commands/project/logs.js +73 -65
- package/commands/project/migrate.d.ts +7 -8
- package/commands/project/migrate.js +49 -26
- 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 +110 -56
- 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 +47 -37
- 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 +3094 -0
- package/lang/en.js +2957 -3316
- package/lang/en.lyaml +89 -214
- 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 +171 -86
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/app/migrate_legacy.js +12 -11
- 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 -0
- package/lib/configMigrate.js +83 -0
- package/lib/configOptions.d.ts +4 -0
- package/lib/configOptions.js +41 -45
- package/lib/constants.d.ts +28 -0
- package/lib/constants.js +29 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +14 -40
- package/lib/doctor/Diagnosis.d.ts +1 -2
- package/lib/doctor/Diagnosis.js +19 -16
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +2 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +10 -9
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +59 -45
- package/lib/errorHandlers/index.js +6 -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/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 +23 -3
- package/lib/middleware/fireAlarmMiddleware.d.ts +4 -0
- package/lib/middleware/fireAlarmMiddleware.js +125 -0
- 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 +6 -0
- package/lib/projectProfiles.js +65 -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 +45 -41
- 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 +27 -0
- package/lib/projects/localDev/AppDevModeInterface.js +186 -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 +14 -2
- package/lib/projects/upload.js +25 -35
- package/lib/projects/urls.d.ts +2 -0
- package/lib/projects/urls.js +14 -2
- 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 +41 -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 +1 -0
- package/lib/prompts/installAppPrompt.js +35 -0
- package/lib/prompts/personalAccessKeyPrompt.js +17 -18
- 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 +3 -2
- package/lib/prompts/promptUtils.js +2 -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/SpinniesManager.d.ts +1 -1
- 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 +4 -2
- package/lib/ui/index.js +20 -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/ui/spinniesUtils.d.ts +5 -5
- 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/package.json +17 -11
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +34 -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 -14
- 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 -21
- package/lib/projects/index.js +0 -194
- package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
- package/lib/prompts/installPublicAppPrompt.js +0 -40
|
@@ -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 {};
|
|
@@ -0,0 +1,158 @@
|
|
|
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.PROJECT_WITH_APP = exports.EMPTY_PROJECT = void 0;
|
|
7
|
+
exports.createV3App = createV3App;
|
|
8
|
+
exports.calculateComponentTemplateChoices = calculateComponentTemplateChoices;
|
|
9
|
+
exports.v3ComponentFlow = v3ComponentFlow;
|
|
10
|
+
exports.generateComponentPaths = generateComponentPaths;
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
|
+
const en_1 = require("../../../lang/en");
|
|
13
|
+
const promptUtils_1 = require("../../prompts/promptUtils");
|
|
14
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
15
|
+
const buildAndDeploy_1 = require("../buildAndDeploy");
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const legacy_1 = require("./legacy");
|
|
18
|
+
const errorHandlers_1 = require("../../errorHandlers");
|
|
19
|
+
const exitCodes_1 = require("../../enums/exitCodes");
|
|
20
|
+
const inquirer = require('inquirer');
|
|
21
|
+
exports.EMPTY_PROJECT = 'empty';
|
|
22
|
+
exports.PROJECT_WITH_APP = 'app';
|
|
23
|
+
async function createV3App(providedAuth, providedDistribution) {
|
|
24
|
+
let authType;
|
|
25
|
+
if (providedAuth &&
|
|
26
|
+
providedDistribution === constants_1.marketplaceDistribution &&
|
|
27
|
+
providedAuth !== constants_1.oAuth) {
|
|
28
|
+
throw new Error(en_1.lib.projects.create.errors.invalidAuthDistCombo(providedAuth, providedDistribution));
|
|
29
|
+
}
|
|
30
|
+
const distribution = providedDistribution ||
|
|
31
|
+
(await (0, promptUtils_1.listPrompt)(en_1.lib.projects.create.prompt.distribution, {
|
|
32
|
+
choices: [
|
|
33
|
+
{
|
|
34
|
+
name: en_1.lib.projects.create.prompt.marketPlaceDistribution,
|
|
35
|
+
value: constants_1.marketplaceDistribution,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: en_1.lib.projects.create.prompt.privateDistribution,
|
|
39
|
+
value: constants_1.privateDistribution,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}));
|
|
43
|
+
if (distribution === constants_1.marketplaceDistribution) {
|
|
44
|
+
// This is the only valid auth type for marketplace
|
|
45
|
+
authType = constants_1.oAuth;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
authType =
|
|
49
|
+
providedAuth ||
|
|
50
|
+
(await (0, promptUtils_1.listPrompt)(en_1.lib.projects.create.prompt.auth, {
|
|
51
|
+
choices: [
|
|
52
|
+
{ name: en_1.lib.projects.create.prompt.staticAuth, value: constants_1.staticAuth },
|
|
53
|
+
{ name: en_1.lib.projects.create.prompt.oauth, value: constants_1.oAuth },
|
|
54
|
+
],
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
distribution,
|
|
59
|
+
authType,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function calculateComponentTemplateChoices(components, authType, distribution, projectMetadata) {
|
|
63
|
+
const enabledComponents = [];
|
|
64
|
+
const disabledComponents = [];
|
|
65
|
+
components.forEach(template => {
|
|
66
|
+
const { supportedAuthTypes, supportedDistributions } = template;
|
|
67
|
+
const disabledReasons = [];
|
|
68
|
+
if (projectMetadata) {
|
|
69
|
+
const { count, maxCount } = projectMetadata.components[template.type];
|
|
70
|
+
if (count >= maxCount) {
|
|
71
|
+
disabledReasons.push(en_1.commands.project.add.error.maxExceeded(maxCount));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(supportedAuthTypes) &&
|
|
75
|
+
authType &&
|
|
76
|
+
!supportedAuthTypes.includes(authType)) {
|
|
77
|
+
disabledReasons.push(en_1.commands.project.add.error.authTypeNotAllowed(authType));
|
|
78
|
+
}
|
|
79
|
+
if (Array.isArray(supportedDistributions) &&
|
|
80
|
+
distribution &&
|
|
81
|
+
!supportedDistributions.includes(distribution)) {
|
|
82
|
+
disabledReasons.push(en_1.commands.project.add.error.distributionNotAllowed(distribution));
|
|
83
|
+
}
|
|
84
|
+
if (disabledReasons.length > 0) {
|
|
85
|
+
disabledComponents.push({
|
|
86
|
+
name: `[${chalk_1.default.yellow('DISABLED')}] ${template.label}`,
|
|
87
|
+
value: template,
|
|
88
|
+
disabled: disabledReasons.join(' '),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
enabledComponents.push({
|
|
93
|
+
name: template.label,
|
|
94
|
+
value: template,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return disabledComponents.length
|
|
99
|
+
? [...enabledComponents, new inquirer.Separator(), ...disabledComponents]
|
|
100
|
+
: [...enabledComponents];
|
|
101
|
+
}
|
|
102
|
+
async function v3ComponentFlow(platformVersion, projectBase, providedAuth, providedDistribution) {
|
|
103
|
+
let repoConfig = undefined;
|
|
104
|
+
let authType;
|
|
105
|
+
let distribution;
|
|
106
|
+
try {
|
|
107
|
+
repoConfig = await (0, legacy_1.getConfigForPlatformVersion)(platformVersion);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
(0, errorHandlers_1.logError)(error);
|
|
111
|
+
return process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
112
|
+
}
|
|
113
|
+
const projectContentsChoice = projectBase ||
|
|
114
|
+
(await (0, promptUtils_1.listPrompt)(en_1.commands.project.create.prompts.parentComponents, {
|
|
115
|
+
choices: [
|
|
116
|
+
{
|
|
117
|
+
name: en_1.commands.project.create.prompts.emptyProject,
|
|
118
|
+
value: exports.EMPTY_PROJECT,
|
|
119
|
+
},
|
|
120
|
+
{ name: en_1.commands.project.create.prompts.app, value: exports.PROJECT_WITH_APP },
|
|
121
|
+
],
|
|
122
|
+
}));
|
|
123
|
+
if (projectContentsChoice === exports.PROJECT_WITH_APP) {
|
|
124
|
+
const { authType: selectedAuthType, distribution: selectedDistribution } = await createV3App(providedAuth, providedDistribution);
|
|
125
|
+
authType = selectedAuthType;
|
|
126
|
+
distribution = selectedDistribution;
|
|
127
|
+
}
|
|
128
|
+
const componentTemplateChoices = calculateComponentTemplateChoices(repoConfig?.components || [], authType, distribution);
|
|
129
|
+
return {
|
|
130
|
+
componentTemplateChoices,
|
|
131
|
+
authType,
|
|
132
|
+
distribution,
|
|
133
|
+
projectContents: projectContentsChoice,
|
|
134
|
+
repoConfig,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function generateComponentPaths({ createProjectPromptResponse, platformVersion, repoConfig, projectContents, authType, distribution, }) {
|
|
138
|
+
if (!(0, buildAndDeploy_1.useV3Api)(platformVersion)) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
const components = createProjectPromptResponse.componentTemplates?.map((componentTemplate) => {
|
|
142
|
+
return path_1.default.join(platformVersion, componentTemplate.path);
|
|
143
|
+
}) || [];
|
|
144
|
+
if (projectContents && projectContents !== exports.EMPTY_PROJECT) {
|
|
145
|
+
const parentComponent = repoConfig?.parentComponents?.find(possibleParent => {
|
|
146
|
+
return (possibleParent.type === projectContents &&
|
|
147
|
+
possibleParent.authType === authType &&
|
|
148
|
+
possibleParent.distribution === distribution);
|
|
149
|
+
});
|
|
150
|
+
if (parentComponent) {
|
|
151
|
+
components.push(path_1.default.join(platformVersion, parentComponent.path));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (repoConfig?.defaultFiles) {
|
|
155
|
+
components.push(path_1.default.join(platformVersion, repoConfig?.defaultFiles));
|
|
156
|
+
}
|
|
157
|
+
return components;
|
|
158
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Project } from '@hubspot/local-dev-lib/types/Project';
|
|
2
|
+
export declare function ensureProjectExists(accountId: number, projectName: string, { forceCreate, allowCreate, noLogs, withPolling, uploadCommand, }?: {
|
|
3
|
+
forceCreate?: boolean | undefined;
|
|
4
|
+
allowCreate?: boolean | undefined;
|
|
5
|
+
noLogs?: boolean | undefined;
|
|
6
|
+
withPolling?: boolean | undefined;
|
|
7
|
+
uploadCommand?: boolean | undefined;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
projectExists: boolean;
|
|
10
|
+
project?: Project;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,97 @@
|
|
|
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.ensureProjectExists = ensureProjectExists;
|
|
7
|
+
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
8
|
+
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const promptUtils_1 = require("../prompts/promptUtils");
|
|
11
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
12
|
+
const ui_1 = require("../ui");
|
|
13
|
+
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
14
|
+
const index_2 = require("../errorHandlers/index");
|
|
15
|
+
const en_1 = require("../../lang/en");
|
|
16
|
+
const logger_1 = require("../ui/logger");
|
|
17
|
+
async function pollFetchProject(accountId, projectName) {
|
|
18
|
+
// Temporary solution for gating slowness. Retry on 403 statusCode
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
let pollCount = 0;
|
|
21
|
+
SpinniesManager_1.default.init();
|
|
22
|
+
SpinniesManager_1.default.add('pollFetchProject', {
|
|
23
|
+
text: en_1.lib.projects.pollFetchProject.checkingProject((0, ui_1.uiAccountDescription)(accountId)),
|
|
24
|
+
});
|
|
25
|
+
const pollInterval = setInterval(async () => {
|
|
26
|
+
try {
|
|
27
|
+
const response = await (0, projects_1.fetchProject)(accountId, projectName);
|
|
28
|
+
if (response && response.data) {
|
|
29
|
+
SpinniesManager_1.default.remove('pollFetchProject');
|
|
30
|
+
clearInterval(pollInterval);
|
|
31
|
+
resolve(response);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
if ((0, index_1.isSpecifiedError)(err, {
|
|
36
|
+
statusCode: 403,
|
|
37
|
+
category: 'GATED',
|
|
38
|
+
subCategory: 'BuildPipelineErrorType.PORTAL_GATED',
|
|
39
|
+
}) &&
|
|
40
|
+
pollCount < 15) {
|
|
41
|
+
pollCount += 1;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
SpinniesManager_1.default.remove('pollFetchProject');
|
|
45
|
+
clearInterval(pollInterval);
|
|
46
|
+
reject(err);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, constants_1.DEFAULT_POLLING_DELAY);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function ensureProjectExists(accountId, projectName, { forceCreate = false, allowCreate = true, noLogs = false, withPolling = false, uploadCommand = false, } = {}) {
|
|
53
|
+
const accountIdentifier = (0, ui_1.uiAccountDescription)(accountId);
|
|
54
|
+
try {
|
|
55
|
+
const { data: project } = withPolling
|
|
56
|
+
? await pollFetchProject(accountId, projectName)
|
|
57
|
+
: await (0, projects_1.fetchProject)(accountId, projectName);
|
|
58
|
+
return { projectExists: !!project, project };
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if ((0, index_1.isSpecifiedError)(err, { statusCode: 404 })) {
|
|
62
|
+
let shouldCreateProject = forceCreate;
|
|
63
|
+
if (allowCreate && !shouldCreateProject) {
|
|
64
|
+
const promptLangFunction = uploadCommand
|
|
65
|
+
? en_1.lib.projects.ensureProjectExists.createPromptUpload
|
|
66
|
+
: en_1.lib.projects.ensureProjectExists.createPrompt;
|
|
67
|
+
const promptResult = await (0, promptUtils_1.promptUser)([
|
|
68
|
+
{
|
|
69
|
+
name: 'shouldCreateProject',
|
|
70
|
+
message: promptLangFunction(projectName, accountIdentifier),
|
|
71
|
+
type: 'confirm',
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
shouldCreateProject = promptResult.shouldCreateProject;
|
|
75
|
+
}
|
|
76
|
+
if (shouldCreateProject) {
|
|
77
|
+
try {
|
|
78
|
+
const { data: project } = await (0, projects_1.createProject)(accountId, projectName);
|
|
79
|
+
logger_1.uiLogger.success(en_1.lib.projects.ensureProjectExists.createSuccess(projectName, accountIdentifier));
|
|
80
|
+
return { projectExists: true, project };
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
(0, index_2.logError)(err, new index_2.ApiErrorContext({ accountId }));
|
|
84
|
+
return { projectExists: false };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (!noLogs) {
|
|
89
|
+
logger_1.uiLogger.log(en_1.lib.projects.ensureProjectExists.notFound(projectName, accountIdentifier));
|
|
90
|
+
}
|
|
91
|
+
return { projectExists: false };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
(0, index_2.logError)(err, new index_2.ApiErrorContext({ accountId }));
|
|
95
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AppIRNode } from '../../../types/ProjectComponents';
|
|
2
|
+
import LocalDevState from './LocalDevState';
|
|
3
|
+
import LocalDevLogger from './LocalDevLogger';
|
|
4
|
+
type AppDevModeInterfaceConstructorOptions = {
|
|
5
|
+
localDevState: LocalDevState;
|
|
6
|
+
localDevLogger: LocalDevLogger;
|
|
7
|
+
};
|
|
8
|
+
declare class AppDevModeInterface {
|
|
9
|
+
localDevState: LocalDevState;
|
|
10
|
+
localDevLogger: LocalDevLogger;
|
|
11
|
+
_appNode?: AppIRNode | null;
|
|
12
|
+
marketplaceAppInstalls?: number;
|
|
13
|
+
constructor(options: AppDevModeInterfaceConstructorOptions);
|
|
14
|
+
private get appNode();
|
|
15
|
+
private get appData();
|
|
16
|
+
private set appData(value);
|
|
17
|
+
private getAppInstallUrl;
|
|
18
|
+
private fetchAppData;
|
|
19
|
+
private checkMarketplaceAppInstalls;
|
|
20
|
+
private checkTestAccountAppInstallation;
|
|
21
|
+
private setUpLocalDevServerMessageListeners;
|
|
22
|
+
setup(args: any): Promise<void>;
|
|
23
|
+
start(): Promise<void>;
|
|
24
|
+
fileChange(filePath: string, event: string): Promise<void>;
|
|
25
|
+
cleanup(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export default AppDevModeInterface;
|