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.
Files changed (74) hide show
  1. package/AGENTS.md +7 -0
  2. package/README.md +9 -3
  3. package/binding/index.cjs +54 -54
  4. package/binding/index.d.cts +7 -3
  5. package/dist/{agent-CI79DuSy.js → agent-DQU8uS6P.js} +4 -188
  6. package/dist/bin.js +288 -278
  7. package/dist/config/bin.js +27 -15
  8. package/dist/{constants-BppDcRc1.js → constants-CG513DRa.js} +10 -2
  9. package/dist/create/bin.js +178 -204
  10. package/dist/{define-config-DPnHe1Mx.js → define-config-CV4bQG_8.js} +3 -3
  11. package/dist/{define-config-CEm_MtvJ.cjs → define-config-DyNLA_f0.cjs} +1 -1
  12. package/dist/define-config.cjs +1 -1
  13. package/dist/define-config.js +1 -1
  14. package/dist/{dist-CSQWHI6y.js → dist-BDYZP12R.js} +193 -149
  15. package/dist/dist-Dqv1-Clg.js +3 -0
  16. package/dist/{editor-CGWdbLgD.js → editor-g4PosU99.js} +188 -108
  17. package/dist/hooks/bin.d.ts +1 -0
  18. package/dist/hooks/bin.js +130 -0
  19. package/dist/hooks-pNCBWtFT.js +570 -0
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/{json-BU88uu6o.js → json-qlK6UH0r.js} +38 -32
  23. package/dist/migration/bin.js +15 -18
  24. package/dist/{oxlint-plugin-config-BHOzlwMw.js → oxlint-plugin-config-BEZ9IUf7.js} +1 -1
  25. package/dist/oxlint-plugin.js +1 -1
  26. package/dist/pack-bin.js +1 -1
  27. package/dist/{package-hV-77cBb.js → package-B4T8RGMG.js} +2 -2
  28. package/dist/{prompts-DYap08te.js → prompts-CHz_98bJ.js} +142 -50
  29. package/dist/{resolve-vite-config-EWXclqvV.js → resolve-vite-config-Dmeyeyj-.js} +2 -9
  30. package/dist/staged/bin.js +224 -206
  31. package/dist/{terminal-CrqqK8WT.js → terminal-Bz-ps6rJ.js} +33 -3
  32. package/dist/test/browser/providers/playwright/context.d.ts +1 -1
  33. package/dist/test/browser/providers/playwright.d.ts +6 -6
  34. package/dist/test/browser/providers/preview/context.d.ts +1 -1
  35. package/dist/test/browser/providers/preview.d.ts +4 -4
  36. package/dist/test/browser/providers/webdriverio/context.d.ts +1 -1
  37. package/dist/test/browser/providers/webdriverio.d.ts +6 -6
  38. package/dist/test/browser-playwright/context.d.ts +1 -1
  39. package/dist/test/browser-playwright.d.ts +6 -6
  40. package/dist/test/browser-preview/context.d.ts +1 -1
  41. package/dist/test/browser-preview.d.ts +4 -4
  42. package/dist/test/browser-webdriverio/context.d.ts +1 -1
  43. package/dist/test/browser-webdriverio.d.ts +6 -6
  44. package/dist/test/context.d.ts +3 -3
  45. package/dist/test/locators.d.ts +1 -1
  46. package/dist/toolchain.d.ts +25 -0
  47. package/dist/toolchain.js +194 -0
  48. package/dist/toolchain.json +193 -0
  49. package/dist/{tsconfig-CVUKLfL8.js → tsconfig-7v_BHagU.js} +3 -3
  50. package/dist/tsgolint-path.js +1 -1
  51. package/dist/version.js +4 -4
  52. package/dist/versions.d.ts +3 -3
  53. package/dist/versions.js +6 -6
  54. package/docs/guide/ci.md +37 -4
  55. package/docs/guide/commit-hooks.md +87 -14
  56. package/docs/guide/create.md +7 -4
  57. package/docs/guide/fmt.md +2 -2
  58. package/docs/guide/github-actions-cache.md +5 -1
  59. package/docs/guide/ide-integration.md +61 -2
  60. package/docs/guide/index.md +3 -1
  61. package/docs/guide/install.md +25 -0
  62. package/docs/guide/installer-env-vars.md +12 -1
  63. package/docs/guide/lint.md +3 -1
  64. package/docs/guide/migrate.md +39 -2
  65. package/docs/guide/monorepo.md +4 -4
  66. package/docs/guide/troubleshooting.md +12 -4
  67. package/docs/guide/upgrade.md +27 -4
  68. package/docs/package.json +1 -1
  69. package/docs/pnpm-workspace.yaml +7 -0
  70. package/docs/vite.config.ts +3 -0
  71. package/package.json +18 -14
  72. package/rules/vite-tools.yml +0 -7
  73. package/dist/dist-DT25H9pj.js +0 -3
  74. package/dist/{tsgolint-path-eMZT-oea.js → tsgolint-path-CbDReEOx.js} +1 -1
@@ -1,7 +1,8 @@
1
- import { a as printHeader, c as renderCliDoc, r as log } from "../terminal-CrqqK8WT.js";
2
- import { i as promptGitHooks, n as defaultInteractive } from "../prompts-DYap08te.js";
1
+ import { i as log, l as renderCliDoc, o as printHeader } from "../terminal-Bz-ps6rJ.js";
2
+ import { i as promptGitHooks, n as defaultInteractive } from "../prompts-CHz_98bJ.js";
3
3
  import { t as lib_default } from "../lib-L3DWSRQp.js";
4
- import { d as install, o as updateExistingAgentInstructions } from "../agent-CI79DuSy.js";
4
+ import { o as updateExistingAgentInstructions } from "../agent-DQU8uS6P.js";
5
+ import { c as resolveHooksLocation, o as install, s as isHooksUserDisabled } from "../hooks-pNCBWtFT.js";
5
6
  import { join } from "node:path";
6
7
  import { existsSync } from "node:fs";
7
8
  //#region src/config/bin.ts
@@ -25,7 +26,7 @@ async function main() {
25
26
  rows: [
26
27
  {
27
28
  label: "--hooks-dir <path>",
28
- description: "Custom hooks directory (default: .vite-hooks)"
29
+ description: "Custom hooks directory (default: .vite-hooks, or last used in this clone)"
29
30
  },
30
31
  {
31
32
  label: "--no-hooks",
@@ -59,17 +60,28 @@ async function main() {
59
60
  const lifecycleEvent = process.env.npm_lifecycle_event;
60
61
  const isLifecycleScript = lifecycleEvent === "prepare" || lifecycleEvent === "postinstall";
61
62
  const root = process.cwd();
62
- const isFirstHooksRun = !existsSync(join(root, dir ?? ".vite-hooks", "_", "pre-commit"));
63
- let shouldSetupHooks = !skipHooks;
64
- if (shouldSetupHooks && interactive && isFirstHooksRun && !dir && !isLifecycleScript) shouldSetupHooks = await promptGitHooks({
65
- interactive,
66
- message: "Install the Git hook dispatcher for this project?"
67
- });
68
- if (shouldSetupHooks) {
69
- const { message, isError } = install(dir);
70
- if (message) {
71
- log(message);
72
- if (isError) process.exit(1);
63
+ if (!skipHooks) {
64
+ const location = resolveHooksLocation(dir);
65
+ if ("isError" in location) {
66
+ if (location.message) log(location.message);
67
+ if (location.isError) process.exit(1);
68
+ } else {
69
+ const isFirstHooksRun = !existsSync(join(location.baseDir, location.dir, "_", "pre-commit"));
70
+ let shouldSetupHooks = true;
71
+ if (isHooksUserDisabled()) {
72
+ log("skip install (hooks disabled; run `vp hooks enable` to re-enable)");
73
+ shouldSetupHooks = false;
74
+ } else if (interactive && isFirstHooksRun && !dir && !isLifecycleScript) shouldSetupHooks = await promptGitHooks({
75
+ interactive,
76
+ message: "Install the Git hook dispatcher for this project?"
77
+ });
78
+ if (shouldSetupHooks) {
79
+ const { message, isError } = install(dir);
80
+ if (message) {
81
+ log(message);
82
+ if (isError) process.exit(1);
83
+ }
84
+ }
73
85
  }
74
86
  }
75
87
  if (!skipAgent) updateExistingAgentInstructions(root);
@@ -1,10 +1,18 @@
1
1
  import { createRequire } from "node:module";
2
2
  //#region package.json
3
- var version = "0.2.8";
3
+ var version = "0.2.9";
4
4
  //#endregion
5
5
  //#region src/utils/constants.ts
6
6
  const VITE_PLUS_NAME = "vite-plus";
7
7
  const VITE_PLUS_VERSION = process.env.VP_VERSION || version;
8
+ const VITE_CONFIG_FILES = [
9
+ "vite.config.js",
10
+ "vite.config.mjs",
11
+ "vite.config.ts",
12
+ "vite.config.cjs",
13
+ "vite.config.mts",
14
+ "vite.config.cts"
15
+ ];
8
16
  const VITEST_VERSION = "4.1.10";
9
17
  const VITE_PLUS_OVERRIDE_PACKAGES = process.env.VP_OVERRIDE_PACKAGES ? JSON.parse(process.env.VP_OVERRIDE_PACKAGES) : {
10
18
  vite: `npm:@voidzero-dev/vite-plus-core@${VITE_PLUS_VERSION}`,
@@ -67,4 +75,4 @@ const DEFAULT_ENVS = {
67
75
  };
68
76
  const CONFIG_METADATA_ENV = "VP_RESOLVING_CONFIG_METADATA";
69
77
  //#endregion
70
- export { VITEST_AGE_GATE_EXEMPT_PACKAGES as a, VITE_PLUS_OVERRIDE_PACKAGES as c, isForceOverrideMode as d, resolve as f, DEFAULT_ENVS as i, VITE_PLUS_VERSION as l, version as m, BASEURL_TSCONFIG_WARNING as n, VITEST_VERSION as o, resolveBundled as p, CONFIG_METADATA_ENV as r, VITE_PLUS_NAME as s, BASEURL_TSCONFIG_FIX_PACKAGE as t, createBaseUrlTsconfigFixArgs as u };
78
+ export { VITEST_AGE_GATE_EXEMPT_PACKAGES as a, VITE_PLUS_NAME as c, createBaseUrlTsconfigFixArgs as d, isForceOverrideMode as f, version as h, DEFAULT_ENVS as i, VITE_PLUS_OVERRIDE_PACKAGES as l, resolveBundled as m, BASEURL_TSCONFIG_WARNING as n, VITEST_VERSION as o, resolve as p, CONFIG_METADATA_ENV as r, VITE_CONFIG_FILES as s, BASEURL_TSCONFIG_FIX_PACKAGE as t, VITE_PLUS_VERSION as u };
@@ -1,13 +1,13 @@
1
1
  import { r as __toESM, t as __commonJSMin } from "../rolldown-runtime-CMFfr-1z.js";
2
- import { a as printHeader, c as renderCliDoc, i as muted, o as success, r as log, t as accent } from "../terminal-CrqqK8WT.js";
3
- import { s as VITE_PLUS_NAME } from "../constants-BppDcRc1.js";
4
- import { A as isCancel, C as log$1, D as spinner, E as select, M as runCommandSilently, N as require_cross_spawn, O as text, S as intro, _ as DependencyType, a as resolveGitInit, b as cancel, c as selectPackageManager, d as readYamlFile, h as resolveApproveBuildTargets, i as promptGitHooks, j as runCommand$1, k as require_picocolors, m as detectGatedBuilds, n as defaultInteractive, o as runViteFmt, p as approveBuilds, r as downloadPackageManager$1, s as runViteInstall, u as editYamlFile, v as PackageManager, w as multiselect, x as confirm } from "../prompts-DYap08te.js";
5
- import { i as readJsonFile, n as editJsonFile } from "../json-BU88uu6o.js";
6
- import { a as resolveViteConfig, n as findWorkspaceRoot, r as hasViteConfig, t as findViteConfig } from "../resolve-vite-config-EWXclqvV.js";
2
+ import { a as muted, i as log, l as renderCliDoc, o as printHeader, r as formatDuration, s as success, t as accent } from "../terminal-Bz-ps6rJ.js";
3
+ import { c as VITE_PLUS_NAME } from "../constants-CG513DRa.js";
4
+ import { A as isCancel, C as log$1, D as spinner, E as select, M as runCommandSilently, N as require_cross_spawn, O as text, S as intro, a as resolveGitInit, c as selectPackageManager, d as readYamlFile, h as resolveApproveBuildTargets, i as promptGitHooks, j as runCommand$1, k as require_picocolors, 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 multiselect, x as confirm, y as PackageManager } from "../prompts-CHz_98bJ.js";
5
+ import { i as readJsonFile, n as editJsonFile } from "../json-qlK6UH0r.js";
6
+ import { a as resolveViteConfig, n as findWorkspaceRoot, r as hasViteConfig, t as findViteConfig } from "../resolve-vite-config-Dmeyeyj-.js";
7
7
  import { t as lib_default } from "../lib-L3DWSRQp.js";
8
- import { o as fetchNpmResource, s as getNpmRegistry, t as checkNpmPackageExists } from "../package-hV-77cBb.js";
9
- import { a as selectAgentTargets, c as writeCopilotSetupWorkflow, f as displayRelative, m as templatesDir, r as detectExistingAgentTargetPaths, s as writeAgentInstructions, t as COPILOT_AGENT_ID } from "../agent-CI79DuSy.js";
10
- import { A as addFrameworkShim, D as isBingoTemplate, E as detectWorkspace$1, H as promptEslintMigration, I as promptPrettierMigration, M as hasFrameworkShim, O as updatePackageJsonWithDeps, P as detectPrettierProject, _ as shouldSkipStagedMigrationForHooks, a as writeEditorConfigs, c as rewriteStandaloneProject, h as installGitHooks, i as selectEditors, j as detectFramework, k as updateWorkspaceConfig, n as detectExistingEditors, o as rewriteMonorepo, p as setPackageManager, s as rewriteMonorepoProject, v as injectCreateDefaultTemplate, z as detectEslintProject } from "../editor-CGWdbLgD.js";
8
+ import { o as fetchNpmResource, r as getScopeFromPackageName, s as getNpmRegistry, t as checkNpmPackageExists } from "../package-B4T8RGMG.js";
9
+ 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-DQU8uS6P.js";
10
+ import { A as isBingoTemplate, F as hasFrameworkShim, G as promptEslintMigration, H as detectEslintProject, L as detectPrettierProject, M as updateWorkspaceConfig, N as addFrameworkShim, P as detectFramework, a as selectEditors, b as initGitRepository, c as rewriteMonorepoProject, g as installGitHooks, j as updatePackageJsonWithDeps, k as detectWorkspace$1, l as rewriteStandaloneProject, m as setPackageManager, n as detectExistingEditors, o as writeEditorConfigs, s as rewriteMonorepo, v as shouldSkipStagedMigrationForHooks, x as injectCreateDefaultTemplate, y as findGitRoot, z as promptPrettierMigration } from "../editor-g4PosU99.js";
11
11
  import path from "node:path";
12
12
  import { runCommand, upsertJsonConfig, vitePlusHeader } from "../../binding/index.js";
13
13
  import { styleText } from "node:util";
@@ -16,18 +16,8 @@ import os from "node:os";
16
16
  import { createHash, randomUUID } from "node:crypto";
17
17
  import fsPromises from "node:fs/promises";
18
18
  import assert from "node:assert";
19
- //#region src/utils/git.ts
20
- var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
21
- async function initGitRepository(cwd) {
22
- return (await runCommandSilently({
23
- command: "git",
24
- args: ["init"],
25
- cwd,
26
- envs: process.env
27
- })).exitCode === 0;
28
- }
29
- //#endregion
30
19
  //#region src/create/command.ts
20
+ var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
31
21
  async function runCommandAndDetectProjectDir(options, parentDir) {
32
22
  const cwd = parentDir ? path.join(options.cwd, parentDir) : options.cwd;
33
23
  const existingDirs = /* @__PURE__ */ new Set();
@@ -962,6 +952,140 @@ function formatManifestTable(manifest, isMonorepo) {
962
952
  };
963
953
  }
964
954
  //#endregion
955
+ //#region src/create/org-resolve.ts
956
+ function printNonInteractiveTable(manifest, orgSpec, isMonorepo) {
957
+ const { lines, filteredCount } = formatManifestTable(manifest, isMonorepo);
958
+ const [firstVisible] = filterManifestForContext(manifest.templates, isMonorepo);
959
+ const body = [
960
+ "",
961
+ `A template name is required when running \`vp create ${orgSpec.scope}\` in non-interactive mode.`,
962
+ "",
963
+ `Available templates in ${manifest.packageName}:`,
964
+ "",
965
+ ...lines
966
+ ];
967
+ if (filteredCount > 0) body.push("", `(omitted ${filteredCount} monorepo-only ${filteredCount === 1 ? "entry" : "entries"} because this workspace is already a monorepo)`);
968
+ body.push("", "Examples:");
969
+ if (firstVisible) body.push(" # Scaffold a specific template from the org", ` vp create ${orgSpec.scope}:${firstVisible.name} --no-interactive`, "");
970
+ body.push(" # Or use a Vite+ built-in template", " vp create vite:application --no-interactive", "");
971
+ process.stderr.write(body.join("\n"));
972
+ }
973
+ function rejectMonorepoEntryInsideMonorepo(entry, isMonorepo) {
974
+ if (entry.monorepo && isMonorepo) {
975
+ log$1.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
976
+ cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
977
+ }
978
+ }
979
+ async function resolveEntry(manifest, entry) {
980
+ if (isRelativePath(entry.template)) return {
981
+ kind: "bundled",
982
+ bundledLocalPath: resolveBundledPath(await ensureOrgPackageExtracted(manifest), entry.template),
983
+ entryName: entry.name,
984
+ scope: manifest.scope,
985
+ ...entry.monorepo === true ? { monorepo: true } : {}
986
+ };
987
+ return {
988
+ kind: "replaced",
989
+ templateName: entry.template
990
+ };
991
+ }
992
+ /**
993
+ * If `selectedTemplateName` points at an `@scope[/name]` org whose
994
+ * `@scope/create` package publishes a `createConfig.templates` manifest, apply the
995
+ * manifest rules (picker / direct lookup / escape hatch / bundled
996
+ * extraction) and report the outcome.
997
+ *
998
+ * The caller — `packages/cli/src/create/bin.ts` — decides what to do next
999
+ * based on the returned variant.
1000
+ */
1001
+ async function resolveOrgManifestForCreate(args) {
1002
+ const orgSpec = parseOrgScopedSpec(args.templateName);
1003
+ if (!orgSpec) return { kind: "passthrough" };
1004
+ let manifest;
1005
+ try {
1006
+ manifest = await readOrgManifest(orgSpec.scope, orgSpec.version);
1007
+ } catch (error) {
1008
+ const message = error instanceof OrgManifestSchemaError ? error.message : `Failed to read ${orgSpec.scope}/create manifest: ${error.message}`;
1009
+ cancelAndExit(message, 1);
1010
+ }
1011
+ if (!manifest) {
1012
+ if (orgSpec.name !== void 0) cancelAndExit(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — \`@org:name\` requires one.`, 1);
1013
+ log$1.info(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — running it as a normal package.`);
1014
+ return { kind: "passthrough" };
1015
+ }
1016
+ if (orgSpec.name === void 0) {
1017
+ if (!args.interactive) {
1018
+ printNonInteractiveTable(manifest, orgSpec, args.isMonorepo);
1019
+ process.exit(1);
1020
+ }
1021
+ const picked = await pickOrgTemplate(manifest, { isMonorepo: args.isMonorepo });
1022
+ if (picked === ORG_PICKER_CANCEL) cancelAndExit();
1023
+ if (picked === ORG_PICKER_BUILTIN_ESCAPE) {
1024
+ if (args.isMonorepo && manifest.templates.every((t) => t.monorepo)) log$1.info(`No templates from ${manifest.packageName} are applicable inside a monorepo — showing Vite+ built-in templates instead.`);
1025
+ return { kind: "escape-hatch" };
1026
+ }
1027
+ rejectMonorepoEntryInsideMonorepo(picked.entry, args.isMonorepo);
1028
+ return resolveEntry(manifest, picked.entry);
1029
+ }
1030
+ const entry = manifest.templates.find((candidate) => candidate.name === orgSpec.name);
1031
+ if (!entry) {
1032
+ const available = filterManifestForContext(manifest.templates, args.isMonorepo).map((t) => t.name).join(", ");
1033
+ cancelAndExit(`No template named "${orgSpec.name}" in ${manifest.packageName}. Available: ${available || "(none applicable in this context)"}.`, 1);
1034
+ }
1035
+ rejectMonorepoEntryInsideMonorepo(entry, args.isMonorepo);
1036
+ return resolveEntry(manifest, entry);
1037
+ }
1038
+ /**
1039
+ * Read the `create` config (`defaultTemplate` + validated `templates`) from
1040
+ * a workspace's `vite.config.ts` in a single config evaluation.
1041
+ *
1042
+ * By default, walks up from `startDir` via `findWorkspaceRoot` (monorepo
1043
+ * markers only — `pnpm-workspace.yaml`, `workspaces` in `package.json`,
1044
+ * `lerna.json`) so monorepo invocations from any subdirectory still pick up
1045
+ * the root config. Pass `walkUp: false` to read `startDir` directly when the
1046
+ * caller already holds the exact workspace root.
1047
+ *
1048
+ * Best-effort for resolution: a missing or unresolvable config reads as
1049
+ * empty. A present-but-malformed `create.templates` still throws a
1050
+ * {@link CreateConfigSchemaError} so the misconfiguration surfaces.
1051
+ *
1052
+ * Pass `throwOnReadError: true` for read-modify-write callers (registration):
1053
+ * if a config file exists but cannot be evaluated, an empty read would let a
1054
+ * later write clobber the real `create` block, so the eval error is rethrown
1055
+ * instead of swallowed.
1056
+ */
1057
+ async function getConfiguredCreate(startDir, options) {
1058
+ const projectRoot = options?.walkUp === false ? startDir : findWorkspaceRoot(startDir) ?? startDir;
1059
+ if (!hasViteConfig(projectRoot)) return { templates: [] };
1060
+ let create;
1061
+ try {
1062
+ create = (await resolveViteConfig(projectRoot)).create;
1063
+ } catch (error) {
1064
+ if (options?.throwOnReadError) throw error;
1065
+ return { templates: [] };
1066
+ }
1067
+ const defaultTemplate = typeof create?.defaultTemplate === "string" && create.defaultTemplate.length > 0 ? create.defaultTemplate : void 0;
1068
+ const templates = validateCreateTemplates(create?.templates);
1069
+ return {
1070
+ ...defaultTemplate !== void 0 ? { defaultTemplate } : {},
1071
+ templates
1072
+ };
1073
+ }
1074
+ /**
1075
+ * Read `create.defaultTemplate` only. Best-effort for missing or unresolvable
1076
+ * configs (returns `undefined`), but a malformed `create.templates` still
1077
+ * rethrows its {@link CreateConfigSchemaError}: swallowing it here would
1078
+ * silently drop a valid `defaultTemplate` along with the diagnostic.
1079
+ */
1080
+ async function getConfiguredDefaultTemplate(startDir) {
1081
+ try {
1082
+ return (await getConfiguredCreate(startDir)).defaultTemplate;
1083
+ } catch (error) {
1084
+ if (error instanceof CreateConfigSchemaError) throw error;
1085
+ return;
1086
+ }
1087
+ }
1088
+ //#endregion
965
1089
  //#region ../../node_modules/.pnpm/validate-npm-package-name@7.0.2/node_modules/validate-npm-package-name/lib/builtin-modules.json
966
1090
  var require_builtin_modules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
967
1091
  module.exports = [
@@ -4110,10 +4234,6 @@ async function checkProjectDirExists(projectDirFullPath, interactive) {
4110
4234
  case "no": cancelAndExit();
4111
4235
  }
4112
4236
  }
4113
- function cancelAndExit(message = "Operation cancelled", exitCode = 0) {
4114
- cancel(message);
4115
- process.exit(exitCode);
4116
- }
4117
4237
  function isEmpty(path) {
4118
4238
  const files = fs.readdirSync(path);
4119
4239
  return files.length === 0 || files.length === 1 && files[0] === ".git";
@@ -4157,139 +4277,6 @@ function validateTargetDir(input, cwd) {
4157
4277
  return { directory: targetDir };
4158
4278
  }
4159
4279
  //#endregion
4160
- //#region src/create/org-resolve.ts
4161
- function printNonInteractiveTable(manifest, orgSpec, isMonorepo) {
4162
- const { lines, filteredCount } = formatManifestTable(manifest, isMonorepo);
4163
- const [firstVisible] = filterManifestForContext(manifest.templates, isMonorepo);
4164
- const body = [
4165
- "",
4166
- `A template name is required when running \`vp create ${orgSpec.scope}\` in non-interactive mode.`,
4167
- "",
4168
- `Available templates in ${manifest.packageName}:`,
4169
- "",
4170
- ...lines
4171
- ];
4172
- if (filteredCount > 0) body.push("", `(omitted ${filteredCount} monorepo-only ${filteredCount === 1 ? "entry" : "entries"} because this workspace is already a monorepo)`);
4173
- body.push("", "Examples:");
4174
- if (firstVisible) body.push(" # Scaffold a specific template from the org", ` vp create ${orgSpec.scope}:${firstVisible.name} --no-interactive`, "");
4175
- body.push(" # Or use a Vite+ built-in template", " vp create vite:application --no-interactive", "");
4176
- process.stderr.write(body.join("\n"));
4177
- }
4178
- function rejectMonorepoEntryInsideMonorepo(entry, isMonorepo) {
4179
- if (entry.monorepo && isMonorepo) {
4180
- log$1.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
4181
- cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
4182
- }
4183
- }
4184
- async function resolveEntry(manifest, entry) {
4185
- if (isRelativePath(entry.template)) return {
4186
- kind: "bundled",
4187
- bundledLocalPath: resolveBundledPath(await ensureOrgPackageExtracted(manifest), entry.template),
4188
- entryName: entry.name,
4189
- scope: manifest.scope,
4190
- ...entry.monorepo === true ? { monorepo: true } : {}
4191
- };
4192
- return {
4193
- kind: "replaced",
4194
- templateName: entry.template
4195
- };
4196
- }
4197
- /**
4198
- * If `selectedTemplateName` points at an `@scope[/name]` org whose
4199
- * `@scope/create` package publishes a `createConfig.templates` manifest, apply the
4200
- * manifest rules (picker / direct lookup / escape hatch / bundled
4201
- * extraction) and report the outcome.
4202
- *
4203
- * The caller — `packages/cli/src/create/bin.ts` — decides what to do next
4204
- * based on the returned variant.
4205
- */
4206
- async function resolveOrgManifestForCreate(args) {
4207
- const orgSpec = parseOrgScopedSpec(args.templateName);
4208
- if (!orgSpec) return { kind: "passthrough" };
4209
- let manifest;
4210
- try {
4211
- manifest = await readOrgManifest(orgSpec.scope, orgSpec.version);
4212
- } catch (error) {
4213
- cancelAndExit(error instanceof OrgManifestSchemaError ? error.message : `Failed to read ${orgSpec.scope}/create manifest: ${error.message}`, 1);
4214
- }
4215
- if (!manifest) {
4216
- if (orgSpec.name !== void 0) cancelAndExit(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — \`@org:name\` requires one.`, 1);
4217
- log$1.info(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — running it as a normal package.`);
4218
- return { kind: "passthrough" };
4219
- }
4220
- if (orgSpec.name === void 0) {
4221
- if (!args.interactive) {
4222
- printNonInteractiveTable(manifest, orgSpec, args.isMonorepo);
4223
- process.exit(1);
4224
- }
4225
- const picked = await pickOrgTemplate(manifest, { isMonorepo: args.isMonorepo });
4226
- if (picked === ORG_PICKER_CANCEL) cancelAndExit();
4227
- if (picked === ORG_PICKER_BUILTIN_ESCAPE) {
4228
- if (args.isMonorepo && manifest.templates.every((t) => t.monorepo)) log$1.info(`No templates from ${manifest.packageName} are applicable inside a monorepo — showing Vite+ built-in templates instead.`);
4229
- return { kind: "escape-hatch" };
4230
- }
4231
- rejectMonorepoEntryInsideMonorepo(picked.entry, args.isMonorepo);
4232
- return resolveEntry(manifest, picked.entry);
4233
- }
4234
- const entry = manifest.templates.find((candidate) => candidate.name === orgSpec.name);
4235
- if (!entry) {
4236
- const available = filterManifestForContext(manifest.templates, args.isMonorepo).map((t) => t.name).join(", ");
4237
- cancelAndExit(`No template named "${orgSpec.name}" in ${manifest.packageName}. Available: ${available || "(none applicable in this context)"}.`, 1);
4238
- }
4239
- rejectMonorepoEntryInsideMonorepo(entry, args.isMonorepo);
4240
- return resolveEntry(manifest, entry);
4241
- }
4242
- /**
4243
- * Read the `create` config (`defaultTemplate` + validated `templates`) from
4244
- * a workspace's `vite.config.ts` in a single config evaluation.
4245
- *
4246
- * By default, walks up from `startDir` via `findWorkspaceRoot` (monorepo
4247
- * markers only — `pnpm-workspace.yaml`, `workspaces` in `package.json`,
4248
- * `lerna.json`) so monorepo invocations from any subdirectory still pick up
4249
- * the root config. Pass `walkUp: false` to read `startDir` directly when the
4250
- * caller already holds the exact workspace root.
4251
- *
4252
- * Best-effort for resolution: a missing or unresolvable config reads as
4253
- * empty. A present-but-malformed `create.templates` still throws a
4254
- * {@link CreateConfigSchemaError} so the misconfiguration surfaces.
4255
- *
4256
- * Pass `throwOnReadError: true` for read-modify-write callers (registration):
4257
- * if a config file exists but cannot be evaluated, an empty read would let a
4258
- * later write clobber the real `create` block, so the eval error is rethrown
4259
- * instead of swallowed.
4260
- */
4261
- async function getConfiguredCreate(startDir, options) {
4262
- const projectRoot = options?.walkUp === false ? startDir : findWorkspaceRoot(startDir) ?? startDir;
4263
- if (!hasViteConfig(projectRoot)) return { templates: [] };
4264
- let create;
4265
- try {
4266
- create = (await resolveViteConfig(projectRoot)).create;
4267
- } catch (error) {
4268
- if (options?.throwOnReadError) throw error;
4269
- return { templates: [] };
4270
- }
4271
- const defaultTemplate = typeof create?.defaultTemplate === "string" && create.defaultTemplate.length > 0 ? create.defaultTemplate : void 0;
4272
- const templates = validateCreateTemplates(create?.templates);
4273
- return {
4274
- ...defaultTemplate !== void 0 ? { defaultTemplate } : {},
4275
- templates
4276
- };
4277
- }
4278
- /**
4279
- * Read `create.defaultTemplate` only. Best-effort for missing or unresolvable
4280
- * configs (returns `undefined`), but a malformed `create.templates` still
4281
- * rethrows its {@link CreateConfigSchemaError}: swallowing it here would
4282
- * silently drop a valid `defaultTemplate` along with the diagnostic.
4283
- */
4284
- async function getConfiguredDefaultTemplate(startDir) {
4285
- try {
4286
- return (await getConfiguredCreate(startDir)).defaultTemplate;
4287
- } catch (error) {
4288
- if (error instanceof CreateConfigSchemaError) throw error;
4289
- return;
4290
- }
4291
- }
4292
- //#endregion
4293
4280
  //#region src/create/register-template.ts
4294
4281
  /**
4295
4282
  * Register a local template into `create.templates` in a monorepo's root
@@ -4674,10 +4661,6 @@ function dropAliasedRuntimeDevDeps(appProjectPath, packageManager) {
4674
4661
  return changed ? pkg : void 0;
4675
4662
  });
4676
4663
  }
4677
- function getScopeFromPackageName(packageName) {
4678
- if (packageName.startsWith("@")) return packageName.split("/")[0];
4679
- return "";
4680
- }
4681
4664
  //#endregion
4682
4665
  //#region src/create/bin.ts
4683
4666
  const helpMessage = renderCliDoc({
@@ -4958,25 +4941,10 @@ function formatTemplateName(templateName) {
4958
4941
  const baseName = isTypeScript ? templateName.slice(0, -3) : templateName;
4959
4942
  return `${templateAliases[baseName] ?? baseName.split(/[-_]/).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join(" ")} + ${isTypeScript ? "TypeScript" : "JavaScript"}`;
4960
4943
  }
4961
- function formatDuration(durationMs) {
4962
- if (durationMs < 1e3) return `${Math.max(1, durationMs)}ms`;
4963
- const durationSeconds = durationMs / 1e3;
4964
- if (durationSeconds < 10) return `${durationSeconds.toFixed(1)}s`;
4965
- return `${Math.round(durationSeconds)}s`;
4966
- }
4967
4944
  function getNextCommand(projectDir, command) {
4968
4945
  if (!projectDir || projectDir === ".") return command;
4969
4946
  return `cd ${projectDir} && ${command}`;
4970
4947
  }
4971
- function findGitRoot(startPath) {
4972
- let dir = startPath;
4973
- while (true) {
4974
- if (fs.existsSync(path.join(dir, ".git"))) return dir;
4975
- const parent = path.dirname(dir);
4976
- if (parent === dir) return;
4977
- dir = parent;
4978
- }
4979
- }
4980
4948
  function getCopilotSetupRoot(projectRoot, isExistingMonorepo) {
4981
4949
  if (!isExistingMonorepo) return projectRoot;
4982
4950
  return findGitRoot(projectRoot) ?? projectRoot;
@@ -5155,36 +5123,40 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
5155
5123
  if (isInSubdirectory && !compactOutput) log$1.info(`Use ${accent("--directory")} to specify a different target location.`);
5156
5124
  selectedParentDir = inferParentDir(selectedTemplateName, workspaceInfoOptional, isLocalTemplate) ?? workspaceInfoOptional.parentDirs[0];
5157
5125
  }
5158
- if (isGitHubUrl(selectedTemplateName)) if (hasExplicitTargetDir(selectedTemplateArgs)) remoteTargetDir = selectedTemplateArgs[0];
5159
- else {
5160
- const inferredTargetDir = inferGitHubRepoName(selectedTemplateName) ?? "template";
5161
- const remoteTargetBaseDir = selectedParentDir ? path.join(workspaceInfoOptional.rootDir, selectedParentDir) : workspaceInfoOptional.rootDir;
5162
- const defaultTargetDir = suggestAvailableTargetDir(inferredTargetDir, remoteTargetBaseDir);
5163
- if (defaultTargetDir !== inferredTargetDir && options.interactive) log$1.info(` Target directory "${inferredTargetDir}" already exists. Suggested: ${accent(defaultTargetDir)}`);
5164
- remoteTargetDir = await promptTargetDir(defaultTargetDir, options.interactive, { cwd: remoteTargetBaseDir });
5165
- selectedTemplateArgs = [remoteTargetDir, ...selectedTemplateArgs];
5126
+ if (isGitHubUrl(selectedTemplateName)) {
5127
+ if (hasExplicitTargetDir(selectedTemplateArgs)) remoteTargetDir = selectedTemplateArgs[0];
5128
+ else {
5129
+ const inferredTargetDir = inferGitHubRepoName(selectedTemplateName) ?? "template";
5130
+ const remoteTargetBaseDir = selectedParentDir ? path.join(workspaceInfoOptional.rootDir, selectedParentDir) : workspaceInfoOptional.rootDir;
5131
+ const defaultTargetDir = suggestAvailableTargetDir(inferredTargetDir, remoteTargetBaseDir);
5132
+ if (defaultTargetDir !== inferredTargetDir && options.interactive) log$1.info(` Target directory "${inferredTargetDir}" already exists. Suggested: ${accent(defaultTargetDir)}`);
5133
+ remoteTargetDir = await promptTargetDir(defaultTargetDir, options.interactive, { cwd: remoteTargetBaseDir });
5134
+ selectedTemplateArgs = [remoteTargetDir, ...selectedTemplateArgs];
5135
+ }
5166
5136
  }
5167
5137
  const directScaffoldFallbackName = bundled ? `vite-plus-${bundled.entryName}` : selectedTemplateName === BuiltinTemplate.monorepo ? "vite-plus-monorepo" : `vite-plus-${selectedTemplateName.split(":")[1]}`;
5168
- if (isDirectScaffoldTemplate && (!targetDir || targetDir === ".")) if (targetDir === ".") {
5169
- packageName = deriveDefaultPackageName(cwd, workspaceInfoOptional.monorepoScope, directScaffoldFallbackName);
5170
- if (isMonorepo) {
5171
- if (!cwdRelativeToRoot) cancelAndExit("Cannot scaffold into the monorepo root directory. Use --directory to specify a target directory", 1);
5172
- const enclosingPackage = workspaceInfoOptional.packages.find((pkg) => cwdRelativeToRoot === pkg.path || cwdRelativeToRoot.startsWith(`${pkg.path}/`));
5173
- if (enclosingPackage) cancelAndExit(`Cannot scaffold inside existing package "${enclosingPackage.name}" (${enclosingPackage.path}). Use --directory to specify a different location`, 1);
5174
- targetDir = cwdRelativeToRoot;
5138
+ if (isDirectScaffoldTemplate && (!targetDir || targetDir === ".")) {
5139
+ if (targetDir === ".") {
5140
+ packageName = deriveDefaultPackageName(cwd, workspaceInfoOptional.monorepoScope, directScaffoldFallbackName);
5141
+ if (isMonorepo) {
5142
+ if (!cwdRelativeToRoot) cancelAndExit("Cannot scaffold into the monorepo root directory. Use --directory to specify a target directory", 1);
5143
+ const enclosingPackage = workspaceInfoOptional.packages.find((pkg) => cwdRelativeToRoot === pkg.path || cwdRelativeToRoot.startsWith(`${pkg.path}/`));
5144
+ if (enclosingPackage) cancelAndExit(`Cannot scaffold inside existing package "${enclosingPackage.name}" (${enclosingPackage.path}). Use --directory to specify a different location`, 1);
5145
+ targetDir = cwdRelativeToRoot;
5146
+ }
5147
+ log$1.info(`Using package name: ${accent(packageName)}`);
5148
+ } else if (selectedTemplateName === BuiltinTemplate.monorepo) {
5149
+ const selected = await promptPackageNameAndTargetDir(getRandomProjectName({ fallbackName: "vite-plus-monorepo" }), options.interactive);
5150
+ packageName = selected.packageName;
5151
+ targetDir = selected.targetDir;
5152
+ } else {
5153
+ const selected = await promptPackageNameAndTargetDir(getRandomProjectName({
5154
+ scope: workspaceInfoOptional.monorepoScope,
5155
+ fallbackName: directScaffoldFallbackName
5156
+ }), options.interactive);
5157
+ packageName = selected.packageName;
5158
+ targetDir = selectedParentDir ? path.join(selectedParentDir, selected.targetDir).split(path.sep).join("/") : selected.targetDir;
5175
5159
  }
5176
- log$1.info(`Using package name: ${accent(packageName)}`);
5177
- } else if (selectedTemplateName === BuiltinTemplate.monorepo) {
5178
- const selected = await promptPackageNameAndTargetDir(getRandomProjectName({ fallbackName: "vite-plus-monorepo" }), options.interactive);
5179
- packageName = selected.packageName;
5180
- targetDir = selected.targetDir;
5181
- } else {
5182
- const selected = await promptPackageNameAndTargetDir(getRandomProjectName({
5183
- scope: workspaceInfoOptional.monorepoScope,
5184
- fallbackName: directScaffoldFallbackName
5185
- }), options.interactive);
5186
- packageName = selected.packageName;
5187
- targetDir = selectedParentDir ? path.join(selectedParentDir, selected.targetDir).split(path.sep).join("/") : selected.targetDir;
5188
5160
  }
5189
5161
  if (options.packageManager && !Object.values(PackageManager).includes(options.packageManager)) {
5190
5162
  const valid = Object.values(PackageManager).join(", ");
@@ -5361,7 +5333,8 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
5361
5333
  editorId: selectedEditors,
5362
5334
  interactive: options.interactive,
5363
5335
  silent: compactOutput,
5364
- extraVsCodeSettings: { "npm.scriptRunner": "vp" }
5336
+ extraVsCodeSettings: { "npm.scriptRunner": "vp" },
5337
+ packageManager
5365
5338
  });
5366
5339
  if (selectedEditors?.includes("vscode")) ensureGitignoreVsCodeEditorConfigs(fullPath);
5367
5340
  resumeCreateProgress();
@@ -5479,7 +5452,8 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
5479
5452
  editorId: selectedEditors,
5480
5453
  interactive: options.interactive,
5481
5454
  silent: compactOutput,
5482
- extraVsCodeSettings: { "npm.scriptRunner": "vp" }
5455
+ extraVsCodeSettings: { "npm.scriptRunner": "vp" },
5456
+ packageManager
5483
5457
  });
5484
5458
  if (selectedEditors?.includes("vscode")) ensureGitignoreVsCodeEditorConfigs(fullPath);
5485
5459
  resumeCreateProgress();
@@ -1,10 +1,10 @@
1
- import { o as VITEST_VERSION, r as CONFIG_METADATA_ENV } from "./constants-BppDcRc1.js";
1
+ import { o as VITEST_VERSION, r as CONFIG_METADATA_ENV } from "./constants-CG513DRa.js";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
- import { readFileSync } from "node:fs";
5
4
  import { fileURLToPath } from "node:url";
5
+ import { readFileSync } from "node:fs";
6
6
  import { defineConfig, defineProject } from "vitest/config";
7
- //#region ../../node_modules/.pnpm/tsdown@0.22.14_@arethetypeswrong+core@0.18.2_@tsdown+css@0.22.14_@tsdown+exe@0.22.14_@t_3f66331a323f6503c9462b3ef80883b8/node_modules/tsdown/esm-shims.js
7
+ //#region ../../node_modules/.pnpm/tsdown@0.22.14_@arethetypeswrong+core@0.18.2_@tsdown+css@0.22.14_@tsdown+exe@0.22.14_@t_8361ec2a4d03114085b1954a2fc42e35/node_modules/tsdown/esm-shims.js
8
8
  const getFilename = () => fileURLToPath(import.meta.url);
9
9
  const getDirname = () => path.dirname(getFilename());
10
10
  const __dirname = /* @__PURE__ */ getDirname();
@@ -37,7 +37,7 @@ let node_module = require("node:module");
37
37
  let node_url = require("node:url");
38
38
  let vitest_config = require("vitest/config");
39
39
  //#region package.json
40
- var version = "0.2.8", VITE_PLUS_VERSION, VITEST_VERSION, CONFIG_METADATA_ENV;
40
+ var version = "0.2.9", VITE_PLUS_VERSION, VITEST_VERSION, CONFIG_METADATA_ENV;
41
41
  var init_constants = __esmMin((() => {
42
42
  VITE_PLUS_VERSION = process.env.VP_VERSION || version;
43
43
  VITEST_VERSION = "4.1.10";
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_define_config = require("./define-config-CEm_MtvJ.cjs");
2
+ const require_define_config = require("./define-config-DyNLA_f0.cjs");
3
3
  require_define_config.init_define_config();
4
4
  exports.AUTO_INLINE_DEPS = require_define_config.AUTO_INLINE_DEPS;
5
5
  exports.assertCoverageProviderVersionMatch = require_define_config.assertCoverageProviderVersionMatch;
@@ -1,2 +1,2 @@
1
- import { a as defineConfig, c as lazyPlugins, i as computeAutoInlineList, l as resolveCoverageProviderToCheck, n as assertCoverageProviderVersionMatch, o as defineProject, r as checkCoverageProviderVersion, s as isVitestFamilySpecifier, t as AUTO_INLINE_DEPS, u as withConfigMetadataResolution } from "./define-config-DPnHe1Mx.js";
1
+ import { a as defineConfig, c as lazyPlugins, i as computeAutoInlineList, l as resolveCoverageProviderToCheck, n as assertCoverageProviderVersionMatch, o as defineProject, r as checkCoverageProviderVersion, s as isVitestFamilySpecifier, t as AUTO_INLINE_DEPS, u as withConfigMetadataResolution } from "./define-config-CV4bQG_8.js";
2
2
  export { AUTO_INLINE_DEPS, assertCoverageProviderVersionMatch, checkCoverageProviderVersion, computeAutoInlineList, defineConfig, defineProject, isVitestFamilySpecifier, lazyPlugins, resolveCoverageProviderToCheck, withConfigMetadataResolution };