@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
package/commands/auth.js
CHANGED
|
@@ -8,13 +8,13 @@ const { ENVIRONMENTS, } = require('@hubspot/local-dev-lib/constants/environments
|
|
|
8
8
|
const { DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME, } = require('@hubspot/local-dev-lib/constants/config');
|
|
9
9
|
const { i18n } = require('../lib/lang');
|
|
10
10
|
const { getAccessToken, updateConfigWithAccessToken, } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
11
|
-
const { updateAccountConfig, writeConfig,
|
|
11
|
+
const { updateAccountConfig, writeConfig, getConfigPath, loadConfig, getConfigDefaultAccount, } = require('@hubspot/local-dev-lib/config');
|
|
12
12
|
const { commaSeparatedValues, toKebabCase, } = require('@hubspot/local-dev-lib/text');
|
|
13
13
|
const { promptUser } = require('../lib/prompts/promptUtils');
|
|
14
14
|
const { personalAccessKeyPrompt, OAUTH_FLOW, } = require('../lib/prompts/personalAccessKeyPrompt');
|
|
15
15
|
const { cliAccountNamePrompt } = require('../lib/prompts/accountNamePrompt');
|
|
16
16
|
const { setAsDefaultAccountPrompt, } = require('../lib/prompts/setAsDefaultAccountPrompt');
|
|
17
|
-
const { addConfigOptions, setLogLevel, getAccountId, addTestingOptions, } = require('../lib/commonOpts');
|
|
17
|
+
const { addConfigOptions, setLogLevel, getAccountId, addTestingOptions, addGlobalOptions, } = require('../lib/commonOpts');
|
|
18
18
|
const { trackAuthAction, trackCommandUsage } = require('../lib/usageTracking');
|
|
19
19
|
const { authenticateWithOauth } = require('../lib/oauth');
|
|
20
20
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
@@ -31,21 +31,23 @@ const ALLOWED_AUTH_METHODS = [
|
|
|
31
31
|
PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
32
32
|
];
|
|
33
33
|
const SUPPORTED_AUTHENTICATION_PROTOCOLS_TEXT = commaSeparatedValues(ALLOWED_AUTH_METHODS);
|
|
34
|
-
exports.command = 'auth
|
|
34
|
+
exports.command = 'auth';
|
|
35
35
|
exports.describe = i18n(`${i18nKey}.describe`, {
|
|
36
36
|
supportedProtocols: SUPPORTED_AUTHENTICATION_PROTOCOLS_TEXT,
|
|
37
37
|
});
|
|
38
38
|
exports.handler = async (options) => {
|
|
39
|
-
const {
|
|
40
|
-
const authType = (
|
|
39
|
+
const { authType: authTypeFlagValue, config: configFlagValue, qa, providedAccountId, } = options;
|
|
40
|
+
const authType = (authTypeFlagValue && authTypeFlagValue.toLowerCase()) ||
|
|
41
|
+
PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
41
42
|
setLogLevel(options);
|
|
42
|
-
|
|
43
|
+
const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
44
|
+
// Needed to load deprecated config
|
|
45
|
+
loadConfig(configFlagValue);
|
|
46
|
+
checkAndWarnGitInclusion(getConfigPath());
|
|
47
|
+
if (!getConfigPath(configFlagValue)) {
|
|
43
48
|
logger.error(i18n(`${i18nKey}.errors.noConfigFileFound`));
|
|
44
49
|
process.exit(EXIT_CODES.ERROR);
|
|
45
50
|
}
|
|
46
|
-
const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
47
|
-
loadConfig(c);
|
|
48
|
-
checkAndWarnGitInclusion(getConfigPath());
|
|
49
51
|
trackCommandUsage('auth');
|
|
50
52
|
trackAuthAction('auth', authType, TRACKING_STATUS.STARTED);
|
|
51
53
|
let configData;
|
|
@@ -64,7 +66,10 @@ exports.handler = async (options) => {
|
|
|
64
66
|
successAuthMethod = OAUTH_AUTH_METHOD.name;
|
|
65
67
|
break;
|
|
66
68
|
case PERSONAL_ACCESS_KEY_AUTH_METHOD.value:
|
|
67
|
-
configData = await personalAccessKeyPrompt({
|
|
69
|
+
configData = await personalAccessKeyPrompt({
|
|
70
|
+
env,
|
|
71
|
+
account: providedAccountId,
|
|
72
|
+
});
|
|
68
73
|
try {
|
|
69
74
|
token = await getAccessToken(configData.personalAccessKey, env);
|
|
70
75
|
defaultName = toKebabCase(token.hubName);
|
|
@@ -110,9 +115,8 @@ exports.handler = async (options) => {
|
|
|
110
115
|
}));
|
|
111
116
|
}
|
|
112
117
|
else {
|
|
113
|
-
const config = getConfig();
|
|
114
118
|
logger.info(i18n(`lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault`, {
|
|
115
|
-
accountName:
|
|
119
|
+
accountName: getConfigDefaultAccount(),
|
|
116
120
|
}));
|
|
117
121
|
}
|
|
118
122
|
logger.success(i18n(`${i18nKey}.success.configFileUpdated`, {
|
|
@@ -130,25 +134,27 @@ exports.handler = async (options) => {
|
|
|
130
134
|
process.exit(EXIT_CODES.SUCCESS);
|
|
131
135
|
};
|
|
132
136
|
exports.builder = yargs => {
|
|
133
|
-
yargs.positional('type', {
|
|
134
|
-
describe: i18n(`${i18nKey}.positionals.type.describe`),
|
|
135
|
-
type: 'string',
|
|
136
|
-
choices: [
|
|
137
|
-
`${PERSONAL_ACCESS_KEY_AUTH_METHOD.value}`,
|
|
138
|
-
`${OAUTH_AUTH_METHOD.value}`,
|
|
139
|
-
],
|
|
140
|
-
default: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
141
|
-
defaultDescription: i18n(`${i18nKey}.positionals.type.defaultDescription`, {
|
|
142
|
-
authMethod: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
143
|
-
}),
|
|
144
|
-
});
|
|
145
137
|
yargs.options({
|
|
138
|
+
'auth-type': {
|
|
139
|
+
describe: i18n(`${i18nKey}.options.authType.describe`),
|
|
140
|
+
type: 'string',
|
|
141
|
+
choices: [
|
|
142
|
+
`${PERSONAL_ACCESS_KEY_AUTH_METHOD.value}`,
|
|
143
|
+
`${OAUTH_AUTH_METHOD.value}`,
|
|
144
|
+
],
|
|
145
|
+
default: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
146
|
+
defaultDescription: i18n(`${i18nKey}.options.authType.defaultDescription`, {
|
|
147
|
+
authMethod: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
146
150
|
account: {
|
|
147
151
|
describe: i18n(`${i18nKey}.options.account.describe`),
|
|
148
152
|
type: 'string',
|
|
153
|
+
alias: 'a',
|
|
149
154
|
},
|
|
150
155
|
});
|
|
151
156
|
addConfigOptions(yargs);
|
|
152
157
|
addTestingOptions(yargs);
|
|
158
|
+
addGlobalOptions(yargs);
|
|
153
159
|
return yargs;
|
|
154
160
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
7
|
+
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
|
+
const { retrieveDefaultModule } = require('@hubspot/local-dev-lib/cms/modules');
|
|
9
|
+
const { i18n } = require('../../lib/lang');
|
|
10
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
11
|
+
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
12
|
+
const { listPrompt } = require('../../lib/prompts/promptUtils');
|
|
13
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
14
|
+
const i18nKey = 'commands.cms.subcommands.getReactModule';
|
|
15
|
+
exports.command = 'get-react-module [name] [dest]';
|
|
16
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
17
|
+
exports.handler = async (options) => {
|
|
18
|
+
const { name, dest } = options;
|
|
19
|
+
trackCommandUsage('get-react-modules');
|
|
20
|
+
let moduleToRetrieve = name;
|
|
21
|
+
if (!moduleToRetrieve) {
|
|
22
|
+
let availableModules;
|
|
23
|
+
try {
|
|
24
|
+
availableModules = await retrieveDefaultModule(null, '');
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
logError(e);
|
|
28
|
+
}
|
|
29
|
+
const moduleChoice = await listPrompt(i18n(`${i18nKey}.selectModulePrompt`), {
|
|
30
|
+
choices: availableModules.map(module => module.name),
|
|
31
|
+
});
|
|
32
|
+
moduleToRetrieve = moduleChoice;
|
|
33
|
+
}
|
|
34
|
+
const destPath = dest
|
|
35
|
+
? path.join(path.resolve(getCwd(), dest), `${moduleToRetrieve}`)
|
|
36
|
+
: path.join(getCwd(), `${moduleToRetrieve}`);
|
|
37
|
+
if (fs.existsSync(destPath)) {
|
|
38
|
+
logger.error(i18n(`${i18nKey}.errors.pathExists`, {
|
|
39
|
+
path: destPath,
|
|
40
|
+
}));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
await retrieveDefaultModule(moduleToRetrieve, destPath);
|
|
45
|
+
logger.success(i18n(`${i18nKey}.success.moduleDownloaded`, {
|
|
46
|
+
moduleName: moduleToRetrieve,
|
|
47
|
+
path: destPath,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
if (e.cause && e.cause.code === 'ERR_BAD_REQUEST') {
|
|
52
|
+
logger.error(i18n(`${i18nKey}.errors.invalidName`));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
logError(e);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
59
|
+
};
|
|
60
|
+
exports.builder = yargs => {
|
|
61
|
+
yargs.positional('name', {
|
|
62
|
+
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
63
|
+
type: 'string',
|
|
64
|
+
});
|
|
65
|
+
yargs.positional('dest', {
|
|
66
|
+
describe: i18n(`${i18nKey}.positionals.dest.describe`),
|
|
67
|
+
type: 'string',
|
|
68
|
+
});
|
|
69
|
+
return yargs;
|
|
70
|
+
};
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
5
|
-
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions,
|
|
5
|
+
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, } = require('../../lib/commonOpts');
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const { getTableContents, getTableHeader } = require('../../lib/ui/table');
|
|
8
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
8
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
10
9
|
const { i18n } = require('../../lib/lang');
|
|
11
10
|
const { fetchThemes } = require('@hubspot/local-dev-lib/api/designManager');
|
|
@@ -53,15 +52,14 @@ const selectTheme = async (accountId) => {
|
|
|
53
52
|
return selectedTheme;
|
|
54
53
|
};
|
|
55
54
|
exports.handler = async (options) => {
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
let themeToCheck = options.theme;
|
|
55
|
+
const { target, verbose, theme, derivedAccountId } = options;
|
|
56
|
+
const includeDesktopScore = target === 'desktop' || !verbose;
|
|
57
|
+
const includeMobileScore = target === 'mobile' || !verbose;
|
|
58
|
+
let themeToCheck = theme;
|
|
61
59
|
if (themeToCheck) {
|
|
62
60
|
let isValidTheme = true;
|
|
63
61
|
try {
|
|
64
|
-
const { data: result } = await fetchThemes(
|
|
62
|
+
const { data: result } = await fetchThemes(derivedAccountId, {
|
|
65
63
|
name: encodeURIComponent(themeToCheck),
|
|
66
64
|
});
|
|
67
65
|
isValidTheme = result && result.total;
|
|
@@ -75,13 +73,13 @@ exports.handler = async (options) => {
|
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
else {
|
|
78
|
-
themeToCheck = await selectTheme(
|
|
76
|
+
themeToCheck = await selectTheme(derivedAccountId);
|
|
79
77
|
logger.log();
|
|
80
78
|
}
|
|
81
79
|
// Kick off the scoring
|
|
82
80
|
let requestResult;
|
|
83
81
|
try {
|
|
84
|
-
const { data } = await requestLighthouseScore(
|
|
82
|
+
const { data } = await requestLighthouseScore(derivedAccountId, {
|
|
85
83
|
themePath: themeToCheck,
|
|
86
84
|
});
|
|
87
85
|
requestResult = data;
|
|
@@ -102,14 +100,14 @@ exports.handler = async (options) => {
|
|
|
102
100
|
const checkScoreStatus = async () => {
|
|
103
101
|
let desktopScoreStatus = 'COMPLETED';
|
|
104
102
|
if (includeDesktopScore) {
|
|
105
|
-
const { data } = await getLighthouseScoreStatus(
|
|
103
|
+
const { data } = await getLighthouseScoreStatus(derivedAccountId, {
|
|
106
104
|
themeId: requestResult.desktopId,
|
|
107
105
|
});
|
|
108
106
|
desktopScoreStatus = data;
|
|
109
107
|
}
|
|
110
108
|
let mobileScoreStatus = 'COMPLETED';
|
|
111
109
|
if (includeDesktopScore) {
|
|
112
|
-
const { data } = await getLighthouseScoreStatus(
|
|
110
|
+
const { data } = await getLighthouseScoreStatus(derivedAccountId, {
|
|
113
111
|
themeId: requestResult.mobileId,
|
|
114
112
|
});
|
|
115
113
|
mobileScoreStatus = data;
|
|
@@ -132,24 +130,24 @@ exports.handler = async (options) => {
|
|
|
132
130
|
let mobileScoreResult = {};
|
|
133
131
|
let verboseViewAverageScoreResult = {};
|
|
134
132
|
try {
|
|
135
|
-
const params = { isAverage: !
|
|
133
|
+
const params = { isAverage: !verbose };
|
|
136
134
|
if (includeDesktopScore) {
|
|
137
|
-
const { data } = await getLighthouseScore(
|
|
135
|
+
const { data } = await getLighthouseScore(derivedAccountId, {
|
|
138
136
|
...params,
|
|
139
137
|
desktopId: requestResult.desktopId,
|
|
140
138
|
});
|
|
141
139
|
desktopScoreResult = data;
|
|
142
140
|
}
|
|
143
141
|
if (includeMobileScore) {
|
|
144
|
-
const { data } = await getLighthouseScore(
|
|
142
|
+
const { data } = await getLighthouseScore(derivedAccountId, {
|
|
145
143
|
...params,
|
|
146
144
|
mobileId: requestResult.mobileId,
|
|
147
145
|
});
|
|
148
146
|
mobileScoreResult = data;
|
|
149
147
|
}
|
|
150
148
|
// This is needed to show the average scores above the verbose output
|
|
151
|
-
if (
|
|
152
|
-
const { data } = await getLighthouseScore(
|
|
149
|
+
if (verbose) {
|
|
150
|
+
const { data } = await getLighthouseScore(derivedAccountId, {
|
|
153
151
|
...params,
|
|
154
152
|
isAverage: true,
|
|
155
153
|
desktopId: includeDesktopScore ? requestResult.desktopId : null,
|
|
@@ -162,8 +160,8 @@ exports.handler = async (options) => {
|
|
|
162
160
|
logger.error(i18n(`${i18nKey}.errors.failedToGetLighthouseScore`));
|
|
163
161
|
process.exit(EXIT_CODES.ERROR);
|
|
164
162
|
}
|
|
165
|
-
if (
|
|
166
|
-
logger.log(`${themeToCheck} ${
|
|
163
|
+
if (verbose) {
|
|
164
|
+
logger.log(`${themeToCheck} ${target} scores`);
|
|
167
165
|
const tableHeader = getTableHeader(DEFAULT_TABLE_HEADER);
|
|
168
166
|
const scores = verboseViewAverageScoreResult.scores
|
|
169
167
|
? verboseViewAverageScoreResult.scores[0]
|
|
@@ -183,7 +181,7 @@ exports.handler = async (options) => {
|
|
|
183
181
|
'Template path',
|
|
184
182
|
...DEFAULT_TABLE_HEADER,
|
|
185
183
|
]);
|
|
186
|
-
const scoreResult =
|
|
184
|
+
const scoreResult = target === 'desktop' ? desktopScoreResult : mobileScoreResult;
|
|
187
185
|
const templateTableData = scoreResult.scores.map(score => {
|
|
188
186
|
return [
|
|
189
187
|
score.templatePath,
|
|
@@ -209,7 +207,7 @@ exports.handler = async (options) => {
|
|
|
209
207
|
});
|
|
210
208
|
}
|
|
211
209
|
logger.log();
|
|
212
|
-
logger.info(i18n(`${i18nKey}.info.targetDeviceNote`, { target
|
|
210
|
+
logger.info(i18n(`${i18nKey}.info.targetDeviceNote`, { target }));
|
|
213
211
|
}
|
|
214
212
|
else {
|
|
215
213
|
logger.log(`Theme: ${themeToCheck}`);
|
package/commands/cms.js
CHANGED
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { i18n } = require('../lib/lang');
|
|
5
|
-
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
5
|
+
const { addConfigOptions, addAccountOptions, addGlobalOptions, } = require('../lib/commonOpts');
|
|
6
6
|
const lighthouseScore = require('./cms/lighthouseScore');
|
|
7
7
|
const convertFields = require('./cms/convertFields');
|
|
8
|
-
const
|
|
8
|
+
const getReactModule = require('./cms/getReactModule');
|
|
9
9
|
const i18nKey = 'commands.cms';
|
|
10
10
|
exports.command = 'cms';
|
|
11
11
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
12
|
exports.builder = yargs => {
|
|
13
13
|
addConfigOptions(yargs);
|
|
14
14
|
addAccountOptions(yargs);
|
|
15
|
+
addGlobalOptions(yargs);
|
|
15
16
|
yargs
|
|
16
17
|
.command(lighthouseScore)
|
|
17
18
|
.command(convertFields)
|
|
18
|
-
.command(
|
|
19
|
+
.command(getReactModule)
|
|
19
20
|
.demandCommand(1, '');
|
|
20
21
|
return yargs;
|
|
21
22
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const yargsParser = require('yargs-parser');
|
|
5
|
+
const { i18n } = require('../lib/lang');
|
|
6
|
+
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
7
|
+
const i18nKey = 'commands.completion';
|
|
8
|
+
exports.command = 'completion';
|
|
9
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
10
|
+
exports.handler = async () => {
|
|
11
|
+
await trackCommandUsage('completion');
|
|
12
|
+
};
|
|
13
|
+
exports.builder = yargs => {
|
|
14
|
+
const { help } = yargsParser(process.argv.slice(2));
|
|
15
|
+
if (!help) {
|
|
16
|
+
yargs.completion();
|
|
17
|
+
}
|
|
18
|
+
yargs.example([
|
|
19
|
+
['$0 completion >> ~/.zshrc', i18n(`${i18nKey}.examples.default`)],
|
|
20
|
+
]);
|
|
21
|
+
return yargs;
|
|
22
|
+
};
|
package/commands/config/set.js
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
5
4
|
const { i18n } = require('../../lib/lang');
|
|
6
|
-
const { getAccountId } = require('../../lib/commonOpts');
|
|
7
5
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
8
6
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
9
7
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
10
|
-
const {
|
|
8
|
+
const { setDefaultCmsPublishMode, setHttpTimeout, setAllowUsageTracking, } = require('../../lib/configOptions');
|
|
11
9
|
const i18nKey = 'commands.config.subcommands.set';
|
|
12
10
|
exports.command = 'set';
|
|
13
11
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
14
12
|
const selectOptions = async () => {
|
|
15
|
-
const {
|
|
13
|
+
const { cmsPublishMode } = await promptUser([
|
|
16
14
|
{
|
|
17
15
|
type: 'list',
|
|
18
16
|
look: false,
|
|
19
|
-
name: '
|
|
17
|
+
name: 'cmsPublishMode',
|
|
20
18
|
pageSize: 20,
|
|
21
19
|
message: i18n(`${i18nKey}.promptMessage`),
|
|
22
20
|
choices: [
|
|
23
|
-
{
|
|
21
|
+
{
|
|
22
|
+
name: 'Default CMS publish mode',
|
|
23
|
+
value: { defaultCmsPublishMode: '' },
|
|
24
|
+
},
|
|
24
25
|
{ name: 'Allow usage tracking', value: { allowUsageTracking: '' } },
|
|
25
26
|
{ name: 'HTTP timeout', value: { httpTimeout: '' } },
|
|
26
27
|
],
|
|
27
28
|
},
|
|
28
29
|
]);
|
|
29
|
-
return
|
|
30
|
+
return cmsPublishMode;
|
|
30
31
|
};
|
|
31
32
|
const handleConfigUpdate = async (accountId, options) => {
|
|
32
|
-
const { allowUsageTracking,
|
|
33
|
-
if (typeof
|
|
34
|
-
await
|
|
33
|
+
const { allowUsageTracking, defaultCmsPublishMode, httpTimeout } = options;
|
|
34
|
+
if (typeof defaultCmsPublishMode !== 'undefined') {
|
|
35
|
+
await setDefaultCmsPublishMode({ defaultCmsPublishMode, accountId });
|
|
35
36
|
return true;
|
|
36
37
|
}
|
|
37
38
|
else if (typeof httpTimeout !== 'undefined') {
|
|
@@ -45,37 +46,34 @@ const handleConfigUpdate = async (accountId, options) => {
|
|
|
45
46
|
return false;
|
|
46
47
|
};
|
|
47
48
|
exports.handler = async (options) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const configUpdated = await handleConfigUpdate(accountId, options);
|
|
49
|
+
const { derivedAccountId } = options;
|
|
50
|
+
trackCommandUsage('config-set', null, derivedAccountId);
|
|
51
|
+
const configUpdated = await handleConfigUpdate(derivedAccountId, options);
|
|
52
52
|
if (!configUpdated) {
|
|
53
53
|
const selectedOptions = await selectOptions();
|
|
54
|
-
await handleConfigUpdate(
|
|
54
|
+
await handleConfigUpdate(derivedAccountId, selectedOptions);
|
|
55
55
|
}
|
|
56
56
|
process.exit(EXIT_CODES.SUCCESS);
|
|
57
57
|
};
|
|
58
58
|
exports.builder = yargs => {
|
|
59
59
|
yargs
|
|
60
60
|
.options({
|
|
61
|
-
|
|
61
|
+
'default-cms-publish-mode': {
|
|
62
62
|
describe: i18n(`${i18nKey}.options.defaultMode.describe`),
|
|
63
63
|
type: 'string',
|
|
64
64
|
},
|
|
65
|
-
|
|
65
|
+
'allow-usage-tracking': {
|
|
66
66
|
describe: i18n(`${i18nKey}.options.allowUsageTracking.describe`),
|
|
67
67
|
type: 'boolean',
|
|
68
68
|
},
|
|
69
|
-
|
|
69
|
+
'http-timeout': {
|
|
70
70
|
describe: i18n(`${i18nKey}.options.httpTimeout.describe`),
|
|
71
71
|
type: 'string',
|
|
72
72
|
},
|
|
73
73
|
})
|
|
74
|
-
.conflicts('
|
|
75
|
-
.conflicts('
|
|
76
|
-
.conflicts('allowUsageTracking', 'httpTimeout')
|
|
77
|
-
|
|
78
|
-
//TODO remove this when "hs accounts use" is fully rolled out
|
|
79
|
-
yargs.strict(false);
|
|
74
|
+
.conflicts('defaultCmsPublishMode', 'allowUsageTracking')
|
|
75
|
+
.conflicts('defaultCmsPublishMode', 'httpTimeout')
|
|
76
|
+
.conflicts('allowUsageTracking', 'httpTimeout')
|
|
77
|
+
.example([['$0 config set', i18n(`${i18nKey}.examples.default`)]]);
|
|
80
78
|
return yargs;
|
|
81
79
|
};
|
package/commands/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const { addConfigOptions,
|
|
4
|
+
const { addConfigOptions, addGlobalOptions } = require('../lib/commonOpts');
|
|
5
5
|
const { i18n } = require('../lib/lang');
|
|
6
6
|
const set = require('./config/set');
|
|
7
7
|
const i18nKey = 'commands.config';
|
|
@@ -9,7 +9,7 @@ exports.command = 'config';
|
|
|
9
9
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
10
10
|
exports.builder = yargs => {
|
|
11
11
|
addConfigOptions(yargs);
|
|
12
|
-
|
|
12
|
+
addGlobalOptions(yargs);
|
|
13
13
|
yargs.command(set).demandCommand(1, '');
|
|
14
14
|
return yargs;
|
|
15
15
|
};
|
package/commands/create.js
CHANGED
|
@@ -27,7 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
const fs = require('fs-extra');
|
|
28
28
|
const { logError } = require('../lib/errorHandlers/index');
|
|
29
29
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
30
|
-
const { setLogLevel,
|
|
30
|
+
const { setLogLevel, addGlobalOptions, addConfigOptions, } = require('../lib/commonOpts');
|
|
31
31
|
const { resolveLocalPath } = require('../lib/filesystem');
|
|
32
32
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
33
33
|
const assets = require('./create/index');
|
|
@@ -36,7 +36,7 @@ const i18nKey = 'commands.create';
|
|
|
36
36
|
const SUPPORTED_ASSET_TYPES = Object.keys(assets)
|
|
37
37
|
.filter(t => !assets[t].hidden)
|
|
38
38
|
.join(', ');
|
|
39
|
-
exports.command = 'create <type> [name] [dest]
|
|
39
|
+
exports.command = 'create <type> [name] [dest]';
|
|
40
40
|
exports.describe = i18n(`${i18nKey}.describe`, {
|
|
41
41
|
supportedAssetTypes: SUPPORTED_ASSET_TYPES,
|
|
42
42
|
});
|
|
@@ -63,7 +63,8 @@ exports.handler = async (options) => {
|
|
|
63
63
|
const asset = assets[assetType];
|
|
64
64
|
const argsToPass = { assetType, name, dest, getInternalVersion, options };
|
|
65
65
|
dest = argsToPass.dest = resolveLocalPath(asset.dest(argsToPass));
|
|
66
|
-
|
|
66
|
+
const { derivedAccountId } = options;
|
|
67
|
+
trackCommandUsage('create', { assetType }, derivedAccountId);
|
|
67
68
|
try {
|
|
68
69
|
await fs.ensureDir(dest);
|
|
69
70
|
}
|
|
@@ -99,5 +100,7 @@ exports.builder = yargs => {
|
|
|
99
100
|
type: 'boolean',
|
|
100
101
|
hidden: true,
|
|
101
102
|
});
|
|
103
|
+
addConfigOptions(yargs);
|
|
104
|
+
addGlobalOptions(yargs);
|
|
102
105
|
return yargs;
|
|
103
106
|
};
|
|
@@ -1,46 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
4
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
6
|
const { logError } = require('../../lib/errorHandlers/index');
|
|
6
7
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
7
|
-
const { checkAndConvertToJson
|
|
8
|
+
const { checkAndConvertToJson } = require('../../lib/validation');
|
|
8
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { getAccountId } = require('../../lib/commonOpts');
|
|
10
10
|
const { batchCreateObjects, } = require('@hubspot/local-dev-lib/api/customObjects');
|
|
11
11
|
const { i18n } = require('../../lib/lang');
|
|
12
12
|
const i18nKey = 'commands.customObject.subcommands.create';
|
|
13
13
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
14
|
-
exports.command = 'create
|
|
14
|
+
exports.command = 'create [name]';
|
|
15
15
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
16
16
|
exports.handler = async (options) => {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const { path, name: providedName, derivedAccountId } = options;
|
|
18
|
+
let definitionPath = path;
|
|
19
|
+
trackCommandUsage('custom-object-batch-create', null, derivedAccountId);
|
|
20
|
+
if (!definitionPath) {
|
|
21
|
+
definitionPath = await (0, promptUtils_1.inputPrompt)(i18n(`${i18nKey}.inputPath`));
|
|
22
|
+
}
|
|
23
|
+
const filePath = getAbsoluteFilePath(definitionPath);
|
|
22
24
|
const objectJson = checkAndConvertToJson(filePath);
|
|
23
25
|
if (!objectJson) {
|
|
24
26
|
process.exit(EXIT_CODES.ERROR);
|
|
25
27
|
}
|
|
28
|
+
const name = providedName || (await (0, promptUtils_1.inputPrompt)(i18n(`${i18nKey}.inputSchema`)));
|
|
26
29
|
try {
|
|
27
|
-
await batchCreateObjects(
|
|
30
|
+
await batchCreateObjects(derivedAccountId, name, objectJson);
|
|
28
31
|
logger.success(i18n(`${i18nKey}.success.objectsCreated`));
|
|
29
32
|
}
|
|
30
33
|
catch (e) {
|
|
31
|
-
logError(e, { accountId });
|
|
34
|
+
logError(e, { accountId: derivedAccountId });
|
|
32
35
|
logger.error(i18n(`${i18nKey}.errors.creationFailed`, {
|
|
33
|
-
definition,
|
|
36
|
+
definition: definitionPath,
|
|
34
37
|
}));
|
|
35
38
|
}
|
|
36
39
|
};
|
|
37
40
|
exports.builder = yargs => {
|
|
38
|
-
yargs
|
|
41
|
+
yargs
|
|
42
|
+
.positional('name', {
|
|
39
43
|
describe: i18n(`${i18nKey}.positionals.name.describe`),
|
|
40
44
|
type: 'string',
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
describe: i18n(`${i18nKey}.
|
|
45
|
+
})
|
|
46
|
+
.option('path', {
|
|
47
|
+
describe: i18n(`${i18nKey}.options.path.describe`),
|
|
44
48
|
type: 'string',
|
|
45
49
|
});
|
|
46
50
|
};
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
5
|
const { logError } = require('../../../lib/errorHandlers/index');
|
|
6
6
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
7
|
-
const { checkAndConvertToJson
|
|
7
|
+
const { checkAndConvertToJson } = require('../../../lib/validation');
|
|
8
8
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
9
|
-
const { addTestingOptions
|
|
9
|
+
const { addTestingOptions } = require('../../../lib/commonOpts');
|
|
10
10
|
const { getEnv, isConfigFlagEnabled, } = require('@hubspot/local-dev-lib/config');
|
|
11
11
|
const { ENVIRONMENTS, } = require('@hubspot/local-dev-lib/constants/environments');
|
|
12
12
|
const { CONFIG_FLAGS } = require('../../../lib/constants');
|
|
@@ -16,43 +16,42 @@ const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
|
16
16
|
const { i18n } = require('../../../lib/lang');
|
|
17
17
|
const i18nKey = 'commands.customObject.subcommands.schema.subcommands.create';
|
|
18
18
|
const { EXIT_CODES } = require('../../../lib/enums/exitCodes');
|
|
19
|
-
exports.command = 'create
|
|
19
|
+
exports.command = 'create';
|
|
20
20
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
21
21
|
exports.handler = async (options) => {
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
trackCommandUsage('custom-object-schema-create', null, accountId);
|
|
26
|
-
const filePath = getAbsoluteFilePath(definition);
|
|
22
|
+
const { path, derivedAccountId } = options;
|
|
23
|
+
trackCommandUsage('custom-object-schema-create', null, derivedAccountId);
|
|
24
|
+
const filePath = getAbsoluteFilePath(path);
|
|
27
25
|
const schemaJson = checkAndConvertToJson(filePath);
|
|
28
26
|
if (!schemaJson) {
|
|
29
27
|
process.exit(EXIT_CODES.ERROR);
|
|
30
28
|
}
|
|
31
29
|
try {
|
|
32
30
|
if (isConfigFlagEnabled(CONFIG_FLAGS.USE_CUSTOM_OBJECT_HUBFILE)) {
|
|
33
|
-
await createSchemaFromHubFile(
|
|
31
|
+
await createSchemaFromHubFile(derivedAccountId, filePath);
|
|
34
32
|
logger.success(i18n(`${i18nKey}.success.schemaCreated`, {
|
|
35
|
-
accountId,
|
|
33
|
+
accountId: derivedAccountId,
|
|
36
34
|
}));
|
|
37
35
|
}
|
|
38
36
|
else {
|
|
39
|
-
const { data } = await createObjectSchema(
|
|
37
|
+
const { data } = await createObjectSchema(derivedAccountId, schemaJson);
|
|
40
38
|
logger.success(i18n(`${i18nKey}.success.schemaViewable`, {
|
|
41
|
-
url: `${getHubSpotWebsiteOrigin(getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD)}/contacts/${
|
|
39
|
+
url: `${getHubSpotWebsiteOrigin(getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD)}/contacts/${derivedAccountId}/objects/${data.objectTypeId}`,
|
|
42
40
|
}));
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
catch (e) {
|
|
46
|
-
logError(e, { accountId });
|
|
44
|
+
logError(e, { accountId: derivedAccountId });
|
|
47
45
|
logger.error(i18n(`${i18nKey}.errors.creationFailed`, {
|
|
48
|
-
definition,
|
|
46
|
+
definition: path,
|
|
49
47
|
}));
|
|
50
48
|
}
|
|
51
49
|
};
|
|
52
50
|
exports.builder = yargs => {
|
|
53
51
|
addTestingOptions(yargs);
|
|
54
|
-
yargs.
|
|
55
|
-
describe: i18n(`${i18nKey}.
|
|
52
|
+
yargs.option('path', {
|
|
53
|
+
describe: i18n(`${i18nKey}.options.definition.describe`),
|
|
56
54
|
type: 'string',
|
|
55
|
+
required: true,
|
|
57
56
|
});
|
|
58
57
|
};
|