vite-plus 1.3.0 → 1.5.0
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 +4 -0
- package/LICENSE +1 -878
- package/README.md +1 -1
- package/bin/vpx +9 -0
- package/binding/index.cjs +59 -54
- package/binding/index.d.cts +159 -2
- package/dist/{agent-97KmGCyL.js → agent-DkQD3xqe.js} +5 -7
- package/dist/bin.js +35 -34
- package/dist/{cli-parse-DHE8NrBU.js → cli-parse-aeUeFDlC.js} +2 -3
- package/dist/command-TjS_6y9O.js +1 -0
- package/dist/{command-CdMBoZFD.js → command-rY79K5NI.js} +28 -30
- package/dist/{comparison-CmVirWIW-DUGaiYqF.js → comparison-CmVirWIW-UlEf2maz.js} +1 -2
- package/dist/config/bin.js +8 -10
- package/dist/{constants-DR55DpRm.js → constants-D2P2aVKb.js} +8 -6
- package/dist/create/bin.d.ts +4 -8
- package/dist/create/bin.js +151 -120
- package/dist/{define-config-Bexdd6RZ.d.ts → define-config-BrvHRi-G.d.ts} +31 -13
- package/dist/{define-config-BxDc_9BK.cjs → define-config-CwtQqYC1.cjs} +41 -14
- package/dist/{define-config-CvE5pHqB.js → define-config-wR57OZG_.js} +34 -12
- package/dist/define-config.cjs +2 -1
- package/dist/define-config.d.ts +2 -2
- package/dist/define-config.js +1 -1
- package/dist/{dist-DIpm7mot.js → dist-Bs0SObNC.js} +73 -145
- package/dist/{dist-Cqz8OtiO.js → dist-CdkMvIiQ.js} +11 -5
- package/dist/dist-zDZV5eEc.js +3 -0
- package/dist/{documentation-DqcZSthV.js → documentation-cv_y0Auv.js} +1 -2
- package/dist/{editor-CtJGQP7C.js → editor-aOy1T15H.js} +2735 -5072
- package/dist/{help-BmKpeOP9.js → help-B03t_iQ4.js} +1 -2
- package/dist/hooks/bin.js +4 -5
- package/dist/{hooks-DhwsWb46.js → hooks-w_e2whkQ.js} +45 -25
- package/dist/index.cjs +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{json-JP24qHUF.js → json-kl84kDyH.js} +9 -18
- package/dist/lint-plugins.cjs +1 -1
- package/dist/migration/bin.js +1782 -256
- package/dist/migration/compat/worker.js +4 -6
- package/dist/{oxlint-plugin-config-BIzrO2y2.js → oxlint-plugin-config-CHsI_zKo.js} +3 -4
- package/dist/oxlint-plugin.d.ts +0 -2
- package/dist/oxlint-plugin.js +33 -9
- package/dist/{pack-BK38MLVZ.d.ts → pack-ARPFMefW.d.ts} +0 -2
- package/dist/pack-bin.d.ts +1 -3
- package/dist/pack-bin.js +4 -5
- package/dist/pack.d.ts +1 -1
- package/dist/{package-CQDXTm6j.js → package-DfFo6-E-.js} +10 -95
- package/dist/{package-overrides-D1RcXSFl.js → package-overrides-Ci8GXouY.js} +5 -8
- package/dist/picomatch-DEUoj81q.js +1916 -0
- package/dist/{prompts-1xNz_ne0.js → prompts-C7DI63WP.js} +30 -50
- package/dist/{protocol-D99W10Qi.js → protocol-CkNmY-Mr.js} +1 -2
- package/dist/register.d.ts +1 -0
- package/dist/register.js +12 -0
- package/dist/{report-NhQk8VHb.js → report-BEdpIQvC.js} +4 -2
- package/dist/resolve-vite-config-33bzSaeT.js +1 -0
- package/dist/{resolve-vite-config-BVr1SUNg.js → resolve-vite-config-Cx3cnVVI.js} +9 -25
- package/dist/{rolldown-runtime-kJ_i4yPo.js → rolldown-runtime-DegdyBIC.js} +1 -2
- package/dist/script-esm-hooks.d.ts +11 -0
- package/dist/script-esm-hooks.js +27 -0
- package/dist/script-hooks-9Fof5UMY.js +176 -0
- package/dist/script-preload.cjs +491 -0
- package/dist/script-register.d.ts +1 -0
- package/dist/script-register.js +27 -0
- package/dist/script-watch.d.ts +1 -0
- package/dist/script-watch.js +2002 -0
- package/dist/staged/bin.js +53 -2011
- package/dist/sync-versions/bin.js +26 -48
- package/dist/sync-versions/bin.mjs +109 -217
- package/dist/{terminal-MKGAuy-p.js → terminal-BcuPUy-j.js} +1 -2
- package/dist/toolchain.js +38 -12
- package/dist/toolchain.json +38 -12
- package/dist/{tsconfig-zWgHiQ3X.js → tsconfig-BE3Wj9OX.js} +1 -1
- package/dist/{tsconfig-BZu7kl-x.js → tsconfig-shNmmCE_.js} +8 -10
- package/dist/version.d.ts +1 -3
- package/dist/version.js +5 -6
- package/dist/versions.js +7 -7
- package/dist/{vitest-ecosystem-BU0AqZq-.js → vitest-ecosystem-BeEYz-qF.js} +1 -2
- package/dist/{vitest-v5-entry-points-DthU1e_O.js → vitest-v5-entry-points-NyJsFeux.js} +1 -2
- package/dist/vpx-bin.d.ts +1 -0
- package/dist/vpx-bin.js +232 -0
- package/dist/vpx-script-EXgV5QOf.js +434 -0
- 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 +10 -2
- package/docs/config/staged.md +1 -1
- package/docs/guide/check.md +6 -1
- package/docs/guide/ci.md +13 -3
- package/docs/guide/create.md +1 -1
- package/docs/guide/env.md +11 -4
- package/docs/guide/global-cli.md +59 -3
- 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/local-cli.md +21 -0
- package/docs/guide/migrate-rules.md +120 -18
- package/docs/guide/migrate.md +9 -9
- package/docs/guide/package-management.md +1 -1
- 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 +210 -9
- package/package.json +43 -34
- package/dist/command-DVTILtS-.js +0 -1
- package/dist/dist-Dhu07wmN.js +0 -3
- package/dist/resolve-vite-config-7WDtXO4G.js +0 -1
package/dist/create/bin.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { r as __toESM, t as __commonJSMin } from "../rolldown-runtime-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { i as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
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-C7DI63WP.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-aOy1T15H.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-DkQD3xqe.js";
|
|
5
|
+
import { t as unwrapCliParseOutcome } from "../cli-parse-aeUeFDlC.js";
|
|
6
|
+
import { t as documentationUrl$1 } from "../documentation-cv_y0Auv.js";
|
|
7
|
+
import { t as renderCliDoc } from "../help-B03t_iQ4.js";
|
|
8
|
+
import { i as readJsonFile, n as editJsonFile } from "../json-kl84kDyH.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-DfFo6-E-.js";
|
|
11
|
+
import { a as resolveViteConfig, r as hasViteConfig, t as findViteConfig } from "../resolve-vite-config-Cx3cnVVI.js";
|
|
12
|
+
import { t as require_dist } from "../dist-Bs0SObNC.js";
|
|
13
|
+
import { d as VITE_PLUS_OVERRIDE_PACKAGES, f as VITE_PLUS_VERSION, u as VITE_PLUS_NAME } from "../constants-D2P2aVKb.js";
|
|
14
|
+
import { i as runCommandSilently, r as runCommand$1 } from "../command-rY79K5NI.js";
|
|
15
15
|
import path from "node:path";
|
|
16
|
-
import { getVpDirs, parseCreateArgs, removeConfigKey, runCommand, upsertJsonConfig, vitePlusHeader } from "../../binding/index.js";
|
|
16
|
+
import { findMonorepoRoot, getVpDirs, parseCreateArgs, removeConfigKey, runCommand, upsertJsonConfig, vitePlusHeader } from "../../binding/index.js";
|
|
17
17
|
import { promisify, styleText } from "node:util";
|
|
18
18
|
import fs from "node:fs";
|
|
19
|
-
import os from "node:os";
|
|
20
19
|
import { createHash, randomUUID } from "node:crypto";
|
|
20
|
+
import os from "node:os";
|
|
21
21
|
import fsPromises from "node:fs/promises";
|
|
22
22
|
import { gunzip } from "node:zlib";
|
|
23
23
|
import assert from "node:assert";
|
|
24
|
-
|
|
24
|
+
// src/create/command.ts
|
|
25
25
|
async function runCommandAndDetectProjectDir(options, parentDir) {
|
|
26
26
|
const cwd = parentDir ? path.join(options.cwd, parentDir) : options.cwd;
|
|
27
27
|
const existingDirs = /* @__PURE__ */ new Set();
|
|
@@ -97,8 +97,7 @@ function prependToPathToEnvs(extraPath, envs) {
|
|
|
97
97
|
if (!current.split(delimiter).filter(Boolean).includes(extraPath)) envs[pathKey] = extraPath + (current ? delimiter + current : "");
|
|
98
98
|
return envs;
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
//#region ../../node_modules/.pnpm/nanotar@0.3.0/node_modules/nanotar/dist/index.mjs
|
|
100
|
+
// ../../node_modules/.pnpm/nanotar@0.3.0/node_modules/nanotar/dist/index.mjs
|
|
102
101
|
const tarItemTypeMap = {
|
|
103
102
|
"0": "file",
|
|
104
103
|
"1": "hardLink",
|
|
@@ -239,8 +238,7 @@ function _parseExtendedHeaders(data) {
|
|
|
239
238
|
}
|
|
240
239
|
return headers;
|
|
241
240
|
}
|
|
242
|
-
|
|
243
|
-
//#region src/create/org-tarball-reader.ts
|
|
241
|
+
// src/create/org-tarball-reader.ts
|
|
244
242
|
const decompress = promisify(gunzip);
|
|
245
243
|
const TAR_BLOCK_BYTES = 512;
|
|
246
244
|
const ORG_TARBALL_LIMITS = {
|
|
@@ -311,8 +309,7 @@ async function parseOrgTarball(bytes, limits = ORG_TARBALL_LIMITS) {
|
|
|
311
309
|
return true;
|
|
312
310
|
} });
|
|
313
311
|
}
|
|
314
|
-
|
|
315
|
-
//#region src/create/org-tarball.ts
|
|
312
|
+
// src/create/org-tarball.ts
|
|
316
313
|
function getCacheRoot() {
|
|
317
314
|
return path.join(getVpDirs().cache, "create-org");
|
|
318
315
|
}
|
|
@@ -545,8 +542,7 @@ function resolveBundledPath(extractedRoot, relativePath) {
|
|
|
545
542
|
if (resolvedTarget !== resolvedRoot && !resolvedTarget.startsWith(`${resolvedRoot}${path.sep}`)) throw new Error(`bundled template path escapes the package root: ${relativePath}`);
|
|
546
543
|
return resolvedTarget;
|
|
547
544
|
}
|
|
548
|
-
|
|
549
|
-
//#region src/create/org-manifest.ts
|
|
545
|
+
// src/create/org-manifest.ts
|
|
550
546
|
/**
|
|
551
547
|
* Parse the org picker specifier: `@scope` (scope only → picker) or
|
|
552
548
|
* `@scope:name` (direct manifest-entry selection). Colon mirrors the
|
|
@@ -767,8 +763,7 @@ function filterManifestForContext(templates, isMonorepo) {
|
|
|
767
763
|
if (!isMonorepo) return [...templates];
|
|
768
764
|
return templates.filter((entry) => !entry.monorepo);
|
|
769
765
|
}
|
|
770
|
-
|
|
771
|
-
//#region src/create/templates/types.ts
|
|
766
|
+
// src/create/templates/types.ts
|
|
772
767
|
const LibraryTemplateRepo = "github:sxzz/tsdown-templates/vite-plus";
|
|
773
768
|
const BuiltinTemplate = {
|
|
774
769
|
generator: "vite:generator",
|
|
@@ -782,8 +777,7 @@ const TemplateType = {
|
|
|
782
777
|
remote: "remote",
|
|
783
778
|
bundled: "bundled"
|
|
784
779
|
};
|
|
785
|
-
|
|
786
|
-
//#region src/create/discovery.ts
|
|
780
|
+
// src/create/discovery.ts
|
|
787
781
|
function isGitHubUrl(templateName) {
|
|
788
782
|
return templateName.startsWith("https://github.com/") || templateName.startsWith("github:") || templateName.includes("github.com/");
|
|
789
783
|
}
|
|
@@ -935,8 +929,7 @@ function inferParentDir(templateName, workspaceInfo, localTemplate = false) {
|
|
|
935
929
|
else if (templateName === BuiltinTemplate.generator) rule = /generator|tool/i;
|
|
936
930
|
for (const parentDir of workspaceInfo.parentDirs) if (rule.test(parentDir)) return parentDir;
|
|
937
931
|
}
|
|
938
|
-
|
|
939
|
-
//#region src/create/initial-template-options.ts
|
|
932
|
+
// src/create/initial-template-options.ts
|
|
940
933
|
function getInitialTemplateOptions(isMonorepo, templates = []) {
|
|
941
934
|
return [
|
|
942
935
|
...!isMonorepo ? [{
|
|
@@ -961,8 +954,7 @@ function getInitialTemplateOptions(isMonorepo, templates = []) {
|
|
|
961
954
|
})) : []
|
|
962
955
|
];
|
|
963
956
|
}
|
|
964
|
-
|
|
965
|
-
//#region src/create/org-picker.ts
|
|
957
|
+
// src/create/org-picker.ts
|
|
966
958
|
const ORG_PICKER_CANCEL = Symbol("org-picker-cancel");
|
|
967
959
|
const ORG_PICKER_BUILTIN_ESCAPE = Symbol("org-picker-builtin-escape");
|
|
968
960
|
const ESCAPE_HATCH = Symbol("builtin-escape");
|
|
@@ -1027,8 +1019,7 @@ function formatManifestTable(manifest, isMonorepo) {
|
|
|
1027
1019
|
filteredCount
|
|
1028
1020
|
};
|
|
1029
1021
|
}
|
|
1030
|
-
|
|
1031
|
-
//#region src/create/org-resolve.ts
|
|
1022
|
+
// src/create/org-resolve.ts
|
|
1032
1023
|
function printNonInteractiveTable(manifest, orgSpec, isMonorepo) {
|
|
1033
1024
|
const { lines, filteredCount } = formatManifestTable(manifest, isMonorepo);
|
|
1034
1025
|
const [firstVisible] = filterManifestForContext(manifest.templates, isMonorepo);
|
|
@@ -1048,7 +1039,7 @@ function printNonInteractiveTable(manifest, orgSpec, isMonorepo) {
|
|
|
1048
1039
|
}
|
|
1049
1040
|
function rejectMonorepoEntryInsideMonorepo(entry, isMonorepo) {
|
|
1050
1041
|
if (entry.monorepo && isMonorepo) {
|
|
1051
|
-
log
|
|
1042
|
+
log.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
|
|
1052
1043
|
cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
|
|
1053
1044
|
}
|
|
1054
1045
|
}
|
|
@@ -1086,7 +1077,7 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
1086
1077
|
}
|
|
1087
1078
|
if (!manifest) {
|
|
1088
1079
|
if (orgSpec.name !== void 0) cancelAndExit(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — \`@org:name\` requires one.`, 1);
|
|
1089
|
-
log
|
|
1080
|
+
log.info(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — running it as a normal package.`);
|
|
1090
1081
|
return { kind: "passthrough" };
|
|
1091
1082
|
}
|
|
1092
1083
|
if (orgSpec.name === void 0) {
|
|
@@ -1097,7 +1088,7 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
1097
1088
|
const picked = await pickOrgTemplate(manifest, { isMonorepo: args.isMonorepo });
|
|
1098
1089
|
if (picked === ORG_PICKER_CANCEL) cancelAndExit();
|
|
1099
1090
|
if (picked === ORG_PICKER_BUILTIN_ESCAPE) {
|
|
1100
|
-
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.`);
|
|
1101
1092
|
return { kind: "escape-hatch" };
|
|
1102
1093
|
}
|
|
1103
1094
|
rejectMonorepoEntryInsideMonorepo(picked.entry, args.isMonorepo);
|
|
@@ -1115,9 +1106,9 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
1115
1106
|
* Read the `create` config (`defaultTemplate` + validated `templates`) from
|
|
1116
1107
|
* a workspace's `vite.config.ts` in a single config evaluation.
|
|
1117
1108
|
*
|
|
1118
|
-
* By default, walks up from `startDir` via `
|
|
1119
|
-
* markers only — `pnpm-workspace.yaml
|
|
1120
|
-
*
|
|
1109
|
+
* By default, walks up from `startDir` via `findMonorepoRoot` (monorepo
|
|
1110
|
+
* markers only — `pnpm-workspace.yaml` or `workspaces` in `package.json`)
|
|
1111
|
+
* so monorepo invocations from any subdirectory still pick up
|
|
1121
1112
|
* the root config. Pass `walkUp: false` to read `startDir` directly when the
|
|
1122
1113
|
* caller already holds the exact workspace root.
|
|
1123
1114
|
*
|
|
@@ -1131,7 +1122,7 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
1131
1122
|
* instead of swallowed.
|
|
1132
1123
|
*/
|
|
1133
1124
|
async function getConfiguredCreate(startDir, options) {
|
|
1134
|
-
const projectRoot = options?.walkUp === false ? startDir :
|
|
1125
|
+
const projectRoot = options?.walkUp === false ? startDir : findMonorepoRoot(startDir) ?? startDir;
|
|
1135
1126
|
if (!hasViteConfig(projectRoot)) return { templates: [] };
|
|
1136
1127
|
let create;
|
|
1137
1128
|
try {
|
|
@@ -1161,8 +1152,7 @@ async function getConfiguredDefaultTemplate(startDir) {
|
|
|
1161
1152
|
return;
|
|
1162
1153
|
}
|
|
1163
1154
|
}
|
|
1164
|
-
|
|
1165
|
-
//#region ../../node_modules/.pnpm/validate-npm-package-name@8.0.0/node_modules/validate-npm-package-name/lib/builtin-modules.json
|
|
1155
|
+
// ../../node_modules/.pnpm/validate-npm-package-name@8.0.0/node_modules/validate-npm-package-name/lib/builtin-modules.json
|
|
1166
1156
|
var require_builtin_modules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1167
1157
|
module.exports = [
|
|
1168
1158
|
"_http_agent",
|
|
@@ -1239,8 +1229,7 @@ var require_builtin_modules = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
1239
1229
|
"node:test/reporters"
|
|
1240
1230
|
];
|
|
1241
1231
|
}));
|
|
1242
|
-
|
|
1243
|
-
//#region ../../node_modules/.pnpm/@nkzw+safe-word-list@3.1.0/node_modules/@nkzw/safe-word-list/index.js
|
|
1232
|
+
// ../../node_modules/.pnpm/@nkzw+safe-word-list@3.1.0/node_modules/@nkzw/safe-word-list/index.js
|
|
1244
1233
|
var import_lib = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1245
1234
|
const builtins = require_builtin_modules();
|
|
1246
1235
|
var scopedPackagePattern = /* @__PURE__ */ new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");
|
|
@@ -4031,8 +4020,7 @@ const random = (min, max) => Math.floor(min + Math.random() * (max - min + 1));
|
|
|
4031
4020
|
function getRandomWord() {
|
|
4032
4021
|
return words[random(0, words.length - 1)];
|
|
4033
4022
|
}
|
|
4034
|
-
|
|
4035
|
-
//#region src/create/random-name.ts
|
|
4023
|
+
// src/create/random-name.ts
|
|
4036
4024
|
const isTest = process.env.VP_CLI_TEST === "1";
|
|
4037
4025
|
function getRandomWords() {
|
|
4038
4026
|
const first = getRandomWord();
|
|
@@ -4047,8 +4035,7 @@ function getRandomProjectName(options = {}) {
|
|
|
4047
4035
|
const projectName = isTest && fallbackName ? fallbackName : getRandomWords().join("-");
|
|
4048
4036
|
return scope ? `${scope}/${projectName}` : projectName;
|
|
4049
4037
|
}
|
|
4050
|
-
|
|
4051
|
-
//#region src/create/utils.ts
|
|
4038
|
+
// src/create/utils.ts
|
|
4052
4039
|
var import_dist = require_dist();
|
|
4053
4040
|
/** Complete only the managed catalog references of a newly created workspace member.
|
|
4054
4041
|
* Running the full root migrator here would also change unrelated packages and overrides.
|
|
@@ -4268,8 +4255,7 @@ function deriveDefaultPackageName(cwd, scope, fallbackName) {
|
|
|
4268
4255
|
fallbackName
|
|
4269
4256
|
});
|
|
4270
4257
|
}
|
|
4271
|
-
|
|
4272
|
-
//#region src/create/prompts.ts
|
|
4258
|
+
// src/create/prompts.ts
|
|
4273
4259
|
async function promptPackageNameAndTargetDir(defaultPackageName, interactive) {
|
|
4274
4260
|
let packageName;
|
|
4275
4261
|
let targetDir;
|
|
@@ -4291,7 +4277,7 @@ async function promptPackageNameAndTargetDir(defaultPackageName, interactive) {
|
|
|
4291
4277
|
} else {
|
|
4292
4278
|
packageName = defaultPackageName;
|
|
4293
4279
|
targetDir = getProjectDirFromPackageName(packageName);
|
|
4294
|
-
log
|
|
4280
|
+
log.info(`Using default package name: ${accent(packageName)}`);
|
|
4295
4281
|
}
|
|
4296
4282
|
return {
|
|
4297
4283
|
packageName,
|
|
@@ -4311,7 +4297,7 @@ async function promptTargetDir(defaultTargetDir, interactive, options) {
|
|
|
4311
4297
|
targetDir = validateTargetDir(selected ?? defaultTargetDir, options?.cwd).directory;
|
|
4312
4298
|
} else {
|
|
4313
4299
|
targetDir = validateTargetDir(defaultTargetDir, options?.cwd).directory;
|
|
4314
|
-
log
|
|
4300
|
+
log.info(`Using default target directory: ${accent(targetDir)}`);
|
|
4315
4301
|
}
|
|
4316
4302
|
return targetDir;
|
|
4317
4303
|
}
|
|
@@ -4324,26 +4310,57 @@ function suggestAvailableTargetDir(defaultTargetDir, cwd) {
|
|
|
4324
4310
|
}
|
|
4325
4311
|
return suggestedTargetDir;
|
|
4326
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
|
+
}
|
|
4327
4341
|
async function checkProjectDirExists(projectDirFullPath, interactive) {
|
|
4328
|
-
|
|
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);
|
|
4329
4346
|
if (!interactive) {
|
|
4330
|
-
log
|
|
4331
|
-
cancelAndExit(
|
|
4347
|
+
log.info("Use --directory to specify a different location or remove the directory first");
|
|
4348
|
+
cancelAndExit(description, 1);
|
|
4332
4349
|
}
|
|
4333
4350
|
const overwrite = await select({
|
|
4334
|
-
message:
|
|
4351
|
+
message: `${description}. Please choose how to proceed:`,
|
|
4335
4352
|
options: [{
|
|
4336
4353
|
label: "Cancel operation",
|
|
4337
4354
|
value: "no"
|
|
4338
4355
|
}, {
|
|
4339
|
-
label:
|
|
4356
|
+
label: removeLabel,
|
|
4340
4357
|
value: "yes"
|
|
4341
4358
|
}]
|
|
4342
4359
|
});
|
|
4343
4360
|
if (isCancel(overwrite)) cancelAndExit();
|
|
4344
4361
|
switch (overwrite) {
|
|
4345
4362
|
case "yes":
|
|
4346
|
-
|
|
4363
|
+
clearTargetPath(targetPath, stats);
|
|
4347
4364
|
break;
|
|
4348
4365
|
case "no": cancelAndExit();
|
|
4349
4366
|
}
|
|
@@ -4352,18 +4369,37 @@ function isEmpty(path) {
|
|
|
4352
4369
|
const files = fs.readdirSync(path);
|
|
4353
4370
|
return files.length === 0 || files.length === 1 && files[0] === ".git";
|
|
4354
4371
|
}
|
|
4355
|
-
function
|
|
4356
|
-
|
|
4357
|
-
|
|
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) {
|
|
4358
4391
|
if (file === ".git") continue;
|
|
4359
|
-
|
|
4392
|
+
if (!getUnchangedTargetStats(strippedTargetPath, expectedStats, true)) return;
|
|
4393
|
+
fs.rmSync(path.resolve(strippedTargetPath, file), {
|
|
4360
4394
|
recursive: true,
|
|
4361
4395
|
force: true
|
|
4362
4396
|
});
|
|
4363
4397
|
}
|
|
4364
4398
|
}
|
|
4365
4399
|
function isTargetDirAvailable(projectDirFullPath) {
|
|
4366
|
-
|
|
4400
|
+
const targetPath = stripTrailingPathSeparators(projectDirFullPath);
|
|
4401
|
+
const stats = fs.lstatSync(targetPath, { throwIfNoEntry: false });
|
|
4402
|
+
return !stats || stats.isDirectory() && isEmpty(targetPath);
|
|
4367
4403
|
}
|
|
4368
4404
|
function validateTargetDir(input, cwd) {
|
|
4369
4405
|
const value = input?.trim() ?? "";
|
|
@@ -4390,8 +4426,7 @@ function validateTargetDir(input, cwd) {
|
|
|
4390
4426
|
};
|
|
4391
4427
|
return { directory: targetDir };
|
|
4392
4428
|
}
|
|
4393
|
-
|
|
4394
|
-
//#region src/create/register-template.ts
|
|
4429
|
+
// src/create/register-template.ts
|
|
4395
4430
|
/**
|
|
4396
4431
|
* Register a local template into `create.templates` in a monorepo's root
|
|
4397
4432
|
* `vite.config.ts`. Used after `vp create vite:generator` scaffolds a
|
|
@@ -4426,7 +4461,7 @@ async function registerLocalTemplate(workspaceRoot, entry, silent = false) {
|
|
|
4426
4461
|
});
|
|
4427
4462
|
const existingEntry = existing.templates.find((t) => t.name === entry.name);
|
|
4428
4463
|
if (existingEntry) {
|
|
4429
|
-
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.`);
|
|
4430
4465
|
return;
|
|
4431
4466
|
}
|
|
4432
4467
|
const nextCreate = {
|
|
@@ -4444,7 +4479,7 @@ async function registerLocalTemplate(workspaceRoot, entry, silent = false) {
|
|
|
4444
4479
|
function ensureViteConfig(workspaceRoot, silent) {
|
|
4445
4480
|
const configPath = path.join(workspaceRoot, "vite.config.ts");
|
|
4446
4481
|
fs.writeFileSync(configPath, `import { defineConfig } from '${VITE_PLUS_NAME}';\n\nexport default defineConfig({});\n`);
|
|
4447
|
-
if (!silent) log
|
|
4482
|
+
if (!silent) log.success(`✔ Created vite.config.ts in ${displayRelative(configPath)}`);
|
|
4448
4483
|
return configPath;
|
|
4449
4484
|
}
|
|
4450
4485
|
/**
|
|
@@ -4469,10 +4504,9 @@ function writeCreateBlock(configPath, create) {
|
|
|
4469
4504
|
fs.rmSync(tempPath, { force: true });
|
|
4470
4505
|
}
|
|
4471
4506
|
}
|
|
4472
|
-
|
|
4473
|
-
//#region src/create/templates/generator.ts
|
|
4507
|
+
// src/create/templates/generator.ts
|
|
4474
4508
|
async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
4475
|
-
if (!options?.silent) log
|
|
4509
|
+
if (!options?.silent) log.step("Creating generator scaffold...");
|
|
4476
4510
|
let description;
|
|
4477
4511
|
if (templateInfo.interactive) {
|
|
4478
4512
|
const defaultDescription = "Generate new components for our monorepo";
|
|
@@ -4495,26 +4529,25 @@ async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
|
4495
4529
|
if (description) pkg.description = description;
|
|
4496
4530
|
return pkg;
|
|
4497
4531
|
});
|
|
4498
|
-
if (!options?.silent) log
|
|
4532
|
+
if (!options?.silent) log.success("Generator scaffold created");
|
|
4499
4533
|
return {
|
|
4500
4534
|
exitCode: 0,
|
|
4501
4535
|
projectDir: templateInfo.targetDir
|
|
4502
4536
|
};
|
|
4503
4537
|
}
|
|
4504
|
-
|
|
4505
|
-
//#region src/create/templates/remote.ts
|
|
4538
|
+
// src/create/templates/remote.ts
|
|
4506
4539
|
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
4507
4540
|
const { gray, yellow } = import_picocolors.default;
|
|
4508
4541
|
async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
4509
4542
|
const silent = options?.silent ?? false;
|
|
4510
|
-
if (!silent) log
|
|
4543
|
+
if (!silent) log.step("Generating project…");
|
|
4511
4544
|
let isGitHubTemplate = templateInfo.command === "degit";
|
|
4512
4545
|
let result;
|
|
4513
4546
|
if (templateInfo.command === "node") {
|
|
4514
4547
|
const command = templateInfo.command;
|
|
4515
4548
|
const args = templateInfo.args;
|
|
4516
4549
|
const envs = templateInfo.envs;
|
|
4517
|
-
if (!silent) log
|
|
4550
|
+
if (!silent) log.info(`Running: ${gray(`${command} ${args.join(" ")}`)}`);
|
|
4518
4551
|
result = await runCommandAndDetectProjectDir({
|
|
4519
4552
|
command,
|
|
4520
4553
|
args,
|
|
@@ -4524,7 +4557,7 @@ async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4524
4557
|
} else {
|
|
4525
4558
|
if (!isGitHubTemplate) {
|
|
4526
4559
|
if (!await checkNpmPackageExists(templateInfo.command)) {
|
|
4527
|
-
if (!silent) log
|
|
4560
|
+
if (!silent) log.error(`Template "${templateInfo.command}" not found on npm. Run ${yellow("vp create --list")} to see available templates.`);
|
|
4528
4561
|
return { exitCode: 1 };
|
|
4529
4562
|
}
|
|
4530
4563
|
}
|
|
@@ -4532,13 +4565,13 @@ async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4532
4565
|
}
|
|
4533
4566
|
const exitCode = result.exitCode;
|
|
4534
4567
|
if (exitCode === 127) {
|
|
4535
|
-
log
|
|
4536
|
-
log
|
|
4568
|
+
log.info(yellow("\nTroubleshooting:"));
|
|
4569
|
+
log.info(` ${gray("•")} Command not found. Make sure Node.js is installed`);
|
|
4537
4570
|
} else if (isGitHubTemplate && exitCode !== 0) {
|
|
4538
|
-
log
|
|
4539
|
-
log
|
|
4540
|
-
log
|
|
4541
|
-
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)`);
|
|
4542
4575
|
}
|
|
4543
4576
|
return result;
|
|
4544
4577
|
}
|
|
@@ -4548,7 +4581,7 @@ async function runRemoteTemplateCommand(workspaceInfo, cwd, templateInfo, detect
|
|
|
4548
4581
|
const execArgs = [...templateInfo.args];
|
|
4549
4582
|
const envs = templateInfo.envs;
|
|
4550
4583
|
const { command, args } = formatDlxCommand(remotePackageName, execArgs, workspaceInfo);
|
|
4551
|
-
if (!silent) log
|
|
4584
|
+
if (!silent) log.info(`Running: ${gray(`${command} ${args.join(" ")}`)}`);
|
|
4552
4585
|
if (detectCreatedProjectDir) return await runCommandAndDetectProjectDir({
|
|
4553
4586
|
command,
|
|
4554
4587
|
args,
|
|
@@ -4588,8 +4621,7 @@ function autoFixRemoteTemplateCommand(templateInfo, workspaceInfo) {
|
|
|
4588
4621
|
else if (packageName === "@tanstack/cli") templateInfo.args.push("--no-git");
|
|
4589
4622
|
}
|
|
4590
4623
|
}
|
|
4591
|
-
|
|
4592
|
-
//#region src/create/templates/monorepo.ts
|
|
4624
|
+
// src/create/templates/monorepo.ts
|
|
4593
4625
|
const InitialMonorepoAppDir = "apps/website";
|
|
4594
4626
|
async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
4595
4627
|
assert(templateInfo.packageName, "packageName is required");
|
|
@@ -4597,8 +4629,8 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4597
4629
|
workspaceInfo.monorepoScope = getScopeFromPackageName(templateInfo.packageName);
|
|
4598
4630
|
const fullPath = path.join(workspaceInfo.rootDir, templateInfo.targetDir);
|
|
4599
4631
|
if (!options?.silent) {
|
|
4600
|
-
log
|
|
4601
|
-
log
|
|
4632
|
+
log.info(`Target directory: ${formatDisplayTargetDir(templateInfo.targetDir)}`);
|
|
4633
|
+
log.step("Creating Vite+ monorepo...");
|
|
4602
4634
|
}
|
|
4603
4635
|
copyDir(path.join(templatesDir, "monorepo"), fullPath);
|
|
4604
4636
|
renameFiles(fullPath);
|
|
@@ -4631,8 +4663,8 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4631
4663
|
const yarnrcPath = path.join(fullPath, ".yarnrc.yml");
|
|
4632
4664
|
if (fs.existsSync(yarnrcPath)) fs.unlinkSync(yarnrcPath);
|
|
4633
4665
|
}
|
|
4634
|
-
if (!options?.silent) log
|
|
4635
|
-
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...");
|
|
4636
4668
|
const appResult = await runRemoteTemplateCommand(workspaceInfo, fullPath, discoverTemplate("create-vite@latest", [
|
|
4637
4669
|
InitialMonorepoAppDir,
|
|
4638
4670
|
"--template",
|
|
@@ -4640,7 +4672,7 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4640
4672
|
"--no-interactive"
|
|
4641
4673
|
], workspaceInfo), false, options?.silent ?? false);
|
|
4642
4674
|
if (appResult.exitCode !== 0) {
|
|
4643
|
-
log
|
|
4675
|
+
log.error(`Failed to create default application: ${appResult.exitCode}`);
|
|
4644
4676
|
return appResult;
|
|
4645
4677
|
}
|
|
4646
4678
|
const appPackageName = workspaceInfo.monorepoScope ? `${workspaceInfo.monorepoScope}/website` : "website";
|
|
@@ -4648,11 +4680,11 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4648
4680
|
setPackageName(appProjectPath, appPackageName);
|
|
4649
4681
|
rewriteMonorepoProject(appProjectPath, workspaceInfo.packageManager, void 0, options?.silent ?? false);
|
|
4650
4682
|
dropAliasedRuntimeDevDeps(appProjectPath, workspaceInfo.packageManager);
|
|
4651
|
-
if (!options?.silent) log
|
|
4683
|
+
if (!options?.silent) log.step("Creating default library in packages/utils...");
|
|
4652
4684
|
const libraryDir = "packages/utils";
|
|
4653
4685
|
const libraryResult = await runRemoteTemplateCommand(workspaceInfo, fullPath, discoverTemplate(LibraryTemplateRepo, [libraryDir], workspaceInfo), false, options?.silent ?? false);
|
|
4654
4686
|
if (libraryResult.exitCode !== 0) {
|
|
4655
|
-
log
|
|
4687
|
+
log.error(`Failed to create default library, exit code: ${libraryResult.exitCode}`);
|
|
4656
4688
|
return libraryResult;
|
|
4657
4689
|
}
|
|
4658
4690
|
const libraryPackageName = workspaceInfo.monorepoScope ? `${workspaceInfo.monorepoScope}/utils` : "utils";
|
|
@@ -4739,8 +4771,7 @@ function dropAliasedRuntimeDevDeps(appProjectPath, packageManager) {
|
|
|
4739
4771
|
return changed ? pkg : void 0;
|
|
4740
4772
|
});
|
|
4741
4773
|
}
|
|
4742
|
-
|
|
4743
|
-
//#region src/create/templates/builtin.ts
|
|
4774
|
+
// src/create/templates/builtin.ts
|
|
4744
4775
|
async function executeBuiltinTemplate(workspaceInfo, templateInfo, options) {
|
|
4745
4776
|
assert(templateInfo.targetDir, "targetDir is required");
|
|
4746
4777
|
assert(templateInfo.packageName, "packageName is required");
|
|
@@ -4762,7 +4793,7 @@ async function executeBuiltinTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4762
4793
|
};
|
|
4763
4794
|
}
|
|
4764
4795
|
if (templateInfo.command.startsWith("vite:")) {
|
|
4765
|
-
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.`);
|
|
4766
4797
|
return { exitCode: 1 };
|
|
4767
4798
|
}
|
|
4768
4799
|
const result = await runRemoteTemplateCommand(workspaceInfo, workspaceInfo.rootDir, templateInfo, false, options?.silent ?? false);
|
|
@@ -4773,8 +4804,7 @@ async function executeBuiltinTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4773
4804
|
projectDir: templateInfo.targetDir
|
|
4774
4805
|
};
|
|
4775
4806
|
}
|
|
4776
|
-
|
|
4777
|
-
//#region src/create/templates/bundled.ts
|
|
4807
|
+
// src/create/templates/bundled.ts
|
|
4778
4808
|
/**
|
|
4779
4809
|
* Scaffold a bundled template by copying the pre-extracted directory at
|
|
4780
4810
|
* `localPath` into `workspaceInfo.rootDir/targetDir`.
|
|
@@ -4799,8 +4829,7 @@ async function executeBundledTemplate(workspaceInfo, templateInfo) {
|
|
|
4799
4829
|
projectDir: templateInfo.targetDir
|
|
4800
4830
|
};
|
|
4801
4831
|
}
|
|
4802
|
-
|
|
4803
|
-
//#region src/create/bin.ts
|
|
4832
|
+
// src/create/bin.ts
|
|
4804
4833
|
const listTemplatesMessage = renderCliDoc({
|
|
4805
4834
|
usage: "vp create --list",
|
|
4806
4835
|
summary: "List available builtin and popular project templates.",
|
|
@@ -4941,15 +4970,15 @@ function getCopilotSetupRoot(projectRoot, isExistingMonorepo) {
|
|
|
4941
4970
|
}
|
|
4942
4971
|
function showCreateSummary(options) {
|
|
4943
4972
|
const { description, gitInitialized, installSummary, nextCommand, packageManager, packageManagerVersion, projectDir } = options;
|
|
4944
|
-
log(`${styleText("magenta", "◇")} Scaffolded ${accent(projectDir)}${description ? ` with ${description}` : ""}`);
|
|
4945
|
-
log(`${styleText("gray", "•")} Node ${process.versions.node} ${packageManager} ${packageManagerVersion}`);
|
|
4946
|
-
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)}`);
|
|
4947
4976
|
if (gitInitialized) {
|
|
4948
4977
|
const git = !projectDir || projectDir === "." ? "git" : `git -C ${formatProjectDirArgument(projectDir)}`;
|
|
4949
4978
|
const gitCommand = `${git} add -A && ${git} commit -m "chore: initial commit"`;
|
|
4950
|
-
log(`${styleText("blue", "→")} Git (optional): ${accent(gitCommand)}`);
|
|
4979
|
+
log$1(`${styleText("blue", "→")} Git (optional): ${accent(gitCommand)}`);
|
|
4951
4980
|
}
|
|
4952
|
-
log(`${styleText("blue", "→")} Next: ${accent(nextCommand)}`);
|
|
4981
|
+
log$1(`${styleText("blue", "→")} Next: ${accent(nextCommand)}`);
|
|
4953
4982
|
}
|
|
4954
4983
|
async function main() {
|
|
4955
4984
|
const { templateName, options, templateArgs } = parseArgs();
|
|
@@ -4964,7 +4993,7 @@ async function main() {
|
|
|
4964
4993
|
if (options.directory) {
|
|
4965
4994
|
const formatted = formatTargetDir(options.directory);
|
|
4966
4995
|
if (formatted.error) {
|
|
4967
|
-
log
|
|
4996
|
+
log.error(formatted.error);
|
|
4968
4997
|
cancelAndExit("The --directory option is invalid", 1);
|
|
4969
4998
|
}
|
|
4970
4999
|
targetDir = formatted.directory;
|
|
@@ -4998,7 +5027,7 @@ async function main() {
|
|
|
4998
5027
|
if (!selectedTemplateName && configuredCreate.defaultTemplate) selectedTemplateName = configuredCreate.defaultTemplate;
|
|
4999
5028
|
} catch (error) {
|
|
5000
5029
|
if (error instanceof CreateConfigSchemaError) cancelAndExit(error.message, 1);
|
|
5001
|
-
log
|
|
5030
|
+
log.warn(`Could not read \`create\` config from the workspace vite.config (${error.message}); local templates are unavailable`);
|
|
5002
5031
|
}
|
|
5003
5032
|
else if (!selectedTemplateName) {
|
|
5004
5033
|
let defaultTemplate;
|
|
@@ -5061,15 +5090,15 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5061
5090
|
if (!isDirectScaffoldTemplate) compactOutput = false;
|
|
5062
5091
|
if (targetDir && !isDirectScaffoldTemplate) cancelAndExit("The --directory option is only available for builtin and bundled @org templates", 1);
|
|
5063
5092
|
if (selectedTemplateName === BuiltinTemplate.monorepo && isMonorepo) {
|
|
5064
|
-
log
|
|
5093
|
+
log.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
|
|
5065
5094
|
cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
|
|
5066
5095
|
}
|
|
5067
5096
|
if (selectedTemplateName === BuiltinTemplate.generator && !isMonorepo) {
|
|
5068
|
-
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`");
|
|
5069
5098
|
cancelAndExit("Cannot create a generator outside a monorepo", 1);
|
|
5070
5099
|
}
|
|
5071
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);
|
|
5072
|
-
if (isInSubdirectory && !compactOutput) log
|
|
5101
|
+
if (isInSubdirectory && !compactOutput) log.info(`Detected monorepo root at ${accent(workspaceInfoOptional.rootDir)}`);
|
|
5073
5102
|
if (isMonorepo && options.interactive && !targetDir) {
|
|
5074
5103
|
let parentDir;
|
|
5075
5104
|
if (workspaceInfoOptional.parentDirs.length > 0 || isInSubdirectory) {
|
|
@@ -5111,7 +5140,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5111
5140
|
selectedParentDir = parentDir;
|
|
5112
5141
|
}
|
|
5113
5142
|
if (isMonorepo && !options.interactive && !targetDir) {
|
|
5114
|
-
if (isInSubdirectory && !compactOutput) log
|
|
5143
|
+
if (isInSubdirectory && !compactOutput) log.info(`Use ${accent("--directory")} to specify a different target location.`);
|
|
5115
5144
|
selectedParentDir = inferParentDir(selectedTemplateName, workspaceInfoOptional, isLocalTemplate) ?? workspaceInfoOptional.parentDirs[0];
|
|
5116
5145
|
}
|
|
5117
5146
|
if (isGitHubUrl(selectedTemplateName)) {
|
|
@@ -5120,7 +5149,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5120
5149
|
const inferredTargetDir = inferGitHubRepoName(selectedTemplateName) ?? "template";
|
|
5121
5150
|
const remoteTargetBaseDir = selectedParentDir ? path.join(workspaceInfoOptional.rootDir, selectedParentDir) : workspaceInfoOptional.rootDir;
|
|
5122
5151
|
const defaultTargetDir = suggestAvailableTargetDir(inferredTargetDir, remoteTargetBaseDir);
|
|
5123
|
-
if (defaultTargetDir !== inferredTargetDir && options.interactive) log
|
|
5152
|
+
if (defaultTargetDir !== inferredTargetDir && options.interactive) log.info(` Target directory "${inferredTargetDir}" already exists. Suggested: ${accent(defaultTargetDir)}`);
|
|
5124
5153
|
remoteTargetDir = await promptTargetDir(defaultTargetDir, options.interactive, { cwd: remoteTargetBaseDir });
|
|
5125
5154
|
selectedTemplateArgs = [remoteTargetDir, ...selectedTemplateArgs];
|
|
5126
5155
|
}
|
|
@@ -5135,7 +5164,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5135
5164
|
if (enclosingPackage) cancelAndExit(`Cannot scaffold inside existing package "${enclosingPackage.name}" (${enclosingPackage.path}). Use --directory to specify a different location`, 1);
|
|
5136
5165
|
targetDir = cwdRelativeToRoot;
|
|
5137
5166
|
}
|
|
5138
|
-
log
|
|
5167
|
+
log.info(`Using package name: ${accent(packageName)}`);
|
|
5139
5168
|
} else if (selectedTemplateName === BuiltinTemplate.monorepo) {
|
|
5140
5169
|
const selected = await promptPackageNameAndTargetDir(getRandomProjectName({ fallbackName: "vite-plus-monorepo" }), options.interactive);
|
|
5141
5170
|
packageName = selected.packageName;
|
|
@@ -5394,7 +5423,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5394
5423
|
template: generatorTemplatePath
|
|
5395
5424
|
}, compactOutput);
|
|
5396
5425
|
} catch (error) {
|
|
5397
|
-
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}' }`);
|
|
5398
5427
|
}
|
|
5399
5428
|
resumeCreateProgress();
|
|
5400
5429
|
}
|
|
@@ -5451,7 +5480,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5451
5480
|
resumeCreateProgress();
|
|
5452
5481
|
};
|
|
5453
5482
|
if (isMonorepo) {
|
|
5454
|
-
if (!compactOutput) log
|
|
5483
|
+
if (!compactOutput) log.step("Monorepo integration...");
|
|
5455
5484
|
if (workspaceInfo.packages.length > 0) {
|
|
5456
5485
|
if (options.interactive) {
|
|
5457
5486
|
pauseCreateProgress();
|
|
@@ -5487,7 +5516,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5487
5516
|
if (shouldMigrateLintFmtTools) await installAndMigrate(workspaceInfo.rootDir);
|
|
5488
5517
|
updateCreateProgress("Integrating into monorepo");
|
|
5489
5518
|
const skipStagedMigration = shouldSkipStagedMigrationForHooks(fullPath, shouldSetupHooks, workspaceInfo.packageManager);
|
|
5490
|
-
rewriteMonorepoProject(fullPath, workspaceInfo.packageManager, skipStagedMigration, compactOutput, void 0, workspaceInfo.packageManager === PackageManager.pnpm ? createCatalogDependencyResolver(workspaceInfo.rootDir, workspaceInfo.packageManager) : void 0
|
|
5519
|
+
rewriteMonorepoProject(fullPath, workspaceInfo.packageManager, skipStagedMigration, compactOutput, void 0, workspaceInfo.packageManager === PackageManager.pnpm ? createCatalogDependencyResolver(workspaceInfo.rootDir, workspaceInfo.packageManager) : void 0, {
|
|
5520
|
+
rootDir: workspaceInfo.rootDir,
|
|
5521
|
+
packages: discoverWorkspacePackages([...workspaceInfo.workspacePatterns, projectDir], workspaceInfo.rootDir)
|
|
5522
|
+
});
|
|
5491
5523
|
if (workspaceInfo.packageManager === PackageManager.pnpm) ensurePnpmCreateCatalogEntries(workspaceInfo.rootDir, fullPath);
|
|
5492
5524
|
for (const framework of detectFramework(fullPath)) if (!hasFrameworkShim(fullPath, framework)) addFrameworkShim(fullPath, framework);
|
|
5493
5525
|
updateCreateProgress("Installing dependencies");
|
|
@@ -5538,12 +5570,11 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5538
5570
|
}
|
|
5539
5571
|
async function showAvailableTemplates() {
|
|
5540
5572
|
printHeader();
|
|
5541
|
-
log(listTemplatesMessage);
|
|
5573
|
+
log$1(listTemplatesMessage);
|
|
5542
5574
|
}
|
|
5543
5575
|
main().catch((err) => {
|
|
5544
|
-
log
|
|
5576
|
+
log.error(err.message);
|
|
5545
5577
|
console.error(err);
|
|
5546
5578
|
cancelAndExit(`Failed to generate code: ${err.message}`, 1);
|
|
5547
5579
|
});
|
|
5548
|
-
//#endregion
|
|
5549
5580
|
export {};
|