vite-plus 0.2.8 → 0.3.0
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 +13 -6
- package/binding/index.cjs +57 -54
- package/binding/index.d.cts +100 -3
- package/dist/{agent-CI79DuSy.js → agent-Wqx0MPk0.js} +4 -188
- package/dist/bin.js +298 -278
- package/dist/command-CLJK5jGW.js +2 -0
- package/dist/command-CguLh2KL.js +471 -0
- package/dist/config/bin.js +29 -15
- package/dist/{constants-BppDcRc1.js → constants-Bn-U8o4v.js} +13 -3
- package/dist/create/bin.js +197 -247
- package/dist/{define-config-DPnHe1Mx.js → define-config-GXUdVT-0.js} +3 -3
- package/dist/{define-config-CEm_MtvJ.cjs → define-config-WiVlryJ2.cjs} +2 -2
- 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-CC4DqODz.js} +736 -153
- package/dist/{terminal-CrqqK8WT.js → help-BmKpeOP9.js} +27 -34
- package/dist/hooks/bin.d.ts +1 -0
- package/dist/hooks/bin.js +131 -0
- package/dist/hooks-DFqViZqZ.js +573 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-BU88uu6o.js → json-cULBl7Pi.js} +145 -139
- package/dist/migration/bin.js +67 -21
- package/dist/migration/compat/worker.js +1 -1
- package/dist/{oxlint-plugin-config-BHOzlwMw.js → oxlint-plugin-config-DX5ezKbB.js} +1 -1
- package/dist/oxlint-plugin.js +1 -1
- package/dist/pack-bin.js +5 -4
- package/dist/{package-hV-77cBb.js → package-CBe9EWPY.js} +2 -2
- package/dist/{prompts-DYap08te.js → prompts-DF3yU-eU.js} +136 -512
- package/dist/{report-BS7ULx7A.js → report-ZNR1Mk6h.js} +1 -0
- package/dist/{resolve-vite-config-EWXclqvV.js → resolve-vite-config-ipGb39Jo.js} +2 -9
- package/dist/staged/bin.js +299 -251
- package/dist/terminal-MKGAuy-p.js +39 -0
- 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-BVHG3DpR.js +2 -0
- package/dist/{tsconfig-CVUKLfL8.js → tsconfig-LD2QhQ0O.js} +5 -4
- package/dist/tsgolint-path.js +1 -1
- package/dist/version.js +5 -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/env.md +20 -6
- 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 +27 -1
- package/docs/guide/installer-env-vars.md +53 -6
- package/docs/guide/lint.md +3 -1
- package/docs/guide/migrate-rules.md +9 -0
- package/docs/guide/migrate.md +41 -4
- package/docs/guide/monorepo.md +4 -4
- package/docs/guide/test.md +8 -0
- package/docs/guide/troubleshooting.md +12 -4
- package/docs/guide/upgrade.md +75 -5
- package/package.json +36 -33
- package/rules/vite-tools.yml +0 -7
- package/dist/dist-DT25H9pj.js +0 -3
- package/docs/_data/team.ts +0 -131
- package/docs/package.json +0 -30
- package/docs/pnpm-lock.yaml +0 -4003
- package/docs/pnpm-workspace.yaml +0 -6
- package/docs/public/checkmark.svg +0 -1
- package/docs/public/cta-background.jpg +0 -0
- package/docs/public/favicon.svg +0 -1
- package/docs/public/icon.svg +0 -1
- package/docs/public/logo.svg +0 -1
- package/docs/public/og.jpg +0 -0
- package/docs/vite.config.ts +0 -17
- package/dist/{log-update-CoW8Z4Dl.js → log-update-DHZRyJ2m.js} +1 -1
- package/dist/{tsgolint-path-eMZT-oea.js → tsgolint-path-CbDReEOx.js} +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { shouldPrintVitePlusHeader, vitePlusHeader } from "../binding/index.js";
|
|
2
1
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
3
2
|
//#region src/utils/help.ts
|
|
3
|
+
const HELP_RIGHT_MARGIN = 4;
|
|
4
4
|
function toLines(value) {
|
|
5
5
|
if (!value) return [];
|
|
6
6
|
return Array.isArray(value) ? [...value] : [value];
|
|
@@ -12,12 +12,35 @@ function padVisible(value, width) {
|
|
|
12
12
|
const padding = Math.max(0, width - visibleLength(value));
|
|
13
13
|
return `${value}${" ".repeat(padding)}`;
|
|
14
14
|
}
|
|
15
|
+
function contentWidth() {
|
|
16
|
+
const terminalWidth = process.stdout.columns;
|
|
17
|
+
return Number.isFinite(terminalWidth) ? Math.max(0, terminalWidth - HELP_RIGHT_MARGIN) : Infinity;
|
|
18
|
+
}
|
|
19
|
+
function wrapLine(line, width) {
|
|
20
|
+
if (!Number.isFinite(width) || width <= 0 || visibleLength(line) <= width) return [line];
|
|
21
|
+
const content = line.trim();
|
|
22
|
+
if (!content) return [line];
|
|
23
|
+
const indent = line.slice(0, line.length - line.trimStart().length);
|
|
24
|
+
const output = [];
|
|
25
|
+
let current = indent;
|
|
26
|
+
for (const [, whitespace, word] of content.matchAll(/(\s*)(\S+)/gu)) {
|
|
27
|
+
const candidate = `${current}${current === indent ? "" : whitespace}${word}`;
|
|
28
|
+
if (current === indent || visibleLength(candidate) <= width) current = candidate;
|
|
29
|
+
else {
|
|
30
|
+
output.push(current);
|
|
31
|
+
current = `${indent}${word}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
output.push(current);
|
|
35
|
+
return output;
|
|
36
|
+
}
|
|
15
37
|
function renderRows(rows) {
|
|
16
38
|
if (rows.length === 0) return [];
|
|
17
39
|
const labelWidth = Math.max(...rows.map((row) => visibleLength(row.label)));
|
|
40
|
+
const descriptionWidth = contentWidth() - labelWidth - 4;
|
|
18
41
|
const output = [];
|
|
19
42
|
for (const row of rows) {
|
|
20
|
-
const descriptionLines = toLines(row.description);
|
|
43
|
+
const descriptionLines = toLines(row.description).flatMap((line) => wrapLine(line, descriptionWidth));
|
|
21
44
|
if (descriptionLines.length === 0) {
|
|
22
45
|
output.push(` ${row.label}`);
|
|
23
46
|
continue;
|
|
@@ -54,7 +77,7 @@ function renderCliDoc(doc, options = {}) {
|
|
|
54
77
|
if (output.length > 0) output.push("");
|
|
55
78
|
output.push(heading(section.title, color));
|
|
56
79
|
const lines = toLines(section.lines);
|
|
57
|
-
if (lines.length > 0) output.push(...lines.
|
|
80
|
+
if (lines.length > 0) output.push(...lines.flatMap((line) => wrapLine(renderMutedCommentSuffix(line, color), contentWidth())));
|
|
58
81
|
if (section.rows && section.rows.length > 0) output.push(...renderRows(section.rows));
|
|
59
82
|
}
|
|
60
83
|
if (doc.documentationUrl) {
|
|
@@ -65,34 +88,4 @@ function renderCliDoc(doc, options = {}) {
|
|
|
65
88
|
return output.join("\n");
|
|
66
89
|
}
|
|
67
90
|
//#endregion
|
|
68
|
-
|
|
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 };
|
|
91
|
+
export { renderCliDoc as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { t as renderCliDoc } from "../help-BmKpeOP9.js";
|
|
2
|
+
import { i as log, o as printHeader } from "../terminal-MKGAuy-p.js";
|
|
3
|
+
import { t as lib_default } from "../lib-L3DWSRQp.js";
|
|
4
|
+
import { i as enable, r as disable, t as DEFAULT_HOOKS_DIR, u as status } from "../hooks-DFqViZqZ.js";
|
|
5
|
+
//#region src/hooks/args.ts
|
|
6
|
+
const KNOWN_HOOKS_ARG_KEYS = /* @__PURE__ */ new Set([
|
|
7
|
+
"_",
|
|
8
|
+
"help",
|
|
9
|
+
"h",
|
|
10
|
+
"hooks-dir"
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* Reject leftover positionals and unknown flags before enable/disable mutate state.
|
|
14
|
+
*/
|
|
15
|
+
function unexpectedHooksArgsError(args) {
|
|
16
|
+
const extra = args._.map(String).filter((value) => value !== "");
|
|
17
|
+
if (extra.length > 0) return `Unexpected argument "${extra[0]}". Use --hooks-dir <path> to set a custom hooks directory.`;
|
|
18
|
+
for (const key of Object.keys(args)) if (!KNOWN_HOOKS_ARG_KEYS.has(key)) return `Unknown option "--${key}".`;
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/hooks/bin.ts
|
|
23
|
+
const SUBCOMMANDS = [
|
|
24
|
+
"enable",
|
|
25
|
+
"disable",
|
|
26
|
+
"status"
|
|
27
|
+
];
|
|
28
|
+
function isSubcommand(value) {
|
|
29
|
+
return !!value && SUBCOMMANDS.includes(value);
|
|
30
|
+
}
|
|
31
|
+
function printHelp() {
|
|
32
|
+
const helpMessage = renderCliDoc({
|
|
33
|
+
usage: "vp hooks <COMMAND> [OPTIONS]",
|
|
34
|
+
summary: "Manage the Vite+ Git hook dispatcher for this repository.",
|
|
35
|
+
documentationUrl: "https://viteplus.dev/guide/commit-hooks",
|
|
36
|
+
sections: [
|
|
37
|
+
{
|
|
38
|
+
title: "Commands",
|
|
39
|
+
rows: [
|
|
40
|
+
{
|
|
41
|
+
label: "enable",
|
|
42
|
+
description: "Install or refresh the hook dispatcher (sets core.hooksPath)"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: "disable",
|
|
46
|
+
description: "Disable hooks: unset core.hooksPath, remove <dir>/_, persist preference"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
label: "status",
|
|
50
|
+
description: "Show preference, core.hooksPath, and dispatcher state"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: "Options",
|
|
56
|
+
rows: [{
|
|
57
|
+
label: "--hooks-dir <path>",
|
|
58
|
+
description: `Custom hooks directory (default: ${DEFAULT_HOOKS_DIR}, or last used)`
|
|
59
|
+
}, {
|
|
60
|
+
label: "-h, --help",
|
|
61
|
+
description: "Show this help message"
|
|
62
|
+
}]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: "Environment",
|
|
66
|
+
rows: [{
|
|
67
|
+
label: "VP_GIT_HOOKS=0",
|
|
68
|
+
description: "Skip dispatcher install in enable (and skip hooks at commit time)"
|
|
69
|
+
}]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
title: "Examples",
|
|
73
|
+
lines: [
|
|
74
|
+
" vp hooks enable",
|
|
75
|
+
" vp hooks enable --hooks-dir .custom-hooks",
|
|
76
|
+
" vp hooks disable",
|
|
77
|
+
" vp hooks status"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
printHeader();
|
|
83
|
+
log(helpMessage);
|
|
84
|
+
}
|
|
85
|
+
function applyResult(result) {
|
|
86
|
+
if (result.message) log(result.message);
|
|
87
|
+
if (result.isError) process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
async function main() {
|
|
90
|
+
const raw = process.argv.slice(3);
|
|
91
|
+
const first = raw[0];
|
|
92
|
+
const wantsHelp = raw.includes("-h") || raw.includes("--help");
|
|
93
|
+
if (!first || first === "-h" || first === "--help") {
|
|
94
|
+
printHelp();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!isSubcommand(first)) {
|
|
98
|
+
log(`Unknown hooks command "${first}". Expected one of: ${SUBCOMMANDS.join(", ")}`);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
const subcommand = first;
|
|
102
|
+
const args = lib_default(raw.slice(1), {
|
|
103
|
+
boolean: ["help"],
|
|
104
|
+
string: ["hooks-dir"],
|
|
105
|
+
alias: { h: "help" }
|
|
106
|
+
});
|
|
107
|
+
if (args.help || wantsHelp) {
|
|
108
|
+
printHelp();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const unexpected = unexpectedHooksArgsError(args);
|
|
112
|
+
if (unexpected) {
|
|
113
|
+
log(unexpected);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
const dirFlag = args["hooks-dir"];
|
|
117
|
+
switch (subcommand) {
|
|
118
|
+
case "enable":
|
|
119
|
+
applyResult(enable(dirFlag));
|
|
120
|
+
return;
|
|
121
|
+
case "disable":
|
|
122
|
+
applyResult(disable(dirFlag));
|
|
123
|
+
return;
|
|
124
|
+
case "status":
|
|
125
|
+
applyResult(status(dirFlag));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
main();
|
|
130
|
+
//#endregion
|
|
131
|
+
export {};
|