@hubspot/cli 6.2.2-experimental.2 → 6.3.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 +21 -2
- package/commands/accounts/clean.js +8 -5
- package/commands/accounts/info.js +6 -6
- package/commands/accounts/list.js +14 -10
- package/commands/accounts/remove.js +1 -1
- package/commands/accounts/rename.js +3 -4
- package/commands/auth.js +11 -7
- package/commands/cms/lighthouseScore.js +19 -19
- package/commands/config/set.js +4 -5
- package/commands/create.js +3 -2
- package/commands/customObject/create.js +4 -6
- package/commands/customObject/schema/create.js +8 -9
- package/commands/customObject/schema/delete.js +3 -5
- package/commands/customObject/schema/fetch-all.js +3 -4
- package/commands/customObject/schema/fetch.js +4 -6
- package/commands/customObject/schema/list.js +3 -4
- package/commands/customObject/schema/update.js +8 -9
- package/commands/fetch.js +4 -4
- package/commands/filemanager/fetch.js +4 -5
- package/commands/filemanager/upload.js +9 -10
- package/commands/functions/deploy.js +12 -10
- package/commands/functions/list.js +5 -5
- package/commands/functions/server.js +4 -5
- package/commands/hubdb/clear.js +5 -6
- package/commands/hubdb/create.js +5 -6
- package/commands/hubdb/delete.js +5 -6
- package/commands/hubdb/fetch.js +4 -5
- package/commands/init.js +26 -8
- package/commands/lint.js +5 -5
- package/commands/list.js +4 -5
- package/commands/logs.js +4 -5
- package/commands/module/marketplace-validate.js +6 -7
- package/commands/mv.js +7 -8
- package/commands/open.js +7 -8
- package/commands/project/add.js +2 -3
- package/commands/project/cloneApp.js +14 -14
- package/commands/project/create.js +3 -3
- package/commands/project/deploy.js +15 -12
- package/commands/project/dev.js +13 -13
- package/commands/project/download.js +11 -9
- package/commands/project/listBuilds.js +10 -8
- package/commands/project/logs.js +5 -5
- package/commands/project/migrateApp.js +18 -18
- package/commands/project/open.js +6 -7
- package/commands/project/upload.js +12 -10
- package/commands/project/watch.js +9 -10
- package/commands/remove.js +10 -8
- package/commands/sandbox/create.js +8 -9
- package/commands/sandbox/delete.js +11 -9
- package/commands/secrets/addSecret.js +6 -7
- package/commands/secrets/deleteSecret.js +6 -7
- package/commands/secrets/listSecrets.js +6 -6
- package/commands/secrets/updateSecret.js +6 -7
- package/commands/theme/marketplace-validate.js +6 -7
- package/commands/theme/preview.js +5 -6
- package/commands/upload.js +18 -15
- package/commands/watch.js +9 -10
- package/lang/en.lyaml +3 -0
- package/lib/buildAccount.js +3 -1
- package/lib/commonOpts.d.ts +9 -1
- package/lib/commonOpts.js +14 -12
- package/lib/developerTestAccounts.js +8 -5
- package/lib/oauth.js +3 -1
- package/lib/prompts/accountsPrompt.js +8 -4
- package/lib/prompts/projectDevTargetAccountPrompt.js +3 -2
- package/lib/prompts/sandboxesPrompt.js +10 -7
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -2
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
const yargs = require('yargs');
|
|
4
4
|
const updateNotifier = require('update-notifier');
|
|
5
5
|
const chalk = require('chalk');
|
|
6
|
+
const fs = require('fs');
|
|
6
7
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
8
|
const { addUserAgentHeader } = require('@hubspot/local-dev-lib/http');
|
|
9
|
+
const { loadConfig, configFileExists, } = require('@hubspot/local-dev-lib/config');
|
|
8
10
|
const { logError } = require('../lib/errorHandlers/index');
|
|
9
|
-
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
11
|
+
const { setLogLevel, getCommandName, injectAccountIdMiddleware, } = require('../lib/commonOpts');
|
|
10
12
|
const { trackHelpUsage, trackConvertFieldsUsage, } = require('../lib/usageTracking');
|
|
11
13
|
const { getIsInProject } = require('../lib/projects');
|
|
12
14
|
const pkg = require('../package.json');
|
|
@@ -116,9 +118,26 @@ const performChecks = argv => {
|
|
|
116
118
|
const setRequestHeaders = () => {
|
|
117
119
|
addUserAgentHeader('HubSpot CLI', pkg.version);
|
|
118
120
|
};
|
|
121
|
+
const loadConfigMiddleware = async (options) => {
|
|
122
|
+
if (configFileExists(true)) {
|
|
123
|
+
loadConfig('', options);
|
|
124
|
+
}
|
|
125
|
+
if (options.config) {
|
|
126
|
+
if (fs.existsSync(options.config)) {
|
|
127
|
+
const { config: configPath } = options;
|
|
128
|
+
await loadConfig(configPath, options);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
119
132
|
const argv = yargs
|
|
120
133
|
.usage('The command line interface to interact with HubSpot.')
|
|
121
|
-
|
|
134
|
+
// loadConfigMiddleware loads the new hidden config for all commands
|
|
135
|
+
.middleware([
|
|
136
|
+
setLogLevel,
|
|
137
|
+
setRequestHeaders,
|
|
138
|
+
loadConfigMiddleware,
|
|
139
|
+
injectAccountIdMiddleware,
|
|
140
|
+
])
|
|
122
141
|
.exitProcess(false)
|
|
123
142
|
.fail(handleFailure)
|
|
124
143
|
.option('debug', {
|
|
@@ -11,8 +11,9 @@ const { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, addTestin
|
|
|
11
11
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
12
12
|
const { getTableContents } = require('../../lib/ui/table');
|
|
13
13
|
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
14
|
-
const { getConfig, deleteAccount } = require('@hubspot/local-dev-lib/config');
|
|
15
14
|
const { uiAccountDescription } = require('../../lib/ui');
|
|
15
|
+
const { deleteAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
16
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
16
17
|
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
17
18
|
const i18nKey = 'commands.accounts.subcommands.clean';
|
|
18
19
|
exports.command = 'clean';
|
|
@@ -20,9 +21,9 @@ exports.describe = i18n(`${i18nKey}.describe`);
|
|
|
20
21
|
exports.handler = async (options) => {
|
|
21
22
|
const { qa } = options;
|
|
22
23
|
await loadAndValidateOptions(options, false);
|
|
23
|
-
const config = getConfig();
|
|
24
24
|
trackCommandUsage('accounts-clean', null);
|
|
25
|
-
const
|
|
25
|
+
const accountsList = getConfigAccounts();
|
|
26
|
+
const filteredTestAccounts = accountsList.filter(p => qa ? p.env === 'qa' : p.env !== 'qa');
|
|
26
27
|
if (filteredTestAccounts && filteredTestAccounts.length === 0) {
|
|
27
28
|
logger.log(i18n(`${i18nKey}.noResults`));
|
|
28
29
|
process.exit(EXIT_CODES.SUCCESS);
|
|
@@ -36,7 +37,7 @@ exports.handler = async (options) => {
|
|
|
36
37
|
});
|
|
37
38
|
for (const account of filteredTestAccounts) {
|
|
38
39
|
try {
|
|
39
|
-
await accessTokenForPersonalAccessKey(account
|
|
40
|
+
await accessTokenForPersonalAccessKey(getAccountIdentifier(account), true);
|
|
40
41
|
}
|
|
41
42
|
catch (error) {
|
|
42
43
|
if (isSpecifiedError(error, {
|
|
@@ -62,7 +63,9 @@ exports.handler = async (options) => {
|
|
|
62
63
|
count: accountsToRemove.length,
|
|
63
64
|
}),
|
|
64
65
|
});
|
|
65
|
-
logger.log(getTableContents(accountsToRemove.map(p => [
|
|
66
|
+
logger.log(getTableContents(accountsToRemove.map(p => [
|
|
67
|
+
uiAccountDescription(getAccountIdentifier(p)),
|
|
68
|
+
]), { border: { bodyLeft: ' ' } }));
|
|
66
69
|
const { accountsCleanPrompt } = await promptUser([
|
|
67
70
|
{
|
|
68
71
|
name: 'accountsCleanPrompt',
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
5
|
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
6
6
|
const { getAccessToken } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
7
|
-
const {
|
|
7
|
+
const { addAccountOptions, addConfigOptions } = require('../../lib/commonOpts');
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
9
|
const { i18n } = require('../../lib/lang');
|
|
10
10
|
const { getTableContents } = require('../../lib/ui/table');
|
|
@@ -13,15 +13,15 @@ exports.describe = i18n(`${i18nKey}.describe`);
|
|
|
13
13
|
exports.command = 'info [--account]';
|
|
14
14
|
exports.handler = async (options) => {
|
|
15
15
|
await loadAndValidateOptions(options);
|
|
16
|
-
const
|
|
17
|
-
const config = getAccountConfig(
|
|
16
|
+
const { derivedAccountId } = options;
|
|
17
|
+
const config = getAccountConfig(derivedAccountId);
|
|
18
18
|
// check if the provided account is using a personal access key, if not, show an error
|
|
19
|
-
if (config.authType === 'personalaccesskey') {
|
|
19
|
+
if (config && config.authType === 'personalaccesskey') {
|
|
20
20
|
const { name, personalAccessKey, env } = config;
|
|
21
|
-
const response = await getAccessToken(personalAccessKey, env,
|
|
21
|
+
const response = await getAccessToken(personalAccessKey, env, derivedAccountId);
|
|
22
22
|
const scopeGroups = response.scopeGroups.map(s => [s]);
|
|
23
23
|
logger.log(i18n(`${i18nKey}.name`, { name }));
|
|
24
|
-
logger.log(i18n(`${i18nKey}.accountId`, { accountId }));
|
|
24
|
+
logger.log(i18n(`${i18nKey}.accountId`, { accountId: derivedAccountId }));
|
|
25
25
|
logger.log(i18n(`${i18nKey}.scopeGroups`));
|
|
26
26
|
logger.log(getTableContents(scopeGroups, { border: { bodyLeft: ' ' } }));
|
|
27
27
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const { getConfig, getConfigPath } = require('@hubspot/local-dev-lib/config');
|
|
5
|
+
const { getConfig, getConfigPath, getConfigDefaultAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
6
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
6
7
|
const { getTableContents, getTableHeader } = require('../../lib/ui/table');
|
|
7
|
-
const { addConfigOptions, addAccountOptions
|
|
8
|
+
const { addConfigOptions, addAccountOptions } = require('../../lib/commonOpts');
|
|
8
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
10
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
10
11
|
const { isSandbox, isDeveloperTestAccount } = require('../../lib/accountTypes');
|
|
@@ -21,7 +22,7 @@ const sortAndMapPortals = portals => {
|
|
|
21
22
|
(p.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD ||
|
|
22
23
|
p.accountType === HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER))
|
|
23
24
|
.forEach(portal => {
|
|
24
|
-
mappedPortalData[portal
|
|
25
|
+
mappedPortalData[getAccountIdentifier(portal)] = [portal];
|
|
25
26
|
});
|
|
26
27
|
// Non-standard portals (sandbox, developer test account)
|
|
27
28
|
portals
|
|
@@ -34,7 +35,7 @@ const sortAndMapPortals = portals => {
|
|
|
34
35
|
];
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
|
-
mappedPortalData[p
|
|
38
|
+
mappedPortalData[getAccountIdentifier(p)] = [p];
|
|
38
39
|
}
|
|
39
40
|
});
|
|
40
41
|
return mappedPortalData;
|
|
@@ -42,7 +43,7 @@ const sortAndMapPortals = portals => {
|
|
|
42
43
|
const getPortalData = mappedPortalData => {
|
|
43
44
|
const portalData = [];
|
|
44
45
|
Object.entries(mappedPortalData).forEach(([key, set]) => {
|
|
45
|
-
const hasParentPortal = set.filter(p => p
|
|
46
|
+
const hasParentPortal = set.filter(p => getAccountIdentifier(p) === parseInt(key, 10))[0];
|
|
46
47
|
set.forEach(portal => {
|
|
47
48
|
let name = `${portal.name} [${HUBSPOT_ACCOUNT_TYPE_STRINGS[portal.accountType]}]`;
|
|
48
49
|
if (isSandbox(portal)) {
|
|
@@ -55,18 +56,19 @@ const getPortalData = mappedPortalData => {
|
|
|
55
56
|
name = `↳ ${name}`;
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
portalData.push([name, portal
|
|
59
|
+
portalData.push([name, getAccountIdentifier(portal), portal.authType]);
|
|
59
60
|
});
|
|
60
61
|
});
|
|
61
62
|
return portalData;
|
|
62
63
|
};
|
|
63
64
|
exports.handler = async (options) => {
|
|
64
65
|
await loadAndValidateOptions(options, false);
|
|
65
|
-
const
|
|
66
|
-
trackCommandUsage('accounts-list', null,
|
|
66
|
+
const { derivedAccountId } = options;
|
|
67
|
+
trackCommandUsage('accounts-list', null, derivedAccountId);
|
|
67
68
|
const config = getConfig();
|
|
68
69
|
const configPath = getConfigPath();
|
|
69
|
-
const
|
|
70
|
+
const accountsList = getConfigAccounts();
|
|
71
|
+
const mappedPortalData = sortAndMapPortals(accountsList);
|
|
70
72
|
const portalData = getPortalData(mappedPortalData);
|
|
71
73
|
portalData.unshift(getTableHeader([
|
|
72
74
|
i18n(`${i18nKey}.labels.name`),
|
|
@@ -74,7 +76,9 @@ exports.handler = async (options) => {
|
|
|
74
76
|
i18n(`${i18nKey}.labels.authType`),
|
|
75
77
|
]));
|
|
76
78
|
logger.log(i18n(`${i18nKey}.configPath`, { configPath }));
|
|
77
|
-
logger.log(i18n(`${i18nKey}.defaultAccount`, {
|
|
79
|
+
logger.log(i18n(`${i18nKey}.defaultAccount`, {
|
|
80
|
+
account: getConfigDefaultAccount(config),
|
|
81
|
+
}));
|
|
78
82
|
logger.log(i18n(`${i18nKey}.accounts`));
|
|
79
83
|
logger.log(getTableContents(portalData, { border: { bodyLeft: ' ' } }));
|
|
80
84
|
};
|
|
@@ -13,7 +13,7 @@ exports.describe = i18n(`${i18nKey}.describe`);
|
|
|
13
13
|
exports.handler = async (options) => {
|
|
14
14
|
await loadAndValidateOptions(options, false);
|
|
15
15
|
let config = getConfig();
|
|
16
|
-
let accountToRemove = options.
|
|
16
|
+
let accountToRemove = options.providedAccountId;
|
|
17
17
|
if (accountToRemove && !getAccountIdFromConfig(accountToRemove)) {
|
|
18
18
|
logger.error(i18n(`${i18nKey}.errors.accountNotFound`, {
|
|
19
19
|
specifiedAccount: accountToRemove,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
5
|
const { renameAccount } = require('@hubspot/local-dev-lib/config');
|
|
6
|
-
const { addConfigOptions, addAccountOptions
|
|
6
|
+
const { addConfigOptions, addAccountOptions } = require('../../lib/commonOpts');
|
|
7
7
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
9
|
const { i18n } = require('../../lib/lang');
|
|
@@ -12,9 +12,8 @@ exports.command = 'rename <accountName> <newName>';
|
|
|
12
12
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
13
|
exports.handler = async (options) => {
|
|
14
14
|
loadAndValidateOptions(options);
|
|
15
|
-
const { accountName, newName } = options;
|
|
16
|
-
|
|
17
|
-
trackCommandUsage('accounts-rename', null, accountId);
|
|
15
|
+
const { accountName, newName, derivedAccountId } = options;
|
|
16
|
+
trackCommandUsage('accounts-rename', null, derivedAccountId);
|
|
18
17
|
await renameAccount(accountName, newName);
|
|
19
18
|
return logger.log(i18n(`${i18nKey}.success.renamed`, {
|
|
20
19
|
name: accountName,
|
package/commands/auth.js
CHANGED
|
@@ -8,7 +8,7 @@ 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, getConfig, getConfigPath, loadConfig, } = require('@hubspot/local-dev-lib/config');
|
|
11
|
+
const { updateAccountConfig, writeConfig, getConfig, 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');
|
|
@@ -36,16 +36,17 @@ exports.describe = i18n(`${i18nKey}.describe`, {
|
|
|
36
36
|
supportedProtocols: SUPPORTED_AUTHENTICATION_PROTOCOLS_TEXT,
|
|
37
37
|
});
|
|
38
38
|
exports.handler = async (options) => {
|
|
39
|
-
const { type, config: c, qa,
|
|
39
|
+
const { type, config: c, qa, providedAccountId } = options;
|
|
40
40
|
const authType = (type && type.toLowerCase()) || PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
41
41
|
setLogLevel(options);
|
|
42
|
+
const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
43
|
+
// Needed to load deprecated config
|
|
44
|
+
loadConfig(c);
|
|
45
|
+
checkAndWarnGitInclusion(getConfigPath());
|
|
42
46
|
if (!getConfigPath(c)) {
|
|
43
47
|
logger.error(i18n(`${i18nKey}.errors.noConfigFileFound`));
|
|
44
48
|
process.exit(EXIT_CODES.ERROR);
|
|
45
49
|
}
|
|
46
|
-
const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
47
|
-
loadConfig(c);
|
|
48
|
-
checkAndWarnGitInclusion(getConfigPath());
|
|
49
50
|
trackCommandUsage('auth');
|
|
50
51
|
trackAuthAction('auth', authType, TRACKING_STATUS.STARTED);
|
|
51
52
|
let configData;
|
|
@@ -64,7 +65,10 @@ exports.handler = async (options) => {
|
|
|
64
65
|
successAuthMethod = OAUTH_AUTH_METHOD.name;
|
|
65
66
|
break;
|
|
66
67
|
case PERSONAL_ACCESS_KEY_AUTH_METHOD.value:
|
|
67
|
-
configData = await personalAccessKeyPrompt({
|
|
68
|
+
configData = await personalAccessKeyPrompt({
|
|
69
|
+
env,
|
|
70
|
+
account: providedAccountId,
|
|
71
|
+
});
|
|
68
72
|
try {
|
|
69
73
|
token = await getAccessToken(configData.personalAccessKey, env);
|
|
70
74
|
defaultName = toKebabCase(token.hubName);
|
|
@@ -112,7 +116,7 @@ exports.handler = async (options) => {
|
|
|
112
116
|
else {
|
|
113
117
|
const config = getConfig();
|
|
114
118
|
logger.info(i18n(`lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault`, {
|
|
115
|
-
accountName: config
|
|
119
|
+
accountName: getConfigDefaultAccount(config),
|
|
116
120
|
}));
|
|
117
121
|
}
|
|
118
122
|
logger.success(i18n(`${i18nKey}.success.configFileUpdated`, {
|
|
@@ -2,7 +2,7 @@
|
|
|
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
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -54,14 +54,14 @@ const selectTheme = async (accountId) => {
|
|
|
54
54
|
};
|
|
55
55
|
exports.handler = async (options) => {
|
|
56
56
|
await loadAndValidateOptions(options);
|
|
57
|
-
const
|
|
58
|
-
const includeDesktopScore =
|
|
59
|
-
const includeMobileScore =
|
|
60
|
-
let themeToCheck =
|
|
57
|
+
const { target, verbose, theme, derivedAccountId } = options;
|
|
58
|
+
const includeDesktopScore = target === 'desktop' || !verbose;
|
|
59
|
+
const includeMobileScore = target === 'mobile' || !verbose;
|
|
60
|
+
let themeToCheck = theme;
|
|
61
61
|
if (themeToCheck) {
|
|
62
62
|
let isValidTheme = true;
|
|
63
63
|
try {
|
|
64
|
-
const { data: result } = await fetchThemes(
|
|
64
|
+
const { data: result } = await fetchThemes(derivedAccountId, {
|
|
65
65
|
name: encodeURIComponent(themeToCheck),
|
|
66
66
|
});
|
|
67
67
|
isValidTheme = result && result.total;
|
|
@@ -75,13 +75,13 @@ exports.handler = async (options) => {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
themeToCheck = await selectTheme(
|
|
78
|
+
themeToCheck = await selectTheme(derivedAccountId);
|
|
79
79
|
logger.log();
|
|
80
80
|
}
|
|
81
81
|
// Kick off the scoring
|
|
82
82
|
let requestResult;
|
|
83
83
|
try {
|
|
84
|
-
const { data } = await requestLighthouseScore(
|
|
84
|
+
const { data } = await requestLighthouseScore(derivedAccountId, {
|
|
85
85
|
themePath: themeToCheck,
|
|
86
86
|
});
|
|
87
87
|
requestResult = data;
|
|
@@ -102,14 +102,14 @@ exports.handler = async (options) => {
|
|
|
102
102
|
const checkScoreStatus = async () => {
|
|
103
103
|
let desktopScoreStatus = 'COMPLETED';
|
|
104
104
|
if (includeDesktopScore) {
|
|
105
|
-
const { data } = await getLighthouseScoreStatus(
|
|
105
|
+
const { data } = await getLighthouseScoreStatus(derivedAccountId, {
|
|
106
106
|
themeId: requestResult.desktopId,
|
|
107
107
|
});
|
|
108
108
|
desktopScoreStatus = data;
|
|
109
109
|
}
|
|
110
110
|
let mobileScoreStatus = 'COMPLETED';
|
|
111
111
|
if (includeDesktopScore) {
|
|
112
|
-
const { data } = await getLighthouseScoreStatus(
|
|
112
|
+
const { data } = await getLighthouseScoreStatus(derivedAccountId, {
|
|
113
113
|
themeId: requestResult.mobileId,
|
|
114
114
|
});
|
|
115
115
|
mobileScoreStatus = data;
|
|
@@ -132,24 +132,24 @@ exports.handler = async (options) => {
|
|
|
132
132
|
let mobileScoreResult = {};
|
|
133
133
|
let verboseViewAverageScoreResult = {};
|
|
134
134
|
try {
|
|
135
|
-
const params = { isAverage: !
|
|
135
|
+
const params = { isAverage: !verbose };
|
|
136
136
|
if (includeDesktopScore) {
|
|
137
|
-
const { data } = await getLighthouseScore(
|
|
137
|
+
const { data } = await getLighthouseScore(derivedAccountId, {
|
|
138
138
|
...params,
|
|
139
139
|
desktopId: requestResult.desktopId,
|
|
140
140
|
});
|
|
141
141
|
desktopScoreResult = data;
|
|
142
142
|
}
|
|
143
143
|
if (includeMobileScore) {
|
|
144
|
-
const { data } = await getLighthouseScore(
|
|
144
|
+
const { data } = await getLighthouseScore(derivedAccountId, {
|
|
145
145
|
...params,
|
|
146
146
|
mobileId: requestResult.mobileId,
|
|
147
147
|
});
|
|
148
148
|
mobileScoreResult = data;
|
|
149
149
|
}
|
|
150
150
|
// This is needed to show the average scores above the verbose output
|
|
151
|
-
if (
|
|
152
|
-
const { data } = await getLighthouseScore(
|
|
151
|
+
if (verbose) {
|
|
152
|
+
const { data } = await getLighthouseScore(derivedAccountId, {
|
|
153
153
|
...params,
|
|
154
154
|
isAverage: true,
|
|
155
155
|
desktopId: includeDesktopScore ? requestResult.desktopId : null,
|
|
@@ -162,8 +162,8 @@ exports.handler = async (options) => {
|
|
|
162
162
|
logger.error(i18n(`${i18nKey}.errors.failedToGetLighthouseScore`));
|
|
163
163
|
process.exit(EXIT_CODES.ERROR);
|
|
164
164
|
}
|
|
165
|
-
if (
|
|
166
|
-
logger.log(`${themeToCheck} ${
|
|
165
|
+
if (verbose) {
|
|
166
|
+
logger.log(`${themeToCheck} ${target} scores`);
|
|
167
167
|
const tableHeader = getTableHeader(DEFAULT_TABLE_HEADER);
|
|
168
168
|
const scores = verboseViewAverageScoreResult.scores
|
|
169
169
|
? verboseViewAverageScoreResult.scores[0]
|
|
@@ -183,7 +183,7 @@ exports.handler = async (options) => {
|
|
|
183
183
|
'Template path',
|
|
184
184
|
...DEFAULT_TABLE_HEADER,
|
|
185
185
|
]);
|
|
186
|
-
const scoreResult =
|
|
186
|
+
const scoreResult = target === 'desktop' ? desktopScoreResult : mobileScoreResult;
|
|
187
187
|
const templateTableData = scoreResult.scores.map(score => {
|
|
188
188
|
return [
|
|
189
189
|
score.templatePath,
|
|
@@ -209,7 +209,7 @@ exports.handler = async (options) => {
|
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
logger.log();
|
|
212
|
-
logger.info(i18n(`${i18nKey}.info.targetDeviceNote`, { target
|
|
212
|
+
logger.info(i18n(`${i18nKey}.info.targetDeviceNote`, { target }));
|
|
213
213
|
}
|
|
214
214
|
else {
|
|
215
215
|
logger.log(`Theme: ${themeToCheck}`);
|
package/commands/config/set.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
5
5
|
const { i18n } = require('../../lib/lang');
|
|
6
|
-
const { getAccountId } = require('../../lib/commonOpts');
|
|
7
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
8
7
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
9
8
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
@@ -46,12 +45,12 @@ const handleConfigUpdate = async (accountId, options) => {
|
|
|
46
45
|
};
|
|
47
46
|
exports.handler = async (options) => {
|
|
48
47
|
await loadAndValidateOptions(options);
|
|
49
|
-
const
|
|
50
|
-
trackCommandUsage('config-set', null,
|
|
51
|
-
const configUpdated = await handleConfigUpdate(
|
|
48
|
+
const { derivedAccountId } = options;
|
|
49
|
+
trackCommandUsage('config-set', null, derivedAccountId);
|
|
50
|
+
const configUpdated = await handleConfigUpdate(derivedAccountId, options);
|
|
52
51
|
if (!configUpdated) {
|
|
53
52
|
const selectedOptions = await selectOptions();
|
|
54
|
-
await handleConfigUpdate(
|
|
53
|
+
await handleConfigUpdate(derivedAccountId, selectedOptions);
|
|
55
54
|
}
|
|
56
55
|
process.exit(EXIT_CODES.SUCCESS);
|
|
57
56
|
};
|
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 } = require('../lib/commonOpts');
|
|
31
31
|
const { resolveLocalPath } = require('../lib/filesystem');
|
|
32
32
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
33
33
|
const assets = require('./create/index');
|
|
@@ -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
|
}
|
|
@@ -6,7 +6,6 @@ const { logError } = require('../../lib/errorHandlers/index');
|
|
|
6
6
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
7
7
|
const { checkAndConvertToJson, loadAndValidateOptions, } = require('../../lib/validation');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { getAccountId } = require('../../lib/commonOpts');
|
|
10
9
|
const { batchCreateObjects, } = require('@hubspot/local-dev-lib/api/customObjects');
|
|
11
10
|
const { i18n } = require('../../lib/lang');
|
|
12
11
|
const i18nKey = 'commands.customObject.subcommands.create';
|
|
@@ -14,21 +13,20 @@ const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
|
14
13
|
exports.command = 'create <name> <definition>';
|
|
15
14
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
16
15
|
exports.handler = async (options) => {
|
|
17
|
-
const { definition, name } = options;
|
|
16
|
+
const { definition, name, derivedAccountId } = options;
|
|
18
17
|
await loadAndValidateOptions(options);
|
|
19
|
-
|
|
20
|
-
trackCommandUsage('custom-object-batch-create', null, accountId);
|
|
18
|
+
trackCommandUsage('custom-object-batch-create', null, derivedAccountId);
|
|
21
19
|
const filePath = getAbsoluteFilePath(definition);
|
|
22
20
|
const objectJson = checkAndConvertToJson(filePath);
|
|
23
21
|
if (!objectJson) {
|
|
24
22
|
process.exit(EXIT_CODES.ERROR);
|
|
25
23
|
}
|
|
26
24
|
try {
|
|
27
|
-
await batchCreateObjects(
|
|
25
|
+
await batchCreateObjects(derivedAccountId, name, objectJson);
|
|
28
26
|
logger.success(i18n(`${i18nKey}.success.objectsCreated`));
|
|
29
27
|
}
|
|
30
28
|
catch (e) {
|
|
31
|
-
logError(e, { accountId });
|
|
29
|
+
logError(e, { accountId: derivedAccountId });
|
|
32
30
|
logger.error(i18n(`${i18nKey}.errors.creationFailed`, {
|
|
33
31
|
definition,
|
|
34
32
|
}));
|
|
@@ -6,7 +6,7 @@ const { logError } = require('../../../lib/errorHandlers/index');
|
|
|
6
6
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
7
7
|
const { checkAndConvertToJson, loadAndValidateOptions, } = 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');
|
|
@@ -19,10 +19,9 @@ const { EXIT_CODES } = require('../../../lib/enums/exitCodes');
|
|
|
19
19
|
exports.command = 'create <definition>';
|
|
20
20
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
21
21
|
exports.handler = async (options) => {
|
|
22
|
-
const { definition } = options;
|
|
22
|
+
const { definition, derivedAccountId } = options;
|
|
23
23
|
await loadAndValidateOptions(options);
|
|
24
|
-
|
|
25
|
-
trackCommandUsage('custom-object-schema-create', null, accountId);
|
|
24
|
+
trackCommandUsage('custom-object-schema-create', null, derivedAccountId);
|
|
26
25
|
const filePath = getAbsoluteFilePath(definition);
|
|
27
26
|
const schemaJson = checkAndConvertToJson(filePath);
|
|
28
27
|
if (!schemaJson) {
|
|
@@ -30,20 +29,20 @@ exports.handler = async (options) => {
|
|
|
30
29
|
}
|
|
31
30
|
try {
|
|
32
31
|
if (isConfigFlagEnabled(CONFIG_FLAGS.USE_CUSTOM_OBJECT_HUBFILE)) {
|
|
33
|
-
await createSchemaFromHubFile(
|
|
32
|
+
await createSchemaFromHubFile(derivedAccountId, filePath);
|
|
34
33
|
logger.success(i18n(`${i18nKey}.success.schemaCreated`, {
|
|
35
|
-
accountId,
|
|
34
|
+
accountId: derivedAccountId,
|
|
36
35
|
}));
|
|
37
36
|
}
|
|
38
37
|
else {
|
|
39
|
-
const { data } = await createObjectSchema(
|
|
38
|
+
const { data } = await createObjectSchema(derivedAccountId, schemaJson);
|
|
40
39
|
logger.success(i18n(`${i18nKey}.success.schemaViewable`, {
|
|
41
|
-
url: `${getHubSpotWebsiteOrigin(getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD)}/contacts/${
|
|
40
|
+
url: `${getHubSpotWebsiteOrigin(getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD)}/contacts/${derivedAccountId}/objects/${data.objectTypeId}`,
|
|
42
41
|
}));
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
catch (e) {
|
|
46
|
-
logError(e, { accountId });
|
|
45
|
+
logError(e, { accountId: derivedAccountId });
|
|
47
46
|
logger.error(i18n(`${i18nKey}.errors.creationFailed`, {
|
|
48
47
|
definition,
|
|
49
48
|
}));
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
5
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
6
6
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
7
|
-
const { getAccountId } = require('../../../lib/commonOpts');
|
|
8
7
|
const { deleteObjectSchema, } = require('@hubspot/local-dev-lib/api/customObjects');
|
|
9
8
|
const { i18n } = require('../../../lib/lang');
|
|
10
9
|
const { logError } = require('../../../lib/errorHandlers');
|
|
@@ -12,12 +11,11 @@ const i18nKey = 'commands.customObject.subcommands.schema.subcommands.delete';
|
|
|
12
11
|
exports.command = 'delete <name>';
|
|
13
12
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
14
13
|
exports.handler = async (options) => {
|
|
15
|
-
const { name } = options;
|
|
14
|
+
const { name, derivedAccountId } = options;
|
|
16
15
|
await loadAndValidateOptions(options);
|
|
17
|
-
|
|
18
|
-
trackCommandUsage('custom-object-schema-delete', null, accountId);
|
|
16
|
+
trackCommandUsage('custom-object-schema-delete', null, derivedAccountId);
|
|
19
17
|
try {
|
|
20
|
-
await deleteObjectSchema(
|
|
18
|
+
await deleteObjectSchema(derivedAccountId, name);
|
|
21
19
|
logger.success(i18n(`${i18nKey}.success.delete`, {
|
|
22
20
|
name,
|
|
23
21
|
}));
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
5
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
6
6
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
7
|
-
const { getAccountId } = require('../../../lib/commonOpts');
|
|
8
7
|
const { downloadSchemas, getResolvedPath, } = require('@hubspot/local-dev-lib/customObjects');
|
|
9
8
|
const { i18n } = require('../../../lib/lang');
|
|
10
9
|
const { logSchemas } = require('../../../lib/schema');
|
|
@@ -14,10 +13,10 @@ exports.command = 'fetch-all [dest]';
|
|
|
14
13
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
14
|
exports.handler = async (options) => {
|
|
16
15
|
await loadAndValidateOptions(options);
|
|
17
|
-
const
|
|
18
|
-
trackCommandUsage('custom-object-schema-fetch-all', null,
|
|
16
|
+
const { derivedAccountId } = options;
|
|
17
|
+
trackCommandUsage('custom-object-schema-fetch-all', null, derivedAccountId);
|
|
19
18
|
try {
|
|
20
|
-
const schemas = await downloadSchemas(
|
|
19
|
+
const schemas = await downloadSchemas(derivedAccountId, options.dest);
|
|
21
20
|
logSchemas(schemas);
|
|
22
21
|
logger.success(i18n(`${i18nKey}.success.fetch`, {
|
|
23
22
|
path: getResolvedPath(options.dest),
|
|
@@ -10,28 +10,26 @@ const { fetchSchema } = require('@hubspot/local-dev-lib/api/fileTransport');
|
|
|
10
10
|
const { getCwd } = require('@hubspot/local-dev-lib/path');
|
|
11
11
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
12
12
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
13
|
-
const { getAccountId } = require('../../../lib/commonOpts');
|
|
14
13
|
const { i18n } = require('../../../lib/lang');
|
|
15
14
|
const { logError } = require('../../../lib/errorHandlers');
|
|
16
15
|
const i18nKey = 'commands.customObject.subcommands.schema.subcommands.fetch';
|
|
17
16
|
exports.command = 'fetch <name> [dest]';
|
|
18
17
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
19
18
|
exports.handler = async (options) => {
|
|
20
|
-
const { name, dest } = options;
|
|
19
|
+
const { name, dest, derivedAccountId } = options;
|
|
21
20
|
await loadAndValidateOptions(options);
|
|
22
|
-
|
|
23
|
-
trackCommandUsage('custom-object-schema-fetch', null, accountId);
|
|
21
|
+
trackCommandUsage('custom-object-schema-fetch', null, derivedAccountId);
|
|
24
22
|
try {
|
|
25
23
|
if (isConfigFlagEnabled(CONFIG_FLAGS.USE_CUSTOM_OBJECT_HUBFILE)) {
|
|
26
24
|
const fullpath = path.resolve(getCwd(), dest);
|
|
27
|
-
await fetchSchema(
|
|
25
|
+
await fetchSchema(derivedAccountId, name, fullpath);
|
|
28
26
|
logger.success(i18n(`${i18nKey}.success.save`, {
|
|
29
27
|
name,
|
|
30
28
|
path: fullpath,
|
|
31
29
|
}));
|
|
32
30
|
}
|
|
33
31
|
else {
|
|
34
|
-
await downloadSchema(
|
|
32
|
+
await downloadSchema(derivedAccountId, name, dest);
|
|
35
33
|
logger.success(i18n(`${i18nKey}.success.savedToPath`, {
|
|
36
34
|
path: getResolvedPath(dest, name),
|
|
37
35
|
}));
|
|
@@ -5,7 +5,6 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
|
5
5
|
const { logError } = require('../../../lib/errorHandlers/index');
|
|
6
6
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
7
7
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
8
|
-
const { getAccountId } = require('../../../lib/commonOpts');
|
|
9
8
|
const { listSchemas } = require('../../../lib/schema');
|
|
10
9
|
const { i18n } = require('../../../lib/lang');
|
|
11
10
|
const i18nKey = 'commands.customObject.subcommands.schema.subcommands.list';
|
|
@@ -13,10 +12,10 @@ exports.command = 'list';
|
|
|
13
12
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
14
13
|
exports.handler = async (options) => {
|
|
15
14
|
await loadAndValidateOptions(options);
|
|
16
|
-
const
|
|
17
|
-
trackCommandUsage('custom-object-schema-list', null,
|
|
15
|
+
const { derivedAccountId } = options;
|
|
16
|
+
trackCommandUsage('custom-object-schema-list', null, derivedAccountId);
|
|
18
17
|
try {
|
|
19
|
-
await listSchemas(
|
|
18
|
+
await listSchemas(derivedAccountId);
|
|
20
19
|
}
|
|
21
20
|
catch (e) {
|
|
22
21
|
logError(e);
|