@hubspot/cli 3.0.12 → 3.0.13-beta.2
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 +28 -2
- package/commands/accounts/use.js +82 -0
- package/commands/accounts.js +2 -0
- package/commands/config/set/allowUsageTracking.js +12 -19
- package/commands/config/set/defaultMode.js +11 -35
- package/commands/config/set/httpTimeout.js +27 -24
- package/commands/config/set.js +81 -13
- package/commands/logs.js +1 -7
- package/commands/module/marketplace-validate.js +77 -0
- package/commands/module.js +17 -0
- package/commands/project/logs.js +124 -60
- package/commands/project/open.js +75 -0
- package/commands/project.js +2 -0
- package/commands/sandbox/create.js +2 -2
- package/commands/sandbox.js +3 -1
- package/commands/theme/marketplace-validate.js +4 -2
- package/commands/upload.js +21 -10
- package/lib/projects.js +10 -7
- package/lib/prompts/personalAccessKeyPrompt.js +1 -1
- package/lib/prompts/projectNamePrompt.js +29 -0
- package/lib/prompts/projectsLogsPrompt.js +57 -0
- package/lib/serverlessLogs.js +25 -11
- package/lib/validators/__tests__/{BaseValidator.js → AbsoluteValidator.js} +3 -3
- package/lib/validators/__tests__/ModuleDependencyValidator.js +79 -0
- package/lib/validators/__tests__/ModuleValidator.js +22 -55
- package/lib/validators/__tests__/RelativeValidator.js +28 -0
- package/lib/validators/__tests__/TemplateValidator.js +1 -1
- package/lib/validators/__tests__/ThemeConfigValidator.js +1 -1
- package/lib/validators/__tests__/{DependencyValidator.js → ThemeDependencyValidator.js} +14 -12
- package/lib/validators/__tests__/ThemeModuleValidator.js +84 -0
- package/lib/validators/__tests__/validatorTestUtils.js +2 -0
- package/lib/validators/applyValidators.js +20 -4
- package/lib/validators/constants.js +4 -2
- package/lib/validators/index.js +8 -4
- package/lib/validators/marketplaceValidators/{BaseValidator.js → AbsoluteValidator.js} +8 -8
- package/lib/validators/marketplaceValidators/RelativeValidator.js +46 -0
- package/lib/validators/marketplaceValidators/module/ModuleDependencyValidator.js +101 -0
- package/lib/validators/marketplaceValidators/module/ModuleValidator.js +102 -0
- package/lib/validators/marketplaceValidators/theme/SectionValidator.js +2 -2
- package/lib/validators/marketplaceValidators/theme/TemplateValidator.js +2 -2
- package/lib/validators/marketplaceValidators/theme/ThemeConfigValidator.js +3 -3
- package/lib/validators/marketplaceValidators/theme/{DependencyValidator.js → ThemeDependencyValidator.js} +15 -12
- package/lib/validators/marketplaceValidators/theme/{ModuleValidator.js → ThemeModuleValidator.js} +5 -5
- package/package.json +4 -5
- package/bin/hubspot +0 -3
- package/commands/config/set/defaultAccount.js +0 -94
- package/commands/server.js +0 -80
- package/lib/server/updateContext.js +0 -105
package/bin/cli.js
CHANGED
|
@@ -8,7 +8,9 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
8
8
|
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
|
|
9
9
|
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
10
10
|
const { trackHelpUsage } = require('../lib/usageTracking');
|
|
11
|
+
const { getIsInProject } = require('../lib/projects');
|
|
11
12
|
const pkg = require('../package.json');
|
|
13
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
12
14
|
|
|
13
15
|
const removeCommand = require('../commands/remove');
|
|
14
16
|
const initCommand = require('../commands/init');
|
|
@@ -29,6 +31,7 @@ const openCommand = require('../commands/open');
|
|
|
29
31
|
const mvCommand = require('../commands/mv');
|
|
30
32
|
const projectCommands = require('../commands/project');
|
|
31
33
|
const themeCommand = require('../commands/theme');
|
|
34
|
+
const moduleCommand = require('../commands/module');
|
|
32
35
|
const configCommand = require('../commands/config');
|
|
33
36
|
const accountsCommand = require('../commands/accounts');
|
|
34
37
|
const sandboxesCommand = require('../commands/sandbox');
|
|
@@ -36,6 +39,8 @@ const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
|
36
39
|
|
|
37
40
|
const notifier = updateNotifier({ pkg: { ...pkg, name: '@hubspot/cli' } });
|
|
38
41
|
|
|
42
|
+
const i18nKey = 'cli.commands.generalErrors';
|
|
43
|
+
|
|
39
44
|
const CLI_UPGRADE_MESSAGE =
|
|
40
45
|
chalk.bold('The CMS CLI is now the HubSpot CLI') +
|
|
41
46
|
'\n\nTo upgrade, run:\n\nnpm uninstall -g @hubspot/cms-cli\nand npm install -g @hubspot/cli';
|
|
@@ -58,8 +63,11 @@ const argv = yargs
|
|
|
58
63
|
.middleware([setLogLevel])
|
|
59
64
|
.exitProcess(false)
|
|
60
65
|
.fail((msg, err, yargs) => {
|
|
61
|
-
if (msg)
|
|
62
|
-
|
|
66
|
+
if (msg) {
|
|
67
|
+
logger.error(msg);
|
|
68
|
+
} else if (err) {
|
|
69
|
+
logErrorInstance(err);
|
|
70
|
+
}
|
|
63
71
|
|
|
64
72
|
if (msg === null) {
|
|
65
73
|
yargs.showHelp();
|
|
@@ -74,6 +82,23 @@ const argv = yargs
|
|
|
74
82
|
describe: 'set log level to debug',
|
|
75
83
|
type: 'boolean',
|
|
76
84
|
})
|
|
85
|
+
.check(argv => {
|
|
86
|
+
if (argv._.length === 1 && ['upload', 'watch'].includes(argv._[0])) {
|
|
87
|
+
if (getIsInProject(argv.src)) {
|
|
88
|
+
logger.error(
|
|
89
|
+
i18n(`${i18nKey}.srcIsProject`, {
|
|
90
|
+
src: argv.src,
|
|
91
|
+
command: argv._.join(' '),
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
process.exit(EXIT_CODES.ERROR);
|
|
95
|
+
} else {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
})
|
|
77
102
|
.command(authCommand)
|
|
78
103
|
.command(initCommand)
|
|
79
104
|
.command(logsCommand)
|
|
@@ -96,6 +121,7 @@ const argv = yargs
|
|
|
96
121
|
.command(mvCommand)
|
|
97
122
|
.command(projectCommands)
|
|
98
123
|
.command(themeCommand)
|
|
124
|
+
.command(moduleCommand)
|
|
99
125
|
.command(configCommand)
|
|
100
126
|
.command(accountsCommand)
|
|
101
127
|
.command(sandboxesCommand)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
+
const {
|
|
3
|
+
getConfig,
|
|
4
|
+
getConfigPath,
|
|
5
|
+
updateDefaultAccount,
|
|
6
|
+
getAccountId: getAccountIdFromConfig,
|
|
7
|
+
} = require('@hubspot/cli-lib/lib/config');
|
|
8
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
|
+
|
|
10
|
+
const { getAccountId } = require('../../lib/commonOpts');
|
|
11
|
+
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
12
|
+
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
13
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
14
|
+
|
|
15
|
+
const i18nKey = 'cli.commands.accounts.subcommands.use';
|
|
16
|
+
|
|
17
|
+
const selectAccountFromConfig = async config => {
|
|
18
|
+
const { default: selectedDefault } = await promptUser([
|
|
19
|
+
{
|
|
20
|
+
type: 'list',
|
|
21
|
+
look: false,
|
|
22
|
+
name: 'default',
|
|
23
|
+
pageSize: 20,
|
|
24
|
+
message: i18n(`${i18nKey}.promptMessage`),
|
|
25
|
+
choices: config.portals.map(p => ({
|
|
26
|
+
name: `${p.name} (${p.portalId})`,
|
|
27
|
+
value: p.name || p.portalId,
|
|
28
|
+
})),
|
|
29
|
+
default: config.defaultPortal,
|
|
30
|
+
},
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
return selectedDefault;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.command = 'use [account]';
|
|
37
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
38
|
+
|
|
39
|
+
exports.handler = async options => {
|
|
40
|
+
await loadAndValidateOptions({ debug: options.debug });
|
|
41
|
+
|
|
42
|
+
const accountId = getAccountId(options);
|
|
43
|
+
const config = getConfig();
|
|
44
|
+
|
|
45
|
+
let newDefaultAccount = options.account;
|
|
46
|
+
|
|
47
|
+
trackCommandUsage('accounts-use', {}, accountId);
|
|
48
|
+
|
|
49
|
+
if (!newDefaultAccount) {
|
|
50
|
+
newDefaultAccount = await selectAccountFromConfig(config);
|
|
51
|
+
} else if (!getAccountIdFromConfig(newDefaultAccount)) {
|
|
52
|
+
logger.error(
|
|
53
|
+
i18n(`${i18nKey}.errors.accountNotFound`, {
|
|
54
|
+
specifiedAccount: newDefaultAccount,
|
|
55
|
+
configPath: getConfigPath(),
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
newDefaultAccount = await selectAccountFromConfig(config);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
updateDefaultAccount(newDefaultAccount);
|
|
62
|
+
|
|
63
|
+
return logger.success(
|
|
64
|
+
i18n(`${i18nKey}.success.defaultAccountUpdated`, {
|
|
65
|
+
accountName: newDefaultAccount,
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.builder = yargs => {
|
|
71
|
+
yargs.positional('account', {
|
|
72
|
+
describe: i18n(`${i18nKey}.positionals.account.describe`),
|
|
73
|
+
type: 'string',
|
|
74
|
+
});
|
|
75
|
+
yargs.example([
|
|
76
|
+
['$0 accounts use', i18n(`${i18nKey}.examples.default`)],
|
|
77
|
+
['$0 accounts use MyAccount', i18n(`${i18nKey}.examples.nameBased`)],
|
|
78
|
+
['$0 accounts use 1234567', i18n(`${i18nKey}.examples.idBased`)],
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
return yargs;
|
|
82
|
+
};
|
package/commands/accounts.js
CHANGED
|
@@ -2,6 +2,7 @@ const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
|
2
2
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
3
3
|
const list = require('./accounts/list');
|
|
4
4
|
const rename = require('./accounts/rename');
|
|
5
|
+
const use = require('./accounts/use');
|
|
5
6
|
|
|
6
7
|
const i18nKey = 'cli.commands.accounts';
|
|
7
8
|
|
|
@@ -18,6 +19,7 @@ exports.builder = yargs => {
|
|
|
18
19
|
aliases: 'ls',
|
|
19
20
|
})
|
|
20
21
|
.command(rename)
|
|
22
|
+
.command(use)
|
|
21
23
|
.demandCommand(1, '');
|
|
22
24
|
|
|
23
25
|
return yargs;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { updateAllowUsageTracking } = require('@hubspot/cli-lib/lib/config');
|
|
3
|
-
|
|
4
|
-
const { getAccountId } = require('../../../lib/commonOpts');
|
|
5
3
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
6
4
|
const { promptUser } = require('../../../lib/prompts/promptUtils');
|
|
7
|
-
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
8
5
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
9
6
|
|
|
10
7
|
const i18nKey =
|
|
11
|
-
'cli.commands.config.subcommands.set.
|
|
8
|
+
'cli.commands.config.subcommands.set.options.allowUsageTracking';
|
|
12
9
|
|
|
13
10
|
const enableOrDisableUsageTracking = async () => {
|
|
14
11
|
const { isEnabled } = await promptUser([
|
|
@@ -35,26 +32,22 @@ const enableOrDisableUsageTracking = async () => {
|
|
|
35
32
|
return isEnabled;
|
|
36
33
|
};
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
exports.handler = async options => {
|
|
42
|
-
await loadAndValidateOptions(options);
|
|
35
|
+
const setAllowUsageTracking = async ({ accountId, allowUsageTracking }) => {
|
|
36
|
+
trackCommandUsage('config-set-allow-usage-tracking', {}, accountId);
|
|
43
37
|
|
|
44
|
-
|
|
38
|
+
let isEnabled;
|
|
45
39
|
|
|
46
|
-
|
|
40
|
+
if (typeof allowUsageTracking === 'boolean') {
|
|
41
|
+
isEnabled = allowUsageTracking;
|
|
42
|
+
} else {
|
|
43
|
+
isEnabled = await enableOrDisableUsageTracking();
|
|
44
|
+
}
|
|
47
45
|
|
|
48
|
-
const isEnabled = await enableOrDisableUsageTracking();
|
|
49
46
|
updateAllowUsageTracking(isEnabled);
|
|
50
47
|
|
|
51
|
-
return logger.log(i18n(`${i18nKey}
|
|
48
|
+
return logger.log(i18n(`${i18nKey}.success`, { isEnabled }));
|
|
52
49
|
};
|
|
53
50
|
|
|
54
|
-
exports
|
|
55
|
-
|
|
56
|
-
['$0 config set allow-usage-tracking', i18n(`${i18nKey}.examples.default`)],
|
|
57
|
-
]);
|
|
58
|
-
|
|
59
|
-
return yargs;
|
|
51
|
+
module.exports = {
|
|
52
|
+
setAllowUsageTracking,
|
|
60
53
|
};
|
|
@@ -2,14 +2,11 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
2
2
|
const { updateDefaultMode } = require('@hubspot/cli-lib/lib/config');
|
|
3
3
|
const { Mode } = require('@hubspot/cli-lib');
|
|
4
4
|
const { commaSeparatedValues } = require('@hubspot/cli-lib/lib/text');
|
|
5
|
-
|
|
6
|
-
const { getAccountId } = require('../../../lib/commonOpts');
|
|
7
5
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
8
6
|
const { promptUser } = require('../../../lib/prompts/promptUtils');
|
|
9
|
-
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
10
7
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
11
8
|
|
|
12
|
-
const i18nKey = 'cli.commands.config.subcommands.set.
|
|
9
|
+
const i18nKey = 'cli.commands.config.subcommands.set.options.defaultMode';
|
|
13
10
|
|
|
14
11
|
const ALL_MODES = Object.values(Mode);
|
|
15
12
|
|
|
@@ -29,29 +26,19 @@ const selectMode = async () => {
|
|
|
29
26
|
return mode;
|
|
30
27
|
};
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
exports.handler = async options => {
|
|
36
|
-
await loadAndValidateOptions(options);
|
|
29
|
+
const setDefaultMode = async ({ accountId, defaultMode }) => {
|
|
30
|
+
trackCommandUsage('config-set-default-mode', {}, accountId);
|
|
37
31
|
|
|
38
|
-
const accountId = getAccountId(options);
|
|
39
|
-
const { newMode: specifiedNewDefault } = options;
|
|
40
32
|
let newDefault;
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!specifiedNewDefault) {
|
|
34
|
+
if (!defaultMode) {
|
|
45
35
|
newDefault = await selectMode();
|
|
46
|
-
} else if (
|
|
47
|
-
|
|
48
|
-
ALL_MODES.find(m => m === specifiedNewDefault)
|
|
49
|
-
) {
|
|
50
|
-
newDefault = specifiedNewDefault;
|
|
36
|
+
} else if (defaultMode && ALL_MODES.find(m => m === defaultMode)) {
|
|
37
|
+
newDefault = defaultMode;
|
|
51
38
|
} else {
|
|
52
39
|
logger.error(
|
|
53
|
-
i18n(`${i18nKey}.errors
|
|
54
|
-
mode:
|
|
40
|
+
i18n(`${i18nKey}.errors`, {
|
|
41
|
+
mode: newDefault,
|
|
55
42
|
validModes: commaSeparatedValues(ALL_MODES),
|
|
56
43
|
})
|
|
57
44
|
);
|
|
@@ -61,23 +48,12 @@ exports.handler = async options => {
|
|
|
61
48
|
updateDefaultMode(newDefault);
|
|
62
49
|
|
|
63
50
|
return logger.success(
|
|
64
|
-
i18n(`${i18nKey}.success
|
|
51
|
+
i18n(`${i18nKey}.success`, {
|
|
65
52
|
mode: newDefault,
|
|
66
53
|
})
|
|
67
54
|
);
|
|
68
55
|
};
|
|
69
56
|
|
|
70
|
-
exports
|
|
71
|
-
|
|
72
|
-
describe: i18n(`${i18nKey}.positionals.newMode.describe`),
|
|
73
|
-
type: 'string',
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
yargs.example([
|
|
77
|
-
['$0 config set default-mode', i18n(`${i18nKey}.examples.default`)],
|
|
78
|
-
['$0 config set default-mode publish', i18n(`${i18nKey}.examples.publish`)],
|
|
79
|
-
['$0 config set default-mode draft', i18n(`${i18nKey}.examples.draft`)],
|
|
80
|
-
]);
|
|
81
|
-
|
|
82
|
-
return yargs;
|
|
57
|
+
module.exports = {
|
|
58
|
+
setDefaultMode,
|
|
83
59
|
};
|
|
@@ -1,39 +1,42 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { updateHttpTimeout } = require('@hubspot/cli-lib/lib/config');
|
|
3
|
-
|
|
4
|
-
const { getAccountId } = require('../../../lib/commonOpts');
|
|
3
|
+
const { promptUser } = require('../../../lib/prompts/promptUtils');
|
|
5
4
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
6
|
-
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
7
5
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
8
6
|
|
|
9
|
-
const i18nKey = 'cli.commands.config.subcommands.set.
|
|
10
|
-
|
|
11
|
-
exports.command = 'http-timeout [timeout]';
|
|
12
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
7
|
+
const i18nKey = 'cli.commands.config.subcommands.set.options.httpTimeout';
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
await
|
|
9
|
+
const enterTimeout = async () => {
|
|
10
|
+
const { timeout } = await promptUser([
|
|
11
|
+
{
|
|
12
|
+
name: 'timeout',
|
|
13
|
+
message: i18n(`${i18nKey}.promptMessage`),
|
|
14
|
+
type: 'input',
|
|
15
|
+
default: 30000,
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
return timeout;
|
|
20
|
+
};
|
|
19
21
|
|
|
22
|
+
const setHttpTimeout = async ({ accountId, httpTimeout }) => {
|
|
20
23
|
trackCommandUsage('config-set-http-timeout', {}, accountId);
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
let newHttpTimeout;
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
if (!httpTimeout) {
|
|
28
|
+
newHttpTimeout = await enterTimeout();
|
|
29
|
+
} else {
|
|
30
|
+
newHttpTimeout = httpTimeout;
|
|
31
|
+
}
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
yargs.positional('timeout', {
|
|
29
|
-
describe: i18n(`${i18nKey}.positionals.timeout.describe`),
|
|
30
|
-
type: 'string',
|
|
31
|
-
default: 30000,
|
|
32
|
-
});
|
|
33
|
+
updateHttpTimeout(newHttpTimeout);
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
return logger.success(
|
|
36
|
+
i18n(`${i18nKey}.success`, { timeout: newHttpTimeout })
|
|
37
|
+
);
|
|
38
|
+
};
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
module.exports = {
|
|
41
|
+
setHttpTimeout,
|
|
39
42
|
};
|
package/commands/config/set.js
CHANGED
|
@@ -1,25 +1,93 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const defaultAccount = require('./set/defaultAccount');
|
|
3
|
-
const defaultMode = require('./set/defaultMode');
|
|
4
|
-
const httpTimeout = require('./set/httpTimeout');
|
|
5
|
-
const allowUsageTracking = require('./set/allowUsageTracking');
|
|
1
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
6
2
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
3
|
+
const { getAccountId } = require('../../lib/commonOpts');
|
|
4
|
+
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
5
|
+
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
6
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
7
|
+
const { setDefaultMode } = require('./set/defaultMode');
|
|
8
|
+
const { setHttpTimeout } = require('./set/httpTimeout');
|
|
9
|
+
const { setAllowUsageTracking } = require('./set/allowUsageTracking');
|
|
7
10
|
|
|
8
11
|
const i18nKey = 'cli.commands.config.subcommands.set';
|
|
9
12
|
|
|
10
13
|
exports.command = 'set';
|
|
11
14
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const selectOptions = async () => {
|
|
17
|
+
const { mode } = await promptUser([
|
|
18
|
+
{
|
|
19
|
+
type: 'list',
|
|
20
|
+
look: false,
|
|
21
|
+
name: 'mode',
|
|
22
|
+
pageSize: 20,
|
|
23
|
+
message: i18n(`${i18nKey}.promptMessage`),
|
|
24
|
+
choices: [
|
|
25
|
+
{ name: 'Default mode', value: { defaultMode: '' } },
|
|
26
|
+
{ name: 'Allow usage tracking', value: { allowUsageTracking: '' } },
|
|
27
|
+
{ name: 'HTTP timeout', value: { httpTimeout: '' } },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
return mode;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const handleConfigUpdate = async (accountId, options) => {
|
|
36
|
+
const { defaultMode, httpTimeout, allowUsageTracking } = options;
|
|
37
|
+
|
|
38
|
+
if (typeof defaultMode !== 'undefined') {
|
|
39
|
+
await setDefaultMode({ defaultMode, accountId });
|
|
40
|
+
return true;
|
|
41
|
+
} else if (typeof httpTimeout !== 'undefined') {
|
|
42
|
+
await setHttpTimeout({ httpTimeout, accountId });
|
|
43
|
+
return true;
|
|
44
|
+
} else if (typeof allowUsageTracking !== 'undefined') {
|
|
45
|
+
await setAllowUsageTracking({ allowUsageTracking, accountId });
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.handler = async options => {
|
|
53
|
+
await loadAndValidateOptions(options);
|
|
54
|
+
|
|
55
|
+
const accountId = getAccountId(options);
|
|
16
56
|
|
|
57
|
+
trackCommandUsage('config-set', {}, accountId);
|
|
58
|
+
|
|
59
|
+
const configUpdated = await handleConfigUpdate(accountId, options);
|
|
60
|
+
|
|
61
|
+
if (!configUpdated) {
|
|
62
|
+
const selectedOptions = await selectOptions();
|
|
63
|
+
|
|
64
|
+
await handleConfigUpdate(accountId, selectedOptions);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.builder = yargs => {
|
|
17
71
|
yargs
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
72
|
+
.options({
|
|
73
|
+
defaultMode: {
|
|
74
|
+
describe: i18n(`${i18nKey}.options.defaultMode.describe`),
|
|
75
|
+
type: 'string',
|
|
76
|
+
},
|
|
77
|
+
allowUsageTracking: {
|
|
78
|
+
describe: i18n(`${i18nKey}.options.allowUsageTracking.describe`),
|
|
79
|
+
type: 'boolean',
|
|
80
|
+
},
|
|
81
|
+
httpTimeout: {
|
|
82
|
+
describe: i18n(`${i18nKey}.options.httpTimeout.describe`),
|
|
83
|
+
type: 'string',
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
.conflicts('defaultMode', 'allowUsageTracking')
|
|
87
|
+
.conflicts('defaultMode', 'httpTimeout')
|
|
88
|
+
.conflicts('allowUsageTracking', 'httpTimeout');
|
|
89
|
+
|
|
90
|
+
yargs.example([['$0 config set', i18n(`${i18nKey}.examples.default`)]]);
|
|
23
91
|
|
|
24
92
|
return yargs;
|
|
25
93
|
};
|
package/commands/logs.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const Spinnies = require('spinnies');
|
|
2
1
|
const {
|
|
3
2
|
addAccountOptions,
|
|
4
3
|
addConfigOptions,
|
|
@@ -42,11 +41,6 @@ const endpointLog = async (accountId, options) => {
|
|
|
42
41
|
let logsResp;
|
|
43
42
|
|
|
44
43
|
if (follow) {
|
|
45
|
-
const spinnies = new Spinnies();
|
|
46
|
-
|
|
47
|
-
spinnies.add('tailLogs', {
|
|
48
|
-
text: i18n(`${i18nKey}.tailLogs`),
|
|
49
|
-
});
|
|
50
44
|
const tailCall = after =>
|
|
51
45
|
getFunctionLogs(accountId, functionPath, { after });
|
|
52
46
|
const fetchLatest = () => {
|
|
@@ -60,9 +54,9 @@ const endpointLog = async (accountId, options) => {
|
|
|
60
54
|
await tailLogs({
|
|
61
55
|
accountId,
|
|
62
56
|
compact,
|
|
63
|
-
spinnies,
|
|
64
57
|
tailCall,
|
|
65
58
|
fetchLatest,
|
|
59
|
+
name: functionPath,
|
|
66
60
|
});
|
|
67
61
|
} else if (latest) {
|
|
68
62
|
try {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
addConfigOptions,
|
|
5
|
+
addAccountOptions,
|
|
6
|
+
addUseEnvironmentOptions,
|
|
7
|
+
getAccountId,
|
|
8
|
+
} = require('../../lib/commonOpts');
|
|
9
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
10
|
+
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
11
|
+
const {
|
|
12
|
+
logValidatorResults,
|
|
13
|
+
} = require('../../lib/validators/logValidatorResults');
|
|
14
|
+
const {
|
|
15
|
+
applyRelativeValidators,
|
|
16
|
+
} = require('../../lib/validators/applyValidators');
|
|
17
|
+
const MARKETPLACE_VALIDATORS = require('../../lib/validators');
|
|
18
|
+
const { VALIDATION_RESULT } = require('../../lib/validators/constants');
|
|
19
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
20
|
+
|
|
21
|
+
const i18nKey = 'cli.commands.module.subcommands.marketplaceValidate';
|
|
22
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
23
|
+
|
|
24
|
+
exports.command = 'marketplace-validate <src>';
|
|
25
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
26
|
+
|
|
27
|
+
exports.handler = async options => {
|
|
28
|
+
const { src } = options;
|
|
29
|
+
|
|
30
|
+
await loadAndValidateOptions(options);
|
|
31
|
+
|
|
32
|
+
const accountId = getAccountId(options);
|
|
33
|
+
|
|
34
|
+
if (!options.json) {
|
|
35
|
+
logger.log(
|
|
36
|
+
i18n(`${i18nKey}.logs.validatingModule`, {
|
|
37
|
+
path: src,
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
trackCommandUsage('validate', {}, accountId);
|
|
42
|
+
|
|
43
|
+
applyRelativeValidators(
|
|
44
|
+
MARKETPLACE_VALIDATORS.module,
|
|
45
|
+
src,
|
|
46
|
+
src,
|
|
47
|
+
accountId
|
|
48
|
+
).then(groupedResults => {
|
|
49
|
+
logValidatorResults(groupedResults, { logAsJson: options.json });
|
|
50
|
+
|
|
51
|
+
if (
|
|
52
|
+
groupedResults
|
|
53
|
+
.flat()
|
|
54
|
+
.some(result => result.result === VALIDATION_RESULT.FATAL)
|
|
55
|
+
) {
|
|
56
|
+
process.exit(EXIT_CODES.WARNING);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.builder = yargs => {
|
|
62
|
+
addConfigOptions(yargs, true);
|
|
63
|
+
addAccountOptions(yargs, true);
|
|
64
|
+
addUseEnvironmentOptions(yargs, true);
|
|
65
|
+
|
|
66
|
+
yargs.options({
|
|
67
|
+
json: {
|
|
68
|
+
describe: i18n(`${i18nKey}.options.json.describe`),
|
|
69
|
+
type: 'boolean',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
yargs.positional('src', {
|
|
73
|
+
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
74
|
+
type: 'string',
|
|
75
|
+
});
|
|
76
|
+
return yargs;
|
|
77
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const marketplaceValidate = require('./module/marketplace-validate');
|
|
2
|
+
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
3
|
+
// const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
4
|
+
|
|
5
|
+
// const i18nKey = 'cli.commands.module';
|
|
6
|
+
|
|
7
|
+
exports.command = 'module';
|
|
8
|
+
exports.describe = false; //i18n(`${i18nKey}.describe`);
|
|
9
|
+
|
|
10
|
+
exports.builder = yargs => {
|
|
11
|
+
addConfigOptions(yargs, true);
|
|
12
|
+
addAccountOptions(yargs, true);
|
|
13
|
+
|
|
14
|
+
yargs.command(marketplaceValidate).demandCommand(1, '');
|
|
15
|
+
|
|
16
|
+
return yargs;
|
|
17
|
+
};
|