@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
|
@@ -2,26 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
5
|
-
const { addAccountOptions, addConfigOptions,
|
|
5
|
+
const { addAccountOptions, addConfigOptions, 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');
|
|
9
9
|
const { poll } = require('../../lib/polling');
|
|
10
10
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
11
11
|
const { buildPackage, getBuildStatus, } = require('@hubspot/local-dev-lib/api/functions');
|
|
12
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
13
12
|
const { outputBuildLog } = require('../../lib/serverlessLogs');
|
|
14
13
|
const { i18n } = require('../../lib/lang');
|
|
15
14
|
const { isHubSpotHttpError } = require('@hubspot/local-dev-lib/errors/index');
|
|
16
|
-
const i18nKey = 'commands.
|
|
15
|
+
const i18nKey = 'commands.function.subcommands.deploy';
|
|
17
16
|
exports.command = 'deploy <path>';
|
|
18
17
|
exports.describe = false;
|
|
19
18
|
exports.handler = async (options) => {
|
|
20
|
-
|
|
21
|
-
const { path: functionPath } = options;
|
|
22
|
-
const accountId = getAccountId(options);
|
|
19
|
+
const { path: functionPath, derivedAccountId } = options;
|
|
23
20
|
const splitFunctionPath = functionPath.split('.');
|
|
24
|
-
trackCommandUsage('functions-deploy', null,
|
|
21
|
+
trackCommandUsage('functions-deploy', null, derivedAccountId);
|
|
25
22
|
if (!splitFunctionPath.length ||
|
|
26
23
|
splitFunctionPath[splitFunctionPath.length - 1] !== 'functions') {
|
|
27
24
|
logger.error(i18n(`${i18nKey}.errors.notFunctionsFolder`, {
|
|
@@ -35,18 +32,18 @@ exports.handler = async (options) => {
|
|
|
35
32
|
SpinniesManager.init();
|
|
36
33
|
SpinniesManager.add('loading', {
|
|
37
34
|
text: i18n(`${i18nKey}.loading`, {
|
|
38
|
-
account: uiAccountDescription(
|
|
35
|
+
account: uiAccountDescription(derivedAccountId),
|
|
39
36
|
functionPath,
|
|
40
37
|
}),
|
|
41
38
|
});
|
|
42
39
|
try {
|
|
43
|
-
const { data: buildId } = await buildPackage(
|
|
44
|
-
const successResp = await poll(getBuildStatus,
|
|
40
|
+
const { data: buildId } = await buildPackage(derivedAccountId, functionPath);
|
|
41
|
+
const successResp = await poll(getBuildStatus, derivedAccountId, buildId);
|
|
45
42
|
const buildTimeSeconds = (successResp.buildTime / 1000).toFixed(2);
|
|
46
43
|
SpinniesManager.succeed('loading');
|
|
47
44
|
await outputBuildLog(successResp.cdnUrl);
|
|
48
45
|
logger.success(i18n(`${i18nKey}.success.deployed`, {
|
|
49
|
-
accountId,
|
|
46
|
+
accountId: derivedAccountId,
|
|
50
47
|
buildTimeSeconds,
|
|
51
48
|
functionPath,
|
|
52
49
|
}));
|
|
@@ -54,7 +51,7 @@ exports.handler = async (options) => {
|
|
|
54
51
|
catch (e) {
|
|
55
52
|
SpinniesManager.fail('loading', {
|
|
56
53
|
text: i18n(`${i18nKey}.loadingFailed`, {
|
|
57
|
-
account: uiAccountDescription(
|
|
54
|
+
account: uiAccountDescription(derivedAccountId),
|
|
58
55
|
functionPath,
|
|
59
56
|
}),
|
|
60
57
|
});
|
|
@@ -70,7 +67,10 @@ exports.handler = async (options) => {
|
|
|
70
67
|
}));
|
|
71
68
|
}
|
|
72
69
|
else {
|
|
73
|
-
logError(e, new ApiErrorContext({
|
|
70
|
+
logError(e, new ApiErrorContext({
|
|
71
|
+
accountId: derivedAccountId,
|
|
72
|
+
request: functionPath,
|
|
73
|
+
}));
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
};
|
|
@@ -6,21 +6,19 @@ 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,
|
|
9
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
10
10
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
12
11
|
const { i18n } = require('../../lib/lang');
|
|
13
|
-
const i18nKey = 'commands.
|
|
12
|
+
const i18nKey = 'commands.function.subcommands.list';
|
|
14
13
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
15
|
-
exports.command = 'list';
|
|
14
|
+
exports.command = ['list', 'ls'];
|
|
16
15
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
17
16
|
exports.handler = async (options) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
trackCommandUsage('functions-list', null, accountId);
|
|
17
|
+
const { derivedAccountId } = options;
|
|
18
|
+
trackCommandUsage('functions-list', null, derivedAccountId);
|
|
21
19
|
logger.debug(i18n(`${i18nKey}.debug.gettingFunctions`));
|
|
22
|
-
const { data: routesResp } = await getRoutes(
|
|
23
|
-
logError(e, new ApiErrorContext({ accountId }));
|
|
20
|
+
const { data: routesResp } = await getRoutes(derivedAccountId).catch(async (e) => {
|
|
21
|
+
logError(e, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
24
22
|
process.exit(EXIT_CODES.SUCCESS);
|
|
25
23
|
});
|
|
26
24
|
if (!routesResp.objects.length) {
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const { addAccountOptions, addConfigOptions,
|
|
4
|
+
const { addAccountOptions, addConfigOptions, 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');
|
|
8
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
8
|
const { i18n } = require('../../lib/lang');
|
|
10
|
-
const i18nKey = 'commands.
|
|
9
|
+
const i18nKey = 'commands.function.subcommands.server';
|
|
11
10
|
exports.command = 'server <path>';
|
|
12
11
|
exports.describe = false;
|
|
13
12
|
exports.handler = async (options) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const accountId = getAccountId(options);
|
|
17
|
-
trackCommandUsage('functions-server', null, accountId);
|
|
13
|
+
const { path: functionPath, derivedAccountId } = options;
|
|
14
|
+
trackCommandUsage('functions-server', null, derivedAccountId);
|
|
18
15
|
logger.debug(i18n(`${i18nKey}.debug.startingServer`, {
|
|
19
16
|
functionPath,
|
|
20
17
|
}));
|
|
21
18
|
startTestServer({
|
|
22
|
-
accountId,
|
|
19
|
+
accountId: derivedAccountId,
|
|
23
20
|
...options,
|
|
24
21
|
});
|
|
25
22
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const { addGlobalOptions } = require('../lib/commonOpts');
|
|
5
|
+
const list = require('./function/list');
|
|
6
|
+
const deploy = require('./function/deploy');
|
|
7
|
+
const server = require('./function/server');
|
|
8
|
+
const { i18n } = require('../lib/lang');
|
|
9
|
+
const i18nKey = 'commands.function';
|
|
10
|
+
exports.command = ['function', 'functions'];
|
|
11
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
|
+
exports.builder = yargs => {
|
|
13
|
+
addGlobalOptions(yargs);
|
|
14
|
+
yargs.command(list).command(deploy).command(server).demandCommand(1, '');
|
|
15
|
+
return yargs;
|
|
16
|
+
};
|
package/commands/hubdb/clear.js
CHANGED
|
@@ -5,26 +5,30 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
|
5
5
|
const { logError } = require('../../lib/errorHandlers/index');
|
|
6
6
|
const { clearHubDbTableRows } = require('@hubspot/local-dev-lib/hubdb');
|
|
7
7
|
const { publishTable } = require('@hubspot/local-dev-lib/api/hubdb');
|
|
8
|
-
const {
|
|
8
|
+
const { selectHubDBTablePrompt, } = require('../../lib/prompts/selectHubDBTablePrompt');
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions,
|
|
10
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
11
11
|
const { i18n } = require('../../lib/lang');
|
|
12
12
|
const i18nKey = 'commands.hubdb.subcommands.clear';
|
|
13
|
-
exports.command = 'clear
|
|
13
|
+
exports.command = 'clear [table-id]';
|
|
14
14
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
15
|
exports.handler = async (options) => {
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
const accountId = getAccountId(options);
|
|
19
|
-
trackCommandUsage('hubdb-clear', null, accountId);
|
|
16
|
+
const { derivedAccountId } = options;
|
|
17
|
+
trackCommandUsage('hubdb-clear', null, derivedAccountId);
|
|
20
18
|
try {
|
|
21
|
-
const {
|
|
19
|
+
const { tableId } = 'tableId' in options
|
|
20
|
+
? options
|
|
21
|
+
: await selectHubDBTablePrompt({
|
|
22
|
+
accountId: derivedAccountId,
|
|
23
|
+
options,
|
|
24
|
+
});
|
|
25
|
+
const { deletedRowCount } = await clearHubDbTableRows(derivedAccountId, tableId);
|
|
22
26
|
if (deletedRowCount > 0) {
|
|
23
27
|
logger.log(i18n(`${i18nKey}.logs.removedRows`, {
|
|
24
28
|
deletedRowCount,
|
|
25
29
|
tableId,
|
|
26
30
|
}));
|
|
27
|
-
const { data: { rowCount }, } = await publishTable(
|
|
31
|
+
const { data: { rowCount }, } = await publishTable(derivedAccountId, tableId);
|
|
28
32
|
logger.log(i18n(`${i18nKey}.logs.rowCount`, {
|
|
29
33
|
rowCount,
|
|
30
34
|
tableId,
|
|
@@ -44,7 +48,7 @@ exports.builder = yargs => {
|
|
|
44
48
|
addAccountOptions(yargs);
|
|
45
49
|
addConfigOptions(yargs);
|
|
46
50
|
addUseEnvironmentOptions(yargs);
|
|
47
|
-
yargs.positional('
|
|
51
|
+
yargs.positional('table-id', {
|
|
48
52
|
describe: i18n(`${i18nKey}.positionals.tableId.describe`),
|
|
49
53
|
type: 'string',
|
|
50
54
|
});
|
package/commands/hubdb/create.js
CHANGED
|
@@ -6,34 +6,58 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
|
6
6
|
const { logError } = require('../../lib/errorHandlers/index');
|
|
7
7
|
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
8
8
|
const { createHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
|
|
9
|
-
const {
|
|
9
|
+
const { untildify, isValidPath } = require('@hubspot/local-dev-lib/path');
|
|
10
|
+
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
11
|
+
const { checkAndConvertToJson } = require('../../lib/validation');
|
|
10
12
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions,
|
|
13
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
12
14
|
const { i18n } = require('../../lib/lang');
|
|
13
15
|
const i18nKey = 'commands.hubdb.subcommands.create';
|
|
14
16
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
15
|
-
exports.command = 'create
|
|
17
|
+
exports.command = 'create';
|
|
16
18
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
19
|
+
function selectPathPrompt(options) {
|
|
20
|
+
return promptUser([
|
|
21
|
+
{
|
|
22
|
+
name: 'path',
|
|
23
|
+
message: i18n(`${i18nKey}.enterPath`),
|
|
24
|
+
when: !options.path,
|
|
25
|
+
validate: (input) => {
|
|
26
|
+
if (!input) {
|
|
27
|
+
return i18n(`${i18nKey}.errors.pathRequired`);
|
|
28
|
+
}
|
|
29
|
+
if (!isValidPath(input)) {
|
|
30
|
+
return i18n(`${i18nKey}.errors.invalidCharacters`);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
},
|
|
34
|
+
filter: (input) => {
|
|
35
|
+
return untildify(input);
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
17
40
|
exports.handler = async (options) => {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
trackCommandUsage('hubdb-create', null, accountId);
|
|
41
|
+
const { derivedAccountId } = options;
|
|
42
|
+
trackCommandUsage('hubdb-create', null, derivedAccountId);
|
|
43
|
+
let filePath;
|
|
22
44
|
try {
|
|
23
|
-
const filePath = path
|
|
45
|
+
const filePath = 'path' in options
|
|
46
|
+
? path.resolve(getCwd(), options.path)
|
|
47
|
+
: path.resolve(getCwd(), (await selectPathPrompt(options)).path);
|
|
24
48
|
if (!checkAndConvertToJson(filePath)) {
|
|
25
49
|
process.exit(EXIT_CODES.ERROR);
|
|
26
50
|
}
|
|
27
|
-
const table = await createHubDbTable(
|
|
51
|
+
const table = await createHubDbTable(derivedAccountId, path.resolve(getCwd(), filePath));
|
|
28
52
|
logger.success(i18n(`${i18nKey}.success.create`, {
|
|
29
|
-
accountId,
|
|
53
|
+
accountId: derivedAccountId,
|
|
30
54
|
rowCount: table.rowCount,
|
|
31
55
|
tableId: table.tableId,
|
|
32
56
|
}));
|
|
33
57
|
}
|
|
34
58
|
catch (e) {
|
|
35
59
|
logger.error(i18n(`${i18nKey}.errors.create`, {
|
|
36
|
-
|
|
60
|
+
filePath,
|
|
37
61
|
}));
|
|
38
62
|
logError(e);
|
|
39
63
|
}
|
|
@@ -42,8 +66,8 @@ exports.builder = yargs => {
|
|
|
42
66
|
addAccountOptions(yargs);
|
|
43
67
|
addConfigOptions(yargs);
|
|
44
68
|
addUseEnvironmentOptions(yargs);
|
|
45
|
-
yargs.
|
|
46
|
-
describe: i18n(`${i18nKey}.
|
|
69
|
+
yargs.options('path', {
|
|
70
|
+
describe: i18n(`${i18nKey}.options.path.describe`),
|
|
47
71
|
type: 'string',
|
|
48
72
|
});
|
|
49
73
|
};
|
package/commands/hubdb/delete.js
CHANGED
|
@@ -4,24 +4,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
5
|
const { logError } = require('../../lib/errorHandlers/index');
|
|
6
6
|
const { deleteTable } = require('@hubspot/local-dev-lib/api/hubdb');
|
|
7
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
8
7
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions,
|
|
8
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
9
|
+
const { selectHubDBTablePrompt, } = require('../../lib/prompts/selectHubDBTablePrompt');
|
|
10
|
+
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
11
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
10
12
|
const { i18n } = require('../../lib/lang');
|
|
11
13
|
const i18nKey = 'commands.hubdb.subcommands.delete';
|
|
12
|
-
exports.command = 'delete
|
|
14
|
+
exports.command = 'delete [table-id]';
|
|
13
15
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
14
16
|
exports.handler = async (options) => {
|
|
15
|
-
const {
|
|
16
|
-
|
|
17
|
-
const accountId = getAccountId(options);
|
|
18
|
-
trackCommandUsage('hubdb-delete', null, accountId);
|
|
17
|
+
const { force, derivedAccountId } = options;
|
|
18
|
+
trackCommandUsage('hubdb-delete', null, derivedAccountId);
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
const { tableId } = 'tableId' in options
|
|
21
|
+
? options
|
|
22
|
+
: await selectHubDBTablePrompt({
|
|
23
|
+
accountId: derivedAccountId,
|
|
24
|
+
options,
|
|
25
|
+
});
|
|
26
|
+
if (!force) {
|
|
27
|
+
const { shouldDeleteTable } = await promptUser({
|
|
28
|
+
name: 'shouldDeleteTable',
|
|
29
|
+
type: 'confirm',
|
|
30
|
+
message: i18n(`${i18nKey}.shouldDeleteTable`, { tableId }),
|
|
31
|
+
});
|
|
32
|
+
if (!shouldDeleteTable) {
|
|
33
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
await deleteTable(derivedAccountId, tableId);
|
|
21
37
|
logger.success(i18n(`${i18nKey}.success.delete`, {
|
|
22
|
-
accountId,
|
|
38
|
+
accountId: derivedAccountId,
|
|
23
39
|
tableId,
|
|
24
40
|
}));
|
|
41
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
25
42
|
}
|
|
26
43
|
catch (e) {
|
|
27
44
|
logger.error(i18n(`${i18nKey}.errors.delete`, {
|
|
@@ -34,8 +51,12 @@ exports.builder = yargs => {
|
|
|
34
51
|
addAccountOptions(yargs);
|
|
35
52
|
addConfigOptions(yargs);
|
|
36
53
|
addUseEnvironmentOptions(yargs);
|
|
37
|
-
yargs.positional('
|
|
54
|
+
yargs.positional('table-id', {
|
|
38
55
|
describe: i18n(`${i18nKey}.positionals.tableId.describe`),
|
|
39
56
|
type: 'string',
|
|
40
57
|
});
|
|
58
|
+
yargs.option('force', {
|
|
59
|
+
describe: i18n(`${i18nKey}.options.force.describe`),
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
});
|
|
41
62
|
};
|
package/commands/hubdb/fetch.js
CHANGED
|
@@ -4,20 +4,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
5
|
const { logError } = require('../../lib/errorHandlers/index');
|
|
6
6
|
const { downloadHubDbTable } = require('@hubspot/local-dev-lib/hubdb');
|
|
7
|
-
const {
|
|
7
|
+
const { selectHubDBTablePrompt, } = require('../../lib/prompts/selectHubDBTablePrompt');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions,
|
|
9
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
10
10
|
const { i18n } = require('../../lib/lang');
|
|
11
11
|
const i18nKey = 'commands.hubdb.subcommands.fetch';
|
|
12
|
-
exports.command = 'fetch
|
|
12
|
+
exports.command = 'fetch [table-id] [dest]';
|
|
13
13
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
14
14
|
exports.handler = async (options) => {
|
|
15
|
-
const {
|
|
16
|
-
|
|
17
|
-
const accountId = getAccountId(options);
|
|
18
|
-
trackCommandUsage('hubdb-fetch', null, accountId);
|
|
15
|
+
const { derivedAccountId } = options;
|
|
16
|
+
trackCommandUsage('hubdb-fetch', null, derivedAccountId);
|
|
19
17
|
try {
|
|
20
|
-
const
|
|
18
|
+
const promptAnswers = await selectHubDBTablePrompt({
|
|
19
|
+
accountId: derivedAccountId,
|
|
20
|
+
options,
|
|
21
|
+
skipDestPrompt: false,
|
|
22
|
+
});
|
|
23
|
+
const tableId = options.tableId || promptAnswers.tableId;
|
|
24
|
+
const dest = options.dest || promptAnswers.dest;
|
|
25
|
+
const { filePath } = await downloadHubDbTable(derivedAccountId, tableId, dest);
|
|
21
26
|
logger.success(i18n(`${i18nKey}.success.fetch`, {
|
|
22
27
|
path: filePath,
|
|
23
28
|
tableId,
|
|
@@ -31,7 +36,7 @@ exports.builder = yargs => {
|
|
|
31
36
|
addAccountOptions(yargs);
|
|
32
37
|
addConfigOptions(yargs);
|
|
33
38
|
addUseEnvironmentOptions(yargs);
|
|
34
|
-
yargs.positional('
|
|
39
|
+
yargs.positional('table-id', {
|
|
35
40
|
describe: i18n(`${i18nKey}.positionals.tableId.describe`),
|
|
36
41
|
type: 'string',
|
|
37
42
|
});
|
package/commands/hubdb.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const {
|
|
4
|
+
const { addGlobalOptions } = require('../lib/commonOpts');
|
|
5
5
|
const createCommand = require('./hubdb/create');
|
|
6
6
|
const fetchCommand = require('./hubdb/fetch');
|
|
7
7
|
const deleteCommand = require('./hubdb/delete');
|
|
@@ -11,8 +11,7 @@ const i18nKey = 'commands.hubdb';
|
|
|
11
11
|
exports.command = 'hubdb';
|
|
12
12
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
13
|
exports.builder = yargs => {
|
|
14
|
-
|
|
15
|
-
addAccountOptions(yargs);
|
|
14
|
+
addGlobalOptions(yargs);
|
|
16
15
|
yargs
|
|
17
16
|
.command(clearCommand)
|
|
18
17
|
.command(createCommand)
|
package/commands/init.js
CHANGED
|
@@ -3,8 +3,8 @@ 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, } = require('@hubspot/local-dev-lib/config');
|
|
7
|
-
const { addConfigOptions } = require('../lib/commonOpts');
|
|
6
|
+
const { getConfigPath, createEmptyConfigFile, deleteEmptyConfigFile, updateDefaultAccount, loadConfig, configFileExists, } = require('@hubspot/local-dev-lib/config');
|
|
7
|
+
const { addConfigOptions, addGlobalOptions } = require('../lib/commonOpts');
|
|
8
8
|
const { handleExit } = require('../lib/process');
|
|
9
9
|
const { checkAndAddConfigToGitignore, } = require('@hubspot/local-dev-lib/gitignore');
|
|
10
10
|
const { debugError, logError } = require('../lib/errorHandlers/index');
|
|
@@ -62,13 +62,16 @@ const AUTH_TYPE_NAMES = {
|
|
|
62
62
|
[PERSONAL_ACCESS_KEY_AUTH_METHOD.value]: PERSONAL_ACCESS_KEY_AUTH_METHOD.name,
|
|
63
63
|
[OAUTH_AUTH_METHOD.value]: OAUTH_AUTH_METHOD.name,
|
|
64
64
|
};
|
|
65
|
-
exports.command = 'init
|
|
65
|
+
exports.command = 'init';
|
|
66
66
|
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:
|
|
71
|
-
const
|
|
70
|
+
const { auth: authTypeFlagValue, c: configFlagValue, providedAccountId, disableTracking, useHiddenConfig, } = options;
|
|
71
|
+
const authType = (authTypeFlagValue && authTypeFlagValue.toLowerCase()) ||
|
|
72
|
+
PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
73
|
+
const configPath = (configFlagValue && path.join(getCwd(), configFlagValue)) ||
|
|
74
|
+
getConfigPath('', useHiddenConfig);
|
|
72
75
|
setLogLevel(options);
|
|
73
76
|
if (!disableTracking) {
|
|
74
77
|
trackCommandUsage('init', {
|
|
@@ -86,20 +89,32 @@ exports.handler = async (options) => {
|
|
|
86
89
|
if (!disableTracking) {
|
|
87
90
|
await trackAuthAction('init', authType, TRACKING_STATUS.STARTED);
|
|
88
91
|
}
|
|
89
|
-
|
|
92
|
+
const doesOtherConfigFileExist = configFileExists(!useHiddenConfig);
|
|
93
|
+
if (doesOtherConfigFileExist) {
|
|
94
|
+
const path = getConfigPath('', !useHiddenConfig);
|
|
95
|
+
logger.error(i18n(`${i18nKey}.errors.bothConfigFilesNotAllowed`, { path }));
|
|
96
|
+
process.exit(EXIT_CODES.ERROR);
|
|
97
|
+
}
|
|
98
|
+
trackAuthAction('init', authType, TRACKING_STATUS.STARTED);
|
|
99
|
+
createEmptyConfigFile({ path: configPath }, useHiddenConfig);
|
|
100
|
+
//Needed to load deprecated config
|
|
101
|
+
loadConfig(configPath, options);
|
|
90
102
|
handleExit(deleteEmptyConfigFile);
|
|
91
103
|
try {
|
|
92
|
-
const { accountId, name } = await CONFIG_CREATION_FLOWS[authType](env,
|
|
93
|
-
const configPath = getConfigPath();
|
|
104
|
+
const { accountId, name } = await CONFIG_CREATION_FLOWS[authType](env, providedAccountId);
|
|
94
105
|
try {
|
|
95
106
|
checkAndAddConfigToGitignore(configPath);
|
|
96
107
|
}
|
|
97
108
|
catch (e) {
|
|
98
109
|
debugError(e);
|
|
99
110
|
}
|
|
111
|
+
let newConfigPath = configPath;
|
|
112
|
+
if (!newConfigPath && !useHiddenConfig) {
|
|
113
|
+
newConfigPath = `${getCwd()}/${DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME}`;
|
|
114
|
+
}
|
|
100
115
|
logger.log('');
|
|
101
116
|
logger.success(i18n(`${i18nKey}.success.configFileCreated`, {
|
|
102
|
-
configPath,
|
|
117
|
+
configPath: newConfigPath,
|
|
103
118
|
}));
|
|
104
119
|
logger.success(i18n(`${i18nKey}.success.configFileUpdated`, {
|
|
105
120
|
authType: AUTH_TYPE_NAMES[authType],
|
|
@@ -120,30 +135,38 @@ exports.handler = async (options) => {
|
|
|
120
135
|
}
|
|
121
136
|
};
|
|
122
137
|
exports.builder = yargs => {
|
|
123
|
-
yargs
|
|
124
|
-
|
|
125
|
-
|
|
138
|
+
yargs
|
|
139
|
+
.options({
|
|
140
|
+
'auth-type': {
|
|
141
|
+
describe: i18n(`${i18nKey}.options.authType.describe`),
|
|
126
142
|
type: 'string',
|
|
127
143
|
choices: [
|
|
128
144
|
`${PERSONAL_ACCESS_KEY_AUTH_METHOD.value}`,
|
|
129
145
|
`${OAUTH_AUTH_METHOD.value}`,
|
|
130
146
|
],
|
|
131
147
|
default: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
132
|
-
defaultDescription: i18n(`${i18nKey}.options.
|
|
148
|
+
defaultDescription: i18n(`${i18nKey}.options.authType.defaultDescription`, {
|
|
133
149
|
defaultType: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
134
150
|
}),
|
|
135
151
|
},
|
|
136
152
|
account: {
|
|
137
153
|
describe: i18n(`${i18nKey}.options.account.describe`),
|
|
138
154
|
type: 'string',
|
|
155
|
+
alias: 'a',
|
|
139
156
|
},
|
|
140
157
|
'disable-tracking': {
|
|
141
158
|
type: 'boolean',
|
|
142
159
|
hidden: true,
|
|
143
160
|
default: false,
|
|
144
161
|
},
|
|
145
|
-
|
|
162
|
+
'use-hidden-config': {
|
|
163
|
+
describe: i18n(`${i18nKey}.options.useHiddenConfig.describe`),
|
|
164
|
+
type: 'boolean',
|
|
165
|
+
},
|
|
166
|
+
})
|
|
167
|
+
.conflicts('use-hidden-config', 'config');
|
|
146
168
|
addConfigOptions(yargs);
|
|
147
169
|
addTestingOptions(yargs);
|
|
170
|
+
addGlobalOptions(yargs);
|
|
148
171
|
return yargs;
|
|
149
172
|
};
|
package/commands/lint.js
CHANGED
|
@@ -5,10 +5,9 @@ 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,
|
|
8
|
+
const { addConfigOptions, addAccountOptions, addGlobalOptions, } = require('../lib/commonOpts');
|
|
9
9
|
const { resolveLocalPath } = require('../lib/filesystem');
|
|
10
10
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
11
|
-
const { loadAndValidateOptions } = require('../lib/validation');
|
|
12
11
|
const { i18n } = require('../lib/lang');
|
|
13
12
|
const i18nKey = 'commands.lint';
|
|
14
13
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
@@ -45,23 +44,22 @@ function printHublValidationResult({ file, validation }) {
|
|
|
45
44
|
}
|
|
46
45
|
const handler = async (options) => {
|
|
47
46
|
const { path: lintPath } = options;
|
|
48
|
-
|
|
49
|
-
const accountId = getAccountId(options);
|
|
47
|
+
const { derivedAccountId } = options;
|
|
50
48
|
const localPath = resolveLocalPath(lintPath);
|
|
51
49
|
const groupName = i18n(`${i18nKey}.groupName`, {
|
|
52
50
|
path: localPath,
|
|
53
51
|
});
|
|
54
|
-
trackCommandUsage('lint', null,
|
|
52
|
+
trackCommandUsage('lint', null, derivedAccountId);
|
|
55
53
|
logger.group(groupName);
|
|
56
54
|
let count = 0;
|
|
57
55
|
try {
|
|
58
|
-
await lint(
|
|
56
|
+
await lint(derivedAccountId, localPath, result => {
|
|
59
57
|
count += printHublValidationResult(result);
|
|
60
58
|
});
|
|
61
59
|
}
|
|
62
60
|
catch (err) {
|
|
63
61
|
logger.groupEnd(groupName);
|
|
64
|
-
logError(err, { accountId });
|
|
62
|
+
logError(err, { accountId: derivedAccountId });
|
|
65
63
|
process.exit(EXIT_CODES.ERROR);
|
|
66
64
|
}
|
|
67
65
|
logger.groupEnd(groupName);
|
|
@@ -73,6 +71,7 @@ exports.handler = handler;
|
|
|
73
71
|
const builder = yargs => {
|
|
74
72
|
addConfigOptions(yargs);
|
|
75
73
|
addAccountOptions(yargs);
|
|
74
|
+
addGlobalOptions(yargs);
|
|
76
75
|
yargs.positional('path', {
|
|
77
76
|
describe: i18n(`${i18nKey}.positionals.path.describe`),
|
|
78
77
|
type: 'string',
|
package/commands/list.js
CHANGED
|
@@ -2,31 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const chalk = require('chalk');
|
|
5
|
-
const { addAccountOptions, addConfigOptions,
|
|
5
|
+
const { addAccountOptions, addConfigOptions, addGlobalOptions, 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');
|
|
9
9
|
const { logError } = require('../lib/errorHandlers/index');
|
|
10
10
|
const { getDirectoryContentsByPath, } = require('@hubspot/local-dev-lib/api/fileMapper');
|
|
11
11
|
const { HUBSPOT_FOLDER, MARKETPLACE_FOLDER } = require('../lib/constants');
|
|
12
|
-
const { loadAndValidateOptions } = require('../lib/validation');
|
|
13
12
|
const { i18n } = require('../lib/lang');
|
|
14
13
|
const i18nKey = 'commands.list';
|
|
15
14
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
16
15
|
exports.command = 'list [path]';
|
|
17
16
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
18
17
|
exports.handler = async (options) => {
|
|
19
|
-
|
|
20
|
-
const { path } = options;
|
|
18
|
+
const { path, derivedAccountId } = options;
|
|
21
19
|
const directoryPath = path || '/';
|
|
22
|
-
const accountId = getAccountId(options);
|
|
23
20
|
let contentsResp;
|
|
24
|
-
trackCommandUsage('list', null,
|
|
21
|
+
trackCommandUsage('list', null, derivedAccountId);
|
|
25
22
|
logger.debug(i18n(`${i18nKey}.gettingPathContents`, {
|
|
26
23
|
path: directoryPath,
|
|
27
24
|
}));
|
|
28
25
|
try {
|
|
29
|
-
const { data } = await getDirectoryContentsByPath(
|
|
26
|
+
const { data } = await getDirectoryContentsByPath(derivedAccountId, directoryPath);
|
|
30
27
|
contentsResp = data;
|
|
31
28
|
}
|
|
32
29
|
catch (e) {
|
|
@@ -64,6 +61,7 @@ exports.builder = yargs => {
|
|
|
64
61
|
addConfigOptions(yargs);
|
|
65
62
|
addAccountOptions(yargs);
|
|
66
63
|
addUseEnvironmentOptions(yargs);
|
|
64
|
+
addGlobalOptions(yargs);
|
|
67
65
|
return yargs;
|
|
68
66
|
};
|
|
69
67
|
const addColorToContents = fileOrFolder => {
|