@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,47 +1,51 @@
|
|
|
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
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
exports.previewPrompt = previewPrompt;
|
|
7
|
+
exports.previewProjectPrompt = previewProjectPrompt;
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
10
|
+
const promptUtils_1 = require("./promptUtils");
|
|
11
|
+
const lang_1 = require("../lang");
|
|
8
12
|
const i18nKey = 'lib.prompts.previewPrompt';
|
|
9
|
-
|
|
10
|
-
return promptUser([
|
|
13
|
+
async function previewPrompt(promptOptions = {}) {
|
|
14
|
+
return (0, promptUtils_1.promptUser)([
|
|
11
15
|
{
|
|
12
16
|
name: 'src',
|
|
13
|
-
message: i18n(`${i18nKey}.enterSrc`),
|
|
17
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterSrc`),
|
|
14
18
|
when: !promptOptions.src,
|
|
15
19
|
default: '.',
|
|
16
|
-
validate: input => {
|
|
20
|
+
validate: (input) => {
|
|
17
21
|
if (!input) {
|
|
18
|
-
return i18n(`${i18nKey}.errors.srcRequired`);
|
|
22
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.srcRequired`);
|
|
19
23
|
}
|
|
20
24
|
return true;
|
|
21
25
|
},
|
|
22
26
|
},
|
|
23
27
|
{
|
|
24
28
|
name: 'dest',
|
|
25
|
-
message: i18n(`${i18nKey}.enterDest`),
|
|
29
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterDest`),
|
|
26
30
|
when: !promptOptions.dest,
|
|
27
|
-
default:
|
|
28
|
-
validate: input => {
|
|
31
|
+
default: path_1.default.basename((0, path_2.getCwd)()),
|
|
32
|
+
validate: (input) => {
|
|
29
33
|
if (!input) {
|
|
30
|
-
return i18n(`${i18nKey}.errors.destRequired`);
|
|
34
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.destRequired`);
|
|
31
35
|
}
|
|
32
36
|
return true;
|
|
33
37
|
},
|
|
34
38
|
},
|
|
35
39
|
]);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return promptUser([
|
|
40
|
+
}
|
|
41
|
+
async function previewProjectPrompt(themeComponents) {
|
|
42
|
+
return (0, promptUtils_1.promptUser)([
|
|
39
43
|
{
|
|
40
44
|
name: 'themeComponentPath',
|
|
41
|
-
message: i18n(`${i18nKey}.themeProjectSelect`),
|
|
45
|
+
message: (0, lang_1.i18n)(`${i18nKey}.themeProjectSelect`),
|
|
42
46
|
type: 'list',
|
|
43
47
|
choices: themeComponents.map(t => {
|
|
44
|
-
const themeName =
|
|
48
|
+
const themeName = path_1.default.basename(t.path);
|
|
45
49
|
return {
|
|
46
50
|
name: themeName,
|
|
47
51
|
value: t.path,
|
|
@@ -49,8 +53,4 @@ const previewProjectPrompt = async (themeComponents) => {
|
|
|
49
53
|
}),
|
|
50
54
|
},
|
|
51
55
|
]);
|
|
52
|
-
}
|
|
53
|
-
module.exports = {
|
|
54
|
-
previewPrompt,
|
|
55
|
-
previewProjectPrompt,
|
|
56
|
-
};
|
|
56
|
+
}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
import { ProjectAddComponentData } from '../../types/Projects';
|
|
2
|
+
type ProjectAddPromptResponse = {
|
|
3
|
+
component: ProjectAddComponentData;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function projectAddPrompt(components: ProjectAddComponentData[], promptOptions?: {
|
|
7
|
+
name?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
}): Promise<ProjectAddPromptResponse>;
|
|
1
10
|
export {};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.projectAddPrompt = projectAddPrompt;
|
|
4
|
+
const promptUtils_1 = require("./promptUtils");
|
|
5
|
+
const lang_1 = require("../lang");
|
|
6
6
|
const i18nKey = 'lib.prompts.projectAddPrompt';
|
|
7
|
-
|
|
8
|
-
return promptUser([
|
|
7
|
+
async function projectAddPrompt(components, promptOptions = {}) {
|
|
8
|
+
return (0, promptUtils_1.promptUser)([
|
|
9
9
|
{
|
|
10
10
|
name: 'component',
|
|
11
11
|
message: () => {
|
|
12
12
|
return promptOptions.type &&
|
|
13
13
|
!components.find(t => t.path === promptOptions.type)
|
|
14
|
-
? i18n(`${i18nKey}.errors.invalidType`, {
|
|
14
|
+
? (0, lang_1.i18n)(`${i18nKey}.errors.invalidType`, {
|
|
15
15
|
type: promptOptions.type,
|
|
16
16
|
})
|
|
17
|
-
: i18n(`${i18nKey}.selectType`);
|
|
17
|
+
: (0, lang_1.i18n)(`${i18nKey}.selectType`);
|
|
18
18
|
},
|
|
19
19
|
when: !promptOptions.type ||
|
|
20
20
|
!components.find(t => t.path === promptOptions.type),
|
|
@@ -28,17 +28,14 @@ const projectAddPrompt = async (components, promptOptions = {}) => {
|
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
name: 'name',
|
|
31
|
-
message: i18n(`${i18nKey}.enterName`),
|
|
31
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterName`),
|
|
32
32
|
when: !promptOptions.name,
|
|
33
|
-
validate: input => {
|
|
33
|
+
validate: (input) => {
|
|
34
34
|
if (!input) {
|
|
35
|
-
return i18n(`${i18nKey}.errors.nameRequired`);
|
|
35
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.nameRequired`);
|
|
36
36
|
}
|
|
37
37
|
return true;
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
]);
|
|
41
|
-
}
|
|
42
|
-
module.exports = {
|
|
43
|
-
projectAddPrompt,
|
|
44
|
-
};
|
|
41
|
+
}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { CLIAccount, AccountType } from '@hubspot/local-dev-lib/types/Accounts';
|
|
2
|
+
import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
3
|
+
export declare function selectSandboxTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<DeveloperTestAccount | CLIAccount>;
|
|
4
|
+
export declare function selectDeveloperTestTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<DeveloperTestAccount | CLIAccount>;
|
|
5
|
+
export declare function confirmDefaultAccountPrompt(accountName: string, accountType: AccountType): Promise<boolean>;
|
|
6
|
+
export declare function confirmUseExistingDeveloperTestAccountPrompt(account: DeveloperTestAccount): Promise<boolean>;
|
|
@@ -1,51 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
3
|
+
exports.selectSandboxTargetAccountPrompt = selectSandboxTargetAccountPrompt;
|
|
4
|
+
exports.selectDeveloperTestTargetAccountPrompt = selectDeveloperTestTargetAccountPrompt;
|
|
5
|
+
exports.confirmDefaultAccountPrompt = confirmDefaultAccountPrompt;
|
|
6
|
+
exports.confirmUseExistingDeveloperTestAccountPrompt = confirmUseExistingDeveloperTestAccountPrompt;
|
|
7
|
+
const promptUtils_1 = require("./promptUtils");
|
|
8
|
+
const lang_1 = require("../lang");
|
|
9
|
+
const ui_1 = require("../ui");
|
|
10
|
+
const accountTypes_1 = require("../accountTypes");
|
|
11
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
12
|
+
const sandboxHubs_1 = require("@hubspot/local-dev-lib/api/sandboxHubs");
|
|
13
|
+
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
14
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
15
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
16
|
+
const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
|
|
17
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
13
18
|
const i18nKey = 'lib.prompts.projectDevTargetAccountPrompt';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
function mapNestedAccount(accountConfig) {
|
|
20
|
+
const parentAccountId = accountConfig.parentAccountId ?? null;
|
|
21
|
+
return {
|
|
22
|
+
name: (0, ui_1.uiAccountDescription)((0, getAccountIdentifier_1.getAccountIdentifier)(accountConfig), false),
|
|
23
|
+
value: {
|
|
24
|
+
targetAccountId: (0, config_1.getAccountId)(accountConfig.name),
|
|
25
|
+
createNestedAccount: false,
|
|
26
|
+
parentAccountId,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function getNonConfigDeveloperTestAccountName(account) {
|
|
31
|
+
return `${account.accountName} [${config_2.HUBSPOT_ACCOUNT_TYPE_STRINGS[config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST]}] (${account.id})`;
|
|
32
|
+
}
|
|
33
|
+
async function selectSandboxTargetAccountPrompt(accounts, defaultAccountConfig) {
|
|
34
|
+
const defaultAccountId = (0, config_1.getAccountId)(defaultAccountConfig.name);
|
|
27
35
|
let choices = [];
|
|
28
|
-
let sandboxUsage = {
|
|
36
|
+
let sandboxUsage = {
|
|
37
|
+
STANDARD: { used: 0, available: 0, limit: 0 },
|
|
38
|
+
DEVELOPER: { used: 0, available: 0, limit: 0 },
|
|
39
|
+
};
|
|
29
40
|
try {
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
if (defaultAccountId) {
|
|
42
|
+
const { data } = await (0, sandboxHubs_1.getSandboxUsageLimits)(defaultAccountId);
|
|
43
|
+
sandboxUsage = data.usage;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
logger_1.logger.error(`${i18nKey}.noAccountId`);
|
|
47
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
48
|
+
}
|
|
32
49
|
}
|
|
33
50
|
catch (err) {
|
|
34
|
-
logger.debug('Unable to fetch sandbox usage limits: ', err);
|
|
51
|
+
logger_1.logger.debug('Unable to fetch sandbox usage limits: ', err);
|
|
35
52
|
}
|
|
36
53
|
const sandboxAccounts = accounts
|
|
37
54
|
.reverse()
|
|
38
|
-
.filter(config => isSandbox(config) && config.parentAccountId === defaultAccountId);
|
|
55
|
+
.filter(config => (0, accountTypes_1.isSandbox)(config) && config.parentAccountId === defaultAccountId);
|
|
39
56
|
let disabledMessage = false;
|
|
40
57
|
if (sandboxUsage['DEVELOPER'] && sandboxUsage['DEVELOPER'].available === 0) {
|
|
41
58
|
if (sandboxAccounts.length < sandboxUsage['DEVELOPER'].limit) {
|
|
42
|
-
disabledMessage = i18n(`${i18nKey}.sandboxLimitWithSuggestion`, {
|
|
43
|
-
authCommand: uiCommandReference('hs auth'),
|
|
59
|
+
disabledMessage = (0, lang_1.i18n)(`${i18nKey}.sandboxLimitWithSuggestion`, {
|
|
60
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
44
61
|
limit: sandboxUsage['DEVELOPER'].limit,
|
|
45
62
|
});
|
|
46
63
|
}
|
|
47
64
|
else {
|
|
48
|
-
disabledMessage = i18n(`${i18nKey}.sandboxLimit`, {
|
|
65
|
+
disabledMessage = (0, lang_1.i18n)(`${i18nKey}.sandboxLimit`, {
|
|
49
66
|
limit: sandboxUsage['DEVELOPER'].limit,
|
|
50
67
|
});
|
|
51
68
|
}
|
|
@@ -53,13 +70,13 @@ const selectSandboxTargetAccountPrompt = async (accounts, defaultAccountConfig)
|
|
|
53
70
|
// Order choices by Developer Sandbox -> Standard Sandbox
|
|
54
71
|
choices = [
|
|
55
72
|
...sandboxAccounts
|
|
56
|
-
.filter(a => a.accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)
|
|
73
|
+
.filter(a => a.accountType === config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)
|
|
57
74
|
.map(mapNestedAccount),
|
|
58
75
|
...sandboxAccounts
|
|
59
|
-
.filter(a => a.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX)
|
|
76
|
+
.filter(a => a.accountType === config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX)
|
|
60
77
|
.map(mapNestedAccount),
|
|
61
78
|
{
|
|
62
|
-
name: i18n(`${i18nKey}.createNewSandboxOption`),
|
|
79
|
+
name: (0, lang_1.i18n)(`${i18nKey}.createNewSandboxOption`),
|
|
63
80
|
value: {
|
|
64
81
|
targetAccountId: null,
|
|
65
82
|
createNestedAccount: true,
|
|
@@ -67,7 +84,7 @@ const selectSandboxTargetAccountPrompt = async (accounts, defaultAccountConfig)
|
|
|
67
84
|
disabled: disabledMessage,
|
|
68
85
|
},
|
|
69
86
|
{
|
|
70
|
-
name: i18n(`${i18nKey}.chooseDefaultAccountOption`),
|
|
87
|
+
name: (0, lang_1.i18n)(`${i18nKey}.chooseDefaultAccountOption`),
|
|
71
88
|
value: {
|
|
72
89
|
targetAccountId: defaultAccountId,
|
|
73
90
|
createNestedAccount: false,
|
|
@@ -75,37 +92,43 @@ const selectSandboxTargetAccountPrompt = async (accounts, defaultAccountConfig)
|
|
|
75
92
|
},
|
|
76
93
|
];
|
|
77
94
|
return selectTargetAccountPrompt(defaultAccountId, 'sandbox account', choices);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const defaultAccountId = getAccountId(defaultAccountConfig.name);
|
|
81
|
-
let devTestAccountsResponse
|
|
95
|
+
}
|
|
96
|
+
async function selectDeveloperTestTargetAccountPrompt(accounts, defaultAccountConfig) {
|
|
97
|
+
const defaultAccountId = (0, config_1.getAccountId)(defaultAccountConfig.name);
|
|
98
|
+
let devTestAccountsResponse;
|
|
82
99
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
if (defaultAccountId) {
|
|
101
|
+
const { data } = await (0, developerTestAccounts_1.fetchDeveloperTestAccounts)(defaultAccountId);
|
|
102
|
+
devTestAccountsResponse = data;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
logger_1.logger.error(`${i18nKey}.noAccountId`);
|
|
106
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
107
|
+
}
|
|
85
108
|
}
|
|
86
109
|
catch (err) {
|
|
87
|
-
logger.debug('Unable to fetch developer test account usage limits: ', err);
|
|
110
|
+
logger_1.logger.debug('Unable to fetch developer test account usage limits: ', err);
|
|
88
111
|
}
|
|
89
112
|
let disabledMessage = false;
|
|
90
113
|
if (devTestAccountsResponse &&
|
|
91
114
|
devTestAccountsResponse.results.length >=
|
|
92
115
|
devTestAccountsResponse.maxTestPortals) {
|
|
93
|
-
disabledMessage = i18n(`${i18nKey}.developerTestAccountLimit`, {
|
|
94
|
-
authCommand: uiCommandReference('hs auth'),
|
|
116
|
+
disabledMessage = (0, lang_1.i18n)(`${i18nKey}.developerTestAccountLimit`, {
|
|
117
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
95
118
|
limit: devTestAccountsResponse.maxTestPortals,
|
|
96
119
|
});
|
|
97
120
|
}
|
|
98
121
|
const devTestAccounts = [];
|
|
99
122
|
if (devTestAccountsResponse && devTestAccountsResponse.results) {
|
|
100
|
-
const accountIds = accounts.map(account =>
|
|
123
|
+
const accountIds = accounts.map(account => (0, getAccountIdentifier_1.getAccountIdentifier)(account));
|
|
101
124
|
devTestAccountsResponse.results.forEach(acct => {
|
|
102
125
|
const inConfig = accountIds.includes(acct.id);
|
|
103
126
|
devTestAccounts.push({
|
|
104
127
|
name: getNonConfigDeveloperTestAccountName(acct),
|
|
105
128
|
value: {
|
|
106
129
|
targetAccountId: acct.id,
|
|
107
|
-
|
|
108
|
-
parentAccountId: defaultAccountId,
|
|
130
|
+
createNestedAccount: false,
|
|
131
|
+
parentAccountId: defaultAccountId ?? null,
|
|
109
132
|
notInConfigAccount: inConfig ? null : acct,
|
|
110
133
|
},
|
|
111
134
|
});
|
|
@@ -114,7 +137,7 @@ const selectDeveloperTestTargetAccountPrompt = async (accounts, defaultAccountCo
|
|
|
114
137
|
const choices = [
|
|
115
138
|
...devTestAccounts,
|
|
116
139
|
{
|
|
117
|
-
name: i18n(`${i18nKey}.createNewDeveloperTestAccountOption`),
|
|
140
|
+
name: (0, lang_1.i18n)(`${i18nKey}.createNewDeveloperTestAccountOption`),
|
|
118
141
|
value: {
|
|
119
142
|
targetAccountId: null,
|
|
120
143
|
createNestedAccount: true,
|
|
@@ -122,50 +145,45 @@ const selectDeveloperTestTargetAccountPrompt = async (accounts, defaultAccountCo
|
|
|
122
145
|
disabled: disabledMessage,
|
|
123
146
|
},
|
|
124
147
|
];
|
|
125
|
-
return selectTargetAccountPrompt(defaultAccountId, HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST], choices);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const
|
|
148
|
+
return selectTargetAccountPrompt(defaultAccountId, config_2.HUBSPOT_ACCOUNT_TYPE_STRINGS[config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST], choices);
|
|
149
|
+
}
|
|
150
|
+
async function selectTargetAccountPrompt(defaultAccountId, accountType, choices) {
|
|
151
|
+
const accountId = defaultAccountId;
|
|
152
|
+
const { targetAccountInfo } = await (0, promptUtils_1.promptUser)([
|
|
129
153
|
{
|
|
130
154
|
name: 'targetAccountInfo',
|
|
131
155
|
type: 'list',
|
|
132
|
-
message: i18n(`${i18nKey}.promptMessage`, {
|
|
133
|
-
accountIdentifier: uiAccountDescription(
|
|
156
|
+
message: (0, lang_1.i18n)(`${i18nKey}.promptMessage`, {
|
|
157
|
+
accountIdentifier: (0, ui_1.uiAccountDescription)(accountId),
|
|
134
158
|
accountType,
|
|
135
159
|
}),
|
|
136
160
|
choices,
|
|
137
161
|
},
|
|
138
162
|
]);
|
|
139
163
|
return targetAccountInfo;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const { useDefaultAccount } = await promptUser([
|
|
164
|
+
}
|
|
165
|
+
async function confirmDefaultAccountPrompt(accountName, accountType) {
|
|
166
|
+
const { useDefaultAccount } = await (0, promptUtils_1.promptUser)([
|
|
143
167
|
{
|
|
144
168
|
name: 'useDefaultAccount',
|
|
145
169
|
type: 'confirm',
|
|
146
|
-
message: i18n(`${i18nKey}.confirmDefaultAccount`, {
|
|
170
|
+
message: (0, lang_1.i18n)(`${i18nKey}.confirmDefaultAccount`, {
|
|
147
171
|
accountName,
|
|
148
172
|
accountType,
|
|
149
173
|
}),
|
|
150
174
|
},
|
|
151
175
|
]);
|
|
152
176
|
return useDefaultAccount;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const { confirmUseExistingDeveloperTestAccount } = await promptUser([
|
|
177
|
+
}
|
|
178
|
+
async function confirmUseExistingDeveloperTestAccountPrompt(account) {
|
|
179
|
+
const { confirmUseExistingDeveloperTestAccount } = await (0, promptUtils_1.promptUser)([
|
|
156
180
|
{
|
|
157
181
|
name: 'confirmUseExistingDeveloperTestAccount',
|
|
158
182
|
type: 'confirm',
|
|
159
|
-
message: i18n(`${i18nKey}.confirmUseExistingDeveloperTestAccount`, {
|
|
183
|
+
message: (0, lang_1.i18n)(`${i18nKey}.confirmUseExistingDeveloperTestAccount`, {
|
|
160
184
|
accountName: getNonConfigDeveloperTestAccountName(account),
|
|
161
185
|
}),
|
|
162
186
|
},
|
|
163
187
|
]);
|
|
164
188
|
return confirmUseExistingDeveloperTestAccount;
|
|
165
|
-
}
|
|
166
|
-
module.exports = {
|
|
167
|
-
selectSandboxTargetAccountPrompt,
|
|
168
|
-
selectDeveloperTestTargetAccountPrompt,
|
|
169
|
-
confirmDefaultAccountPrompt,
|
|
170
|
-
confirmUseExistingDeveloperTestAccountPrompt,
|
|
171
|
-
};
|
|
189
|
+
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
type ProjectLogsPromptOptions = {
|
|
2
|
+
functionChoices?: string[];
|
|
3
|
+
promptOptions?: {
|
|
4
|
+
function?: string;
|
|
5
|
+
};
|
|
6
|
+
projectName?: string;
|
|
7
|
+
};
|
|
8
|
+
type ProjectLogsPromptResponse = {
|
|
9
|
+
functionName?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function projectLogsPrompt({ functionChoices, promptOptions, projectName, }: ProjectLogsPromptOptions): Promise<ProjectLogsPromptResponse>;
|
|
1
12
|
export {};
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.projectLogsPrompt = projectLogsPrompt;
|
|
4
|
+
const lang_1 = require("../lang");
|
|
5
|
+
const promptUtils_1 = require("./promptUtils");
|
|
6
6
|
const i18nKey = 'lib.prompts.projectLogsPrompt';
|
|
7
|
-
|
|
7
|
+
async function projectLogsPrompt({ functionChoices, promptOptions, projectName = '', }) {
|
|
8
8
|
if (!functionChoices) {
|
|
9
9
|
return {};
|
|
10
10
|
}
|
|
11
|
-
if (functionChoices
|
|
11
|
+
if (functionChoices.length === 1) {
|
|
12
12
|
return { functionName: functionChoices[0] };
|
|
13
13
|
}
|
|
14
|
-
return promptUser([
|
|
14
|
+
return (0, promptUtils_1.promptUser)([
|
|
15
15
|
{
|
|
16
16
|
name: 'functionName',
|
|
17
17
|
type: 'list',
|
|
18
|
-
message: i18n(`${i18nKey}.functionName`, { projectName }),
|
|
18
|
+
message: (0, lang_1.i18n)(`${i18nKey}.functionName`, { projectName }),
|
|
19
19
|
when: () => (!promptOptions || !promptOptions.function) &&
|
|
20
20
|
functionChoices.length > 0,
|
|
21
21
|
choices: functionChoices,
|
|
22
22
|
},
|
|
23
23
|
]);
|
|
24
|
-
}
|
|
25
|
-
module.exports = {
|
|
26
|
-
projectLogsPrompt,
|
|
27
|
-
};
|
|
24
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { PromptConfig, GenericPromptResponse, PromptWhen, PromptChoices } from '../../types/Prompts';
|
|
2
|
+
export declare function promptUser<T extends GenericPromptResponse>(config: PromptConfig<T> | PromptConfig<T>[]): Promise<T>;
|
|
2
3
|
export declare function confirmPrompt(message: string, options?: {
|
|
3
4
|
defaultAnswer?: boolean;
|
|
4
|
-
when?:
|
|
5
|
+
when?: PromptWhen;
|
|
5
6
|
}): Promise<boolean>;
|
|
6
7
|
export declare function listPrompt(message: string, { choices, when, }: {
|
|
7
|
-
choices:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
choices: PromptChoices;
|
|
9
|
+
when?: PromptWhen;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
export declare function inputPrompt(message: string, { when, }?: {
|
|
11
12
|
when?: boolean | (() => boolean);
|
|
12
13
|
}): Promise<string>;
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promptUser =
|
|
3
|
+
exports.promptUser = promptUser;
|
|
4
4
|
exports.confirmPrompt = confirmPrompt;
|
|
5
5
|
exports.listPrompt = listPrompt;
|
|
6
|
+
exports.inputPrompt = inputPrompt;
|
|
6
7
|
const inquirer = require('inquirer');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const promptModule = inquirer.createPromptModule();
|
|
9
|
+
function promptUser(config) {
|
|
10
|
+
return promptModule(config);
|
|
11
|
+
}
|
|
10
12
|
async function confirmPrompt(message, options = {}) {
|
|
11
|
-
const { defaultAnswer, when } = options;
|
|
12
|
-
const { choice } = await
|
|
13
|
+
const { defaultAnswer = true, when } = options;
|
|
14
|
+
const { choice } = await promptUser([
|
|
13
15
|
{
|
|
14
16
|
name: 'choice',
|
|
15
17
|
type: 'confirm',
|
|
16
18
|
message,
|
|
17
|
-
default: defaultAnswer
|
|
19
|
+
default: defaultAnswer,
|
|
18
20
|
when,
|
|
19
21
|
},
|
|
20
22
|
]);
|
|
21
23
|
return choice;
|
|
22
24
|
}
|
|
23
25
|
async function listPrompt(message, { choices, when, }) {
|
|
24
|
-
const { choice } = await
|
|
26
|
+
const { choice } = await promptUser([
|
|
25
27
|
{
|
|
26
28
|
name: 'choice',
|
|
27
29
|
type: 'list',
|
|
@@ -32,3 +34,14 @@ async function listPrompt(message, { choices, when, }) {
|
|
|
32
34
|
]);
|
|
33
35
|
return choice;
|
|
34
36
|
}
|
|
37
|
+
async function inputPrompt(message, { when, } = {}) {
|
|
38
|
+
const { input } = await promptUser([
|
|
39
|
+
{
|
|
40
|
+
name: 'input',
|
|
41
|
+
type: 'input',
|
|
42
|
+
message,
|
|
43
|
+
when,
|
|
44
|
+
},
|
|
45
|
+
]);
|
|
46
|
+
return input;
|
|
47
|
+
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
type SandboxTypePromptResponse = {
|
|
2
|
+
type: string;
|
|
3
|
+
};
|
|
4
|
+
type DeleteSandboxPromptResponse = {
|
|
5
|
+
account: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function sandboxTypePrompt(): Promise<SandboxTypePromptResponse>;
|
|
8
|
+
export declare function deleteSandboxPrompt(promptParentAccount?: boolean): Promise<DeleteSandboxPromptResponse> | void;
|
|
1
9
|
export {};
|