@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
|
@@ -1,28 +1,36 @@
|
|
|
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 { loadAndValidateOptions } = require('../../lib/validation');
|
|
7
|
+
const { updateSecret, fetchSecrets, } = require('@hubspot/local-dev-lib/api/secrets');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
9
|
const { uiAccountDescription } = require('../../lib/ui');
|
|
10
|
-
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions,
|
|
11
|
-
const { secretValuePrompt } = require('../../lib/prompts/secretPrompt');
|
|
10
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
11
|
+
const { secretValuePrompt, secretListPrompt, } = require('../../lib/prompts/secretPrompt');
|
|
12
12
|
const { i18n } = require('../../lib/lang');
|
|
13
|
-
const i18nKey = 'commands.
|
|
14
|
-
exports.command = 'update
|
|
13
|
+
const i18nKey = 'commands.secret.subcommands.update';
|
|
14
|
+
exports.command = 'update [name]';
|
|
15
15
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
16
16
|
exports.handler = async (options) => {
|
|
17
|
-
const { name
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
trackCommandUsage('secrets-update', null, accountId);
|
|
17
|
+
const { name, derivedAccountId } = options;
|
|
18
|
+
let secretName = name;
|
|
19
|
+
trackCommandUsage('secrets-update', null, derivedAccountId);
|
|
21
20
|
try {
|
|
21
|
+
const { data: { results: secrets }, } = await fetchSecrets(derivedAccountId);
|
|
22
|
+
if (secretName && !secrets.includes(secretName)) {
|
|
23
|
+
logger.error(i18n(`${i18nKey}.errors.noSecret`, { secretName }));
|
|
24
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
25
|
+
}
|
|
26
|
+
if (!secretName) {
|
|
27
|
+
const { secretToModify } = await secretListPrompt(secrets, i18n(`${i18nKey}.selectSecret`));
|
|
28
|
+
secretName = secretToModify;
|
|
29
|
+
}
|
|
22
30
|
const { secretValue } = await secretValuePrompt();
|
|
23
|
-
await updateSecret(
|
|
31
|
+
await updateSecret(derivedAccountId, secretName, secretValue);
|
|
24
32
|
logger.success(i18n(`${i18nKey}.success.update`, {
|
|
25
|
-
accountIdentifier: uiAccountDescription(
|
|
33
|
+
accountIdentifier: uiAccountDescription(derivedAccountId),
|
|
26
34
|
secretName,
|
|
27
35
|
}));
|
|
28
36
|
logger.log(i18n(`${i18nKey}.success.updateExplanation`));
|
|
@@ -33,7 +41,7 @@ exports.handler = async (options) => {
|
|
|
33
41
|
}));
|
|
34
42
|
logError(err, new ApiErrorContext({
|
|
35
43
|
request: 'update secret',
|
|
36
|
-
accountId,
|
|
44
|
+
accountId: derivedAccountId,
|
|
37
45
|
}));
|
|
38
46
|
}
|
|
39
47
|
};
|
|
@@ -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,27 @@
|
|
|
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,
|
|
6
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
5
|
+
const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
7
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
8
7
|
const { kickOffValidation, pollForValidationFinish, fetchValidationResults, processValidationErrors, displayValidationResults, } = require('../../lib/marketplaceValidate');
|
|
9
8
|
const { i18n } = require('../../lib/lang');
|
|
10
9
|
const i18nKey = 'commands.theme.subcommands.marketplaceValidate';
|
|
11
|
-
exports.command = 'marketplace-validate <
|
|
10
|
+
exports.command = 'marketplace-validate <path>';
|
|
12
11
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
12
|
exports.handler = async (options) => {
|
|
14
|
-
const {
|
|
15
|
-
|
|
16
|
-
const accountId = getAccountId(options);
|
|
17
|
-
trackCommandUsage('validate', null, accountId);
|
|
13
|
+
const { path, derivedAccountId } = options;
|
|
14
|
+
trackCommandUsage('validate', null, derivedAccountId);
|
|
18
15
|
SpinniesManager.init();
|
|
19
16
|
SpinniesManager.add('marketplaceValidation', {
|
|
20
17
|
text: i18n(`${i18nKey}.logs.validatingTheme`, {
|
|
21
|
-
path
|
|
18
|
+
path,
|
|
22
19
|
}),
|
|
23
20
|
});
|
|
24
21
|
const assetType = 'THEME';
|
|
25
|
-
const validationId = await kickOffValidation(
|
|
26
|
-
await pollForValidationFinish(
|
|
22
|
+
const validationId = await kickOffValidation(derivedAccountId, assetType, path);
|
|
23
|
+
await pollForValidationFinish(derivedAccountId, validationId);
|
|
27
24
|
SpinniesManager.remove('marketplaceValidation');
|
|
28
|
-
const validationResults = await fetchValidationResults(
|
|
25
|
+
const validationResults = await fetchValidationResults(derivedAccountId, validationId);
|
|
29
26
|
processValidationErrors(i18nKey, validationResults);
|
|
30
27
|
displayValidationResults(i18nKey, validationResults);
|
|
31
28
|
process.exit();
|
|
@@ -34,8 +31,8 @@ exports.builder = yargs => {
|
|
|
34
31
|
addConfigOptions(yargs);
|
|
35
32
|
addAccountOptions(yargs);
|
|
36
33
|
addUseEnvironmentOptions(yargs);
|
|
37
|
-
yargs.positional('
|
|
38
|
-
describe: i18n(`${i18nKey}.positionals.
|
|
34
|
+
yargs.positional('path', {
|
|
35
|
+
describe: i18n(`${i18nKey}.positionals.path.describe`),
|
|
39
36
|
type: 'string',
|
|
40
37
|
});
|
|
41
38
|
return yargs;
|
|
@@ -5,11 +5,10 @@ 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');
|
|
12
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
13
12
|
const { previewPrompt, previewProjectPrompt, } = require('../../lib/prompts/previewPrompt');
|
|
14
13
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
15
14
|
const { FILE_UPLOAD_RESULT_TYPES, } = require('@hubspot/local-dev-lib/constants/files');
|
|
@@ -18,7 +17,7 @@ const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
|
18
17
|
const { handleExit, handleKeypress } = require('../../lib/process');
|
|
19
18
|
const { getThemeJSONPath } = require('@hubspot/local-dev-lib/cms/themes');
|
|
20
19
|
const { getProjectConfig } = require('../../lib/projects');
|
|
21
|
-
const { findProjectComponents, COMPONENT_TYPES, } = require('../../lib/
|
|
20
|
+
const { findProjectComponents, COMPONENT_TYPES, } = require('../../lib/projects/structure');
|
|
22
21
|
const { preview } = require('@hubspot/theme-preview-dev-server');
|
|
23
22
|
const { hasFeature } = require('../../lib/hasFeature');
|
|
24
23
|
const i18nKey = 'commands.theme.subcommands.preview';
|
|
@@ -90,9 +89,7 @@ const determineSrcAndDest = async (options) => {
|
|
|
90
89
|
return { absoluteSrc, dest };
|
|
91
90
|
};
|
|
92
91
|
exports.handler = async (options) => {
|
|
93
|
-
const { notify, noSsl, resetSession, port, generateFieldsTypes } = options;
|
|
94
|
-
await loadAndValidateOptions(options);
|
|
95
|
-
const accountId = getAccountId(options);
|
|
92
|
+
const { derivedAccountId, notify, noSsl, resetSession, port, generateFieldsTypes, } = options;
|
|
96
93
|
const { absoluteSrc, dest } = await determineSrcAndDest(options);
|
|
97
94
|
const filePaths = await getUploadableFileList(absoluteSrc, false);
|
|
98
95
|
const startProgressBar = numFiles => {
|
|
@@ -134,7 +131,7 @@ exports.handler = async (options) => {
|
|
|
134
131
|
if (result.resultType == FILE_UPLOAD_RESULT_TYPES.FAILURE) {
|
|
135
132
|
logger.error('Uploading file "%s" to "%s" failed', result.file, dest);
|
|
136
133
|
logError(result.error, new ApiErrorContext({
|
|
137
|
-
accountId,
|
|
134
|
+
accountId: derivedAccountId,
|
|
138
135
|
request: dest,
|
|
139
136
|
payload: result.file,
|
|
140
137
|
}));
|
|
@@ -144,7 +141,7 @@ exports.handler = async (options) => {
|
|
|
144
141
|
};
|
|
145
142
|
return uploadOptions;
|
|
146
143
|
};
|
|
147
|
-
trackCommandUsage('preview',
|
|
144
|
+
trackCommandUsage('preview', derivedAccountId);
|
|
148
145
|
let createUnifiedDevServer;
|
|
149
146
|
try {
|
|
150
147
|
require.resolve('@hubspot/cms-dev-server');
|
|
@@ -154,7 +151,7 @@ exports.handler = async (options) => {
|
|
|
154
151
|
catch (e) {
|
|
155
152
|
logger.warn('Unified dev server requires node 20 to run. Defaulting to legacy preview.');
|
|
156
153
|
}
|
|
157
|
-
const isUngatedForUnified = await hasFeature(
|
|
154
|
+
const isUngatedForUnified = await hasFeature(derivedAccountId, 'cms:react:unifiedThemePreview');
|
|
158
155
|
if (isUngatedForUnified && createUnifiedDevServer) {
|
|
159
156
|
if (port) {
|
|
160
157
|
process.env['PORT'] = port;
|
|
@@ -168,7 +165,7 @@ exports.handler = async (options) => {
|
|
|
168
165
|
});
|
|
169
166
|
}
|
|
170
167
|
else {
|
|
171
|
-
preview(
|
|
168
|
+
preview(derivedAccountId, absoluteSrc, dest, {
|
|
172
169
|
notify,
|
|
173
170
|
filePaths,
|
|
174
171
|
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
|
-
const {
|
|
18
|
-
const {
|
|
17
|
+
const { confirmPrompt } = require('../lib/prompts/promptUtils');
|
|
18
|
+
const { validateCmsPublishMode } = 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);
|
|
@@ -34,12 +34,11 @@ const logThemePreview = (filePath, accountId) => {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
exports.handler = async (options) => {
|
|
37
|
-
|
|
38
|
-
if (!validateMode(options)) {
|
|
37
|
+
if (!validateCmsPublishMode(options)) {
|
|
39
38
|
process.exit(EXIT_CODES.WARNING);
|
|
40
39
|
}
|
|
41
|
-
const
|
|
42
|
-
const
|
|
40
|
+
const { derivedAccountId } = options;
|
|
41
|
+
const cmsPublishMode = getCmsPublishMode(options);
|
|
43
42
|
const uploadPromptAnswers = await uploadPrompt(options);
|
|
44
43
|
const src = options.src || uploadPromptAnswers.src;
|
|
45
44
|
const saveOutput = options.saveOutput;
|
|
@@ -82,7 +81,7 @@ exports.handler = async (options) => {
|
|
|
82
81
|
return;
|
|
83
82
|
}
|
|
84
83
|
const normalizedDest = convertToUnixPath(dest);
|
|
85
|
-
trackCommandUsage('upload', { mode, type: stats.isFile() ? 'file' : 'folder' },
|
|
84
|
+
trackCommandUsage('upload', { mode: cmsPublishMode, type: stats.isFile() ? 'file' : 'folder' }, derivedAccountId);
|
|
86
85
|
const srcDestIssues = await validateSrcAndDestPaths({ isLocal: true, path: src }, { isHubSpot: true, path: dest });
|
|
87
86
|
if (srcDestIssues.length) {
|
|
88
87
|
srcDestIssues.forEach(({ message }) => logger.error(message));
|
|
@@ -101,14 +100,14 @@ exports.handler = async (options) => {
|
|
|
101
100
|
}));
|
|
102
101
|
return;
|
|
103
102
|
}
|
|
104
|
-
upload(
|
|
103
|
+
upload(derivedAccountId, absoluteSrcPath, normalizedDest, getFileMapperQueryValues(cmsPublishMode, options))
|
|
105
104
|
.then(() => {
|
|
106
105
|
logger.success(i18n(`${i18nKey}.success.fileUploaded`, {
|
|
107
|
-
accountId,
|
|
106
|
+
accountId: derivedAccountId,
|
|
108
107
|
dest: normalizedDest,
|
|
109
108
|
src,
|
|
110
109
|
}));
|
|
111
|
-
logThemePreview(src,
|
|
110
|
+
logThemePreview(src, derivedAccountId);
|
|
112
111
|
})
|
|
113
112
|
.catch(error => {
|
|
114
113
|
logger.error(i18n(`${i18nKey}.errors.uploadFailed`, {
|
|
@@ -116,7 +115,7 @@ exports.handler = async (options) => {
|
|
|
116
115
|
src,
|
|
117
116
|
}));
|
|
118
117
|
logError(error, new ApiErrorContext({
|
|
119
|
-
accountId,
|
|
118
|
+
accountId: derivedAccountId,
|
|
120
119
|
request: normalizedDest,
|
|
121
120
|
payload: src,
|
|
122
121
|
}));
|
|
@@ -133,7 +132,7 @@ exports.handler = async (options) => {
|
|
|
133
132
|
}
|
|
134
133
|
else {
|
|
135
134
|
logger.log(i18n(`${i18nKey}.uploading`, {
|
|
136
|
-
accountId,
|
|
135
|
+
accountId: derivedAccountId,
|
|
137
136
|
dest,
|
|
138
137
|
src,
|
|
139
138
|
}));
|
|
@@ -143,30 +142,36 @@ exports.handler = async (options) => {
|
|
|
143
142
|
// If clean is true, will first delete the dest folder and then upload src. Cleans up files that only exist on HS.
|
|
144
143
|
let cleanUpload = options.force;
|
|
145
144
|
if (!options.force) {
|
|
146
|
-
cleanUpload = await
|
|
145
|
+
cleanUpload = await confirmPrompt(i18n(`${i18nKey}.confirmCleanUpload`, {
|
|
146
|
+
accountId: derivedAccountId,
|
|
147
|
+
path: dest,
|
|
148
|
+
}), { defaultAnswer: false });
|
|
147
149
|
}
|
|
148
150
|
if (cleanUpload) {
|
|
149
151
|
try {
|
|
150
|
-
await deleteFile(
|
|
151
|
-
logger.log(i18n(`${i18nKey}.cleaning`, {
|
|
152
|
+
await deleteFile(derivedAccountId, dest);
|
|
153
|
+
logger.log(i18n(`${i18nKey}.cleaning`, {
|
|
154
|
+
accountId: derivedAccountId,
|
|
155
|
+
filePath: dest,
|
|
156
|
+
}));
|
|
152
157
|
}
|
|
153
158
|
catch (error) {
|
|
154
159
|
logger.error(i18n(`${i18nKey}.errors.deleteFailed`, {
|
|
155
|
-
accountId,
|
|
160
|
+
accountId: derivedAccountId,
|
|
156
161
|
path: dest,
|
|
157
162
|
}));
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
}
|
|
161
|
-
uploadFolder(
|
|
162
|
-
|
|
166
|
+
uploadFolder(derivedAccountId, absoluteSrcPath, dest, {
|
|
167
|
+
cmsPublishMode,
|
|
163
168
|
}, options, filePaths)
|
|
164
169
|
.then(results => {
|
|
165
170
|
if (!hasUploadErrors(results)) {
|
|
166
171
|
logger.success(i18n(`${i18nKey}.success.uploadComplete`, {
|
|
167
172
|
dest,
|
|
168
173
|
}));
|
|
169
|
-
logThemePreview(src,
|
|
174
|
+
logThemePreview(src, derivedAccountId);
|
|
170
175
|
}
|
|
171
176
|
else {
|
|
172
177
|
logger.error(i18n(`${i18nKey}.errors.someFilesFailed`, {
|
|
@@ -181,17 +186,13 @@ exports.handler = async (options) => {
|
|
|
181
186
|
src,
|
|
182
187
|
}));
|
|
183
188
|
logError(error, {
|
|
184
|
-
accountId,
|
|
189
|
+
accountId: derivedAccountId,
|
|
185
190
|
});
|
|
186
191
|
process.exit(EXIT_CODES.WARNING);
|
|
187
192
|
});
|
|
188
193
|
}
|
|
189
194
|
};
|
|
190
195
|
exports.builder = yargs => {
|
|
191
|
-
addConfigOptions(yargs);
|
|
192
|
-
addAccountOptions(yargs);
|
|
193
|
-
addModeOptions(yargs, { write: true });
|
|
194
|
-
addUseEnvironmentOptions(yargs);
|
|
195
196
|
yargs.positional('src', {
|
|
196
197
|
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
197
198
|
type: 'string',
|
|
@@ -226,5 +227,10 @@ exports.builder = yargs => {
|
|
|
226
227
|
type: 'boolean',
|
|
227
228
|
default: false,
|
|
228
229
|
});
|
|
230
|
+
addConfigOptions(yargs);
|
|
231
|
+
addAccountOptions(yargs);
|
|
232
|
+
addCmsPublishModeOptions(yargs, { write: true });
|
|
233
|
+
addUseEnvironmentOptions(yargs);
|
|
234
|
+
addGlobalOptions(yargs);
|
|
229
235
|
return yargs;
|
|
230
236
|
};
|
package/commands/watch.js
CHANGED
|
@@ -6,25 +6,23 @@ const path = require('path');
|
|
|
6
6
|
const { watch } = require('@hubspot/local-dev-lib/cms/watch');
|
|
7
7
|
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
8
8
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
9
|
-
const { addConfigOptions, addAccountOptions,
|
|
9
|
+
const { addConfigOptions, addAccountOptions, addCmsPublishModeOptions, addUseEnvironmentOptions, addGlobalOptions, getCmsPublishMode, } = require('../lib/commonOpts');
|
|
10
10
|
const { uploadPrompt } = require('../lib/prompts/uploadPrompt');
|
|
11
|
-
const {
|
|
11
|
+
const { validateCmsPublishMode } = require('../lib/validation');
|
|
12
12
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
13
13
|
const { i18n } = require('../lib/lang');
|
|
14
14
|
const { getUploadableFileList } = require('../lib/upload');
|
|
15
15
|
const { logError, ApiErrorContext } = require('../lib/errorHandlers/index');
|
|
16
16
|
const i18nKey = 'commands.watch';
|
|
17
17
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
18
|
-
exports.command = 'watch [
|
|
18
|
+
exports.command = 'watch [src] [dest]';
|
|
19
19
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
20
20
|
exports.handler = async (options) => {
|
|
21
|
-
const { remove, initialUpload, disableInitial, notify } = options;
|
|
22
|
-
|
|
23
|
-
if (!validateMode(options)) {
|
|
21
|
+
const { remove, initialUpload, disableInitial, notify, derivedAccountId } = options;
|
|
22
|
+
if (!validateCmsPublishMode(options)) {
|
|
24
23
|
process.exit(EXIT_CODES.ERROR);
|
|
25
24
|
}
|
|
26
|
-
const
|
|
27
|
-
const mode = getMode(options);
|
|
25
|
+
const cmsPublishMode = getCmsPublishMode(options);
|
|
28
26
|
const uploadPromptAnswers = await uploadPrompt(options);
|
|
29
27
|
const src = options.src || uploadPromptAnswers.src;
|
|
30
28
|
const dest = options.dest || uploadPromptAnswers.dest;
|
|
@@ -59,33 +57,33 @@ exports.handler = async (options) => {
|
|
|
59
57
|
if (initialUpload) {
|
|
60
58
|
filesToUpload = await getUploadableFileList(absoluteSrcPath, options.convertFields);
|
|
61
59
|
}
|
|
62
|
-
trackCommandUsage('watch', { mode },
|
|
60
|
+
trackCommandUsage('watch', { mode: cmsPublishMode }, derivedAccountId);
|
|
63
61
|
const postInitialUploadCallback = null;
|
|
64
62
|
const onUploadFolderError = error => {
|
|
65
63
|
logger.error(i18n(`${i18nKey}.errors.folderFailed`, {
|
|
66
64
|
src,
|
|
67
65
|
dest,
|
|
68
|
-
accountId,
|
|
66
|
+
accountId: derivedAccountId,
|
|
69
67
|
}));
|
|
70
68
|
logError(error, {
|
|
71
|
-
accountId,
|
|
69
|
+
accountId: derivedAccountId,
|
|
72
70
|
});
|
|
73
71
|
};
|
|
74
72
|
const onQueueAddError = null;
|
|
75
|
-
const onUploadFileError = (file, dest,
|
|
73
|
+
const onUploadFileError = (file, dest, derivedAccountId) => error => {
|
|
76
74
|
logger.error(i18n(`${i18nKey}.errors.fileFailed`, {
|
|
77
75
|
file,
|
|
78
76
|
dest,
|
|
79
|
-
accountId,
|
|
77
|
+
accountId: derivedAccountId,
|
|
80
78
|
}));
|
|
81
79
|
logError(error, new ApiErrorContext({
|
|
82
|
-
accountId,
|
|
80
|
+
accountId: derivedAccountId,
|
|
83
81
|
request: dest,
|
|
84
82
|
payload: file,
|
|
85
83
|
}));
|
|
86
84
|
};
|
|
87
|
-
watch(
|
|
88
|
-
|
|
85
|
+
watch(derivedAccountId, absoluteSrcPath, dest, {
|
|
86
|
+
cmsPublishMode,
|
|
89
87
|
remove,
|
|
90
88
|
disableInitial: initialUpload ? false : true,
|
|
91
89
|
notify,
|
|
@@ -94,10 +92,6 @@ exports.handler = async (options) => {
|
|
|
94
92
|
}, postInitialUploadCallback, onUploadFolderError, onQueueAddError, onUploadFileError);
|
|
95
93
|
};
|
|
96
94
|
exports.builder = yargs => {
|
|
97
|
-
addConfigOptions(yargs);
|
|
98
|
-
addAccountOptions(yargs);
|
|
99
|
-
addModeOptions(yargs, { write: true });
|
|
100
|
-
addUseEnvironmentOptions(yargs);
|
|
101
95
|
yargs.positional('src', {
|
|
102
96
|
describe: i18n(`${i18nKey}.positionals.src.describe`),
|
|
103
97
|
type: 'string',
|
|
@@ -143,5 +137,10 @@ exports.builder = yargs => {
|
|
|
143
137
|
type: 'boolean',
|
|
144
138
|
default: false,
|
|
145
139
|
});
|
|
140
|
+
addConfigOptions(yargs);
|
|
141
|
+
addAccountOptions(yargs);
|
|
142
|
+
addCmsPublishModeOptions(yargs, { write: true });
|
|
143
|
+
addUseEnvironmentOptions(yargs);
|
|
144
|
+
addGlobalOptions(yargs);
|
|
146
145
|
return yargs;
|
|
147
146
|
};
|