@hubspot/cli 6.3.0-experimental.0 → 6.4.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 +2 -21
- package/commands/accounts/clean.js +5 -8
- package/commands/accounts/info.js +6 -6
- package/commands/accounts/list.js +10 -14
- package/commands/accounts/remove.js +1 -1
- package/commands/accounts/rename.js +4 -3
- package/commands/auth.js +7 -11
- package/commands/cms/lighthouseScore.js +19 -19
- package/commands/config/set.js +5 -4
- package/commands/create.js +2 -3
- package/commands/customObject/create.js +6 -4
- package/commands/customObject/schema/create.js +9 -8
- package/commands/customObject/schema/delete.js +5 -3
- package/commands/customObject/schema/fetch-all.js +4 -3
- package/commands/customObject/schema/fetch.js +6 -4
- package/commands/customObject/schema/list.js +4 -3
- package/commands/customObject/schema/update.js +9 -8
- package/commands/fetch.js +4 -4
- package/commands/filemanager/fetch.js +5 -4
- package/commands/filemanager/upload.js +10 -9
- package/commands/functions/deploy.js +10 -12
- package/commands/functions/list.js +5 -5
- package/commands/functions/server.js +5 -4
- package/commands/hubdb/clear.js +6 -5
- package/commands/hubdb/create.js +6 -5
- package/commands/hubdb/delete.js +6 -5
- package/commands/hubdb/fetch.js +5 -4
- package/commands/init.js +8 -26
- package/commands/lint.js +5 -5
- package/commands/list.js +5 -4
- package/commands/logs.js +5 -4
- package/commands/module/marketplace-validate.js +7 -6
- package/commands/mv.js +8 -7
- package/commands/open.js +8 -7
- package/commands/project/add.js +3 -2
- package/commands/project/cloneApp.js +14 -14
- package/commands/project/create.js +3 -3
- package/commands/project/deploy.js +12 -15
- package/commands/project/dev.js +13 -13
- package/commands/project/download.js +9 -11
- package/commands/project/listBuilds.js +8 -10
- package/commands/project/logs.js +5 -5
- package/commands/project/migrateApp.js +18 -18
- package/commands/project/open.js +7 -6
- package/commands/project/upload.js +10 -12
- package/commands/project/watch.js +10 -9
- package/commands/remove.js +8 -10
- package/commands/sandbox/create.js +9 -8
- package/commands/sandbox/delete.js +9 -11
- package/commands/secrets/addSecret.js +7 -6
- package/commands/secrets/deleteSecret.js +7 -6
- package/commands/secrets/listSecrets.js +6 -6
- package/commands/secrets/updateSecret.js +7 -6
- package/commands/theme/marketplace-validate.js +7 -6
- package/commands/theme/preview.js +42 -23
- package/commands/upload.js +15 -18
- package/commands/watch.js +10 -9
- package/lang/en.lyaml +1 -3
- package/lib/buildAccount.js +1 -3
- package/lib/commonOpts.d.ts +1 -9
- package/lib/commonOpts.js +12 -14
- package/lib/developerTestAccounts.js +5 -8
- package/lib/errorHandlers/index.d.ts +14 -1
- package/lib/errorHandlers/index.js +43 -50
- package/lib/errorHandlers/suppressError.d.ts +2 -1
- package/lib/errorHandlers/suppressError.js +32 -37
- package/lib/links.d.ts +9 -0
- package/lib/links.js +99 -97
- package/lib/oauth.js +1 -3
- package/lib/prompts/accountsPrompt.js +4 -8
- package/lib/prompts/projectDevTargetAccountPrompt.js +2 -3
- package/lib/prompts/sandboxesPrompt.js +7 -10
- package/lib/prompts/setAsDefaultAccountPrompt.js +2 -4
- package/lib/sandboxSync.js +2 -5
- package/lib/sandboxes.js +7 -12
- package/lib/ui/serverlessFunctionLogs.js +8 -4
- package/package.json +4 -1
|
@@ -7,7 +7,7 @@ const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
|
7
7
|
const { ENVIRONMENTS, } = require('@hubspot/local-dev-lib/constants/environments');
|
|
8
8
|
const { checkAndConvertToJson, loadAndValidateOptions, } = require('../../../lib/validation');
|
|
9
9
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
10
|
-
const { addTestingOptions } = require('../../../lib/commonOpts');
|
|
10
|
+
const { addTestingOptions, getAccountId } = require('../../../lib/commonOpts');
|
|
11
11
|
const { CONFIG_FLAGS } = require('../../../lib/constants');
|
|
12
12
|
const { getEnv, isConfigFlagEnabled, } = require('@hubspot/local-dev-lib/config');
|
|
13
13
|
const { updateObjectSchema, } = require('@hubspot/local-dev-lib/api/customObjects');
|
|
@@ -19,9 +19,10 @@ const { EXIT_CODES } = require('../../../lib/enums/exitCodes');
|
|
|
19
19
|
exports.command = 'update <name> <definition>';
|
|
20
20
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
21
21
|
exports.handler = async (options) => {
|
|
22
|
-
const { definition, name
|
|
22
|
+
const { definition, name } = options;
|
|
23
23
|
await loadAndValidateOptions(options);
|
|
24
|
-
|
|
24
|
+
const accountId = getAccountId(options);
|
|
25
|
+
trackCommandUsage('custom-object-schema-update', null, accountId);
|
|
25
26
|
const filePath = getAbsoluteFilePath(definition);
|
|
26
27
|
const schemaJson = checkAndConvertToJson(filePath);
|
|
27
28
|
if (!schemaJson) {
|
|
@@ -29,20 +30,20 @@ exports.handler = async (options) => {
|
|
|
29
30
|
}
|
|
30
31
|
try {
|
|
31
32
|
if (isConfigFlagEnabled(CONFIG_FLAGS.USE_CUSTOM_OBJECT_HUBFILE)) {
|
|
32
|
-
await updateSchemaFromHubFile(
|
|
33
|
+
await updateSchemaFromHubFile(accountId, filePath);
|
|
33
34
|
logger.success(i18n(`${i18nKey}.success.update`, {
|
|
34
|
-
accountId
|
|
35
|
+
accountId,
|
|
35
36
|
}));
|
|
36
37
|
}
|
|
37
38
|
else {
|
|
38
|
-
const { data } = await updateObjectSchema(
|
|
39
|
+
const { data } = await updateObjectSchema(accountId, name, schemaJson);
|
|
39
40
|
logger.success(i18n(`${i18nKey}.success.viewAtUrl`, {
|
|
40
|
-
url: `${getHubSpotWebsiteOrigin(getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD)}/contacts/${
|
|
41
|
+
url: `${getHubSpotWebsiteOrigin(getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD)}/contacts/${accountId}/objects/${data.objectTypeId}`,
|
|
41
42
|
}));
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
catch (e) {
|
|
45
|
-
logError(e, { accountId
|
|
46
|
+
logError(e, { accountId });
|
|
46
47
|
logger.error(i18n(`${i18nKey}.errors.update`, {
|
|
47
48
|
definition,
|
|
48
49
|
}));
|
package/commands/fetch.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { downloadFileOrFolder } = require('@hubspot/local-dev-lib/fileMapper');
|
|
5
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
6
|
-
const { addConfigOptions, addAccountOptions, addOverwriteOptions, addModeOptions, addUseEnvironmentOptions, getMode, } = require('../lib/commonOpts');
|
|
6
|
+
const { addConfigOptions, addAccountOptions, addOverwriteOptions, addModeOptions, addUseEnvironmentOptions, getAccountId, getMode, } = require('../lib/commonOpts');
|
|
7
7
|
const { resolveLocalPath } = require('../lib/filesystem');
|
|
8
8
|
const { validateMode, loadAndValidateOptions } = require('../lib/validation');
|
|
9
9
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
@@ -23,12 +23,12 @@ exports.handler = async (options) => {
|
|
|
23
23
|
logger.error(i18n(`${i18nKey}.errors.sourceRequired`));
|
|
24
24
|
process.exit(EXIT_CODES.ERROR);
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const accountId = getAccountId(options);
|
|
27
27
|
const mode = getMode(options);
|
|
28
|
-
trackCommandUsage('fetch', { mode },
|
|
28
|
+
trackCommandUsage('fetch', { mode }, accountId);
|
|
29
29
|
try {
|
|
30
30
|
// Fetch and write file/folder.
|
|
31
|
-
await downloadFileOrFolder(
|
|
31
|
+
await downloadFileOrFolder(accountId, src, resolveLocalPath(dest), mode, options);
|
|
32
32
|
}
|
|
33
33
|
catch (err) {
|
|
34
34
|
logError(err);
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { downloadFileOrFolder } = require('@hubspot/local-dev-lib/fileManager');
|
|
5
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
6
6
|
const { resolveLocalPath } = require('../../lib/filesystem');
|
|
7
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
7
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
10
|
const { i18n } = require('../../lib/lang');
|
|
@@ -14,17 +14,18 @@ const { logError } = require('../../lib/errorHandlers/index');
|
|
|
14
14
|
exports.command = 'fetch <src> [dest]';
|
|
15
15
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
16
16
|
exports.handler = async (options) => {
|
|
17
|
-
const { src, includeArchived
|
|
17
|
+
const { src, includeArchived } = options;
|
|
18
18
|
await loadAndValidateOptions(options);
|
|
19
19
|
if (typeof src !== 'string') {
|
|
20
20
|
logger.error(i18n(`${i18nKey}.errors.sourceRequired`));
|
|
21
21
|
process.exit(EXIT_CODES.ERROR);
|
|
22
22
|
}
|
|
23
23
|
const dest = resolveLocalPath(options.dest);
|
|
24
|
-
|
|
24
|
+
const accountId = getAccountId(options);
|
|
25
|
+
trackCommandUsage('filemanager-fetch', null, accountId);
|
|
25
26
|
try {
|
|
26
27
|
// Fetch and write file/folder.
|
|
27
|
-
await downloadFileOrFolder(
|
|
28
|
+
await downloadFileOrFolder(accountId, src, dest, false, includeArchived || false);
|
|
28
29
|
}
|
|
29
30
|
catch (err) {
|
|
30
31
|
logError(err);
|
|
@@ -10,7 +10,7 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
|
10
10
|
const { validateSrcAndDestPaths, } = require('@hubspot/local-dev-lib/cms/modules');
|
|
11
11
|
const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
|
|
12
12
|
const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
13
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
13
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
14
14
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
15
15
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
16
16
|
const { i18n } = require('../../lib/lang');
|
|
@@ -19,8 +19,9 @@ const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
|
19
19
|
exports.command = 'upload <src> <dest>';
|
|
20
20
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
21
21
|
exports.handler = async (options) => {
|
|
22
|
-
const { src, dest
|
|
22
|
+
const { src, dest } = options;
|
|
23
23
|
await loadAndValidateOptions(options);
|
|
24
|
+
const accountId = getAccountId(options);
|
|
24
25
|
const absoluteSrcPath = path.resolve(getCwd(), src);
|
|
25
26
|
let stats;
|
|
26
27
|
try {
|
|
@@ -43,7 +44,7 @@ exports.handler = async (options) => {
|
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
const normalizedDest = convertToUnixPath(dest);
|
|
46
|
-
trackCommandUsage('filemanager-upload', { type: stats.isFile() ? 'file' : 'folder' },
|
|
47
|
+
trackCommandUsage('filemanager-upload', { type: stats.isFile() ? 'file' : 'folder' }, accountId);
|
|
47
48
|
const srcDestIssues = await validateSrcAndDestPaths({ isLocal: true, path: src }, { isHubSpot: true, path: dest });
|
|
48
49
|
if (srcDestIssues.length) {
|
|
49
50
|
srcDestIssues.forEach(({ message }) => logger.error(message));
|
|
@@ -56,10 +57,10 @@ exports.handler = async (options) => {
|
|
|
56
57
|
}));
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
|
-
uploadFile(
|
|
60
|
+
uploadFile(accountId, absoluteSrcPath, normalizedDest)
|
|
60
61
|
.then(() => {
|
|
61
62
|
logger.success(i18n(`${i18nKey}.success.upload`, {
|
|
62
|
-
accountId
|
|
63
|
+
accountId,
|
|
63
64
|
dest: normalizedDest,
|
|
64
65
|
src,
|
|
65
66
|
}));
|
|
@@ -70,7 +71,7 @@ exports.handler = async (options) => {
|
|
|
70
71
|
src,
|
|
71
72
|
}));
|
|
72
73
|
logError(error, new ApiErrorContext({
|
|
73
|
-
accountId
|
|
74
|
+
accountId,
|
|
74
75
|
request: normalizedDest,
|
|
75
76
|
payload: src,
|
|
76
77
|
}));
|
|
@@ -78,11 +79,11 @@ exports.handler = async (options) => {
|
|
|
78
79
|
}
|
|
79
80
|
else {
|
|
80
81
|
logger.log(i18n(`${i18nKey}.logs.uploading`, {
|
|
81
|
-
accountId
|
|
82
|
+
accountId,
|
|
82
83
|
dest,
|
|
83
84
|
src,
|
|
84
85
|
}));
|
|
85
|
-
uploadFolder(
|
|
86
|
+
uploadFolder(accountId, absoluteSrcPath, dest)
|
|
86
87
|
.then(() => {
|
|
87
88
|
logger.success(i18n(`${i18nKey}.success.uploadComplete`, {
|
|
88
89
|
dest,
|
|
@@ -91,7 +92,7 @@ exports.handler = async (options) => {
|
|
|
91
92
|
.catch(error => {
|
|
92
93
|
logger.error(i18n(`${i18nKey}.errors.uploadingFailed`));
|
|
93
94
|
logError(error, {
|
|
94
|
-
accountId
|
|
95
|
+
accountId,
|
|
95
96
|
});
|
|
96
97
|
});
|
|
97
98
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
5
|
-
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
5
|
+
const { addAccountOptions, addConfigOptions, getAccountId, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
6
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
7
7
|
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
8
8
|
const { uiAccountDescription } = require('../../lib/ui');
|
|
@@ -18,9 +18,10 @@ exports.command = 'deploy <path>';
|
|
|
18
18
|
exports.describe = false;
|
|
19
19
|
exports.handler = async (options) => {
|
|
20
20
|
await loadAndValidateOptions(options);
|
|
21
|
-
const { path: functionPath
|
|
21
|
+
const { path: functionPath } = options;
|
|
22
|
+
const accountId = getAccountId(options);
|
|
22
23
|
const splitFunctionPath = functionPath.split('.');
|
|
23
|
-
trackCommandUsage('functions-deploy', null,
|
|
24
|
+
trackCommandUsage('functions-deploy', null, accountId);
|
|
24
25
|
if (!splitFunctionPath.length ||
|
|
25
26
|
splitFunctionPath[splitFunctionPath.length - 1] !== 'functions') {
|
|
26
27
|
logger.error(i18n(`${i18nKey}.errors.notFunctionsFolder`, {
|
|
@@ -34,18 +35,18 @@ exports.handler = async (options) => {
|
|
|
34
35
|
SpinniesManager.init();
|
|
35
36
|
SpinniesManager.add('loading', {
|
|
36
37
|
text: i18n(`${i18nKey}.loading`, {
|
|
37
|
-
account: uiAccountDescription(
|
|
38
|
+
account: uiAccountDescription(accountId),
|
|
38
39
|
functionPath,
|
|
39
40
|
}),
|
|
40
41
|
});
|
|
41
42
|
try {
|
|
42
|
-
const { data: buildId } = await buildPackage(
|
|
43
|
-
const successResp = await poll(getBuildStatus,
|
|
43
|
+
const { data: buildId } = await buildPackage(accountId, functionPath);
|
|
44
|
+
const successResp = await poll(getBuildStatus, accountId, buildId);
|
|
44
45
|
const buildTimeSeconds = (successResp.buildTime / 1000).toFixed(2);
|
|
45
46
|
SpinniesManager.succeed('loading');
|
|
46
47
|
await outputBuildLog(successResp.cdnUrl);
|
|
47
48
|
logger.success(i18n(`${i18nKey}.success.deployed`, {
|
|
48
|
-
accountId
|
|
49
|
+
accountId,
|
|
49
50
|
buildTimeSeconds,
|
|
50
51
|
functionPath,
|
|
51
52
|
}));
|
|
@@ -53,7 +54,7 @@ exports.handler = async (options) => {
|
|
|
53
54
|
catch (e) {
|
|
54
55
|
SpinniesManager.fail('loading', {
|
|
55
56
|
text: i18n(`${i18nKey}.loadingFailed`, {
|
|
56
|
-
account: uiAccountDescription(
|
|
57
|
+
account: uiAccountDescription(accountId),
|
|
57
58
|
functionPath,
|
|
58
59
|
}),
|
|
59
60
|
});
|
|
@@ -69,10 +70,7 @@ exports.handler = async (options) => {
|
|
|
69
70
|
}));
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
72
|
-
logError(e, new ApiErrorContext({
|
|
73
|
-
accountId: derivedAccountId,
|
|
74
|
-
request: functionPath,
|
|
75
|
-
}));
|
|
73
|
+
logError(e, new ApiErrorContext({ accountId, request: functionPath }));
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
};
|
|
@@ -6,7 +6,7 @@ const { getRoutes } = require('@hubspot/local-dev-lib/api/functions');
|
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
8
8
|
const { getTableContents, getTableHeader } = require('../../lib/ui/table');
|
|
9
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
9
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
10
10
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
11
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
12
12
|
const { i18n } = require('../../lib/lang');
|
|
@@ -16,11 +16,11 @@ exports.command = 'list';
|
|
|
16
16
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
17
17
|
exports.handler = async (options) => {
|
|
18
18
|
loadAndValidateOptions(options);
|
|
19
|
-
const
|
|
20
|
-
trackCommandUsage('functions-list', null,
|
|
19
|
+
const accountId = getAccountId(options);
|
|
20
|
+
trackCommandUsage('functions-list', null, accountId);
|
|
21
21
|
logger.debug(i18n(`${i18nKey}.debug.gettingFunctions`));
|
|
22
|
-
const { data: routesResp } = await getRoutes(
|
|
23
|
-
logError(e, new ApiErrorContext({ accountId
|
|
22
|
+
const { data: routesResp } = await getRoutes(accountId).catch(async (e) => {
|
|
23
|
+
logError(e, new ApiErrorContext({ accountId }));
|
|
24
24
|
process.exit(EXIT_CODES.SUCCESS);
|
|
25
25
|
});
|
|
26
26
|
if (!routesResp.objects.length) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
4
|
+
const { addAccountOptions, addConfigOptions, getAccountId, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
5
5
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const { start: startTestServer } = require('@hubspot/serverless-dev-runtime');
|
|
@@ -12,13 +12,14 @@ exports.command = 'server <path>';
|
|
|
12
12
|
exports.describe = false;
|
|
13
13
|
exports.handler = async (options) => {
|
|
14
14
|
await loadAndValidateOptions(options);
|
|
15
|
-
const { path: functionPath
|
|
16
|
-
|
|
15
|
+
const { path: functionPath } = options;
|
|
16
|
+
const accountId = getAccountId(options);
|
|
17
|
+
trackCommandUsage('functions-server', null, accountId);
|
|
17
18
|
logger.debug(i18n(`${i18nKey}.debug.startingServer`, {
|
|
18
19
|
functionPath,
|
|
19
20
|
}));
|
|
20
21
|
startTestServer({
|
|
21
|
-
accountId
|
|
22
|
+
accountId,
|
|
22
23
|
...options,
|
|
23
24
|
});
|
|
24
25
|
};
|
package/commands/hubdb/clear.js
CHANGED
|
@@ -7,23 +7,24 @@ const { clearHubDbTableRows } = require('@hubspot/local-dev-lib/hubdb');
|
|
|
7
7
|
const { publishTable } = require('@hubspot/local-dev-lib/api/hubdb');
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
10
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
11
11
|
const { i18n } = require('../../lib/lang');
|
|
12
12
|
const i18nKey = 'commands.hubdb.subcommands.clear';
|
|
13
13
|
exports.command = 'clear <tableId>';
|
|
14
14
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
15
|
exports.handler = async (options) => {
|
|
16
|
-
const { tableId
|
|
16
|
+
const { tableId } = options;
|
|
17
17
|
await loadAndValidateOptions(options);
|
|
18
|
-
|
|
18
|
+
const accountId = getAccountId(options);
|
|
19
|
+
trackCommandUsage('hubdb-clear', null, accountId);
|
|
19
20
|
try {
|
|
20
|
-
const { deletedRowCount } = await clearHubDbTableRows(
|
|
21
|
+
const { deletedRowCount } = await clearHubDbTableRows(accountId, tableId);
|
|
21
22
|
if (deletedRowCount > 0) {
|
|
22
23
|
logger.log(i18n(`${i18nKey}.logs.removedRows`, {
|
|
23
24
|
deletedRowCount,
|
|
24
25
|
tableId,
|
|
25
26
|
}));
|
|
26
|
-
const { data: { rowCount }, } = await publishTable(
|
|
27
|
+
const { data: { rowCount }, } = await publishTable(accountId, tableId);
|
|
27
28
|
logger.log(i18n(`${i18nKey}.logs.rowCount`, {
|
|
28
29
|
rowCount,
|
|
29
30
|
tableId,
|
package/commands/hubdb/create.js
CHANGED
|
@@ -8,24 +8,25 @@ const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
|
8
8
|
const { createHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
|
|
9
9
|
const { checkAndConvertToJson, loadAndValidateOptions, } = require('../../lib/validation');
|
|
10
10
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
11
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
12
12
|
const { i18n } = require('../../lib/lang');
|
|
13
13
|
const i18nKey = 'commands.hubdb.subcommands.create';
|
|
14
14
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
15
15
|
exports.command = 'create <src>';
|
|
16
16
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
17
17
|
exports.handler = async (options) => {
|
|
18
|
-
const { src
|
|
18
|
+
const { src } = options;
|
|
19
19
|
await loadAndValidateOptions(options);
|
|
20
|
-
|
|
20
|
+
const accountId = getAccountId(options);
|
|
21
|
+
trackCommandUsage('hubdb-create', null, accountId);
|
|
21
22
|
try {
|
|
22
23
|
const filePath = path.resolve(getCwd(), src);
|
|
23
24
|
if (!checkAndConvertToJson(filePath)) {
|
|
24
25
|
process.exit(EXIT_CODES.ERROR);
|
|
25
26
|
}
|
|
26
|
-
const table = await createHubDbTable(
|
|
27
|
+
const table = await createHubDbTable(accountId, path.resolve(getCwd(), src));
|
|
27
28
|
logger.success(i18n(`${i18nKey}.success.create`, {
|
|
28
|
-
accountId
|
|
29
|
+
accountId,
|
|
29
30
|
rowCount: table.rowCount,
|
|
30
31
|
tableId: table.tableId,
|
|
31
32
|
}));
|
package/commands/hubdb/delete.js
CHANGED
|
@@ -6,19 +6,20 @@ const { logError } = require('../../lib/errorHandlers/index');
|
|
|
6
6
|
const { deleteTable } = require('@hubspot/local-dev-lib/api/hubdb');
|
|
7
7
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
9
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
10
10
|
const { i18n } = require('../../lib/lang');
|
|
11
11
|
const i18nKey = 'commands.hubdb.subcommands.delete';
|
|
12
12
|
exports.command = 'delete <tableId>';
|
|
13
13
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
14
14
|
exports.handler = async (options) => {
|
|
15
|
-
const { tableId
|
|
15
|
+
const { tableId } = options;
|
|
16
16
|
await loadAndValidateOptions(options);
|
|
17
|
-
|
|
17
|
+
const accountId = getAccountId(options);
|
|
18
|
+
trackCommandUsage('hubdb-delete', null, accountId);
|
|
18
19
|
try {
|
|
19
|
-
await deleteTable(
|
|
20
|
+
await deleteTable(accountId, tableId);
|
|
20
21
|
logger.success(i18n(`${i18nKey}.success.delete`, {
|
|
21
|
-
accountId
|
|
22
|
+
accountId,
|
|
22
23
|
tableId,
|
|
23
24
|
}));
|
|
24
25
|
}
|
package/commands/hubdb/fetch.js
CHANGED
|
@@ -6,17 +6,18 @@ const { logError } = require('../../lib/errorHandlers/index');
|
|
|
6
6
|
const { downloadHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
|
|
7
7
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
9
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
10
10
|
const { i18n } = require('../../lib/lang');
|
|
11
11
|
const i18nKey = 'commands.hubdb.subcommands.fetch';
|
|
12
12
|
exports.command = 'fetch <tableId> [dest]';
|
|
13
13
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
14
14
|
exports.handler = async (options) => {
|
|
15
|
-
const { tableId, dest
|
|
15
|
+
const { tableId, dest } = options;
|
|
16
16
|
await loadAndValidateOptions(options);
|
|
17
|
-
|
|
17
|
+
const accountId = getAccountId(options);
|
|
18
|
+
trackCommandUsage('hubdb-fetch', null, accountId);
|
|
18
19
|
try {
|
|
19
|
-
const { filePath } = await downloadHubDbTable(
|
|
20
|
+
const { filePath } = await downloadHubDbTable(accountId, tableId, dest);
|
|
20
21
|
logger.success(i18n(`${i18nKey}.success.fetch`, {
|
|
21
22
|
path: filePath,
|
|
22
23
|
tableId,
|
package/commands/init.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require('fs-extra');
|
|
6
|
-
const { getConfigPath, createEmptyConfigFile, deleteEmptyConfigFile, updateDefaultAccount,
|
|
6
|
+
const { getConfigPath, createEmptyConfigFile, deleteEmptyConfigFile, updateDefaultAccount, } = require('@hubspot/local-dev-lib/config');
|
|
7
7
|
const { addConfigOptions } = require('../lib/commonOpts');
|
|
8
8
|
const { handleExit } = require('../lib/process');
|
|
9
9
|
const { checkAndAddConfigToGitignore, } = require('@hubspot/local-dev-lib/gitignore');
|
|
@@ -67,8 +67,8 @@ exports.describe = i18n(`${i18nKey}.describe`, {
|
|
|
67
67
|
configName: DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
68
68
|
});
|
|
69
69
|
exports.handler = async (options) => {
|
|
70
|
-
const { auth: authType = PERSONAL_ACCESS_KEY_AUTH_METHOD.value, c, account: optionalAccount,
|
|
71
|
-
const configPath = (c && path.join(getCwd(), c)) || getConfigPath(
|
|
70
|
+
const { auth: authType = PERSONAL_ACCESS_KEY_AUTH_METHOD.value, c, account: optionalAccount, disableTracking, } = options;
|
|
71
|
+
const configPath = (c && path.join(getCwd(), c)) || getConfigPath();
|
|
72
72
|
setLogLevel(options);
|
|
73
73
|
if (!disableTracking) {
|
|
74
74
|
trackCommandUsage('init', {
|
|
@@ -86,32 +86,20 @@ exports.handler = async (options) => {
|
|
|
86
86
|
if (!disableTracking) {
|
|
87
87
|
await trackAuthAction('init', authType, TRACKING_STATUS.STARTED);
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
if (doesOtherConfigFileExist) {
|
|
91
|
-
const path = getConfigPath('', !useHiddenConfig);
|
|
92
|
-
logger.error(i18n(`${i18nKey}.errors.bothConfigFilesNotAllowed`, { path }));
|
|
93
|
-
process.exit(EXIT_CODES.ERROR);
|
|
94
|
-
}
|
|
95
|
-
trackAuthAction('init', authType, TRACKING_STATUS.STARTED);
|
|
96
|
-
createEmptyConfigFile({ path: configPath }, useHiddenConfig);
|
|
97
|
-
//Needed to load deprecated config
|
|
98
|
-
loadConfig(configPath, options);
|
|
89
|
+
createEmptyConfigFile({ path: configPath });
|
|
99
90
|
handleExit(deleteEmptyConfigFile);
|
|
100
91
|
try {
|
|
101
92
|
const { accountId, name } = await CONFIG_CREATION_FLOWS[authType](env, optionalAccount);
|
|
93
|
+
const configPath = getConfigPath();
|
|
102
94
|
try {
|
|
103
95
|
checkAndAddConfigToGitignore(configPath);
|
|
104
96
|
}
|
|
105
97
|
catch (e) {
|
|
106
98
|
debugError(e);
|
|
107
99
|
}
|
|
108
|
-
let newConfigPath = configPath;
|
|
109
|
-
if (!newConfigPath && !useHiddenConfig) {
|
|
110
|
-
newConfigPath = `${getCwd()}/${DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME}`;
|
|
111
|
-
}
|
|
112
100
|
logger.log('');
|
|
113
101
|
logger.success(i18n(`${i18nKey}.success.configFileCreated`, {
|
|
114
|
-
configPath
|
|
102
|
+
configPath,
|
|
115
103
|
}));
|
|
116
104
|
logger.success(i18n(`${i18nKey}.success.configFileUpdated`, {
|
|
117
105
|
authType: AUTH_TYPE_NAMES[authType],
|
|
@@ -132,8 +120,7 @@ exports.handler = async (options) => {
|
|
|
132
120
|
}
|
|
133
121
|
};
|
|
134
122
|
exports.builder = yargs => {
|
|
135
|
-
yargs
|
|
136
|
-
.options({
|
|
123
|
+
yargs.options({
|
|
137
124
|
auth: {
|
|
138
125
|
describe: i18n(`${i18nKey}.options.auth.describe`),
|
|
139
126
|
type: 'string',
|
|
@@ -155,12 +142,7 @@ exports.builder = yargs => {
|
|
|
155
142
|
hidden: true,
|
|
156
143
|
default: false,
|
|
157
144
|
},
|
|
158
|
-
|
|
159
|
-
describe: i18n(`${i18nKey}.options.useHiddenConfig.describe`),
|
|
160
|
-
type: 'boolean',
|
|
161
|
-
},
|
|
162
|
-
})
|
|
163
|
-
.conflicts('use-hidden-config', 'config');
|
|
145
|
+
});
|
|
164
146
|
addConfigOptions(yargs);
|
|
165
147
|
addTestingOptions(yargs);
|
|
166
148
|
return yargs;
|
package/commands/lint.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.builder = exports.handler = exports.describe = exports.command = void 0;
|
|
|
5
5
|
const { lint } = require('@hubspot/local-dev-lib/cms/validate');
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const { logError } = require('../lib/errorHandlers/index');
|
|
8
|
-
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
8
|
+
const { addConfigOptions, addAccountOptions, getAccountId, } = require('../lib/commonOpts');
|
|
9
9
|
const { resolveLocalPath } = require('../lib/filesystem');
|
|
10
10
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
11
11
|
const { loadAndValidateOptions } = require('../lib/validation');
|
|
@@ -46,22 +46,22 @@ function printHublValidationResult({ file, validation }) {
|
|
|
46
46
|
const handler = async (options) => {
|
|
47
47
|
const { path: lintPath } = options;
|
|
48
48
|
await loadAndValidateOptions(options);
|
|
49
|
-
const
|
|
49
|
+
const accountId = getAccountId(options);
|
|
50
50
|
const localPath = resolveLocalPath(lintPath);
|
|
51
51
|
const groupName = i18n(`${i18nKey}.groupName`, {
|
|
52
52
|
path: localPath,
|
|
53
53
|
});
|
|
54
|
-
trackCommandUsage('lint', null,
|
|
54
|
+
trackCommandUsage('lint', null, accountId);
|
|
55
55
|
logger.group(groupName);
|
|
56
56
|
let count = 0;
|
|
57
57
|
try {
|
|
58
|
-
await lint(
|
|
58
|
+
await lint(accountId, localPath, result => {
|
|
59
59
|
count += printHublValidationResult(result);
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
catch (err) {
|
|
63
63
|
logger.groupEnd(groupName);
|
|
64
|
-
logError(err, { accountId
|
|
64
|
+
logError(err, { accountId });
|
|
65
65
|
process.exit(EXIT_CODES.ERROR);
|
|
66
66
|
}
|
|
67
67
|
logger.groupEnd(groupName);
|
package/commands/list.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const chalk = require('chalk');
|
|
5
|
-
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, } = require('../lib/commonOpts');
|
|
5
|
+
const { addAccountOptions, addConfigOptions, getAccountId, addUseEnvironmentOptions, } = require('../lib/commonOpts');
|
|
6
6
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
7
7
|
const { isPathFolder } = require('../lib/filesystem');
|
|
8
8
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
@@ -17,15 +17,16 @@ exports.command = 'list [path]';
|
|
|
17
17
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
18
18
|
exports.handler = async (options) => {
|
|
19
19
|
await loadAndValidateOptions(options);
|
|
20
|
-
const { path
|
|
20
|
+
const { path } = options;
|
|
21
21
|
const directoryPath = path || '/';
|
|
22
|
+
const accountId = getAccountId(options);
|
|
22
23
|
let contentsResp;
|
|
23
|
-
trackCommandUsage('list', null,
|
|
24
|
+
trackCommandUsage('list', null, accountId);
|
|
24
25
|
logger.debug(i18n(`${i18nKey}.gettingPathContents`, {
|
|
25
26
|
path: directoryPath,
|
|
26
27
|
}));
|
|
27
28
|
try {
|
|
28
|
-
const { data } = await getDirectoryContentsByPath(
|
|
29
|
+
const { data } = await getDirectoryContentsByPath(accountId, directoryPath);
|
|
29
30
|
contentsResp = data;
|
|
30
31
|
}
|
|
31
32
|
catch (e) {
|
package/commands/logs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, } = require('../lib/commonOpts');
|
|
4
|
+
const { addAccountOptions, addConfigOptions, getAccountId, addUseEnvironmentOptions, } = require('../lib/commonOpts');
|
|
5
5
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const { outputLogs } = require('../lib/ui/serverlessFunctionLogs');
|
|
@@ -73,9 +73,10 @@ exports.command = 'logs [endpoint]';
|
|
|
73
73
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
74
74
|
exports.handler = async (options) => {
|
|
75
75
|
await loadAndValidateOptions(options);
|
|
76
|
-
const { latest
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
const { latest } = options;
|
|
77
|
+
const accountId = getAccountId(options);
|
|
78
|
+
trackCommandUsage('logs', { latest }, accountId);
|
|
79
|
+
endpointLog(accountId, options);
|
|
79
80
|
};
|
|
80
81
|
exports.builder = yargs => {
|
|
81
82
|
yargs.positional('endpoint', {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
5
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
5
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
6
6
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
7
7
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
8
8
|
const { kickOffValidation, pollForValidationFinish, fetchValidationResults, processValidationErrors, displayValidationResults, } = require('../../lib/marketplaceValidate');
|
|
@@ -11,9 +11,10 @@ const i18nKey = 'commands.module.subcommands.marketplaceValidate';
|
|
|
11
11
|
exports.command = 'marketplace-validate <src>';
|
|
12
12
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
13
|
exports.handler = async (options) => {
|
|
14
|
-
const { src
|
|
14
|
+
const { src } = options;
|
|
15
15
|
await loadAndValidateOptions(options);
|
|
16
|
-
|
|
16
|
+
const accountId = getAccountId(options);
|
|
17
|
+
trackCommandUsage('validate', null, accountId);
|
|
17
18
|
SpinniesManager.init();
|
|
18
19
|
SpinniesManager.add('marketplaceValidation', {
|
|
19
20
|
text: i18n(`${i18nKey}.logs.validatingModule`, {
|
|
@@ -21,10 +22,10 @@ exports.handler = async (options) => {
|
|
|
21
22
|
}),
|
|
22
23
|
});
|
|
23
24
|
const assetType = 'MODULE';
|
|
24
|
-
const validationId = await kickOffValidation(
|
|
25
|
-
await pollForValidationFinish(
|
|
25
|
+
const validationId = await kickOffValidation(accountId, assetType, src);
|
|
26
|
+
await pollForValidationFinish(accountId, validationId);
|
|
26
27
|
SpinniesManager.remove('marketplaceValidation');
|
|
27
|
-
const validationResults = await fetchValidationResults(
|
|
28
|
+
const validationResults = await fetchValidationResults(accountId, validationId);
|
|
28
29
|
processValidationErrors(i18nKey, validationResults);
|
|
29
30
|
displayValidationResults(i18nKey, validationResults);
|
|
30
31
|
process.exit();
|