vite-plus 0.2.7 → 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.
- package/LICENSE +5 -1
- package/bin/vpr +3 -2
- package/binding/index.cjs +193 -80
- package/binding/index.d.cts +99 -8
- package/dist/agent-CI79DuSy.js +600 -0
- package/dist/bin.js +1368 -13
- package/dist/{cli-truncate-BVOlIIPy.js → cli-truncate-Bg3RDXpi.js} +0 -2
- package/dist/client/bundledDevClient.mjs +1 -0
- package/dist/config/bin.js +13 -126
- package/dist/{constants-BsuzPowC.js → constants-BppDcRc1.js} +1 -1
- package/dist/create/bin.js +90 -77
- package/dist/{define-config-DLh9fE95.cjs → define-config-CEm_MtvJ.cjs} +1 -1
- package/dist/{define-config-C2KfLHpC.js → define-config-DPnHe1Mx.js} +2 -2
- package/dist/{define-config-eLQH9us2.d.ts → define-config-DWoAkNdp.d.ts} +16 -0
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.d.ts +1 -1
- package/dist/define-config.js +1 -1
- package/dist/{dist-CKz3vcoG.js → dist-CSQWHI6y.js} +3 -8
- package/dist/dist-DT25H9pj.js +3 -0
- package/dist/{agent-CPwWJ4qf.js → editor-CGWdbLgD.js} +690 -579
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-DiRs8ceZ.js → json-BU88uu6o.js} +2 -6
- package/dist/migration/bin.js +58 -48
- package/dist/{oxlint-plugin-config-Bxgc4cwF.js → oxlint-plugin-config-BHOzlwMw.js} +1 -1
- package/dist/oxlint-plugin.js +1 -1
- package/dist/pack-bin.js +1 -1
- package/dist/{package-Ds3uThLb.js → package-hV-77cBb.js} +2 -2
- package/dist/{tsconfig-Jia2vgMG.js → prompts-DYap08te.js} +32 -174
- package/dist/{resolve-vite-config-BiuLZnn8.js → resolve-vite-config-EWXclqvV.js} +1 -1
- package/dist/{rolldown-runtime-C7HZzL1F.js → rolldown-runtime-CMFfr-1z.js} +1 -1
- package/dist/staged/bin.js +20 -23
- package/dist/{help-YP84FSEz.js → terminal-CrqqK8WT.js} +39 -2
- package/dist/tsconfig-CVUKLfL8.js +151 -0
- package/dist/{tsgolint-path-B-yOos8p.js → tsgolint-path-eMZT-oea.js} +4 -2
- package/dist/tsgolint-path.js +1 -1
- package/dist/version.js +5 -5
- package/dist/versions.js +4 -4
- package/docs/config/index.md +13 -0
- package/docs/config/staged.md +2 -1
- package/docs/guide/commit-hooks.md +38 -20
- package/docs/guide/env.md +8 -4
- package/docs/guide/index.md +1 -1
- package/docs/guide/install.md +2 -0
- package/docs/guide/installer-env-vars.md +3 -3
- package/docs/guide/migrate.md +10 -2
- package/docs/guide/monorepo.md +94 -6
- package/docs/guide/troubleshooting.md +3 -2
- package/package.json +17 -23
- package/dist/dist-CtM2JRbM.js +0 -3
- package/dist/editor-BbT1lTNc.js +0 -675
- package/dist/terminal-uTv0ZaMr.js +0 -33
- package/dist/{log-update-DHZRyJ2m.js → log-update-CoW8Z4Dl.js} +1 -1
|
@@ -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));
|
package/dist/staged/bin.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { r as __toESM, t as __commonJSMin } from "../rolldown-runtime-
|
|
2
|
-
import { a as printHeader, n as errorMsg, r as log } from "../terminal-
|
|
3
|
-
import { a as resolveViteConfig } from "../resolve-vite-config-
|
|
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 {
|
|
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-
|
|
1549
|
-
const { default: truncate } = await import("../cli-truncate-
|
|
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:
|
|
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(
|
|
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-
|
|
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$
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
});
|
package/dist/tsgolint-path.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as resolveWindowsTsgolintExecutable, t as resolveTsgolintExecutable } from "./tsgolint-path-
|
|
1
|
+
import { n as resolveWindowsTsgolintExecutable, t as resolveTsgolintExecutable } from "./tsgolint-path-eMZT-oea.js";
|
|
2
2
|
export { resolveTsgolintExecutable, resolveWindowsTsgolintExecutable };
|
package/dist/version.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { i as hasVitePlusDependency, n as detectPackageMetadata } from "./package-
|
|
4
|
-
import { t as renderCliDoc } from "./help-YP84FSEz.js";
|
|
1
|
+
import { a as printHeader, c as renderCliDoc, r as log, t as accent } from "./terminal-CrqqK8WT.js";
|
|
2
|
+
import { m as version } from "./constants-BppDcRc1.js";
|
|
3
|
+
import { i as hasVitePlusDependency, n as detectPackageMetadata } from "./package-hV-77cBb.js";
|
|
5
4
|
import path from "node:path";
|
|
6
5
|
import fs from "node:fs";
|
|
7
6
|
//#region src/version.ts
|
|
@@ -30,7 +29,8 @@ function isVitePlusDeclaredInAncestors(cwd) {
|
|
|
30
29
|
while (true) {
|
|
31
30
|
const packageJsonPath = path.join(currentDir, "package.json");
|
|
32
31
|
try {
|
|
33
|
-
|
|
32
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
33
|
+
if (hasVitePlusDependency(pkg)) return true;
|
|
34
34
|
} catch {}
|
|
35
35
|
const parentDir = path.dirname(currentDir);
|
|
36
36
|
if (parentDir === currentDir) break;
|
package/dist/versions.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const versions = {
|
|
2
|
-
"vite": "8.
|
|
3
|
-
"rolldown": "1.2.
|
|
2
|
+
"vite": "8.2.0",
|
|
3
|
+
"rolldown": "1.2.2",
|
|
4
4
|
"tsdown": "0.22.14",
|
|
5
|
-
"oxlint": "1.
|
|
6
|
-
"oxfmt": "0.
|
|
5
|
+
"oxlint": "1.76.0",
|
|
6
|
+
"oxfmt": "0.61.0",
|
|
7
7
|
"oxlint-tsgolint": "7.0.2001",
|
|
8
8
|
"vitest": "4.1.10"
|
|
9
9
|
};
|
package/docs/config/index.md
CHANGED
|
@@ -33,3 +33,16 @@ Vite+ extends the basic Vite configuration with these additions:
|
|
|
33
33
|
- [`test`](/config/test) for Vitest
|
|
34
34
|
- [`pack`](/config/pack) for tsdown
|
|
35
35
|
- [`staged`](/config/staged) for staged-file checks
|
|
36
|
+
- [`defaultPackage`](#defaultpackage) for the default target of bare app commands at a workspace root
|
|
37
|
+
|
|
38
|
+
## defaultPackage
|
|
39
|
+
|
|
40
|
+
Default target directory for `vp dev` / `vp build` / `vp preview` / `vp pack` when you invoke them bare in the directory containing the config, an implicit [`vp -C <dir>`](/guide/monorepo#app-commands):
|
|
41
|
+
|
|
42
|
+
```ts [vite.config.ts]
|
|
43
|
+
export default {
|
|
44
|
+
defaultPackage: './frontend',
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
vp reads the values without executing the config, so `defaultPackage` also works at repository roots with no vite-plus dependency (for example a Laravel or Rails repo whose Vite app lives in `frontend/`, with vite-plus installed only there). That static read is why the values must stay plain string literals rather than expressions. An explicit `-C` or positional target always wins over the config.
|
package/docs/config/staged.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Staged Config
|
|
2
2
|
|
|
3
|
-
`vp staged`
|
|
3
|
+
`vp staged` reads staged-file rules from the `staged` block in `vite.config.ts`. See the
|
|
4
|
+
[Commit hooks guide](/guide/commit-hooks).
|
|
4
5
|
|
|
5
6
|
## Example
|
|
6
7
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Commit Hooks
|
|
2
2
|
|
|
3
|
-
Use `vp config` to install
|
|
3
|
+
Use `vp config` to install the Git hook dispatcher, and `vp staged` to run checks on staged
|
|
4
|
+
files.
|
|
4
5
|
|
|
5
6
|
## Overview
|
|
6
7
|
|
|
@@ -8,7 +9,7 @@ Vite+ supports commit hooks and staged-file checks without additional tooling.
|
|
|
8
9
|
|
|
9
10
|
Use:
|
|
10
11
|
|
|
11
|
-
- `vp config` to
|
|
12
|
+
- `vp config` to install generated hook infrastructure and related integrations
|
|
12
13
|
- `vp staged` to run checks against the files currently staged in Git
|
|
13
14
|
|
|
14
15
|
If you use [`vp create`](/guide/create) or [`vp migrate`](/guide/migrate), Vite+ prompts you to set this up for your project automatically.
|
|
@@ -17,7 +18,9 @@ If you use [`vp create`](/guide/create) or [`vp migrate`](/guide/migrate), Vite+
|
|
|
17
18
|
|
|
18
19
|
### `vp config`
|
|
19
20
|
|
|
20
|
-
`vp config` configures Vite+ for the current project. It installs
|
|
21
|
+
`vp config` configures Vite+ for the current project. It installs the generated Git hook
|
|
22
|
+
dispatcher and can also handle related project integration such as agent setup. By default,
|
|
23
|
+
project hooks are read from `.vite-hooks`:
|
|
21
24
|
|
|
22
25
|
```bash
|
|
23
26
|
vp config
|
|
@@ -26,16 +29,21 @@ vp config --no-hooks
|
|
|
26
29
|
vp config --no-agent
|
|
27
30
|
```
|
|
28
31
|
|
|
29
|
-
Use `--no-hooks` when you want `vp config` to leave
|
|
30
|
-
`--no-agent` when you want it to skip updates to existing coding agent instruction files. You
|
|
31
|
-
|
|
32
|
+
Use `--no-hooks` when you want `vp config` to leave the Git hook dispatcher unchanged. Use
|
|
33
|
+
`--no-agent` when you want it to skip updates to existing coding agent instruction files. You can
|
|
34
|
+
pass both flags when you want `vp config` to skip both setup steps.
|
|
32
35
|
|
|
33
|
-
You can also set `
|
|
36
|
+
You can also set `VP_GIT_HOOKS=0` to disable hook installation from lifecycle scripts such as
|
|
34
37
|
`prepare` or `postinstall`.
|
|
35
38
|
|
|
39
|
+
Project-owned hook scripts such as `.vite-hooks/pre-commit` should be committed to the repository.
|
|
40
|
+
The generated dispatcher and shims under `.vite-hooks/_` are ignored and recreated by `vp config`.
|
|
41
|
+
`vp config` does not create or modify project hook scripts or staged-file configuration.
|
|
42
|
+
|
|
36
43
|
### `vp staged`
|
|
37
44
|
|
|
38
|
-
`vp staged` runs staged-file checks using the `staged` config from `vite.config.ts`.
|
|
45
|
+
`vp staged` runs staged-file checks using the `staged` config from `vite.config.ts`. To run it
|
|
46
|
+
before each commit, add it to the project-owned pre-commit hook:
|
|
39
47
|
|
|
40
48
|
```bash
|
|
41
49
|
vp staged
|
|
@@ -43,6 +51,10 @@ vp staged --verbose
|
|
|
43
51
|
vp staged --fail-on-changes
|
|
44
52
|
```
|
|
45
53
|
|
|
54
|
+
```sh [.vite-hooks/pre-commit]
|
|
55
|
+
vp staged
|
|
56
|
+
```
|
|
57
|
+
|
|
46
58
|
## Configuration
|
|
47
59
|
|
|
48
60
|
Define staged-file checks in the `staged` block in `vite.config.ts`:
|
|
@@ -57,7 +69,12 @@ export default defineConfig({
|
|
|
57
69
|
});
|
|
58
70
|
```
|
|
59
71
|
|
|
60
|
-
This is the default Vite+ approach and should replace separate `lint-staged` configuration in most
|
|
72
|
+
This is the default Vite+ approach and should replace separate `lint-staged` configuration in most
|
|
73
|
+
projects. When you opt into hooks during `vp create`, Vite+ scaffolds both this configuration and
|
|
74
|
+
the corresponding pre-commit hook. During `vp migrate`, existing hook policy is preserved, and
|
|
75
|
+
the default is introduced only when no existing hook policy is found. Because
|
|
76
|
+
`vp staged` reads from `vite.config.ts`, your staged-file checks stay in the same place as your
|
|
77
|
+
lint, format, test, build, and task-runner config.
|
|
61
78
|
|
|
62
79
|
## Disabling Hooks in Specific Environments
|
|
63
80
|
|
|
@@ -65,13 +82,13 @@ The installed hooks check the environment on every run, so you can disable them
|
|
|
65
82
|
|
|
66
83
|
### Environment variable
|
|
67
84
|
|
|
68
|
-
Set `
|
|
85
|
+
Set `VP_GIT_HOOKS=0` in the environment of the process that runs `git commit`, and every Vite+ hook exits immediately without running:
|
|
69
86
|
|
|
70
87
|
```bash
|
|
71
|
-
|
|
88
|
+
VP_GIT_HOOKS=0 git commit -m "content update"
|
|
72
89
|
```
|
|
73
90
|
|
|
74
|
-
`HUSKY=0` is honored the same way for ecosystem tooling compatibility. Setting `
|
|
91
|
+
`HUSKY=0` is honored the same way for ecosystem tooling compatibility. Setting `VP_GIT_HOOKS=0` in an environment also keeps `vp config` from reinstalling hooks there when a lifecycle script such as `prepare` runs.
|
|
75
92
|
|
|
76
93
|
### Init script
|
|
77
94
|
|
|
@@ -83,27 +100,28 @@ Before checking the environment variable, each hook sources an init script if on
|
|
|
83
100
|
To disable hooks for a whole machine, create the init script and export the variable there:
|
|
84
101
|
|
|
85
102
|
```sh [~/.config/vite-plus/hooks-init.sh]
|
|
86
|
-
export
|
|
103
|
+
export VP_GIT_HOOKS=0
|
|
87
104
|
```
|
|
88
105
|
|
|
89
106
|
Because the hook itself reads this file, it works even when the committing process does not inherit your shell environment, for example if a daemon or web server is making commits.
|
|
90
107
|
|
|
91
108
|
## Removing commit hooks
|
|
92
109
|
|
|
93
|
-
To
|
|
110
|
+
To stop using the Vite+ hook dispatcher:
|
|
111
|
+
|
|
112
|
+
1. Remove `vp config` from the `prepare` or `postinstall` script in `package.json`.
|
|
94
113
|
|
|
95
|
-
|
|
114
|
+
2. Unset the Git hooks path that points at the Vite+ dispatcher:
|
|
96
115
|
|
|
97
116
|
```bash
|
|
98
117
|
git config --unset core.hooksPath
|
|
99
118
|
```
|
|
100
119
|
|
|
101
|
-
|
|
120
|
+
3. Remove the generated dispatcher directory (use your `--hooks-dir` value if you changed it):
|
|
102
121
|
|
|
103
122
|
```bash
|
|
104
|
-
rm -rf .vite-hooks
|
|
123
|
+
rm -rf .vite-hooks/_
|
|
105
124
|
```
|
|
106
125
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
4. Remove the `staged` block from `vite.config.ts` if it exists
|
|
126
|
+
Project-owned scripts such as `.vite-hooks/pre-commit` and the `staged` block in `vite.config.ts`
|
|
127
|
+
can remain for later use, or you can remove them separately if the project no longer needs them.
|
package/docs/guide/env.md
CHANGED
|
@@ -6,12 +6,16 @@
|
|
|
6
6
|
|
|
7
7
|
Managed mode is on by default, so `node`, `npm`, and related shims resolve through Vite+ and pick the right Node.js version for the current project.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Vite+ checks the current directory first, then walks up through its parents. The nearest directory
|
|
10
|
+
with a supported declaration wins. Within each directory, sources are checked in this order:
|
|
10
11
|
|
|
11
|
-
1. `.node-version` file
|
|
12
|
+
1. `.node-version` file
|
|
12
13
|
2. `devEngines.runtime` in `package.json` (the [devEngines standard](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#devengines))
|
|
13
14
|
3. `engines.node` in `package.json`
|
|
14
|
-
4.
|
|
15
|
+
4. `.nvmrc` file
|
|
16
|
+
|
|
17
|
+
If no directory declares a version, Vite+ uses the global default (`vp env default`) and then the
|
|
18
|
+
latest LTS.
|
|
15
19
|
|
|
16
20
|
`devEngines.runtime` ranks above `engines.node` because it declares the development-environment requirement, while `engines.node` is a consumer-facing support range. `vp env doctor` warns when declared sources conflict.
|
|
17
21
|
|
|
@@ -112,7 +116,7 @@ vp env print # Print shell snippet for this session
|
|
|
112
116
|
|
|
113
117
|
# Manage
|
|
114
118
|
vp env pin lts # Pin the project to the latest LTS release
|
|
115
|
-
vp env install # Install the version from .node-version or
|
|
119
|
+
vp env install # Install the version from .node-version, package.json, or .nvmrc
|
|
116
120
|
vp env default lts # Set the global default version
|
|
117
121
|
vp env use 20 # Use Node.js 20 for the current shell session
|
|
118
122
|
vp env use --unset # Remove the session override
|
package/docs/guide/index.md
CHANGED
|
@@ -92,7 +92,7 @@ Vite+ can handle the entire local frontend development cycle from starting a pro
|
|
|
92
92
|
|
|
93
93
|
- [`vp create`](/guide/create) creates new apps, packages, and monorepos.
|
|
94
94
|
- [`vp migrate`](/guide/migrate) moves existing projects onto Vite+.
|
|
95
|
-
- [`vp config`](/guide/commit-hooks)
|
|
95
|
+
- [`vp config`](/guide/commit-hooks) installs the Git hook dispatcher and configures agent integration.
|
|
96
96
|
- [`vp staged`](/guide/commit-hooks) runs checks on staged files.
|
|
97
97
|
- [`vp install`](/guide/install) installs dependencies with the right package manager.
|
|
98
98
|
- [`vp env`](/guide/env) manages Node.js versions.
|
package/docs/guide/install.md
CHANGED
|
@@ -69,6 +69,8 @@ Use the `-g` flag for installing, updating or removing globally installed packag
|
|
|
69
69
|
- `vp list -g [pkg]` lists global packages
|
|
70
70
|
- `vp outdated -g [pkg]` prints outdated packages
|
|
71
71
|
|
|
72
|
+
Updates keep the version spec a package was installed with: a package installed from a dist-tag (e.g. `vp install -g some-pkg@nightly`) updates to the newest version of that tag, and a version range stays within the range. Reinstall with a different spec (e.g. `vp update -g some-pkg@latest`) to switch, or pass `--latest` to `vp update -g` to move packages to the `latest` tag and clear their recorded specs. `vp outdated -g` reports both the newest version matching the recorded spec (`Wanted`) and the newest version on the `latest` tag.
|
|
73
|
+
|
|
72
74
|
::: warning
|
|
73
75
|
These commands do **NOT** interact with the underlying package manager's global installation directory.
|
|
74
76
|
|
|
@@ -147,14 +147,14 @@ Vite+ sets additional `VP_*` variables during shim dispatch and shell integratio
|
|
|
147
147
|
|
|
148
148
|
## Logging and Debugging
|
|
149
149
|
|
|
150
|
-
### `
|
|
150
|
+
### `VP_LOG`
|
|
151
151
|
|
|
152
152
|
- **Purpose**: Log filter string for `tracing_subscriber`
|
|
153
153
|
- **Default**: None
|
|
154
154
|
- **Example**:
|
|
155
155
|
```bash
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
VP_LOG=debug vp dev
|
|
157
|
+
VP_LOG=vite_task=trace vp build
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
### `VP_DEBUG_SHIM`
|
package/docs/guide/migrate.md
CHANGED
|
@@ -168,11 +168,19 @@ export default defineConfig({
|
|
|
168
168
|
});
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
When no existing hook policy owns the workflow, `vp migrate` can move supported lint-staged rules
|
|
172
|
+
and remove the old configuration and dependency. If an existing hook tool is preserved, keep
|
|
173
|
+
lint-staged in place until you convert that hook policy manually. See the
|
|
174
|
+
[Commit hooks guide](/guide/commit-hooks) and [Staged config reference](/config/staged) for details.
|
|
172
175
|
|
|
173
176
|
### Git hook tools
|
|
174
177
|
|
|
175
|
-
The `vp migrate` command
|
|
178
|
+
The `vp migrate` command does not automatically convert Husky setups. When Husky is detected,
|
|
179
|
+
Vite+ leaves its hooks, lifecycle scripts, configuration, and dependencies unchanged and shows a
|
|
180
|
+
warning. You can migrate the project manually using the [Commit hooks guide](/guide/commit-hooks).
|
|
181
|
+
|
|
182
|
+
Existing project-owned Vite+ hooks are also preserved. The default staged workflow is introduced
|
|
183
|
+
only when no existing hook policy is found.
|
|
176
184
|
|
|
177
185
|
If your project currently uses `lefthook`, `simple-git-hooks`, or `yorkie`, `vp migrate` will leave your existing configuration alone and show a warning. This happens even if you choose to set up hooks during the prompt or include the `--hooks` flag.
|
|
178
186
|
|