@hubspot/cli 7.2.1-experimental.0 → 7.2.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 (122) hide show
  1. package/bin/cli.js +52 -3
  2. package/commands/account/auth.d.ts +10 -0
  3. package/commands/account/auth.js +154 -0
  4. package/commands/account/createOverride.d.ts +10 -0
  5. package/commands/account/createOverride.js +62 -0
  6. package/commands/account/list.js +4 -0
  7. package/commands/account.js +4 -0
  8. package/commands/auth.js +9 -5
  9. package/commands/config/migrate.d.ts +10 -0
  10. package/commands/config/migrate.js +86 -0
  11. package/commands/config/set.d.ts +12 -0
  12. package/commands/config/set.js +30 -29
  13. package/commands/config.d.ts +4 -1
  14. package/commands/config.js +45 -10
  15. package/commands/create/api-sample.js +4 -14
  16. package/commands/customObject/create.d.ts +0 -11
  17. package/commands/customObject/create.js +28 -37
  18. package/commands/customObject/schema/create.d.ts +0 -10
  19. package/commands/customObject/schema/create.js +42 -40
  20. package/commands/customObject/schema/delete.d.ts +0 -11
  21. package/commands/customObject/schema/delete.js +27 -34
  22. package/commands/customObject/schema/fetch-all.d.ts +0 -10
  23. package/commands/customObject/schema/fetch-all.js +24 -31
  24. package/commands/customObject/schema/fetch.d.ts +0 -11
  25. package/commands/customObject/schema/fetch.js +42 -34
  26. package/commands/customObject/schema/list.d.ts +0 -7
  27. package/commands/customObject/schema/list.js +14 -23
  28. package/commands/customObject/schema/update.d.ts +0 -11
  29. package/commands/customObject/schema/update.js +46 -44
  30. package/commands/customObject/schema.d.ts +1 -5
  31. package/commands/customObject/schema.js +11 -49
  32. package/commands/customObject.d.ts +1 -4
  33. package/commands/customObject.js +21 -54
  34. package/commands/filemanager/fetch.d.ts +0 -12
  35. package/commands/filemanager/fetch.js +30 -33
  36. package/commands/filemanager/upload.d.ts +0 -11
  37. package/commands/filemanager/upload.js +47 -53
  38. package/commands/filemanager.d.ts +1 -4
  39. package/commands/filemanager.js +7 -41
  40. package/commands/init.js +15 -26
  41. package/commands/project/add.js +16 -62
  42. package/commands/project/cloneApp.js +3 -3
  43. package/commands/project/create.js +15 -70
  44. package/commands/project/dev.d.ts +1 -0
  45. package/commands/project/dev.js +146 -0
  46. package/commands/project/migrateApp.js +3 -3
  47. package/commands/project/upload.js +2 -7
  48. package/commands/sandbox/create.d.ts +0 -12
  49. package/commands/sandbox/create.js +72 -90
  50. package/commands/sandbox/delete.d.ts +0 -11
  51. package/commands/sandbox/delete.js +95 -112
  52. package/commands/sandbox.d.ts +1 -4
  53. package/commands/sandbox.js +10 -44
  54. package/commands/theme/generate-selectors.d.ts +0 -9
  55. package/commands/theme/generate-selectors.js +43 -61
  56. package/commands/theme/marketplace-validate.d.ts +0 -10
  57. package/commands/theme/marketplace-validate.js +26 -32
  58. package/commands/theme/preview.d.ts +0 -16
  59. package/commands/theme/preview.js +97 -104
  60. package/commands/theme.d.ts +1 -4
  61. package/commands/theme.js +10 -44
  62. package/lang/en.lyaml +67 -40
  63. package/lib/LocalDevManager.d.ts +2 -2
  64. package/lib/buildAccount.d.ts +3 -2
  65. package/lib/configMigrate.d.ts +2 -0
  66. package/lib/configMigrate.js +83 -0
  67. package/lib/constants.d.ts +3 -12
  68. package/lib/constants.js +4 -13
  69. package/lib/doctor/Diagnosis.d.ts +1 -0
  70. package/lib/doctor/Diagnosis.js +7 -0
  71. package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -6
  72. package/lib/doctor/DiagnosticInfoBuilder.js +1 -5
  73. package/lib/doctor/Doctor.d.ts +1 -1
  74. package/lib/doctor/Doctor.js +14 -6
  75. package/lib/localDev.d.ts +1 -2
  76. package/lib/marketplaceValidate.d.ts +2 -2
  77. package/lib/projects/buildAndDeploy.js +1 -4
  78. package/lib/projects/index.d.ts +5 -1
  79. package/lib/projects/index.js +62 -1
  80. package/lib/projects/structure.d.ts +0 -4
  81. package/lib/projects/structure.js +0 -9
  82. package/lib/projects/upload.d.ts +1 -1
  83. package/lib/projects/upload.js +2 -2
  84. package/lib/prompts/accountNamePrompt.d.ts +1 -1
  85. package/lib/prompts/createProjectPrompt.d.ts +8 -6
  86. package/lib/prompts/createProjectPrompt.js +54 -26
  87. package/lib/prompts/projectAddPrompt.d.ts +3 -3
  88. package/lib/prompts/projectAddPrompt.js +6 -16
  89. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +2 -3
  90. package/lib/prompts/sandboxesPrompt.d.ts +2 -3
  91. package/lib/prompts/sandboxesPrompt.js +1 -1
  92. package/lib/sandboxSync.js +2 -6
  93. package/lib/sandboxes.d.ts +5 -2
  94. package/lib/ui/index.d.ts +1 -1
  95. package/lib/ui/index.js +0 -1
  96. package/lib/upload.d.ts +1 -1
  97. package/lib/upload.js +20 -20
  98. package/lib/usageTracking.d.ts +1 -1
  99. package/lib/validation.d.ts +1 -1
  100. package/package.json +4 -5
  101. package/types/Projects.d.ts +6 -1
  102. package/types/Prompts.d.ts +0 -7
  103. package/types/Sandboxes.d.ts +0 -2
  104. package/types/Yargs.d.ts +0 -8
  105. package/commands/project/dev/deprecatedFlow.d.ts +0 -5
  106. package/commands/project/dev/deprecatedFlow.js +0 -137
  107. package/commands/project/dev/index.d.ts +0 -6
  108. package/commands/project/dev/index.js +0 -52
  109. package/commands/project/dev/unifiedFlow.d.ts +0 -5
  110. package/commands/project/dev/unifiedFlow.js +0 -112
  111. package/lib/DevServerManagerV2.d.ts +0 -34
  112. package/lib/DevServerManagerV2.js +0 -85
  113. package/lib/LocalDevManagerV2.d.ts +0 -64
  114. package/lib/LocalDevManagerV2.js +0 -382
  115. package/lib/customObject.d.ts +0 -3
  116. package/lib/customObject.js +0 -15
  117. package/lib/projects/create.d.ts +0 -5
  118. package/lib/projects/create.js +0 -51
  119. package/lib/testUtils.d.ts +0 -12
  120. package/lib/testUtils.js +0 -10
  121. package/types/ProjectComponents.d.ts +0 -38
  122. package/types/ProjectComponents.js +0 -3
@@ -1,382 +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
- const path_1 = __importDefault(require("path"));
7
- const chokidar_1 = __importDefault(require("chokidar"));
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const logger_1 = require("@hubspot/local-dev-lib/logger");
10
- const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
11
- const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
12
- const config_1 = require("@hubspot/local-dev-lib/config");
13
- const constants_1 = require("./constants");
14
- const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
15
- const DevServerManagerV2_1 = __importDefault(require("./DevServerManagerV2"));
16
- const exitCodes_1 = require("./enums/exitCodes");
17
- const urls_1 = require("./projects/urls");
18
- const structure_1 = require("./projects/structure");
19
- const ui_1 = require("./ui");
20
- const index_1 = require("./errorHandlers/index");
21
- const installPublicAppPrompt_1 = require("./prompts/installPublicAppPrompt");
22
- const promptUtils_1 = require("./prompts/promptUtils");
23
- const lang_1 = require("./lang");
24
- const process_1 = require("./process");
25
- const WATCH_EVENTS = {
26
- add: 'add',
27
- change: 'change',
28
- unlink: 'unlink',
29
- unlinkDir: 'unlinkDir',
30
- };
31
- const i18nKey = 'lib.LocalDevManager';
32
- class LocalDevManagerV2 {
33
- targetProjectAccountId;
34
- targetTestingAccountId;
35
- projectConfig;
36
- projectDir;
37
- projectId;
38
- debug;
39
- deployedBuild;
40
- isGithubLinked;
41
- watcher;
42
- uploadWarnings;
43
- projectNodes;
44
- activeApp;
45
- activePublicAppData;
46
- env;
47
- publicAppActiveInstalls;
48
- projectSourceDir;
49
- mostRecentUploadWarning;
50
- constructor(options) {
51
- this.targetProjectAccountId = options.targetProjectAccountId;
52
- this.targetTestingAccountId = options.targetTestingAccountId;
53
- this.projectConfig = options.projectConfig;
54
- this.projectDir = options.projectDir;
55
- this.projectId = options.projectId;
56
- this.debug = options.debug || false;
57
- this.deployedBuild = options.deployedBuild;
58
- this.isGithubLinked = options.isGithubLinked;
59
- this.watcher = null;
60
- this.uploadWarnings = {};
61
- this.projectNodes = options.projectNodes;
62
- this.activeApp = null;
63
- this.activePublicAppData = null;
64
- this.env = options.env;
65
- this.publicAppActiveInstalls = null;
66
- this.mostRecentUploadWarning = null;
67
- this.projectSourceDir = path_1.default.join(this.projectDir, this.projectConfig.srcDir);
68
- if (!this.targetProjectAccountId ||
69
- !this.projectConfig ||
70
- !this.projectDir) {
71
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.failedToInitialize`));
72
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
73
- }
74
- }
75
- async setActiveApp(appUid) {
76
- if (!appUid) {
77
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.missingUid`, {
78
- devCommand: (0, ui_1.uiCommandReference)('hs project dev'),
79
- }));
80
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
81
- }
82
- const app = Object.values(this.projectNodes).find(component => component.uid === appUid) || null;
83
- if (app && (0, structure_1.isAppIRNode)(app)) {
84
- this.activeApp = app;
85
- if (app.config.distribution === constants_1.APP_DISTRIBUTION_TYPES.MARKETPLACE) {
86
- try {
87
- await this.setActivePublicAppData();
88
- await this.checkActivePublicAppInstalls();
89
- await this.checkPublicAppInstallation();
90
- }
91
- catch (e) {
92
- (0, index_1.logError)(e);
93
- }
94
- }
95
- }
96
- return;
97
- }
98
- async setActivePublicAppData() {
99
- const { data: { results: portalPublicApps }, } = await (0, appsDev_1.fetchPublicAppsForPortal)(this.targetProjectAccountId);
100
- const activePublicAppData = portalPublicApps.find(({ sourceId }) => sourceId === this.activeApp?.uid);
101
- if (!activePublicAppData) {
102
- return;
103
- }
104
- const { data: { uniquePortalInstallCount }, } = await (0, appsDev_1.fetchPublicAppProductionInstallCounts)(activePublicAppData.id, this.targetProjectAccountId);
105
- this.activePublicAppData = activePublicAppData;
106
- this.publicAppActiveInstalls = uniquePortalInstallCount;
107
- }
108
- async checkActivePublicAppInstalls() {
109
- if (!this.activePublicAppData ||
110
- !this.publicAppActiveInstalls ||
111
- this.publicAppActiveInstalls < 1) {
112
- return;
113
- }
114
- (0, ui_1.uiLine)();
115
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.activeInstallWarning.installCount`, {
116
- appName: this.activePublicAppData.name,
117
- installCount: this.publicAppActiveInstalls,
118
- installText: this.publicAppActiveInstalls === 1 ? 'install' : 'installs',
119
- }));
120
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.activeInstallWarning.explanation`));
121
- (0, ui_1.uiLine)();
122
- const proceed = await (0, promptUtils_1.confirmPrompt)((0, lang_1.i18n)(`${i18nKey}.activeInstallWarning.confirmationPrompt`), { defaultAnswer: false });
123
- if (!proceed) {
124
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
125
- }
126
- }
127
- async start() {
128
- SpinniesManager_1.default.stopAll();
129
- SpinniesManager_1.default.init();
130
- // Local dev currently relies on the existence of a deployed build in the target account
131
- if (!this.deployedBuild) {
132
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.noDeployedBuild`, {
133
- projectName: this.projectConfig.name,
134
- accountIdentifier: (0, ui_1.uiAccountDescription)(this.targetProjectAccountId),
135
- uploadCommand: this.getUploadCommand(),
136
- }));
137
- logger_1.logger.log();
138
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
139
- }
140
- const setupSucceeded = await this.devServerSetup();
141
- if (!setupSucceeded) {
142
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
143
- }
144
- else if (!this.debug) {
145
- console.clear();
146
- }
147
- (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.betaMessage`));
148
- logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.learnMoreLocalDevServer`), 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
149
- logger_1.logger.log();
150
- logger_1.logger.log(chalk_1.default.hex(ui_1.UI_COLORS.SORBET)((0, lang_1.i18n)(`${i18nKey}.running`, {
151
- accountIdentifier: (0, ui_1.uiAccountDescription)(this.targetProjectAccountId),
152
- projectName: this.projectConfig.name,
153
- })));
154
- logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.viewProjectLink`), (0, urls_1.getProjectDetailUrl)(this.projectConfig.name, this.targetProjectAccountId) || ''));
155
- logger_1.logger.log();
156
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.quitHelper`));
157
- (0, ui_1.uiLine)();
158
- logger_1.logger.log();
159
- await this.devServerStart();
160
- // Initialize project file watcher to detect configuration file changes
161
- this.startWatching();
162
- this.updateKeypressListeners();
163
- this.monitorConsoleOutput();
164
- // Verify that there are no mismatches between components in the local project
165
- // and components in the deployed build of the project.
166
- this.compareLocalProjectToDeployed();
167
- }
168
- async stop(showProgress = true) {
169
- if (showProgress) {
170
- SpinniesManager_1.default.add('cleanupMessage', {
171
- text: (0, lang_1.i18n)(`${i18nKey}.exitingStart`),
172
- });
173
- }
174
- await this.stopWatching();
175
- const cleanupSucceeded = await this.devServerCleanup();
176
- if (!cleanupSucceeded) {
177
- if (showProgress) {
178
- SpinniesManager_1.default.fail('cleanupMessage', {
179
- text: (0, lang_1.i18n)(`${i18nKey}.exitingFail`),
180
- });
181
- }
182
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
183
- }
184
- if (showProgress) {
185
- SpinniesManager_1.default.succeed('cleanupMessage', {
186
- text: (0, lang_1.i18n)(`${i18nKey}.exitingSucceed`),
187
- });
188
- }
189
- process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
190
- }
191
- async checkPublicAppInstallation() {
192
- if (!this.activeApp || !this.activePublicAppData) {
193
- return;
194
- }
195
- const { data: { isInstalledWithScopeGroups, previouslyAuthorizedScopeGroups }, } = await (0, localDevAuth_1.fetchAppInstallationData)(this.targetTestingAccountId, this.projectId, this.activeApp.uid, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.optionalScopes);
196
- const isReinstall = previouslyAuthorizedScopeGroups.length > 0;
197
- if (!isInstalledWithScopeGroups) {
198
- await (0, installPublicAppPrompt_1.installPublicAppPrompt)(this.env, this.targetTestingAccountId, this.activePublicAppData.clientId, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.redirectUrls, isReinstall);
199
- }
200
- }
201
- updateKeypressListeners() {
202
- (0, process_1.handleKeypress)(async (key) => {
203
- if ((key.ctrl && key.name === 'c') || key.name === 'q') {
204
- this.stop();
205
- }
206
- });
207
- }
208
- getUploadCommand() {
209
- const currentDefaultAccount = (0, config_1.getConfigDefaultAccount)() || undefined;
210
- return this.targetProjectAccountId !== (0, config_1.getAccountId)(currentDefaultAccount)
211
- ? (0, ui_1.uiCommandReference)(`hs project upload --account=${this.targetProjectAccountId}`)
212
- : (0, ui_1.uiCommandReference)('hs project upload');
213
- }
214
- logUploadWarning(reason) {
215
- let warning;
216
- if (reason) {
217
- warning = reason;
218
- }
219
- else {
220
- warning =
221
- this.publicAppActiveInstalls && this.publicAppActiveInstalls > 0
222
- ? (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultPublicAppWarning`, {
223
- installCount: this.publicAppActiveInstalls,
224
- installText: this.publicAppActiveInstalls === 1 ? 'install' : 'installs',
225
- })
226
- : (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultWarning`);
227
- }
228
- // Avoid logging the warning to the console if it is currently the most
229
- // recently logged warning. We do not want to spam the console with the same message.
230
- if (!this.uploadWarnings[warning]) {
231
- logger_1.logger.log();
232
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.uploadWarning.header`, { warning }));
233
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.stopDev`, {
234
- command: (0, ui_1.uiCommandReference)('hs project dev'),
235
- }));
236
- if (this.isGithubLinked) {
237
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.pushToGithub`));
238
- }
239
- else {
240
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.runUpload`, {
241
- command: this.getUploadCommand(),
242
- }));
243
- }
244
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.restartDev`, {
245
- command: (0, ui_1.uiCommandReference)('hs project dev'),
246
- }));
247
- this.mostRecentUploadWarning = warning;
248
- this.uploadWarnings[warning] = true;
249
- }
250
- }
251
- monitorConsoleOutput() {
252
- const originalStdoutWrite = process.stdout.write.bind(process.stdout);
253
- function customStdoutWrite(chunk, encoding, callback) {
254
- // Reset the most recently logged warning
255
- if (this.mostRecentUploadWarning &&
256
- this.uploadWarnings[this.mostRecentUploadWarning]) {
257
- delete this.uploadWarnings[this.mostRecentUploadWarning];
258
- }
259
- if (typeof encoding === 'function') {
260
- return originalStdoutWrite(chunk, callback);
261
- }
262
- return originalStdoutWrite(chunk, encoding, callback);
263
- }
264
- customStdoutWrite.bind(this);
265
- process.stdout.write = customStdoutWrite;
266
- }
267
- compareLocalProjectToDeployed() {
268
- const deployedComponentNames = this.deployedBuild.subbuildStatuses.map(subbuildStatus => subbuildStatus.buildName);
269
- const missingProjectNodes = [];
270
- Object.values(this.projectNodes).forEach(node => {
271
- if ((0, structure_1.isAppIRNode)(node) || (0, structure_1.isCardIRNode)(node)) {
272
- if (!deployedComponentNames.includes(node.uid)) {
273
- missingProjectNodes.push(`${(0, lang_1.i18n)(`${i18nKey}.uploadWarning.appLabel`)} ${node.uid}`);
274
- }
275
- }
276
- });
277
- if (missingProjectNodes.length) {
278
- this.logUploadWarning((0, lang_1.i18n)(`${i18nKey}.uploadWarning.missingComponents`, {
279
- missingComponents: missingProjectNodes.join(', '),
280
- }));
281
- }
282
- }
283
- startWatching() {
284
- this.watcher = chokidar_1.default.watch(this.projectDir, {
285
- ignoreInitial: true,
286
- });
287
- const configPaths = Object.values(this.projectNodes)
288
- .filter(structure_1.isAppIRNode)
289
- .map(component => component.localDev.componentConfigPath);
290
- const projectConfigPath = path_1.default.join(this.projectDir, constants_1.PROJECT_CONFIG_FILE);
291
- configPaths.push(projectConfigPath);
292
- this.watcher.on('add', filePath => {
293
- this.handleWatchEvent(filePath, WATCH_EVENTS.add, configPaths);
294
- });
295
- this.watcher.on('change', filePath => {
296
- this.handleWatchEvent(filePath, WATCH_EVENTS.change, configPaths);
297
- });
298
- this.watcher.on('unlink', filePath => {
299
- this.handleWatchEvent(filePath, WATCH_EVENTS.unlink, configPaths);
300
- });
301
- this.watcher.on('unlinkDir', filePath => {
302
- this.handleWatchEvent(filePath, WATCH_EVENTS.unlinkDir, configPaths);
303
- });
304
- }
305
- async stopWatching() {
306
- await this.watcher?.close();
307
- }
308
- handleWatchEvent(filePath, event, configPaths) {
309
- if (configPaths.includes(filePath)) {
310
- this.logUploadWarning();
311
- }
312
- else {
313
- this.devServerFileChange(filePath, event);
314
- }
315
- }
316
- async devServerSetup() {
317
- try {
318
- await DevServerManagerV2_1.default.setup({
319
- projectNodes: this.projectNodes,
320
- onUploadRequired: this.logUploadWarning.bind(this),
321
- accountId: this.targetTestingAccountId,
322
- setActiveApp: this.setActiveApp.bind(this),
323
- });
324
- return true;
325
- }
326
- catch (e) {
327
- if (this.debug) {
328
- logger_1.logger.error(e);
329
- }
330
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.setupError`, {
331
- message: e instanceof Error ? e.message : '',
332
- }));
333
- return false;
334
- }
335
- }
336
- async devServerStart() {
337
- try {
338
- await DevServerManagerV2_1.default.start({
339
- accountId: this.targetTestingAccountId,
340
- projectConfig: this.projectConfig,
341
- });
342
- }
343
- catch (e) {
344
- if (this.debug) {
345
- logger_1.logger.error(e);
346
- }
347
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.startError`, {
348
- message: e instanceof Error ? e.message : '',
349
- }));
350
- process.exit(exitCodes_1.EXIT_CODES.ERROR);
351
- }
352
- }
353
- devServerFileChange(filePath, event) {
354
- try {
355
- DevServerManagerV2_1.default.fileChange({ filePath, event });
356
- }
357
- catch (e) {
358
- if (this.debug) {
359
- logger_1.logger.error(e);
360
- }
361
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.fileChangeError`, {
362
- message: e instanceof Error ? e.message : '',
363
- }));
364
- }
365
- }
366
- async devServerCleanup() {
367
- try {
368
- await DevServerManagerV2_1.default.cleanup();
369
- return true;
370
- }
371
- catch (e) {
372
- if (this.debug) {
373
- logger_1.logger.error(e);
374
- }
375
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.cleanupError`, {
376
- message: e instanceof Error ? e.message : '',
377
- }));
378
- return false;
379
- }
380
- }
381
- }
382
- exports.default = LocalDevManagerV2;
@@ -1,3 +0,0 @@
1
- import { SchemaDefinition, ObjectDefinition } from '@hubspot/local-dev-lib/types/Schemas';
2
- export declare function isSchemaDefinition(schema: unknown): schema is SchemaDefinition;
3
- export declare function isObjectDefinition(object: unknown): object is ObjectDefinition;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSchemaDefinition = isSchemaDefinition;
4
- exports.isObjectDefinition = isObjectDefinition;
5
- function isSchemaDefinition(schema) {
6
- return (typeof schema === 'object' &&
7
- schema !== null &&
8
- 'labels' in schema &&
9
- 'name' in schema &&
10
- 'properties' in schema &&
11
- 'requiredProperties' in schema);
12
- }
13
- function isObjectDefinition(object) {
14
- return typeof object === 'object' && object !== null && 'inputs' in object;
15
- }
@@ -1,5 +0,0 @@
1
- import { RepoPath } from '@hubspot/local-dev-lib/types/Github';
2
- import { ProjectTemplate, ComponentTemplate } from '../../types/Projects';
3
- export declare const EMPTY_PROJECT_TEMPLATE_NAME = "no-template";
4
- export declare function getProjectComponentListFromRepo(githubRef: string): Promise<ComponentTemplate[]>;
5
- export declare function getProjectTemplateListFromRepo(templateSource: RepoPath, githubRef: string): Promise<ProjectTemplate[]>;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EMPTY_PROJECT_TEMPLATE_NAME = void 0;
4
- exports.getProjectComponentListFromRepo = getProjectComponentListFromRepo;
5
- exports.getProjectTemplateListFromRepo = getProjectTemplateListFromRepo;
6
- const logger_1 = require("@hubspot/local-dev-lib/logger");
7
- const github_1 = require("@hubspot/local-dev-lib/api/github");
8
- const constants_1 = require("../constants");
9
- const exitCodes_1 = require("../enums/exitCodes");
10
- const lang_1 = require("../lang");
11
- const index_1 = require("../errorHandlers/index");
12
- const i18nKey = 'lib.projects.create';
13
- exports.EMPTY_PROJECT_TEMPLATE_NAME = 'no-template';
14
- const PROJECT_TEMPLATE_PROPERTIES = ['name', 'label', 'path', 'insertPath'];
15
- async function getProjectComponentListFromRepo(githubRef) {
16
- let config;
17
- try {
18
- const { data } = await (0, github_1.fetchRepoFile)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', githubRef);
19
- config = data;
20
- }
21
- catch (err) {
22
- (0, index_1.debugError)(err);
23
- }
24
- if (config) {
25
- return config[constants_1.PROJECT_COMPONENT_TYPES.COMPONENTS] || [];
26
- }
27
- return [];
28
- }
29
- async function getProjectTemplateListFromRepo(templateSource, githubRef) {
30
- let config;
31
- try {
32
- const { data } = await (0, github_1.fetchRepoFile)(templateSource, 'config.json', githubRef);
33
- config = data;
34
- }
35
- catch (e) {
36
- (0, index_1.debugError)(e);
37
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.missingConfigFileTemplateSource`));
38
- return process.exit(exitCodes_1.EXIT_CODES.ERROR);
39
- }
40
- if (!config || !config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS]) {
41
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noProjectsInConfig`));
42
- return process.exit(exitCodes_1.EXIT_CODES.ERROR);
43
- }
44
- const templates = config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS];
45
- const templatesContainAllProperties = templates.every(config => PROJECT_TEMPLATE_PROPERTIES.every(p => Object.prototype.hasOwnProperty.call(config, p)));
46
- if (!templatesContainAllProperties) {
47
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.missingPropertiesInConfig`));
48
- return process.exit(exitCodes_1.EXIT_CODES.ERROR);
49
- }
50
- return templates;
51
- }
@@ -1,12 +0,0 @@
1
- import { HubSpotHttpError } from '@hubspot/local-dev-lib/models/HubSpotHttpError';
2
- type MockResponse = {
3
- status: number;
4
- data: {
5
- message?: string;
6
- errorType?: string;
7
- category?: string;
8
- subCategory?: string;
9
- };
10
- };
11
- export declare const makeHubSpotHttpError: (message: string, response: MockResponse) => HubSpotHttpError;
12
- export {};
package/lib/testUtils.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeHubSpotHttpError = void 0;
4
- const HubSpotHttpError_1 = require("@hubspot/local-dev-lib/models/HubSpotHttpError");
5
- const makeHubSpotHttpError = (message, response) => {
6
- return new HubSpotHttpError_1.HubSpotHttpError(message, {
7
- cause: { isAxiosError: true, response },
8
- });
9
- };
10
- exports.makeHubSpotHttpError = makeHubSpotHttpError;
@@ -1,38 +0,0 @@
1
- import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
2
- import { IR_COMPONENT_TYPES, APP_DISTRIBUTION_TYPES, APP_AUTH_TYPES } from '../lib/constants';
3
- import { ValueOf } from '@hubspot/local-dev-lib/types/Utils';
4
- type AppDistributionType = ValueOf<typeof APP_DISTRIBUTION_TYPES>;
5
- type AppAuthType = ValueOf<typeof APP_AUTH_TYPES>;
6
- type AppConfig = {
7
- description: string;
8
- name: string;
9
- logo: string;
10
- distribution: AppDistributionType;
11
- auth: {
12
- type: AppAuthType;
13
- redirectUrls: string[];
14
- requiredScopes: string[];
15
- optionalScopes: string[];
16
- conditionallyRequiredScopes: string[];
17
- };
18
- };
19
- type CardConfig = {
20
- name: string;
21
- description: string;
22
- previewImage: {
23
- file: string;
24
- altText: string;
25
- };
26
- entrypoint: string;
27
- location: string;
28
- objectTypes: string[];
29
- };
30
- export interface AppIRNode extends IntermediateRepresentationNodeLocalDev {
31
- componentType: typeof IR_COMPONENT_TYPES.APPLICATION;
32
- config: AppConfig;
33
- }
34
- export interface CardIRNode extends IntermediateRepresentationNodeLocalDev {
35
- componentType: typeof IR_COMPONENT_TYPES.CARD;
36
- config: CardConfig;
37
- }
38
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- // These types are for Unified Apps and projects on platform version 2025.1 and above
3
- Object.defineProperty(exports, "__esModule", { value: true });