varlock 0.7.1 → 0.7.2

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 (91) hide show
  1. package/dist/auto-load.js +2 -2
  2. package/dist/chunk-3I5FHXMJ.js +162 -0
  3. package/dist/chunk-3I5FHXMJ.js.map +1 -0
  4. package/dist/{chunk-EQGPMXDI.js → chunk-3LT4WWHG.js} +6 -5
  5. package/dist/chunk-3LT4WWHG.js.map +1 -0
  6. package/dist/{chunk-UGUCGDKH.js → chunk-AJCLNVYI.js} +6 -5
  7. package/dist/chunk-AJCLNVYI.js.map +1 -0
  8. package/dist/chunk-AKWP77PS.js +387 -0
  9. package/dist/chunk-AKWP77PS.js.map +1 -0
  10. package/dist/{chunk-GCEP6UVQ.js → chunk-BIIYEXRU.js} +4 -4
  11. package/dist/{chunk-GCEP6UVQ.js.map → chunk-BIIYEXRU.js.map} +1 -1
  12. package/dist/chunk-CHQDS2PI.js +138 -0
  13. package/dist/chunk-CHQDS2PI.js.map +1 -0
  14. package/dist/chunk-D5YM4IWS.js +79 -0
  15. package/dist/chunk-D5YM4IWS.js.map +1 -0
  16. package/dist/{chunk-WHSHSZQR.js → chunk-EBOBYFMY.js} +4 -4
  17. package/dist/{chunk-WHSHSZQR.js.map → chunk-EBOBYFMY.js.map} +1 -1
  18. package/dist/{chunk-4KSIULUK.js → chunk-EPWHAD6X.js} +5 -4
  19. package/dist/chunk-EPWHAD6X.js.map +1 -0
  20. package/dist/{chunk-B6SVDIAN.js → chunk-G2GPGCAP.js} +1435 -202
  21. package/dist/chunk-G2GPGCAP.js.map +1 -0
  22. package/dist/chunk-GXNQVEXD.js +15 -0
  23. package/dist/chunk-GXNQVEXD.js.map +1 -0
  24. package/dist/{chunk-BEV4WCAI.js → chunk-GYK3QFZB.js} +8 -4
  25. package/dist/chunk-GYK3QFZB.js.map +1 -0
  26. package/dist/{chunk-TQDVHRUW.js → chunk-LQ25CRHF.js} +7 -136
  27. package/dist/chunk-LQ25CRHF.js.map +1 -0
  28. package/dist/{chunk-4MCJ5H6K.js → chunk-MOXREUY6.js} +3 -3
  29. package/dist/{chunk-4MCJ5H6K.js.map → chunk-MOXREUY6.js.map} +1 -1
  30. package/dist/chunk-N5O4Z32O.js +74 -0
  31. package/dist/chunk-N5O4Z32O.js.map +1 -0
  32. package/dist/{chunk-MC4SUVBY.js → chunk-P4WZ2JXY.js} +5 -5
  33. package/dist/{chunk-MC4SUVBY.js.map → chunk-P4WZ2JXY.js.map} +1 -1
  34. package/dist/{chunk-WKQ6WUA7.js → chunk-TY6CHCQK.js} +6 -5
  35. package/dist/chunk-TY6CHCQK.js.map +1 -0
  36. package/dist/{chunk-JTK7LTYE.js → chunk-U3UHTU2X.js} +8 -17
  37. package/dist/chunk-U3UHTU2X.js.map +1 -0
  38. package/dist/{chunk-CHWXFSUK.js → chunk-WUI34NTD.js} +5 -5
  39. package/dist/{chunk-CHWXFSUK.js.map → chunk-WUI34NTD.js.map} +1 -1
  40. package/dist/cli/cli-executable.js +177 -26
  41. package/dist/cli/cli-executable.js.map +1 -1
  42. package/dist/config-item-I7ZL2FXU.js +5 -0
  43. package/dist/{config-item-VMLNH4QK.js.map → config-item-I7ZL2FXU.js.map} +1 -1
  44. package/dist/dotenv-compat.js +2 -2
  45. package/dist/{env-graph-BI5ASRYd.d.ts → env-graph-CwJhXKDk.d.ts} +51 -1
  46. package/dist/explain.command-IQOZKKSF.js +12 -0
  47. package/dist/explain.command-IQOZKKSF.js.map +1 -0
  48. package/dist/index.d.ts +2 -2
  49. package/dist/index.js +6 -5
  50. package/dist/index.js.map +1 -1
  51. package/dist/init.command-NVADFQ55.js +12 -0
  52. package/dist/{init.command-C2WNQ4UP.js.map → init.command-NVADFQ55.js.map} +1 -1
  53. package/dist/install-plugin.command-WE66PLU2.js +11 -0
  54. package/dist/install-plugin.command-WE66PLU2.js.map +1 -0
  55. package/dist/lib/exec-sync-varlock.d.ts +7 -0
  56. package/dist/lib/exec-sync-varlock.js +1 -1
  57. package/dist/load.command-NKKZAEE5.js +12 -0
  58. package/dist/{load.command-5X3BSCLF.js.map → load.command-NKKZAEE5.js.map} +1 -1
  59. package/dist/plugin-lib.d.ts +2 -2
  60. package/dist/printenv.command-TY5KCVC3.js +12 -0
  61. package/dist/{printenv.command-XZEQ3CZB.js.map → printenv.command-TY5KCVC3.js.map} +1 -1
  62. package/dist/run.command-PI2VAO7M.js +13 -0
  63. package/dist/{run.command-FE26WTNO.js.map → run.command-PI2VAO7M.js.map} +1 -1
  64. package/dist/runtime/env.d.ts +1 -1
  65. package/dist/scan.command-YIYJ6NTJ.js +14 -0
  66. package/dist/{scan.command-2M4RN4ZP.js.map → scan.command-YIYJ6NTJ.js.map} +1 -1
  67. package/dist/telemetry.command-WYD4SOWI.js +11 -0
  68. package/dist/{telemetry.command-SPOD3GAJ.js.map → telemetry.command-WYD4SOWI.js.map} +1 -1
  69. package/dist/typegen.command-5WQGI3CE.js +12 -0
  70. package/dist/{typegen.command-RUNVYBAM.js.map → typegen.command-5WQGI3CE.js.map} +1 -1
  71. package/package.json +1 -1
  72. package/dist/chunk-4KSIULUK.js.map +0 -1
  73. package/dist/chunk-B6SVDIAN.js.map +0 -1
  74. package/dist/chunk-BEV4WCAI.js.map +0 -1
  75. package/dist/chunk-EQGPMXDI.js.map +0 -1
  76. package/dist/chunk-JMJCAFEL.js +0 -1434
  77. package/dist/chunk-JMJCAFEL.js.map +0 -1
  78. package/dist/chunk-JTK7LTYE.js.map +0 -1
  79. package/dist/chunk-K6M42GW2.js +0 -59
  80. package/dist/chunk-K6M42GW2.js.map +0 -1
  81. package/dist/chunk-TQDVHRUW.js.map +0 -1
  82. package/dist/chunk-UGUCGDKH.js.map +0 -1
  83. package/dist/chunk-WKQ6WUA7.js.map +0 -1
  84. package/dist/config-item-VMLNH4QK.js +0 -5
  85. package/dist/init.command-C2WNQ4UP.js +0 -11
  86. package/dist/load.command-5X3BSCLF.js +0 -11
  87. package/dist/printenv.command-XZEQ3CZB.js +0 -11
  88. package/dist/run.command-FE26WTNO.js +0 -12
  89. package/dist/scan.command-2M4RN4ZP.js +0 -12
  90. package/dist/telemetry.command-SPOD3GAJ.js +0 -10
  91. package/dist/typegen.command-RUNVYBAM.js +0 -11
@@ -1,1434 +0,0 @@
1
- import { spawnAsync } from './chunk-GGBNUVWR.js';
2
- import { detectJsPackageManager, logLines, fmt, installJsDependency } from './chunk-WHSHSZQR.js';
3
- import { define } from './chunk-4A54P4EM.js';
4
- import { gracefulExit } from './chunk-TQDVHRUW.js';
5
- import { envSpecUpdater, ParsedEnvSpecStaticValue, tryCatch, parseEnvSpecDotEnvFile, ansis_default, pathExists } from './chunk-B6SVDIAN.js';
6
- import { __commonJS, __toESM, __name } from './chunk-6PEHRAEP.js';
7
- import path2, { dirname } from 'path';
8
- import fs3 from 'fs/promises';
9
- import { styleText } from 'util';
10
- import N2, { stdin, stdout } from 'process';
11
- import ot from 'readline';
12
- import { WriteStream } from 'tty';
13
- import 'fs';
14
-
15
- // ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
16
- var require_src = __commonJS({
17
- "../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports$1, module) {
18
- var ESC = "\x1B";
19
- var CSI = `${ESC}[`;
20
- var beep = "\x07";
21
- var cursor = {
22
- to(x3, y2) {
23
- if (!y2) return `${CSI}${x3 + 1}G`;
24
- return `${CSI}${y2 + 1};${x3 + 1}H`;
25
- },
26
- move(x3, y2) {
27
- let ret = "";
28
- if (x3 < 0) ret += `${CSI}${-x3}D`;
29
- else if (x3 > 0) ret += `${CSI}${x3}C`;
30
- if (y2 < 0) ret += `${CSI}${-y2}A`;
31
- else if (y2 > 0) ret += `${CSI}${y2}B`;
32
- return ret;
33
- },
34
- up: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}A`, "up"),
35
- down: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}B`, "down"),
36
- forward: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}C`, "forward"),
37
- backward: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}D`, "backward"),
38
- nextLine: /* @__PURE__ */ __name((count = 1) => `${CSI}E`.repeat(count), "nextLine"),
39
- prevLine: /* @__PURE__ */ __name((count = 1) => `${CSI}F`.repeat(count), "prevLine"),
40
- left: `${CSI}G`,
41
- hide: `${CSI}?25l`,
42
- show: `${CSI}?25h`,
43
- save: `${ESC}7`,
44
- restore: `${ESC}8`
45
- };
46
- var scroll = {
47
- up: /* @__PURE__ */ __name((count = 1) => `${CSI}S`.repeat(count), "up"),
48
- down: /* @__PURE__ */ __name((count = 1) => `${CSI}T`.repeat(count), "down")
49
- };
50
- var erase = {
51
- screen: `${CSI}2J`,
52
- up: /* @__PURE__ */ __name((count = 1) => `${CSI}1J`.repeat(count), "up"),
53
- down: /* @__PURE__ */ __name((count = 1) => `${CSI}J`.repeat(count), "down"),
54
- line: `${CSI}2K`,
55
- lineEnd: `${CSI}K`,
56
- lineStart: `${CSI}1K`,
57
- lines(count) {
58
- let clear = "";
59
- for (let i = 0; i < count; i++)
60
- clear += this.line + (i < count - 1 ? cursor.up() : "");
61
- if (count)
62
- clear += cursor.left;
63
- return clear;
64
- }
65
- };
66
- module.exports = { cursor, scroll, erase, beep };
67
- }
68
- });
69
-
70
- // ../../node_modules/.bun/@clack+core@1.1.0/node_modules/@clack/core/dist/index.mjs
71
- var import_sisteransi = __toESM(require_src(), 1);
72
- function x(t2, e, s) {
73
- if (!s.some((u) => !u.disabled)) return t2;
74
- const i = t2 + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
75
- return s[n].disabled ? x(n, e < 0 ? -1 : 1, s) : n;
76
- }
77
- __name(x, "x");
78
- var at = /* @__PURE__ */ __name((t2) => t2 === 161 || t2 === 164 || t2 === 167 || t2 === 168 || t2 === 170 || t2 === 173 || t2 === 174 || t2 >= 176 && t2 <= 180 || t2 >= 182 && t2 <= 186 || t2 >= 188 && t2 <= 191 || t2 === 198 || t2 === 208 || t2 === 215 || t2 === 216 || t2 >= 222 && t2 <= 225 || t2 === 230 || t2 >= 232 && t2 <= 234 || t2 === 236 || t2 === 237 || t2 === 240 || t2 === 242 || t2 === 243 || t2 >= 247 && t2 <= 250 || t2 === 252 || t2 === 254 || t2 === 257 || t2 === 273 || t2 === 275 || t2 === 283 || t2 === 294 || t2 === 295 || t2 === 299 || t2 >= 305 && t2 <= 307 || t2 === 312 || t2 >= 319 && t2 <= 322 || t2 === 324 || t2 >= 328 && t2 <= 331 || t2 === 333 || t2 === 338 || t2 === 339 || t2 === 358 || t2 === 359 || t2 === 363 || t2 === 462 || t2 === 464 || t2 === 466 || t2 === 468 || t2 === 470 || t2 === 472 || t2 === 474 || t2 === 476 || t2 === 593 || t2 === 609 || t2 === 708 || t2 === 711 || t2 >= 713 && t2 <= 715 || t2 === 717 || t2 === 720 || t2 >= 728 && t2 <= 731 || t2 === 733 || t2 === 735 || t2 >= 768 && t2 <= 879 || t2 >= 913 && t2 <= 929 || t2 >= 931 && t2 <= 937 || t2 >= 945 && t2 <= 961 || t2 >= 963 && t2 <= 969 || t2 === 1025 || t2 >= 1040 && t2 <= 1103 || t2 === 1105 || t2 === 8208 || t2 >= 8211 && t2 <= 8214 || t2 === 8216 || t2 === 8217 || t2 === 8220 || t2 === 8221 || t2 >= 8224 && t2 <= 8226 || t2 >= 8228 && t2 <= 8231 || t2 === 8240 || t2 === 8242 || t2 === 8243 || t2 === 8245 || t2 === 8251 || t2 === 8254 || t2 === 8308 || t2 === 8319 || t2 >= 8321 && t2 <= 8324 || t2 === 8364 || t2 === 8451 || t2 === 8453 || t2 === 8457 || t2 === 8467 || t2 === 8470 || t2 === 8481 || t2 === 8482 || t2 === 8486 || t2 === 8491 || t2 === 8531 || t2 === 8532 || t2 >= 8539 && t2 <= 8542 || t2 >= 8544 && t2 <= 8555 || t2 >= 8560 && t2 <= 8569 || t2 === 8585 || t2 >= 8592 && t2 <= 8601 || t2 === 8632 || t2 === 8633 || t2 === 8658 || t2 === 8660 || t2 === 8679 || t2 === 8704 || t2 === 8706 || t2 === 8707 || t2 === 8711 || t2 === 8712 || t2 === 8715 || t2 === 8719 || t2 === 8721 || t2 === 8725 || t2 === 8730 || t2 >= 8733 && t2 <= 8736 || t2 === 8739 || t2 === 8741 || t2 >= 8743 && t2 <= 8748 || t2 === 8750 || t2 >= 8756 && t2 <= 8759 || t2 === 8764 || t2 === 8765 || t2 === 8776 || t2 === 8780 || t2 === 8786 || t2 === 8800 || t2 === 8801 || t2 >= 8804 && t2 <= 8807 || t2 === 8810 || t2 === 8811 || t2 === 8814 || t2 === 8815 || t2 === 8834 || t2 === 8835 || t2 === 8838 || t2 === 8839 || t2 === 8853 || t2 === 8857 || t2 === 8869 || t2 === 8895 || t2 === 8978 || t2 >= 9312 && t2 <= 9449 || t2 >= 9451 && t2 <= 9547 || t2 >= 9552 && t2 <= 9587 || t2 >= 9600 && t2 <= 9615 || t2 >= 9618 && t2 <= 9621 || t2 === 9632 || t2 === 9633 || t2 >= 9635 && t2 <= 9641 || t2 === 9650 || t2 === 9651 || t2 === 9654 || t2 === 9655 || t2 === 9660 || t2 === 9661 || t2 === 9664 || t2 === 9665 || t2 >= 9670 && t2 <= 9672 || t2 === 9675 || t2 >= 9678 && t2 <= 9681 || t2 >= 9698 && t2 <= 9701 || t2 === 9711 || t2 === 9733 || t2 === 9734 || t2 === 9737 || t2 === 9742 || t2 === 9743 || t2 === 9756 || t2 === 9758 || t2 === 9792 || t2 === 9794 || t2 === 9824 || t2 === 9825 || t2 >= 9827 && t2 <= 9829 || t2 >= 9831 && t2 <= 9834 || t2 === 9836 || t2 === 9837 || t2 === 9839 || t2 === 9886 || t2 === 9887 || t2 === 9919 || t2 >= 9926 && t2 <= 9933 || t2 >= 9935 && t2 <= 9939 || t2 >= 9941 && t2 <= 9953 || t2 === 9955 || t2 === 9960 || t2 === 9961 || t2 >= 9963 && t2 <= 9969 || t2 === 9972 || t2 >= 9974 && t2 <= 9977 || t2 === 9979 || t2 === 9980 || t2 === 9982 || t2 === 9983 || t2 === 10045 || t2 >= 10102 && t2 <= 10111 || t2 >= 11094 && t2 <= 11097 || t2 >= 12872 && t2 <= 12879 || t2 >= 57344 && t2 <= 63743 || t2 >= 65024 && t2 <= 65039 || t2 === 65533 || t2 >= 127232 && t2 <= 127242 || t2 >= 127248 && t2 <= 127277 || t2 >= 127280 && t2 <= 127337 || t2 >= 127344 && t2 <= 127373 || t2 === 127375 || t2 === 127376 || t2 >= 127387 && t2 <= 127404 || t2 >= 917760 && t2 <= 917999 || t2 >= 983040 && t2 <= 1048573 || t2 >= 1048576 && t2 <= 1114109, "at");
79
- var lt = /* @__PURE__ */ __name((t2) => t2 === 12288 || t2 >= 65281 && t2 <= 65376 || t2 >= 65504 && t2 <= 65510, "lt");
80
- var ht = /* @__PURE__ */ __name((t2) => t2 >= 4352 && t2 <= 4447 || t2 === 8986 || t2 === 8987 || t2 === 9001 || t2 === 9002 || t2 >= 9193 && t2 <= 9196 || t2 === 9200 || t2 === 9203 || t2 === 9725 || t2 === 9726 || t2 === 9748 || t2 === 9749 || t2 >= 9800 && t2 <= 9811 || t2 === 9855 || t2 === 9875 || t2 === 9889 || t2 === 9898 || t2 === 9899 || t2 === 9917 || t2 === 9918 || t2 === 9924 || t2 === 9925 || t2 === 9934 || t2 === 9940 || t2 === 9962 || t2 === 9970 || t2 === 9971 || t2 === 9973 || t2 === 9978 || t2 === 9981 || t2 === 9989 || t2 === 9994 || t2 === 9995 || t2 === 10024 || t2 === 10060 || t2 === 10062 || t2 >= 10067 && t2 <= 10069 || t2 === 10071 || t2 >= 10133 && t2 <= 10135 || t2 === 10160 || t2 === 10175 || t2 === 11035 || t2 === 11036 || t2 === 11088 || t2 === 11093 || t2 >= 11904 && t2 <= 11929 || t2 >= 11931 && t2 <= 12019 || t2 >= 12032 && t2 <= 12245 || t2 >= 12272 && t2 <= 12287 || t2 >= 12289 && t2 <= 12350 || t2 >= 12353 && t2 <= 12438 || t2 >= 12441 && t2 <= 12543 || t2 >= 12549 && t2 <= 12591 || t2 >= 12593 && t2 <= 12686 || t2 >= 12688 && t2 <= 12771 || t2 >= 12783 && t2 <= 12830 || t2 >= 12832 && t2 <= 12871 || t2 >= 12880 && t2 <= 19903 || t2 >= 19968 && t2 <= 42124 || t2 >= 42128 && t2 <= 42182 || t2 >= 43360 && t2 <= 43388 || t2 >= 44032 && t2 <= 55203 || t2 >= 63744 && t2 <= 64255 || t2 >= 65040 && t2 <= 65049 || t2 >= 65072 && t2 <= 65106 || t2 >= 65108 && t2 <= 65126 || t2 >= 65128 && t2 <= 65131 || t2 >= 94176 && t2 <= 94180 || t2 === 94192 || t2 === 94193 || t2 >= 94208 && t2 <= 100343 || t2 >= 100352 && t2 <= 101589 || t2 >= 101632 && t2 <= 101640 || t2 >= 110576 && t2 <= 110579 || t2 >= 110581 && t2 <= 110587 || t2 === 110589 || t2 === 110590 || t2 >= 110592 && t2 <= 110882 || t2 === 110898 || t2 >= 110928 && t2 <= 110930 || t2 === 110933 || t2 >= 110948 && t2 <= 110951 || t2 >= 110960 && t2 <= 111355 || t2 === 126980 || t2 === 127183 || t2 === 127374 || t2 >= 127377 && t2 <= 127386 || t2 >= 127488 && t2 <= 127490 || t2 >= 127504 && t2 <= 127547 || t2 >= 127552 && t2 <= 127560 || t2 === 127568 || t2 === 127569 || t2 >= 127584 && t2 <= 127589 || t2 >= 127744 && t2 <= 127776 || t2 >= 127789 && t2 <= 127797 || t2 >= 127799 && t2 <= 127868 || t2 >= 127870 && t2 <= 127891 || t2 >= 127904 && t2 <= 127946 || t2 >= 127951 && t2 <= 127955 || t2 >= 127968 && t2 <= 127984 || t2 === 127988 || t2 >= 127992 && t2 <= 128062 || t2 === 128064 || t2 >= 128066 && t2 <= 128252 || t2 >= 128255 && t2 <= 128317 || t2 >= 128331 && t2 <= 128334 || t2 >= 128336 && t2 <= 128359 || t2 === 128378 || t2 === 128405 || t2 === 128406 || t2 === 128420 || t2 >= 128507 && t2 <= 128591 || t2 >= 128640 && t2 <= 128709 || t2 === 128716 || t2 >= 128720 && t2 <= 128722 || t2 >= 128725 && t2 <= 128727 || t2 >= 128732 && t2 <= 128735 || t2 === 128747 || t2 === 128748 || t2 >= 128756 && t2 <= 128764 || t2 >= 128992 && t2 <= 129003 || t2 === 129008 || t2 >= 129292 && t2 <= 129338 || t2 >= 129340 && t2 <= 129349 || t2 >= 129351 && t2 <= 129535 || t2 >= 129648 && t2 <= 129660 || t2 >= 129664 && t2 <= 129672 || t2 >= 129680 && t2 <= 129725 || t2 >= 129727 && t2 <= 129733 || t2 >= 129742 && t2 <= 129755 || t2 >= 129760 && t2 <= 129768 || t2 >= 129776 && t2 <= 129784 || t2 >= 131072 && t2 <= 196605 || t2 >= 196608 && t2 <= 262141, "ht");
81
- var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
82
- var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
83
- var L = /\t{1,1000}/y;
84
- var P = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
85
- var M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
86
- var ct = new RegExp("\\p{M}+", "gu");
87
- var ft = { limit: 1 / 0, ellipsis: "" };
88
- var X = /* @__PURE__ */ __name((t2, e = {}, s = {}) => {
89
- const i = e.limit ?? 1 / 0, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, ft, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V2 = s.wideWidth ?? 2;
90
- let h2 = 0, o = 0, p = t2.length, v = 0, F = false, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
91
- t: for (; ; ) {
92
- if (w > C || o >= p && o > h2) {
93
- const ut = t2.slice(C, w) || t2.slice(h2, o);
94
- v = 0;
95
- for (const Y of ut.replaceAll(ct, "")) {
96
- const $ = Y.codePointAt(0) || 0;
97
- if (lt($) ? f = m : ht($) ? f = V2 : E !== A && at($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h2) + v)), c + f > i) {
98
- F = true;
99
- break t;
100
- }
101
- v += Y.length, c += f;
102
- }
103
- C = w = 0;
104
- }
105
- if (o >= p) break;
106
- if (M.lastIndex = o, M.test(t2)) {
107
- if (v = M.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
108
- F = true;
109
- break;
110
- }
111
- c += f, C = h2, w = o, o = h2 = M.lastIndex;
112
- continue;
113
- }
114
- if (O.lastIndex = o, O.test(t2)) {
115
- if (c + u > b && (d = Math.min(d, o)), c + u > i) {
116
- F = true;
117
- break;
118
- }
119
- c += u, C = h2, w = o, o = h2 = O.lastIndex;
120
- continue;
121
- }
122
- if (y.lastIndex = o, y.test(t2)) {
123
- if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
124
- F = true;
125
- break;
126
- }
127
- c += f, C = h2, w = o, o = h2 = y.lastIndex;
128
- continue;
129
- }
130
- if (L.lastIndex = o, L.test(t2)) {
131
- if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
132
- F = true;
133
- break;
134
- }
135
- c += f, C = h2, w = o, o = h2 = L.lastIndex;
136
- continue;
137
- }
138
- if (P.lastIndex = o, P.test(t2)) {
139
- if (c + g > b && (d = Math.min(d, o)), c + g > i) {
140
- F = true;
141
- break;
142
- }
143
- c += g, C = h2, w = o, o = h2 = P.lastIndex;
144
- continue;
145
- }
146
- o += 1;
147
- }
148
- return { width: F ? b : c, index: F ? d : p, truncated: F, ellipsed: F && i >= n };
149
- }, "X");
150
- var pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
151
- var S = /* @__PURE__ */ __name((t2, e = {}) => X(t2, pt, e).width, "S");
152
- var T = "\x1B";
153
- var Z = "\x9B";
154
- var Ft = 39;
155
- var j = "\x07";
156
- var Q = "[";
157
- var dt = "]";
158
- var tt = "m";
159
- var U = `${dt}8;;`;
160
- var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
161
- var mt = /* @__PURE__ */ __name((t2) => {
162
- if (t2 >= 30 && t2 <= 37 || t2 >= 90 && t2 <= 97) return 39;
163
- if (t2 >= 40 && t2 <= 47 || t2 >= 100 && t2 <= 107) return 49;
164
- if (t2 === 1 || t2 === 2) return 22;
165
- if (t2 === 3) return 23;
166
- if (t2 === 4) return 24;
167
- if (t2 === 7) return 27;
168
- if (t2 === 8) return 28;
169
- if (t2 === 9) return 29;
170
- if (t2 === 0) return 0;
171
- }, "mt");
172
- var st = /* @__PURE__ */ __name((t2) => `${T}${Q}${t2}${tt}`, "st");
173
- var it = /* @__PURE__ */ __name((t2) => `${T}${U}${t2}${j}`, "it");
174
- var gt = /* @__PURE__ */ __name((t2) => t2.map((e) => S(e)), "gt");
175
- var G = /* @__PURE__ */ __name((t2, e, s) => {
176
- const i = e[Symbol.iterator]();
177
- let r = false, n = false, u = t2.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
178
- for (; !l.done; ) {
179
- const m = l.value, A = S(m);
180
- a + A <= s ? t2[t2.length - 1] += m : (t2.push(m), a = 0), (m === T || m === Z) && (r = true, n = e.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t2.push(""), a = 0)), l = E, E = i.next(), g += m.length;
181
- }
182
- u = t2.at(-1), !a && u !== void 0 && u.length > 0 && t2.length > 1 && (t2[t2.length - 2] += t2.pop());
183
- }, "G");
184
- var vt = /* @__PURE__ */ __name((t2) => {
185
- const e = t2.split(" ");
186
- let s = e.length;
187
- for (; s > 0 && !(S(e[s - 1]) > 0); ) s--;
188
- return s === e.length ? t2 : e.slice(0, s).join(" ") + e.slice(s).join("");
189
- }, "vt");
190
- var Et = /* @__PURE__ */ __name((t2, e, s = {}) => {
191
- if (s.trim !== false && t2.trim() === "") return "";
192
- let i = "", r, n;
193
- const u = t2.split(" "), a = gt(u);
194
- let l = [""];
195
- for (const [h2, o] of u.entries()) {
196
- s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
197
- let p = S(l.at(-1) ?? "");
198
- if (h2 !== 0 && (p >= e && (s.wordWrap === false || s.trim === false) && (l.push(""), p = 0), (p > 0 || s.trim === false) && (l[l.length - 1] += " ", p++)), s.hard && a[h2] > e) {
199
- const v = e - p, F = 1 + Math.floor((a[h2] - v - 1) / e);
200
- Math.floor((a[h2] - 1) / e) < F && l.push(""), G(l, o, e);
201
- continue;
202
- }
203
- if (p + a[h2] > e && p > 0 && a[h2] > 0) {
204
- if (s.wordWrap === false && p < e) {
205
- G(l, o, e);
206
- continue;
207
- }
208
- l.push("");
209
- }
210
- if (p + a[h2] > e && s.wordWrap === false) {
211
- G(l, o, e);
212
- continue;
213
- }
214
- l[l.length - 1] += o;
215
- }
216
- s.trim !== false && (l = l.map((h2) => vt(h2)));
217
- const E = l.join(`
218
- `), g = E[Symbol.iterator]();
219
- let m = g.next(), A = g.next(), V2 = 0;
220
- for (; !m.done; ) {
221
- const h2 = m.value, o = A.value;
222
- if (i += h2, h2 === T || h2 === Z) {
223
- et.lastIndex = V2 + 1;
224
- const F = et.exec(E)?.groups;
225
- if (F?.code !== void 0) {
226
- const d = Number.parseFloat(F.code);
227
- r = d === Ft ? void 0 : d;
228
- } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
229
- }
230
- const p = r ? mt(r) : void 0;
231
- o === `
232
- ` ? (n && (i += it("")), r && p && (i += st(p))) : h2 === `
233
- ` && (r && p && (i += st(r)), n && (i += it(n))), V2 += h2.length, m = A, A = g.next();
234
- }
235
- return i;
236
- }, "Et");
237
- function K(t2, e, s) {
238
- return String(t2).normalize().replaceAll(`\r
239
- `, `
240
- `).split(`
241
- `).map((i) => Et(i, e, s)).join(`
242
- `);
243
- }
244
- __name(K, "K");
245
- var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
246
- var _ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), withGuide: true };
247
- function H(t2, e) {
248
- if (typeof t2 == "string") return _.aliases.get(t2) === e;
249
- for (const s of t2) if (s !== void 0 && H(s, e)) return true;
250
- return false;
251
- }
252
- __name(H, "H");
253
- function _t(t2, e) {
254
- if (t2 === e) return;
255
- const s = t2.split(`
256
- `), i = e.split(`
257
- `), r = Math.max(s.length, i.length), n = [];
258
- for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
259
- return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
260
- }
261
- __name(_t, "_t");
262
- globalThis.process.platform.startsWith("win");
263
- var z = /* @__PURE__ */ Symbol("clack:cancel");
264
- function Ct(t2) {
265
- return t2 === z;
266
- }
267
- __name(Ct, "Ct");
268
- function W(t2, e) {
269
- const s = t2;
270
- s.isTTY && s.setRawMode(e);
271
- }
272
- __name(W, "W");
273
- var rt = /* @__PURE__ */ __name((t2) => "columns" in t2 && typeof t2.columns == "number" ? t2.columns : 80, "rt");
274
- var nt = /* @__PURE__ */ __name((t2) => "rows" in t2 && typeof t2.rows == "number" ? t2.rows : 20, "nt");
275
- function Bt(t2, e, s, i = s) {
276
- const r = rt(t2 ?? stdout);
277
- return K(e, r - s.length, { hard: true, trim: false }).split(`
278
- `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
279
- `);
280
- }
281
- __name(Bt, "Bt");
282
- var B = class {
283
- static {
284
- __name(this, "B");
285
- }
286
- input;
287
- output;
288
- _abortSignal;
289
- rl;
290
- opts;
291
- _render;
292
- _track = false;
293
- _prevFrame = "";
294
- _subscribers = /* @__PURE__ */ new Map();
295
- _cursor = 0;
296
- state = "initial";
297
- error = "";
298
- value;
299
- userInput = "";
300
- constructor(e, s = true) {
301
- const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
302
- this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
303
- }
304
- unsubscribe() {
305
- this._subscribers.clear();
306
- }
307
- setSubscriber(e, s) {
308
- const i = this._subscribers.get(e) ?? [];
309
- i.push(s), this._subscribers.set(e, i);
310
- }
311
- on(e, s) {
312
- this.setSubscriber(e, { cb: s });
313
- }
314
- once(e, s) {
315
- this.setSubscriber(e, { cb: s, once: true });
316
- }
317
- emit(e, ...s) {
318
- const i = this._subscribers.get(e) ?? [], r = [];
319
- for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
320
- for (const n of r) n();
321
- }
322
- prompt() {
323
- return new Promise((e) => {
324
- if (this._abortSignal) {
325
- if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z);
326
- this._abortSignal.addEventListener("abort", () => {
327
- this.state = "cancel", this.close();
328
- }, { once: true });
329
- }
330
- this.rl = ot.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), W(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
331
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), W(this.input, false), e(this.value);
332
- }), this.once("cancel", () => {
333
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), W(this.input, false), e(z);
334
- });
335
- });
336
- }
337
- _isActionKey(e, s) {
338
- return e === " ";
339
- }
340
- _setValue(e) {
341
- this.value = e, this.emit("value", this.value);
342
- }
343
- _setUserInput(e, s) {
344
- this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
345
- }
346
- _clearUserInput() {
347
- this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
348
- }
349
- onKeypress(e, s) {
350
- if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
351
- if (this.opts.validate) {
352
- const i = this.opts.validate(this.value);
353
- i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
354
- }
355
- this.state !== "error" && (this.state = "submit");
356
- }
357
- H([e, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
358
- }
359
- close() {
360
- this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
361
- `), W(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
362
- }
363
- restoreCursor() {
364
- const e = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
365
- `).length - 1;
366
- this.output.write(import_sisteransi.cursor.move(-999, e * -1));
367
- }
368
- render() {
369
- const e = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
370
- if (e !== this._prevFrame) {
371
- if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
372
- else {
373
- const s = _t(this._prevFrame, e), i = nt(this.output);
374
- if (this.restoreCursor(), s) {
375
- const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
376
- let u = s.lines.find((a) => a >= r);
377
- if (u === void 0) {
378
- this._prevFrame = e;
379
- return;
380
- }
381
- if (s.lines.length === 1) {
382
- this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
383
- const a = e.split(`
384
- `);
385
- this.output.write(a[u]), this._prevFrame = e, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
386
- return;
387
- } else if (s.lines.length > 1) {
388
- if (r < n) u = r;
389
- else {
390
- const l = u - n;
391
- l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
392
- }
393
- this.output.write(import_sisteransi.erase.down());
394
- const a = e.split(`
395
- `).slice(u);
396
- this.output.write(a.join(`
397
- `)), this._prevFrame = e;
398
- return;
399
- }
400
- }
401
- this.output.write(import_sisteransi.erase.down());
402
- }
403
- this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
404
- }
405
- }
406
- };
407
- var kt = class extends B {
408
- static {
409
- __name(this, "kt");
410
- }
411
- get cursor() {
412
- return this.value ? 0 : 1;
413
- }
414
- get _value() {
415
- return this.cursor === 0;
416
- }
417
- constructor(e) {
418
- super(e, false), this.value = !!e.initialValue, this.on("userInput", () => {
419
- this.value = this._value;
420
- }), this.on("confirm", (s) => {
421
- this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
422
- }), this.on("cursor", () => {
423
- this.value = !this.value;
424
- });
425
- }
426
- };
427
- var Lt = class extends B {
428
- static {
429
- __name(this, "Lt");
430
- }
431
- options;
432
- cursor = 0;
433
- get _value() {
434
- return this.options[this.cursor].value;
435
- }
436
- get _enabledOptions() {
437
- return this.options.filter((e) => e.disabled !== true);
438
- }
439
- toggleAll() {
440
- const e = this._enabledOptions, s = this.value !== void 0 && this.value.length === e.length;
441
- this.value = s ? [] : e.map((i) => i.value);
442
- }
443
- toggleInvert() {
444
- const e = this.value;
445
- if (!e) return;
446
- const s = this._enabledOptions.filter((i) => !e.includes(i.value));
447
- this.value = s.map((i) => i.value);
448
- }
449
- toggleValue() {
450
- this.value === void 0 && (this.value = []);
451
- const e = this.value.includes(this._value);
452
- this.value = e ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
453
- }
454
- constructor(e) {
455
- super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
456
- const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
457
- this.cursor = this.options[s].disabled ? x(s, 1, this.options) : s, this.on("key", (i) => {
458
- i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
459
- }), this.on("cursor", (i) => {
460
- switch (i) {
461
- case "left":
462
- case "up":
463
- this.cursor = x(this.cursor, -1, this.options);
464
- break;
465
- case "down":
466
- case "right":
467
- this.cursor = x(this.cursor, 1, this.options);
468
- break;
469
- case "space":
470
- this.toggleValue();
471
- break;
472
- }
473
- });
474
- }
475
- };
476
- var Tt = class extends B {
477
- static {
478
- __name(this, "Tt");
479
- }
480
- options;
481
- cursor = 0;
482
- get _selectedValue() {
483
- return this.options[this.cursor];
484
- }
485
- changeValue() {
486
- this.value = this._selectedValue.value;
487
- }
488
- constructor(e) {
489
- super(e, false), this.options = e.options;
490
- const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
491
- this.cursor = this.options[i].disabled ? x(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
492
- switch (r) {
493
- case "left":
494
- case "up":
495
- this.cursor = x(this.cursor, -1, this.options);
496
- break;
497
- case "down":
498
- case "right":
499
- this.cursor = x(this.cursor, 1, this.options);
500
- break;
501
- }
502
- this.changeValue();
503
- });
504
- }
505
- };
506
-
507
- // ../../node_modules/.bun/@clack+prompts@1.1.0/node_modules/@clack/prompts/dist/index.mjs
508
- __toESM(require_src(), 1);
509
- function pt2() {
510
- return N2.platform !== "win32" ? N2.env.TERM !== "linux" : !!N2.env.CI || !!N2.env.WT_SESSION || !!N2.env.TERMINUS_SUBLIME || N2.env.ConEmuTask === "{cmd::Cmder}" || N2.env.TERM_PROGRAM === "Terminus-Sublime" || N2.env.TERM_PROGRAM === "vscode" || N2.env.TERM === "xterm-256color" || N2.env.TERM === "alacritty" || N2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
511
- }
512
- __name(pt2, "pt");
513
- var ee = pt2();
514
- var I2 = /* @__PURE__ */ __name((e, r) => ee ? e : r, "I");
515
- var Re = I2("\u25C6", "*");
516
- var $e = I2("\u25A0", "x");
517
- var de = I2("\u25B2", "x");
518
- var V = I2("\u25C7", "o");
519
- I2("\u250C", "T");
520
- var h = I2("\u2502", "|");
521
- var x2 = I2("\u2514", "\u2014");
522
- I2("\u2510", "T");
523
- I2("\u2518", "\u2014");
524
- var z2 = I2("\u25CF", ">");
525
- var H2 = I2("\u25CB", " ");
526
- I2("\u25FB", "[\u2022]");
527
- I2("\u25FC", "[+]");
528
- I2("\u25FB", "[ ]");
529
- I2("\u25AA", "\u2022");
530
- I2("\u2500", "-");
531
- I2("\u256E", "+");
532
- I2("\u251C", "+");
533
- I2("\u256F", "+");
534
- I2("\u2570", "+");
535
- I2("\u256D", "+");
536
- I2("\u25CF", "\u2022");
537
- I2("\u25C6", "*");
538
- I2("\u25B2", "!");
539
- I2("\u25A0", "x");
540
- var W2 = /* @__PURE__ */ __name((e) => {
541
- switch (e) {
542
- case "initial":
543
- case "active":
544
- return styleText("cyan", Re);
545
- case "cancel":
546
- return styleText("red", $e);
547
- case "error":
548
- return styleText("yellow", de);
549
- case "submit":
550
- return styleText("green", V);
551
- }
552
- }, "W");
553
- var ve = /* @__PURE__ */ __name((e) => {
554
- switch (e) {
555
- case "initial":
556
- case "active":
557
- return styleText("cyan", h);
558
- case "cancel":
559
- return styleText("red", h);
560
- case "error":
561
- return styleText("yellow", h);
562
- case "submit":
563
- return styleText("green", h);
564
- }
565
- }, "ve");
566
- var mt2 = /* @__PURE__ */ __name((e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109, "mt");
567
- var gt2 = /* @__PURE__ */ __name((e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, "gt");
568
- var ft2 = /* @__PURE__ */ __name((e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, "ft");
569
- var we = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
570
- var re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
571
- var ie = /\t{1,1000}/y;
572
- var Ae = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
573
- var ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
574
- var Ft2 = new RegExp("\\p{M}+", "gu");
575
- var yt2 = { limit: 1 / 0, ellipsis: "" };
576
- var Le = /* @__PURE__ */ __name((e, r = {}, s = {}) => {
577
- const i = r.limit ?? 1 / 0, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? Le(a, yt2, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, p = s.emojiWidth ?? 2, f = s.fullWidthWidth ?? 2, g = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
578
- let $ = 0, m = 0, d = e.length, F = 0, y2 = false, v = d, C = Math.max(0, i - o), A = 0, b = 0, w = 0, S2 = 0;
579
- e: for (; ; ) {
580
- if (b > A || m >= d && m > $) {
581
- const T2 = e.slice(A, b) || e.slice($, m);
582
- F = 0;
583
- for (const M2 of T2.replaceAll(Ft2, "")) {
584
- const O2 = M2.codePointAt(0) || 0;
585
- if (gt2(O2) ? S2 = f : ft2(O2) ? S2 = E : c !== g && mt2(O2) ? S2 = c : S2 = g, w + S2 > C && (v = Math.min(v, Math.max(A, $) + F)), w + S2 > i) {
586
- y2 = true;
587
- break e;
588
- }
589
- F += M2.length, w += S2;
590
- }
591
- A = b = 0;
592
- }
593
- if (m >= d) break;
594
- if (ne.lastIndex = m, ne.test(e)) {
595
- if (F = ne.lastIndex - m, S2 = F * g, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S2 > i) {
596
- y2 = true;
597
- break;
598
- }
599
- w += S2, A = $, b = m, m = $ = ne.lastIndex;
600
- continue;
601
- }
602
- if (we.lastIndex = m, we.test(e)) {
603
- if (w + u > C && (v = Math.min(v, m)), w + u > i) {
604
- y2 = true;
605
- break;
606
- }
607
- w += u, A = $, b = m, m = $ = we.lastIndex;
608
- continue;
609
- }
610
- if (re.lastIndex = m, re.test(e)) {
611
- if (F = re.lastIndex - m, S2 = F * l, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S2 > i) {
612
- y2 = true;
613
- break;
614
- }
615
- w += S2, A = $, b = m, m = $ = re.lastIndex;
616
- continue;
617
- }
618
- if (ie.lastIndex = m, ie.test(e)) {
619
- if (F = ie.lastIndex - m, S2 = F * n, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S2 > i) {
620
- y2 = true;
621
- break;
622
- }
623
- w += S2, A = $, b = m, m = $ = ie.lastIndex;
624
- continue;
625
- }
626
- if (Ae.lastIndex = m, Ae.test(e)) {
627
- if (w + p > C && (v = Math.min(v, m)), w + p > i) {
628
- y2 = true;
629
- break;
630
- }
631
- w += p, A = $, b = m, m = $ = Ae.lastIndex;
632
- continue;
633
- }
634
- m += 1;
635
- }
636
- return { width: y2 ? C : w, index: y2 ? v : d, truncated: y2, ellipsed: y2 && i >= o };
637
- }, "Le");
638
- var Et2 = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
639
- var D2 = /* @__PURE__ */ __name((e, r = {}) => Le(e, Et2, r).width, "D");
640
- var ae = "\x1B";
641
- var je = "\x9B";
642
- var vt2 = 39;
643
- var Ce = "\x07";
644
- var ke = "[";
645
- var wt = "]";
646
- var Ve = "m";
647
- var Se = `${wt}8;;`;
648
- var He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y");
649
- var At2 = /* @__PURE__ */ __name((e) => {
650
- if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
651
- if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
652
- if (e === 1 || e === 2) return 22;
653
- if (e === 3) return 23;
654
- if (e === 4) return 24;
655
- if (e === 7) return 27;
656
- if (e === 8) return 28;
657
- if (e === 9) return 29;
658
- if (e === 0) return 0;
659
- }, "At");
660
- var Ue = /* @__PURE__ */ __name((e) => `${ae}${ke}${e}${Ve}`, "Ue");
661
- var Ke = /* @__PURE__ */ __name((e) => `${ae}${Se}${e}${Ce}`, "Ke");
662
- var Ct2 = /* @__PURE__ */ __name((e) => e.map((r) => D2(r)), "Ct");
663
- var Ie = /* @__PURE__ */ __name((e, r, s) => {
664
- const i = r[Symbol.iterator]();
665
- let a = false, o = false, u = e.at(-1), l = u === void 0 ? 0 : D2(u), n = i.next(), c = i.next(), p = 0;
666
- for (; !n.done; ) {
667
- const f = n.value, g = D2(f);
668
- l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = true, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = false, o = false) : f === Ve && (a = false) : (l += g, l === s && !c.done && (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
669
- }
670
- u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
671
- }, "Ie");
672
- var St = /* @__PURE__ */ __name((e) => {
673
- const r = e.split(" ");
674
- let s = r.length;
675
- for (; s > 0 && !(D2(r[s - 1]) > 0); ) s--;
676
- return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
677
- }, "St");
678
- var It2 = /* @__PURE__ */ __name((e, r, s = {}) => {
679
- if (s.trim !== false && e.trim() === "") return "";
680
- let i = "", a, o;
681
- const u = e.split(" "), l = Ct2(u);
682
- let n = [""];
683
- for (const [$, m] of u.entries()) {
684
- s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
685
- let d = D2(n.at(-1) ?? "");
686
- if ($ !== 0 && (d >= r && (s.wordWrap === false || s.trim === false) && (n.push(""), d = 0), (d > 0 || s.trim === false) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
687
- const F = r - d, y2 = 1 + Math.floor((l[$] - F - 1) / r);
688
- Math.floor((l[$] - 1) / r) < y2 && n.push(""), Ie(n, m, r);
689
- continue;
690
- }
691
- if (d + l[$] > r && d > 0 && l[$] > 0) {
692
- if (s.wordWrap === false && d < r) {
693
- Ie(n, m, r);
694
- continue;
695
- }
696
- n.push("");
697
- }
698
- if (d + l[$] > r && s.wordWrap === false) {
699
- Ie(n, m, r);
700
- continue;
701
- }
702
- n[n.length - 1] += m;
703
- }
704
- s.trim !== false && (n = n.map(($) => St($)));
705
- const c = n.join(`
706
- `), p = c[Symbol.iterator]();
707
- let f = p.next(), g = p.next(), E = 0;
708
- for (; !f.done; ) {
709
- const $ = f.value, m = g.value;
710
- if (i += $, $ === ae || $ === je) {
711
- He.lastIndex = E + 1;
712
- const y2 = He.exec(c)?.groups;
713
- if (y2?.code !== void 0) {
714
- const v = Number.parseFloat(y2.code);
715
- a = v === vt2 ? void 0 : v;
716
- } else y2?.uri !== void 0 && (o = y2.uri.length === 0 ? void 0 : y2.uri);
717
- }
718
- const d = a ? At2(a) : void 0;
719
- m === `
720
- ` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
721
- ` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
722
- }
723
- return i;
724
- }, "It");
725
- function J2(e, r, s) {
726
- return String(e).normalize().replaceAll(`\r
727
- `, `
728
- `).split(`
729
- `).map((i) => It2(i, r, s)).join(`
730
- `);
731
- }
732
- __name(J2, "J");
733
- var bt2 = /* @__PURE__ */ __name((e, r, s, i, a) => {
734
- let o = r, u = 0;
735
- for (let l = s; l < i; l++) {
736
- const n = e[l];
737
- if (o = o - n.length, u++, o <= a) break;
738
- }
739
- return { lineCount: o, removals: u };
740
- }, "bt");
741
- var X2 = /* @__PURE__ */ __name(({ cursor: e, options: r, style: s, output: i = process.stdout, maxItems: a = Number.POSITIVE_INFINITY, columnPadding: o = 0, rowPadding: u = 4 }) => {
742
- const l = rt(i) - o, n = nt(i), c = styleText("dim", "..."), p = Math.max(n - u, 0), f = Math.max(Math.min(a, p), 5);
743
- let g = 0;
744
- e >= f - 3 && (g = Math.max(Math.min(e - f + 3, r.length - f), 0));
745
- let E = f < r.length && g > 0, $ = f < r.length && g + f < r.length;
746
- const m = Math.min(g + f, r.length), d = [];
747
- let F = 0;
748
- E && F++, $ && F++;
749
- const y2 = g + (E ? 1 : 0), v = m - ($ ? 1 : 0);
750
- for (let A = y2; A < v; A++) {
751
- const b = J2(s(r[A], A === e), l, { hard: true, trim: false }).split(`
752
- `);
753
- d.push(b), F += b.length;
754
- }
755
- if (F > p) {
756
- let A = 0, b = 0, w = F;
757
- const S2 = e - y2, T2 = /* @__PURE__ */ __name((M2, O2) => bt2(d, w, M2, O2, p), "T");
758
- E ? ({ lineCount: w, removals: A } = T2(0, S2), w > p && ({ lineCount: w, removals: b } = T2(S2 + 1, d.length))) : ({ lineCount: w, removals: b } = T2(S2 + 1, d.length), w > p && ({ lineCount: w, removals: A } = T2(0, S2))), A > 0 && (E = true, d.splice(0, A)), b > 0 && ($ = true, d.splice(d.length - b, b));
759
- }
760
- const C = [];
761
- E && C.push(c);
762
- for (const A of d) for (const b of A) C.push(b);
763
- return $ && C.push(c), C;
764
- }, "X");
765
- ({ light: I2("\u2500", "-"), heavy: I2("\u2501", "="), block: I2("\u2588", "#") });
766
- var oe = /* @__PURE__ */ __name((e, r) => e.includes(`
767
- `) ? e.split(`
768
- `).map((s) => r(s)).join(`
769
- `) : r(e), "oe");
770
- var Jt = /* @__PURE__ */ __name((e) => {
771
- const r = /* @__PURE__ */ __name((s, i) => {
772
- const a = s.label ?? String(s.value);
773
- switch (i) {
774
- case "disabled":
775
- return `${styleText("gray", H2)} ${oe(a, (o) => styleText("gray", o))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
776
- case "selected":
777
- return `${oe(a, (o) => styleText("dim", o))}`;
778
- case "active":
779
- return `${styleText("green", z2)} ${a}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
780
- case "cancelled":
781
- return `${oe(a, (o) => styleText(["strikethrough", "dim"], o))}`;
782
- default:
783
- return `${styleText("dim", H2)} ${oe(a, (o) => styleText("dim", o))}`;
784
- }
785
- }, "r");
786
- return new Tt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
787
- const s = e.withGuide ?? _.withGuide, i = `${W2(this.state)} `, a = `${ve(this.state)} `, o = Bt(e.output, e.message, a, i), u = `${s ? `${styleText("gray", h)}
788
- ` : ""}${o}
789
- `;
790
- switch (this.state) {
791
- case "submit": {
792
- const l = s ? `${styleText("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "selected"), l);
793
- return `${u}${n}`;
794
- }
795
- case "cancel": {
796
- const l = s ? `${styleText("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "cancelled"), l);
797
- return `${u}${n}${s ? `
798
- ${styleText("gray", h)}` : ""}`;
799
- }
800
- default: {
801
- const l = s ? `${styleText("cyan", h)} ` : "", n = s ? styleText("cyan", x2) : "", c = u.split(`
802
- `).length, p = s ? 2 : 1;
803
- return `${u}${l}${X2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: l.length, rowPadding: c + p, style: /* @__PURE__ */ __name((f, g) => r(f, f.disabled ? "disabled" : g ? "active" : "inactive"), "style") }).join(`
804
- ${l}`)}
805
- ${n}
806
- `;
807
- }
808
- }
809
- } }).prompt();
810
- }, "Jt");
811
- `${styleText("gray", h)} `;
812
- async function checkIsFileGitIgnored(path3, warnIfNotGitRepo = false) {
813
- try {
814
- await spawnAsync("git", ["check-ignore", path3, "-q"], { cwd: dirname(path3) });
815
- return true;
816
- } catch (err) {
817
- const errorOutput = err.data;
818
- if (err.exitCode === 127 || errorOutput.includes("not found") || errorOutput.includes("not recognized")) {
819
- return void 0;
820
- }
821
- if (err.code === "ENOENT") return void 0;
822
- if (errorOutput === "") return false;
823
- if (errorOutput.includes("not a git repository")) {
824
- if (warnIfNotGitRepo) {
825
- console.log("\u{1F536} Your code is not currently in a git repository - run `git init` to initialize a new repo.");
826
- }
827
- return false;
828
- }
829
- if (errorOutput.includes("is outside repository")) {
830
- return void 0;
831
- }
832
- throw err;
833
- }
834
- }
835
- __name(checkIsFileGitIgnored, "checkIsFileGitIgnored");
836
- function isUnicodeSupported() {
837
- const { env } = N2;
838
- const { TERM, TERM_PROGRAM } = env;
839
- if (N2.platform !== "win32") {
840
- return TERM !== "linux";
841
- }
842
- return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
843
- }
844
- __name(isUnicodeSupported, "isUnicodeSupported");
845
-
846
- // src/cli/helpers/prompts.ts
847
- var unicode = isUnicodeSupported();
848
- var unicodeOr = /* @__PURE__ */ __name((c, fallback) => unicode ? c : fallback, "unicodeOr");
849
- var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
850
- var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
851
- var S_STEP_ERROR = unicodeOr("\u25B2", "x");
852
- var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
853
- unicodeOr("\u250C", "T");
854
- var S_BAR = unicodeOr("\u2502", "|");
855
- var S_BAR_END = unicodeOr("\u2514", "\u2014");
856
- var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
857
- var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
858
- var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
859
- var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
860
- var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
861
- unicodeOr("\u25AA", "\u2022");
862
- unicodeOr("\u2500", "-");
863
- unicodeOr("\u256E", "+");
864
- unicodeOr("\u251C", "+");
865
- unicodeOr("\u256F", "+");
866
- unicodeOr("\u25CF", "\u2022");
867
- unicodeOr("\u25C6", "*");
868
- unicodeOr("\u25B2", "!");
869
- unicodeOr("\u25A0", "x");
870
- var symbol = /* @__PURE__ */ __name((state) => {
871
- switch (state) {
872
- case "initial":
873
- case "active":
874
- return ansis_default.cyan(S_STEP_ACTIVE);
875
- case "cancel":
876
- return ansis_default.red(S_STEP_CANCEL);
877
- case "error":
878
- return ansis_default.yellow(S_STEP_ERROR);
879
- case "submit":
880
- return ansis_default.green(S_STEP_SUBMIT);
881
- }
882
- }, "symbol");
883
- var limitOptions = /* @__PURE__ */ __name((params) => {
884
- const { cursor, options, style } = params;
885
- const output = params.output ?? process.stdout;
886
- const rows = output instanceof WriteStream && output.rows !== void 0 ? output.rows : 10;
887
- const paramMaxItems = params.maxItems ?? Number.POSITIVE_INFINITY;
888
- const outputMaxItems = Math.max(rows - 4, 0);
889
- const maxItems = Math.min(outputMaxItems, Math.max(paramMaxItems, 5));
890
- let slidingWindowLocation = 0;
891
- if (cursor >= slidingWindowLocation + maxItems - 3) {
892
- slidingWindowLocation = Math.max(Math.min(cursor - maxItems + 3, options.length - maxItems), 0);
893
- } else if (cursor < slidingWindowLocation + 2) {
894
- slidingWindowLocation = Math.max(cursor - 2, 0);
895
- }
896
- const shouldRenderTopEllipsis = maxItems < options.length && slidingWindowLocation > 0;
897
- const shouldRenderBottomEllipsis = maxItems < options.length && slidingWindowLocation + maxItems < options.length;
898
- return options.slice(slidingWindowLocation, slidingWindowLocation + maxItems).map((option, i, arr) => {
899
- const isTopLimit = i === 0 && shouldRenderTopEllipsis;
900
- const isBottomLimit = i === arr.length - 1 && shouldRenderBottomEllipsis;
901
- return isTopLimit || isBottomLimit ? ansis_default.dim("...") : style(option, i + slidingWindowLocation === cursor);
902
- });
903
- }, "limitOptions");
904
- var confirm = /* @__PURE__ */ __name((opts) => {
905
- const active = opts.active ?? "Yes";
906
- const inactive = opts.inactive ?? "No";
907
- return new kt({
908
- active,
909
- inactive,
910
- input: opts.input,
911
- output: opts.output,
912
- initialValue: opts.initialValue ?? true,
913
- render() {
914
- const title = `
915
- ${symbol(this.state)} ${opts.message}
916
- `;
917
- const value = this.value ? active : inactive;
918
- switch (this.state) {
919
- case "submit":
920
- return `${title}\u200E ${ansis_default.dim(value)}`;
921
- case "cancel":
922
- return `${title}\u200E ${ansis_default.strikethrough(
923
- ansis_default.dim(value)
924
- )}
925
- `;
926
- default: {
927
- return `${title}\u200E ${this.value ? `${ansis_default.green(S_RADIO_ACTIVE)} ${active}` : `${ansis_default.dim(S_RADIO_INACTIVE)} ${ansis_default.dim(active)}`} ${ansis_default.dim("/")} ${!this.value ? `${ansis_default.green(S_RADIO_ACTIVE)} ${inactive}` : `${ansis_default.dim(S_RADIO_INACTIVE)} ${ansis_default.dim(inactive)}`}
928
- `;
929
- }
930
- }
931
- }
932
- }).prompt();
933
- }, "confirm");
934
- var select = /* @__PURE__ */ __name((opts) => {
935
- const opt = /* @__PURE__ */ __name((option, state) => {
936
- const label = option.label ?? String(option.value);
937
- switch (state) {
938
- case "selected":
939
- return `${ansis_default.dim(label)}`;
940
- case "active":
941
- return `${ansis_default.green(S_RADIO_ACTIVE)} ${label} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
942
- case "cancelled":
943
- return `${ansis_default.strikethrough(ansis_default.dim(label))}`;
944
- default:
945
- return `${ansis_default.dim(S_RADIO_INACTIVE)} ${ansis_default.dim(label)}`;
946
- }
947
- }, "opt");
948
- return new Tt({
949
- options: opts.options,
950
- input: opts.input,
951
- output: opts.output,
952
- initialValue: opts.initialValue,
953
- render() {
954
- const title = `${ansis_default.gray(S_BAR)}
955
- ${symbol(this.state)} ${opts.message}
956
- `;
957
- switch (this.state) {
958
- case "submit":
959
- return `${title}${ansis_default.gray(S_BAR)} ${opt(this.options[this.cursor], "selected")}`;
960
- case "cancel":
961
- return `${title}${ansis_default.gray(S_BAR)} ${opt(
962
- this.options[this.cursor],
963
- "cancelled"
964
- )}
965
- ${ansis_default.gray(S_BAR)}`;
966
- default: {
967
- return `${title}${ansis_default.cyan(S_BAR)} ${limitOptions({
968
- output: opts.output,
969
- cursor: this.cursor,
970
- options: this.options,
971
- maxItems: opts.maxItems,
972
- style: /* @__PURE__ */ __name((item, active) => opt(item, active ? "active" : "inactive"), "style")
973
- }).join(`
974
- ${ansis_default.cyan(S_BAR)} `)}
975
- ${ansis_default.cyan(S_BAR_END)}
976
- `;
977
- }
978
- }
979
- }
980
- }).prompt();
981
- }, "select");
982
- var multiselect = /* @__PURE__ */ __name((opts) => {
983
- const opt = /* @__PURE__ */ __name((option, state) => {
984
- const label = option.label ?? String(option.value);
985
- if (state === "active") {
986
- return `${ansis_default.cyan(S_CHECKBOX_ACTIVE)} ${label} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
987
- }
988
- if (state === "selected") {
989
- return `${ansis_default.green(S_CHECKBOX_SELECTED)} ${ansis_default.dim(label)} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
990
- }
991
- if (state === "cancelled") {
992
- return `${ansis_default.strikethrough(ansis_default.dim(label))}`;
993
- }
994
- if (state === "active-selected") {
995
- return `${ansis_default.green(S_CHECKBOX_SELECTED)} ${label} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
996
- }
997
- if (state === "submitted") {
998
- return `${ansis_default.dim(label)}`;
999
- }
1000
- return `${ansis_default.dim(S_CHECKBOX_INACTIVE)} ${ansis_default.dim(label)}`;
1001
- }, "opt");
1002
- return new Lt({
1003
- options: opts.options,
1004
- input: opts.input,
1005
- output: opts.output,
1006
- initialValues: opts.initialValues,
1007
- required: opts.required ?? true,
1008
- cursorAt: opts.cursorAt,
1009
- validate(selected) {
1010
- if (this.required && (!selected || selected.length === 0)) {
1011
- return `Please select at least one option.
1012
- ${ansis_default.reset(
1013
- ansis_default.dim(
1014
- `Press ${ansis_default.gray(ansis_default.bgWhite(ansis_default.inverse(" space ")))} to select, ${ansis_default.gray(
1015
- ansis_default.bgWhite(ansis_default.inverse(" enter "))
1016
- )} to submit`
1017
- )
1018
- )}`;
1019
- }
1020
- },
1021
- render() {
1022
- let title = `${ansis_default.gray(S_BAR)}
1023
- ${symbol(this.state)} ${opts.message}
1024
- `;
1025
- if (opts.details) title += `${ansis_default.gray(S_BAR)} ${opts.details}
1026
- `;
1027
- const styleOption = /* @__PURE__ */ __name((option, active) => {
1028
- const selected = this.value?.includes(option.value);
1029
- if (active && selected) {
1030
- return opt(option, "active-selected");
1031
- }
1032
- if (selected) {
1033
- return opt(option, "selected");
1034
- }
1035
- return opt(option, active ? "active" : "inactive");
1036
- }, "styleOption");
1037
- switch (this.state) {
1038
- case "submit": {
1039
- return `${title}${ansis_default.gray(S_BAR)} ${this.options.filter(({ value }) => this.value?.includes(value)).map((option) => opt(option, "submitted")).join(ansis_default.dim(", ")) || ansis_default.dim("none")}`;
1040
- }
1041
- case "cancel": {
1042
- const label = this.options.filter(({ value }) => this.value?.includes(value)).map((option) => opt(option, "cancelled")).join(ansis_default.dim(", "));
1043
- return `${title}${ansis_default.gray(S_BAR)} ${label.trim() ? `${label}
1044
- ${ansis_default.gray(S_BAR)}` : ""}`;
1045
- }
1046
- case "error": {
1047
- const footer = this.error.split("\n").map((ln, i) => i === 0 ? `${ansis_default.yellow(S_BAR_END)} ${ansis_default.yellow(ln)}` : ` ${ln}`).join("\n");
1048
- return `${title + ansis_default.yellow(S_BAR)} ${limitOptions({
1049
- output: opts.output,
1050
- options: this.options,
1051
- cursor: this.cursor,
1052
- maxItems: opts.maxItems,
1053
- style: styleOption
1054
- }).join(`
1055
- ${ansis_default.yellow(S_BAR)} `)}
1056
- ${footer}
1057
- `;
1058
- }
1059
- default: {
1060
- return `${title}${ansis_default.cyan(S_BAR)} ${limitOptions({
1061
- output: opts.output,
1062
- options: this.options,
1063
- cursor: this.cursor,
1064
- maxItems: opts.maxItems,
1065
- style: styleOption
1066
- }).join(`
1067
- ${ansis_default.cyan(S_BAR)} `)}
1068
- ${ansis_default.cyan(S_BAR_END)}
1069
- `;
1070
- }
1071
- }
1072
- }
1073
- }).prompt();
1074
- }, "multiselect");
1075
- var prompts = {
1076
- confirm,
1077
- select,
1078
- multiselect
1079
- };
1080
- var prompts_default = prompts;
1081
- var PUBLIC_PREFIXES = [
1082
- "PUBLIC",
1083
- "VITE",
1084
- "NEXT_PUBLIC",
1085
- "NUXT_PUBLIC"
1086
- ];
1087
- var PUBLIC_KEYWORDS = ["PUBLIC"];
1088
- var SENSITIVE_KEYWORDS = [
1089
- "SECRET",
1090
- "API_KEY",
1091
- "PASSWORD",
1092
- "TOKEN",
1093
- "PRIVATE",
1094
- "CREDENTIALS"
1095
- ];
1096
- function isValidUrl(val) {
1097
- try {
1098
- const u = new URL(val);
1099
- return true;
1100
- } catch (err) {
1101
- return false;
1102
- }
1103
- }
1104
- __name(isValidUrl, "isValidUrl");
1105
- var EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1106
- var VALID_NUMBER_REGEX = /^(0|([1-9][0-9]*))?(\.[0-9]+)?$/;
1107
- function inferItemDecorators(file, itemKey, valueStr) {
1108
- let itemIsPublic = false;
1109
- if (PUBLIC_PREFIXES.some((prefix) => itemKey.startsWith(prefix))) itemIsPublic = true;
1110
- if (PUBLIC_KEYWORDS.some((keyword) => itemKey.includes(keyword))) itemIsPublic = true;
1111
- let itemIsSensitive = false;
1112
- if (SENSITIVE_KEYWORDS.some((keyword) => itemKey.includes(keyword))) itemIsSensitive = true;
1113
- if (itemIsPublic) ; else if (itemIsSensitive) {
1114
- envSpecUpdater.setItemDecorator(file, itemKey, "sensitive", "true");
1115
- }
1116
- if (itemKey === "PORT" || itemKey.endsWith("_PORT")) {
1117
- envSpecUpdater.setItemDecorator(file, itemKey, "type", "port");
1118
- } else if (itemKey.endsWith("_EMAIL")) {
1119
- envSpecUpdater.setItemDecorator(file, itemKey, "type", "email");
1120
- } else if (itemKey.endsWith("_URL") || itemKey.endsWith("_URI")) {
1121
- envSpecUpdater.setItemDecorator(file, itemKey, "type", "url");
1122
- } else if (valueStr) {
1123
- if (valueStr.startsWith("<") && valueStr.endsWith(">")) {
1124
- envSpecUpdater.setItemDecorator(file, itemKey, "example", valueStr);
1125
- }
1126
- if (valueStr === "true" || valueStr === "false") {
1127
- envSpecUpdater.setItemDecorator(file, itemKey, "type", "boolean");
1128
- } else if (EMAIL_REGEX.test(valueStr)) {
1129
- envSpecUpdater.setItemDecorator(file, itemKey, "type", "email");
1130
- } else if (valueStr !== "0" && valueStr !== "1" && VALID_NUMBER_REGEX.test(valueStr)) {
1131
- envSpecUpdater.setItemDecorator(file, itemKey, "type", "number");
1132
- } else if (isValidUrl(valueStr)) {
1133
- envSpecUpdater.setItemDecorator(file, itemKey, "type", "url");
1134
- }
1135
- }
1136
- }
1137
- __name(inferItemDecorators, "inferItemDecorators");
1138
- function inferSchemaUpdates(file) {
1139
- for (const item of file.configItems) {
1140
- const valueStr = item.value instanceof ParsedEnvSpecStaticValue && item.value.value?.toString() || "";
1141
- inferItemDecorators(file, item.key, valueStr);
1142
- }
1143
- }
1144
- __name(inferSchemaUpdates, "inferSchemaUpdates");
1145
- function ensureAllItemsExist(schemaFile, otherFiles) {
1146
- const addedItemKeys = [];
1147
- for (const otherFile of otherFiles) {
1148
- for (const item of otherFile.parsedFile.configItems) {
1149
- const itemInSchema = schemaFile.configItems.find((i) => i.key === item.key);
1150
- if (itemInSchema) continue;
1151
- if (addedItemKeys.length === 0) {
1152
- envSpecUpdater.injectFromStr(schemaFile, [
1153
- "",
1154
- "# items added to schema by `varlock init`",
1155
- "# that were missing in example, but detected in other .env files",
1156
- "# PLEASE REVIEW THESE!",
1157
- "# ---",
1158
- ""
1159
- ].join("\n"), { location: "end" });
1160
- }
1161
- addedItemKeys.push(item.key);
1162
- envSpecUpdater.injectFromStr(schemaFile, `${item.key}=`);
1163
- const itemValue = item.value instanceof ParsedEnvSpecStaticValue && item.value.value?.toString() || "";
1164
- inferItemDecorators(schemaFile, item.key, String(itemValue));
1165
- }
1166
- }
1167
- }
1168
- __name(ensureAllItemsExist, "ensureAllItemsExist");
1169
- async function detectRedundantValues(schemaFile, otherFiles, opts = {}) {
1170
- const redundantItemsBySourcePath = {};
1171
- const schemaValues = schemaFile.toSimpleObj();
1172
- for (const otherFile of Object.values(otherFiles)) {
1173
- if (otherFile.fileName.startsWith(".env.schema") || otherFile.fileName.startsWith(".env.example") || otherFile.fileName.startsWith(".env.sample") || otherFile.fileName.startsWith(".env.default")) continue;
1174
- const otherFileValues = otherFile.parsedFile.toSimpleObj();
1175
- for (const itemKey in otherFileValues) {
1176
- if (!(itemKey in schemaValues)) continue;
1177
- if (otherFileValues[itemKey] !== schemaValues[itemKey]) continue;
1178
- redundantItemsBySourcePath[otherFile.fullPath] ||= [];
1179
- redundantItemsBySourcePath[otherFile.fullPath].push(itemKey);
1180
- if (opts.delete) {
1181
- envSpecUpdater.deleteItem(otherFile.parsedFile, itemKey);
1182
- }
1183
- }
1184
- if (opts.delete) {
1185
- await fs3.writeFile(otherFile.fullPath, otherFile.parsedFile.toString(), "utf8");
1186
- }
1187
- }
1188
- return redundantItemsBySourcePath;
1189
- }
1190
- __name(detectRedundantValues, "detectRedundantValues");
1191
- var SKIP_FILE_TYPES = [".md", ".d.ts"];
1192
- async function findEnvFiles(opts) {
1193
- const cwd = opts?.cwd || process.cwd();
1194
- const envFiles = [];
1195
- const filesWithinDir = await fs3.readdir(cwd);
1196
- for (const fileName of filesWithinDir) {
1197
- if (fileName === ".env" || fileName.startsWith(".env.")) {
1198
- let skip = false;
1199
- for (const fileType of SKIP_FILE_TYPES) {
1200
- if (fileName.endsWith(fileType)) skip = true;
1201
- }
1202
- if (skip) continue;
1203
- envFiles.push(path2.join(cwd, fileName));
1204
- }
1205
- }
1206
- return envFiles;
1207
- }
1208
- __name(findEnvFiles, "findEnvFiles");
1209
-
1210
- // src/cli/commands/init.command.ts
1211
- var commandSpec = define({
1212
- name: "init",
1213
- description: "Set up varlock in the current project",
1214
- args: {},
1215
- examples: `
1216
- This command starts an interactive onboarding process to help you get started with Varlock.
1217
- It will:
1218
- - Scan for existing .env files in your project
1219
- - Help create a .env.schema file from your .env.example or .env.sample file
1220
- - Install varlock as a dependency in package.json (if applicable)
1221
-
1222
- \u{1F4CD} Run this command in directories that contain .env or .env.* files
1223
-
1224
- Examples:
1225
- varlock init # Run in the current directory
1226
- cd path/to/your/project && varlock init
1227
-
1228
- For more information, visit https://varlock.dev/getting-started/installation
1229
- `.trim()
1230
- });
1231
- var commandFn = /* @__PURE__ */ __name(async (ctx) => {
1232
- const jsPackageManager = detectJsPackageManager();
1233
- console.log("\u{1F9D9} Hello and welcome to Varlock \u{1F512}\u{1F525}\u2728");
1234
- const envFilePaths = await findEnvFiles();
1235
- const parsedEnvFiles = {};
1236
- for (const filePath of envFilePaths) {
1237
- const fileContents = await fs3.readFile(filePath, "utf-8");
1238
- const fileName = path2.basename(filePath);
1239
- const parsedFile = await tryCatch(async () => parseEnvSpecDotEnvFile(fileContents), () => {
1240
- logLines([
1241
- "",
1242
- `Unable to parse ${fmt.filePath(filePath)}`,
1243
- "This file will be skipped."
1244
- ]);
1245
- });
1246
- if (!parsedFile) {
1247
- continue;
1248
- }
1249
- parsedEnvFiles[fileName] = {
1250
- fileName,
1251
- fullPath: filePath,
1252
- parsedFile
1253
- };
1254
- }
1255
- const existingSchemaFile = parsedEnvFiles[".env.schema"];
1256
- if (existingSchemaFile) {
1257
- logLines([
1258
- `It looks like you already have a ${fmt.fileName(".env.schema")} file \u{1F389}`,
1259
- "This init helper is meant to help you get a new project set up.",
1260
- "If you need to make changes to your schema or values, you can update your files directly.",
1261
- "See more docs at https://varlock.dev/guides/schema"
1262
- ]);
1263
- } else {
1264
- const allExampleFileNames = Object.keys(parsedEnvFiles).filter((fileName) => {
1265
- return fileName.startsWith(".env.example") || fileName.startsWith(".env.sample");
1266
- });
1267
- let exampleFileToConvert;
1268
- if (allExampleFileNames.length === 1) {
1269
- exampleFileToConvert = parsedEnvFiles[allExampleFileNames[0]];
1270
- } else if (allExampleFileNames.length > 1) {
1271
- console.log("");
1272
- const selectedExample = await Jt({
1273
- message: `We detected more than one example .env file. Which one should we use to create your new ${fmt.fileName(".env.schema")}?`,
1274
- options: allExampleFileNames.map((fileName) => ({
1275
- label: fileName,
1276
- value: parsedEnvFiles[fileName]
1277
- }))
1278
- });
1279
- if (Ct(selectedExample)) return gracefulExit(0);
1280
- exampleFileToConvert = selectedExample;
1281
- }
1282
- const parsedEnvSchemaFile = exampleFileToConvert?.parsedFile || parseEnvSpecDotEnvFile("");
1283
- if (!parsedEnvSchemaFile) throw new Error("expected parsed .env example file");
1284
- envSpecUpdater.ensureHeader(parsedEnvSchemaFile, [
1285
- "This env file uses @env-spec - see https://varlock.dev/env-spec for more info",
1286
- ""
1287
- // TODO: add env spec version? real links?
1288
- ].join("\n"));
1289
- envSpecUpdater.setRootDecorator(parsedEnvSchemaFile, "defaultRequired", "infer", { explicitTrue: true });
1290
- envSpecUpdater.setRootDecorator(parsedEnvSchemaFile, "defaultSensitive", "false", { explicitTrue: true });
1291
- envSpecUpdater.setRootDecorator(parsedEnvSchemaFile, "generateTypes", "lang=ts, path=env.d.ts", { bareFnArgs: true });
1292
- envSpecUpdater.injectFromStr(parsedEnvSchemaFile, [
1293
- "",
1294
- "# example env variable injected by `varlock init` \u26A0\uFE0F DELETE THIS ITEM! \u26A0\uFE0F",
1295
- '# @required @sensitive @example="example value"',
1296
- 'EXAMPLE_ITEM="delete me!"',
1297
- ""
1298
- ].join("\n"), { location: "after_header" });
1299
- inferSchemaUpdates(parsedEnvSchemaFile);
1300
- ensureAllItemsExist(parsedEnvSchemaFile, Object.values(parsedEnvFiles));
1301
- const schemaFilePath = path2.join(process.cwd(), ".env.schema");
1302
- await fs3.writeFile(schemaFilePath, parsedEnvSchemaFile.toString());
1303
- if (exampleFileToConvert) {
1304
- logLines([
1305
- "",
1306
- `Your ${fmt.fileName(exampleFileToConvert.fileName)} has been used to generate your new ${fmt.fileName(".env.schema")}:`,
1307
- fmt.filePath(schemaFilePath)
1308
- ]);
1309
- } else {
1310
- logLines([
1311
- "",
1312
- `Your new ${fmt.fileName(".env.schema")} file has been created:`,
1313
- fmt.filePath(schemaFilePath)
1314
- ]);
1315
- }
1316
- if (await checkIsFileGitIgnored(schemaFilePath)) {
1317
- logLines([ansis_default.dim(`(and updated ${fmt.fileName(".gitignore")} to ensure it will be tracked by git)`)]);
1318
- await fs3.appendFile(".gitignore", "\n!.env.schema");
1319
- }
1320
- logLines([
1321
- "",
1322
- ansis_default.bold(`\u{1F6A7} Please review and update your new ${fmt.fileName(".env.schema")} file! \u{1F6A7}`),
1323
- `We've done our best to get you started, but you must review and make sure it is correct!`,
1324
- "",
1325
- `\u{1F449} Some helpful pointers to get you started:`,
1326
- `- add a description to each item when the name is not self explanatory - it will come through in generated types`,
1327
- `- use ${fmt.decorator("@required")} (or ${fmt.decorator("@optional")}) to tag items that should fail validation when empty`,
1328
- `- use ${fmt.decorator("@sensitive")} to tag items that contain sensitive secrets, and must be handled accordingly`,
1329
- `- use ${fmt.decorator("@type")} to set an item's data type (if not a basic string), which affects validation and coercion logic`,
1330
- `- if an item value is a ${ansis_default.italic("useful example")} rather than a default, use ${fmt.decorator("@example")}`,
1331
- `- if an item value is just a dummy placeholder, delete it`
1332
- ]);
1333
- const confirmReviewed = await prompts_default.confirm({
1334
- message: `Have you reviewed and updated your new ${fmt.fileName(".env.schema")} file?`
1335
- });
1336
- if (Ct(confirmReviewed)) return gracefulExit(0);
1337
- const reloadedSchemaFile = await parseEnvSpecDotEnvFile(await fs3.readFile(schemaFilePath, "utf-8"));
1338
- if (reloadedSchemaFile.configItems.find((i) => i.key === "EXAMPLE_ITEM")) {
1339
- logLines([
1340
- "",
1341
- ansis_default.bold(`\u{1F6A8} Really? ${ansis_default.red("You didn't remove the EXAMPLE_ITEM!")}`),
1342
- `Please make sure your schema is all correct before using it...`
1343
- ]);
1344
- }
1345
- if (exampleFileToConvert) {
1346
- const confirmDeleteExample = await prompts_default.confirm({
1347
- message: `Should we delete your ${fmt.fileName(exampleFileToConvert.fileName)} file? ${ansis_default.italic.gray("(you can always do this yourself later)")}`
1348
- });
1349
- if (Ct(confirmDeleteExample)) return gracefulExit(0);
1350
- if (confirmDeleteExample) {
1351
- await fs3.unlink(exampleFileToConvert.fullPath);
1352
- }
1353
- }
1354
- const defaultsFile = Object.values(parsedEnvFiles).find((f) => {
1355
- return f.fileName.startsWith(".env.default");
1356
- });
1357
- if (defaultsFile) {
1358
- logLines([
1359
- "",
1360
- `\u{1F6A7} We detected a ${fmt.fileName(defaultsFile.fileName)} file in your project`,
1361
- `You should migrate these default values into ${fmt.fileName(".env.schema")} and delete it.`
1362
- ]);
1363
- }
1364
- const redundantInfo = await detectRedundantValues(parsedEnvSchemaFile, parsedEnvFiles);
1365
- if (Object.keys(redundantInfo).length > 0) {
1366
- logLines([
1367
- "",
1368
- ansis_default.bold("\u203C\uFE0F Now that your schema contains defaults, some values in your other .env files are redundant:")
1369
- ]);
1370
- for (const [sourcePath, itemKeys] of Object.entries(redundantInfo)) {
1371
- console.log(fmt.filePath(sourcePath));
1372
- console.log(" ", itemKeys.map((k2) => ansis_default.italic(k2)).join(", "));
1373
- }
1374
- const confirmDeleteRedundant = await prompts_default.confirm({
1375
- message: "Should we delete these redundant values from your other .env files?"
1376
- });
1377
- if (Ct(confirmDeleteRedundant)) return gracefulExit(0);
1378
- if (confirmDeleteRedundant) {
1379
- await detectRedundantValues(parsedEnvSchemaFile, parsedEnvFiles, { delete: true });
1380
- }
1381
- }
1382
- logLines([
1383
- "",
1384
- ansis_default.bold("\u{1F389} Great!"),
1385
- `You can run ${fmt.command("varlock load", { jsPackageManager })} to attempt loading your env vars validate against your new schema.`,
1386
- "",
1387
- "Check out our docs for more info about integrating into your application.",
1388
- "",
1389
- "\u{1F4D6} https://varlock.dev \u{1F448}",
1390
- ""
1391
- ]);
1392
- }
1393
- if (jsPackageManager && await pathExists(path2.join(process.cwd(), "package.json"))) {
1394
- const installResult = installJsDependency({
1395
- packageManager: jsPackageManager.name,
1396
- packageName: "varlock"
1397
- });
1398
- if (installResult) {
1399
- logLines([
1400
- "",
1401
- `\u2705 Added ${fmt.packageName("varlock")} as a dependency in your package.json`
1402
- ]);
1403
- }
1404
- }
1405
- if (jsPackageManager?.name === "bun") {
1406
- const bunfigPath = path2.join(process.cwd(), "bunfig.toml");
1407
- const bunfigExists = await pathExists(bunfigPath);
1408
- if (bunfigExists) {
1409
- const bunfigContents = await fs3.readFile(bunfigPath, "utf-8");
1410
- if (!/^\s*env\s*=\s*false\s*$/m.test(bunfigContents)) {
1411
- await fs3.writeFile(bunfigPath, `env = false
1412
- ${bunfigContents}`);
1413
- logLines([
1414
- "",
1415
- `\u2705 Added ${ansis_default.bold("env = false")} to your existing ${fmt.fileName("bunfig.toml")}`,
1416
- ansis_default.dim("This disables Bun's automatic .env loading, which conflicts with Varlock."),
1417
- ansis_default.dim(`See ${ansis_default.underline("https://varlock.dev/integrations/bun")} for more info.`)
1418
- ]);
1419
- }
1420
- } else {
1421
- await fs3.writeFile(bunfigPath, "env = false\n");
1422
- logLines([
1423
- "",
1424
- `\u2705 Created ${fmt.fileName("bunfig.toml")} with ${ansis_default.bold("env = false")}`,
1425
- ansis_default.dim("This disables Bun's automatic .env loading, which conflicts with Varlock."),
1426
- ansis_default.dim(`See ${ansis_default.underline("https://varlock.dev/integrations/bun")} for more info.`)
1427
- ]);
1428
- }
1429
- }
1430
- }, "commandFn");
1431
-
1432
- export { commandFn, commandSpec };
1433
- //# sourceMappingURL=chunk-JMJCAFEL.js.map
1434
- //# sourceMappingURL=chunk-JMJCAFEL.js.map