@hubspot/cli 7.1.0-beta.0 → 7.1.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 (139) hide show
  1. package/commands/account/clean.d.ts +9 -0
  2. package/commands/account/clean.js +51 -45
  3. package/commands/account/list.d.ts +7 -0
  4. package/commands/account/list.js +69 -60
  5. package/commands/account/remove.d.ts +9 -0
  6. package/commands/account/remove.js +33 -31
  7. package/commands/account/rename.d.ts +10 -0
  8. package/commands/account/rename.js +36 -23
  9. package/commands/account/use.d.ts +9 -0
  10. package/commands/account/use.js +26 -24
  11. package/commands/account.d.ts +4 -1
  12. package/commands/account.js +47 -13
  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/hubdb/clear.d.ts +11 -0
  39. package/commands/hubdb/clear.js +33 -30
  40. package/commands/hubdb/create.d.ts +10 -0
  41. package/commands/hubdb/create.js +46 -40
  42. package/commands/hubdb/delete.d.ts +10 -0
  43. package/commands/hubdb/delete.js +38 -35
  44. package/commands/hubdb/fetch.d.ts +11 -0
  45. package/commands/hubdb/fetch.js +30 -27
  46. package/commands/hubdb.d.ts +4 -1
  47. package/commands/hubdb.js +45 -11
  48. package/commands/init.js +2 -1
  49. package/commands/project/add.js +62 -16
  50. package/commands/project/cloneApp.js +3 -3
  51. package/commands/project/create.js +70 -15
  52. package/commands/project/dev/deprecatedFlow.d.ts +5 -0
  53. package/commands/project/dev/deprecatedFlow.js +137 -0
  54. package/commands/project/dev/index.d.ts +6 -0
  55. package/commands/project/dev/index.js +52 -0
  56. package/commands/project/dev/unifiedFlow.d.ts +5 -0
  57. package/commands/project/dev/unifiedFlow.js +110 -0
  58. package/commands/project/migrateApp.js +3 -3
  59. package/commands/project/upload.js +7 -2
  60. package/commands/sandbox/create.d.ts +12 -0
  61. package/commands/sandbox/create.js +90 -72
  62. package/commands/sandbox/delete.d.ts +11 -0
  63. package/commands/sandbox/delete.js +112 -95
  64. package/commands/sandbox.d.ts +4 -1
  65. package/commands/sandbox.js +44 -10
  66. package/commands/secret/addSecret.d.ts +10 -0
  67. package/commands/secret/addSecret.js +32 -31
  68. package/commands/secret/deleteSecret.d.ts +11 -0
  69. package/commands/secret/deleteSecret.js +31 -29
  70. package/commands/secret/listSecret.d.ts +9 -0
  71. package/commands/secret/listSecret.js +41 -0
  72. package/commands/secret/updateSecret.d.ts +10 -0
  73. package/commands/secret/updateSecret.js +33 -31
  74. package/commands/secret.d.ts +4 -1
  75. package/commands/secret.js +46 -12
  76. package/commands/theme/generate-selectors.d.ts +9 -0
  77. package/commands/theme/generate-selectors.js +61 -43
  78. package/commands/theme/marketplace-validate.d.ts +10 -0
  79. package/commands/theme/marketplace-validate.js +32 -26
  80. package/commands/theme/preview.d.ts +16 -0
  81. package/commands/theme/preview.js +104 -97
  82. package/commands/theme.d.ts +4 -1
  83. package/commands/theme.js +44 -10
  84. package/lang/en.lyaml +36 -16
  85. package/lib/DevServerManagerV2.d.ts +34 -0
  86. package/lib/DevServerManagerV2.js +85 -0
  87. package/lib/LocalDevManager.d.ts +2 -2
  88. package/lib/LocalDevManagerV2.d.ts +64 -0
  89. package/lib/LocalDevManagerV2.js +382 -0
  90. package/lib/buildAccount.d.ts +2 -3
  91. package/lib/constants.d.ts +12 -3
  92. package/lib/constants.js +13 -4
  93. package/lib/customObject.d.ts +3 -0
  94. package/lib/customObject.js +15 -0
  95. package/lib/doctor/DiagnosticInfoBuilder.d.ts +6 -0
  96. package/lib/doctor/DiagnosticInfoBuilder.js +5 -0
  97. package/lib/doctor/Doctor.d.ts +1 -0
  98. package/lib/doctor/Doctor.js +10 -0
  99. package/lib/localDev.d.ts +2 -1
  100. package/lib/marketplaceValidate.d.ts +2 -2
  101. package/lib/process.d.ts +1 -0
  102. package/lib/process.js +11 -10
  103. package/lib/projects/buildAndDeploy.js +4 -1
  104. package/lib/projects/create.d.ts +5 -0
  105. package/lib/projects/create.js +51 -0
  106. package/lib/projects/index.d.ts +1 -5
  107. package/lib/projects/index.js +1 -62
  108. package/lib/projects/structure.d.ts +4 -0
  109. package/lib/projects/structure.js +9 -0
  110. package/lib/projects/upload.d.ts +1 -1
  111. package/lib/projects/upload.js +2 -2
  112. package/lib/prompts/createProjectPrompt.d.ts +6 -8
  113. package/lib/prompts/createProjectPrompt.js +26 -54
  114. package/lib/prompts/projectAddPrompt.d.ts +3 -3
  115. package/lib/prompts/projectAddPrompt.js +16 -6
  116. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -2
  117. package/lib/prompts/sandboxesPrompt.d.ts +3 -2
  118. package/lib/prompts/sandboxesPrompt.js +1 -1
  119. package/lib/sandboxSync.js +6 -2
  120. package/lib/sandboxes.d.ts +3 -5
  121. package/lib/sandboxes.js +1 -0
  122. package/lib/testUtils.d.ts +12 -0
  123. package/lib/testUtils.js +10 -0
  124. package/lib/ui/index.d.ts +2 -2
  125. package/lib/ui/index.js +1 -0
  126. package/lib/upload.d.ts +1 -1
  127. package/lib/upload.js +20 -20
  128. package/lib/validation.d.ts +1 -1
  129. package/package.json +6 -5
  130. package/types/ProjectComponents.d.ts +38 -0
  131. package/types/ProjectComponents.js +3 -0
  132. package/types/Projects.d.ts +1 -6
  133. package/types/Prompts.d.ts +7 -0
  134. package/types/Sandboxes.d.ts +2 -0
  135. package/types/Yargs.d.ts +15 -0
  136. package/commands/project/dev.d.ts +0 -1
  137. package/commands/project/dev.js +0 -146
  138. package/commands/secret/listSecrets.d.ts +0 -1
  139. package/commands/secret/listSecrets.js +0 -39
@@ -1,37 +1,42 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const fs = require('fs');
5
- const path = require('path');
6
- const { i18n } = require('../../lib/lang');
7
- const { logger } = require('@hubspot/local-dev-lib/logger');
8
- const { addAccountOptions, addConfigOptions } = require('../../lib/commonOpts');
9
- const { getCwd } = require('@hubspot/local-dev-lib/path');
10
- const { getUploadableFileList } = require('../../lib/upload');
11
- const { trackCommandUsage } = require('../../lib/usageTracking');
12
- const { previewPrompt, previewProjectPrompt, } = require('../../lib/prompts/previewPrompt');
13
- const { EXIT_CODES } = require('../../lib/enums/exitCodes');
14
- const { FILE_UPLOAD_RESULT_TYPES, } = require('@hubspot/local-dev-lib/constants/files');
15
- const cliProgress = require('cli-progress');
16
- const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
17
- const { handleExit, handleKeypress } = require('../../lib/process');
18
- const { getThemeJSONPath } = require('@hubspot/local-dev-lib/cms/themes');
19
- const { getProjectConfig } = require('../../lib/projects');
20
- const { findProjectComponents } = require('../../lib/projects/structure');
21
- const { ComponentTypes } = require('../../types/Projects');
22
- const { preview } = require('@hubspot/theme-preview-dev-server');
23
- const { hasFeature } = require('../../lib/hasFeature');
6
+ exports.describe = exports.command = void 0;
7
+ exports.handler = handler;
8
+ exports.builder = builder;
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const cli_progress_1 = __importDefault(require("cli-progress"));
12
+ const lang_1 = require("../../lib/lang");
13
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
14
+ const path_2 = require("@hubspot/local-dev-lib/path");
15
+ const files_1 = require("@hubspot/local-dev-lib/constants/files");
16
+ const themes_1 = require("@hubspot/local-dev-lib/cms/themes");
17
+ const theme_preview_dev_server_1 = require("@hubspot/theme-preview-dev-server");
18
+ const commonOpts_1 = require("../../lib/commonOpts");
19
+ const upload_1 = require("../../lib/upload");
20
+ const usageTracking_1 = require("../../lib/usageTracking");
21
+ const previewPrompt_1 = require("../../lib/prompts/previewPrompt");
22
+ const exitCodes_1 = require("../../lib/enums/exitCodes");
23
+ const index_1 = require("../../lib/errorHandlers/index");
24
+ const process_1 = require("../../lib/process");
25
+ const projects_1 = require("../../lib/projects");
26
+ const structure_1 = require("../../lib/projects/structure");
27
+ const Projects_1 = require("../../types/Projects");
28
+ const hasFeature_1 = require("../../lib/hasFeature");
24
29
  const i18nKey = 'commands.theme.subcommands.preview';
25
30
  exports.command = 'preview [--src] [--dest]';
26
- exports.describe = i18n(`${i18nKey}.describe`);
27
- const validateSrcPath = src => {
31
+ exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
32
+ function validateSrcPath(src) {
28
33
  const logInvalidPath = () => {
29
- logger.error(i18n(`${i18nKey}.errors.invalidPath`, {
34
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPath`, {
30
35
  path: src,
31
36
  }));
32
37
  };
33
38
  try {
34
- const stats = fs.statSync(src);
39
+ const stats = fs_1.default.statSync(src);
35
40
  if (!stats.isDirectory()) {
36
41
  logInvalidPath();
37
42
  return false;
@@ -42,65 +47,65 @@ const validateSrcPath = src => {
42
47
  return false;
43
48
  }
44
49
  return true;
45
- };
46
- const handleUserInput = () => {
50
+ }
51
+ function handleUserInput() {
47
52
  const onTerminate = () => {
48
- logger.log(i18n(`${i18nKey}.logs.processExited`));
49
- process.exit(EXIT_CODES.SUCCESS);
53
+ logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.logs.processExited`));
54
+ process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
50
55
  };
51
- handleExit(onTerminate);
52
- handleKeypress(key => {
56
+ (0, process_1.handleExit)(onTerminate);
57
+ (0, process_1.handleKeypress)(key => {
53
58
  if ((key.ctrl && key.name === 'c') || key.name === 'q') {
54
59
  onTerminate();
55
60
  }
56
61
  });
57
- };
58
- const determineSrcAndDest = async (options) => {
62
+ }
63
+ async function determineSrcAndDest(args) {
59
64
  let absoluteSrc;
60
65
  let dest;
61
- const { projectDir, projectConfig } = await getProjectConfig();
66
+ const { projectDir, projectConfig } = await (0, projects_1.getProjectConfig)();
62
67
  if (!(projectDir && projectConfig)) {
63
68
  // Not in a project, prompt for src and dest of traditional theme
64
- const previewPromptAnswers = await previewPrompt(options);
65
- const src = options.src || previewPromptAnswers.src;
66
- dest = options.dest || previewPromptAnswers.dest;
67
- absoluteSrc = path.resolve(getCwd(), src);
69
+ const previewPromptAnswers = await (0, previewPrompt_1.previewPrompt)(args);
70
+ const src = args.src || previewPromptAnswers.src;
71
+ dest = args.dest || previewPromptAnswers.dest;
72
+ absoluteSrc = path_1.default.resolve((0, path_2.getCwd)(), src);
68
73
  if (!dest || !validateSrcPath(absoluteSrc)) {
69
- process.exit(EXIT_CODES.ERROR);
74
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
70
75
  }
71
76
  }
72
77
  else {
73
78
  // In a project
74
- let themeJsonPath = getThemeJSONPath();
79
+ let themeJsonPath = (0, themes_1.getThemeJSONPath)((0, path_2.getCwd)());
75
80
  if (!themeJsonPath) {
76
- const projectComponents = await findProjectComponents(projectDir);
77
- const themeComponents = projectComponents.filter(c => c.type === ComponentTypes.HublTheme);
81
+ const projectComponents = await (0, structure_1.findProjectComponents)(projectDir);
82
+ const themeComponents = projectComponents.filter(c => c.type === Projects_1.ComponentTypes.HublTheme);
78
83
  if (themeComponents.length === 0) {
79
- logger.error(i18n(`${i18nKey}.errors.noThemeComponents`));
80
- process.exit(EXIT_CODES.ERROR);
84
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noThemeComponents`));
85
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
81
86
  }
82
- const answer = await previewProjectPrompt(themeComponents);
87
+ const answer = await (0, previewPrompt_1.previewProjectPrompt)(themeComponents);
83
88
  themeJsonPath = `${answer.themeComponentPath}/theme.json`;
84
89
  }
85
- const { dir: themeDir } = path.parse(themeJsonPath);
90
+ const { dir: themeDir } = path_1.default.parse(themeJsonPath);
86
91
  absoluteSrc = themeDir;
87
- const { base: themeName } = path.parse(themeDir);
92
+ const { base: themeName } = path_1.default.parse(themeDir);
88
93
  dest = `@projects/${projectConfig.name}/${themeName}`;
89
94
  }
90
95
  return { absoluteSrc, dest };
91
- };
92
- exports.handler = async (options) => {
93
- const { derivedAccountId, notify, noSsl, resetSession, port, generateFieldsTypes, } = options;
94
- const { absoluteSrc, dest } = await determineSrcAndDest(options);
95
- const filePaths = await getUploadableFileList(absoluteSrc, false);
96
- const startProgressBar = numFiles => {
97
- const initialUploadProgressBar = new cliProgress.SingleBar({
96
+ }
97
+ async function handler(args) {
98
+ const { derivedAccountId, notify, noSsl, resetSession, port, generateFieldsTypes, } = args;
99
+ const { absoluteSrc, dest } = await determineSrcAndDest(args);
100
+ const filePaths = await (0, upload_1.getUploadableFileList)(absoluteSrc, false);
101
+ function startProgressBar(numFiles) {
102
+ const initialUploadProgressBar = new cli_progress_1.default.SingleBar({
98
103
  gracefulExit: true,
99
104
  format: '[{bar}] {percentage}% | {value}/{total} | {label}',
100
105
  hideCursor: true,
101
- }, cliProgress.Presets.rect);
106
+ }, cli_progress_1.default.Presets.rect);
102
107
  initialUploadProgressBar.start(numFiles, 0, {
103
- label: i18n(`${i18nKey}.initialUploadProgressBar.start`),
108
+ label: (0, lang_1.i18n)(`${i18nKey}.initialUploadProgressBar.start`),
104
109
  });
105
110
  let uploadsHaveStarted = false;
106
111
  const uploadOptions = {
@@ -112,7 +117,7 @@ exports.handler = async (options) => {
112
117
  if (!uploadsHaveStarted) {
113
118
  uploadsHaveStarted = true;
114
119
  initialUploadProgressBar.update(0, {
115
- label: i18n(`${i18nKey}.initialUploadProgressBar.uploading`),
120
+ label: (0, lang_1.i18n)(`${i18nKey}.initialUploadProgressBar.uploading`),
116
121
  });
117
122
  }
118
123
  },
@@ -123,15 +128,15 @@ exports.handler = async (options) => {
123
128
  /* Intentionally blank */
124
129
  },
125
130
  onFinalErrorCallback: () => initialUploadProgressBar.increment(),
126
- onFinishCallback: results => {
131
+ onFinishCallback: (results) => {
127
132
  initialUploadProgressBar.update(numFiles, {
128
- label: i18n(`${i18nKey}.initialUploadProgressBar.finish`),
133
+ label: (0, lang_1.i18n)(`${i18nKey}.initialUploadProgressBar.finish`),
129
134
  });
130
135
  initialUploadProgressBar.stop();
131
136
  results.forEach(result => {
132
- if (result.resultType == FILE_UPLOAD_RESULT_TYPES.FAILURE) {
133
- logger.error('Uploading file "%s" to "%s" failed', result.file, dest);
134
- logError(result.error, new ApiErrorContext({
137
+ if (result.resultType == files_1.FILE_UPLOAD_RESULT_TYPES.FAILURE) {
138
+ logger_1.logger.error('Uploading file "%s" to "%s" failed', result.file, dest);
139
+ (0, index_1.logError)(result.error, new index_1.ApiErrorContext({
135
140
  accountId: derivedAccountId,
136
141
  request: dest,
137
142
  payload: result.file,
@@ -141,76 +146,78 @@ exports.handler = async (options) => {
141
146
  },
142
147
  };
143
148
  return uploadOptions;
144
- };
145
- trackCommandUsage('preview', derivedAccountId);
149
+ }
150
+ (0, usageTracking_1.trackCommandUsage)('preview', {}, derivedAccountId);
146
151
  let createUnifiedDevServer;
147
152
  try {
153
+ // @ts-ignore TODO: Remove when we deprecate Node 18
148
154
  require.resolve('@hubspot/cms-dev-server');
155
+ // @ts-ignore TODO: Remove when we deprecate Node 18
149
156
  const { createDevServer } = await import('@hubspot/cms-dev-server');
150
157
  createUnifiedDevServer = createDevServer;
151
158
  }
152
159
  catch (e) {
153
- logger.warn('Unified dev server requires node 20 to run. Defaulting to legacy preview.');
160
+ logger_1.logger.warn('Unified dev server requires node 20 to run. Defaulting to legacy preview.');
154
161
  }
155
- const isUngatedForUnified = await hasFeature(derivedAccountId, 'cms:react:unifiedThemePreview');
162
+ const isUngatedForUnified = await (0, hasFeature_1.hasFeature)(derivedAccountId, 'cms:react:unifiedThemePreview');
156
163
  if (isUngatedForUnified && createUnifiedDevServer) {
157
164
  if (port) {
158
- process.env['PORT'] = port;
165
+ process.env['PORT'] = port.toString();
159
166
  }
160
- createUnifiedDevServer(absoluteSrc, false, false, false, !noSsl, generateFieldsTypes, {
167
+ createUnifiedDevServer(absoluteSrc, false, '', '', !noSsl, generateFieldsTypes, {
161
168
  filePaths,
162
- resetSession,
169
+ resetSession: resetSession || false,
163
170
  startProgressBar,
164
- handleUserInput,
165
171
  dest,
166
172
  });
167
173
  }
168
174
  else {
169
- preview(derivedAccountId, absoluteSrc, dest, {
175
+ (0, theme_preview_dev_server_1.preview)(derivedAccountId, absoluteSrc, dest, {
170
176
  notify,
171
177
  filePaths,
172
178
  noSsl,
173
179
  port,
174
- resetSession,
180
+ resetSession: resetSession || false,
175
181
  startProgressBar,
176
182
  handleUserInput,
177
183
  });
178
184
  }
179
- };
180
- exports.builder = yargs => {
181
- addConfigOptions(yargs);
182
- addAccountOptions(yargs);
183
- yargs.option('src', {
184
- describe: i18n(`${i18nKey}.options.src.describe`),
185
+ }
186
+ function builder(yargs) {
187
+ (0, commonOpts_1.addConfigOptions)(yargs);
188
+ (0, commonOpts_1.addAccountOptions)(yargs);
189
+ yargs
190
+ .option('src', {
191
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.src.describe`),
185
192
  type: 'string',
186
193
  requiresArg: true,
187
- });
188
- yargs.option('dest', {
189
- describe: i18n(`${i18nKey}.options.dest.describe`),
194
+ })
195
+ .option('dest', {
196
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.dest.describe`),
190
197
  type: 'string',
191
198
  requiresArg: true,
192
- });
193
- yargs.option('notify', {
199
+ })
200
+ .option('notify', {
194
201
  alias: 'n',
195
- describe: i18n(`${i18nKey}.options.notify.describe`),
202
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.notify.describe`),
196
203
  type: 'string',
197
204
  requiresArg: true,
198
- });
199
- yargs.option('no-ssl', {
200
- describe: i18n(`${i18nKey}.options.noSsl.describe`),
205
+ })
206
+ .option('no-ssl', {
207
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.noSsl.describe`),
201
208
  type: 'boolean',
202
- });
203
- yargs.option('port', {
204
- describe: i18n(`${i18nKey}.options.port.describe`),
209
+ })
210
+ .option('port', {
211
+ describe: (0, lang_1.i18n)(`${i18nKey}.options.port.describe`),
205
212
  type: 'number',
206
- });
207
- yargs.option('resetSession', {
208
- describe: false,
213
+ })
214
+ .option('resetSession', {
215
+ hidden: true,
209
216
  type: 'boolean',
210
- });
211
- yargs.option('generateFieldsTypes', {
212
- describe: false,
217
+ })
218
+ .option('generateFieldsTypes', {
219
+ hidden: true,
213
220
  type: 'boolean',
214
221
  });
215
222
  return yargs;
216
- };
223
+ }
@@ -1 +1,4 @@
1
- export {};
1
+ import { Argv } from 'yargs';
2
+ export declare const command: string[];
3
+ export declare const describe: string;
4
+ export declare function builder(yargs: Argv): Argv;
package/commands/theme.js CHANGED
@@ -1,20 +1,54 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const marketplaceValidate = require('./theme/marketplace-validate');
5
- const generateSelectors = require('./theme/generate-selectors');
6
- const previewCommand = require('./theme/preview');
7
- const { addGlobalOptions } = require('../lib/commonOpts');
8
- const { i18n } = require('../lib/lang');
36
+ exports.describe = exports.command = void 0;
37
+ exports.builder = builder;
38
+ const marketplaceValidate = __importStar(require("./theme/marketplace-validate"));
39
+ const generateSelectors = __importStar(require("./theme/generate-selectors"));
40
+ const previewCommand = __importStar(require("./theme/preview"));
41
+ const commonOpts_1 = require("../lib/commonOpts");
42
+ const lang_1 = require("../lib/lang");
9
43
  const i18nKey = 'commands.theme';
10
44
  exports.command = ['theme', 'themes'];
11
- exports.describe = i18n(`${i18nKey}.describe`);
12
- exports.builder = yargs => {
13
- addGlobalOptions(yargs);
45
+ exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
46
+ function builder(yargs) {
47
+ (0, commonOpts_1.addGlobalOptions)(yargs);
14
48
  yargs
15
49
  .command(previewCommand)
16
50
  .command(marketplaceValidate)
17
51
  .command(generateSelectors)
18
52
  .demandCommand(1, '');
19
53
  return yargs;
20
- };
54
+ }
package/lang/en.lyaml CHANGED
@@ -207,6 +207,7 @@ en:
207
207
  create:
208
208
  describe: "Create custom object instances."
209
209
  errors:
210
+ invalidObjectDefinition: "The object definition is invalid. Please check the schema and try again."
210
211
  creationFailed: "Object creation from {{ definition }} failed"
211
212
  options:
212
213
  path:
@@ -224,6 +225,7 @@ en:
224
225
  create:
225
226
  describe: "Create a custom object schema."
226
227
  errors:
228
+ invalidSchema: "The schema definition is invalid. Please check the schema and try again."
227
229
  creationFailed: "Schema creation from {{ definition }} failed"
228
230
  options:
229
231
  definition:
@@ -285,6 +287,7 @@ en:
285
287
  update:
286
288
  describe: "Update an existing custom object schema."
287
289
  errors:
290
+ invalidSchema: "The schema definition is invalid. Please check the schema and try again."
288
291
  update: "Schema update from {{ definition }} failed"
289
292
  options:
290
293
  path:
@@ -522,13 +525,21 @@ en:
522
525
  learnMoreLocalDevServer: "Learn more about the projects local dev server"
523
526
  errors:
524
527
  noProjectConfig: "No project detected. Please run this command again from a project directory."
528
+ noAccount: "An error occurred while reading account {{ accountId }} from your config. Run {{ authCommand }} to re-auth this account."
529
+ noAccountsInConfig: "No accounts found in your config. Run {{ authCommand }} to configure a HubSpot account with the CLI."
525
530
  invalidProjectComponents: "Projects cannot contain both private and public apps. Move your apps to separate projects before attempting local development."
526
531
  noRunnableComponents: "No supported components were found in this project. Run {{ command }} to see a list of available components and add one to your project."
532
+ invalidUnifiedAppsAccount: "You must target a Combined account to use Unified Apps Local Dev"
527
533
  examples:
528
534
  default: "Start local dev for the current project"
529
535
  create:
530
536
  describe: "Create a new project."
537
+ errors:
538
+ failedToDownloadProject: "Failed to download project. Please try again later."
539
+ failedToFetchProjectList: "Failed to fetch the list of available project templates. Please try again later."
540
+ cannotNestProjects: "A project already exists at {{ projectDir }}. Projects cannot be nested within other projects. Please choose a different destination and try again."
531
541
  logs:
542
+ success: "Project {{#bold}}{{ projectName }}{{/bold}} was successfully created in {{ projectDest }}"
532
543
  welcomeMessage: "Welcome to HubSpot Developer Projects!"
533
544
  examples:
534
545
  default: "Create a new project"
@@ -601,12 +612,13 @@ en:
601
612
  describe: "The name for your newly created component"
602
613
  type:
603
614
  describe: "The path to the component type's location within the hubspot-project-components Github repo: https://github.com/HubSpot/hubspot-project-components"
604
- creatingComponent:
605
- message: "Adding a new component to your project"
606
- success:
607
- message: "{{ componentName }} was added to your project"
615
+ creatingComponent: "Adding a new component to {{#bold}}{{ projectName }}{{/bold}}"
616
+ success: "{{ componentName }} was successfully added to your project."
608
617
  error:
609
- locationInProject: "The component location must be within a project folder"
618
+ failedToDownloadComponent: "Failed to download project component. Please try again later."
619
+ locationInProject: "This command must be run from within a project directory."
620
+ failedToFetchComponentList: "Failed to fetch the list of available components. Please try again later."
621
+ projectContainsPublicApp: "This project contains a public app. This command is currently only compatible with projects that contain private apps."
610
622
  examples:
611
623
  default: "Create a component within your project"
612
624
  withFlags: "Use --name and --type flags to bypass the prompt."
@@ -813,6 +825,8 @@ en:
813
825
  invalidAccountType: "Sandboxes must be created from a production account. Your current default account {{#bold}}{{ accountName }}{{/bold}} is a {{ accountType }}.
814
826
  \n- Run {{#bold}}hs accounts use{{/bold}} to switch to your default account to your production account.
815
827
  \n- Run {{#bold}}hs auth{{/bold}} to connect a production account to the HubSpot CLI.\n"
828
+ noAccountConfig: "There is no account associated with {{ accountId }} in the config file. Please choose another account and try again, or authenticate {{ accountId }} using {{ authCommand }}."
829
+ noSandboxAccountConfig: "There is no sandbox account associated with {{ accountId }} in the config file. Please try to re-authenticate your sandbox account using {{ authCommand}}."
816
830
  delete:
817
831
  describe: "Delete a sandbox account."
818
832
  debug:
@@ -829,11 +843,12 @@ en:
829
843
  failure:
830
844
  invalidUser: "Couldn't delete {{ accountName }} because your account has been removed from {{ parentAccountName }} or your permission set doesn't allow you to delete the sandbox. To update your permissions, contact a super admin in {{ parentAccountName }}."
831
845
  noAccount: "No account specified. Specify an account by using the --account flag."
832
- noSandboxAccounts: "There are no sandboxes connected to the CLI. To add a sandbox, run {{#bold}}hs auth{{/bold}}."
833
- noParentAccount: "This sandbox can't be deleted from the CLI because you haven't given the CLI access to its parent account. To do this, run {{#bold}}hs auth{{/bold}} and add the parent account."
846
+ noSandboxAccounts: "There are no sandboxes connected to the CLI. To add a sandbox, run {{ authCommand }}."
847
+ noSandboxAccountId: "This sandbox can't be deleted from the CLI because we could not find the associated sandbox account."
848
+ noParentAccount: "This sandbox can't be deleted from the CLI because you haven't given the CLI access to its parent account. To do this, run {{ authCommand }} and add the parent account."
834
849
  objectNotFound: "Sandbox {{#bold}}{{ account }}{{/bold}} may have been deleted through the UI. The account has been removed from the config."
835
- noParentPortalAvailable: "This sandbox can't be deleted from the CLI because you haven't given the CLI access to its parent account. To do this, run {{#bold}}{{ command }}{{/bold}}. You can also delete the sandbox from the HubSpot management tool: {{#bold}}{{ url }}{{/bold}}."
836
- invalidKey: "Your personal access key for account {{#bold}}{{ account }}{{/bold}} is inactive. To re-authenticate, please run {{#bold}}hs auth personalaccesskey{{/bold}}."
850
+ noParentPortalAvailable: "This sandbox can't be deleted from the CLI because you haven't given the CLI access to its parent account. To do this, run {{ command }}. You can also delete the sandbox from the HubSpot management tool: {{#bold}}{{ url }}{{/bold}}."
851
+ invalidKey: "Your personal access key for account {{#bold}}{{ account }}{{/bold}} is inactive. To re-authenticate, please run {{ authCommand }}."
837
852
  options:
838
853
  force:
839
854
  describe: "Skips all confirmation prompts when deleting a sandbox account."
@@ -1101,6 +1116,11 @@ en:
1101
1116
  checkIfParentAccountIsAuthed:
1102
1117
  notAuthedError: "To develop this project locally, run {{ authCommand }} to authenticate the App Developer Account {{ accountId }} associated with {{ accountIdentifier }}."
1103
1118
  projects:
1119
+ create:
1120
+ errors:
1121
+ 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."
1122
+ 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."
1123
+ 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\"]."
1104
1124
  validateProjectConfig:
1105
1125
  configNotFound: "Unable to locate a project configuration file. Try running again from a project directory, or run {{ createCommand }} to create a new project."
1106
1126
  configMissingFields: "The project configuruation file is missing required fields."
@@ -1308,12 +1328,9 @@ en:
1308
1328
  errors:
1309
1329
  nameRequired: "A project name is required"
1310
1330
  destRequired: "A project dest is required"
1311
- invalidDest: "The selected destination already exists. Please provide a new path for this project."
1331
+ invalidDest: "There is an existing project at this destination. Please provide a new path for this project."
1312
1332
  invalidCharacters: "The selected destination contains invalid characters. Please provide a new path and try again."
1313
- invalidTemplate: "[--template] Could not find template {{ template }}. Please choose an available template."
1314
- noProjectsInConfig: "Please ensure that there is a config.json file that contains a \"projects\" field."
1315
- missingConfigFileTemplateSource: "Please ensure that there is a config.json file in the repository used as the --template-source"
1316
- missingPropertiesInConfig: "Please ensure that each of the projects in your config.json file contain the following properties: [\"name\", \"label\", \"path\", \"insertPath\"]."
1333
+ invalidTemplate: "[--template] Could not find template \"{{ template }}\". Please choose an available template:"
1317
1334
  selectPublicAppPrompt:
1318
1335
  selectAppIdMigrate: "[--appId] Choose an app under {{ accountName }} to migrate:"
1319
1336
  selectAppIdClone: "[--appId] Choose an app under {{ accountName }} to clone:"
@@ -1331,11 +1348,11 @@ en:
1331
1348
  projectNotFound: "Your project {{ projectName }} could not be found in {{ accountId }}. Please select a valid project:"
1332
1349
  accountIdRequired: "An account ID is required to download a project."
1333
1350
  projectAddPrompt:
1334
- selectType: "[--type] Select your component type:"
1351
+ selectType: "[--type] Select a component to add: "
1335
1352
  enterName: "[--name] Give your component a name: "
1336
1353
  errors:
1337
1354
  nameRequired: "A component name is required"
1338
- invalidType: "[--type] Could not find type {{ type }}. Please choose an available type."
1355
+ invalidType: "[--type] Could not find type \"{{ type }}\". Please choose an available type:"
1339
1356
  secretPrompt:
1340
1357
  enterValue: "Enter a value for your secret: "
1341
1358
  enterName: "Enter a name for your secret: "
@@ -1559,6 +1576,9 @@ en:
1559
1576
  defaultAccountSubHeader: "Default Account: {{accountDetails}}"
1560
1577
  noConfigFile: "CLI configuration not found"
1561
1578
  noConfigFileSecondary: "Run {{command}} and follow the prompts to create your CLI configuration file and connect it to your HubSpot account"
1579
+ settings:
1580
+ httpUseLocalhost: "The setting {{#bold}}httpUseLocalhost{{/bold}} is enabled"
1581
+ httpUseLocalhostSecondary: "This setting causes all CLI requests to route to localhost"
1562
1582
  projectConfig:
1563
1583
  header: "Project configuration"
1564
1584
  projectDirSubHeader: "Project dir: {{#bold}}{{ projectDir }}{{/bold}}"
@@ -0,0 +1,34 @@
1
+ import { ProjectConfig } from '../types/Projects';
2
+ import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
3
+ type DevServerInterface = {
4
+ setup?: Function;
5
+ start?: (options: object) => Promise<void>;
6
+ fileChange?: (filePath: string, event: string) => Promise<void>;
7
+ cleanup?: () => Promise<void>;
8
+ };
9
+ declare class DevServerManagerV2 {
10
+ private initialized;
11
+ private started;
12
+ private devServers;
13
+ constructor();
14
+ iterateDevServers(callback: (serverInterface: DevServerInterface) => Promise<void>): Promise<void>;
15
+ setup({ projectNodes, onUploadRequired, accountId, setActiveApp, }: {
16
+ projectNodes: {
17
+ [key: string]: IntermediateRepresentationNodeLocalDev;
18
+ };
19
+ onUploadRequired: () => void;
20
+ accountId: number;
21
+ setActiveApp: (appUid: string | undefined) => Promise<void>;
22
+ }): Promise<void>;
23
+ start({ accountId, projectConfig, }: {
24
+ accountId: number;
25
+ projectConfig: ProjectConfig;
26
+ }): Promise<void>;
27
+ fileChange({ filePath, event, }: {
28
+ filePath: string;
29
+ event: string;
30
+ }): Promise<void>;
31
+ cleanup(): Promise<void>;
32
+ }
33
+ declare const Manager: DevServerManagerV2;
34
+ export default Manager;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
4
+ const lang_1 = require("./lang");
5
+ const promptUtils_1 = require("./prompts/promptUtils");
6
+ const ui_extensions_dev_server_1 = require("@hubspot/ui-extensions-dev-server");
7
+ const portManager_1 = require("@hubspot/local-dev-lib/portManager");
8
+ const urls_1 = require("@hubspot/local-dev-lib/urls");
9
+ const config_1 = require("@hubspot/local-dev-lib/config");
10
+ const i18nKey = 'lib.DevServerManager';
11
+ class DevServerManagerV2 {
12
+ initialized;
13
+ started;
14
+ devServers;
15
+ constructor() {
16
+ this.initialized = false;
17
+ this.started = false;
18
+ this.devServers = [ui_extensions_dev_server_1.DevModeUnifiedInterface];
19
+ }
20
+ async iterateDevServers(callback) {
21
+ await Promise.all(this.devServers.map(devServer => callback(devServer)));
22
+ }
23
+ async setup({ projectNodes, onUploadRequired, accountId, setActiveApp, }) {
24
+ let env;
25
+ const accountConfig = (0, config_1.getAccountConfig)(accountId);
26
+ if (accountConfig) {
27
+ env = accountConfig.env;
28
+ }
29
+ await (0, portManager_1.startPortManagerServer)();
30
+ await this.iterateDevServers(async (serverInterface) => {
31
+ if (serverInterface.setup) {
32
+ await serverInterface.setup({
33
+ components: projectNodes,
34
+ onUploadRequired,
35
+ promptUser: promptUtils_1.promptUser,
36
+ logger: logger_1.logger,
37
+ urls: {
38
+ api: (0, urls_1.getHubSpotApiOrigin)(env),
39
+ web: (0, urls_1.getHubSpotWebsiteOrigin)(env),
40
+ },
41
+ setActiveApp,
42
+ });
43
+ }
44
+ });
45
+ this.initialized = true;
46
+ }
47
+ async start({ accountId, projectConfig, }) {
48
+ if (this.initialized) {
49
+ await this.iterateDevServers(async (serverInterface) => {
50
+ if (serverInterface.start) {
51
+ await serverInterface.start({
52
+ accountId,
53
+ projectConfig,
54
+ requestPorts: portManager_1.requestPorts,
55
+ });
56
+ }
57
+ });
58
+ }
59
+ else {
60
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.notInitialized`));
61
+ }
62
+ this.started = true;
63
+ }
64
+ async fileChange({ filePath, event, }) {
65
+ if (this.started) {
66
+ this.iterateDevServers(async (serverInterface) => {
67
+ if (serverInterface.fileChange) {
68
+ await serverInterface.fileChange(filePath, event);
69
+ }
70
+ });
71
+ }
72
+ }
73
+ async cleanup() {
74
+ if (this.started) {
75
+ await this.iterateDevServers(async (serverInterface) => {
76
+ if (serverInterface.cleanup) {
77
+ await serverInterface.cleanup();
78
+ }
79
+ });
80
+ await (0, portManager_1.stopPortManagerServer)();
81
+ }
82
+ }
83
+ }
84
+ const Manager = new DevServerManagerV2();
85
+ exports.default = Manager;