@wix/cli 1.1.58 → 1.1.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/build/DevCommand-D6QHU2YA.js +7561 -0
  2. package/build/DevCommand-D6QHU2YA.js.map +1 -0
  3. package/build/{DevCommand-32POU3TX.js → DevCommand-PLIPWJKO.js} +14 -15
  4. package/build/{DevCommand-32POU3TX.js.map → DevCommand-PLIPWJKO.js.map} +1 -1
  5. package/build/{LoginCommand-WRCKEWCE.js → LoginCommand-NRZ4VWWM.js} +12 -12
  6. package/build/{LogoutCommand-BYWH527O.js → LogoutCommand-INOYIE67.js} +8 -8
  7. package/build/{WhoamiCommand-WKXZCRSJ.js → WhoamiCommand-4V4GTNFW.js} +4 -4
  8. package/build/{chunk-JMUOY2KY.js → chunk-3RBFRZE2.js} +8 -8
  9. package/build/{chunk-JMUOY2KY.js.map → chunk-3RBFRZE2.js.map} +1 -1
  10. package/build/{chunk-X7GWN4JO.js → chunk-4HVBZRJL.js} +2 -2
  11. package/build/{chunk-CQHI53JJ.js → chunk-4OBSJ6OG.js} +5043 -659
  12. package/build/chunk-4OBSJ6OG.js.map +1 -0
  13. package/build/{chunk-LOJ4G3VD.js → chunk-5XUFGBCU.js} +2 -2
  14. package/build/{chunk-WYEQRRT2.js → chunk-5ZVEBKUO.js} +2829 -66
  15. package/build/chunk-5ZVEBKUO.js.map +1 -0
  16. package/build/{chunk-UQXJQCG3.js → chunk-AXVTET6V.js} +2 -2
  17. package/build/{chunk-53UCEZFU.js → chunk-BNWDAMAL.js} +175 -45
  18. package/build/chunk-BNWDAMAL.js.map +1 -0
  19. package/build/{chunk-MPSJ2YGQ.js → chunk-BV3B44QL.js} +3 -3
  20. package/build/{chunk-IRR7PD4K.js → chunk-CMXHWKEP.js} +3 -3
  21. package/build/{chunk-RJBLVNKS.js → chunk-CS26555F.js} +7 -7
  22. package/build/{chunk-BQ6AW6QJ.js → chunk-F3E4MMLD.js} +6 -6
  23. package/build/{chunk-3R4OZ46Z.js → chunk-G6TDIUNY.js} +2 -2
  24. package/build/{chunk-4S2ZMDZM.js → chunk-GLXEVSFE.js} +7 -7
  25. package/build/{chunk-OIH7DI4E.js → chunk-HYAIYTKF.js} +62 -6
  26. package/build/{chunk-OIH7DI4E.js.map → chunk-HYAIYTKF.js.map} +1 -1
  27. package/build/{chunk-24HYCAK2.js → chunk-JG7FKL4X.js} +3 -3
  28. package/build/{chunk-F63O2UMD.js → chunk-KCTZ5EX4.js} +401 -116
  29. package/build/chunk-KCTZ5EX4.js.map +1 -0
  30. package/build/{chunk-Q5WMVJRK.js → chunk-N5IXBRXL.js} +2 -2
  31. package/build/{chunk-KLWKSELB.js → chunk-OOGMXJJV.js} +6 -6
  32. package/build/{chunk-3KIPOGXI.js → chunk-PNUERA4W.js} +5 -5
  33. package/build/{chunk-WRMFR7CU.js → chunk-QGSHUCNV.js} +8 -8
  34. package/build/{chunk-KOCJZPLK.js → chunk-SELJR2HV.js} +2 -2
  35. package/build/{chunk-XU2RG4HE.js → chunk-T4OH34QF.js} +8 -2
  36. package/build/{chunk-XU2RG4HE.js.map → chunk-T4OH34QF.js.map} +1 -1
  37. package/build/{chunk-WZEZZAE4.js → chunk-U32RURCT.js} +126 -70
  38. package/build/chunk-U32RURCT.js.map +1 -0
  39. package/build/{chunk-5EXKEGN6.js → chunk-V4DAKO7L.js} +297 -440
  40. package/build/chunk-V4DAKO7L.js.map +1 -0
  41. package/build/{chunk-NK4U57KS.js → chunk-VEVISRHN.js} +5 -5
  42. package/build/{chunk-W32TRG4E.js → chunk-WN3D6AOY.js} +39 -25
  43. package/build/chunk-WN3D6AOY.js.map +1 -0
  44. package/build/{chunk-ZOWPPCOU.js → chunk-X7XOMWAQ.js} +5 -5
  45. package/build/{chunk-LC2NSYSB.js → chunk-YUFAOC35.js} +6 -6
  46. package/build/{chunk-KT54TL6D.js → chunk-Z7P6TDPB.js} +6 -6
  47. package/build/{dev-M7P6GT7S.js → dev-TEWYYBKR.js} +23 -24
  48. package/build/{dev-M7P6GT7S.js.map → dev-TEWYYBKR.js.map} +1 -1
  49. package/build/index.js +26 -26
  50. package/build/{install-SX7OQQGW.js → install-MTS6LPPU.js} +17 -17
  51. package/build/{preview-7WGCS2DK.js → preview-TDMPHSVV.js} +18 -18
  52. package/build/{publish-U7Y5KNMR.js → publish-5VLMBE6J.js} +18 -18
  53. package/build/{render-command-TJTVTOHT.js → render-command-7OMEGPW4.js} +11 -11
  54. package/build/{render-command-P4B7B4WB.js → render-command-FELGYBEY.js} +12 -12
  55. package/build/{render-command-6GZ7MNO5.js → render-command-UQPFUBIL.js} +12 -12
  56. package/build/{run-command-ZLQ3PKCS.js → run-command-3YTQS4ZX.js} +10 -10
  57. package/build/{src-WBDWTVY2.js → src-4W2WPIAM.js} +8 -8
  58. package/build/{src-JGFI4IQH.js → src-7NEL65ZK.js} +18 -18
  59. package/build/{src-Q3X5WF65.js → src-IBLQL7AB.js} +6 -6
  60. package/build/{src-WKNIYADZ.js → src-LA3GYOE6.js} +7 -7
  61. package/build/{src-5XWKD5UB.js → src-UWOBS6D7.js} +2 -2
  62. package/build/{src-I6QIZSAX.js → src-Y334LPF5.js} +7 -7
  63. package/build/sync-types-W3PVOJTK.js +30 -0
  64. package/build/{uninstall-L6JBTJHG.js → uninstall-M4DEVSQC.js} +16 -16
  65. package/package.json +5 -5
  66. package/build/DevCommand-WT3DJON6.js +0 -1040
  67. package/build/DevCommand-WT3DJON6.js.map +0 -1
  68. package/build/chunk-53UCEZFU.js.map +0 -1
  69. package/build/chunk-5EXKEGN6.js.map +0 -1
  70. package/build/chunk-CQHI53JJ.js.map +0 -1
  71. package/build/chunk-F63O2UMD.js.map +0 -1
  72. package/build/chunk-OUBPZBBH.js +0 -558
  73. package/build/chunk-OUBPZBBH.js.map +0 -1
  74. package/build/chunk-W32TRG4E.js.map +0 -1
  75. package/build/chunk-WYEQRRT2.js.map +0 -1
  76. package/build/chunk-WZEZZAE4.js.map +0 -1
  77. package/build/sync-types-6XPVFG3C.js +0 -31
  78. /package/build/{LoginCommand-WRCKEWCE.js.map → LoginCommand-NRZ4VWWM.js.map} +0 -0
  79. /package/build/{LogoutCommand-BYWH527O.js.map → LogoutCommand-INOYIE67.js.map} +0 -0
  80. /package/build/{WhoamiCommand-WKXZCRSJ.js.map → WhoamiCommand-4V4GTNFW.js.map} +0 -0
  81. /package/build/{chunk-X7GWN4JO.js.map → chunk-4HVBZRJL.js.map} +0 -0
  82. /package/build/{chunk-LOJ4G3VD.js.map → chunk-5XUFGBCU.js.map} +0 -0
  83. /package/build/{chunk-UQXJQCG3.js.map → chunk-AXVTET6V.js.map} +0 -0
  84. /package/build/{chunk-MPSJ2YGQ.js.map → chunk-BV3B44QL.js.map} +0 -0
  85. /package/build/{chunk-IRR7PD4K.js.map → chunk-CMXHWKEP.js.map} +0 -0
  86. /package/build/{chunk-RJBLVNKS.js.map → chunk-CS26555F.js.map} +0 -0
  87. /package/build/{chunk-BQ6AW6QJ.js.map → chunk-F3E4MMLD.js.map} +0 -0
  88. /package/build/{chunk-3R4OZ46Z.js.map → chunk-G6TDIUNY.js.map} +0 -0
  89. /package/build/{chunk-4S2ZMDZM.js.map → chunk-GLXEVSFE.js.map} +0 -0
  90. /package/build/{chunk-24HYCAK2.js.map → chunk-JG7FKL4X.js.map} +0 -0
  91. /package/build/{chunk-Q5WMVJRK.js.map → chunk-N5IXBRXL.js.map} +0 -0
  92. /package/build/{chunk-KLWKSELB.js.map → chunk-OOGMXJJV.js.map} +0 -0
  93. /package/build/{chunk-3KIPOGXI.js.map → chunk-PNUERA4W.js.map} +0 -0
  94. /package/build/{chunk-WRMFR7CU.js.map → chunk-QGSHUCNV.js.map} +0 -0
  95. /package/build/{chunk-KOCJZPLK.js.map → chunk-SELJR2HV.js.map} +0 -0
  96. /package/build/{chunk-NK4U57KS.js.map → chunk-VEVISRHN.js.map} +0 -0
  97. /package/build/{chunk-ZOWPPCOU.js.map → chunk-X7XOMWAQ.js.map} +0 -0
  98. /package/build/{chunk-LC2NSYSB.js.map → chunk-YUFAOC35.js.map} +0 -0
  99. /package/build/{chunk-KT54TL6D.js.map → chunk-Z7P6TDPB.js.map} +0 -0
  100. /package/build/{install-SX7OQQGW.js.map → install-MTS6LPPU.js.map} +0 -0
  101. /package/build/{preview-7WGCS2DK.js.map → preview-TDMPHSVV.js.map} +0 -0
  102. /package/build/{publish-U7Y5KNMR.js.map → publish-5VLMBE6J.js.map} +0 -0
  103. /package/build/{render-command-TJTVTOHT.js.map → render-command-7OMEGPW4.js.map} +0 -0
  104. /package/build/{render-command-P4B7B4WB.js.map → render-command-FELGYBEY.js.map} +0 -0
  105. /package/build/{render-command-6GZ7MNO5.js.map → render-command-UQPFUBIL.js.map} +0 -0
  106. /package/build/{run-command-ZLQ3PKCS.js.map → run-command-3YTQS4ZX.js.map} +0 -0
  107. /package/build/{src-5XWKD5UB.js.map → src-4W2WPIAM.js.map} +0 -0
  108. /package/build/{src-JGFI4IQH.js.map → src-7NEL65ZK.js.map} +0 -0
  109. /package/build/{src-Q3X5WF65.js.map → src-IBLQL7AB.js.map} +0 -0
  110. /package/build/{src-WKNIYADZ.js.map → src-LA3GYOE6.js.map} +0 -0
  111. /package/build/{src-WBDWTVY2.js.map → src-UWOBS6D7.js.map} +0 -0
  112. /package/build/{src-I6QIZSAX.js.map → src-Y334LPF5.js.map} +0 -0
  113. /package/build/{sync-types-6XPVFG3C.js.map → sync-types-W3PVOJTK.js.map} +0 -0
  114. /package/build/{uninstall-L6JBTJHG.js.map → uninstall-M4DEVSQC.js.map} +0 -0
@@ -182,10 +182,22 @@ var require_help = __commonJS({
182
182
  var Help2 = class {
183
183
  constructor() {
184
184
  this.helpWidth = void 0;
185
+ this.minWidthToWrap = 40;
185
186
  this.sortSubcommands = false;
186
187
  this.sortOptions = false;
187
188
  this.showGlobalOptions = false;
188
189
  }
190
+ /**
191
+ * prepareContext is called by Commander after applying overrides from `Command.configureHelp()`
192
+ * and just before calling `formatHelp()`.
193
+ *
194
+ * Commander just uses the helpWidth and the rest is provided for optional use by more complex subclasses.
195
+ *
196
+ * @param {{ error?: boolean, helpWidth?: number, outputHasColors?: boolean }} contextOptions
197
+ */
198
+ prepareContext(contextOptions) {
199
+ this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
200
+ }
189
201
  /**
190
202
  * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
191
203
  *
@@ -322,7 +334,12 @@ var require_help = __commonJS({
322
334
  */
323
335
  longestSubcommandTermLength(cmd, helper) {
324
336
  return helper.visibleCommands(cmd).reduce((max, command) => {
325
- return Math.max(max, helper.subcommandTerm(command).length);
337
+ return Math.max(
338
+ max,
339
+ this.displayWidth(
340
+ helper.styleSubcommandTerm(helper.subcommandTerm(command))
341
+ )
342
+ );
326
343
  }, 0);
327
344
  }
328
345
  /**
@@ -334,7 +351,10 @@ var require_help = __commonJS({
334
351
  */
335
352
  longestOptionTermLength(cmd, helper) {
336
353
  return helper.visibleOptions(cmd).reduce((max, option) => {
337
- return Math.max(max, helper.optionTerm(option).length);
354
+ return Math.max(
355
+ max,
356
+ this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))
357
+ );
338
358
  }, 0);
339
359
  }
340
360
  /**
@@ -346,7 +366,10 @@ var require_help = __commonJS({
346
366
  */
347
367
  longestGlobalOptionTermLength(cmd, helper) {
348
368
  return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
349
- return Math.max(max, helper.optionTerm(option).length);
369
+ return Math.max(
370
+ max,
371
+ this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option)))
372
+ );
350
373
  }, 0);
351
374
  }
352
375
  /**
@@ -358,7 +381,12 @@ var require_help = __commonJS({
358
381
  */
359
382
  longestArgumentTermLength(cmd, helper) {
360
383
  return helper.visibleArguments(cmd).reduce((max, argument) => {
361
- return Math.max(max, helper.argumentTerm(argument).length);
384
+ return Math.max(
385
+ max,
386
+ this.displayWidth(
387
+ helper.styleArgumentTerm(helper.argumentTerm(argument))
388
+ )
389
+ );
362
390
  }, 0);
363
391
  }
364
392
  /**
@@ -450,11 +478,11 @@ var require_help = __commonJS({
450
478
  );
451
479
  }
452
480
  if (extraInfo.length > 0) {
453
- const extraDescripton = `(${extraInfo.join(", ")})`;
481
+ const extraDescription = `(${extraInfo.join(", ")})`;
454
482
  if (argument.description) {
455
- return `${argument.description} ${extraDescripton}`;
483
+ return `${argument.description} ${extraDescription}`;
456
484
  }
457
- return extraDescripton;
485
+ return extraDescription;
458
486
  }
459
487
  return argument.description;
460
488
  }
@@ -467,75 +495,148 @@ var require_help = __commonJS({
467
495
  */
468
496
  formatHelp(cmd, helper) {
469
497
  const termWidth = helper.padWidth(cmd, helper);
470
- const helpWidth = helper.helpWidth || 80;
471
- const itemIndentWidth = 2;
472
- const itemSeparatorWidth = 2;
473
- function formatItem(term, description) {
474
- if (description) {
475
- const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
476
- return helper.wrap(
477
- fullText,
478
- helpWidth - itemIndentWidth,
479
- termWidth + itemSeparatorWidth
480
- );
481
- }
482
- return term;
483
- }
484
- function formatList(textArray) {
485
- return textArray.join("\n").replace(/^/gm, " ".repeat(itemIndentWidth));
486
- }
487
- let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
498
+ const helpWidth = helper.helpWidth ?? 80;
499
+ function callFormatItem(term, description) {
500
+ return helper.formatItem(term, termWidth, description, helper);
501
+ }
502
+ let output = [
503
+ `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
504
+ ""
505
+ ];
488
506
  const commandDescription = helper.commandDescription(cmd);
489
507
  if (commandDescription.length > 0) {
490
508
  output = output.concat([
491
- helper.wrap(commandDescription, helpWidth, 0),
509
+ helper.boxWrap(
510
+ helper.styleCommandDescription(commandDescription),
511
+ helpWidth
512
+ ),
492
513
  ""
493
514
  ]);
494
515
  }
495
516
  const argumentList = helper.visibleArguments(cmd).map((argument) => {
496
- return formatItem(
497
- helper.argumentTerm(argument),
498
- helper.argumentDescription(argument)
517
+ return callFormatItem(
518
+ helper.styleArgumentTerm(helper.argumentTerm(argument)),
519
+ helper.styleArgumentDescription(helper.argumentDescription(argument))
499
520
  );
500
521
  });
501
522
  if (argumentList.length > 0) {
502
- output = output.concat(["Arguments:", formatList(argumentList), ""]);
523
+ output = output.concat([
524
+ helper.styleTitle("Arguments:"),
525
+ ...argumentList,
526
+ ""
527
+ ]);
503
528
  }
504
529
  const optionList = helper.visibleOptions(cmd).map((option) => {
505
- return formatItem(
506
- helper.optionTerm(option),
507
- helper.optionDescription(option)
530
+ return callFormatItem(
531
+ helper.styleOptionTerm(helper.optionTerm(option)),
532
+ helper.styleOptionDescription(helper.optionDescription(option))
508
533
  );
509
534
  });
510
535
  if (optionList.length > 0) {
511
- output = output.concat(["Options:", formatList(optionList), ""]);
536
+ output = output.concat([
537
+ helper.styleTitle("Options:"),
538
+ ...optionList,
539
+ ""
540
+ ]);
512
541
  }
513
- if (this.showGlobalOptions) {
542
+ if (helper.showGlobalOptions) {
514
543
  const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
515
- return formatItem(
516
- helper.optionTerm(option),
517
- helper.optionDescription(option)
544
+ return callFormatItem(
545
+ helper.styleOptionTerm(helper.optionTerm(option)),
546
+ helper.styleOptionDescription(helper.optionDescription(option))
518
547
  );
519
548
  });
520
549
  if (globalOptionList.length > 0) {
521
550
  output = output.concat([
522
- "Global Options:",
523
- formatList(globalOptionList),
551
+ helper.styleTitle("Global Options:"),
552
+ ...globalOptionList,
524
553
  ""
525
554
  ]);
526
555
  }
527
556
  }
528
557
  const commandList = helper.visibleCommands(cmd).map((cmd2) => {
529
- return formatItem(
530
- helper.subcommandTerm(cmd2),
531
- helper.subcommandDescription(cmd2)
558
+ return callFormatItem(
559
+ helper.styleSubcommandTerm(helper.subcommandTerm(cmd2)),
560
+ helper.styleSubcommandDescription(helper.subcommandDescription(cmd2))
532
561
  );
533
562
  });
534
563
  if (commandList.length > 0) {
535
- output = output.concat(["Commands:", formatList(commandList), ""]);
564
+ output = output.concat([
565
+ helper.styleTitle("Commands:"),
566
+ ...commandList,
567
+ ""
568
+ ]);
536
569
  }
537
570
  return output.join("\n");
538
571
  }
572
+ /**
573
+ * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.
574
+ *
575
+ * @param {string} str
576
+ * @returns {number}
577
+ */
578
+ displayWidth(str) {
579
+ return stripColor(str).length;
580
+ }
581
+ /**
582
+ * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
583
+ *
584
+ * @param {string} str
585
+ * @returns {string}
586
+ */
587
+ styleTitle(str) {
588
+ return str;
589
+ }
590
+ styleUsage(str) {
591
+ return str.split(" ").map((word) => {
592
+ if (word === "[options]") return this.styleOptionText(word);
593
+ if (word === "[command]") return this.styleSubcommandText(word);
594
+ if (word[0] === "[" || word[0] === "<")
595
+ return this.styleArgumentText(word);
596
+ return this.styleCommandText(word);
597
+ }).join(" ");
598
+ }
599
+ styleCommandDescription(str) {
600
+ return this.styleDescriptionText(str);
601
+ }
602
+ styleOptionDescription(str) {
603
+ return this.styleDescriptionText(str);
604
+ }
605
+ styleSubcommandDescription(str) {
606
+ return this.styleDescriptionText(str);
607
+ }
608
+ styleArgumentDescription(str) {
609
+ return this.styleDescriptionText(str);
610
+ }
611
+ styleDescriptionText(str) {
612
+ return str;
613
+ }
614
+ styleOptionTerm(str) {
615
+ return this.styleOptionText(str);
616
+ }
617
+ styleSubcommandTerm(str) {
618
+ return str.split(" ").map((word) => {
619
+ if (word === "[options]") return this.styleOptionText(word);
620
+ if (word[0] === "[" || word[0] === "<")
621
+ return this.styleArgumentText(word);
622
+ return this.styleSubcommandText(word);
623
+ }).join(" ");
624
+ }
625
+ styleArgumentTerm(str) {
626
+ return this.styleArgumentText(str);
627
+ }
628
+ styleOptionText(str) {
629
+ return str;
630
+ }
631
+ styleArgumentText(str) {
632
+ return str;
633
+ }
634
+ styleSubcommandText(str) {
635
+ return str;
636
+ }
637
+ styleCommandText(str) {
638
+ return str;
639
+ }
539
640
  /**
540
641
  * Calculate the pad width from the maximum term length.
541
642
  *
@@ -552,40 +653,94 @@ var require_help = __commonJS({
552
653
  );
553
654
  }
554
655
  /**
555
- * Wrap the given string to width characters per line, with lines after the first indented.
556
- * Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
656
+ * Detect manually wrapped and indented strings by checking for line break followed by whitespace.
557
657
  *
558
658
  * @param {string} str
559
- * @param {number} width
560
- * @param {number} indent
561
- * @param {number} [minColumnWidth=40]
562
- * @return {string}
659
+ * @returns {boolean}
660
+ */
661
+ preformatted(str) {
662
+ return /\n[^\S\r\n]/.test(str);
663
+ }
664
+ /**
665
+ * Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
563
666
  *
667
+ * So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
668
+ * TTT DDD DDDD
669
+ * DD DDD
670
+ *
671
+ * @param {string} term
672
+ * @param {number} termWidth
673
+ * @param {string} description
674
+ * @param {Help} helper
675
+ * @returns {string}
564
676
  */
565
- wrap(str, width, indent, minColumnWidth = 40) {
566
- const indents = " \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF";
567
- const manualIndent = new RegExp(`[\\n][${indents}]+`);
568
- if (str.match(manualIndent)) return str;
569
- const columnWidth = width - indent;
570
- if (columnWidth < minColumnWidth) return str;
571
- const leadingStr = str.slice(0, indent);
572
- const columnText = str.slice(indent).replace("\r\n", "\n");
573
- const indentString = " ".repeat(indent);
574
- const zeroWidthSpace = "\u200B";
575
- const breaks = `\\s${zeroWidthSpace}`;
576
- const regex = new RegExp(
577
- `
578
- |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,
579
- "g"
677
+ formatItem(term, termWidth, description, helper) {
678
+ const itemIndent = 2;
679
+ const itemIndentStr = " ".repeat(itemIndent);
680
+ if (!description) return itemIndentStr + term;
681
+ const paddedTerm = term.padEnd(
682
+ termWidth + term.length - helper.displayWidth(term)
580
683
  );
581
- const lines = columnText.match(regex) || [];
582
- return leadingStr + lines.map((line, i) => {
583
- if (line === "\n") return "";
584
- return (i > 0 ? indentString : "") + line.trimEnd();
585
- }).join("\n");
684
+ const spacerWidth = 2;
685
+ const helpWidth = this.helpWidth ?? 80;
686
+ const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
687
+ let formattedDescription;
688
+ if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
689
+ formattedDescription = description;
690
+ } else {
691
+ const wrappedDescription = helper.boxWrap(description, remainingWidth);
692
+ formattedDescription = wrappedDescription.replace(
693
+ /\n/g,
694
+ "\n" + " ".repeat(termWidth + spacerWidth)
695
+ );
696
+ }
697
+ return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
698
+ ${itemIndentStr}`);
699
+ }
700
+ /**
701
+ * Wrap a string at whitespace, preserving existing line breaks.
702
+ * Wrapping is skipped if the width is less than `minWidthToWrap`.
703
+ *
704
+ * @param {string} str
705
+ * @param {number} width
706
+ * @returns {string}
707
+ */
708
+ boxWrap(str, width) {
709
+ if (width < this.minWidthToWrap) return str;
710
+ const rawLines = str.split(/\r\n|\n/);
711
+ const chunkPattern = /[\s]*[^\s]+/g;
712
+ const wrappedLines = [];
713
+ rawLines.forEach((line) => {
714
+ const chunks = line.match(chunkPattern);
715
+ if (chunks === null) {
716
+ wrappedLines.push("");
717
+ return;
718
+ }
719
+ let sumChunks = [chunks.shift()];
720
+ let sumWidth = this.displayWidth(sumChunks[0]);
721
+ chunks.forEach((chunk) => {
722
+ const visibleWidth = this.displayWidth(chunk);
723
+ if (sumWidth + visibleWidth <= width) {
724
+ sumChunks.push(chunk);
725
+ sumWidth += visibleWidth;
726
+ return;
727
+ }
728
+ wrappedLines.push(sumChunks.join(""));
729
+ const nextChunk = chunk.trimStart();
730
+ sumChunks = [nextChunk];
731
+ sumWidth = this.displayWidth(nextChunk);
732
+ });
733
+ wrappedLines.push(sumChunks.join(""));
734
+ });
735
+ return wrappedLines.join("\n");
586
736
  }
587
737
  };
738
+ function stripColor(str) {
739
+ const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
740
+ return str.replace(sgrPattern, "");
741
+ }
588
742
  exports.Help = Help2;
743
+ exports.stripColor = stripColor;
589
744
  }
590
745
  });
591
746
 
@@ -775,12 +930,15 @@ var require_option = __commonJS({
775
930
  }
776
931
  /**
777
932
  * Return option name, in a camelcase format that can be used
778
- * as a object attribute key.
933
+ * as an object attribute key.
779
934
  *
780
935
  * @return {string}
781
936
  */
782
937
  attributeName() {
783
- return camelcase(this.name().replace(/^no-/, ""));
938
+ if (this.negate) {
939
+ return camelcase(this.name().replace(/^no-/, ""));
940
+ }
941
+ return camelcase(this.name());
784
942
  }
785
943
  /**
786
944
  * Check if `arg` matches the short or long flag.
@@ -848,14 +1006,25 @@ var require_option = __commonJS({
848
1006
  function splitOptionFlags(flags) {
849
1007
  let shortFlag;
850
1008
  let longFlag;
851
- const flagParts = flags.split(/[ |,]+/);
852
- if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
853
- shortFlag = flagParts.shift();
854
- longFlag = flagParts.shift();
855
- if (!shortFlag && /^-[^-]$/.test(longFlag)) {
856
- shortFlag = longFlag;
857
- longFlag = void 0;
858
- }
1009
+ const shortFlagExp = /^-[^-]$/;
1010
+ const longFlagExp = /^--[^-]/;
1011
+ const flagParts = flags.split(/[ |,]+/).concat("guard");
1012
+ if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();
1013
+ if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift();
1014
+ if (/^-[^-][^-]/.test(flagParts[0]))
1015
+ throw new Error(
1016
+ `invalid Option flags, short option is dash and single character: '${flags}'`
1017
+ );
1018
+ if (shortFlag && shortFlagExp.test(flagParts[0]))
1019
+ throw new Error(
1020
+ `invalid Option flags, more than one short flag: '${flags}'`
1021
+ );
1022
+ if (longFlag && longFlagExp.test(flagParts[0]))
1023
+ throw new Error(
1024
+ `invalid Option flags, more than one long flag: '${flags}'`
1025
+ );
1026
+ if (!(shortFlag || longFlag) || flagParts[0].startsWith("-"))
1027
+ throw new Error(`invalid Option flags: '${flags}'`);
859
1028
  return { shortFlag, longFlag };
860
1029
  }
861
1030
  exports.Option = Option2;
@@ -957,7 +1126,7 @@ var require_command = __commonJS({
957
1126
  var process = __require("node:process");
958
1127
  var { Argument: Argument2, humanReadableArgName } = require_argument();
959
1128
  var { CommanderError: CommanderError2 } = require_error();
960
- var { Help: Help2 } = require_help();
1129
+ var { Help: Help2, stripColor } = require_help();
961
1130
  var { Option: Option2, DualOptions } = require_option();
962
1131
  var { suggestSimilar } = require_suggestSimilar();
963
1132
  var Command2 = class _Command extends EventEmitter {
@@ -972,7 +1141,7 @@ var require_command = __commonJS({
972
1141
  this.options = [];
973
1142
  this.parent = null;
974
1143
  this._allowUnknownOption = false;
975
- this._allowExcessArguments = true;
1144
+ this._allowExcessArguments = false;
976
1145
  this.registeredArguments = [];
977
1146
  this._args = this.registeredArguments;
978
1147
  this.args = [];
@@ -999,12 +1168,16 @@ var require_command = __commonJS({
999
1168
  this._lifeCycleHooks = {};
1000
1169
  this._showHelpAfterError = false;
1001
1170
  this._showSuggestionAfterError = true;
1171
+ this._savedState = null;
1002
1172
  this._outputConfiguration = {
1003
1173
  writeOut: (str) => process.stdout.write(str),
1004
1174
  writeErr: (str) => process.stderr.write(str),
1175
+ outputError: (str, write) => write(str),
1005
1176
  getOutHelpWidth: () => process.stdout.isTTY ? process.stdout.columns : void 0,
1006
1177
  getErrHelpWidth: () => process.stderr.isTTY ? process.stderr.columns : void 0,
1007
- outputError: (str, write) => write(str)
1178
+ getOutHasColors: () => useColor() ?? (process.stdout.isTTY && process.stdout.hasColors?.()),
1179
+ getErrHasColors: () => useColor() ?? (process.stderr.isTTY && process.stderr.hasColors?.()),
1180
+ stripColor: (str) => stripColor(str)
1008
1181
  };
1009
1182
  this._hidden = false;
1010
1183
  this._helpOption = void 0;
@@ -1132,14 +1305,18 @@ var require_command = __commonJS({
1132
1305
  *
1133
1306
  * The configuration properties are all functions:
1134
1307
  *
1135
- * // functions to change where being written, stdout and stderr
1308
+ * // change how output being written, defaults to stdout and stderr
1136
1309
  * writeOut(str)
1137
1310
  * writeErr(str)
1138
- * // matching functions to specify width for wrapping help
1311
+ * // change how output being written for errors, defaults to writeErr
1312
+ * outputError(str, write) // used for displaying errors and not used for displaying help
1313
+ * // specify width for wrapping help
1139
1314
  * getOutHelpWidth()
1140
1315
  * getErrHelpWidth()
1141
- * // functions based on what is being written out
1142
- * outputError(str, write) // used for displaying errors, and not used for displaying help
1316
+ * // color support, currently only used with Help
1317
+ * getOutHasColors()
1318
+ * getErrHasColors()
1319
+ * stripColor() // used to remove ANSI escape codes if output does not have colors
1143
1320
  *
1144
1321
  * @param {object} [configuration] - configuration options
1145
1322
  * @return {(Command | object)} `this` command for chaining, or stored configuration
@@ -1846,6 +2023,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1846
2023
  * @return {Command} `this` command for chaining
1847
2024
  */
1848
2025
  parse(argv, parseOptions) {
2026
+ this._prepareForParse();
1849
2027
  const userArgs = this._prepareUserArgs(argv, parseOptions);
1850
2028
  this._parseCommand([], userArgs);
1851
2029
  return this;
@@ -1871,10 +2049,68 @@ Expecting one of '${allowedValues.join("', '")}'`);
1871
2049
  * @return {Promise}
1872
2050
  */
1873
2051
  async parseAsync(argv, parseOptions) {
2052
+ this._prepareForParse();
1874
2053
  const userArgs = this._prepareUserArgs(argv, parseOptions);
1875
2054
  await this._parseCommand([], userArgs);
1876
2055
  return this;
1877
2056
  }
2057
+ _prepareForParse() {
2058
+ if (this._savedState === null) {
2059
+ this.saveStateBeforeParse();
2060
+ } else {
2061
+ this.restoreStateBeforeParse();
2062
+ }
2063
+ }
2064
+ /**
2065
+ * Called the first time parse is called to save state and allow a restore before subsequent calls to parse.
2066
+ * Not usually called directly, but available for subclasses to save their custom state.
2067
+ *
2068
+ * This is called in a lazy way. Only commands used in parsing chain will have state saved.
2069
+ */
2070
+ saveStateBeforeParse() {
2071
+ this._savedState = {
2072
+ // name is stable if supplied by author, but may be unspecified for root command and deduced during parsing
2073
+ _name: this._name,
2074
+ // option values before parse have default values (including false for negated options)
2075
+ // shallow clones
2076
+ _optionValues: { ...this._optionValues },
2077
+ _optionValueSources: { ...this._optionValueSources }
2078
+ };
2079
+ }
2080
+ /**
2081
+ * Restore state before parse for calls after the first.
2082
+ * Not usually called directly, but available for subclasses to save their custom state.
2083
+ *
2084
+ * This is called in a lazy way. Only commands used in parsing chain will have state restored.
2085
+ */
2086
+ restoreStateBeforeParse() {
2087
+ if (this._storeOptionsAsProperties)
2088
+ throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
2089
+ - either make a new Command for each call to parse, or stop storing options as properties`);
2090
+ this._name = this._savedState._name;
2091
+ this._scriptPath = null;
2092
+ this.rawArgs = [];
2093
+ this._optionValues = { ...this._savedState._optionValues };
2094
+ this._optionValueSources = { ...this._savedState._optionValueSources };
2095
+ this.args = [];
2096
+ this.processedArgs = [];
2097
+ }
2098
+ /**
2099
+ * Throw if expected executable is missing. Add lots of help for author.
2100
+ *
2101
+ * @param {string} executableFile
2102
+ * @param {string} executableDir
2103
+ * @param {string} subcommandName
2104
+ */
2105
+ _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
2106
+ if (fs.existsSync(executableFile)) return;
2107
+ const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
2108
+ const executableMissing = `'${executableFile}' does not exist
2109
+ - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
2110
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
2111
+ - ${executableDirMessage}`;
2112
+ throw new Error(executableMissing);
2113
+ }
1878
2114
  /**
1879
2115
  * Execute a sub-command executable.
1880
2116
  *
@@ -1902,7 +2138,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1902
2138
  let resolvedScriptPath;
1903
2139
  try {
1904
2140
  resolvedScriptPath = fs.realpathSync(this._scriptPath);
1905
- } catch (err) {
2141
+ } catch {
1906
2142
  resolvedScriptPath = this._scriptPath;
1907
2143
  }
1908
2144
  executableDir = path.resolve(
@@ -1937,6 +2173,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1937
2173
  proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
1938
2174
  }
1939
2175
  } else {
2176
+ this._checkForMissingExecutable(
2177
+ executableFile,
2178
+ executableDir,
2179
+ subcommand._name
2180
+ );
1940
2181
  args.unshift(executableFile);
1941
2182
  args = incrementNodeInspectorPort(process.execArgv).concat(args);
1942
2183
  proc = childProcess.spawn(process.execPath, args, { stdio: "inherit" });
@@ -1968,12 +2209,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1968
2209
  });
1969
2210
  proc.on("error", (err) => {
1970
2211
  if (err.code === "ENOENT") {
1971
- const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
1972
- const executableMissing = `'${executableFile}' does not exist
1973
- - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
1974
- - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
1975
- - ${executableDirMessage}`;
1976
- throw new Error(executableMissing);
2212
+ this._checkForMissingExecutable(
2213
+ executableFile,
2214
+ executableDir,
2215
+ subcommand._name
2216
+ );
1977
2217
  } else if (err.code === "EACCES") {
1978
2218
  throw new Error(`'${executableFile}' not executable`);
1979
2219
  }
@@ -1997,6 +2237,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1997
2237
  _dispatchSubcommand(commandName, operands, unknown) {
1998
2238
  const subCommand = this._findCommand(commandName);
1999
2239
  if (!subCommand) this.help({ error: true });
2240
+ subCommand._prepareForParse();
2000
2241
  let promiseChain;
2001
2242
  promiseChain = this._chainOrCallSubCommandHook(
2002
2243
  promiseChain,
@@ -2309,6 +2550,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2309
2550
  * Parse options from `argv` removing known options,
2310
2551
  * and return argv split into operands and unknown arguments.
2311
2552
  *
2553
+ * Side effects: modifies command by storing options. Does not reset state if called again.
2554
+ *
2312
2555
  * Examples:
2313
2556
  *
2314
2557
  * argv => operands, unknown
@@ -2793,26 +3036,47 @@ Expecting one of '${allowedValues.join("', '")}'`);
2793
3036
  */
2794
3037
  helpInformation(contextOptions) {
2795
3038
  const helper = this.createHelp();
2796
- if (helper.helpWidth === void 0) {
2797
- helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
2798
- }
2799
- return helper.formatHelp(this, helper);
3039
+ const context = this._getOutputContext(contextOptions);
3040
+ helper.prepareContext({
3041
+ error: context.error,
3042
+ helpWidth: context.helpWidth,
3043
+ outputHasColors: context.hasColors
3044
+ });
3045
+ const text = helper.formatHelp(this, helper);
3046
+ if (context.hasColors) return text;
3047
+ return this._outputConfiguration.stripColor(text);
2800
3048
  }
2801
3049
  /**
3050
+ * @typedef HelpContext
3051
+ * @type {object}
3052
+ * @property {boolean} error
3053
+ * @property {number} helpWidth
3054
+ * @property {boolean} hasColors
3055
+ * @property {function} write - includes stripColor if needed
3056
+ *
3057
+ * @returns {HelpContext}
2802
3058
  * @private
2803
3059
  */
2804
- _getHelpContext(contextOptions) {
3060
+ _getOutputContext(contextOptions) {
2805
3061
  contextOptions = contextOptions || {};
2806
- const context = { error: !!contextOptions.error };
2807
- let write;
2808
- if (context.error) {
2809
- write = (arg) => this._outputConfiguration.writeErr(arg);
3062
+ const error = !!contextOptions.error;
3063
+ let baseWrite;
3064
+ let hasColors;
3065
+ let helpWidth;
3066
+ if (error) {
3067
+ baseWrite = (str) => this._outputConfiguration.writeErr(str);
3068
+ hasColors = this._outputConfiguration.getErrHasColors();
3069
+ helpWidth = this._outputConfiguration.getErrHelpWidth();
2810
3070
  } else {
2811
- write = (arg) => this._outputConfiguration.writeOut(arg);
3071
+ baseWrite = (str) => this._outputConfiguration.writeOut(str);
3072
+ hasColors = this._outputConfiguration.getOutHasColors();
3073
+ helpWidth = this._outputConfiguration.getOutHelpWidth();
2812
3074
  }
2813
- context.write = contextOptions.write || write;
2814
- context.command = this;
2815
- return context;
3075
+ const write = (str) => {
3076
+ if (!hasColors) str = this._outputConfiguration.stripColor(str);
3077
+ return baseWrite(str);
3078
+ };
3079
+ return { error, write, hasColors, helpWidth };
2816
3080
  }
2817
3081
  /**
2818
3082
  * Output help information for this command.
@@ -2827,23 +3091,28 @@ Expecting one of '${allowedValues.join("', '")}'`);
2827
3091
  deprecatedCallback = contextOptions;
2828
3092
  contextOptions = void 0;
2829
3093
  }
2830
- const context = this._getHelpContext(contextOptions);
2831
- this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", context));
2832
- this.emit("beforeHelp", context);
2833
- let helpInformation = this.helpInformation(context);
3094
+ const outputContext = this._getOutputContext(contextOptions);
3095
+ const eventContext = {
3096
+ error: outputContext.error,
3097
+ write: outputContext.write,
3098
+ command: this
3099
+ };
3100
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
3101
+ this.emit("beforeHelp", eventContext);
3102
+ let helpInformation = this.helpInformation({ error: outputContext.error });
2834
3103
  if (deprecatedCallback) {
2835
3104
  helpInformation = deprecatedCallback(helpInformation);
2836
3105
  if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
2837
3106
  throw new Error("outputHelp callback must return a string or a Buffer");
2838
3107
  }
2839
3108
  }
2840
- context.write(helpInformation);
3109
+ outputContext.write(helpInformation);
2841
3110
  if (this._getHelpOption()?.long) {
2842
3111
  this.emit(this._getHelpOption().long);
2843
3112
  }
2844
- this.emit("afterHelp", context);
3113
+ this.emit("afterHelp", eventContext);
2845
3114
  this._getCommandAndAncestors().forEach(
2846
- (command) => command.emit("afterAllHelp", context)
3115
+ (command) => command.emit("afterAllHelp", eventContext)
2847
3116
  );
2848
3117
  }
2849
3118
  /**
@@ -2905,12 +3174,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
2905
3174
  */
2906
3175
  help(contextOptions) {
2907
3176
  this.outputHelp(contextOptions);
2908
- let exitCode = process.exitCode || 0;
3177
+ let exitCode = Number(process.exitCode ?? 0);
2909
3178
  if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2910
3179
  exitCode = 1;
2911
3180
  }
2912
3181
  this._exit(exitCode, "commander.help", "(outputHelp)");
2913
3182
  }
3183
+ /**
3184
+ * // Do a little typing to coordinate emit and listener for the help text events.
3185
+ * @typedef HelpTextEventContext
3186
+ * @type {object}
3187
+ * @property {boolean} error
3188
+ * @property {Command} command
3189
+ * @property {function} write
3190
+ */
2914
3191
  /**
2915
3192
  * Add additional text to be displayed with the built-in help.
2916
3193
  *
@@ -2986,7 +3263,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
2986
3263
  return arg;
2987
3264
  });
2988
3265
  }
3266
+ function useColor() {
3267
+ if (process.env.NO_COLOR || process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false")
3268
+ return false;
3269
+ if (process.env.FORCE_COLOR || process.env.CLICOLOR_FORCE !== void 0)
3270
+ return true;
3271
+ return void 0;
3272
+ }
2989
3273
  exports.Command = Command2;
3274
+ exports.useColor = useColor;
2990
3275
  }
2991
3276
  });
2992
3277
 
@@ -3059,4 +3344,4 @@ export {
3059
3344
  Argument,
3060
3345
  Option
3061
3346
  };
3062
- //# sourceMappingURL=chunk-F63O2UMD.js.map
3347
+ //# sourceMappingURL=chunk-KCTZ5EX4.js.map