vite-plus 0.1.6 → 0.1.7
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/dist/config/hooks.js
CHANGED
|
@@ -77,7 +77,10 @@ export function install(dir = '.vite-hooks') {
|
|
|
77
77
|
const target = rel ? `${rel}/${dir}/_` : `${dir}/_`;
|
|
78
78
|
const checkResult = spawnSync('git', ['config', '--local', 'core.hooksPath']);
|
|
79
79
|
const existingHooksPath = checkResult.status === 0 ? checkResult.stdout?.toString().trim() : '';
|
|
80
|
-
if (existingHooksPath &&
|
|
80
|
+
if (existingHooksPath &&
|
|
81
|
+
existingHooksPath !== target &&
|
|
82
|
+
existingHooksPath !== '.husky' &&
|
|
83
|
+
!existingHooksPath.startsWith('.husky/')) {
|
|
81
84
|
return {
|
|
82
85
|
message: `core.hooksPath is already set to "${existingHooksPath}", skipping`,
|
|
83
86
|
isError: false,
|
package/dist/global/config.js
CHANGED
|
@@ -327,7 +327,7 @@ function install(dir = ".vite-hooks") {
|
|
|
327
327
|
"core.hooksPath"
|
|
328
328
|
]);
|
|
329
329
|
const existingHooksPath = checkResult.status === 0 ? checkResult.stdout?.toString().trim() : "";
|
|
330
|
-
if (existingHooksPath && existingHooksPath !== target) return {
|
|
330
|
+
if (existingHooksPath && existingHooksPath !== target && existingHooksPath !== ".husky" && !existingHooksPath.startsWith(".husky/")) return {
|
|
331
331
|
message: `core.hooksPath is already set to "${existingHooksPath}", skipping`,
|
|
332
332
|
isError: false
|
|
333
333
|
};
|
package/dist/global/create.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, t as __commonJSMin } from "./chunk-CgnkrU7a.js";
|
|
2
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-CpNB3GIY.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-pvS7F6d2.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";
|
|
@@ -3700,7 +3700,7 @@ const listTemplatesMessage = renderCliDoc({
|
|
|
3700
3700
|
},
|
|
3701
3701
|
{
|
|
3702
3702
|
label: "vite:generator",
|
|
3703
|
-
description: "Scaffold a new code generator"
|
|
3703
|
+
description: "Scaffold a new code generator (monorepo only)"
|
|
3704
3704
|
}
|
|
3705
3705
|
]
|
|
3706
3706
|
},
|
|
@@ -3952,6 +3952,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
3952
3952
|
log.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
|
|
3953
3953
|
cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
|
|
3954
3954
|
}
|
|
3955
|
+
if (selectedTemplateName === BuiltinTemplate.generator && !isMonorepo) {
|
|
3956
|
+
log.info("The vite:generator template requires a monorepo workspace.\nRun this command inside a Vite+ monorepo, or create one first with `vp create vite:monorepo`");
|
|
3957
|
+
cancelAndExit("Cannot create a generator outside a monorepo", 1);
|
|
3958
|
+
}
|
|
3955
3959
|
if (isInSubdirectory && !compactOutput) log.info(`Detected monorepo root at ${accent(workspaceInfoOptional.rootDir)}`);
|
|
3956
3960
|
if (isMonorepo && options.interactive && !targetDir) {
|
|
3957
3961
|
let parentDir;
|
package/dist/global/migrate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM } from "./chunk-CgnkrU7a.js";
|
|
2
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-CpNB3GIY.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-pvS7F6d2.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";
|
|
@@ -1911,6 +1911,8 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
1911
1911
|
}
|
|
1912
1912
|
if (!skipStagedMigration) rewriteLintStagedConfigFile(projectPath, report);
|
|
1913
1913
|
mergeViteConfigFiles(projectPath, silent, report);
|
|
1914
|
+
injectLintTypeCheckDefaults(projectPath, silent, report);
|
|
1915
|
+
injectFmtDefaults(projectPath, silent, report);
|
|
1914
1916
|
mergeTsdownConfigFile(projectPath, silent, report);
|
|
1915
1917
|
rewriteAllImports(projectPath, silent, report);
|
|
1916
1918
|
setPackageManager(projectPath, workspaceInfo.downloadPackageManager);
|
|
@@ -1926,6 +1928,8 @@ function rewriteMonorepo(workspaceInfo, skipStagedMigration, silent = false, rep
|
|
|
1926
1928
|
for (const pkg of workspaceInfo.packages) rewriteMonorepoProject(path.join(workspaceInfo.rootDir, pkg.path), workspaceInfo.packageManager, skipStagedMigration, silent, report);
|
|
1927
1929
|
if (!skipStagedMigration) rewriteLintStagedConfigFile(workspaceInfo.rootDir, report);
|
|
1928
1930
|
mergeViteConfigFiles(workspaceInfo.rootDir, silent, report);
|
|
1931
|
+
injectLintTypeCheckDefaults(workspaceInfo.rootDir, silent, report);
|
|
1932
|
+
injectFmtDefaults(workspaceInfo.rootDir, silent, report);
|
|
1929
1933
|
mergeTsdownConfigFile(workspaceInfo.rootDir, silent, report);
|
|
1930
1934
|
rewriteAllImports(workspaceInfo.rootDir, silent, report);
|
|
1931
1935
|
setPackageManager(workspaceInfo.rootDir, workspaceInfo.downloadPackageManager);
|
|
@@ -2211,6 +2215,44 @@ function mergeViteConfigFiles(projectPath, silent = false, report) {
|
|
|
2211
2215
|
}
|
|
2212
2216
|
if (configs.oxfmtConfig) mergeAndRemoveJsonConfig(projectPath, viteConfig, configs.oxfmtConfig, "fmt", silent, report);
|
|
2213
2217
|
}
|
|
2218
|
+
/**
|
|
2219
|
+
* Inject typeAware and typeCheck defaults into vite.config.ts lint config.
|
|
2220
|
+
* Called after mergeViteConfigFiles() to handle the case where no .oxlintrc.json exists
|
|
2221
|
+
* (e.g., newly created projects from create-vite templates).
|
|
2222
|
+
*/
|
|
2223
|
+
function injectLintTypeCheckDefaults(projectPath, silent = false, report) {
|
|
2224
|
+
if (hasBaseUrlInTsconfig(projectPath)) return;
|
|
2225
|
+
injectConfigDefaults(projectPath, "lint", ".vite-plus-lint-init.oxlintrc.json", JSON.stringify({ options: {
|
|
2226
|
+
typeAware: true,
|
|
2227
|
+
typeCheck: true
|
|
2228
|
+
} }), silent, report);
|
|
2229
|
+
}
|
|
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
|
+
function injectConfigDefaults(projectPath, configKey, tempFileName, tempFileContent, silent, report) {
|
|
2239
|
+
const configs = detectConfigs(projectPath);
|
|
2240
|
+
if (configs.viteConfig) {
|
|
2241
|
+
const content = fs.readFileSync(path.join(projectPath, configs.viteConfig), "utf8");
|
|
2242
|
+
if (new RegExp(`\\b${configKey}\\s*:`).test(content)) return;
|
|
2243
|
+
}
|
|
2244
|
+
const viteConfig = ensureViteConfig(projectPath, configs, silent, report);
|
|
2245
|
+
const tempConfigPath = path.join(projectPath, tempFileName);
|
|
2246
|
+
fs.writeFileSync(tempConfigPath, tempFileContent);
|
|
2247
|
+
const fullViteConfigPath = path.join(projectPath, viteConfig);
|
|
2248
|
+
let result;
|
|
2249
|
+
try {
|
|
2250
|
+
result = mergeJsonConfig(fullViteConfigPath, tempConfigPath, configKey);
|
|
2251
|
+
} finally {
|
|
2252
|
+
fs.rmSync(tempConfigPath, { force: true });
|
|
2253
|
+
}
|
|
2254
|
+
if (result.updated) fs.writeFileSync(fullViteConfigPath, result.content);
|
|
2255
|
+
}
|
|
2214
2256
|
function mergeAndRemoveJsonConfig(projectPath, viteConfigPath, jsonConfigPath, configKey, silent = false, report) {
|
|
2215
2257
|
const fullViteConfigPath = path.join(projectPath, viteConfigPath);
|
|
2216
2258
|
const fullJsonConfigPath = path.join(projectPath, jsonConfigPath);
|
package/dist/init-config.js
CHANGED
|
@@ -98,6 +98,26 @@ 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
|
+
}
|
|
101
121
|
async function vpFmt(cwd, filePath) {
|
|
102
122
|
const { binPath, envs } = await resolveFmt();
|
|
103
123
|
const result = await runCommandSilently({
|
|
@@ -186,6 +206,7 @@ export async function applyToolInitConfigToViteConfig(command, args, projectPath
|
|
|
186
206
|
if (generatedConfigPath) {
|
|
187
207
|
fs.rmSync(generatedConfigPath, { force: true });
|
|
188
208
|
}
|
|
209
|
+
injectFmtDefaultsIfMissing(viteConfigPath);
|
|
189
210
|
await vpFmt(projectPath, path.relative(projectPath, viteConfigPath));
|
|
190
211
|
return {
|
|
191
212
|
handled: true,
|
|
@@ -208,6 +229,7 @@ export async function applyToolInitConfigToViteConfig(command, args, projectPath
|
|
|
208
229
|
}
|
|
209
230
|
fs.writeFileSync(viteConfigPath, mergeResult.content);
|
|
210
231
|
fs.rmSync(generatedConfigPath, { force: true });
|
|
232
|
+
injectFmtDefaultsIfMissing(viteConfigPath);
|
|
211
233
|
await vpFmt(projectPath, path.relative(projectPath, viteConfigPath));
|
|
212
234
|
return {
|
|
213
235
|
handled: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"oxfmt": "./bin/oxfmt",
|
|
@@ -120,8 +120,8 @@
|
|
|
120
120
|
},
|
|
121
121
|
"./test/config": {
|
|
122
122
|
"types": "./dist/test/config.d.ts",
|
|
123
|
-
"
|
|
124
|
-
"
|
|
123
|
+
"default": "./dist/test/config.js",
|
|
124
|
+
"require": "./dist/test/config.cjs"
|
|
125
125
|
},
|
|
126
126
|
"./test/coverage": {
|
|
127
127
|
"types": "./dist/test/coverage.d.ts",
|
|
@@ -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": "^0.
|
|
301
|
-
"oxlint": "^1.
|
|
300
|
+
"oxfmt": "^0.38.0",
|
|
301
|
+
"oxlint": "^1.53.0",
|
|
302
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-test": "0.1.7",
|
|
305
|
+
"@voidzero-dev/vite-plus-core": "0.1.7"
|
|
306
306
|
},
|
|
307
307
|
"devDependencies": {
|
|
308
308
|
"@napi-rs/cli": "^3.4.1",
|
|
@@ -325,7 +325,7 @@
|
|
|
325
325
|
"yaml": "^2.8.1",
|
|
326
326
|
"@voidzero-dev/vite-plus-prompts": "0.0.0",
|
|
327
327
|
"rolldown": "1.0.0-rc.8",
|
|
328
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.
|
|
328
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.7"
|
|
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.7",
|
|
347
|
+
"@voidzero-dev/vite-plus-darwin-x64": "0.1.7",
|
|
348
|
+
"@voidzero-dev/vite-plus-linux-arm64-gnu": "0.1.7",
|
|
349
|
+
"@voidzero-dev/vite-plus-linux-x64-gnu": "0.1.7",
|
|
350
|
+
"@voidzero-dev/vite-plus-win32-x64-msvc": "0.1.7",
|
|
351
|
+
"@voidzero-dev/vite-plus-win32-arm64-msvc": "0.1.7"
|
|
352
352
|
},
|
|
353
353
|
"scripts": {
|
|
354
354
|
"build": "oxnode -C dev ./build.ts",
|