vite-plus 0.2.7 → 0.2.9

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 (89) hide show
  1. package/AGENTS.md +7 -0
  2. package/LICENSE +5 -1
  3. package/README.md +9 -3
  4. package/bin/vpr +3 -2
  5. package/binding/index.cjs +193 -80
  6. package/binding/index.d.cts +106 -11
  7. package/dist/agent-DQU8uS6P.js +416 -0
  8. package/dist/bin.js +1388 -23
  9. package/dist/{cli-truncate-BVOlIIPy.js → cli-truncate-Bg3RDXpi.js} +0 -2
  10. package/dist/client/bundledDevClient.mjs +1 -0
  11. package/dist/config/bin.js +32 -133
  12. package/dist/{constants-BsuzPowC.js → constants-CG513DRa.js} +10 -2
  13. package/dist/create/bin.js +255 -268
  14. package/dist/{define-config-C2KfLHpC.js → define-config-CV4bQG_8.js} +3 -3
  15. package/dist/{define-config-eLQH9us2.d.ts → define-config-DWoAkNdp.d.ts} +16 -0
  16. package/dist/{define-config-DLh9fE95.cjs → define-config-DyNLA_f0.cjs} +1 -1
  17. package/dist/define-config.cjs +1 -1
  18. package/dist/define-config.d.ts +1 -1
  19. package/dist/define-config.js +1 -1
  20. package/dist/{dist-CKz3vcoG.js → dist-BDYZP12R.js} +196 -157
  21. package/dist/dist-Dqv1-Clg.js +3 -0
  22. package/dist/{agent-CPwWJ4qf.js → editor-g4PosU99.js} +819 -628
  23. package/dist/hooks/bin.d.ts +1 -0
  24. package/dist/hooks/bin.js +130 -0
  25. package/dist/hooks-pNCBWtFT.js +570 -0
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/{json-DiRs8ceZ.js → json-qlK6UH0r.js} +40 -38
  30. package/dist/migration/bin.js +65 -58
  31. package/dist/{oxlint-plugin-config-Bxgc4cwF.js → oxlint-plugin-config-BEZ9IUf7.js} +1 -1
  32. package/dist/oxlint-plugin.js +1 -1
  33. package/dist/pack-bin.js +1 -1
  34. package/dist/{package-Ds3uThLb.js → package-B4T8RGMG.js} +2 -2
  35. package/dist/{tsconfig-Jia2vgMG.js → prompts-CHz_98bJ.js} +169 -219
  36. package/dist/{resolve-vite-config-BiuLZnn8.js → resolve-vite-config-Dmeyeyj-.js} +2 -9
  37. package/dist/{rolldown-runtime-C7HZzL1F.js → rolldown-runtime-CMFfr-1z.js} +1 -1
  38. package/dist/staged/bin.js +241 -226
  39. package/dist/terminal-Bz-ps6rJ.js +128 -0
  40. package/dist/test/browser/providers/playwright/context.d.ts +1 -1
  41. package/dist/test/browser/providers/playwright.d.ts +6 -6
  42. package/dist/test/browser/providers/preview/context.d.ts +1 -1
  43. package/dist/test/browser/providers/preview.d.ts +4 -4
  44. package/dist/test/browser/providers/webdriverio/context.d.ts +1 -1
  45. package/dist/test/browser/providers/webdriverio.d.ts +6 -6
  46. package/dist/test/browser-playwright/context.d.ts +1 -1
  47. package/dist/test/browser-playwright.d.ts +6 -6
  48. package/dist/test/browser-preview/context.d.ts +1 -1
  49. package/dist/test/browser-preview.d.ts +4 -4
  50. package/dist/test/browser-webdriverio/context.d.ts +1 -1
  51. package/dist/test/browser-webdriverio.d.ts +6 -6
  52. package/dist/test/context.d.ts +3 -3
  53. package/dist/test/locators.d.ts +1 -1
  54. package/dist/toolchain.d.ts +25 -0
  55. package/dist/toolchain.js +194 -0
  56. package/dist/toolchain.json +193 -0
  57. package/dist/tsconfig-7v_BHagU.js +151 -0
  58. package/dist/{tsgolint-path-B-yOos8p.js → tsgolint-path-CbDReEOx.js} +5 -3
  59. package/dist/tsgolint-path.js +1 -1
  60. package/dist/version.js +6 -6
  61. package/dist/versions.d.ts +3 -3
  62. package/dist/versions.js +6 -6
  63. package/docs/config/index.md +13 -0
  64. package/docs/config/staged.md +2 -1
  65. package/docs/guide/ci.md +37 -4
  66. package/docs/guide/commit-hooks.md +112 -21
  67. package/docs/guide/create.md +7 -4
  68. package/docs/guide/env.md +8 -4
  69. package/docs/guide/fmt.md +2 -2
  70. package/docs/guide/github-actions-cache.md +5 -1
  71. package/docs/guide/ide-integration.md +61 -2
  72. package/docs/guide/index.md +4 -2
  73. package/docs/guide/install.md +27 -0
  74. package/docs/guide/installer-env-vars.md +14 -3
  75. package/docs/guide/lint.md +3 -1
  76. package/docs/guide/migrate.md +49 -4
  77. package/docs/guide/monorepo.md +98 -10
  78. package/docs/guide/troubleshooting.md +12 -3
  79. package/docs/guide/upgrade.md +27 -4
  80. package/docs/package.json +1 -1
  81. package/docs/pnpm-workspace.yaml +7 -0
  82. package/docs/vite.config.ts +3 -0
  83. package/package.json +21 -23
  84. package/rules/vite-tools.yml +0 -7
  85. package/dist/dist-CtM2JRbM.js +0 -3
  86. package/dist/editor-BbT1lTNc.js +0 -675
  87. package/dist/help-YP84FSEz.js +0 -61
  88. package/dist/terminal-uTv0ZaMr.js +0 -33
  89. package/dist/{log-update-DHZRyJ2m.js → log-update-CoW8Z4Dl.js} +1 -1
@@ -1,12 +1,13 @@
1
- import { n as __require, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-C7HZzL1F.js";
2
- import { l as VITE_PLUS_VERSION, t as BASEURL_TSCONFIG_FIX_PACKAGE, u as createBaseUrlTsconfigFixArgs } from "./constants-BsuzPowC.js";
3
- import { t as accent } from "./terminal-uTv0ZaMr.js";
4
- import { a as writeJsonFile, c as parse, i as readJsonFile, o as applyEdits, s as modify } from "./json-DiRs8ceZ.js";
5
- import { t as require_dist } from "./dist-CKz3vcoG.js";
1
+ import { n as __require, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-CMFfr-1z.js";
2
+ import { t as accent } from "./terminal-Bz-ps6rJ.js";
3
+ import { u as VITE_PLUS_VERSION } from "./constants-CG513DRa.js";
4
+ import { a as writeJsonFile, i as readJsonFile } from "./json-qlK6UH0r.js";
5
+ import { t as require_dist } from "./dist-BDYZP12R.js";
6
6
  import path from "node:path";
7
7
  import { downloadPackageManager } from "../binding/index.js";
8
- import fs from "node:fs";
9
8
  import { stripVTControlCharacters, styleText } from "node:util";
9
+ import fs from "node:fs";
10
+ import { constants as constants$1 } from "node:os";
10
11
  import process$1, { stdin, stdout } from "node:process";
11
12
  import * as l from "node:readline";
12
13
  import l__default from "node:readline";
@@ -123,7 +124,8 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
123
124
  const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
124
125
  const getPathInfo = (cmd, opt) => {
125
126
  const colon = opt.colon || COLON;
126
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH || "").split(colon)];
127
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH ||
128
+ /* istanbul ignore next: very unusual */ "").split(colon)];
127
129
  const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
128
130
  const pathExt = isWindows ? pathExtExe.split(colon) : [""];
129
131
  if (isWindows) {
@@ -155,8 +157,10 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
155
157
  if (ii === pathExt.length) return resolve(step(i + 1));
156
158
  const ext = pathExt[ii];
157
159
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
158
- if (!er && is) if (opt.all) found.push(p + ext);
159
- else return resolve(p + ext);
160
+ if (!er && is) {
161
+ if (opt.all) found.push(p + ext);
162
+ else return resolve(p + ext);
163
+ }
160
164
  return resolve(subStep(p, i, ii + 1));
161
165
  });
162
166
  });
@@ -174,8 +178,10 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
174
178
  for (let j = 0; j < pathExt.length; j++) {
175
179
  const cur = p + pathExt[j];
176
180
  try {
177
- if (isexe.sync(cur, { pathExt: pathExtExe })) if (opt.all) found.push(cur);
178
- else return cur;
181
+ if (isexe.sync(cur, { pathExt: pathExtExe })) {
182
+ if (opt.all) found.push(cur);
183
+ else return cur;
184
+ }
179
185
  } catch (ex) {}
180
186
  }
181
187
  }
@@ -411,6 +417,11 @@ var require_cross_spawn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
411
417
  //#endregion
412
418
  //#region src/utils/command.ts
413
419
  var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
420
+ function exitCodeFromClose(code, signal) {
421
+ if (code !== null) return code;
422
+ const signalNumber = signal && constants$1.signals[signal];
423
+ return signalNumber ? 128 + signalNumber : 1;
424
+ }
414
425
  async function runCommandSilently(options) {
415
426
  const child = (0, import_cross_spawn.default)(options.command, options.args, {
416
427
  stdio: [
@@ -436,14 +447,14 @@ async function runCommandSilently(options) {
436
447
  child.stderr?.on("data", (data) => {
437
448
  stderr.push(data);
438
449
  });
439
- child.on("close", (code) => {
450
+ child.on("close", (code, signal) => {
440
451
  clearTimeout(timer);
441
452
  if (timedOut) {
442
453
  reject(/* @__PURE__ */ new Error(`Command timed out after ${options.timeoutMs}ms: ${options.command}`));
443
454
  return;
444
455
  }
445
456
  resolve({
446
- exitCode: code ?? 0,
457
+ exitCode: exitCodeFromClose(code, signal),
447
458
  stdout: Buffer.concat(stdout),
448
459
  stderr: Buffer.concat(stderr)
449
460
  });
@@ -461,8 +472,8 @@ async function runCommand$1(options) {
461
472
  env: options.envs
462
473
  });
463
474
  return new Promise((resolve, reject) => {
464
- child.on("close", (code) => {
465
- resolve({ exitCode: code ?? 0 });
475
+ child.on("close", (code, signal) => {
476
+ resolve({ exitCode: exitCodeFromClose(code, signal) });
466
477
  });
467
478
  child.on("error", (err) => {
468
479
  reject(err);
@@ -1162,9 +1173,7 @@ var a = class extends V {
1162
1173
  case "right":
1163
1174
  this.cursor = findCursor(this.cursor, 1, this.options);
1164
1175
  break;
1165
- case "space":
1166
- this.toggleValue();
1167
- break;
1176
+ case "space": this.toggleValue();
1168
1177
  }
1169
1178
  });
1170
1179
  }
@@ -1189,9 +1198,7 @@ let n$1 = class n extends V {
1189
1198
  this.cursor = findCursor(this.cursor, -1, this.options);
1190
1199
  break;
1191
1200
  case "down":
1192
- case "right":
1193
- this.cursor = findCursor(this.cursor, 1, this.options);
1194
- break;
1201
+ case "right": this.cursor = findCursor(this.cursor, 1, this.options);
1195
1202
  }
1196
1203
  this.changeValue();
1197
1204
  });
@@ -1683,7 +1690,7 @@ const limitOptions = (params) => {
1683
1690
  };
1684
1691
  /**
1685
1692
  * Render-milestone markers for the PTY snapshot suite
1686
- * (crates/vite_cli_snapshots): invisible window-title updates the runner
1693
+ * (crates/vp_cli_snapshots): invisible window-title updates the runner
1687
1694
  * synchronizes on via `expect-milestone` interactions. Emission is gated on
1688
1695
  * `VP_EMIT_MILESTONES=1`, which only the runner sets; real terminals and
1689
1696
  * piped output never see these markers as content (they only update the
@@ -2024,8 +2031,10 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
2024
2031
  const elapsedMs = getElapsedMs();
2025
2032
  const step = code === 0 ? completeColor(S_STEP_SUBMIT) : code === 1 ? import_picocolors.default.red(S_STEP_CANCEL) : import_picocolors.default.red(S_STEP_ERROR);
2026
2033
  _message = msg ?? _message;
2027
- if (!silent) if (indicator === "timer") output.write(`${step} ${_message} ${formatTimer(elapsedMs)}\n\n`);
2028
- else output.write(`${step} ${_message}\n\n`);
2034
+ if (!silent) {
2035
+ if (indicator === "timer") output.write(`${step} ${_message} ${formatTimer(elapsedMs)}\n\n`);
2036
+ else output.write(`${step} ${_message}\n\n`);
2037
+ }
2029
2038
  if (!preserveElapsed) _elapsedMs = 0;
2030
2039
  _prevMessage = void 0;
2031
2040
  clearHooks();
@@ -2167,14 +2176,12 @@ const text = (opts) => {
2167
2176
  //#endregion
2168
2177
  //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
2169
2178
  var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2170
- const SEMVER_SPEC_VERSION = "2.0.0";
2171
- const MAX_LENGTH = 256;
2172
- const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
2173
2179
  module.exports = {
2174
- MAX_LENGTH,
2180
+ MAX_LENGTH: 256,
2175
2181
  MAX_SAFE_COMPONENT_LENGTH: 16,
2176
- MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
2177
- MAX_SAFE_INTEGER,
2182
+ MAX_SAFE_BUILD_LENGTH: 250,
2183
+ MAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER ||
2184
+ /* istanbul ignore next */ 9007199254740991,
2178
2185
  RELEASE_TYPES: [
2179
2186
  "major",
2180
2187
  "premajor",
@@ -2184,7 +2191,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2184
2191
  "prepatch",
2185
2192
  "prerelease"
2186
2193
  ],
2187
- SEMVER_SPEC_VERSION,
2194
+ SEMVER_SPEC_VERSION: "2.0.0",
2188
2195
  FLAG_INCLUDE_PRERELEASE: 1,
2189
2196
  FLAG_LOOSE: 2
2190
2197
  };
@@ -2322,9 +2329,10 @@ var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2322
2329
  module.exports = class SemVer {
2323
2330
  constructor(version, options) {
2324
2331
  options = parseOptions(options);
2325
- if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
2326
- else version = version.version;
2327
- else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
2332
+ if (version instanceof SemVer) {
2333
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
2334
+ else version = version.version;
2335
+ } else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
2328
2336
  if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
2329
2337
  debug("SemVer", version, options);
2330
2338
  this.options = options;
@@ -2777,9 +2785,7 @@ var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2777
2785
  version.minor = 0;
2778
2786
  version.patch = 0;
2779
2787
  break;
2780
- case "minor":
2781
- version.patch = 0;
2782
- break;
2788
+ case "minor": version.patch = 0;
2783
2789
  }
2784
2790
  return version.format();
2785
2791
  };
@@ -2828,8 +2834,10 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2828
2834
  module.exports = class Range {
2829
2835
  constructor(range, options) {
2830
2836
  options = parseOptions(options);
2831
- if (range instanceof Range) if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
2832
- else return new Range(range.raw, options);
2837
+ if (range instanceof Range) {
2838
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
2839
+ else return new Range(range.raw, options);
2840
+ }
2833
2841
  if (range instanceof Comparator) {
2834
2842
  this.raw = range.value;
2835
2843
  this.set = [[range]];
@@ -2999,18 +3007,21 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2999
3007
  let ret;
3000
3008
  if (isX(M)) ret = "";
3001
3009
  else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
3002
- else if (isX(p)) if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
3003
- else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
3004
- else if (pr) {
3010
+ else if (isX(p)) {
3011
+ if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
3012
+ else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
3013
+ } else if (pr) {
3005
3014
  debug("replaceCaret pr", pr);
3006
- if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
3007
- else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
3008
- else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
3015
+ if (M === "0") {
3016
+ if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
3017
+ else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
3018
+ } else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
3009
3019
  } else {
3010
3020
  debug("no pr");
3011
- if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
3012
- else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
3013
- else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
3021
+ if (M === "0") {
3022
+ if (m === "0") ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
3023
+ else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
3024
+ } else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
3014
3025
  }
3015
3026
  debug("caret return", ret);
3016
3027
  return ret;
@@ -3032,9 +3043,10 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3032
3043
  const anyX = xp;
3033
3044
  if (gtlt === "=" && anyX) gtlt = "";
3034
3045
  pr = options.includePrerelease ? "-0" : "";
3035
- if (xM) if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
3036
- else ret = "*";
3037
- else if (gtlt && anyX) {
3046
+ if (xM) {
3047
+ if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
3048
+ else ret = "*";
3049
+ } else if (gtlt && anyX) {
3038
3050
  if (xm) m = 0;
3039
3051
  p = 0;
3040
3052
  if (gtlt === ">") {
@@ -3108,8 +3120,10 @@ var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3108
3120
  }
3109
3121
  constructor(comp, options) {
3110
3122
  options = parseOptions(options);
3111
- if (comp instanceof Comparator) if (comp.loose === !!options.loose) return comp;
3112
- else comp = comp.value;
3123
+ if (comp instanceof Comparator) {
3124
+ if (comp.loose === !!options.loose) return comp;
3125
+ else comp = comp.value;
3126
+ }
3113
3127
  comp = comp.trim().split(/\s+/).join(" ");
3114
3128
  debug("comparator", comp, options);
3115
3129
  this.options = options;
@@ -3429,11 +3443,15 @@ var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3429
3443
  const minimumVersion = [new Comparator(">=0.0.0")];
3430
3444
  const simpleSubset = (sub, dom, options) => {
3431
3445
  if (sub === dom) return true;
3432
- if (sub.length === 1 && sub[0].semver === ANY) if (dom.length === 1 && dom[0].semver === ANY) return true;
3433
- else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
3434
- else sub = minimumVersion;
3435
- if (dom.length === 1 && dom[0].semver === ANY) if (options.includePrerelease) return true;
3436
- else dom = minimumVersion;
3446
+ if (sub.length === 1 && sub[0].semver === ANY) {
3447
+ if (dom.length === 1 && dom[0].semver === ANY) return true;
3448
+ else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
3449
+ else sub = minimumVersion;
3450
+ }
3451
+ if (dom.length === 1 && dom[0].semver === ANY) {
3452
+ if (options.includePrerelease) return true;
3453
+ else dom = minimumVersion;
3454
+ }
3437
3455
  const eqSet = /* @__PURE__ */ new Set();
3438
3456
  let gt, lt;
3439
3457
  for (const c of sub) if (c.operator === ">" || c.operator === ">=") gt = higherGT(gt, c, options);
@@ -3677,6 +3695,42 @@ function parseBunUntrusted(output) {
3677
3695
  return match ? match[1] : null;
3678
3696
  });
3679
3697
  }
3698
+ /**
3699
+ * npm >= 12 skips dependency install scripts that the `allowScripts` allowlist
3700
+ * in package.json does not cover, and reports them on stderr:
3701
+ *
3702
+ * ```
3703
+ * npm warn install-scripts 2 packages had install scripts blocked because they are not covered by allowScripts:
3704
+ * npm warn install-scripts core-js@3.49.0 (postinstall: node -e "try{require('./postinstall')}catch(e){}")
3705
+ * npm warn install-scripts esbuild@0.28.1 (postinstall: node install.js)
3706
+ * ```
3707
+ *
3708
+ * npm 11.16 - 11.x print a similar warning ("install scripts not yet covered by
3709
+ * allowScripts") but still run the scripts, so only the npm 12 "blocked" wording
3710
+ * is parsed.
3711
+ */
3712
+ const NPM_BLOCKED_SCRIPTS_MARKER = "install scripts blocked because they are not covered by allowScripts";
3713
+ /**
3714
+ * A blocked-package entry line: `npm warn install-scripts <spec> (<lifecycle>:
3715
+ * <command>)`. Anchoring on the lifecycle name keeps the count line ("2 packages
3716
+ * had install scripts blocked ...") and the trailing hint line from matching.
3717
+ */
3718
+ const NPM_BLOCKED_ENTRY = /^npm warn install-scripts\s+(\S+) \((?:pre|post)?install:/u;
3719
+ /**
3720
+ * Parse the package names npm >= 12 reports as having blocked install scripts
3721
+ * from captured `npm install` / `npm ci` output. Strips version suffixes and
3722
+ * dedupes while preserving first-seen order. Returns `[]` when the warning is
3723
+ * absent (including the npm 11.x advisory variant, where scripts still run).
3724
+ */
3725
+ function parseNpmBlockedScripts(output) {
3726
+ if (!output) return [];
3727
+ const clean = stripVTControlCharacters(output);
3728
+ if (!clean.includes(NPM_BLOCKED_SCRIPTS_MARKER)) return [];
3729
+ return dedupeNames(clean.split("\n"), (rawLine) => {
3730
+ const match = rawLine.trim().match(NPM_BLOCKED_ENTRY);
3731
+ return match ? stripPackageVersion(match[1]) : null;
3732
+ });
3733
+ }
3680
3734
  const YARN_DISABLED_BUILDS_MARKER = "lists build scripts, but all build scripts have been disabled";
3681
3735
  /**
3682
3736
  * Yarn (Berry) gates build scripts when `enableScripts` is false: each gated
@@ -3705,12 +3759,14 @@ function yarnDescriptorName(descriptor) {
3705
3759
  /**
3706
3760
  * Parse the gated build-script package names from an install log, dispatching on
3707
3761
  * the package manager: pnpm prints `Ignored build scripts:`, yarn prints
3708
- * `... build scripts have been disabled`. bun is not parsed here (its blocked
3709
- * packages are queried separately via `bun pm untrusted`).
3762
+ * `... build scripts have been disabled`, npm >= 12 prints `... install scripts
3763
+ * blocked ...`. bun is not parsed here (its blocked packages are queried
3764
+ * separately via `bun pm untrusted`).
3710
3765
  */
3711
3766
  function parseInstallGatedBuilds(output, packageManager) {
3712
3767
  if (packageManager === PackageManager.pnpm) return parseIgnoredBuilds(output);
3713
3768
  if (packageManager === PackageManager.yarn) return parseYarnDisabledBuilds(output);
3769
+ if (packageManager === PackageManager.npm) return parseNpmBlockedScripts(output);
3714
3770
  return [];
3715
3771
  }
3716
3772
  /**
@@ -3755,14 +3811,15 @@ function pnpmSupportsPositionalApprove(version) {
3755
3811
  const GATED_BUILD_PACKAGE_MANAGERS = /* @__PURE__ */ new Set([
3756
3812
  PackageManager.pnpm,
3757
3813
  PackageManager.bun,
3758
- PackageManager.yarn
3814
+ PackageManager.yarn,
3815
+ PackageManager.npm
3759
3816
  ]);
3760
3817
  /**
3761
3818
  * Narrow a package manager's gated builds down to the ones worth surfacing
3762
3819
  * during `vp create`: packages the generated project depends on directly.
3763
3820
  * Transitive gated builds (e.g. `esbuild` pulled in by Vite) are noise the user
3764
3821
  * did not choose, so they are dropped. Returns `[]` for package managers that
3765
- * do not gate build scripts (npm, yarn classic), since there is nothing to
3822
+ * do not gate build scripts (npm < 12, yarn classic), since there is nothing to
3766
3823
  * approve.
3767
3824
  */
3768
3825
  function resolveApproveBuildTargets(projectDir, pendingBuilds, packageManager) {
@@ -3780,15 +3837,15 @@ function resolveApproveBuildTargets(projectDir, pendingBuilds, packageManager) {
3780
3837
  * Enumerate the packages whose build scripts a package manager gated during the
3781
3838
  * install, as raw names (still unfiltered by direct dependency).
3782
3839
  *
3783
- * - pnpm and yarn report them in their install output, so the names are parsed
3784
- * there (see {@link parseInstallGatedBuilds}) and passed in via
3840
+ * - pnpm, yarn, and npm >= 12 report them in their install output, so the names
3841
+ * are parsed there (see {@link parseInstallGatedBuilds}) and passed in via
3785
3842
  * `pendingBuildsFromInstall`.
3786
3843
  * - bun exits 0 and only prints a count, so `bun pm untrusted` is queried here.
3787
3844
  *
3788
3845
  * Other package managers run build scripts by default and return `[]`.
3789
3846
  */
3790
3847
  async function detectGatedBuilds(installCwd, packageManager, pendingBuildsFromInstall) {
3791
- if (packageManager === PackageManager.pnpm || packageManager === PackageManager.yarn) return pendingBuildsFromInstall ?? [];
3848
+ if (packageManager === PackageManager.pnpm || packageManager === PackageManager.yarn || packageManager === PackageManager.npm) return pendingBuildsFromInstall ?? [];
3792
3849
  if (packageManager === PackageManager.bun) {
3793
3850
  const { exitCode, stdout, stderr } = await runCommandSilently({
3794
3851
  command: process.env.VP_CLI_BIN ?? "vp",
@@ -3815,16 +3872,17 @@ function printApproveBuildsGuidance(targets, packageManager) {
3815
3872
  log.info(`These dependencies may not work until built. Enable them in the workspace root package.json (${accent("dependenciesMeta.<pkg>.built: true")}) and reinstall, or re-create with ${accent("--approve-builds")}.`);
3816
3873
  return;
3817
3874
  }
3818
- const command = packageManager === PackageManager.bun ? `vp pm approve-builds ${targets.join(" ")}` : "vp pm approve-builds";
3875
+ const command = packageManager === PackageManager.bun || packageManager === PackageManager.npm ? `vp pm approve-builds ${targets.join(" ")}` : "vp pm approve-builds";
3819
3876
  log.info(`These dependencies may not work until built. Run ${accent(command)} in the project to approve them, or re-create with ${accent("--approve-builds")}.`);
3820
3877
  }
3821
3878
  /**
3822
3879
  * Run a `vp` build/approval command and report the outcome through a spinner.
3823
- * On failure the approval has still been recorded (pnpm/bun config or yarn's
3824
- * `dependenciesMeta`), so the retry hint points back at `vp install`. Returns
3880
+ * On failure the approval has still been recorded (pnpm/bun/npm config or
3881
+ * yarn's `dependenciesMeta`), so the retry hint points back at `retryCommand`
3882
+ * (`vp install` unless the package manager needs an explicit rebuild). Returns
3825
3883
  * `true` when the command succeeded, `false` when the build exited non-zero.
3826
3884
  */
3827
- async function runBuildAndReport(args, cwd, packages, interactive, silent, extraEnv) {
3885
+ async function runBuildAndReport(args, cwd, packages, interactive, silent, extraEnv, retryCommand = "vp install") {
3828
3886
  const spinner = silent ? getSilentSpinner() : getSpinner(interactive);
3829
3887
  spinner.start(`Building ${packages.join(", ")}...`);
3830
3888
  const { exitCode, stdout, stderr } = await runCommandSilently({
@@ -3843,10 +3901,42 @@ async function runBuildAndReport(args, cwd, packages, interactive, silent, extra
3843
3901
  spinner.stop(`Build failed for ${packages.join(", ")}`);
3844
3902
  const output = `${stdout.toString()}\n${stderr.toString()}`.trim();
3845
3903
  if (output) log.info(lastLines(output, 20));
3846
- log.warn(`Build scripts failed for ${accent(packages.join(", "))}. They were approved; fix the build toolchain and run ${accent("vp install")} to retry.`);
3904
+ log.warn(`Build scripts failed for ${accent(packages.join(", "))}. They were approved; fix the build toolchain and run ${accent(retryCommand)} to retry.`);
3847
3905
  return false;
3848
3906
  }
3849
3907
  /**
3908
+ * Approve gated install scripts for npm >= 12, then run them. npm's approval
3909
+ * (`npm approve-scripts`, via `vp pm approve-builds`) only records the
3910
+ * `allowScripts` allowlist in package.json: scripts the install already skipped
3911
+ * do not run on approval, and a plain reinstall short-circuits on the
3912
+ * up-to-date tree without running them either. `npm rebuild` is what executes
3913
+ * the newly approved scripts, so approval and rebuild are two steps.
3914
+ */
3915
+ async function approveNpmScripts(installCwd, packages, interactive, silent) {
3916
+ const approveCommand = `vp pm approve-builds ${packages.join(" ")}`;
3917
+ const { exitCode, stdout, stderr } = await runCommandSilently({
3918
+ command: process.env.VP_CLI_BIN ?? "vp",
3919
+ args: [
3920
+ "pm",
3921
+ "approve-builds",
3922
+ ...packages
3923
+ ],
3924
+ cwd: installCwd,
3925
+ envs: process.env
3926
+ });
3927
+ if (exitCode !== 0) {
3928
+ const output = `${stdout.toString()}\n${stderr.toString()}`.trim();
3929
+ if (output) log.info(lastLines(output, 20));
3930
+ log.warn(`Approving build scripts failed for ${accent(packages.join(", "))}. Run ${accent(approveCommand)} in the project to retry.`);
3931
+ return false;
3932
+ }
3933
+ return runBuildAndReport([
3934
+ "pm",
3935
+ "rebuild",
3936
+ ...packages
3937
+ ], installCwd, packages, interactive, silent, void 0, `vp pm rebuild ${packages.join(" ")}`);
3938
+ }
3939
+ /**
3850
3940
  * Mark each package as build-allowed in yarn's `dependenciesMeta[<pkg>].built`,
3851
3941
  * preserving existing metadata. Guards against a non-object container or
3852
3942
  * per-package value so a hand-authored scalar doesn't corrupt package.json.
@@ -3887,8 +3977,8 @@ async function approveYarnBuilds(installCwd, packages, interactive, silent) {
3887
3977
  return runBuildAndReport(["install"], installCwd, packages, interactive, silent, { YARN_ENABLE_IMMUTABLE_INSTALLS: "false" });
3888
3978
  }
3889
3979
  /**
3890
- * Surface pnpm's gated build scripts after a `vp create` install and let the
3891
- * user act on them:
3980
+ * Surface the package manager's gated build scripts after a `vp create` install
3981
+ * and let the user act on them:
3892
3982
  * - `--approve-builds`: approve + build every target, no prompt.
3893
3983
  * - interactive: a default-off multiselect so each package is approved
3894
3984
  * individually (pnpm gates them for security, so nothing is opt-in by
@@ -3921,6 +4011,7 @@ async function approveBuilds(options) {
3921
4011
  return true;
3922
4012
  }
3923
4013
  if (packageManager === PackageManager.yarn) return approveYarnBuilds(cwd, selected, interactive, silent);
4014
+ if (packageManager === PackageManager.npm) return approveNpmScripts(cwd, selected, interactive, silent);
3924
4015
  if (packageManager === PackageManager.pnpm && !pnpmSupportsPositionalApprove(packageManagerVersion)) {
3925
4016
  printApproveBuildsGuidance(selected, packageManager);
3926
4017
  return !(autoApprove && !interactive);
@@ -3935,10 +4026,12 @@ async function approveBuilds(options) {
3935
4026
  //#region src/utils/yaml.ts
3936
4027
  var import_dist = require_dist();
3937
4028
  function readYamlFile(file) {
3938
- return (0, import_dist.parse)(fs.readFileSync(file, "utf-8"));
4029
+ const content = fs.readFileSync(file, "utf-8");
4030
+ return (0, import_dist.parse)(content);
3939
4031
  }
3940
4032
  function editYamlFile(file, callback) {
3941
- const doc = (0, import_dist.parseDocument)(fs.readFileSync(file, "utf-8"));
4033
+ const content = fs.readFileSync(file, "utf-8");
4034
+ const doc = (0, import_dist.parseDocument)(content);
3942
4035
  callback(doc);
3943
4036
  fs.writeFileSync(file, doc.toString({ singleQuote: true }), "utf-8");
3944
4037
  }
@@ -4226,7 +4319,7 @@ async function promptGitHooks(options) {
4226
4319
  if (options.hooks === true) return true;
4227
4320
  if (options.interactive) {
4228
4321
  const selected = await confirm({
4229
- message: "Set up pre-commit hooks to run formatting, linting, and type checking with auto-fixes?",
4322
+ message: options.message ?? "Set up pre-commit hooks to run formatting, linting, and type checking with auto-fixes?",
4230
4323
  initialValue: true
4231
4324
  });
4232
4325
  if (isCancel(selected)) {
@@ -4261,147 +4354,4 @@ function defaultInteractive() {
4261
4354
  return !process.env.CI && process.stdin.isTTY;
4262
4355
  }
4263
4356
  //#endregion
4264
- //#region src/utils/tsconfig.ts
4265
- /**
4266
- * Check if tsconfig.json has compilerOptions.baseUrl set.
4267
- * oxlint's TypeScript checker (tsgolint) does not support baseUrl,
4268
- * so typeAware/typeCheck must be disabled when it is present.
4269
- */
4270
- function hasBaseUrlInTsconfigFile(filePath) {
4271
- try {
4272
- return parse(fs.readFileSync(filePath, "utf-8"))?.compilerOptions?.baseUrl != null;
4273
- } catch {
4274
- return false;
4275
- }
4276
- }
4277
- const TSCONFIG_FILE_RE = /^tsconfig(\.[\w-]+)?\.json$/i;
4278
- function findTsconfigFiles(projectPath) {
4279
- try {
4280
- return fs.readdirSync(projectPath).filter((name) => TSCONFIG_FILE_RE.test(name)).map((name) => path.join(projectPath, name));
4281
- } catch {
4282
- return [];
4283
- }
4284
- }
4285
- function hasBaseUrlInTsconfig(projectPath) {
4286
- return findTsconfigFiles(projectPath).some((filePath) => hasBaseUrlInTsconfigFile(filePath));
4287
- }
4288
- function findTsconfigFilesWithBaseUrl(projectPath) {
4289
- return findTsconfigFiles(projectPath).filter((filePath) => hasBaseUrlInTsconfigFile(filePath));
4290
- }
4291
- async function confirmBaseUrlFix(interactive) {
4292
- if (!interactive) return true;
4293
- const command = [BASEURL_TSCONFIG_FIX_PACKAGE, ...createBaseUrlTsconfigFixArgs("<tsconfig path>")].join(" ");
4294
- const confirmed = await confirm({
4295
- message: "Your tsconfig contains `baseUrl`, which prevents enabling type-aware linting.\n " + styleText("gray", "`baseUrl` is deprecated in TypeScript 6.0 and removed in TypeScript 7.0.") + `\n Download and run the external \`${BASEURL_TSCONFIG_FIX_PACKAGE}\` fixer now?\n ` + styleText("gray", `Equivalent command: \`vp dlx ${command}\``),
4296
- initialValue: true
4297
- });
4298
- if (isCancel(confirmed)) cancelAndExit();
4299
- return confirmed;
4300
- }
4301
- async function fixBaseUrlInTsconfig(projectPath, options) {
4302
- const files = findTsconfigFilesWithBaseUrl(projectPath);
4303
- if (files.length === 0) return "not-needed";
4304
- if (!(options?.confirmed ?? await confirmBaseUrlFix(options?.interactive ?? false))) {
4305
- options?.onStatus?.("declined", projectPath);
4306
- return "declined";
4307
- }
4308
- try {
4309
- for (const filePath of files) {
4310
- const fixArgs = createBaseUrlTsconfigFixArgs(path.relative(projectPath, filePath) || filePath);
4311
- if (!options?.silent) log.info(`Running vp dlx ${BASEURL_TSCONFIG_FIX_PACKAGE} ${fixArgs.join(" ")}`);
4312
- const result = await runCommandSilently({
4313
- command: process.env.VP_CLI_BIN ?? "vp",
4314
- args: [
4315
- "dlx",
4316
- BASEURL_TSCONFIG_FIX_PACKAGE,
4317
- ...fixArgs
4318
- ],
4319
- cwd: projectPath,
4320
- envs: process.env
4321
- });
4322
- if (result.exitCode !== 0) {
4323
- if (!options?.silent) {
4324
- const output = `${result.stdout.toString()}${result.stderr.toString()}`.trim();
4325
- if (output) log.warn(output);
4326
- }
4327
- options?.onStatus?.("failed", projectPath);
4328
- return "failed";
4329
- }
4330
- }
4331
- if (hasBaseUrlInTsconfig(projectPath)) {
4332
- if (!options?.silent) log.warn("tsconfig still contains baseUrl after running the fixer.");
4333
- options?.onStatus?.("failed", projectPath);
4334
- return "failed";
4335
- }
4336
- } catch (error) {
4337
- if (!options?.silent && error instanceof Error) log.warn(error.message);
4338
- options?.onStatus?.("failed", projectPath);
4339
- return "failed";
4340
- }
4341
- options?.onStatus?.("fixed", projectPath);
4342
- return "fixed";
4343
- }
4344
- function removeDeprecatedTsconfigFalseOption(filePath, optionName) {
4345
- let text;
4346
- try {
4347
- text = fs.readFileSync(filePath, "utf-8");
4348
- } catch {
4349
- return false;
4350
- }
4351
- if (parse(text)?.compilerOptions?.[optionName] !== false) return false;
4352
- const edits = modify(text, ["compilerOptions", optionName], void 0, {});
4353
- if (edits.length === 0) return false;
4354
- const newText = applyEdits(text, edits);
4355
- fs.writeFileSync(filePath, newText);
4356
- return true;
4357
- }
4358
- const TSCONFIG_TYPE_REPLACEMENTS = { "tsdown/client": "vite-plus/pack/client" };
4359
- function hasTypesToRewriteInTsconfig(filePath) {
4360
- let text;
4361
- try {
4362
- text = fs.readFileSync(filePath, "utf-8");
4363
- } catch {
4364
- return false;
4365
- }
4366
- const types = parse(text)?.compilerOptions?.types;
4367
- return Array.isArray(types) && types.some((t) => typeof t === "string" && t in TSCONFIG_TYPE_REPLACEMENTS);
4368
- }
4369
- function hasVitestTypesInTsconfig(filePath) {
4370
- let text;
4371
- try {
4372
- text = fs.readFileSync(filePath, "utf-8");
4373
- } catch {
4374
- return false;
4375
- }
4376
- const types = parse(text)?.compilerOptions?.types;
4377
- return Array.isArray(types) && types.some((type) => typeof type === "string" ? type === "vitest" || type.startsWith("vitest/") : false);
4378
- }
4379
- function rewriteTypesInTsconfig(filePath) {
4380
- let text;
4381
- try {
4382
- text = fs.readFileSync(filePath, "utf-8");
4383
- } catch {
4384
- return false;
4385
- }
4386
- const types = parse(text)?.compilerOptions?.types;
4387
- if (!Array.isArray(types)) return false;
4388
- const toReplace = types.map((t, i) => typeof t === "string" && t in TSCONFIG_TYPE_REPLACEMENTS ? {
4389
- i,
4390
- newVal: TSCONFIG_TYPE_REPLACEMENTS[t]
4391
- } : null).filter((x) => x !== null);
4392
- if (toReplace.length === 0) return false;
4393
- let currentText = text;
4394
- for (let j = toReplace.length - 1; j >= 0; j--) {
4395
- const { i, newVal } = toReplace[j];
4396
- const edits = modify(currentText, [
4397
- "compilerOptions",
4398
- "types",
4399
- i
4400
- ], newVal, {});
4401
- if (edits.length > 0) currentText = applyEdits(currentText, edits);
4402
- }
4403
- fs.writeFileSync(filePath, currentText);
4404
- return true;
4405
- }
4406
- //#endregion
4407
- export { intro as A, runCommandSilently as B, resolveApproveBuildTargets as C, require_semver as D, PackageManager as E, spinner as F, text as I, require_picocolors as L, multiselect as M, outro as N, cancel as O, select as P, isCancel as R, detectGatedBuilds as S, DependencyType as T, require_cross_spawn as V, upgradeYarn as _, hasTypesToRewriteInTsconfig as a, scalarString as b, rewriteTypesInTsconfig as c, downloadPackageManager$1 as d, promptGitHooks as f, selectPackageManager as g, runViteInstall as h, hasBaseUrlInTsconfig as i, log as j, confirm as k, cancelAndExit as l, runViteFmt as m, findTsconfigFiles as n, hasVitestTypesInTsconfig as o, resolveGitInit as p, fixBaseUrlInTsconfig as r, removeDeprecatedTsconfigFalseOption as s, confirmBaseUrlFix as t, defaultInteractive as u, editYamlFile as v, getSpinner as w, approveBuilds as x, readYamlFile as y, runCommand$1 as z };
4357
+ export { isCancel as A, log as C, spinner as D, select as E, runCommandSilently as M, require_cross_spawn as N, text as O, intro as S, outro as T, getSpinner as _, resolveGitInit as a, require_semver as b, selectPackageManager as c, readYamlFile as d, scalarString as f, getSilentSpinner as g, resolveApproveBuildTargets as h, promptGitHooks as i, runCommand$1 as j, require_picocolors as k, upgradeYarn as l, detectGatedBuilds as m, defaultInteractive as n, runViteFmt as o, approveBuilds as p, downloadPackageManager$1 as r, runViteInstall as s, cancelAndExit as t, editYamlFile as u, DependencyType as v, multiselect as w, confirm as x, PackageManager as y };
@@ -1,15 +1,8 @@
1
- import { u as withConfigMetadataResolution } from "./define-config-C2KfLHpC.js";
1
+ import { s as VITE_CONFIG_FILES } from "./constants-CG513DRa.js";
2
+ import { u as withConfigMetadataResolution } from "./define-config-CV4bQG_8.js";
2
3
  import path from "node:path";
3
4
  import fs from "node:fs";
4
5
  //#region src/resolve-vite-config.ts
5
- const VITE_CONFIG_FILES = [
6
- "vite.config.js",
7
- "vite.config.mjs",
8
- "vite.config.ts",
9
- "vite.config.cjs",
10
- "vite.config.mts",
11
- "vite.config.cts"
12
- ];
13
6
  /**
14
7
  * Find a vite config file by walking up from `startDir` to `stopDir`.
15
8
  * Returns the absolute path of the first config file found, or undefined.
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
21
21
  value: mod,
22
22
  enumerable: true
23
23
  }) : target, mod));