@hubspot/cli 7.0.0-experimental.1 → 7.0.1-experimental.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 +35 -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 +3 -3
- package/lib/buildAccount.js +5 -11
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -38
- package/lib/configOptions.d.ts +13 -1
- package/lib/configOptions.js +54 -57
- package/lib/constants.d.ts +1 -4
- 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 +4 -3
- package/lib/generateSelectors.d.ts +19 -0
- package/lib/generateSelectors.js +23 -23
- package/lib/localDev.js +2 -1
- 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 +128 -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 +14 -7
- 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
|
@@ -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 {};
|
package/lib/usageTracking.js
CHANGED
|
@@ -1,43 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.trackCommandUsage = trackCommandUsage;
|
|
4
|
+
exports.trackHelpUsage = trackHelpUsage;
|
|
5
|
+
exports.trackConvertFieldsUsage = trackConvertFieldsUsage;
|
|
6
|
+
exports.trackAuthAction = trackAuthAction;
|
|
4
7
|
exports.trackCommandMetadataUsage = trackCommandMetadataUsage;
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const { setLogLevel } = require('./commonOpts');
|
|
12
|
-
/* **
|
|
13
|
-
Available tracking meta properties
|
|
14
|
-
|
|
15
|
-
- action: "The specific action taken in the CLI"
|
|
16
|
-
- os: "The user's OS"
|
|
17
|
-
- nodeVersion: "The user's version of node.js"
|
|
18
|
-
- nodeMajorVersion: "The user's major version of node.js"
|
|
19
|
-
- version: "The user's version of the CLI"
|
|
20
|
-
- command: "The specific command that the user ran in this interaction"
|
|
21
|
-
- authType: "The configured auth type the user has for the CLI"
|
|
22
|
-
- step: "The specific step in the auth process"
|
|
23
|
-
- assetType: "The CMS asset type"
|
|
24
|
-
- mode: "The CLI mode (draft or publish"
|
|
25
|
-
- type: "The upload type (file or folder)"
|
|
26
|
-
- file: "Whether or not the 'file' flag was used"
|
|
27
|
-
- successful: "Whether or not the CLI interaction was successful"
|
|
28
|
-
|
|
29
|
-
*/
|
|
8
|
+
const trackUsage_1 = require("@hubspot/local-dev-lib/trackUsage");
|
|
9
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
10
|
+
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
11
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
12
|
+
const package_json_1 = require("../package.json");
|
|
13
|
+
const errorHandlers_1 = require("./errorHandlers");
|
|
30
14
|
const EventClass = {
|
|
31
15
|
USAGE: 'USAGE',
|
|
32
16
|
INTERACTION: 'INTERACTION',
|
|
33
17
|
VIEW: 'VIEW',
|
|
34
18
|
ACTIVATION: 'ACTIVATION',
|
|
35
19
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
function getNodeVersionData() {
|
|
21
|
+
return {
|
|
22
|
+
nodeVersion: process.version,
|
|
23
|
+
nodeMajorVersion: (process.version || '').split('.')[0],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function getPlatform() {
|
|
41
27
|
switch (process.platform) {
|
|
42
28
|
case 'darwin':
|
|
43
29
|
return 'macos';
|
|
@@ -46,144 +32,130 @@ const getPlatform = () => {
|
|
|
46
32
|
default:
|
|
47
33
|
return process.platform;
|
|
48
34
|
}
|
|
49
|
-
}
|
|
50
|
-
function trackCommandUsage(command, meta = {}, accountId) {
|
|
51
|
-
if (!isTrackingAllowed()) {
|
|
35
|
+
}
|
|
36
|
+
async function trackCommandUsage(command, meta = {}, accountId) {
|
|
37
|
+
if (!(0, config_1.isTrackingAllowed)()) {
|
|
52
38
|
return;
|
|
53
39
|
}
|
|
54
|
-
logger.debug('Attempting to track usage of "%s" command', command);
|
|
40
|
+
logger_1.logger.debug('Attempting to track usage of "%s" command', command);
|
|
55
41
|
let authType = 'unknown';
|
|
56
42
|
if (accountId) {
|
|
57
|
-
const accountConfig = getAccountConfig(accountId);
|
|
43
|
+
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
58
44
|
authType =
|
|
59
45
|
accountConfig && accountConfig.authType
|
|
60
46
|
? accountConfig.authType
|
|
61
|
-
: API_KEY_AUTH_METHOD.value;
|
|
47
|
+
: auth_1.API_KEY_AUTH_METHOD.value;
|
|
62
48
|
}
|
|
63
49
|
setImmediate(async () => {
|
|
64
50
|
const usageTrackingEvent = {
|
|
65
51
|
action: 'cli-command',
|
|
66
52
|
os: getPlatform(),
|
|
67
53
|
...getNodeVersionData(),
|
|
68
|
-
version,
|
|
54
|
+
version: package_json_1.version,
|
|
69
55
|
command,
|
|
70
56
|
authType,
|
|
71
57
|
...meta,
|
|
72
58
|
};
|
|
73
59
|
try {
|
|
74
|
-
await trackUsage('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
|
|
75
|
-
logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
|
|
60
|
+
await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
|
|
61
|
+
logger_1.logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
|
|
76
62
|
}
|
|
77
63
|
catch (e) {
|
|
78
|
-
|
|
64
|
+
(0, errorHandlers_1.debugError)(e);
|
|
79
65
|
}
|
|
80
66
|
});
|
|
81
67
|
}
|
|
82
68
|
async function trackHelpUsage(command) {
|
|
83
|
-
if (!isTrackingAllowed()) {
|
|
69
|
+
if (!(0, config_1.isTrackingAllowed)()) {
|
|
84
70
|
return;
|
|
85
71
|
}
|
|
86
72
|
try {
|
|
87
73
|
if (command) {
|
|
88
|
-
logger.debug('Tracking help usage of "%s" sub-command', command);
|
|
74
|
+
logger_1.logger.debug('Tracking help usage of "%s" sub-command', command);
|
|
89
75
|
}
|
|
90
76
|
else {
|
|
91
|
-
logger.debug('Tracking help usage of main command');
|
|
77
|
+
logger_1.logger.debug('Tracking help usage of main command');
|
|
92
78
|
}
|
|
93
|
-
await trackUsage('cli-interaction', EventClass.INTERACTION, {
|
|
79
|
+
await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, {
|
|
94
80
|
action: 'cli-help',
|
|
95
81
|
os: getPlatform(),
|
|
96
82
|
...getNodeVersionData(),
|
|
97
|
-
version,
|
|
83
|
+
version: package_json_1.version,
|
|
98
84
|
command,
|
|
99
85
|
});
|
|
100
86
|
}
|
|
101
87
|
catch (e) {
|
|
102
|
-
|
|
88
|
+
(0, errorHandlers_1.debugError)(e);
|
|
103
89
|
}
|
|
104
90
|
}
|
|
105
91
|
async function trackConvertFieldsUsage(command) {
|
|
106
|
-
if (!isTrackingAllowed()) {
|
|
92
|
+
if (!(0, config_1.isTrackingAllowed)()) {
|
|
107
93
|
return;
|
|
108
94
|
}
|
|
109
95
|
try {
|
|
110
|
-
logger.debug('Attempting to track usage of "%s" command', command);
|
|
111
|
-
await trackUsage('cli-interaction', EventClass.INTERACTION, {
|
|
96
|
+
logger_1.logger.debug('Attempting to track usage of "%s" command', command);
|
|
97
|
+
await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, {
|
|
112
98
|
action: 'cli-process-fields',
|
|
113
99
|
os: getPlatform(),
|
|
114
100
|
...getNodeVersionData(),
|
|
115
|
-
version,
|
|
101
|
+
version: package_json_1.version,
|
|
116
102
|
command,
|
|
117
103
|
});
|
|
118
104
|
}
|
|
119
105
|
catch (e) {
|
|
120
|
-
|
|
106
|
+
(0, errorHandlers_1.debugError)(e);
|
|
121
107
|
}
|
|
122
108
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
setLogLevel(program);
|
|
126
|
-
trackHelpUsage(command);
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
const trackAuthAction = async (command, authType, step, accountId) => {
|
|
130
|
-
if (!isTrackingAllowed()) {
|
|
109
|
+
async function trackAuthAction(command, authType, step, accountId) {
|
|
110
|
+
if (!(0, config_1.isTrackingAllowed)()) {
|
|
131
111
|
return;
|
|
132
112
|
}
|
|
133
113
|
const usageTrackingEvent = {
|
|
134
114
|
action: 'cli-auth',
|
|
135
115
|
os: getPlatform(),
|
|
136
116
|
...getNodeVersionData(),
|
|
137
|
-
version,
|
|
117
|
+
version: package_json_1.version,
|
|
138
118
|
command,
|
|
139
119
|
authType,
|
|
140
120
|
step,
|
|
141
121
|
};
|
|
142
122
|
try {
|
|
143
|
-
await trackUsage('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
|
|
144
|
-
logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
|
|
123
|
+
await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
|
|
124
|
+
logger_1.logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
|
|
145
125
|
}
|
|
146
126
|
catch (e) {
|
|
147
|
-
|
|
127
|
+
(0, errorHandlers_1.debugError)(e);
|
|
148
128
|
}
|
|
149
|
-
}
|
|
150
|
-
function trackCommandMetadataUsage(command, meta = {}, accountId) {
|
|
151
|
-
if (!isTrackingAllowed()) {
|
|
129
|
+
}
|
|
130
|
+
async function trackCommandMetadataUsage(command, meta = {}, accountId) {
|
|
131
|
+
if (!(0, config_1.isTrackingAllowed)()) {
|
|
152
132
|
return;
|
|
153
133
|
}
|
|
154
|
-
logger.debug('Attempting to track metadata usage of "%s" command', command);
|
|
134
|
+
logger_1.logger.debug('Attempting to track metadata usage of "%s" command', command);
|
|
155
135
|
let authType = 'unknown';
|
|
156
136
|
if (accountId) {
|
|
157
|
-
const accountConfig = getAccountConfig(accountId);
|
|
137
|
+
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
158
138
|
authType =
|
|
159
139
|
accountConfig && accountConfig.authType
|
|
160
140
|
? accountConfig.authType
|
|
161
|
-
: API_KEY_AUTH_METHOD.value;
|
|
141
|
+
: auth_1.API_KEY_AUTH_METHOD.value;
|
|
162
142
|
}
|
|
163
143
|
setImmediate(async () => {
|
|
164
144
|
const usageTrackingEvent = {
|
|
165
145
|
action: 'cli-command-metadata',
|
|
166
146
|
os: getPlatform(),
|
|
167
147
|
...getNodeVersionData(),
|
|
168
|
-
version,
|
|
148
|
+
version: package_json_1.version,
|
|
169
149
|
command,
|
|
170
150
|
authType,
|
|
171
151
|
...meta,
|
|
172
152
|
};
|
|
173
153
|
try {
|
|
174
|
-
await trackUsage('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
|
|
175
|
-
logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
|
|
154
|
+
await (0, trackUsage_1.trackUsage)('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
|
|
155
|
+
logger_1.logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
|
|
176
156
|
}
|
|
177
157
|
catch (e) {
|
|
178
|
-
|
|
158
|
+
(0, errorHandlers_1.debugError)(e);
|
|
179
159
|
}
|
|
180
160
|
});
|
|
181
161
|
}
|
|
182
|
-
module.exports = {
|
|
183
|
-
trackCommandUsage,
|
|
184
|
-
trackHelpUsage,
|
|
185
|
-
addHelpUsageTracking,
|
|
186
|
-
trackConvertFieldsUsage,
|
|
187
|
-
trackAuthAction,
|
|
188
|
-
trackCommandMetadataUsage,
|
|
189
|
-
};
|