@hubspot/cli 3.0.9 → 3.0.10-beta.11
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/README.md +6 -0
- package/bin/cli.js +3 -2
- package/commands/accounts/list.js +18 -26
- package/commands/accounts/rename.js +13 -24
- package/commands/accounts.js +4 -1
- package/commands/app/deploy.js +22 -28
- package/commands/auth.js +30 -13
- package/commands/config/set/allowUsageTracking.js +15 -31
- package/commands/config/set/defaultAccount.js +22 -32
- package/commands/config/set/defaultMode.js +23 -42
- package/commands/config/set/httpTimeout.js +10 -28
- package/commands/config/set.js +4 -1
- package/commands/config.js +4 -1
- package/commands/create/api-sample.js +14 -12
- package/commands/create/module.js +19 -6
- package/commands/create/project.js +8 -1
- package/commands/create/template.js +19 -4
- package/commands/create.js +23 -8
- package/commands/customObject/create.js +22 -24
- package/commands/customObject/schema/create.js +30 -28
- package/commands/customObject/schema/delete.js +20 -20
- package/commands/customObject/schema/fetch-all.js +17 -24
- package/commands/customObject/schema/fetch.js +29 -24
- package/commands/customObject/schema/list.js +8 -17
- package/commands/customObject/schema/update.js +31 -29
- package/commands/customObject/schema.js +4 -1
- package/commands/customObject.js +10 -21
- package/commands/fetch.js +15 -30
- package/commands/filemanager/fetch.js +13 -25
- package/commands/filemanager/upload.js +47 -35
- package/commands/filemanager.js +4 -1
- package/commands/functions/deploy.js +34 -37
- package/commands/functions/list.js +9 -24
- package/commands/functions/server.js +13 -29
- package/commands/functions.js +4 -1
- package/commands/hubdb/clear.js +25 -21
- package/commands/hubdb/create.js +25 -22
- package/commands/hubdb/delete.js +19 -20
- package/commands/hubdb/fetch.js +15 -20
- package/commands/hubdb.js +4 -1
- package/commands/init.js +23 -11
- package/commands/lint.js +14 -23
- package/commands/list.js +19 -25
- package/commands/logs.js +41 -135
- package/commands/mv.js +21 -25
- package/commands/open.js +7 -5
- package/commands/project/create.js +111 -0
- package/commands/project/deploy.js +30 -34
- package/commands/project/listBuilds.js +160 -0
- package/commands/project/logs.js +192 -0
- package/commands/project/upload.js +108 -55
- package/commands/project.js +7 -8
- package/commands/remove.js +12 -20
- package/commands/sandbox/create.js +16 -11
- package/commands/secrets/addSecret.js +18 -21
- package/commands/secrets/deleteSecret.js +18 -21
- package/commands/secrets/listSecrets.js +10 -19
- package/commands/secrets/updateSecret.js +18 -21
- package/commands/secrets.js +4 -1
- package/commands/server.js +13 -5
- package/commands/{marketplaceValidate/validateTheme.js → theme/marketplace-validate.js} +26 -24
- package/commands/theme.js +5 -3
- package/commands/upload.js +66 -45
- package/commands/watch.js +33 -55
- package/lib/__tests__/serverlessLogs.js +8 -9
- package/lib/commonOpts.js +14 -11
- package/lib/enums/exitCodes.js +14 -0
- package/lib/projects.js +246 -235
- package/lib/prompts/projects.js +8 -5
- package/lib/prompts/sandboxes.js +5 -2
- package/lib/prompts.js +26 -27
- package/lib/serverlessLogs.js +11 -12
- package/lib/ui.js +48 -0
- package/lib/validation.js +2 -1
- package/package.json +9 -7
- package/commands/project/init.js +0 -108
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
const {
|
|
2
|
-
loadConfig,
|
|
3
|
-
validateConfig,
|
|
4
|
-
checkAndWarnGitInclusion,
|
|
5
|
-
} = require('@hubspot/cli-lib');
|
|
6
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
7
2
|
const {
|
|
8
3
|
logServerlessFunctionApiErrorInstance,
|
|
@@ -10,42 +5,44 @@ const {
|
|
|
10
5
|
} = require('@hubspot/cli-lib/errorHandlers');
|
|
11
6
|
const { deleteSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
12
7
|
|
|
13
|
-
const {
|
|
8
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
14
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
15
10
|
|
|
16
11
|
const {
|
|
17
12
|
addConfigOptions,
|
|
18
13
|
addAccountOptions,
|
|
19
14
|
addUseEnvironmentOptions,
|
|
20
|
-
setLogLevel,
|
|
21
15
|
getAccountId,
|
|
22
16
|
} = require('../../lib/commonOpts');
|
|
23
|
-
const {
|
|
17
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
18
|
+
|
|
19
|
+
const i18nKey = 'cli.commands.secrets.subcommands.delete';
|
|
24
20
|
|
|
25
21
|
exports.command = 'delete <name>';
|
|
26
|
-
exports.describe =
|
|
22
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
27
23
|
|
|
28
24
|
exports.handler = async options => {
|
|
29
|
-
const {
|
|
25
|
+
const { name: secretName } = options;
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
logDebugInfo(options);
|
|
33
|
-
loadConfig(configPath, options);
|
|
34
|
-
checkAndWarnGitInclusion();
|
|
27
|
+
await loadAndValidateOptions(options);
|
|
35
28
|
|
|
36
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
29
|
const accountId = getAccountId(options);
|
|
40
30
|
trackCommandUsage('secrets-delete', {}, accountId);
|
|
41
31
|
|
|
42
32
|
try {
|
|
43
33
|
await deleteSecret(accountId, secretName);
|
|
44
|
-
logger.
|
|
45
|
-
|
|
34
|
+
logger.success(
|
|
35
|
+
i18n(`${i18nKey}.success.delete`, {
|
|
36
|
+
accountId,
|
|
37
|
+
secretName,
|
|
38
|
+
})
|
|
46
39
|
);
|
|
47
40
|
} catch (e) {
|
|
48
|
-
logger.error(
|
|
41
|
+
logger.error(
|
|
42
|
+
i18n(`${i18nKey}.errors.delete`, {
|
|
43
|
+
secretName,
|
|
44
|
+
})
|
|
45
|
+
);
|
|
49
46
|
await logServerlessFunctionApiErrorInstance(
|
|
50
47
|
accountId,
|
|
51
48
|
e,
|
|
@@ -62,7 +59,7 @@ exports.builder = yargs => {
|
|
|
62
59
|
addAccountOptions(yargs, true);
|
|
63
60
|
addUseEnvironmentOptions(yargs, true);
|
|
64
61
|
yargs.positional('name', {
|
|
65
|
-
describe:
|
|
62
|
+
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
66
63
|
type: 'string',
|
|
67
64
|
});
|
|
68
65
|
return yargs;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
const {
|
|
2
|
-
loadConfig,
|
|
3
|
-
validateConfig,
|
|
4
|
-
checkAndWarnGitInclusion,
|
|
5
|
-
} = require('@hubspot/cli-lib');
|
|
6
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
7
2
|
const {
|
|
8
3
|
logServerlessFunctionApiErrorInstance,
|
|
@@ -10,42 +5,38 @@ const {
|
|
|
10
5
|
} = require('@hubspot/cli-lib/errorHandlers');
|
|
11
6
|
const { fetchSecrets } = require('@hubspot/cli-lib/api/secrets');
|
|
12
7
|
|
|
13
|
-
const {
|
|
8
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
14
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
15
10
|
|
|
16
11
|
const {
|
|
17
12
|
addConfigOptions,
|
|
18
13
|
addAccountOptions,
|
|
19
14
|
addUseEnvironmentOptions,
|
|
20
|
-
setLogLevel,
|
|
21
15
|
getAccountId,
|
|
22
16
|
} = require('../../lib/commonOpts');
|
|
23
|
-
const {
|
|
17
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
18
|
+
|
|
19
|
+
const i18nKey = 'cli.commands.secrets.subcommands.list';
|
|
24
20
|
|
|
25
21
|
exports.command = 'list';
|
|
26
|
-
exports.describe =
|
|
22
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
27
23
|
|
|
28
24
|
exports.handler = async options => {
|
|
29
|
-
|
|
30
|
-
logDebugInfo(options);
|
|
31
|
-
const { config: configPath } = options;
|
|
32
|
-
loadConfig(configPath, options);
|
|
33
|
-
checkAndWarnGitInclusion();
|
|
25
|
+
await loadAndValidateOptions(options);
|
|
34
26
|
|
|
35
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
27
|
const accountId = getAccountId(options);
|
|
39
28
|
trackCommandUsage('secrets-list', {}, accountId);
|
|
40
29
|
|
|
41
30
|
try {
|
|
42
31
|
const { results } = await fetchSecrets(accountId);
|
|
43
|
-
const groupLabel =
|
|
32
|
+
const groupLabel = i18n(`${i18nKey}.groupLabel`, {
|
|
33
|
+
accountId,
|
|
34
|
+
});
|
|
44
35
|
logger.group(groupLabel);
|
|
45
36
|
results.forEach(secret => logger.log(secret));
|
|
46
37
|
logger.groupEnd(groupLabel);
|
|
47
38
|
} catch (e) {
|
|
48
|
-
logger.error(
|
|
39
|
+
logger.error(i18n(`${i18nKey}.errors.list`));
|
|
49
40
|
await logServerlessFunctionApiErrorInstance(
|
|
50
41
|
accountId,
|
|
51
42
|
e,
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
const {
|
|
2
|
-
loadConfig,
|
|
3
|
-
validateConfig,
|
|
4
|
-
checkAndWarnGitInclusion,
|
|
5
|
-
} = require('@hubspot/cli-lib');
|
|
6
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
7
2
|
const {
|
|
8
3
|
logServerlessFunctionApiErrorInstance,
|
|
@@ -10,33 +5,28 @@ const {
|
|
|
10
5
|
} = require('@hubspot/cli-lib/errorHandlers');
|
|
11
6
|
const { updateSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
12
7
|
|
|
13
|
-
const {
|
|
8
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
14
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
15
10
|
|
|
16
11
|
const {
|
|
17
12
|
addConfigOptions,
|
|
18
13
|
addAccountOptions,
|
|
19
14
|
addUseEnvironmentOptions,
|
|
20
|
-
setLogLevel,
|
|
21
15
|
getAccountId,
|
|
22
16
|
} = require('../../lib/commonOpts');
|
|
23
|
-
const { logDebugInfo } = require('../../lib/debugInfo');
|
|
24
17
|
const { secretValuePrompt } = require('../../lib/secretPrompt');
|
|
18
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
19
|
+
|
|
20
|
+
const i18nKey = 'cli.commands.secrets.subcommands.update';
|
|
25
21
|
|
|
26
22
|
exports.command = 'update <name>';
|
|
27
|
-
exports.describe =
|
|
23
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
28
24
|
|
|
29
25
|
exports.handler = async options => {
|
|
30
|
-
const { name: secretName
|
|
26
|
+
const { name: secretName } = options;
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
logDebugInfo(options);
|
|
34
|
-
loadConfig(configPath, options);
|
|
35
|
-
checkAndWarnGitInclusion();
|
|
28
|
+
await loadAndValidateOptions(options);
|
|
36
29
|
|
|
37
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
30
|
const accountId = getAccountId(options);
|
|
41
31
|
trackCommandUsage('secrets-update', {}, accountId);
|
|
42
32
|
|
|
@@ -44,11 +34,18 @@ exports.handler = async options => {
|
|
|
44
34
|
const { secretValue } = await secretValuePrompt();
|
|
45
35
|
|
|
46
36
|
await updateSecret(accountId, secretName, secretValue);
|
|
47
|
-
logger.
|
|
48
|
-
|
|
37
|
+
logger.success(
|
|
38
|
+
i18n(`${i18nKey}.success.update`, {
|
|
39
|
+
accountId,
|
|
40
|
+
secretName,
|
|
41
|
+
})
|
|
49
42
|
);
|
|
50
43
|
} catch (e) {
|
|
51
|
-
logger.error(
|
|
44
|
+
logger.error(
|
|
45
|
+
i18n(`${i18nKey}.errors.update`, {
|
|
46
|
+
secretName,
|
|
47
|
+
})
|
|
48
|
+
);
|
|
52
49
|
await logServerlessFunctionApiErrorInstance(
|
|
53
50
|
accountId,
|
|
54
51
|
e,
|
|
@@ -65,7 +62,7 @@ exports.builder = yargs => {
|
|
|
65
62
|
addAccountOptions(yargs, true);
|
|
66
63
|
addUseEnvironmentOptions(yargs, true);
|
|
67
64
|
yargs.positional('name', {
|
|
68
|
-
describe:
|
|
65
|
+
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
69
66
|
type: 'string',
|
|
70
67
|
});
|
|
71
68
|
return yargs;
|
package/commands/secrets.js
CHANGED
|
@@ -4,9 +4,12 @@ const addSecretCommand = require('./secrets/addSecret');
|
|
|
4
4
|
const listSecretsCommand = require('./secrets/listSecrets');
|
|
5
5
|
const deleteSecretCommand = require('./secrets/deleteSecret');
|
|
6
6
|
const updateSecretCommand = require('./secrets/updateSecret');
|
|
7
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
8
|
+
|
|
9
|
+
const i18nKey = 'cli.commands.secrets';
|
|
7
10
|
|
|
8
11
|
exports.command = 'secrets';
|
|
9
|
-
exports.describe =
|
|
12
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
10
13
|
|
|
11
14
|
exports.builder = yargs => {
|
|
12
15
|
addConfigOptions(yargs, true);
|
package/commands/server.js
CHANGED
|
@@ -21,11 +21,15 @@ const {
|
|
|
21
21
|
getAccountId,
|
|
22
22
|
} = require('../lib/commonOpts');
|
|
23
23
|
const { logDebugInfo } = require('../lib/debugInfo');
|
|
24
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
25
|
+
|
|
26
|
+
const i18nKey = 'cli.commands.server';
|
|
27
|
+
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
24
28
|
|
|
25
29
|
function configureServerCommand(program) {
|
|
26
30
|
program
|
|
27
31
|
.version(version)
|
|
28
|
-
.description(
|
|
32
|
+
.description(i18n(`${i18nKey}.description`))
|
|
29
33
|
.option('--serverConfig <serverConfig>')
|
|
30
34
|
.option('--contextDir [contextDir]')
|
|
31
35
|
.arguments('<src>')
|
|
@@ -37,13 +41,13 @@ function configureServerCommand(program) {
|
|
|
37
41
|
checkAndWarnGitInclusion();
|
|
38
42
|
|
|
39
43
|
if (!validateConfig()) {
|
|
40
|
-
process.exit(
|
|
44
|
+
process.exit(EXIT_CODES.ERROR);
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
const accountId = getAccountId(options);
|
|
44
48
|
|
|
45
49
|
// TODO: add flag to bypass
|
|
46
|
-
logger.log(
|
|
50
|
+
logger.log(i18n(`${i18nKey}.fetching`, { accountId }));
|
|
47
51
|
await updateServerContext(accountId, path.join(getCwd(), contextDir));
|
|
48
52
|
|
|
49
53
|
const cwd = getCwd();
|
|
@@ -55,8 +59,12 @@ function configureServerCommand(program) {
|
|
|
55
59
|
hubspot/local-cms-server
|
|
56
60
|
`;
|
|
57
61
|
|
|
58
|
-
logger.log(
|
|
59
|
-
logger.debug(
|
|
62
|
+
logger.log(i18n(`${i18nKey}.startingServer`));
|
|
63
|
+
logger.debug(
|
|
64
|
+
i18n(`${i18nKey}.runningServer`, {
|
|
65
|
+
cmd,
|
|
66
|
+
})
|
|
67
|
+
);
|
|
60
68
|
shell.exec(cmd, { async: true });
|
|
61
69
|
});
|
|
62
70
|
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const {
|
|
5
|
-
loadConfig,
|
|
6
|
-
validateConfig,
|
|
7
|
-
checkAndWarnGitInclusion,
|
|
8
|
-
} = require('@hubspot/cli-lib');
|
|
9
4
|
const { getCwd } = require('@hubspot/cli-lib/path');
|
|
10
5
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
11
6
|
const { walk } = require('@hubspot/cli-lib');
|
|
@@ -14,11 +9,9 @@ const {
|
|
|
14
9
|
addConfigOptions,
|
|
15
10
|
addAccountOptions,
|
|
16
11
|
addUseEnvironmentOptions,
|
|
17
|
-
setLogLevel,
|
|
18
12
|
getAccountId,
|
|
19
13
|
} = require('../../lib/commonOpts');
|
|
20
|
-
const {
|
|
21
|
-
const { validateAccount } = require('../../lib/validation');
|
|
14
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
22
15
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
23
16
|
const {
|
|
24
17
|
logValidatorResults,
|
|
@@ -26,20 +19,18 @@ const {
|
|
|
26
19
|
const { applyValidators } = require('../../lib/validators/applyValidators');
|
|
27
20
|
const MARKETPLACE_VALIDATORS = require('../../lib/validators');
|
|
28
21
|
const { VALIDATION_RESULT } = require('../../lib/validators/constants');
|
|
22
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
23
|
+
|
|
24
|
+
const i18nKey = 'cli.commands.theme.subcommands.marketplaceValidate';
|
|
25
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
29
26
|
|
|
30
27
|
exports.command = 'marketplace-validate <src>';
|
|
31
|
-
exports.describe =
|
|
28
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
32
29
|
|
|
33
30
|
exports.handler = async options => {
|
|
34
|
-
const { src
|
|
35
|
-
setLogLevel(options);
|
|
36
|
-
logDebugInfo(options);
|
|
37
|
-
loadConfig(configPath, options);
|
|
38
|
-
checkAndWarnGitInclusion();
|
|
31
|
+
const { src } = options;
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
33
|
+
await loadAndValidateOptions(options);
|
|
43
34
|
|
|
44
35
|
const accountId = getAccountId(options);
|
|
45
36
|
const absoluteSrcPath = path.resolve(getCwd(), src);
|
|
@@ -47,16 +38,28 @@ exports.handler = async options => {
|
|
|
47
38
|
try {
|
|
48
39
|
stats = fs.statSync(absoluteSrcPath);
|
|
49
40
|
if (!stats.isDirectory()) {
|
|
50
|
-
logger.error(
|
|
41
|
+
logger.error(
|
|
42
|
+
i18n(`${i18nKey}.errors.invalidPath`, {
|
|
43
|
+
path: src,
|
|
44
|
+
})
|
|
45
|
+
);
|
|
51
46
|
return;
|
|
52
47
|
}
|
|
53
48
|
} catch (e) {
|
|
54
|
-
logger.error(
|
|
49
|
+
logger.error(
|
|
50
|
+
i18n(`${i18nKey}.errors.invalidPath`, {
|
|
51
|
+
path: src,
|
|
52
|
+
})
|
|
53
|
+
);
|
|
55
54
|
return;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
if (!options.json) {
|
|
59
|
-
logger.log(
|
|
58
|
+
logger.log(
|
|
59
|
+
i18n(`${i18nKey}.logs.validatingTheme`, {
|
|
60
|
+
path: src,
|
|
61
|
+
})
|
|
62
|
+
);
|
|
60
63
|
}
|
|
61
64
|
trackCommandUsage('validate', {}, accountId);
|
|
62
65
|
|
|
@@ -75,7 +78,7 @@ exports.handler = async options => {
|
|
|
75
78
|
.flat()
|
|
76
79
|
.some(result => result.result === VALIDATION_RESULT.FATAL)
|
|
77
80
|
) {
|
|
78
|
-
process.exit(
|
|
81
|
+
process.exit(EXIT_CODES.WARNING);
|
|
79
82
|
}
|
|
80
83
|
});
|
|
81
84
|
};
|
|
@@ -87,13 +90,12 @@ exports.builder = yargs => {
|
|
|
87
90
|
|
|
88
91
|
yargs.options({
|
|
89
92
|
json: {
|
|
90
|
-
describe:
|
|
93
|
+
describe: i18n(`${i18nKey}.options.json.describe`),
|
|
91
94
|
type: 'boolean',
|
|
92
95
|
},
|
|
93
96
|
});
|
|
94
97
|
yargs.positional('src', {
|
|
95
|
-
describe:
|
|
96
|
-
'Path to the local theme, relative to your current working directory.',
|
|
98
|
+
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
97
99
|
type: 'string',
|
|
98
100
|
});
|
|
99
101
|
return yargs;
|
package/commands/theme.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
const marketplaceValidate = require('./
|
|
1
|
+
const marketplaceValidate = require('./theme/marketplace-validate');
|
|
2
2
|
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
3
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
4
|
+
|
|
5
|
+
const i18nKey = 'cli.commands.theme';
|
|
3
6
|
|
|
4
7
|
exports.command = 'theme';
|
|
5
|
-
exports.describe =
|
|
6
|
-
'Commands for working with themes, including marketplace validation with the marketplace-validate subcommand';
|
|
8
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
7
9
|
|
|
8
10
|
exports.builder = yargs => {
|
|
9
11
|
addConfigOptions(yargs, true);
|
package/commands/upload.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const {
|
|
5
|
-
loadConfig,
|
|
6
|
-
uploadFolder,
|
|
7
|
-
validateConfig,
|
|
8
|
-
checkAndWarnGitInclusion,
|
|
9
|
-
} = require('@hubspot/cli-lib');
|
|
4
|
+
const { uploadFolder } = require('@hubspot/cli-lib');
|
|
10
5
|
const { getFileMapperQueryValues } = require('@hubspot/cli-lib/fileMapper');
|
|
11
6
|
const { upload } = require('@hubspot/cli-lib/api/fileMapper');
|
|
12
7
|
const {
|
|
@@ -28,45 +23,39 @@ const {
|
|
|
28
23
|
addAccountOptions,
|
|
29
24
|
addModeOptions,
|
|
30
25
|
addUseEnvironmentOptions,
|
|
31
|
-
setLogLevel,
|
|
32
26
|
getAccountId,
|
|
33
27
|
getMode,
|
|
34
28
|
} = require('../lib/commonOpts');
|
|
35
|
-
const {
|
|
36
|
-
const { validateAccount, validateMode } = require('../lib/validation');
|
|
29
|
+
const { validateMode, loadAndValidateOptions } = require('../lib/validation');
|
|
37
30
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
38
31
|
const { getThemePreviewUrl } = require('@hubspot/cli-lib/lib/files');
|
|
32
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
33
|
+
|
|
34
|
+
const i18nKey = 'cli.commands.upload';
|
|
35
|
+
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
39
36
|
|
|
40
37
|
exports.command = 'upload <src> <dest>';
|
|
41
|
-
exports.describe =
|
|
42
|
-
'Upload a folder or file from your computer to the HubSpot CMS';
|
|
38
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
43
39
|
|
|
44
40
|
const logThemePreview = (filePath, accountId) => {
|
|
45
41
|
const previewUrl = getThemePreviewUrl(filePath, accountId);
|
|
46
42
|
// Only log if we are actually in a theme
|
|
47
43
|
if (previewUrl) {
|
|
48
|
-
logger.log(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
logger.log(
|
|
45
|
+
i18n(`${i18nKey}.previewUrl`, {
|
|
46
|
+
previewUrl,
|
|
47
|
+
})
|
|
48
|
+
);
|
|
52
49
|
}
|
|
53
50
|
};
|
|
54
51
|
|
|
55
52
|
exports.handler = async options => {
|
|
56
|
-
const { src, dest
|
|
57
|
-
setLogLevel(options);
|
|
58
|
-
logDebugInfo(options);
|
|
59
|
-
loadConfig(configPath, options);
|
|
60
|
-
checkAndWarnGitInclusion();
|
|
53
|
+
const { src, dest } = options;
|
|
61
54
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
validateMode(options)
|
|
67
|
-
)
|
|
68
|
-
) {
|
|
69
|
-
process.exit(1);
|
|
55
|
+
await loadAndValidateOptions(options);
|
|
56
|
+
|
|
57
|
+
if (!validateMode(options)) {
|
|
58
|
+
process.exit(EXIT_CODES.ERROR);
|
|
70
59
|
}
|
|
71
60
|
|
|
72
61
|
const accountId = getAccountId(options);
|
|
@@ -76,16 +65,24 @@ exports.handler = async options => {
|
|
|
76
65
|
try {
|
|
77
66
|
stats = fs.statSync(absoluteSrcPath);
|
|
78
67
|
if (!stats.isFile() && !stats.isDirectory()) {
|
|
79
|
-
logger.error(
|
|
68
|
+
logger.error(
|
|
69
|
+
i18n(`${i18nKey}.errors.invalidPath`, {
|
|
70
|
+
path: src,
|
|
71
|
+
})
|
|
72
|
+
);
|
|
80
73
|
return;
|
|
81
74
|
}
|
|
82
75
|
} catch (e) {
|
|
83
|
-
logger.error(
|
|
76
|
+
logger.error(
|
|
77
|
+
i18n(`${i18nKey}.errors.invalidPath`, {
|
|
78
|
+
path: src,
|
|
79
|
+
})
|
|
80
|
+
);
|
|
84
81
|
return;
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
if (!dest) {
|
|
88
|
-
logger.error(
|
|
85
|
+
logger.error(i18n(`${i18nKey}.errors.destinationRequired`));
|
|
89
86
|
return;
|
|
90
87
|
}
|
|
91
88
|
const normalizedDest = convertToUnixPath(dest);
|
|
@@ -101,16 +98,24 @@ exports.handler = async options => {
|
|
|
101
98
|
|
|
102
99
|
if (srcDestIssues.length) {
|
|
103
100
|
srcDestIssues.forEach(({ message }) => logger.error(message));
|
|
104
|
-
process.exit(
|
|
101
|
+
process.exit(EXIT_CODES.ERROR);
|
|
105
102
|
}
|
|
106
103
|
if (stats.isFile()) {
|
|
107
104
|
if (!isAllowedExtension(src)) {
|
|
108
|
-
logger.error(
|
|
105
|
+
logger.error(
|
|
106
|
+
i18n(`${i18nKey}.errors.invalidPath`, {
|
|
107
|
+
path: src,
|
|
108
|
+
})
|
|
109
|
+
);
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
if (shouldIgnoreFile(absoluteSrcPath)) {
|
|
113
|
-
logger.error(
|
|
114
|
+
logger.error(
|
|
115
|
+
i18n(`${i18nKey}.errors.fileIgnored`, {
|
|
116
|
+
path: src,
|
|
117
|
+
})
|
|
118
|
+
);
|
|
114
119
|
return;
|
|
115
120
|
}
|
|
116
121
|
|
|
@@ -122,15 +127,21 @@ exports.handler = async options => {
|
|
|
122
127
|
)
|
|
123
128
|
.then(() => {
|
|
124
129
|
logger.success(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
i18n(`${i18nKey}.success.fileUploaded`, {
|
|
131
|
+
accountId,
|
|
132
|
+
dest: normalizedDest,
|
|
133
|
+
src,
|
|
134
|
+
})
|
|
129
135
|
);
|
|
130
136
|
logThemePreview(src, accountId);
|
|
131
137
|
})
|
|
132
138
|
.catch(error => {
|
|
133
|
-
logger.error(
|
|
139
|
+
logger.error(
|
|
140
|
+
i18n(`${i18nKey}.errors.uploadFailed`, {
|
|
141
|
+
dest: normalizedDest,
|
|
142
|
+
src,
|
|
143
|
+
})
|
|
144
|
+
);
|
|
134
145
|
logApiUploadErrorInstance(
|
|
135
146
|
error,
|
|
136
147
|
new ApiErrorContext({
|
|
@@ -142,19 +153,30 @@ exports.handler = async options => {
|
|
|
142
153
|
});
|
|
143
154
|
} else {
|
|
144
155
|
logger.log(
|
|
145
|
-
|
|
156
|
+
i18n(`${i18nKey}.uploading`, {
|
|
157
|
+
accountId,
|
|
158
|
+
dest,
|
|
159
|
+
src,
|
|
160
|
+
})
|
|
146
161
|
);
|
|
147
162
|
uploadFolder(accountId, absoluteSrcPath, dest, {
|
|
148
163
|
mode,
|
|
149
164
|
})
|
|
150
165
|
.then(() => {
|
|
151
166
|
logger.success(
|
|
152
|
-
|
|
167
|
+
i18n(`${i18nKey}.success.uploadComplete`, {
|
|
168
|
+
dest,
|
|
169
|
+
})
|
|
153
170
|
);
|
|
154
171
|
logThemePreview(src, accountId);
|
|
155
172
|
})
|
|
156
173
|
.catch(error => {
|
|
157
|
-
logger.error(
|
|
174
|
+
logger.error(
|
|
175
|
+
i18n(`${i18nKey}.errors.uploadFailed`, {
|
|
176
|
+
dest,
|
|
177
|
+
src,
|
|
178
|
+
})
|
|
179
|
+
);
|
|
158
180
|
logErrorInstance(error, {
|
|
159
181
|
accountId,
|
|
160
182
|
});
|
|
@@ -169,12 +191,11 @@ exports.builder = yargs => {
|
|
|
169
191
|
addUseEnvironmentOptions(yargs, true);
|
|
170
192
|
|
|
171
193
|
yargs.positional('src', {
|
|
172
|
-
describe:
|
|
173
|
-
'Path to the local file, relative to your current working directory.',
|
|
194
|
+
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
174
195
|
type: 'string',
|
|
175
196
|
});
|
|
176
197
|
yargs.positional('dest', {
|
|
177
|
-
describe:
|
|
198
|
+
describe: i18n(`${i18nKey}.positionals.dest.describe`),
|
|
178
199
|
type: 'string',
|
|
179
200
|
});
|
|
180
201
|
return yargs;
|