@hubspot/cli 7.2.2-experimental.0 → 7.2.3-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 (114) hide show
  1. package/bin/cli.js +5 -52
  2. package/commands/account/list.js +0 -4
  3. package/commands/account.js +0 -4
  4. package/commands/app/migrate.d.ts +6 -0
  5. package/commands/app/migrate.js +80 -0
  6. package/commands/app.d.ts +4 -0
  7. package/commands/app.js +47 -0
  8. package/commands/auth.js +5 -9
  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/create/api-sample.js +14 -4
  14. package/commands/customObject/create.d.ts +11 -0
  15. package/commands/customObject/create.js +37 -28
  16. package/commands/customObject/schema/create.d.ts +10 -0
  17. package/commands/customObject/schema/create.js +40 -42
  18. package/commands/customObject/schema/delete.d.ts +11 -0
  19. package/commands/customObject/schema/delete.js +34 -27
  20. package/commands/customObject/schema/fetch-all.d.ts +10 -0
  21. package/commands/customObject/schema/fetch-all.js +31 -24
  22. package/commands/customObject/schema/fetch.d.ts +11 -0
  23. package/commands/customObject/schema/fetch.js +34 -42
  24. package/commands/customObject/schema/list.d.ts +7 -0
  25. package/commands/customObject/schema/list.js +23 -14
  26. package/commands/customObject/schema/update.d.ts +11 -0
  27. package/commands/customObject/schema/update.js +44 -46
  28. package/commands/customObject/schema.d.ts +5 -1
  29. package/commands/customObject/schema.js +49 -11
  30. package/commands/customObject.d.ts +4 -1
  31. package/commands/customObject.js +54 -21
  32. package/commands/filemanager/fetch.d.ts +12 -0
  33. package/commands/filemanager/fetch.js +33 -30
  34. package/commands/filemanager/upload.d.ts +11 -0
  35. package/commands/filemanager/upload.js +53 -47
  36. package/commands/filemanager.d.ts +4 -1
  37. package/commands/filemanager.js +41 -7
  38. package/commands/init.js +26 -15
  39. package/commands/project/add.js +62 -16
  40. package/commands/project/cloneApp.d.ts +5 -1
  41. package/commands/project/cloneApp.js +80 -77
  42. package/commands/project/create.js +70 -15
  43. package/commands/project/dev.d.ts +7 -0
  44. package/commands/project/dev.js +96 -75
  45. package/commands/project/migrateApp.d.ts +6 -1
  46. package/commands/project/migrateApp.js +17 -184
  47. package/commands/sandbox/create.d.ts +12 -0
  48. package/commands/sandbox/create.js +90 -72
  49. package/commands/sandbox/delete.d.ts +11 -0
  50. package/commands/sandbox/delete.js +112 -95
  51. package/commands/sandbox.d.ts +4 -1
  52. package/commands/sandbox.js +44 -10
  53. package/commands/theme/generate-selectors.d.ts +9 -0
  54. package/commands/theme/generate-selectors.js +61 -43
  55. package/commands/theme/marketplace-validate.d.ts +10 -0
  56. package/commands/theme/marketplace-validate.js +32 -26
  57. package/commands/theme/preview.d.ts +16 -0
  58. package/commands/theme/preview.js +104 -97
  59. package/commands/theme.d.ts +4 -1
  60. package/commands/theme.js +44 -10
  61. package/lang/en.lyaml +62 -67
  62. package/lib/LocalDevManager.d.ts +2 -2
  63. package/lib/app/migrate.d.ts +6 -0
  64. package/lib/app/migrate.js +277 -0
  65. package/lib/buildAccount.d.ts +2 -3
  66. package/lib/constants.d.ts +0 -3
  67. package/lib/constants.js +1 -4
  68. package/lib/customObject.d.ts +3 -0
  69. package/lib/customObject.js +15 -0
  70. package/lib/doctor/Diagnosis.d.ts +0 -1
  71. package/lib/doctor/Diagnosis.js +0 -7
  72. package/lib/doctor/DiagnosticInfoBuilder.d.ts +0 -1
  73. package/lib/doctor/DiagnosticInfoBuilder.js +0 -1
  74. package/lib/doctor/Doctor.d.ts +0 -1
  75. package/lib/doctor/Doctor.js +0 -18
  76. package/lib/localDev.d.ts +2 -1
  77. package/lib/marketplaceValidate.d.ts +2 -2
  78. package/lib/projects/buildAndDeploy.js +4 -1
  79. package/lib/projects/create.d.ts +5 -0
  80. package/lib/projects/create.js +51 -0
  81. package/lib/projects/index.d.ts +1 -5
  82. package/lib/projects/index.js +1 -62
  83. package/lib/prompts/accountNamePrompt.d.ts +1 -1
  84. package/lib/prompts/createProjectPrompt.d.ts +6 -8
  85. package/lib/prompts/createProjectPrompt.js +26 -54
  86. package/lib/prompts/projectAddPrompt.d.ts +3 -3
  87. package/lib/prompts/projectAddPrompt.js +16 -6
  88. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -2
  89. package/lib/prompts/promptUtils.d.ts +3 -3
  90. package/lib/prompts/sandboxesPrompt.d.ts +3 -2
  91. package/lib/prompts/sandboxesPrompt.js +1 -1
  92. package/lib/sandboxSync.js +6 -2
  93. package/lib/sandboxes.d.ts +2 -5
  94. package/lib/testUtils.d.ts +12 -0
  95. package/lib/testUtils.js +10 -0
  96. package/lib/ui/index.d.ts +3 -3
  97. package/lib/ui/index.js +8 -4
  98. package/lib/upload.d.ts +1 -1
  99. package/lib/upload.js +20 -20
  100. package/lib/usageTracking.d.ts +2 -1
  101. package/lib/validation.d.ts +1 -1
  102. package/package.json +4 -3
  103. package/types/Projects.d.ts +1 -6
  104. package/types/Prompts.d.ts +9 -2
  105. package/types/Sandboxes.d.ts +2 -0
  106. package/types/Yargs.d.ts +13 -0
  107. package/commands/account/auth.d.ts +0 -10
  108. package/commands/account/auth.js +0 -154
  109. package/commands/account/createOverride.d.ts +0 -10
  110. package/commands/account/createOverride.js +0 -62
  111. package/commands/config/migrate.d.ts +0 -10
  112. package/commands/config/migrate.js +0 -86
  113. package/lib/configMigrate.d.ts +0 -2
  114. package/lib/configMigrate.js +0 -83
@@ -1,154 +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 exitCodes_1 = require("../../lib/enums/exitCodes");
25
- const ui_1 = require("../../lib/ui");
26
- const i18nKey = 'commands.account.subcommands.auth';
27
- const TRACKING_STATUS = {
28
- STARTED: 'started',
29
- ERROR: 'error',
30
- COMPLETE: 'complete',
31
- };
32
- async function updateConfig(env, doesConfigExist, disableTracking, authType, account) {
33
- try {
34
- const { personalAccessKey } = await (0, personalAccessKeyPrompt_1.personalAccessKeyPrompt)({
35
- env,
36
- account,
37
- });
38
- const token = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env);
39
- const defaultName = token.hubName ? (0, text_1.toKebabCase)(token.hubName) : undefined;
40
- const name = doesConfigExist
41
- ? undefined
42
- : (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultName)).name;
43
- const updatedConfig = await (0, personalAccessKey_1.updateConfigWithAccessToken)(token, personalAccessKey, env, name, !doesConfigExist);
44
- if (!updatedConfig)
45
- return null;
46
- if (doesConfigExist && !updatedConfig.name) {
47
- updatedConfig.name = (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultName)).name;
48
- (0, config_1.updateAccountConfig)({
49
- ...updatedConfig,
50
- });
51
- (0, config_1.writeConfig)();
52
- }
53
- return updatedConfig;
54
- }
55
- catch (e) {
56
- if (!disableTracking) {
57
- await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.ERROR);
58
- }
59
- (0, index_1.debugError)(e);
60
- return null;
61
- }
62
- }
63
- exports.describe = undefined; // i18n(`${i18nKey}.describe`);
64
- exports.command = 'auth';
65
- async function handler(args) {
66
- const { providedAccountId, disableTracking } = args;
67
- const authType = auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
68
- const deprecatedConfigExists = (0, migrate_1.configFileExists)(false);
69
- const globalConfigExists = (0, migrate_1.configFileExists)(true);
70
- if (deprecatedConfigExists) {
71
- if (globalConfigExists) {
72
- try {
73
- await (0, configMigrate_1.handleMerge)();
74
- }
75
- catch (error) {
76
- (0, index_2.logError)(error);
77
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
78
- }
79
- }
80
- else {
81
- try {
82
- await (0, configMigrate_1.handleMigration)();
83
- }
84
- catch (error) {
85
- (0, index_2.logError)(error);
86
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
87
- }
88
- }
89
- }
90
- if (!disableTracking) {
91
- (0, usageTracking_1.trackCommandUsage)('account-auth', {}, providedAccountId);
92
- await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.STARTED);
93
- }
94
- const env = args.qa ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD;
95
- const configAlreadyExists = (0, migrate_1.configFileExists)(true);
96
- if (!configAlreadyExists) {
97
- (0, config_1.createEmptyConfigFile)({}, true);
98
- }
99
- (0, config_1.loadConfig)('');
100
- (0, process_1.handleExit)(config_1.deleteEmptyConfigFile);
101
- const updatedConfig = await updateConfig(env, configAlreadyExists, disableTracking, authType, providedAccountId);
102
- if (!updatedConfig) {
103
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.failedToUpdateConfig`));
104
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
105
- }
106
- const { name } = updatedConfig;
107
- const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(updatedConfig);
108
- // If the config file was just created, we don't need to prompt the user to set as default
109
- if (!configAlreadyExists) {
110
- logger_1.logger.log('');
111
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.configFileCreated`, {
112
- configPath: (0, config_1.getConfigPath)('', true),
113
- }));
114
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.configFileUpdated`, {
115
- account: name || accountId || '',
116
- }));
117
- }
118
- else {
119
- const setAsDefault = await (0, setAsDefaultAccountPrompt_1.setAsDefaultAccountPrompt)(name);
120
- logger_1.logger.log('');
121
- if (setAsDefault) {
122
- logger_1.logger.success((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.setAsDefaultAccount`, {
123
- accountName: name,
124
- }));
125
- }
126
- else {
127
- logger_1.logger.info((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault`, {
128
- accountName: (0, config_1.getConfigDefaultAccount)(),
129
- }));
130
- }
131
- }
132
- (0, ui_1.uiFeatureHighlight)(['helpCommand', 'authCommand', 'accountsListCommand']);
133
- if (!disableTracking) {
134
- await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.COMPLETE, accountId);
135
- }
136
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
137
- }
138
- function builder(yargs) {
139
- yargs.options({
140
- account: {
141
- describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
142
- type: 'string',
143
- alias: 'a',
144
- },
145
- 'disable-tracking': {
146
- type: 'boolean',
147
- hidden: true,
148
- default: false,
149
- },
150
- });
151
- (0, commonOpts_1.addTestingOptions)(yargs);
152
- (0, commonOpts_1.addGlobalOptions)(yargs);
153
- return yargs;
154
- }
@@ -1,10 +0,0 @@
1
- import { Argv, ArgumentsCamelCase } from 'yargs';
2
- import { CommonArgs } from '../../types/Yargs';
3
- export declare const describe: undefined;
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,62 +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 exitCodes_1 = require("../../lib/enums/exitCodes");
17
- const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
18
- const index_1 = require("../../lib/errorHandlers/index");
19
- const i18nKey = 'commands.account.subcommands.createOverride';
20
- exports.describe = undefined; // i18n(`${i18nKey}.describe`);
21
- exports.command = 'create-override [account]';
22
- async function handler(args) {
23
- let overrideDefaultAccount = args.account;
24
- if (!overrideDefaultAccount) {
25
- overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
26
- }
27
- else if (!(0, config_2.getAccountId)(overrideDefaultAccount)) {
28
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.accountNotFound`, {
29
- configPath: (0, config_2.getConfigPath)() || '',
30
- }));
31
- overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
32
- }
33
- const accountId = (0, config_2.getAccountId)(overrideDefaultAccount);
34
- try {
35
- const overrideFilePath = path_1.default.join((0, path_2.getCwd)(), config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME);
36
- await fs_extra_1.default.writeFile(overrideFilePath, accountId.toString(), 'utf8');
37
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success`, { overrideFilePath }));
38
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
39
- }
40
- catch (e) {
41
- (0, index_1.logError)(e);
42
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
43
- }
44
- }
45
- function builder(yargs) {
46
- yargs.positional('account', {
47
- describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
48
- type: 'string',
49
- });
50
- yargs.example([
51
- ['$0 account create-override', (0, lang_1.i18n)(`${i18nKey}.examples.default`)],
52
- [
53
- '$0 account create-override 12345678',
54
- (0, lang_1.i18n)(`${i18nKey}.examples.idBased`),
55
- ],
56
- [
57
- '$0 account create-override MyAccount',
58
- (0, lang_1.i18n)(`${i18nKey}.examples.nameBased`),
59
- ],
60
- ]);
61
- return yargs;
62
- }
@@ -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,86 +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 logger_1 = require("@hubspot/local-dev-lib/logger");
12
- const migrate_1 = require("@hubspot/local-dev-lib/config/migrate");
13
- const configMigrate_1 = require("../../lib/configMigrate");
14
- const commonOpts_1 = require("../../lib/commonOpts");
15
- const lang_1 = require("../../lib/lang");
16
- const index_1 = require("../../lib/errorHandlers/index");
17
- const exitCodes_1 = require("../../lib/enums/exitCodes");
18
- const i18nKey = 'commands.config.subcommands.migrate';
19
- exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`, {
20
- deprecatedConfigPath: config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
21
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
22
- });
23
- exports.command = 'migrate';
24
- async function handler(args) {
25
- const { config: configPath, force } = args;
26
- if (configPath && !fs_1.default.existsSync(configPath)) {
27
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.errors.configNotFound`, {
28
- configPath,
29
- }));
30
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
31
- }
32
- const deprecatedConfigExists = (0, migrate_1.configFileExists)(false, configPath);
33
- const globalConfigExists = (0, migrate_1.configFileExists)(true);
34
- if (!globalConfigExists && deprecatedConfigExists) {
35
- try {
36
- await (0, configMigrate_1.handleMigration)(configPath);
37
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
38
- }
39
- catch (error) {
40
- (0, index_1.logError)(error);
41
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
42
- }
43
- }
44
- else if (globalConfigExists && deprecatedConfigExists) {
45
- try {
46
- await (0, configMigrate_1.handleMerge)(configPath, force);
47
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
48
- }
49
- catch (error) {
50
- (0, index_1.logError)(error);
51
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
52
- }
53
- }
54
- else if (globalConfigExists && !deprecatedConfigExists) {
55
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.migrationAlreadyCompleted`, {
56
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
57
- }));
58
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
59
- }
60
- }
61
- function builder(yargs) {
62
- (0, commonOpts_1.addConfigOptions)(yargs);
63
- yargs
64
- .option('force', {
65
- alias: 'f',
66
- type: 'boolean',
67
- default: false,
68
- description: (0, lang_1.i18n)(`${i18nKey}.options.force`),
69
- })
70
- .example([
71
- [
72
- '$0 config migrate',
73
- (0, lang_1.i18n)(`${i18nKey}.examples.default`, {
74
- deprecatedConfigPath: config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
75
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
76
- }),
77
- ],
78
- [
79
- '$0 config migrate --config=/path/to/config.yml',
80
- (0, lang_1.i18n)(`${i18nKey}.examples.configFlag`, {
81
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
82
- }),
83
- ],
84
- ]);
85
- return yargs;
86
- }
@@ -1,2 +0,0 @@
1
- export declare function handleMigration(configPath?: string): Promise<void>;
2
- export declare function handleMerge(configPath?: string, force?: boolean): Promise<void>;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleMigration = handleMigration;
4
- exports.handleMerge = handleMerge;
5
- const migrate_1 = require("@hubspot/local-dev-lib/config/migrate");
6
- const config_1 = require("@hubspot/local-dev-lib/constants/config");
7
- const logger_1 = require("@hubspot/local-dev-lib/logger");
8
- const promptUtils_1 = require("./prompts/promptUtils");
9
- const lang_1 = require("./lang");
10
- const i18nKey = 'lib.configMigrate';
11
- async function handleMigration(configPath) {
12
- const { shouldMigrateConfig } = await (0, promptUtils_1.promptUser)({
13
- name: 'shouldMigrateConfig',
14
- type: 'confirm',
15
- message: (0, lang_1.i18n)(`${i18nKey}.migrateConfigPrompt`, {
16
- deprecatedConfigPath: (0, migrate_1.getConfigPath)(configPath, false) ||
17
- config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
18
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
19
- }),
20
- });
21
- if (!shouldMigrateConfig) {
22
- return;
23
- }
24
- const deprecatedConfig = (0, migrate_1.getConfig)(false, configPath);
25
- // @ts-ignore Cannot reconcile CLIConfig_NEW and CLIConfig_DEPRECATED
26
- (0, migrate_1.migrateConfig)(deprecatedConfig);
27
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.migrationSuccess`, {
28
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
29
- }));
30
- return;
31
- }
32
- async function mergeConfigProperties(globalConfig, deprecatedConfig, force) {
33
- const { initialConfig, conflicts, } = (0, migrate_1.mergeConfigProperties)(globalConfig, deprecatedConfig, force);
34
- if (conflicts.length > 0 && !force) {
35
- for (const conflict of conflicts) {
36
- const { property, newValue, oldValue } = conflict;
37
- const { shouldOverwrite } = await (0, promptUtils_1.promptUser)({
38
- name: 'shouldOverwrite',
39
- type: 'confirm',
40
- message: (0, lang_1.i18n)(`${i18nKey}.mergeConfigConflictPrompt`, {
41
- property,
42
- values: `${oldValue} (deprecated) vs ${newValue} (global)`,
43
- }),
44
- });
45
- if (shouldOverwrite) {
46
- // @ts-ignore Cannot reconcile CLIConfig_NEW and CLIConfig_DEPRECATED
47
- initialConfig[property] = oldValue;
48
- }
49
- }
50
- }
51
- return initialConfig;
52
- }
53
- async function handleMerge(configPath, force) {
54
- const { shouldMergeConfigs } = await (0, promptUtils_1.promptUser)({
55
- name: 'shouldMergeConfigs',
56
- type: 'confirm',
57
- message: (0, lang_1.i18n)(`${i18nKey}.mergeConfigsPrompt`, {
58
- deprecatedConfigPath: (0, migrate_1.getConfigPath)(configPath, false) ||
59
- config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
60
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
61
- }),
62
- });
63
- if (!shouldMergeConfigs) {
64
- return;
65
- }
66
- const deprecatedConfig = (0, migrate_1.getConfig)(false, configPath);
67
- const globalConfig = (0, migrate_1.getConfig)(true);
68
- const mergedConfig = await mergeConfigProperties(
69
- // @ts-ignore Cannot reconcile CLIConfig_NEW and CLIConfig_DEPRECATED
70
- globalConfig, deprecatedConfig, force);
71
- const { skippedAccountIds } = (0, migrate_1.mergeExistingConfigs)(mergedConfig,
72
- // @ts-ignore Cannot reconcile CLIConfig_NEW and CLIConfig_DEPRECATED
73
- deprecatedConfig);
74
- if (skippedAccountIds.length > 0) {
75
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.skippedExistingAccounts`, {
76
- skippedAccountIds: skippedAccountIds.join(', '),
77
- }));
78
- }
79
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.mergeSuccess`, {
80
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
81
- }));
82
- return;
83
- }