vite-plus 0.2.6 → 0.2.8

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 (61) hide show
  1. package/AGENTS.md +4 -0
  2. package/LICENSE +5 -1
  3. package/README.md +1 -1
  4. package/bin/vpr +3 -2
  5. package/binding/index.cjs +193 -80
  6. package/binding/index.d.cts +99 -8
  7. package/dist/agent-CI79DuSy.js +600 -0
  8. package/dist/bin.js +1367 -11
  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 +13 -126
  12. package/dist/{constants-CaXMuYUG.js → constants-BppDcRc1.js} +1 -1
  13. package/dist/create/bin.js +90 -77
  14. package/dist/{define-config-iGV0CGUk.cjs → define-config-CEm_MtvJ.cjs} +1 -1
  15. package/dist/{define-config-hV8qyU8p.js → define-config-DPnHe1Mx.js} +2 -2
  16. package/dist/{define-config-eLQH9us2.d.ts → define-config-DWoAkNdp.d.ts} +16 -0
  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-CSQWHI6y.js} +3 -8
  21. package/dist/dist-DT25H9pj.js +3 -0
  22. package/dist/{agent-0gFJkIKu.js → editor-CGWdbLgD.js} +709 -579
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/{json-DiRs8ceZ.js → json-BU88uu6o.js} +2 -6
  27. package/dist/migration/bin.js +60 -50
  28. package/dist/{oxlint-plugin-config-CMSCIkks.js → oxlint-plugin-config-BHOzlwMw.js} +1 -1
  29. package/dist/oxlint-plugin.js +1 -1
  30. package/dist/pack-bin.js +2 -2
  31. package/dist/{package-CP5EUXlu.js → package-hV-77cBb.js} +2 -2
  32. package/dist/{tsconfig-Cac-NNdT.js → prompts-DYap08te.js} +32 -174
  33. package/dist/{resolve-vite-config-BY7PB-LW.js → resolve-vite-config-EWXclqvV.js} +1 -1
  34. package/dist/{rolldown-runtime-C7HZzL1F.js → rolldown-runtime-CMFfr-1z.js} +1 -1
  35. package/dist/staged/bin.js +20 -23
  36. package/dist/{help-YP84FSEz.js → terminal-CrqqK8WT.js} +39 -2
  37. package/dist/tsconfig-CVUKLfL8.js +151 -0
  38. package/dist/{tsgolint-path-B-yOos8p.js → tsgolint-path-eMZT-oea.js} +4 -2
  39. package/dist/tsgolint-path.js +1 -1
  40. package/dist/version.js +5 -5
  41. package/dist/versions.js +5 -5
  42. package/docs/config/index.md +13 -0
  43. package/docs/config/staged.md +2 -1
  44. package/docs/guide/build.md +1 -1
  45. package/docs/guide/ci.md +28 -3
  46. package/docs/guide/commit-hooks.md +76 -9
  47. package/docs/guide/dev.md +4 -0
  48. package/docs/guide/env.md +8 -4
  49. package/docs/guide/index.md +1 -1
  50. package/docs/guide/install.md +2 -0
  51. package/docs/guide/installer-env-vars.md +3 -3
  52. package/docs/guide/migrate.md +11 -3
  53. package/docs/guide/monorepo.md +94 -6
  54. package/docs/guide/run.md +15 -0
  55. package/docs/guide/test.md +4 -0
  56. package/docs/guide/troubleshooting.md +9 -5
  57. package/package.json +18 -24
  58. package/dist/dist-CtM2JRbM.js +0 -3
  59. package/dist/editor-D4T70tKk.js +0 -675
  60. package/dist/terminal-uTv0ZaMr.js +0 -33
  61. 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-CaXMuYUG.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-CrqqK8WT.js";
3
+ import { l as VITE_PLUS_VERSION } from "./constants-BppDcRc1.js";
4
+ import { a as writeJsonFile, i as readJsonFile } from "./json-BU88uu6o.js";
5
+ import { t as require_dist } from "./dist-CSQWHI6y.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) {
@@ -411,6 +413,11 @@ var require_cross_spawn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
411
413
  //#endregion
412
414
  //#region src/utils/command.ts
413
415
  var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
416
+ function exitCodeFromClose(code, signal) {
417
+ if (code !== null) return code;
418
+ const signalNumber = signal && constants$1.signals[signal];
419
+ return signalNumber ? 128 + signalNumber : 1;
420
+ }
414
421
  async function runCommandSilently(options) {
415
422
  const child = (0, import_cross_spawn.default)(options.command, options.args, {
416
423
  stdio: [
@@ -436,14 +443,14 @@ async function runCommandSilently(options) {
436
443
  child.stderr?.on("data", (data) => {
437
444
  stderr.push(data);
438
445
  });
439
- child.on("close", (code) => {
446
+ child.on("close", (code, signal) => {
440
447
  clearTimeout(timer);
441
448
  if (timedOut) {
442
449
  reject(/* @__PURE__ */ new Error(`Command timed out after ${options.timeoutMs}ms: ${options.command}`));
443
450
  return;
444
451
  }
445
452
  resolve({
446
- exitCode: code ?? 0,
453
+ exitCode: exitCodeFromClose(code, signal),
447
454
  stdout: Buffer.concat(stdout),
448
455
  stderr: Buffer.concat(stderr)
449
456
  });
@@ -461,8 +468,8 @@ async function runCommand$1(options) {
461
468
  env: options.envs
462
469
  });
463
470
  return new Promise((resolve, reject) => {
464
- child.on("close", (code) => {
465
- resolve({ exitCode: code ?? 0 });
471
+ child.on("close", (code, signal) => {
472
+ resolve({ exitCode: exitCodeFromClose(code, signal) });
466
473
  });
467
474
  child.on("error", (err) => {
468
475
  reject(err);
@@ -1162,9 +1169,7 @@ var a = class extends V {
1162
1169
  case "right":
1163
1170
  this.cursor = findCursor(this.cursor, 1, this.options);
1164
1171
  break;
1165
- case "space":
1166
- this.toggleValue();
1167
- break;
1172
+ case "space": this.toggleValue();
1168
1173
  }
1169
1174
  });
1170
1175
  }
@@ -1189,9 +1194,7 @@ let n$1 = class n extends V {
1189
1194
  this.cursor = findCursor(this.cursor, -1, this.options);
1190
1195
  break;
1191
1196
  case "down":
1192
- case "right":
1193
- this.cursor = findCursor(this.cursor, 1, this.options);
1194
- break;
1197
+ case "right": this.cursor = findCursor(this.cursor, 1, this.options);
1195
1198
  }
1196
1199
  this.changeValue();
1197
1200
  });
@@ -2167,14 +2170,12 @@ const text = (opts) => {
2167
2170
  //#endregion
2168
2171
  //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
2169
2172
  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
2173
  module.exports = {
2174
- MAX_LENGTH,
2174
+ MAX_LENGTH: 256,
2175
2175
  MAX_SAFE_COMPONENT_LENGTH: 16,
2176
- MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
2177
- MAX_SAFE_INTEGER,
2176
+ MAX_SAFE_BUILD_LENGTH: 250,
2177
+ MAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER ||
2178
+ /* istanbul ignore next */ 9007199254740991,
2178
2179
  RELEASE_TYPES: [
2179
2180
  "major",
2180
2181
  "premajor",
@@ -2184,7 +2185,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2184
2185
  "prepatch",
2185
2186
  "prerelease"
2186
2187
  ],
2187
- SEMVER_SPEC_VERSION,
2188
+ SEMVER_SPEC_VERSION: "2.0.0",
2188
2189
  FLAG_INCLUDE_PRERELEASE: 1,
2189
2190
  FLAG_LOOSE: 2
2190
2191
  };
@@ -2777,9 +2778,7 @@ var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2777
2778
  version.minor = 0;
2778
2779
  version.patch = 0;
2779
2780
  break;
2780
- case "minor":
2781
- version.patch = 0;
2782
- break;
2781
+ case "minor": version.patch = 0;
2783
2782
  }
2784
2783
  return version.format();
2785
2784
  };
@@ -3935,10 +3934,12 @@ async function approveBuilds(options) {
3935
3934
  //#region src/utils/yaml.ts
3936
3935
  var import_dist = require_dist();
3937
3936
  function readYamlFile(file) {
3938
- return (0, import_dist.parse)(fs.readFileSync(file, "utf-8"));
3937
+ const content = fs.readFileSync(file, "utf-8");
3938
+ return (0, import_dist.parse)(content);
3939
3939
  }
3940
3940
  function editYamlFile(file, callback) {
3941
- const doc = (0, import_dist.parseDocument)(fs.readFileSync(file, "utf-8"));
3941
+ const content = fs.readFileSync(file, "utf-8");
3942
+ const doc = (0, import_dist.parseDocument)(content);
3942
3943
  callback(doc);
3943
3944
  fs.writeFileSync(file, doc.toString({ singleQuote: true }), "utf-8");
3944
3945
  }
@@ -4226,7 +4227,7 @@ async function promptGitHooks(options) {
4226
4227
  if (options.hooks === true) return true;
4227
4228
  if (options.interactive) {
4228
4229
  const selected = await confirm({
4229
- message: "Set up pre-commit hooks to run formatting, linting, and type checking with auto-fixes?",
4230
+ message: options.message ?? "Set up pre-commit hooks to run formatting, linting, and type checking with auto-fixes?",
4230
4231
  initialValue: true
4231
4232
  });
4232
4233
  if (isCancel(selected)) {
@@ -4261,147 +4262,4 @@ function defaultInteractive() {
4261
4262
  return !process.env.CI && process.stdin.isTTY;
4262
4263
  }
4263
4264
  //#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 };
4265
+ 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, DependencyType as _, resolveGitInit as a, cancel as b, selectPackageManager as c, readYamlFile as d, scalarString as f, getSpinner 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, PackageManager as v, multiselect as w, confirm as x, require_semver as y };
@@ -1,4 +1,4 @@
1
- import { u as withConfigMetadataResolution } from "./define-config-hV8qyU8p.js";
1
+ import { u as withConfigMetadataResolution } from "./define-config-DPnHe1Mx.js";
2
2
  import path from "node:path";
3
3
  import fs from "node:fs";
4
4
  //#region src/resolve-vite-config.ts
@@ -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));
@@ -1,19 +1,18 @@
1
- import { r as __toESM, t as __commonJSMin } from "../rolldown-runtime-C7HZzL1F.js";
2
- import { a as printHeader, n as errorMsg, r as log } from "../terminal-uTv0ZaMr.js";
3
- import { a as resolveViteConfig } from "../resolve-vite-config-BY7PB-LW.js";
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";
4
4
  import { t as lib_default } from "../lib-L3DWSRQp.js";
5
- import { t as renderCliDoc } from "../help-YP84FSEz.js";
6
5
  import { createRequire } from "node:module";
7
6
  import path, { basename, delimiter, dirname, normalize, resolve } from "node:path";
8
- import { closeSync, constants, openSync, readSync, statSync } from "node:fs";
9
7
  import { formatWithOptions, inspect, promisify } from "node:util";
8
+ import { closeSync, constants, openSync, readSync, statSync } from "node:fs";
9
+ import { EOL } from "node:os";
10
10
  import { cwd } from "node:process";
11
11
  import l__default from "node:readline";
12
12
  import nodeTty from "node:tty";
13
13
  import crypto from "node:crypto";
14
14
  import { pathToFileURL } from "node:url";
15
- import { EOL } from "node:os";
16
- import fsPromises, { constants as constants$1 } from "node:fs/promises";
15
+ import fsPromises, { constants as constants$2 } from "node:fs/promises";
17
16
  import { PassThrough, Writable } from "node:stream";
18
17
  import { exec, spawn } from "node:child_process";
19
18
  import { pipeline } from "node:stream/promises";
@@ -1545,8 +1544,8 @@ var DefaultRenderer = class DefaultRenderer {
1545
1544
  this.logger.options.color = this.options.color;
1546
1545
  }
1547
1546
  async render() {
1548
- const { createLogUpdate } = await import("../log-update-DHZRyJ2m.js");
1549
- const { default: truncate } = await import("../cli-truncate-BVOlIIPy.js");
1547
+ const { createLogUpdate } = await import("../log-update-CoW8Z4Dl.js");
1548
+ const { default: truncate } = await import("../cli-truncate-Bg3RDXpi.js");
1550
1549
  const { default: wrap } = await import("../wrap-ansi-DUi52C6W.js");
1551
1550
  this.updater = createLogUpdate(this.logger.process.stdout);
1552
1551
  this.truncate = truncate;
@@ -1753,9 +1752,7 @@ var DefaultRenderer = class DefaultRenderer {
1753
1752
  });
1754
1753
  task.on(ListrTaskEventType.STATE, (state) => {
1755
1754
  switch (state) {
1756
- case ListrTaskState.RETRY || ListrTaskState.ROLLING_BACK:
1757
- this.buffer.bottom.delete(task.id);
1758
- break;
1755
+ case ListrTaskState.RETRY || ListrTaskState.ROLLING_BACK: this.buffer.bottom.delete(task.id);
1759
1756
  }
1760
1757
  });
1761
1758
  } else if (this.shouldOutputToOutputBar(task) && !this.buffer.output.has(task.id)) {
@@ -1765,9 +1762,7 @@ var DefaultRenderer = class DefaultRenderer {
1765
1762
  });
1766
1763
  task.on(ListrTaskEventType.STATE, (state) => {
1767
1764
  switch (state) {
1768
- case ListrTaskState.RETRY || ListrTaskState.ROLLING_BACK:
1769
- this.buffer.output.delete(task.id);
1770
- break;
1765
+ case ListrTaskState.RETRY || ListrTaskState.ROLLING_BACK: this.buffer.output.delete(task.id);
1771
1766
  }
1772
1767
  });
1773
1768
  }
@@ -3012,7 +3007,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3012
3007
  };
3013
3008
  module.exports = {
3014
3009
  DEFAULT_MAX_EXTGLOB_RECURSION,
3015
- MAX_LENGTH: 1024 * 64,
3010
+ MAX_LENGTH: 65536,
3016
3011
  POSIX_REGEX_SOURCE: {
3017
3012
  __proto__: null,
3018
3013
  alnum: "a-zA-Z0-9",
@@ -4898,13 +4893,14 @@ const generateTasks = ({ config, cwd = process.cwd(), files, relative = false })
4898
4893
  }));
4899
4894
  return Object.entries(config).map(([pattern, commands]) => {
4900
4895
  const isParentDirPattern = pattern.startsWith("../");
4896
+ const includedFiles = relativeFiles.filter((file) => {
4897
+ if (isParentDirPattern) return true;
4898
+ return !file.filepath.startsWith("..") && !path.isAbsolute(file.filepath);
4899
+ });
4901
4900
  const task = {
4902
4901
  pattern,
4903
4902
  commands,
4904
- fileList: matchFiles(relativeFiles.filter((file) => {
4905
- if (isParentDirPattern) return true;
4906
- return !file.filepath.startsWith("..") && !path.isAbsolute(file.filepath);
4907
- }), pattern, cwd).map((file) => ({
4903
+ fileList: matchFiles(includedFiles, pattern, cwd).map((file) => ({
4908
4904
  filepath: normalizePath(relative ? file.filepath : path.resolve(cwd, file.filepath)),
4909
4905
  status: file.status
4910
4906
  }))
@@ -5946,7 +5942,7 @@ const jsonParse = async (filename) => {
5946
5942
  const yamlParse = async (filename) => {
5947
5943
  const isPackageFile = PACKAGE_YAML_FILES.includes(path.basename(filename));
5948
5944
  try {
5949
- const [YAML, content] = await Promise.all([import("../dist-CtM2JRbM.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)), readFile(filename)]);
5945
+ const [YAML, content] = await Promise.all([import("../dist-DT25H9pj.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)), readFile(filename)]);
5950
5946
  const yaml = YAML.parse(content);
5951
5947
  return isPackageFile ? yaml[CONFIG_NAME] : yaml;
5952
5948
  } catch (error) {
@@ -6206,7 +6202,7 @@ const listConfigFilesFromFs = async ({ cwd }) => {
6206
6202
  debugLog$3("Listing possible configs from filesystem starting from \"%s\"...", cwd);
6207
6203
  const possibleConfigFiles = (await Promise.allSettled(CONFIG_FILE_NAMES.map(async (f) => {
6208
6204
  const filepath = path.join(cwd, f);
6209
- await fsPromises.access(filepath, constants$1.F_OK);
6205
+ await fsPromises.access(filepath, constants$2.F_OK);
6210
6206
  return filepath;
6211
6207
  }))).flatMap((r) => r.status === "fulfilled" ? [normalizePath(r.value)] : []);
6212
6208
  if (possibleConfigFiles.length > 0) {
@@ -6752,7 +6748,8 @@ if (args.help) {
6752
6748
  try {
6753
6749
  stagedConfig = (await resolveViteConfig(args.cwd ?? process.cwd())).staged;
6754
6750
  } catch (err) {
6755
- log(`Failed to load vite.config: ${err instanceof Error ? err.message : String(err)}`);
6751
+ const message = err instanceof Error ? err.message : String(err);
6752
+ log(`Failed to load vite.config: ${message}`);
6756
6753
  process.exit(1);
6757
6754
  }
6758
6755
  if (stagedConfig) options.config = stagedConfig;
@@ -1,3 +1,4 @@
1
+ import { shouldPrintVitePlusHeader, vitePlusHeader } from "../binding/index.js";
1
2
  import { stripVTControlCharacters, styleText } from "node:util";
2
3
  //#region src/utils/help.ts
3
4
  function toLines(value) {
@@ -31,6 +32,12 @@ function heading(label, color) {
31
32
  if (!color) return `${label}:`;
32
33
  return label === "Usage" ? styleText("bold", `${label}:`) : styleText(["blue", "bold"], `${label}:`);
33
34
  }
35
+ function renderMutedCommentSuffix(line, color) {
36
+ if (!color) return line;
37
+ const commentIndex = line.indexOf(" #");
38
+ if (commentIndex === -1) return line;
39
+ return `${line.slice(0, commentIndex)}${styleText("gray", line.slice(commentIndex))}`;
40
+ }
34
41
  function renderCliDoc(doc, options = {}) {
35
42
  const color = options.color ?? true;
36
43
  const output = [];
@@ -47,7 +54,7 @@ function renderCliDoc(doc, options = {}) {
47
54
  if (output.length > 0) output.push("");
48
55
  output.push(heading(section.title, color));
49
56
  const lines = toLines(section.lines);
50
- if (lines.length > 0) output.push(...lines);
57
+ if (lines.length > 0) output.push(...lines.map((line) => renderMutedCommentSuffix(line, color)));
51
58
  if (section.rows && section.rows.length > 0) output.push(...renderRows(section.rows));
52
59
  }
53
60
  if (doc.documentationUrl) {
@@ -58,4 +65,34 @@ function renderCliDoc(doc, options = {}) {
58
65
  return output.join("\n");
59
66
  }
60
67
  //#endregion
61
- export { renderCliDoc as t };
68
+ //#region src/utils/terminal.ts
69
+ function log(message) {
70
+ console.log(message);
71
+ }
72
+ /**
73
+ * Emit the Vite+ banner (header line + trailing blank line) to stdout.
74
+ * Gating (non-TTY, git hooks) lives in `shouldPrintVitePlusHeader` on the
75
+ * Rust side so both CLIs stay in sync.
76
+ */
77
+ function printHeader() {
78
+ if (!shouldPrintVitePlusHeader()) return;
79
+ log(vitePlusHeader());
80
+ log("");
81
+ }
82
+ function accent(text) {
83
+ return styleText("blue", text);
84
+ }
85
+ function muted(text) {
86
+ return styleText("gray", text);
87
+ }
88
+ function success(text) {
89
+ return styleText("green", text);
90
+ }
91
+ function warnMsg(msg) {
92
+ console.error(styleText(["yellow", "bold"], "warn:"), msg);
93
+ }
94
+ function errorMsg(msg) {
95
+ console.error(styleText(["red", "bold"], "error:"), msg);
96
+ }
97
+ //#endregion
98
+ export { printHeader as a, renderCliDoc as c, muted as i, errorMsg as n, success as o, log as r, warnMsg as s, accent as t };
@@ -0,0 +1,151 @@
1
+ import { t as BASEURL_TSCONFIG_FIX_PACKAGE, u as createBaseUrlTsconfigFixArgs } from "./constants-BppDcRc1.js";
2
+ import { A as isCancel, C as log, M as runCommandSilently, t as cancelAndExit, x as confirm } from "./prompts-DYap08te.js";
3
+ import { c as parse, o as applyEdits, s as modify } from "./json-BU88uu6o.js";
4
+ import path from "node:path";
5
+ import { styleText } from "node:util";
6
+ import fs from "node:fs";
7
+ //#region src/utils/tsconfig.ts
8
+ /**
9
+ * Check if tsconfig.json has compilerOptions.baseUrl set.
10
+ * oxlint's TypeScript checker (tsgolint) does not support baseUrl,
11
+ * so typeAware/typeCheck must be disabled when it is present.
12
+ */
13
+ function hasBaseUrlInTsconfigFile(filePath) {
14
+ try {
15
+ return parse(fs.readFileSync(filePath, "utf-8"))?.compilerOptions?.baseUrl != null;
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+ const TSCONFIG_FILE_RE = /^tsconfig(\.[\w-]+)?\.json$/i;
21
+ function findTsconfigFiles(projectPath) {
22
+ try {
23
+ return fs.readdirSync(projectPath).filter((name) => TSCONFIG_FILE_RE.test(name)).map((name) => path.join(projectPath, name));
24
+ } catch {
25
+ return [];
26
+ }
27
+ }
28
+ function hasBaseUrlInTsconfig(projectPath) {
29
+ return findTsconfigFiles(projectPath).some((filePath) => hasBaseUrlInTsconfigFile(filePath));
30
+ }
31
+ function findTsconfigFilesWithBaseUrl(projectPath) {
32
+ return findTsconfigFiles(projectPath).filter((filePath) => hasBaseUrlInTsconfigFile(filePath));
33
+ }
34
+ async function confirmBaseUrlFix(interactive) {
35
+ if (!interactive) return true;
36
+ const command = [BASEURL_TSCONFIG_FIX_PACKAGE, ...createBaseUrlTsconfigFixArgs("<tsconfig path>")].join(" ");
37
+ const confirmed = await confirm({
38
+ 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}\``),
39
+ initialValue: true
40
+ });
41
+ if (isCancel(confirmed)) cancelAndExit();
42
+ return confirmed;
43
+ }
44
+ async function fixBaseUrlInTsconfig(projectPath, options) {
45
+ const files = findTsconfigFilesWithBaseUrl(projectPath);
46
+ if (files.length === 0) return "not-needed";
47
+ if (!(options?.confirmed ?? await confirmBaseUrlFix(options?.interactive ?? false))) {
48
+ options?.onStatus?.("declined", projectPath);
49
+ return "declined";
50
+ }
51
+ try {
52
+ for (const filePath of files) {
53
+ const target = path.relative(projectPath, filePath) || filePath;
54
+ const fixArgs = createBaseUrlTsconfigFixArgs(target);
55
+ if (!options?.silent) log.info(`Running vp dlx ${BASEURL_TSCONFIG_FIX_PACKAGE} ${fixArgs.join(" ")}`);
56
+ const result = await runCommandSilently({
57
+ command: process.env.VP_CLI_BIN ?? "vp",
58
+ args: [
59
+ "dlx",
60
+ BASEURL_TSCONFIG_FIX_PACKAGE,
61
+ ...fixArgs
62
+ ],
63
+ cwd: projectPath,
64
+ envs: process.env
65
+ });
66
+ if (result.exitCode !== 0) {
67
+ if (!options?.silent) {
68
+ const output = `${result.stdout.toString()}${result.stderr.toString()}`.trim();
69
+ if (output) log.warn(output);
70
+ }
71
+ options?.onStatus?.("failed", projectPath);
72
+ return "failed";
73
+ }
74
+ }
75
+ if (hasBaseUrlInTsconfig(projectPath)) {
76
+ if (!options?.silent) log.warn("tsconfig still contains baseUrl after running the fixer.");
77
+ options?.onStatus?.("failed", projectPath);
78
+ return "failed";
79
+ }
80
+ } catch (error) {
81
+ if (!options?.silent && error instanceof Error) log.warn(error.message);
82
+ options?.onStatus?.("failed", projectPath);
83
+ return "failed";
84
+ }
85
+ options?.onStatus?.("fixed", projectPath);
86
+ return "fixed";
87
+ }
88
+ function removeDeprecatedTsconfigFalseOption(filePath, optionName) {
89
+ let text;
90
+ try {
91
+ text = fs.readFileSync(filePath, "utf-8");
92
+ } catch {
93
+ return false;
94
+ }
95
+ if (parse(text)?.compilerOptions?.[optionName] !== false) return false;
96
+ const edits = modify(text, ["compilerOptions", optionName], void 0, {});
97
+ if (edits.length === 0) return false;
98
+ const newText = applyEdits(text, edits);
99
+ fs.writeFileSync(filePath, newText);
100
+ return true;
101
+ }
102
+ const TSCONFIG_TYPE_REPLACEMENTS = { "tsdown/client": "vite-plus/pack/client" };
103
+ function hasTypesToRewriteInTsconfig(filePath) {
104
+ let text;
105
+ try {
106
+ text = fs.readFileSync(filePath, "utf-8");
107
+ } catch {
108
+ return false;
109
+ }
110
+ const types = parse(text)?.compilerOptions?.types;
111
+ return Array.isArray(types) && types.some((t) => typeof t === "string" && t in TSCONFIG_TYPE_REPLACEMENTS);
112
+ }
113
+ function hasVitestTypesInTsconfig(filePath) {
114
+ let text;
115
+ try {
116
+ text = fs.readFileSync(filePath, "utf-8");
117
+ } catch {
118
+ return false;
119
+ }
120
+ const types = parse(text)?.compilerOptions?.types;
121
+ return Array.isArray(types) && types.some((type) => typeof type === "string" ? type === "vitest" || type.startsWith("vitest/") : false);
122
+ }
123
+ function rewriteTypesInTsconfig(filePath) {
124
+ let text;
125
+ try {
126
+ text = fs.readFileSync(filePath, "utf-8");
127
+ } catch {
128
+ return false;
129
+ }
130
+ const types = parse(text)?.compilerOptions?.types;
131
+ if (!Array.isArray(types)) return false;
132
+ const toReplace = types.map((t, i) => typeof t === "string" && t in TSCONFIG_TYPE_REPLACEMENTS ? {
133
+ i,
134
+ newVal: TSCONFIG_TYPE_REPLACEMENTS[t]
135
+ } : null).filter((x) => x !== null);
136
+ if (toReplace.length === 0) return false;
137
+ let currentText = text;
138
+ for (let j = toReplace.length - 1; j >= 0; j--) {
139
+ const { i, newVal } = toReplace[j];
140
+ const edits = modify(currentText, [
141
+ "compilerOptions",
142
+ "types",
143
+ i
144
+ ], newVal, {});
145
+ if (edits.length > 0) currentText = applyEdits(currentText, edits);
146
+ }
147
+ fs.writeFileSync(filePath, currentText);
148
+ return true;
149
+ }
150
+ //#endregion
151
+ export { hasTypesToRewriteInTsconfig as a, rewriteTypesInTsconfig as c, hasBaseUrlInTsconfig as i, findTsconfigFiles as n, hasVitestTypesInTsconfig as o, fixBaseUrlInTsconfig as r, removeDeprecatedTsconfigFalseOption as s, confirmBaseUrlFix as t };
@@ -14,7 +14,8 @@ function resolveTsgolintExecutable(tsgolintBinPath, scriptUrl) {
14
14
  if (process.platform !== "win32") return tsgolintBinPath;
15
15
  const scriptDir = dirname(fileURLToPath(scriptUrl));
16
16
  const localBinDir = join(scriptDir, "..", "node_modules", ".bin");
17
- const projectBinDir = join(dirname(dirname(tsgolintBinPath)), "..", ".bin");
17
+ const oxlintTsgolintPackagePath = dirname(dirname(tsgolintBinPath));
18
+ const projectBinDir = join(oxlintTsgolintPackagePath, "..", ".bin");
18
19
  return resolveWindowsTsgolintExecutable([
19
20
  join(localBinDir, "tsgolint.exe"),
20
21
  join(localBinDir, "tsgolint.cmd"),
@@ -23,7 +24,8 @@ function resolveTsgolintExecutable(tsgolintBinPath, scriptUrl) {
23
24
  ], {
24
25
  exists: existsSync,
25
26
  getRealpathCandidates: () => {
26
- const realBinDir = join(dirname(realpathSync(join(scriptDir, ".."))), ".bin");
27
+ const realPkgDir = realpathSync(join(scriptDir, ".."));
28
+ const realBinDir = join(dirname(realPkgDir), ".bin");
27
29
  return [join(realBinDir, "tsgolint.exe"), join(realBinDir, "tsgolint.cmd")];
28
30
  }
29
31
  });
@@ -1,2 +1,2 @@
1
- import { n as resolveWindowsTsgolintExecutable, t as resolveTsgolintExecutable } from "./tsgolint-path-B-yOos8p.js";
1
+ import { n as resolveWindowsTsgolintExecutable, t as resolveTsgolintExecutable } from "./tsgolint-path-eMZT-oea.js";
2
2
  export { resolveTsgolintExecutable, resolveWindowsTsgolintExecutable };