@hubspot/cli 7.0.7-experimental.0 → 7.0.9-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 -8
- package/commands/account/createOverride.d.ts +10 -0
- package/commands/account/createOverride.js +64 -0
- package/commands/account/list.js +5 -1
- package/commands/account.js +2 -0
- package/commands/function/deploy.js +1 -1
- package/commands/init.js +1 -1
- package/commands/project/cloneApp.js +1 -1
- package/commands/project/migrateApp.js +1 -1
- package/lang/en.lyaml +22 -1
- package/lib/constants.d.ts +7 -1
- package/lib/constants.js +8 -2
- package/lib/doctor/Diagnosis.d.ts +1 -0
- package/lib/doctor/Diagnosis.js +7 -0
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -0
- package/lib/doctor/DiagnosticInfoBuilder.js +1 -0
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +19 -0
- package/lib/polling.d.ts +5 -13
- package/lib/polling.js +7 -21
- package/lib/projects/buildAndDeploy.js +3 -3
- package/lib/projects/index.js +1 -1
- package/lib/projects/upload.js +1 -0
- package/package.json +3 -3
package/bin/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ const chalk = require('chalk');
|
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const { addUserAgentHeader } = require('@hubspot/local-dev-lib/http');
|
|
8
8
|
const { loadConfig, getAccountId, configFileExists, getConfigPath, validateConfig, } = require('@hubspot/local-dev-lib/config');
|
|
9
|
+
const { DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID, DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND, } = require('@hubspot/local-dev-lib/constants/config');
|
|
9
10
|
const { logError } = require('../lib/errorHandlers/index');
|
|
10
11
|
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
11
12
|
const { validateAccount } = require('../lib/validation');
|
|
@@ -164,7 +165,24 @@ const injectAccountIdMiddleware = async (options) => {
|
|
|
164
165
|
options.derivedAccountId = parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
165
166
|
}
|
|
166
167
|
else {
|
|
167
|
-
|
|
168
|
+
try {
|
|
169
|
+
options.derivedAccountId = getAccountId(account);
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
logError(error);
|
|
173
|
+
if (error.cause === DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID) {
|
|
174
|
+
logger.log(i18n(`${i18nKey}.injectAccountIdMiddleware.invalidAccountId`, {
|
|
175
|
+
overrideCommand: uiCommandReference('hs account create-override'),
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
if (error.cause === DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND) {
|
|
179
|
+
logger.log(i18n(`${i18nKey}.injectAccountIdMiddleware.accountNotFound`, {
|
|
180
|
+
configPath: getConfigPath(),
|
|
181
|
+
authCommand: uiCommandReference('hs account auth'),
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
process.exit(EXIT_CODES.ERROR);
|
|
185
|
+
}
|
|
168
186
|
}
|
|
169
187
|
};
|
|
170
188
|
const loadConfigMiddleware = async (options) => {
|
|
@@ -184,14 +202,9 @@ const loadConfigMiddleware = async (options) => {
|
|
|
184
202
|
}));
|
|
185
203
|
process.exit(EXIT_CODES.ERROR);
|
|
186
204
|
}
|
|
187
|
-
else if (!
|
|
205
|
+
else if (!options._.includes('init')) {
|
|
188
206
|
const { config: configPath } = options;
|
|
189
|
-
|
|
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
|
-
}
|
|
207
|
+
loadConfig(configPath, options);
|
|
195
208
|
}
|
|
196
209
|
maybeValidateConfig();
|
|
197
210
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const describe: null;
|
|
4
|
+
export declare const command = "create-override [account]";
|
|
5
|
+
type AccountInfoArgs = CommonArgs & ConfigArgs & {
|
|
6
|
+
account: string | number;
|
|
7
|
+
};
|
|
8
|
+
export declare function handler(args: ArgumentsCamelCase<AccountInfoArgs>): Promise<void>;
|
|
9
|
+
export declare function builder(yargs: Argv): Argv<AccountInfoArgs>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.command = exports.describe = void 0;
|
|
7
|
+
exports.handler = handler;
|
|
8
|
+
exports.builder = builder;
|
|
9
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
12
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
13
|
+
const config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
14
|
+
const config_2 = require("@hubspot/local-dev-lib/config");
|
|
15
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
16
|
+
const lang_1 = require("../../lib/lang");
|
|
17
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
18
|
+
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
19
|
+
const index_1 = require("../../lib/errorHandlers/index");
|
|
20
|
+
const i18nKey = 'commands.account.subcommands.createOverride';
|
|
21
|
+
exports.describe = null; // i18n(`${i18nKey}.describe`);
|
|
22
|
+
exports.command = 'create-override [account]';
|
|
23
|
+
async function handler(args) {
|
|
24
|
+
let overrideDefaultAccount = args.account;
|
|
25
|
+
if (!overrideDefaultAccount) {
|
|
26
|
+
overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
27
|
+
}
|
|
28
|
+
else if (!(0, config_2.getAccountId)(overrideDefaultAccount)) {
|
|
29
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.accountNotFound`, {
|
|
30
|
+
configPath: (0, config_2.getConfigPath)() || '',
|
|
31
|
+
}));
|
|
32
|
+
overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
33
|
+
}
|
|
34
|
+
const accountId = (0, config_2.getAccountId)(overrideDefaultAccount);
|
|
35
|
+
try {
|
|
36
|
+
const overrideFilePath = path_1.default.join((0, path_2.getCwd)(), config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME);
|
|
37
|
+
await fs_extra_1.default.writeFile(overrideFilePath, accountId.toString(), 'utf8');
|
|
38
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success`, { overrideFilePath }));
|
|
39
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
(0, index_1.logError)(e);
|
|
43
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function builder(yargs) {
|
|
47
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
48
|
+
yargs.positional('account', {
|
|
49
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
|
|
50
|
+
type: 'string',
|
|
51
|
+
});
|
|
52
|
+
yargs.example([
|
|
53
|
+
['$0 account create-override', (0, lang_1.i18n)(`${i18nKey}.examples.default`)],
|
|
54
|
+
[
|
|
55
|
+
'$0 account create-override 12345678',
|
|
56
|
+
(0, lang_1.i18n)(`${i18nKey}.examples.idBased`),
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
'$0 account create-override MyAccount',
|
|
60
|
+
(0, lang_1.i18n)(`${i18nKey}.examples.nameBased`),
|
|
61
|
+
],
|
|
62
|
+
]);
|
|
63
|
+
return yargs;
|
|
64
|
+
}
|
package/commands/account/list.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, getConfigDefaultAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
5
|
+
const { getConfigPath, getConfigDefaultAccount, getConfigAccounts, getDefaultAccountOverrideFilePath, } = require('@hubspot/local-dev-lib/config');
|
|
6
6
|
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
7
7
|
const { addConfigOptions } = require('../../lib/commonOpts');
|
|
8
8
|
const { getTableContents, getTableHeader } = require('../../lib/ui/table');
|
|
@@ -64,6 +64,7 @@ exports.handler = async (options) => {
|
|
|
64
64
|
const { derivedAccountId } = options;
|
|
65
65
|
trackCommandUsage('accounts-list', null, derivedAccountId);
|
|
66
66
|
const configPath = getConfigPath();
|
|
67
|
+
const overrideFilePath = getDefaultAccountOverrideFilePath();
|
|
67
68
|
const accountsList = getConfigAccounts();
|
|
68
69
|
const mappedPortalData = sortAndMapPortals(accountsList);
|
|
69
70
|
const portalData = getPortalData(mappedPortalData);
|
|
@@ -73,6 +74,9 @@ exports.handler = async (options) => {
|
|
|
73
74
|
i18n(`${i18nKey}.labels.authType`),
|
|
74
75
|
]));
|
|
75
76
|
logger.log(i18n(`${i18nKey}.configPath`, { configPath }));
|
|
77
|
+
if (overrideFilePath) {
|
|
78
|
+
logger.log(i18n(`${i18nKey}.overrideFilePath`, { overrideFilePath }));
|
|
79
|
+
}
|
|
76
80
|
logger.log(i18n(`${i18nKey}.defaultAccount`, {
|
|
77
81
|
account: getConfigDefaultAccount(),
|
|
78
82
|
}));
|
package/commands/account.js
CHANGED
|
@@ -9,6 +9,7 @@ const use = require('./account/use');
|
|
|
9
9
|
const info = require('./account/info');
|
|
10
10
|
const remove = require('./account/remove');
|
|
11
11
|
const clean = require('./account/clean');
|
|
12
|
+
const createOverride = require('./account/createOverride');
|
|
12
13
|
const i18nKey = 'commands.account';
|
|
13
14
|
exports.command = ['account', 'accounts'];
|
|
14
15
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
@@ -21,6 +22,7 @@ exports.builder = yargs => {
|
|
|
21
22
|
.command(info)
|
|
22
23
|
.command(remove)
|
|
23
24
|
.command(clean)
|
|
25
|
+
.command(createOverride)
|
|
24
26
|
.demandCommand(1, '');
|
|
25
27
|
return yargs;
|
|
26
28
|
};
|
|
@@ -38,7 +38,7 @@ exports.handler = async (options) => {
|
|
|
38
38
|
});
|
|
39
39
|
try {
|
|
40
40
|
const { data: buildId } = await buildPackage(derivedAccountId, functionPath);
|
|
41
|
-
const successResp = await poll(
|
|
41
|
+
const successResp = await poll(getBuildStatus, derivedAccountId, buildId);
|
|
42
42
|
const buildTimeSeconds = (successResp.buildTime / 1000).toFixed(2);
|
|
43
43
|
SpinniesManager.succeed('loading');
|
|
44
44
|
await outputBuildLog(successResp.cdnUrl);
|
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 { auth: 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)) ||
|
|
@@ -68,7 +68,7 @@ exports.handler = async (options) => {
|
|
|
68
68
|
text: i18n(`${i18nKey}.cloneStatus.inProgress`),
|
|
69
69
|
});
|
|
70
70
|
const { data: { exportId }, } = await cloneApp(derivedAccountId, appId);
|
|
71
|
-
const { status } = await poll(
|
|
71
|
+
const { status } = await poll(checkCloneStatus, derivedAccountId, exportId);
|
|
72
72
|
if (status === 'SUCCESS') {
|
|
73
73
|
// Ensure correct project folder structure exists
|
|
74
74
|
const baseDestPath = path.resolve(getCwd(), projectDest);
|
|
@@ -126,7 +126,7 @@ exports.handler = async (options) => {
|
|
|
126
126
|
});
|
|
127
127
|
const { data: migrateResponse } = await migrateApp(derivedAccountId, appId, projectName);
|
|
128
128
|
const { id } = migrateResponse;
|
|
129
|
-
const pollResponse = await poll(
|
|
129
|
+
const pollResponse = await poll(checkMigrationStatus, derivedAccountId, id);
|
|
130
130
|
const { status, project } = pollResponse;
|
|
131
131
|
if (status === 'SUCCESS') {
|
|
132
132
|
const absoluteDestPath = path.resolve(getCwd(), projectDest);
|
package/lang/en.lyaml
CHANGED
|
@@ -11,6 +11,9 @@ en:
|
|
|
11
11
|
portalEnvVarDeprecated: "The HUBSPOT_PORTAL_ID environment variable is deprecated. Please use HUBSPOT_ACCOUNT_ID instead."
|
|
12
12
|
loadConfigMiddleware:
|
|
13
13
|
configFileExists: "A configuration file already exists at {{ configPath }}. To specify a new configuration file, delete the existing one and try again."
|
|
14
|
+
injectAccountIdMiddleware:
|
|
15
|
+
invalidAccountId: "In the default override file (.hsaccount), the account ID must be a number. Please delete the current file and generate a new one using {{ overrideCommand }}."
|
|
16
|
+
accountNotFound: "The account in the default override file (.hsaccount) wasn't found in your configured accounts. You can authorize this account using {{ authCommand }}."
|
|
14
17
|
completion:
|
|
15
18
|
describe: "Enable bash completion shortcuts for commands. Concat the generated script to your .bashrc, .bash_profile, or .zshrc file."
|
|
16
19
|
examples:
|
|
@@ -18,11 +21,24 @@ en:
|
|
|
18
21
|
account:
|
|
19
22
|
describe: "Commands for managing configured accounts."
|
|
20
23
|
subcommands:
|
|
24
|
+
createOverride:
|
|
25
|
+
describe: "Create a new default account override file (.hs-account) in the current working directory."
|
|
26
|
+
success: "Default account override file created at {{ overrideFilePath }}"
|
|
27
|
+
errors:
|
|
28
|
+
accountNotFound: "The specified account could not be found in the config file {{ configPath }}"
|
|
29
|
+
options:
|
|
30
|
+
account:
|
|
31
|
+
describe: "Name or ID of the account to create an override file for."
|
|
32
|
+
examples:
|
|
33
|
+
default: "Create a new default account override file (.hs-account) in the current working directory"
|
|
34
|
+
idBased: "Create a new default account override file (.hs-account) in the current working directory, using the account with accountId \"1234567\""
|
|
35
|
+
nameBased: "Create a new default account override file (.hs-account) in the current working directory, using the account with name \"MyAccount\""
|
|
21
36
|
list:
|
|
22
37
|
accounts: "{{#bold}}Accounts{{/bold}}:"
|
|
23
38
|
defaultAccount: "{{#bold}}Default account{{/bold}}: {{ account }}"
|
|
24
39
|
describe: "List names of accounts defined in config."
|
|
25
40
|
configPath: "{{#bold}}Config path{{/bold}}: {{ configPath }}"
|
|
41
|
+
overrideFilePath: "{{#bold}}Default account override file path{{/bold}}: {{ overrideFilePath }}"
|
|
26
42
|
labels:
|
|
27
43
|
accountId: "Account ID"
|
|
28
44
|
authType: "Auth Type"
|
|
@@ -1113,6 +1129,7 @@ en:
|
|
|
1113
1129
|
notFound: "Your project {{#bold}}{{ projectName }}{{/bold}} could not be found in {{#bold}}{{ accountIdentifier }}{{/bold}}."
|
|
1114
1130
|
pollFetchProject:
|
|
1115
1131
|
checkingProject: "Checking if project exists in {{ accountIdentifier }}"
|
|
1132
|
+
unableToFindAutodeployStatus: "Unable to find the auto deploy for build #{{ buildId }}. This deploy may have been skipped. {{ viewDeploysLink }}."
|
|
1116
1133
|
logFeedbackMessage:
|
|
1117
1134
|
feedbackHeader: "We'd love to hear your feedback!"
|
|
1118
1135
|
feedbackMessage: "How are you liking the new projects and developer tools? \n > Run `{{#yellow}}hs feedback{{/yellow}}` to let us know what you think!\n"
|
|
@@ -1128,7 +1145,6 @@ en:
|
|
|
1128
1145
|
buildSucceededAutomaticallyDeploying: "Build #{{ buildId }} succeeded. {{#bold}}Automatically deploying{{/bold}} to {{ accountIdentifier }}\n"
|
|
1129
1146
|
cleanedUpTempFile: "Cleaned up temporary file {{ path }}"
|
|
1130
1147
|
viewDeploys: "View all deploys for this project in HubSpot"
|
|
1131
|
-
unableToFindAutodeployStatus: "Unable to find the auto deploy for build #{{ buildId }}. This deploy may have been skipped. {{ viewDeploysLink }}."
|
|
1132
1148
|
projectUpload:
|
|
1133
1149
|
uploadProjectFiles:
|
|
1134
1150
|
add: "Uploading {{#bold}}{{ projectName }}{{/bold}} project files to {{ accountIdentifier }}"
|
|
@@ -1511,6 +1527,9 @@ en:
|
|
|
1511
1527
|
doctor:
|
|
1512
1528
|
runningDiagnostics: "Running diagnostics..."
|
|
1513
1529
|
diagnosticsComplete: "Diagnostics complete"
|
|
1530
|
+
defaultAccountOverrideFileChecks:
|
|
1531
|
+
overrideActive: "Default account override file active: {{ defaultAccountOverrideFile }}"
|
|
1532
|
+
overrideAccountId: "Active account ID: {{ overrideAccountId }}"
|
|
1514
1533
|
accountChecks:
|
|
1515
1534
|
active: "Default account active"
|
|
1516
1535
|
inactive: "Default account isn't active"
|
|
@@ -1557,6 +1576,8 @@ en:
|
|
|
1557
1576
|
defaultAccountSubHeader: "Default Account: {{accountDetails}}"
|
|
1558
1577
|
noConfigFile: "CLI configuration not found"
|
|
1559
1578
|
noConfigFileSecondary: "Run {{command}} and follow the prompts to create your CLI configuration file and connect it to your HubSpot account"
|
|
1579
|
+
defaultAccountOverrideFile:
|
|
1580
|
+
header: "Default account override file path:"
|
|
1560
1581
|
projectConfig:
|
|
1561
1582
|
header: "Project configuration"
|
|
1562
1583
|
projectDirSubHeader: "Project dir: {{#bold}}{{ projectDir }}{{/bold}}"
|
package/lib/constants.d.ts
CHANGED
|
@@ -6,7 +6,13 @@ export declare const MARKETPLACE_FOLDER: "@marketplace";
|
|
|
6
6
|
export declare const CONFIG_FLAGS: {
|
|
7
7
|
readonly USE_CUSTOM_OBJECT_HUBFILE: "useCustomObjectHubfile";
|
|
8
8
|
};
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const POLLING_DELAY = 2000;
|
|
10
|
+
export declare const POLLING_STATUS: {
|
|
11
|
+
readonly SUCCESS: "SUCCESS";
|
|
12
|
+
readonly ERROR: "ERROR";
|
|
13
|
+
readonly REVERTED: "REVERTED";
|
|
14
|
+
readonly FAILURE: "FAILURE";
|
|
15
|
+
};
|
|
10
16
|
export declare const PROJECT_CONFIG_FILE: "hsproject.json";
|
|
11
17
|
export declare const PROJECT_BUILD_STATES: {
|
|
12
18
|
readonly BUILDING: "BUILDING";
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.
|
|
3
|
+
exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.POLLING_STATUS = exports.POLLING_DELAY = exports.CONFIG_FLAGS = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
|
|
4
4
|
exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = 'HubSpot/hubspot-project-components';
|
|
5
5
|
exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = 'main';
|
|
6
6
|
exports.FEEDBACK_INTERVAL = 10;
|
|
@@ -9,7 +9,13 @@ exports.MARKETPLACE_FOLDER = '@marketplace';
|
|
|
9
9
|
exports.CONFIG_FLAGS = {
|
|
10
10
|
USE_CUSTOM_OBJECT_HUBFILE: 'useCustomObjectHubfile',
|
|
11
11
|
};
|
|
12
|
-
exports.
|
|
12
|
+
exports.POLLING_DELAY = 2000;
|
|
13
|
+
exports.POLLING_STATUS = {
|
|
14
|
+
SUCCESS: 'SUCCESS',
|
|
15
|
+
ERROR: 'ERROR',
|
|
16
|
+
REVERTED: 'REVERTED',
|
|
17
|
+
FAILURE: 'FAILURE',
|
|
18
|
+
};
|
|
13
19
|
exports.PROJECT_CONFIG_FILE = 'hsproject.json';
|
|
14
20
|
exports.PROJECT_BUILD_STATES = {
|
|
15
21
|
BUILDING: 'BUILDING',
|
|
@@ -21,6 +21,7 @@ export declare class Diagnosis {
|
|
|
21
21
|
addCliSection(section: Section): void;
|
|
22
22
|
addProjectSection(section: Section): void;
|
|
23
23
|
addCLIConfigSection(section: Section): void;
|
|
24
|
+
addDefaultAccountOverrideFileSection(section: Section): void;
|
|
24
25
|
toString(): string;
|
|
25
26
|
private generateSections;
|
|
26
27
|
}
|
package/lib/doctor/Diagnosis.js
CHANGED
|
@@ -29,6 +29,10 @@ class Diagnosis {
|
|
|
29
29
|
header: i18n(`${i18nKey}.cliConfig.header`),
|
|
30
30
|
sections: [],
|
|
31
31
|
},
|
|
32
|
+
defaultAccountOverrideFile: {
|
|
33
|
+
header: i18n(`${i18nKey}.defaultAccountOverrideFile.header`),
|
|
34
|
+
sections: [],
|
|
35
|
+
},
|
|
32
36
|
project: {
|
|
33
37
|
header: i18n(`${i18nKey}.projectConfig.header`),
|
|
34
38
|
subheaders: [
|
|
@@ -71,6 +75,9 @@ class Diagnosis {
|
|
|
71
75
|
addCLIConfigSection(section) {
|
|
72
76
|
this.diagnosis.cliConfig.sections.push(section);
|
|
73
77
|
}
|
|
78
|
+
addDefaultAccountOverrideFileSection(section) {
|
|
79
|
+
this.diagnosis.defaultAccountOverrideFile.sections.push(section);
|
|
80
|
+
}
|
|
74
81
|
toString() {
|
|
75
82
|
const output = [];
|
|
76
83
|
for (const value of Object.values(this.diagnosis)) {
|
|
@@ -60,6 +60,7 @@ class DiagnosticInfoBuilder {
|
|
|
60
60
|
arch,
|
|
61
61
|
path: mainModule?.path,
|
|
62
62
|
config: (0, config_2.getConfigPath)(),
|
|
63
|
+
defaultAccountOverrideFile: (0, config_1.getDefaultAccountOverrideFilePath)(),
|
|
63
64
|
versions: {
|
|
64
65
|
[hubspotCli]: package_json_1.default.version,
|
|
65
66
|
node,
|
package/lib/doctor/Doctor.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class Doctor {
|
|
|
10
10
|
private performCliChecks;
|
|
11
11
|
private performProjectChecks;
|
|
12
12
|
private performCliConfigChecks;
|
|
13
|
+
private performDefaultAccountOverrideFileChecks;
|
|
13
14
|
private checkIfAccessTokenValid;
|
|
14
15
|
private checkIfNodeIsInstalled;
|
|
15
16
|
private checkIfNpmIsInstalled;
|
package/lib/doctor/Doctor.js
CHANGED
|
@@ -49,6 +49,7 @@ class Doctor {
|
|
|
49
49
|
await Promise.all([
|
|
50
50
|
...this.performCliChecks(),
|
|
51
51
|
...this.performCliConfigChecks(),
|
|
52
|
+
...this.performDefaultAccountOverrideFileChecks(),
|
|
52
53
|
...(this.projectConfig?.projectConfig ? this.performProjectChecks() : []),
|
|
53
54
|
]);
|
|
54
55
|
SpinniesManager_1.default.succeed('runningDiagnostics', {
|
|
@@ -87,6 +88,24 @@ class Doctor {
|
|
|
87
88
|
}
|
|
88
89
|
return [this.checkIfAccessTokenValid()];
|
|
89
90
|
}
|
|
91
|
+
performDefaultAccountOverrideFileChecks() {
|
|
92
|
+
const localI18nKey = `${i18nKey}.defaultAccountOverrideFileChecks`;
|
|
93
|
+
if (this.diagnosticInfo?.defaultAccountOverrideFile) {
|
|
94
|
+
this.diagnosis?.addDefaultAccountOverrideFileSection({
|
|
95
|
+
type: 'warning',
|
|
96
|
+
message: i18n(`${localI18nKey}.overrideActive`, {
|
|
97
|
+
defaultAccountOverrideFile: this.diagnosticInfo.defaultAccountOverrideFile,
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
this.diagnosis?.addDefaultAccountOverrideFileSection({
|
|
101
|
+
type: 'warning',
|
|
102
|
+
message: i18n(`${localI18nKey}.overrideAccountId`, {
|
|
103
|
+
overrideAccountId: (0, config_1.getCWDAccountOverride)(),
|
|
104
|
+
}),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
90
109
|
async checkIfAccessTokenValid() {
|
|
91
110
|
const localI18nKey = `${i18nKey}.accountChecks`;
|
|
92
111
|
try {
|
package/lib/polling.d.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { HubSpotPromise } from '@hubspot/local-dev-lib/types/Http';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readonly SUCCESS: "SUCCESS";
|
|
5
|
-
readonly ERROR: "ERROR";
|
|
6
|
-
readonly REVERTED: "REVERTED";
|
|
7
|
-
readonly FAILURE: "FAILURE";
|
|
8
|
-
};
|
|
2
|
+
import { ValueOf } from '@hubspot/local-dev-lib/types/Utils';
|
|
3
|
+
import { POLLING_STATUS } from './constants';
|
|
9
4
|
type GenericPollingResponse = {
|
|
10
|
-
status:
|
|
5
|
+
status: ValueOf<typeof POLLING_STATUS>;
|
|
11
6
|
};
|
|
12
|
-
type PollingCallback<T extends GenericPollingResponse> = () => HubSpotPromise<T>;
|
|
13
|
-
export declare function poll<T extends GenericPollingResponse>(callback: PollingCallback<T>,
|
|
14
|
-
successStates: string[];
|
|
15
|
-
errorStates: string[];
|
|
16
|
-
}): Promise<T>;
|
|
7
|
+
type PollingCallback<T extends GenericPollingResponse> = (accountId: number, taskId: number | string) => HubSpotPromise<T>;
|
|
8
|
+
export declare function poll<T extends GenericPollingResponse>(callback: PollingCallback<T>, accountId: number, taskId: number | string): Promise<T>;
|
|
17
9
|
export {};
|
package/lib/polling.js
CHANGED
|
@@ -1,34 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_POLLING_STATES = void 0;
|
|
4
3
|
exports.poll = poll;
|
|
5
4
|
const constants_1 = require("./constants");
|
|
6
|
-
|
|
7
|
-
STARTED: 'STARTED',
|
|
8
|
-
SUCCESS: 'SUCCESS',
|
|
9
|
-
ERROR: 'ERROR',
|
|
10
|
-
REVERTED: 'REVERTED',
|
|
11
|
-
FAILURE: 'FAILURE',
|
|
12
|
-
};
|
|
13
|
-
const DEFAULT_POLLING_STATUS_LOOKUP = {
|
|
14
|
-
successStates: [exports.DEFAULT_POLLING_STATES.SUCCESS],
|
|
15
|
-
errorStates: [
|
|
16
|
-
exports.DEFAULT_POLLING_STATES.ERROR,
|
|
17
|
-
exports.DEFAULT_POLLING_STATES.REVERTED,
|
|
18
|
-
exports.DEFAULT_POLLING_STATES.FAILURE,
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
function poll(callback, statusLookup = DEFAULT_POLLING_STATUS_LOOKUP) {
|
|
5
|
+
function poll(callback, accountId, taskId) {
|
|
22
6
|
return new Promise((resolve, reject) => {
|
|
23
7
|
const pollInterval = setInterval(async () => {
|
|
24
8
|
try {
|
|
25
|
-
const { data: pollResp } = await callback();
|
|
9
|
+
const { data: pollResp } = await callback(accountId, taskId);
|
|
26
10
|
const { status } = pollResp;
|
|
27
|
-
if (
|
|
11
|
+
if (status === constants_1.POLLING_STATUS.SUCCESS) {
|
|
28
12
|
clearInterval(pollInterval);
|
|
29
13
|
resolve(pollResp);
|
|
30
14
|
}
|
|
31
|
-
else if (
|
|
15
|
+
else if (status === constants_1.POLLING_STATUS.ERROR ||
|
|
16
|
+
status === constants_1.POLLING_STATUS.REVERTED ||
|
|
17
|
+
status === constants_1.POLLING_STATUS.FAILURE) {
|
|
32
18
|
clearInterval(pollInterval);
|
|
33
19
|
reject(pollResp);
|
|
34
20
|
}
|
|
@@ -37,6 +23,6 @@ function poll(callback, statusLookup = DEFAULT_POLLING_STATUS_LOOKUP) {
|
|
|
37
23
|
clearInterval(pollInterval);
|
|
38
24
|
reject(error);
|
|
39
25
|
}
|
|
40
|
-
}, constants_1.
|
|
26
|
+
}, constants_1.POLLING_DELAY);
|
|
41
27
|
});
|
|
42
28
|
}
|
|
@@ -197,13 +197,13 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
|
|
|
197
197
|
resolve(taskStatus);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
}, constants_1.
|
|
200
|
+
}, constants_1.POLLING_DELAY);
|
|
201
201
|
});
|
|
202
202
|
};
|
|
203
203
|
}
|
|
204
204
|
function pollBuildAutodeployStatus(accountId, taskName, buildId) {
|
|
205
205
|
return new Promise((resolve, reject) => {
|
|
206
|
-
let maxIntervals = (30 * 1000) / constants_1.
|
|
206
|
+
let maxIntervals = (30 * 1000) / constants_1.POLLING_DELAY; // Num of intervals in ~30s
|
|
207
207
|
const pollInterval = setInterval(async () => {
|
|
208
208
|
let build;
|
|
209
209
|
try {
|
|
@@ -224,7 +224,7 @@ function pollBuildAutodeployStatus(accountId, taskName, buildId) {
|
|
|
224
224
|
else {
|
|
225
225
|
maxIntervals -= 1;
|
|
226
226
|
}
|
|
227
|
-
}, constants_1.
|
|
227
|
+
}, constants_1.POLLING_DELAY);
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
exports.pollBuildStatus = makePollTaskStatusFunc({
|
package/lib/projects/index.js
CHANGED
|
@@ -171,7 +171,7 @@ async function pollFetchProject(accountId, projectName) {
|
|
|
171
171
|
reject(err);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
}, constants_1.
|
|
174
|
+
}, constants_1.POLLING_DELAY);
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
async function ensureProjectExists(accountId, projectName, { forceCreate = false, allowCreate = true, noLogs = false, withPolling = false, uploadCommand = false, } = {}) {
|
package/lib/projects/upload.js
CHANGED
|
@@ -76,6 +76,7 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
|
|
|
76
76
|
}));
|
|
77
77
|
const { buildId, error } = await uploadProjectFiles(accountId, projectConfig.name, tempFile.name, uploadMessage, projectConfig.platformVersion);
|
|
78
78
|
if (error) {
|
|
79
|
+
console.log(error);
|
|
79
80
|
resolve({ uploadError: error });
|
|
80
81
|
}
|
|
81
82
|
else if (callbackFunc) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.9-experimental.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@hubspot/local-dev-lib": "
|
|
8
|
+
"@hubspot/local-dev-lib": "0.1.2-experimental.0",
|
|
9
9
|
"@hubspot/serverless-dev-runtime": "7.0.1",
|
|
10
10
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
11
|
-
"@hubspot/ui-extensions-dev-server": "0.8.
|
|
11
|
+
"@hubspot/ui-extensions-dev-server": "0.8.40",
|
|
12
12
|
"archiver": "^7.0.1",
|
|
13
13
|
"chalk": "^4.1.2",
|
|
14
14
|
"chokidar": "^3.0.1",
|