@hubspot/cli 6.4.0 → 7.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +110 -16
- package/bin/hs +2 -0
- package/bin/hscms +2 -0
- package/bin/silenceErrors.d.ts +2 -0
- package/bin/silenceErrors.js +12 -0
- package/commands/{accounts → account}/clean.js +10 -11
- package/commands/{accounts → account}/info.js +10 -16
- package/commands/{accounts → account}/list.js +16 -16
- package/commands/{accounts → account}/remove.js +12 -15
- package/commands/{accounts → account}/rename.js +4 -7
- package/commands/{accounts → account}/use.js +8 -14
- package/commands/account.js +26 -0
- package/commands/auth.js +30 -24
- package/commands/cms/getReactModule.js +70 -0
- package/commands/cms/lighthouseScore.js +19 -21
- package/commands/cms.js +4 -3
- package/commands/completion.js +22 -0
- package/commands/config/set.js +22 -24
- package/commands/config.js +2 -2
- package/commands/create.js +6 -3
- package/commands/customObject/create.js +19 -15
- package/commands/customObject/schema/create.js +15 -16
- package/commands/customObject/schema/delete.js +29 -11
- package/commands/customObject/schema/fetch-all.js +14 -11
- package/commands/customObject/schema/fetch.js +22 -14
- package/commands/customObject/schema/list.js +3 -6
- package/commands/customObject/schema/update.js +28 -18
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +3 -4
- package/commands/doctor.js +4 -2
- package/commands/feedback.js +2 -0
- package/commands/fetch.js +13 -13
- package/commands/filemanager/fetch.js +6 -7
- package/commands/filemanager/upload.js +10 -12
- package/commands/filemanager.js +1 -8
- package/commands/{functions → function}/deploy.js +13 -13
- package/commands/{functions → function}/list.js +7 -9
- package/commands/{functions → function}/server.js +5 -8
- package/commands/function.js +16 -0
- package/commands/hubdb/clear.js +14 -10
- package/commands/hubdb/create.js +37 -13
- package/commands/hubdb/delete.js +31 -10
- package/commands/hubdb/fetch.js +14 -9
- package/commands/hubdb.js +2 -3
- package/commands/init.js +37 -14
- package/commands/lint.js +6 -7
- package/commands/list.js +5 -7
- package/commands/logs.js +24 -15
- package/commands/module/marketplace-validate.js +6 -9
- package/commands/module.js +2 -1
- package/commands/mv.js +11 -13
- package/commands/open.js +11 -10
- package/commands/project/add.js +2 -5
- package/commands/project/cloneApp.js +28 -32
- package/commands/project/create.js +8 -10
- package/commands/project/deploy.js +19 -16
- package/commands/project/dev.js +17 -18
- package/commands/project/download.js +18 -15
- package/commands/project/listBuilds.js +36 -32
- package/commands/project/logs.js +6 -8
- package/commands/project/migrateApp.js +27 -27
- package/commands/project/open.js +9 -11
- package/commands/project/upload.js +30 -32
- package/commands/project/watch.js +17 -24
- package/commands/project.js +3 -4
- package/commands/remove.js +14 -13
- package/commands/sandbox/create.js +12 -15
- package/commands/sandbox/delete.js +19 -20
- package/commands/sandbox.js +4 -8
- package/commands/{secrets → secret}/addSecret.js +25 -12
- package/commands/secret/deleteSecret.js +71 -0
- package/commands/{secrets → secret}/listSecrets.js +7 -9
- package/commands/{secrets → secret}/updateSecret.js +21 -13
- package/commands/secret.js +22 -0
- package/commands/theme/generate-selectors.js +8 -8
- package/commands/theme/marketplace-validate.js +10 -13
- package/commands/theme/preview.js +7 -10
- package/commands/theme.js +3 -1
- package/commands/upload.js +32 -26
- package/commands/watch.js +19 -20
- package/lang/en.lyaml +200 -126
- package/lib/DevServerManager.js +1 -1
- package/lib/LocalDevManager.js +4 -4
- package/lib/buildAccount.js +5 -11
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -39
- package/lib/configOptions.d.ts +13 -1
- package/lib/configOptions.js +54 -57
- package/lib/constants.d.ts +1 -4
- package/lib/dependencyManagement.d.ts +4 -1
- package/lib/dependencyManagement.js +2 -2
- package/lib/developerTestAccounts.d.ts +5 -1
- package/lib/developerTestAccounts.js +45 -39
- package/lib/doctor/DiagnosticInfoBuilder.js +8 -4
- package/lib/doctor/Doctor.js +11 -6
- package/lib/generateSelectors.d.ts +19 -0
- package/lib/generateSelectors.js +23 -23
- package/lib/localDev.js +3 -2
- package/lib/marketplaceValidate.d.ts +6 -1
- package/lib/marketplaceValidate.js +76 -77
- package/lib/oauth.d.ts +2 -1
- package/lib/oauth.js +49 -37
- package/lib/polling.d.ts +8 -0
- package/lib/polling.js +9 -12
- package/lib/projects/ProjectLogsManager.d.ts +20 -0
- package/lib/projects/ProjectLogsManager.js +105 -0
- package/lib/projects/buildAndDeploy.d.ts +16 -0
- package/lib/projects/buildAndDeploy.js +342 -0
- package/lib/projects/index.d.ts +24 -0
- package/lib/projects/index.js +256 -0
- package/lib/projects/structure.d.ts +78 -0
- package/lib/projects/structure.js +151 -0
- package/lib/projects/upload.d.ts +8 -0
- package/lib/projects/upload.js +107 -0
- package/lib/projects/urls.d.ts +4 -0
- package/lib/projects/urls.js +27 -0
- package/lib/{projectsWatch.js → projects/watch.js} +3 -3
- package/lib/prompts/accountNamePrompt.d.ts +11 -0
- package/lib/prompts/accountNamePrompt.js +45 -46
- package/lib/prompts/accountsPrompt.d.ts +1 -1
- package/lib/prompts/accountsPrompt.js +21 -19
- package/lib/prompts/cmsFieldPrompt.d.ts +1 -1
- package/lib/prompts/cmsFieldPrompt.js +23 -24
- package/lib/prompts/createApiSamplePrompt.d.ts +17 -0
- package/lib/prompts/createApiSamplePrompt.js +47 -44
- package/lib/prompts/createFunctionPrompt.d.ts +7 -0
- package/lib/prompts/createFunctionPrompt.js +17 -20
- package/lib/prompts/createModulePrompt.d.ts +8 -0
- package/lib/prompts/createModulePrompt.js +29 -17
- package/lib/prompts/createProjectPrompt.d.ts +13 -0
- package/lib/prompts/createProjectPrompt.js +48 -49
- package/lib/prompts/createTemplatePrompt.d.ts +8 -0
- package/lib/prompts/createTemplatePrompt.js +15 -17
- package/lib/prompts/downloadProjectPrompt.d.ts +8 -0
- package/lib/prompts/downloadProjectPrompt.js +25 -23
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/installPublicAppPrompt.js +21 -19
- package/lib/prompts/personalAccessKeyPrompt.d.ts +28 -0
- package/lib/prompts/personalAccessKeyPrompt.js +46 -52
- package/lib/prompts/previewPrompt.d.ts +14 -0
- package/lib/prompts/previewPrompt.js +24 -24
- package/lib/prompts/projectAddPrompt.d.ts +9 -0
- package/lib/prompts/projectAddPrompt.js +11 -14
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +87 -69
- package/lib/prompts/projectsLogsPrompt.d.ts +11 -0
- package/lib/prompts/projectsLogsPrompt.js +8 -11
- package/lib/prompts/promptUtils.d.ts +7 -6
- package/lib/prompts/promptUtils.js +21 -8
- package/lib/prompts/sandboxesPrompt.d.ts +8 -0
- package/lib/prompts/sandboxesPrompt.js +43 -45
- package/lib/prompts/secretPrompt.d.ts +12 -0
- package/lib/prompts/secretPrompt.js +32 -19
- package/lib/prompts/selectHubDBTablePrompt.d.ts +12 -0
- package/lib/prompts/selectHubDBTablePrompt.js +69 -0
- package/lib/prompts/selectPublicAppPrompt.d.ts +8 -0
- package/lib/prompts/selectPublicAppPrompt.js +28 -27
- package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -1
- package/lib/prompts/setAsDefaultAccountPrompt.js +12 -14
- package/lib/prompts/uploadPrompt.d.ts +8 -0
- package/lib/prompts/uploadPrompt.js +18 -18
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/usageTracking.d.ts +21 -2
- package/lib/usageTracking.js +53 -81
- package/lib/validation.d.ts +11 -1
- package/lib/validation.js +98 -91
- package/package.json +12 -6
- package/types/Projects.d.ts +43 -0
- package/types/Projects.js +2 -0
- package/types/Prompts.d.ts +25 -0
- package/types/Prompts.js +2 -0
- package/commands/accounts.js +0 -30
- package/commands/cms/reactModules.js +0 -60
- package/commands/functions.js +0 -24
- package/commands/secrets/deleteSecret.js +0 -46
- package/commands/secrets.js +0 -23
- package/lib/ProjectLogsManager.js +0 -91
- package/lib/projectStructure.js +0 -116
- package/lib/projects.d.ts +0 -4
- package/lib/projects.js +0 -681
- package/lib/projectsWatch.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.js +0 -20
- /package/commands/{accounts → account}/clean.d.ts +0 -0
- /package/commands/{accounts → account}/info.d.ts +0 -0
- /package/commands/{accounts → account}/list.d.ts +0 -0
- /package/commands/{accounts → account}/remove.d.ts +0 -0
- /package/commands/{accounts → account}/rename.d.ts +0 -0
- /package/commands/{accounts → account}/use.d.ts +0 -0
- /package/commands/{accounts.d.ts → account.d.ts} +0 -0
- /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
- /package/commands/{functions.d.ts → completion.d.ts} +0 -0
- /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
- /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
- /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
- /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
- /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
- /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
- /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
- /package/{lib/ProjectLogsManager.d.ts → commands/secret/updateSecret.d.ts} +0 -0
- /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
- /package/lib/{projectStructure.d.ts → projects/watch.d.ts} +0 -0
package/lib/DevServerManager.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 { COMPONENT_TYPES } = require('./
|
|
5
|
+
const { COMPONENT_TYPES } = require('./projects/structure');
|
|
6
6
|
const { i18n } = require('./lang');
|
|
7
7
|
const { promptUser } = require('./prompts/promptUtils');
|
|
8
8
|
const { DevModeInterface } = require('@hubspot/ui-extensions-dev-server');
|
package/lib/LocalDevManager.js
CHANGED
|
@@ -14,9 +14,9 @@ const { PROJECT_CONFIG_FILE } = require('./constants');
|
|
|
14
14
|
const SpinniesManager = require('./ui/SpinniesManager');
|
|
15
15
|
const DevServerManager = require('./DevServerManager');
|
|
16
16
|
const { EXIT_CODES } = require('./enums/exitCodes');
|
|
17
|
-
const { getProjectDetailUrl } = require('./projects');
|
|
17
|
+
const { getProjectDetailUrl } = require('./projects/urls');
|
|
18
18
|
const { getAccountHomeUrl } = require('./localDev');
|
|
19
|
-
const { CONFIG_FILES, COMPONENT_TYPES, getAppCardConfigs, } = require('./
|
|
19
|
+
const { CONFIG_FILES, COMPONENT_TYPES, getAppCardConfigs, } = require('./projects/structure');
|
|
20
20
|
const { UI_COLORS, uiCommandReference, uiAccountDescription, uiBetaTag, uiLink, uiLine, } = require('./ui');
|
|
21
21
|
const { logError } = require('./errorHandlers/index');
|
|
22
22
|
const { installPublicAppPrompt } = require('./prompts/installPublicAppPrompt');
|
|
@@ -77,7 +77,7 @@ class LocalDevManager {
|
|
|
77
77
|
if (!this.activeApp) {
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
const { data: portalPublicApps } = await fetchPublicAppsForPortal(this.targetProjectAccountId);
|
|
80
|
+
const { data: { results: portalPublicApps }, } = await fetchPublicAppsForPortal(this.targetProjectAccountId);
|
|
81
81
|
const activePublicAppData = portalPublicApps.find(({ sourceId }) => sourceId === this.activeApp.config.uid);
|
|
82
82
|
// TODO: Update to account for new API with { data }
|
|
83
83
|
const { data: { uniquePortalInstallCount }, } = await fetchPublicAppProductionInstallCounts(activePublicAppData.id, this.targetProjectAccountId);
|
|
@@ -175,7 +175,7 @@ class LocalDevManager {
|
|
|
175
175
|
return data;
|
|
176
176
|
}
|
|
177
177
|
async checkPublicAppInstallation() {
|
|
178
|
-
const { isInstalledWithScopeGroups, previouslyAuthorizedScopeGroups
|
|
178
|
+
const { isInstalledWithScopeGroups, previouslyAuthorizedScopeGroups } = await this.getActiveAppInstallationData();
|
|
179
179
|
const isReinstall = previouslyAuthorizedScopeGroups.length > 0;
|
|
180
180
|
if (!isInstalledWithScopeGroups) {
|
|
181
181
|
await installPublicAppPrompt(this.env, this.targetAccountId, this.activePublicAppData.clientId, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.redirectUrls, isReinstall);
|
package/lib/buildAccount.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { getAccessToken, updateConfigWithAccessToken, } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
5
5
|
const { personalAccessKeyPrompt, } = require('./prompts/personalAccessKeyPrompt');
|
|
6
6
|
const { accountNameExistsInConfig, updateAccountConfig, writeConfig, getAccountId, } = require('@hubspot/local-dev-lib/config');
|
|
7
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
7
8
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
9
|
const { i18n } = require('./lang');
|
|
9
10
|
const { cliAccountNamePrompt } = require('./prompts/accountNamePrompt');
|
|
@@ -26,10 +27,7 @@ async function saveAccountToConfig({ env, personalAccessKey, accountName, accoun
|
|
|
26
27
|
const updatedConfig = await updateConfigWithAccessToken(token, personalAccessKey, env);
|
|
27
28
|
let validName = updatedConfig.name;
|
|
28
29
|
if (!updatedConfig.name) {
|
|
29
|
-
const nameForConfig = accountName
|
|
30
|
-
.toLowerCase()
|
|
31
|
-
.split(' ')
|
|
32
|
-
.join('-');
|
|
30
|
+
const nameForConfig = accountName.toLowerCase().split(' ').join('-');
|
|
33
31
|
validName = nameForConfig;
|
|
34
32
|
const invalidAccountName = accountNameExistsInConfig(nameForConfig);
|
|
35
33
|
if (invalidAccountName) {
|
|
@@ -62,7 +60,8 @@ force = false, }) {
|
|
|
62
60
|
SpinniesManager.init({
|
|
63
61
|
succeedColor: 'white',
|
|
64
62
|
});
|
|
65
|
-
const
|
|
63
|
+
const id = getAccountIdentifier(accountConfig);
|
|
64
|
+
const accountId = getAccountId(id);
|
|
66
65
|
const isSandbox = accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX ||
|
|
67
66
|
accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
|
|
68
67
|
const isDeveloperTestAccount = accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST;
|
|
@@ -116,12 +115,7 @@ force = false, }) {
|
|
|
116
115
|
handleSandboxCreateError({ err, env, accountConfig, name, accountId });
|
|
117
116
|
}
|
|
118
117
|
if (isDeveloperTestAccount) {
|
|
119
|
-
handleDeveloperTestAccountCreateError(
|
|
120
|
-
err,
|
|
121
|
-
env,
|
|
122
|
-
accountId,
|
|
123
|
-
portalLimit,
|
|
124
|
-
});
|
|
118
|
+
handleDeveloperTestAccountCreateError(err, env, accountId, portalLimit);
|
|
125
119
|
}
|
|
126
120
|
}
|
|
127
121
|
let configAccountName;
|
package/lib/commonOpts.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
1
2
|
import { Argv, Arguments } from 'yargs';
|
|
2
|
-
|
|
3
|
+
export declare function addGlobalOptions(yargs: Argv): Argv<{
|
|
4
|
+
debug: boolean;
|
|
5
|
+
}>;
|
|
3
6
|
export declare function addAccountOptions(yargs: Argv): Argv;
|
|
4
7
|
export declare function addConfigOptions(yargs: Argv): Argv;
|
|
5
8
|
export declare function addOverwriteOptions(yargs: Argv): Argv;
|
|
6
|
-
export declare function
|
|
9
|
+
export declare function addCmsPublishModeOptions(yargs: Argv, { read, write }: {
|
|
7
10
|
read?: boolean;
|
|
8
11
|
write?: boolean;
|
|
9
12
|
}): Argv;
|
|
@@ -19,9 +22,15 @@ export declare function getCommandName(argv: Arguments<{
|
|
|
19
22
|
* Obtains accountId using supplied --account flag or from environment variables
|
|
20
23
|
*/
|
|
21
24
|
export declare function getAccountId(options: Arguments<{
|
|
22
|
-
portal?: number | string;
|
|
23
25
|
account?: number | string;
|
|
24
26
|
}>): number | null;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Auto-injects the derivedAccountId flag into all commands
|
|
29
|
+
*/
|
|
30
|
+
export declare function injectAccountIdMiddleware(options: Arguments<{
|
|
31
|
+
derivedAccountId?: number | null;
|
|
32
|
+
account?: number | string;
|
|
33
|
+
}>): Promise<void>;
|
|
34
|
+
export declare function getCmsPublishMode(options: Arguments<{
|
|
35
|
+
cmsPublishMode?: CmsPublishMode;
|
|
36
|
+
}>): CmsPublishMode;
|
package/lib/commonOpts.js
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addGlobalOptions = addGlobalOptions;
|
|
3
4
|
exports.addAccountOptions = addAccountOptions;
|
|
4
5
|
exports.addConfigOptions = addConfigOptions;
|
|
5
6
|
exports.addOverwriteOptions = addOverwriteOptions;
|
|
6
|
-
exports.
|
|
7
|
+
exports.addCmsPublishModeOptions = addCmsPublishModeOptions;
|
|
7
8
|
exports.addTestingOptions = addTestingOptions;
|
|
8
9
|
exports.addUseEnvironmentOptions = addUseEnvironmentOptions;
|
|
9
10
|
exports.setLogLevel = setLogLevel;
|
|
10
11
|
exports.getCommandName = getCommandName;
|
|
11
12
|
exports.getAccountId = getAccountId;
|
|
12
|
-
exports.
|
|
13
|
+
exports.injectAccountIdMiddleware = injectAccountIdMiddleware;
|
|
14
|
+
exports.getCmsPublishMode = getCmsPublishMode;
|
|
13
15
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
16
|
const files_1 = require("@hubspot/local-dev-lib/constants/files");
|
|
15
17
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
16
18
|
const lang_1 = require("./lang");
|
|
17
19
|
const i18nKey = 'lib.commonOpts';
|
|
20
|
+
function addGlobalOptions(yargs) {
|
|
21
|
+
yargs.version(false);
|
|
22
|
+
return yargs.option('debug', {
|
|
23
|
+
alias: 'd',
|
|
24
|
+
default: false,
|
|
25
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.debug.describe`),
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
18
29
|
function addAccountOptions(yargs) {
|
|
19
|
-
return yargs.option('
|
|
20
|
-
alias:
|
|
21
|
-
describe: (0, lang_1.i18n)(`${i18nKey}.options.
|
|
30
|
+
return yargs.option('account', {
|
|
31
|
+
alias: 'a',
|
|
32
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
|
|
22
33
|
type: 'string',
|
|
23
34
|
});
|
|
24
35
|
}
|
|
@@ -37,11 +48,11 @@ function addOverwriteOptions(yargs) {
|
|
|
37
48
|
default: false,
|
|
38
49
|
});
|
|
39
50
|
}
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
return yargs.option('mode', {
|
|
51
|
+
function addCmsPublishModeOptions(yargs, { read, write }) {
|
|
52
|
+
const cmsPublishModes = `<${Object.values(files_1.CMS_PUBLISH_MODE).join(' | ')}>`;
|
|
53
|
+
return yargs.option('cms-publish-mode', {
|
|
43
54
|
alias: 'm',
|
|
44
|
-
describe: (0, lang_1.i18n)(`${i18nKey}.options.modes.describe.${read ? 'read' : write ? 'write' : 'default'}`, { modes }),
|
|
55
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.modes.describe.${read ? 'read' : write ? 'write' : 'default'}`, { modes: cmsPublishModes }),
|
|
45
56
|
type: 'string',
|
|
46
57
|
});
|
|
47
58
|
}
|
|
@@ -54,11 +65,12 @@ function addTestingOptions(yargs) {
|
|
|
54
65
|
});
|
|
55
66
|
}
|
|
56
67
|
function addUseEnvironmentOptions(yargs) {
|
|
57
|
-
return yargs
|
|
68
|
+
return yargs
|
|
69
|
+
.option('use-env', {
|
|
58
70
|
describe: (0, lang_1.i18n)(`${i18nKey}.options.useEnv.describe`),
|
|
59
71
|
type: 'boolean',
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
})
|
|
73
|
+
.conflicts('use-env', 'account');
|
|
62
74
|
}
|
|
63
75
|
function setLogLevel(options) {
|
|
64
76
|
const { debug } = options;
|
|
@@ -76,40 +88,42 @@ function getCommandName(argv) {
|
|
|
76
88
|
* Obtains accountId using supplied --account flag or from environment variables
|
|
77
89
|
*/
|
|
78
90
|
function getAccountId(options) {
|
|
79
|
-
const {
|
|
80
|
-
if (options?.useEnv && process.env.
|
|
81
|
-
return parseInt(process.env.
|
|
91
|
+
const { account } = options || {};
|
|
92
|
+
if (options?.useEnv && process.env.HUBSPOT_ACCOUNT_ID) {
|
|
93
|
+
return parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
94
|
+
}
|
|
95
|
+
return (0, config_1.getAccountId)(account);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Auto-injects the derivedAccountId flag into all commands
|
|
99
|
+
*/
|
|
100
|
+
async function injectAccountIdMiddleware(options) {
|
|
101
|
+
const { account } = options;
|
|
102
|
+
// Preserves the original --account flag for certain commands.
|
|
103
|
+
options.providedAccountId = account;
|
|
104
|
+
if (options.useEnv && process.env.HUBSPOT_ACCOUNT_ID) {
|
|
105
|
+
options.derivedAccountId = parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
106
|
+
return;
|
|
82
107
|
}
|
|
83
|
-
|
|
108
|
+
options.derivedAccountId = (0, config_1.getAccountId)(account);
|
|
84
109
|
}
|
|
85
|
-
function
|
|
86
|
-
// 1. --
|
|
87
|
-
const {
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
110
|
+
function getCmsPublishMode(options) {
|
|
111
|
+
// 1. --cmsPublishMode
|
|
112
|
+
const { cmsPublishMode } = options;
|
|
113
|
+
if (cmsPublishMode && typeof cmsPublishMode === 'string') {
|
|
114
|
+
return cmsPublishMode.toLowerCase();
|
|
90
115
|
}
|
|
91
|
-
// 2. config[
|
|
116
|
+
// 2. config[account].defaultCmsPublishMode
|
|
92
117
|
const accountId = getAccountId(options);
|
|
93
118
|
if (accountId) {
|
|
94
119
|
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
95
|
-
if (accountConfig && accountConfig.
|
|
96
|
-
return accountConfig.
|
|
120
|
+
if (accountConfig && accountConfig.defaultCmsPublishMode) {
|
|
121
|
+
return accountConfig.defaultCmsPublishMode;
|
|
97
122
|
}
|
|
98
123
|
}
|
|
99
|
-
// 3. config.
|
|
100
|
-
// 4.
|
|
124
|
+
// 3. config.defaultCmsPublishMode
|
|
125
|
+
// 4. DEFAULT_CMS_PUBLISH_MODE
|
|
101
126
|
const config = (0, config_1.getAndLoadConfigIfNeeded)();
|
|
102
|
-
return (config && config.
|
|
127
|
+
return ((config && config.defaultCmsPublishMode) ||
|
|
128
|
+
files_1.DEFAULT_CMS_PUBLISH_MODE);
|
|
103
129
|
}
|
|
104
|
-
module.exports = {
|
|
105
|
-
addAccountOptions,
|
|
106
|
-
addConfigOptions,
|
|
107
|
-
addOverwriteOptions,
|
|
108
|
-
addModeOptions,
|
|
109
|
-
addTestingOptions,
|
|
110
|
-
addUseEnvironmentOptions,
|
|
111
|
-
getCommandName,
|
|
112
|
-
getMode,
|
|
113
|
-
getAccountId,
|
|
114
|
-
setLogLevel,
|
|
115
|
-
};
|
package/lib/configOptions.d.ts
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
2
|
+
export declare function setAllowUsageTracking({ accountId, allowUsageTracking, }: {
|
|
3
|
+
accountId: number;
|
|
4
|
+
allowUsageTracking?: boolean;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
export declare function setDefaultCmsPublishMode({ accountId, defaultCmsPublishMode, }: {
|
|
7
|
+
accountId: number;
|
|
8
|
+
defaultCmsPublishMode?: CmsPublishMode;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
export declare function setHttpTimeout({ accountId, httpTimeout, }: {
|
|
11
|
+
accountId: number;
|
|
12
|
+
httpTimeout?: string;
|
|
13
|
+
}): Promise<void>;
|
package/lib/configOptions.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
3
|
+
exports.setAllowUsageTracking = setAllowUsageTracking;
|
|
4
|
+
exports.setDefaultCmsPublishMode = setDefaultCmsPublishMode;
|
|
5
|
+
exports.setHttpTimeout = setHttpTimeout;
|
|
6
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
|
+
const files_1 = require("@hubspot/local-dev-lib/constants/files");
|
|
9
|
+
const text_1 = require("@hubspot/local-dev-lib/text");
|
|
10
|
+
const usageTracking_1 = require("./usageTracking");
|
|
11
|
+
const promptUtils_1 = require("./prompts/promptUtils");
|
|
12
|
+
const lang_1 = require("../lib/lang");
|
|
11
13
|
const i18nKey = 'commands.config.subcommands.set.options';
|
|
12
|
-
|
|
13
|
-
const { isEnabled } = await promptUser([
|
|
14
|
+
async function enableOrDisableUsageTracking() {
|
|
15
|
+
const { isEnabled } = await (0, promptUtils_1.promptUser)([
|
|
14
16
|
{
|
|
15
17
|
type: 'list',
|
|
16
|
-
look: false,
|
|
17
18
|
name: 'isEnabled',
|
|
18
19
|
pageSize: 20,
|
|
19
|
-
message: i18n(`${i18nKey}.allowUsageTracking.promptMessage`),
|
|
20
|
+
message: (0, lang_1.i18n)(`${i18nKey}.allowUsageTracking.promptMessage`),
|
|
20
21
|
choices: [
|
|
21
22
|
{
|
|
22
|
-
name: i18n(`${i18nKey}.allowUsageTracking.labels.enabled`),
|
|
23
|
+
name: (0, lang_1.i18n)(`${i18nKey}.allowUsageTracking.labels.enabled`),
|
|
23
24
|
value: true,
|
|
24
25
|
},
|
|
25
26
|
{
|
|
26
|
-
name: i18n(`${i18nKey}.allowUsageTracking.labels.disabled`),
|
|
27
|
+
name: (0, lang_1.i18n)(`${i18nKey}.allowUsageTracking.labels.disabled`),
|
|
27
28
|
value: false,
|
|
28
29
|
},
|
|
29
30
|
],
|
|
@@ -31,9 +32,9 @@ const enableOrDisableUsageTracking = async () => {
|
|
|
31
32
|
},
|
|
32
33
|
]);
|
|
33
34
|
return isEnabled;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
trackCommandUsage('config-set-allow-usage-tracking',
|
|
35
|
+
}
|
|
36
|
+
async function setAllowUsageTracking({ accountId, allowUsageTracking, }) {
|
|
37
|
+
(0, usageTracking_1.trackCommandUsage)('config-set-allow-usage-tracking', undefined, accountId);
|
|
37
38
|
let isEnabled;
|
|
38
39
|
if (typeof allowUsageTracking === 'boolean') {
|
|
39
40
|
isEnabled = allowUsageTracking;
|
|
@@ -41,58 +42,59 @@ const setAllowUsageTracking = async ({ accountId, allowUsageTracking }) => {
|
|
|
41
42
|
else {
|
|
42
43
|
isEnabled = await enableOrDisableUsageTracking();
|
|
43
44
|
}
|
|
44
|
-
updateAllowUsageTracking(isEnabled);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
(0, config_1.updateAllowUsageTracking)(isEnabled);
|
|
46
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.allowUsageTracking.success`, {
|
|
47
|
+
isEnabled: isEnabled.toString(),
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
const ALL_CMS_PUBLISH_MODES = Object.values(files_1.CMS_PUBLISH_MODE);
|
|
51
|
+
async function selectCmsPublishMode() {
|
|
52
|
+
const { cmsPublishMode } = await (0, promptUtils_1.promptUser)([
|
|
50
53
|
{
|
|
51
54
|
type: 'list',
|
|
52
|
-
|
|
53
|
-
name: 'mode',
|
|
55
|
+
name: 'cmsPublishMode',
|
|
54
56
|
pageSize: 20,
|
|
55
|
-
message: i18n(`${i18nKey}.defaultMode.promptMessage`),
|
|
56
|
-
choices:
|
|
57
|
-
default:
|
|
57
|
+
message: (0, lang_1.i18n)(`${i18nKey}.defaultMode.promptMessage`),
|
|
58
|
+
choices: ALL_CMS_PUBLISH_MODES,
|
|
59
|
+
default: files_1.CMS_PUBLISH_MODE.publish,
|
|
58
60
|
},
|
|
59
61
|
]);
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
trackCommandUsage('config-set-default-mode',
|
|
62
|
+
return cmsPublishMode;
|
|
63
|
+
}
|
|
64
|
+
async function setDefaultCmsPublishMode({ accountId, defaultCmsPublishMode, }) {
|
|
65
|
+
(0, usageTracking_1.trackCommandUsage)('config-set-default-mode', undefined, accountId);
|
|
64
66
|
let newDefault;
|
|
65
|
-
if (!
|
|
66
|
-
newDefault = await
|
|
67
|
+
if (!defaultCmsPublishMode) {
|
|
68
|
+
newDefault = await selectCmsPublishMode();
|
|
67
69
|
}
|
|
68
|
-
else if (
|
|
69
|
-
|
|
70
|
+
else if (defaultCmsPublishMode &&
|
|
71
|
+
ALL_CMS_PUBLISH_MODES.find(m => m === defaultCmsPublishMode)) {
|
|
72
|
+
newDefault = defaultCmsPublishMode;
|
|
70
73
|
}
|
|
71
74
|
else {
|
|
72
|
-
logger.error(i18n(`${i18nKey}.defaultMode.
|
|
73
|
-
|
|
74
|
-
validModes: commaSeparatedValues(ALL_MODES),
|
|
75
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.defaultMode.error`, {
|
|
76
|
+
validModes: (0, text_1.commaSeparatedValues)(ALL_CMS_PUBLISH_MODES),
|
|
75
77
|
}));
|
|
76
|
-
newDefault = await
|
|
78
|
+
newDefault = await selectCmsPublishMode();
|
|
77
79
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
(0, config_1.updateDefaultCmsPublishMode)(newDefault);
|
|
81
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.defaultMode.success`, {
|
|
80
82
|
mode: newDefault,
|
|
81
83
|
}));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const { timeout } = await promptUser([
|
|
84
|
+
}
|
|
85
|
+
async function enterTimeout() {
|
|
86
|
+
const { timeout } = await (0, promptUtils_1.promptUser)([
|
|
85
87
|
{
|
|
86
88
|
name: 'timeout',
|
|
87
|
-
message: i18n(`${i18nKey}.httpTimeout.promptMessage`),
|
|
89
|
+
message: (0, lang_1.i18n)(`${i18nKey}.httpTimeout.promptMessage`),
|
|
88
90
|
type: 'input',
|
|
89
91
|
default: 30000,
|
|
90
92
|
},
|
|
91
93
|
]);
|
|
92
94
|
return timeout;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
trackCommandUsage('config-set-http-timeout',
|
|
95
|
+
}
|
|
96
|
+
async function setHttpTimeout({ accountId, httpTimeout, }) {
|
|
97
|
+
(0, usageTracking_1.trackCommandUsage)('config-set-http-timeout', undefined, accountId);
|
|
96
98
|
let newHttpTimeout;
|
|
97
99
|
if (!httpTimeout) {
|
|
98
100
|
newHttpTimeout = await enterTimeout();
|
|
@@ -100,11 +102,6 @@ const setHttpTimeout = async ({ accountId, httpTimeout }) => {
|
|
|
100
102
|
else {
|
|
101
103
|
newHttpTimeout = httpTimeout;
|
|
102
104
|
}
|
|
103
|
-
updateHttpTimeout(newHttpTimeout);
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
module.exports = {
|
|
107
|
-
setAllowUsageTracking,
|
|
108
|
-
setDefaultMode,
|
|
109
|
-
setHttpTimeout,
|
|
110
|
-
};
|
|
105
|
+
(0, config_1.updateHttpTimeout)(newHttpTimeout);
|
|
106
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.httpTimeout.success`, { timeout: newHttpTimeout }));
|
|
107
|
+
}
|
package/lib/constants.d.ts
CHANGED
|
@@ -60,10 +60,7 @@ export declare const PROJECT_ERROR_TYPES: {
|
|
|
60
60
|
readonly SUBDEPLOY_FAILED: "DeployPipelineErrorType.DEPENDENT_SUBDEPLOY_FAILED";
|
|
61
61
|
};
|
|
62
62
|
export declare const PROJECT_TASK_TYPES: {
|
|
63
|
-
|
|
64
|
-
readonly PUBLIC_APP: "public app";
|
|
65
|
-
readonly APP_FUNCTION: "function";
|
|
66
|
-
readonly CRM_CARD_V2: "card";
|
|
63
|
+
[key: string]: string;
|
|
67
64
|
};
|
|
68
65
|
export declare const PROJECT_COMPONENT_TYPES: {
|
|
69
66
|
readonly PROJECTS: "projects";
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare function isGloballyInstalled(command: any): Promise<boolean>;
|
|
2
|
-
export declare function getLatestCliVersion():
|
|
2
|
+
export declare function getLatestCliVersion(): {
|
|
3
|
+
latest: string;
|
|
4
|
+
next: string;
|
|
5
|
+
};
|
|
3
6
|
export declare function hasMissingPackages(directory: any): Promise<boolean>;
|
|
@@ -38,8 +38,8 @@ async function isGloballyInstalled(command) {
|
|
|
38
38
|
async function getLatestCliVersion() {
|
|
39
39
|
const exec = util.promisify(execAsync);
|
|
40
40
|
const { stdout } = await exec(`npm info ${pkg.name} dist-tags --json`);
|
|
41
|
-
const { latest } = JSON.parse(stdout);
|
|
42
|
-
return latest;
|
|
41
|
+
const { latest, next } = JSON.parse(stdout);
|
|
42
|
+
return { latest, next };
|
|
43
43
|
}
|
|
44
44
|
async function installPackages({ packages, installLocations }) {
|
|
45
45
|
const installDirs = installLocations || (await getProjectPackageJsonLocations());
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
2
|
+
import { FetchDeveloperTestAccountsResponse } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
3
|
+
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
4
|
+
export declare function validateDevTestAccountUsageLimits(accountConfig: CLIAccount): Promise<FetchDeveloperTestAccountsResponse | null>;
|
|
5
|
+
export declare function handleDeveloperTestAccountCreateError(err: unknown, accountId: number, env: Environment, portalLimit: number): never;
|
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
exports.validateDevTestAccountUsageLimits = validateDevTestAccountUsageLimits;
|
|
4
|
+
exports.handleDeveloperTestAccountCreateError = handleDeveloperTestAccountCreateError;
|
|
5
|
+
const config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
6
|
+
const config_2 = require("@hubspot/local-dev-lib/config");
|
|
7
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
8
|
+
const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
|
|
9
|
+
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
10
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
11
|
+
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
12
|
+
const lang_1 = require("./lang");
|
|
13
|
+
const ui_1 = require("./ui");
|
|
14
|
+
const index_2 = require("./errorHandlers/index");
|
|
15
|
+
function getHasDevTestAccounts(appDeveloperAccountConfig) {
|
|
16
|
+
const id = (0, getAccountIdentifier_1.getAccountIdentifier)(appDeveloperAccountConfig);
|
|
17
|
+
const parentPortalId = (0, config_2.getAccountId)(id);
|
|
18
|
+
const accountsList = (0, config_2.getConfigAccounts)();
|
|
19
|
+
if (!accountsList) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
for (const portal of accountsList) {
|
|
17
23
|
if (Boolean(portal.parentAccountId) &&
|
|
18
24
|
portal.parentAccountId === parentPortalId &&
|
|
19
|
-
portal.accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST) {
|
|
25
|
+
portal.accountType === config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST) {
|
|
20
26
|
return true;
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
return false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
30
|
+
}
|
|
31
|
+
async function validateDevTestAccountUsageLimits(accountConfig) {
|
|
32
|
+
const id = (0, getAccountIdentifier_1.getAccountIdentifier)(accountConfig);
|
|
33
|
+
const accountId = (0, config_2.getAccountId)(id);
|
|
34
|
+
if (!accountId) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const { data } = await (0, developerTestAccounts_1.fetchDeveloperTestAccounts)(accountId);
|
|
28
38
|
if (!data) {
|
|
29
39
|
return null;
|
|
30
40
|
}
|
|
@@ -33,49 +43,45 @@ const validateDevTestAccountUsageLimits = async (accountConfig) => {
|
|
|
33
43
|
if (count >= limit) {
|
|
34
44
|
const hasDevTestAccounts = getHasDevTestAccounts(accountConfig);
|
|
35
45
|
if (hasDevTestAccounts) {
|
|
36
|
-
throw new Error(i18n('lib.developerTestAccount.create.failure.alreadyInConfig', {
|
|
46
|
+
throw new Error((0, lang_1.i18n)('lib.developerTestAccount.create.failure.alreadyInConfig', {
|
|
37
47
|
accountName: accountConfig.name || accountId,
|
|
38
48
|
limit,
|
|
39
49
|
}));
|
|
40
50
|
}
|
|
41
51
|
else {
|
|
42
|
-
throw new Error(i18n('lib.developerTestAccount.create.failure.limit', {
|
|
52
|
+
throw new Error((0, lang_1.i18n)('lib.developerTestAccount.create.failure.limit', {
|
|
43
53
|
accountName: accountConfig.name || accountId,
|
|
44
54
|
limit,
|
|
45
55
|
}));
|
|
46
56
|
}
|
|
47
57
|
}
|
|
48
58
|
return data;
|
|
49
|
-
}
|
|
50
|
-
function handleDeveloperTestAccountCreateError(
|
|
51
|
-
if (isMissingScopeError(err)) {
|
|
52
|
-
logger.error(i18n('lib.developerTestAccount.create.failure.scopes.message', {
|
|
53
|
-
accountName: uiAccountDescription(accountId),
|
|
59
|
+
}
|
|
60
|
+
function handleDeveloperTestAccountCreateError(err, accountId, env, portalLimit) {
|
|
61
|
+
if ((0, index_1.isMissingScopeError)(err)) {
|
|
62
|
+
logger_1.logger.error((0, lang_1.i18n)('lib.developerTestAccount.create.failure.scopes.message', {
|
|
63
|
+
accountName: (0, ui_1.uiAccountDescription)(accountId),
|
|
54
64
|
}));
|
|
55
|
-
const websiteOrigin = getHubSpotWebsiteOrigin(env);
|
|
65
|
+
const websiteOrigin = (0, urls_1.getHubSpotWebsiteOrigin)(env);
|
|
56
66
|
const url = `${websiteOrigin}/personal-access-key/${accountId}`;
|
|
57
|
-
logger.info(i18n('lib.developerTestAccount.create.failure.scopes.instructions', {
|
|
58
|
-
accountName: uiAccountDescription(accountId),
|
|
67
|
+
logger_1.logger.info((0, lang_1.i18n)('lib.developerTestAccount.create.failure.scopes.instructions', {
|
|
68
|
+
accountName: (0, ui_1.uiAccountDescription)(accountId),
|
|
59
69
|
url,
|
|
60
70
|
}));
|
|
61
71
|
}
|
|
62
|
-
else if (isSpecifiedError(err, {
|
|
72
|
+
else if ((0, index_1.isSpecifiedError)(err, {
|
|
63
73
|
statusCode: 400,
|
|
64
74
|
errorType: 'TEST_PORTAL_LIMIT_REACHED',
|
|
65
75
|
})) {
|
|
66
|
-
logger.log('');
|
|
67
|
-
logger.error(i18n('lib.developerTestAccount.create.failure.limit', {
|
|
68
|
-
accountName: uiAccountDescription(accountId),
|
|
76
|
+
logger_1.logger.log('');
|
|
77
|
+
logger_1.logger.error((0, lang_1.i18n)('lib.developerTestAccount.create.failure.limit', {
|
|
78
|
+
accountName: (0, ui_1.uiAccountDescription)(accountId),
|
|
69
79
|
limit: portalLimit,
|
|
70
80
|
}));
|
|
71
|
-
logger.log('');
|
|
81
|
+
logger_1.logger.log('');
|
|
72
82
|
}
|
|
73
83
|
else {
|
|
74
|
-
logError(err);
|
|
84
|
+
(0, index_2.logError)(err);
|
|
75
85
|
}
|
|
76
86
|
throw err;
|
|
77
87
|
}
|
|
78
|
-
module.exports = {
|
|
79
|
-
validateDevTestAccountUsageLimits,
|
|
80
|
-
handleDeveloperTestAccountCreateError,
|
|
81
|
-
};
|
|
@@ -46,11 +46,12 @@ class DiagnosticInfoBuilder {
|
|
|
46
46
|
this.processInfo = processInfo;
|
|
47
47
|
}
|
|
48
48
|
async generateDiagnosticInfo() {
|
|
49
|
-
// @ts-expect-error getProjectConfig not typed yet
|
|
50
49
|
this._projectConfig = await (0, projects_1.getProjectConfig)();
|
|
51
50
|
if (this._projectConfig?.projectConfig) {
|
|
52
51
|
await this.fetchProjectDetails();
|
|
53
52
|
await this.fetchAccessToken();
|
|
53
|
+
}
|
|
54
|
+
if (this._projectConfig?.projectDir) {
|
|
54
55
|
await this.fetchProjectFilenames();
|
|
55
56
|
}
|
|
56
57
|
const { platform, arch, versions: { node }, mainModule, } = this.processInfo;
|
|
@@ -82,7 +83,9 @@ class DiagnosticInfoBuilder {
|
|
|
82
83
|
}
|
|
83
84
|
async fetchProjectDetails() {
|
|
84
85
|
try {
|
|
85
|
-
const { data } = await (0, projects_2.fetchProject)(this.accountId,
|
|
86
|
+
const { data } = await (0, projects_2.fetchProject)(this.accountId,
|
|
87
|
+
// We check that config exists before running this function
|
|
88
|
+
this._projectConfig.projectConfig.name);
|
|
86
89
|
this.projectDetails = data;
|
|
87
90
|
}
|
|
88
91
|
catch (e) {
|
|
@@ -100,9 +103,10 @@ class DiagnosticInfoBuilder {
|
|
|
100
103
|
}
|
|
101
104
|
async fetchProjectFilenames() {
|
|
102
105
|
try {
|
|
103
|
-
|
|
106
|
+
// We check that projectDir exists before running this function
|
|
107
|
+
this.files = (await (0, fs_1.walk)(this._projectConfig.projectDir))
|
|
104
108
|
.filter(file => !path_1.default.dirname(file).includes('node_modules'))
|
|
105
|
-
.map(filename => path_1.default.relative(this._projectConfig
|
|
109
|
+
.map(filename => path_1.default.relative(this._projectConfig.projectDir, filename));
|
|
106
110
|
}
|
|
107
111
|
catch (e) {
|
|
108
112
|
logger_1.logger.debug(e);
|