@hubspot/cli 6.4.0 → 7.0.0-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/bin/cli.js +110 -16
- package/bin/hs +2 -0
- package/bin/hscms +2 -0
- package/bin/silenceErrors.d.ts +2 -0
- package/bin/silenceErrors.js +12 -0
- package/commands/{accounts → account}/clean.js +10 -11
- package/commands/{accounts → account}/info.js +10 -16
- package/commands/{accounts → account}/list.js +16 -16
- package/commands/{accounts → account}/remove.js +12 -15
- package/commands/{accounts → account}/rename.js +4 -7
- package/commands/{accounts → account}/use.js +8 -14
- package/commands/account.js +26 -0
- package/commands/auth.js +30 -24
- package/commands/cms/getReactModule.js +70 -0
- package/commands/cms/lighthouseScore.js +19 -21
- package/commands/cms.js +4 -3
- package/commands/completion.js +22 -0
- package/commands/config/set.js +22 -24
- package/commands/config.js +2 -2
- package/commands/create.js +6 -3
- package/commands/customObject/create.js +19 -15
- package/commands/customObject/schema/create.js +15 -16
- package/commands/customObject/schema/delete.js +29 -11
- package/commands/customObject/schema/fetch-all.js +14 -11
- package/commands/customObject/schema/fetch.js +22 -14
- package/commands/customObject/schema/list.js +3 -6
- package/commands/customObject/schema/update.js +28 -18
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +3 -4
- package/commands/doctor.js +4 -2
- package/commands/feedback.js +2 -0
- package/commands/fetch.js +13 -13
- package/commands/filemanager/fetch.js +6 -7
- package/commands/filemanager/upload.js +10 -12
- package/commands/filemanager.js +1 -8
- package/commands/{functions → function}/deploy.js +13 -13
- package/commands/{functions → function}/list.js +7 -9
- package/commands/{functions → function}/server.js +5 -8
- package/commands/function.js +16 -0
- package/commands/hubdb/clear.js +14 -10
- package/commands/hubdb/create.js +37 -13
- package/commands/hubdb/delete.js +31 -10
- package/commands/hubdb/fetch.js +14 -9
- package/commands/hubdb.js +2 -3
- package/commands/init.js +37 -14
- package/commands/lint.js +6 -7
- package/commands/list.js +5 -7
- package/commands/logs.js +24 -15
- package/commands/module/marketplace-validate.js +6 -9
- package/commands/module.js +2 -1
- package/commands/mv.js +11 -13
- package/commands/open.js +11 -10
- package/commands/project/add.js +2 -5
- package/commands/project/cloneApp.js +28 -32
- package/commands/project/create.js +8 -10
- package/commands/project/deploy.js +19 -16
- package/commands/project/dev.js +17 -18
- package/commands/project/download.js +18 -15
- package/commands/project/listBuilds.js +36 -32
- package/commands/project/logs.js +6 -8
- package/commands/project/migrateApp.js +27 -27
- package/commands/project/open.js +9 -11
- package/commands/project/upload.js +30 -32
- package/commands/project/watch.js +17 -24
- package/commands/project.js +3 -4
- package/commands/remove.js +14 -13
- package/commands/sandbox/create.js +12 -15
- package/commands/sandbox/delete.js +19 -20
- package/commands/sandbox.js +4 -8
- package/commands/{secrets → secret}/addSecret.js +25 -12
- package/commands/secret/deleteSecret.js +71 -0
- package/commands/{secrets → secret}/listSecrets.js +7 -9
- package/commands/{secrets → secret}/updateSecret.js +21 -13
- package/commands/secret.js +22 -0
- package/commands/theme/generate-selectors.js +8 -8
- package/commands/theme/marketplace-validate.js +10 -13
- package/commands/theme/preview.js +7 -10
- package/commands/theme.js +3 -1
- package/commands/upload.js +32 -26
- package/commands/watch.js +19 -20
- package/lang/en.lyaml +200 -126
- package/lib/DevServerManager.js +1 -1
- package/lib/LocalDevManager.js +4 -4
- package/lib/buildAccount.js +5 -11
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -39
- package/lib/configOptions.d.ts +13 -1
- package/lib/configOptions.js +54 -57
- package/lib/constants.d.ts +1 -4
- package/lib/dependencyManagement.d.ts +4 -1
- package/lib/dependencyManagement.js +2 -2
- package/lib/developerTestAccounts.d.ts +5 -1
- package/lib/developerTestAccounts.js +45 -39
- package/lib/doctor/DiagnosticInfoBuilder.js +8 -4
- package/lib/doctor/Doctor.js +11 -6
- package/lib/generateSelectors.d.ts +19 -0
- package/lib/generateSelectors.js +23 -23
- package/lib/localDev.js +3 -2
- package/lib/marketplaceValidate.d.ts +6 -1
- package/lib/marketplaceValidate.js +76 -77
- package/lib/oauth.d.ts +2 -1
- package/lib/oauth.js +49 -37
- package/lib/polling.d.ts +8 -0
- package/lib/polling.js +9 -12
- package/lib/projects/ProjectLogsManager.d.ts +20 -0
- package/lib/projects/ProjectLogsManager.js +105 -0
- package/lib/projects/buildAndDeploy.d.ts +16 -0
- package/lib/projects/buildAndDeploy.js +342 -0
- package/lib/projects/index.d.ts +24 -0
- package/lib/projects/index.js +256 -0
- package/lib/projects/structure.d.ts +78 -0
- package/lib/projects/structure.js +151 -0
- package/lib/projects/upload.d.ts +8 -0
- package/lib/projects/upload.js +107 -0
- package/lib/projects/urls.d.ts +4 -0
- package/lib/projects/urls.js +27 -0
- package/lib/{projectsWatch.js → projects/watch.js} +3 -3
- package/lib/prompts/accountNamePrompt.d.ts +11 -0
- package/lib/prompts/accountNamePrompt.js +45 -46
- package/lib/prompts/accountsPrompt.d.ts +1 -1
- package/lib/prompts/accountsPrompt.js +21 -19
- package/lib/prompts/cmsFieldPrompt.d.ts +1 -1
- package/lib/prompts/cmsFieldPrompt.js +23 -24
- package/lib/prompts/createApiSamplePrompt.d.ts +17 -0
- package/lib/prompts/createApiSamplePrompt.js +47 -44
- package/lib/prompts/createFunctionPrompt.d.ts +7 -0
- package/lib/prompts/createFunctionPrompt.js +17 -20
- package/lib/prompts/createModulePrompt.d.ts +8 -0
- package/lib/prompts/createModulePrompt.js +29 -17
- package/lib/prompts/createProjectPrompt.d.ts +13 -0
- package/lib/prompts/createProjectPrompt.js +48 -49
- package/lib/prompts/createTemplatePrompt.d.ts +8 -0
- package/lib/prompts/createTemplatePrompt.js +15 -17
- package/lib/prompts/downloadProjectPrompt.d.ts +8 -0
- package/lib/prompts/downloadProjectPrompt.js +25 -23
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/installPublicAppPrompt.js +21 -19
- package/lib/prompts/personalAccessKeyPrompt.d.ts +28 -0
- package/lib/prompts/personalAccessKeyPrompt.js +46 -52
- package/lib/prompts/previewPrompt.d.ts +14 -0
- package/lib/prompts/previewPrompt.js +24 -24
- package/lib/prompts/projectAddPrompt.d.ts +9 -0
- package/lib/prompts/projectAddPrompt.js +11 -14
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +87 -69
- package/lib/prompts/projectsLogsPrompt.d.ts +11 -0
- package/lib/prompts/projectsLogsPrompt.js +8 -11
- package/lib/prompts/promptUtils.d.ts +7 -6
- package/lib/prompts/promptUtils.js +21 -8
- package/lib/prompts/sandboxesPrompt.d.ts +8 -0
- package/lib/prompts/sandboxesPrompt.js +43 -45
- package/lib/prompts/secretPrompt.d.ts +12 -0
- package/lib/prompts/secretPrompt.js +32 -19
- package/lib/prompts/selectHubDBTablePrompt.d.ts +12 -0
- package/lib/prompts/selectHubDBTablePrompt.js +69 -0
- package/lib/prompts/selectPublicAppPrompt.d.ts +8 -0
- package/lib/prompts/selectPublicAppPrompt.js +28 -27
- package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -1
- package/lib/prompts/setAsDefaultAccountPrompt.js +12 -14
- package/lib/prompts/uploadPrompt.d.ts +8 -0
- package/lib/prompts/uploadPrompt.js +18 -18
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/usageTracking.d.ts +21 -2
- package/lib/usageTracking.js +53 -81
- package/lib/validation.d.ts +11 -1
- package/lib/validation.js +98 -91
- package/package.json +12 -6
- package/types/Projects.d.ts +43 -0
- package/types/Projects.js +2 -0
- package/types/Prompts.d.ts +25 -0
- package/types/Prompts.js +2 -0
- package/commands/accounts.js +0 -30
- package/commands/cms/reactModules.js +0 -60
- package/commands/functions.js +0 -24
- package/commands/secrets/deleteSecret.js +0 -46
- package/commands/secrets.js +0 -23
- package/lib/ProjectLogsManager.js +0 -91
- package/lib/projectStructure.js +0 -116
- package/lib/projects.d.ts +0 -4
- package/lib/projects.js +0 -681
- package/lib/projectsWatch.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.js +0 -20
- /package/commands/{accounts → account}/clean.d.ts +0 -0
- /package/commands/{accounts → account}/info.d.ts +0 -0
- /package/commands/{accounts → account}/list.d.ts +0 -0
- /package/commands/{accounts → account}/remove.d.ts +0 -0
- /package/commands/{accounts → account}/rename.d.ts +0 -0
- /package/commands/{accounts → account}/use.d.ts +0 -0
- /package/commands/{accounts.d.ts → account.d.ts} +0 -0
- /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
- /package/commands/{functions.d.ts → completion.d.ts} +0 -0
- /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
- /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
- /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
- /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
- /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
- /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
- /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
- /package/{lib/ProjectLogsManager.d.ts → commands/secret/updateSecret.d.ts} +0 -0
- /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
- /package/lib/{projectStructure.d.ts → projects/watch.d.ts} +0 -0
|
@@ -1,72 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
3
|
+
exports.getCliAccountNamePromptConfig = getCliAccountNamePromptConfig;
|
|
4
|
+
exports.cliAccountNamePrompt = cliAccountNamePrompt;
|
|
5
|
+
exports.hubspotAccountNamePrompt = hubspotAccountNamePrompt;
|
|
6
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
7
|
+
const promptUtils_1 = require("./promptUtils");
|
|
8
|
+
const lang_1 = require("../lang");
|
|
9
|
+
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
8
10
|
const i18nKey = 'lib.prompts.accountNamePrompt';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
function getCliAccountNamePromptConfig(defaultName) {
|
|
12
|
+
return {
|
|
13
|
+
name: 'name',
|
|
14
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterAccountName`),
|
|
15
|
+
default: defaultName,
|
|
16
|
+
validate(val) {
|
|
17
|
+
if (typeof val !== 'string') {
|
|
18
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidName`);
|
|
19
|
+
}
|
|
20
|
+
else if (!val.length) {
|
|
21
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.nameRequired`);
|
|
22
|
+
}
|
|
23
|
+
else if (val.indexOf(' ') >= 0) {
|
|
24
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.spacesInName`);
|
|
25
|
+
}
|
|
26
|
+
return (0, config_1.accountNameExistsInConfig)(val)
|
|
27
|
+
? (0, lang_1.i18n)(`${i18nKey}.errors.accountNameExists`, { name: val })
|
|
28
|
+
: true;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function cliAccountNamePrompt(defaultName) {
|
|
33
|
+
return (0, promptUtils_1.promptUser)(getCliAccountNamePromptConfig(defaultName));
|
|
34
|
+
}
|
|
35
|
+
function hubspotAccountNamePrompt({ accountType, currentPortalCount = 0, }) {
|
|
36
|
+
const isDevelopmentSandbox = accountType === config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
|
|
37
|
+
const isSandbox = accountType === config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX ||
|
|
34
38
|
isDevelopmentSandbox;
|
|
35
|
-
const isDeveloperTestAccount = accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST;
|
|
39
|
+
const isDeveloperTestAccount = accountType === config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST;
|
|
36
40
|
let promptMessageString;
|
|
37
41
|
let defaultName;
|
|
38
42
|
if (isSandbox) {
|
|
39
43
|
promptMessageString = isDevelopmentSandbox
|
|
40
|
-
? i18n(`${i18nKey}.enterDevelopmentSandboxName`)
|
|
41
|
-
: i18n(`${i18nKey}.enterStandardSandboxName`);
|
|
44
|
+
? (0, lang_1.i18n)(`${i18nKey}.enterDevelopmentSandboxName`)
|
|
45
|
+
: (0, lang_1.i18n)(`${i18nKey}.enterStandardSandboxName`);
|
|
42
46
|
}
|
|
43
47
|
else if (isDeveloperTestAccount) {
|
|
44
|
-
promptMessageString = i18n(`${i18nKey}.enterDeveloperTestAccountName`);
|
|
45
|
-
defaultName = i18n(`${i18nKey}.developerTestAccountDefaultName`, {
|
|
48
|
+
promptMessageString = (0, lang_1.i18n)(`${i18nKey}.enterDeveloperTestAccountName`);
|
|
49
|
+
defaultName = (0, lang_1.i18n)(`${i18nKey}.developerTestAccountDefaultName`, {
|
|
46
50
|
count: currentPortalCount + 1,
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
|
-
return promptUser([
|
|
53
|
+
return (0, promptUtils_1.promptUser)([
|
|
50
54
|
{
|
|
51
55
|
name: 'name',
|
|
52
56
|
message: promptMessageString,
|
|
53
57
|
validate(val) {
|
|
54
58
|
if (typeof val !== 'string') {
|
|
55
|
-
return i18n(`${i18nKey}.errors.invalidName`);
|
|
59
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidName`);
|
|
56
60
|
}
|
|
57
61
|
else if (!val.trim().length) {
|
|
58
|
-
return i18n(`${i18nKey}.errors.nameRequired`);
|
|
62
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.nameRequired`);
|
|
59
63
|
}
|
|
60
|
-
return accountNameExistsInConfig(val)
|
|
61
|
-
? i18n(`${i18nKey}.errors.accountNameExists`, { name: val })
|
|
64
|
+
return (0, config_1.accountNameExistsInConfig)(val)
|
|
65
|
+
? (0, lang_1.i18n)(`${i18nKey}.errors.accountNameExists`, { name: val })
|
|
62
66
|
: true;
|
|
63
67
|
},
|
|
64
68
|
default: defaultName,
|
|
65
69
|
},
|
|
66
70
|
]);
|
|
67
|
-
}
|
|
68
|
-
module.exports = {
|
|
69
|
-
getCliAccountNamePromptConfig,
|
|
70
|
-
cliAccountNamePrompt,
|
|
71
|
-
hubspotAccountNamePrompt,
|
|
72
|
-
};
|
|
71
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function selectAccountFromConfig(prompt?: string): Promise<string>;
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
exports.selectAccountFromConfig = selectAccountFromConfig;
|
|
4
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
5
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
6
|
+
const promptUtils_1 = require("./promptUtils");
|
|
7
|
+
const lang_1 = require("../lang");
|
|
8
|
+
const ui_1 = require("../ui");
|
|
9
|
+
function mapAccountChoices(portals) {
|
|
10
|
+
return (portals?.map(p => ({
|
|
11
|
+
name: (0, ui_1.uiAccountDescription)((0, getAccountIdentifier_1.getAccountIdentifier)(p), false),
|
|
12
|
+
value: String(p.name || (0, getAccountIdentifier_1.getAccountIdentifier)(p)),
|
|
13
|
+
})) || []);
|
|
14
|
+
}
|
|
15
|
+
const i18nKey = 'commands.account.subcommands.use';
|
|
16
|
+
async function selectAccountFromConfig(prompt = '') {
|
|
17
|
+
const accountsList = (0, config_1.getConfigAccounts)();
|
|
18
|
+
const defaultAccount = (0, config_1.getConfigDefaultAccount)();
|
|
19
|
+
const { default: selectedDefault } = await (0, promptUtils_1.promptUser)([
|
|
14
20
|
{
|
|
15
21
|
type: 'list',
|
|
16
|
-
look: false,
|
|
17
22
|
name: 'default',
|
|
18
23
|
pageSize: 20,
|
|
19
|
-
message: prompt || i18n(`${i18nKey}.promptMessage`),
|
|
20
|
-
choices: mapAccountChoices(
|
|
21
|
-
default:
|
|
24
|
+
message: prompt || (0, lang_1.i18n)(`${i18nKey}.promptMessage`),
|
|
25
|
+
choices: mapAccountChoices(accountsList),
|
|
26
|
+
default: defaultAccount ?? undefined,
|
|
22
27
|
},
|
|
23
28
|
]);
|
|
24
29
|
return selectedDefault;
|
|
25
|
-
}
|
|
26
|
-
module.exports = {
|
|
27
|
-
selectAccountFromConfig,
|
|
28
|
-
};
|
|
30
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function fieldsJsPrompt(filePath: string, projectDir: string, skipFiles?: string[]): Promise<[string, string[]]>;
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
exports.fieldsJsPrompt = fieldsJsPrompt;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const promptUtils_1 = require("./promptUtils");
|
|
10
|
+
const lang_1 = require("../lang");
|
|
11
|
+
const escapeRegExp_1 = require("@hubspot/local-dev-lib/escapeRegExp");
|
|
9
12
|
const i18nKey = 'lib.prompts.uploadPrompt';
|
|
10
13
|
const FIELDS_FILES = ['fields.json', 'fields.js', 'fields.cjs', 'fields.mjs'];
|
|
11
|
-
|
|
12
|
-
const dirName =
|
|
14
|
+
async function fieldsJsPrompt(filePath, projectDir, skipFiles = []) {
|
|
15
|
+
const dirName = path_1.default.dirname(filePath);
|
|
13
16
|
// Get a list of all field files in the directory, resolve their absolute path, and remove the ones that we already skipped.
|
|
14
|
-
const fileChoices =
|
|
17
|
+
const fileChoices = fs_1.default
|
|
15
18
|
.readdirSync(dirName)
|
|
16
19
|
.filter(file => FIELDS_FILES.includes(file))
|
|
17
|
-
.map(file =>
|
|
20
|
+
.map(file => path_1.default.resolve(dirName, file))
|
|
18
21
|
.filter(file => !skipFiles.includes(file));
|
|
19
22
|
if (!fileChoices.length)
|
|
20
23
|
return [filePath, []];
|
|
21
|
-
if (fileChoices.length
|
|
24
|
+
if (fileChoices.length === 1)
|
|
22
25
|
return [fileChoices[0], []];
|
|
23
26
|
// We get the directory above the project one so that relative paths are printed with the root of the project dir attached.
|
|
24
27
|
projectDir = projectDir.substring(0, projectDir.lastIndexOf('/'));
|
|
25
|
-
const projectDirRegex = new RegExp(`^${escapeRegExp(projectDir)}`);
|
|
26
|
-
const fileDir =
|
|
27
|
-
const selection =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
const promptVal = await promptUser([
|
|
28
|
+
const projectDirRegex = new RegExp(`^${(0, escapeRegExp_1.escapeRegExp)(projectDir)}`);
|
|
29
|
+
const fileDir = path_1.default.dirname(fileChoices[0]).replace(projectDirRegex, '');
|
|
30
|
+
const selection = fileChoices.map(fileChoice => ({
|
|
31
|
+
name: fileChoice.replace(projectDirRegex, ''),
|
|
32
|
+
value: fileChoice,
|
|
33
|
+
}));
|
|
34
|
+
const promptVal = await (0, promptUtils_1.promptUser)([
|
|
35
35
|
{
|
|
36
|
-
message: i18n(`${i18nKey}.fieldsPrompt`, { dir: fileDir }),
|
|
36
|
+
message: (0, lang_1.i18n)(`${i18nKey}.fieldsPrompt`, { dir: fileDir }),
|
|
37
37
|
type: 'list',
|
|
38
38
|
name: 'filePathChoice',
|
|
39
39
|
choices: selection,
|
|
@@ -44,5 +44,4 @@ const fieldsJsPrompt = async (filePath, projectDir, skipFiles = []) => {
|
|
|
44
44
|
const notPicked = fileChoices.filter(item => item !== choice);
|
|
45
45
|
skipFiles.push(...notPicked);
|
|
46
46
|
return [choice, skipFiles];
|
|
47
|
-
}
|
|
48
|
-
module.exports = { fieldsJsPrompt };
|
|
47
|
+
}
|
|
@@ -1 +1,18 @@
|
|
|
1
|
+
type SampleChoice = {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
id: string;
|
|
5
|
+
languages: string[];
|
|
6
|
+
};
|
|
7
|
+
type SampleConfig = {
|
|
8
|
+
samples: SampleChoice[];
|
|
9
|
+
};
|
|
10
|
+
type SampleTypePromptResponse = {
|
|
11
|
+
sampleType?: string;
|
|
12
|
+
};
|
|
13
|
+
type LanguagePromptResponse = {
|
|
14
|
+
sampleLanguage?: string;
|
|
15
|
+
};
|
|
16
|
+
type CreateApiSamplePromptResponse = SampleTypePromptResponse & LanguagePromptResponse;
|
|
17
|
+
export declare function createApiSamplePrompt(samplesConfig: SampleConfig): Promise<CreateApiSamplePromptResponse>;
|
|
1
18
|
export {};
|
|
@@ -1,50 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.createApiSamplePrompt = createApiSamplePrompt;
|
|
4
|
+
const promptUtils_1 = require("./promptUtils");
|
|
5
|
+
const lang_1 = require("../lang");
|
|
6
6
|
const i18nKey = 'lib.prompts.createApiSamplePrompt';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
7
|
+
function getSampleTypesPrompt(choices) {
|
|
8
|
+
return {
|
|
9
|
+
type: 'rawlist',
|
|
10
|
+
name: 'sampleType',
|
|
11
|
+
message: (0, lang_1.i18n)(`${i18nKey}.selectApiSampleApp`),
|
|
12
|
+
choices: choices.map(choice => ({
|
|
13
|
+
name: `${choice.name} - ${choice.description}`,
|
|
14
|
+
value: choice.id,
|
|
15
|
+
})),
|
|
16
|
+
validate: function (input) {
|
|
17
|
+
return new Promise(function (resolve, reject) {
|
|
18
|
+
if (input && input.length > 0) {
|
|
19
|
+
resolve(true);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
reject((0, lang_1.i18n)(`${i18nKey}.errors.apiSampleAppRequired`));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function getLanguagesPrompt(choices) {
|
|
29
|
+
return {
|
|
30
|
+
type: 'rawlist',
|
|
31
|
+
name: 'sampleLanguage',
|
|
32
|
+
message: (0, lang_1.i18n)(`${i18nKey}.selectLanguage`),
|
|
33
|
+
choices: choices.map(choice => ({
|
|
34
|
+
name: choice,
|
|
35
|
+
value: choice,
|
|
36
|
+
})),
|
|
37
|
+
validate: function (input) {
|
|
38
|
+
return new Promise(function (resolve, reject) {
|
|
39
|
+
if (input && input.length > 0) {
|
|
40
|
+
resolve(true);
|
|
41
|
+
}
|
|
42
|
+
reject((0, lang_1.i18n)(`${i18nKey}.errors.languageRequired`));
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async function createApiSamplePrompt(samplesConfig) {
|
|
42
48
|
try {
|
|
43
49
|
const { samples } = samplesConfig;
|
|
44
|
-
const sampleTypeAnswer = await promptUser(getSampleTypesPrompt(samples));
|
|
50
|
+
const sampleTypeAnswer = await (0, promptUtils_1.promptUser)(getSampleTypesPrompt(samples));
|
|
45
51
|
const chosenSample = samples.find(sample => sample.id === sampleTypeAnswer.sampleType);
|
|
46
52
|
const { languages } = chosenSample;
|
|
47
|
-
const languagesAnswer = await promptUser(getLanguagesPrompt(languages));
|
|
53
|
+
const languagesAnswer = await (0, promptUtils_1.promptUser)(getLanguagesPrompt(languages));
|
|
48
54
|
return {
|
|
49
55
|
...sampleTypeAnswer,
|
|
50
56
|
...languagesAnswer,
|
|
@@ -53,7 +59,4 @@ const createApiSamplePrompt = async (samplesConfig) => {
|
|
|
53
59
|
catch (e) {
|
|
54
60
|
return {};
|
|
55
61
|
}
|
|
56
|
-
}
|
|
57
|
-
module.exports = {
|
|
58
|
-
createApiSamplePrompt,
|
|
59
|
-
};
|
|
62
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.createFunctionPrompt = createFunctionPrompt;
|
|
4
|
+
const promptUtils_1 = require("./promptUtils");
|
|
5
|
+
const lang_1 = require("../lang");
|
|
6
6
|
const i18nKey = 'lib.prompts.createFunctionPrompt';
|
|
7
7
|
const FUNCTIONS_FOLDER_PROMPT = {
|
|
8
8
|
name: 'functionsFolder',
|
|
9
|
-
message: i18n(`${i18nKey}.enterFolder`),
|
|
9
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterFolder`),
|
|
10
10
|
validate(val) {
|
|
11
11
|
if (typeof val !== 'string') {
|
|
12
|
-
return i18n(`${i18nKey}.errors.invalid`);
|
|
12
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalid`);
|
|
13
13
|
}
|
|
14
14
|
else if (!val.length) {
|
|
15
|
-
return i18n(`${i18nKey}.errors.blank`);
|
|
15
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.blank`);
|
|
16
16
|
}
|
|
17
17
|
else if (val.indexOf(' ') >= 0) {
|
|
18
|
-
return i18n(`${i18nKey}.errors.space`);
|
|
18
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.space`);
|
|
19
19
|
}
|
|
20
20
|
return true;
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
const FUNCTION_FILENAME_PROMPT = {
|
|
24
24
|
name: 'filename',
|
|
25
|
-
message: i18n(`${i18nKey}.enterFilename`),
|
|
25
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterFilename`),
|
|
26
26
|
validate(val) {
|
|
27
27
|
if (typeof val !== 'string') {
|
|
28
|
-
return i18n(`${i18nKey}.errors.invalid`);
|
|
28
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalid`);
|
|
29
29
|
}
|
|
30
30
|
else if (!val.length) {
|
|
31
|
-
return i18n(`${i18nKey}.errors.blank`);
|
|
31
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.blank`);
|
|
32
32
|
}
|
|
33
33
|
else if (val.indexOf(' ') >= 0) {
|
|
34
|
-
return i18n(`${i18nKey}.errors.space`);
|
|
34
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.space`);
|
|
35
35
|
}
|
|
36
36
|
return true;
|
|
37
37
|
},
|
|
@@ -39,34 +39,31 @@ const FUNCTION_FILENAME_PROMPT = {
|
|
|
39
39
|
const ENDPOINT_METHOD_PROMPT = {
|
|
40
40
|
type: 'list',
|
|
41
41
|
name: 'endpointMethod',
|
|
42
|
-
message: i18n(`${i18nKey}.selectEndpointMethod`),
|
|
42
|
+
message: (0, lang_1.i18n)(`${i18nKey}.selectEndpointMethod`),
|
|
43
43
|
default: 'GET',
|
|
44
44
|
choices: ['DELETE', 'GET', 'PATCH', 'POST', 'PUT'],
|
|
45
45
|
};
|
|
46
46
|
const ENDPOINT_PATH_PROMPT = {
|
|
47
47
|
name: 'endpointPath',
|
|
48
|
-
message: i18n(`${i18nKey}.enterEndpointPath`),
|
|
48
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterEndpointPath`),
|
|
49
49
|
validate(val) {
|
|
50
50
|
if (typeof val !== 'string') {
|
|
51
|
-
return i18n(`${i18nKey}.errors.invalid`);
|
|
51
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalid`);
|
|
52
52
|
}
|
|
53
53
|
else if (!val.length) {
|
|
54
|
-
return i18n(`${i18nKey}.errors.blank`);
|
|
54
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.blank`);
|
|
55
55
|
}
|
|
56
56
|
else if (val.indexOf(' ') >= 0) {
|
|
57
|
-
return i18n(`${i18nKey}.errors.space`);
|
|
57
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.space`);
|
|
58
58
|
}
|
|
59
59
|
return true;
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
function createFunctionPrompt() {
|
|
63
|
-
return promptUser([
|
|
63
|
+
return (0, promptUtils_1.promptUser)([
|
|
64
64
|
FUNCTIONS_FOLDER_PROMPT,
|
|
65
65
|
FUNCTION_FILENAME_PROMPT,
|
|
66
66
|
ENDPOINT_METHOD_PROMPT,
|
|
67
67
|
ENDPOINT_PATH_PROMPT,
|
|
68
68
|
]);
|
|
69
69
|
}
|
|
70
|
-
module.exports = {
|
|
71
|
-
createFunctionPrompt,
|
|
72
|
-
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.createModulePrompt = createModulePrompt;
|
|
4
|
+
const promptUtils_1 = require("./promptUtils");
|
|
5
|
+
const lang_1 = require("../lang");
|
|
6
6
|
const i18nKey = 'lib.prompts.createModulePrompt';
|
|
7
7
|
const MODULE_LABEL_PROMPT = {
|
|
8
8
|
name: 'moduleLabel',
|
|
9
|
-
message: i18n(`${i18nKey}.enterLabel`),
|
|
9
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterLabel`),
|
|
10
10
|
validate(val) {
|
|
11
11
|
if (typeof val !== 'string') {
|
|
12
|
-
return i18n(`${i18nKey}.errors.invalidLabel`);
|
|
12
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidLabel`);
|
|
13
13
|
}
|
|
14
14
|
else if (!val.length) {
|
|
15
|
-
return i18n(`${i18nKey}.errors.labelRequired`);
|
|
15
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.labelRequired`);
|
|
16
16
|
}
|
|
17
17
|
return true;
|
|
18
18
|
},
|
|
@@ -20,43 +20,55 @@ const MODULE_LABEL_PROMPT = {
|
|
|
20
20
|
const REACT_TYPE_PROMPT = {
|
|
21
21
|
type: 'confirm',
|
|
22
22
|
name: 'reactType',
|
|
23
|
-
message: i18n(`${i18nKey}.selectReactType`),
|
|
23
|
+
message: (0, lang_1.i18n)(`${i18nKey}.selectReactType`),
|
|
24
24
|
default: false,
|
|
25
25
|
};
|
|
26
26
|
const CONTENT_TYPES_PROMPT = {
|
|
27
27
|
type: 'checkbox',
|
|
28
28
|
name: 'contentTypes',
|
|
29
|
-
message: i18n(`${i18nKey}.selectContentType`),
|
|
30
|
-
default: ['
|
|
29
|
+
message: (0, lang_1.i18n)(`${i18nKey}.selectContentType`),
|
|
30
|
+
default: ['ANY'],
|
|
31
31
|
choices: [
|
|
32
|
-
{ name: '
|
|
32
|
+
{ name: 'Any', value: 'ANY' },
|
|
33
|
+
{ name: 'Landing page', value: 'LANDING_PAGE' },
|
|
34
|
+
{ name: 'Site page', value: 'SITE_PAGE' },
|
|
33
35
|
{ name: 'Blog post', value: 'BLOG_POST' },
|
|
34
36
|
{ name: 'Blog listing', value: 'BLOG_LISTING' },
|
|
35
37
|
{ name: 'Email', value: 'EMAIL' },
|
|
38
|
+
{ name: 'Knowledge base', value: 'KNOWLEDGE_BASE' },
|
|
39
|
+
{ name: 'Quote template', value: 'QUOTE_TEMPLATE' },
|
|
40
|
+
{ name: 'Customer portal', value: 'CUSTOMER_PORTAL' },
|
|
41
|
+
{ name: 'Web interactive', value: 'WEB_INTERACTIVE' },
|
|
42
|
+
{ name: 'Subscription', value: 'SUBSCRIPTION' },
|
|
43
|
+
{ name: 'Membership', value: 'MEMBERSHIP' },
|
|
36
44
|
],
|
|
37
|
-
validate: input => {
|
|
45
|
+
validate: (input) => {
|
|
38
46
|
return new Promise(function (resolve, reject) {
|
|
39
47
|
if (input.length > 0) {
|
|
40
48
|
resolve(true);
|
|
41
49
|
}
|
|
42
|
-
reject(i18n(`${i18nKey}.errors.contentTypeRequired`));
|
|
50
|
+
reject((0, lang_1.i18n)(`${i18nKey}.errors.contentTypeRequired`));
|
|
43
51
|
});
|
|
44
52
|
},
|
|
45
53
|
};
|
|
46
54
|
const GLOBAL_PROMPT = {
|
|
47
55
|
type: 'confirm',
|
|
48
56
|
name: 'global',
|
|
49
|
-
message: i18n(`${i18nKey}.confirmGlobal`),
|
|
57
|
+
message: (0, lang_1.i18n)(`${i18nKey}.confirmGlobal`),
|
|
50
58
|
default: false,
|
|
51
59
|
};
|
|
60
|
+
const AVAILABLE_FOR_NEW_CONTENT = {
|
|
61
|
+
type: 'confirm',
|
|
62
|
+
name: 'availableForNewContent',
|
|
63
|
+
message: (0, lang_1.i18n)(`${i18nKey}.availableForNewContent`),
|
|
64
|
+
default: true,
|
|
65
|
+
};
|
|
52
66
|
function createModulePrompt() {
|
|
53
|
-
return promptUser([
|
|
67
|
+
return (0, promptUtils_1.promptUser)([
|
|
54
68
|
MODULE_LABEL_PROMPT,
|
|
55
69
|
REACT_TYPE_PROMPT,
|
|
56
70
|
CONTENT_TYPES_PROMPT,
|
|
57
71
|
GLOBAL_PROMPT,
|
|
72
|
+
AVAILABLE_FOR_NEW_CONTENT,
|
|
58
73
|
]);
|
|
59
74
|
}
|
|
60
|
-
module.exports = {
|
|
61
|
-
createModulePrompt,
|
|
62
|
-
};
|
|
@@ -1 +1,14 @@
|
|
|
1
|
+
import { RepoPath } from '@hubspot/local-dev-lib/types/Github';
|
|
2
|
+
import { ProjectTemplate } from '../../types/Projects';
|
|
3
|
+
type CreateProjectPromptResponse = {
|
|
4
|
+
name: string;
|
|
5
|
+
dest: string;
|
|
6
|
+
template: ProjectTemplate;
|
|
7
|
+
};
|
|
8
|
+
export declare function createProjectPrompt(githubRef: string, promptOptions: {
|
|
9
|
+
name: string;
|
|
10
|
+
dest: string;
|
|
11
|
+
template: string;
|
|
12
|
+
templateSource: RepoPath;
|
|
13
|
+
}, skipTemplatePrompt?: boolean): Promise<CreateProjectPromptResponse>;
|
|
1
14
|
export {};
|