@hubspot/cli 6.4.0 → 7.0.0-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +36 -15
- package/commands/{accounts → account}/clean.js +10 -9
- package/commands/{accounts → account}/info.js +10 -14
- package/commands/{accounts → account}/list.js +16 -13
- package/commands/{accounts → account}/remove.js +8 -8
- package/commands/{accounts → account}/rename.js +4 -5
- package/commands/{accounts → account}/use.js +5 -8
- package/commands/account.js +26 -0
- package/commands/auth.js +30 -23
- package/commands/cms/getReactModule.js +70 -0
- package/commands/cms/lighthouseScore.js +19 -19
- package/commands/cms.js +4 -3
- package/commands/completion.js +22 -0
- package/commands/config/set.js +22 -22
- package/commands/config.js +2 -2
- package/commands/create.js +5 -3
- package/commands/customObject/create.js +18 -13
- package/commands/customObject/schema/create.js +14 -14
- package/commands/customObject/schema/delete.js +29 -9
- package/commands/customObject/schema/fetch-all.js +14 -9
- package/commands/customObject/schema/fetch.js +22 -12
- package/commands/customObject/schema/list.js +3 -4
- package/commands/customObject/schema/update.js +27 -16
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +3 -4
- package/commands/doctor.js +2 -0
- package/commands/feedback.js +2 -0
- package/commands/fetch.js +13 -12
- package/commands/filemanager/fetch.js +6 -5
- package/commands/filemanager/upload.js +10 -10
- package/commands/filemanager.js +0 -4
- package/commands/{functions → function}/deploy.js +13 -11
- package/commands/{functions → function}/list.js +7 -7
- package/commands/{functions → function}/server.js +5 -6
- package/commands/function.js +20 -0
- package/commands/hubdb/clear.js +14 -8
- package/commands/hubdb/create.js +36 -11
- package/commands/hubdb/delete.js +31 -8
- package/commands/hubdb/fetch.js +14 -7
- package/commands/hubdb.js +2 -3
- package/commands/init.js +37 -14
- package/commands/lint.js +6 -5
- package/commands/list.js +5 -5
- package/commands/logs.js +24 -13
- package/commands/module/marketplace-validate.js +6 -7
- package/commands/module.js +2 -1
- package/commands/mv.js +11 -11
- package/commands/open.js +11 -10
- package/commands/project/add.js +2 -3
- package/commands/project/cloneApp.js +28 -30
- package/commands/project/create.js +8 -8
- package/commands/project/deploy.js +16 -13
- package/commands/project/dev.js +14 -14
- package/commands/project/download.js +18 -13
- package/commands/project/listBuilds.js +34 -29
- package/commands/project/logs.js +5 -5
- package/commands/project/migrateApp.js +27 -25
- package/commands/project/open.js +7 -8
- package/commands/project/upload.js +27 -29
- package/commands/project/watch.js +12 -19
- package/commands/project.js +3 -4
- package/commands/remove.js +14 -11
- package/commands/sandbox/create.js +12 -13
- package/commands/sandbox/delete.js +15 -13
- package/commands/sandbox.js +3 -4
- package/commands/{secrets → secret}/addSecret.js +24 -9
- package/commands/secret/deleteSecret.js +71 -0
- package/commands/{secrets → secret}/listSecrets.js +6 -6
- package/commands/secret/updateSecret.d.ts +1 -0
- package/commands/{secrets → secret}/updateSecret.js +20 -10
- package/commands/secret.js +22 -0
- package/commands/theme/generate-selectors.js +8 -8
- package/commands/theme/marketplace-validate.js +10 -11
- package/commands/theme/preview.js +6 -7
- package/commands/theme.js +3 -1
- package/commands/upload.js +28 -24
- package/commands/watch.js +19 -19
- package/lang/en.lyaml +177 -111
- package/lib/buildAccount.js +3 -1
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -38
- package/lib/configOptions.js +19 -18
- package/lib/developerTestAccounts.js +8 -5
- package/lib/oauth.js +3 -1
- package/lib/projects.js +10 -5
- package/lib/prompts/accountsPrompt.js +9 -5
- package/lib/prompts/createModulePrompt.js +17 -2
- package/lib/prompts/createProjectPrompt.js +5 -5
- package/lib/prompts/projectDevTargetAccountPrompt.js +3 -2
- package/lib/prompts/promptUtils.d.ts +3 -0
- package/lib/prompts/promptUtils.js +14 -2
- package/lib/prompts/sandboxesPrompt.js +10 -7
- package/lib/prompts/secretPrompt.d.ts +3 -1
- package/lib/prompts/secretPrompt.js +32 -19
- package/lib/prompts/selectHubDBTablePrompt.d.ts +8 -0
- package/lib/prompts/selectHubDBTablePrompt.js +69 -0
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -2
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/lib/validation.js +14 -13
- package/package.json +5 -4
- 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/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/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
|
@@ -1,28 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
5
|
+
const secrets_1 = require("@hubspot/local-dev-lib/api/secrets");
|
|
6
|
+
const ui_1 = require("../../lib/ui");
|
|
4
7
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
8
|
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
6
9
|
const { addSecret } = require('@hubspot/local-dev-lib/api/secrets');
|
|
7
10
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
8
11
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions,
|
|
12
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
10
13
|
const { uiAccountDescription } = require('../../lib/ui');
|
|
11
|
-
const { secretValuePrompt } = require('../../lib/prompts/secretPrompt');
|
|
14
|
+
const { secretValuePrompt, secretNamePrompt, } = require('../../lib/prompts/secretPrompt');
|
|
12
15
|
const { i18n } = require('../../lib/lang');
|
|
13
16
|
const i18nKey = 'commands.secrets.subcommands.add';
|
|
14
|
-
exports.command = 'add
|
|
17
|
+
exports.command = 'add [name]';
|
|
15
18
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
16
19
|
exports.handler = async (options) => {
|
|
17
|
-
const { name
|
|
20
|
+
const { name, derivedAccountId } = options;
|
|
21
|
+
let secretName = name;
|
|
18
22
|
await loadAndValidateOptions(options);
|
|
19
|
-
|
|
20
|
-
trackCommandUsage('secrets-add', null, accountId);
|
|
23
|
+
trackCommandUsage('secrets-add', null, derivedAccountId);
|
|
21
24
|
try {
|
|
25
|
+
if (!secretName) {
|
|
26
|
+
const { secretName: name } = await secretNamePrompt();
|
|
27
|
+
secretName = name;
|
|
28
|
+
}
|
|
29
|
+
const { data: { results: secrets }, } = await (0, secrets_1.fetchSecrets)(derivedAccountId);
|
|
30
|
+
if (secrets.includes(secretName)) {
|
|
31
|
+
logger.error(i18n(`${i18nKey}.errors.alreadyExists`, {
|
|
32
|
+
secretName,
|
|
33
|
+
command: (0, ui_1.uiCommandReference)('hs secret update'),
|
|
34
|
+
}));
|
|
35
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
36
|
+
}
|
|
22
37
|
const { secretValue } = await secretValuePrompt();
|
|
23
|
-
await addSecret(
|
|
38
|
+
await addSecret(derivedAccountId, secretName, secretValue);
|
|
24
39
|
logger.success(i18n(`${i18nKey}.success.add`, {
|
|
25
|
-
accountIdentifier: uiAccountDescription(
|
|
40
|
+
accountIdentifier: uiAccountDescription(derivedAccountId),
|
|
26
41
|
secretName,
|
|
27
42
|
}));
|
|
28
43
|
}
|
|
@@ -32,7 +47,7 @@ exports.handler = async (options) => {
|
|
|
32
47
|
}));
|
|
33
48
|
logError(err, new ApiErrorContext({
|
|
34
49
|
request: 'add secret',
|
|
35
|
-
accountId,
|
|
50
|
+
accountId: derivedAccountId,
|
|
36
51
|
}));
|
|
37
52
|
}
|
|
38
53
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const secretPrompt_1 = require("../../lib/prompts/secretPrompt");
|
|
5
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
6
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
7
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
|
+
const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
9
|
+
const { deleteSecret, fetchSecrets, } = require('@hubspot/local-dev-lib/api/secrets');
|
|
10
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
|
+
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
12
|
+
const { uiAccountDescription } = require('../../lib/ui');
|
|
13
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
14
|
+
const { i18n } = require('../../lib/lang');
|
|
15
|
+
const i18nKey = 'commands.secrets.subcommands.delete';
|
|
16
|
+
exports.command = 'delete [name]';
|
|
17
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
18
|
+
exports.handler = async (options) => {
|
|
19
|
+
const { name, derivedAccountId, force } = options;
|
|
20
|
+
let secretName = name;
|
|
21
|
+
await loadAndValidateOptions(options);
|
|
22
|
+
trackCommandUsage('secrets-delete', null, derivedAccountId);
|
|
23
|
+
try {
|
|
24
|
+
const { data: { results: secrets }, } = await fetchSecrets(derivedAccountId);
|
|
25
|
+
if (secretName && !secrets.includes(secretName)) {
|
|
26
|
+
logger.error(i18n(`${i18nKey}.errors.noSecret`, { secretName }));
|
|
27
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
28
|
+
}
|
|
29
|
+
if (!secretName) {
|
|
30
|
+
const { secretToModify } = await (0, secretPrompt_1.secretListPrompt)(secrets, i18n(`${i18nKey}.selectSecret`));
|
|
31
|
+
secretName = secretToModify;
|
|
32
|
+
}
|
|
33
|
+
const confirmDelete = force ||
|
|
34
|
+
(await (0, promptUtils_1.confirmPrompt)(i18n(`${i18nKey}.confirmDelete`, { secretName }), {
|
|
35
|
+
defaultAnswer: false,
|
|
36
|
+
}));
|
|
37
|
+
if (!confirmDelete) {
|
|
38
|
+
logger.success(i18n(`${i18nKey}.deleteCanceled`));
|
|
39
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
40
|
+
}
|
|
41
|
+
await deleteSecret(derivedAccountId, secretName);
|
|
42
|
+
logger.success(i18n(`${i18nKey}.success.delete`, {
|
|
43
|
+
accountIdentifier: uiAccountDescription(derivedAccountId),
|
|
44
|
+
secretName,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
logger.error(i18n(`${i18nKey}.errors.delete`, {
|
|
49
|
+
secretName,
|
|
50
|
+
}));
|
|
51
|
+
logError(err, new ApiErrorContext({
|
|
52
|
+
request: 'delete a secret',
|
|
53
|
+
accountId: derivedAccountId,
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.builder = yargs => {
|
|
58
|
+
addConfigOptions(yargs);
|
|
59
|
+
addAccountOptions(yargs);
|
|
60
|
+
addUseEnvironmentOptions(yargs);
|
|
61
|
+
yargs
|
|
62
|
+
.positional('name', {
|
|
63
|
+
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
64
|
+
type: 'string',
|
|
65
|
+
})
|
|
66
|
+
.options('force', {
|
|
67
|
+
describe: 'Force the deletion',
|
|
68
|
+
type: 'boolean',
|
|
69
|
+
});
|
|
70
|
+
return yargs;
|
|
71
|
+
};
|
|
@@ -7,19 +7,19 @@ const { fetchSecrets } = require('@hubspot/local-dev-lib/api/secrets');
|
|
|
7
7
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
9
|
const { uiAccountDescription } = require('../../lib/ui');
|
|
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.secrets.subcommands.list';
|
|
13
13
|
exports.command = 'list';
|
|
14
14
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
15
|
exports.handler = async (options) => {
|
|
16
16
|
await loadAndValidateOptions(options);
|
|
17
|
-
const
|
|
18
|
-
trackCommandUsage('secrets-list', null,
|
|
17
|
+
const { derivedAccountId } = options;
|
|
18
|
+
trackCommandUsage('secrets-list', null, derivedAccountId);
|
|
19
19
|
try {
|
|
20
|
-
const { data: { results }, } = await fetchSecrets(
|
|
20
|
+
const { data: { results }, } = await fetchSecrets(derivedAccountId);
|
|
21
21
|
const groupLabel = i18n(`${i18nKey}.groupLabel`, {
|
|
22
|
-
accountIdentifier: uiAccountDescription(
|
|
22
|
+
accountIdentifier: uiAccountDescription(derivedAccountId),
|
|
23
23
|
});
|
|
24
24
|
logger.group(groupLabel);
|
|
25
25
|
results.forEach(secret => logger.log(secret));
|
|
@@ -29,7 +29,7 @@ exports.handler = async (options) => {
|
|
|
29
29
|
logger.error(i18n(`${i18nKey}.errors.list`));
|
|
30
30
|
logError(err, new ApiErrorContext({
|
|
31
31
|
request: 'add secret',
|
|
32
|
-
accountId,
|
|
32
|
+
accountId: derivedAccountId,
|
|
33
33
|
}));
|
|
34
34
|
}
|
|
35
35
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,28 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
4
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
6
|
const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
6
|
-
const { updateSecret } = require('@hubspot/local-dev-lib/api/secrets');
|
|
7
|
+
const { updateSecret, fetchSecrets, } = require('@hubspot/local-dev-lib/api/secrets');
|
|
7
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
8
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
10
|
const { uiAccountDescription } = require('../../lib/ui');
|
|
10
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions,
|
|
11
|
-
const { secretValuePrompt } = require('../../lib/prompts/secretPrompt');
|
|
11
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
12
|
+
const { secretValuePrompt, secretListPrompt, } = require('../../lib/prompts/secretPrompt');
|
|
12
13
|
const { i18n } = require('../../lib/lang');
|
|
13
14
|
const i18nKey = 'commands.secrets.subcommands.update';
|
|
14
|
-
exports.command = 'update
|
|
15
|
+
exports.command = 'update [name]';
|
|
15
16
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
16
17
|
exports.handler = async (options) => {
|
|
17
|
-
const { name
|
|
18
|
+
const { name, derivedAccountId } = options;
|
|
19
|
+
let secretName = name;
|
|
18
20
|
await loadAndValidateOptions(options);
|
|
19
|
-
|
|
20
|
-
trackCommandUsage('secrets-update', null, accountId);
|
|
21
|
+
trackCommandUsage('secrets-update', null, derivedAccountId);
|
|
21
22
|
try {
|
|
23
|
+
const { data: { results: secrets }, } = await fetchSecrets(derivedAccountId);
|
|
24
|
+
if (secretName && !secrets.includes(secretName)) {
|
|
25
|
+
logger.error(i18n(`${i18nKey}.errors.noSecret`, { secretName }));
|
|
26
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
27
|
+
}
|
|
28
|
+
if (!secretName) {
|
|
29
|
+
const { secretToModify } = await secretListPrompt(secrets, i18n(`${i18nKey}.selectSecret`));
|
|
30
|
+
secretName = secretToModify;
|
|
31
|
+
}
|
|
22
32
|
const { secretValue } = await secretValuePrompt();
|
|
23
|
-
await updateSecret(
|
|
33
|
+
await updateSecret(derivedAccountId, secretName, secretValue);
|
|
24
34
|
logger.success(i18n(`${i18nKey}.success.update`, {
|
|
25
|
-
accountIdentifier: uiAccountDescription(
|
|
35
|
+
accountIdentifier: uiAccountDescription(derivedAccountId),
|
|
26
36
|
secretName,
|
|
27
37
|
}));
|
|
28
38
|
logger.log(i18n(`${i18nKey}.success.updateExplanation`));
|
|
@@ -33,7 +43,7 @@ exports.handler = async (options) => {
|
|
|
33
43
|
}));
|
|
34
44
|
logError(err, new ApiErrorContext({
|
|
35
45
|
request: 'update secret',
|
|
36
|
-
accountId,
|
|
46
|
+
accountId: derivedAccountId,
|
|
37
47
|
}));
|
|
38
48
|
}
|
|
39
49
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const { addGlobalOptions } = require('../lib/commonOpts');
|
|
5
|
+
const addSecretCommand = require('./secret/addSecret');
|
|
6
|
+
const listSecretsCommand = require('./secret/listSecrets');
|
|
7
|
+
const deleteSecretCommand = require('./secret/deleteSecret');
|
|
8
|
+
const updateSecretCommand = require('./secret/updateSecret');
|
|
9
|
+
const { i18n } = require('../lib/lang');
|
|
10
|
+
const i18nKey = 'commands.secret';
|
|
11
|
+
exports.command = ['secret', 'secrets'];
|
|
12
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
|
+
exports.builder = yargs => {
|
|
14
|
+
addGlobalOptions(yargs);
|
|
15
|
+
yargs
|
|
16
|
+
.command(listSecretsCommand)
|
|
17
|
+
.command(addSecretCommand)
|
|
18
|
+
.command(updateSecretCommand)
|
|
19
|
+
.command(deleteSecretCommand)
|
|
20
|
+
.demandCommand(1, '');
|
|
21
|
+
return yargs;
|
|
22
|
+
};
|
|
@@ -16,17 +16,17 @@ const CSS_SELECTORS_REGEX = new RegExp(/([\s\w:.,\0-[\]]*){/, 'i');
|
|
|
16
16
|
const CSS_EXPRESSION_REGEX = new RegExp(/(?!\s)([^}])*(?![.#\s,>])[^}]*}/, 'g');
|
|
17
17
|
const THEME_PATH_REGEX = new RegExp(/=\s*.*(theme\.(\w|\.)*)/, 'i');
|
|
18
18
|
const i18nKey = 'commands.theme.subcommands.generateSelectors';
|
|
19
|
-
exports.command = 'generate-selectors <
|
|
19
|
+
exports.command = 'generate-selectors <path>';
|
|
20
20
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
21
21
|
exports.handler = options => {
|
|
22
|
-
const {
|
|
23
|
-
const fieldsJsonPath = findFieldsJsonPath(
|
|
22
|
+
const { path } = options;
|
|
23
|
+
const fieldsJsonPath = findFieldsJsonPath(path);
|
|
24
24
|
if (!fieldsJsonPath) {
|
|
25
25
|
logger.error(i18n(`${i18nKey}.errors.fieldsNotFound`));
|
|
26
26
|
process.exit(EXIT_CODES.ERROR);
|
|
27
27
|
}
|
|
28
28
|
let fieldsJson = JSON.parse(fs.readFileSync(fieldsJsonPath));
|
|
29
|
-
let cssString = combineThemeCss(
|
|
29
|
+
let cssString = combineThemeCss(path);
|
|
30
30
|
/**
|
|
31
31
|
* Creates map of HubL variable names to theme field paths
|
|
32
32
|
*/
|
|
@@ -135,16 +135,16 @@ exports.handler = options => {
|
|
|
135
135
|
fieldsJson = generateInheritedSelectors(fieldsJson, fieldsJson);
|
|
136
136
|
}
|
|
137
137
|
const selectorsMap = generateSelectorsMap(fieldsJson);
|
|
138
|
-
const selectorsPath = `${
|
|
138
|
+
const selectorsPath = `${path}/editor-preview.json`;
|
|
139
139
|
fs.writeFileSync(selectorsPath, `${JSON.stringify({ selectors: selectorsMap }, null, 2)}\n`);
|
|
140
140
|
logger.success(i18n(`${i18nKey}.success`, {
|
|
141
|
-
themePath,
|
|
141
|
+
themePath: path,
|
|
142
142
|
selectorsPath,
|
|
143
143
|
}));
|
|
144
144
|
};
|
|
145
145
|
exports.builder = yargs => {
|
|
146
|
-
yargs.positional('
|
|
147
|
-
describe: i18n(`${i18nKey}.positionals.
|
|
146
|
+
yargs.positional('path', {
|
|
147
|
+
describe: i18n(`${i18nKey}.positionals.path.describe`),
|
|
148
148
|
type: 'string',
|
|
149
149
|
});
|
|
150
150
|
return yargs;
|
|
@@ -2,30 +2,29 @@
|
|
|
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,
|
|
5
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = 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');
|
|
9
9
|
const { i18n } = require('../../lib/lang');
|
|
10
10
|
const i18nKey = 'commands.theme.subcommands.marketplaceValidate';
|
|
11
|
-
exports.command = 'marketplace-validate <
|
|
11
|
+
exports.command = 'marketplace-validate <path>';
|
|
12
12
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
13
|
exports.handler = async (options) => {
|
|
14
|
-
const {
|
|
14
|
+
const { path, derivedAccountId } = options;
|
|
15
15
|
await loadAndValidateOptions(options);
|
|
16
|
-
|
|
17
|
-
trackCommandUsage('validate', null, accountId);
|
|
16
|
+
trackCommandUsage('validate', null, derivedAccountId);
|
|
18
17
|
SpinniesManager.init();
|
|
19
18
|
SpinniesManager.add('marketplaceValidation', {
|
|
20
19
|
text: i18n(`${i18nKey}.logs.validatingTheme`, {
|
|
21
|
-
path
|
|
20
|
+
path,
|
|
22
21
|
}),
|
|
23
22
|
});
|
|
24
23
|
const assetType = 'THEME';
|
|
25
|
-
const validationId = await kickOffValidation(
|
|
26
|
-
await pollForValidationFinish(
|
|
24
|
+
const validationId = await kickOffValidation(derivedAccountId, assetType, path);
|
|
25
|
+
await pollForValidationFinish(derivedAccountId, validationId);
|
|
27
26
|
SpinniesManager.remove('marketplaceValidation');
|
|
28
|
-
const validationResults = await fetchValidationResults(
|
|
27
|
+
const validationResults = await fetchValidationResults(derivedAccountId, validationId);
|
|
29
28
|
processValidationErrors(i18nKey, validationResults);
|
|
30
29
|
displayValidationResults(i18nKey, validationResults);
|
|
31
30
|
process.exit();
|
|
@@ -34,8 +33,8 @@ exports.builder = yargs => {
|
|
|
34
33
|
addConfigOptions(yargs);
|
|
35
34
|
addAccountOptions(yargs);
|
|
36
35
|
addUseEnvironmentOptions(yargs);
|
|
37
|
-
yargs.positional('
|
|
38
|
-
describe: i18n(`${i18nKey}.positionals.
|
|
36
|
+
yargs.positional('path', {
|
|
37
|
+
describe: i18n(`${i18nKey}.positionals.path.describe`),
|
|
39
38
|
type: 'string',
|
|
40
39
|
});
|
|
41
40
|
return yargs;
|
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const { i18n } = require('../../lib/lang');
|
|
7
7
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
|
-
const { addAccountOptions, addConfigOptions
|
|
8
|
+
const { addAccountOptions, addConfigOptions } = require('../../lib/commonOpts');
|
|
9
9
|
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
10
10
|
const { getUploadableFileList } = require('../../lib/upload');
|
|
11
11
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
@@ -90,9 +90,8 @@ const determineSrcAndDest = async (options) => {
|
|
|
90
90
|
return { absoluteSrc, dest };
|
|
91
91
|
};
|
|
92
92
|
exports.handler = async (options) => {
|
|
93
|
-
const { notify, noSsl, resetSession, port, generateFieldsTypes } = options;
|
|
93
|
+
const { derivedAccountId, notify, noSsl, resetSession, port, generateFieldsTypes, } = options;
|
|
94
94
|
await loadAndValidateOptions(options);
|
|
95
|
-
const accountId = getAccountId(options);
|
|
96
95
|
const { absoluteSrc, dest } = await determineSrcAndDest(options);
|
|
97
96
|
const filePaths = await getUploadableFileList(absoluteSrc, false);
|
|
98
97
|
const startProgressBar = numFiles => {
|
|
@@ -134,7 +133,7 @@ exports.handler = async (options) => {
|
|
|
134
133
|
if (result.resultType == FILE_UPLOAD_RESULT_TYPES.FAILURE) {
|
|
135
134
|
logger.error('Uploading file "%s" to "%s" failed', result.file, dest);
|
|
136
135
|
logError(result.error, new ApiErrorContext({
|
|
137
|
-
accountId,
|
|
136
|
+
accountId: derivedAccountId,
|
|
138
137
|
request: dest,
|
|
139
138
|
payload: result.file,
|
|
140
139
|
}));
|
|
@@ -144,7 +143,7 @@ exports.handler = async (options) => {
|
|
|
144
143
|
};
|
|
145
144
|
return uploadOptions;
|
|
146
145
|
};
|
|
147
|
-
trackCommandUsage('preview',
|
|
146
|
+
trackCommandUsage('preview', derivedAccountId);
|
|
148
147
|
let createUnifiedDevServer;
|
|
149
148
|
try {
|
|
150
149
|
require.resolve('@hubspot/cms-dev-server');
|
|
@@ -154,7 +153,7 @@ exports.handler = async (options) => {
|
|
|
154
153
|
catch (e) {
|
|
155
154
|
logger.warn('Unified dev server requires node 20 to run. Defaulting to legacy preview.');
|
|
156
155
|
}
|
|
157
|
-
const isUngatedForUnified = await hasFeature(
|
|
156
|
+
const isUngatedForUnified = await hasFeature(derivedAccountId, 'cms:react:unifiedThemePreview');
|
|
158
157
|
if (isUngatedForUnified && createUnifiedDevServer) {
|
|
159
158
|
if (port) {
|
|
160
159
|
process.env['PORT'] = port;
|
|
@@ -168,7 +167,7 @@ exports.handler = async (options) => {
|
|
|
168
167
|
});
|
|
169
168
|
}
|
|
170
169
|
else {
|
|
171
|
-
preview(
|
|
170
|
+
preview(derivedAccountId, absoluteSrc, dest, {
|
|
172
171
|
notify,
|
|
173
172
|
filePaths,
|
|
174
173
|
noSsl,
|
package/commands/theme.js
CHANGED
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const marketplaceValidate = require('./theme/marketplace-validate');
|
|
5
5
|
const generateSelectors = require('./theme/generate-selectors');
|
|
6
6
|
const previewCommand = require('./theme/preview');
|
|
7
|
+
const { addGlobalOptions } = require('../lib/commonOpts');
|
|
7
8
|
const { i18n } = require('../lib/lang');
|
|
8
9
|
const i18nKey = 'commands.theme';
|
|
9
|
-
exports.command = 'theme';
|
|
10
|
+
exports.command = ['theme', 'themes'];
|
|
10
11
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
11
12
|
exports.builder = yargs => {
|
|
13
|
+
addGlobalOptions(yargs);
|
|
12
14
|
yargs
|
|
13
15
|
.command(previewCommand)
|
|
14
16
|
.command(marketplaceValidate)
|
package/commands/upload.js
CHANGED
|
@@ -12,17 +12,17 @@ const { ApiErrorContext, logError } = require('../lib/errorHandlers/index');
|
|
|
12
12
|
const { validateSrcAndDestPaths, } = require('@hubspot/local-dev-lib/cms/modules');
|
|
13
13
|
const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
|
|
14
14
|
const { getThemePreviewUrl, getThemeJSONPath, } = require('@hubspot/local-dev-lib/cms/themes');
|
|
15
|
-
const { addConfigOptions, addAccountOptions,
|
|
15
|
+
const { addConfigOptions, addAccountOptions, addCmsPublishModeOptions, addUseEnvironmentOptions, addGlobalOptions, getCmsPublishMode, } = require('../lib/commonOpts');
|
|
16
16
|
const { uploadPrompt } = require('../lib/prompts/uploadPrompt');
|
|
17
17
|
const { cleanUploadPrompt } = require('../lib/prompts/cleanUploadPrompt');
|
|
18
|
-
const {
|
|
18
|
+
const { validateCmsPublishMode, loadAndValidateOptions, } = require('../lib/validation');
|
|
19
19
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
20
20
|
const { getUploadableFileList } = require('../lib/upload');
|
|
21
21
|
const { i18n } = require('../lib/lang');
|
|
22
22
|
const i18nKey = 'commands.upload';
|
|
23
23
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
24
24
|
const { FieldsJs, isConvertableFieldJs, cleanupTmpDirSync, } = require('@hubspot/local-dev-lib/cms/handleFieldsJS');
|
|
25
|
-
exports.command = 'upload [
|
|
25
|
+
exports.command = 'upload [src] [dest]';
|
|
26
26
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
27
27
|
const logThemePreview = (filePath, accountId) => {
|
|
28
28
|
const previewUrl = getThemePreviewUrl(filePath, accountId);
|
|
@@ -35,11 +35,11 @@ const logThemePreview = (filePath, accountId) => {
|
|
|
35
35
|
};
|
|
36
36
|
exports.handler = async (options) => {
|
|
37
37
|
await loadAndValidateOptions(options);
|
|
38
|
-
if (!
|
|
38
|
+
if (!validateCmsPublishMode(options)) {
|
|
39
39
|
process.exit(EXIT_CODES.WARNING);
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
const
|
|
41
|
+
const { derivedAccountId } = options;
|
|
42
|
+
const cmsPublishMode = getCmsPublishMode(options);
|
|
43
43
|
const uploadPromptAnswers = await uploadPrompt(options);
|
|
44
44
|
const src = options.src || uploadPromptAnswers.src;
|
|
45
45
|
const saveOutput = options.saveOutput;
|
|
@@ -82,7 +82,7 @@ exports.handler = async (options) => {
|
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
const normalizedDest = convertToUnixPath(dest);
|
|
85
|
-
trackCommandUsage('upload', { mode, type: stats.isFile() ? 'file' : 'folder' },
|
|
85
|
+
trackCommandUsage('upload', { mode: cmsPublishMode, type: stats.isFile() ? 'file' : 'folder' }, derivedAccountId);
|
|
86
86
|
const srcDestIssues = await validateSrcAndDestPaths({ isLocal: true, path: src }, { isHubSpot: true, path: dest });
|
|
87
87
|
if (srcDestIssues.length) {
|
|
88
88
|
srcDestIssues.forEach(({ message }) => logger.error(message));
|
|
@@ -101,14 +101,14 @@ exports.handler = async (options) => {
|
|
|
101
101
|
}));
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
upload(
|
|
104
|
+
upload(derivedAccountId, absoluteSrcPath, normalizedDest, getFileMapperQueryValues(cmsPublishMode, options))
|
|
105
105
|
.then(() => {
|
|
106
106
|
logger.success(i18n(`${i18nKey}.success.fileUploaded`, {
|
|
107
|
-
accountId,
|
|
107
|
+
accountId: derivedAccountId,
|
|
108
108
|
dest: normalizedDest,
|
|
109
109
|
src,
|
|
110
110
|
}));
|
|
111
|
-
logThemePreview(src,
|
|
111
|
+
logThemePreview(src, derivedAccountId);
|
|
112
112
|
})
|
|
113
113
|
.catch(error => {
|
|
114
114
|
logger.error(i18n(`${i18nKey}.errors.uploadFailed`, {
|
|
@@ -116,7 +116,7 @@ exports.handler = async (options) => {
|
|
|
116
116
|
src,
|
|
117
117
|
}));
|
|
118
118
|
logError(error, new ApiErrorContext({
|
|
119
|
-
accountId,
|
|
119
|
+
accountId: derivedAccountId,
|
|
120
120
|
request: normalizedDest,
|
|
121
121
|
payload: src,
|
|
122
122
|
}));
|
|
@@ -133,7 +133,7 @@ exports.handler = async (options) => {
|
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
135
|
logger.log(i18n(`${i18nKey}.uploading`, {
|
|
136
|
-
accountId,
|
|
136
|
+
accountId: derivedAccountId,
|
|
137
137
|
dest,
|
|
138
138
|
src,
|
|
139
139
|
}));
|
|
@@ -143,30 +143,33 @@ exports.handler = async (options) => {
|
|
|
143
143
|
// If clean is true, will first delete the dest folder and then upload src. Cleans up files that only exist on HS.
|
|
144
144
|
let cleanUpload = options.force;
|
|
145
145
|
if (!options.force) {
|
|
146
|
-
cleanUpload = await cleanUploadPrompt(
|
|
146
|
+
cleanUpload = await cleanUploadPrompt(derivedAccountId, dest);
|
|
147
147
|
}
|
|
148
148
|
if (cleanUpload) {
|
|
149
149
|
try {
|
|
150
|
-
await deleteFile(
|
|
151
|
-
logger.log(i18n(`${i18nKey}.cleaning`, {
|
|
150
|
+
await deleteFile(derivedAccountId, dest);
|
|
151
|
+
logger.log(i18n(`${i18nKey}.cleaning`, {
|
|
152
|
+
accountId: derivedAccountId,
|
|
153
|
+
filePath: dest,
|
|
154
|
+
}));
|
|
152
155
|
}
|
|
153
156
|
catch (error) {
|
|
154
157
|
logger.error(i18n(`${i18nKey}.errors.deleteFailed`, {
|
|
155
|
-
accountId,
|
|
158
|
+
accountId: derivedAccountId,
|
|
156
159
|
path: dest,
|
|
157
160
|
}));
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
|
-
uploadFolder(
|
|
162
|
-
|
|
164
|
+
uploadFolder(derivedAccountId, absoluteSrcPath, dest, {
|
|
165
|
+
cmsPublishMode,
|
|
163
166
|
}, options, filePaths)
|
|
164
167
|
.then(results => {
|
|
165
168
|
if (!hasUploadErrors(results)) {
|
|
166
169
|
logger.success(i18n(`${i18nKey}.success.uploadComplete`, {
|
|
167
170
|
dest,
|
|
168
171
|
}));
|
|
169
|
-
logThemePreview(src,
|
|
172
|
+
logThemePreview(src, derivedAccountId);
|
|
170
173
|
}
|
|
171
174
|
else {
|
|
172
175
|
logger.error(i18n(`${i18nKey}.errors.someFilesFailed`, {
|
|
@@ -181,17 +184,13 @@ exports.handler = async (options) => {
|
|
|
181
184
|
src,
|
|
182
185
|
}));
|
|
183
186
|
logError(error, {
|
|
184
|
-
accountId,
|
|
187
|
+
accountId: derivedAccountId,
|
|
185
188
|
});
|
|
186
189
|
process.exit(EXIT_CODES.WARNING);
|
|
187
190
|
});
|
|
188
191
|
}
|
|
189
192
|
};
|
|
190
193
|
exports.builder = yargs => {
|
|
191
|
-
addConfigOptions(yargs);
|
|
192
|
-
addAccountOptions(yargs);
|
|
193
|
-
addModeOptions(yargs, { write: true });
|
|
194
|
-
addUseEnvironmentOptions(yargs);
|
|
195
194
|
yargs.positional('src', {
|
|
196
195
|
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
197
196
|
type: 'string',
|
|
@@ -226,5 +225,10 @@ exports.builder = yargs => {
|
|
|
226
225
|
type: 'boolean',
|
|
227
226
|
default: false,
|
|
228
227
|
});
|
|
228
|
+
addConfigOptions(yargs);
|
|
229
|
+
addAccountOptions(yargs);
|
|
230
|
+
addCmsPublishModeOptions(yargs, { write: true });
|
|
231
|
+
addUseEnvironmentOptions(yargs);
|
|
232
|
+
addGlobalOptions(yargs);
|
|
229
233
|
return yargs;
|
|
230
234
|
};
|