@hubspot/cli 7.4.8-experimental.0 → 7.4.9-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/migrate.d.ts +14 -4
- package/api/migrate.js +16 -2
- package/bin/cli.js +8 -183
- package/commands/account/auth.d.ts +10 -0
- package/commands/account/auth.js +188 -0
- package/commands/account/clean.js +38 -5
- package/commands/account/createOverride.d.ts +10 -0
- package/commands/account/createOverride.js +113 -0
- package/commands/account/info.js +38 -4
- package/commands/account/list.js +23 -5
- package/commands/account/remove.js +42 -3
- package/commands/account/removeOverride.d.ts +10 -0
- package/commands/account/removeOverride.js +85 -0
- package/commands/account/use.js +25 -3
- package/commands/account.js +7 -2
- package/commands/app/migrate.d.ts +6 -6
- package/commands/app/migrate.js +62 -45
- package/commands/app.js +0 -2
- package/commands/auth.js +15 -12
- 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 +24 -16
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +25 -13
- package/commands/config/migrate.d.ts +10 -0
- package/commands/config/migrate.js +84 -0
- package/commands/config/set.d.ts +10 -0
- package/commands/config/set.js +34 -29
- package/commands/config.d.ts +4 -1
- package/commands/config.js +45 -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 +55 -74
- package/commands/customObject/create.d.ts +4 -9
- package/commands/customObject/create.js +17 -10
- package/commands/customObject/schema/create.d.ts +4 -9
- package/commands/customObject/schema/create.js +18 -11
- package/commands/customObject/schema/delete.d.ts +4 -9
- package/commands/customObject/schema/delete.js +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 +22 -48
- package/commands/doctor.js +5 -6
- package/commands/feedback.d.ts +7 -1
- package/commands/feedback.js +36 -21
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -34
- package/commands/filemanager.js +1 -2
- 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 +24 -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.d.ts +3 -2
- package/commands/hubdb.js +24 -47
- package/commands/init.js +18 -20
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +44 -44
- package/commands/list.js +5 -6
- 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 -28
- package/commands/module.d.ts +3 -1
- package/commands/module.js +22 -12
- package/commands/mv.js +4 -5
- package/commands/open.js +4 -5
- package/commands/project/add.d.ts +3 -7
- package/commands/project/add.js +28 -23
- package/commands/project/cloneApp.d.ts +6 -8
- package/commands/project/cloneApp.js +49 -45
- package/commands/project/create.d.ts +10 -1
- package/commands/project/create.js +85 -63
- package/commands/project/deploy.d.ts +3 -6
- package/commands/project/deploy.js +27 -25
- package/commands/project/dev/deprecatedFlow.js +32 -25
- package/commands/project/dev/index.d.ts +4 -2
- package/commands/project/dev/index.js +31 -18
- package/commands/project/dev/unifiedFlow.js +37 -15
- 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 +6 -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/upload.d.ts +9 -1
- package/commands/project/upload.js +78 -54
- 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 -35
- package/commands/remove.js +7 -5
- 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 +20 -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 +25 -49
- package/commands/theme/generate-selectors.js +5 -6
- package/commands/theme/marketplace-validate.js +5 -6
- package/commands/theme/preview.js +16 -16
- package/commands/theme.js +1 -2
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +118 -98
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +76 -66
- package/lang/en.d.ts +2828 -0
- package/lang/en.js +2681 -3300
- package/lang/en.lyaml +101 -41
- package/lib/accountTypes.d.ts +1 -0
- package/lib/accountTypes.js +12 -0
- package/lib/app/migrate.d.ts +10 -4
- package/lib/app/migrate.js +208 -94
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/app/migrate_legacy.js +10 -7
- package/lib/buildAccount.d.ts +1 -2
- package/lib/buildAccount.js +11 -10
- package/lib/commonOpts.d.ts +3 -4
- package/lib/commonOpts.js +46 -18
- package/lib/configMigrate.d.ts +2 -0
- package/lib/configMigrate.js +104 -0
- package/lib/configOptions.js +11 -10
- package/lib/constants.d.ts +9 -0
- package/lib/constants.js +10 -1
- package/lib/dependencyManagement.js +2 -2
- 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 +57 -44
- 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 +1 -2
- package/lib/hasFeature.d.ts +3 -1
- package/lib/interpolation.d.ts +2 -3
- package/lib/lang.d.ts +2 -3
- package/lib/middleware/__test__/configMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/configMiddleware.test.js +194 -0
- package/lib/middleware/__test__/gitMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/gitMiddleware.test.js +76 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.js +10 -0
- package/lib/middleware/__test__/requestMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/requestMiddleware.test.js +20 -0
- package/lib/middleware/__test__/utils.test.d.ts +1 -0
- package/lib/middleware/__test__/utils.test.js +53 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +81 -0
- package/lib/middleware/configMiddleware.d.ts +13 -0
- package/lib/middleware/configMiddleware.js +116 -0
- package/lib/middleware/fireAlarmMiddleware.d.ts +4 -0
- package/lib/middleware/fireAlarmMiddleware.js +123 -0
- package/lib/middleware/gitMiddleware.d.ts +2 -0
- package/lib/middleware/gitMiddleware.js +14 -0
- package/lib/middleware/notificationsMiddleware.d.ts +1 -0
- package/lib/middleware/notificationsMiddleware.js +38 -0
- package/lib/middleware/requestMiddleware.d.ts +1 -0
- package/lib/middleware/requestMiddleware.js +11 -0
- package/lib/middleware/utils.d.ts +8 -0
- package/lib/middleware/utils.js +17 -0
- package/lib/middleware/yargsChecksMiddleware.d.ts +4 -0
- package/lib/middleware/yargsChecksMiddleware.js +24 -0
- package/lib/oauth.js +1 -2
- package/lib/process.js +1 -2
- package/lib/projects/ProjectLogsManager.d.ts +1 -1
- package/lib/projects/ProjectLogsManager.js +16 -21
- package/lib/projects/buildAndDeploy.js +45 -41
- package/lib/projects/config.d.ts +9 -0
- package/lib/projects/config.js +79 -0
- package/lib/projects/create.js +5 -6
- package/lib/projects/ensureProjectExists.d.ts +11 -0
- package/lib/projects/ensureProjectExists.js +97 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +25 -0
- package/lib/projects/localDev/AppDevModeInterface.js +117 -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 +158 -0
- package/lib/{LocalDevManager.d.ts → projects/localDev/LocalDevManager.d.ts} +1 -1
- package/lib/{LocalDevManager.js → projects/localDev/LocalDevManager.js} +48 -82
- package/lib/projects/localDev/LocalDevProcess.d.ts +41 -0
- package/lib/projects/localDev/LocalDevProcess.js +178 -0
- package/lib/projects/localDev/LocalDevWatcher.d.ts +10 -0
- package/lib/projects/localDev/LocalDevWatcher.js +55 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +15 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +80 -0
- package/lib/{localDev.d.ts → projects/localDev/helpers.d.ts} +5 -4
- package/lib/{localDev.js → projects/localDev/helpers.js} +97 -114
- package/lib/projects/ui.d.ts +1 -0
- package/lib/projects/ui.js +15 -0
- package/lib/projects/upload.d.ts +13 -2
- package/lib/projects/upload.js +18 -34
- package/lib/projects/urls.d.ts +1 -0
- package/lib/projects/urls.js +6 -0
- 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 +11 -4
- package/lib/prompts/createProjectPrompt.js +14 -9
- 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/installPublicAppPrompt.js +6 -5
- package/lib/prompts/personalAccessKeyPrompt.js +17 -18
- package/lib/prompts/previewPrompt.js +5 -6
- package/lib/prompts/projectAddPrompt.js +4 -5
- package/lib/prompts/projectDevTargetAccountPrompt.js +11 -12
- package/lib/prompts/projectNamePrompt.js +5 -6
- package/lib/prompts/projectsLogsPrompt.js +3 -2
- package/lib/prompts/promptUtils.d.ts +1 -1
- package/lib/prompts/sandboxesPrompt.js +5 -6
- package/lib/prompts/secretPrompt.js +2 -3
- package/lib/prompts/selectHubDBTablePrompt.js +11 -8
- package/lib/prompts/selectPublicAppPrompt.js +6 -7
- package/lib/prompts/setAsDefaultAccountPrompt.js +1 -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/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 +16 -16
- 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/yargsUtils.d.ts +5 -1
- package/lib/yargsUtils.js +6 -0
- package/package.json +9 -6
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +22 -0
- package/types/LocalDev.js +2 -0
- package/types/Yargs.d.ts +9 -10
- package/lib/DevServerManagerV2.d.ts +0 -33
- package/lib/LocalDevManagerV2.d.ts +0 -64
- package/lib/LocalDevManagerV2.js +0 -377
- package/lib/projects/index.d.ts +0 -20
- package/lib/projects/index.js +0 -194
package/lib/projects/upload.js
CHANGED
|
@@ -10,23 +10,20 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
12
12
|
const ignoreRules_1 = require("@hubspot/local-dev-lib/ignoreRules");
|
|
13
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
13
|
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
15
14
|
const ui_1 = require("../ui");
|
|
16
|
-
const lang_1 = require("../lang");
|
|
17
15
|
const exitCodes_1 = require("../enums/exitCodes");
|
|
18
16
|
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
19
17
|
const errorHandlers_1 = require("../errorHandlers");
|
|
20
18
|
const node_util_1 = __importDefault(require("node:util"));
|
|
21
|
-
const
|
|
19
|
+
const en_1 = require("../../lang/en");
|
|
20
|
+
const ensureProjectExists_1 = require("./ensureProjectExists");
|
|
21
|
+
const logger_1 = require("../ui/logger");
|
|
22
22
|
async function uploadProjectFiles(accountId, projectName, filePath, uploadMessage, platformVersion, intermediateRepresentation) {
|
|
23
23
|
SpinniesManager_1.default.init({});
|
|
24
24
|
const accountIdentifier = (0, ui_1.uiAccountDescription)(accountId);
|
|
25
25
|
SpinniesManager_1.default.add('upload', {
|
|
26
|
-
text:
|
|
27
|
-
accountIdentifier,
|
|
28
|
-
projectName,
|
|
29
|
-
}),
|
|
26
|
+
text: en_1.lib.projectUpload.uploadProjectFiles.add(projectName, accountIdentifier),
|
|
30
27
|
succeedColor: 'white',
|
|
31
28
|
});
|
|
32
29
|
let buildId;
|
|
@@ -35,48 +32,33 @@ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessag
|
|
|
35
32
|
const { data: upload } = await (0, projects_1.uploadProject)(accountId, projectName, filePath, uploadMessage, platformVersion, intermediateRepresentation);
|
|
36
33
|
buildId = upload.buildId;
|
|
37
34
|
SpinniesManager_1.default.succeed('upload', {
|
|
38
|
-
text:
|
|
39
|
-
accountIdentifier,
|
|
40
|
-
projectName,
|
|
41
|
-
}),
|
|
35
|
+
text: en_1.lib.projectUpload.uploadProjectFiles.succeed(projectName, accountIdentifier),
|
|
42
36
|
});
|
|
43
37
|
if (buildId) {
|
|
44
|
-
logger_1.
|
|
45
|
-
buildId,
|
|
46
|
-
projectName,
|
|
47
|
-
}));
|
|
38
|
+
logger_1.uiLogger.debug(en_1.lib.projectUpload.uploadProjectFiles.buildCreated(projectName, buildId));
|
|
48
39
|
}
|
|
49
40
|
}
|
|
50
41
|
catch (err) {
|
|
51
42
|
SpinniesManager_1.default.fail('upload', {
|
|
52
|
-
text:
|
|
53
|
-
accountIdentifier,
|
|
54
|
-
projectName,
|
|
55
|
-
}),
|
|
43
|
+
text: en_1.lib.projectUpload.uploadProjectFiles.fail(projectName, accountIdentifier),
|
|
56
44
|
});
|
|
57
45
|
error = err;
|
|
58
46
|
}
|
|
59
47
|
return { buildId, error };
|
|
60
48
|
}
|
|
61
|
-
async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage, sendIR = false, skipValidation = false) {
|
|
49
|
+
async function handleProjectUpload({ accountId, projectConfig, projectDir, callbackFunc, uploadMessage = '', forceCreate = false, isUploadCommand = false, sendIR = false, skipValidation = false, }) {
|
|
62
50
|
const srcDir = path_1.default.resolve(projectDir, projectConfig.srcDir);
|
|
63
51
|
const filenames = fs_extra_1.default.readdirSync(srcDir);
|
|
64
52
|
if (!filenames || filenames.length === 0) {
|
|
65
|
-
logger_1.
|
|
66
|
-
srcDir: projectConfig.srcDir,
|
|
67
|
-
}));
|
|
53
|
+
logger_1.uiLogger.log(en_1.lib.projectUpload.handleProjectUpload.emptySource(projectConfig.srcDir));
|
|
68
54
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
69
55
|
}
|
|
70
56
|
const tempFile = tmp_1.default.fileSync({ postfix: '.zip' });
|
|
71
|
-
logger_1.
|
|
72
|
-
path: tempFile.name,
|
|
73
|
-
}));
|
|
57
|
+
logger_1.uiLogger.debug(en_1.lib.projectUpload.handleProjectUpload.compressing(tempFile.name));
|
|
74
58
|
const output = fs_extra_1.default.createWriteStream(tempFile.name);
|
|
75
59
|
const archive = (0, archiver_1.default)('zip');
|
|
76
60
|
const result = new Promise(resolve => output.on('close', async function () {
|
|
77
|
-
logger_1.
|
|
78
|
-
byteCount: archive.pointer(),
|
|
79
|
-
}));
|
|
61
|
+
logger_1.uiLogger.debug(en_1.lib.projectUpload.handleProjectUpload.compressed(archive.pointer()));
|
|
80
62
|
let intermediateRepresentation;
|
|
81
63
|
if (sendIR) {
|
|
82
64
|
try {
|
|
@@ -85,11 +67,11 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
|
|
|
85
67
|
platformVersion: projectConfig.platformVersion,
|
|
86
68
|
accountId,
|
|
87
69
|
}, { skipValidation });
|
|
88
|
-
logger_1.
|
|
70
|
+
logger_1.uiLogger.debug(node_util_1.default.inspect(intermediateRepresentation, false, null, true));
|
|
89
71
|
}
|
|
90
72
|
catch (e) {
|
|
91
73
|
if ((0, project_parsing_lib_1.isTranslationError)(e)) {
|
|
92
|
-
logger_1.
|
|
74
|
+
logger_1.uiLogger.error(e.toString());
|
|
93
75
|
}
|
|
94
76
|
else {
|
|
95
77
|
(0, errorHandlers_1.logError)(e);
|
|
@@ -97,6 +79,10 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
|
|
|
97
79
|
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
98
80
|
}
|
|
99
81
|
}
|
|
82
|
+
await (0, ensureProjectExists_1.ensureProjectExists)(accountId, projectConfig.name, {
|
|
83
|
+
forceCreate,
|
|
84
|
+
uploadCommand: isUploadCommand,
|
|
85
|
+
});
|
|
100
86
|
const { buildId, error } = await uploadProjectFiles(accountId, projectConfig.name, tempFile.name, uploadMessage, projectConfig.platformVersion, intermediateRepresentation);
|
|
101
87
|
if (error) {
|
|
102
88
|
resolve({ uploadError: error });
|
|
@@ -113,9 +99,7 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
|
|
|
113
99
|
if (ignored) {
|
|
114
100
|
const isNodeModule = file.name.includes('node_modules');
|
|
115
101
|
if (!isNodeModule || !loggedIgnoredNodeModule) {
|
|
116
|
-
logger_1.
|
|
117
|
-
filename: file.name,
|
|
118
|
-
}));
|
|
102
|
+
logger_1.uiLogger.debug(en_1.lib.projectUpload.handleProjectUpload.fileFiltered(file.name));
|
|
119
103
|
}
|
|
120
104
|
if (isNodeModule && !loggedIgnoredNodeModule) {
|
|
121
105
|
loggedIgnoredNodeModule = true;
|
package/lib/projects/urls.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function getProjectDetailUrl(projectName: string, accountId: number): string | undefined;
|
|
2
|
+
export declare function getProjectSettingsUrl(projectName: string, accountId: number): string | undefined;
|
|
2
3
|
export declare function getProjectActivityUrl(projectName: string, accountId: number): string;
|
|
3
4
|
export declare function getProjectBuildDetailUrl(projectName: string, buildId: number, accountId: number): string;
|
|
4
5
|
export declare function getProjectDeployDetailUrl(projectName: string, deployId: number, accountId: number): string;
|
package/lib/projects/urls.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getProjectDetailUrl = getProjectDetailUrl;
|
|
4
|
+
exports.getProjectSettingsUrl = getProjectSettingsUrl;
|
|
4
5
|
exports.getProjectActivityUrl = getProjectActivityUrl;
|
|
5
6
|
exports.getProjectBuildDetailUrl = getProjectBuildDetailUrl;
|
|
6
7
|
exports.getProjectDeployDetailUrl = getProjectDeployDetailUrl;
|
|
@@ -16,6 +17,11 @@ function getProjectDetailUrl(projectName, accountId) {
|
|
|
16
17
|
return;
|
|
17
18
|
return `${getProjectHomeUrl(accountId)}/project/${projectName}`;
|
|
18
19
|
}
|
|
20
|
+
function getProjectSettingsUrl(projectName, accountId) {
|
|
21
|
+
if (!projectName)
|
|
22
|
+
return;
|
|
23
|
+
return `${getProjectDetailUrl(projectName, accountId)}/settings`;
|
|
24
|
+
}
|
|
19
25
|
function getProjectActivityUrl(projectName, accountId) {
|
|
20
26
|
return `${getProjectDetailUrl(projectName, accountId)}/activity`;
|
|
21
27
|
}
|
package/lib/projects/watch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ProjectConfig } from '../../types/Projects';
|
|
2
|
-
type ProjectWatchHandlerFunction = (accountId: number, projectName: string, currentBuildId: number) => Promise<void
|
|
2
|
+
type ProjectWatchHandlerFunction = (accountId: number, projectName: string, currentBuildId: number) => Promise<void> | void;
|
|
3
3
|
export declare function createWatcher(accountId: number, projectConfig: ProjectConfig, projectDir: string, handleBuildStatusFn: ProjectWatchHandlerFunction, handleUserInputFn: ProjectWatchHandlerFunction): Promise<void>;
|
|
4
4
|
export {};
|
package/lib/projects/watch.js
CHANGED
|
@@ -8,16 +8,15 @@ const chokidar_1 = __importDefault(require("chokidar"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const p_queue_1 = __importDefault(require("p-queue"));
|
|
11
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
12
11
|
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
13
12
|
const extensions_1 = require("@hubspot/local-dev-lib/constants/extensions");
|
|
14
13
|
const ignoreRules_1 = require("@hubspot/local-dev-lib/ignoreRules");
|
|
15
14
|
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
16
15
|
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
17
16
|
const errorHandlers_1 = require("../errorHandlers");
|
|
18
|
-
const lang_1 = require("../lang");
|
|
19
17
|
const constants_1 = require("../constants");
|
|
20
|
-
const
|
|
18
|
+
const en_1 = require("../../lang/en");
|
|
19
|
+
const logger_1 = require("../ui/logger");
|
|
21
20
|
const queue = new p_queue_1.default({
|
|
22
21
|
concurrency: 10,
|
|
23
22
|
});
|
|
@@ -44,18 +43,18 @@ function debounceQueueBuild(accountId, projectName, platformVersion) {
|
|
|
44
43
|
clearTimeout(timer);
|
|
45
44
|
}
|
|
46
45
|
timer = setTimeout(async () => {
|
|
47
|
-
logger_1.
|
|
46
|
+
logger_1.uiLogger.debug(en_1.commands.project.watch.debug.pause);
|
|
48
47
|
queue.pause();
|
|
49
48
|
await queue.onIdle();
|
|
50
49
|
try {
|
|
51
50
|
await (0, projects_1.queueBuild)(accountId, projectName, platformVersion);
|
|
52
|
-
logger_1.
|
|
51
|
+
logger_1.uiLogger.debug(en_1.commands.project.watch.debug.buildStarted);
|
|
53
52
|
}
|
|
54
53
|
catch (err) {
|
|
55
54
|
if ((0, index_1.isSpecifiedError)(err, {
|
|
56
55
|
subCategory: constants_1.PROJECT_ERROR_TYPES.MISSING_PROJECT_PROVISION,
|
|
57
56
|
})) {
|
|
58
|
-
logger_1.
|
|
57
|
+
logger_1.uiLogger.log(en_1.commands.project.watch.logs.watchCancelledFromUi);
|
|
59
58
|
process.exit(0);
|
|
60
59
|
}
|
|
61
60
|
else {
|
|
@@ -69,24 +68,24 @@ function debounceQueueBuild(accountId, projectName, platformVersion) {
|
|
|
69
68
|
await processStandByQueue(accountId, projectName, platformVersion);
|
|
70
69
|
}
|
|
71
70
|
queue.start();
|
|
72
|
-
logger_1.
|
|
73
|
-
logger_1.
|
|
71
|
+
logger_1.uiLogger.log(en_1.commands.project.watch.logs.resuming);
|
|
72
|
+
logger_1.uiLogger.log(`\n> Press ${chalk_1.default.bold('q')} to quit watching\n`);
|
|
74
73
|
}, 2000);
|
|
75
74
|
}
|
|
76
75
|
async function queueFileOrFolder(accountId, projectName, platformVersion, filePath, remotePath, action) {
|
|
77
76
|
if (action === 'upload' &&
|
|
78
77
|
!(0, path_2.isAllowedExtension)(filePath, Array.from(extensions_1.JSR_ALLOWED_EXTENSIONS))) {
|
|
79
|
-
logger_1.
|
|
78
|
+
logger_1.uiLogger.debug(en_1.commands.project.watch.debug.extensionNotAllowed(filePath));
|
|
80
79
|
return;
|
|
81
80
|
}
|
|
82
81
|
if ((0, ignoreRules_1.shouldIgnoreFile)(filePath, true)) {
|
|
83
|
-
logger_1.
|
|
82
|
+
logger_1.uiLogger.debug(en_1.commands.project.watch.debug.ignored(filePath));
|
|
84
83
|
return;
|
|
85
84
|
}
|
|
86
85
|
if (!queue.isPaused) {
|
|
87
86
|
debounceQueueBuild(accountId, projectName, platformVersion);
|
|
88
87
|
}
|
|
89
|
-
logger_1.
|
|
88
|
+
logger_1.uiLogger.debug(en_1.commands.project.watch.debug.uploading(filePath, remotePath));
|
|
90
89
|
return queue.add(async () => {
|
|
91
90
|
try {
|
|
92
91
|
if (action === 'upload') {
|
|
@@ -95,16 +94,20 @@ async function queueFileOrFolder(accountId, projectName, platformVersion, filePa
|
|
|
95
94
|
else if (action === 'deleteFile' || action === 'deleteFolder') {
|
|
96
95
|
await (0, projects_1.deleteFileFromBuild)(accountId, projectName, remotePath);
|
|
97
96
|
}
|
|
98
|
-
logger_1.
|
|
97
|
+
logger_1.uiLogger.log(
|
|
98
|
+
// @ts-expect-error
|
|
99
|
+
en_1.commands.project.watch.logs[`${action}Succeeded`](remotePath, filePath));
|
|
99
100
|
}
|
|
100
101
|
catch (err) {
|
|
101
|
-
logger_1.
|
|
102
|
+
logger_1.uiLogger.debug(
|
|
103
|
+
// @ts-expect-error
|
|
104
|
+
en_1.commands.project.watch.errors[`${action}Failed`](remotePath, filePath));
|
|
102
105
|
}
|
|
103
106
|
});
|
|
104
107
|
}
|
|
105
108
|
async function createNewBuild(accountId, projectName, platformVersion) {
|
|
106
109
|
try {
|
|
107
|
-
logger_1.
|
|
110
|
+
logger_1.uiLogger.debug(en_1.commands.project.watch.debug.attemptNewBuild);
|
|
108
111
|
const { data: { buildId }, } = await (0, projects_1.provisionBuild)(accountId, projectName, platformVersion);
|
|
109
112
|
return buildId;
|
|
110
113
|
}
|
|
@@ -112,7 +115,7 @@ async function createNewBuild(accountId, projectName, platformVersion) {
|
|
|
112
115
|
(0, errorHandlers_1.logError)(err, new errorHandlers_1.ApiErrorContext({ accountId }));
|
|
113
116
|
if ((0, index_1.isSpecifiedError)(err, { subCategory: constants_1.PROJECT_ERROR_TYPES.PROJECT_LOCKED })) {
|
|
114
117
|
await (0, projects_1.cancelStagedBuild)(accountId, projectName);
|
|
115
|
-
logger_1.
|
|
118
|
+
logger_1.uiLogger.log(en_1.commands.project.watch.logs.previousStagingBuildCancelled);
|
|
116
119
|
}
|
|
117
120
|
process.exit(1);
|
|
118
121
|
}
|
|
@@ -121,7 +124,7 @@ async function handleWatchEvent(accountId, projectName, platformVersion, project
|
|
|
121
124
|
const remotePath = path_1.default.relative(projectSourceDir, filePath);
|
|
122
125
|
if (queue.isPaused) {
|
|
123
126
|
if (standbyQueue.find(file => file.filePath === filePath)) {
|
|
124
|
-
logger_1.
|
|
127
|
+
logger_1.uiLogger.debug(en_1.commands.project.watch.debug.fileAlreadyQueued(filePath));
|
|
125
128
|
}
|
|
126
129
|
else {
|
|
127
130
|
standbyQueue.push({
|
|
@@ -145,8 +148,8 @@ async function createWatcher(accountId, projectConfig, projectDir, handleBuildSt
|
|
|
145
148
|
ignored: file => (0, ignoreRules_1.shouldIgnoreFile)(file),
|
|
146
149
|
});
|
|
147
150
|
watcher.on('ready', async () => {
|
|
148
|
-
logger_1.
|
|
149
|
-
logger_1.
|
|
151
|
+
logger_1.uiLogger.log(en_1.commands.project.watch.logs.watching(projectDir));
|
|
152
|
+
logger_1.uiLogger.log(`\n> Press ${chalk_1.default.bold('q')} to quit watching\n`);
|
|
150
153
|
});
|
|
151
154
|
watcher.on('add', async (path) => {
|
|
152
155
|
handleWatchEvent(accountId, projectConfig.name, projectConfig.platformVersion, projectSourceDir, path);
|
|
@@ -7,24 +7,25 @@ const config_1 = require("@hubspot/local-dev-lib/config");
|
|
|
7
7
|
const promptUtils_1 = require("./promptUtils");
|
|
8
8
|
const lang_1 = require("../lang");
|
|
9
9
|
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
10
|
-
const i18nKey = 'lib.prompts.accountNamePrompt';
|
|
11
10
|
function getCliAccountNamePromptConfig(defaultName) {
|
|
12
11
|
return {
|
|
13
12
|
name: 'name',
|
|
14
|
-
message: (0, lang_1.i18n)(
|
|
13
|
+
message: (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.enterAccountName`),
|
|
15
14
|
default: defaultName,
|
|
16
15
|
validate(val) {
|
|
17
16
|
if (typeof val !== 'string') {
|
|
18
|
-
return (0, lang_1.i18n)(
|
|
17
|
+
return (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.errors.invalidName`);
|
|
19
18
|
}
|
|
20
19
|
else if (!val.length) {
|
|
21
|
-
return (0, lang_1.i18n)(
|
|
20
|
+
return (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.errors.nameRequired`);
|
|
22
21
|
}
|
|
23
22
|
else if (val.indexOf(' ') >= 0) {
|
|
24
|
-
return (0, lang_1.i18n)(
|
|
23
|
+
return (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.errors.spacesInName`);
|
|
25
24
|
}
|
|
26
25
|
return (0, config_1.accountNameExistsInConfig)(val)
|
|
27
|
-
? (0, lang_1.i18n)(
|
|
26
|
+
? (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.errors.accountNameExists`, {
|
|
27
|
+
name: val,
|
|
28
|
+
})
|
|
28
29
|
: true;
|
|
29
30
|
},
|
|
30
31
|
};
|
|
@@ -41,12 +42,12 @@ function hubspotAccountNamePrompt({ accountType, currentPortalCount = 0, }) {
|
|
|
41
42
|
let defaultName;
|
|
42
43
|
if (isSandbox) {
|
|
43
44
|
promptMessageString = isDevelopmentSandbox
|
|
44
|
-
? (0, lang_1.i18n)(
|
|
45
|
-
: (0, lang_1.i18n)(
|
|
45
|
+
? (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.enterDevelopmentSandboxName`)
|
|
46
|
+
: (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.enterStandardSandboxName`);
|
|
46
47
|
}
|
|
47
48
|
else if (isDeveloperTestAccount) {
|
|
48
|
-
promptMessageString = (0, lang_1.i18n)(
|
|
49
|
-
defaultName = (0, lang_1.i18n)(
|
|
49
|
+
promptMessageString = (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.enterDeveloperTestAccountName`);
|
|
50
|
+
defaultName = (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.developerTestAccountDefaultName`, {
|
|
50
51
|
count: currentPortalCount + 1,
|
|
51
52
|
});
|
|
52
53
|
}
|
|
@@ -56,13 +57,15 @@ function hubspotAccountNamePrompt({ accountType, currentPortalCount = 0, }) {
|
|
|
56
57
|
message: promptMessageString,
|
|
57
58
|
validate(val) {
|
|
58
59
|
if (typeof val !== 'string') {
|
|
59
|
-
return (0, lang_1.i18n)(
|
|
60
|
+
return (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.errors.invalidName`);
|
|
60
61
|
}
|
|
61
62
|
else if (!val.trim().length) {
|
|
62
|
-
return (0, lang_1.i18n)(
|
|
63
|
+
return (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.errors.nameRequired`);
|
|
63
64
|
}
|
|
64
65
|
return (0, config_1.accountNameExistsInConfig)(val)
|
|
65
|
-
? (0, lang_1.i18n)(
|
|
66
|
+
? (0, lang_1.i18n)(`lib.prompts.accountNamePrompt.errors.accountNameExists`, {
|
|
67
|
+
name: val,
|
|
68
|
+
})
|
|
66
69
|
: true;
|
|
67
70
|
},
|
|
68
71
|
default: defaultName,
|
|
@@ -12,7 +12,6 @@ function mapAccountChoices(portals) {
|
|
|
12
12
|
value: String(p.name || (0, getAccountIdentifier_1.getAccountIdentifier)(p)),
|
|
13
13
|
})) || []);
|
|
14
14
|
}
|
|
15
|
-
const i18nKey = 'commands.account.subcommands.use';
|
|
16
15
|
async function selectAccountFromConfig(prompt = '') {
|
|
17
16
|
const accountsList = (0, config_1.getConfigAccounts)();
|
|
18
17
|
const defaultAccount = (0, config_1.getConfigDefaultAccount)();
|
|
@@ -21,7 +20,7 @@ async function selectAccountFromConfig(prompt = '') {
|
|
|
21
20
|
type: 'list',
|
|
22
21
|
name: 'default',
|
|
23
22
|
pageSize: 20,
|
|
24
|
-
message: prompt || (0, lang_1.i18n)(
|
|
23
|
+
message: prompt || (0, lang_1.i18n)(`commands.account.subcommands.use.promptMessage`),
|
|
25
24
|
choices: mapAccountChoices(accountsList),
|
|
26
25
|
default: defaultAccount ?? undefined,
|
|
27
26
|
},
|
|
@@ -9,7 +9,6 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
9
9
|
const promptUtils_1 = require("./promptUtils");
|
|
10
10
|
const lang_1 = require("../lang");
|
|
11
11
|
const escapeRegExp_1 = require("@hubspot/local-dev-lib/escapeRegExp");
|
|
12
|
-
const i18nKey = 'lib.prompts.uploadPrompt';
|
|
13
12
|
const FIELDS_FILES = ['fields.json', 'fields.js', 'fields.cjs', 'fields.mjs'];
|
|
14
13
|
async function fieldsJsPrompt(filePath, projectDir, skipFiles = []) {
|
|
15
14
|
const dirName = path_1.default.dirname(filePath);
|
|
@@ -33,7 +32,7 @@ async function fieldsJsPrompt(filePath, projectDir, skipFiles = []) {
|
|
|
33
32
|
}));
|
|
34
33
|
const promptVal = await (0, promptUtils_1.promptUser)([
|
|
35
34
|
{
|
|
36
|
-
message: (0, lang_1.i18n)(
|
|
35
|
+
message: (0, lang_1.i18n)(`lib.prompts.uploadPrompt.fieldsPrompt`, { dir: fileDir }),
|
|
37
36
|
type: 'list',
|
|
38
37
|
name: 'filePathChoice',
|
|
39
38
|
choices: selection,
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
id: string;
|
|
5
|
-
languages: string[];
|
|
6
|
-
};
|
|
7
|
-
type SampleConfig = {
|
|
8
|
-
samples: SampleChoice[];
|
|
9
|
-
};
|
|
1
|
+
import { ApiSampleConfig } from '../../types/Cms';
|
|
10
2
|
type SampleTypePromptResponse = {
|
|
11
3
|
sampleType?: string;
|
|
12
4
|
};
|
|
@@ -14,5 +6,5 @@ type LanguagePromptResponse = {
|
|
|
14
6
|
sampleLanguage?: string;
|
|
15
7
|
};
|
|
16
8
|
type CreateApiSamplePromptResponse = SampleTypePromptResponse & LanguagePromptResponse;
|
|
17
|
-
export declare function createApiSamplePrompt(samplesConfig:
|
|
9
|
+
export declare function createApiSamplePrompt(samplesConfig: ApiSampleConfig): Promise<CreateApiSamplePromptResponse>;
|
|
18
10
|
export {};
|
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createApiSamplePrompt = createApiSamplePrompt;
|
|
4
4
|
const promptUtils_1 = require("./promptUtils");
|
|
5
5
|
const lang_1 = require("../lang");
|
|
6
|
-
const i18nKey = 'lib.prompts.createApiSamplePrompt';
|
|
7
6
|
function getSampleTypesPrompt(choices) {
|
|
8
7
|
return {
|
|
9
8
|
type: 'rawlist',
|
|
10
9
|
name: 'sampleType',
|
|
11
|
-
message: (0, lang_1.i18n)(
|
|
10
|
+
message: (0, lang_1.i18n)(`lib.prompts.createApiSamplePrompt.selectApiSampleApp`),
|
|
12
11
|
choices: choices.map(choice => ({
|
|
13
12
|
name: `${choice.name} - ${choice.description}`,
|
|
14
13
|
value: choice.id,
|
|
@@ -19,7 +18,7 @@ function getSampleTypesPrompt(choices) {
|
|
|
19
18
|
resolve(true);
|
|
20
19
|
}
|
|
21
20
|
else {
|
|
22
|
-
reject((0, lang_1.i18n)(
|
|
21
|
+
reject((0, lang_1.i18n)(`lib.prompts.createApiSamplePrompt.errors.apiSampleAppRequired`));
|
|
23
22
|
}
|
|
24
23
|
});
|
|
25
24
|
},
|
|
@@ -29,7 +28,7 @@ function getLanguagesPrompt(choices) {
|
|
|
29
28
|
return {
|
|
30
29
|
type: 'rawlist',
|
|
31
30
|
name: 'sampleLanguage',
|
|
32
|
-
message: (0, lang_1.i18n)(
|
|
31
|
+
message: (0, lang_1.i18n)(`lib.prompts.createApiSamplePrompt.selectLanguage`),
|
|
33
32
|
choices: choices.map(choice => ({
|
|
34
33
|
name: choice,
|
|
35
34
|
value: choice,
|
|
@@ -39,7 +38,7 @@ function getLanguagesPrompt(choices) {
|
|
|
39
38
|
if (input && input.length > 0) {
|
|
40
39
|
resolve(true);
|
|
41
40
|
}
|
|
42
|
-
reject((0, lang_1.i18n)(
|
|
41
|
+
reject((0, lang_1.i18n)(`lib.prompts.createApiSamplePrompt.errors.languageRequired`));
|
|
43
42
|
});
|
|
44
43
|
},
|
|
45
44
|
};
|
|
@@ -3,35 +3,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createFunctionPrompt = createFunctionPrompt;
|
|
4
4
|
const promptUtils_1 = require("./promptUtils");
|
|
5
5
|
const lang_1 = require("../lang");
|
|
6
|
-
const i18nKey = 'lib.prompts.createFunctionPrompt';
|
|
7
6
|
const FUNCTIONS_FOLDER_PROMPT = {
|
|
8
7
|
name: 'functionsFolder',
|
|
9
|
-
message: (0, lang_1.i18n)(
|
|
8
|
+
message: (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.enterFolder`),
|
|
10
9
|
validate(val) {
|
|
11
10
|
if (typeof val !== 'string') {
|
|
12
|
-
return (0, lang_1.i18n)(
|
|
11
|
+
return (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.errors.invalid`);
|
|
13
12
|
}
|
|
14
13
|
else if (!val.length) {
|
|
15
|
-
return (0, lang_1.i18n)(
|
|
14
|
+
return (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.errors.blank`);
|
|
16
15
|
}
|
|
17
16
|
else if (val.indexOf(' ') >= 0) {
|
|
18
|
-
return (0, lang_1.i18n)(
|
|
17
|
+
return (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.errors.space`);
|
|
19
18
|
}
|
|
20
19
|
return true;
|
|
21
20
|
},
|
|
22
21
|
};
|
|
23
22
|
const FUNCTION_FILENAME_PROMPT = {
|
|
24
23
|
name: 'filename',
|
|
25
|
-
message: (0, lang_1.i18n)(
|
|
24
|
+
message: (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.enterFilename`),
|
|
26
25
|
validate(val) {
|
|
27
26
|
if (typeof val !== 'string') {
|
|
28
|
-
return (0, lang_1.i18n)(
|
|
27
|
+
return (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.errors.invalid`);
|
|
29
28
|
}
|
|
30
29
|
else if (!val.length) {
|
|
31
|
-
return (0, lang_1.i18n)(
|
|
30
|
+
return (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.errors.blank`);
|
|
32
31
|
}
|
|
33
32
|
else if (val.indexOf(' ') >= 0) {
|
|
34
|
-
return (0, lang_1.i18n)(
|
|
33
|
+
return (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.errors.space`);
|
|
35
34
|
}
|
|
36
35
|
return true;
|
|
37
36
|
},
|
|
@@ -39,22 +38,22 @@ const FUNCTION_FILENAME_PROMPT = {
|
|
|
39
38
|
const ENDPOINT_METHOD_PROMPT = {
|
|
40
39
|
type: 'list',
|
|
41
40
|
name: 'endpointMethod',
|
|
42
|
-
message: (0, lang_1.i18n)(
|
|
41
|
+
message: (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.selectEndpointMethod`),
|
|
43
42
|
default: 'GET',
|
|
44
43
|
choices: ['DELETE', 'GET', 'PATCH', 'POST', 'PUT'],
|
|
45
44
|
};
|
|
46
45
|
const ENDPOINT_PATH_PROMPT = {
|
|
47
46
|
name: 'endpointPath',
|
|
48
|
-
message: (0, lang_1.i18n)(
|
|
47
|
+
message: (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.enterEndpointPath`),
|
|
49
48
|
validate(val) {
|
|
50
49
|
if (typeof val !== 'string') {
|
|
51
|
-
return (0, lang_1.i18n)(
|
|
50
|
+
return (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.errors.invalid`);
|
|
52
51
|
}
|
|
53
52
|
else if (!val.length) {
|
|
54
|
-
return (0, lang_1.i18n)(
|
|
53
|
+
return (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.errors.blank`);
|
|
55
54
|
}
|
|
56
55
|
else if (val.indexOf(' ') >= 0) {
|
|
57
|
-
return (0, lang_1.i18n)(
|
|
56
|
+
return (0, lang_1.i18n)(`lib.prompts.createFunctionPrompt.errors.space`);
|
|
58
57
|
}
|
|
59
58
|
return true;
|
|
60
59
|
},
|
|
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createModulePrompt = createModulePrompt;
|
|
4
4
|
const promptUtils_1 = require("./promptUtils");
|
|
5
5
|
const lang_1 = require("../lang");
|
|
6
|
-
const i18nKey = 'lib.prompts.createModulePrompt';
|
|
7
6
|
const MODULE_LABEL_PROMPT = {
|
|
8
7
|
name: 'moduleLabel',
|
|
9
|
-
message: (0, lang_1.i18n)(
|
|
8
|
+
message: (0, lang_1.i18n)(`lib.prompts.createModulePrompt.enterLabel`),
|
|
10
9
|
validate(val) {
|
|
11
10
|
if (typeof val !== 'string') {
|
|
12
|
-
return (0, lang_1.i18n)(
|
|
11
|
+
return (0, lang_1.i18n)(`lib.prompts.createModulePrompt.errors.invalidLabel`);
|
|
13
12
|
}
|
|
14
13
|
else if (!val.length) {
|
|
15
|
-
return (0, lang_1.i18n)(
|
|
14
|
+
return (0, lang_1.i18n)(`lib.prompts.createModulePrompt.errors.labelRequired`);
|
|
16
15
|
}
|
|
17
16
|
return true;
|
|
18
17
|
},
|
|
@@ -20,13 +19,13 @@ const MODULE_LABEL_PROMPT = {
|
|
|
20
19
|
const REACT_TYPE_PROMPT = {
|
|
21
20
|
type: 'confirm',
|
|
22
21
|
name: 'reactType',
|
|
23
|
-
message: (0, lang_1.i18n)(
|
|
22
|
+
message: (0, lang_1.i18n)(`lib.prompts.createModulePrompt.selectReactType`),
|
|
24
23
|
default: false,
|
|
25
24
|
};
|
|
26
25
|
const CONTENT_TYPES_PROMPT = {
|
|
27
26
|
type: 'checkbox',
|
|
28
27
|
name: 'contentTypes',
|
|
29
|
-
message: (0, lang_1.i18n)(
|
|
28
|
+
message: (0, lang_1.i18n)(`lib.prompts.createModulePrompt.selectContentType`),
|
|
30
29
|
default: ['ANY'],
|
|
31
30
|
choices: [
|
|
32
31
|
{ name: 'Any', value: 'ANY' },
|
|
@@ -47,20 +46,20 @@ const CONTENT_TYPES_PROMPT = {
|
|
|
47
46
|
if (input.length > 0) {
|
|
48
47
|
resolve(true);
|
|
49
48
|
}
|
|
50
|
-
reject((0, lang_1.i18n)(
|
|
49
|
+
reject((0, lang_1.i18n)(`lib.prompts.createModulePrompt.errors.contentTypeRequired`));
|
|
51
50
|
});
|
|
52
51
|
},
|
|
53
52
|
};
|
|
54
53
|
const GLOBAL_PROMPT = {
|
|
55
54
|
type: 'confirm',
|
|
56
55
|
name: 'global',
|
|
57
|
-
message: (0, lang_1.i18n)(
|
|
56
|
+
message: (0, lang_1.i18n)(`lib.prompts.createModulePrompt.confirmGlobal`),
|
|
58
57
|
default: false,
|
|
59
58
|
};
|
|
60
59
|
const AVAILABLE_FOR_NEW_CONTENT = {
|
|
61
60
|
type: 'confirm',
|
|
62
61
|
name: 'availableForNewContent',
|
|
63
|
-
message: (0, lang_1.i18n)(
|
|
62
|
+
message: (0, lang_1.i18n)(`lib.prompts.createModulePrompt.availableForNewContent`),
|
|
64
63
|
default: true,
|
|
65
64
|
};
|
|
66
65
|
function createModulePrompt() {
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { ProjectTemplate } from '../../types/Projects';
|
|
2
|
-
type
|
|
2
|
+
type CreateProjectPromptResponseWithTemplate = {
|
|
3
3
|
name: string;
|
|
4
4
|
dest: string;
|
|
5
|
-
projectTemplate
|
|
5
|
+
projectTemplate: ProjectTemplate;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type CreateProjectPromptResponseWithoutTemplate = {
|
|
8
|
+
name: string;
|
|
9
|
+
dest: string;
|
|
10
|
+
projectTemplate?: undefined;
|
|
11
|
+
};
|
|
12
|
+
type PromptOptionsArg = {
|
|
8
13
|
name?: string;
|
|
9
14
|
dest?: string;
|
|
10
15
|
template?: string;
|
|
11
|
-
}
|
|
16
|
+
};
|
|
17
|
+
export declare function createProjectPrompt(promptOptions: PromptOptionsArg, projectTemplates: ProjectTemplate[]): Promise<CreateProjectPromptResponseWithTemplate>;
|
|
18
|
+
export declare function createProjectPrompt(promptOptions: PromptOptionsArg, projectTemplates?: undefined): Promise<CreateProjectPromptResponseWithoutTemplate>;
|
|
12
19
|
export {};
|