@hubspot/cli 7.0.9-experimental.0 → 7.0.10-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 +8 -21
- package/commands/account/list.js +1 -5
- package/commands/account.js +0 -2
- package/commands/function/deploy.js +1 -1
- package/commands/init.js +1 -1
- package/commands/project/cloneApp.js +1 -1
- package/commands/project/deploy.js +6 -1
- package/commands/project/migrateApp.js +1 -1
- package/commands/project/upload.js +7 -2
- package/lang/en.lyaml +1 -22
- package/lib/constants.d.ts +1 -7
- package/lib/constants.js +2 -8
- package/lib/doctor/Diagnosis.d.ts +0 -1
- package/lib/doctor/Diagnosis.js +0 -7
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +0 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +0 -1
- package/lib/doctor/Doctor.d.ts +0 -1
- package/lib/doctor/Doctor.js +0 -19
- package/lib/errorHandlers/index.js +1 -1
- package/lib/polling.d.ts +13 -5
- package/lib/polling.js +21 -7
- package/lib/projects/buildAndDeploy.js +3 -3
- package/lib/projects/index.js +1 -1
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +27 -5
- package/package.json +3 -2
- package/commands/account/createOverride.d.ts +0 -10
- package/commands/account/createOverride.js +0 -64
package/bin/cli.js
CHANGED
|
@@ -6,7 +6,6 @@ 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');
|
|
10
9
|
const { logError } = require('../lib/errorHandlers/index');
|
|
11
10
|
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
12
11
|
const { validateAccount } = require('../lib/validation');
|
|
@@ -165,24 +164,7 @@ const injectAccountIdMiddleware = async (options) => {
|
|
|
165
164
|
options.derivedAccountId = parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
166
165
|
}
|
|
167
166
|
else {
|
|
168
|
-
|
|
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
|
-
}
|
|
167
|
+
options.derivedAccountId = getAccountId(account);
|
|
186
168
|
}
|
|
187
169
|
};
|
|
188
170
|
const loadConfigMiddleware = async (options) => {
|
|
@@ -202,9 +184,14 @@ const loadConfigMiddleware = async (options) => {
|
|
|
202
184
|
}));
|
|
203
185
|
process.exit(EXIT_CODES.ERROR);
|
|
204
186
|
}
|
|
205
|
-
else if (!options
|
|
187
|
+
else if (!isTargetedCommand(options, { init: { target: true } })) {
|
|
206
188
|
const { config: configPath } = options;
|
|
207
|
-
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
|
+
}
|
|
208
195
|
}
|
|
209
196
|
maybeValidateConfig();
|
|
210
197
|
};
|
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,
|
|
5
|
+
const { getConfigPath, getConfigDefaultAccount, getConfigAccounts, } = 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,7 +64,6 @@ 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();
|
|
68
67
|
const accountsList = getConfigAccounts();
|
|
69
68
|
const mappedPortalData = sortAndMapPortals(accountsList);
|
|
70
69
|
const portalData = getPortalData(mappedPortalData);
|
|
@@ -74,9 +73,6 @@ exports.handler = async (options) => {
|
|
|
74
73
|
i18n(`${i18nKey}.labels.authType`),
|
|
75
74
|
]));
|
|
76
75
|
logger.log(i18n(`${i18nKey}.configPath`, { configPath }));
|
|
77
|
-
if (overrideFilePath) {
|
|
78
|
-
logger.log(i18n(`${i18nKey}.overrideFilePath`, { overrideFilePath }));
|
|
79
|
-
}
|
|
80
76
|
logger.log(i18n(`${i18nKey}.defaultAccount`, {
|
|
81
77
|
account: getConfigDefaultAccount(),
|
|
82
78
|
}));
|
package/commands/account.js
CHANGED
|
@@ -9,7 +9,6 @@ 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');
|
|
13
12
|
const i18nKey = 'commands.account';
|
|
14
13
|
exports.command = ['account', 'accounts'];
|
|
15
14
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
@@ -22,7 +21,6 @@ exports.builder = yargs => {
|
|
|
22
21
|
.command(info)
|
|
23
22
|
.command(remove)
|
|
24
23
|
.command(clean)
|
|
25
|
-
.command(createOverride)
|
|
26
24
|
.demandCommand(1, '');
|
|
27
25
|
return yargs;
|
|
28
26
|
};
|
|
@@ -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(getBuildStatus
|
|
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 { 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)) ||
|
|
@@ -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(checkCloneStatus
|
|
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);
|
|
@@ -83,7 +83,7 @@ exports.handler = async (options) => {
|
|
|
83
83
|
logger.error(i18n(`${i18nKey}.errors.noBuildId`));
|
|
84
84
|
return process.exit(EXIT_CODES.ERROR);
|
|
85
85
|
}
|
|
86
|
-
const { data: deployResp } = await deployProject(derivedAccountId, projectName, buildIdToDeploy);
|
|
86
|
+
const { data: deployResp } = await deployProject(derivedAccountId, projectName, buildIdToDeploy, options.useV3);
|
|
87
87
|
if (!deployResp || deployResp.error) {
|
|
88
88
|
logger.error(i18n(`${i18nKey}.errors.deploy`, {
|
|
89
89
|
details: deployResp.error.message,
|
|
@@ -123,6 +123,11 @@ exports.builder = yargs => {
|
|
|
123
123
|
describe: i18n(`${i18nKey}.options.build.describe`),
|
|
124
124
|
type: 'number',
|
|
125
125
|
},
|
|
126
|
+
'use-v3': {
|
|
127
|
+
hidden: true,
|
|
128
|
+
type: 'boolean',
|
|
129
|
+
default: false,
|
|
130
|
+
},
|
|
126
131
|
});
|
|
127
132
|
yargs.example([
|
|
128
133
|
['$0 project deploy', i18n(`${i18nKey}.examples.default`)],
|
|
@@ -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(checkMigrationStatus
|
|
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);
|
|
@@ -22,15 +22,15 @@ 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
|
-
trackCommandUsage('project-upload', { type: accountType }, derivedAccountId);
|
|
26
25
|
const { projectConfig, projectDir } = await getProjectConfig();
|
|
26
|
+
trackCommandUsage('project-upload', { type: accountType }, derivedAccountId);
|
|
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, uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message);
|
|
33
|
+
const { result, uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message, options.translate);
|
|
34
34
|
if (uploadError) {
|
|
35
35
|
if (isSpecifiedError(uploadError, {
|
|
36
36
|
subCategory: PROJECT_ERROR_TYPES.PROJECT_LOCKED,
|
|
@@ -80,6 +80,11 @@ exports.builder = yargs => {
|
|
|
80
80
|
type: 'string',
|
|
81
81
|
default: '',
|
|
82
82
|
},
|
|
83
|
+
translate: {
|
|
84
|
+
hidden: true,
|
|
85
|
+
type: 'boolean',
|
|
86
|
+
default: false,
|
|
87
|
+
},
|
|
83
88
|
});
|
|
84
89
|
yargs.example([['$0 project upload', i18n(`${i18nKey}.examples.default`)]]);
|
|
85
90
|
addConfigOptions(yargs);
|
package/lang/en.lyaml
CHANGED
|
@@ -11,9 +11,6 @@ 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 }}."
|
|
17
14
|
completion:
|
|
18
15
|
describe: "Enable bash completion shortcuts for commands. Concat the generated script to your .bashrc, .bash_profile, or .zshrc file."
|
|
19
16
|
examples:
|
|
@@ -21,24 +18,11 @@ en:
|
|
|
21
18
|
account:
|
|
22
19
|
describe: "Commands for managing configured accounts."
|
|
23
20
|
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\""
|
|
36
21
|
list:
|
|
37
22
|
accounts: "{{#bold}}Accounts{{/bold}}:"
|
|
38
23
|
defaultAccount: "{{#bold}}Default account{{/bold}}: {{ account }}"
|
|
39
24
|
describe: "List names of accounts defined in config."
|
|
40
25
|
configPath: "{{#bold}}Config path{{/bold}}: {{ configPath }}"
|
|
41
|
-
overrideFilePath: "{{#bold}}Default account override file path{{/bold}}: {{ overrideFilePath }}"
|
|
42
26
|
labels:
|
|
43
27
|
accountId: "Account ID"
|
|
44
28
|
authType: "Auth Type"
|
|
@@ -1129,7 +1113,6 @@ en:
|
|
|
1129
1113
|
notFound: "Your project {{#bold}}{{ projectName }}{{/bold}} could not be found in {{#bold}}{{ accountIdentifier }}{{/bold}}."
|
|
1130
1114
|
pollFetchProject:
|
|
1131
1115
|
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 }}."
|
|
1133
1116
|
logFeedbackMessage:
|
|
1134
1117
|
feedbackHeader: "We'd love to hear your feedback!"
|
|
1135
1118
|
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"
|
|
@@ -1145,6 +1128,7 @@ en:
|
|
|
1145
1128
|
buildSucceededAutomaticallyDeploying: "Build #{{ buildId }} succeeded. {{#bold}}Automatically deploying{{/bold}} to {{ accountIdentifier }}\n"
|
|
1146
1129
|
cleanedUpTempFile: "Cleaned up temporary file {{ path }}"
|
|
1147
1130
|
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 }}."
|
|
1148
1132
|
projectUpload:
|
|
1149
1133
|
uploadProjectFiles:
|
|
1150
1134
|
add: "Uploading {{#bold}}{{ projectName }}{{/bold}} project files to {{ accountIdentifier }}"
|
|
@@ -1527,9 +1511,6 @@ en:
|
|
|
1527
1511
|
doctor:
|
|
1528
1512
|
runningDiagnostics: "Running diagnostics..."
|
|
1529
1513
|
diagnosticsComplete: "Diagnostics complete"
|
|
1530
|
-
defaultAccountOverrideFileChecks:
|
|
1531
|
-
overrideActive: "Default account override file active: {{ defaultAccountOverrideFile }}"
|
|
1532
|
-
overrideAccountId: "Active account ID: {{ overrideAccountId }}"
|
|
1533
1514
|
accountChecks:
|
|
1534
1515
|
active: "Default account active"
|
|
1535
1516
|
inactive: "Default account isn't active"
|
|
@@ -1576,8 +1557,6 @@ en:
|
|
|
1576
1557
|
defaultAccountSubHeader: "Default Account: {{accountDetails}}"
|
|
1577
1558
|
noConfigFile: "CLI configuration not found"
|
|
1578
1559
|
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:"
|
|
1581
1560
|
projectConfig:
|
|
1582
1561
|
header: "Project configuration"
|
|
1583
1562
|
projectDirSubHeader: "Project dir: {{#bold}}{{ projectDir }}{{/bold}}"
|
package/lib/constants.d.ts
CHANGED
|
@@ -6,13 +6,7 @@ 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
|
|
10
|
-
export declare const POLLING_STATUS: {
|
|
11
|
-
readonly SUCCESS: "SUCCESS";
|
|
12
|
-
readonly ERROR: "ERROR";
|
|
13
|
-
readonly REVERTED: "REVERTED";
|
|
14
|
-
readonly FAILURE: "FAILURE";
|
|
15
|
-
};
|
|
9
|
+
export declare const DEFAULT_POLLING_DELAY = 2000;
|
|
16
10
|
export declare const PROJECT_CONFIG_FILE: "hsproject.json";
|
|
17
11
|
export declare const PROJECT_BUILD_STATES: {
|
|
18
12
|
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.DEFAULT_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,13 +9,7 @@ exports.MARKETPLACE_FOLDER = '@marketplace';
|
|
|
9
9
|
exports.CONFIG_FLAGS = {
|
|
10
10
|
USE_CUSTOM_OBJECT_HUBFILE: 'useCustomObjectHubfile',
|
|
11
11
|
};
|
|
12
|
-
exports.
|
|
13
|
-
exports.POLLING_STATUS = {
|
|
14
|
-
SUCCESS: 'SUCCESS',
|
|
15
|
-
ERROR: 'ERROR',
|
|
16
|
-
REVERTED: 'REVERTED',
|
|
17
|
-
FAILURE: 'FAILURE',
|
|
18
|
-
};
|
|
12
|
+
exports.DEFAULT_POLLING_DELAY = 2000;
|
|
19
13
|
exports.PROJECT_CONFIG_FILE = 'hsproject.json';
|
|
20
14
|
exports.PROJECT_BUILD_STATES = {
|
|
21
15
|
BUILDING: 'BUILDING',
|
|
@@ -21,7 +21,6 @@ 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;
|
|
25
24
|
toString(): string;
|
|
26
25
|
private generateSections;
|
|
27
26
|
}
|
package/lib/doctor/Diagnosis.js
CHANGED
|
@@ -29,10 +29,6 @@ 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
|
-
},
|
|
36
32
|
project: {
|
|
37
33
|
header: i18n(`${i18nKey}.projectConfig.header`),
|
|
38
34
|
subheaders: [
|
|
@@ -75,9 +71,6 @@ class Diagnosis {
|
|
|
75
71
|
addCLIConfigSection(section) {
|
|
76
72
|
this.diagnosis.cliConfig.sections.push(section);
|
|
77
73
|
}
|
|
78
|
-
addDefaultAccountOverrideFileSection(section) {
|
|
79
|
-
this.diagnosis.defaultAccountOverrideFile.sections.push(section);
|
|
80
|
-
}
|
|
81
74
|
toString() {
|
|
82
75
|
const output = [];
|
|
83
76
|
for (const value of Object.values(this.diagnosis)) {
|
|
@@ -60,7 +60,6 @@ class DiagnosticInfoBuilder {
|
|
|
60
60
|
arch,
|
|
61
61
|
path: mainModule?.path,
|
|
62
62
|
config: (0, config_2.getConfigPath)(),
|
|
63
|
-
defaultAccountOverrideFile: (0, config_1.getDefaultAccountOverrideFilePath)(),
|
|
64
63
|
versions: {
|
|
65
64
|
[hubspotCli]: package_json_1.default.version,
|
|
66
65
|
node,
|
package/lib/doctor/Doctor.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export declare class Doctor {
|
|
|
10
10
|
private performCliChecks;
|
|
11
11
|
private performProjectChecks;
|
|
12
12
|
private performCliConfigChecks;
|
|
13
|
-
private performDefaultAccountOverrideFileChecks;
|
|
14
13
|
private checkIfAccessTokenValid;
|
|
15
14
|
private checkIfNodeIsInstalled;
|
|
16
15
|
private checkIfNpmIsInstalled;
|
package/lib/doctor/Doctor.js
CHANGED
|
@@ -49,7 +49,6 @@ class Doctor {
|
|
|
49
49
|
await Promise.all([
|
|
50
50
|
...this.performCliChecks(),
|
|
51
51
|
...this.performCliConfigChecks(),
|
|
52
|
-
...this.performDefaultAccountOverrideFileChecks(),
|
|
53
52
|
...(this.projectConfig?.projectConfig ? this.performProjectChecks() : []),
|
|
54
53
|
]);
|
|
55
54
|
SpinniesManager_1.default.succeed('runningDiagnostics', {
|
|
@@ -88,24 +87,6 @@ class Doctor {
|
|
|
88
87
|
}
|
|
89
88
|
return [this.checkIfAccessTokenValid()];
|
|
90
89
|
}
|
|
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
|
-
}
|
|
109
90
|
async checkIfAccessTokenValid() {
|
|
110
91
|
const localI18nKey = `${i18nKey}.accountChecks`;
|
|
111
92
|
try {
|
|
@@ -53,7 +53,7 @@ function debugError(error, context) {
|
|
|
53
53
|
if (error instanceof Error && error.cause) {
|
|
54
54
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.errorCause`, {
|
|
55
55
|
cause: (0, axios_1.isAxiosError)(error.cause)
|
|
56
|
-
? `${error.cause}`
|
|
56
|
+
? `${error.cause.message}`
|
|
57
57
|
: util_1.default.inspect(error.cause, false, null, true),
|
|
58
58
|
}));
|
|
59
59
|
}
|
package/lib/polling.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { HubSpotPromise } from '@hubspot/local-dev-lib/types/Http';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export declare const DEFAULT_POLLING_STATES: {
|
|
3
|
+
readonly STARTED: "STARTED";
|
|
4
|
+
readonly SUCCESS: "SUCCESS";
|
|
5
|
+
readonly ERROR: "ERROR";
|
|
6
|
+
readonly REVERTED: "REVERTED";
|
|
7
|
+
readonly FAILURE: "FAILURE";
|
|
8
|
+
};
|
|
4
9
|
type GenericPollingResponse = {
|
|
5
|
-
status:
|
|
10
|
+
status: string;
|
|
6
11
|
};
|
|
7
|
-
type PollingCallback<T extends GenericPollingResponse> = (
|
|
8
|
-
export declare function poll<T extends GenericPollingResponse>(callback: PollingCallback<T>,
|
|
12
|
+
type PollingCallback<T extends GenericPollingResponse> = () => HubSpotPromise<T>;
|
|
13
|
+
export declare function poll<T extends GenericPollingResponse>(callback: PollingCallback<T>, statusLookup?: {
|
|
14
|
+
successStates: string[];
|
|
15
|
+
errorStates: string[];
|
|
16
|
+
}): Promise<T>;
|
|
9
17
|
export {};
|
package/lib/polling.js
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_POLLING_STATES = void 0;
|
|
3
4
|
exports.poll = poll;
|
|
4
5
|
const constants_1 = require("./constants");
|
|
5
|
-
|
|
6
|
+
exports.DEFAULT_POLLING_STATES = {
|
|
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) {
|
|
6
22
|
return new Promise((resolve, reject) => {
|
|
7
23
|
const pollInterval = setInterval(async () => {
|
|
8
24
|
try {
|
|
9
|
-
const { data: pollResp } = await callback(
|
|
25
|
+
const { data: pollResp } = await callback();
|
|
10
26
|
const { status } = pollResp;
|
|
11
|
-
if (
|
|
27
|
+
if (statusLookup.successStates.includes(status)) {
|
|
12
28
|
clearInterval(pollInterval);
|
|
13
29
|
resolve(pollResp);
|
|
14
30
|
}
|
|
15
|
-
else if (
|
|
16
|
-
status === constants_1.POLLING_STATUS.REVERTED ||
|
|
17
|
-
status === constants_1.POLLING_STATUS.FAILURE) {
|
|
31
|
+
else if (statusLookup.errorStates.includes(status)) {
|
|
18
32
|
clearInterval(pollInterval);
|
|
19
33
|
reject(pollResp);
|
|
20
34
|
}
|
|
@@ -23,6 +37,6 @@ function poll(callback, accountId, taskId) {
|
|
|
23
37
|
clearInterval(pollInterval);
|
|
24
38
|
reject(error);
|
|
25
39
|
}
|
|
26
|
-
}, constants_1.
|
|
40
|
+
}, constants_1.DEFAULT_POLLING_DELAY);
|
|
27
41
|
});
|
|
28
42
|
}
|
|
@@ -197,13 +197,13 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
|
|
|
197
197
|
resolve(taskStatus);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
}, constants_1.
|
|
200
|
+
}, constants_1.DEFAULT_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.DEFAULT_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.DEFAULT_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.DEFAULT_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.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ type ProjectUploadResult<T> = {
|
|
|
5
5
|
result?: T;
|
|
6
6
|
uploadError?: unknown;
|
|
7
7
|
};
|
|
8
|
-
export declare function handleProjectUpload<T>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string): Promise<ProjectUploadResult<T>>;
|
|
8
|
+
export declare function handleProjectUpload<T>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string, sendIR?: boolean): Promise<ProjectUploadResult<T>>;
|
|
9
9
|
export {};
|
package/lib/projects/upload.js
CHANGED
|
@@ -15,8 +15,11 @@ const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
|
15
15
|
const ui_1 = require("../ui");
|
|
16
16
|
const lang_1 = require("../lang");
|
|
17
17
|
const exitCodes_1 = require("../enums/exitCodes");
|
|
18
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
19
|
+
const errorHandlers_1 = require("../errorHandlers");
|
|
20
|
+
const node_util_1 = __importDefault(require("node:util"));
|
|
18
21
|
const i18nKey = 'lib.projectUpload';
|
|
19
|
-
async function uploadProjectFiles(accountId, projectName, filePath, uploadMessage, platformVersion) {
|
|
22
|
+
async function uploadProjectFiles(accountId, projectName, filePath, uploadMessage, platformVersion, intermediateRepresentation) {
|
|
20
23
|
SpinniesManager_1.default.init({});
|
|
21
24
|
const accountIdentifier = (0, ui_1.uiAccountDescription)(accountId);
|
|
22
25
|
SpinniesManager_1.default.add('upload', {
|
|
@@ -29,7 +32,7 @@ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessag
|
|
|
29
32
|
let buildId;
|
|
30
33
|
let error;
|
|
31
34
|
try {
|
|
32
|
-
const { data: upload } = await (0, projects_1.uploadProject)(accountId, projectName, filePath, uploadMessage, platformVersion);
|
|
35
|
+
const { data: upload } = await (0, projects_1.uploadProject)(accountId, projectName, filePath, uploadMessage, platformVersion, intermediateRepresentation);
|
|
33
36
|
buildId = upload.buildId;
|
|
34
37
|
SpinniesManager_1.default.succeed('upload', {
|
|
35
38
|
text: (0, lang_1.i18n)(`${i18nKey}.uploadProjectFiles.succeed`, {
|
|
@@ -55,7 +58,7 @@ async function uploadProjectFiles(accountId, projectName, filePath, uploadMessag
|
|
|
55
58
|
}
|
|
56
59
|
return { buildId, error };
|
|
57
60
|
}
|
|
58
|
-
async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage) {
|
|
61
|
+
async function handleProjectUpload(accountId, projectConfig, projectDir, callbackFunc, uploadMessage, sendIR = false) {
|
|
59
62
|
const srcDir = path_1.default.resolve(projectDir, projectConfig.srcDir);
|
|
60
63
|
const filenames = fs_extra_1.default.readdirSync(srcDir);
|
|
61
64
|
if (!filenames || filenames.length === 0) {
|
|
@@ -74,9 +77,28 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
|
|
|
74
77
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.handleProjectUpload.compressed`, {
|
|
75
78
|
byteCount: archive.pointer(),
|
|
76
79
|
}));
|
|
77
|
-
|
|
80
|
+
let intermediateRepresentation;
|
|
81
|
+
if (sendIR) {
|
|
82
|
+
try {
|
|
83
|
+
intermediateRepresentation = await (0, project_parsing_lib_1.translate)({
|
|
84
|
+
projectSourceDir: path_1.default.join(projectDir, projectConfig.srcDir),
|
|
85
|
+
platformVersion: projectConfig.platformVersion,
|
|
86
|
+
accountId,
|
|
87
|
+
});
|
|
88
|
+
logger_1.logger.debug(node_util_1.default.inspect(intermediateRepresentation, false, null, true));
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
if ((0, project_parsing_lib_1.isTranslationError)(e)) {
|
|
92
|
+
logger_1.logger.error(e.toString());
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
(0, errorHandlers_1.logError)(e);
|
|
96
|
+
}
|
|
97
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const { buildId, error } = await uploadProjectFiles(accountId, projectConfig.name, tempFile.name, uploadMessage, projectConfig.platformVersion, intermediateRepresentation);
|
|
78
101
|
if (error) {
|
|
79
|
-
console.log(error);
|
|
80
102
|
resolve({ uploadError: error });
|
|
81
103
|
}
|
|
82
104
|
else if (callbackFunc) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.10-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": "0.1.
|
|
8
|
+
"@hubspot/local-dev-lib": "0.1.1-experimental.0",
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.0.3-experimental.0",
|
|
9
10
|
"@hubspot/serverless-dev-runtime": "7.0.1",
|
|
10
11
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
11
12
|
"@hubspot/ui-extensions-dev-server": "0.8.40",
|
|
@@ -1,10 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
}
|