vite-plus 0.2.8 → 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.
- package/AGENTS.md +7 -0
- package/README.md +9 -3
- package/binding/index.cjs +54 -54
- package/binding/index.d.cts +7 -3
- package/dist/{agent-CI79DuSy.js → agent-DQU8uS6P.js} +4 -188
- package/dist/bin.js +288 -278
- package/dist/config/bin.js +27 -15
- package/dist/{constants-BppDcRc1.js → constants-CG513DRa.js} +10 -2
- package/dist/create/bin.js +178 -204
- package/dist/{define-config-DPnHe1Mx.js → define-config-CV4bQG_8.js} +3 -3
- package/dist/{define-config-CEm_MtvJ.cjs → define-config-DyNLA_f0.cjs} +1 -1
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.js +1 -1
- package/dist/{dist-CSQWHI6y.js → dist-BDYZP12R.js} +193 -149
- package/dist/dist-Dqv1-Clg.js +3 -0
- package/dist/{editor-CGWdbLgD.js → editor-g4PosU99.js} +188 -108
- package/dist/hooks/bin.d.ts +1 -0
- package/dist/hooks/bin.js +130 -0
- package/dist/hooks-pNCBWtFT.js +570 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-BU88uu6o.js → json-qlK6UH0r.js} +38 -32
- package/dist/migration/bin.js +15 -18
- package/dist/{oxlint-plugin-config-BHOzlwMw.js → oxlint-plugin-config-BEZ9IUf7.js} +1 -1
- package/dist/oxlint-plugin.js +1 -1
- package/dist/pack-bin.js +1 -1
- package/dist/{package-hV-77cBb.js → package-B4T8RGMG.js} +2 -2
- package/dist/{prompts-DYap08te.js → prompts-CHz_98bJ.js} +142 -50
- package/dist/{resolve-vite-config-EWXclqvV.js → resolve-vite-config-Dmeyeyj-.js} +2 -9
- package/dist/staged/bin.js +224 -206
- package/dist/{terminal-CrqqK8WT.js → terminal-Bz-ps6rJ.js} +33 -3
- package/dist/test/browser/providers/playwright/context.d.ts +1 -1
- package/dist/test/browser/providers/playwright.d.ts +6 -6
- package/dist/test/browser/providers/preview/context.d.ts +1 -1
- package/dist/test/browser/providers/preview.d.ts +4 -4
- package/dist/test/browser/providers/webdriverio/context.d.ts +1 -1
- package/dist/test/browser/providers/webdriverio.d.ts +6 -6
- package/dist/test/browser-playwright/context.d.ts +1 -1
- package/dist/test/browser-playwright.d.ts +6 -6
- package/dist/test/browser-preview/context.d.ts +1 -1
- package/dist/test/browser-preview.d.ts +4 -4
- package/dist/test/browser-webdriverio/context.d.ts +1 -1
- package/dist/test/browser-webdriverio.d.ts +6 -6
- package/dist/test/context.d.ts +3 -3
- package/dist/test/locators.d.ts +1 -1
- package/dist/toolchain.d.ts +25 -0
- package/dist/toolchain.js +194 -0
- package/dist/toolchain.json +193 -0
- package/dist/{tsconfig-CVUKLfL8.js → tsconfig-7v_BHagU.js} +3 -3
- package/dist/tsgolint-path.js +1 -1
- package/dist/version.js +4 -4
- package/dist/versions.d.ts +3 -3
- package/dist/versions.js +6 -6
- package/docs/guide/ci.md +37 -4
- package/docs/guide/commit-hooks.md +87 -14
- package/docs/guide/create.md +7 -4
- package/docs/guide/fmt.md +2 -2
- package/docs/guide/github-actions-cache.md +5 -1
- package/docs/guide/ide-integration.md +61 -2
- package/docs/guide/index.md +3 -1
- package/docs/guide/install.md +25 -0
- package/docs/guide/installer-env-vars.md +12 -1
- package/docs/guide/lint.md +3 -1
- package/docs/guide/migrate.md +39 -2
- package/docs/guide/monorepo.md +4 -4
- package/docs/guide/troubleshooting.md +12 -4
- package/docs/guide/upgrade.md +27 -4
- package/docs/package.json +1 -1
- package/docs/pnpm-workspace.yaml +7 -0
- package/docs/vite.config.ts +3 -0
- package/package.json +18 -14
- package/rules/vite-tools.yml +0 -7
- package/dist/dist-DT25H9pj.js +0 -3
- package/dist/{tsgolint-path-eMZT-oea.js → tsgolint-path-CbDReEOx.js} +1 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { A as isCancel, C as log, E as select, w as multiselect } from "./prompts-
|
|
2
|
-
import path
|
|
1
|
+
import { A as isCancel, C as log, E as select, w as multiselect } from "./prompts-CHz_98bJ.js";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
|
-
import fs
|
|
4
|
+
import fs from "node:fs";
|
|
5
5
|
import fsPromises from "node:fs/promises";
|
|
6
|
-
import { spawnSync } from "node:child_process";
|
|
7
6
|
//#region src/utils/path.ts
|
|
8
7
|
function findPkgRoot() {
|
|
9
8
|
let dir = import.meta.dirname;
|
|
@@ -20,189 +19,6 @@ function displayRelative(to, from = process.cwd()) {
|
|
|
20
19
|
return path.relative(from, to).replaceAll("\\", "/");
|
|
21
20
|
}
|
|
22
21
|
//#endregion
|
|
23
|
-
//#region src/config/hooks.ts
|
|
24
|
-
const SUPPORTED_GIT_HOOK_NAMES = [
|
|
25
|
-
"pre-commit",
|
|
26
|
-
"pre-merge-commit",
|
|
27
|
-
"prepare-commit-msg",
|
|
28
|
-
"commit-msg",
|
|
29
|
-
"post-commit",
|
|
30
|
-
"applypatch-msg",
|
|
31
|
-
"pre-applypatch",
|
|
32
|
-
"post-applypatch",
|
|
33
|
-
"pre-rebase",
|
|
34
|
-
"post-rewrite",
|
|
35
|
-
"post-checkout",
|
|
36
|
-
"post-merge",
|
|
37
|
-
"pre-push",
|
|
38
|
-
"pre-auto-gc"
|
|
39
|
-
];
|
|
40
|
-
function nestedDirname(depth) {
|
|
41
|
-
let expr = "\"$0\"";
|
|
42
|
-
for (let i = 0; i < depth; i++) expr = `"$(dirname ${expr})"`;
|
|
43
|
-
return expr;
|
|
44
|
-
}
|
|
45
|
-
function hookScript(dir) {
|
|
46
|
-
const separators = process.platform === "win32" ? /[\\/]/ : /\//;
|
|
47
|
-
return `#!/usr/bin/env sh
|
|
48
|
-
{ [ "$HUSKY" = "2" ] || [ "$VP_GIT_HOOKS" = "2" ] || [ "$VITE_GIT_HOOKS" = "2" ]; } && set -x
|
|
49
|
-
n=$(basename "$0")
|
|
50
|
-
s=$(dirname "$(dirname "$0")")/$n
|
|
51
|
-
|
|
52
|
-
[ ! -f "$s" ] && exit 0
|
|
53
|
-
|
|
54
|
-
i="\${XDG_CONFIG_HOME:-$HOME/.config}/vite-plus/hooks-init.sh"
|
|
55
|
-
[ ! -f "$i" ] && i="\${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh"
|
|
56
|
-
[ -f "$i" ] && . "$i"
|
|
57
|
-
|
|
58
|
-
{ [ "\${HUSKY-}" = "0" ] || [ "\${VP_GIT_HOOKS-}" = "0" ] || [ "\${VITE_GIT_HOOKS-}" = "0" ]; } && exit 0
|
|
59
|
-
|
|
60
|
-
d=${nestedDirname(dir.split(separators).filter((s) => s !== "" && s !== ".").length + 2)}
|
|
61
|
-
__vp_shell=/bin/sh
|
|
62
|
-
[ -x "$__vp_shell" ] || __vp_shell=$(command -v sh)
|
|
63
|
-
|
|
64
|
-
if [ -n "\${VP_HOME-}" ]; then
|
|
65
|
-
__vp_bin="$VP_HOME/bin"
|
|
66
|
-
elif [ -n "\${HOME-}" ]; then
|
|
67
|
-
__vp_bin="$HOME/.vite-plus/bin"
|
|
68
|
-
else
|
|
69
|
-
__vp_bin=""
|
|
70
|
-
fi
|
|
71
|
-
[ -n "$__vp_bin" ] && [ -d "$__vp_bin" ] && export PATH="$PATH:$__vp_bin"
|
|
72
|
-
|
|
73
|
-
export PATH="$d/node_modules/.bin:$PATH"
|
|
74
|
-
"$__vp_shell" -e "$s" "$@"
|
|
75
|
-
c=$?
|
|
76
|
-
|
|
77
|
-
[ $c != 0 ] && echo "VITE+ - $n script failed (code $c)"
|
|
78
|
-
[ $c = 127 ] && echo "VITE+ - command not found in PATH=$PATH"
|
|
79
|
-
exit $c`;
|
|
80
|
-
}
|
|
81
|
-
function normalizeHooksPath(hooksPath) {
|
|
82
|
-
let normalized = normalize(hooksPath);
|
|
83
|
-
while (normalized.endsWith(sep)) normalized = normalized.slice(0, -1);
|
|
84
|
-
return normalized;
|
|
85
|
-
}
|
|
86
|
-
function findUnsafeHookInstallPath(root, dir) {
|
|
87
|
-
const projectRoot = resolve(root);
|
|
88
|
-
const internalPath = resolve(projectRoot, dir, "_");
|
|
89
|
-
const relativeInternalPath = relative(projectRoot, internalPath);
|
|
90
|
-
let currentPath = projectRoot;
|
|
91
|
-
for (const component of relativeInternalPath.split(sep).filter(Boolean)) {
|
|
92
|
-
currentPath = join(currentPath, component);
|
|
93
|
-
const stats = lstatSync(currentPath, { throwIfNoEntry: false });
|
|
94
|
-
if (!stats) return null;
|
|
95
|
-
if (stats.isSymbolicLink()) return {
|
|
96
|
-
kind: "symbolic",
|
|
97
|
-
relativePath: relative(projectRoot, currentPath)
|
|
98
|
-
};
|
|
99
|
-
if (!stats.isDirectory()) return {
|
|
100
|
-
kind: "not-directory",
|
|
101
|
-
relativePath: relative(projectRoot, currentPath)
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
for (const filename of [
|
|
105
|
-
"husky.sh",
|
|
106
|
-
".gitignore",
|
|
107
|
-
"h",
|
|
108
|
-
...SUPPORTED_GIT_HOOK_NAMES
|
|
109
|
-
]) {
|
|
110
|
-
const filePath = join(internalPath, filename);
|
|
111
|
-
const stats = lstatSync(filePath, { throwIfNoEntry: false });
|
|
112
|
-
if (!stats) continue;
|
|
113
|
-
if (stats.isSymbolicLink()) return {
|
|
114
|
-
kind: "symbolic",
|
|
115
|
-
relativePath: relative(projectRoot, filePath)
|
|
116
|
-
};
|
|
117
|
-
if (!stats.isFile()) return {
|
|
118
|
-
kind: "not-file",
|
|
119
|
-
relativePath: relative(projectRoot, filePath)
|
|
120
|
-
};
|
|
121
|
-
if (stats.nlink > 1) return {
|
|
122
|
-
kind: "linked",
|
|
123
|
-
relativePath: relative(projectRoot, filePath)
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
function describeUnsafeHookInstallPath(unsafePath) {
|
|
129
|
-
if (unsafePath.kind === "symbolic") return `symbolic hook path "${unsafePath.relativePath}" not allowed`;
|
|
130
|
-
if (unsafePath.kind === "linked") return `multiply linked hook path "${unsafePath.relativePath}" not allowed`;
|
|
131
|
-
if (unsafePath.kind === "not-directory") return `hook path "${unsafePath.relativePath}" is not a directory`;
|
|
132
|
-
return `hook path "${unsafePath.relativePath}" is not a file`;
|
|
133
|
-
}
|
|
134
|
-
function install(dir = ".vite-hooks") {
|
|
135
|
-
if (process.env.HUSKY === "0" || process.env.VP_GIT_HOOKS === "0" || process.env.VITE_GIT_HOOKS === "0") return {
|
|
136
|
-
message: "skip install (git hooks disabled)",
|
|
137
|
-
isError: false
|
|
138
|
-
};
|
|
139
|
-
if (dir.includes("..")) return {
|
|
140
|
-
message: ".. not allowed",
|
|
141
|
-
isError: false
|
|
142
|
-
};
|
|
143
|
-
if (isAbsolute(dir)) return {
|
|
144
|
-
message: "absolute hooks directory not allowed",
|
|
145
|
-
isError: false
|
|
146
|
-
};
|
|
147
|
-
if (relative(process.cwd(), resolve(process.cwd(), dir)) === "") return {
|
|
148
|
-
message: "hooks directory must be a project subdirectory",
|
|
149
|
-
isError: false
|
|
150
|
-
};
|
|
151
|
-
const unsafeInstallPath = findUnsafeHookInstallPath(process.cwd(), dir);
|
|
152
|
-
if (unsafeInstallPath) return {
|
|
153
|
-
message: describeUnsafeHookInstallPath(unsafeInstallPath),
|
|
154
|
-
isError: false
|
|
155
|
-
};
|
|
156
|
-
const prefixResult = spawnSync("git", ["rev-parse", "--show-prefix"]);
|
|
157
|
-
if (prefixResult.status == null) return {
|
|
158
|
-
message: "git command not found",
|
|
159
|
-
isError: true
|
|
160
|
-
};
|
|
161
|
-
if (prefixResult.status !== 0) return {
|
|
162
|
-
message: ".git can't be found",
|
|
163
|
-
isError: false
|
|
164
|
-
};
|
|
165
|
-
const internal = (x = "") => join(dir, "_", x);
|
|
166
|
-
const rel = prefixResult.stdout.toString().trim().replace(/\/$/, "");
|
|
167
|
-
const target = rel ? `${rel}/${dir}/_` : `${dir}/_`;
|
|
168
|
-
const checkResult = spawnSync("git", [
|
|
169
|
-
"config",
|
|
170
|
-
"--get",
|
|
171
|
-
"core.hooksPath"
|
|
172
|
-
]);
|
|
173
|
-
const existingHooksPath = checkResult.status === 0 ? checkResult.stdout?.toString().trim() : "";
|
|
174
|
-
if (existingHooksPath && normalizeHooksPath(existingHooksPath) !== normalizeHooksPath(target)) return {
|
|
175
|
-
message: `core.hooksPath is already set to "${existingHooksPath}", skipping`,
|
|
176
|
-
isError: false
|
|
177
|
-
};
|
|
178
|
-
rmSync(internal("husky.sh"), { force: true });
|
|
179
|
-
mkdirSync(internal(), { recursive: true });
|
|
180
|
-
writeFileSync(internal(".gitignore"), "*");
|
|
181
|
-
writeFileSync(internal("h"), hookScript(dir), { mode: 493 });
|
|
182
|
-
chmodSync(internal("h"), 493);
|
|
183
|
-
for (const hook of SUPPORTED_GIT_HOOK_NAMES) {
|
|
184
|
-
writeFileSync(internal(hook), `#!/usr/bin/env sh\n. "$(dirname "$0")/h"`, { mode: 493 });
|
|
185
|
-
chmodSync(internal(hook), 493);
|
|
186
|
-
}
|
|
187
|
-
const { status, stderr } = spawnSync("git", [
|
|
188
|
-
"config",
|
|
189
|
-
"core.hooksPath",
|
|
190
|
-
target
|
|
191
|
-
]);
|
|
192
|
-
if (status == null) return {
|
|
193
|
-
message: "git command not found",
|
|
194
|
-
isError: true
|
|
195
|
-
};
|
|
196
|
-
if (status) return {
|
|
197
|
-
message: "" + stderr,
|
|
198
|
-
isError: true
|
|
199
|
-
};
|
|
200
|
-
return {
|
|
201
|
-
message: "",
|
|
202
|
-
isError: false
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
//#endregion
|
|
206
22
|
//#region src/utils/agent.ts
|
|
207
23
|
const AGENTS = [
|
|
208
24
|
{
|
|
@@ -597,4 +413,4 @@ function getMarkedRange(content, startMarker, endMarker) {
|
|
|
597
413
|
};
|
|
598
414
|
}
|
|
599
415
|
//#endregion
|
|
600
|
-
export { selectAgentTargets as a, writeCopilotSetupWorkflow as c,
|
|
416
|
+
export { selectAgentTargets as a, writeCopilotSetupWorkflow as c, templatesDir as d, selectAgentTargetPaths as i, displayRelative as l, detectAgentConflicts as n, updateExistingAgentInstructions as o, detectExistingAgentTargetPaths as r, writeAgentInstructions as s, COPILOT_AGENT_ID as t, rulesDir as u };
|