@hubspot/cli 7.2.5-experimental.0 → 7.3.0-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.
Files changed (66) hide show
  1. package/bin/cli.js +79 -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
@@ -1,34 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const { promptUser } = require('./promptUtils');
5
- const { i18n } = require('../lang');
6
- const { ensureProjectExists } = require('../projects');
7
- const { uiAccountDescription } = require('../ui');
3
+ exports.projectNamePrompt = projectNamePrompt;
4
+ const promptUtils_1 = require("./promptUtils");
5
+ const lang_1 = require("../lang");
6
+ const projects_1 = require("../projects");
7
+ const ui_1 = require("../ui");
8
8
  const i18nKey = 'lib.prompts.projectNamePrompt';
9
- const projectNamePrompt = (accountId, options = {}) => {
10
- return promptUser({
9
+ async function projectNamePrompt(accountId, options = {}) {
10
+ const result = await (0, promptUtils_1.promptUser)({
11
11
  name: 'projectName',
12
- message: i18n(`${i18nKey}.enterName`),
12
+ message: (0, lang_1.i18n)(`${i18nKey}.enterName`),
13
13
  when: !options.project,
14
14
  validate: async (val) => {
15
15
  if (typeof val !== 'string' || !val) {
16
- return i18n(`${i18nKey}.errors.invalidName`);
16
+ return (0, lang_1.i18n)(`${i18nKey}.errors.invalidName`);
17
17
  }
18
- const { projectExists } = await ensureProjectExists(accountId, val, {
18
+ const { projectExists } = await (0, projects_1.ensureProjectExists)(accountId, val, {
19
19
  allowCreate: false,
20
20
  noLogs: true,
21
21
  });
22
22
  if (!projectExists) {
23
- return i18n(`${i18nKey}.errors.projectDoesNotExist`, {
23
+ return (0, lang_1.i18n)(`${i18nKey}.errors.projectDoesNotExist`, {
24
24
  projectName: val,
25
- accountIdentifier: uiAccountDescription(accountId),
25
+ accountIdentifier: (0, ui_1.uiAccountDescription)(accountId),
26
26
  });
27
27
  }
28
28
  return true;
29
29
  },
30
30
  });
31
- };
32
- module.exports = {
33
- projectNamePrompt,
34
- };
31
+ if (!result.projectName && options.project) {
32
+ result.projectName = options.project;
33
+ }
34
+ return result;
35
+ }
@@ -1,5 +1,6 @@
1
+ import { AxiosResponse } from 'axios';
1
2
  import { HubSpotHttpError } from '@hubspot/local-dev-lib/models/HubSpotHttpError';
2
- type MockResponse = {
3
+ type MockErrorResponse = {
3
4
  status: number;
4
5
  data: {
5
6
  message?: string;
@@ -8,5 +9,6 @@ type MockResponse = {
8
9
  subCategory?: string;
9
10
  };
10
11
  };
11
- export declare const makeHubSpotHttpError: (message: string, response: MockResponse) => HubSpotHttpError;
12
+ export declare const mockHubSpotHttpResponse: (data: any) => AxiosResponse;
13
+ export declare const mockHubSpotHttpError: (message: string, response: MockErrorResponse) => HubSpotHttpError;
12
14
  export {};
package/lib/testUtils.js CHANGED
@@ -1,10 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeHubSpotHttpError = void 0;
3
+ exports.mockHubSpotHttpError = exports.mockHubSpotHttpResponse = void 0;
4
+ const axios_1 = require("axios");
4
5
  const HubSpotHttpError_1 = require("@hubspot/local-dev-lib/models/HubSpotHttpError");
5
- const makeHubSpotHttpError = (message, response) => {
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ const mockHubSpotHttpResponse = (data) => {
8
+ return {
9
+ data,
10
+ status: 200,
11
+ statusText: 'OK',
12
+ headers: {},
13
+ config: {
14
+ headers: new axios_1.AxiosHeaders(),
15
+ },
16
+ };
17
+ };
18
+ exports.mockHubSpotHttpResponse = mockHubSpotHttpResponse;
19
+ const mockHubSpotHttpError = (message, response) => {
6
20
  return new HubSpotHttpError_1.HubSpotHttpError(message, {
7
21
  cause: { isAxiosError: true, response },
8
22
  });
9
23
  };
10
- exports.makeHubSpotHttpError = makeHubSpotHttpError;
24
+ exports.mockHubSpotHttpError = mockHubSpotHttpError;
package/lib/ui/index.d.ts CHANGED
@@ -9,9 +9,9 @@ export declare function uiAccountDescription(accountId?: number | null, bold?: b
9
9
  export declare function uiInfoSection(title: string, logContent: () => void): void;
10
10
  export declare function uiCommandReference(command: string, withQuotes?: boolean): string;
11
11
  export declare function uiFeatureHighlight(features: string[], title?: string): void;
12
- export declare function uiBetaTag(message: string, log?: boolean): string | undefined;
12
+ export declare function uiBetaTag(message: string, log?: true): undefined;
13
+ export declare function uiBetaTag(message: string, log: false): string;
13
14
  export declare function uiDeprecatedTag(message: string): void;
14
15
  export declare function uiCommandDisabledBanner(command: string, url?: string, message?: string): void;
15
16
  export declare function uiDeprecatedDescription(message: string, command: string, url?: string): void;
16
17
  export declare function uiDeprecatedMessage(command: string, url?: string, message?: string): void;
17
- export declare function indent(level: number): string;
package/lib/ui/index.js CHANGED
@@ -15,7 +15,6 @@ exports.uiDeprecatedTag = uiDeprecatedTag;
15
15
  exports.uiCommandDisabledBanner = uiCommandDisabledBanner;
16
16
  exports.uiDeprecatedDescription = uiDeprecatedDescription;
17
17
  exports.uiDeprecatedMessage = uiDeprecatedMessage;
18
- exports.indent = indent;
19
18
  const chalk_1 = __importDefault(require("chalk"));
20
19
  const config_1 = require("@hubspot/local-dev-lib/config");
21
20
  const logger_1 = require("@hubspot/local-dev-lib/logger");
@@ -148,7 +147,3 @@ function uiDeprecatedMessage(command, url, message) {
148
147
  uiDeprecatedTag(tag);
149
148
  logger_1.logger.log();
150
149
  }
151
- function indent(level) {
152
- const indentation = ' ';
153
- return indentation.repeat(level);
154
- }
@@ -1,9 +1,9 @@
1
1
  import { Argv } from 'yargs';
2
2
  export declare function hasFlag(flag: string, argv?: string[]): boolean;
3
- export declare function makeYargsBuilder<T>(callback: (yargs: Argv) => Argv<T>, command: string, describe: string, options: {
3
+ export declare function makeYargsBuilder<T>(callback: (yargs: Argv) => Argv<T>, command: string, describe: string, options?: {
4
4
  useGlobalOptions?: boolean;
5
5
  useAccountOptions?: boolean;
6
6
  useConfigOptions?: boolean;
7
- useUseEnvironmentOptions?: boolean;
7
+ useEnvironmentOptions?: boolean;
8
8
  useTestingOptions?: boolean;
9
9
  }): (yargs: Argv) => Promise<Argv<T>>;
package/lib/yargsUtils.js CHANGED
@@ -15,7 +15,7 @@ function hasFlag(flag, argv = process_1.default.argv) {
15
15
  return (position !== -1 &&
16
16
  (terminatorPosition === -1 || position < terminatorPosition));
17
17
  }
18
- function makeYargsBuilder(callback, command, describe, options) {
18
+ function makeYargsBuilder(callback, command, describe, options = {}) {
19
19
  return async function (yargs) {
20
20
  if (options.useGlobalOptions) {
21
21
  (0, commonOpts_1.addGlobalOptions)(yargs);
@@ -26,7 +26,7 @@ function makeYargsBuilder(callback, command, describe, options) {
26
26
  if (options.useConfigOptions) {
27
27
  (0, commonOpts_1.addConfigOptions)(yargs);
28
28
  }
29
- if (options.useUseEnvironmentOptions) {
29
+ if (options.useEnvironmentOptions) {
30
30
  (0, commonOpts_1.addUseEnvironmentOptions)(yargs);
31
31
  }
32
32
  if (options.useTestingOptions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.2.5-experimental.0",
3
+ "version": "7.3.0-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",
@@ -58,7 +58,7 @@
58
58
  "typescript": "^5.6.2"
59
59
  },
60
60
  "optionalDependencies": {
61
- "@hubspot/cms-dev-server": "^0.18.10"
61
+ "@hubspot/cms-dev-server": "^1.0.9"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "ts-node ./scripts/build.ts",
@@ -1,10 +0,0 @@
1
- import { Argv, ArgumentsCamelCase } from 'yargs';
2
- import { CommonArgs, ConfigArgs } from '../../types/Yargs';
3
- export declare const describe: string;
4
- export declare const command = "auth";
5
- type AccountAuthArgs = CommonArgs & ConfigArgs & {
6
- disableTracking?: boolean;
7
- };
8
- export declare function handler(args: ArgumentsCamelCase<AccountAuthArgs>): Promise<void>;
9
- export declare function builder(yargs: Argv): Argv<AccountAuthArgs>;
10
- export {};
@@ -1,169 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.command = exports.describe = void 0;
4
- exports.handler = handler;
5
- exports.builder = builder;
6
- const config_1 = require("@hubspot/local-dev-lib/config");
7
- const migrate_1 = require("@hubspot/local-dev-lib/config/migrate");
8
- const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
9
- const logger_1 = require("@hubspot/local-dev-lib/logger");
10
- const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
11
- const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
12
- const text_1 = require("@hubspot/local-dev-lib/text");
13
- const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
14
- const commonOpts_1 = require("../../lib/commonOpts");
15
- const configMigrate_1 = require("../../lib/configMigrate");
16
- const process_1 = require("../../lib/process");
17
- const index_1 = require("../../lib/errorHandlers/index");
18
- const lang_1 = require("../../lib/lang");
19
- const usageTracking_1 = require("../../lib/usageTracking");
20
- const personalAccessKeyPrompt_1 = require("../../lib/prompts/personalAccessKeyPrompt");
21
- const accountNamePrompt_1 = require("../../lib/prompts/accountNamePrompt");
22
- const setAsDefaultAccountPrompt_1 = require("../../lib/prompts/setAsDefaultAccountPrompt");
23
- const index_2 = require("../../lib/errorHandlers/index");
24
- const usageTracking_2 = require("../../lib/usageTracking");
25
- const exitCodes_1 = require("../../lib/enums/exitCodes");
26
- const ui_1 = require("../../lib/ui");
27
- const i18nKey = 'commands.account.subcommands.auth';
28
- const TRACKING_STATUS = {
29
- STARTED: 'started',
30
- ERROR: 'error',
31
- COMPLETE: 'complete',
32
- };
33
- async function updateConfig(env, doesConfigExist, disableTracking, authType, account) {
34
- try {
35
- const { personalAccessKey } = await (0, personalAccessKeyPrompt_1.personalAccessKeyPrompt)({
36
- env,
37
- account,
38
- });
39
- const token = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env);
40
- const defaultName = token.hubName ? (0, text_1.toKebabCase)(token.hubName) : undefined;
41
- const name = doesConfigExist
42
- ? undefined
43
- : (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultName)).name;
44
- const updatedConfig = await (0, personalAccessKey_1.updateConfigWithAccessToken)(token, personalAccessKey, env, name, !doesConfigExist);
45
- if (!updatedConfig)
46
- return null;
47
- if (doesConfigExist && !updatedConfig.name) {
48
- updatedConfig.name = (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultName)).name;
49
- (0, config_1.updateAccountConfig)({
50
- ...updatedConfig,
51
- });
52
- (0, config_1.writeConfig)();
53
- }
54
- return updatedConfig;
55
- }
56
- catch (e) {
57
- if (!disableTracking) {
58
- await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.ERROR);
59
- }
60
- (0, index_1.debugError)(e);
61
- return null;
62
- }
63
- }
64
- exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
65
- exports.command = 'auth';
66
- async function handler(args) {
67
- const { providedAccountId, disableTracking } = args;
68
- const authType = auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
69
- const deprecatedConfigExists = (0, migrate_1.configFileExists)(false);
70
- const globalConfigExists = (0, migrate_1.configFileExists)(true);
71
- if (deprecatedConfigExists) {
72
- if (globalConfigExists) {
73
- try {
74
- await (0, configMigrate_1.handleMerge)(providedAccountId);
75
- }
76
- catch (error) {
77
- (0, index_2.logError)(error);
78
- (0, usageTracking_2.trackCommandMetadataUsage)('account-auth', {
79
- command: 'hs account auth',
80
- type: 'Merge configs',
81
- successful: false,
82
- }, providedAccountId);
83
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
84
- }
85
- }
86
- else {
87
- try {
88
- await (0, configMigrate_1.handleMigration)(providedAccountId);
89
- }
90
- catch (error) {
91
- (0, index_2.logError)(error);
92
- (0, usageTracking_2.trackCommandMetadataUsage)('account-auth', {
93
- command: 'hs account auth',
94
- type: 'Migrate a single config',
95
- successful: false,
96
- }, providedAccountId);
97
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
98
- }
99
- }
100
- }
101
- if (!disableTracking) {
102
- (0, usageTracking_1.trackCommandUsage)('account-auth', {}, providedAccountId);
103
- await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.STARTED);
104
- }
105
- const env = args.qa ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD;
106
- const configAlreadyExists = (0, migrate_1.configFileExists)(true);
107
- if (!configAlreadyExists) {
108
- (0, config_1.createEmptyConfigFile)({}, true);
109
- }
110
- (0, config_1.loadConfig)('');
111
- (0, process_1.handleExit)(config_1.deleteEmptyConfigFile);
112
- const updatedConfig = await updateConfig(env, configAlreadyExists, disableTracking, authType, providedAccountId);
113
- if (!updatedConfig) {
114
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.failedToUpdateConfig`));
115
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
116
- }
117
- const { name } = updatedConfig;
118
- const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(updatedConfig);
119
- // If the config file was just created, we don't need to prompt the user to set as default
120
- if (!configAlreadyExists) {
121
- logger_1.logger.log('');
122
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.configFileCreated`, {
123
- configPath: (0, config_1.getConfigPath)('', true),
124
- }));
125
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.configFileUpdated`, {
126
- account: name || accountId || '',
127
- }));
128
- }
129
- else {
130
- const setAsDefault = await (0, setAsDefaultAccountPrompt_1.setAsDefaultAccountPrompt)(name);
131
- logger_1.logger.log('');
132
- if (setAsDefault) {
133
- logger_1.logger.success((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.setAsDefaultAccount`, {
134
- accountName: name,
135
- }));
136
- }
137
- else {
138
- logger_1.logger.info((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault`, {
139
- accountName: (0, config_1.getConfigDefaultAccount)(),
140
- }));
141
- }
142
- }
143
- (0, ui_1.uiFeatureHighlight)([
144
- 'helpCommand',
145
- 'accountAuthCommand',
146
- 'accountsListCommand',
147
- ]);
148
- if (!disableTracking) {
149
- await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.COMPLETE, accountId);
150
- }
151
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
152
- }
153
- function builder(yargs) {
154
- yargs.options({
155
- account: {
156
- describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
157
- type: 'string',
158
- alias: 'a',
159
- },
160
- 'disable-tracking': {
161
- type: 'boolean',
162
- hidden: true,
163
- default: false,
164
- },
165
- });
166
- (0, commonOpts_1.addTestingOptions)(yargs);
167
- (0, commonOpts_1.addGlobalOptions)(yargs);
168
- return yargs;
169
- }
@@ -1,10 +0,0 @@
1
- import { Argv, ArgumentsCamelCase } from 'yargs';
2
- import { CommonArgs } from '../../types/Yargs';
3
- export declare const describe: string;
4
- export declare const command = "create-override [account]";
5
- type AccountCreateOverrideArgs = CommonArgs & {
6
- account: string | number;
7
- };
8
- export declare function handler(args: ArgumentsCamelCase<AccountCreateOverrideArgs>): Promise<void>;
9
- export declare function builder(yargs: Argv): Argv<AccountCreateOverrideArgs>;
10
- export {};
@@ -1,103 +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 lang_1 = require("../../lib/lang");
16
- const promptUtils_1 = require("../../lib/prompts/promptUtils");
17
- const exitCodes_1 = require("../../lib/enums/exitCodes");
18
- const usageTracking_1 = require("../../lib/usageTracking");
19
- const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
20
- const index_1 = require("../../lib/errorHandlers/index");
21
- const i18nKey = 'commands.account.subcommands.createOverride';
22
- exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`, {
23
- hsAccountFileName: config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
24
- });
25
- exports.command = 'create-override [account]';
26
- async function handler(args) {
27
- let overrideDefaultAccount = args.account;
28
- const accountOverride = (0, config_2.getCWDAccountOverride)();
29
- const overrideFilePath = (0, config_2.getDefaultAccountOverrideFilePath)();
30
- if (accountOverride && overrideFilePath) {
31
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.accountOverride`, {
32
- accountOverride,
33
- overrideFilePath,
34
- }));
35
- const { replaceOverrideFile } = await (0, promptUtils_1.promptUser)({
36
- type: 'confirm',
37
- name: 'replaceOverrideFile',
38
- message: (0, lang_1.i18n)(`${i18nKey}.prompts.replaceOverrideFile`),
39
- });
40
- logger_1.logger.log('');
41
- if (!replaceOverrideFile) {
42
- const accountId = (0, config_2.getAccountId)(accountOverride) || undefined;
43
- (0, usageTracking_1.trackCommandMetadataUsage)('account-createOverride', {
44
- command: 'hs account create-override',
45
- step: 'Reject overwriting an override via prompt',
46
- }, accountId);
47
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
48
- }
49
- }
50
- if (!overrideDefaultAccount) {
51
- overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
52
- }
53
- else if (!(0, config_2.getAccountId)(overrideDefaultAccount)) {
54
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.accountNotFound`, {
55
- configPath: (0, config_2.getConfigPath)() || '',
56
- }));
57
- overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
58
- }
59
- const accountId = (0, config_2.getAccountId)(overrideDefaultAccount);
60
- try {
61
- const overrideFilePath = path_1.default.join((0, path_2.getCwd)(), config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME);
62
- await fs_extra_1.default.writeFile(overrideFilePath, accountId.toString(), 'utf8');
63
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success`, { overrideFilePath }));
64
- const trackingId = accountId || undefined;
65
- (0, usageTracking_1.trackCommandMetadataUsage)('config-migrate', {
66
- command: 'hs config migrate',
67
- step: 'Confirm overwriting an override via prompt',
68
- successful: true,
69
- }, trackingId);
70
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
71
- }
72
- catch (e) {
73
- (0, index_1.logError)(e);
74
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
75
- }
76
- }
77
- function builder(yargs) {
78
- yargs.positional('account', {
79
- describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
80
- type: 'string',
81
- });
82
- yargs.example([
83
- [
84
- '$0 account create-override',
85
- (0, lang_1.i18n)(`${i18nKey}.examples.default`, {
86
- hsAccountFileName: config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
87
- }),
88
- ],
89
- [
90
- '$0 account create-override 12345678',
91
- (0, lang_1.i18n)(`${i18nKey}.examples.idBased`, {
92
- hsAccountFileName: config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
93
- }),
94
- ],
95
- [
96
- '$0 account create-override MyAccount',
97
- (0, lang_1.i18n)(`${i18nKey}.examples.nameBased`, {
98
- hsAccountFileName: config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
99
- }),
100
- ],
101
- ]);
102
- return yargs;
103
- }
@@ -1,10 +0,0 @@
1
- import { Argv, ArgumentsCamelCase } from 'yargs';
2
- import { CommonArgs } from '../../types/Yargs';
3
- export declare const describe: string;
4
- export declare const command = "remove-override";
5
- type RemoveOverrideArgs = CommonArgs & {
6
- force?: boolean;
7
- };
8
- export declare function handler(args: ArgumentsCamelCase<RemoveOverrideArgs>): Promise<void>;
9
- export declare function builder(yargs: Argv): Argv<RemoveOverrideArgs>;
10
- export {};
@@ -1,77 +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 logger_1 = require("@hubspot/local-dev-lib/logger");
11
- const config_1 = require("@hubspot/local-dev-lib/config");
12
- const config_2 = require("@hubspot/local-dev-lib/constants/config");
13
- const lang_1 = require("../../lib/lang");
14
- const promptUtils_1 = require("../../lib/prompts/promptUtils");
15
- const usageTracking_1 = require("../../lib/usageTracking");
16
- const exitCodes_1 = require("../../lib/enums/exitCodes");
17
- const index_1 = require("../../lib/errorHandlers/index");
18
- const i18nKey = 'commands.account.subcommands.removeOverride';
19
- exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`, {
20
- overrideFile: config_2.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
21
- });
22
- exports.command = 'remove-override';
23
- async function handler(args) {
24
- const { force } = args;
25
- const accountOverride = (0, config_1.getCWDAccountOverride)();
26
- const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
27
- if (accountOverride && overrideFilePath) {
28
- const accountId = (0, config_1.getAccountId)(accountOverride) || undefined;
29
- if (!force) {
30
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.accountOverride`, {
31
- accountOverride,
32
- overrideFilePath,
33
- }));
34
- const { deleteOverrideFile } = await (0, promptUtils_1.promptUser)({
35
- type: 'confirm',
36
- name: 'deleteOverrideFile',
37
- message: (0, lang_1.i18n)(`${i18nKey}.prompts.deleteOverrideFile`, {
38
- accountOverride,
39
- overrideFilePath,
40
- }),
41
- });
42
- logger_1.logger.log('');
43
- if (!deleteOverrideFile) {
44
- (0, usageTracking_1.trackCommandMetadataUsage)('account-removeOverride', {
45
- command: 'hs account remove-override',
46
- step: 'Reject removing override via prompt',
47
- }, accountId);
48
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
49
- }
50
- }
51
- try {
52
- fs_extra_1.default.unlinkSync(overrideFilePath);
53
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success`));
54
- (0, usageTracking_1.trackCommandMetadataUsage)('account-removeOverride', {
55
- command: 'hs account remove-override',
56
- step: 'Confirm removing override file (via prompt/force)',
57
- successful: true,
58
- }, accountId);
59
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
60
- }
61
- catch (error) {
62
- (0, index_1.logError)(error);
63
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
64
- }
65
- }
66
- else {
67
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.noOverrideFile`));
68
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
69
- }
70
- }
71
- function builder(yargs) {
72
- yargs.options('force', {
73
- describe: (0, lang_1.i18n)(`${i18nKey}.options.force.describe`),
74
- type: 'boolean',
75
- });
76
- return yargs;
77
- }
@@ -1,10 +0,0 @@
1
- import { Argv, ArgumentsCamelCase } from 'yargs';
2
- import { CommonArgs, ConfigArgs } from '../../types/Yargs';
3
- export declare const describe: string;
4
- export declare const command = "migrate";
5
- type ConfigMigrateArgs = CommonArgs & ConfigArgs & {
6
- force?: boolean;
7
- };
8
- export declare function handler(args: ArgumentsCamelCase<ConfigMigrateArgs>): Promise<void>;
9
- export declare function builder(yargs: Argv): Argv<ConfigMigrateArgs>;
10
- export {};
@@ -1,85 +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_1 = __importDefault(require("fs"));
10
- const config_1 = require("@hubspot/local-dev-lib/constants/config");
11
- const migrate_1 = require("@hubspot/local-dev-lib/config/migrate");
12
- const logger_1 = require("@hubspot/local-dev-lib/logger");
13
- const configMigrate_1 = require("../../lib/configMigrate");
14
- const commonOpts_1 = require("../../lib/commonOpts");
15
- const lang_1 = require("../../lib/lang");
16
- const usageTracking_1 = require("../../lib/usageTracking");
17
- const index_1 = require("../../lib/errorHandlers/index");
18
- const exitCodes_1 = require("../../lib/enums/exitCodes");
19
- const i18nKey = 'commands.config.subcommands.migrate';
20
- exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`, {
21
- deprecatedConfigPath: config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
22
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
23
- });
24
- exports.command = 'migrate';
25
- async function handler(args) {
26
- const { config: configPath, force, derivedAccountId } = args;
27
- if (configPath && !fs_1.default.existsSync(configPath)) {
28
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.errors.configNotFound`, {
29
- configPath,
30
- }));
31
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
32
- }
33
- const deprecatedConfigExists = (0, migrate_1.configFileExists)(false, configPath);
34
- const globalConfigExists = (0, migrate_1.configFileExists)(true);
35
- if (!deprecatedConfigExists) {
36
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.migrationAlreadyCompleted`, {
37
- deprecatedConfigPath: config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
38
- }));
39
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
40
- }
41
- try {
42
- if (!globalConfigExists) {
43
- await (0, configMigrate_1.handleMigration)(derivedAccountId, configPath);
44
- }
45
- else {
46
- await (0, configMigrate_1.handleMerge)(derivedAccountId, configPath, force);
47
- }
48
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
49
- }
50
- catch (error) {
51
- (0, usageTracking_1.trackCommandMetadataUsage)('config-migrate', {
52
- command: 'hs config migrate',
53
- type: 'Migration/merge',
54
- successful: false,
55
- }, derivedAccountId);
56
- (0, index_1.logError)(error);
57
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
58
- }
59
- }
60
- function builder(yargs) {
61
- (0, commonOpts_1.addConfigOptions)(yargs);
62
- yargs
63
- .option('force', {
64
- alias: 'f',
65
- type: 'boolean',
66
- default: false,
67
- description: (0, lang_1.i18n)(`${i18nKey}.options.force`),
68
- })
69
- .example([
70
- [
71
- '$0 config migrate',
72
- (0, lang_1.i18n)(`${i18nKey}.examples.default`, {
73
- deprecatedConfigPath: config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
74
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
75
- }),
76
- ],
77
- [
78
- '$0 config migrate --config=/path/to/config.yml',
79
- (0, lang_1.i18n)(`${i18nKey}.examples.configFlag`, {
80
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
81
- }),
82
- ],
83
- ]);
84
- return yargs;
85
- }
@@ -1,2 +0,0 @@
1
- export declare function handleMigration(accountId: number | undefined, configPath?: string): Promise<void>;
2
- export declare function handleMerge(accountId: number | undefined, configPath?: string, force?: boolean): Promise<void>;