vite-plus 0.1.7 → 0.1.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/README.md +2 -1
- package/dist/bin.js +11 -2
- package/dist/config/bin.js +1 -0
- package/dist/global/{agent-CpNB3GIY.js → agent-CA64n2mH.js} +1 -1
- package/dist/global/config.js +3 -2
- package/dist/global/create.js +28 -54
- package/dist/global/{help-BAGHa8fD.js → help-CbTzUdXc.js} +10 -2
- package/dist/global/migrate.js +44 -3
- package/dist/global/staged.js +4 -2
- package/dist/global/version.js +1 -1
- package/dist/global/{workspace-pvS7F6d2.js → workspace-CpFQmwjZ.js} +2 -12
- package/dist/init-config.js +1 -23
- package/dist/run-config.d.ts +4 -6
- package/dist/staged/bin.js +4 -2
- package/dist/utils/editor.js +1 -1
- package/dist/utils/help.d.ts +1 -0
- package/dist/utils/help.js +12 -1
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Install Vite+ globally as `vp`:
|
|
|
29
29
|
For Linux or macOS:
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
curl -fsSL https://
|
|
32
|
+
curl -fsSL https://vite.plus | bash
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
For Windows:
|
|
@@ -138,6 +138,7 @@ Vite+ automatically wraps your package manager (pnpm, npm, or Yarn) based on `pa
|
|
|
138
138
|
#### Maintain
|
|
139
139
|
|
|
140
140
|
- **upgrade** - Update `vp` itself to the latest version
|
|
141
|
+
- **implode** - Remove `vp` and all related data
|
|
141
142
|
|
|
142
143
|
### Scaffolding your first Vite+ project
|
|
143
144
|
|
package/dist/bin.js
CHANGED
|
@@ -19,7 +19,16 @@ import { pack } from './resolve-pack.js';
|
|
|
19
19
|
import { test } from './resolve-test.js';
|
|
20
20
|
import { resolveUniversalViteConfig } from './resolve-vite-config.js';
|
|
21
21
|
import { vite } from './resolve-vite.js';
|
|
22
|
-
import { accent, log } from './utils/terminal.js';
|
|
22
|
+
import { accent, errorMsg, log } from './utils/terminal.js';
|
|
23
|
+
function getErrorMessage(err) {
|
|
24
|
+
if (err instanceof Error) {
|
|
25
|
+
return err.message;
|
|
26
|
+
}
|
|
27
|
+
if (typeof err === 'object' && err && 'message' in err && typeof err.message === 'string') {
|
|
28
|
+
return err.message;
|
|
29
|
+
}
|
|
30
|
+
return String(err);
|
|
31
|
+
}
|
|
23
32
|
// Parse command line arguments
|
|
24
33
|
let args = process.argv.slice(2);
|
|
25
34
|
// Transform `vp help [command]` into `vp [command] --help`
|
|
@@ -100,7 +109,7 @@ else {
|
|
|
100
109
|
process.exit(finalExitCode);
|
|
101
110
|
}
|
|
102
111
|
catch (err) {
|
|
103
|
-
|
|
112
|
+
errorMsg(getErrorMessage(err));
|
|
104
113
|
process.exit(1);
|
|
105
114
|
}
|
|
106
115
|
}
|
package/dist/config/bin.js
CHANGED
|
@@ -23,6 +23,7 @@ async function main() {
|
|
|
23
23
|
const helpMessage = renderCliDoc({
|
|
24
24
|
usage: 'vp config [OPTIONS]',
|
|
25
25
|
summary: 'Configure Vite+ for the current project (hooks + agent integration).',
|
|
26
|
+
documentationUrl: 'https://viteplus.dev/guide/commit-hooks',
|
|
26
27
|
sections: [
|
|
27
28
|
{
|
|
28
29
|
title: 'Options',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __commonJSMin } from "./chunk-CgnkrU7a.js";
|
|
2
2
|
import { o as DEFAULT_ENVS, u as resolve$1 } from "./json-BRdVJ52a.js";
|
|
3
|
-
import { n as accent } from "./help-
|
|
3
|
+
import { n as accent } from "./help-CbTzUdXc.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { stripVTControlCharacters } from "node:util";
|
|
6
6
|
import color from "picocolors";
|
package/dist/global/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as select, C as cancel, E as log, N as Ct, O as note, _ as pkgRoot, c as defaultInteractive, d as promptGitHooks, i as getAgentById, n as detectAgents } from "./agent-
|
|
1
|
+
import { A as select, C as cancel, E as log, N as Ct, O as note, _ as pkgRoot, c as defaultInteractive, d as promptGitHooks, i as getAgentById, n as detectAgents } from "./agent-CA64n2mH.js";
|
|
2
2
|
import { t as lib_default } from "./lib-DxappLRQ.js";
|
|
3
3
|
import { i as writeJsonFile, r as readJsonFile, s as VITE_PLUS_NAME } from "./json-BRdVJ52a.js";
|
|
4
|
-
import {
|
|
4
|
+
import { i as log$1, t as renderCliDoc } from "./help-CbTzUdXc.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";
|
|
@@ -366,6 +366,7 @@ async function main() {
|
|
|
366
366
|
const helpMessage = renderCliDoc({
|
|
367
367
|
usage: "vp config [OPTIONS]",
|
|
368
368
|
summary: "Configure Vite+ for the current project (hooks + agent integration).",
|
|
369
|
+
documentationUrl: "https://viteplus.dev/guide/commit-hooks",
|
|
369
370
|
sections: [{
|
|
370
371
|
title: "Options",
|
|
371
372
|
rows: [{
|
package/dist/global/create.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { i as __toESM, t as __commonJSMin } from "./chunk-CgnkrU7a.js";
|
|
2
|
-
import { A as select, C as cancel, D as multiselect, E as log, M as text, N as Ct, S as PackageManager, T as intro, a as selectAgentTargetPaths, c as defaultInteractive, d as promptGitHooks, f as runViteFmt, g as displayRelative, j as spinner, l as downloadPackageManager$1, m as selectPackageManager, o as writeAgentInstructions, p as runViteInstall, r as detectExistingAgentTargetPaths, w as confirm, x as DependencyType, y as templatesDir } from "./agent-
|
|
2
|
+
import { A as select, C as cancel, D as multiselect, E as log, M as text, N as Ct, S as PackageManager, T as intro, a as selectAgentTargetPaths, c as defaultInteractive, d as promptGitHooks, f as runViteFmt, g as displayRelative, j as spinner, l as downloadPackageManager$1, m as selectPackageManager, o as writeAgentInstructions, p as runViteInstall, r as detectExistingAgentTargetPaths, w as confirm, x as DependencyType, y as templatesDir } from "./agent-CA64n2mH.js";
|
|
3
3
|
import { t as lib_default } from "./lib-DxappLRQ.js";
|
|
4
|
-
import { _ as rewriteMonorepo, a as detectExistingEditor, f as installGitHooks, n as updatePackageJsonWithDeps, o as selectEditor, r as updateWorkspaceConfig, s as writeEditorConfigs, t as detectWorkspace$1, v as rewriteMonorepoProject, y as rewriteStandaloneProject } from "./workspace-
|
|
4
|
+
import { _ as rewriteMonorepo, a as detectExistingEditor, f as installGitHooks, n as updatePackageJsonWithDeps, o as selectEditor, r as updateWorkspaceConfig, s as writeEditorConfigs, t as detectWorkspace$1, v as rewriteMonorepoProject, y as rewriteStandaloneProject } from "./workspace-CpFQmwjZ.js";
|
|
5
5
|
import "./browser-CBapUTD0.js";
|
|
6
6
|
import { r as readJsonFile, t as editJsonFile } from "./json-BRdVJ52a.js";
|
|
7
7
|
import "./package-YAMvX5PJ.js";
|
|
8
|
-
import { a as
|
|
8
|
+
import { a as muted, i as log$1, n as accent, o as success, t as renderCliDoc } from "./help-CbTzUdXc.js";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { styleText } from "node:util";
|
|
11
11
|
import color from "picocolors";
|
|
@@ -253,6 +253,27 @@ function inferParentDir(templateName, workspaceInfo) {
|
|
|
253
253
|
for (const parentDir of workspaceInfo.parentDirs) if (rule.test(parentDir)) return parentDir;
|
|
254
254
|
}
|
|
255
255
|
//#endregion
|
|
256
|
+
//#region src/create/initial-template-options.ts
|
|
257
|
+
function getInitialTemplateOptions(isMonorepo) {
|
|
258
|
+
return [
|
|
259
|
+
...!isMonorepo ? [{
|
|
260
|
+
label: "Vite+ Monorepo",
|
|
261
|
+
value: BuiltinTemplate.monorepo,
|
|
262
|
+
hint: "Create a new Vite+ monorepo project"
|
|
263
|
+
}] : [],
|
|
264
|
+
{
|
|
265
|
+
label: "Vite+ Application",
|
|
266
|
+
value: BuiltinTemplate.application,
|
|
267
|
+
hint: "Create vite applications"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
label: "Vite+ Library",
|
|
271
|
+
value: BuiltinTemplate.library,
|
|
272
|
+
hint: "Create vite libraries"
|
|
273
|
+
}
|
|
274
|
+
];
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
256
277
|
//#region ../../node_modules/.pnpm/validate-npm-package-name@7.0.2/node_modules/validate-npm-package-name/lib/builtin-modules.json
|
|
257
278
|
var require_builtin_modules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
258
279
|
module.exports = [
|
|
@@ -3592,6 +3613,7 @@ function getScopeFromPackageName(packageName) {
|
|
|
3592
3613
|
const helpMessage = renderCliDoc({
|
|
3593
3614
|
usage: "vp create [TEMPLATE] [OPTIONS] [-- TEMPLATE_OPTIONS]",
|
|
3594
3615
|
summary: "Use any builtin, local or remote template with Vite+.",
|
|
3616
|
+
documentationUrl: "https://viteplus.dev/guide/create",
|
|
3595
3617
|
sections: [
|
|
3596
3618
|
{
|
|
3597
3619
|
title: "Arguments",
|
|
@@ -3682,6 +3704,7 @@ const helpMessage = renderCliDoc({
|
|
|
3682
3704
|
const listTemplatesMessage = renderCliDoc({
|
|
3683
3705
|
usage: "vp create --list",
|
|
3684
3706
|
summary: "List available builtin and popular project templates.",
|
|
3707
|
+
documentationUrl: "https://viteplus.dev/guide/create",
|
|
3685
3708
|
sections: [
|
|
3686
3709
|
{
|
|
3687
3710
|
title: "Vite+ Built-in Templates",
|
|
@@ -3889,61 +3912,12 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
3889
3912
|
let remoteTargetDir;
|
|
3890
3913
|
let shouldSetupHooks = false;
|
|
3891
3914
|
if (!selectedTemplateName) {
|
|
3892
|
-
const templates = [];
|
|
3893
|
-
if (isMonorepo) {
|
|
3894
|
-
for (const pkg of workspaceInfoOptional.packages) if (pkg.isTemplatePackage) templates.push({
|
|
3895
|
-
label: pkg.name,
|
|
3896
|
-
value: pkg.name,
|
|
3897
|
-
hint: pkg.description ?? pkg.path
|
|
3898
|
-
});
|
|
3899
|
-
} else templates.push({
|
|
3900
|
-
label: "Vite+ Monorepo",
|
|
3901
|
-
value: BuiltinTemplate.monorepo,
|
|
3902
|
-
hint: "Create a new Vite+ monorepo project"
|
|
3903
|
-
});
|
|
3904
3915
|
const template = await select({
|
|
3905
3916
|
message: "",
|
|
3906
|
-
options:
|
|
3907
|
-
...templates,
|
|
3908
|
-
{
|
|
3909
|
-
label: "Vite+ Application",
|
|
3910
|
-
value: BuiltinTemplate.application,
|
|
3911
|
-
hint: "Create vite applications"
|
|
3912
|
-
},
|
|
3913
|
-
{
|
|
3914
|
-
label: "Vite+ Library",
|
|
3915
|
-
value: BuiltinTemplate.library,
|
|
3916
|
-
hint: "Create vite libraries"
|
|
3917
|
-
},
|
|
3918
|
-
...isMonorepo ? [{
|
|
3919
|
-
label: "Vite+ Generator",
|
|
3920
|
-
value: BuiltinTemplate.generator,
|
|
3921
|
-
hint: "Scaffold a new code generator"
|
|
3922
|
-
}] : [],
|
|
3923
|
-
{
|
|
3924
|
-
label: "TanStack Start",
|
|
3925
|
-
value: "@tanstack/create-start@latest",
|
|
3926
|
-
hint: "Create TanStack applications and libraries"
|
|
3927
|
-
},
|
|
3928
|
-
{
|
|
3929
|
-
label: "Others",
|
|
3930
|
-
value: "other",
|
|
3931
|
-
hint: "Enter a custom template package name"
|
|
3932
|
-
}
|
|
3933
|
-
]
|
|
3917
|
+
options: getInitialTemplateOptions(isMonorepo)
|
|
3934
3918
|
});
|
|
3935
3919
|
if (Ct(template)) cancelAndExit();
|
|
3936
|
-
|
|
3937
|
-
const customTemplate = await text({
|
|
3938
|
-
message: "Enter the template package name:",
|
|
3939
|
-
placeholder: "e.g., create-next-app, create-nuxt",
|
|
3940
|
-
validate: (value) => {
|
|
3941
|
-
if (!value || value.trim().length === 0) return "Template name is required";
|
|
3942
|
-
}
|
|
3943
|
-
});
|
|
3944
|
-
if (Ct(customTemplate)) cancelAndExit();
|
|
3945
|
-
selectedTemplateName = customTemplate;
|
|
3946
|
-
} else selectedTemplateName = template;
|
|
3920
|
+
selectedTemplateName = template;
|
|
3947
3921
|
}
|
|
3948
3922
|
const isBuiltinTemplate = selectedTemplateName.startsWith("vite:");
|
|
3949
3923
|
if (!isBuiltinTemplate) compactOutput = false;
|
|
@@ -12,6 +12,9 @@ function muted(text) {
|
|
|
12
12
|
function success(text) {
|
|
13
13
|
return styleText("green", text);
|
|
14
14
|
}
|
|
15
|
+
function errorMsg(msg) {
|
|
16
|
+
console.error(styleText(["red", "bold"], "error:"), msg);
|
|
17
|
+
}
|
|
15
18
|
//#endregion
|
|
16
19
|
//#region src/utils/help.ts
|
|
17
20
|
function toLines(value) {
|
|
@@ -42,7 +45,8 @@ function renderRows(rows) {
|
|
|
42
45
|
return output;
|
|
43
46
|
}
|
|
44
47
|
function heading(label, color) {
|
|
45
|
-
|
|
48
|
+
if (!color) return `${label}:`;
|
|
49
|
+
return label === "Usage" ? styleText("bold", `${label}:`) : styleText(["blue", "bold"], `${label}:`);
|
|
46
50
|
}
|
|
47
51
|
function renderCliDoc(doc, options = {}) {
|
|
48
52
|
const color = options.color ?? true;
|
|
@@ -63,8 +67,12 @@ function renderCliDoc(doc, options = {}) {
|
|
|
63
67
|
if (lines.length > 0) output.push(...lines);
|
|
64
68
|
if (section.rows && section.rows.length > 0) output.push(...renderRows(section.rows));
|
|
65
69
|
}
|
|
70
|
+
if (doc.documentationUrl) {
|
|
71
|
+
if (output.length > 0) output.push("");
|
|
72
|
+
output.push(`${heading("Documentation", color)} ${doc.documentationUrl}`);
|
|
73
|
+
}
|
|
66
74
|
output.push("");
|
|
67
75
|
return output.join("\n");
|
|
68
76
|
}
|
|
69
77
|
//#endregion
|
|
70
|
-
export {
|
|
78
|
+
export { muted as a, log as i, accent as n, success as o, errorMsg as r, renderCliDoc as t };
|
package/dist/global/migrate.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { i as __toESM } from "./chunk-CgnkrU7a.js";
|
|
2
|
-
import { A as select, E as log, N as Ct, S as PackageManager, a as selectAgentTargetPaths, c as defaultInteractive, d as promptGitHooks, g as displayRelative, h as upgradeYarn, j as spinner, k as outro, l as downloadPackageManager$1, m as selectPackageManager, o as writeAgentInstructions, p as runViteInstall, s as cancelAndExit, t as detectAgentConflicts, w as confirm } from "./agent-
|
|
2
|
+
import { A as select, E as log, N as Ct, S as PackageManager, a as selectAgentTargetPaths, c as defaultInteractive, d as promptGitHooks, g as displayRelative, h as upgradeYarn, j as spinner, k as outro, l as downloadPackageManager$1, m as selectPackageManager, o as writeAgentInstructions, p as runViteInstall, s as cancelAndExit, t as detectAgentConflicts, w as confirm } from "./agent-CA64n2mH.js";
|
|
3
3
|
import { t as lib_default } from "./lib-DxappLRQ.js";
|
|
4
|
-
import { _ as rewriteMonorepo, b as createMigrationReport, c as checkViteVersion, d as detectPrettierProject, f as installGitHooks, g as preflightGitHooksSetup, h as migratePrettierToOxfmt, i as detectEditorConflicts, l as checkVitestVersion, m as migrateEslintToOxlint, o as selectEditor, p as mergeViteConfigFiles, s as writeEditorConfigs, t as detectWorkspace$1, u as detectEslintProject, x as require_semver, y as rewriteStandaloneProject } from "./workspace-
|
|
4
|
+
import { _ as rewriteMonorepo, b as createMigrationReport, c as checkViteVersion, d as detectPrettierProject, f as installGitHooks, g as preflightGitHooksSetup, h as migratePrettierToOxfmt, i as detectEditorConflicts, l as checkVitestVersion, m as migrateEslintToOxlint, o as selectEditor, p as mergeViteConfigFiles, s as writeEditorConfigs, t as detectWorkspace$1, u as detectEslintProject, x as require_semver, y as rewriteStandaloneProject } from "./workspace-CpFQmwjZ.js";
|
|
5
5
|
import "./browser-CBapUTD0.js";
|
|
6
6
|
import "./json-BRdVJ52a.js";
|
|
7
7
|
import { i as readNearestPackageJson, r as hasVitePlusDependency } from "./package-YAMvX5PJ.js";
|
|
8
|
-
import {
|
|
8
|
+
import { a as muted, i as log$1, n as accent, t as renderCliDoc } from "./help-CbTzUdXc.js";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { styleText } from "node:util";
|
|
11
11
|
import { vitePlusHeader } from "../../binding/index.js";
|
|
@@ -72,6 +72,7 @@ async function promptPrettierMigration(projectPath, interactive, packages) {
|
|
|
72
72
|
const helpMessage = renderCliDoc({
|
|
73
73
|
usage: "vp migrate [PATH] [OPTIONS]",
|
|
74
74
|
summary: "Migrate standalone Vite, Vitest, Oxlint, Oxfmt, and Prettier projects to unified Vite+.",
|
|
75
|
+
documentationUrl: "https://viteplus.dev/guide/migrate",
|
|
75
76
|
sections: [
|
|
76
77
|
{
|
|
77
78
|
title: "Arguments",
|
|
@@ -129,6 +130,46 @@ const helpMessage = renderCliDoc({
|
|
|
129
130
|
` ${muted("# Non-interactive mode")}`,
|
|
130
131
|
` ${accent("vp migrate --no-interactive")}`
|
|
131
132
|
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
title: "Migration Prompt",
|
|
136
|
+
lines: [
|
|
137
|
+
" Give this to a coding agent when you want it to drive the migration:",
|
|
138
|
+
"",
|
|
139
|
+
" Migrate this project to Vite+.",
|
|
140
|
+
" Vite+ replaces the current split tooling around runtime management, package",
|
|
141
|
+
" management, dev/build/test commands, linting, formatting, and packaging.",
|
|
142
|
+
" Run `vp help` and `vp help migrate` before making changes.",
|
|
143
|
+
` Use ${accent("vp migrate --no-interactive")} in the workspace root.`,
|
|
144
|
+
" Make sure the project is using Vite 8+ and Vitest 4.1+ before migrating.",
|
|
145
|
+
"",
|
|
146
|
+
" After the migration:",
|
|
147
|
+
" - Confirm `vite` imports were rewritten to `vite-plus` where needed",
|
|
148
|
+
" - Confirm `vitest` imports were rewritten to `vite-plus/test` where needed",
|
|
149
|
+
" - Remove old `vite` and `vitest` dependencies only after those rewrites",
|
|
150
|
+
" are confirmed",
|
|
151
|
+
" - Move remaining tool-specific config into the appropriate blocks in",
|
|
152
|
+
" `vite.config.ts`",
|
|
153
|
+
"",
|
|
154
|
+
" Command mapping:",
|
|
155
|
+
" - `vp run <script>` is the equivalent of `pnpm run <script>`",
|
|
156
|
+
" - `vp test` runs the built-in test command, while `vp run test` runs the",
|
|
157
|
+
" `test` script from `package.json`",
|
|
158
|
+
" - `vp install`, `vp add`, and `vp remove` delegate through the package",
|
|
159
|
+
" manager declared by `packageManager`",
|
|
160
|
+
" - `vp dev`, `vp build`, `vp preview`, `vp lint`, `vp fmt`, `vp check`,",
|
|
161
|
+
" and `vp pack` replace the corresponding standalone tools",
|
|
162
|
+
" - Prefer `vp check` for validation loops",
|
|
163
|
+
"",
|
|
164
|
+
" Finally, verify the migration by running:",
|
|
165
|
+
` - ${accent("vp install")}`,
|
|
166
|
+
` - ${accent("vp check")}`,
|
|
167
|
+
` - ${accent("vp test")}`,
|
|
168
|
+
` - ${accent("vp build")}`,
|
|
169
|
+
"",
|
|
170
|
+
" Summarize the migration at the end and report any manual follow-up still",
|
|
171
|
+
" required."
|
|
172
|
+
]
|
|
132
173
|
}
|
|
133
174
|
]
|
|
134
175
|
});
|
package/dist/global/staged.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-CgnkrU7a.js";
|
|
2
2
|
import { t as lib_default } from "./lib-DxappLRQ.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as log, r as errorMsg, t as renderCliDoc } from "./help-CbTzUdXc.js";
|
|
4
4
|
import path, { delimiter, dirname, normalize, resolve } from "node:path";
|
|
5
5
|
import { formatWithOptions, inspect, promisify } from "node:util";
|
|
6
6
|
import { cwd } from "node:process";
|
|
@@ -8157,6 +8157,7 @@ if (args.help) {
|
|
|
8157
8157
|
const helpMessage = renderCliDoc({
|
|
8158
8158
|
usage: "vp staged [options]",
|
|
8159
8159
|
summary: "Run linters on staged files using staged config from vite.config.ts.",
|
|
8160
|
+
documentationUrl: "https://viteplus.dev/guide/commit-hooks",
|
|
8160
8161
|
sections: [{
|
|
8161
8162
|
title: "Options",
|
|
8162
8163
|
rows: [
|
|
@@ -8251,7 +8252,8 @@ if (args.help) {
|
|
|
8251
8252
|
}
|
|
8252
8253
|
if (stagedConfig) options.config = stagedConfig;
|
|
8253
8254
|
else {
|
|
8254
|
-
log(
|
|
8255
|
+
log(vitePlusHeader() + "\n");
|
|
8256
|
+
errorMsg("No \"staged\" config found in vite.config.ts. Please add a staged config:");
|
|
8255
8257
|
log("");
|
|
8256
8258
|
log(" // vite.config.ts");
|
|
8257
8259
|
log(" export default defineConfig({");
|
package/dist/global/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as VITE_PLUS_NAME } from "./json-BRdVJ52a.js";
|
|
2
2
|
import { r as hasVitePlusDependency, t as detectPackageMetadata } from "./package-YAMvX5PJ.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as log, n as accent, t as renderCliDoc } from "./help-CbTzUdXc.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import { vitePlusHeader } from "../../binding/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as __toESM, t as __commonJSMin } from "./chunk-CgnkrU7a.js";
|
|
2
|
-
import { A as select, E as log, N as Ct, S as PackageManager, b as runCommandSilently, g as displayRelative, u as getSpinner, v as rulesDir } from "./agent-
|
|
2
|
+
import { A as select, E as log, N as Ct, S as PackageManager, b as runCommandSilently, g as displayRelative, u as getSpinner, v as rulesDir } from "./agent-CA64n2mH.js";
|
|
3
3
|
import { _ as YAMLMap, g as YAMLSeq, i as parseDocument, n as parse, y as Scalar } from "./browser-CBapUTD0.js";
|
|
4
4
|
import { a as BASEURL_TSCONFIG_WARNING, c as VITE_PLUS_OVERRIDE_PACKAGES, i as writeJsonFile, l as VITE_PLUS_VERSION, n as isJsonFile, r as readJsonFile, s as VITE_PLUS_NAME, t as editJsonFile } from "./json-BRdVJ52a.js";
|
|
5
5
|
import { n as getScopeFromPackageName, t as detectPackageMetadata } from "./package-YAMvX5PJ.js";
|
|
@@ -1912,7 +1912,6 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
1912
1912
|
if (!skipStagedMigration) rewriteLintStagedConfigFile(projectPath, report);
|
|
1913
1913
|
mergeViteConfigFiles(projectPath, silent, report);
|
|
1914
1914
|
injectLintTypeCheckDefaults(projectPath, silent, report);
|
|
1915
|
-
injectFmtDefaults(projectPath, silent, report);
|
|
1916
1915
|
mergeTsdownConfigFile(projectPath, silent, report);
|
|
1917
1916
|
rewriteAllImports(projectPath, silent, report);
|
|
1918
1917
|
setPackageManager(projectPath, workspaceInfo.downloadPackageManager);
|
|
@@ -1929,7 +1928,6 @@ function rewriteMonorepo(workspaceInfo, skipStagedMigration, silent = false, rep
|
|
|
1929
1928
|
if (!skipStagedMigration) rewriteLintStagedConfigFile(workspaceInfo.rootDir, report);
|
|
1930
1929
|
mergeViteConfigFiles(workspaceInfo.rootDir, silent, report);
|
|
1931
1930
|
injectLintTypeCheckDefaults(workspaceInfo.rootDir, silent, report);
|
|
1932
|
-
injectFmtDefaults(workspaceInfo.rootDir, silent, report);
|
|
1933
1931
|
mergeTsdownConfigFile(workspaceInfo.rootDir, silent, report);
|
|
1934
1932
|
rewriteAllImports(workspaceInfo.rootDir, silent, report);
|
|
1935
1933
|
setPackageManager(workspaceInfo.rootDir, workspaceInfo.downloadPackageManager);
|
|
@@ -2227,14 +2225,6 @@ function injectLintTypeCheckDefaults(projectPath, silent = false, report) {
|
|
|
2227
2225
|
typeCheck: true
|
|
2228
2226
|
} }), silent, report);
|
|
2229
2227
|
}
|
|
2230
|
-
/**
|
|
2231
|
-
* Inject an empty `fmt: {}` field into vite.config.ts if it doesn't already exist.
|
|
2232
|
-
* This is needed because oxfmt auto-discovers vite.config.ts and errors if
|
|
2233
|
-
* the `fmt` field is missing.
|
|
2234
|
-
*/
|
|
2235
|
-
function injectFmtDefaults(projectPath, silent = false, report) {
|
|
2236
|
-
injectConfigDefaults(projectPath, "fmt", ".vite-plus-fmt-init.oxfmtrc.json", "{}", silent, report);
|
|
2237
|
-
}
|
|
2238
2228
|
function injectConfigDefaults(projectPath, configKey, tempFileName, tempFileContent, silent, report) {
|
|
2239
2229
|
const configs = detectConfigs(projectPath);
|
|
2240
2230
|
if (configs.viteConfig) {
|
|
@@ -2619,7 +2609,7 @@ const VSCODE_SETTINGS = {
|
|
|
2619
2609
|
"editor.formatOnSaveMode": "file",
|
|
2620
2610
|
"editor.codeActionsOnSave": { "source.fixAll.oxc": "explicit" }
|
|
2621
2611
|
};
|
|
2622
|
-
const VSCODE_EXTENSIONS = { recommendations: ["
|
|
2612
|
+
const VSCODE_EXTENSIONS = { recommendations: ["VoidZero.vite-plus-extension-pack"] };
|
|
2623
2613
|
const EDITORS = [{
|
|
2624
2614
|
id: "vscode",
|
|
2625
2615
|
label: "VSCode",
|
package/dist/init-config.js
CHANGED
|
@@ -98,26 +98,6 @@ function hasConfigKey(viteConfigPath, configKey) {
|
|
|
98
98
|
const viteConfig = fs.readFileSync(viteConfigPath, 'utf8');
|
|
99
99
|
return new RegExp(`\\b${configKey}\\s*:`).test(viteConfig);
|
|
100
100
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Ensure `fmt: {}` exists in vite.config.ts so oxfmt auto-discovery doesn't
|
|
103
|
-
* error when the config file lacks a `fmt` field.
|
|
104
|
-
*/
|
|
105
|
-
function injectFmtDefaultsIfMissing(viteConfigPath) {
|
|
106
|
-
if (hasConfigKey(viteConfigPath, 'fmt')) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const tempConfigPath = `${viteConfigPath}.fmt-init.json`;
|
|
110
|
-
fs.writeFileSync(tempConfigPath, '{}');
|
|
111
|
-
try {
|
|
112
|
-
const result = mergeJsonConfig(viteConfigPath, tempConfigPath, 'fmt');
|
|
113
|
-
if (result.updated) {
|
|
114
|
-
fs.writeFileSync(viteConfigPath, result.content);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
finally {
|
|
118
|
-
fs.rmSync(tempConfigPath, { force: true });
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
101
|
async function vpFmt(cwd, filePath) {
|
|
122
102
|
const { binPath, envs } = await resolveFmt();
|
|
123
103
|
const result = await runCommandSilently({
|
|
@@ -130,7 +110,7 @@ async function vpFmt(cwd, filePath) {
|
|
|
130
110
|
},
|
|
131
111
|
});
|
|
132
112
|
if (result.exitCode !== 0) {
|
|
133
|
-
|
|
113
|
+
warnMsg(`Failed to format ${filePath} with vp fmt:\n${result.stdout.toString()}${result.stderr.toString()}`);
|
|
134
114
|
}
|
|
135
115
|
}
|
|
136
116
|
function resolveInitSpec(command, args) {
|
|
@@ -206,7 +186,6 @@ export async function applyToolInitConfigToViteConfig(command, args, projectPath
|
|
|
206
186
|
if (generatedConfigPath) {
|
|
207
187
|
fs.rmSync(generatedConfigPath, { force: true });
|
|
208
188
|
}
|
|
209
|
-
injectFmtDefaultsIfMissing(viteConfigPath);
|
|
210
189
|
await vpFmt(projectPath, path.relative(projectPath, viteConfigPath));
|
|
211
190
|
return {
|
|
212
191
|
handled: true,
|
|
@@ -229,7 +208,6 @@ export async function applyToolInitConfigToViteConfig(command, args, projectPath
|
|
|
229
208
|
}
|
|
230
209
|
fs.writeFileSync(viteConfigPath, mergeResult.content);
|
|
231
210
|
fs.rmSync(generatedConfigPath, { force: true });
|
|
232
|
-
injectFmtDefaultsIfMissing(viteConfigPath);
|
|
233
211
|
await vpFmt(projectPath, path.relative(projectPath, viteConfigPath));
|
|
234
212
|
return {
|
|
235
213
|
handled: true,
|
package/dist/run-config.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export type Task = {
|
|
2
2
|
/**
|
|
3
3
|
* The command to run for the task.
|
|
4
|
-
*
|
|
5
|
-
* If omitted, the script from `package.json` with the same name will be used
|
|
6
4
|
*/
|
|
7
|
-
command
|
|
5
|
+
command: string;
|
|
8
6
|
/**
|
|
9
7
|
* The working directory for the task, relative to the package root (not workspace root).
|
|
10
8
|
*/
|
|
@@ -21,11 +19,11 @@ export type Task = {
|
|
|
21
19
|
/**
|
|
22
20
|
* Environment variable names to be fingerprinted and passed to the task.
|
|
23
21
|
*/
|
|
24
|
-
|
|
22
|
+
env?: Array<string>;
|
|
25
23
|
/**
|
|
26
24
|
* Environment variable names to be passed to the task without fingerprinting.
|
|
27
25
|
*/
|
|
28
|
-
|
|
26
|
+
untrackedEnv?: Array<string>;
|
|
29
27
|
/**
|
|
30
28
|
* Files to include in the cache fingerprint.
|
|
31
29
|
*
|
|
@@ -37,7 +35,7 @@ export type Task = {
|
|
|
37
35
|
*
|
|
38
36
|
* Patterns are relative to the package directory.
|
|
39
37
|
*/
|
|
40
|
-
|
|
38
|
+
input?: Array<string | {
|
|
41
39
|
/**
|
|
42
40
|
* Automatically track which files the task reads
|
|
43
41
|
*/
|
package/dist/staged/bin.js
CHANGED
|
@@ -13,7 +13,7 @@ import mri from 'mri';
|
|
|
13
13
|
import { vitePlusHeader } from '../../binding/index.js';
|
|
14
14
|
import { resolveViteConfig } from '../resolve-vite-config.js';
|
|
15
15
|
import { renderCliDoc } from '../utils/help.js';
|
|
16
|
-
import { log } from '../utils/terminal.js';
|
|
16
|
+
import { errorMsg, log } from '../utils/terminal.js';
|
|
17
17
|
const args = mri(process.argv.slice(3), {
|
|
18
18
|
alias: {
|
|
19
19
|
h: 'help',
|
|
@@ -43,6 +43,7 @@ if (args.help) {
|
|
|
43
43
|
const helpMessage = renderCliDoc({
|
|
44
44
|
usage: 'vp staged [options]',
|
|
45
45
|
summary: 'Run linters on staged files using staged config from vite.config.ts.',
|
|
46
|
+
documentationUrl: 'https://viteplus.dev/guide/commit-hooks',
|
|
46
47
|
sections: [
|
|
47
48
|
{
|
|
48
49
|
title: 'Options',
|
|
@@ -147,7 +148,8 @@ else {
|
|
|
147
148
|
options.config = stagedConfig;
|
|
148
149
|
}
|
|
149
150
|
else {
|
|
150
|
-
log(
|
|
151
|
+
log(vitePlusHeader() + '\n');
|
|
152
|
+
errorMsg('No "staged" config found in vite.config.ts. Please add a staged config:');
|
|
151
153
|
log('');
|
|
152
154
|
log(' // vite.config.ts');
|
|
153
155
|
log(' export default defineConfig({');
|
package/dist/utils/editor.js
CHANGED
package/dist/utils/help.d.ts
CHANGED
package/dist/utils/help.js
CHANGED
|
@@ -33,7 +33,12 @@ function renderRows(rows) {
|
|
|
33
33
|
return output;
|
|
34
34
|
}
|
|
35
35
|
function heading(label, color) {
|
|
36
|
-
|
|
36
|
+
if (!color) {
|
|
37
|
+
return `${label}:`;
|
|
38
|
+
}
|
|
39
|
+
return label === 'Usage'
|
|
40
|
+
? styleText('bold', `${label}:`)
|
|
41
|
+
: styleText(['blue', 'bold'], `${label}:`);
|
|
37
42
|
}
|
|
38
43
|
export function renderCliDoc(doc, options = {}) {
|
|
39
44
|
const color = options.color ?? true;
|
|
@@ -62,6 +67,12 @@ export function renderCliDoc(doc, options = {}) {
|
|
|
62
67
|
output.push(...renderRows(section.rows));
|
|
63
68
|
}
|
|
64
69
|
}
|
|
70
|
+
if (doc.documentationUrl) {
|
|
71
|
+
if (output.length > 0) {
|
|
72
|
+
output.push('');
|
|
73
|
+
}
|
|
74
|
+
output.push(`${heading('Documentation', color)} ${doc.documentationUrl}`);
|
|
75
|
+
}
|
|
65
76
|
output.push('');
|
|
66
77
|
return output.join('\n');
|
|
67
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"oxfmt": "./bin/oxfmt",
|
|
@@ -297,12 +297,12 @@
|
|
|
297
297
|
"@oxc-project/types": "=0.115.0",
|
|
298
298
|
"cac": "^6.7.14",
|
|
299
299
|
"cross-spawn": "^7.0.5",
|
|
300
|
-
"oxfmt": "
|
|
301
|
-
"oxlint": "
|
|
302
|
-
"oxlint-tsgolint": "
|
|
300
|
+
"oxfmt": "=0.39.0",
|
|
301
|
+
"oxlint": "=1.54.0",
|
|
302
|
+
"oxlint-tsgolint": "=0.16.0",
|
|
303
303
|
"picocolors": "^1.1.1",
|
|
304
|
-
"@voidzero-dev/vite-plus-
|
|
305
|
-
"@voidzero-dev/vite-plus-
|
|
304
|
+
"@voidzero-dev/vite-plus-core": "0.1.8",
|
|
305
|
+
"@voidzero-dev/vite-plus-test": "0.1.8"
|
|
306
306
|
},
|
|
307
307
|
"devDependencies": {
|
|
308
308
|
"@napi-rs/cli": "^3.4.1",
|
|
@@ -320,12 +320,12 @@
|
|
|
320
320
|
"mri": "^1.2.0",
|
|
321
321
|
"rolldown-plugin-dts": "^0.22.0",
|
|
322
322
|
"semver": "^7.7.3",
|
|
323
|
-
"tsdown": "^0.21.
|
|
323
|
+
"tsdown": "^0.21.2",
|
|
324
324
|
"validate-npm-package-name": "^7.0.2",
|
|
325
325
|
"yaml": "^2.8.1",
|
|
326
326
|
"@voidzero-dev/vite-plus-prompts": "0.0.0",
|
|
327
|
-
"rolldown": "1.0.0-rc.
|
|
328
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.
|
|
327
|
+
"rolldown": "1.0.0-rc.9",
|
|
328
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.8"
|
|
329
329
|
},
|
|
330
330
|
"napi": {
|
|
331
331
|
"binaryName": "vite-plus",
|
|
@@ -343,12 +343,12 @@
|
|
|
343
343
|
"node": "^20.19.0 || >=22.12.0"
|
|
344
344
|
},
|
|
345
345
|
"optionalDependencies": {
|
|
346
|
-
"@voidzero-dev/vite-plus-darwin-arm64": "0.1.
|
|
347
|
-
"@voidzero-dev/vite-plus-darwin-x64": "0.1.
|
|
348
|
-
"@voidzero-dev/vite-plus-linux-arm64-gnu": "0.1.
|
|
349
|
-
"@voidzero-dev/vite-plus-linux-x64-gnu": "0.1.
|
|
350
|
-
"@voidzero-dev/vite-plus-win32-x64-msvc": "0.1.
|
|
351
|
-
"@voidzero-dev/vite-plus-win32-arm64-msvc": "0.1.
|
|
346
|
+
"@voidzero-dev/vite-plus-darwin-arm64": "0.1.8",
|
|
347
|
+
"@voidzero-dev/vite-plus-darwin-x64": "0.1.8",
|
|
348
|
+
"@voidzero-dev/vite-plus-linux-arm64-gnu": "0.1.8",
|
|
349
|
+
"@voidzero-dev/vite-plus-linux-x64-gnu": "0.1.8",
|
|
350
|
+
"@voidzero-dev/vite-plus-win32-x64-msvc": "0.1.8",
|
|
351
|
+
"@voidzero-dev/vite-plus-win32-arm64-msvc": "0.1.8"
|
|
352
352
|
},
|
|
353
353
|
"scripts": {
|
|
354
354
|
"build": "oxnode -C dev ./build.ts",
|