@hubspot/cli 7.7.1-experimental.0 → 7.7.2-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 (59) hide show
  1. package/commands/account/auth.js +51 -82
  2. package/commands/auth.js +2 -15
  3. package/commands/config/migrate.js +17 -36
  4. package/commands/init.js +1 -2
  5. package/commands/module/marketplace-validate.js +6 -8
  6. package/commands/module.js +2 -1
  7. package/commands/project/add.d.ts +5 -2
  8. package/commands/project/add.js +43 -80
  9. package/commands/project/create.d.ts +2 -8
  10. package/commands/project/create.js +84 -55
  11. package/commands/project/dev/unifiedFlow.js +1 -0
  12. package/commands/remove.js +6 -12
  13. package/commands/theme/generate-selectors.js +7 -10
  14. package/commands/theme/marketplace-validate.js +6 -8
  15. package/commands/theme/preview.js +17 -18
  16. package/commands/theme.js +2 -2
  17. package/commands/upload.js +26 -63
  18. package/commands/watch.js +20 -32
  19. package/lang/en.d.ts +140 -92
  20. package/lang/en.js +143 -98
  21. package/lang/en.lyaml +3 -186
  22. package/lib/configMigrate.d.ts +2 -2
  23. package/lib/configMigrate.js +34 -69
  24. package/lib/constants.d.ts +23 -5
  25. package/lib/constants.js +24 -6
  26. package/lib/generateSelectors.js +3 -5
  27. package/lib/marketplaceValidate.d.ts +12 -2
  28. package/lib/marketplaceValidate.js +22 -29
  29. package/lib/middleware/configMiddleware.js +1 -0
  30. package/lib/projects/add/legacyAddComponent.d.ts +5 -0
  31. package/lib/projects/add/legacyAddComponent.js +48 -0
  32. package/lib/projects/add/v3AddComponent.d.ts +8 -0
  33. package/lib/projects/add/v3AddComponent.js +85 -0
  34. package/lib/projects/components.d.ts +2 -0
  35. package/lib/projects/components.js +82 -0
  36. package/lib/projects/create/index.d.ts +23 -0
  37. package/lib/projects/create/index.js +33 -0
  38. package/lib/projects/create/legacy.d.ts +6 -0
  39. package/lib/projects/{create.js → create/legacy.js} +20 -11
  40. package/lib/projects/create/v3.d.ts +27 -0
  41. package/lib/projects/create/v3.js +158 -0
  42. package/lib/projects/localDev/AppDevModeInterface.d.ts +3 -2
  43. package/lib/projects/localDev/AppDevModeInterface.js +38 -2
  44. package/lib/projects/localDev/LocalDevProcess.d.ts +12 -5
  45. package/lib/projects/localDev/LocalDevProcess.js +47 -17
  46. package/lib/projects/localDev/LocalDevState.d.ts +16 -3
  47. package/lib/projects/localDev/LocalDevState.js +43 -2
  48. package/lib/projects/localDev/LocalDevWatcher.js +3 -6
  49. package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +3 -0
  50. package/lib/projects/localDev/LocalDevWebsocketServer.js +48 -9
  51. package/lib/prompts/createProjectPrompt.d.ts +14 -5
  52. package/lib/prompts/createProjectPrompt.js +36 -13
  53. package/lib/prompts/projectAddPrompt.d.ts +5 -1
  54. package/lib/prompts/projectAddPrompt.js +35 -7
  55. package/lib/prompts/setAsDefaultAccountPrompt.js +10 -0
  56. package/package.json +6 -5
  57. package/types/LocalDev.d.ts +11 -1
  58. package/types/Projects.d.ts +19 -2
  59. package/lib/projects/create.d.ts +0 -5
package/lang/en.lyaml CHANGED
@@ -20,19 +20,6 @@ en:
20
20
  account:
21
21
  describe: "Commands for managing configured accounts."
22
22
  subcommands:
23
- auth:
24
- describe: "Configure authentication for your HubSpot account."
25
- verboseDescribe: "Configure authentication for a HubSpot account. This will create or update the global config file at {{ globalConfigPath }} 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.\nIf a deprecated config file exists, you will be prompted to migrate it to the new global config file. If both deprecated and global config files exist, you will be prompted to merge them. If any conflicts exist between the two files, you will be prompted to reconcile them."
26
- options:
27
- account:
28
- describe: "HubSpot account to authenticate"
29
- errors:
30
- failedToUpdateConfig: "Failed to update the configuration file. Please try again."
31
- migrationNotConfirmed: "Did not migrate. Use the {{ authCommand }} command to update the deprecated config at {{ deprecatedConfigPath }}."
32
- mergeNotConfirmed: "Did not merge. When you are ready to merge the deprecated config file with the global config file, run the {{ authCommand }} or {{ migrateCommand }} command."
33
- success:
34
- configFileCreated: "Created config file \"{{ configPath }}\""
35
- configFileUpdated: "Connected account \"{{ account }}\" and set it as the default account"
36
23
  createOverride:
37
24
  describe: "Create a new default account override file ({{ hsAccountFileName }}) in the current working directory."
38
25
  success: "Default account override file created at {{ overrideFilePath }}"
@@ -156,7 +143,7 @@ en:
156
143
  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."
157
144
  errors:
158
145
  unsupportedAuthType: "Unsupported auth type: {{ type }}. The only supported authentication protocols are {{ supportedProtocols }}."
159
- globalConfigFileExists: "A global config file exists at {{ configPath }}. To authorize an account, please use {{ authCommand }}."
146
+ globalConfigFileExists: "You are using our new global configuration for account management, which is not compatible with this command. Please use {{ accountAuthCommand }} instead."
160
147
  options:
161
148
  authType:
162
149
  describe: "Authentication method"
@@ -167,17 +154,6 @@ en:
167
154
  config:
168
155
  describe: "Commands for managing the CLI config file."
169
156
  subcommands:
170
- migrate:
171
- describe: "Migrate from the deprecated {{ deprecatedConfigPath }} file to the new global config file at {{ globalConfigPath }}."
172
- verboseDescribe: "This command will create a new global configuration file in your root directory and rename the deprecated config to {{ archivedConfigPath }}. If any conflicting values are detected, we will prompt you to reconcile them unless the \"--force\" flag is supplied."
173
- migrationAlreadyCompleted: "No {{ deprecatedConfigPath }} deprecated configuration file found. No migration necessary."
174
- errors:
175
- configNotFound: "A configuration file at {{ configPath }} could not be found. Please try again with a valid file path."
176
- options:
177
- 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."
178
- examples:
179
- default: "Migrate from the deprecated {{ deprecatedConfigPath }} file to the new global config file at {{ globalConfigPath }}"
180
- configFlag: "Migrate a specific config file (specified with the config flag) to the new global config file at {{ globalConfigPath }}"
181
157
  set:
182
158
  describe: "Set various configuration options within the hubspot.config.yml file."
183
159
  promptMessage: "Select a config option to update"
@@ -532,7 +508,7 @@ en:
532
508
  updateConfig: "To update an existing config file, use the \"hs auth\" command."
533
509
  errors:
534
510
  configFileExists: "The config file {{ configPath }} already exists."
535
- globalConfigFileExists: "A global config file already exists at {{ configPath }}. To specify a new local config file, delete the existing one and try again."
511
+ globalConfigFileExists: "You are using our new global configuration for account management, which is not compatible with this command. Please use {{ accountAuthCommand }} instead."
536
512
  lint:
537
513
  issuesFound: "{{ count }} issues found."
538
514
  groupName: "Linting {{ path }}"
@@ -874,14 +850,6 @@ en:
874
850
  noProjectConfig: "No project detected. Run this command from a project directory."
875
851
  noPackageJsonInProject: "No dependencies to install. The project {{ projectName }} folder might be missing component or subcomponent files. {{ link }}"
876
852
  packageManagerNotInstalled: "This command depends on {{ packageManager }}, install {{#bold}}{{ link }}{{/bold}}"
877
- remove:
878
- describe: "Delete a file or folder from HubSpot."
879
- deleted: "Deleted \"{{ path }}\" from account {{ accountId }}"
880
- errors:
881
- deleteFailed: "Deleting \"{{ path }}\" from account {{ accountId }} failed"
882
- positionals:
883
- path:
884
- describe: "Remote hubspot path"
885
853
  sandbox:
886
854
  describe: "Commands for managing sandboxes."
887
855
  subcommands:
@@ -979,144 +947,6 @@ en:
979
947
  success:
980
948
  update: "The secret \"{{ secretName }}\" was updated in the HubSpot account: {{ accountIdentifier }}"
981
949
  updateExplanation: "Existing serverless functions will start using this new value within 10 seconds."
982
- theme:
983
- describe: "Commands for managing themes."
984
- subcommands:
985
- generateSelectors:
986
- describe: "Automatically generates an editor-preview.json file for the given theme. The selectors this command generates are not perfect, so please edit editor-preview.json after running."
987
- errors:
988
- invalidPath: "Could not find directory \"{{ themePath }}\""
989
- fieldsNotFound: "Unable to find theme's fields.json."
990
- noSelectorsFound: "No selectors found."
991
- success: "Selectors generated for {{ themePath }}, please double check the selectors generated at {{ selectorsPath }} before uploading the theme."
992
- positionals:
993
- path:
994
- describe: "The path of the theme you'd like to generate an editor-preview.json for."
995
- marketplaceValidate:
996
- describe: "Validate a theme for the marketplace."
997
- errors:
998
- invalidPath: "The path \"{{ path }}\" is not a path to a folder in the Design Manager"
999
- logs:
1000
- validatingTheme: "Validating theme \"{{ path }}\" \n"
1001
- results:
1002
- required: "Required validation results:"
1003
- recommended: "Recommended validation results:"
1004
- warnings:
1005
- file: "File: {{ file }}"
1006
- lineNumber: "Line number: {{ line }}"
1007
- noErrors: "No errors"
1008
- positionals:
1009
- path:
1010
- describe: "Path to the theme within the Design Manager."
1011
- preview:
1012
- describe: "Upload and watch a theme directory on your computer for changes and start a local development server to preview theme changes on a site."
1013
- errors:
1014
- invalidPath: "The path \"{{ path }}\" is not a path to a directory"
1015
- noThemeComponents: "Your project has no theme components available to preview."
1016
- positionals:
1017
- src:
1018
- describe: "Path to the local directory your theme is in, relative to your current working directory"
1019
- dest:
1020
- describe: "Path in HubSpot Design Tools. Can be a net new path. If you wish to preview a site page using your theme changes it must match the path of the theme used by the site."
1021
- options:
1022
- notify:
1023
- describe: "Log to specified file when a watch task is triggered and after workers have gone idle. Ex. --notify path/to/file"
1024
- noSsl:
1025
- describe: "Disable HTTPS"
1026
- port:
1027
- describe: "The port on which to start the local server"
1028
- initialUploadProgressBar:
1029
- start: "Starting..."
1030
- uploading: "Uploading..."
1031
- finish: "Complete!"
1032
- logs:
1033
- processExited: "Stopping dev server..."
1034
- module:
1035
- describe: "Commands for working with modules, including marketplace validation with the marketplace-validate subcommand."
1036
- subcommands:
1037
- marketplaceValidate:
1038
- describe: "Validate a module for the marketplace. Make sure to include the suffix .module in the path to the module within the Design Manager."
1039
- errors:
1040
- invalidPath: "The path \"{{ path }}\" is not a path to a module within the Design Manager."
1041
- logs:
1042
- validatingModule: "Validating module \"{{ path }}\" \n"
1043
- options:
1044
- json:
1045
- describe: "Output raw json data"
1046
- results:
1047
- required: "Required validation results:"
1048
- recommended: "Recommended validation results:"
1049
- warnings:
1050
- file: "File: {{ file }}"
1051
- lineNumber: "Line number: {{ line }}"
1052
- noErrors: "No errors"
1053
- positionals:
1054
- src:
1055
- describe: "Path to the module within the Design Manager."
1056
- upload:
1057
- describe: "Upload a folder or file from your computer to the HubSpot CMS."
1058
- errors:
1059
- destinationRequired: "A destination path needs to be passed"
1060
- fileIgnored: "The file \"{{ path }}\" is being ignored via an .hsignore rule"
1061
- invalidPath: "The path \"{{ path }}\" is not a path to a file or folder"
1062
- uploadFailed: "Uploading file \"{{ src }}\" to \"{{ dest }}\" failed"
1063
- someFilesFailed: "One or more files failed to upload to \"{{ dest }}\" in the Design Manager"
1064
- deleteFailed: "Deleting \"{{ path }}\" from account {{ accountId }} failed"
1065
- options:
1066
- options:
1067
- describe: "Options to pass to javascript fields files"
1068
- saveOutput:
1069
- describe: "If true, saves all output from javascript fields files as 'fields.output.json'."
1070
- convertFields:
1071
- describe: "If true, converts any javascript fields files contained in module folder or project root."
1072
- clean:
1073
- describe: "Will delete the destination directory and its contents before uploading. This will also clear the global content associated with any global partial templates and modules."
1074
- force:
1075
- describe: "Skips confirmation prompts when doing a clean upload."
1076
- previewUrl: "To preview this theme, visit: {{ previewUrl }}"
1077
- positionals:
1078
- src:
1079
- describe: "Path to the local file, relative to your current working directory."
1080
- dest:
1081
- describe: "Path in HubSpot Design Tools, can be a net new path."
1082
- success:
1083
- fileUploaded: "Uploaded file from \"{{ src }}\" to \"{{ dest }}\" in the Design Manager of account {{ accountId }}"
1084
- uploadComplete: "Uploading files to \"{{ dest }}\" in the Design Manager is complete"
1085
- uploading: "Uploading files from \"{{ src }}\" to \"{{ dest }}\" in the Design Manager of account {{ accountId }}"
1086
- notUploaded: "There was an error processing \"{{ src }}\". The file has not been uploaded."
1087
- cleaning: "Removing \"{{ filePath }}\" from account {{ accountId }} and uploading local..."
1088
- confirmCleanUpload: "You are about to delete the directory \"{{ filePath }}\" and its contents on HubSpot account {{ accountId }} before uploading. This will also clear the global content associated with any global partial templates and modules. Are you sure you want to do this?"
1089
- watch:
1090
- describe: "Watch a directory on your computer for changes and upload the changed files to the HubSpot CMS."
1091
- errors:
1092
- folderFailed: "Initial uploading of folder \"{{ src }}\" to \"{{ dest }}\" in account {{ accountId }} had failures"
1093
- fileFailed: "Upload of file \"{{ file }}\" to \"{{ dest }}\" in account {{ accountId }} failed"
1094
- destinationRequired: "A destination directory needs to be passed"
1095
- invalidPath: "The \"{{ path }}\" is not a path to a directory"
1096
- options:
1097
- disableInitial:
1098
- describe: "Disable the initial upload when watching a directory (default)"
1099
- initialUpload:
1100
- describe: "Upload directory before watching for updates"
1101
- notify:
1102
- describe: "Log to specified file when a watch task is triggered and after workers have gone idle. Ex. --notify path/to/file"
1103
- remove:
1104
- describe: "Will cause watch to delete files in your HubSpot account that are not found locally."
1105
- convertFields:
1106
- describe: "If true, converts any javascript fields files contained in module folder or project root."
1107
- saveOutput:
1108
- describe: "If true, saves all output from javascript fields files as 'fields.output.json'."
1109
- options:
1110
- describe: "Options to pass to javascript fields files"
1111
- positionals:
1112
- src:
1113
- describe: "Path to the local directory your files are in, relative to your current working directory"
1114
- dest:
1115
- describe: "Path in HubSpot Design Tools. Can be a net new path"
1116
- warnings:
1117
- disableInitial: "Passing the \"--disable-initial\" option is no longer necessary. Running \"hs watch\" no longer uploads the watched directory by default."
1118
- initialUpload: "To upload the directory run \"hs upload\" beforehand or add the \"--initial-upload\" option when running \"hs watch\"."
1119
- notUploaded: "The \"hs watch\" command no longer uploads the watched directory when started. The directory \"{{ path }}\" was not uploaded."
1120
950
  convertFields:
1121
951
  describe: "Converts a specific JavaScript fields file of a module or theme to JSON."
1122
952
  positionals:
@@ -1203,7 +1033,7 @@ en:
1203
1033
  errors:
1204
1034
  noProjectsInConfig: "Unable to find any projects in the target repository's config.json file. Please ensure that there is a \"projects\" array in the config file."
1205
1035
  missingConfigFileTemplateSource: "Failed to fetch the config.json file from the target repository. Please ensure that there is a valid config.json file at the root of the repository and try again."
1206
- missingPropertiesInConfig: "Found misconfigured projects in the target repository's config.json file. Please ensure that each project in the target repository's config.json file contains the following properties: [\"name\", \"label\", \"path\", \"insertPath\"]."
1036
+ missingPropertiesInConfig: "Found misconfigured projects in the target repository's config.json file. Please ensure that each project in the target repository's config.json file contains the following properties: [\"name\", \"label\", \"path\"]."
1207
1037
  validateProjectConfig:
1208
1038
  configNotFound: "Unable to locate a project configuration file. Try running again from a project directory, or run {{ createCommand }} to create a new project."
1209
1039
  configMissingFields: "The project configuration file is missing required fields."
@@ -1335,19 +1165,6 @@ en:
1335
1165
  describe: "Use environment variable config"
1336
1166
  debug:
1337
1167
  describe: "Set log level to debug"
1338
- configMigrate:
1339
- migrationHeader: "Migrate your existing configuration file to the new global location?"
1340
- migrationDescription: "This action will create a new global configuration file in your root directory and rename the deprecated config to {{ archivedConfigPath}}. If any conflicting values are detected, we will prompt you to reconcile them unless the \"--force\" flag is supplied."
1341
- mergeHeader: "Merge your existing configuration file with the global config?"
1342
- mergeDescription: "This action will merge your deprecated config file with the global config file located in your root directory. It will also rename the deprecated config to {{ archivedConfigPath }}. If any conflicting values are detected, we will prompt you to reconcile them unless the \"--force\" flag is supplied."
1343
- migrateConfigPromptDescription: "From deprecated config file: {{ deprecatedConfigPath }}\nTo new global config file: {{ globalConfigPath }}"
1344
- migrateConfigPrompt: "Migrate to the new config?"
1345
- mergeConfigConflictPrompt: "Change the {{ property }} property in the global config from {{ newValue }} to {{ oldValue }}?"
1346
- mergeConfigsPromptDescription: "Two config files detected. \nDeprecated config file: {{ deprecatedConfigPath }}\nGlobal config: {{ globalConfigPath }}"
1347
- mergeConfigsPrompt: "Merge configs?"
1348
- migrationSuccess: "The deprecated config file has been migrated to the new global config file at {{ globalConfigPath }}."
1349
- mergeSuccess: "The deprecated config file has been merged with the global config file at {{ globalConfigPath }}."
1350
- skippedExistingAccounts: "\nThe following accounts were not merged, because they already exist in the global config: {{ skippedAccountIds }}.\n"
1351
1168
  prompts:
1352
1169
  projectDevTargetAccountPrompt:
1353
1170
  createNewSandboxOption: "<Test on a new development sandbox>"
@@ -1,2 +1,2 @@
1
- export declare function handleMigration(accountId: number | undefined, configPath?: string): Promise<boolean>;
2
- export declare function handleMerge(accountId: number | undefined, configPath?: string, force?: boolean): Promise<boolean>;
1
+ export declare function handleMigration(deprecatedConfigPath?: string, hideWarning?: boolean): Promise<boolean>;
2
+ export declare function handleMerge(deprecatedConfigPath?: string, force?: boolean, hideWarning?: boolean): Promise<boolean>;
@@ -4,61 +4,44 @@ exports.handleMigration = handleMigration;
4
4
  exports.handleMerge = handleMerge;
5
5
  const migrate_1 = require("@hubspot/local-dev-lib/config/migrate");
6
6
  const config_1 = require("@hubspot/local-dev-lib/constants/config");
7
- const logger_1 = require("@hubspot/local-dev-lib/logger");
8
7
  const promptUtils_1 = require("./prompts/promptUtils");
9
- const lang_1 = require("./lang");
10
- const usageTracking_1 = require("./usageTracking");
11
- async function handleMigration(accountId, configPath) {
12
- logger_1.logger.log((0, lang_1.i18n)('lib.configMigrate.migrationHeader'));
13
- logger_1.logger.log('');
14
- logger_1.logger.log((0, lang_1.i18n)('lib.configMigrate.migrationDescription', {
15
- archivedConfigPath: config_1.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME,
16
- }));
17
- logger_1.logger.log('');
18
- logger_1.logger.log((0, lang_1.i18n)('lib.configMigrate.migrateConfigPromptDescription', {
19
- deprecatedConfigPath: (0, migrate_1.getConfigPath)(configPath, false) ||
20
- config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
21
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
22
- }));
8
+ const en_1 = require("../lang/en");
9
+ const logger_1 = require("./ui/logger");
10
+ async function handleMigration(deprecatedConfigPath, hideWarning) {
11
+ if (!hideWarning) {
12
+ logger_1.uiLogger.warn(en_1.lib.configMigrate.deprecatedConfigWarning(deprecatedConfigPath || (0, migrate_1.getConfigPath)(undefined, false)));
13
+ logger_1.uiLogger.log('');
14
+ }
15
+ logger_1.uiLogger.log(en_1.lib.configMigrate.handleMigration.description(config_1.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME));
16
+ logger_1.uiLogger.log('');
23
17
  const { shouldMigrateConfig } = await (0, promptUtils_1.promptUser)({
24
18
  name: 'shouldMigrateConfig',
25
19
  type: 'confirm',
26
- message: (0, lang_1.i18n)('lib.configMigrate.migrateConfigPrompt'),
20
+ message: en_1.lib.configMigrate.handleMigration.confirmPrompt,
27
21
  });
28
22
  if (!shouldMigrateConfig) {
29
- (0, usageTracking_1.trackCommandMetadataUsage)('config-migrate', {
30
- command: 'hs config migrate',
31
- type: 'migration',
32
- step: 'Reject migration via prompt',
33
- }, accountId);
34
23
  return false;
35
24
  }
36
- const deprecatedConfig = (0, migrate_1.getDeprecatedConfig)(configPath);
25
+ const deprecatedConfig = (0, migrate_1.getDeprecatedConfig)(deprecatedConfigPath);
37
26
  (0, migrate_1.migrateConfig)(deprecatedConfig);
38
- (0, usageTracking_1.trackCommandMetadataUsage)('config-migrate', {
39
- command: 'hs config migrate',
40
- type: 'migration',
41
- step: 'Confirm migration via prompt',
42
- successful: true,
43
- }, accountId);
44
- logger_1.logger.success((0, lang_1.i18n)('lib.configMigrate.migrationSuccess', {
45
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
46
- }));
27
+ logger_1.uiLogger.success(en_1.lib.configMigrate.handleMigration.success);
47
28
  return true;
48
29
  }
49
- async function mergeConfigProperties(globalConfig, deprecatedConfig, force) {
30
+ async function handleMergeConfigProperties(globalConfig, deprecatedConfig, force) {
50
31
  const { initialConfig, conflicts, } = (0, migrate_1.mergeConfigProperties)(globalConfig, deprecatedConfig, force);
51
32
  if (conflicts.length > 0) {
33
+ const properties = conflicts.map(c => c.property);
34
+ const propertyList = properties.length <= 2
35
+ ? properties.join(' and ')
36
+ : `${properties.slice(0, -1).join(', ')}, and ${properties.at(-1)}`;
37
+ logger_1.uiLogger.log('');
38
+ logger_1.uiLogger.warn(en_1.lib.configMigrate.handleMergeConfigProperties.mergeConflictMessage(conflicts.length, propertyList));
52
39
  for (const conflict of conflicts) {
53
40
  const { property, newValue, oldValue } = conflict;
54
41
  const { shouldOverwrite } = await (0, promptUtils_1.promptUser)({
55
42
  name: 'shouldOverwrite',
56
43
  type: 'confirm',
57
- message: (0, lang_1.i18n)('lib.configMigrate.mergeConfigConflictPrompt', {
58
- property,
59
- oldValue: `${oldValue}`,
60
- newValue: `${newValue}`,
61
- }),
44
+ message: en_1.lib.configMigrate.handleMergeConfigProperties.mergeConfigConflictPrompt(property, newValue.toString(), oldValue.toString()),
62
45
  });
63
46
  if (shouldOverwrite) {
64
47
  // @ts-expect-error Cannot reconcile CLIConfig_NEW and CLIConfig_DEPRECATED
@@ -68,51 +51,33 @@ async function mergeConfigProperties(globalConfig, deprecatedConfig, force) {
68
51
  }
69
52
  return initialConfig;
70
53
  }
71
- async function handleMerge(accountId, configPath, force) {
72
- logger_1.logger.log((0, lang_1.i18n)('lib.configMigrate.mergeHeader'));
73
- logger_1.logger.log('');
74
- logger_1.logger.log((0, lang_1.i18n)('lib.configMigrate.mergeDescription', {
75
- archivedConfigPath: config_1.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME,
76
- }));
77
- logger_1.logger.log('');
78
- logger_1.logger.log((0, lang_1.i18n)('lib.configMigrate.mergeConfigsPromptDescription', {
79
- deprecatedConfigPath: (0, migrate_1.getConfigPath)(configPath, false) ||
80
- config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
81
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
82
- }));
54
+ async function handleMerge(deprecatedConfigPath, force, hideWarning) {
55
+ if (!hideWarning) {
56
+ logger_1.uiLogger.warn(en_1.lib.configMigrate.deprecatedConfigWarning(deprecatedConfigPath || (0, migrate_1.getConfigPath)(undefined, false)));
57
+ logger_1.uiLogger.log('');
58
+ }
59
+ logger_1.uiLogger.log(en_1.lib.configMigrate.handleMerge.description(config_1.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME));
60
+ logger_1.uiLogger.log('');
83
61
  const { shouldMergeConfigs } = await (0, promptUtils_1.promptUser)({
84
62
  name: 'shouldMergeConfigs',
85
63
  type: 'confirm',
86
- message: (0, lang_1.i18n)('lib.configMigrate.mergeConfigsPrompt'),
64
+ message: en_1.lib.configMigrate.handleMerge.confirmPrompt,
87
65
  });
88
66
  if (!shouldMergeConfigs) {
89
- (0, usageTracking_1.trackCommandMetadataUsage)('config-migrate', {
90
- command: 'hs config migrate',
91
- type: 'merge',
92
- step: 'Reject merge via prompt',
93
- }, accountId);
94
67
  return false;
95
68
  }
96
- const deprecatedConfig = (0, migrate_1.getDeprecatedConfig)(configPath);
69
+ const deprecatedConfig = (0, migrate_1.getDeprecatedConfig)(deprecatedConfigPath);
97
70
  const globalConfig = (0, migrate_1.getGlobalConfig)();
98
71
  if (!deprecatedConfig || !globalConfig) {
99
72
  return true;
100
73
  }
101
- const mergedConfig = await mergeConfigProperties(globalConfig, deprecatedConfig, force);
74
+ const mergedConfig = await handleMergeConfigProperties(globalConfig, deprecatedConfig, force);
102
75
  const { skippedAccountIds } = (0, migrate_1.mergeExistingConfigs)(mergedConfig, deprecatedConfig);
103
76
  if (skippedAccountIds.length > 0) {
104
- logger_1.logger.log((0, lang_1.i18n)('lib.configMigrate.skippedExistingAccounts', {
105
- skippedAccountIds: skippedAccountIds.join(', '),
106
- }));
77
+ logger_1.uiLogger.log('');
78
+ logger_1.uiLogger.log(en_1.lib.configMigrate.handleMerge.skippedExistingAccounts(skippedAccountIds));
79
+ logger_1.uiLogger.log('');
107
80
  }
108
- logger_1.logger.success((0, lang_1.i18n)('lib.configMigrate.mergeSuccess', {
109
- globalConfigPath: config_1.GLOBAL_CONFIG_PATH,
110
- }));
111
- (0, usageTracking_1.trackCommandMetadataUsage)('config-migrate', {
112
- command: 'hs config migrate',
113
- type: 'merge',
114
- step: 'Confirm merge via prompt',
115
- successful: true,
116
- }, accountId);
81
+ logger_1.uiLogger.success(en_1.lib.configMigrate.handleMerge.success);
117
82
  return true;
118
83
  }
@@ -78,9 +78,27 @@ export declare const FEATURES: {
78
78
  readonly UNIFIED_THEME_PREVIEW: "cms:react:unifiedThemePreview";
79
79
  readonly UNIFIED_APPS: "Developers:UnifiedApps:PrivateBeta";
80
80
  };
81
- export declare const LOCAL_DEV_UI_WEBSOCKET_MESSAGE_TYPES: {
82
- readonly UPLOAD: "upload";
83
- readonly INSTALL_DEPS: "installDeps";
84
- readonly APP_INSTALLED: "appInstalled";
85
- readonly UPDATE_PROJECT_NODES: "updateProjectNodes";
81
+ export declare const LOCAL_DEV_UI_MESSAGE_SEND_TYPES: {
82
+ UPLOAD_SUCCESS: string;
83
+ UPLOAD_FAILURE: string;
84
+ UPDATE_PROJECT_NODES: string;
85
+ UPDATE_APP_DATA: string;
86
+ UPDATE_PROJECT_DATA: string;
87
+ };
88
+ export declare const LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES: {
89
+ UPLOAD: string;
90
+ };
91
+ export declare const APP_INSTALLATION_STATES: {
92
+ readonly NOT_INSTALLED: "NOT_INSTALLED";
93
+ readonly INSTALLED: "INSTALLED";
94
+ readonly INSTALLED_WITH_OUTDATED_SCOPES: "INSTALLED_WITH_OUTDATED_SCOPES";
95
+ };
96
+ export declare const staticAuth = "static";
97
+ export declare const oAuth = "oauth";
98
+ export declare const privateDistribution = "private";
99
+ export declare const marketplaceDistribution = "marketplace";
100
+ export declare const appComponent = "app";
101
+ export declare const LOCAL_DEV_SERVER_MESSAGE_TYPES: {
102
+ readonly INITIAL: "INITIAL";
103
+ readonly WEBSOCKET_SERVER_CONNECTED: "WEBSOCKET_SERVER_CONNECTED";
86
104
  };
package/lib/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LOCAL_DEV_UI_WEBSOCKET_MESSAGE_TYPES = exports.FEATURES = exports.APP_AUTH_TYPES = exports.APP_DISTRIBUTION_TYPES = exports.IR_COMPONENT_TYPES = exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.DEFAULT_POLLING_DELAY = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
3
+ exports.LOCAL_DEV_SERVER_MESSAGE_TYPES = exports.appComponent = exports.marketplaceDistribution = exports.privateDistribution = exports.oAuth = exports.staticAuth = exports.APP_INSTALLATION_STATES = exports.LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES = exports.LOCAL_DEV_UI_MESSAGE_SEND_TYPES = exports.FEATURES = exports.APP_AUTH_TYPES = exports.APP_DISTRIBUTION_TYPES = exports.IR_COMPONENT_TYPES = exports.PLATFORM_VERSION_ERROR_TYPES = exports.PROJECT_COMPONENT_TYPES = exports.PROJECT_TASK_TYPES = exports.PROJECT_ERROR_TYPES = exports.PROJECT_DEPLOY_TEXT = exports.PROJECT_BUILD_TEXT = exports.PROJECT_DEPLOY_STATES = exports.PROJECT_BUILD_STATES = exports.PROJECT_CONFIG_FILE = exports.DEFAULT_POLLING_DELAY = exports.MARKETPLACE_FOLDER = exports.HUBSPOT_FOLDER = exports.FEEDBACK_INTERVAL = exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = void 0;
4
4
  exports.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH = 'HubSpot/hubspot-project-components';
5
5
  exports.DEFAULT_PROJECT_TEMPLATE_BRANCH = 'main';
6
6
  exports.FEEDBACK_INTERVAL = 10;
@@ -73,9 +73,27 @@ exports.FEATURES = {
73
73
  UNIFIED_THEME_PREVIEW: 'cms:react:unifiedThemePreview',
74
74
  UNIFIED_APPS: 'Developers:UnifiedApps:PrivateBeta',
75
75
  };
76
- exports.LOCAL_DEV_UI_WEBSOCKET_MESSAGE_TYPES = {
77
- UPLOAD: 'upload',
78
- INSTALL_DEPS: 'installDeps',
79
- APP_INSTALLED: 'appInstalled',
80
- UPDATE_PROJECT_NODES: 'updateProjectNodes',
76
+ exports.LOCAL_DEV_UI_MESSAGE_SEND_TYPES = {
77
+ UPLOAD_SUCCESS: 'server:uploadSuccess',
78
+ UPLOAD_FAILURE: 'server:uploadFailure',
79
+ UPDATE_PROJECT_NODES: 'server:updateProjectNodes',
80
+ UPDATE_APP_DATA: 'server:updateAppData',
81
+ UPDATE_PROJECT_DATA: 'server:updateProjectData',
82
+ };
83
+ exports.LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES = {
84
+ UPLOAD: 'client:upload',
85
+ };
86
+ exports.APP_INSTALLATION_STATES = {
87
+ NOT_INSTALLED: 'NOT_INSTALLED',
88
+ INSTALLED: 'INSTALLED',
89
+ INSTALLED_WITH_OUTDATED_SCOPES: 'INSTALLED_WITH_OUTDATED_SCOPES',
90
+ };
91
+ exports.staticAuth = 'static';
92
+ exports.oAuth = 'oauth';
93
+ exports.privateDistribution = 'private';
94
+ exports.marketplaceDistribution = 'marketplace';
95
+ exports.appComponent = 'app';
96
+ exports.LOCAL_DEV_SERVER_MESSAGE_TYPES = {
97
+ INITIAL: 'INITIAL',
98
+ WEBSOCKET_SERVER_CONNECTED: 'WEBSOCKET_SERVER_CONNECTED',
81
99
  };
@@ -10,9 +10,9 @@ exports.setPreviewSelectors = setPreviewSelectors;
10
10
  exports.generateInheritedSelectors = generateInheritedSelectors;
11
11
  exports.generateSelectorsMap = generateSelectorsMap;
12
12
  const fs_1 = __importDefault(require("fs"));
13
- const logger_1 = require("@hubspot/local-dev-lib/logger");
14
13
  const exitCodes_1 = require("./enums/exitCodes");
15
- const lang_1 = require("./lang");
14
+ const en_1 = require("../lang/en");
15
+ const logger_1 = require("./ui/logger");
16
16
  const CSS_COMMENTS_REGEX = new RegExp(/\/\*.*\*\//, 'g');
17
17
  const CSS_PSEUDO_CLASS_REGEX = new RegExp(/:active|:checked|:disabled|:empty|:enabled|:first-of-type|:focus|:hover|:in-range|:invalid|:link|:optional|:out-of-range|:read-only|:read-write|:required|:target|:valid|:visited/, 'g');
18
18
  let maxFieldsDepth = 0;
@@ -22,9 +22,7 @@ function getMaxFieldsDepth() {
22
22
  function findFieldsJsonPath(basePath) {
23
23
  const _path = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
24
24
  if (!fs_1.default.existsSync(_path)) {
25
- logger_1.logger.error((0, lang_1.i18n)(`commands.theme.subcommands.generateSelectors.errors.invalidPath`, {
26
- themePath: basePath,
27
- }));
25
+ logger_1.uiLogger.error(en_1.commands.theme.subcommands.generateSelectors.errors.invalidPath(basePath));
28
26
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
29
27
  }
30
28
  const files = fs_1.default.readdirSync(_path);
@@ -2,5 +2,15 @@ import { GetValidationResultsResponse } from '@hubspot/local-dev-lib/types/Marke
2
2
  export declare function kickOffValidation(accountId: number, assetType: string, src: string): Promise<number>;
3
3
  export declare function pollForValidationFinish(accountId: number, validationId: number): Promise<void>;
4
4
  export declare function fetchValidationResults(accountId: number, validationId: number): Promise<GetValidationResultsResponse>;
5
- export declare function processValidationErrors(i18nKey: string, validationResults: GetValidationResultsResponse): void;
6
- export declare function displayValidationResults(i18nKey: string, validationResults: GetValidationResultsResponse): void;
5
+ export declare function processValidationErrors(invalidPathError: (path: string) => string, validationResults: GetValidationResultsResponse): void;
6
+ type ResultsCopy = {
7
+ noErrors: string;
8
+ required: string;
9
+ recommended: string;
10
+ warnings: {
11
+ file: (file: string) => string;
12
+ lineNumber: (line: string) => string;
13
+ };
14
+ };
15
+ export declare function displayValidationResults(resultsCopy: ResultsCopy, validationResults: GetValidationResultsResponse): void;
16
+ export {};
@@ -10,8 +10,7 @@ exports.processValidationErrors = processValidationErrors;
10
10
  exports.displayValidationResults = displayValidationResults;
11
11
  const chalk_1 = __importDefault(require("chalk"));
12
12
  const marketplaceValidation_1 = require("@hubspot/local-dev-lib/api/marketplaceValidation");
13
- const logger_1 = require("@hubspot/local-dev-lib/logger");
14
- const lang_1 = require("./lang");
13
+ const logger_1 = require("./ui/logger");
15
14
  const exitCodes_1 = require("./enums/exitCodes");
16
15
  const SLEEP_TIME = 2000;
17
16
  async function kickOffValidation(accountId, assetType, src) {
@@ -25,7 +24,7 @@ async function kickOffValidation(accountId, assetType, src) {
25
24
  return requestResult;
26
25
  }
27
26
  catch (err) {
28
- logger_1.logger.debug(err);
27
+ logger_1.uiLogger.debug(err);
29
28
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
30
29
  }
31
30
  }
@@ -43,7 +42,7 @@ async function pollForValidationFinish(accountId, validationId) {
43
42
  await checkValidationStatus();
44
43
  }
45
44
  catch (err) {
46
- logger_1.logger.debug(err);
45
+ logger_1.uiLogger.debug(err);
47
46
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
48
47
  }
49
48
  }
@@ -55,69 +54,63 @@ async function fetchValidationResults(accountId, validationId) {
55
54
  return validationResults;
56
55
  }
57
56
  catch (err) {
58
- logger_1.logger.debug(err);
57
+ logger_1.uiLogger.debug(err);
59
58
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
60
59
  }
61
60
  }
62
- function processValidationErrors(i18nKey, validationResults) {
61
+ function processValidationErrors(invalidPathError, validationResults) {
63
62
  if (validationResults.errors.length) {
64
63
  const { assetPath, errors } = validationResults;
65
64
  errors.forEach(err => {
66
65
  if (err.failureReasonType === 'DOWNLOAD_EMPTY') {
67
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPath`, {
68
- path: assetPath,
69
- }));
66
+ logger_1.uiLogger.error(invalidPathError(assetPath));
70
67
  }
71
68
  else {
72
- logger_1.logger.error(`${err.context}`);
69
+ logger_1.uiLogger.error(`${err.context}`);
73
70
  }
74
71
  });
75
72
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
76
73
  }
77
74
  }
78
- function displayFileInfo(file, line, i18nKey) {
75
+ function displayFileInfo(file, line, resultsCopy) {
79
76
  if (file) {
80
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.results.warnings.file`, {
81
- file,
82
- }));
77
+ logger_1.uiLogger.log(resultsCopy.warnings.file(file));
83
78
  }
84
79
  if (line) {
85
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.results.warnings.lineNumber`, {
86
- line,
87
- }));
80
+ logger_1.uiLogger.log(resultsCopy.warnings.lineNumber(line.toString()));
88
81
  }
89
82
  }
90
- function displayResults(checks, i18nKey) {
83
+ function displayResults(checks, resultsCopy) {
91
84
  if (checks) {
92
85
  const { status, results } = checks;
93
86
  if (status === 'FAIL') {
94
87
  const failedValidations = results.filter(test => test.status === 'FAIL');
95
88
  const warningValidations = results.filter(test => test.status === 'WARN');
96
89
  failedValidations.forEach(val => {
97
- logger_1.logger.error(`${val.message}`);
98
- displayFileInfo(val.file, val.line, i18nKey);
90
+ logger_1.uiLogger.error(`${val.message}`);
91
+ displayFileInfo(val.file, val.line, resultsCopy);
99
92
  });
100
93
  warningValidations.forEach(val => {
101
- logger_1.logger.warn(`${val.message}`);
102
- displayFileInfo(val.file, val.line, i18nKey);
94
+ logger_1.uiLogger.warn(`${val.message}`);
95
+ displayFileInfo(val.file, val.line, resultsCopy);
103
96
  });
104
97
  }
105
98
  if (status === 'PASS') {
106
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.results.noErrors`));
99
+ logger_1.uiLogger.success(resultsCopy.noErrors);
107
100
  results.forEach(test => {
108
101
  if (test.status === 'WARN') {
109
- logger_1.logger.warn(`${test.message}`);
110
- displayFileInfo(test.file, test.line, i18nKey);
102
+ logger_1.uiLogger.warn(`${test.message}`);
103
+ displayFileInfo(test.file, test.line, resultsCopy);
111
104
  }
112
105
  });
113
106
  }
114
107
  }
115
108
  return;
116
109
  }
117
- function displayValidationResults(i18nKey, validationResults) {
110
+ function displayValidationResults(resultsCopy, validationResults) {
118
111
  Object.keys(validationResults.results).forEach(type => {
119
- logger_1.logger.log(chalk_1.default.bold((0, lang_1.i18n)(`${i18nKey}.results.${type.toLowerCase()}`)));
120
- displayResults(validationResults.results[type], i18nKey);
121
- logger_1.logger.log();
112
+ logger_1.uiLogger.log(chalk_1.default.bold(resultsCopy[type.toLowerCase()]));
113
+ displayResults(validationResults.results[type], resultsCopy);
114
+ logger_1.uiLogger.log('');
122
115
  });
123
116
  }