@hubspot/cli 7.2.5-experimental.0 → 7.3.0-experimental.1

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.
Files changed (66) hide show
  1. package/bin/cli.js +81 -73
  2. package/commands/account/clean.js +5 -36
  3. package/commands/account/info.js +0 -23
  4. package/commands/account/list.js +4 -22
  5. package/commands/account/remove.js +0 -28
  6. package/commands/account/use.js +0 -13
  7. package/commands/account.js +0 -6
  8. package/commands/auth.js +2 -6
  9. package/commands/config/set.d.ts +0 -12
  10. package/commands/config/set.js +29 -30
  11. package/commands/config.d.ts +1 -4
  12. package/commands/config.js +10 -45
  13. package/commands/customObject.d.ts +1 -1
  14. package/commands/init.js +10 -9
  15. package/commands/mv.d.ts +1 -1
  16. package/commands/project/add.d.ts +10 -0
  17. package/commands/project/add.js +64 -52
  18. package/commands/project/deploy.d.ts +11 -1
  19. package/commands/project/deploy.js +79 -71
  20. package/commands/project/dev/index.d.ts +1 -1
  21. package/commands/project/download.d.ts +11 -0
  22. package/commands/project/download.js +56 -54
  23. package/commands/project/listBuilds.d.ts +10 -0
  24. package/commands/project/listBuilds.js +101 -91
  25. package/commands/project/open.d.ts +9 -0
  26. package/commands/project/open.js +43 -35
  27. package/commands/sandbox/create.d.ts +1 -1
  28. package/commands/sandbox/delete.d.ts +1 -1
  29. package/commands/sandbox.d.ts +1 -1
  30. package/lang/en.js +3448 -0
  31. package/lang/en.lyaml +13 -88
  32. package/lib/dependencyManagement.d.ts +0 -5
  33. package/lib/dependencyManagement.js +13 -39
  34. package/lib/doctor/Diagnosis.d.ts +2 -1
  35. package/lib/doctor/Diagnosis.js +6 -10
  36. package/lib/doctor/DiagnosticInfoBuilder.d.ts +0 -1
  37. package/lib/doctor/DiagnosticInfoBuilder.js +0 -1
  38. package/lib/doctor/Doctor.d.ts +0 -1
  39. package/lib/doctor/Doctor.js +2 -19
  40. package/lib/errorHandlers/index.js +17 -0
  41. package/lib/npm.d.ts +9 -0
  42. package/lib/npm.js +36 -0
  43. package/lib/projects/buildAndDeploy.d.ts +1 -1
  44. package/lib/projects/buildAndDeploy.js +1 -1
  45. package/lib/projects/index.d.ts +1 -1
  46. package/lib/projects/index.js +1 -1
  47. package/lib/prompts/downloadProjectPrompt.js +5 -1
  48. package/lib/prompts/projectNamePrompt.d.ts +6 -1
  49. package/lib/prompts/projectNamePrompt.js +17 -16
  50. package/lib/testUtils.d.ts +4 -2
  51. package/lib/testUtils.js +17 -3
  52. package/lib/ui/index.d.ts +2 -2
  53. package/lib/ui/index.js +0 -5
  54. package/lib/yargsUtils.d.ts +2 -2
  55. package/lib/yargsUtils.js +2 -2
  56. package/package.json +2 -2
  57. package/commands/account/auth.d.ts +0 -10
  58. package/commands/account/auth.js +0 -169
  59. package/commands/account/createOverride.d.ts +0 -10
  60. package/commands/account/createOverride.js +0 -103
  61. package/commands/account/removeOverride.d.ts +0 -10
  62. package/commands/account/removeOverride.js +0 -77
  63. package/commands/config/migrate.d.ts +0 -10
  64. package/commands/config/migrate.js +0 -85
  65. package/lib/configMigrate.d.ts +0 -2
  66. package/lib/configMigrate.js +0 -105
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 ({{ hsAccountFileName }}), 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 ({{ hsAccountFileName }}) 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,51 +18,11 @@ en:
21
18
  account:
22
19
  describe: "Commands for managing configured accounts."
23
20
  subcommands:
24
- auth:
25
- describe: "Configure authentication for your HubSpot account."
26
- options:
27
- account:
28
- describe: "HubSpot account to authenticate"
29
- errors:
30
- failedToUpdateConfig: "Failed to update the configuration file. Please try again."
31
- bothConfigFilesNotAllowed: "Unable to create config file, because there is an existing \"{{ deprecatedConfig }}\" file. To create a new config file, delete the existing one and try again."
32
- success:
33
- configFileCreated: "Created config file \"{{ configPath }}\""
34
- configFileUpdated: "Connected account \"{{ account }}\" and set it as the default account"
35
- createOverride:
36
- describe: "Create a new default account override file ({{ hsAccountFileName }}) in the current working directory."
37
- success: "Default account override file created at {{ overrideFilePath }}"
38
- accountOverride: "An account override file already exists at {{ overrideFilePath }} associated with account \"{{ accountOverride }}\"."
39
- prompts:
40
- replaceOverrideFile: "Replace existing account override file?"
41
- errors:
42
- accountNotFound: "The specified account could not be found in the config file {{ configPath }}"
43
- options:
44
- account:
45
- describe: "Name or ID of the account to create an override file for."
46
- examples:
47
- default: "Create a new default account override file ({{ hsAccountFileName }}) in the current working directory"
48
- idBased: "Create a new default account override file ({{ hsAccountFileName }}) in the current working directory, using the account with accountId \"1234567\""
49
- nameBased: "Create a new default account override file ({{ hsAccountFileName }}) in the current working directory, using the account with name \"MyAccount\""
50
- removeOverride:
51
- describe: "Remove the default account override file ({{ overrideFile }}) from the current working directory."
52
- accountOverride: "There is an account override file at {{ overrideFilePath }} associated with account \"{{ accountOverride }}\"."
53
- prompts:
54
- deleteOverrideFile: "Delete account override file?"
55
- success: "Removed the default account override file."
56
- noOverrideFile: "No default account override file found in the current working directory. No action required."
57
- options:
58
- force:
59
- describe: "Skip confirmation prompt when removing the override file"
60
21
  list:
61
- describe: "List names of accounts defined in config."
62
22
  accounts: "{{#bold}}Accounts{{/bold}}:"
63
- defaultAccountTitle: "{{#bold}}Default Account{{/bold}}"
64
- defaultAccount: "Account: {{ account }}"
65
- configPath: "Source: {{ configPath }}"
66
- overrideFilePathTitle: "{{#bold}}Default Account Override{{/bold}}"
67
- overrideFilePath: "Source: {{ overrideFilePath }}"
68
- overrideAccount: "Account: {{ account }}"
23
+ defaultAccount: "{{#bold}}Default account{{/bold}}: {{ account }}"
24
+ describe: "List names of accounts defined in config."
25
+ configPath: "{{#bold}}Config path{{/bold}}: {{ configPath }}"
69
26
  labels:
70
27
  accountId: "Account ID"
71
28
  authType: "Auth Type"
@@ -83,8 +40,6 @@ en:
83
40
  describe: "Set the Hubspot account to use as the default account. The default account can be overridden with the \"--account\" option."
84
41
  errors:
85
42
  accountNotFound: "The account \"{{ specifiedAccount }}\" could not be found in {{ configPath }}"
86
- accountOverride: "This project currently has an account override set: \"{{ accountOverride }}\". Account \"{{accountOverride}}\" will continue to act as the default account for this project."
87
- accountOverrideCommands: "Use {{ createOverrideCommand }} to change override accounts, or {{ removeOverrideCommand }} to remove the override and use your default account."
88
43
  examples:
89
44
  default: "Select a HubSpot account to use as the default account"
90
45
  idBased: "Set the default account to the account in the config with accountId equal to \"1234567\""
@@ -100,7 +55,6 @@ en:
100
55
  logs:
101
56
  replaceDefaultAccount: "The removed account was the default account."
102
57
  prompts:
103
- deleteOverrideFile: "Delete the override file ({{ overrideFilePath }}) associated with {{ accountName }}?"
104
58
  selectAccountToRemove: "Select an account to remove from the config"
105
59
  errors:
106
60
  accountNotFound: "The account \"{{ specifiedAccount }}\" could not be found in {{ configPath }}"
@@ -116,12 +70,6 @@ en:
116
70
  info:
117
71
  accountId: "{{#bold}}Account ID{{/bold}}: {{ accountId }}"
118
72
  describe: "Print information about the default account, or about the account specified with the \"account\" option."
119
- defaultAccountTitle: "{{#bold}}Default Account{{/bold}}"
120
- defaultAccount: "Account: {{ account }}"
121
- configPath: "Source: {{ configPath }}"
122
- overrideFilePathTitle: "{{#bold}}Default Account Override{{/bold}}"
123
- overrideFilePath: "Source: {{ overrideFilePath }}"
124
- overrideAccount: "Account: {{ account }}"
125
73
  errors:
126
74
  notUsingPersonalAccessKey: "This command currently only supports fetching scopes for the personal access key auth type."
127
75
  options:
@@ -144,15 +92,13 @@ en:
144
92
  confirm:
145
93
  one: "Remove 1 inactive account from the CLI config?"
146
94
  other: "Remove {{ count }} inactive accounts from the CLI config?"
147
- defaultAccountOverride: "\n(This will also delete the default account override file at {{ overrideFilePath }})"
148
- replaceDefaultAccount: "The default account was removed."
149
95
  removeSuccess: "Removed {{ accountName }} from the CLI config."
150
96
  auth:
151
97
  describe: "Configure authentication for your HubSpot account."
152
98
  verboseDescribe: "Configure authentication for a HubSpot account. This will update the {{ configName }} file that stores your account information.\n\nThe recommended authentication method is {{#bold}}{{ authMethod }}{{/bold}}, which uses an access token tied to a specific user account."
153
99
  errors:
100
+ noConfigFileFound: "No config file was found. To create a new config file, use the \"hs init\" command."
154
101
  unsupportedAuthType: "Unsupported auth type: {{ type }}. The only supported authentication protocols are {{ supportedProtocols }}."
155
- globalConfigFileExists: "A global config file exists at {{ configPath }}. To authorize an account, please use {{ authCommand }}."
156
102
  options:
157
103
  authType:
158
104
  describe: "Authentication method"
@@ -163,16 +109,6 @@ en:
163
109
  config:
164
110
  describe: "Commands for managing the CLI config file."
165
111
  subcommands:
166
- migrate:
167
- describe: "Migrate from the deprecated {{ deprecatedConfigPath }} file to the new global config file at {{ globalConfigPath }}."
168
- migrationAlreadyCompleted: "No {{ deprecatedConfigPath }} deprecated configuration file found. No migration necessary."
169
- errors:
170
- configNotFound: "A configuration file at {{ configPath }} could not be found. Please try again with a valid file path."
171
- options:
172
- force: "When merging a deprecated configuration file with an existing global configuration file, overwrite any conflicting values in the global config with the deprecated config values."
173
- examples:
174
- default: "Migrate from the deprecated {{ deprecatedConfigPath }} file to the new global config file at {{ globalConfigPath }}"
175
- configFlag: "Migrate a specific config file (specified with the config flag) to the new global config file at {{ globalConfigPath }}"
176
112
  set:
177
113
  describe: "Set various configuration options within the hubspot.config.yml file."
178
114
  promptMessage: "Select a config option to update"
@@ -520,6 +456,8 @@ en:
520
456
  describe: "Authentication method"
521
457
  account:
522
458
  describe: "HubSpot account to authenticate"
459
+ useHiddenConfig:
460
+ describe: "Use the new HubSpot configuration file located in a hidden file in the user's home directory"
523
461
  success:
524
462
  configFileCreated: "Created config file \"{{ configPath }}\""
525
463
  configFileUpdated: "Connected account \"{{ account }}\" using \"{{ authType }}\" and set it as the default account"
@@ -527,7 +465,7 @@ en:
527
465
  updateConfig: "To update an existing config file, use the \"hs auth\" command."
528
466
  errors:
529
467
  configFileExists: "The config file {{ configPath }} already exists."
530
- globalConfigFileExists: "A global config file already exists at {{ configPath }}. To specify a new local config file, delete the existing one and try again."
468
+ bothConfigFilesNotAllowed: "Unable to create config file, because there is an existing one at \"{{ path }}\". To create a new config file, delete the existing one and try again."
531
469
  lint:
532
470
  issuesFound: "{{ count }} issues found."
533
471
  groupName: "Linting {{ path }}"
@@ -693,7 +631,7 @@ en:
693
631
  debug:
694
632
  deploying: "Deploying project at path: {{ path }}"
695
633
  errors:
696
- deploy: "Deploy error: {{ details }}"
634
+ deploy: "Deploy error: an unknown error occurred."
697
635
  noBuilds: "Deploy error: no builds for this project were found."
698
636
  noBuildId: "You must specify a build to deploy"
699
637
  projectNotFound: "The project {{ projectName }} does not exist in account {{ accountIdentifier }}. Run {{ command }} to upload your project files to HubSpot."
@@ -812,7 +750,7 @@ en:
812
750
  downloadSucceeded: "Downloaded build \"{{ buildId }}\" from project \"{{ projectName }}\""
813
751
  errors:
814
752
  downloadFailed: "Something went wrong downloading the project"
815
- projectNotFound: "Your project {{ projectName }} could not be found in {{ accountId }}"
753
+ noBuildIdToDownload: "This project is empty. There is no build content to download"
816
754
  warnings:
817
755
  cannotDownloadWithinProject: "Cancelling project download. Please run the command again outside the context of an existing project."
818
756
  options:
@@ -1245,14 +1183,11 @@ en:
1245
1183
  command: "--account"
1246
1184
  message: "Use the {{ command }} option with any command to override the default account"
1247
1185
  accountsListCommand:
1248
- command: "hs account list"
1186
+ command: hs accounts list
1249
1187
  message: "Run {{ command }} to see a list of configured HubSpot accounts"
1250
1188
  accountsUseCommand:
1251
- command: "hs account use"
1189
+ command: "hs accounts use"
1252
1190
  message: "Run {{ command }} to set the Hubspot account that the CLI will target by default"
1253
- accountAuthCommand:
1254
- command: "hs account auth"
1255
- message: "Run {{ command }} to connect the CLI to additional HubSpot accounts"
1256
1191
  authCommand:
1257
1192
  command: "hs auth"
1258
1193
  message: "Run {{ command }} to connect the CLI to additional HubSpot accounts"
@@ -1314,13 +1249,6 @@ en:
1314
1249
  describe: "Use environment variable config"
1315
1250
  debug:
1316
1251
  describe: "Set log level to debug"
1317
- configMigrate:
1318
- migrateConfigPrompt: "Migrate config?\n From deprecated config file: {{ deprecatedConfigPath }}\n To new global config file: {{ globalConfigPath }}\n (This action will delete the deprecated config file).\n"
1319
- mergeConfigConflictPrompt: "Change the {{ property }} property in the global config from {{ newValue }} to {{ oldValue }}?"
1320
- mergeConfigsPrompt: "Two config files detected. Merge them?\n Deprecated config file: {{ deprecatedConfigPath }}\n Global config: {{ globalConfigPath }}\n (This action will delete the deprecated config file).\n"
1321
- migrationSuccess: "The deprecated config file has been migrated to the new global config file at {{ globalConfigPath }}."
1322
- mergeSuccess: "The deprecated config file has been merged with the global config file at {{ globalConfigPath }}."
1323
- skippedExistingAccounts: "\nThe following accounts were not merged, because they already exist in the global config: {{ skippedAccountIds }}.\n"
1324
1252
  prompts:
1325
1253
  projectDevTargetAccountPrompt:
1326
1254
  createNewSandboxOption: "<Test on a new development sandbox>"
@@ -1586,6 +1514,8 @@ en:
1586
1514
  errorContext: "Context: {{ context }}"
1587
1515
  errorCause: "Cause: {{ cause }}"
1588
1516
  unknownErrorOccurred: "An unknown error has occurred."
1517
+ configTimeoutErrorOccurred: "This error occurred because a request exceeded the default HTTP timeout of {{ timeout }}ms. To increase the default HTTP timeout, run {{ configSetCommand }}."
1518
+ genericTimeoutErrorOccurred: "This error occurred because an HTTP request timed out. Re-running the command may resolve this issue."
1589
1519
  suppressErrors:
1590
1520
  platformVersionErrors:
1591
1521
  header: "Platform version update required"
@@ -1605,9 +1535,6 @@ en:
1605
1535
  doctor:
1606
1536
  runningDiagnostics: "Running diagnostics..."
1607
1537
  diagnosticsComplete: "Diagnostics complete"
1608
- defaultAccountOverrideFileChecks:
1609
- overrideActive: "Default account override file active: {{ defaultAccountOverrideFile }}"
1610
- overrideAccountId: "Active account ID: {{ overrideAccountId }}"
1611
1538
  accountChecks:
1612
1539
  active: "Default account active"
1613
1540
  inactive: "Default account isn't active"
@@ -1659,8 +1586,6 @@ en:
1659
1586
  settings:
1660
1587
  httpUseLocalhost: "The setting {{#bold}}httpUseLocalhost{{/bold}} is enabled"
1661
1588
  httpUseLocalhostSecondary: "This setting causes all CLI requests to route to localhost"
1662
- defaultAccountOverrideFile:
1663
- header: "Default account override file path:"
1664
1589
  projectConfig:
1665
1590
  header: "Project configuration"
1666
1591
  projectDirSubHeader: "Project dir: {{#bold}}{{ projectDir }}{{/bold}}"
@@ -1,8 +1,3 @@
1
- export declare function isGloballyInstalled(command: string): Promise<boolean>;
2
- export declare function getLatestCliVersion(): Promise<{
3
- latest: string;
4
- next: string;
5
- }>;
6
1
  export declare function installPackages({ packages, installLocations, }: {
7
2
  packages?: string[];
8
3
  installLocations?: string[];
@@ -3,23 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isGloballyInstalled = isGloballyInstalled;
7
- exports.getLatestCliVersion = getLatestCliVersion;
8
6
  exports.installPackages = installPackages;
9
7
  exports.getProjectPackageJsonLocations = getProjectPackageJsonLocations;
10
8
  exports.hasMissingPackages = hasMissingPackages;
11
- const logger_1 = require("@hubspot/local-dev-lib/logger");
12
- const projects_1 = require("./projects");
13
- const child_process_1 = require("child_process");
14
- const fs_1 = require("@hubspot/local-dev-lib/fs");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const util_1 = __importDefault(require("util"));
15
11
  const path_1 = __importDefault(require("path"));
12
+ const child_process_1 = require("child_process");
13
+ const fs_2 = require("@hubspot/local-dev-lib/fs");
14
+ const projects_1 = require("./projects");
16
15
  const ui_1 = require("./ui");
17
- const util_1 = __importDefault(require("util"));
18
16
  const lang_1 = require("./lang");
19
17
  const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
20
- const fs_2 = __importDefault(require("fs"));
21
- const package_json_1 = __importDefault(require("../package.json"));
22
- const DEFAULT_PACKAGE_MANAGER = 'npm';
18
+ const npm_1 = require("./npm");
23
19
  const i18nKey = `commands.project.subcommands.installDeps`;
24
20
  class NoPackageJsonFilesError extends Error {
25
21
  constructor(projectName) {
@@ -29,22 +25,6 @@ class NoPackageJsonFilesError extends Error {
29
25
  }));
30
26
  }
31
27
  }
32
- async function isGloballyInstalled(command) {
33
- const exec = util_1.default.promisify(child_process_1.exec);
34
- try {
35
- await exec(`${command} --version`);
36
- return true;
37
- }
38
- catch (e) {
39
- return false;
40
- }
41
- }
42
- async function getLatestCliVersion() {
43
- const exec = util_1.default.promisify(child_process_1.exec);
44
- const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
45
- const { latest, next } = JSON.parse(stdout);
46
- return { latest, next };
47
- }
48
28
  async function installPackages({ packages, installLocations, }) {
49
29
  const installDirs = installLocations || (await getProjectPackageJsonLocations());
50
30
  await Promise.all(installDirs.map(async (dir) => {
@@ -65,14 +45,8 @@ async function installPackagesInDirectory(directory, packages) {
65
45
  directory: relativeDir,
66
46
  }),
67
47
  });
68
- let installCommand = `${DEFAULT_PACKAGE_MANAGER} install`;
69
- if (packages) {
70
- installCommand = `${installCommand} ${packages.join(' ')}`;
71
- }
72
- logger_1.logger.debug(`Running ${installCommand}`);
73
48
  try {
74
- const exec = util_1.default.promisify(child_process_1.exec);
75
- await exec(installCommand, { cwd: directory });
49
+ await (0, npm_1.executeInstall)(packages, null, { cwd: directory });
76
50
  SpinniesManager_1.default.succeed(spinner, {
77
51
  text: (0, lang_1.i18n)(`${i18nKey}.installationSuccessful`, {
78
52
  directory: relativeDir,
@@ -100,17 +74,17 @@ async function getProjectPackageJsonLocations() {
100
74
  throw new Error((0, lang_1.i18n)(`${i18nKey}.noProjectConfig`));
101
75
  }
102
76
  const { projectDir, projectConfig: { srcDir, name }, } = projectConfig;
103
- if (!(await isGloballyInstalled(DEFAULT_PACKAGE_MANAGER))) {
77
+ if (!(await (0, npm_1.isGloballyInstalled)())) {
104
78
  throw new Error((0, lang_1.i18n)(`${i18nKey}.packageManagerNotInstalled`, {
105
- packageManager: DEFAULT_PACKAGE_MANAGER,
106
- link: (0, ui_1.uiLink)(DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
79
+ packageManager: npm_1.DEFAULT_PACKAGE_MANAGER,
80
+ link: (0, ui_1.uiLink)(npm_1.DEFAULT_PACKAGE_MANAGER, 'https://docs.npmjs.com/downloading-and-installing-node-js-and-npm'),
107
81
  }));
108
82
  }
109
- if (!fs_2.default.existsSync(projectConfig.projectDir) ||
110
- !fs_2.default.existsSync(path_1.default.join(projectDir, srcDir))) {
83
+ if (!fs_1.default.existsSync(projectConfig.projectDir) ||
84
+ !fs_1.default.existsSync(path_1.default.join(projectDir, srcDir))) {
111
85
  throw new NoPackageJsonFilesError(name);
112
86
  }
113
- const packageJsonFiles = (await (0, fs_1.walk)(path_1.default.join(projectDir, srcDir))).filter(file => file.includes('package.json') &&
87
+ const packageJsonFiles = (await (0, fs_2.walk)(path_1.default.join(projectDir, srcDir))).filter(file => file.includes('package.json') &&
114
88
  !file.includes('node_modules') &&
115
89
  !file.includes('.vite'));
116
90
  if (packageJsonFiles.length === 0) {
@@ -11,15 +11,16 @@ interface Section {
11
11
  export declare class Diagnosis {
12
12
  private readonly prefixes;
13
13
  private readonly diagnosis;
14
+ private readonly indentation;
14
15
  private errorCount;
15
16
  private warningCount;
16
17
  constructor({ diagnosticInfo, accountId }: DiagnosisOptions);
18
+ private indent;
17
19
  getErrorCount(): number;
18
20
  getWarningCount(): number;
19
21
  addCliSection(section: Section): void;
20
22
  addProjectSection(section: Section): void;
21
23
  addCLIConfigSection(section: Section): void;
22
- addDefaultAccountOverrideFileSection(section: Section): void;
23
24
  toString(): string;
24
25
  private generateSections;
25
26
  }
@@ -5,12 +5,12 @@ const spinniesUtils_1 = require("../ui/spinniesUtils");
5
5
  const chalk_1 = require("chalk");
6
6
  const interpolation_1 = require("../interpolation");
7
7
  const ui_1 = require("../ui");
8
- const index_1 = require("../ui/index");
9
8
  const { i18n } = require('../lang');
10
9
  const i18nKey = `lib.doctor.diagnosis`;
11
10
  class Diagnosis {
12
11
  prefixes;
13
12
  diagnosis;
13
+ indentation = ' ';
14
14
  errorCount = 0;
15
15
  warningCount = 0;
16
16
  constructor({ diagnosticInfo, accountId }) {
@@ -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: [
@@ -57,6 +53,9 @@ class Diagnosis {
57
53
  ];
58
54
  }
59
55
  }
56
+ indent(level) {
57
+ return this.indentation.repeat(level);
58
+ }
60
59
  getErrorCount() {
61
60
  return this.errorCount;
62
61
  }
@@ -72,9 +71,6 @@ class Diagnosis {
72
71
  addCLIConfigSection(section) {
73
72
  this.diagnosis.cliConfig.sections.push(section);
74
73
  }
75
- addDefaultAccountOverrideFileSection(section) {
76
- this.diagnosis.defaultAccountOverrideFile.sections.push(section);
77
- }
78
74
  toString() {
79
75
  const output = [];
80
76
  for (const value of Object.values(this.diagnosis)) {
@@ -112,9 +108,9 @@ class Diagnosis {
112
108
  else if (section.type === 'warning') {
113
109
  this.warningCount++;
114
110
  }
115
- output.push(`${(0, index_1.indent)(1)}${this.prefixes[section.type]} ${section.message}`);
111
+ output.push(`${this.indent(1)}${this.prefixes[section.type]} ${section.message}`);
116
112
  if (section.secondaryMessaging) {
117
- output.push(`${(0, index_1.indent)(2)}- ${section.secondaryMessaging}`);
113
+ output.push(`${this.indent(2)}- ${section.secondaryMessaging}`);
118
114
  }
119
115
  });
120
116
  return output.join('\n');
@@ -21,7 +21,6 @@ export interface DiagnosticInfo extends FilesInfo {
21
21
  npm: string | null;
22
22
  };
23
23
  config: string | null;
24
- defaultAccountOverrideFile: string | null | undefined;
25
24
  configSettings: {
26
25
  [key: string]: unknown;
27
26
  };
@@ -64,7 +64,6 @@ class DiagnosticInfoBuilder {
64
64
  arch,
65
65
  path: mainModule?.path,
66
66
  config: (0, config_2.getConfigPath)(),
67
- defaultAccountOverrideFile: (0, config_1.getDefaultAccountOverrideFilePath)(),
68
67
  configSettings: this.configSettings,
69
68
  versions: {
70
69
  [hubspotCli]: package_json_1.default.version,
@@ -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 performCliConfigSettingsChecks;
15
14
  private checkIfAccessTokenValid;
16
15
  private checkIfNodeIsInstalled;
@@ -8,6 +8,7 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
8
8
  const config_1 = require("@hubspot/local-dev-lib/config");
9
9
  const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
10
10
  const dependencyManagement_1 = require("../dependencyManagement");
11
+ const npm_1 = require("../npm");
11
12
  const util_1 = __importDefault(require("util"));
12
13
  const fs_1 = __importDefault(require("fs"));
13
14
  const path_1 = __importDefault(require("path"));
@@ -51,7 +52,6 @@ class Doctor {
51
52
  ...this.performCliConfigChecks(),
52
53
  ...(this.projectConfig?.projectConfig ? this.performProjectChecks() : []),
53
54
  ]);
54
- this.performDefaultAccountOverrideFileChecks();
55
55
  this.performCliConfigSettingsChecks();
56
56
  SpinniesManager_1.default.succeed('runningDiagnostics', {
57
57
  text: i18n(`${i18nKey}.diagnosticsComplete`),
@@ -89,23 +89,6 @@ class Doctor {
89
89
  }
90
90
  return [this.checkIfAccessTokenValid()];
91
91
  }
92
- performDefaultAccountOverrideFileChecks() {
93
- const localI18nKey = `${i18nKey}.defaultAccountOverrideFileChecks`;
94
- if (this.diagnosticInfo?.defaultAccountOverrideFile) {
95
- this.diagnosis?.addDefaultAccountOverrideFileSection({
96
- type: 'warning',
97
- message: i18n(`${localI18nKey}.overrideActive`, {
98
- defaultAccountOverrideFile: this.diagnosticInfo.defaultAccountOverrideFile,
99
- }),
100
- });
101
- this.diagnosis?.addDefaultAccountOverrideFileSection({
102
- type: 'warning',
103
- message: i18n(`${localI18nKey}.overrideAccountId`, {
104
- overrideAccountId: (0, config_1.getCWDAccountOverride)(),
105
- }),
106
- });
107
- }
108
- }
109
92
  performCliConfigSettingsChecks() {
110
93
  if (this.diagnosticInfo?.configSettings.httpUseLocalhost) {
111
94
  this.diagnosis?.addCLIConfigSection({
@@ -233,7 +216,7 @@ class Doctor {
233
216
  let latestCLIVersion;
234
217
  let nextCliVersion;
235
218
  try {
236
- const { latest, next } = await (0, dependencyManagement_1.getLatestCliVersion)();
219
+ const { latest, next } = await (0, npm_1.getLatestCliVersion)();
237
220
  latestCLIVersion = latest;
238
221
  nextCliVersion = next;
239
222
  }
@@ -8,9 +8,11 @@ exports.logError = logError;
8
8
  exports.debugError = debugError;
9
9
  const logger_1 = require("@hubspot/local-dev-lib/logger");
10
10
  const index_1 = require("@hubspot/local-dev-lib/errors/index");
11
+ const config_1 = require("@hubspot/local-dev-lib/config");
11
12
  const suppressError_1 = require("./suppressError");
12
13
  const lang_1 = require("../lang");
13
14
  const util_1 = __importDefault(require("util"));
15
+ const ui_1 = require("../ui");
14
16
  const i18nKey = 'lib.errorHandlers.index';
15
17
  function logError(error, context) {
16
18
  debugError(error, context);
@@ -41,6 +43,21 @@ function logError(error, context) {
41
43
  // Unknown errors
42
44
  logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.unknownErrorOccurred`));
43
45
  }
46
+ if ((0, index_1.isHubSpotHttpError)(error) && error.code === 'ETIMEDOUT') {
47
+ const config = (0, config_1.getConfig)();
48
+ const defaultTimeout = config?.httpTimeout;
49
+ // Timeout was caused by the default timeout
50
+ if (error.timeout && defaultTimeout === error.timeout) {
51
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.configTimeoutErrorOccurred`, {
52
+ timeout: error.timeout,
53
+ configSetCommand: (0, ui_1.uiCommandReference)('hs config set'),
54
+ }));
55
+ }
56
+ // Timeout was caused by a custom timeout set by the CLI or LDL
57
+ else {
58
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.genericTimeoutErrorOccurred`));
59
+ }
60
+ }
44
61
  }
45
62
  function debugError(error, context) {
46
63
  if ((0, index_1.isHubSpotHttpError)(error)) {
package/lib/npm.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export declare const DEFAULT_PACKAGE_MANAGER = "npm";
2
+ export declare function isGloballyInstalled(): Promise<boolean>;
3
+ export declare function getLatestCliVersion(): Promise<{
4
+ latest: string;
5
+ next: string;
6
+ }>;
7
+ export declare function executeInstall(packages?: string[], flags?: string | null, options?: {
8
+ cwd?: string;
9
+ }): Promise<void>;
package/lib/npm.js ADDED
@@ -0,0 +1,36 @@
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.DEFAULT_PACKAGE_MANAGER = void 0;
7
+ exports.isGloballyInstalled = isGloballyInstalled;
8
+ exports.getLatestCliVersion = getLatestCliVersion;
9
+ exports.executeInstall = executeInstall;
10
+ const child_process_1 = require("child_process");
11
+ const util_1 = __importDefault(require("util"));
12
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
13
+ const package_json_1 = __importDefault(require("../package.json"));
14
+ exports.DEFAULT_PACKAGE_MANAGER = 'npm';
15
+ async function isGloballyInstalled() {
16
+ const exec = util_1.default.promisify(child_process_1.exec);
17
+ try {
18
+ await exec(`${exports.DEFAULT_PACKAGE_MANAGER} --version`);
19
+ return true;
20
+ }
21
+ catch (e) {
22
+ return false;
23
+ }
24
+ }
25
+ async function getLatestCliVersion() {
26
+ const exec = util_1.default.promisify(child_process_1.exec);
27
+ const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
28
+ const { latest, next } = JSON.parse(stdout);
29
+ return { latest, next };
30
+ }
31
+ async function executeInstall(packages = [], flags, options) {
32
+ const installCommand = `${exports.DEFAULT_PACKAGE_MANAGER} install${flags ? ` ${flags}` : ''} ${packages.join(' ')}`;
33
+ logger_1.logger.debug('Running ', installCommand);
34
+ const exec = util_1.default.promisify(child_process_1.exec);
35
+ await exec(installCommand, options);
36
+ }
@@ -3,7 +3,7 @@ import { Build } from '@hubspot/local-dev-lib/types/Build';
3
3
  import { Deploy } from '@hubspot/local-dev-lib/types/Deploy';
4
4
  import { ProjectConfig, ProjectTask, ProjectPollResult } from '../../types/Projects';
5
5
  export declare function useV3Api(platformVersion?: string | null): boolean;
6
- type PollTaskStatusFunction<T extends ProjectTask> = (accountId: number, taskName: string, taskId: number, deployedBuildId: number | null, silenceLogs: boolean) => Promise<T>;
6
+ type PollTaskStatusFunction<T extends ProjectTask> = (accountId: number, taskName: string, taskId: number, deployedBuildId: number | null, silenceLogs?: boolean) => Promise<T>;
7
7
  export declare const pollBuildStatus: PollTaskStatusFunction<Build>;
8
8
  export declare const pollDeployStatus: PollTaskStatusFunction<Deploy>;
9
9
  export declare function displayWarnLogs(accountId: number, projectName: string, taskId: number, isDeploy?: boolean): Promise<void>;
@@ -59,7 +59,7 @@ function handleTaskStatusError(statusText) {
59
59
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
60
60
  }
61
61
  function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrings, linkToHubSpot, }) {
62
- return async function (accountId, taskName, taskId, deployedBuildId = null, silenceLogs = false) {
62
+ return async function (accountId, taskName, taskId, deployedBuildId, silenceLogs = false) {
63
63
  const displayId = deployedBuildId || taskId;
64
64
  if (linkToHubSpot && !silenceLogs) {
65
65
  logger_1.logger.log(`\n${linkToHubSpot(accountId, taskName, taskId, deployedBuildId)}\n`);
@@ -6,7 +6,7 @@ export declare function getProjectConfig(dir?: string): Promise<{
6
6
  projectDir: string | null;
7
7
  projectConfig: ProjectConfig | null;
8
8
  }>;
9
- export declare function validateProjectConfig(projectConfig: ProjectConfig, projectDir: string): void;
9
+ export declare function validateProjectConfig(projectConfig: ProjectConfig | null, projectDir: string | null): void;
10
10
  export declare function ensureProjectExists(accountId: number, projectName: string, { forceCreate, allowCreate, noLogs, withPolling, uploadCommand, }?: {
11
11
  forceCreate?: boolean | undefined;
12
12
  allowCreate?: boolean | undefined;
@@ -67,7 +67,7 @@ async function getProjectConfig(dir) {
67
67
  }
68
68
  }
69
69
  function validateProjectConfig(projectConfig, projectDir) {
70
- if (!projectConfig) {
70
+ if (!projectConfig || !projectDir) {
71
71
  logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.validateProjectConfig.configNotFound`, {
72
72
  createCommand: (0, ui_1.uiCommandReference)('hs project create'),
73
73
  }));
@@ -26,7 +26,7 @@ async function createProjectsList(accountId) {
26
26
  async function downloadProjectPrompt(promptOptions) {
27
27
  const accountId = (0, config_1.getAccountId)(promptOptions.account);
28
28
  const projectsList = await createProjectsList(accountId);
29
- return (0, promptUtils_1.promptUser)([
29
+ const response = await (0, promptUtils_1.promptUser)([
30
30
  {
31
31
  name: 'project',
32
32
  message: () => {
@@ -49,4 +49,8 @@ async function downloadProjectPrompt(promptOptions) {
49
49
  }),
50
50
  },
51
51
  ]);
52
+ if (!response.project) {
53
+ response.project = promptOptions.project;
54
+ }
55
+ return response;
52
56
  }
@@ -1 +1,6 @@
1
- export {};
1
+ export type ProjectNamePromptResponse = {
2
+ projectName: string;
3
+ };
4
+ export declare function projectNamePrompt(accountId: number, options?: {
5
+ project?: string;
6
+ }): Promise<ProjectNamePromptResponse>;