vite-plus 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding/index.cjs +116 -55
- package/binding/index.d.cts +31 -0
- package/dist/{agent-D8oxxhVR.js → agent-CowvWq3j.js} +2 -2
- package/dist/bin.js +30 -8
- package/dist/config/bin.js +5 -5
- package/dist/{constants-DRUnJ_Dz.js → constants-D5f7inVN.js} +6 -2
- package/dist/create/bin.js +115 -65
- package/dist/{define-config-Cv2P6NT2.cjs → define-config-BGCfAiIo.cjs} +35 -3
- package/dist/{define-config-rPhYIFSn.d.ts → define-config-BrvHRi-G.d.ts} +30 -2
- package/dist/{define-config-ChwJcu5e.js → define-config-XKYhw0xH.js} +30 -5
- package/dist/define-config.cjs +2 -1
- package/dist/define-config.d.ts +2 -2
- package/dist/define-config.js +1 -1
- package/dist/{editor-ClL78D8u.js → editor-BVaNnIey.js} +1266 -884
- package/dist/hooks/bin.js +2 -2
- package/dist/{hooks-xRcJPc-O.js → hooks-w_e2whkQ.js} +40 -21
- package/dist/index.cjs +4 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/lint-plugins.cjs +1 -1
- package/dist/migration/bin.js +1302 -311
- package/dist/migration/compat/worker.js +1 -1
- package/dist/{oxlint-plugin-config-BVpqYdcC.js → oxlint-plugin-config-5hVqz4kj.js} +1 -1
- package/dist/oxlint-plugin.js +29 -4
- package/dist/pack-bin.js +2 -2
- package/dist/{package-DzsomcUD.js → package-DLUCo6L_.js} +1 -1
- package/dist/{prompts-GL1vj0wk.js → prompts-DLpJGhfK.js} +3 -3
- package/dist/register.d.ts +1 -0
- package/dist/register.js +12 -0
- package/dist/{report-DLHO30yZ.js → report-BEdpIQvC.js} +2 -0
- package/dist/{resolve-vite-config-Dn5896A4.js → resolve-vite-config-D-JtjGRa.js} +2 -2
- package/dist/{resolve-vite-config-QO6cC0SP.js → resolve-vite-config-D7IUZYKq.js} +1 -1
- package/dist/script-esm-hooks.d.ts +5 -2
- package/dist/script-esm-hooks.js +5 -2
- package/dist/script-preload.cjs +24 -1
- package/dist/script-register.js +7 -2
- package/dist/script-watch.js +135 -41
- package/dist/staged/bin.js +2 -2
- package/dist/sync-versions/bin.js +1 -1
- package/dist/toolchain.js +14 -14
- package/dist/toolchain.json +14 -14
- package/dist/{tsconfig-LE_mAwe_.js → tsconfig-D3DiCiW6.js} +2 -2
- package/dist/{tsconfig-Do6MAG_f.js → tsconfig-DLERIAbF.js} +1 -1
- package/dist/version.js +2 -2
- package/dist/versions.js +7 -7
- package/docs/config/check.md +2 -0
- package/docs/config/fmt.md +1 -1
- package/docs/config/lint.md +1 -1
- package/docs/config/run.md +6 -2
- package/docs/config/staged.md +1 -1
- package/docs/guide/check.md +5 -1
- package/docs/guide/ci.md +2 -2
- package/docs/guide/create.md +1 -1
- package/docs/guide/env.md +1 -1
- package/docs/guide/global-cli.md +13 -9
- package/docs/guide/homebrew.md +127 -0
- package/docs/guide/ide-integration.md +1 -3
- package/docs/guide/implode.md +5 -3
- package/docs/guide/index.md +4 -4
- package/docs/guide/local-cli.md +22 -1
- package/docs/guide/migrate-rules.md +81 -22
- package/docs/guide/migrate.md +9 -9
- package/docs/guide/package-management/add.md +84 -0
- package/docs/guide/package-management/approve-builds.md +48 -0
- package/docs/guide/package-management/audit.md +39 -0
- package/docs/guide/package-management/cache.md +53 -0
- package/docs/guide/package-management/ci.md +28 -0
- package/docs/guide/package-management/config.md +119 -0
- package/docs/guide/package-management/dedupe.md +32 -0
- package/docs/guide/package-management/deprecate.md +39 -0
- package/docs/guide/package-management/dist-tag.md +61 -0
- package/docs/guide/package-management/dlx.md +40 -0
- package/docs/guide/package-management/fund.md +32 -0
- package/docs/guide/package-management/global-packages.md +32 -0
- package/docs/guide/package-management/index.md +78 -0
- package/docs/guide/package-management/info.md +35 -0
- package/docs/guide/package-management/install.md +89 -0
- package/docs/guide/package-management/licenses.md +42 -0
- package/docs/guide/package-management/link.md +29 -0
- package/docs/guide/package-management/list.md +60 -0
- package/docs/guide/package-management/login.md +34 -0
- package/docs/guide/package-management/logout.md +34 -0
- package/docs/guide/package-management/outdated.md +60 -0
- package/docs/guide/package-management/owner.md +79 -0
- package/docs/guide/package-management/pack.md +40 -0
- package/docs/guide/package-management/package-manager-selection.md +60 -0
- package/docs/guide/package-management/patch-commit.md +27 -0
- package/docs/guide/package-management/patch.md +29 -0
- package/docs/guide/package-management/ping.md +32 -0
- package/docs/guide/package-management/pkg.md +88 -0
- package/docs/guide/package-management/prune.md +34 -0
- package/docs/guide/package-management/publish.md +61 -0
- package/docs/guide/package-management/rebuild.md +31 -0
- package/docs/guide/package-management/remove.md +47 -0
- package/docs/guide/package-management/search.md +38 -0
- package/docs/guide/package-management/stage.md +175 -0
- package/docs/guide/package-management/team.md +140 -0
- package/docs/guide/package-management/token.md +87 -0
- package/docs/guide/package-management/unlink.md +33 -0
- package/docs/guide/package-management/update.md +62 -0
- package/docs/guide/package-management/version.md +36 -0
- package/docs/guide/package-management/whoami.md +30 -0
- package/docs/guide/package-management/why.md +55 -0
- package/docs/guide/run.md +23 -1
- package/docs/guide/test.md +1 -1
- package/docs/guide/troubleshooting.md +1 -1
- package/docs/guide/upgrade.md +12 -6
- package/docs/guide/vitest-v5.md +2 -2
- package/docs/guide/vpx.md +45 -5
- package/package.json +40 -34
- package/docs/guide/package-management.md +0 -269
package/dist/config/bin.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as promptGitHooks, n as defaultInteractive } from "../prompts-GL1vj0wk.js";
|
|
3
|
-
import { o as updateExistingAgentInstructions } from "../agent-D8oxxhVR.js";
|
|
4
|
-
import { t as require_dist } from "../dist-Bs0SObNC.js";
|
|
5
|
-
import { c as isGitHooksEnvDisabled, l as isHooksUserDisabled, s as install, u as resolveHooksLocation } from "../hooks-xRcJPc-O.js";
|
|
1
|
+
import { o as updateExistingAgentInstructions } from "../agent-CowvWq3j.js";
|
|
6
2
|
import { t as unwrapCliParseOutcome } from "../cli-parse-aeUeFDlC.js";
|
|
3
|
+
import { t as require_dist } from "../dist-Bs0SObNC.js";
|
|
4
|
+
import { i as promptGitHooks, n as defaultInteractive } from "../prompts-DLpJGhfK.js";
|
|
5
|
+
import { i as log, n as errorMsg } from "../terminal-BcuPUy-j.js";
|
|
6
|
+
import { c as isGitHooksEnvDisabled, l as isHooksUserDisabled, s as install, u as resolveHooksLocation } from "../hooks-w_e2whkQ.js";
|
|
7
7
|
import path, { join, relative } from "node:path";
|
|
8
8
|
import { parseConfigArgs } from "../../binding/index.js";
|
|
9
9
|
import fs, { existsSync } from "node:fs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
// package.json
|
|
3
|
-
var version = "1.
|
|
3
|
+
var version = "1.5.1";
|
|
4
4
|
var exports = {
|
|
5
5
|
".": {
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,6 +45,10 @@ var exports = {
|
|
|
45
45
|
"types": "./dist/oxlint-plugin.d.ts"
|
|
46
46
|
},
|
|
47
47
|
"./package.json": "./package.json",
|
|
48
|
+
"./register": {
|
|
49
|
+
"types": "./dist/register.d.ts",
|
|
50
|
+
"default": "./dist/register.js"
|
|
51
|
+
},
|
|
48
52
|
"./pack": {
|
|
49
53
|
"types": "./dist/pack.d.ts",
|
|
50
54
|
"import": "./dist/pack.js"
|
|
@@ -288,7 +292,7 @@ const VITE_CONFIG_FILES = [
|
|
|
288
292
|
"vite.config.mts",
|
|
289
293
|
"vite.config.cts"
|
|
290
294
|
];
|
|
291
|
-
const VITEST_VERSION = "5.0
|
|
295
|
+
const VITEST_VERSION = "5.1.0";
|
|
292
296
|
const SETUP_VP_VERSION = "v1.21.2";
|
|
293
297
|
const TSDOWN_MIGRATION_SKILL_URL = "https://github.com/rolldown/tsdown/blob/main/skills/tsdown-migrate/SKILL.md";
|
|
294
298
|
const VITE_PLUS_OVERRIDE_PACKAGES = process.env.VP_OVERRIDE_PACKAGES ? JSON.parse(process.env.VP_OVERRIDE_PACKAGES) : {
|
package/dist/create/bin.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { r as __toESM, t as __commonJSMin } from "../rolldown-runtime-DegdyBIC.js";
|
|
2
|
+
import { A as text, E as multiselect, M as isCancel, O as select, S as normalize$1, T as log, a as resolveGitInit, c as selectPackageManager, d as readYamlFile, h as resolveApproveBuildTargets, i as promptGitHooks, j as require_picocolors, k as spinner, m as detectGatedBuilds, n as defaultInteractive, o as runViteFmt, p as approveBuilds, r as downloadPackageManager$1, s as runViteInstall, t as cancelAndExit, u as editYamlFile, v as DependencyType, w as intro, y as PackageManager } from "../prompts-DLpJGhfK.js";
|
|
3
|
+
import { $ as promptTsupMigration, B as isBingoTemplate, G as initGitRepository, H as updateWorkspaceConfig, I as createCatalogDependencyResolver, J as detectFramework, L as supportsCatalog, R as detectWorkspace$1, V as updatePackageJsonWithDeps, W as findGitRoot, Y as hasFrameworkShim, Z as detectTsupProject, a as selectEditors, c as rewriteMonorepoProject, h as setPackageManager, it as promptPrettierMigration, l as rewriteStandaloneProject, n as detectExistingEditors, nt as detectPrettierProject, o as writeEditorConfigs, q as addFrameworkShim, s as rewriteMonorepo, st as detectEslintProject, ut as promptEslintMigration, v as installGitHooks, w as injectCreateDefaultTemplate, x as shouldSkipStagedMigrationForHooks, z as discoverWorkspacePackages } from "../editor-BVaNnIey.js";
|
|
4
|
+
import { a as selectAgentTargets, c as writeCopilotSetupWorkflow, d as templatesDir, l as displayRelative, r as detectExistingAgentTargetPaths, s as writeAgentInstructions, t as COPILOT_AGENT_ID } from "../agent-CowvWq3j.js";
|
|
5
|
+
import { t as unwrapCliParseOutcome } from "../cli-parse-aeUeFDlC.js";
|
|
2
6
|
import { t as documentationUrl$1 } from "../documentation-cv_y0Auv.js";
|
|
3
7
|
import { t as renderCliDoc } from "../help-B03t_iQ4.js";
|
|
4
|
-
import { a as muted, i as log, o as printHeader, r as formatDuration, s as success, t as accent } from "../terminal-BcuPUy-j.js";
|
|
5
|
-
import { d as VITE_PLUS_OVERRIDE_PACKAGES, f as VITE_PLUS_VERSION, u as VITE_PLUS_NAME } from "../constants-DRUnJ_Dz.js";
|
|
6
8
|
import { i as readJsonFile, n as editJsonFile } from "../json-kl84kDyH.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { a as selectAgentTargets, c as writeCopilotSetupWorkflow, d as templatesDir, l as displayRelative, r as detectExistingAgentTargetPaths, s as writeAgentInstructions, t as COPILOT_AGENT_ID } from "../agent-D8oxxhVR.js";
|
|
11
|
-
import { $ as promptTsupMigration, B as isBingoTemplate, G as initGitRepository, H as updateWorkspaceConfig, I as createCatalogDependencyResolver, J as detectFramework, L as supportsCatalog, R as detectWorkspace$1, V as updatePackageJsonWithDeps, W as findGitRoot, Y as hasFrameworkShim, Z as detectTsupProject, a as selectEditors, c as rewriteMonorepoProject, h as setPackageManager, it as promptPrettierMigration, l as rewriteStandaloneProject, n as detectExistingEditors, nt as detectPrettierProject, o as writeEditorConfigs, q as addFrameworkShim, s as rewriteMonorepo, st as detectEslintProject, ut as promptEslintMigration, v as installGitHooks, w as injectCreateDefaultTemplate, x as shouldSkipStagedMigrationForHooks, z as discoverWorkspacePackages } from "../editor-ClL78D8u.js";
|
|
12
|
-
import { i as runCommandSilently, r as runCommand$1 } from "../command-rY79K5NI.js";
|
|
9
|
+
import { a as muted, i as log$1, o as printHeader, r as formatDuration, s as success, t as accent } from "../terminal-BcuPUy-j.js";
|
|
10
|
+
import { c as getNpmRegistry, r as getScopeFromPackageName, s as fetchNpmResource, t as checkNpmPackageExists } from "../package-DLUCo6L_.js";
|
|
11
|
+
import { a as resolveViteConfig, r as hasViteConfig, t as findViteConfig } from "../resolve-vite-config-D-JtjGRa.js";
|
|
13
12
|
import { t as require_dist } from "../dist-Bs0SObNC.js";
|
|
14
|
-
import {
|
|
13
|
+
import { d as VITE_PLUS_OVERRIDE_PACKAGES, f as VITE_PLUS_VERSION, u as VITE_PLUS_NAME } from "../constants-D5f7inVN.js";
|
|
14
|
+
import { i as runCommandSilently, r as runCommand$1 } from "../command-rY79K5NI.js";
|
|
15
15
|
import path from "node:path";
|
|
16
16
|
import { findMonorepoRoot, getVpDirs, parseCreateArgs, removeConfigKey, runCommand, upsertJsonConfig, vitePlusHeader } from "../../binding/index.js";
|
|
17
17
|
import { promisify, styleText } from "node:util";
|
|
@@ -1039,7 +1039,7 @@ function printNonInteractiveTable(manifest, orgSpec, isMonorepo) {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
function rejectMonorepoEntryInsideMonorepo(entry, isMonorepo) {
|
|
1041
1041
|
if (entry.monorepo && isMonorepo) {
|
|
1042
|
-
log
|
|
1042
|
+
log.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
|
|
1043
1043
|
cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
|
|
1044
1044
|
}
|
|
1045
1045
|
}
|
|
@@ -1077,7 +1077,7 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
if (!manifest) {
|
|
1079
1079
|
if (orgSpec.name !== void 0) cancelAndExit(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — \`@org:name\` requires one.`, 1);
|
|
1080
|
-
log
|
|
1080
|
+
log.info(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — running it as a normal package.`);
|
|
1081
1081
|
return { kind: "passthrough" };
|
|
1082
1082
|
}
|
|
1083
1083
|
if (orgSpec.name === void 0) {
|
|
@@ -1088,7 +1088,7 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
1088
1088
|
const picked = await pickOrgTemplate(manifest, { isMonorepo: args.isMonorepo });
|
|
1089
1089
|
if (picked === ORG_PICKER_CANCEL) cancelAndExit();
|
|
1090
1090
|
if (picked === ORG_PICKER_BUILTIN_ESCAPE) {
|
|
1091
|
-
if (args.isMonorepo && manifest.templates.every((t) => t.monorepo)) log
|
|
1091
|
+
if (args.isMonorepo && manifest.templates.every((t) => t.monorepo)) log.info(`No templates from ${manifest.packageName} are applicable inside a monorepo — showing Vite+ built-in templates instead.`);
|
|
1092
1092
|
return { kind: "escape-hatch" };
|
|
1093
1093
|
}
|
|
1094
1094
|
rejectMonorepoEntryInsideMonorepo(picked.entry, args.isMonorepo);
|
|
@@ -4277,7 +4277,7 @@ async function promptPackageNameAndTargetDir(defaultPackageName, interactive) {
|
|
|
4277
4277
|
} else {
|
|
4278
4278
|
packageName = defaultPackageName;
|
|
4279
4279
|
targetDir = getProjectDirFromPackageName(packageName);
|
|
4280
|
-
log
|
|
4280
|
+
log.info(`Using default package name: ${accent(packageName)}`);
|
|
4281
4281
|
}
|
|
4282
4282
|
return {
|
|
4283
4283
|
packageName,
|
|
@@ -4297,7 +4297,7 @@ async function promptTargetDir(defaultTargetDir, interactive, options) {
|
|
|
4297
4297
|
targetDir = validateTargetDir(selected ?? defaultTargetDir, options?.cwd).directory;
|
|
4298
4298
|
} else {
|
|
4299
4299
|
targetDir = validateTargetDir(defaultTargetDir, options?.cwd).directory;
|
|
4300
|
-
log
|
|
4300
|
+
log.info(`Using default target directory: ${accent(targetDir)}`);
|
|
4301
4301
|
}
|
|
4302
4302
|
return targetDir;
|
|
4303
4303
|
}
|
|
@@ -4310,26 +4310,57 @@ function suggestAvailableTargetDir(defaultTargetDir, cwd) {
|
|
|
4310
4310
|
}
|
|
4311
4311
|
return suggestedTargetDir;
|
|
4312
4312
|
}
|
|
4313
|
+
function describeExistingTarget(projectDirFullPath, stats) {
|
|
4314
|
+
if (stats.isSymbolicLink()) {
|
|
4315
|
+
let linkedPath;
|
|
4316
|
+
try {
|
|
4317
|
+
linkedPath = fs.realpathSync(projectDirFullPath);
|
|
4318
|
+
} catch {
|
|
4319
|
+
linkedPath = path.resolve(path.dirname(projectDirFullPath), fs.readlinkSync(projectDirFullPath));
|
|
4320
|
+
}
|
|
4321
|
+
return {
|
|
4322
|
+
description: `Target path "${projectDirFullPath}" is a symbolic link to "${linkedPath}"`,
|
|
4323
|
+
removeLabel: "Remove symbolic link and continue"
|
|
4324
|
+
};
|
|
4325
|
+
}
|
|
4326
|
+
if (stats.isDirectory()) return {
|
|
4327
|
+
description: `Target directory "${projectDirFullPath}" is not empty`,
|
|
4328
|
+
removeLabel: "Remove existing files and continue"
|
|
4329
|
+
};
|
|
4330
|
+
return {
|
|
4331
|
+
description: `Target path "${projectDirFullPath}" already exists`,
|
|
4332
|
+
removeLabel: "Remove existing path and continue"
|
|
4333
|
+
};
|
|
4334
|
+
}
|
|
4335
|
+
function stripTrailingPathSeparators(targetPath) {
|
|
4336
|
+
const root = path.parse(targetPath).root;
|
|
4337
|
+
let end = targetPath.length;
|
|
4338
|
+
while (end > root.length && targetPath[end - 1] === path.sep) end--;
|
|
4339
|
+
return targetPath.slice(0, end);
|
|
4340
|
+
}
|
|
4313
4341
|
async function checkProjectDirExists(projectDirFullPath, interactive) {
|
|
4314
|
-
|
|
4342
|
+
const targetPath = stripTrailingPathSeparators(projectDirFullPath);
|
|
4343
|
+
const stats = fs.lstatSync(targetPath, { throwIfNoEntry: false });
|
|
4344
|
+
if (!stats || stats.isDirectory() && isEmpty(targetPath)) return;
|
|
4345
|
+
const { description, removeLabel } = describeExistingTarget(targetPath, stats);
|
|
4315
4346
|
if (!interactive) {
|
|
4316
|
-
log
|
|
4317
|
-
cancelAndExit(
|
|
4347
|
+
log.info("Use --directory to specify a different location or remove the directory first");
|
|
4348
|
+
cancelAndExit(description, 1);
|
|
4318
4349
|
}
|
|
4319
4350
|
const overwrite = await select({
|
|
4320
|
-
message:
|
|
4351
|
+
message: `${description}. Please choose how to proceed:`,
|
|
4321
4352
|
options: [{
|
|
4322
4353
|
label: "Cancel operation",
|
|
4323
4354
|
value: "no"
|
|
4324
4355
|
}, {
|
|
4325
|
-
label:
|
|
4356
|
+
label: removeLabel,
|
|
4326
4357
|
value: "yes"
|
|
4327
4358
|
}]
|
|
4328
4359
|
});
|
|
4329
4360
|
if (isCancel(overwrite)) cancelAndExit();
|
|
4330
4361
|
switch (overwrite) {
|
|
4331
4362
|
case "yes":
|
|
4332
|
-
|
|
4363
|
+
clearTargetPath(targetPath, stats);
|
|
4333
4364
|
break;
|
|
4334
4365
|
case "no": cancelAndExit();
|
|
4335
4366
|
}
|
|
@@ -4338,18 +4369,37 @@ function isEmpty(path) {
|
|
|
4338
4369
|
const files = fs.readdirSync(path);
|
|
4339
4370
|
return files.length === 0 || files.length === 1 && files[0] === ".git";
|
|
4340
4371
|
}
|
|
4341
|
-
function
|
|
4342
|
-
|
|
4343
|
-
|
|
4372
|
+
function isSameTargetEntry(expected, actual) {
|
|
4373
|
+
return expected.dev === actual.dev && expected.ino === actual.ino && expected.isDirectory() === actual.isDirectory() && expected.isSymbolicLink() === actual.isSymbolicLink();
|
|
4374
|
+
}
|
|
4375
|
+
function getUnchangedTargetStats(targetPath, expected, cleanupStarted = false) {
|
|
4376
|
+
const stats = fs.lstatSync(targetPath, { throwIfNoEntry: false });
|
|
4377
|
+
if (!stats) return;
|
|
4378
|
+
if (!isSameTargetEntry(expected, stats)) throw new Error(cleanupStarted ? `Target path "${targetPath}" changed during cleanup. Cleanup was stopped. Please inspect the target and retry the command.` : `Target path "${targetPath}" changed while waiting for confirmation. No files were removed. Please retry the command.`);
|
|
4379
|
+
return stats;
|
|
4380
|
+
}
|
|
4381
|
+
function clearTargetPath(targetPath, expectedStats) {
|
|
4382
|
+
const strippedTargetPath = stripTrailingPathSeparators(targetPath);
|
|
4383
|
+
const stats = getUnchangedTargetStats(strippedTargetPath, expectedStats);
|
|
4384
|
+
if (!stats) return;
|
|
4385
|
+
if (!stats.isDirectory()) {
|
|
4386
|
+
fs.unlinkSync(strippedTargetPath);
|
|
4387
|
+
return;
|
|
4388
|
+
}
|
|
4389
|
+
const files = fs.readdirSync(strippedTargetPath);
|
|
4390
|
+
for (const file of files) {
|
|
4344
4391
|
if (file === ".git") continue;
|
|
4345
|
-
|
|
4392
|
+
if (!getUnchangedTargetStats(strippedTargetPath, expectedStats, true)) return;
|
|
4393
|
+
fs.rmSync(path.resolve(strippedTargetPath, file), {
|
|
4346
4394
|
recursive: true,
|
|
4347
4395
|
force: true
|
|
4348
4396
|
});
|
|
4349
4397
|
}
|
|
4350
4398
|
}
|
|
4351
4399
|
function isTargetDirAvailable(projectDirFullPath) {
|
|
4352
|
-
|
|
4400
|
+
const targetPath = stripTrailingPathSeparators(projectDirFullPath);
|
|
4401
|
+
const stats = fs.lstatSync(targetPath, { throwIfNoEntry: false });
|
|
4402
|
+
return !stats || stats.isDirectory() && isEmpty(targetPath);
|
|
4353
4403
|
}
|
|
4354
4404
|
function validateTargetDir(input, cwd) {
|
|
4355
4405
|
const value = input?.trim() ?? "";
|
|
@@ -4411,7 +4461,7 @@ async function registerLocalTemplate(workspaceRoot, entry, silent = false) {
|
|
|
4411
4461
|
});
|
|
4412
4462
|
const existingEntry = existing.templates.find((t) => t.name === entry.name);
|
|
4413
4463
|
if (existingEntry) {
|
|
4414
|
-
if (existingEntry.template !== entry.template) log
|
|
4464
|
+
if (existingEntry.template !== entry.template) log.warn(`create.templates already has an entry named '${entry.name}' pointing at '${existingEntry.template}'; left unchanged.\nUpdate it by hand if it should run '${entry.template}' instead.`);
|
|
4415
4465
|
return;
|
|
4416
4466
|
}
|
|
4417
4467
|
const nextCreate = {
|
|
@@ -4429,7 +4479,7 @@ async function registerLocalTemplate(workspaceRoot, entry, silent = false) {
|
|
|
4429
4479
|
function ensureViteConfig(workspaceRoot, silent) {
|
|
4430
4480
|
const configPath = path.join(workspaceRoot, "vite.config.ts");
|
|
4431
4481
|
fs.writeFileSync(configPath, `import { defineConfig } from '${VITE_PLUS_NAME}';\n\nexport default defineConfig({});\n`);
|
|
4432
|
-
if (!silent) log
|
|
4482
|
+
if (!silent) log.success(`✔ Created vite.config.ts in ${displayRelative(configPath)}`);
|
|
4433
4483
|
return configPath;
|
|
4434
4484
|
}
|
|
4435
4485
|
/**
|
|
@@ -4456,7 +4506,7 @@ function writeCreateBlock(configPath, create) {
|
|
|
4456
4506
|
}
|
|
4457
4507
|
// src/create/templates/generator.ts
|
|
4458
4508
|
async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
4459
|
-
if (!options?.silent) log
|
|
4509
|
+
if (!options?.silent) log.step("Creating generator scaffold...");
|
|
4460
4510
|
let description;
|
|
4461
4511
|
if (templateInfo.interactive) {
|
|
4462
4512
|
const defaultDescription = "Generate new components for our monorepo";
|
|
@@ -4479,7 +4529,7 @@ async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
|
4479
4529
|
if (description) pkg.description = description;
|
|
4480
4530
|
return pkg;
|
|
4481
4531
|
});
|
|
4482
|
-
if (!options?.silent) log
|
|
4532
|
+
if (!options?.silent) log.success("Generator scaffold created");
|
|
4483
4533
|
return {
|
|
4484
4534
|
exitCode: 0,
|
|
4485
4535
|
projectDir: templateInfo.targetDir
|
|
@@ -4490,14 +4540,14 @@ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
|
4490
4540
|
const { gray, yellow } = import_picocolors.default;
|
|
4491
4541
|
async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
4492
4542
|
const silent = options?.silent ?? false;
|
|
4493
|
-
if (!silent) log
|
|
4543
|
+
if (!silent) log.step("Generating project…");
|
|
4494
4544
|
let isGitHubTemplate = templateInfo.command === "degit";
|
|
4495
4545
|
let result;
|
|
4496
4546
|
if (templateInfo.command === "node") {
|
|
4497
4547
|
const command = templateInfo.command;
|
|
4498
4548
|
const args = templateInfo.args;
|
|
4499
4549
|
const envs = templateInfo.envs;
|
|
4500
|
-
if (!silent) log
|
|
4550
|
+
if (!silent) log.info(`Running: ${gray(`${command} ${args.join(" ")}`)}`);
|
|
4501
4551
|
result = await runCommandAndDetectProjectDir({
|
|
4502
4552
|
command,
|
|
4503
4553
|
args,
|
|
@@ -4507,7 +4557,7 @@ async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4507
4557
|
} else {
|
|
4508
4558
|
if (!isGitHubTemplate) {
|
|
4509
4559
|
if (!await checkNpmPackageExists(templateInfo.command)) {
|
|
4510
|
-
if (!silent) log
|
|
4560
|
+
if (!silent) log.error(`Template "${templateInfo.command}" not found on npm. Run ${yellow("vp create --list")} to see available templates.`);
|
|
4511
4561
|
return { exitCode: 1 };
|
|
4512
4562
|
}
|
|
4513
4563
|
}
|
|
@@ -4515,13 +4565,13 @@ async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4515
4565
|
}
|
|
4516
4566
|
const exitCode = result.exitCode;
|
|
4517
4567
|
if (exitCode === 127) {
|
|
4518
|
-
log
|
|
4519
|
-
log
|
|
4568
|
+
log.info(yellow("\nTroubleshooting:"));
|
|
4569
|
+
log.info(` ${gray("•")} Command not found. Make sure Node.js is installed`);
|
|
4520
4570
|
} else if (isGitHubTemplate && exitCode !== 0) {
|
|
4521
|
-
log
|
|
4522
|
-
log
|
|
4523
|
-
log
|
|
4524
|
-
log
|
|
4571
|
+
log.info(yellow("\nTroubleshooting:"));
|
|
4572
|
+
log.info(` ${gray("•")} Make sure the GitHub repository exists`);
|
|
4573
|
+
log.info(` ${gray("•")} Check your internet connection`);
|
|
4574
|
+
log.info(` ${gray("•")} Repository might be private (requires authentication)`);
|
|
4525
4575
|
}
|
|
4526
4576
|
return result;
|
|
4527
4577
|
}
|
|
@@ -4531,7 +4581,7 @@ async function runRemoteTemplateCommand(workspaceInfo, cwd, templateInfo, detect
|
|
|
4531
4581
|
const execArgs = [...templateInfo.args];
|
|
4532
4582
|
const envs = templateInfo.envs;
|
|
4533
4583
|
const { command, args } = formatDlxCommand(remotePackageName, execArgs, workspaceInfo);
|
|
4534
|
-
if (!silent) log
|
|
4584
|
+
if (!silent) log.info(`Running: ${gray(`${command} ${args.join(" ")}`)}`);
|
|
4535
4585
|
if (detectCreatedProjectDir) return await runCommandAndDetectProjectDir({
|
|
4536
4586
|
command,
|
|
4537
4587
|
args,
|
|
@@ -4565,7 +4615,7 @@ function autoFixRemoteTemplateCommand(templateInfo, workspaceInfo) {
|
|
|
4565
4615
|
} else if (packageName === "sv") {
|
|
4566
4616
|
if (templateInfo.args[0] !== "create") templateInfo.args.unshift("create");
|
|
4567
4617
|
templateInfo.args.push("--no-install");
|
|
4568
|
-
}
|
|
4618
|
+
} else if (packageName === "create-react-router") templateInfo.args.push("--no-git-init");
|
|
4569
4619
|
if (workspaceInfo.isMonorepo) {
|
|
4570
4620
|
if (packageName === "create-nuxt") templateInfo.args.push("--no-gitInit");
|
|
4571
4621
|
else if (packageName === "@tanstack/cli") templateInfo.args.push("--no-git");
|
|
@@ -4579,8 +4629,8 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4579
4629
|
workspaceInfo.monorepoScope = getScopeFromPackageName(templateInfo.packageName);
|
|
4580
4630
|
const fullPath = path.join(workspaceInfo.rootDir, templateInfo.targetDir);
|
|
4581
4631
|
if (!options?.silent) {
|
|
4582
|
-
log
|
|
4583
|
-
log
|
|
4632
|
+
log.info(`Target directory: ${formatDisplayTargetDir(templateInfo.targetDir)}`);
|
|
4633
|
+
log.step("Creating Vite+ monorepo...");
|
|
4584
4634
|
}
|
|
4585
4635
|
copyDir(path.join(templatesDir, "monorepo"), fullPath);
|
|
4586
4636
|
renameFiles(fullPath);
|
|
@@ -4613,8 +4663,8 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4613
4663
|
const yarnrcPath = path.join(fullPath, ".yarnrc.yml");
|
|
4614
4664
|
if (fs.existsSync(yarnrcPath)) fs.unlinkSync(yarnrcPath);
|
|
4615
4665
|
}
|
|
4616
|
-
if (!options?.silent) log
|
|
4617
|
-
if (!options?.silent) log
|
|
4666
|
+
if (!options?.silent) log.success("Monorepo template created");
|
|
4667
|
+
if (!options?.silent) log.step("Creating default application in apps/website...");
|
|
4618
4668
|
const appResult = await runRemoteTemplateCommand(workspaceInfo, fullPath, discoverTemplate("create-vite@latest", [
|
|
4619
4669
|
InitialMonorepoAppDir,
|
|
4620
4670
|
"--template",
|
|
@@ -4622,7 +4672,7 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4622
4672
|
"--no-interactive"
|
|
4623
4673
|
], workspaceInfo), false, options?.silent ?? false);
|
|
4624
4674
|
if (appResult.exitCode !== 0) {
|
|
4625
|
-
log
|
|
4675
|
+
log.error(`Failed to create default application: ${appResult.exitCode}`);
|
|
4626
4676
|
return appResult;
|
|
4627
4677
|
}
|
|
4628
4678
|
const appPackageName = workspaceInfo.monorepoScope ? `${workspaceInfo.monorepoScope}/website` : "website";
|
|
@@ -4630,11 +4680,11 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4630
4680
|
setPackageName(appProjectPath, appPackageName);
|
|
4631
4681
|
rewriteMonorepoProject(appProjectPath, workspaceInfo.packageManager, void 0, options?.silent ?? false);
|
|
4632
4682
|
dropAliasedRuntimeDevDeps(appProjectPath, workspaceInfo.packageManager);
|
|
4633
|
-
if (!options?.silent) log
|
|
4683
|
+
if (!options?.silent) log.step("Creating default library in packages/utils...");
|
|
4634
4684
|
const libraryDir = "packages/utils";
|
|
4635
4685
|
const libraryResult = await runRemoteTemplateCommand(workspaceInfo, fullPath, discoverTemplate(LibraryTemplateRepo, [libraryDir], workspaceInfo), false, options?.silent ?? false);
|
|
4636
4686
|
if (libraryResult.exitCode !== 0) {
|
|
4637
|
-
log
|
|
4687
|
+
log.error(`Failed to create default library, exit code: ${libraryResult.exitCode}`);
|
|
4638
4688
|
return libraryResult;
|
|
4639
4689
|
}
|
|
4640
4690
|
const libraryPackageName = workspaceInfo.monorepoScope ? `${workspaceInfo.monorepoScope}/utils` : "utils";
|
|
@@ -4743,7 +4793,7 @@ async function executeBuiltinTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4743
4793
|
};
|
|
4744
4794
|
}
|
|
4745
4795
|
if (templateInfo.command.startsWith("vite:")) {
|
|
4746
|
-
if (!options?.silent) log
|
|
4796
|
+
if (!options?.silent) log.error(`Unknown builtin template "${templateInfo.command}". Run ${import_picocolors.default.yellow("vp create --list")} to see available templates.`);
|
|
4747
4797
|
return { exitCode: 1 };
|
|
4748
4798
|
}
|
|
4749
4799
|
const result = await runRemoteTemplateCommand(workspaceInfo, workspaceInfo.rootDir, templateInfo, false, options?.silent ?? false);
|
|
@@ -4920,15 +4970,15 @@ function getCopilotSetupRoot(projectRoot, isExistingMonorepo) {
|
|
|
4920
4970
|
}
|
|
4921
4971
|
function showCreateSummary(options) {
|
|
4922
4972
|
const { description, gitInitialized, installSummary, nextCommand, packageManager, packageManagerVersion, projectDir } = options;
|
|
4923
|
-
log(`${styleText("magenta", "◇")} Scaffolded ${accent(projectDir)}${description ? ` with ${description}` : ""}`);
|
|
4924
|
-
log(`${styleText("gray", "•")} Node ${process.versions.node} ${packageManager} ${packageManagerVersion}`);
|
|
4925
|
-
if (installSummary?.status === "installed") log(`${styleText("green", "✓")} Dependencies installed in ${formatDuration(installSummary.durationMs)}`);
|
|
4973
|
+
log$1(`${styleText("magenta", "◇")} Scaffolded ${accent(projectDir)}${description ? ` with ${description}` : ""}`);
|
|
4974
|
+
log$1(`${styleText("gray", "•")} Node ${process.versions.node} ${packageManager} ${packageManagerVersion}`);
|
|
4975
|
+
if (installSummary?.status === "installed") log$1(`${styleText("green", "✓")} Dependencies installed in ${formatDuration(installSummary.durationMs)}`);
|
|
4926
4976
|
if (gitInitialized) {
|
|
4927
4977
|
const git = !projectDir || projectDir === "." ? "git" : `git -C ${formatProjectDirArgument(projectDir)}`;
|
|
4928
4978
|
const gitCommand = `${git} add -A && ${git} commit -m "chore: initial commit"`;
|
|
4929
|
-
log(`${styleText("blue", "→")} Git (optional): ${accent(gitCommand)}`);
|
|
4979
|
+
log$1(`${styleText("blue", "→")} Git (optional): ${accent(gitCommand)}`);
|
|
4930
4980
|
}
|
|
4931
|
-
log(`${styleText("blue", "→")} Next: ${accent(nextCommand)}`);
|
|
4981
|
+
log$1(`${styleText("blue", "→")} Next: ${accent(nextCommand)}`);
|
|
4932
4982
|
}
|
|
4933
4983
|
async function main() {
|
|
4934
4984
|
const { templateName, options, templateArgs } = parseArgs();
|
|
@@ -4943,7 +4993,7 @@ async function main() {
|
|
|
4943
4993
|
if (options.directory) {
|
|
4944
4994
|
const formatted = formatTargetDir(options.directory);
|
|
4945
4995
|
if (formatted.error) {
|
|
4946
|
-
log
|
|
4996
|
+
log.error(formatted.error);
|
|
4947
4997
|
cancelAndExit("The --directory option is invalid", 1);
|
|
4948
4998
|
}
|
|
4949
4999
|
targetDir = formatted.directory;
|
|
@@ -4977,7 +5027,7 @@ async function main() {
|
|
|
4977
5027
|
if (!selectedTemplateName && configuredCreate.defaultTemplate) selectedTemplateName = configuredCreate.defaultTemplate;
|
|
4978
5028
|
} catch (error) {
|
|
4979
5029
|
if (error instanceof CreateConfigSchemaError) cancelAndExit(error.message, 1);
|
|
4980
|
-
log
|
|
5030
|
+
log.warn(`Could not read \`create\` config from the workspace vite.config (${error.message}); local templates are unavailable`);
|
|
4981
5031
|
}
|
|
4982
5032
|
else if (!selectedTemplateName) {
|
|
4983
5033
|
let defaultTemplate;
|
|
@@ -5040,15 +5090,15 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5040
5090
|
if (!isDirectScaffoldTemplate) compactOutput = false;
|
|
5041
5091
|
if (targetDir && !isDirectScaffoldTemplate) cancelAndExit("The --directory option is only available for builtin and bundled @org templates", 1);
|
|
5042
5092
|
if (selectedTemplateName === BuiltinTemplate.monorepo && isMonorepo) {
|
|
5043
|
-
log
|
|
5093
|
+
log.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
|
|
5044
5094
|
cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
|
|
5045
5095
|
}
|
|
5046
5096
|
if (selectedTemplateName === BuiltinTemplate.generator && !isMonorepo) {
|
|
5047
|
-
log
|
|
5097
|
+
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`");
|
|
5048
5098
|
cancelAndExit("Cannot create a generator outside a monorepo", 1);
|
|
5049
5099
|
}
|
|
5050
5100
|
if (isMonorepo && options.git !== void 0) cancelAndExit("The --git/--no-git options are not available when adding a package to an existing monorepo", 1);
|
|
5051
|
-
if (isInSubdirectory && !compactOutput) log
|
|
5101
|
+
if (isInSubdirectory && !compactOutput) log.info(`Detected monorepo root at ${accent(workspaceInfoOptional.rootDir)}`);
|
|
5052
5102
|
if (isMonorepo && options.interactive && !targetDir) {
|
|
5053
5103
|
let parentDir;
|
|
5054
5104
|
if (workspaceInfoOptional.parentDirs.length > 0 || isInSubdirectory) {
|
|
@@ -5090,7 +5140,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5090
5140
|
selectedParentDir = parentDir;
|
|
5091
5141
|
}
|
|
5092
5142
|
if (isMonorepo && !options.interactive && !targetDir) {
|
|
5093
|
-
if (isInSubdirectory && !compactOutput) log
|
|
5143
|
+
if (isInSubdirectory && !compactOutput) log.info(`Use ${accent("--directory")} to specify a different target location.`);
|
|
5094
5144
|
selectedParentDir = inferParentDir(selectedTemplateName, workspaceInfoOptional, isLocalTemplate) ?? workspaceInfoOptional.parentDirs[0];
|
|
5095
5145
|
}
|
|
5096
5146
|
if (isGitHubUrl(selectedTemplateName)) {
|
|
@@ -5099,7 +5149,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5099
5149
|
const inferredTargetDir = inferGitHubRepoName(selectedTemplateName) ?? "template";
|
|
5100
5150
|
const remoteTargetBaseDir = selectedParentDir ? path.join(workspaceInfoOptional.rootDir, selectedParentDir) : workspaceInfoOptional.rootDir;
|
|
5101
5151
|
const defaultTargetDir = suggestAvailableTargetDir(inferredTargetDir, remoteTargetBaseDir);
|
|
5102
|
-
if (defaultTargetDir !== inferredTargetDir && options.interactive) log
|
|
5152
|
+
if (defaultTargetDir !== inferredTargetDir && options.interactive) log.info(` Target directory "${inferredTargetDir}" already exists. Suggested: ${accent(defaultTargetDir)}`);
|
|
5103
5153
|
remoteTargetDir = await promptTargetDir(defaultTargetDir, options.interactive, { cwd: remoteTargetBaseDir });
|
|
5104
5154
|
selectedTemplateArgs = [remoteTargetDir, ...selectedTemplateArgs];
|
|
5105
5155
|
}
|
|
@@ -5114,7 +5164,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5114
5164
|
if (enclosingPackage) cancelAndExit(`Cannot scaffold inside existing package "${enclosingPackage.name}" (${enclosingPackage.path}). Use --directory to specify a different location`, 1);
|
|
5115
5165
|
targetDir = cwdRelativeToRoot;
|
|
5116
5166
|
}
|
|
5117
|
-
log
|
|
5167
|
+
log.info(`Using package name: ${accent(packageName)}`);
|
|
5118
5168
|
} else if (selectedTemplateName === BuiltinTemplate.monorepo) {
|
|
5119
5169
|
const selected = await promptPackageNameAndTargetDir(getRandomProjectName({ fallbackName: "vite-plus-monorepo" }), options.interactive);
|
|
5120
5170
|
packageName = selected.packageName;
|
|
@@ -5373,7 +5423,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5373
5423
|
template: generatorTemplatePath
|
|
5374
5424
|
}, compactOutput);
|
|
5375
5425
|
} catch (error) {
|
|
5376
|
-
log
|
|
5426
|
+
log.warn(`Could not register the generator in create.templates (${error.message}).\nAdd it by hand: { name: '${generatorName || path.basename(projectDir)}', template: '${generatorTemplatePath}' }`);
|
|
5377
5427
|
}
|
|
5378
5428
|
resumeCreateProgress();
|
|
5379
5429
|
}
|
|
@@ -5430,7 +5480,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5430
5480
|
resumeCreateProgress();
|
|
5431
5481
|
};
|
|
5432
5482
|
if (isMonorepo) {
|
|
5433
|
-
if (!compactOutput) log
|
|
5483
|
+
if (!compactOutput) log.step("Monorepo integration...");
|
|
5434
5484
|
if (workspaceInfo.packages.length > 0) {
|
|
5435
5485
|
if (options.interactive) {
|
|
5436
5486
|
pauseCreateProgress();
|
|
@@ -5520,10 +5570,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5520
5570
|
}
|
|
5521
5571
|
async function showAvailableTemplates() {
|
|
5522
5572
|
printHeader();
|
|
5523
|
-
log(listTemplatesMessage);
|
|
5573
|
+
log$1(listTemplatesMessage);
|
|
5524
5574
|
}
|
|
5525
5575
|
main().catch((err) => {
|
|
5526
|
-
log
|
|
5576
|
+
log.error(err.message);
|
|
5527
5577
|
console.error(err);
|
|
5528
5578
|
cancelAndExit(`Failed to generate code: ${err.message}`, 1);
|
|
5529
5579
|
});
|
|
@@ -75,10 +75,10 @@ function ignoreOutput(path) {
|
|
|
75
75
|
var addon;
|
|
76
76
|
var init_src = __esmMin((() => {}));
|
|
77
77
|
// package.json
|
|
78
|
-
var version = "1.
|
|
78
|
+
var version = "1.5.1", VITE_PLUS_VERSION, VITEST_VERSION, CONFIG_METADATA_ENV;
|
|
79
79
|
var init_constants = __esmMin((() => {
|
|
80
80
|
VITE_PLUS_VERSION = process.env.VP_VERSION || version;
|
|
81
|
-
VITEST_VERSION = "5.0
|
|
81
|
+
VITEST_VERSION = "5.1.0";
|
|
82
82
|
process.env.VP_OVERRIDE_PACKAGES ? JSON.parse(process.env.VP_OVERRIDE_PACKAGES) : `${VITE_PLUS_VERSION}`;
|
|
83
83
|
(0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
84
84
|
process.versions.node, process.release.name;
|
|
@@ -113,6 +113,7 @@ var define_config_exports = /* @__PURE__ */ __exportAll({
|
|
|
113
113
|
defineProject: () => defineProject,
|
|
114
114
|
isVitestFamilySpecifier: () => isVitestFamilySpecifier,
|
|
115
115
|
lazyPlugins: () => lazyPlugins,
|
|
116
|
+
resolveConfigFromFile: () => resolveConfigFromFile,
|
|
116
117
|
resolveCoverageProviderToCheck: () => resolveCoverageProviderToCheck,
|
|
117
118
|
withConfigMetadataResolution: () => withConfigMetadataResolution
|
|
118
119
|
});
|
|
@@ -635,13 +636,37 @@ async function withConfigMetadataResolution(fn) {
|
|
|
635
636
|
}
|
|
636
637
|
}
|
|
637
638
|
}
|
|
639
|
+
/**
|
|
640
|
+
* Resolve a Vite config file to read a non-plugin block (`lint`, `fmt`, `pack`, …) from it,
|
|
641
|
+
* for tools such as oxlint, oxfmt, and Vite+ itself.
|
|
642
|
+
*
|
|
643
|
+
* With an absolute `configFile`, default resolution of the initial `root` from the
|
|
644
|
+
* config file is independent of `process.cwd()`: an unset or relative `root`
|
|
645
|
+
* resolves from the config file's parent directory.
|
|
646
|
+
* Callers can supply `rootBase` to use a different project directory,
|
|
647
|
+
* such as when the config is in a subdirectory. Absolute roots are preserved.
|
|
648
|
+
* Plugin hooks can later change `root` using Vite's normal semantics. For example,
|
|
649
|
+
* a relative `root` returned by a `config` hook resolves from `process.cwd()`.
|
|
650
|
+
*
|
|
651
|
+
* Relative `configFile` and explicit `rootBase` paths still resolve from `process.cwd()`.
|
|
652
|
+
* The helper does not change the process cwd; config code and plugins can still read it.
|
|
653
|
+
* The resolver loads the config once, as a config-metadata resolution,
|
|
654
|
+
* so `lazyPlugins` skips its factory.
|
|
655
|
+
* Plugins outside `lazyPlugins` still run their hooks and side effects,
|
|
656
|
+
* e.g. TanStack Start's router generator scans `src/routes`.
|
|
657
|
+
*/
|
|
658
|
+
async function resolveConfigFromFile(configFile, options = {}) {
|
|
659
|
+
if (configFile.length === 0) throw new Error("Config file path must not be empty.");
|
|
660
|
+
const rootBase = (0, node_path.resolve)(options.rootBase ?? (0, node_path.dirname)((0, node_path.resolve)(configFile)));
|
|
661
|
+
return withConfigMetadataResolution(() => resolveConfigWithInternalOptions({ configFile }, "build", void 0, void 0, void 0, void 0, void 0, { rootBase }));
|
|
662
|
+
}
|
|
638
663
|
function lazyPlugins(cb) {
|
|
639
664
|
if (process.env["VP_RESOLVING_CONFIG_METADATA"] === "1") return;
|
|
640
665
|
const result = cb();
|
|
641
666
|
if (result instanceof Promise) return [result];
|
|
642
667
|
return result;
|
|
643
668
|
}
|
|
644
|
-
var vitePlusRequire, vitePlusModuleFile, vitestAnchor, vitestExports, AUTO_INLINE_DEPS, KNOWN_COVERAGE_PROVIDERS, bundledVitestAnchorCache, coverageGuardedVitestInstances, VITE_PLUS_TEST_PLUGIN_NAMES, configMetadataDepth, configMetadataSavedValue;
|
|
669
|
+
var vitePlusRequire, vitePlusModuleFile, vitestAnchor, vitestExports, AUTO_INLINE_DEPS, KNOWN_COVERAGE_PROVIDERS, bundledVitestAnchorCache, coverageGuardedVitestInstances, VITE_PLUS_TEST_PLUGIN_NAMES, configMetadataDepth, configMetadataSavedValue, resolveConfigWithInternalOptions;
|
|
645
670
|
var init_define_config = __esmMin((() => {
|
|
646
671
|
init_src();
|
|
647
672
|
init_constants();
|
|
@@ -662,6 +687,7 @@ var init_define_config = __esmMin((() => {
|
|
|
662
687
|
"vite-plus:vitest-cache-paths"
|
|
663
688
|
]);
|
|
664
689
|
configMetadataDepth = 0;
|
|
690
|
+
resolveConfigWithInternalOptions = vite.resolveConfig;
|
|
665
691
|
}));
|
|
666
692
|
Object.defineProperty(exports, "AUTO_INLINE_DEPS", {
|
|
667
693
|
enumerable: true,
|
|
@@ -729,6 +755,12 @@ Object.defineProperty(exports, "lazyPlugins", {
|
|
|
729
755
|
return lazyPlugins;
|
|
730
756
|
}
|
|
731
757
|
});
|
|
758
|
+
Object.defineProperty(exports, "resolveConfigFromFile", {
|
|
759
|
+
enumerable: true,
|
|
760
|
+
get: function() {
|
|
761
|
+
return resolveConfigFromFile;
|
|
762
|
+
}
|
|
763
|
+
});
|
|
732
764
|
Object.defineProperty(exports, "resolveCoverageProviderToCheck", {
|
|
733
765
|
enumerable: true,
|
|
734
766
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as PackUserConfig } from "./pack-ARPFMefW.js";
|
|
2
|
-
import { PluginOption, UserConfig } from "vite";
|
|
2
|
+
import { PluginOption, ResolvedConfig, UserConfig } from "vite";
|
|
3
3
|
import { ConfigEnv, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig } from "vitest/config";
|
|
4
4
|
import { OxfmtConfig } from "oxfmt";
|
|
5
5
|
import { OxlintConfig } from "oxlint";
|
|
@@ -418,6 +418,34 @@ declare function defineProject$1(config: UserProjectConfigExport): UserProjectCo
|
|
|
418
418
|
* all load plugins.
|
|
419
419
|
*/
|
|
420
420
|
declare function withConfigMetadataResolution<T>(fn: () => Promise<T>): Promise<T>;
|
|
421
|
+
interface ResolveConfigFromFileOptions {
|
|
422
|
+
/**
|
|
423
|
+
* Base directory for an unset or relative `root` in the config file.
|
|
424
|
+
* Defaults to the config file's parent directory.
|
|
425
|
+
* Relative paths resolve from `process.cwd()`. Does not change the process cwd.
|
|
426
|
+
*/
|
|
427
|
+
rootBase?: string;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Resolve a Vite config file to read a non-plugin block (`lint`, `fmt`, `pack`, …) from it,
|
|
431
|
+
* for tools such as oxlint, oxfmt, and Vite+ itself.
|
|
432
|
+
*
|
|
433
|
+
* With an absolute `configFile`, default resolution of the initial `root` from the
|
|
434
|
+
* config file is independent of `process.cwd()`: an unset or relative `root`
|
|
435
|
+
* resolves from the config file's parent directory.
|
|
436
|
+
* Callers can supply `rootBase` to use a different project directory,
|
|
437
|
+
* such as when the config is in a subdirectory. Absolute roots are preserved.
|
|
438
|
+
* Plugin hooks can later change `root` using Vite's normal semantics. For example,
|
|
439
|
+
* a relative `root` returned by a `config` hook resolves from `process.cwd()`.
|
|
440
|
+
*
|
|
441
|
+
* Relative `configFile` and explicit `rootBase` paths still resolve from `process.cwd()`.
|
|
442
|
+
* The helper does not change the process cwd; config code and plugins can still read it.
|
|
443
|
+
* The resolver loads the config once, as a config-metadata resolution,
|
|
444
|
+
* so `lazyPlugins` skips its factory.
|
|
445
|
+
* Plugins outside `lazyPlugins` still run their hooks and side effects,
|
|
446
|
+
* e.g. TanStack Start's router generator scans `src/routes`.
|
|
447
|
+
*/
|
|
448
|
+
declare function resolveConfigFromFile(configFile: string, options?: ResolveConfigFromFileOptions): Promise<ResolvedConfig>;
|
|
421
449
|
declare function lazyPlugins(cb: () => PluginOption[]): PluginOption[] | undefined;
|
|
422
450
|
declare function lazyPlugins(cb: () => Promise<PluginOption[]>): PluginOption[] | undefined;
|
|
423
|
-
export {
|
|
451
|
+
export { computeAutoInlineList as a, isVitestFamilySpecifier as c, resolveCoverageProviderToCheck as d, withConfigMetadataResolution as f, checkCoverageProviderVersion as i, lazyPlugins as l, ResolveConfigFromFileOptions as n, defineConfig$1 as o, assertCoverageProviderVersionMatch as r, defineProject$1 as s, AUTO_INLINE_DEPS as t, resolveConfigFromFile as u };
|