vite-plus 0.2.8 → 0.3.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 (92) hide show
  1. package/AGENTS.md +7 -0
  2. package/README.md +13 -6
  3. package/binding/index.cjs +57 -54
  4. package/binding/index.d.cts +100 -3
  5. package/dist/{agent-CI79DuSy.js → agent-Wqx0MPk0.js} +4 -188
  6. package/dist/bin.js +298 -278
  7. package/dist/command-CLJK5jGW.js +2 -0
  8. package/dist/command-CguLh2KL.js +471 -0
  9. package/dist/config/bin.js +29 -15
  10. package/dist/{constants-BppDcRc1.js → constants-Bn-U8o4v.js} +13 -3
  11. package/dist/create/bin.js +197 -247
  12. package/dist/{define-config-DPnHe1Mx.js → define-config-GXUdVT-0.js} +3 -3
  13. package/dist/{define-config-CEm_MtvJ.cjs → define-config-WiVlryJ2.cjs} +2 -2
  14. package/dist/define-config.cjs +1 -1
  15. package/dist/define-config.js +1 -1
  16. package/dist/{dist-CSQWHI6y.js → dist-BDYZP12R.js} +193 -149
  17. package/dist/dist-Dqv1-Clg.js +3 -0
  18. package/dist/{editor-CGWdbLgD.js → editor-CC4DqODz.js} +736 -153
  19. package/dist/{terminal-CrqqK8WT.js → help-BmKpeOP9.js} +27 -34
  20. package/dist/hooks/bin.d.ts +1 -0
  21. package/dist/hooks/bin.js +131 -0
  22. package/dist/hooks-DFqViZqZ.js +573 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/{json-BU88uu6o.js → json-cULBl7Pi.js} +145 -139
  26. package/dist/migration/bin.js +67 -21
  27. package/dist/migration/compat/worker.js +1 -1
  28. package/dist/{oxlint-plugin-config-BHOzlwMw.js → oxlint-plugin-config-DX5ezKbB.js} +1 -1
  29. package/dist/oxlint-plugin.js +1 -1
  30. package/dist/pack-bin.js +5 -4
  31. package/dist/{package-hV-77cBb.js → package-CBe9EWPY.js} +2 -2
  32. package/dist/{prompts-DYap08te.js → prompts-DF3yU-eU.js} +136 -512
  33. package/dist/{report-BS7ULx7A.js → report-ZNR1Mk6h.js} +1 -0
  34. package/dist/{resolve-vite-config-EWXclqvV.js → resolve-vite-config-ipGb39Jo.js} +2 -9
  35. package/dist/staged/bin.js +299 -251
  36. package/dist/terminal-MKGAuy-p.js +39 -0
  37. package/dist/test/browser/providers/playwright/context.d.ts +1 -1
  38. package/dist/test/browser/providers/playwright.d.ts +6 -6
  39. package/dist/test/browser/providers/preview/context.d.ts +1 -1
  40. package/dist/test/browser/providers/preview.d.ts +4 -4
  41. package/dist/test/browser/providers/webdriverio/context.d.ts +1 -1
  42. package/dist/test/browser/providers/webdriverio.d.ts +6 -6
  43. package/dist/test/browser-playwright/context.d.ts +1 -1
  44. package/dist/test/browser-playwright.d.ts +6 -6
  45. package/dist/test/browser-preview/context.d.ts +1 -1
  46. package/dist/test/browser-preview.d.ts +4 -4
  47. package/dist/test/browser-webdriverio/context.d.ts +1 -1
  48. package/dist/test/browser-webdriverio.d.ts +6 -6
  49. package/dist/test/context.d.ts +3 -3
  50. package/dist/test/locators.d.ts +1 -1
  51. package/dist/toolchain.d.ts +25 -0
  52. package/dist/toolchain.js +194 -0
  53. package/dist/toolchain.json +193 -0
  54. package/dist/tsconfig-BVHG3DpR.js +2 -0
  55. package/dist/{tsconfig-CVUKLfL8.js → tsconfig-LD2QhQ0O.js} +5 -4
  56. package/dist/tsgolint-path.js +1 -1
  57. package/dist/version.js +5 -4
  58. package/dist/versions.d.ts +3 -3
  59. package/dist/versions.js +6 -6
  60. package/docs/guide/ci.md +37 -4
  61. package/docs/guide/commit-hooks.md +87 -14
  62. package/docs/guide/create.md +7 -4
  63. package/docs/guide/env.md +20 -6
  64. package/docs/guide/fmt.md +2 -2
  65. package/docs/guide/github-actions-cache.md +5 -1
  66. package/docs/guide/ide-integration.md +61 -2
  67. package/docs/guide/index.md +3 -1
  68. package/docs/guide/install.md +27 -1
  69. package/docs/guide/installer-env-vars.md +53 -6
  70. package/docs/guide/lint.md +3 -1
  71. package/docs/guide/migrate-rules.md +9 -0
  72. package/docs/guide/migrate.md +41 -4
  73. package/docs/guide/monorepo.md +4 -4
  74. package/docs/guide/test.md +8 -0
  75. package/docs/guide/troubleshooting.md +12 -4
  76. package/docs/guide/upgrade.md +75 -5
  77. package/package.json +36 -33
  78. package/rules/vite-tools.yml +0 -7
  79. package/dist/dist-DT25H9pj.js +0 -3
  80. package/docs/_data/team.ts +0 -131
  81. package/docs/package.json +0 -30
  82. package/docs/pnpm-lock.yaml +0 -4003
  83. package/docs/pnpm-workspace.yaml +0 -6
  84. package/docs/public/checkmark.svg +0 -1
  85. package/docs/public/cta-background.jpg +0 -0
  86. package/docs/public/favicon.svg +0 -1
  87. package/docs/public/icon.svg +0 -1
  88. package/docs/public/logo.svg +0 -1
  89. package/docs/public/og.jpg +0 -0
  90. package/docs/vite.config.ts +0 -17
  91. package/dist/{log-update-CoW8Z4Dl.js → log-update-DHZRyJ2m.js} +1 -1
  92. package/dist/{tsgolint-path-eMZT-oea.js → tsgolint-path-CbDReEOx.js} +1 -1
@@ -1,17 +1,18 @@
1
1
  import { r as __toESM, t as __commonJSMin } from "../rolldown-runtime-CMFfr-1z.js";
2
- import { a as printHeader, c as renderCliDoc, n as errorMsg, r as log } from "../terminal-CrqqK8WT.js";
3
- import { a as resolveViteConfig } from "../resolve-vite-config-EWXclqvV.js";
2
+ import { t as renderCliDoc } from "../help-BmKpeOP9.js";
3
+ import { i as log, n as errorMsg, o as printHeader } from "../terminal-MKGAuy-p.js";
4
+ import { a as resolveViteConfig } from "../resolve-vite-config-ipGb39Jo.js";
4
5
  import { t as lib_default } from "../lib-L3DWSRQp.js";
5
6
  import { createRequire } from "node:module";
6
7
  import path, { basename, delimiter, dirname, normalize, resolve } from "node:path";
8
+ import { pathToFileURL } from "node:url";
7
9
  import { formatWithOptions, inspect, promisify } from "node:util";
8
10
  import { closeSync, constants, openSync, readSync, statSync } from "node:fs";
9
- import { EOL } from "node:os";
10
11
  import { cwd } from "node:process";
11
12
  import l__default from "node:readline";
12
13
  import nodeTty from "node:tty";
13
14
  import crypto from "node:crypto";
14
- import { pathToFileURL } from "node:url";
15
+ import { EOL } from "node:os";
15
16
  import fsPromises, { constants as constants$2 } from "node:fs/promises";
16
17
  import { PassThrough, Writable } from "node:stream";
17
18
  import { exec, spawn } from "node:child_process";
@@ -117,201 +118,212 @@ const createDebug = (name) => {
117
118
  };
118
119
  };
119
120
  //#endregion
120
- //#region ../../node_modules/.pnpm/tinyexec@1.2.4/node_modules/tinyexec/dist/main.mjs
121
- const h = /^path$/i;
122
- const g = {
121
+ //#region ../../node_modules/.pnpm/tinyexec@1.3.0/node_modules/tinyexec/dist/main.mjs
122
+ const isPathLikePattern = /^path$/i;
123
+ const defaultEnvPathInfo = {
123
124
  key: "PATH",
124
125
  value: ""
125
126
  };
126
- function _(e) {
127
- for (const t in e) {
128
- if (!Object.prototype.hasOwnProperty.call(e, t) || !h.test(t)) continue;
129
- const n = e[t];
130
- if (!n) return g;
127
+ function getPathFromEnv(env) {
128
+ for (const key in env) {
129
+ if (!Object.prototype.hasOwnProperty.call(env, key) || !isPathLikePattern.test(key)) continue;
130
+ const value = env[key];
131
+ if (!value) return defaultEnvPathInfo;
131
132
  return {
132
- key: t,
133
- value: n
133
+ key,
134
+ value
134
135
  };
135
136
  }
136
- return g;
137
+ return defaultEnvPathInfo;
137
138
  }
138
- function v(e, t) {
139
- const n = t.value.split(delimiter);
140
- const r = [];
141
- let o = e;
142
- let c;
139
+ function addNodeBinToPath(cwd, path) {
140
+ const parts = path.value.split(delimiter);
141
+ const nodeBinPaths = [];
142
+ let currentPath = cwd;
143
+ let lastPath;
143
144
  do {
144
- r.push(resolve(o, "node_modules", ".bin"));
145
- c = o;
146
- o = dirname(o);
147
- } while (o !== c);
148
- r.push(dirname(process.execPath));
149
- const l = r.concat(n).join(delimiter);
145
+ nodeBinPaths.push(resolve(currentPath, "node_modules", ".bin"));
146
+ lastPath = currentPath;
147
+ currentPath = dirname(currentPath);
148
+ } while (currentPath !== lastPath);
149
+ nodeBinPaths.push(dirname(process.execPath));
150
+ const newPath = nodeBinPaths.concat(parts).join(delimiter);
150
151
  return {
151
- key: t.key,
152
- value: l
152
+ key: path.key,
153
+ value: newPath
153
154
  };
154
155
  }
155
- function y(e, t, n = true) {
156
- const r = {
156
+ function computeEnv(cwd, env, nodePath = true) {
157
+ const envWithDefault = {
157
158
  ...process.env,
158
- ...t
159
+ ...env
159
160
  };
160
- if (!n) return r;
161
- const i = v(e, _(r));
162
- r[i.key] = i.value;
163
- return r;
161
+ if (!nodePath) return envWithDefault;
162
+ const envPathInfo = addNodeBinToPath(cwd, getPathFromEnv(envWithDefault));
163
+ envWithDefault[envPathInfo.key] = envPathInfo.value;
164
+ return envWithDefault;
164
165
  }
165
- const b = (e) => {
166
- let t = e.length;
167
- const n = new PassThrough();
168
- const r = () => {
169
- if (--t === 0) n.end();
166
+ const combineStreams = (streams) => {
167
+ let streamCount = streams.length;
168
+ const combined = new PassThrough();
169
+ const maybeEmitEnd = () => {
170
+ if (--streamCount === 0) combined.end();
170
171
  };
171
- for (const t of e) pipeline(t, n, { end: false }).then(r).catch(r);
172
- return n;
172
+ for (const stream of streams) pipeline(stream, combined, { end: false }).then(maybeEmitEnd).catch(maybeEmitEnd);
173
+ return combined;
173
174
  };
174
- const x = /([()\][%!^"`<>&|;, *?])/g;
175
- const S = /^#!\s*(.+)/;
176
- const C = /\.(?:com|exe)$/i;
177
- const w = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i;
178
- const T = process.platform === "win32";
179
- const E = [
175
+ const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
176
+ const shebangRegExp = /^#!\s*(.+)/;
177
+ const isWindowsExecutableRegExp = /\.(?:com|exe)$/i;
178
+ const isNodeModulesCmdRegExp = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i;
179
+ const isWindows$1 = process.platform === "win32";
180
+ const defaultPathExt = [
180
181
  ".EXE",
181
182
  ".CMD",
182
183
  ".BAT",
183
184
  ".COM"
184
185
  ];
186
+ const noPathExt = [""];
185
187
  /**
186
188
  * Normalizes the command and arguments to work cross-platform.
187
189
  * On Windows, this basically handles things like shebangs, calling
188
190
  * `node_modules/.bin` commands, and escaping meta characters.
189
191
  * On other platforms, it just returns the command and arguments as-is.
190
192
  */
191
- function D(e, t = [], n = {}) {
192
- if (n.shell === true || !T) return {
193
- command: e,
194
- args: t,
195
- options: n
193
+ function normalizeSpawnCommand(command, args = [], options = {}) {
194
+ if (options.shell === true || !isWindows$1) return {
195
+ command,
196
+ args,
197
+ options
196
198
  };
197
- let i = O(e, n);
198
- let a = null;
199
- if (i !== null) {
200
- const e = 150;
201
- const t = Buffer.alloc(e);
202
- let n = null;
199
+ let file = resolveCommand(command, options);
200
+ let shebang = null;
201
+ if (file !== null) {
202
+ const size = 150;
203
+ const buffer = Buffer.alloc(size);
204
+ let fd = null;
203
205
  try {
204
- n = openSync(i, "r");
205
- readSync(n, t, 0, e, 0);
206
+ fd = openSync(file, "r");
207
+ readSync(fd, buffer, 0, size, 0);
206
208
  } catch {} finally {
207
- if (n !== null) closeSync(n);
209
+ if (fd !== null) closeSync(fd);
208
210
  }
209
- const o = t.toString().match(S);
210
- if (o !== null) {
211
- const e = o[1].trim();
212
- const t = e.indexOf(" ");
213
- const n = t !== -1 ? e.slice(0, t) : e;
214
- const i = t !== -1 ? e.slice(t + 1) : "";
215
- const s = basename(n);
216
- a = s === "env" ? i || null : s;
211
+ const match = buffer.toString().match(shebangRegExp);
212
+ if (match !== null) {
213
+ const line = match[1].trim();
214
+ const separatorIndex = line.indexOf(" ");
215
+ const path = separatorIndex !== -1 ? line.slice(0, separatorIndex) : line;
216
+ const argument = separatorIndex !== -1 ? line.slice(separatorIndex + 1) : "";
217
+ const binary = basename(path);
218
+ shebang = binary === "env" ? argument || null : binary;
217
219
  }
218
220
  }
219
- if (a !== null && i !== null) {
220
- t = [i, ...t];
221
- e = a;
222
- i = O(e, n);
223
- }
224
- if (i === null || !C.test(i)) {
225
- const r = i !== null && w.test(i);
226
- e = normalize(e);
227
- e = e.replace(x, "^$1");
228
- t = t.map((e) => {
229
- e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
230
- e = e.replace(/(?=(\\+?)?)\1$/, "$1$1");
231
- e = `"${e}"`;
232
- e = e.replace(x, "^$1");
233
- if (r) e = e.replace(x, "^$1");
234
- return e;
221
+ if (shebang !== null && file !== null) {
222
+ args = [file, ...args];
223
+ command = shebang;
224
+ file = resolveCommand(command, options);
225
+ }
226
+ if (file === null || !isWindowsExecutableRegExp.test(file)) {
227
+ const needsDoubleEscapeMetaChars = file !== null && isNodeModulesCmdRegExp.test(file);
228
+ command = normalize(command);
229
+ command = command.replace(metaCharsRegExp, "^$1");
230
+ args = args.map((arg) => {
231
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
232
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
233
+ arg = `"${arg}"`;
234
+ arg = arg.replace(metaCharsRegExp, "^$1");
235
+ if (needsDoubleEscapeMetaChars) arg = arg.replace(metaCharsRegExp, "^$1");
236
+ return arg;
235
237
  });
236
- t = [
238
+ args = [
237
239
  "/d",
238
240
  "/s",
239
241
  "/c",
240
- `"${[e, ...t].join(" ")}"`
242
+ `"${[command, ...args].join(" ")}"`
241
243
  ];
242
- e = n.env?.comspec ?? "cmd.exe";
243
- n = {
244
- ...n,
244
+ command = options.env?.comspec ?? "cmd.exe";
245
+ options = {
246
+ ...options,
245
247
  windowsVerbatimArguments: true
246
248
  };
247
249
  }
248
250
  return {
249
- command: e,
250
- args: t,
251
- options: n
251
+ command,
252
+ args,
253
+ options
252
254
  };
253
255
  }
254
256
  /**
255
257
  * Resolves the command to an absolute path if possible.
256
258
  * Handles things like traversing PATH and adding extensions from PATHEXT
257
259
  */
258
- function O(e, t) {
259
- const r = (t.cwd ?? cwd()).toString();
260
- const a = t.env ?? process.env;
261
- const o = _(a).value;
262
- const c = e.includes("/") || e.includes("\\") ? [""] : [r, ...o.split(delimiter)];
263
- const l = a.PATHEXT ? a.PATHEXT.split(delimiter) : E;
264
- if (e.includes(".") && l[0] !== "") l.unshift("");
265
- for (const t of c) {
266
- const n = resolve(r, t.startsWith("\"") && t.endsWith("\"") && t.length > 1 ? t.slice(1, -1) : t, e);
267
- for (const e of l) {
268
- const t = n + e;
260
+ function resolveCommand(command, options) {
261
+ const cwd$3 = (options.cwd ?? cwd()).toString();
262
+ const env = options.env ?? process.env;
263
+ const PATH = getPathFromEnv(env).value;
264
+ const pathEnv = command.includes("/") || command.includes("\\") ? [""] : [cwd$3, ...PATH.split(delimiter)];
265
+ let pathExt = env.PATHEXT ? env.PATHEXT.split(delimiter) : defaultPathExt;
266
+ if (command.includes(".") && pathExt[0] !== "") pathExt = ["", ...pathExt];
267
+ for (const extensions of [pathExt, noPathExt]) for (const path of pathEnv) {
268
+ const dest = resolve(cwd$3, path.startsWith("\"") && path.endsWith("\"") && path.length > 1 ? path.slice(1, -1) : path, command);
269
+ for (const ext of extensions) {
270
+ const destWithExt = dest + ext;
269
271
  try {
270
- if (statSync(t).isFile()) return t;
272
+ if (statSync(destWithExt).isFile()) return destWithExt;
271
273
  } catch {}
272
274
  }
273
275
  }
274
276
  return null;
275
277
  }
276
- var k = class extends Error {
278
+ var NonZeroExitError = class extends Error {
277
279
  result;
278
280
  output;
279
- get exitCode() {
280
- if (this.result.exitCode !== null) return this.result.exitCode;
281
- }
282
- constructor(e, t) {
283
- super(`Process exited with non-zero status (${e.exitCode})`);
284
- this.result = e;
285
- this.output = t;
281
+ exitCode;
282
+ get signalCode() {
283
+ return this.result.signalCode;
284
+ }
285
+ constructor(result, output, command, args) {
286
+ let target = "The process";
287
+ if (command) target = `The command \`${args?.length ? `${command} ${args.map((a) => /[ "'`()]/.test(a) ? JSON.stringify(a) : a).join(" ")}` : command}\``;
288
+ const exitCode = result.exitCode ?? 1;
289
+ super(result.signalCode !== null ? `${target} was killed by the signal ${result.signalCode}` : `${target} exited with a non-zero status (${exitCode})`);
290
+ this.result = result;
291
+ this.output = output;
292
+ this.exitCode = exitCode;
293
+ Object.defineProperty(this, "result", {
294
+ enumerable: false,
295
+ writable: false,
296
+ configurable: false
297
+ });
286
298
  }
287
299
  };
288
- const j = {
300
+ const defaultOptions = {
289
301
  timeout: void 0,
290
302
  persist: false
291
303
  };
292
- const N = { windowsHide: true };
293
- function P(e) {
294
- const t = new AbortController();
295
- for (const n of e) {
296
- if (n.aborted) {
297
- t.abort();
298
- return n;
304
+ const defaultNodeOptions = { windowsHide: true };
305
+ function combineSignals(signals) {
306
+ const controller = new AbortController();
307
+ for (const signal of signals) {
308
+ if (signal.aborted) {
309
+ controller.abort();
310
+ return signal;
299
311
  }
300
- const e = () => {
301
- t.abort(n.reason);
312
+ const onAbort = () => {
313
+ controller.abort(signal.reason);
302
314
  };
303
- n.addEventListener("abort", e, { signal: t.signal });
315
+ signal.addEventListener("abort", onAbort, { signal: controller.signal });
304
316
  }
305
- return t.signal;
317
+ return controller.signal;
306
318
  }
307
- async function F(e) {
308
- let t = "";
319
+ async function readStream(stream) {
320
+ let output = "";
309
321
  try {
310
- for await (const n of e) t += n.toString();
322
+ for await (const chunk of stream) output += chunk.toString();
311
323
  } catch {}
312
- return t;
324
+ return output;
313
325
  }
314
- var I = class {
326
+ var ExecProcess = class {
315
327
  _process;
316
328
  _aborted = false;
317
329
  _options;
@@ -329,19 +341,22 @@ var I = class {
329
341
  get exitCode() {
330
342
  if (this._process && this._process.exitCode !== null) return this._process.exitCode;
331
343
  }
332
- constructor(e, t, n) {
344
+ get signalCode() {
345
+ return this._process?.signalCode ?? null;
346
+ }
347
+ constructor(command, args, options) {
333
348
  this._options = {
334
- ...j,
335
- ...n
349
+ ...defaultOptions,
350
+ ...options
336
351
  };
337
- this._command = e;
338
- this._args = t ?? [];
339
- this._processClosed = new Promise((e) => {
340
- this._resolveClose = e;
352
+ this._command = command;
353
+ this._args = args ?? [];
354
+ this._processClosed = new Promise((resolve) => {
355
+ this._resolveClose = resolve;
341
356
  });
342
357
  }
343
- kill(e) {
344
- return this._process?.kill(e) === true;
358
+ kill(signal) {
359
+ return this._process?.kill(signal) === true;
345
360
  }
346
361
  get aborted() {
347
362
  return this._aborted;
@@ -349,99 +364,99 @@ var I = class {
349
364
  get killed() {
350
365
  return this._process?.killed === true;
351
366
  }
352
- pipe(e, t, n) {
353
- return z(e, t, {
354
- ...n,
367
+ pipe(command, args, options) {
368
+ return exec$1(command, args, {
369
+ ...options,
355
370
  stdin: this
356
371
  });
357
372
  }
358
373
  async *[Symbol.asyncIterator]() {
359
- const e = this._process;
360
- if (!e) return;
361
- const t = [];
362
- if (this._streamErr) t.push(this._streamErr);
363
- if (this._streamOut) t.push(this._streamOut);
364
- const n = b(t);
365
- const r = l__default.createInterface({ input: n });
366
- for await (const e of r) yield e.toString();
374
+ const proc = this._process;
375
+ if (!proc) return;
376
+ const streams = [];
377
+ if (this._streamErr) streams.push(this._streamErr);
378
+ if (this._streamOut) streams.push(this._streamOut);
379
+ const streamCombined = combineStreams(streams);
380
+ const rl = l__default.createInterface({ input: streamCombined });
381
+ for await (const chunk of rl) yield chunk.toString();
367
382
  await this._processClosed;
368
- e.removeAllListeners();
383
+ proc.removeAllListeners();
369
384
  if (this._thrownError) throw this._thrownError;
370
- if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new k(this);
385
+ if (this._options?.throwOnError && (this.exitCode !== 0 && this.exitCode !== void 0 || this.signalCode !== null)) throw new NonZeroExitError(this, void 0, this._command, this._args);
371
386
  }
372
387
  async _waitForOutput() {
373
- const e = this._process;
374
- if (!e) throw new Error("No process was started");
375
- const [t, n] = await Promise.all([this._streamOut ? F(this._streamOut) : "", this._streamErr ? F(this._streamErr) : ""]);
388
+ const proc = this._process;
389
+ if (!proc) throw new Error("No process was started");
390
+ const [stdout, stderr] = await Promise.all([this._streamOut ? readStream(this._streamOut) : "", this._streamErr ? readStream(this._streamErr) : ""]);
376
391
  await this._processClosed;
377
- const { stdin: r } = this._options;
378
- if (r && typeof r !== "string") await r;
379
- e.removeAllListeners();
392
+ const { stdin } = this._options;
393
+ if (stdin && typeof stdin !== "string") await stdin;
394
+ proc.removeAllListeners();
380
395
  if (this._thrownError) throw this._thrownError;
381
- const i = {
382
- stderr: n,
383
- stdout: t,
396
+ const result = {
397
+ stderr,
398
+ stdout,
384
399
  exitCode: this.exitCode
385
400
  };
386
- if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new k(this, i);
387
- return i;
401
+ if (this._options.throwOnError && (this.exitCode !== 0 && this.exitCode !== void 0 || this.signalCode !== null)) throw new NonZeroExitError(this, result, this._command, this._args);
402
+ return result;
388
403
  }
389
- then(e, t) {
390
- return this._waitForOutput().then(e, t);
404
+ then(onfulfilled, onrejected) {
405
+ return this._waitForOutput().then(onfulfilled, onrejected);
391
406
  }
392
407
  _streamOut;
393
408
  _streamErr;
394
409
  spawn() {
395
- const t = cwd();
396
- const r = this._options;
397
- const i = {
398
- ...N,
399
- ...r.nodeOptions
410
+ const cwd$1 = cwd();
411
+ const options = this._options;
412
+ const nodeOptions = {
413
+ ...defaultNodeOptions,
414
+ ...options.nodeOptions
400
415
  };
401
- const a = [];
416
+ const signals = [];
402
417
  this._resetState();
403
- if (r.timeout !== void 0) a.push(AbortSignal.timeout(r.timeout));
404
- if (r.signal !== void 0) a.push(r.signal);
405
- if (r.persist === true) i.detached = true;
406
- if (a.length > 0) i.signal = P(a);
407
- i.env = y(t, i.env, r.nodePath);
408
- const o = D(this._command, this._args, i);
409
- const s = spawn(o.command, o.args, o.options);
410
- if (s.stderr) this._streamErr = s.stderr;
411
- if (s.stdout) this._streamOut = s.stdout;
412
- this._process = s;
413
- s.once("error", this._onError);
414
- s.once("close", this._onClose);
415
- if (s.stdin) {
416
- const { stdin: e } = r;
417
- if (typeof e === "string") s.stdin.end(e);
418
- else e?.process?.stdout?.pipe(s.stdin);
418
+ if (options.timeout !== void 0) signals.push(AbortSignal.timeout(options.timeout));
419
+ if (options.signal !== void 0) signals.push(options.signal);
420
+ if (options.persist === true) nodeOptions.detached = true;
421
+ if (signals.length > 0) nodeOptions.signal = combineSignals(signals);
422
+ nodeOptions.env = computeEnv(cwd$1, nodeOptions.env, options.nodePath);
423
+ const crossResult = normalizeSpawnCommand(this._command, this._args, nodeOptions);
424
+ const handle = spawn(crossResult.command, crossResult.args, crossResult.options);
425
+ if (handle.stderr) this._streamErr = handle.stderr;
426
+ if (handle.stdout) this._streamOut = handle.stdout;
427
+ this._process = handle;
428
+ handle.once("error", this._onError);
429
+ handle.once("close", this._onClose);
430
+ if (handle.stdin) {
431
+ const { stdin } = options;
432
+ if (typeof stdin === "string") handle.stdin.end(stdin);
433
+ else stdin?.process?.stdout?.pipe(handle.stdin);
419
434
  }
420
435
  }
421
436
  _resetState() {
422
437
  this._aborted = false;
423
- this._processClosed = new Promise((e) => {
424
- this._resolveClose = e;
438
+ this._processClosed = new Promise((resolve) => {
439
+ this._resolveClose = resolve;
425
440
  });
426
441
  this._thrownError = void 0;
427
442
  }
428
- _onError = (e) => {
429
- if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
443
+ _onError = (err) => {
444
+ if (err.name === "AbortError" && (!(err.cause instanceof Error) || err.cause.name !== "TimeoutError")) {
430
445
  this._aborted = true;
431
446
  return;
432
447
  }
433
- this._thrownError = e;
448
+ this._thrownError = err;
434
449
  };
435
450
  _onClose = () => {
436
451
  if (this._resolveClose) this._resolveClose();
437
452
  };
438
453
  };
439
- const R = (e, t, n) => {
440
- const r = new I(e, t, n);
441
- r.spawn();
442
- return r;
454
+ const x = (command, args, userOptions) => {
455
+ const proc = new ExecProcess(command, args, userOptions);
456
+ proc.spawn();
457
+ return proc;
443
458
  };
444
- const z = R;
459
+ const exec$1 = x;
445
460
  //#endregion
446
461
  //#region ../../node_modules/.pnpm/lint-staged@16.4.0/node_modules/lint-staged/lib/execGit.js
447
462
  const debugLog$15 = createDebug("lint-staged:execGit");
@@ -456,7 +471,7 @@ const NO_SUBMODULE_RECURSE = ["-c", "submodule.recurse=false"];
456
471
  /** @type {(cmd: string[], options?: { cwd?: string }) => Promise<string>} */
457
472
  const execGit = async (cmd, options) => {
458
473
  debugLog$15("Running git command:", cmd);
459
- const result = z("git", [...NO_SUBMODULE_RECURSE, ...cmd], { nodeOptions: {
474
+ const result = exec$1("git", [...NO_SUBMODULE_RECURSE, ...cmd], { nodeOptions: {
460
475
  cwd: options?.cwd,
461
476
  stdio: ["ignore"]
462
477
  } });
@@ -1544,7 +1559,7 @@ var DefaultRenderer = class DefaultRenderer {
1544
1559
  this.logger.options.color = this.options.color;
1545
1560
  }
1546
1561
  async render() {
1547
- const { createLogUpdate } = await import("../log-update-CoW8Z4Dl.js");
1562
+ const { createLogUpdate } = await import("../log-update-DHZRyJ2m.js");
1548
1563
  const { default: truncate } = await import("../cli-truncate-Bg3RDXpi.js");
1549
1564
  const { default: wrap } = await import("../wrap-ansi-DUi52C6W.js");
1550
1565
  this.updater = createLogUpdate(this.logger.process.stdout);
@@ -3886,10 +3901,12 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3886
3901
  }
3887
3902
  return esc ? m : `\\${m}`;
3888
3903
  });
3889
- if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
3890
- else output = output.replace(/\\+/g, (m) => {
3891
- return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
3892
- });
3904
+ if (backslashes === true) {
3905
+ if (opts.unescape === true) output = output.replace(/\\/g, "");
3906
+ else output = output.replace(/\\+/g, (m) => {
3907
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
3908
+ });
3909
+ }
3893
3910
  if (output === input && opts.contains === true) {
3894
3911
  state.output = input;
3895
3912
  return state;
@@ -4660,8 +4677,10 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4660
4677
  output = format ? format(input) : input;
4661
4678
  match = output === glob;
4662
4679
  }
4663
- if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix);
4664
- else match = regex.exec(output);
4680
+ if (match === false || opts.capture === true) {
4681
+ if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix);
4682
+ else match = regex.exec(output);
4683
+ }
4665
4684
  return {
4666
4685
  isMatch: Boolean(match),
4667
4686
  match,
@@ -5101,7 +5120,7 @@ const getSpawnedTask = ({ abortController, color, command, continueOnError = fal
5101
5120
  debugLog$12("Tinyexec options:", tinyExecOptions);
5102
5121
  /** @param {ReturnType<typeof getInitialState>} ctx context */
5103
5122
  return async (ctx = getInitialState()) => {
5104
- const result = z(cmd, isFn ? args : args.concat(files), tinyExecOptions);
5123
+ const result = exec$1(cmd, isFn ? args : args.concat(files), tinyExecOptions);
5105
5124
  const taskFailed = () => result.exitCode > 0 || result.process?.signalCode;
5106
5125
  /** @type {keyof typeof Signal | undefined} */
5107
5126
  let signal;
@@ -5942,7 +5961,7 @@ const jsonParse = async (filename) => {
5942
5961
  const yamlParse = async (filename) => {
5943
5962
  const isPackageFile = PACKAGE_YAML_FILES.includes(path.basename(filename));
5944
5963
  try {
5945
- const [YAML, content] = await Promise.all([import("../dist-DT25H9pj.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)), readFile(filename)]);
5964
+ const [YAML, content] = await Promise.all([import("../dist-Dqv1-Clg.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)), readFile(filename)]);
5946
5965
  const yaml = YAML.parse(content);
5947
5966
  return isPackageFile ? yaml[CONFIG_NAME] : yaml;
5948
5967
  } catch (error) {
@@ -6623,37 +6642,66 @@ const lintStaged = async ({ allowEmpty = false, color = SUPPORTS_COLOR, concurre
6623
6642
  }
6624
6643
  };
6625
6644
  //#endregion
6645
+ //#region src/staged/args.ts
6646
+ function parseStagedArgs(argv) {
6647
+ return lib_default(argv, {
6648
+ alias: {
6649
+ h: "help",
6650
+ p: "concurrent",
6651
+ d: "debug",
6652
+ q: "quiet",
6653
+ r: "relative",
6654
+ v: "verbose"
6655
+ },
6656
+ boolean: [
6657
+ "help",
6658
+ "allow-empty",
6659
+ "debug",
6660
+ "continue-on-error",
6661
+ "fail-on-changes",
6662
+ "hide-partially-staged",
6663
+ "hide-unstaged",
6664
+ "quiet",
6665
+ "relative",
6666
+ "revert",
6667
+ "stash",
6668
+ "verbose"
6669
+ ],
6670
+ string: [
6671
+ "concurrent",
6672
+ "cwd",
6673
+ "diff",
6674
+ "diff-filter"
6675
+ ]
6676
+ });
6677
+ }
6678
+ function normalizeStagedArgs(args) {
6679
+ return {
6680
+ concurrent: normalizeConcurrent(args.concurrent),
6681
+ cwd: normalizeStringOption(args.cwd, "cwd", "path"),
6682
+ diff: normalizeStringOption(args.diff, "diff", "string"),
6683
+ diffFilter: normalizeStringOption(args["diff-filter"], "diff-filter", "string")
6684
+ };
6685
+ }
6686
+ function normalizeConcurrent(value) {
6687
+ if (value == null) return;
6688
+ if (value === true || value === false) return value;
6689
+ if (value === "") return true;
6690
+ if (value === "true") return true;
6691
+ if (value === "false") return false;
6692
+ const number = Number(value);
6693
+ if (Number.isFinite(number) && number > 0) return number;
6694
+ throw new Error("Option \"--concurrent\" must be true, false, or a number greater than 0.");
6695
+ }
6696
+ function normalizeStringOption(value, option, valueName) {
6697
+ if (value == null) return;
6698
+ if (value === false) throw new Error(`Option "--no-${option}" is not supported. Use "--${option} <${valueName}>".`);
6699
+ if (typeof value !== "string" || value === "") throw new Error(`Option "--${option}" requires a value.`);
6700
+ return value;
6701
+ }
6702
+ //#endregion
6626
6703
  //#region src/staged/bin.ts
6627
- const args = lib_default(process.argv.slice(3), {
6628
- alias: {
6629
- h: "help",
6630
- p: "concurrent",
6631
- d: "debug",
6632
- q: "quiet",
6633
- r: "relative",
6634
- v: "verbose"
6635
- },
6636
- boolean: [
6637
- "help",
6638
- "allow-empty",
6639
- "debug",
6640
- "continue-on-error",
6641
- "fail-on-changes",
6642
- "hide-partially-staged",
6643
- "hide-unstaged",
6644
- "quiet",
6645
- "relative",
6646
- "revert",
6647
- "stash",
6648
- "verbose"
6649
- ],
6650
- string: [
6651
- "concurrent",
6652
- "cwd",
6653
- "diff",
6654
- "diff-filter"
6655
- ]
6656
- });
6704
+ const args = parseStagedArgs(process.argv.slice(3));
6657
6705
  if (args.help) {
6658
6706
  const helpMessage = renderCliDoc({
6659
6707
  usage: "vp staged [options]",
@@ -6732,6 +6780,14 @@ if (args.help) {
6732
6780
  printHeader();
6733
6781
  log(helpMessage);
6734
6782
  } else {
6783
+ let normalizedArgs;
6784
+ try {
6785
+ normalizedArgs = normalizeStagedArgs(args);
6786
+ } catch (err) {
6787
+ printHeader();
6788
+ errorMsg(err instanceof Error ? err.message : String(err));
6789
+ process.exit(1);
6790
+ }
6735
6791
  const options = {};
6736
6792
  if (args["allow-empty"] != null) options.allowEmpty = args["allow-empty"];
6737
6793
  if (args.debug != null) options.debug = args.debug;
@@ -6746,7 +6802,7 @@ if (args.help) {
6746
6802
  if (args.verbose != null) options.verbose = args.verbose;
6747
6803
  let stagedConfig;
6748
6804
  try {
6749
- stagedConfig = (await resolveViteConfig(args.cwd ?? process.cwd())).staged;
6805
+ stagedConfig = (await resolveViteConfig(normalizedArgs.cwd ?? process.cwd())).staged;
6750
6806
  } catch (err) {
6751
6807
  const message = err instanceof Error ? err.message : String(err);
6752
6808
  log(`Failed to load vite.config: ${message}`);
@@ -6763,18 +6819,10 @@ if (args.help) {
6763
6819
  log(" });");
6764
6820
  process.exit(1);
6765
6821
  }
6766
- if (args.cwd != null) options.cwd = args.cwd;
6767
- if (args.diff != null) options.diff = args.diff;
6768
- if (args["diff-filter"] != null) options.diffFilter = args["diff-filter"];
6769
- if (args.concurrent != null) {
6770
- const val = args.concurrent;
6771
- if (val === "true") options.concurrent = true;
6772
- else if (val === "false") options.concurrent = false;
6773
- else {
6774
- const num = Number(val);
6775
- options.concurrent = Number.isNaN(num) || val === "" ? true : num;
6776
- }
6777
- }
6822
+ if (normalizedArgs.cwd != null) options.cwd = normalizedArgs.cwd;
6823
+ if (normalizedArgs.diff != null) options.diff = normalizedArgs.diff;
6824
+ if (normalizedArgs.diffFilter != null) options.diffFilter = normalizedArgs.diffFilter;
6825
+ if (normalizedArgs.concurrent != null) options.concurrent = normalizedArgs.concurrent;
6778
6826
  const success = await lintStaged(options);
6779
6827
  process.exit(success ? 0 : 1);
6780
6828
  }