@hubspot/cms-dev-server 1.2.76 → 1.2.78

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.
package/dist/run.js CHANGED
@@ -1,4 +1,2110 @@
1
1
  #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // node_modules/inquirer/lib/utils/events.js
13
+ import { fromEvent, filter, map, share, takeUntil } from "rxjs";
14
+ function normalizeKeypressEvents(value, key) {
15
+ return { value, key: key || {} };
16
+ }
17
+ function observe(rl) {
18
+ const keypress = fromEvent(rl.input, "keypress", normalizeKeypressEvents).pipe(takeUntil(fromEvent(rl, "close"))).pipe(filter(({ key }) => key.name !== "enter" && key.name !== "return"));
19
+ return {
20
+ line: fromEvent(rl, "line"),
21
+ keypress,
22
+ normalizedUpKey: keypress.pipe(
23
+ filter(
24
+ ({ key }) => key.name === "up" || key.name === "k" || key.name === "p" && key.ctrl
25
+ ),
26
+ share()
27
+ ),
28
+ normalizedDownKey: keypress.pipe(
29
+ filter(
30
+ ({ key }) => key.name === "down" || key.name === "j" || key.name === "n" && key.ctrl
31
+ ),
32
+ share()
33
+ ),
34
+ numberKey: keypress.pipe(
35
+ filter((e) => e.value && "123456789".includes(e.value)),
36
+ map((e) => Number(e.value)),
37
+ share()
38
+ ),
39
+ spaceKey: keypress.pipe(
40
+ filter(({ key }) => key && key.name === "space"),
41
+ share()
42
+ ),
43
+ aKey: keypress.pipe(
44
+ filter(({ key }) => key && key.name === "a"),
45
+ share()
46
+ ),
47
+ iKey: keypress.pipe(
48
+ filter(({ key }) => key && key.name === "i"),
49
+ share()
50
+ )
51
+ };
52
+ }
53
+ var init_events = __esm({
54
+ "node_modules/inquirer/lib/utils/events.js"() {
55
+ }
56
+ });
57
+
58
+ // node_modules/inquirer/lib/utils/paginator.js
59
+ import colors from "yoctocolors-cjs";
60
+ var Paginator;
61
+ var init_paginator = __esm({
62
+ "node_modules/inquirer/lib/utils/paginator.js"() {
63
+ Paginator = class {
64
+ /**
65
+ * @param {import("./screen-manager")} [screen]
66
+ * @param {{isInfinite?: boolean}} [options]
67
+ */
68
+ constructor(screen, options = {}) {
69
+ const { isInfinite = true } = options;
70
+ this.lastIndex = 0;
71
+ this.screen = screen;
72
+ this.isInfinite = isInfinite;
73
+ }
74
+ paginate(output, active, pageSize) {
75
+ pageSize ||= 7;
76
+ let lines = output.split("\n");
77
+ if (this.screen) {
78
+ lines = this.screen.breakLines(lines);
79
+ active = lines.map((lineParts) => lineParts.length).splice(0, active).reduce((a, b) => a + b, 0);
80
+ lines = lines.flat();
81
+ }
82
+ if (lines.length <= pageSize) {
83
+ return output;
84
+ }
85
+ const visibleLines = this.isInfinite ? this.getInfiniteLines(lines, active, pageSize) : this.getFiniteLines(lines, active, pageSize);
86
+ this.lastIndex = active;
87
+ return visibleLines.join("\n") + "\n" + colors.dim("(Move up and down to reveal more choices)");
88
+ }
89
+ getInfiniteLines(lines, active, pageSize) {
90
+ if (this.pointer === void 0) {
91
+ this.pointer = 0;
92
+ }
93
+ const middleOfList = Math.floor(pageSize / 2);
94
+ if (this.pointer < middleOfList && this.lastIndex < active && active - this.lastIndex < pageSize) {
95
+ this.pointer = Math.min(middleOfList, this.pointer + active - this.lastIndex);
96
+ }
97
+ const infinite = [lines, lines, lines].flat();
98
+ const topIndex = Math.max(0, active + lines.length - this.pointer);
99
+ return infinite.splice(topIndex, pageSize);
100
+ }
101
+ getFiniteLines(lines, active, pageSize) {
102
+ let topIndex = active - pageSize / 2;
103
+ if (topIndex < 0) {
104
+ topIndex = 0;
105
+ } else if (topIndex + pageSize > lines.length) {
106
+ topIndex = lines.length - pageSize;
107
+ }
108
+ return lines.splice(topIndex, pageSize);
109
+ }
110
+ };
111
+ }
112
+ });
113
+
114
+ // node_modules/inquirer/lib/utils/incrementListIndex.js
115
+ function incrementListIndex(current, dir, opt) {
116
+ const len = opt.choices.realLength;
117
+ const shouldLoop = "loop" in opt ? Boolean(opt.loop) : true;
118
+ if (dir === "up") {
119
+ if (current > 0) {
120
+ return current - 1;
121
+ }
122
+ return shouldLoop ? len - 1 : current;
123
+ }
124
+ if (dir === "down") {
125
+ if (current < len - 1) {
126
+ return current + 1;
127
+ }
128
+ return shouldLoop ? 0 : current;
129
+ }
130
+ throw new Error("dir must be up or down");
131
+ }
132
+ var init_incrementListIndex = __esm({
133
+ "node_modules/inquirer/lib/utils/incrementListIndex.js"() {
134
+ }
135
+ });
136
+
137
+ // node_modules/inquirer/lib/objects/separator.js
138
+ import colors2 from "yoctocolors-cjs";
139
+ import figures from "@inquirer/figures";
140
+ var Separator;
141
+ var init_separator = __esm({
142
+ "node_modules/inquirer/lib/objects/separator.js"() {
143
+ Separator = class {
144
+ constructor(line) {
145
+ this.type = "separator";
146
+ this.line = colors2.dim(line || Array.from({ length: 15 }).join(figures.line));
147
+ }
148
+ /**
149
+ * Helper function returning false if object is a separator
150
+ * @param {Object} obj object to test against
151
+ * @return {Boolean} `false` if object is a separator
152
+ */
153
+ static exclude(obj) {
154
+ return obj.type !== "separator";
155
+ }
156
+ /**
157
+ * Stringify separator
158
+ * @return {String} the separator display string
159
+ */
160
+ toString() {
161
+ return this.line;
162
+ }
163
+ };
164
+ }
165
+ });
166
+
167
+ // node_modules/inquirer/lib/objects/choice.js
168
+ var Choice;
169
+ var init_choice = __esm({
170
+ "node_modules/inquirer/lib/objects/choice.js"() {
171
+ Choice = class {
172
+ constructor(val, answers) {
173
+ if (val instanceof Choice || val.type === "separator") {
174
+ return val;
175
+ }
176
+ if (typeof val === "string" || typeof val === "number") {
177
+ this.name = String(val);
178
+ this.value = val;
179
+ this.short = String(val);
180
+ } else {
181
+ Object.assign(this, val, {
182
+ name: val.name || val.value,
183
+ value: "value" in val ? val.value : val.name,
184
+ short: val.short || val.name || val.value
185
+ });
186
+ }
187
+ this.disabled = typeof val.disabled === "function" ? val.disabled(answers) : val.disabled;
188
+ }
189
+ };
190
+ }
191
+ });
192
+
193
+ // node_modules/inquirer/lib/objects/choices.js
194
+ import assert from "node:assert";
195
+ var Choices;
196
+ var init_choices = __esm({
197
+ "node_modules/inquirer/lib/objects/choices.js"() {
198
+ init_separator();
199
+ init_choice();
200
+ Choices = class {
201
+ /** @param {Array} choices All `choice` to keep in the collection */
202
+ constructor(choices, answers) {
203
+ this.choices = choices.map((val) => {
204
+ if (val.type === "separator") {
205
+ if (!(val instanceof Separator)) {
206
+ val = new Separator(val.line);
207
+ }
208
+ return val;
209
+ }
210
+ return new Choice(val, answers);
211
+ });
212
+ this.realChoices = this.choices.filter(Separator.exclude).filter((item) => !item.disabled);
213
+ Object.defineProperty(this, "length", {
214
+ get() {
215
+ return this.choices.length;
216
+ },
217
+ set(val) {
218
+ this.choices.length = val;
219
+ }
220
+ });
221
+ Object.defineProperty(this, "realLength", {
222
+ get() {
223
+ return this.realChoices.length;
224
+ },
225
+ set() {
226
+ throw new Error("Cannot set `realLength` of a Choices collection");
227
+ }
228
+ });
229
+ }
230
+ [Symbol.iterator]() {
231
+ const data = this.choices;
232
+ let index = -1;
233
+ return {
234
+ next: () => ({ value: data[++index], done: !(index in data) })
235
+ };
236
+ }
237
+ /**
238
+ * Get a valid choice from the collection
239
+ * @param {Number} selector The selected choice index
240
+ * @return {Choice|Undefined} Return the matched choice or undefined
241
+ */
242
+ getChoice(selector) {
243
+ assert(typeof selector === "number");
244
+ return this.realChoices[selector];
245
+ }
246
+ /**
247
+ * Get a raw element from the collection
248
+ * @param {Number} selector The selected index value
249
+ * @return {Choice|Undefined} Return the matched choice or undefined
250
+ */
251
+ get(selector) {
252
+ assert(typeof selector === "number");
253
+ return this.choices[selector];
254
+ }
255
+ /**
256
+ * Match the valid choices against a where clause
257
+ * @param {Function|Object} whereClause filter function or key-value object to match against
258
+ * @return {Array} Matching choices or empty array
259
+ */
260
+ where(whereClause) {
261
+ let filterFn;
262
+ if (typeof whereClause === "function") {
263
+ filterFn = whereClause;
264
+ } else {
265
+ const [key, value] = Object.entries(whereClause)[0];
266
+ filterFn = (choice) => choice[key] === value;
267
+ }
268
+ return this.realChoices.filter(filterFn);
269
+ }
270
+ /**
271
+ * Pluck a particular key from the choices
272
+ * @param {String} propertyName Property name to select
273
+ * @return {Array} Selected properties
274
+ */
275
+ pluck(propertyName) {
276
+ return this.realChoices.map((choice) => choice[propertyName]);
277
+ }
278
+ // Expose usual Array methods
279
+ indexOf(...args) {
280
+ return this.choices.indexOf(...args);
281
+ }
282
+ forEach(...args) {
283
+ return this.choices.forEach(...args);
284
+ }
285
+ filter(...args) {
286
+ return this.choices.filter(...args);
287
+ }
288
+ reduce(...args) {
289
+ return this.choices.reduce(...args);
290
+ }
291
+ find(func) {
292
+ return this.choices.find(func);
293
+ }
294
+ some(func) {
295
+ return this.choices.some(func);
296
+ }
297
+ push(...args) {
298
+ const objs = args.map((val) => new Choice(val));
299
+ this.choices.push(...objs);
300
+ this.realChoices = this.choices.filter(Separator.exclude).filter((item) => !item.disabled);
301
+ return this.choices;
302
+ }
303
+ };
304
+ }
305
+ });
306
+
307
+ // node_modules/inquirer/lib/utils/readline.js
308
+ import ansiEscapes from "ansi-escapes";
309
+ var left, right, up, down, clearLine;
310
+ var init_readline = __esm({
311
+ "node_modules/inquirer/lib/utils/readline.js"() {
312
+ left = function(rl, x) {
313
+ rl.output.write(ansiEscapes.cursorBackward(x));
314
+ };
315
+ right = function(rl, x) {
316
+ rl.output.write(ansiEscapes.cursorForward(x));
317
+ };
318
+ up = function(rl, x) {
319
+ rl.output.write(ansiEscapes.cursorUp(x));
320
+ };
321
+ down = function(rl, x) {
322
+ rl.output.write(ansiEscapes.cursorDown(x));
323
+ };
324
+ clearLine = function(rl, len) {
325
+ rl.output.write(ansiEscapes.eraseLines(len));
326
+ };
327
+ }
328
+ });
329
+
330
+ // node_modules/inquirer/lib/utils/screen-manager.js
331
+ import ansiEscapes2 from "ansi-escapes";
332
+ import cliWidth from "cli-width";
333
+ import wrapAnsi from "wrap-ansi";
334
+ import stripAnsi from "strip-ansi";
335
+ import stringWidth from "string-width";
336
+ import ora from "ora";
337
+ function height(content) {
338
+ return content.split("\n").length;
339
+ }
340
+ function lastLine(content) {
341
+ return content.split("\n").pop();
342
+ }
343
+ var ScreenManager;
344
+ var init_screen_manager = __esm({
345
+ "node_modules/inquirer/lib/utils/screen-manager.js"() {
346
+ init_readline();
347
+ ScreenManager = class {
348
+ constructor(rl) {
349
+ this.height = 0;
350
+ this.extraLinesUnderPrompt = 0;
351
+ this.rl = rl;
352
+ }
353
+ renderWithSpinner(content, bottomContent) {
354
+ if (this.spinnerId) {
355
+ clearInterval(this.spinnerId);
356
+ }
357
+ let spinner;
358
+ let contentFunc;
359
+ let bottomContentFunc;
360
+ if (bottomContent) {
361
+ spinner = ora(bottomContent);
362
+ contentFunc = () => content;
363
+ bottomContentFunc = () => spinner.frame();
364
+ } else {
365
+ spinner = ora(content);
366
+ contentFunc = () => spinner.frame();
367
+ bottomContentFunc = () => "";
368
+ }
369
+ this.spinnerId = setInterval(
370
+ () => this.render(contentFunc(), bottomContentFunc(), true),
371
+ spinner.interval
372
+ );
373
+ }
374
+ render(content, bottomContent, spinning = false) {
375
+ if (this.spinnerId && !spinning) {
376
+ clearInterval(this.spinnerId);
377
+ }
378
+ this.rl.output.unmute();
379
+ this.clean(this.extraLinesUnderPrompt);
380
+ const promptLine = lastLine(content);
381
+ const rawPromptLine = stripAnsi(promptLine);
382
+ let prompt2 = rawPromptLine;
383
+ if (this.rl.line.length > 0) {
384
+ prompt2 = prompt2.slice(0, -this.rl.line.length);
385
+ }
386
+ this.rl.setPrompt(prompt2);
387
+ const cursorPos = this.rl._getCursorPos();
388
+ const width = this.normalizedCliWidth();
389
+ content = this.forceLineReturn(content, width);
390
+ bottomContent &&= this.forceLineReturn(bottomContent, width);
391
+ if (rawPromptLine.length % width === 0) {
392
+ content += "\n";
393
+ }
394
+ const fullContent = content + (bottomContent ? "\n" + bottomContent : "");
395
+ this.rl.output.write(fullContent);
396
+ const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - cursorPos.rows;
397
+ const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
398
+ if (bottomContentHeight > 0) {
399
+ up(this.rl, bottomContentHeight);
400
+ }
401
+ left(this.rl, stringWidth(lastLine(fullContent)));
402
+ if (cursorPos.cols > 0) {
403
+ right(this.rl, cursorPos.cols);
404
+ }
405
+ this.extraLinesUnderPrompt = bottomContentHeight;
406
+ this.height = height(fullContent);
407
+ this.rl.output.mute();
408
+ }
409
+ clean(extraLines) {
410
+ if (extraLines > 0) {
411
+ down(this.rl, extraLines);
412
+ }
413
+ clearLine(this.rl, this.height);
414
+ }
415
+ done() {
416
+ this.rl.setPrompt("");
417
+ this.rl.output.unmute();
418
+ this.rl.output.write(`
419
+ ${ansiEscapes2.cursorShow}`);
420
+ }
421
+ releaseCursor() {
422
+ if (this.extraLinesUnderPrompt > 0) {
423
+ down(this.rl, this.extraLinesUnderPrompt);
424
+ }
425
+ }
426
+ normalizedCliWidth() {
427
+ const width = cliWidth({
428
+ defaultWidth: 80,
429
+ output: this.rl.output
430
+ });
431
+ return width;
432
+ }
433
+ /**
434
+ * @param {string[]} lines
435
+ */
436
+ breakLines(lines, width = this.normalizedCliWidth()) {
437
+ return lines.map(
438
+ (line) => wrapAnsi(line, width, { trim: false, hard: true }).split("\n")
439
+ );
440
+ }
441
+ /**
442
+ * @param {string} content
443
+ */
444
+ forceLineReturn(content, width = this.normalizedCliWidth()) {
445
+ return this.breakLines(content.split("\n"), width).flat().join("\n");
446
+ }
447
+ };
448
+ }
449
+ });
450
+
451
+ // node_modules/inquirer/lib/prompts/base.js
452
+ import colors3 from "yoctocolors-cjs";
453
+ import runAsync from "run-async";
454
+ import { filter as filter2, mergeMap, share as share2, take, takeUntil as takeUntil2 } from "rxjs";
455
+ var Prompt;
456
+ var init_base = __esm({
457
+ "node_modules/inquirer/lib/prompts/base.js"() {
458
+ init_choices();
459
+ init_screen_manager();
460
+ Prompt = class {
461
+ constructor(question, rl, answers) {
462
+ Object.assign(this, {
463
+ answers,
464
+ status: "pending"
465
+ });
466
+ this.opt = {
467
+ validate: () => true,
468
+ validatingText: "",
469
+ filter: (val) => val,
470
+ filteringText: "",
471
+ when: () => true,
472
+ suffix: "",
473
+ prefix: colors3.green("?"),
474
+ transformer: (val) => val,
475
+ ...question
476
+ };
477
+ if (!this.opt.name) {
478
+ this.throwParamError("name");
479
+ }
480
+ this.opt.message ||= this.opt.name + ":";
481
+ if (Array.isArray(this.opt.choices)) {
482
+ this.opt.choices = new Choices(this.opt.choices, answers);
483
+ }
484
+ this.rl = rl;
485
+ this.screen = new ScreenManager(this.rl);
486
+ }
487
+ /**
488
+ * Start the Inquiry session and manage output value filtering
489
+ * @return {Promise}
490
+ */
491
+ run() {
492
+ return new Promise((resolve3, reject) => {
493
+ this._run(
494
+ (value) => resolve3(value),
495
+ (error) => reject(error)
496
+ );
497
+ });
498
+ }
499
+ // Default noop (this one should be overwritten in prompts)
500
+ _run(cb) {
501
+ cb();
502
+ }
503
+ /**
504
+ * Throw an error telling a required parameter is missing
505
+ * @param {String} name Name of the missing param
506
+ * @return {Throw Error}
507
+ */
508
+ throwParamError(name) {
509
+ throw new Error("You must provide a `" + name + "` parameter");
510
+ }
511
+ /**
512
+ * Called when the UI closes. Override to do any specific cleanup necessary
513
+ */
514
+ close() {
515
+ this.screen.releaseCursor();
516
+ }
517
+ /**
518
+ * Run the provided validation method each time a submit event occur.
519
+ * @param {Rx.Observable} submit - submit event flow
520
+ * @return {Object} Object containing two observables: `success` and `error`
521
+ */
522
+ handleSubmitEvents(submit) {
523
+ const validate = runAsync(this.opt.validate);
524
+ const asyncFilter = runAsync(this.opt.filter);
525
+ const validation = submit.pipe(
526
+ mergeMap((value) => {
527
+ this.startSpinner(value, this.opt.filteringText);
528
+ return asyncFilter(value, this.answers).then(
529
+ (filteredValue) => {
530
+ this.startSpinner(filteredValue, this.opt.validatingText);
531
+ return validate(filteredValue, this.answers).then(
532
+ (isValid) => ({ isValid, value: filteredValue }),
533
+ (error_) => ({ isValid: error_, value: filteredValue })
534
+ );
535
+ },
536
+ (error_) => ({ isValid: error_ })
537
+ );
538
+ }),
539
+ share2()
540
+ );
541
+ const success = validation.pipe(
542
+ filter2((state) => state.isValid === true),
543
+ take(1)
544
+ );
545
+ const error = validation.pipe(
546
+ filter2((state) => state.isValid !== true),
547
+ takeUntil2(success)
548
+ );
549
+ return {
550
+ success,
551
+ error
552
+ };
553
+ }
554
+ startSpinner(value, bottomContent) {
555
+ value = this.getSpinningValue(value);
556
+ const content = bottomContent ? this.getQuestion() + value : this.getQuestion().slice(this.opt.prefix.length + 1) + value;
557
+ this.screen.renderWithSpinner(content, bottomContent);
558
+ }
559
+ /**
560
+ * Allow override, e.g. for password prompts
561
+ * See: https://github.com/SBoudrias/Inquirer.js/issues/1022
562
+ *
563
+ * @return {String} value to display while spinning
564
+ */
565
+ getSpinningValue(value) {
566
+ return value;
567
+ }
568
+ /**
569
+ * Generate the prompt question string
570
+ * @return {String} prompt question string
571
+ */
572
+ getQuestion() {
573
+ let message = (this.opt.prefix ? this.opt.prefix + " " : "") + colors3.bold(this.opt.message) + this.opt.suffix + colors3.reset(" ");
574
+ if (this.opt.default != null && this.status !== "touched" && this.status !== "answered") {
575
+ message += this.opt.type === "password" ? colors3.italic(colors3.dim("[hidden] ")) : colors3.dim("(" + this.opt.default + ") ");
576
+ }
577
+ return message;
578
+ }
579
+ };
580
+ }
581
+ });
582
+
583
+ // node_modules/inquirer/lib/prompts/list.js
584
+ import ansiEscapes3 from "ansi-escapes";
585
+ import colors4 from "yoctocolors-cjs";
586
+ import figures2 from "@inquirer/figures";
587
+ import runAsync2 from "run-async";
588
+ import { flatMap, map as map2, take as take2, takeUntil as takeUntil3 } from "rxjs";
589
+ function listRender(choices, pointer) {
590
+ let output = "";
591
+ let separatorOffset = 0;
592
+ choices.forEach((choice, i) => {
593
+ if (choice.type === "separator") {
594
+ separatorOffset++;
595
+ output += " " + choice + "\n";
596
+ return;
597
+ }
598
+ if (choice.disabled) {
599
+ separatorOffset++;
600
+ output += " - " + choice.name;
601
+ output += ` (${typeof choice.disabled === "string" ? choice.disabled : "Disabled"})`;
602
+ output += "\n";
603
+ return;
604
+ }
605
+ const isSelected = i - separatorOffset === pointer;
606
+ let line = (isSelected ? figures2.pointer + " " : " ") + choice.name;
607
+ if (isSelected) {
608
+ line = colors4.cyan(line);
609
+ }
610
+ output += line + " \n";
611
+ });
612
+ return output.replaceAll(/\n$/g, "");
613
+ }
614
+ var ListPrompt;
615
+ var init_list = __esm({
616
+ "node_modules/inquirer/lib/prompts/list.js"() {
617
+ init_events();
618
+ init_paginator();
619
+ init_incrementListIndex();
620
+ init_base();
621
+ ListPrompt = class extends Prompt {
622
+ constructor(questions, rl, answers) {
623
+ super(questions, rl, answers);
624
+ if (!this.opt.choices) {
625
+ this.throwParamError("choices");
626
+ }
627
+ this.firstRender = true;
628
+ this.selected = 0;
629
+ const def = this.opt.default;
630
+ if (typeof def === "number" && def >= 0 && def < this.opt.choices.realLength) {
631
+ this.selected = def;
632
+ } else if (typeof def !== "number" && def != null) {
633
+ const index = this.opt.choices.realChoices.findIndex(({ value }) => value === def);
634
+ this.selected = Math.max(index, 0);
635
+ }
636
+ this.opt.default = null;
637
+ const shouldLoop = this.opt.loop === void 0 ? true : this.opt.loop;
638
+ this.paginator = new Paginator(this.screen, { isInfinite: shouldLoop });
639
+ }
640
+ /**
641
+ * Start the Inquiry session
642
+ * @param {Function} cb Callback when prompt is done
643
+ * @return {this}
644
+ */
645
+ _run(cb) {
646
+ this.done = cb;
647
+ const events = observe(this.rl);
648
+ events.normalizedUpKey.pipe(takeUntil3(events.line)).forEach(this.onUpKey.bind(this));
649
+ events.normalizedDownKey.pipe(takeUntil3(events.line)).forEach(this.onDownKey.bind(this));
650
+ events.numberKey.pipe(takeUntil3(events.line)).forEach(this.onNumberKey.bind(this));
651
+ events.line.pipe(
652
+ take2(1),
653
+ map2(this.getCurrentValue.bind(this)),
654
+ flatMap(
655
+ (value) => runAsync2(this.opt.filter)(value, this.answers).catch((error) => error)
656
+ )
657
+ ).forEach(this.onSubmit.bind(this));
658
+ this.render();
659
+ return this;
660
+ }
661
+ /**
662
+ * Render the prompt to screen
663
+ * @return {ListPrompt} self
664
+ */
665
+ render() {
666
+ let message = this.getQuestion();
667
+ if (this.firstRender) {
668
+ message += colors4.dim("(Use arrow keys)");
669
+ }
670
+ if (this.status === "answered") {
671
+ message += colors4.cyan(this.opt.choices.getChoice(this.selected).short);
672
+ } else {
673
+ const choicesStr = listRender(this.opt.choices, this.selected);
674
+ const indexPosition = this.opt.choices.indexOf(
675
+ this.opt.choices.getChoice(this.selected)
676
+ );
677
+ const realIndexPosition = this.opt.choices.reduce((acc, value, i) => {
678
+ if (i > indexPosition) {
679
+ return acc;
680
+ }
681
+ if (value.type === "separator") {
682
+ return acc + 1;
683
+ }
684
+ let l = value.name;
685
+ if (typeof l !== "string") {
686
+ return acc + 1;
687
+ }
688
+ l = l.split("\n");
689
+ return acc + l.length;
690
+ }, 0) - 1;
691
+ message += "\n" + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
692
+ }
693
+ message += ansiEscapes3.cursorHide;
694
+ this.firstRender = false;
695
+ this.screen.render(message);
696
+ }
697
+ /**
698
+ * When user press `enter` key
699
+ */
700
+ onSubmit(value) {
701
+ this.status = "answered";
702
+ this.render();
703
+ this.screen.done();
704
+ this.done(value);
705
+ }
706
+ getCurrentValue() {
707
+ return this.opt.choices.getChoice(this.selected).value;
708
+ }
709
+ /**
710
+ * When user press a key
711
+ */
712
+ onUpKey() {
713
+ this.selected = incrementListIndex(this.selected, "up", this.opt);
714
+ this.render();
715
+ }
716
+ onDownKey() {
717
+ this.selected = incrementListIndex(this.selected, "down", this.opt);
718
+ this.render();
719
+ }
720
+ onNumberKey(input) {
721
+ if (input <= this.opt.choices.realLength) {
722
+ this.selected = input - 1;
723
+ }
724
+ this.render();
725
+ }
726
+ };
727
+ }
728
+ });
729
+
730
+ // node_modules/inquirer/lib/prompts/input.js
731
+ import colors5 from "yoctocolors-cjs";
732
+ import { map as map3, takeUntil as takeUntil4 } from "rxjs";
733
+ var InputPrompt;
734
+ var init_input = __esm({
735
+ "node_modules/inquirer/lib/prompts/input.js"() {
736
+ init_events();
737
+ init_base();
738
+ InputPrompt = class extends Prompt {
739
+ /**
740
+ * Start the Inquiry session
741
+ * @param {Function} cb Callback when prompt is done
742
+ * @return {this}
743
+ */
744
+ _run(cb) {
745
+ this.done = cb;
746
+ const events = observe(this.rl);
747
+ const submit = events.line.pipe(map3(this.filterInput.bind(this)));
748
+ const validation = this.handleSubmitEvents(submit);
749
+ validation.success.forEach(this.onEnd.bind(this));
750
+ validation.error.forEach(this.onError.bind(this));
751
+ events.keypress.pipe(takeUntil4(validation.success)).forEach(this.onKeypress.bind(this));
752
+ this.render();
753
+ return this;
754
+ }
755
+ /**
756
+ * Render the prompt to screen
757
+ * @return {InputPrompt} self
758
+ */
759
+ render(error) {
760
+ let bottomContent = "";
761
+ let appendContent = "";
762
+ let message = this.getQuestion();
763
+ const { transformer } = this.opt;
764
+ const isFinal = this.status === "answered";
765
+ appendContent = isFinal ? this.answer : this.rl.line;
766
+ if (transformer) {
767
+ message += transformer(appendContent, this.answers, { isFinal });
768
+ } else {
769
+ message += isFinal ? colors5.cyan(appendContent) : appendContent;
770
+ }
771
+ if (error) {
772
+ bottomContent = colors5.red(">> ") + error;
773
+ }
774
+ this.screen.render(message, bottomContent);
775
+ }
776
+ /**
777
+ * When user press `enter` key
778
+ */
779
+ filterInput(input) {
780
+ if (!input) {
781
+ return this.opt.default == null ? "" : this.opt.default;
782
+ }
783
+ return input;
784
+ }
785
+ onEnd(state) {
786
+ this.answer = state.value;
787
+ this.status = "answered";
788
+ this.render();
789
+ this.screen.done();
790
+ this.done(state.value);
791
+ }
792
+ onError({ value = "", isValid }) {
793
+ this.rl.line += value;
794
+ this.rl.cursor += value.length;
795
+ this.render(isValid);
796
+ }
797
+ /**
798
+ * When user press a key
799
+ */
800
+ onKeypress() {
801
+ this.status = "touched";
802
+ this.render();
803
+ }
804
+ };
805
+ }
806
+ });
807
+
808
+ // node_modules/inquirer/lib/prompts/number.js
809
+ var NumberPrompt;
810
+ var init_number = __esm({
811
+ "node_modules/inquirer/lib/prompts/number.js"() {
812
+ init_input();
813
+ NumberPrompt = class extends InputPrompt {
814
+ filterInput(input) {
815
+ if (input && typeof input === "string") {
816
+ input = input.trim();
817
+ const numberMatch = input.match(/(^-?\d+|^-?\d+\.\d*|^\d*\.\d+)(e\d+)?$/);
818
+ if (numberMatch) {
819
+ return Number(numberMatch[0]);
820
+ }
821
+ }
822
+ return this.opt.default == null ? Number.NaN : this.opt.default;
823
+ }
824
+ };
825
+ }
826
+ });
827
+
828
+ // node_modules/inquirer/lib/prompts/confirm.js
829
+ import colors6 from "yoctocolors-cjs";
830
+ import { take as take3, takeUntil as takeUntil5 } from "rxjs";
831
+ var ConfirmPrompt;
832
+ var init_confirm = __esm({
833
+ "node_modules/inquirer/lib/prompts/confirm.js"() {
834
+ init_events();
835
+ init_base();
836
+ ConfirmPrompt = class extends Prompt {
837
+ constructor(questions, rl, answers) {
838
+ super(questions, rl, answers);
839
+ let rawDefault = true;
840
+ Object.assign(this.opt, {
841
+ filter(input) {
842
+ if (input != null && input !== "") {
843
+ if (/^y(es)?/i.test(input))
844
+ return true;
845
+ if (/^n(o)?/i.test(input))
846
+ return false;
847
+ }
848
+ return rawDefault;
849
+ }
850
+ });
851
+ if (this.opt.default != null) {
852
+ rawDefault = Boolean(this.opt.default);
853
+ }
854
+ this.opt.default = rawDefault ? "Y/n" : "y/N";
855
+ }
856
+ /**
857
+ * Start the Inquiry session
858
+ * @param {Function} cb Callback when prompt is done
859
+ * @return {this}
860
+ */
861
+ _run(cb) {
862
+ this.done = cb;
863
+ const events = observe(this.rl);
864
+ events.keypress.pipe(takeUntil5(events.line)).forEach(this.onKeypress.bind(this));
865
+ events.line.pipe(take3(1)).forEach(this.onEnd.bind(this));
866
+ this.render();
867
+ return this;
868
+ }
869
+ /**
870
+ * Render the prompt to screen
871
+ * @return {ConfirmPrompt} self
872
+ */
873
+ render(answer) {
874
+ let message = this.getQuestion();
875
+ if (typeof answer === "boolean") {
876
+ message += colors6.cyan(answer ? "Yes" : "No");
877
+ } else if (answer) {
878
+ message += answer;
879
+ } else {
880
+ message += this.rl.line;
881
+ }
882
+ this.screen.render(message);
883
+ return this;
884
+ }
885
+ /**
886
+ * When user press `enter` key
887
+ */
888
+ onEnd(input) {
889
+ this.status = "answered";
890
+ let output = this.opt.filter(input);
891
+ if (this.opt.transformer) {
892
+ output = this.opt.transformer(output);
893
+ }
894
+ this.render(output);
895
+ this.screen.done();
896
+ this.done(output);
897
+ }
898
+ /**
899
+ * When user press a key
900
+ */
901
+ onKeypress() {
902
+ this.render();
903
+ }
904
+ };
905
+ }
906
+ });
907
+
908
+ // node_modules/inquirer/lib/prompts/rawlist.js
909
+ import colors7 from "yoctocolors-cjs";
910
+ import { map as map4, takeUntil as takeUntil6 } from "rxjs";
911
+ function renderChoices(choices, pointer) {
912
+ let output = "";
913
+ let separatorOffset = 0;
914
+ choices.forEach((choice, i) => {
915
+ output += output ? "\n " : " ";
916
+ if (choice.type === "separator") {
917
+ separatorOffset++;
918
+ output += " " + choice;
919
+ return;
920
+ }
921
+ const index = i - separatorOffset;
922
+ let display = index + 1 + ") " + choice.name;
923
+ if (index === pointer) {
924
+ display = colors7.cyan(display);
925
+ }
926
+ output += display;
927
+ });
928
+ return output;
929
+ }
930
+ var RawListPrompt;
931
+ var init_rawlist = __esm({
932
+ "node_modules/inquirer/lib/prompts/rawlist.js"() {
933
+ init_separator();
934
+ init_events();
935
+ init_paginator();
936
+ init_incrementListIndex();
937
+ init_base();
938
+ RawListPrompt = class extends Prompt {
939
+ constructor(questions, rl, answers) {
940
+ super(questions, rl, answers);
941
+ this.hiddenLine = "";
942
+ this.lastKey = "";
943
+ if (!this.opt.choices) {
944
+ this.throwParamError("choices");
945
+ }
946
+ this.opt.validChoices = this.opt.choices.filter(Separator.exclude);
947
+ this.selected = 0;
948
+ this.rawDefault = 0;
949
+ Object.assign(this.opt, {
950
+ validate(val) {
951
+ return val != null;
952
+ }
953
+ });
954
+ const def = this.opt.default;
955
+ if (typeof def === "number" && def >= 0 && def < this.opt.choices.realLength) {
956
+ this.selected = def;
957
+ this.rawDefault = def;
958
+ } else if (typeof def !== "number" && def != null) {
959
+ const index = this.opt.choices.realChoices.findIndex(({ value }) => value === def);
960
+ const safeIndex = Math.max(index, 0);
961
+ this.selected = safeIndex;
962
+ this.rawDefault = safeIndex;
963
+ }
964
+ this.opt.default = null;
965
+ const shouldLoop = this.opt.loop === void 0 ? true : this.opt.loop;
966
+ this.paginator = new Paginator(void 0, { isInfinite: shouldLoop });
967
+ }
968
+ /**
969
+ * Start the Inquiry session
970
+ * @param {Function} cb Callback when prompt is done
971
+ * @return {this}
972
+ */
973
+ _run(cb) {
974
+ this.done = cb;
975
+ const events = observe(this.rl);
976
+ const submit = events.line.pipe(map4(this.getCurrentValue.bind(this)));
977
+ const validation = this.handleSubmitEvents(submit);
978
+ validation.success.forEach(this.onEnd.bind(this));
979
+ validation.error.forEach(this.onError.bind(this));
980
+ events.normalizedUpKey.pipe(takeUntil6(validation.success)).forEach(this.onUpKey.bind(this));
981
+ events.normalizedDownKey.pipe(takeUntil6(validation.success)).forEach(this.onDownKey.bind(this));
982
+ events.keypress.pipe(takeUntil6(validation.success)).forEach(this.onKeypress.bind(this));
983
+ this.render();
984
+ return this;
985
+ }
986
+ /**
987
+ * Render the prompt to screen
988
+ * @return {RawListPrompt} self
989
+ */
990
+ render(error) {
991
+ let message = this.getQuestion();
992
+ let bottomContent = "";
993
+ if (this.status === "answered") {
994
+ message += colors7.cyan(this.opt.choices.getChoice(this.selected).short);
995
+ } else {
996
+ const choicesStr = renderChoices(this.opt.choices, this.selected);
997
+ message += "\n" + this.paginator.paginate(choicesStr, this.selected, this.opt.pageSize);
998
+ message += "\n Answer: ";
999
+ }
1000
+ message += this.rl.line;
1001
+ if (error) {
1002
+ bottomContent = "\n" + colors7.red(">> ") + error;
1003
+ }
1004
+ this.screen.render(message, bottomContent);
1005
+ }
1006
+ /**
1007
+ * When user press `enter` key
1008
+ */
1009
+ getCurrentValue(index) {
1010
+ if (index == null) {
1011
+ index = this.rawDefault;
1012
+ } else if (index === "") {
1013
+ this.selected = this.selected === void 0 ? -1 : this.selected;
1014
+ index = this.selected;
1015
+ } else {
1016
+ index -= 1;
1017
+ }
1018
+ const choice = this.opt.choices.getChoice(index);
1019
+ return choice ? choice.value : null;
1020
+ }
1021
+ onEnd(state) {
1022
+ this.status = "answered";
1023
+ this.answer = state.value;
1024
+ this.render();
1025
+ this.screen.done();
1026
+ this.done(state.value);
1027
+ }
1028
+ onError() {
1029
+ this.render("Please enter a valid index");
1030
+ }
1031
+ /**
1032
+ * When user press a key
1033
+ */
1034
+ onKeypress() {
1035
+ let index;
1036
+ if (this.lastKey === "arrow") {
1037
+ index = this.hiddenLine.length > 0 ? Number(this.hiddenLine) - 1 : 0;
1038
+ } else {
1039
+ index = this.rl.line.length > 0 ? Number(this.rl.line) - 1 : 0;
1040
+ }
1041
+ this.lastKey = "";
1042
+ this.selected = this.opt.choices.getChoice(index) ? index : void 0;
1043
+ this.render();
1044
+ }
1045
+ /**
1046
+ * When user press up key
1047
+ */
1048
+ onUpKey() {
1049
+ this.onArrowKey("up");
1050
+ }
1051
+ /**
1052
+ * When user press down key
1053
+ */
1054
+ onDownKey() {
1055
+ this.onArrowKey("down");
1056
+ }
1057
+ /**
1058
+ * When user press up or down key
1059
+ * @param {String} type Arrow type: up or down
1060
+ */
1061
+ onArrowKey(type) {
1062
+ this.selected = incrementListIndex(this.selected, type, this.opt) || 0;
1063
+ this.hiddenLine = String(this.selected + 1);
1064
+ this.rl.line = "";
1065
+ this.lastKey = "arrow";
1066
+ }
1067
+ };
1068
+ }
1069
+ });
1070
+
1071
+ // node_modules/inquirer/lib/prompts/expand.js
1072
+ import colors8 from "yoctocolors-cjs";
1073
+ import { map as map5, takeUntil as takeUntil7 } from "rxjs";
1074
+ function renderChoices2(choices, pointer) {
1075
+ let output = "";
1076
+ choices.forEach((choice) => {
1077
+ output += "\n ";
1078
+ if (choice.type === "separator") {
1079
+ output += " " + choice;
1080
+ return;
1081
+ }
1082
+ let choiceStr = choice.key + ") " + choice.name;
1083
+ if (pointer === choice.key) {
1084
+ choiceStr = colors8.cyan(choiceStr);
1085
+ }
1086
+ output += choiceStr;
1087
+ });
1088
+ return output;
1089
+ }
1090
+ var ExpandPrompt;
1091
+ var init_expand = __esm({
1092
+ "node_modules/inquirer/lib/prompts/expand.js"() {
1093
+ init_separator();
1094
+ init_events();
1095
+ init_paginator();
1096
+ init_base();
1097
+ ExpandPrompt = class extends Prompt {
1098
+ constructor(questions, rl, answers) {
1099
+ super(questions, rl, answers);
1100
+ if (!this.opt.choices) {
1101
+ this.throwParamError("choices");
1102
+ }
1103
+ this.validateChoices(this.opt.choices);
1104
+ this.opt.choices.push({
1105
+ key: "h",
1106
+ name: "Help, list all options",
1107
+ value: "help"
1108
+ });
1109
+ this.opt.validate = (choice) => {
1110
+ if (choice == null) {
1111
+ return "Please enter a valid command";
1112
+ }
1113
+ return choice !== "help";
1114
+ };
1115
+ this.opt.default = this.generateChoicesString(this.opt.choices, this.opt.default);
1116
+ this.paginator = new Paginator(this.screen);
1117
+ }
1118
+ /**
1119
+ * Start the Inquiry session
1120
+ * @param {Function} cb Callback when prompt is done
1121
+ * @return {this}
1122
+ */
1123
+ _run(cb) {
1124
+ this.done = cb;
1125
+ const events = observe(this.rl);
1126
+ const validation = this.handleSubmitEvents(
1127
+ events.line.pipe(map5(this.getCurrentValue.bind(this)))
1128
+ );
1129
+ validation.success.forEach(this.onSubmit.bind(this));
1130
+ validation.error.forEach(this.onError.bind(this));
1131
+ this.keypressObs = events.keypress.pipe(takeUntil7(validation.success)).forEach(this.onKeypress.bind(this));
1132
+ this.render();
1133
+ return this;
1134
+ }
1135
+ /**
1136
+ * Render the prompt to screen
1137
+ * @return {ExpandPrompt} self
1138
+ */
1139
+ render(error, hint) {
1140
+ let message = this.getQuestion();
1141
+ let bottomContent = "";
1142
+ if (this.status === "answered") {
1143
+ message += colors8.cyan(this.answer);
1144
+ } else if (this.status === "expanded") {
1145
+ const choicesStr = renderChoices2(this.opt.choices, this.selectedKey);
1146
+ message += this.paginator.paginate(choicesStr, this.selectedKey, this.opt.pageSize);
1147
+ message += "\n Answer: ";
1148
+ }
1149
+ message += this.rl.line;
1150
+ if (error) {
1151
+ bottomContent = colors8.red(">> ") + error;
1152
+ }
1153
+ if (hint) {
1154
+ bottomContent = colors8.cyan(">> ") + hint;
1155
+ }
1156
+ this.screen.render(message, bottomContent);
1157
+ }
1158
+ getCurrentValue(input) {
1159
+ input ||= this.rawDefault;
1160
+ const selected = this.opt.choices.where({ key: input.toLowerCase().trim() })[0];
1161
+ if (!selected) {
1162
+ return null;
1163
+ }
1164
+ return selected.value;
1165
+ }
1166
+ /**
1167
+ * Generate the prompt choices string
1168
+ * @return {String} Choices string
1169
+ */
1170
+ getChoices() {
1171
+ let output = "";
1172
+ this.opt.choices.forEach((choice) => {
1173
+ output += "\n ";
1174
+ if (choice.type === "separator") {
1175
+ output += " " + choice;
1176
+ return;
1177
+ }
1178
+ let choiceStr = choice.key + ") " + choice.name;
1179
+ if (this.selectedKey === choice.key) {
1180
+ choiceStr = colors8.cyan(choiceStr);
1181
+ }
1182
+ output += choiceStr;
1183
+ });
1184
+ return output;
1185
+ }
1186
+ onError(state) {
1187
+ if (state.value === "help") {
1188
+ this.selectedKey = "";
1189
+ this.status = "expanded";
1190
+ this.render();
1191
+ return;
1192
+ }
1193
+ this.render(state.isValid);
1194
+ }
1195
+ /**
1196
+ * When user press `enter` key
1197
+ */
1198
+ onSubmit(state) {
1199
+ this.status = "answered";
1200
+ const choice = this.opt.choices.where({ value: state.value })[0];
1201
+ this.answer = choice.short || choice.name;
1202
+ this.render();
1203
+ this.screen.done();
1204
+ this.done(state.value);
1205
+ }
1206
+ /**
1207
+ * When user press a key
1208
+ */
1209
+ onKeypress() {
1210
+ this.selectedKey = this.rl.line.toLowerCase();
1211
+ const selected = this.opt.choices.where({ key: this.selectedKey })[0];
1212
+ if (this.status === "expanded") {
1213
+ this.render();
1214
+ } else {
1215
+ this.render(null, selected ? selected.name : null);
1216
+ }
1217
+ }
1218
+ /**
1219
+ * Validate the choices
1220
+ * @param {Array} choices
1221
+ */
1222
+ validateChoices(choices) {
1223
+ let formatError;
1224
+ const errors = [];
1225
+ const keymap = {};
1226
+ choices.filter(Separator.exclude).forEach((choice) => {
1227
+ if (!choice.key || choice.key.length !== 1) {
1228
+ formatError = true;
1229
+ }
1230
+ choice.key = String(choice.key).toLowerCase();
1231
+ if (keymap[choice.key]) {
1232
+ errors.push(choice.key);
1233
+ }
1234
+ keymap[choice.key] = true;
1235
+ });
1236
+ if (formatError) {
1237
+ throw new Error(
1238
+ "Format error: `key` param must be a single letter and is required."
1239
+ );
1240
+ }
1241
+ if (keymap.h) {
1242
+ throw new Error(
1243
+ "Reserved key error: `key` param cannot be `h` - this value is reserved."
1244
+ );
1245
+ }
1246
+ if (errors.length > 0) {
1247
+ throw new Error(
1248
+ "Duplicate key error: `key` param must be unique. Duplicates: " + [...new Set(errors)].join(",")
1249
+ );
1250
+ }
1251
+ }
1252
+ /**
1253
+ * Generate a string out of the choices keys
1254
+ * @param {Array} choices
1255
+ * @param {Number|String} default - the choice index or name to capitalize
1256
+ * @return {String} The rendered choices key string
1257
+ */
1258
+ generateChoicesString(choices, defaultChoice) {
1259
+ let defIndex = choices.realLength - 1;
1260
+ if (typeof defaultChoice === "number" && this.opt.choices.getChoice(defaultChoice)) {
1261
+ defIndex = defaultChoice;
1262
+ } else if (typeof defaultChoice === "string") {
1263
+ const index = choices.realChoices.findIndex(({ value }) => value === defaultChoice);
1264
+ defIndex = index === -1 ? defIndex : index;
1265
+ }
1266
+ const defStr = this.opt.choices.pluck("key");
1267
+ this.rawDefault = defStr[defIndex];
1268
+ defStr[defIndex] = String(defStr[defIndex]).toUpperCase();
1269
+ return defStr.join("");
1270
+ }
1271
+ };
1272
+ }
1273
+ });
1274
+
1275
+ // node_modules/inquirer/lib/prompts/checkbox.js
1276
+ import ansiEscapes4 from "ansi-escapes";
1277
+ import colors9 from "yoctocolors-cjs";
1278
+ import figures3 from "@inquirer/figures";
1279
+ import { map as map6, takeUntil as takeUntil8 } from "rxjs";
1280
+ function renderChoices3(choices, pointer) {
1281
+ let output = "";
1282
+ let separatorOffset = 0;
1283
+ choices.forEach((choice, i) => {
1284
+ if (choice.type === "separator") {
1285
+ separatorOffset++;
1286
+ output += " " + choice + "\n";
1287
+ return;
1288
+ }
1289
+ if (choice.disabled) {
1290
+ separatorOffset++;
1291
+ output += " - " + choice.name;
1292
+ output += ` (${typeof choice.disabled === "string" ? choice.disabled : "Disabled"})`;
1293
+ } else {
1294
+ const line = getCheckbox(choice.checked) + " " + choice.name;
1295
+ output += i - separatorOffset === pointer ? colors9.cyan(figures3.pointer + line) : " " + line;
1296
+ }
1297
+ output += "\n";
1298
+ });
1299
+ return output.replaceAll(/\n$/g, "");
1300
+ }
1301
+ function getCheckbox(checked) {
1302
+ return checked ? colors9.green(figures3.radioOn) : figures3.radioOff;
1303
+ }
1304
+ var CheckboxPrompt;
1305
+ var init_checkbox = __esm({
1306
+ "node_modules/inquirer/lib/prompts/checkbox.js"() {
1307
+ init_events();
1308
+ init_paginator();
1309
+ init_incrementListIndex();
1310
+ init_base();
1311
+ CheckboxPrompt = class extends Prompt {
1312
+ constructor(questions, rl, answers) {
1313
+ super(questions, rl, answers);
1314
+ if (!this.opt.choices) {
1315
+ this.throwParamError("choices");
1316
+ }
1317
+ if (Array.isArray(this.opt.default)) {
1318
+ for (const choice of this.opt.choices) {
1319
+ if (this.opt.default.includes(choice.value)) {
1320
+ choice.checked = true;
1321
+ }
1322
+ }
1323
+ }
1324
+ this.pointer = 0;
1325
+ this.opt.default = null;
1326
+ const shouldLoop = this.opt.loop === void 0 ? true : this.opt.loop;
1327
+ this.paginator = new Paginator(this.screen, { isInfinite: shouldLoop });
1328
+ }
1329
+ /**
1330
+ * Start the Inquiry session
1331
+ * @param {Function} cb Callback when prompt is done
1332
+ * @return {this}
1333
+ */
1334
+ _run(cb) {
1335
+ this.done = cb;
1336
+ const events = observe(this.rl);
1337
+ const validation = this.handleSubmitEvents(
1338
+ events.line.pipe(map6(this.getCurrentValue.bind(this)))
1339
+ );
1340
+ validation.success.forEach(this.onEnd.bind(this));
1341
+ validation.error.forEach(this.onError.bind(this));
1342
+ events.normalizedUpKey.pipe(takeUntil8(validation.success)).forEach(this.onUpKey.bind(this));
1343
+ events.normalizedDownKey.pipe(takeUntil8(validation.success)).forEach(this.onDownKey.bind(this));
1344
+ events.numberKey.pipe(takeUntil8(validation.success)).forEach(this.onNumberKey.bind(this));
1345
+ events.spaceKey.pipe(takeUntil8(validation.success)).forEach(this.onSpaceKey.bind(this));
1346
+ events.aKey.pipe(takeUntil8(validation.success)).forEach(this.onAllKey.bind(this));
1347
+ events.iKey.pipe(takeUntil8(validation.success)).forEach(this.onInverseKey.bind(this));
1348
+ this.render();
1349
+ this.firstRender = false;
1350
+ return this;
1351
+ }
1352
+ /**
1353
+ * Render the prompt to screen
1354
+ * @return {CheckboxPrompt} self
1355
+ */
1356
+ render(error) {
1357
+ let message = this.getQuestion();
1358
+ let bottomContent = "";
1359
+ if (!this.dontShowHints) {
1360
+ message += "(Press " + colors9.cyan(colors9.bold("<space>")) + " to select, " + colors9.cyan(colors9.bold("<a>")) + " to toggle all, " + colors9.cyan(colors9.bold("<i>")) + " to invert selection, and " + colors9.cyan(colors9.bold("<enter>")) + " to proceed)";
1361
+ }
1362
+ if (this.status === "answered") {
1363
+ message += colors9.cyan(this.selection.join(", "));
1364
+ } else {
1365
+ const choicesStr = renderChoices3(this.opt.choices, this.pointer);
1366
+ const indexPosition = this.opt.choices.indexOf(
1367
+ this.opt.choices.getChoice(this.pointer)
1368
+ );
1369
+ const realIndexPosition = this.opt.choices.reduce((acc, value, i) => {
1370
+ if (i > indexPosition) {
1371
+ return acc;
1372
+ }
1373
+ if (value.type === "separator") {
1374
+ return acc + 1;
1375
+ }
1376
+ let l = value.name;
1377
+ if (typeof l !== "string") {
1378
+ return acc + 1;
1379
+ }
1380
+ l = l.split("\n");
1381
+ return acc + l.length;
1382
+ }, 0) - 1;
1383
+ message += "\n" + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
1384
+ }
1385
+ if (error) {
1386
+ bottomContent = colors9.red(">> ") + error;
1387
+ }
1388
+ message += ansiEscapes4.cursorHide;
1389
+ this.screen.render(message, bottomContent);
1390
+ }
1391
+ /**
1392
+ * When user press `enter` key
1393
+ */
1394
+ onEnd(state) {
1395
+ this.status = "answered";
1396
+ this.dontShowHints = true;
1397
+ this.render();
1398
+ this.screen.done();
1399
+ this.done(state.value);
1400
+ }
1401
+ onError(state) {
1402
+ this.render(state.isValid);
1403
+ }
1404
+ getCurrentValue() {
1405
+ const choices = this.opt.choices.filter(
1406
+ (choice) => Boolean(choice.checked) && !choice.disabled
1407
+ );
1408
+ this.selection = choices.map((choice) => choice.short);
1409
+ return choices.map((choice) => choice.value);
1410
+ }
1411
+ onUpKey() {
1412
+ this.pointer = incrementListIndex(this.pointer, "up", this.opt);
1413
+ this.render();
1414
+ }
1415
+ onDownKey() {
1416
+ this.pointer = incrementListIndex(this.pointer, "down", this.opt);
1417
+ this.render();
1418
+ }
1419
+ onNumberKey(input) {
1420
+ if (input <= this.opt.choices.realLength) {
1421
+ this.pointer = input - 1;
1422
+ this.toggleChoice(this.pointer);
1423
+ }
1424
+ this.render();
1425
+ }
1426
+ onSpaceKey() {
1427
+ this.toggleChoice(this.pointer);
1428
+ this.render();
1429
+ }
1430
+ onAllKey() {
1431
+ const shouldBeChecked = this.opt.choices.some(
1432
+ (choice) => choice.type !== "separator" && !choice.checked
1433
+ );
1434
+ this.opt.choices.forEach((choice) => {
1435
+ if (choice.type !== "separator") {
1436
+ choice.checked = shouldBeChecked;
1437
+ }
1438
+ });
1439
+ this.render();
1440
+ }
1441
+ onInverseKey() {
1442
+ this.opt.choices.forEach((choice) => {
1443
+ if (choice.type !== "separator") {
1444
+ choice.checked = !choice.checked;
1445
+ }
1446
+ });
1447
+ this.render();
1448
+ }
1449
+ toggleChoice(index) {
1450
+ const item = this.opt.choices.getChoice(index);
1451
+ if (item !== void 0) {
1452
+ this.opt.choices.getChoice(index).checked = !item.checked;
1453
+ }
1454
+ }
1455
+ };
1456
+ }
1457
+ });
1458
+
1459
+ // node_modules/inquirer/lib/prompts/password.js
1460
+ import colors10 from "yoctocolors-cjs";
1461
+ import { map as map7, takeUntil as takeUntil9 } from "rxjs";
1462
+ function mask(input, maskChar) {
1463
+ input = String(input);
1464
+ maskChar = typeof maskChar === "string" ? maskChar : "*";
1465
+ if (input.length === 0) {
1466
+ return "";
1467
+ }
1468
+ return Array.from({ length: input.length + 1 }).join(maskChar);
1469
+ }
1470
+ var PasswordPrompt;
1471
+ var init_password = __esm({
1472
+ "node_modules/inquirer/lib/prompts/password.js"() {
1473
+ init_events();
1474
+ init_base();
1475
+ PasswordPrompt = class extends Prompt {
1476
+ /**
1477
+ * Start the Inquiry session
1478
+ * @param {Function} cb Callback when prompt is done
1479
+ * @return {this}
1480
+ */
1481
+ _run(cb) {
1482
+ this.done = cb;
1483
+ const events = observe(this.rl);
1484
+ const submit = events.line.pipe(map7(this.filterInput.bind(this)));
1485
+ const validation = this.handleSubmitEvents(submit);
1486
+ validation.success.forEach(this.onEnd.bind(this));
1487
+ validation.error.forEach(this.onError.bind(this));
1488
+ events.keypress.pipe(takeUntil9(validation.success)).forEach(this.onKeypress.bind(this));
1489
+ this.render();
1490
+ return this;
1491
+ }
1492
+ /**
1493
+ * Render the prompt to screen
1494
+ * @return {PasswordPrompt} self
1495
+ */
1496
+ render(error) {
1497
+ let message = this.getQuestion();
1498
+ let bottomContent = "";
1499
+ message += this.status === "answered" ? this.getMaskedValue(this.answer) : this.getMaskedValue(this.rl.line || "");
1500
+ if (error) {
1501
+ bottomContent = "\n" + colors10.red(">> ") + error;
1502
+ }
1503
+ this.screen.render(message, bottomContent);
1504
+ }
1505
+ getMaskedValue(value) {
1506
+ if (this.status === "answered") {
1507
+ return this.opt.mask ? colors10.cyan(mask(value, this.opt.mask)) : colors10.italic(colors10.dim("[hidden]"));
1508
+ }
1509
+ return this.opt.mask ? mask(value, this.opt.mask) : colors10.italic(colors10.dim("[input is hidden] "));
1510
+ }
1511
+ /**
1512
+ * Mask value during async filter/validation.
1513
+ */
1514
+ getSpinningValue(value) {
1515
+ return this.getMaskedValue(value);
1516
+ }
1517
+ /**
1518
+ * When user press `enter` key
1519
+ */
1520
+ filterInput(input) {
1521
+ if (!input) {
1522
+ return this.opt.default == null ? "" : this.opt.default;
1523
+ }
1524
+ return input;
1525
+ }
1526
+ onEnd(state) {
1527
+ this.status = "answered";
1528
+ this.answer = state.value;
1529
+ this.render();
1530
+ this.screen.done();
1531
+ this.done(state.value);
1532
+ }
1533
+ onError(state) {
1534
+ this.render(state.isValid);
1535
+ }
1536
+ onKeypress() {
1537
+ this.opt.default &&= void 0;
1538
+ this.render();
1539
+ }
1540
+ };
1541
+ }
1542
+ });
1543
+
1544
+ // node_modules/inquirer/lib/prompts/editor.js
1545
+ import colors11 from "yoctocolors-cjs";
1546
+ import { editAsync } from "@inquirer/external-editor";
1547
+ import { Subject } from "rxjs";
1548
+ var EditorPrompt;
1549
+ var init_editor = __esm({
1550
+ "node_modules/inquirer/lib/prompts/editor.js"() {
1551
+ init_events();
1552
+ init_base();
1553
+ EditorPrompt = class extends Prompt {
1554
+ /**
1555
+ * Start the Inquiry session
1556
+ * @param {Function} cb Callback when prompt is done
1557
+ * @return {this}
1558
+ */
1559
+ _run(cb) {
1560
+ this.done = cb;
1561
+ this.editorResult = new Subject();
1562
+ const events = observe(this.rl);
1563
+ this.lineSubscription = events.line.subscribe(this.startExternalEditor.bind(this));
1564
+ const waitUserInput = this.opt.waitUserInput === void 0 ? true : this.opt.waitUserInput;
1565
+ const validation = this.handleSubmitEvents(this.editorResult);
1566
+ validation.success.forEach(this.onEnd.bind(this));
1567
+ validation.error.forEach(this.onError.bind(this));
1568
+ this.currentText = this.opt.default;
1569
+ this.opt.default = null;
1570
+ if (waitUserInput) {
1571
+ this.render();
1572
+ } else {
1573
+ this.startExternalEditor();
1574
+ }
1575
+ return this;
1576
+ }
1577
+ /**
1578
+ * Render the prompt to screen
1579
+ * @return {EditorPrompt} self
1580
+ */
1581
+ render(error) {
1582
+ let bottomContent = "";
1583
+ let message = this.getQuestion();
1584
+ message += this.status === "answered" ? colors11.dim("Received") : colors11.dim("Press <enter> to launch your preferred editor.");
1585
+ if (error) {
1586
+ bottomContent = colors11.red(">> ") + error;
1587
+ }
1588
+ this.screen.render(message, bottomContent);
1589
+ }
1590
+ /**
1591
+ * Launch $EDITOR on user press enter
1592
+ */
1593
+ startExternalEditor() {
1594
+ this.rl.pause();
1595
+ editAsync(this.currentText, this.endExternalEditor.bind(this), {
1596
+ postfix: this.opt.postfix ?? ".txt"
1597
+ });
1598
+ }
1599
+ endExternalEditor(error, result) {
1600
+ this.rl.resume();
1601
+ if (error) {
1602
+ this.editorResult.error(error);
1603
+ } else {
1604
+ this.editorResult.next(result);
1605
+ }
1606
+ }
1607
+ onEnd(state) {
1608
+ this.editorResult.unsubscribe();
1609
+ this.lineSubscription.unsubscribe();
1610
+ this.answer = state.value;
1611
+ this.status = "answered";
1612
+ this.render();
1613
+ this.screen.done();
1614
+ this.done(this.answer);
1615
+ }
1616
+ onError(state) {
1617
+ this.render(state.isValid);
1618
+ }
1619
+ };
1620
+ }
1621
+ });
1622
+
1623
+ // node_modules/inquirer/lib/ui/baseUI.js
1624
+ import readline from "node:readline";
1625
+ import MuteStream from "mute-stream";
1626
+ function setupReadlineOptions(opt = {}) {
1627
+ opt.skipTTYChecks = opt.skipTTYChecks === void 0 ? true : opt.skipTTYChecks;
1628
+ const input = opt.input || process.stdin;
1629
+ if (!opt.skipTTYChecks && !input.isTTY) {
1630
+ const nonTtyError = new Error(
1631
+ "Prompts can not be meaningfully rendered in non-TTY environments"
1632
+ );
1633
+ nonTtyError.isTtyError = true;
1634
+ throw nonTtyError;
1635
+ }
1636
+ const ms = new MuteStream();
1637
+ ms.pipe(opt.output || process.stdout);
1638
+ const output = ms;
1639
+ return {
1640
+ terminal: true,
1641
+ ...opt,
1642
+ input,
1643
+ output
1644
+ };
1645
+ }
1646
+ var UI;
1647
+ var init_baseUI = __esm({
1648
+ "node_modules/inquirer/lib/ui/baseUI.js"() {
1649
+ UI = class {
1650
+ constructor(opt) {
1651
+ this.rl ||= readline.createInterface(setupReadlineOptions(opt));
1652
+ this.rl.resume();
1653
+ this.onForceClose = this.onForceClose.bind(this);
1654
+ process.on("exit", this.onForceClose);
1655
+ this.rl.on("SIGINT", this.onForceClose);
1656
+ }
1657
+ /**
1658
+ * Handle the ^C exit
1659
+ * @return {null}
1660
+ */
1661
+ onForceClose() {
1662
+ this.close();
1663
+ process.kill(process.pid, "SIGINT");
1664
+ console.log("");
1665
+ }
1666
+ /**
1667
+ * Close the interface and cleanup listeners
1668
+ */
1669
+ close() {
1670
+ this.rl.removeListener("SIGINT", this.onForceClose);
1671
+ process.removeListener("exit", this.onForceClose);
1672
+ this.rl.output.unmute();
1673
+ if (this.activePrompt && typeof this.activePrompt.close === "function") {
1674
+ this.activePrompt.close();
1675
+ }
1676
+ this.rl.output.end();
1677
+ this.rl.pause();
1678
+ this.rl.close();
1679
+ }
1680
+ };
1681
+ }
1682
+ });
1683
+
1684
+ // node_modules/inquirer/lib/ui/bottom-bar.js
1685
+ import { Writable } from "node:stream";
1686
+ var BottomBar;
1687
+ var init_bottom_bar = __esm({
1688
+ "node_modules/inquirer/lib/ui/bottom-bar.js"() {
1689
+ init_readline();
1690
+ init_baseUI();
1691
+ BottomBar = class extends UI {
1692
+ constructor(opt = {}) {
1693
+ super(opt);
1694
+ this.log = new Writable({
1695
+ write: (chunk, encoding, cb) => {
1696
+ this.writeLog(chunk);
1697
+ cb();
1698
+ }
1699
+ });
1700
+ this.bottomBar = opt.bottomBar || "";
1701
+ this.render();
1702
+ }
1703
+ /**
1704
+ * Render the prompt to screen
1705
+ * @return {BottomBar} self
1706
+ */
1707
+ render() {
1708
+ this.write(this.bottomBar);
1709
+ return this;
1710
+ }
1711
+ clean() {
1712
+ clearLine(this.rl, this.bottomBar.split("\n").length);
1713
+ return this;
1714
+ }
1715
+ /**
1716
+ * Update the bottom bar content and rerender
1717
+ * @param {String} bottomBar Bottom bar content
1718
+ * @return {BottomBar} self
1719
+ */
1720
+ updateBottomBar(bottomBar) {
1721
+ clearLine(this.rl, 1);
1722
+ this.rl.output.unmute();
1723
+ this.clean();
1724
+ this.bottomBar = bottomBar;
1725
+ this.render();
1726
+ this.rl.output.mute();
1727
+ return this;
1728
+ }
1729
+ /**
1730
+ * Write out log data
1731
+ * @param {String} data - The log data to be output
1732
+ * @return {BottomBar} self
1733
+ */
1734
+ writeLog(data) {
1735
+ this.rl.output.unmute();
1736
+ this.clean();
1737
+ this.rl.output.write(this.enforceLF(data.toString()));
1738
+ this.render();
1739
+ this.rl.output.mute();
1740
+ return this;
1741
+ }
1742
+ /**
1743
+ * Make sure line end on a line feed
1744
+ * @param {String} str Input string
1745
+ * @return {String} The input string with a final line feed
1746
+ */
1747
+ enforceLF(str) {
1748
+ return /[\n\r]$/.test(str) ? str : str + "\n";
1749
+ }
1750
+ /**
1751
+ * Helper for writing message in Prompt
1752
+ * @param {String} message - The message to be output
1753
+ */
1754
+ write(message) {
1755
+ const msgLines = message.split(/\n/);
1756
+ this.height = msgLines.length;
1757
+ this.rl.setPrompt(msgLines.at(-1));
1758
+ if (this.rl.output.rows === 0 && this.rl.output.columns === 0) {
1759
+ left(this.rl, message.length + this.rl.line.length);
1760
+ }
1761
+ this.rl.output.write(message);
1762
+ }
1763
+ };
1764
+ }
1765
+ });
1766
+
1767
+ // node_modules/inquirer/lib/utils/utils.js
1768
+ import { from, of } from "rxjs";
1769
+ import runAsync3 from "run-async";
1770
+ var fetchAsyncQuestionProperty;
1771
+ var init_utils = __esm({
1772
+ "node_modules/inquirer/lib/utils/utils.js"() {
1773
+ fetchAsyncQuestionProperty = function(question, prop, answers) {
1774
+ if (typeof question[prop] !== "function") {
1775
+ return of(question);
1776
+ }
1777
+ return from(
1778
+ runAsync3(question[prop])(answers).then((value) => {
1779
+ question[prop] = value;
1780
+ return question;
1781
+ })
1782
+ );
1783
+ };
1784
+ }
1785
+ });
1786
+
1787
+ // node_modules/inquirer/lib/ui/prompt.js
1788
+ import {
1789
+ defer,
1790
+ EMPTY,
1791
+ from as from2,
1792
+ of as of2,
1793
+ concatMap,
1794
+ filter as filter3,
1795
+ publish,
1796
+ reduce,
1797
+ isObservable
1798
+ } from "rxjs";
1799
+ import runAsync4 from "run-async";
1800
+ var _, PromptUI;
1801
+ var init_prompt = __esm({
1802
+ "node_modules/inquirer/lib/ui/prompt.js"() {
1803
+ init_utils();
1804
+ init_baseUI();
1805
+ _ = {
1806
+ set: (obj, path19 = "", value) => {
1807
+ let pointer = obj;
1808
+ path19.split(".").forEach((key, index, arr) => {
1809
+ if (key === "__proto__" || key === "constructor")
1810
+ return;
1811
+ if (index === arr.length - 1) {
1812
+ pointer[key] = value;
1813
+ } else if (!(key in pointer) || typeof pointer[key] !== "object") {
1814
+ pointer[key] = {};
1815
+ }
1816
+ pointer = pointer[key];
1817
+ });
1818
+ },
1819
+ get: (obj, path19 = "", defaultValue) => {
1820
+ const travel = (regexp) => String.prototype.split.call(path19, regexp).filter(Boolean).reduce(
1821
+ // @ts-expect-error implicit any on res[key]
1822
+ (res, key) => res !== null && res !== void 0 ? res[key] : res,
1823
+ obj
1824
+ );
1825
+ const result = travel(/[,[\]]+?/) || travel(/[,.[\]]+?/);
1826
+ return result === void 0 || result === obj ? defaultValue : result;
1827
+ }
1828
+ };
1829
+ PromptUI = class extends UI {
1830
+ constructor(prompts, opt) {
1831
+ super(opt);
1832
+ this.prompts = prompts;
1833
+ }
1834
+ run(questions, answers) {
1835
+ this.answers = typeof answers === "object" ? { ...answers } : {};
1836
+ let obs;
1837
+ if (Array.isArray(questions)) {
1838
+ obs = from2(questions);
1839
+ } else if (isObservable(questions)) {
1840
+ obs = questions;
1841
+ } else if (Object.values(questions).every(
1842
+ (maybeQuestion) => typeof maybeQuestion === "object" && !Array.isArray(maybeQuestion) && maybeQuestion != null
1843
+ )) {
1844
+ obs = from2(
1845
+ Object.entries(questions).map(([name, question]) => ({
1846
+ name,
1847
+ ...question
1848
+ }))
1849
+ );
1850
+ } else {
1851
+ obs = from2([questions]);
1852
+ }
1853
+ this.process = obs.pipe(
1854
+ concatMap(this.processQuestion.bind(this)),
1855
+ publish()
1856
+ // Creates a hot Observable. It prevents duplicating prompts.
1857
+ );
1858
+ this.process.connect();
1859
+ return this.process.pipe(
1860
+ reduce((answersObj, answer) => {
1861
+ _.set(answersObj, answer.name, answer.answer);
1862
+ return answersObj;
1863
+ }, this.answers)
1864
+ ).toPromise(Promise).then(this.onCompletion.bind(this), this.onError.bind(this));
1865
+ }
1866
+ /**
1867
+ * Once all prompt are over
1868
+ */
1869
+ onCompletion() {
1870
+ this.close();
1871
+ return this.answers;
1872
+ }
1873
+ onError(error) {
1874
+ this.close();
1875
+ return Promise.reject(error);
1876
+ }
1877
+ processQuestion(question) {
1878
+ question = { ...question };
1879
+ return defer(() => {
1880
+ const obs = of2(question);
1881
+ return obs.pipe(
1882
+ concatMap(this.setDefaultType.bind(this)),
1883
+ concatMap(this.filterIfRunnable.bind(this)),
1884
+ concatMap(
1885
+ () => fetchAsyncQuestionProperty(question, "message", this.answers)
1886
+ ),
1887
+ concatMap(
1888
+ () => fetchAsyncQuestionProperty(question, "default", this.answers)
1889
+ ),
1890
+ concatMap(
1891
+ () => fetchAsyncQuestionProperty(question, "choices", this.answers)
1892
+ ),
1893
+ concatMap(this.fetchAnswer.bind(this))
1894
+ );
1895
+ });
1896
+ }
1897
+ fetchAnswer(question) {
1898
+ const Prompt2 = this.prompts[question.type];
1899
+ this.activePrompt = new Prompt2(question, this.rl, this.answers);
1900
+ return defer(
1901
+ () => from2(this.activePrompt.run().then((answer) => ({ name: question.name, answer })))
1902
+ );
1903
+ }
1904
+ setDefaultType(question) {
1905
+ if (!this.prompts[question.type]) {
1906
+ question.type = "input";
1907
+ }
1908
+ return defer(() => of2(question));
1909
+ }
1910
+ filterIfRunnable(question) {
1911
+ if (question.askAnswered !== true && _.get(this.answers, question.name) !== void 0) {
1912
+ return EMPTY;
1913
+ }
1914
+ if (question.when === false) {
1915
+ return EMPTY;
1916
+ }
1917
+ if (typeof question.when !== "function") {
1918
+ return of2(question);
1919
+ }
1920
+ const { answers } = this;
1921
+ return defer(
1922
+ () => from2(
1923
+ runAsync4(question.when)(answers).then((shouldRun) => {
1924
+ if (shouldRun) {
1925
+ return question;
1926
+ }
1927
+ })
1928
+ ).pipe(filter3((val) => val != null))
1929
+ );
1930
+ }
1931
+ };
1932
+ }
1933
+ });
1934
+
1935
+ // node_modules/inquirer/lib/index.js
1936
+ var lib_exports = {};
1937
+ __export(lib_exports, {
1938
+ createPromptModule: () => createPromptModule,
1939
+ default: () => lib_default
1940
+ });
1941
+ function createPromptModule(opt) {
1942
+ const promptModule = function(questions, answers) {
1943
+ let uiInstance;
1944
+ try {
1945
+ uiInstance = new PromptUI(promptModule.prompts, opt);
1946
+ } catch (error) {
1947
+ return Promise.reject(error);
1948
+ }
1949
+ const promise = uiInstance.run(questions, answers);
1950
+ promise.ui = uiInstance;
1951
+ return promise;
1952
+ };
1953
+ promptModule.prompts = {};
1954
+ promptModule.registerPrompt = function(name, prompt2) {
1955
+ promptModule.prompts[name] = prompt2;
1956
+ return this;
1957
+ };
1958
+ promptModule.restoreDefaultPrompts = function() {
1959
+ this.registerPrompt("list", ListPrompt);
1960
+ this.registerPrompt("input", InputPrompt);
1961
+ this.registerPrompt("number", NumberPrompt);
1962
+ this.registerPrompt("confirm", ConfirmPrompt);
1963
+ this.registerPrompt("rawlist", RawListPrompt);
1964
+ this.registerPrompt("expand", ExpandPrompt);
1965
+ this.registerPrompt("checkbox", CheckboxPrompt);
1966
+ this.registerPrompt("password", PasswordPrompt);
1967
+ this.registerPrompt("editor", EditorPrompt);
1968
+ };
1969
+ promptModule.restoreDefaultPrompts();
1970
+ return promptModule;
1971
+ }
1972
+ function registerPrompt(name, newPrompt) {
1973
+ prompt.registerPrompt(name, newPrompt);
1974
+ }
1975
+ function restoreDefaultPrompts() {
1976
+ prompt.restoreDefaultPrompts();
1977
+ }
1978
+ var prompt, inquirer, lib_default;
1979
+ var init_lib = __esm({
1980
+ "node_modules/inquirer/lib/index.js"() {
1981
+ init_list();
1982
+ init_input();
1983
+ init_number();
1984
+ init_confirm();
1985
+ init_rawlist();
1986
+ init_expand();
1987
+ init_checkbox();
1988
+ init_password();
1989
+ init_editor();
1990
+ init_bottom_bar();
1991
+ init_prompt();
1992
+ init_separator();
1993
+ prompt = createPromptModule();
1994
+ inquirer = {
1995
+ prompt,
1996
+ ui: {
1997
+ BottomBar,
1998
+ Prompt: PromptUI
1999
+ },
2000
+ createPromptModule,
2001
+ registerPrompt,
2002
+ restoreDefaultPrompts,
2003
+ Separator
2004
+ };
2005
+ lib_default = inquirer;
2006
+ }
2007
+ });
2008
+
2009
+ // ../node_modules/@inquirer/select/dist/esm/index.mjs
2010
+ var esm_exports = {};
2011
+ __export(esm_exports, {
2012
+ Separator: () => Separator2,
2013
+ default: () => esm_default
2014
+ });
2015
+ import { createPrompt, useState, useKeypress, usePrefix, usePagination, useRef, useMemo, isEnterKey, isUpKey, isDownKey, isNumberKey, Separator as Separator2, makeTheme } from "@inquirer/core";
2016
+ import chalk2 from "chalk";
2017
+ import figures4 from "figures";
2018
+ import ansiEscapes5 from "ansi-escapes";
2019
+ function isSelectable(item) {
2020
+ return !Separator2.isSeparator(item) && !item.disabled;
2021
+ }
2022
+ var selectTheme, esm_default;
2023
+ var init_esm = __esm({
2024
+ "../node_modules/@inquirer/select/dist/esm/index.mjs"() {
2025
+ selectTheme = {
2026
+ icon: { cursor: figures4.pointer },
2027
+ style: { disabled: (text) => chalk2.dim(`- ${text}`) }
2028
+ };
2029
+ esm_default = createPrompt((config, done) => {
2030
+ const { choices: items, loop = true, pageSize = 7 } = config;
2031
+ const firstRender = useRef(true);
2032
+ const theme = makeTheme(selectTheme, config.theme);
2033
+ const prefix = usePrefix({ theme });
2034
+ const [status, setStatus] = useState("pending");
2035
+ const bounds = useMemo(() => {
2036
+ const first = items.findIndex(isSelectable);
2037
+ const last = items.length - 1 - [...items].reverse().findIndex(isSelectable);
2038
+ if (first < 0)
2039
+ throw new Error("[select prompt] No selectable choices. All choices are disabled.");
2040
+ return { first, last };
2041
+ }, [items]);
2042
+ const defaultItemIndex = useMemo(() => {
2043
+ if (!("default" in config))
2044
+ return -1;
2045
+ return items.findIndex((item) => isSelectable(item) && item.value === config.default);
2046
+ }, [config.default, items]);
2047
+ const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
2048
+ const selectedChoice = items[active];
2049
+ useKeypress((key) => {
2050
+ if (isEnterKey(key)) {
2051
+ setStatus("done");
2052
+ done(selectedChoice.value);
2053
+ } else if (isUpKey(key) || isDownKey(key)) {
2054
+ if (loop || isUpKey(key) && active !== bounds.first || isDownKey(key) && active !== bounds.last) {
2055
+ const offset = isUpKey(key) ? -1 : 1;
2056
+ let next = active;
2057
+ do {
2058
+ next = (next + offset + items.length) % items.length;
2059
+ } while (!isSelectable(items[next]));
2060
+ setActive(next);
2061
+ }
2062
+ } else if (isNumberKey(key)) {
2063
+ const position = Number(key.name) - 1;
2064
+ const item = items[position];
2065
+ if (item != null && isSelectable(item)) {
2066
+ setActive(position);
2067
+ }
2068
+ }
2069
+ });
2070
+ const message = theme.style.message(config.message);
2071
+ let helpTip;
2072
+ if (firstRender.current && items.length <= pageSize) {
2073
+ firstRender.current = false;
2074
+ helpTip = theme.style.help("(Use arrow keys)");
2075
+ }
2076
+ const page = usePagination({
2077
+ items,
2078
+ active,
2079
+ renderItem({ item, isActive }) {
2080
+ if (Separator2.isSeparator(item)) {
2081
+ return ` ${item.separator}`;
2082
+ }
2083
+ const line = item.name || item.value;
2084
+ if (item.disabled) {
2085
+ const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
2086
+ return theme.style.disabled(`${line} ${disabledLabel}`);
2087
+ }
2088
+ const color = isActive ? theme.style.highlight : (x) => x;
2089
+ const cursor = isActive ? theme.icon.cursor : ` `;
2090
+ return color(`${cursor} ${line}`);
2091
+ },
2092
+ pageSize,
2093
+ loop,
2094
+ theme
2095
+ });
2096
+ if (status === "done") {
2097
+ const answer = selectedChoice.name || // TODO: Could we enforce that at the type level? Name should be defined for non-string values.
2098
+ String(selectedChoice.value);
2099
+ return `${prefix} ${message} ${theme.style.answer(answer)}`;
2100
+ }
2101
+ const choiceDescription = selectedChoice.description ? `
2102
+ ${selectedChoice.description}` : ``;
2103
+ return `${[prefix, message, helpTip].filter(Boolean).join(" ")}
2104
+ ${page}${choiceDescription}${ansiEscapes5.cursorHide}`;
2105
+ });
2106
+ }
2107
+ });
2
2108
 
3
2109
  // src/lib/instrument.ts
4
2110
  import * as Sentry from "@sentry/node";
@@ -45,7 +2151,6 @@ import { createIgnoreFilter } from "@hubspot/local-dev-lib/ignoreRules";
45
2151
  import { isAllowedExtension } from "@hubspot/local-dev-lib/path";
46
2152
  import { isConvertableFieldJs } from "@hubspot/local-dev-lib/cms/handleFieldsJS";
47
2153
  import { escapeRegExp } from "@hubspot/local-dev-lib/escapeRegExp";
48
- import inquirer from "inquirer";
49
2154
  import { getThemeJSONPath } from "@hubspot/local-dev-lib/cms/themes";
50
2155
  import findup from "findup-sync";
51
2156
  import { getAbsoluteFilePath } from "@hubspot/local-dev-lib/path";
@@ -357,9 +2462,10 @@ async function getUploadableFileList(src, convertFields) {
357
2462
  }
358
2463
  return uploadableFiles;
359
2464
  }
360
- function promptUser(promptConfig) {
361
- const prompt = inquirer.createPromptModule();
362
- return prompt(promptConfig);
2465
+ async function promptUser(promptConfig) {
2466
+ const { default: inquirer2 } = await Promise.resolve().then(() => (init_lib(), lib_exports));
2467
+ const prompt2 = inquirer2.createPromptModule();
2468
+ return prompt2(promptConfig);
363
2469
  }
364
2470
  async function fieldsJsPrompt(filePath, projectDir, skipFiles = []) {
365
2471
  const FIELDS_FILES = ["fields.json", "fields.js", "fields.cjs", "fields.mjs"];
@@ -896,7 +3002,7 @@ function packagePath(metaUrl, projectPath) {
896
3002
  );
897
3003
  }
898
3004
 
899
- // ../cms-js-internal/dist/types-B-d4FeeE.js
3005
+ // ../cms-js-internal/dist/types-Dvw_fW6p.js
900
3006
  import path4 from "path";
901
3007
  import { createHash } from "crypto";
902
3008
  import fs3, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
@@ -1147,6 +3253,13 @@ function isFullHeightPreviewEnabled(config) {
1147
3253
  }
1148
3254
  return false;
1149
3255
  }
3256
+ function isLocalUiDisabled(config) {
3257
+ var _a;
3258
+ if ("devServer" in config) {
3259
+ return ((_a = config.devServer) == null ? void 0 : _a.disableLocalUi) ?? false;
3260
+ }
3261
+ return false;
3262
+ }
1150
3263
  var ENABLED_FEATURES_GATE_MAP = {
1151
3264
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
1152
3265
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
@@ -1463,7 +3576,7 @@ function noncePlaceholderPlugin() {
1463
3576
  },
1464
3577
  transformIndexHtml(html) {
1465
3578
  const regex = /<(style|script|link) (.*)>/gi;
1466
- const replacer = (_, p1, p2) => {
3579
+ const replacer = (_2, p1, p2) => {
1467
3580
  if (p1 === "style" || p1 === "script" || // if link, only nonce for stylesheet
1468
3581
  p1 === "link" && p2.includes('rel="stylesheet"')) {
1469
3582
  const noncePlaceholderValue = p1 === "script" ? "hs-random-nonce" : "hs-random-style-nonce";
@@ -2255,7 +4368,7 @@ function trackUsage(action) {
2255
4368
  eventName: EVENT_NAME,
2256
4369
  action,
2257
4370
  nodeVersion: getNodeVersionData(),
2258
- version: "1.2.76",
4371
+ version: "1.2.78",
2259
4372
  os: getPlatform()
2260
4373
  };
2261
4374
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -3695,8 +5808,84 @@ function extractRelevantCss(cssText) {
3695
5808
  return output;
3696
5809
  }
3697
5810
 
5811
+ // src/lib/htmlExtract.ts
5812
+ import { parse as parse2, serializeOuter } from "parse5";
5813
+ function parseHtml(html) {
5814
+ return parse2(html);
5815
+ }
5816
+ function isElement(node) {
5817
+ return typeof node.tagName === "string";
5818
+ }
5819
+ function getAttr(node, name) {
5820
+ var _a, _b;
5821
+ return (_b = (_a = node.attrs) == null ? void 0 : _a.find((a) => a.name === name)) == null ? void 0 : _b.value;
5822
+ }
5823
+ function findFirst(node, predicate) {
5824
+ if (predicate(node))
5825
+ return node;
5826
+ if (node.childNodes) {
5827
+ for (const child of node.childNodes) {
5828
+ const match = findFirst(child, predicate);
5829
+ if (match)
5830
+ return match;
5831
+ }
5832
+ }
5833
+ return null;
5834
+ }
5835
+ function findAll(node, predicate) {
5836
+ const out = [];
5837
+ const visit = (n) => {
5838
+ var _a;
5839
+ if (predicate(n))
5840
+ out.push(n);
5841
+ (_a = n.childNodes) == null ? void 0 : _a.forEach(visit);
5842
+ };
5843
+ visit(node);
5844
+ return out;
5845
+ }
5846
+ function textContent(node) {
5847
+ let out = "";
5848
+ const visit = (n) => {
5849
+ var _a;
5850
+ if (n.nodeName === "#text" && typeof n.value === "string")
5851
+ out += n.value;
5852
+ (_a = n.childNodes) == null ? void 0 : _a.forEach(visit);
5853
+ };
5854
+ visit(node);
5855
+ return out;
5856
+ }
5857
+ function hasAncestor(node, predicate) {
5858
+ let p = node.parentNode;
5859
+ while (p) {
5860
+ if (predicate(p))
5861
+ return true;
5862
+ p = p.parentNode ?? null;
5863
+ }
5864
+ return false;
5865
+ }
5866
+ function extractModuleOuterHtml(root) {
5867
+ const el = findFirst(
5868
+ root,
5869
+ (n) => isElement(n) && n.tagName === "div" && getAttr(n, "data-hs-cos-type") === "module"
5870
+ );
5871
+ if (!el) {
5872
+ throw new Error(
5873
+ 'module node (div[data-hs-cos-type="module"]) not found in preview HTML'
5874
+ );
5875
+ }
5876
+ return serializeOuter(el);
5877
+ }
5878
+ function extractStyleText(root, opts = {}) {
5879
+ let styles = findAll(root, (n) => isElement(n) && n.tagName === "style");
5880
+ if (opts.headOnly) {
5881
+ styles = styles.filter(
5882
+ (s) => hasAncestor(s, (a) => isElement(a) && a.tagName === "head")
5883
+ );
5884
+ }
5885
+ return styles.map((s) => textContent(s)).join("\n");
5886
+ }
5887
+
3698
5888
  // src/lib/renderModulePreview.ts
3699
- import jsdom from "jsdom";
3700
5889
  var DEFAULT_SECTION_VARIANT = "section1";
3701
5890
  var _webDefaultStylesCss = null;
3702
5891
  function getWebDefaultStylesCss(metaUrl) {
@@ -3758,7 +5947,6 @@ async function signedGet(authedPortalId, unsignedUrl, headers, gates) {
3758
5947
  }
3759
5948
  return await response.text();
3760
5949
  }
3761
- var { JSDOM } = jsdom;
3762
5950
  async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue, gates) {
3763
5951
  const moduleInfoQueryParams = new URLSearchParams({
3764
5952
  portalId: `${authedPortalId}`
@@ -3811,13 +5999,9 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
3811
5999
  }
3812
6000
  }
3813
6001
  }
3814
- const dom = new JSDOM(modulePreviewHtml);
3815
- const modulePreviewContent = dom.window.document.querySelector(
3816
- 'div[data-hs-cos-type="module"]'
3817
- ).outerHTML;
3818
- const allStyleContent = Array.from(
3819
- dom.window.document.querySelectorAll("style")
3820
- ).map((element) => element.textContent || "").join("\n");
6002
+ const previewDoc = parseHtml(modulePreviewHtml);
6003
+ const modulePreviewContent = extractModuleOuterHtml(previewDoc);
6004
+ const allStyleContent = extractStyleText(previewDoc);
3821
6005
  const filteredCss = extractRelevantCss(allStyleContent);
3822
6006
  const cssNeeded = filteredCss ? `<style>${filteredCss}</style>` : "";
3823
6007
  return { html: modulePreviewContent, cssNeeded };
@@ -3942,10 +6126,9 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
3942
6126
  );
3943
6127
  }
3944
6128
  localRenderPlaceholders[0].json.props.fieldValues = localFieldValues;
3945
- const previewDom = new JSDOM(templatePreview);
3946
- const allStyleContent = Array.from(
3947
- previewDom.window.document.querySelectorAll("head style")
3948
- ).map((element) => element.textContent || "").join("\n");
6129
+ const allStyleContent = extractStyleText(parseHtml(templatePreview), {
6130
+ headOnly: true
6131
+ });
3949
6132
  const filteredCss = extractRelevantCss(allStyleContent);
3950
6133
  const themeVariablesCss = filteredCss ? `<style data-hs-styles="theme-variables">${filteredCss}</style>` : "";
3951
6134
  const webDefaultStylesCss = meta.editor_version === "2.0" ? getWebDefaultStylesCss(import.meta.url) : "";
@@ -5503,7 +7686,7 @@ async function getDevServerUIData(appLocals) {
5503
7686
  runCommand: `${runCommand} ${scriptName}`
5504
7687
  })
5505
7688
  ) : [];
5506
- reactModules = projectName ? await mapReactModules(modulesData, themeWebRoot, appViteServer) : [];
7689
+ reactModules = projectName && appViteServer ? await mapReactModules(modulesData, themeWebRoot, appViteServer) : [];
5507
7690
  }
5508
7691
  let hubLModuleData = { objects: [] };
5509
7692
  let hubLTemplateData = { objects: [] };
@@ -5562,6 +7745,11 @@ var appServerRouteHandler = async (req, res, __next) => {
5562
7745
  const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
5563
7746
  render = ssrRender;
5564
7747
  } else {
7748
+ if (!appViteServer) {
7749
+ throw new Error(
7750
+ "appViteServer is required to render the dev server UI in development"
7751
+ );
7752
+ }
5565
7753
  template = await appViteServer.transformIndexHtml(url3, template);
5566
7754
  render = (await appViteServer.ssrLoadModule(serverEntryPath)).render;
5567
7755
  }
@@ -5612,12 +7800,14 @@ var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
5612
7800
  if (isProd2) {
5613
7801
  const distAssetsPath = path15.join(appWebRoot, "assets");
5614
7802
  devServerApp.use("/assets", expressStatic(distAssetsPath));
5615
- } else {
7803
+ } else if (appViteServer) {
5616
7804
  devServerApp.use("/local", appViteServer.middlewares);
5617
7805
  }
5618
7806
  devServerApp.use(viteServer.middlewares);
5619
7807
  devServerApp.use("/api", createAppServerAPIRoutes_default());
5620
- devServerApp.get("/", appServerRouteHandler_default);
7808
+ if (appViteServer) {
7809
+ devServerApp.get("/", appServerRouteHandler_default);
7810
+ }
5621
7811
  devServerApp.get("/legacy", legacyRouteHandler_default);
5622
7812
  devServerApp.get("/proxy", proxyPathPageRouteHandler);
5623
7813
  devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
@@ -5723,7 +7913,7 @@ async function createShadowDevServerRoutes(devServerPort, themePath) {
5723
7913
 
5724
7914
  // src/shadowDevServer/startShadowDevServer.ts
5725
7915
  var testNetServer = net.createServer();
5726
- async function startShadowDevServer(devServerPort, shadowPort, themePath) {
7916
+ async function startShadowDevServer(devServerPort, shadowPort, themePath, host) {
5727
7917
  const portIsTaken = await new Promise((res, rej) => {
5728
7918
  console.log(`Starting proxy link server on port ${shadowPort}`);
5729
7919
  testNetServer.once("error", (err) => {
@@ -5742,13 +7932,13 @@ async function startShadowDevServer(devServerPort, shadowPort, themePath) {
5742
7932
  testNetServer.once("close", () => {
5743
7933
  res(false);
5744
7934
  });
5745
- testNetServer.listen(shadowPort);
7935
+ testNetServer.listen(shadowPort, host);
5746
7936
  });
5747
7937
  if (portIsTaken) {
5748
7938
  return;
5749
7939
  }
5750
7940
  const shadowDevServer = express();
5751
- shadowDevServer.listen(shadowPort);
7941
+ shadowDevServer.listen(shadowPort, host);
5752
7942
  shadowDevServer.use(
5753
7943
  "/",
5754
7944
  await createShadowDevServerRoutes(devServerPort, themePath)
@@ -5976,7 +8166,6 @@ async function fetchWebsiteDomainNames(portalId) {
5976
8166
  // src/lib/validateHSPlatform.ts
5977
8167
  import path16 from "path";
5978
8168
  import fs8 from "fs";
5979
- import select from "@inquirer/select";
5980
8169
  import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
5981
8170
  var HSPROJECT_JSON = "hsproject.json";
5982
8171
  function checkFileExists(filePath) {
@@ -5999,7 +8188,7 @@ function findHSProjectJson(startPath) {
5999
8188
  );
6000
8189
  return null;
6001
8190
  }
6002
- async function validateHSPlatform(projectConfigPath, portalId) {
8191
+ async function validateHSPlatform(projectConfigPath, portalId, deferSelection) {
6003
8192
  if (projectConfigPath === null) {
6004
8193
  console.log(
6005
8194
  `Unable to find local ${HSPROJECT_JSON}, skipping platform version validation.`
@@ -6023,29 +8212,37 @@ async function validateHSPlatform(projectConfigPath, portalId) {
6023
8212
  return false;
6024
8213
  }
6025
8214
  if (platformVersion === void 0 || !platformVersionResult.activePlatformVersions.includes(platformVersion)) {
6026
- const answer = await select({
6027
- message: 'Your local "hsproject.json" does not have a valid platform version, please select a valid platform version. You can read more about Platform Versioning here https://developers.hubspot.com/docs/platform/platform-versioning',
6028
- choices: platformVersionResult.activePlatformVersions.map(
6029
- (versionNumber) => ({
6030
- name: versionNumber,
6031
- value: versionNumber
6032
- })
6033
- )
6034
- });
6035
- hsProjectJSONData.platformVersion = answer;
6036
- try {
6037
- fs8.writeFileSync(
6038
- projectConfigPath,
6039
- JSON.stringify(hsProjectJSONData, void 0, 2),
6040
- "utf8"
6041
- );
6042
- return true;
6043
- } catch (e) {
6044
- console.error(
6045
- `unable to write updated valid platform version, please make sure platformVersion in "${HSPROJECT_JSON}" is one of ${platformVersionResult.activePlatformVersions}`
6046
- );
8215
+ const promptAndWrite = async () => {
8216
+ const { default: select } = await Promise.resolve().then(() => (init_esm(), esm_exports));
8217
+ const answer = await select({
8218
+ message: 'Your local "hsproject.json" does not have a valid platform version, please select a valid platform version. You can read more about Platform Versioning here https://developers.hubspot.com/docs/platform/platform-versioning',
8219
+ choices: platformVersionResult.activePlatformVersions.map(
8220
+ (versionNumber) => ({
8221
+ name: versionNumber,
8222
+ value: versionNumber
8223
+ })
8224
+ )
8225
+ });
8226
+ hsProjectJSONData.platformVersion = answer;
8227
+ try {
8228
+ fs8.writeFileSync(
8229
+ projectConfigPath,
8230
+ JSON.stringify(hsProjectJSONData, void 0, 2),
8231
+ "utf8"
8232
+ );
8233
+ return true;
8234
+ } catch (e) {
8235
+ console.error(
8236
+ `unable to write updated valid platform version, please make sure platformVersion in "${HSPROJECT_JSON}" is one of ${platformVersionResult.activePlatformVersions}`
8237
+ );
8238
+ return false;
8239
+ }
8240
+ };
8241
+ if (deferSelection) {
8242
+ deferSelection(promptAndWrite);
6047
8243
  return false;
6048
8244
  }
8245
+ return promptAndWrite();
6049
8246
  }
6050
8247
  return true;
6051
8248
  }
@@ -6100,6 +8297,7 @@ var fieldTypeNameByType = {
6100
8297
  textalignment: "TextAlignmentFieldType",
6101
8298
  text: "TextFieldType",
6102
8299
  url: "UrlFieldType",
8300
+ variantselection: "VariantSelectionFieldType",
6103
8301
  videoplayer: "VideoFieldType",
6104
8302
  workflow: "WorkflowFieldType"
6105
8303
  };
@@ -6215,7 +8413,7 @@ function getFieldTypes(fields) {
6215
8413
  if (field.children) {
6216
8414
  const childrenResult = getFieldTypes(field.children);
6217
8415
  imports.push(...childrenResult.imports);
6218
- if (childrenResult.types.length) {
8416
+ if (childrenResult.types.length || field.type === "GroupFieldType") {
6219
8417
  const subType = ts.factory.createTypeLiteralNode(childrenResult.types);
6220
8418
  const { type: type2, imports: newImports2 } = buildTypeFromField(
6221
8419
  field,
@@ -6298,7 +8496,7 @@ function writeFieldsType(fields, fileName, typeName) {
6298
8496
  // src/lib/watchFieldsUpdates.ts
6299
8497
  import fs9 from "fs";
6300
8498
  import path17 from "path";
6301
- import readline from "readline";
8499
+ import readline2 from "readline";
6302
8500
  var lastSerializedFieldsCache = {};
6303
8501
  var formatAsTypeName = (str) => {
6304
8502
  const typeName = `${str.replace(/[^a-zA-Z0-9_$]/g, "_")}FieldsType`;
@@ -6321,7 +8519,7 @@ var fileContainsAutoGenComment = async (filePath) => {
6321
8519
  if (!fs9.existsSync(filePath))
6322
8520
  return true;
6323
8521
  const stream2 = fs9.createReadStream(filePath);
6324
- const reader = readline.createInterface({ input: stream2 });
8522
+ const reader = readline2.createInterface({ input: stream2 });
6325
8523
  const firstLine = await new Promise(
6326
8524
  (resolve3) => reader.once("line", (line) => resolve3(line.trim()))
6327
8525
  );
@@ -6422,6 +8620,7 @@ function getSecretNamesFromConfig(config) {
6422
8620
  // src/createDevServer.ts
6423
8621
  var BASE_PATH = "/";
6424
8622
  var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
8623
+ var DEV_SERVER_HOST = process.env.CMS_DEV_SERVER_HOST || "127.0.0.1";
6425
8624
  var SHADOW_PORT = 1442;
6426
8625
  var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
6427
8626
  function getWebRootProjectComponentFolder(absoluteWebRoot, projectConfigPath) {
@@ -6491,22 +8690,46 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
6491
8690
  }
6492
8691
  authedEnv = env2;
6493
8692
  personalAccessKey = (account == null ? void 0 : account.authType) === PERSONAL_ACCESS_KEY_AUTH_METHOD.value ? account == null ? void 0 : account.personalAccessKey : null;
6494
- if (personalAccessKey) {
8693
+ } else {
8694
+ console.warn(
8695
+ `Couldn't find an account to use, make sure there is hubspot.config.yaml in this folder (or a parent).
8696
+ If needed you can refer to another config file with --config.
8697
+
8698
+ Local proxy functionality and module preview routes will not work without setting up authentication. You can work purely on modules locally at "/module/[module_name]", however the experience may be degraded due to missing account data.`
8699
+ );
8700
+ secretNames = secretNamesFromConfig;
8701
+ }
8702
+ setTrackingInfo(authedPortalId, authedEnv);
8703
+ sendTrackingRequest("start-dev-server");
8704
+ const absoluteWebRoot = normalizePath10(path18.resolve(process.cwd(), webRoot2));
8705
+ const projectConfigPath = findHSProjectJson(absoluteWebRoot);
8706
+ const webRootProjectComponentFolder = getWebRootProjectComponentFolder(
8707
+ absoluteWebRoot,
8708
+ projectConfigPath
8709
+ );
8710
+ let domainsToProxy = [];
8711
+ let authedHublet = "na1";
8712
+ let platformVersionPrompt = null;
8713
+ const bootTasks = [];
8714
+ if (isValid && personalAccessKey) {
8715
+ const portalId = authedPortalId;
8716
+ const env2 = authedEnv;
8717
+ const pak = personalAccessKey;
8718
+ bootTasks.push(async () => {
6495
8719
  try {
6496
- jsRenderingGates = await getJsRenderingGates(
6497
- authedPortalId,
6498
- authedEnv,
6499
- personalAccessKey
6500
- );
8720
+ jsRenderingGates = await getJsRenderingGates(portalId, env2, pak);
6501
8721
  } catch (e) {
6502
8722
  console.warn(
6503
8723
  `Unable to get gating information. Gated features will not be available in the local dev server.`
6504
8724
  );
6505
8725
  }
6506
- }
6507
- if (cmsAssetConfig) {
8726
+ });
8727
+ }
8728
+ if (isValid && cmsAssetConfig) {
8729
+ const portalId = authedPortalId;
8730
+ bootTasks.push(async () => {
6508
8731
  try {
6509
- const secretsResponse = (await fetchSecrets(authedPortalId)).data;
8732
+ const secretsResponse = (await fetchSecrets(portalId)).data;
6510
8733
  if (secretNamesFromConfig && secretsResponse) {
6511
8734
  secretNames = secretsResponse.results.filter(
6512
8735
  (secretName) => secretNamesFromConfig.includes(secretName)
@@ -6526,54 +8749,51 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
6526
8749
  handleSecretsError(e);
6527
8750
  console.log(e);
6528
8751
  }
6529
- }
6530
- } else {
6531
- console.warn(
6532
- `Couldn't find an account to use, make sure there is hubspot.config.yaml in this folder (or a parent).
6533
- If needed you can refer to another config file with --config.
6534
-
6535
- Local proxy functionality and module preview routes will not work without setting up authentication. You can work purely on modules locally at "/module/[module_name]", however the experience may be degraded due to missing account data.`
6536
- );
6537
- secretNames = secretNamesFromConfig;
8752
+ });
6538
8753
  }
6539
- setTrackingInfo(authedPortalId, authedEnv);
6540
- sendTrackingRequest("start-dev-server");
6541
- let domainsToProxy = [];
6542
8754
  if (authedPortalId) {
6543
- try {
6544
- const portalDomains = await fetchWebsiteDomainNames(authedPortalId);
6545
- domainsToProxy = (process.env.DOMAINS_TO_PROXY || "").split(",").filter((d) => !!d);
6546
- domainsToProxy = [...domainsToProxy, ...portalDomains];
6547
- } catch (e) {
6548
- if (e instanceof MissingScopeError) {
6549
- logMissingScopeWarning(e);
6550
- } else {
6551
- const failedDomainFetchMessages = [
6552
- "Failed to fetch the portal's domains, as a result:",
6553
- "- HTTPS proxying won't work with them.",
6554
- "- Proxying to serverless functions won't work."
6555
- ].map((msg) => wrapMessageInColor("yellow", msg)).join("\n");
6556
- console.warn(failedDomainFetchMessages);
8755
+ const portalId = authedPortalId;
8756
+ bootTasks.push(async () => {
8757
+ try {
8758
+ const portalDomains = await fetchWebsiteDomainNames(portalId);
8759
+ domainsToProxy = (process.env.DOMAINS_TO_PROXY || "").split(",").filter((d) => !!d);
8760
+ domainsToProxy = [...domainsToProxy, ...portalDomains];
8761
+ } catch (e) {
8762
+ if (e instanceof MissingScopeError) {
8763
+ logMissingScopeWarning(e);
8764
+ } else {
8765
+ const failedDomainFetchMessages = [
8766
+ "Failed to fetch the portal's domains, as a result:",
8767
+ "- HTTPS proxying won't work with them.",
8768
+ "- Proxying to serverless functions won't work."
8769
+ ].map((msg) => wrapMessageInColor("yellow", msg)).join("\n");
8770
+ console.warn(failedDomainFetchMessages);
8771
+ }
6557
8772
  }
6558
- }
6559
- }
6560
- let authedHublet;
6561
- try {
6562
- const accountInformation = (await hsCliHttp12.get(authedPortalId, {
6563
- url: "/account-info/v3/details"
6564
- })).data;
6565
- authedHublet = accountInformation.dataHostingLocation;
6566
- } catch (e) {
6567
- authedHublet = "na1";
8773
+ });
8774
+ bootTasks.push(async () => {
8775
+ try {
8776
+ const accountInformation = (await hsCliHttp12.get(portalId, {
8777
+ url: "/account-info/v3/details"
8778
+ })).data;
8779
+ authedHublet = accountInformation.dataHostingLocation;
8780
+ } catch (e) {
8781
+ authedHublet = "na1";
8782
+ }
8783
+ });
8784
+ bootTasks.push(async () => {
8785
+ await validateHSPlatform(
8786
+ projectConfigPath,
8787
+ portalId,
8788
+ (promptAndWrite) => {
8789
+ platformVersionPrompt = promptAndWrite;
8790
+ }
8791
+ );
8792
+ });
6568
8793
  }
6569
- const absoluteWebRoot = normalizePath10(path18.resolve(process.cwd(), webRoot2));
6570
- const projectConfigPath = findHSProjectJson(absoluteWebRoot);
6571
- const webRootProjectComponentFolder = getWebRootProjectComponentFolder(
6572
- absoluteWebRoot,
6573
- projectConfigPath
6574
- );
6575
- if (authedPortalId) {
6576
- await validateHSPlatform(projectConfigPath, authedPortalId);
8794
+ await Promise.all(bootTasks.map((task) => task()));
8795
+ if (platformVersionPrompt) {
8796
+ await platformVersionPrompt();
6577
8797
  }
6578
8798
  let _localPreviewToken = null;
6579
8799
  let _tokenStatus;
@@ -6626,11 +8846,8 @@ Local proxy functionality and module preview routes will not work without settin
6626
8846
  if (true) {
6627
8847
  appWebRoot = path18.join(__dirname, "app");
6628
8848
  }
6629
- const appViteServer = await createAppServer_default(
6630
- appWebRoot,
6631
- PORT,
6632
- sslEnabledOption2
6633
- );
8849
+ const skipUiServer = isLocalUiDisabled(cmsAssetConfig);
8850
+ const appViteServer = skipUiServer ? null : await createAppServer_default(appWebRoot, PORT, sslEnabledOption2);
6634
8851
  const appLocals = {
6635
8852
  themeWebRoot: absoluteWebRoot,
6636
8853
  authedPortalId,
@@ -6659,7 +8876,7 @@ Local proxy functionality and module preview routes will not work without settin
6659
8876
  { key: httpsKey, cert: httpsCert },
6660
8877
  expressServer
6661
8878
  );
6662
- server.listen(PORT);
8879
+ server.listen(PORT, DEV_SERVER_HOST);
6663
8880
  httpServers.push(server);
6664
8881
  httpServers.push(innerHTTPServer);
6665
8882
  httpServers.push(innerHTTPSServer);
@@ -6669,14 +8886,15 @@ Local proxy functionality and module preview routes will not work without settin
6669
8886
  }
6670
8887
  } else {
6671
8888
  const httpServer = http3.createServer(expressServer);
6672
- httpServer.listen(PORT);
8889
+ httpServer.listen(PORT, DEV_SERVER_HOST);
6673
8890
  httpServers.push(httpServer);
6674
8891
  }
6675
8892
  if (!process.env.IN_CODESANDBOX && !process.env.CODESANDBOX_HOST) {
6676
8893
  startShadowDevServer(
6677
8894
  PORT,
6678
8895
  SHADOW_PORT,
6679
- themePreviewOptions2 ? themePreviewOptions2.dest : ""
8896
+ themePreviewOptions2 ? themePreviewOptions2.dest : "",
8897
+ DEV_SERVER_HOST
6680
8898
  );
6681
8899
  }
6682
8900
  let extraServerInfo = "";
@@ -6768,7 +8986,7 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
6768
8986
  return Promise.allSettled([
6769
8987
  ...serverClosePromises,
6770
8988
  viteServer.close(),
6771
- appViteServer.close()
8989
+ appViteServer ? appViteServer.close() : Promise.resolve()
6772
8990
  ]);
6773
8991
  }
6774
8992
  };