vite-plus 0.1.2 → 0.1.3
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/binding/index.cjs +2 -0
- package/binding/index.d.cts +32 -0
- package/dist/global/{prompts-CAIahN1u.js → agent-BE4Xze8Q.js} +380 -1280
- package/dist/global/{browser-CY4NBwxR.js → browser-CBapUTD0.js} +579 -1023
- package/dist/global/{browser-DFpJ6sKb.js → browser-EZnNDcaO.js} +2 -3
- package/dist/global/{chunk-CtfvYSle.js → chunk-CgnkrU7a.js} +13 -22
- package/dist/global/{cli-truncate-BxinOqz5.js → cli-truncate-Da6Y8aM8.js} +25 -74
- package/dist/global/config.js +86 -166
- package/dist/global/create.js +353 -496
- package/dist/global/{terminal-Cb-NuRkb.js → help-BAGHa8fD.js} +22 -54
- package/dist/global/{json-Bfvtp2rL.js → json-BRdVJ52a.js} +24 -58
- package/dist/global/{lib-CibYHP32.js → lib-DxappLRQ.js} +19 -43
- package/dist/global/{log-update-DdU6_LCN.js → log-update-C8WCYCbc.js} +102 -281
- package/dist/global/mcp.js +97 -169
- package/dist/global/migrate.js +223 -83
- package/dist/global/{package-Pq2biU7_.js → package-YAMvX5PJ.js} +6 -13
- package/dist/global/{slice-ansi-BhwAwMdF.js → slice-ansi-Fap0ehe9.js} +21 -52
- package/dist/global/{src-C6aLHRsS.js → src-DwSJ0s0I.js} +28 -110
- package/dist/global/staged.js +654 -1521
- package/dist/global/{strip-ansi-BL-dgd7n.js → strip-ansi-CE-VDMdw.js} +20 -67
- package/dist/global/version.js +16 -37
- package/dist/global/{workspace-MTwAF3M9.js → workspace-lRm8huz4.js} +1625 -2816
- package/dist/global/wrap-ansi-Ou9oAs-a.js +3 -0
- package/dist/global/{wrap-ansi-Iww6Ak1s.js → wrap-ansi-eywLlPVQ.js} +29 -80
- package/dist/index.d.ts +1 -1
- package/dist/init-config.js +10 -2
- package/dist/utils/agent.d.ts +15 -1
- package/dist/utils/agent.js +104 -20
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -0
- package/dist/utils/editor.d.ts +16 -3
- package/dist/utils/editor.js +55 -17
- package/dist/utils/prompts.d.ts +32 -3
- package/dist/utils/prompts.js +32 -8
- package/dist/utils/tsconfig.d.ts +6 -0
- package/dist/utils/tsconfig.js +16 -0
- package/package.json +13 -13
- package/templates/monorepo/package.json +1 -1
- package/dist/global/wrap-ansi-BJxjUEQR.js +0 -4
- package/dist/oxlint-config.d.ts +0 -498
- package/dist/oxlint-config.js +0 -309
package/dist/global/config.js
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as lib_default } from "./lib-
|
|
3
|
-
import { i as writeJsonFile,
|
|
4
|
-
import {
|
|
1
|
+
import { A as select, C as cancel, E as log, M as Ct, O as note, _ as pkgRoot, c as defaultInteractive, d as promptGitHooks, i as getAgentById, n as detectAgents } from "./agent-BE4Xze8Q.js";
|
|
2
|
+
import { t as lib_default } from "./lib-DxappLRQ.js";
|
|
3
|
+
import { i as writeJsonFile, r as readJsonFile, s as VITE_PLUS_NAME } from "./json-BRdVJ52a.js";
|
|
4
|
+
import { r as log$1, t as renderCliDoc } from "./help-BAGHa8fD.js";
|
|
5
5
|
import { dirname, join, relative } from "node:path";
|
|
6
6
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { vitePlusHeader } from "../../binding/index.js";
|
|
8
8
|
import { spawnSync } from "node:child_process";
|
|
9
|
-
|
|
10
9
|
//#region src/utils/skills.ts
|
|
11
10
|
function parseSkills(skillsDir) {
|
|
12
|
-
if (!existsSync(skillsDir))
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
11
|
+
if (!existsSync(skillsDir)) return [];
|
|
15
12
|
const entries = readdirSync(skillsDir, { withFileTypes: true });
|
|
16
13
|
const skills = [];
|
|
17
14
|
for (const entry of entries) {
|
|
18
|
-
if (!entry.isDirectory())
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
15
|
+
if (!entry.isDirectory()) continue;
|
|
21
16
|
const skillMd = join(skillsDir, entry.name, "SKILL.md");
|
|
22
|
-
if (!existsSync(skillMd))
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
const content = readFileSync(skillMd, "utf-8");
|
|
26
|
-
const frontmatter = content.match(/^---\n([\s\S]*?)\n---/);
|
|
17
|
+
if (!existsSync(skillMd)) continue;
|
|
18
|
+
const frontmatter = readFileSync(skillMd, "utf-8").match(/^---\n([\s\S]*?)\n---/);
|
|
27
19
|
if (!frontmatter) {
|
|
28
20
|
log.warn(` Skipping ${entry.name}: SKILL.md is missing valid frontmatter`);
|
|
29
21
|
continue;
|
|
@@ -49,18 +41,14 @@ function pathExists(p) {
|
|
|
49
41
|
}
|
|
50
42
|
function linkSkills(root, skillsDir, skills, agentSkillsDir) {
|
|
51
43
|
const targetDir = join(root, agentSkillsDir);
|
|
52
|
-
if (!existsSync(targetDir)) {
|
|
53
|
-
mkdirSync(targetDir, { recursive: true });
|
|
54
|
-
}
|
|
44
|
+
if (!existsSync(targetDir)) mkdirSync(targetDir, { recursive: true });
|
|
55
45
|
let linked = 0;
|
|
56
46
|
for (const skill of skills) {
|
|
57
47
|
const linkPath = join(targetDir, skill.dirName);
|
|
58
|
-
const
|
|
59
|
-
const relativeTarget = relative(targetDir, sourcePath);
|
|
48
|
+
const relativeTarget = relative(targetDir, join(skillsDir, skill.dirName));
|
|
60
49
|
if (pathExists(linkPath)) {
|
|
61
50
|
try {
|
|
62
|
-
|
|
63
|
-
if (existing === relativeTarget) {
|
|
51
|
+
if (readlinkSync(linkPath) === relativeTarget) {
|
|
64
52
|
log.info(` ${skill.name} — already linked`);
|
|
65
53
|
continue;
|
|
66
54
|
}
|
|
@@ -88,21 +76,15 @@ function getStableSkillsDir(root) {
|
|
|
88
76
|
const resolvedSkillsDir = join(pkgRoot, "skills");
|
|
89
77
|
const logicalSkillsDir = join(root, "node_modules", VITE_PLUS_NAME, "skills");
|
|
90
78
|
try {
|
|
91
|
-
if (realpathSync(logicalSkillsDir) === realpathSync(resolvedSkillsDir))
|
|
92
|
-
return logicalSkillsDir;
|
|
93
|
-
}
|
|
79
|
+
if (realpathSync(logicalSkillsDir) === realpathSync(resolvedSkillsDir)) return logicalSkillsDir;
|
|
94
80
|
} catch {}
|
|
95
81
|
return resolvedSkillsDir;
|
|
96
82
|
}
|
|
97
83
|
function linkSkillsForSpecificAgents(root, agentConfigs) {
|
|
98
84
|
const skillsDir = getStableSkillsDir(root);
|
|
99
85
|
const skills = parseSkills(skillsDir);
|
|
100
|
-
if (skills.length === 0)
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
if (agentConfigs.length === 0) {
|
|
104
|
-
return 0;
|
|
105
|
-
}
|
|
86
|
+
if (skills.length === 0) return 0;
|
|
87
|
+
if (agentConfigs.length === 0) return 0;
|
|
106
88
|
let totalLinked = 0;
|
|
107
89
|
for (const agent of agentConfigs) {
|
|
108
90
|
log.info(`${agent.displayName} → ${agent.skillsDir}`);
|
|
@@ -110,16 +92,11 @@ function linkSkillsForSpecificAgents(root, agentConfigs) {
|
|
|
110
92
|
}
|
|
111
93
|
return totalLinked;
|
|
112
94
|
}
|
|
113
|
-
|
|
114
95
|
//#endregion
|
|
115
96
|
//#region src/config/agent.ts
|
|
116
97
|
function detectInstructionFilePath(root, agentConfigs) {
|
|
117
|
-
if (agentConfigs.some((a) => a.skillsDir === ".claude/skills"))
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
if (existsSync(join(root, "CLAUDE.md"))) {
|
|
121
|
-
return "CLAUDE.md";
|
|
122
|
-
}
|
|
98
|
+
if (agentConfigs.some((a) => a.skillsDir === ".claude/skills")) return "CLAUDE.md";
|
|
99
|
+
if (existsSync(join(root, "CLAUDE.md"))) return "CLAUDE.md";
|
|
123
100
|
return "AGENTS.md";
|
|
124
101
|
}
|
|
125
102
|
async function pickAgentWhenUndetected() {
|
|
@@ -152,19 +129,15 @@ async function pickAgentWhenUndetected() {
|
|
|
152
129
|
cancel("Setup cancelled.");
|
|
153
130
|
process.exit(0);
|
|
154
131
|
}
|
|
155
|
-
if (choice === "generic") {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
};
|
|
160
|
-
}
|
|
132
|
+
if (choice === "generic") return {
|
|
133
|
+
instructionFilePath: "AGENTS.md",
|
|
134
|
+
agents: []
|
|
135
|
+
};
|
|
161
136
|
const selected = getAgentById(choice);
|
|
162
|
-
if (!selected) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
};
|
|
167
|
-
}
|
|
137
|
+
if (!selected) return {
|
|
138
|
+
instructionFilePath: "AGENTS.md",
|
|
139
|
+
agents: []
|
|
140
|
+
};
|
|
168
141
|
return {
|
|
169
142
|
instructionFilePath: choice === "claude-code" ? "CLAUDE.md" : "AGENTS.md",
|
|
170
143
|
agents: [selected]
|
|
@@ -172,19 +145,15 @@ async function pickAgentWhenUndetected() {
|
|
|
172
145
|
}
|
|
173
146
|
async function resolveAgentSetup(root, interactive) {
|
|
174
147
|
const detected = detectAgents(root);
|
|
175
|
-
if (detected.length > 0 || !interactive) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
};
|
|
180
|
-
}
|
|
148
|
+
if (detected.length > 0 || !interactive) return {
|
|
149
|
+
instructionFilePath: detectInstructionFilePath(root, detected),
|
|
150
|
+
agents: detected
|
|
151
|
+
};
|
|
181
152
|
return pickAgentWhenUndetected();
|
|
182
153
|
}
|
|
183
154
|
function getOwnVersion() {
|
|
184
155
|
const pkg = JSON.parse(readFileSync(join(pkgRoot, "package.json"), "utf-8"));
|
|
185
|
-
if (typeof pkg.version !== "string")
|
|
186
|
-
throw new Error("vite-plus package.json is missing a \"version\" field");
|
|
187
|
-
}
|
|
156
|
+
if (typeof pkg.version !== "string") throw new Error("vite-plus package.json is missing a \"version\" field");
|
|
188
157
|
return pkg.version;
|
|
189
158
|
}
|
|
190
159
|
function readAgentPrompt() {
|
|
@@ -198,9 +167,7 @@ function hasExistingAgentInstructions(root) {
|
|
|
198
167
|
const fullPath = join(root, file);
|
|
199
168
|
if (existsSync(fullPath)) {
|
|
200
169
|
const content = readFileSync(fullPath, "utf-8");
|
|
201
|
-
if (MARKER_OPEN_RE.test(content))
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
170
|
+
if (MARKER_OPEN_RE.test(content)) return true;
|
|
204
171
|
}
|
|
205
172
|
}
|
|
206
173
|
return false;
|
|
@@ -209,8 +176,7 @@ function injectAgentBlock(root, filePath) {
|
|
|
209
176
|
const fullPath = join(root, filePath);
|
|
210
177
|
const version = getOwnVersion();
|
|
211
178
|
const promptContent = readAgentPrompt();
|
|
212
|
-
const
|
|
213
|
-
const block = `${openMarker}\n${promptContent}\n${MARKER_CLOSE}`;
|
|
179
|
+
const block = `${`<!--injected-by-vite-plus-v${version}-->`}\n${promptContent}\n${MARKER_CLOSE}`;
|
|
214
180
|
if (existsSync(fullPath)) {
|
|
215
181
|
const existing = readFileSync(fullPath, "utf-8");
|
|
216
182
|
const match = existing.match(MARKER_OPEN_RE);
|
|
@@ -221,16 +187,14 @@ function injectAgentBlock(root, filePath) {
|
|
|
221
187
|
}
|
|
222
188
|
const updated = existing.replace(MARKER_BLOCK_RE, block);
|
|
223
189
|
if (updated === existing) {
|
|
224
|
-
|
|
225
|
-
writeFileSync(fullPath, existing + separator + block + "\n");
|
|
190
|
+
writeFileSync(fullPath, existing + (existing.endsWith("\n") ? "\n" : "\n\n") + block + "\n");
|
|
226
191
|
log.warn(`Existing Vite+ block in ${filePath} was malformed; appended fresh block`);
|
|
227
192
|
} else {
|
|
228
193
|
writeFileSync(fullPath, updated);
|
|
229
194
|
log.success(`Updated Vite+ instructions in ${filePath} (v${match[1]} → v${version})`);
|
|
230
195
|
}
|
|
231
196
|
} else {
|
|
232
|
-
|
|
233
|
-
writeFileSync(fullPath, existing + separator + block + "\n");
|
|
197
|
+
writeFileSync(fullPath, existing + (existing.endsWith("\n") ? "\n" : "\n\n") + block + "\n");
|
|
234
198
|
log.success(`Added Vite+ instructions to ${filePath}`);
|
|
235
199
|
}
|
|
236
200
|
} else {
|
|
@@ -241,17 +205,13 @@ function injectAgentBlock(root, filePath) {
|
|
|
241
205
|
function writeMcpConfigForTarget(root, target) {
|
|
242
206
|
const fullPath = join(root, target.filePath);
|
|
243
207
|
let existing = {};
|
|
244
|
-
if (existsSync(fullPath)) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (!existing[target.rootKey]) {
|
|
253
|
-
existing[target.rootKey] = {};
|
|
208
|
+
if (existsSync(fullPath)) try {
|
|
209
|
+
existing = readJsonFile(fullPath);
|
|
210
|
+
} catch {
|
|
211
|
+
log.warn(`Could not parse ${target.filePath} — skipping MCP config. Please add the config manually.`);
|
|
212
|
+
return;
|
|
254
213
|
}
|
|
214
|
+
if (!existing[target.rootKey]) existing[target.rootKey] = {};
|
|
255
215
|
if (existing[target.rootKey]["vite-plus"]) {
|
|
256
216
|
log.info(`${target.filePath} already has vite-plus MCP config`);
|
|
257
217
|
return;
|
|
@@ -266,9 +226,7 @@ function writeMcpConfigForTarget(root, target) {
|
|
|
266
226
|
log.success(`Added vite-plus MCP server to ${target.filePath}`);
|
|
267
227
|
}
|
|
268
228
|
function pickMcpTarget(root, targets) {
|
|
269
|
-
if (targets.length === 1)
|
|
270
|
-
return targets[0];
|
|
271
|
-
}
|
|
229
|
+
if (targets.length === 1) return targets[0];
|
|
272
230
|
return targets.find((t) => existsSync(join(root, t.filePath))) ?? targets[0];
|
|
273
231
|
}
|
|
274
232
|
function setupMcpConfig(root, selectedAgents) {
|
|
@@ -281,29 +239,21 @@ function setupMcpConfig(root, selectedAgents) {
|
|
|
281
239
|
}
|
|
282
240
|
const mcpAgents = [];
|
|
283
241
|
const hintAgents = [];
|
|
284
|
-
for (const agent of selectedAgents) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
hint: agent.mcpHint
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
for (const { agent, hint } of hintAgents) {
|
|
298
|
-
log.info(`${agent.displayName}: ${hint}`);
|
|
299
|
-
}
|
|
242
|
+
for (const agent of selectedAgents) if (agent.mcpConfig) mcpAgents.push({
|
|
243
|
+
agent,
|
|
244
|
+
targets: agent.mcpConfig
|
|
245
|
+
});
|
|
246
|
+
else if (agent.mcpHint) hintAgents.push({
|
|
247
|
+
agent,
|
|
248
|
+
hint: agent.mcpHint
|
|
249
|
+
});
|
|
250
|
+
for (const { agent, hint } of hintAgents) log.info(`${agent.displayName}: ${hint}`);
|
|
300
251
|
for (const { agent, targets } of mcpAgents) {
|
|
301
252
|
const target = pickMcpTarget(root, targets);
|
|
302
253
|
log.info(`${agent.displayName} MCP target: ${target.filePath}`);
|
|
303
254
|
writeMcpConfigForTarget(root, target);
|
|
304
255
|
}
|
|
305
256
|
}
|
|
306
|
-
|
|
307
257
|
//#endregion
|
|
308
258
|
//#region src/config/hooks.ts
|
|
309
259
|
const HOOKS = [
|
|
@@ -324,15 +274,10 @@ const HOOKS = [
|
|
|
324
274
|
];
|
|
325
275
|
function nestedDirname(depth) {
|
|
326
276
|
let expr = "\"$0\"";
|
|
327
|
-
for (let i = 0; i < depth; i++) {
|
|
328
|
-
expr = `"$(dirname ${expr})"`;
|
|
329
|
-
}
|
|
277
|
+
for (let i = 0; i < depth; i++) expr = `"$(dirname ${expr})"`;
|
|
330
278
|
return expr;
|
|
331
279
|
}
|
|
332
280
|
function hookScript(dir) {
|
|
333
|
-
const segments = dir.split("/").filter((s) => s !== "" && s !== ".").length;
|
|
334
|
-
const depth = segments + 2;
|
|
335
|
-
const rootExpr = nestedDirname(depth);
|
|
336
281
|
return `#!/usr/bin/env sh
|
|
337
282
|
{ [ "$HUSKY" = "2" ] || [ "$VITE_GIT_HOOKS" = "2" ]; } && set -x
|
|
338
283
|
n=$(basename "$0")
|
|
@@ -346,7 +291,7 @@ i="\${XDG_CONFIG_HOME:-$HOME/.config}/vite-plus/hooks-init.sh"
|
|
|
346
291
|
|
|
347
292
|
{ [ "\${HUSKY-}" = "0" ] || [ "\${VITE_GIT_HOOKS-}" = "0" ]; } && exit 0
|
|
348
293
|
|
|
349
|
-
d=${
|
|
294
|
+
d=${nestedDirname(dir.split("/").filter((s) => s !== "" && s !== ".").length + 2)}
|
|
350
295
|
export PATH="$d/node_modules/.bin:$PATH"
|
|
351
296
|
sh -e "$s" "$@"
|
|
352
297
|
c=$?
|
|
@@ -356,31 +301,23 @@ c=$?
|
|
|
356
301
|
exit $c`;
|
|
357
302
|
}
|
|
358
303
|
function install(dir = ".vite-hooks") {
|
|
359
|
-
if (process.env.HUSKY === "0" || process.env.VITE_GIT_HOOKS === "0") {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
message: ".. not allowed",
|
|
368
|
-
isError: false
|
|
369
|
-
};
|
|
370
|
-
}
|
|
304
|
+
if (process.env.HUSKY === "0" || process.env.VITE_GIT_HOOKS === "0") return {
|
|
305
|
+
message: "skip install (git hooks disabled)",
|
|
306
|
+
isError: false
|
|
307
|
+
};
|
|
308
|
+
if (dir.includes("..")) return {
|
|
309
|
+
message: ".. not allowed",
|
|
310
|
+
isError: false
|
|
311
|
+
};
|
|
371
312
|
const prefixResult = spawnSync("git", ["rev-parse", "--show-prefix"]);
|
|
372
|
-
if (prefixResult.status == null) {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
message: ".git can't be found",
|
|
381
|
-
isError: false
|
|
382
|
-
};
|
|
383
|
-
}
|
|
313
|
+
if (prefixResult.status == null) return {
|
|
314
|
+
message: "git command not found",
|
|
315
|
+
isError: true
|
|
316
|
+
};
|
|
317
|
+
if (prefixResult.status !== 0) return {
|
|
318
|
+
message: ".git can't be found",
|
|
319
|
+
isError: false
|
|
320
|
+
};
|
|
384
321
|
const internal = (x = "") => join(dir, "_", x);
|
|
385
322
|
const rel = prefixResult.stdout.toString().trim().replace(/\/$/, "");
|
|
386
323
|
const target = rel ? `${rel}/${dir}/_` : `${dir}/_`;
|
|
@@ -390,42 +327,33 @@ function install(dir = ".vite-hooks") {
|
|
|
390
327
|
"core.hooksPath"
|
|
391
328
|
]);
|
|
392
329
|
const existingHooksPath = checkResult.status === 0 ? checkResult.stdout?.toString().trim() : "";
|
|
393
|
-
if (existingHooksPath && existingHooksPath !== target) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
};
|
|
398
|
-
}
|
|
330
|
+
if (existingHooksPath && existingHooksPath !== target) return {
|
|
331
|
+
message: `core.hooksPath is already set to "${existingHooksPath}", skipping`,
|
|
332
|
+
isError: false
|
|
333
|
+
};
|
|
399
334
|
const { status, stderr } = spawnSync("git", [
|
|
400
335
|
"config",
|
|
401
336
|
"core.hooksPath",
|
|
402
337
|
target
|
|
403
338
|
]);
|
|
404
|
-
if (status == null) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
message: "" + stderr,
|
|
413
|
-
isError: true
|
|
414
|
-
};
|
|
415
|
-
}
|
|
339
|
+
if (status == null) return {
|
|
340
|
+
message: "git command not found",
|
|
341
|
+
isError: true
|
|
342
|
+
};
|
|
343
|
+
if (status) return {
|
|
344
|
+
message: "" + stderr,
|
|
345
|
+
isError: true
|
|
346
|
+
};
|
|
416
347
|
rmSync(internal("husky.sh"), { force: true });
|
|
417
348
|
mkdirSync(internal(), { recursive: true });
|
|
418
349
|
writeFileSync(internal(".gitignore"), "*");
|
|
419
350
|
writeFileSync(internal("h"), hookScript(dir), { mode: 493 });
|
|
420
|
-
for (const hook of HOOKS) {
|
|
421
|
-
writeFileSync(internal(hook), `#!/usr/bin/env sh\n. "$(dirname "$0")/h"`, { mode: 493 });
|
|
422
|
-
}
|
|
351
|
+
for (const hook of HOOKS) writeFileSync(internal(hook), `#!/usr/bin/env sh\n. "$(dirname "$0")/h"`, { mode: 493 });
|
|
423
352
|
return {
|
|
424
353
|
message: "",
|
|
425
354
|
isError: false
|
|
426
355
|
};
|
|
427
356
|
}
|
|
428
|
-
|
|
429
357
|
//#endregion
|
|
430
358
|
//#region src/config/bin.ts
|
|
431
359
|
async function main() {
|
|
@@ -463,19 +391,14 @@ async function main() {
|
|
|
463
391
|
const hooksOnly = args["hooks-only"];
|
|
464
392
|
const interactive = defaultInteractive();
|
|
465
393
|
const root = process.cwd();
|
|
466
|
-
const
|
|
467
|
-
const isFirstHooksRun = !existsSync(join(root, hooksDir, "pre-commit"));
|
|
394
|
+
const isFirstHooksRun = !existsSync(join(root, dir ?? ".vite-hooks", "pre-commit"));
|
|
468
395
|
let shouldSetupHooks = true;
|
|
469
|
-
if (interactive && isFirstHooksRun && !dir) {
|
|
470
|
-
shouldSetupHooks = await promptGitHooks({ interactive });
|
|
471
|
-
}
|
|
396
|
+
if (interactive && isFirstHooksRun && !dir) shouldSetupHooks = await promptGitHooks({ interactive });
|
|
472
397
|
if (shouldSetupHooks) {
|
|
473
398
|
const { message, isError } = install(dir);
|
|
474
399
|
if (message) {
|
|
475
400
|
log$1(message);
|
|
476
|
-
if (isError)
|
|
477
|
-
process.exit(1);
|
|
478
|
-
}
|
|
401
|
+
if (isError) process.exit(1);
|
|
479
402
|
}
|
|
480
403
|
}
|
|
481
404
|
if (!hooksOnly && process.env.npm_lifecycle_event !== "prepare") {
|
|
@@ -483,11 +406,8 @@ async function main() {
|
|
|
483
406
|
const agentSetup = await resolveAgentSetup(root, interactive && isFirstAgentRun);
|
|
484
407
|
injectAgentBlock(root, agentSetup.instructionFilePath);
|
|
485
408
|
setupMcpConfig(root, agentSetup.agents);
|
|
486
|
-
if (agentSetup.agents.length > 0)
|
|
487
|
-
linkSkillsForSpecificAgents(root, agentSetup.agents);
|
|
488
|
-
}
|
|
409
|
+
if (agentSetup.agents.length > 0) linkSkillsForSpecificAgents(root, agentSetup.agents);
|
|
489
410
|
}
|
|
490
411
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
//#endregion
|
|
412
|
+
main();
|
|
413
|
+
//#endregion
|