@maltty/cli 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -0
  3. package/bin/maltty.js +3 -0
  4. package/dist/_format-CeQhQTl5.js +23 -0
  5. package/dist/_format-CeQhQTl5.js.map +1 -0
  6. package/dist/attemptAsync-BdXzRSIT.js +42 -0
  7. package/dist/attemptAsync-BdXzRSIT.js.map +1 -0
  8. package/dist/chunk-DsIazq42.js +26 -0
  9. package/dist/commands/add/command.d.ts +7 -0
  10. package/dist/commands/add/command.d.ts.map +1 -0
  11. package/dist/commands/add/command.js +123 -0
  12. package/dist/commands/add/command.js.map +1 -0
  13. package/dist/commands/add/config.d.ts +7 -0
  14. package/dist/commands/add/config.d.ts.map +1 -0
  15. package/dist/commands/add/config.js +57 -0
  16. package/dist/commands/add/config.js.map +1 -0
  17. package/dist/commands/add/index.d.ts +7 -0
  18. package/dist/commands/add/index.d.ts.map +1 -0
  19. package/dist/commands/add/index.js +7 -0
  20. package/dist/commands/add/index.js.map +1 -0
  21. package/dist/commands/add/middleware.d.ts +7 -0
  22. package/dist/commands/add/middleware.d.ts.map +1 -0
  23. package/dist/commands/add/middleware.js +88 -0
  24. package/dist/commands/add/middleware.js.map +1 -0
  25. package/dist/commands/build.d.ts +15 -0
  26. package/dist/commands/build.d.ts.map +1 -0
  27. package/dist/commands/build.js +246 -0
  28. package/dist/commands/build.js.map +1 -0
  29. package/dist/commands/commands.d.ts +14 -0
  30. package/dist/commands/commands.d.ts.map +1 -0
  31. package/dist/commands/commands.js +189 -0
  32. package/dist/commands/commands.js.map +1 -0
  33. package/dist/commands/dev.d.ts +13 -0
  34. package/dist/commands/dev.d.ts.map +1 -0
  35. package/dist/commands/dev.js +58 -0
  36. package/dist/commands/dev.js.map +1 -0
  37. package/dist/commands/doctor.d.ts +13 -0
  38. package/dist/commands/doctor.d.ts.map +1 -0
  39. package/dist/commands/doctor.js +658 -0
  40. package/dist/commands/doctor.js.map +1 -0
  41. package/dist/commands/init.d.ts +7 -0
  42. package/dist/commands/init.d.ts.map +1 -0
  43. package/dist/commands/init.js +305 -0
  44. package/dist/commands/init.js.map +1 -0
  45. package/dist/commands/run.d.ts +19 -0
  46. package/dist/commands/run.d.ts.map +1 -0
  47. package/dist/commands/run.js +478 -0
  48. package/dist/commands/run.js.map +1 -0
  49. package/dist/commands/stories.d.ts +11 -0
  50. package/dist/commands/stories.d.ts.map +1 -0
  51. package/dist/commands/stories.js +22 -0
  52. package/dist/commands/stories.js.map +1 -0
  53. package/dist/config-helpers-pv_2Spux.js +15 -0
  54. package/dist/config-helpers-pv_2Spux.js.map +1 -0
  55. package/dist/defu-BBwssjW3.js +192 -0
  56. package/dist/defu-BBwssjW3.js.map +1 -0
  57. package/dist/detect-AOq1ehTE.js +61 -0
  58. package/dist/detect-AOq1ehTE.js.map +1 -0
  59. package/dist/dist-DW_gRP7_.js +1119 -0
  60. package/dist/dist-DW_gRP7_.js.map +1 -0
  61. package/dist/dist-Xa07jNxS.js +15617 -0
  62. package/dist/dist-Xa07jNxS.js.map +1 -0
  63. package/dist/index.d.ts +1 -0
  64. package/dist/index.js +46 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/jiti-CxWlVmZ_.js +5458 -0
  67. package/dist/jiti-CxWlVmZ_.js.map +1 -0
  68. package/dist/json-D7WbuVK1.js +43 -0
  69. package/dist/json-D7WbuVK1.js.map +1 -0
  70. package/dist/json5-z-PGDMyy.js +777 -0
  71. package/dist/json5-z-PGDMyy.js.map +1 -0
  72. package/dist/jsonc-DqZkfC3S.js +401 -0
  73. package/dist/jsonc-DqZkfC3S.js.map +1 -0
  74. package/dist/jsonc-KADMdSjU.js +2 -0
  75. package/dist/lib/templates/command/command.ts.liquid +12 -0
  76. package/dist/lib/templates/config/config.ts.liquid +16 -0
  77. package/dist/lib/templates/middleware/middleware.ts.liquid +9 -0
  78. package/dist/lib/templates/project/gitignore.liquid +3 -0
  79. package/dist/lib/templates/project/maltty.config.ts.liquid +6 -0
  80. package/dist/lib/templates/project/package.json.liquid +30 -0
  81. package/dist/lib/templates/project/src/commands/hello.ts.liquid +12 -0
  82. package/dist/lib/templates/project/src/config.ts.liquid +16 -0
  83. package/dist/lib/templates/project/src/index.ts.liquid +13 -0
  84. package/dist/lib/templates/project/tsconfig.json.liquid +19 -0
  85. package/dist/lib/templates/project/vitest.config.ts.liquid +8 -0
  86. package/dist/main-C_8x2aB3.js +274 -0
  87. package/dist/main-C_8x2aB3.js.map +1 -0
  88. package/dist/manifest-BIKVDJML.js +112 -0
  89. package/dist/manifest-BIKVDJML.js.map +1 -0
  90. package/dist/multipart-parser-MNkxNO83.js +174 -0
  91. package/dist/multipart-parser-MNkxNO83.js.map +1 -0
  92. package/dist/node-C91xGGqn.js +644 -0
  93. package/dist/node-C91xGGqn.js.map +1 -0
  94. package/dist/node-Drmc03fL.js +3973 -0
  95. package/dist/node-Drmc03fL.js.map +1 -0
  96. package/dist/ohash-BPoV4zBH.js +185 -0
  97. package/dist/ohash-BPoV4zBH.js.map +1 -0
  98. package/dist/pnpm-workspace.yaml +26 -0
  99. package/dist/toml-LuHsHQtV.js +646 -0
  100. package/dist/toml-LuHsHQtV.js.map +1 -0
  101. package/dist/utils-DlIJNGLQ.js +1905 -0
  102. package/dist/utils-DlIJNGLQ.js.map +1 -0
  103. package/dist/validate-C_SXBoLq.js +18 -0
  104. package/dist/validate-C_SXBoLq.js.map +1 -0
  105. package/dist/write-CSwG4Stj.js +152 -0
  106. package/dist/write-CSwG4Stj.js.map +1 -0
  107. package/dist/yaml-BS9RDuUr.js +1067 -0
  108. package/dist/yaml-BS9RDuUr.js.map +1 -0
  109. package/package.json +65 -0
@@ -0,0 +1,644 @@
1
+ import { n as err, r as ok, t as attemptAsync } from "./attemptAsync-BdXzRSIT.js";
2
+ import * as fsNative from "node:fs/promises";
3
+ import { pathToFileURL } from "node:url";
4
+ import { execFile, spawn } from "node:child_process";
5
+ //#region ../../node_modules/.pnpm/ts-pattern@5.9.0/node_modules/ts-pattern/dist/index.js
6
+ const t = Symbol.for("@ts-pattern/matcher"), e = Symbol.for("@ts-pattern/isVariadic"), n = "@ts-pattern/anonymous-select-key", r = (t) => Boolean(t && "object" == typeof t), i = (e) => e && !!e[t], o = (n, s, c) => {
7
+ if (i(n)) {
8
+ const { matched: r, selections: i } = n[t]().match(s);
9
+ return r && i && Object.keys(i).forEach((t) => c(t, i[t])), r;
10
+ }
11
+ if (r(n)) {
12
+ if (!r(s)) return !1;
13
+ if (Array.isArray(n)) {
14
+ if (!Array.isArray(s)) return !1;
15
+ let t = [], r = [], u = [];
16
+ for (const o of n.keys()) {
17
+ const s = n[o];
18
+ i(s) && s[e] ? u.push(s) : u.length ? r.push(s) : t.push(s);
19
+ }
20
+ if (u.length) {
21
+ if (u.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
22
+ if (s.length < t.length + r.length) return !1;
23
+ const e = s.slice(0, t.length), n = 0 === r.length ? [] : s.slice(-r.length), i = s.slice(t.length, 0 === r.length ? Infinity : -r.length);
24
+ return t.every((t, n) => o(t, e[n], c)) && r.every((t, e) => o(t, n[e], c)) && (0 === u.length || o(u[0], i, c));
25
+ }
26
+ return n.length === s.length && n.every((t, e) => o(t, s[e], c));
27
+ }
28
+ return Reflect.ownKeys(n).every((e) => {
29
+ const r = n[e];
30
+ return (e in s || i(u = r) && "optional" === u[t]().matcherType) && o(r, s[e], c);
31
+ var u;
32
+ });
33
+ }
34
+ return Object.is(s, n);
35
+ }, s = (e) => {
36
+ var n, o, u;
37
+ return r(e) ? i(e) ? null != (n = null == (o = (u = e[t]()).getSelectionKeys) ? void 0 : o.call(u)) ? n : [] : Array.isArray(e) ? c(e, s) : c(Object.values(e), s) : [];
38
+ }, c = (t, e) => t.reduce((t, n) => t.concat(e(n)), []);
39
+ function u(...t) {
40
+ if (1 === t.length) {
41
+ const [e] = t;
42
+ return (t) => o(e, t, () => {});
43
+ }
44
+ if (2 === t.length) {
45
+ const [e, n] = t;
46
+ return o(e, n, () => {});
47
+ }
48
+ throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`);
49
+ }
50
+ function a(t) {
51
+ return Object.assign(t, {
52
+ optional: () => h(t),
53
+ and: (e) => d(t, e),
54
+ or: (e) => y(t, e),
55
+ select: (e) => void 0 === e ? v(t) : v(e, t)
56
+ });
57
+ }
58
+ function l(t) {
59
+ return Object.assign(((t) => Object.assign(t, { [Symbol.iterator]() {
60
+ let n = 0;
61
+ const r = [{
62
+ value: Object.assign(t, { [e]: !0 }),
63
+ done: !1
64
+ }, {
65
+ done: !0,
66
+ value: void 0
67
+ }];
68
+ return { next: () => {
69
+ var t;
70
+ return null != (t = r[n++]) ? t : r.at(-1);
71
+ } };
72
+ } }))(t), {
73
+ optional: () => l(h(t)),
74
+ select: (e) => l(void 0 === e ? v(t) : v(e, t))
75
+ });
76
+ }
77
+ function h(e) {
78
+ return a({ [t]: () => ({
79
+ match: (t) => {
80
+ let n = {};
81
+ const r = (t, e) => {
82
+ n[t] = e;
83
+ };
84
+ return void 0 === t ? (s(e).forEach((t) => r(t, void 0)), {
85
+ matched: !0,
86
+ selections: n
87
+ }) : {
88
+ matched: o(e, t, r),
89
+ selections: n
90
+ };
91
+ },
92
+ getSelectionKeys: () => s(e),
93
+ matcherType: "optional"
94
+ }) });
95
+ }
96
+ const f = (t, e) => {
97
+ for (const n of t) if (!e(n)) return !1;
98
+ return !0;
99
+ }, g = (t, e) => {
100
+ for (const [n, r] of t.entries()) if (!e(r, n)) return !1;
101
+ return !0;
102
+ }, m = (t, e) => {
103
+ const n = Reflect.ownKeys(t);
104
+ for (const r of n) if (!e(r, t[r])) return !1;
105
+ return !0;
106
+ };
107
+ function d(...e) {
108
+ return a({ [t]: () => ({
109
+ match: (t) => {
110
+ let n = {};
111
+ const r = (t, e) => {
112
+ n[t] = e;
113
+ };
114
+ return {
115
+ matched: e.every((e) => o(e, t, r)),
116
+ selections: n
117
+ };
118
+ },
119
+ getSelectionKeys: () => c(e, s),
120
+ matcherType: "and"
121
+ }) });
122
+ }
123
+ function y(...e) {
124
+ return a({ [t]: () => ({
125
+ match: (t) => {
126
+ let n = {};
127
+ const r = (t, e) => {
128
+ n[t] = e;
129
+ };
130
+ return c(e, s).forEach((t) => r(t, void 0)), {
131
+ matched: e.some((e) => o(e, t, r)),
132
+ selections: n
133
+ };
134
+ },
135
+ getSelectionKeys: () => c(e, s),
136
+ matcherType: "or"
137
+ }) });
138
+ }
139
+ function p(e) {
140
+ return { [t]: () => ({ match: (t) => ({ matched: Boolean(e(t)) }) }) };
141
+ }
142
+ function v(...e) {
143
+ const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
144
+ return a({ [t]: () => ({
145
+ match: (t) => {
146
+ let e = { [null != r ? r : n]: t };
147
+ return {
148
+ matched: void 0 === i || o(i, t, (t, n) => {
149
+ e[t] = n;
150
+ }),
151
+ selections: e
152
+ };
153
+ },
154
+ getSelectionKeys: () => [null != r ? r : n].concat(void 0 === i ? [] : s(i))
155
+ }) });
156
+ }
157
+ function b(t) {
158
+ return !0;
159
+ }
160
+ function w(t) {
161
+ return "number" == typeof t;
162
+ }
163
+ function S(t) {
164
+ return "string" == typeof t;
165
+ }
166
+ function j(t) {
167
+ return "bigint" == typeof t;
168
+ }
169
+ const K = a(p(b)), O = a(p(b)), E = K, x = (t) => Object.assign(a(t), {
170
+ startsWith: (e) => {
171
+ return x(d(t, (n = e, p((t) => S(t) && t.startsWith(n)))));
172
+ var n;
173
+ },
174
+ endsWith: (e) => {
175
+ return x(d(t, (n = e, p((t) => S(t) && t.endsWith(n)))));
176
+ var n;
177
+ },
178
+ minLength: (e) => x(d(t, ((t) => p((e) => S(e) && e.length >= t))(e))),
179
+ length: (e) => x(d(t, ((t) => p((e) => S(e) && e.length === t))(e))),
180
+ maxLength: (e) => x(d(t, ((t) => p((e) => S(e) && e.length <= t))(e))),
181
+ includes: (e) => {
182
+ return x(d(t, (n = e, p((t) => S(t) && t.includes(n)))));
183
+ var n;
184
+ },
185
+ regex: (e) => {
186
+ return x(d(t, (n = e, p((t) => S(t) && Boolean(t.match(n))))));
187
+ var n;
188
+ }
189
+ }), A = x(p(S)), N = (t) => Object.assign(a(t), {
190
+ between: (e, n) => N(d(t, ((t, e) => p((n) => w(n) && t <= n && e >= n))(e, n))),
191
+ lt: (e) => N(d(t, ((t) => p((e) => w(e) && e < t))(e))),
192
+ gt: (e) => N(d(t, ((t) => p((e) => w(e) && e > t))(e))),
193
+ lte: (e) => N(d(t, ((t) => p((e) => w(e) && e <= t))(e))),
194
+ gte: (e) => N(d(t, ((t) => p((e) => w(e) && e >= t))(e))),
195
+ int: () => N(d(t, p((t) => w(t) && Number.isInteger(t)))),
196
+ finite: () => N(d(t, p((t) => w(t) && Number.isFinite(t)))),
197
+ positive: () => N(d(t, p((t) => w(t) && t > 0))),
198
+ negative: () => N(d(t, p((t) => w(t) && t < 0)))
199
+ }), P = N(p(w)), k = (t) => Object.assign(a(t), {
200
+ between: (e, n) => k(d(t, ((t, e) => p((n) => j(n) && t <= n && e >= n))(e, n))),
201
+ lt: (e) => k(d(t, ((t) => p((e) => j(e) && e < t))(e))),
202
+ gt: (e) => k(d(t, ((t) => p((e) => j(e) && e > t))(e))),
203
+ lte: (e) => k(d(t, ((t) => p((e) => j(e) && e <= t))(e))),
204
+ gte: (e) => k(d(t, ((t) => p((e) => j(e) && e >= t))(e))),
205
+ positive: () => k(d(t, p((t) => j(t) && t > 0))),
206
+ negative: () => k(d(t, p((t) => j(t) && t < 0)))
207
+ });
208
+ var z = {
209
+ __proto__: null,
210
+ matcher: t,
211
+ optional: h,
212
+ array: function(...e) {
213
+ return l({ [t]: () => ({
214
+ match: (t) => {
215
+ if (!Array.isArray(t)) return { matched: !1 };
216
+ if (0 === e.length) return { matched: !0 };
217
+ const n = e[0];
218
+ let r = {};
219
+ if (0 === t.length) return s(n).forEach((t) => {
220
+ r[t] = [];
221
+ }), {
222
+ matched: !0,
223
+ selections: r
224
+ };
225
+ const i = (t, e) => {
226
+ r[t] = (r[t] || []).concat([e]);
227
+ };
228
+ return {
229
+ matched: t.every((t) => o(n, t, i)),
230
+ selections: r
231
+ };
232
+ },
233
+ getSelectionKeys: () => 0 === e.length ? [] : s(e[0])
234
+ }) });
235
+ },
236
+ set: function(...e) {
237
+ return a({ [t]: () => ({
238
+ match: (t) => {
239
+ if (!(t instanceof Set)) return { matched: !1 };
240
+ let n = {};
241
+ if (0 === t.size) return {
242
+ matched: !0,
243
+ selections: n
244
+ };
245
+ if (0 === e.length) return { matched: !0 };
246
+ const r = (t, e) => {
247
+ n[t] = (n[t] || []).concat([e]);
248
+ }, i = e[0];
249
+ return {
250
+ matched: f(t, (t) => o(i, t, r)),
251
+ selections: n
252
+ };
253
+ },
254
+ getSelectionKeys: () => 0 === e.length ? [] : s(e[0])
255
+ }) });
256
+ },
257
+ map: function(...e) {
258
+ return a({ [t]: () => ({
259
+ match: (t) => {
260
+ if (!(t instanceof Map)) return { matched: !1 };
261
+ let n = {};
262
+ if (0 === t.size) return {
263
+ matched: !0,
264
+ selections: n
265
+ };
266
+ const r = (t, e) => {
267
+ n[t] = (n[t] || []).concat([e]);
268
+ };
269
+ if (0 === e.length) return { matched: !0 };
270
+ var i;
271
+ if (1 === e.length) throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${null == (i = e[0]) ? void 0 : i.toString()}`);
272
+ const [s, c] = e;
273
+ return {
274
+ matched: g(t, (t, e) => {
275
+ const n = o(s, e, r), i = o(c, t, r);
276
+ return n && i;
277
+ }),
278
+ selections: n
279
+ };
280
+ },
281
+ getSelectionKeys: () => 0 === e.length ? [] : [...s(e[0]), ...s(e[1])]
282
+ }) });
283
+ },
284
+ record: function(...e) {
285
+ return a({ [t]: () => ({
286
+ match: (t) => {
287
+ if (null === t || "object" != typeof t || Array.isArray(t)) return { matched: !1 };
288
+ var n;
289
+ if (0 === e.length) throw new Error(`\`P.record\` wasn't given enough arguments. Expected (value) or (key, value), received ${null == (n = e[0]) ? void 0 : n.toString()}`);
290
+ let r = {};
291
+ const i = (t, e) => {
292
+ r[t] = (r[t] || []).concat([e]);
293
+ }, [s, c] = 1 === e.length ? [A, e[0]] : e;
294
+ return {
295
+ matched: m(t, (t, e) => {
296
+ const n = "string" != typeof t || Number.isNaN(Number(t)) ? null : Number(t), r = null !== n && o(s, n, i), u = o(s, t, i), a = o(c, e, i);
297
+ return (u || r) && a;
298
+ }),
299
+ selections: r
300
+ };
301
+ },
302
+ getSelectionKeys: () => 0 === e.length ? [] : [...s(e[0]), ...s(e[1])]
303
+ }) });
304
+ },
305
+ intersection: d,
306
+ union: y,
307
+ not: function(e) {
308
+ return a({ [t]: () => ({
309
+ match: (t) => ({ matched: !o(e, t, () => {}) }),
310
+ getSelectionKeys: () => [],
311
+ matcherType: "not"
312
+ }) });
313
+ },
314
+ when: p,
315
+ select: v,
316
+ any: K,
317
+ unknown: O,
318
+ _: E,
319
+ string: A,
320
+ number: P,
321
+ bigint: k(p(j)),
322
+ boolean: a(p(function(t) {
323
+ return "boolean" == typeof t;
324
+ })),
325
+ symbol: a(p(function(t) {
326
+ return "symbol" == typeof t;
327
+ })),
328
+ nullish: a(p(function(t) {
329
+ return null == t;
330
+ })),
331
+ nonNullable: a(p(function(t) {
332
+ return null != t;
333
+ })),
334
+ instanceOf: function(t) {
335
+ return a(p(function(t) {
336
+ return (e) => e instanceof t;
337
+ }(t)));
338
+ },
339
+ shape: function(t) {
340
+ return a(p(u(t)));
341
+ }
342
+ };
343
+ var I = class extends Error {
344
+ constructor(t) {
345
+ let e;
346
+ try {
347
+ e = JSON.stringify(t);
348
+ } catch (n) {
349
+ e = t;
350
+ }
351
+ super(`Pattern matching error: no pattern matches value ${e}`), this.input = void 0, this.input = t;
352
+ }
353
+ };
354
+ const L = {
355
+ matched: !1,
356
+ value: void 0
357
+ };
358
+ function M(t) {
359
+ return new R(t, L);
360
+ }
361
+ var R = class R {
362
+ constructor(t, e) {
363
+ this.input = void 0, this.state = void 0, this.input = t, this.state = e;
364
+ }
365
+ with(...t) {
366
+ if (this.state.matched) return this;
367
+ const e = t[t.length - 1], r = [t[0]];
368
+ let i;
369
+ 3 === t.length && "function" == typeof t[1] ? i = t[1] : t.length > 2 && r.push(...t.slice(1, t.length - 1));
370
+ let s = !1, c = {};
371
+ const u = (t, e) => {
372
+ s = !0, c[t] = e;
373
+ }, a = !r.some((t) => o(t, this.input, u)) || i && !Boolean(i(this.input)) ? L : {
374
+ matched: !0,
375
+ value: e(s ? n in c ? c[n] : c : this.input, this.input)
376
+ };
377
+ return new R(this.input, a);
378
+ }
379
+ when(t, e) {
380
+ if (this.state.matched) return this;
381
+ const n = Boolean(t(this.input));
382
+ return new R(this.input, n ? {
383
+ matched: !0,
384
+ value: e(this.input, this.input)
385
+ } : L);
386
+ }
387
+ otherwise(t) {
388
+ return this.state.matched ? this.state.value : t(this.input);
389
+ }
390
+ exhaustive(t = F) {
391
+ return this.state.matched ? this.state.value : t(this.input);
392
+ }
393
+ run() {
394
+ return this.exhaustive();
395
+ }
396
+ returnType() {
397
+ return this;
398
+ }
399
+ narrow() {
400
+ return this;
401
+ }
402
+ };
403
+ function F(t) {
404
+ throw new I(t);
405
+ }
406
+ //#endregion
407
+ //#region ../utils/dist/chunk-pbuEa-1d.js
408
+ var __defProp = Object.defineProperty;
409
+ var __exportAll = (all, no_symbols) => {
410
+ let target = {};
411
+ for (var name in all) __defProp(target, name, {
412
+ get: all[name],
413
+ enumerable: true
414
+ });
415
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
416
+ return target;
417
+ };
418
+ //#endregion
419
+ //#region ../utils/dist/fs-6FuEguuO.js
420
+ var fs_exports = /* @__PURE__ */ __exportAll({
421
+ exists: () => exists$1,
422
+ list: () => list,
423
+ mkdir: () => mkdir$1,
424
+ read: () => read,
425
+ remove: () => remove,
426
+ write: () => write
427
+ });
428
+ /**
429
+ * Check whether a path exists and is accessible.
430
+ *
431
+ * Wraps `fs.access` into a boolean check — never throws.
432
+ *
433
+ * @param path - The absolute path to check.
434
+ * @returns True when the path exists and is accessible.
435
+ */
436
+ async function exists$1(path) {
437
+ const [error] = await attemptAsync(() => fsNative.access(path));
438
+ return error === null;
439
+ }
440
+ /**
441
+ * Read a file's contents as a UTF-8 string.
442
+ *
443
+ * @param path - The absolute file path to read.
444
+ * @returns A result tuple with the file contents or an Error.
445
+ */
446
+ async function read(path) {
447
+ const [error, contents] = await attemptAsync(() => fsNative.readFile(path, "utf8"));
448
+ if (error || contents === null) return err(new Error(`failed to read ${path}`, { cause: error }));
449
+ return ok(contents);
450
+ }
451
+ /**
452
+ * Write a UTF-8 string to a file.
453
+ *
454
+ * @param path - The absolute file path to write.
455
+ * @param content - The string content to write.
456
+ * @returns A result tuple with void on success or an Error.
457
+ */
458
+ async function write(path, content) {
459
+ const [error] = await attemptAsync(() => fsNative.writeFile(path, content, "utf8"));
460
+ if (error) return err(new Error(`failed to write ${path}`, { cause: error }));
461
+ return ok();
462
+ }
463
+ /**
464
+ * List filenames in a directory.
465
+ *
466
+ * @param path - The absolute directory path to list.
467
+ * @returns A result tuple with filenames or an Error.
468
+ */
469
+ async function list(path) {
470
+ const [error, entries] = await attemptAsync(() => fsNative.readdir(path));
471
+ if (error || entries === null) return err(new Error(`failed to list ${path}`, { cause: error }));
472
+ return ok(entries);
473
+ }
474
+ /**
475
+ * Create a directory, including parent directories.
476
+ *
477
+ * @param path - The absolute directory path to create.
478
+ * @returns A result tuple with void on success or an Error.
479
+ */
480
+ async function mkdir$1(path) {
481
+ const [error] = await attemptAsync(() => fsNative.mkdir(path, { recursive: true }));
482
+ if (error) return err(new Error(`failed to create directory ${path}`, { cause: error }));
483
+ return ok();
484
+ }
485
+ /**
486
+ * Remove a file or directory. Silently succeeds if the path does not exist.
487
+ *
488
+ * @param path - The absolute path to remove.
489
+ * @returns A result tuple with void on success or an Error.
490
+ */
491
+ async function remove(path) {
492
+ const [error] = await attemptAsync(() => fsNative.rm(path, {
493
+ recursive: true,
494
+ force: true
495
+ }));
496
+ if (error) return err(new Error(`failed to remove ${path}`, { cause: error }));
497
+ return ok();
498
+ }
499
+ //#endregion
500
+ //#region ../utils/dist/node.js
501
+ var path_exports = /* @__PURE__ */ __exportAll({
502
+ toImportUrl: () => toImportUrl,
503
+ toPosixPath: () => toPosixPath
504
+ });
505
+ /**
506
+ * Convert a filesystem path to an ESM import specifier (a `file://` URL).
507
+ *
508
+ * Required wherever a filesystem path becomes a JavaScript import string —
509
+ * dynamic `import()` calls or static import specifiers embedded in generated
510
+ * source code. On Windows, raw paths like `C:\foo\bar.ts` contain `\f`, `\b`,
511
+ * `\u`, and other sequences that JavaScript parses as string escapes, which
512
+ * either crashes the bundler or breaks runtime resolution. The `file://` URL
513
+ * form is platform-neutral (`file:///C:/foo/bar.ts` on Windows,
514
+ * `file:///foo/bar.ts` on POSIX).
515
+ *
516
+ * @param filePath - An absolute filesystem path.
517
+ * @returns A `file://` URL string suitable as an ESM import specifier.
518
+ */
519
+ function toImportUrl(filePath) {
520
+ return pathToFileURL(filePath).href;
521
+ }
522
+ /**
523
+ * Normalize a native path string to use forward-slash separators.
524
+ *
525
+ * `path.relative()` and `path.join()` return separators native to the OS
526
+ * (`\` on Windows, `/` elsewhere). When paths flow into string operations —
527
+ * regex matching, `includes()` / `startsWith()` checks, template-engine
528
+ * lookups — Windows backslashes silently break POSIX-shaped patterns.
529
+ * Normalizing once at the boundary lets downstream code assume `/`.
530
+ *
531
+ * Node's `path.join()` accepts forward slashes on Windows and produces
532
+ * correct native paths during filesystem operations, so the normalized form
533
+ * remains usable for subsequent path composition.
534
+ *
535
+ * @param p - A native path string.
536
+ * @returns The path with all `\` replaced by `/`.
537
+ */
538
+ function toPosixPath(p) {
539
+ return p.replaceAll("\\", "/");
540
+ }
541
+ var process_exports = /* @__PURE__ */ __exportAll({
542
+ exec: () => exec,
543
+ exists: () => exists,
544
+ spawn: () => spawn$1
545
+ });
546
+ /**
547
+ * Execute a command with arguments and return the result.
548
+ *
549
+ * Wraps `child_process.execFile` into an async Result tuple. On failure,
550
+ * the error includes stderr as a property for diagnostic access.
551
+ *
552
+ * @param params - The command and arguments to execute.
553
+ * @returns A result tuple with stdout/stderr on success or an Error on failure.
554
+ */
555
+ function exec(params) {
556
+ const { cmd, args = [], cwd } = params;
557
+ return new Promise((resolve) => {
558
+ execFile(cmd, [...args], {
559
+ cwd,
560
+ shell: needsShell()
561
+ }, (error, stdout, stderr) => {
562
+ if (error) {
563
+ const enriched = new Error(`${cmd} failed: ${error.message}`, { cause: error });
564
+ Object.defineProperty(enriched, "stderr", {
565
+ enumerable: true,
566
+ value: stderr
567
+ });
568
+ resolve(err(enriched));
569
+ return;
570
+ }
571
+ resolve(ok({
572
+ stdout,
573
+ stderr
574
+ }));
575
+ });
576
+ });
577
+ }
578
+ /**
579
+ * Spawn an interactive process with inherited stdio.
580
+ *
581
+ * Returns the exit code of the child process. Stdio is inherited so the
582
+ * child process shares the parent's terminal.
583
+ *
584
+ * @param cmd - The command to spawn.
585
+ * @param args - Arguments to pass to the command.
586
+ * @param cwd - Working directory for the child process.
587
+ * @returns The exit code of the spawned process.
588
+ */
589
+ function spawn$1(params) {
590
+ return new Promise((resolve) => {
591
+ const child = spawn(params.cmd, [...params.args], {
592
+ cwd: params.cwd,
593
+ shell: needsShell(),
594
+ stdio: "inherit"
595
+ });
596
+ child.on("error", () => {
597
+ resolve(1);
598
+ });
599
+ child.on("close", (code) => {
600
+ resolve(code ?? 1);
601
+ });
602
+ });
603
+ }
604
+ /**
605
+ * Check whether a binary is available on the system PATH.
606
+ *
607
+ * Uses `which` (unix) or `where` (windows) to resolve the binary
608
+ * without executing it.
609
+ *
610
+ * @param cmd - The command name to check.
611
+ * @returns `true` when the command is found on PATH.
612
+ */
613
+ function exists(cmd) {
614
+ const lookup = M(process.platform).with("win32", () => "where").otherwise(() => "which");
615
+ return new Promise((resolve) => {
616
+ execFile(lookup, [cmd], (error) => {
617
+ resolve(error === null);
618
+ });
619
+ });
620
+ }
621
+ /**
622
+ * Whether the current platform requires `shell: true` for `child_process`
623
+ * calls.
624
+ *
625
+ * Evaluated at call time rather than captured at module load so tests that
626
+ * stub `process.platform` get a fresh value, and so the result is never
627
+ * frozen against a value that was true only at startup.
628
+ *
629
+ * On Windows, npm/pnpm-installed CLIs (e.g. `tsx`) ship as `.cmd` shim
630
+ * files that Node's `child_process` can't launch via `CreateProcess` —
631
+ * only `cmd.exe` can. `shell: true` routes through `cmd.exe` so the shim
632
+ * runs. On POSIX it's unnecessary and changes argument escaping, so it's
633
+ * gated to Windows.
634
+ *
635
+ * @private
636
+ * @returns `true` on Windows, `false` elsewhere.
637
+ */
638
+ function needsShell() {
639
+ return process.platform === "win32";
640
+ }
641
+ //#endregion
642
+ export { z as a, M as i, process_exports as n, fs_exports as r, path_exports as t };
643
+
644
+ //# sourceMappingURL=node-C91xGGqn.js.map