@hubspot/cli 7.0.2-experimental.0 → 7.0.3-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 +7 -2
- package/commands/account/info.d.ts +7 -0
- package/commands/account/info.js +28 -25
- package/commands/account/remove.js +4 -4
- package/commands/account/use.js +3 -3
- package/commands/auth.js +3 -3
- package/commands/init.js +1 -1
- package/commands/logs.js +1 -7
- package/commands/project/create.js +6 -0
- package/commands/project/installDeps.js +2 -4
- package/commands/project/upload.js +5 -10
- package/commands/project/watch.js +4 -4
- package/commands/sandbox/create.js +2 -8
- package/commands/sandbox/delete.js +6 -10
- package/lang/en.lyaml +8 -3
- package/lib/LocalDevManager.d.ts +58 -1
- package/lib/LocalDevManager.js +162 -122
- package/lib/buildAccount.d.ts +12 -0
- package/lib/buildAccount.js +110 -95
- package/lib/commonOpts.d.ts +4 -8
- package/lib/commonOpts.js +2 -14
- package/lib/developerTestAccounts.d.ts +1 -0
- package/lib/developerTestAccounts.js +1 -0
- package/lib/localDev.d.ts +17 -1
- package/lib/localDev.js +203 -197
- package/lib/projects/buildAndDeploy.d.ts +1 -7
- package/lib/projects/index.js +8 -3
- package/lib/projects/structure.d.ts +3 -0
- package/lib/projects/structure.js +21 -0
- package/lib/projects/upload.d.ts +4 -3
- package/lib/projects/upload.js +7 -31
- package/lib/prompts/createProjectPrompt.js +8 -1
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/personalAccessKeyPrompt.d.ts +1 -1
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +2 -2
- package/lib/sandboxes.d.ts +1 -1
- package/lib/serverlessLogs.d.ts +4 -1
- package/lib/serverlessLogs.js +64 -60
- package/lib/ui/serverlessFunctionLogs.d.ts +8 -0
- package/lib/ui/serverlessFunctionLogs.js +1 -3
- package/lib/validation.d.ts +2 -0
- package/lib/validation.js +5 -8
- package/package.json +2 -3
- package/types/Projects.d.ts +8 -2
- package/types/Yargs.d.ts +14 -0
- package/types/Yargs.js +2 -0
package/bin/cli.js
CHANGED
|
@@ -184,9 +184,14 @@ const loadConfigMiddleware = async (options) => {
|
|
|
184
184
|
}));
|
|
185
185
|
process.exit(EXIT_CODES.ERROR);
|
|
186
186
|
}
|
|
187
|
-
else if (!options
|
|
187
|
+
else if (!isTargetedCommand(options, { init: { target: true } })) {
|
|
188
188
|
const { config: configPath } = options;
|
|
189
|
-
loadConfig(configPath, options);
|
|
189
|
+
const config = loadConfig(configPath, options);
|
|
190
|
+
// We don't run validateConfig() for auth because users should be able to run it when
|
|
191
|
+
// no accounts are configured, but we still want to exit if the config file is not found
|
|
192
|
+
if (isTargetedCommand(options, { auth: { target: true } }) && !config) {
|
|
193
|
+
process.exit(EXIT_CODES.ERROR);
|
|
194
|
+
}
|
|
190
195
|
}
|
|
191
196
|
maybeValidateConfig();
|
|
192
197
|
};
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const describe: string;
|
|
4
|
+
export declare const command = "info [account]";
|
|
5
|
+
type AccountInfoArgs = CommonArgs & ConfigArgs;
|
|
6
|
+
export declare function handler(args: ArgumentsCamelCase<AccountInfoArgs>): Promise<void>;
|
|
7
|
+
export declare function builder(yargs: Argv): Argv<AccountInfoArgs>;
|
|
1
8
|
export {};
|
package/commands/account/info.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
3
|
+
exports.command = exports.describe = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
|
+
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
9
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
10
|
+
const lang_1 = require("../../lib/lang");
|
|
11
|
+
const table_1 = require("../../lib/ui/table");
|
|
10
12
|
const i18nKey = 'commands.account.subcommands.info';
|
|
11
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
12
14
|
exports.command = 'info [account]';
|
|
13
|
-
|
|
14
|
-
const { derivedAccountId } =
|
|
15
|
-
const config = getAccountConfig(derivedAccountId);
|
|
15
|
+
async function handler(args) {
|
|
16
|
+
const { derivedAccountId } = args;
|
|
17
|
+
const config = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
16
18
|
// check if the provided account is using a personal access key, if not, show an error
|
|
17
19
|
if (config && config.authType === 'personalaccesskey') {
|
|
18
20
|
const { name, personalAccessKey, env } = config;
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
logger.log(i18n(`${i18nKey}.
|
|
23
|
-
logger.log(i18n(`${i18nKey}.
|
|
24
|
-
logger.log(
|
|
21
|
+
let scopeGroups = [];
|
|
22
|
+
const response = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env, derivedAccountId);
|
|
23
|
+
scopeGroups = response.scopeGroups.map(s => [s]);
|
|
24
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.name`, { name: name }));
|
|
25
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.accountId`, { accountId: derivedAccountId }));
|
|
26
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.scopeGroups`));
|
|
27
|
+
logger_1.logger.log((0, table_1.getTableContents)(scopeGroups, { border: { bodyLeft: ' ' } }));
|
|
25
28
|
}
|
|
26
29
|
else {
|
|
27
|
-
logger.log(i18n(`${i18nKey}.errors.notUsingPersonalAccessKey`));
|
|
30
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.errors.notUsingPersonalAccessKey`));
|
|
28
31
|
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
addConfigOptions(yargs);
|
|
32
|
+
}
|
|
33
|
+
function builder(yargs) {
|
|
34
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
32
35
|
yargs.example([
|
|
33
|
-
['$0 accounts info', i18n(`${i18nKey}.examples.default`)],
|
|
34
|
-
['$0 accounts info MyAccount', i18n(`${i18nKey}.examples.nameBased`)],
|
|
35
|
-
['$0 accounts info 1234567', i18n(`${i18nKey}.examples.idBased`)],
|
|
36
|
+
['$0 accounts info', (0, lang_1.i18n)(`${i18nKey}.examples.default`)],
|
|
37
|
+
['$0 accounts info MyAccount', (0, lang_1.i18n)(`${i18nKey}.examples.nameBased`)],
|
|
38
|
+
['$0 accounts info 1234567', (0, lang_1.i18n)(`${i18nKey}.examples.idBased`)],
|
|
36
39
|
]);
|
|
37
40
|
return yargs;
|
|
38
|
-
}
|
|
41
|
+
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { addConfigOptions } = require('../../lib/commonOpts');
|
|
5
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
6
|
-
const { loadConfig, getConfigPath, deleteAccount, getConfigDefaultAccount, getAccountId
|
|
6
|
+
const { loadConfig, getConfigPath, deleteAccount, getConfigDefaultAccount, getAccountId, updateDefaultAccount, } = require('@hubspot/local-dev-lib/config');
|
|
7
7
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
8
8
|
const { i18n } = require('../../lib/lang');
|
|
9
9
|
const { selectAccountFromConfig } = require('../../lib/prompts/accountsPrompt');
|
|
@@ -13,16 +13,16 @@ exports.describe = i18n(`${i18nKey}.describe`);
|
|
|
13
13
|
exports.handler = async (options) => {
|
|
14
14
|
const { account } = options;
|
|
15
15
|
let accountToRemove = account;
|
|
16
|
-
if (accountToRemove && !
|
|
16
|
+
if (accountToRemove && !getAccountId(accountToRemove)) {
|
|
17
17
|
logger.error(i18n(`${i18nKey}.errors.accountNotFound`, {
|
|
18
18
|
specifiedAccount: accountToRemove,
|
|
19
19
|
configPath: getConfigPath(),
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
22
|
-
if (!accountToRemove || !
|
|
22
|
+
if (!accountToRemove || !getAccountId(accountToRemove)) {
|
|
23
23
|
accountToRemove = await selectAccountFromConfig(i18n(`${i18nKey}.prompts.selectAccountToRemove`));
|
|
24
24
|
}
|
|
25
|
-
trackCommandUsage('accounts-remove', null,
|
|
25
|
+
trackCommandUsage('accounts-remove', null, getAccountId(accountToRemove));
|
|
26
26
|
const currentDefaultAccount = getConfigDefaultAccount();
|
|
27
27
|
await deleteAccount(accountToRemove);
|
|
28
28
|
logger.success(i18n(`${i18nKey}.success.accountRemoved`, {
|
package/commands/account/use.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const { getConfigPath, updateDefaultAccount, getAccountId
|
|
5
|
+
const { getConfigPath, updateDefaultAccount, getAccountId, } = require('@hubspot/local-dev-lib/config');
|
|
6
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
7
7
|
const { i18n } = require('../../lib/lang');
|
|
8
8
|
const { selectAccountFromConfig } = require('../../lib/prompts/accountsPrompt');
|
|
@@ -14,14 +14,14 @@ exports.handler = async (options) => {
|
|
|
14
14
|
if (!newDefaultAccount) {
|
|
15
15
|
newDefaultAccount = await selectAccountFromConfig();
|
|
16
16
|
}
|
|
17
|
-
else if (!
|
|
17
|
+
else if (!getAccountId(newDefaultAccount)) {
|
|
18
18
|
logger.error(i18n(`${i18nKey}.errors.accountNotFound`, {
|
|
19
19
|
specifiedAccount: newDefaultAccount,
|
|
20
20
|
configPath: getConfigPath(),
|
|
21
21
|
}));
|
|
22
22
|
newDefaultAccount = await selectAccountFromConfig();
|
|
23
23
|
}
|
|
24
|
-
trackCommandUsage('accounts-use', null,
|
|
24
|
+
trackCommandUsage('accounts-use', null, getAccountId(newDefaultAccount));
|
|
25
25
|
updateDefaultAccount(newDefaultAccount);
|
|
26
26
|
return logger.success(i18n(`${i18nKey}.success.defaultAccountUpdated`, {
|
|
27
27
|
accountName: newDefaultAccount,
|
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, getConfigPath, loadConfig, getConfigDefaultAccount, } = require('@hubspot/local-dev-lib/config');
|
|
11
|
+
const { updateAccountConfig, writeConfig, getConfigPath, loadConfig, getConfigDefaultAccount, getAccountId, } = 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,
|
|
17
|
+
const { addConfigOptions, setLogLevel, 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');
|
|
@@ -129,7 +129,7 @@ exports.handler = async (options) => {
|
|
|
129
129
|
'accountOption',
|
|
130
130
|
'accountsListCommand',
|
|
131
131
|
]);
|
|
132
|
-
const accountId = getAccountId(
|
|
132
|
+
const accountId = getAccountId(accountName);
|
|
133
133
|
await trackAuthAction('auth', authType, TRACKING_STATUS.COMPLETE, accountId);
|
|
134
134
|
process.exit(EXIT_CODES.SUCCESS);
|
|
135
135
|
};
|
package/commands/init.js
CHANGED
|
@@ -67,7 +67,7 @@ exports.describe = i18n(`${i18nKey}.describe`, {
|
|
|
67
67
|
configName: DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
68
68
|
});
|
|
69
69
|
exports.handler = async (options) => {
|
|
70
|
-
const {
|
|
70
|
+
const { authType: authTypeFlagValue, c: configFlagValue, providedAccountId, disableTracking, useHiddenConfig, } = options;
|
|
71
71
|
const authType = (authTypeFlagValue && authTypeFlagValue.toLowerCase()) ||
|
|
72
72
|
PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
73
73
|
const configPath = (configFlagValue && path.join(getCwd(), configFlagValue)) ||
|
package/commands/logs.js
CHANGED
|
@@ -44,13 +44,7 @@ const endpointLog = async (accountId, functionPath, options) => {
|
|
|
44
44
|
handleLogsError(e, accountId, functionPath);
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
await tailLogs(
|
|
48
|
-
accountId,
|
|
49
|
-
compact,
|
|
50
|
-
tailCall,
|
|
51
|
-
fetchLatest,
|
|
52
|
-
name: functionPath,
|
|
53
|
-
});
|
|
47
|
+
await tailLogs(accountId, functionPath, fetchLatest, tailCall, compact);
|
|
54
48
|
}
|
|
55
49
|
else if (latest) {
|
|
56
50
|
try {
|
|
@@ -56,6 +56,12 @@ exports.builder = yargs => {
|
|
|
56
56
|
},
|
|
57
57
|
});
|
|
58
58
|
yargs.example([['$0 project create', i18n(`${i18nKey}.examples.default`)]]);
|
|
59
|
+
yargs.example([
|
|
60
|
+
[
|
|
61
|
+
'$0 project create --template-source HubSpot/ui-extensions-examples',
|
|
62
|
+
i18n(`${i18nKey}.examples.templateSource`),
|
|
63
|
+
],
|
|
64
|
+
]);
|
|
59
65
|
addConfigOptions(yargs);
|
|
60
66
|
addAccountOptions(yargs);
|
|
61
67
|
addUseEnvironmentOptions(yargs);
|
|
@@ -9,16 +9,14 @@ const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const { i18n } = require('../../lib/lang');
|
|
11
11
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
12
|
-
const { getAccountId } = require('../../lib/commonOpts');
|
|
13
12
|
const { uiBetaTag } = require('../../lib/ui');
|
|
14
13
|
const i18nKey = `commands.project.subcommands.installDeps`;
|
|
15
14
|
exports.command = 'install-deps [packages..]';
|
|
16
15
|
exports.describe = uiBetaTag(i18n(`${i18nKey}.help.describe`), false);
|
|
17
16
|
exports.handler = async (options) => {
|
|
18
|
-
const { packages } = options || {};
|
|
17
|
+
const { derivedAccountId, packages } = options || {};
|
|
19
18
|
try {
|
|
20
|
-
|
|
21
|
-
trackCommandUsage('project-install-deps', null, accountId);
|
|
19
|
+
trackCommandUsage('project-install-deps', null, derivedAccountId);
|
|
22
20
|
const projectConfig = await getProjectConfig();
|
|
23
21
|
if (!projectConfig || !projectConfig.projectDir) {
|
|
24
22
|
logger.error(i18n(`${i18nKey}.noProjectConfig`));
|
|
@@ -22,17 +22,17 @@ exports.handler = async (options) => {
|
|
|
22
22
|
const { forceCreate, message, derivedAccountId } = options;
|
|
23
23
|
const accountConfig = getAccountConfig(derivedAccountId);
|
|
24
24
|
const accountType = accountConfig && accountConfig.accountType;
|
|
25
|
-
const { projectConfig, projectDir } = await getProjectConfig();
|
|
26
25
|
trackCommandUsage('project-upload', { type: accountType }, derivedAccountId);
|
|
26
|
+
const { projectConfig, projectDir } = await getProjectConfig();
|
|
27
27
|
validateProjectConfig(projectConfig, projectDir);
|
|
28
28
|
await ensureProjectExists(derivedAccountId, projectConfig.name, {
|
|
29
29
|
forceCreate,
|
|
30
30
|
uploadCommand: true,
|
|
31
31
|
});
|
|
32
32
|
try {
|
|
33
|
-
const result = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message
|
|
34
|
-
if (
|
|
35
|
-
if (isSpecifiedError(
|
|
33
|
+
const { result, uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message);
|
|
34
|
+
if (uploadError) {
|
|
35
|
+
if (isSpecifiedError(uploadError, {
|
|
36
36
|
subCategory: PROJECT_ERROR_TYPES.PROJECT_LOCKED,
|
|
37
37
|
})) {
|
|
38
38
|
logger.log();
|
|
@@ -40,7 +40,7 @@ exports.handler = async (options) => {
|
|
|
40
40
|
logger.log();
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
|
-
logError(
|
|
43
|
+
logError(uploadError, new ApiErrorContext({
|
|
44
44
|
accountId: derivedAccountId,
|
|
45
45
|
request: 'project upload',
|
|
46
46
|
}));
|
|
@@ -80,11 +80,6 @@ exports.builder = yargs => {
|
|
|
80
80
|
type: 'string',
|
|
81
81
|
default: '',
|
|
82
82
|
},
|
|
83
|
-
translate: {
|
|
84
|
-
hidden: true,
|
|
85
|
-
type: 'boolean',
|
|
86
|
-
default: false,
|
|
87
|
-
},
|
|
88
83
|
});
|
|
89
84
|
yargs.example([['$0 project upload', i18n(`${i18nKey}.examples.default`)]]);
|
|
90
85
|
addConfigOptions(yargs);
|
|
@@ -71,9 +71,9 @@ exports.handler = async (options) => {
|
|
|
71
71
|
};
|
|
72
72
|
// Upload all files if no build exists for this project yet
|
|
73
73
|
if (initialUpload || hasNoBuilds) {
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
if (isSpecifiedError(
|
|
74
|
+
const { uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, startWatching);
|
|
75
|
+
if (uploadError) {
|
|
76
|
+
if (isSpecifiedError(uploadError, {
|
|
77
77
|
subCategory: PROJECT_ERROR_TYPES.PROJECT_LOCKED,
|
|
78
78
|
})) {
|
|
79
79
|
logger.log();
|
|
@@ -81,7 +81,7 @@ exports.handler = async (options) => {
|
|
|
81
81
|
logger.log();
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
|
-
logError(
|
|
84
|
+
logError(uploadError, new ApiErrorContext({
|
|
85
85
|
accountId: derivedAccountId,
|
|
86
86
|
request: 'project upload',
|
|
87
87
|
}));
|
|
@@ -17,7 +17,7 @@ const { logError } = require('../../lib/errorHandlers/index');
|
|
|
17
17
|
const { isMissingScopeError } = require('@hubspot/local-dev-lib/errors/index');
|
|
18
18
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
19
19
|
const { HUBSPOT_ACCOUNT_TYPES, HUBSPOT_ACCOUNT_TYPE_STRINGS, } = require('@hubspot/local-dev-lib/constants/config');
|
|
20
|
-
const {
|
|
20
|
+
const { buildSandbox } = require('../../lib/buildAccount');
|
|
21
21
|
const { hubspotAccountNamePrompt, } = require('../../lib/prompts/accountNamePrompt');
|
|
22
22
|
const i18nKey = 'commands.sandbox.subcommands.create';
|
|
23
23
|
exports.command = 'create';
|
|
@@ -97,13 +97,7 @@ exports.handler = async (options) => {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
try {
|
|
100
|
-
const
|
|
101
|
-
name: sandboxName,
|
|
102
|
-
accountType: sandboxType,
|
|
103
|
-
accountConfig,
|
|
104
|
-
env,
|
|
105
|
-
force,
|
|
106
|
-
});
|
|
100
|
+
const result = await buildSandbox(sandboxName, accountConfig, sandboxType, env, force);
|
|
107
101
|
const sandboxAccountConfig = getAccountConfig(result.sandbox.sandboxHubId);
|
|
108
102
|
// For v1 sandboxes, keep sync here. Once we migrate to v2, this will be handled by BE automatically
|
|
109
103
|
const handleSyncSandbox = async (syncTasks) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions,
|
|
4
|
+
const { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, addTestingOptions, } = require('../../lib/commonOpts');
|
|
5
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
6
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
7
7
|
const { logError, debugError } = require('../../lib/errorHandlers/index');
|
|
@@ -9,7 +9,7 @@ const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
|
9
9
|
const { deleteSandbox } = require('@hubspot/local-dev-lib/api/sandboxHubs');
|
|
10
10
|
const { i18n } = require('../../lib/lang');
|
|
11
11
|
const { deleteSandboxPrompt } = require('../../lib/prompts/sandboxesPrompt');
|
|
12
|
-
const { getEnv, removeSandboxAccountFromConfig, updateDefaultAccount,
|
|
12
|
+
const { getEnv, removeSandboxAccountFromConfig, updateDefaultAccount, getAccountId, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
13
13
|
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
14
14
|
const { selectAccountFromConfig } = require('../../lib/prompts/accountsPrompt');
|
|
15
15
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
@@ -40,10 +40,8 @@ exports.handler = async (options) => {
|
|
|
40
40
|
process.exit(EXIT_CODES.ERROR);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
const sandboxAccountId = getAccountId(
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
const isDefaultAccount = sandboxAccountId === getAccountId(getConfigDefaultAccount());
|
|
43
|
+
const sandboxAccountId = getAccountId(providedAccountId || accountPrompt.account);
|
|
44
|
+
const isDefaultAccount = sandboxAccountId === getAccountId();
|
|
47
45
|
const baseUrl = getHubSpotWebsiteOrigin(getValidEnv(getEnv(sandboxAccountId)));
|
|
48
46
|
let parentAccountId;
|
|
49
47
|
const accountsList = getConfigAccounts();
|
|
@@ -54,9 +52,7 @@ exports.handler = async (options) => {
|
|
|
54
52
|
}
|
|
55
53
|
else if (!force) {
|
|
56
54
|
const parentAccountPrompt = await deleteSandboxPrompt(true);
|
|
57
|
-
parentAccountId = getAccountId(
|
|
58
|
-
account: parentAccountPrompt.account,
|
|
59
|
-
});
|
|
55
|
+
parentAccountId = getAccountId(parentAccountPrompt.account);
|
|
60
56
|
}
|
|
61
57
|
else {
|
|
62
58
|
logger.error(i18n(`${i18nKey}.failure.noParentAccount`));
|
|
@@ -66,7 +62,7 @@ exports.handler = async (options) => {
|
|
|
66
62
|
}
|
|
67
63
|
const url = `${baseUrl}/sandboxes/${parentAccountId}`;
|
|
68
64
|
const command = `hs auth ${getEnv(sandboxAccountId) === 'qa' ? '--qa' : ''} --account=${parentAccountId}`;
|
|
69
|
-
if (parentAccountId && !getAccountId(
|
|
65
|
+
if (parentAccountId && !getAccountId(parentAccountId)) {
|
|
70
66
|
logger.log('');
|
|
71
67
|
logger.error(i18n(`${i18nKey}.failure.noParentPortalAvailable`, {
|
|
72
68
|
parentAccountId,
|
package/lang/en.lyaml
CHANGED
|
@@ -532,6 +532,7 @@ en:
|
|
|
532
532
|
welcomeMessage: "Welcome to HubSpot Developer Projects!"
|
|
533
533
|
examples:
|
|
534
534
|
default: "Create a new project"
|
|
535
|
+
templateSource: "Create a new project from a custom GitHub repository. The repository must contain a valid project template and a config.json file defining the available templates"
|
|
535
536
|
options:
|
|
536
537
|
dest:
|
|
537
538
|
describe: "Directory where the project should be created"
|
|
@@ -972,7 +973,7 @@ en:
|
|
|
972
973
|
convertFields:
|
|
973
974
|
describe: "If true, converts any javascript fields files contained in module folder or project root."
|
|
974
975
|
clean:
|
|
975
|
-
describe: "Will
|
|
976
|
+
describe: "Will delete the destination directory and its contents before uploading. This will also clear the global content associated with any global partial templates and modules."
|
|
976
977
|
force:
|
|
977
978
|
describe: "Skips confirmation prompts when doing a clean upload."
|
|
978
979
|
previewUrl: "To preview this theme, visit: {{ previewUrl }}"
|
|
@@ -987,7 +988,7 @@ en:
|
|
|
987
988
|
uploading: "Uploading files from \"{{ src }}\" to \"{{ dest }}\" in the Design Manager of account {{ accountId }}"
|
|
988
989
|
notUploaded: "There was an error processing \"{{ src }}\". The file has not been uploaded."
|
|
989
990
|
cleaning: "Removing \"{{ filePath }}\" from account {{ accountId }} and uploading local..."
|
|
990
|
-
confirmCleanUpload: "You are about to
|
|
991
|
+
confirmCleanUpload: "You are about to delete the directory \"{{ filePath }}\" and its contents on HubSpot account {{ accountId }} before uploading. This will also clear the global content associated with any global partial templates and modules. Are you sure you want to do this?"
|
|
991
992
|
watch:
|
|
992
993
|
describe: "Watch a directory on your computer for changes and upload the changed files to the HubSpot CMS."
|
|
993
994
|
errors:
|
|
@@ -1075,6 +1076,7 @@ en:
|
|
|
1075
1076
|
fileChangeError: "Failed to notify local dev server of file change: {{ message }}"
|
|
1076
1077
|
localDev:
|
|
1077
1078
|
confirmDefaultAccountIsTarget:
|
|
1079
|
+
configError: "An error occurred while reading the default account from your config. Run {{ authCommand }} to re-auth this account"
|
|
1078
1080
|
declineDefaultAccountExplanation: "To develop on a different account, run {{ useCommand }} to change your default account, then re-run {{ devCommand }}."
|
|
1079
1081
|
checkIfDefaultAccountIsSupported:
|
|
1080
1082
|
publicApp: "This project contains a public app. Local development of public apps is only supported on developer accounts and developer test accounts. Change your default account using {{ useCommand }}, or link a new account with {{ authCommand }}."
|
|
@@ -1095,6 +1097,7 @@ en:
|
|
|
1095
1097
|
createInitialBuildForNewProject:
|
|
1096
1098
|
initialUploadMessage: "HubSpot Local Dev Server Startup"
|
|
1097
1099
|
projectLockedError: "Your project is locked. This may mean that another user is running the {{#bold}}`hs project watch`{{/bold}} command for this project. If this is you, unlock the project in Projects UI."
|
|
1100
|
+
genericError: "An error occurred while creating the initial build for this project. Run {{ uploadCommand }} to try again."
|
|
1098
1101
|
checkIfParentAccountIsAuthed:
|
|
1099
1102
|
notAuthedError: "To develop this project locally, run {{ authCommand }} to authenticate the App Developer Account {{ accountId }} associated with {{ accountIdentifier }}."
|
|
1100
1103
|
projects:
|
|
@@ -1309,6 +1312,7 @@ en:
|
|
|
1309
1312
|
invalidCharacters: "The selected destination contains invalid characters. Please provide a new path and try again."
|
|
1310
1313
|
invalidTemplate: "[--template] Could not find template {{ template }}. Please choose an available template."
|
|
1311
1314
|
noProjectsInConfig: "Please ensure that there is a config.json file that contains a \"projects\" field."
|
|
1315
|
+
missingConfigFileTemplateSource: "Please ensure that there is a config.json file in the repository used as the --template-source"
|
|
1312
1316
|
missingPropertiesInConfig: "Please ensure that each of the projects in your config.json file contain the following properties: [\"name\", \"label\", \"path\", \"insertPath\"]."
|
|
1313
1317
|
selectPublicAppPrompt:
|
|
1314
1318
|
selectAppIdMigrate: "[--appId] Choose an app under {{ accountName }} to migrate:"
|
|
@@ -1421,6 +1425,7 @@ en:
|
|
|
1421
1425
|
invalidUser: "Couldn't create {{#bold}}{{ accountName }}{{/bold}} because your account has been removed from {{#bold}}{{ parentAccountName }}{{/bold}} or your permission set doesn't allow you to create the sandbox. To update your permissions, contact a super admin in {{#bold}}{{ parentAccountName }}{{/bold}}."
|
|
1422
1426
|
403Gating: "Couldn't create {{#bold}}{{ accountName }}{{/bold}} because {{#bold}}{{ parentAccountName }}{{/bold}} does not have access to development sandboxes. To opt in to the CRM Development Beta and use development sandboxes, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236."
|
|
1423
1427
|
usageLimitsFetch: "Unable to fetch sandbox usage limits. Please try again."
|
|
1428
|
+
generic: "An error occurred while creating a new sandbox. Please try again."
|
|
1424
1429
|
limit:
|
|
1425
1430
|
developer:
|
|
1426
1431
|
one: "{{#bold}}{{ accountName }}{{/bold}} reached the limit of {{ limit }} development sandbox.
|
|
@@ -1499,7 +1504,7 @@ en:
|
|
|
1499
1504
|
missingScopeError: "Couldn't execute the {{ request }} because the access key for {{ accountName }} is missing required scopes. To update scopes, run {{ authCommand }}. Then deactivate the existing key and generate a new one that includes the missing scopes."
|
|
1500
1505
|
serverless:
|
|
1501
1506
|
verifyAccessKeyAndUserAccess:
|
|
1502
|
-
fetchScopeDataError: "Error verifying access of scopeGroup {{ scopeGroup }}:
|
|
1507
|
+
fetchScopeDataError: "Error verifying access of scopeGroup {{ scopeGroup }}:"
|
|
1503
1508
|
portalMissingScope: "Your account does not have access to this action. Talk to an account admin to request it."
|
|
1504
1509
|
userMissingScope: "You don't have access to this action. Ask an account admin to change your permissions in Users & Teams settings."
|
|
1505
1510
|
genericMissingScope: "Your access key does not allow this action. Please generate a new access key by running `hs auth personalaccesskey`."
|
package/lib/LocalDevManager.d.ts
CHANGED
|
@@ -1 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
import { FSWatcher } from 'chokidar';
|
|
2
|
+
import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
3
|
+
import { PublicApp } from '@hubspot/local-dev-lib/types/Apps';
|
|
4
|
+
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
5
|
+
import { Component, ProjectConfig } from '../types/Projects';
|
|
6
|
+
type LocalDevManagerConstructorOptions = {
|
|
7
|
+
targetAccountId: number;
|
|
8
|
+
parentAccountId: number;
|
|
9
|
+
projectConfig: ProjectConfig;
|
|
10
|
+
projectDir: string;
|
|
11
|
+
projectId: number;
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
deployedBuild: Build;
|
|
14
|
+
isGithubLinked: boolean;
|
|
15
|
+
runnableComponents: Component[];
|
|
16
|
+
env: Environment;
|
|
17
|
+
};
|
|
18
|
+
declare class LocalDevManager {
|
|
19
|
+
targetAccountId: number;
|
|
20
|
+
targetProjectAccountId: number;
|
|
21
|
+
projectConfig: ProjectConfig;
|
|
22
|
+
projectDir: string;
|
|
23
|
+
projectId: number;
|
|
24
|
+
debug: boolean;
|
|
25
|
+
deployedBuild: Build;
|
|
26
|
+
isGithubLinked: boolean;
|
|
27
|
+
watcher: FSWatcher | null;
|
|
28
|
+
uploadWarnings: {
|
|
29
|
+
[key: string]: boolean;
|
|
30
|
+
};
|
|
31
|
+
runnableComponents: Component[];
|
|
32
|
+
activeApp: Component | null;
|
|
33
|
+
activePublicAppData: PublicApp | null;
|
|
34
|
+
env: Environment;
|
|
35
|
+
publicAppActiveInstalls: number | null;
|
|
36
|
+
projectSourceDir: string;
|
|
37
|
+
mostRecentUploadWarning: string | null;
|
|
38
|
+
constructor(options: LocalDevManagerConstructorOptions);
|
|
39
|
+
setActiveApp(appUid?: string): Promise<void>;
|
|
40
|
+
setActivePublicAppData(): Promise<void>;
|
|
41
|
+
checkActivePublicAppInstalls(): Promise<void>;
|
|
42
|
+
start(): Promise<void>;
|
|
43
|
+
stop(showProgress?: boolean): Promise<void>;
|
|
44
|
+
checkPublicAppInstallation(): Promise<void>;
|
|
45
|
+
updateKeypressListeners(): void;
|
|
46
|
+
getUploadCommand(): string;
|
|
47
|
+
logUploadWarning(reason?: string): void;
|
|
48
|
+
monitorConsoleOutput(): void;
|
|
49
|
+
compareLocalProjectToDeployed(): void;
|
|
50
|
+
startWatching(): void;
|
|
51
|
+
stopWatching(): Promise<void>;
|
|
52
|
+
handleWatchEvent(filePath: string, event: string, configPaths: string[]): void;
|
|
53
|
+
devServerSetup(): Promise<boolean>;
|
|
54
|
+
devServerStart(): Promise<void>;
|
|
55
|
+
devServerFileChange(filePath: string, event: string): void;
|
|
56
|
+
devServerCleanup(): Promise<boolean>;
|
|
57
|
+
}
|
|
58
|
+
export default LocalDevManager;
|