@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,71 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
3
|
+
exports.sandboxTypePrompt = sandboxTypePrompt;
|
|
4
|
+
exports.deleteSandboxPrompt = deleteSandboxPrompt;
|
|
5
|
+
const promptUtils_1 = require("./promptUtils");
|
|
6
|
+
const lang_1 = require("../lang");
|
|
7
|
+
const ui_1 = require("../ui");
|
|
8
|
+
const config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
9
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
10
|
+
const accountTypes_1 = require("../accountTypes");
|
|
11
|
+
const config_2 = require("@hubspot/local-dev-lib/config");
|
|
9
12
|
const i18nKey = 'lib.prompts.sandboxesPrompt';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
name: uiAccountDescription(p
|
|
15
|
-
value: p.name || p
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
name: `${p.name} (${p
|
|
23
|
-
value: p.name || p
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return promptUser([
|
|
13
|
+
function mapSandboxAccountChoices(portals) {
|
|
14
|
+
return (portals
|
|
15
|
+
?.filter(p => (0, accountTypes_1.isSandbox)(p))
|
|
16
|
+
.map(p => ({
|
|
17
|
+
name: (0, ui_1.uiAccountDescription)((0, getAccountIdentifier_1.getAccountIdentifier)(p), false),
|
|
18
|
+
value: p.name || (0, getAccountIdentifier_1.getAccountIdentifier)(p),
|
|
19
|
+
})) || []);
|
|
20
|
+
}
|
|
21
|
+
function mapNonSandboxAccountChoices(portals) {
|
|
22
|
+
return (portals
|
|
23
|
+
?.filter(p => !(0, accountTypes_1.isSandbox)(p))
|
|
24
|
+
.map(p => ({
|
|
25
|
+
name: `${p.name} (${(0, getAccountIdentifier_1.getAccountIdentifier)(p)})`,
|
|
26
|
+
value: p.name || (0, getAccountIdentifier_1.getAccountIdentifier)(p),
|
|
27
|
+
})) || []);
|
|
28
|
+
}
|
|
29
|
+
async function sandboxTypePrompt() {
|
|
30
|
+
return (0, promptUtils_1.promptUser)([
|
|
28
31
|
{
|
|
29
32
|
name: 'type',
|
|
30
|
-
message: i18n(`${i18nKey}.type.message`),
|
|
33
|
+
message: (0, lang_1.i18n)(`${i18nKey}.type.message`),
|
|
31
34
|
type: 'list',
|
|
32
|
-
look: false,
|
|
33
35
|
choices: [
|
|
34
36
|
{
|
|
35
|
-
name: i18n(`${i18nKey}.type.developer`),
|
|
36
|
-
value: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
37
|
+
name: (0, lang_1.i18n)(`${i18nKey}.type.developer`),
|
|
38
|
+
value: config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
37
39
|
},
|
|
38
40
|
{
|
|
39
|
-
name: i18n(`${i18nKey}.type.standard`),
|
|
40
|
-
value: HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
|
|
41
|
+
name: (0, lang_1.i18n)(`${i18nKey}.type.standard`),
|
|
42
|
+
value: config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
|
|
41
43
|
},
|
|
42
44
|
],
|
|
43
|
-
default: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
45
|
+
default: config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
44
46
|
},
|
|
45
47
|
]);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
+
}
|
|
49
|
+
function deleteSandboxPrompt(promptParentAccount = false) {
|
|
50
|
+
const accountsList = (0, config_2.getConfigAccounts)();
|
|
48
51
|
const choices = promptParentAccount
|
|
49
|
-
? mapNonSandboxAccountChoices(
|
|
50
|
-
: mapSandboxAccountChoices(
|
|
52
|
+
? mapNonSandboxAccountChoices(accountsList)
|
|
53
|
+
: mapSandboxAccountChoices(accountsList);
|
|
51
54
|
if (!choices.length) {
|
|
52
|
-
return
|
|
55
|
+
return;
|
|
53
56
|
}
|
|
54
|
-
return promptUser([
|
|
57
|
+
return (0, promptUtils_1.promptUser)([
|
|
55
58
|
{
|
|
56
59
|
name: 'account',
|
|
57
|
-
message: i18n(promptParentAccount
|
|
60
|
+
message: (0, lang_1.i18n)(promptParentAccount
|
|
58
61
|
? `${i18nKey}.selectParentAccountName`
|
|
59
62
|
: `${i18nKey}.selectAccountName`),
|
|
60
63
|
type: 'list',
|
|
61
|
-
look: false,
|
|
62
64
|
pageSize: 20,
|
|
63
65
|
choices,
|
|
64
|
-
default:
|
|
66
|
+
default: (0, config_2.getConfigDefaultAccount)(),
|
|
65
67
|
},
|
|
66
68
|
]);
|
|
67
|
-
}
|
|
68
|
-
module.exports = {
|
|
69
|
-
sandboxTypePrompt,
|
|
70
|
-
deleteSandboxPrompt,
|
|
71
|
-
};
|
|
69
|
+
}
|
|
@@ -1 +1,13 @@
|
|
|
1
|
+
type SecretValuePromptResponse = {
|
|
2
|
+
secretValue: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function secretValuePrompt(): Promise<SecretValuePromptResponse>;
|
|
5
|
+
type SecretNamePromptResponse = {
|
|
6
|
+
secretName: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function secretNamePrompt(): Promise<SecretNamePromptResponse>;
|
|
9
|
+
type SecretListPromptResponse = {
|
|
10
|
+
secretToModify: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function secretListPrompt(secrets: string[], message: string): Promise<SecretListPromptResponse>;
|
|
1
13
|
export {};
|
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.secretValuePrompt = secretValuePrompt;
|
|
4
|
+
exports.secretNamePrompt = secretNamePrompt;
|
|
5
|
+
exports.secretListPrompt = secretListPrompt;
|
|
6
|
+
const promptUtils_1 = require("./promptUtils");
|
|
7
|
+
const lang_1 = require("../lang");
|
|
6
8
|
const i18nKey = 'lib.prompts.secretPrompt';
|
|
7
|
-
const SECRET_VALUE_PROMPT = {
|
|
8
|
-
name: 'secretValue',
|
|
9
|
-
type: 'password',
|
|
10
|
-
mask: '*',
|
|
11
|
-
message: i18n(`${i18nKey}.enterValue`),
|
|
12
|
-
validate(val) {
|
|
13
|
-
if (typeof val !== 'string') {
|
|
14
|
-
return i18n(`${i18nKey}.errors.invalidValue`);
|
|
15
|
-
}
|
|
16
|
-
return true;
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
9
|
function secretValuePrompt() {
|
|
20
|
-
return promptUser([
|
|
10
|
+
return (0, promptUtils_1.promptUser)([
|
|
11
|
+
{
|
|
12
|
+
name: 'secretValue',
|
|
13
|
+
type: 'password',
|
|
14
|
+
mask: '*',
|
|
15
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterValue`),
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
function secretNamePrompt() {
|
|
20
|
+
return (0, promptUtils_1.promptUser)([
|
|
21
|
+
{
|
|
22
|
+
name: 'secretName',
|
|
23
|
+
type: 'input',
|
|
24
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterName`),
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
function secretListPrompt(secrets, message) {
|
|
29
|
+
return (0, promptUtils_1.promptUser)([
|
|
30
|
+
{
|
|
31
|
+
name: 'secretToModify',
|
|
32
|
+
type: 'list',
|
|
33
|
+
choices: secrets,
|
|
34
|
+
message,
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
21
37
|
}
|
|
22
|
-
module.exports = {
|
|
23
|
-
secretValuePrompt,
|
|
24
|
-
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.selectHubDBTablePrompt = selectHubDBTablePrompt;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const promptUtils_1 = require("./promptUtils");
|
|
9
|
+
const lang_1 = require("../lang");
|
|
10
|
+
const index_1 = require("../errorHandlers/index");
|
|
11
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
12
|
+
const hubdb_1 = require("@hubspot/local-dev-lib/api/hubdb");
|
|
13
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
14
|
+
const path_1 = require("@hubspot/local-dev-lib/path");
|
|
15
|
+
const i18nKey = 'lib.prompts.selectHubDBTablePrompt';
|
|
16
|
+
async function fetchHubDBOptions(accountId) {
|
|
17
|
+
try {
|
|
18
|
+
const { data: { results: tables }, } = await (0, hubdb_1.fetchTables)(accountId);
|
|
19
|
+
if (tables.length === 0) {
|
|
20
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.errors.noTables`, { accountId }));
|
|
21
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
22
|
+
}
|
|
23
|
+
return tables;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
(0, index_1.debugError)(error, { accountId });
|
|
27
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.errorFetchingTables`, { accountId }));
|
|
28
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function selectHubDBTablePrompt({ accountId, options, skipDestPrompt = true, }) {
|
|
32
|
+
const hubdbTables = (await fetchHubDBOptions(accountId)) || [];
|
|
33
|
+
const id = options.tableId?.toString();
|
|
34
|
+
const isValidTable = options.tableId && hubdbTables.find(table => table.id === id);
|
|
35
|
+
return (0, promptUtils_1.promptUser)([
|
|
36
|
+
{
|
|
37
|
+
name: 'tableId',
|
|
38
|
+
message: (0, lang_1.i18n)(`${i18nKey}.selectTable`),
|
|
39
|
+
when: !id && !isValidTable,
|
|
40
|
+
type: 'list',
|
|
41
|
+
choices: hubdbTables.map(table => {
|
|
42
|
+
return {
|
|
43
|
+
name: `${table.label} (${table.id})`,
|
|
44
|
+
value: table.id,
|
|
45
|
+
};
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'dest',
|
|
50
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterDest`),
|
|
51
|
+
when: !options.dest && !skipDestPrompt,
|
|
52
|
+
validate: (input) => {
|
|
53
|
+
if (!input) {
|
|
54
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.destRequired`);
|
|
55
|
+
}
|
|
56
|
+
if (fs_1.default.existsSync(input)) {
|
|
57
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidDest`);
|
|
58
|
+
}
|
|
59
|
+
if (!(0, path_1.isValidPath)(input)) {
|
|
60
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.invalidCharacters`);
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
},
|
|
64
|
+
filter: (input) => {
|
|
65
|
+
return (0, path_1.untildify)(input);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
type PublicAppPromptResponse = {
|
|
2
|
+
appId: number;
|
|
3
|
+
};
|
|
4
|
+
export declare function selectPublicAppPrompt({ accountId, accountName, isMigratingApp, }: {
|
|
5
|
+
accountId: number | null;
|
|
6
|
+
accountName: string;
|
|
7
|
+
isMigratingApp?: boolean;
|
|
8
|
+
}): Promise<PublicAppPromptResponse>;
|
|
1
9
|
export {};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
3
|
+
exports.selectPublicAppPrompt = selectPublicAppPrompt;
|
|
4
|
+
const promptUtils_1 = require("./promptUtils");
|
|
5
|
+
const lang_1 = require("../lang");
|
|
6
|
+
const ui_1 = require("../ui");
|
|
7
|
+
const index_1 = require("../errorHandlers/index");
|
|
8
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
9
|
+
const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
|
|
10
|
+
const exitCodes_1 = require("../enums/exitCodes");
|
|
11
11
|
const i18nKey = 'lib.prompts.selectPublicAppPrompt';
|
|
12
|
-
|
|
12
|
+
async function fetchPublicAppOptions(accountId, accountName, isMigratingApp = false) {
|
|
13
13
|
try {
|
|
14
|
-
|
|
14
|
+
if (!accountId) {
|
|
15
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noAccountId`));
|
|
16
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
17
|
+
}
|
|
18
|
+
const { data: { results: publicApps }, } = await (0, appsDev_1.fetchPublicAppsForPortal)(accountId);
|
|
15
19
|
const filteredPublicApps = publicApps.filter(app => !app.projectId && !app.sourceId);
|
|
16
20
|
if (!filteredPublicApps.length ||
|
|
17
21
|
(isMigratingApp &&
|
|
@@ -22,29 +26,29 @@ const fetchPublicAppOptions = async (accountId, accountName, isMigratingApp = fa
|
|
|
22
26
|
const messageTranslationKey = isMigratingApp
|
|
23
27
|
? 'noAppsMigrationMessage'
|
|
24
28
|
: 'noAppsCloneMessage';
|
|
25
|
-
uiLine();
|
|
26
|
-
logger.error(i18n(`${i18nKey}.errors.${headerTranslationKey}`));
|
|
27
|
-
logger.log(i18n(`${i18nKey}.errors.${messageTranslationKey}`, { accountName }));
|
|
28
|
-
uiLine();
|
|
29
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
29
|
+
(0, ui_1.uiLine)();
|
|
30
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.${headerTranslationKey}`));
|
|
31
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.errors.${messageTranslationKey}`, { accountName }));
|
|
32
|
+
(0, ui_1.uiLine)();
|
|
33
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
30
34
|
}
|
|
31
35
|
return filteredPublicApps;
|
|
32
36
|
}
|
|
33
37
|
catch (error) {
|
|
34
|
-
logError(error, { accountId });
|
|
35
|
-
logger.error(i18n(`${i18nKey}.errors.errorFetchingApps`));
|
|
36
|
-
process.exit(EXIT_CODES.ERROR);
|
|
38
|
+
(0, index_1.logError)(error, accountId ? { accountId } : undefined);
|
|
39
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.errorFetchingApps`));
|
|
40
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
37
41
|
}
|
|
38
|
-
}
|
|
39
|
-
|
|
42
|
+
}
|
|
43
|
+
async function selectPublicAppPrompt({ accountId, accountName, isMigratingApp = false, }) {
|
|
40
44
|
const publicApps = await fetchPublicAppOptions(accountId, accountName, isMigratingApp);
|
|
41
45
|
const translationKey = isMigratingApp
|
|
42
46
|
? 'selectAppIdMigrate'
|
|
43
47
|
: 'selectAppIdClone';
|
|
44
|
-
return promptUser([
|
|
48
|
+
return (0, promptUtils_1.promptUser)([
|
|
45
49
|
{
|
|
46
50
|
name: 'appId',
|
|
47
|
-
message: i18n(`${i18nKey}.${translationKey}`, {
|
|
51
|
+
message: (0, lang_1.i18n)(`${i18nKey}.${translationKey}`, {
|
|
48
52
|
accountName,
|
|
49
53
|
}),
|
|
50
54
|
type: 'list',
|
|
@@ -53,7 +57,7 @@ const selectPublicAppPrompt = async ({ accountId, accountName, isMigratingApp =
|
|
|
53
57
|
if (isMigratingApp && preventProjectMigrations && listingInfo) {
|
|
54
58
|
return {
|
|
55
59
|
name: `${app.name} (${app.id})`,
|
|
56
|
-
disabled: i18n(`${i18nKey}.errors.cannotBeMigrated`),
|
|
60
|
+
disabled: (0, lang_1.i18n)(`${i18nKey}.errors.cannotBeMigrated`),
|
|
57
61
|
};
|
|
58
62
|
}
|
|
59
63
|
return {
|
|
@@ -63,7 +67,4 @@ const selectPublicAppPrompt = async ({ accountId, accountName, isMigratingApp =
|
|
|
63
67
|
}),
|
|
64
68
|
},
|
|
65
69
|
]);
|
|
66
|
-
}
|
|
67
|
-
module.exports = {
|
|
68
|
-
selectPublicAppPrompt,
|
|
69
|
-
};
|
|
70
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function setAsDefaultAccountPrompt(accountName: string): Promise<boolean>;
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
3
|
+
exports.setAsDefaultAccountPrompt = setAsDefaultAccountPrompt;
|
|
4
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
5
|
+
const promptUtils_1 = require("./promptUtils");
|
|
6
|
+
const lang_1 = require("../lang");
|
|
7
7
|
const i18nKey = 'lib.prompts.setAsDefaultAccountPrompt';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
8
|
+
async function setAsDefaultAccountPrompt(accountName) {
|
|
9
|
+
// Accounts for deprecated and new config
|
|
10
|
+
const defaultAccount = (0, config_1.getConfigDefaultAccount)();
|
|
11
|
+
const { setAsDefault } = await (0, promptUtils_1.promptUser)([
|
|
11
12
|
{
|
|
12
13
|
name: 'setAsDefault',
|
|
13
14
|
type: 'confirm',
|
|
14
|
-
when:
|
|
15
|
-
message: i18n(`${i18nKey}.setAsDefaultAccountMessage`),
|
|
15
|
+
when: defaultAccount !== accountName,
|
|
16
|
+
message: (0, lang_1.i18n)(`${i18nKey}.setAsDefaultAccountMessage`),
|
|
16
17
|
},
|
|
17
18
|
]);
|
|
18
19
|
if (setAsDefault) {
|
|
19
|
-
updateDefaultAccount(accountName);
|
|
20
|
+
(0, config_1.updateDefaultAccount)(accountName);
|
|
20
21
|
}
|
|
21
22
|
return setAsDefault;
|
|
22
|
-
}
|
|
23
|
-
module.exports = {
|
|
24
|
-
setAsDefaultAccountPrompt,
|
|
25
|
-
};
|
|
23
|
+
}
|
|
@@ -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
|
|
6
|
+
exports.uploadPrompt = uploadPrompt;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
9
|
+
const promptUtils_1 = require("./promptUtils");
|
|
10
|
+
const lang_1 = require("../lang");
|
|
8
11
|
const i18nKey = 'lib.prompts.uploadPrompt';
|
|
9
|
-
|
|
10
|
-
return promptUser([
|
|
12
|
+
async function uploadPrompt(promptOptions = {}) {
|
|
13
|
+
return (0, promptUtils_1.promptUser)([
|
|
11
14
|
{
|
|
12
15
|
name: 'src',
|
|
13
|
-
message: i18n(`${i18nKey}.enterSrc`),
|
|
16
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterSrc`),
|
|
14
17
|
when: !promptOptions.src,
|
|
15
18
|
default: '.',
|
|
16
|
-
validate: input => {
|
|
19
|
+
validate: (input) => {
|
|
17
20
|
if (!input) {
|
|
18
|
-
return i18n(`${i18nKey}.errors.srcRequired`);
|
|
21
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.srcRequired`);
|
|
19
22
|
}
|
|
20
23
|
return true;
|
|
21
24
|
},
|
|
22
25
|
},
|
|
23
26
|
{
|
|
24
27
|
name: 'dest',
|
|
25
|
-
message: i18n(`${i18nKey}.enterDest`),
|
|
28
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterDest`),
|
|
26
29
|
when: !promptOptions.dest,
|
|
27
|
-
default:
|
|
28
|
-
validate: input => {
|
|
30
|
+
default: path_1.default.basename((0, path_2.getCwd)()),
|
|
31
|
+
validate: (input) => {
|
|
29
32
|
if (!input) {
|
|
30
|
-
return i18n(`${i18nKey}.errors.destRequired`);
|
|
33
|
+
return (0, lang_1.i18n)(`${i18nKey}.errors.destRequired`);
|
|
31
34
|
}
|
|
32
35
|
return true;
|
|
33
36
|
},
|
|
34
37
|
},
|
|
35
38
|
]);
|
|
36
|
-
}
|
|
37
|
-
module.exports = {
|
|
38
|
-
uploadPrompt,
|
|
39
|
-
};
|
|
39
|
+
}
|
package/lib/sandboxSync.js
CHANGED
|
@@ -11,6 +11,7 @@ const { debugError, logError, ApiErrorContext, } = require('./errorHandlers/inde
|
|
|
11
11
|
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
12
12
|
const { getSandboxTypeAsString } = require('./sandboxes');
|
|
13
13
|
const { getAccountId } = require('@hubspot/local-dev-lib/config');
|
|
14
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
14
15
|
const { uiAccountDescription, uiLine, uiLink, uiCommandDisabledBanner, } = require('./ui');
|
|
15
16
|
const { isDevelopmentSandbox } = require('./accountTypes');
|
|
16
17
|
const i18nKey = 'lib.sandbox.sync';
|
|
@@ -22,8 +23,10 @@ const i18nKey = 'lib.sandbox.sync';
|
|
|
22
23
|
* @returns
|
|
23
24
|
*/
|
|
24
25
|
const syncSandbox = async ({ accountConfig, parentAccountConfig, env, syncTasks, slimInfoMessage = false, }) => {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
26
|
+
const id = getAccountIdentifier(accountConfig);
|
|
27
|
+
const accountId = getAccountId(id);
|
|
28
|
+
const parentId = getAccountIdentifier(parentAccountConfig);
|
|
29
|
+
const parentAccountId = getAccountId(parentId);
|
|
27
30
|
const isDevSandbox = isDevelopmentSandbox(accountConfig);
|
|
28
31
|
SpinniesManager.init({
|
|
29
32
|
succeedColor: 'white',
|
package/lib/sandboxes.js
CHANGED
|
@@ -5,11 +5,12 @@ const { i18n } = require('./lang');
|
|
|
5
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
6
6
|
const { getSandboxUsageLimits, } = require('@hubspot/local-dev-lib/api/sandboxHubs');
|
|
7
7
|
const { fetchTypes } = require('@hubspot/local-dev-lib/api/sandboxSync');
|
|
8
|
-
const {
|
|
8
|
+
const { getAccountId, getEnv, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
9
9
|
const { promptUser } = require('./prompts/promptUtils');
|
|
10
10
|
const { isDevelopmentSandbox } = require('./accountTypes');
|
|
11
11
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
12
12
|
const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
|
|
13
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
13
14
|
const { uiAccountDescription } = require('./ui');
|
|
14
15
|
const { isMissingScopeError, isSpecifiedError, } = require('@hubspot/local-dev-lib/errors/index');
|
|
15
16
|
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
|
|
@@ -34,9 +35,10 @@ const getSandboxTypeAsString = accountType => {
|
|
|
34
35
|
return 'standard';
|
|
35
36
|
};
|
|
36
37
|
function getHasSandboxesByType(parentAccountConfig, type) {
|
|
37
|
-
const
|
|
38
|
-
const parentPortalId = getAccountId(
|
|
39
|
-
|
|
38
|
+
const id = getAccountIdentifier(parentAccountConfig);
|
|
39
|
+
const parentPortalId = getAccountId(id);
|
|
40
|
+
const accountsList = getConfigAccounts();
|
|
41
|
+
for (const portal of accountsList) {
|
|
40
42
|
if ((portal.parentAccountId !== null ||
|
|
41
43
|
portal.parentAccountId !== undefined) &&
|
|
42
44
|
portal.parentAccountId === parentPortalId &&
|
|
@@ -54,8 +56,10 @@ function getSandboxLimit(error) {
|
|
|
54
56
|
}
|
|
55
57
|
// Fetches available sync types for a given sandbox portal
|
|
56
58
|
async function getAvailableSyncTypes(parentAccountConfig, config) {
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
+
const parentId = getAccountIdentifier(parentAccountConfig);
|
|
60
|
+
const parentPortalId = getAccountId(parentId);
|
|
61
|
+
const id = getAccountIdentifier(config);
|
|
62
|
+
const portalId = getAccountId(id);
|
|
59
63
|
const { data: { results: syncTypes }, } = await fetchTypes(parentPortalId, portalId);
|
|
60
64
|
if (!syncTypes) {
|
|
61
65
|
throw new Error('Unable to fetch available sandbox sync types. Please try again.');
|
|
@@ -98,7 +102,8 @@ const getSyncTypesWithContactRecordsPrompt = async (accountConfig, syncTasks, sk
|
|
|
98
102
|
* @returns {null}
|
|
99
103
|
*/
|
|
100
104
|
const validateSandboxUsageLimits = async (accountConfig, sandboxType, env) => {
|
|
101
|
-
const
|
|
105
|
+
const id = getAccountIdentifier(accountConfig);
|
|
106
|
+
const accountId = getAccountId(id);
|
|
102
107
|
const { data: { usage }, } = await getSandboxUsageLimits(accountId);
|
|
103
108
|
if (!usage) {
|
|
104
109
|
throw new Error('Unable to fetch sandbox usage limits. Please try again.');
|
package/lib/ui/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const UI_COLORS: {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function uiLine(): void;
|
|
7
7
|
export declare function uiLink(linkText: string, url: string): string;
|
|
8
|
-
export declare function uiAccountDescription(accountId
|
|
8
|
+
export declare function uiAccountDescription(accountId?: number | null, bold?: boolean): string;
|
|
9
9
|
export declare function uiInfoSection(title: string, logContent: () => void): void;
|
|
10
10
|
export declare function uiCommandReference(command: string): string;
|
|
11
11
|
export declare function uiFeatureHighlight(commands: string[], title: string): void;
|
package/lib/ui/index.js
CHANGED
|
@@ -55,7 +55,7 @@ function uiLink(linkText, url) {
|
|
|
55
55
|
: `${linkText}: ${encodedUrl}`;
|
|
56
56
|
}
|
|
57
57
|
function uiAccountDescription(accountId, bold = true) {
|
|
58
|
-
const account = (0, config_1.getAccountConfig)(accountId);
|
|
58
|
+
const account = (0, config_1.getAccountConfig)(accountId || undefined);
|
|
59
59
|
let message;
|
|
60
60
|
if (account && account.accountType) {
|
|
61
61
|
message = `${account.name} [${HUBSPOT_ACCOUNT_TYPE_STRINGS[account.accountType]}] (${accountId})`;
|
package/lib/usageTracking.d.ts
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type Meta = {
|
|
2
|
+
action?: string;
|
|
3
|
+
os?: string;
|
|
4
|
+
nodeVersion?: string;
|
|
5
|
+
nodeMajorVersion?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
command?: string;
|
|
8
|
+
authType?: string;
|
|
9
|
+
step?: string;
|
|
10
|
+
assetType?: string;
|
|
11
|
+
mode?: string;
|
|
12
|
+
type?: string | number;
|
|
13
|
+
file?: boolean;
|
|
14
|
+
successful?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function trackCommandUsage(command: string, meta?: Meta, accountId?: number): Promise<void>;
|
|
17
|
+
export declare function trackHelpUsage(command: string): Promise<void>;
|
|
18
|
+
export declare function trackConvertFieldsUsage(command: string): Promise<void>;
|
|
19
|
+
export declare function trackAuthAction(command: string, authType: string, step: string, accountId: number): Promise<void>;
|
|
20
|
+
export declare function trackCommandMetadataUsage(command: string, meta?: Meta, accountId?: number): Promise<void>;
|
|
21
|
+
export {};
|