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,21 +1,22 @@
|
|
|
1
1
|
import { r as __toESM } from "./rolldown-runtime-CMFfr-1z.js";
|
|
2
|
-
import { a as VITEST_AGE_GATE_EXEMPT_PACKAGES, c as
|
|
3
|
-
import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-
|
|
4
|
-
import { A as isCancel, C as log, E as select, M as runCommandSilently, N as require_cross_spawn, d as readYamlFile, f as scalarString, g as
|
|
5
|
-
import { a as writeJsonFile, c as parse, i as readJsonFile, n as editJsonFile, o as applyEdits, r as isJsonFile, s as modify, t as detectFormattingOptions } from "./json-
|
|
6
|
-
import { t as require_dist } from "./dist-
|
|
7
|
-
import { a as hasTypesToRewriteInTsconfig, c as rewriteTypesInTsconfig, i as hasBaseUrlInTsconfig, n as findTsconfigFiles, o as hasVitestTypesInTsconfig, s as removeDeprecatedTsconfigFalseOption } from "./tsconfig-
|
|
8
|
-
import { n as detectPackageMetadata, r as getScopeFromPackageName } from "./package-
|
|
9
|
-
import {
|
|
2
|
+
import { a as VITEST_AGE_GATE_EXEMPT_PACKAGES, c as VITE_PLUS_NAME, f as isForceOverrideMode, l as VITE_PLUS_OVERRIDE_PACKAGES, n as BASEURL_TSCONFIG_WARNING, o as VITEST_VERSION, s as VITE_CONFIG_FILES, u as VITE_PLUS_VERSION } from "./constants-CG513DRa.js";
|
|
3
|
+
import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-BEZ9IUf7.js";
|
|
4
|
+
import { A as isCancel, C as log, E as select, M as runCommandSilently, N as require_cross_spawn, _ as getSpinner, b as require_semver, d as readYamlFile, f as scalarString, g as getSilentSpinner, t as cancelAndExit, u as editYamlFile, w as multiselect, x as confirm, y as PackageManager } from "./prompts-CHz_98bJ.js";
|
|
5
|
+
import { a as writeJsonFile, c as parse, i as readJsonFile, n as editJsonFile, o as applyEdits, r as isJsonFile, s as modify, t as detectFormattingOptions } from "./json-qlK6UH0r.js";
|
|
6
|
+
import { t as require_dist } from "./dist-BDYZP12R.js";
|
|
7
|
+
import { a as hasTypesToRewriteInTsconfig, c as rewriteTypesInTsconfig, i as hasBaseUrlInTsconfig, n as findTsconfigFiles, o as hasVitestTypesInTsconfig, s as removeDeprecatedTsconfigFalseOption } from "./tsconfig-7v_BHagU.js";
|
|
8
|
+
import { n as detectPackageMetadata, r as getScopeFromPackageName } from "./package-B4T8RGMG.js";
|
|
9
|
+
import { l as displayRelative, u as rulesDir } from "./agent-DQU8uS6P.js";
|
|
10
10
|
import { n as addMigrationWarning, t as addManualStep } from "./report-BS7ULx7A.js";
|
|
11
|
+
import { a as findUnsafeHookInstallPath, n as SUPPORTED_GIT_HOOK_NAMES } from "./hooks-pNCBWtFT.js";
|
|
11
12
|
import path, { posix, win32 } from "node:path";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
12
14
|
import { detectWorkspace, hasConfigKey, mergeJsonConfig, mergeTsdownConfig, rewriteEslint, rewriteImportsInDirectory, rewritePrettier, rewriteScripts, wrapLazyPlugins } from "../binding/index.js";
|
|
13
15
|
import { styleText } from "node:util";
|
|
14
16
|
import * as actualFS from "node:fs";
|
|
15
17
|
import fs from "node:fs";
|
|
16
18
|
import os from "node:os";
|
|
17
|
-
import { lstatSync as lstatSync$1, readdir, readdirSync, readlinkSync, realpathSync as realpathSync$1 } from "fs";
|
|
18
|
-
import { fileURLToPath } from "node:url";
|
|
19
|
+
import { lstatSync as lstatSync$1, readdir, readdirSync as readdirSync$1, readlinkSync, realpathSync as realpathSync$1 } from "fs";
|
|
19
20
|
import "oxlint";
|
|
20
21
|
import fsPromises, { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
|
|
21
22
|
import { EventEmitter } from "node:events";
|
|
@@ -153,14 +154,7 @@ const PRETTIER_CONFIG_FILES = [
|
|
|
153
154
|
];
|
|
154
155
|
function detectConfigs(projectPath) {
|
|
155
156
|
const configs = {};
|
|
156
|
-
for (const config of
|
|
157
|
-
"vite.config.ts",
|
|
158
|
-
"vite.config.mts",
|
|
159
|
-
"vite.config.cts",
|
|
160
|
-
"vite.config.js",
|
|
161
|
-
"vite.config.mjs",
|
|
162
|
-
"vite.config.cjs"
|
|
163
|
-
]) if (fs.existsSync(path.join(projectPath, config))) {
|
|
157
|
+
for (const config of VITE_CONFIG_FILES) if (fs.existsSync(path.join(projectPath, config))) {
|
|
164
158
|
configs.viteConfig = config;
|
|
165
159
|
break;
|
|
166
160
|
}
|
|
@@ -308,17 +302,7 @@ async function runOxlintMigrateStep(vpBin, cwd, migratePackage, args, spinner, f
|
|
|
308
302
|
}
|
|
309
303
|
async function migrateEslintToOxlint(projectPath, interactive, eslintConfigFile, packages, options) {
|
|
310
304
|
const vpBin = process.env.VP_CLI_BIN ?? "vp";
|
|
311
|
-
const spinner = options?.silent ?
|
|
312
|
-
start: () => {},
|
|
313
|
-
stop: () => {},
|
|
314
|
-
pause: () => {},
|
|
315
|
-
resume: () => {},
|
|
316
|
-
cancel: () => {},
|
|
317
|
-
error: () => {},
|
|
318
|
-
clear: () => {},
|
|
319
|
-
message: () => {},
|
|
320
|
-
isCancelled: false
|
|
321
|
-
} : getSpinner(interactive);
|
|
305
|
+
const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
|
|
322
306
|
if (eslintConfigFile) {
|
|
323
307
|
const { versions } = await import("./versions.js");
|
|
324
308
|
const migratePackage = `@oxlint/migrate@${versions.oxlint}`;
|
|
@@ -778,17 +762,7 @@ async function runPrettierMigrateStep(vpBin, cwd, spinner, failMessage, manualHi
|
|
|
778
762
|
}
|
|
779
763
|
async function migratePrettierToOxfmt(projectPath, interactive, prettierConfigFile, packages, options) {
|
|
780
764
|
const vpBin = process.env.VP_CLI_BIN ?? "vp";
|
|
781
|
-
const spinner = options?.silent ?
|
|
782
|
-
start: () => {},
|
|
783
|
-
stop: () => {},
|
|
784
|
-
pause: () => {},
|
|
785
|
-
resume: () => {},
|
|
786
|
-
cancel: () => {},
|
|
787
|
-
error: () => {},
|
|
788
|
-
clear: () => {},
|
|
789
|
-
message: () => {},
|
|
790
|
-
isCancelled: false
|
|
791
|
-
} : getSpinner(interactive);
|
|
765
|
+
const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
|
|
792
766
|
if (prettierConfigFile) {
|
|
793
767
|
let tempPrettierConfig;
|
|
794
768
|
if (prettierConfigFile === "package.json#prettier") {
|
|
@@ -2711,9 +2685,10 @@ var Minimatch = class {
|
|
|
2711
2685
|
const next = pp[i + 1];
|
|
2712
2686
|
const prev = pp[i - 1];
|
|
2713
2687
|
if (p !== GLOBSTAR || prev === GLOBSTAR) return;
|
|
2714
|
-
if (prev === void 0)
|
|
2715
|
-
|
|
2716
|
-
|
|
2688
|
+
if (prev === void 0) {
|
|
2689
|
+
if (next !== void 0 && next !== GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
2690
|
+
else pp[i] = twoStar;
|
|
2691
|
+
} else if (next === void 0) pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
|
|
2717
2692
|
else if (next !== GLOBSTAR) {
|
|
2718
2693
|
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
2719
2694
|
pp[i + 1] = GLOBSTAR;
|
|
@@ -2971,7 +2946,7 @@ var L = class c {
|
|
|
2971
2946
|
}
|
|
2972
2947
|
}
|
|
2973
2948
|
getRemainingTTL(t) {
|
|
2974
|
-
return this.#s.has(t) ?
|
|
2949
|
+
return this.#s.has(t) ? 1 / 0 : 0;
|
|
2975
2950
|
}
|
|
2976
2951
|
#j() {
|
|
2977
2952
|
let t = new z(this.#o), e = new z(this.#o);
|
|
@@ -3011,7 +2986,7 @@ var L = class c {
|
|
|
3011
2986
|
let r = this.#s.get(h);
|
|
3012
2987
|
if (r === void 0) return 0;
|
|
3013
2988
|
let a = t[r], w = e[r];
|
|
3014
|
-
if (!a || !w) return
|
|
2989
|
+
if (!a || !w) return 1 / 0;
|
|
3015
2990
|
return a - ((n || o()) - w);
|
|
3016
2991
|
}, this.#p = (h) => {
|
|
3017
2992
|
let r = e[h], a = t[h];
|
|
@@ -4211,7 +4186,7 @@ const realpathSync$2 = realpathSync$1.native;
|
|
|
4211
4186
|
const defaultFS = {
|
|
4212
4187
|
lstatSync: lstatSync$1,
|
|
4213
4188
|
readdir,
|
|
4214
|
-
readdirSync,
|
|
4189
|
+
readdirSync: readdirSync$1,
|
|
4215
4190
|
readlinkSync,
|
|
4216
4191
|
realpathSync: realpathSync$2,
|
|
4217
4192
|
promises: {
|
|
@@ -4251,7 +4226,7 @@ const ENOREALPATH = 512;
|
|
|
4251
4226
|
const ENOCHILD = 704;
|
|
4252
4227
|
const TYPEMASK = 1023;
|
|
4253
4228
|
const entToType = (s) => s.isFile() ? IFREG : s.isDirectory() ? IFDIR : s.isSymbolicLink() ? IFLNK : s.isCharacterDevice() ? IFCHR : s.isBlockDevice() ? IFBLK : s.isSocket() ? IFSOCK : s.isFIFO() ? IFIFO : UNKNOWN;
|
|
4254
|
-
const normalizeCache = new L({ max:
|
|
4229
|
+
const normalizeCache = new L({ max: 4096 });
|
|
4255
4230
|
const normalize$1 = (s) => {
|
|
4256
4231
|
const c = normalizeCache.get(s);
|
|
4257
4232
|
if (c) return c;
|
|
@@ -4259,7 +4234,7 @@ const normalize$1 = (s) => {
|
|
|
4259
4234
|
normalizeCache.set(s, n);
|
|
4260
4235
|
return n;
|
|
4261
4236
|
};
|
|
4262
|
-
const normalizeNocaseCache = new L({ max:
|
|
4237
|
+
const normalizeNocaseCache = new L({ max: 4096 });
|
|
4263
4238
|
const normalizeNocase = (s) => {
|
|
4264
4239
|
const c = normalizeNocaseCache.get(s);
|
|
4265
4240
|
if (c) return c;
|
|
@@ -5979,8 +5954,10 @@ var Ignore = class {
|
|
|
5979
5954
|
const absolute = p.isAbsolute();
|
|
5980
5955
|
if (absolute) this.absolute.push(m);
|
|
5981
5956
|
else this.relative.push(m);
|
|
5982
|
-
if (children)
|
|
5983
|
-
|
|
5957
|
+
if (children) {
|
|
5958
|
+
if (absolute) this.absoluteChildren.push(m);
|
|
5959
|
+
else this.relativeChildren.push(m);
|
|
5960
|
+
}
|
|
5984
5961
|
}
|
|
5985
5962
|
}
|
|
5986
5963
|
ignored(p) {
|
|
@@ -8118,20 +8095,21 @@ function ensureVitePlusBootstrap(workspaceInfo, report) {
|
|
|
8118
8095
|
});
|
|
8119
8096
|
result.packageJson = result.packageJson || childChanged;
|
|
8120
8097
|
}
|
|
8121
|
-
if (workspaceInfo.packageManager === PackageManager.pnpm)
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8098
|
+
if (workspaceInfo.packageManager === PackageManager.pnpm) {
|
|
8099
|
+
if (usePnpmWorkspaceYaml) {
|
|
8100
|
+
const before = readTextFileIfExists(pnpmWorkspaceYamlPath);
|
|
8101
|
+
migratePnpmSettingsToWorkspaceYaml(projectPath, movedPnpmSettings);
|
|
8102
|
+
const catalogDependencyResolver = readPnpmWorkspaceCatalogDependencyResolver(projectPath);
|
|
8103
|
+
if (movedPnpmSettings !== void 0 || result.packageJson || ecosystemCatalogReferencesPending || !pnpmWorkspaceExoticSubdepsSettingSatisfied(projectPath) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath) || workspaceCatalogVitePlusDependencyPending(projectPath, workspaceInfo.packages, catalogDependencyResolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, catalogDependencyResolver) || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest)) rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserBuilds, usesVitest, vitestEcosystemPackages, true, providerCatalogAdditions);
|
|
8104
|
+
if (fs.existsSync(pnpmWorkspaceYamlPath)) ensurePnpmWorkspacePackages(projectPath, workspaceInfo.workspacePatterns);
|
|
8105
|
+
result.packageManagerConfig = before !== readTextFileIfExists(pnpmWorkspaceYamlPath);
|
|
8106
|
+
} else {
|
|
8107
|
+
const exoticChanged = ensurePnpmWorkspaceExoticSubdepsSetting(projectPath);
|
|
8108
|
+
if (fs.existsSync(pnpmWorkspaceYamlPath)) ensurePnpmWorkspacePackages(projectPath, workspaceInfo.workspacePatterns);
|
|
8109
|
+
const after = readTextFileIfExists(pnpmWorkspaceYamlPath);
|
|
8110
|
+
result.packageManagerConfig = exoticChanged || pnpmWorkspaceCatalogBefore !== after;
|
|
8111
|
+
}
|
|
8112
|
+
} else if (workspaceInfo.packageManager === PackageManager.yarn) {
|
|
8135
8113
|
const yarnrcYmlPath = path.join(projectPath, ".yarnrc.yml");
|
|
8136
8114
|
const before = readTextFileIfExists(yarnrcYmlPath);
|
|
8137
8115
|
rewriteYarnrcYml(projectPath, usesVitest, vitestEcosystemPackages, providerCatalogAdditions, supportCatalog);
|
|
@@ -8625,16 +8603,41 @@ function rewriteAllImports(projectPath, silent = false, report, preserveNuxtVite
|
|
|
8625
8603
|
log.success(`Rewrote imports in ${modified === 1 ? "one file" : `${modified} files`}`);
|
|
8626
8604
|
log.info(result.modifiedFiles.map((file) => ` ${displayRelative(file)}`).join("\n"));
|
|
8627
8605
|
}
|
|
8628
|
-
if (errors > 0)
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8606
|
+
if (errors > 0) {
|
|
8607
|
+
if (report) warnMigration(`${errors === 1 ? "one file had an error" : `${errors} files had errors`} while rewriting imports`, report);
|
|
8608
|
+
else {
|
|
8609
|
+
log.warn(`⚠ ${errors === 1 ? "one file had an error" : `${errors} files had errors`}:`);
|
|
8610
|
+
for (const error of result.errors) log.error(` ${displayRelative(error.path)}: ${error.message}`);
|
|
8611
|
+
}
|
|
8632
8612
|
}
|
|
8633
8613
|
return modified > 0;
|
|
8634
8614
|
}
|
|
8635
8615
|
//#endregion
|
|
8636
|
-
//#region src/
|
|
8616
|
+
//#region src/utils/git.ts
|
|
8637
8617
|
var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
|
|
8618
|
+
/**
|
|
8619
|
+
* Walk up from `startPath` looking for `.git` (directory or file — submodules
|
|
8620
|
+
* use a `.git` file). Returns the directory that contains `.git`, or `null`.
|
|
8621
|
+
*/
|
|
8622
|
+
function findGitRoot(startPath) {
|
|
8623
|
+
let dir = startPath;
|
|
8624
|
+
while (true) {
|
|
8625
|
+
if (fs.existsSync(path.join(dir, ".git"))) return dir;
|
|
8626
|
+
const parent = path.dirname(dir);
|
|
8627
|
+
if (parent === dir) return null;
|
|
8628
|
+
dir = parent;
|
|
8629
|
+
}
|
|
8630
|
+
}
|
|
8631
|
+
async function initGitRepository(cwd) {
|
|
8632
|
+
return (await runCommandSilently({
|
|
8633
|
+
command: "git",
|
|
8634
|
+
args: ["init"],
|
|
8635
|
+
cwd,
|
|
8636
|
+
envs: process.env
|
|
8637
|
+
})).exitCode === 0;
|
|
8638
|
+
}
|
|
8639
|
+
//#endregion
|
|
8640
|
+
//#region src/migration/migrator/git-hooks.ts
|
|
8638
8641
|
const OTHER_HOOK_TOOLS = [
|
|
8639
8642
|
"simple-git-hooks",
|
|
8640
8643
|
"lefthook",
|
|
@@ -8669,19 +8672,6 @@ function findNonRegularViteHookPath(projectPath) {
|
|
|
8669
8672
|
}
|
|
8670
8673
|
return null;
|
|
8671
8674
|
}
|
|
8672
|
-
/**
|
|
8673
|
-
* Walk up from `startPath` looking for `.git` (directory or file — submodules
|
|
8674
|
-
* use a `.git` file). Returns the directory that contains `.git`, or `null`.
|
|
8675
|
-
*/
|
|
8676
|
-
function findGitRoot(startPath) {
|
|
8677
|
-
let dir = startPath;
|
|
8678
|
-
while (true) {
|
|
8679
|
-
if (fs.existsSync(path.join(dir, ".git"))) return dir;
|
|
8680
|
-
const parent = path.dirname(dir);
|
|
8681
|
-
if (parent === dir) return null;
|
|
8682
|
-
dir = parent;
|
|
8683
|
-
}
|
|
8684
|
-
}
|
|
8685
8675
|
function findWorkspacePackageHookPolicy(workspaceRoot, packages) {
|
|
8686
8676
|
for (const pkg of packages) {
|
|
8687
8677
|
const packagePath = path.join(workspaceRoot, pkg.path);
|
|
@@ -8996,10 +8986,26 @@ function readRulesYaml() {
|
|
|
8996
8986
|
cachedRulesYaml ??= fs.readFileSync(RULES_YAML_PATH, "utf8");
|
|
8997
8987
|
return cachedRulesYaml;
|
|
8998
8988
|
}
|
|
8989
|
+
function splitRuleDocuments(yaml) {
|
|
8990
|
+
const lines = yaml.split("\n");
|
|
8991
|
+
const documents = [];
|
|
8992
|
+
let start = 0;
|
|
8993
|
+
for (const [index, line] of lines.entries()) {
|
|
8994
|
+
if (line.trimEnd() !== "---") continue;
|
|
8995
|
+
let documentStart = index;
|
|
8996
|
+
while (documentStart > start && lines[documentStart - 1].trimStart().startsWith("#")) documentStart--;
|
|
8997
|
+
if (documentStart > start) {
|
|
8998
|
+
documents.push(lines.slice(start, documentStart).join("\n"));
|
|
8999
|
+
start = documentStart;
|
|
9000
|
+
}
|
|
9001
|
+
}
|
|
9002
|
+
documents.push(lines.slice(start).join("\n"));
|
|
9003
|
+
return documents;
|
|
9004
|
+
}
|
|
8999
9005
|
function getScriptRulesYaml(skipStagedMigration) {
|
|
9000
9006
|
const yaml = readRulesYaml();
|
|
9001
9007
|
if (!skipStagedMigration) return yaml;
|
|
9002
|
-
cachedRulesYamlNoLintStaged ??= yaml
|
|
9008
|
+
cachedRulesYamlNoLintStaged ??= splitRuleDocuments(yaml).filter((document) => !document.includes("id: replace-lint-staged")).join("\n");
|
|
9003
9009
|
return cachedRulesYamlNoLintStaged;
|
|
9004
9010
|
}
|
|
9005
9011
|
function getCoreMigrationProjectPaths(workspaceInfo) {
|
|
@@ -9236,7 +9242,8 @@ const VSCODE_SETTINGS = {
|
|
|
9236
9242
|
"[javascriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
|
|
9237
9243
|
"[typescript]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
|
|
9238
9244
|
"[typescriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
|
|
9239
|
-
"oxc.
|
|
9245
|
+
"oxc.disableNestedConfig": true,
|
|
9246
|
+
"oxc.fmt.disableNestedConfig": true,
|
|
9240
9247
|
"editor.formatOnSave": true,
|
|
9241
9248
|
"editor.formatOnSaveMode": "file",
|
|
9242
9249
|
"editor.codeActionsOnSave": { "source.fixAll.oxc": "explicit" }
|
|
@@ -9280,19 +9287,65 @@ const ZED_SETTINGS = {
|
|
|
9280
9287
|
...language === "JavaScript" ? { code_action: "source.fixAll.oxc" } : {}
|
|
9281
9288
|
}]))
|
|
9282
9289
|
};
|
|
9283
|
-
const
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
+
const JETBRAINS_EXTERNAL_DEPENDENCIES = `<?xml version="1.0" encoding="UTF-8"?>
|
|
9291
|
+
<project version="4">
|
|
9292
|
+
<component name="ExternalDependencies">
|
|
9293
|
+
<plugin id="com.github.oxc.project.oxcintellijplugin" />
|
|
9294
|
+
</component>
|
|
9295
|
+
</project>
|
|
9296
|
+
`;
|
|
9297
|
+
function jetbrainsWorkspaceConfig(packageManager) {
|
|
9298
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
9299
|
+
<project version="4">
|
|
9300
|
+
<component name="PropertiesComponent">
|
|
9301
|
+
<![CDATA[${JSON.stringify({ keyToString: {
|
|
9302
|
+
"javascript.preferred.runtime.type.id": "node",
|
|
9303
|
+
nodejs_interpreter_path: "$USER_HOME$/.vite-plus/bin/node.exe",
|
|
9304
|
+
nodejs_package_manager_path: packageManager
|
|
9305
|
+
} }, null, 2)}]]>
|
|
9306
|
+
</component>
|
|
9307
|
+
</project>
|
|
9308
|
+
`;
|
|
9309
|
+
}
|
|
9310
|
+
const EDITORS = [
|
|
9311
|
+
{
|
|
9312
|
+
id: "vscode",
|
|
9313
|
+
label: "VSCode",
|
|
9314
|
+
targetDir: ".vscode",
|
|
9315
|
+
files: {
|
|
9316
|
+
"settings.json": VSCODE_SETTINGS,
|
|
9317
|
+
"extensions.json": VSCODE_EXTENSIONS
|
|
9318
|
+
}
|
|
9319
|
+
},
|
|
9320
|
+
{
|
|
9321
|
+
id: "zed",
|
|
9322
|
+
label: "Zed",
|
|
9323
|
+
targetDir: ".zed",
|
|
9324
|
+
files: { "settings.json": ZED_SETTINGS }
|
|
9325
|
+
},
|
|
9326
|
+
{
|
|
9327
|
+
id: "jetbrains",
|
|
9328
|
+
label: "JetBrains (IntelliJ, WebStorm, etc)",
|
|
9329
|
+
targetDir: ".idea",
|
|
9330
|
+
files: {
|
|
9331
|
+
"externalDependencies.xml": JETBRAINS_EXTERNAL_DEPENDENCIES,
|
|
9332
|
+
"workspace.xml": jetbrainsWorkspaceConfig(PackageManager.pnpm),
|
|
9333
|
+
"OxfmtSettings.xml": `<?xml version="1.0" encoding="UTF-8"?>
|
|
9334
|
+
<project version="4">
|
|
9335
|
+
<component name="OxfmtSettings">
|
|
9336
|
+
<option name="preferOxfmtCodeStyleSettings" value="true" />
|
|
9337
|
+
</component>
|
|
9338
|
+
</project>
|
|
9339
|
+
`
|
|
9340
|
+
}
|
|
9290
9341
|
}
|
|
9342
|
+
];
|
|
9343
|
+
const EDITOR_ALIASES = [{
|
|
9344
|
+
id: "intellij",
|
|
9345
|
+
alias: "jetbrains"
|
|
9291
9346
|
}, {
|
|
9292
|
-
id: "
|
|
9293
|
-
|
|
9294
|
-
targetDir: ".zed",
|
|
9295
|
-
files: { "settings.json": ZED_SETTINGS }
|
|
9347
|
+
id: "webstorm",
|
|
9348
|
+
alias: "jetbrains"
|
|
9296
9349
|
}];
|
|
9297
9350
|
async function selectEditor({ interactive, editor, onCancel }) {
|
|
9298
9351
|
if (editor === false) return;
|
|
@@ -9374,7 +9427,7 @@ function detectEditorConflicts({ projectRoot, editorId }) {
|
|
|
9374
9427
|
}
|
|
9375
9428
|
return conflicts;
|
|
9376
9429
|
}
|
|
9377
|
-
async function writeEditorConfigs({ projectRoot, editorId, interactive, conflictDecisions, silent = false, extraVsCodeSettings }) {
|
|
9430
|
+
async function writeEditorConfigs({ projectRoot, editorId, interactive, conflictDecisions, silent = false, extraVsCodeSettings, packageManager = PackageManager.pnpm }) {
|
|
9378
9431
|
const editorIds = normalizeEditorSelection(editorId);
|
|
9379
9432
|
if (editorIds.length === 0) return;
|
|
9380
9433
|
for (const currentEditorId of editorIds) await writeEditorConfig({
|
|
@@ -9383,10 +9436,11 @@ async function writeEditorConfigs({ projectRoot, editorId, interactive, conflict
|
|
|
9383
9436
|
interactive,
|
|
9384
9437
|
conflictDecisions,
|
|
9385
9438
|
silent,
|
|
9386
|
-
extraVsCodeSettings
|
|
9439
|
+
extraVsCodeSettings,
|
|
9440
|
+
packageManager
|
|
9387
9441
|
});
|
|
9388
9442
|
}
|
|
9389
|
-
async function writeEditorConfig({ projectRoot, editorId, interactive, conflictDecisions, silent, extraVsCodeSettings }) {
|
|
9443
|
+
async function writeEditorConfig({ projectRoot, editorId, interactive, conflictDecisions, silent, extraVsCodeSettings, packageManager }) {
|
|
9390
9444
|
const editorConfig = EDITORS.find((e) => e.id === editorId);
|
|
9391
9445
|
if (!editorConfig) return;
|
|
9392
9446
|
const targetDir = path.join(projectRoot, editorConfig.targetDir);
|
|
@@ -9395,8 +9449,9 @@ async function writeEditorConfig({ projectRoot, editorId, interactive, conflictD
|
|
|
9395
9449
|
const incoming = editorId === "vscode" && fileName === "settings.json" && extraVsCodeSettings ? {
|
|
9396
9450
|
...extraVsCodeSettings,
|
|
9397
9451
|
...baseIncoming
|
|
9398
|
-
} : baseIncoming;
|
|
9452
|
+
} : editorId === "jetbrains" && fileName === "workspace.xml" ? jetbrainsWorkspaceConfig(packageManager) : baseIncoming;
|
|
9399
9453
|
const filePath = path.join(targetDir, fileName);
|
|
9454
|
+
const jsonFormat = isJsonLikeFile(fileName);
|
|
9400
9455
|
if (fs.existsSync(filePath)) {
|
|
9401
9456
|
const displayPath = `${editorConfig.targetDir}/${fileName}`;
|
|
9402
9457
|
let conflictAction;
|
|
@@ -9404,11 +9459,11 @@ async function writeEditorConfig({ projectRoot, editorId, interactive, conflictD
|
|
|
9404
9459
|
if (preResolved) conflictAction = preResolved;
|
|
9405
9460
|
else if (interactive) {
|
|
9406
9461
|
const action = await select({
|
|
9407
|
-
message: `${displayPath} already exists.\n ` + styleText("gray", `Vite+ adds ${editorConfig.label} settings for the built-in linter and formatter. Merge adds new keys without overwriting existing ones.`),
|
|
9462
|
+
message: `${displayPath} already exists.\n ` + styleText("gray", jsonFormat ? `Vite+ adds ${editorConfig.label} settings for the built-in linter and formatter. Merge adds new keys without overwriting existing ones.` : `Vite+ adds ${editorConfig.label} settings for the built-in linter and formatter. Overwrite replaces the existing file with the generated config.`),
|
|
9408
9463
|
options: [{
|
|
9409
|
-
label: "Merge",
|
|
9464
|
+
label: jsonFormat ? "Merge" : "Overwrite",
|
|
9410
9465
|
value: "merge",
|
|
9411
|
-
hint: "Merge new settings into existing file"
|
|
9466
|
+
hint: jsonFormat ? "Merge new settings into existing file" : "Replace existing file with generated config"
|
|
9412
9467
|
}, {
|
|
9413
9468
|
label: "Skip",
|
|
9414
9469
|
value: "skip",
|
|
@@ -9417,15 +9472,34 @@ async function writeEditorConfig({ projectRoot, editorId, interactive, conflictD
|
|
|
9417
9472
|
initialValue: "skip"
|
|
9418
9473
|
});
|
|
9419
9474
|
conflictAction = isCancel(action) || action === "skip" ? "skip" : "merge";
|
|
9420
|
-
} else conflictAction = "merge";
|
|
9421
|
-
if (conflictAction === "merge")
|
|
9422
|
-
|
|
9475
|
+
} else conflictAction = jsonFormat ? "merge" : "skip";
|
|
9476
|
+
if (conflictAction === "merge") {
|
|
9477
|
+
if (jsonFormat) {
|
|
9478
|
+
if (!isPlainObject(incoming)) throw new Error(`Cannot merge editor config: ${displayPath} incoming value is not JSON`);
|
|
9479
|
+
mergeAndWriteEditorConfig(filePath, incoming, fileName, displayPath, silent);
|
|
9480
|
+
} else writeTextEditorConfig(filePath, incoming, displayPath, silent);
|
|
9481
|
+
} else if (!silent) log.info(`Skipped writing ${displayPath}`);
|
|
9423
9482
|
continue;
|
|
9424
9483
|
}
|
|
9425
|
-
|
|
9484
|
+
if (jsonFormat) {
|
|
9485
|
+
if (!isPlainObject(incoming)) throw new Error(`Cannot write editor config: ${editorConfig.targetDir}/${fileName} must be JSON`);
|
|
9486
|
+
writeJsonFile(filePath, incoming);
|
|
9487
|
+
} else writeTextEditorConfig(filePath, incoming, `${editorConfig.targetDir}/${fileName}`, silent);
|
|
9426
9488
|
if (!silent) log.success(`Wrote editor config to ${editorConfig.targetDir}/${fileName}`);
|
|
9427
9489
|
}
|
|
9428
9490
|
}
|
|
9491
|
+
function isJsonLikeFile(fileName) {
|
|
9492
|
+
const ext = path.extname(fileName).toLowerCase();
|
|
9493
|
+
return ext === ".json" || ext === ".jsonc";
|
|
9494
|
+
}
|
|
9495
|
+
function writeTextEditorConfig(filePath, incoming, displayPath, silent = false) {
|
|
9496
|
+
if (typeof incoming !== "string") throw new Error(`Cannot write editor config: ${displayPath} must be text content`);
|
|
9497
|
+
if ((fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf-8") : void 0) === incoming) {
|
|
9498
|
+
if (!silent) log.info(`No changes needed for ${displayPath}`);
|
|
9499
|
+
return;
|
|
9500
|
+
}
|
|
9501
|
+
fs.writeFileSync(filePath, incoming, "utf-8");
|
|
9502
|
+
}
|
|
9429
9503
|
function normalizeEditorSelection(editorId) {
|
|
9430
9504
|
if (!editorId) return [];
|
|
9431
9505
|
return [...new Set(Array.isArray(editorId) ? editorId : [editorId])];
|
|
@@ -9497,7 +9571,13 @@ function mergeExtensionsText(text, existing, incoming, formattingOptions) {
|
|
|
9497
9571
|
}
|
|
9498
9572
|
function resolveEditorId(editor) {
|
|
9499
9573
|
const normalized = editor.trim().toLowerCase();
|
|
9500
|
-
|
|
9574
|
+
const match = EDITORS.find((option) => option.id === normalized || option.label.toLowerCase() === normalized);
|
|
9575
|
+
if (match) return match.id;
|
|
9576
|
+
const aliasMatch = EDITOR_ALIASES.find((option) => option.id === normalized);
|
|
9577
|
+
if (aliasMatch) {
|
|
9578
|
+
log.warn(`--editor ${aliasMatch.id} was passed; use --editor ${aliasMatch.alias} instead, as it's the canonical ID for that editor.`);
|
|
9579
|
+
return aliasMatch.alias;
|
|
9580
|
+
}
|
|
9501
9581
|
}
|
|
9502
9582
|
function resolveEditorIds(editors) {
|
|
9503
9583
|
const editorIds = editors.flatMap((editor) => {
|
|
@@ -9508,4 +9588,4 @@ function resolveEditorIds(editors) {
|
|
|
9508
9588
|
return uniqueEditorIds.length === 0 ? void 0 : uniqueEditorIds;
|
|
9509
9589
|
}
|
|
9510
9590
|
//#endregion
|
|
9511
|
-
export {
|
|
9591
|
+
export { isBingoTemplate as A, warnPackageLevelPrettier as B, mergeViteConfigFiles as C, configureYarnNodeModulesMode as D, ensureVitePlusBootstrap as E, hasFrameworkShim as F, promptEslintMigration as G, detectEslintProject as H, confirmPrettierMigration as I, warnPackageLevelEslint as J, warnIncompatibleEslintIntegration as K, detectPrettierProject as L, updateWorkspaceConfig as M, addFrameworkShim as N, detectYarnPnpMode as O, detectFramework as P, migratePrettierToOxfmt as R, injectLintTypeCheckDefaults as S, detectVitePlusBootstrapPending as T, detectIncompatibleEslintIntegration as U, confirmEslintMigration as V, migrateEslintToOxlint as W, checkVitestVersion as X, checkViteVersion as Y, preflightGitHooksSetup as _, selectEditors as a, initGitRepository as b, rewriteMonorepoProject as c, finalizeCoreMigrationForExistingVitePlus as d, detectNodeVersionManagerFile as f, installGitHooks as g, detectLegacyGitHooksMigrationCandidate as h, selectEditor as i, updatePackageJsonWithDeps as j, detectWorkspace$1 as k, rewriteStandaloneProject as l, setPackageManager as m, detectExistingEditors as n, writeEditorConfigs as o, migrateNodeVersionManagerFile as p, warnLegacyEslintConfig as q, isJsonLikeFile as r, rewriteMonorepo as s, detectEditorConflicts as t, detectPendingCoreMigration as u, shouldSkipStagedMigrationForHooks as v, collectToolchainVersionChanges as w, injectCreateDefaultTemplate as x, findGitRoot as y, promptPrettierMigration as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { i as log, l as renderCliDoc, o as printHeader } from "../terminal-Bz-ps6rJ.js";
|
|
2
|
+
import { t as lib_default } from "../lib-L3DWSRQp.js";
|
|
3
|
+
import { i as enable, l as status, r as disable, t as DEFAULT_HOOKS_DIR } from "../hooks-pNCBWtFT.js";
|
|
4
|
+
//#region src/hooks/args.ts
|
|
5
|
+
const KNOWN_HOOKS_ARG_KEYS = /* @__PURE__ */ new Set([
|
|
6
|
+
"_",
|
|
7
|
+
"help",
|
|
8
|
+
"h",
|
|
9
|
+
"hooks-dir"
|
|
10
|
+
]);
|
|
11
|
+
/**
|
|
12
|
+
* Reject leftover positionals and unknown flags before enable/disable mutate state.
|
|
13
|
+
*/
|
|
14
|
+
function unexpectedHooksArgsError(args) {
|
|
15
|
+
const extra = args._.map(String).filter((value) => value !== "");
|
|
16
|
+
if (extra.length > 0) return `Unexpected argument "${extra[0]}". Use --hooks-dir <path> to set a custom hooks directory.`;
|
|
17
|
+
for (const key of Object.keys(args)) if (!KNOWN_HOOKS_ARG_KEYS.has(key)) return `Unknown option "--${key}".`;
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/hooks/bin.ts
|
|
22
|
+
const SUBCOMMANDS = [
|
|
23
|
+
"enable",
|
|
24
|
+
"disable",
|
|
25
|
+
"status"
|
|
26
|
+
];
|
|
27
|
+
function isSubcommand(value) {
|
|
28
|
+
return !!value && SUBCOMMANDS.includes(value);
|
|
29
|
+
}
|
|
30
|
+
function printHelp() {
|
|
31
|
+
const helpMessage = renderCliDoc({
|
|
32
|
+
usage: "vp hooks <COMMAND> [OPTIONS]",
|
|
33
|
+
summary: "Manage the Vite+ Git hook dispatcher for this repository.",
|
|
34
|
+
documentationUrl: "https://viteplus.dev/guide/commit-hooks",
|
|
35
|
+
sections: [
|
|
36
|
+
{
|
|
37
|
+
title: "Commands",
|
|
38
|
+
rows: [
|
|
39
|
+
{
|
|
40
|
+
label: "enable",
|
|
41
|
+
description: "Install or refresh the hook dispatcher (sets core.hooksPath)"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: "disable",
|
|
45
|
+
description: "Disable hooks: unset core.hooksPath, remove <dir>/_, persist preference"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: "status",
|
|
49
|
+
description: "Show preference, core.hooksPath, and dispatcher state"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: "Options",
|
|
55
|
+
rows: [{
|
|
56
|
+
label: "--hooks-dir <path>",
|
|
57
|
+
description: `Custom hooks directory (default: ${DEFAULT_HOOKS_DIR}, or last used)`
|
|
58
|
+
}, {
|
|
59
|
+
label: "-h, --help",
|
|
60
|
+
description: "Show this help message"
|
|
61
|
+
}]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: "Environment",
|
|
65
|
+
rows: [{
|
|
66
|
+
label: "VP_GIT_HOOKS=0",
|
|
67
|
+
description: "Skip dispatcher install in enable (and skip hooks at commit time)"
|
|
68
|
+
}]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
title: "Examples",
|
|
72
|
+
lines: [
|
|
73
|
+
" vp hooks enable",
|
|
74
|
+
" vp hooks enable --hooks-dir .custom-hooks",
|
|
75
|
+
" vp hooks disable",
|
|
76
|
+
" vp hooks status"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
printHeader();
|
|
82
|
+
log(helpMessage);
|
|
83
|
+
}
|
|
84
|
+
function applyResult(result) {
|
|
85
|
+
if (result.message) log(result.message);
|
|
86
|
+
if (result.isError) process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
async function main() {
|
|
89
|
+
const raw = process.argv.slice(3);
|
|
90
|
+
const first = raw[0];
|
|
91
|
+
const wantsHelp = raw.includes("-h") || raw.includes("--help");
|
|
92
|
+
if (!first || first === "-h" || first === "--help") {
|
|
93
|
+
printHelp();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!isSubcommand(first)) {
|
|
97
|
+
log(`Unknown hooks command "${first}". Expected one of: ${SUBCOMMANDS.join(", ")}`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
const subcommand = first;
|
|
101
|
+
const args = lib_default(raw.slice(1), {
|
|
102
|
+
boolean: ["help"],
|
|
103
|
+
string: ["hooks-dir"],
|
|
104
|
+
alias: { h: "help" }
|
|
105
|
+
});
|
|
106
|
+
if (args.help || wantsHelp) {
|
|
107
|
+
printHelp();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const unexpected = unexpectedHooksArgsError(args);
|
|
111
|
+
if (unexpected) {
|
|
112
|
+
log(unexpected);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
const dirFlag = args["hooks-dir"];
|
|
116
|
+
switch (subcommand) {
|
|
117
|
+
case "enable":
|
|
118
|
+
applyResult(enable(dirFlag));
|
|
119
|
+
return;
|
|
120
|
+
case "disable":
|
|
121
|
+
applyResult(disable(dirFlag));
|
|
122
|
+
return;
|
|
123
|
+
case "status":
|
|
124
|
+
applyResult(status(dirFlag));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
main();
|
|
129
|
+
//#endregion
|
|
130
|
+
export {};
|