vite-plus 0.1.21 → 0.1.23
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 +1 -0
- package/binding/index.cjs +120 -52
- package/binding/index.d.cts +3232 -2
- package/dist/agent-aSGY0osq.js +2461 -0
- package/dist/bin.js +9 -14
- package/dist/cli-truncate-CWsmbK3p.js +867 -0
- package/dist/{compat-DdC7fHjB.js → compat-DXZgnEyq.js} +1 -1
- package/dist/config/bin.js +18 -5
- package/dist/constants-DCBWlNrn.js +33 -0
- package/dist/create/bin.js +215 -77
- package/dist/{define-config-cWg3Z2bC.d.ts → define-config-COdn-tsn.d.ts} +7 -5
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.d.ts +1 -1
- package/dist/define-config.js +1 -1
- package/dist/dist-Bapm49IR.js +3 -0
- package/dist/{dist-DjG9AYbK.js → dist-BgQuvbtq.js} +136 -110
- package/dist/fmt.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/is-fullwidth-code-point-BUNlIICg.js +8 -0
- package/dist/lint.d.ts +1 -1
- package/dist/{log-update-CLxR0iRf.js → log-update-lyIiuflf.js} +111 -24
- package/dist/{main-A6UrSTYb.js → main-DpJl3LoU.js} +1 -28
- package/dist/migration/bin.js +71 -30
- package/dist/oxlint-plugin-config-B89iKTKN.js +37 -0
- package/dist/oxlint-plugin.d.ts +6 -0
- package/dist/oxlint-plugin.js +91 -0
- package/dist/pack-bin.js +1 -1
- package/dist/pack.d.ts +1 -1
- package/dist/{package-CrKanQYM.js → package-PmBUZ-ve.js} +2 -1
- package/dist/staged/bin.js +10 -10
- package/dist/strip-ansi-C3wrWz9t.js +853 -0
- package/dist/{agent-D2ocSU01.js → tsconfig-DlUVXT3J.js} +666 -2090
- package/dist/version.js +5 -5
- package/dist/versions.js +6 -6
- package/dist/{workspace-QXeJWs3P.js → workspace-DElv730L.js} +15 -15
- package/dist/wrap-ansi-CeQuiQ31.js +2 -0
- package/dist/{wrap-ansi-Dy0LjO7Q.js → wrap-ansi-k7Dn4VtV.js} +1 -1
- package/docs/config/run.md +39 -4
- package/docs/guide/cache.md +10 -1
- package/docs/guide/create.md +3 -1
- package/docs/guide/env.md +26 -1
- package/docs/guide/ide-integration.md +2 -2
- package/docs/guide/install.md +6 -0
- package/docs/guide/run.md +2 -0
- package/docs/guide/troubleshooting.md +5 -2
- package/docs/package.json +3 -1
- package/docs/pnpm-lock.yaml +798 -62
- package/package.json +27 -19
- package/templates/monorepo/_gitignore +1 -0
- package/dist/cli-truncate-DJcN4dJ8.js +0 -138
- package/dist/dist-D2_BiE1V.js +0 -3
- package/dist/slice-ansi-CwJYd1aw.js +0 -113
- package/dist/strip-ansi-D86nYqKl.js +0 -198
- package/dist/tsconfig-lBAWm4sf.js +0 -517
- package/dist/wrap-ansi-DbY7Idw_.js +0 -2
- /package/dist/{chunk-q7NCDQ7-.js → chunk-DnnnRqeS.js} +0 -0
- /package/dist/{define-config-GqLoRwH9.cjs → define-config-BR1Y88zz.cjs} +0 -0
- /package/dist/{define-config-B62DkkqH.js → define-config-BRC7qPNE.js} +0 -0
- /package/dist/{help-BtkjXtRM.js → help-YP84FSEz.js} +0 -0
- /package/dist/{lib-BamM40b7.js → lib-L3DWSRQp.js} +0 -0
- /package/dist/{pack-BcBvbQgt.d.ts → pack-Ciiho0Tq.d.ts} +0 -0
- /package/dist/{report-DbrfjWiP.js → report-DgSBQUdz.js} +0 -0
- /package/dist/{resolve-vite-config-C1KX9CZU.js → resolve-vite-config-TTvhycU1.js} +0 -0
- /package/dist/{terminal-CxTMfsxZ.js → terminal-uTv0ZaMr.js} +0 -0
package/dist/create/bin.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { r as __toESM, t as __commonJSMin } from "../chunk-
|
|
2
|
-
import {
|
|
3
|
-
import { a as printHeader, i as muted, o as success, r as log, t as accent } from "../terminal-
|
|
4
|
-
import { i as resolveViteConfig, n as hasViteConfig, t as findWorkspaceRoot } from "../resolve-vite-config-
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import { c as
|
|
8
|
-
import { a as detectExistingEditors, c as writeEditorConfigs, n as updatePackageJsonWithDeps, r as updateWorkspaceConfig, s as selectEditors, t as detectWorkspace$1 } from "../workspace-
|
|
9
|
-
import { t as renderCliDoc } from "../help-
|
|
1
|
+
import { r as __toESM, t as __commonJSMin } from "../chunk-DnnnRqeS.js";
|
|
2
|
+
import { A as q, C as log, D as spinner, E as select, M as runCommandSilently, N as require_cross_spawn, O as text, S as intro, _ as DependencyType, b as cancel, c as defaultInteractive, d as promptGitHooks, f as promptGitInit, h as selectPackageManager, j as runCommand$1, k as require_picocolors, l as downloadPackageManager$1, m as runViteInstall, p as runViteFmt, v as PackageManager, w as multiselect, x as confirm } from "../tsconfig-DlUVXT3J.js";
|
|
3
|
+
import { a as printHeader, i as muted, o as success, r as log$1, t as accent } from "../terminal-uTv0ZaMr.js";
|
|
4
|
+
import { i as resolveViteConfig, n as hasViteConfig, t as findWorkspaceRoot } from "../resolve-vite-config-TTvhycU1.js";
|
|
5
|
+
import { t as lib_default } from "../lib-L3DWSRQp.js";
|
|
6
|
+
import { c as editJsonFile, o as fetchNpmResource, s as getNpmRegistry, t as checkNpmPackageExists, u as readJsonFile } from "../package-PmBUZ-ve.js";
|
|
7
|
+
import { A as promptEslintMigration, F as setPackageManager, H as displayRelative, M as rewriteMonorepo, N as rewriteMonorepoProject, P as rewriteStandaloneProject, S as injectCreateDefaultTemplate, U as templatesDir, a as selectAgentTargets, b as hasFrameworkShim, c as writeCopilotSetupWorkflow, h as detectFramework, j as promptPrettierMigration, l as addFrameworkShim, m as detectEslintProject, r as detectExistingAgentTargetPaths, s as writeAgentInstructions, t as COPILOT_AGENT_ID, v as detectPrettierProject, w as installGitHooks } from "../agent-aSGY0osq.js";
|
|
8
|
+
import { a as detectExistingEditors, c as writeEditorConfigs, n as updatePackageJsonWithDeps, r as updateWorkspaceConfig, s as selectEditors, t as detectWorkspace$1 } from "../workspace-DElv730L.js";
|
|
9
|
+
import { t as renderCliDoc } from "../help-YP84FSEz.js";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { runCommand, vitePlusHeader } from "../../binding/index.js";
|
|
12
12
|
import fs from "node:fs";
|
|
@@ -15,8 +15,36 @@ import os from "node:os";
|
|
|
15
15
|
import fsPromises from "node:fs/promises";
|
|
16
16
|
import { createHash, randomUUID } from "node:crypto";
|
|
17
17
|
import assert from "node:assert";
|
|
18
|
-
//#region src/
|
|
18
|
+
//#region src/utils/git.ts
|
|
19
19
|
var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
|
|
20
|
+
async function initGitRepository(cwd) {
|
|
21
|
+
return (await runCommandSilently({
|
|
22
|
+
command: "git",
|
|
23
|
+
args: ["init"],
|
|
24
|
+
cwd,
|
|
25
|
+
envs: process.env
|
|
26
|
+
})).exitCode === 0;
|
|
27
|
+
}
|
|
28
|
+
async function createInitialCommit(cwd) {
|
|
29
|
+
await runCommandSilently({
|
|
30
|
+
command: "git",
|
|
31
|
+
args: ["add", "-A"],
|
|
32
|
+
cwd,
|
|
33
|
+
envs: process.env
|
|
34
|
+
});
|
|
35
|
+
return (await runCommandSilently({
|
|
36
|
+
command: "git",
|
|
37
|
+
args: [
|
|
38
|
+
"commit",
|
|
39
|
+
"-m",
|
|
40
|
+
"Initial commit from Vite+"
|
|
41
|
+
],
|
|
42
|
+
cwd,
|
|
43
|
+
envs: process.env
|
|
44
|
+
})).exitCode === 0;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/create/command.ts
|
|
20
48
|
async function runCommandAndDetectProjectDir(options, parentDir) {
|
|
21
49
|
const cwd = parentDir ? path.join(options.cwd, parentDir) : options.cwd;
|
|
22
50
|
const existingDirs = /* @__PURE__ */ new Set();
|
|
@@ -32,10 +60,14 @@ async function runCommandAndDetectProjectDir(options, parentDir) {
|
|
|
32
60
|
cwd
|
|
33
61
|
});
|
|
34
62
|
let projectDir;
|
|
63
|
+
let currentDirPackageJsonWritten = false;
|
|
35
64
|
let minDepth = Infinity;
|
|
36
65
|
for (const [filePath, pathAccess] of Object.entries(result.pathAccesses)) if (pathAccess.write && filePath.endsWith("package.json") && !filePath.includes("node_modules")) {
|
|
37
66
|
const dir = path.dirname(filePath);
|
|
38
|
-
if (dir === "." || dir === "")
|
|
67
|
+
if (dir === "." || dir === "") {
|
|
68
|
+
currentDirPackageJsonWritten = true;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
39
71
|
if (existingDirs.has(dir)) continue;
|
|
40
72
|
const depth = dir.split(path.sep).length;
|
|
41
73
|
if (depth < minDepth) {
|
|
@@ -43,6 +75,7 @@ async function runCommandAndDetectProjectDir(options, parentDir) {
|
|
|
43
75
|
projectDir = dir;
|
|
44
76
|
}
|
|
45
77
|
}
|
|
78
|
+
if (!projectDir && currentDirPackageJsonWritten) projectDir = ".";
|
|
46
79
|
if (parentDir && projectDir) projectDir = path.join(parentDir, projectDir);
|
|
47
80
|
return {
|
|
48
81
|
exitCode: result.exitCode,
|
|
@@ -3807,6 +3840,18 @@ function setPackageName(projectDir, packageName) {
|
|
|
3807
3840
|
return pkg;
|
|
3808
3841
|
});
|
|
3809
3842
|
}
|
|
3843
|
+
const RENAME_FILES = {
|
|
3844
|
+
_gitignore: ".gitignore",
|
|
3845
|
+
_npmrc: ".npmrc",
|
|
3846
|
+
"_yarnrc.yml": ".yarnrc.yml"
|
|
3847
|
+
};
|
|
3848
|
+
/** Rename underscore-prefixed scaffold files to their dotfile names in `projectDir`. */
|
|
3849
|
+
function renameFiles(projectDir) {
|
|
3850
|
+
for (const [from, to] of Object.entries(RENAME_FILES)) {
|
|
3851
|
+
const fromPath = path.join(projectDir, from);
|
|
3852
|
+
if (fs.existsSync(fromPath)) fs.renameSync(fromPath, path.join(projectDir, to));
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3810
3855
|
/**
|
|
3811
3856
|
* Make sure the scaffolded project's `.gitignore` excludes `node_modules`.
|
|
3812
3857
|
*
|
|
@@ -3825,6 +3870,35 @@ function ensureGitignoreNodeModules(projectDir) {
|
|
|
3825
3870
|
const prefix = content === "" || content.endsWith("\n") ? "" : "\n";
|
|
3826
3871
|
fs.appendFileSync(gitignorePath, `${prefix}node_modules\n`);
|
|
3827
3872
|
}
|
|
3873
|
+
const VSCODE_SETTINGS_PATH = ".vscode/settings.json";
|
|
3874
|
+
const VSCODE_CONFIG_UNIGNORE_BLOCK = [
|
|
3875
|
+
"!.vscode/",
|
|
3876
|
+
`!${VSCODE_SETTINGS_PATH}`,
|
|
3877
|
+
`!.vscode/extensions.json`
|
|
3878
|
+
];
|
|
3879
|
+
/**
|
|
3880
|
+
* Make generated VS Code workspace config trackable when `vp create` writes VS Code config.
|
|
3881
|
+
*/
|
|
3882
|
+
function ensureGitignoreVsCodeEditorConfigs(projectDir) {
|
|
3883
|
+
if (!fs.existsSync(path.join(projectDir, VSCODE_SETTINGS_PATH))) return;
|
|
3884
|
+
const gitignorePath = path.join(projectDir, ".gitignore");
|
|
3885
|
+
let content;
|
|
3886
|
+
try {
|
|
3887
|
+
content = fs.readFileSync(gitignorePath, "utf-8");
|
|
3888
|
+
} catch {
|
|
3889
|
+
return;
|
|
3890
|
+
}
|
|
3891
|
+
appendGitignoreVsCodeEditorConfigsBlock(gitignorePath, content);
|
|
3892
|
+
}
|
|
3893
|
+
function appendGitignoreVsCodeEditorConfigsBlock(gitignorePath, content) {
|
|
3894
|
+
if (content.trimEnd().endsWith(VSCODE_CONFIG_UNIGNORE_BLOCK.join("\n"))) return;
|
|
3895
|
+
appendGitignoreLines(gitignorePath, content, VSCODE_CONFIG_UNIGNORE_BLOCK);
|
|
3896
|
+
}
|
|
3897
|
+
function appendGitignoreLines(gitignorePath, content, lines) {
|
|
3898
|
+
if (lines.length === 0) return;
|
|
3899
|
+
const prefix = content === "" || content.endsWith("\n") ? "" : "\n";
|
|
3900
|
+
fs.appendFileSync(gitignorePath, `${prefix}${lines.join("\n")}\n`);
|
|
3901
|
+
}
|
|
3828
3902
|
function formatDisplayTargetDir(targetDir) {
|
|
3829
3903
|
const normalized = targetDir.split(path.sep).join("/");
|
|
3830
3904
|
if (normalized === "" || normalized === ".") return "./";
|
|
@@ -3862,7 +3936,7 @@ async function promptPackageNameAndTargetDir(defaultPackageName, interactive) {
|
|
|
3862
3936
|
} else {
|
|
3863
3937
|
packageName = defaultPackageName;
|
|
3864
3938
|
targetDir = getProjectDirFromPackageName(packageName);
|
|
3865
|
-
log
|
|
3939
|
+
log.info(`Using default package name: ${accent(packageName)}`);
|
|
3866
3940
|
}
|
|
3867
3941
|
return {
|
|
3868
3942
|
packageName,
|
|
@@ -3882,7 +3956,7 @@ async function promptTargetDir(defaultTargetDir, interactive, options) {
|
|
|
3882
3956
|
targetDir = validateTargetDir(selected ?? defaultTargetDir, options?.cwd).directory;
|
|
3883
3957
|
} else {
|
|
3884
3958
|
targetDir = validateTargetDir(defaultTargetDir, options?.cwd).directory;
|
|
3885
|
-
log
|
|
3959
|
+
log.info(`Using default target directory: ${accent(targetDir)}`);
|
|
3886
3960
|
}
|
|
3887
3961
|
return targetDir;
|
|
3888
3962
|
}
|
|
@@ -3898,7 +3972,7 @@ function suggestAvailableTargetDir(defaultTargetDir, cwd) {
|
|
|
3898
3972
|
async function checkProjectDirExists(projectDirFullPath, interactive) {
|
|
3899
3973
|
if (isTargetDirAvailable(projectDirFullPath)) return;
|
|
3900
3974
|
if (!interactive) {
|
|
3901
|
-
log
|
|
3975
|
+
log.info("Use --directory to specify a different location or remove the directory first");
|
|
3902
3976
|
cancelAndExit(`Target directory "${projectDirFullPath}" is not empty`, 1);
|
|
3903
3977
|
}
|
|
3904
3978
|
const overwrite = await select({
|
|
@@ -3986,7 +4060,7 @@ function printNonInteractiveTable(manifest, orgSpec, isMonorepo) {
|
|
|
3986
4060
|
}
|
|
3987
4061
|
function rejectMonorepoEntryInsideMonorepo(entry, isMonorepo) {
|
|
3988
4062
|
if (entry.monorepo && isMonorepo) {
|
|
3989
|
-
log
|
|
4063
|
+
log.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
|
|
3990
4064
|
cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
|
|
3991
4065
|
}
|
|
3992
4066
|
}
|
|
@@ -4023,7 +4097,7 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
4023
4097
|
}
|
|
4024
4098
|
if (!manifest) {
|
|
4025
4099
|
if (orgSpec.name !== void 0) cancelAndExit(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — \`@org:name\` requires one.`, 1);
|
|
4026
|
-
log
|
|
4100
|
+
log.info(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — running it as a normal package.`);
|
|
4027
4101
|
return { kind: "passthrough" };
|
|
4028
4102
|
}
|
|
4029
4103
|
if (orgSpec.name === void 0) {
|
|
@@ -4034,7 +4108,7 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
4034
4108
|
const picked = await pickOrgTemplate(manifest, { isMonorepo: args.isMonorepo });
|
|
4035
4109
|
if (picked === ORG_PICKER_CANCEL) cancelAndExit();
|
|
4036
4110
|
if (picked === ORG_PICKER_BUILTIN_ESCAPE) {
|
|
4037
|
-
if (args.isMonorepo && manifest.templates.every((t) => t.monorepo)) log
|
|
4111
|
+
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.`);
|
|
4038
4112
|
return { kind: "escape-hatch" };
|
|
4039
4113
|
}
|
|
4040
4114
|
rejectMonorepoEntryInsideMonorepo(picked.entry, args.isMonorepo);
|
|
@@ -4071,7 +4145,7 @@ async function getConfiguredDefaultTemplate(startDir) {
|
|
|
4071
4145
|
//#endregion
|
|
4072
4146
|
//#region src/create/templates/generator.ts
|
|
4073
4147
|
async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
4074
|
-
if (!options?.silent) log
|
|
4148
|
+
if (!options?.silent) log.step("Creating generator scaffold...");
|
|
4075
4149
|
let description;
|
|
4076
4150
|
if (templateInfo.interactive) {
|
|
4077
4151
|
const defaultDescription = "Generate new components for our monorepo";
|
|
@@ -4090,7 +4164,7 @@ async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
|
4090
4164
|
if (description) pkg.description = description;
|
|
4091
4165
|
return pkg;
|
|
4092
4166
|
});
|
|
4093
|
-
if (!options?.silent) log
|
|
4167
|
+
if (!options?.silent) log.success("Generator scaffold created");
|
|
4094
4168
|
return {
|
|
4095
4169
|
exitCode: 0,
|
|
4096
4170
|
projectDir: templateInfo.targetDir
|
|
@@ -4102,14 +4176,14 @@ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
|
4102
4176
|
const { gray, yellow } = import_picocolors.default;
|
|
4103
4177
|
async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
4104
4178
|
const silent = options?.silent ?? false;
|
|
4105
|
-
if (!silent) log
|
|
4179
|
+
if (!silent) log.step("Generating project…");
|
|
4106
4180
|
let isGitHubTemplate = templateInfo.command === "degit";
|
|
4107
4181
|
let result;
|
|
4108
4182
|
if (templateInfo.command === "node") {
|
|
4109
4183
|
const command = templateInfo.command;
|
|
4110
4184
|
const args = templateInfo.args;
|
|
4111
4185
|
const envs = templateInfo.envs;
|
|
4112
|
-
if (!silent) log
|
|
4186
|
+
if (!silent) log.info(`Running: ${gray(`${command} ${args.join(" ")}`)}`);
|
|
4113
4187
|
result = await runCommandAndDetectProjectDir({
|
|
4114
4188
|
command,
|
|
4115
4189
|
args,
|
|
@@ -4119,7 +4193,7 @@ async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4119
4193
|
} else {
|
|
4120
4194
|
if (!isGitHubTemplate) {
|
|
4121
4195
|
if (!await checkNpmPackageExists(templateInfo.command)) {
|
|
4122
|
-
if (!silent) log
|
|
4196
|
+
if (!silent) log.error(`Template "${templateInfo.command}" not found on npm. Run ${yellow("vp create --list")} to see available templates.`);
|
|
4123
4197
|
return { exitCode: 1 };
|
|
4124
4198
|
}
|
|
4125
4199
|
}
|
|
@@ -4127,13 +4201,13 @@ async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4127
4201
|
}
|
|
4128
4202
|
const exitCode = result.exitCode;
|
|
4129
4203
|
if (exitCode === 127) {
|
|
4130
|
-
log
|
|
4131
|
-
log
|
|
4204
|
+
log.info(yellow("\nTroubleshooting:"));
|
|
4205
|
+
log.info(` ${gray("•")} Command not found. Make sure Node.js is installed`);
|
|
4132
4206
|
} else if (isGitHubTemplate && exitCode !== 0) {
|
|
4133
|
-
log
|
|
4134
|
-
log
|
|
4135
|
-
log
|
|
4136
|
-
log
|
|
4207
|
+
log.info(yellow("\nTroubleshooting:"));
|
|
4208
|
+
log.info(` ${gray("•")} Make sure the GitHub repository exists`);
|
|
4209
|
+
log.info(` ${gray("•")} Check your internet connection`);
|
|
4210
|
+
log.info(` ${gray("•")} Repository might be private (requires authentication)`);
|
|
4137
4211
|
}
|
|
4138
4212
|
return result;
|
|
4139
4213
|
}
|
|
@@ -4143,7 +4217,7 @@ async function runRemoteTemplateCommand(workspaceInfo, cwd, templateInfo, detect
|
|
|
4143
4217
|
const execArgs = [...templateInfo.args];
|
|
4144
4218
|
const envs = templateInfo.envs;
|
|
4145
4219
|
const { command, args } = formatDlxCommand(remotePackageName, execArgs, workspaceInfo);
|
|
4146
|
-
if (!silent) log
|
|
4220
|
+
if (!silent) log.info(`Running: ${gray(`${command} ${args.join(" ")}`)}`);
|
|
4147
4221
|
if (detectCreatedProjectDir) return await runCommandAndDetectProjectDir({
|
|
4148
4222
|
command,
|
|
4149
4223
|
args,
|
|
@@ -4204,7 +4278,7 @@ async function executeBuiltinTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4204
4278
|
};
|
|
4205
4279
|
}
|
|
4206
4280
|
if (templateInfo.command.startsWith("vite:")) {
|
|
4207
|
-
if (!options?.silent) log
|
|
4281
|
+
if (!options?.silent) log.error(`Unknown builtin template "${templateInfo.command}". Run ${import_picocolors.default.yellow("vp create --list")} to see available templates.`);
|
|
4208
4282
|
return { exitCode: 1 };
|
|
4209
4283
|
}
|
|
4210
4284
|
const result = await runRemoteTemplateCommand(workspaceInfo, workspaceInfo.rootDir, templateInfo, false, options?.silent ?? false);
|
|
@@ -4232,6 +4306,7 @@ async function executeBundledTemplate(workspaceInfo, templateInfo) {
|
|
|
4232
4306
|
if (error.code === "ENOENT") throw new Error(`bundled template directory not found: ${templateInfo.localPath}`, { cause: error });
|
|
4233
4307
|
throw error;
|
|
4234
4308
|
}
|
|
4309
|
+
renameFiles(destDir);
|
|
4235
4310
|
try {
|
|
4236
4311
|
setPackageName(destDir, templateInfo.packageName);
|
|
4237
4312
|
} catch {}
|
|
@@ -4249,8 +4324,8 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4249
4324
|
workspaceInfo.monorepoScope = getScopeFromPackageName(templateInfo.packageName);
|
|
4250
4325
|
const fullPath = path.join(workspaceInfo.rootDir, templateInfo.targetDir);
|
|
4251
4326
|
if (!options?.silent) {
|
|
4252
|
-
log
|
|
4253
|
-
log
|
|
4327
|
+
log.info(`Target directory: ${formatDisplayTargetDir(templateInfo.targetDir)}`);
|
|
4328
|
+
log.step("Creating Vite+ monorepo...");
|
|
4254
4329
|
}
|
|
4255
4330
|
copyDir(path.join(templatesDir, "monorepo"), fullPath);
|
|
4256
4331
|
renameFiles(fullPath);
|
|
@@ -4283,8 +4358,8 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4283
4358
|
const yarnrcPath = path.join(fullPath, ".yarnrc.yml");
|
|
4284
4359
|
if (fs.existsSync(yarnrcPath)) fs.unlinkSync(yarnrcPath);
|
|
4285
4360
|
}
|
|
4286
|
-
if (!options?.silent) log
|
|
4287
|
-
if (!options?.silent) log
|
|
4361
|
+
if (!options?.silent) log.success("Monorepo template created");
|
|
4362
|
+
if (!options?.silent) log.step("Creating default application in apps/website...");
|
|
4288
4363
|
const appResult = await runRemoteTemplateCommand(workspaceInfo, fullPath, discoverTemplate("create-vite@latest", [
|
|
4289
4364
|
InitialMonorepoAppDir,
|
|
4290
4365
|
"--template",
|
|
@@ -4292,18 +4367,26 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4292
4367
|
"--no-interactive"
|
|
4293
4368
|
], workspaceInfo), false, options?.silent ?? false);
|
|
4294
4369
|
if (appResult.exitCode !== 0) {
|
|
4295
|
-
log
|
|
4370
|
+
log.error(`Failed to create default application: ${appResult.exitCode}`);
|
|
4296
4371
|
return appResult;
|
|
4297
4372
|
}
|
|
4298
4373
|
const appPackageName = workspaceInfo.monorepoScope ? `${workspaceInfo.monorepoScope}/website` : "website";
|
|
4299
4374
|
const appProjectPath = path.join(fullPath, InitialMonorepoAppDir);
|
|
4300
4375
|
setPackageName(appProjectPath, appPackageName);
|
|
4301
4376
|
rewriteMonorepoProject(appProjectPath, workspaceInfo.packageManager, void 0, options?.silent ?? false);
|
|
4302
|
-
|
|
4377
|
+
editJsonFile(path.join(appProjectPath, "package.json"), (pkg) => {
|
|
4378
|
+
let changed = false;
|
|
4379
|
+
for (const name of ["vite", "vitest"]) if (pkg.devDependencies?.[name]) {
|
|
4380
|
+
delete pkg.devDependencies[name];
|
|
4381
|
+
changed = true;
|
|
4382
|
+
}
|
|
4383
|
+
return changed ? pkg : void 0;
|
|
4384
|
+
});
|
|
4385
|
+
if (!options?.silent) log.step("Creating default library in packages/utils...");
|
|
4303
4386
|
const libraryDir = "packages/utils";
|
|
4304
4387
|
const libraryResult = await runRemoteTemplateCommand(workspaceInfo, fullPath, discoverTemplate(LibraryTemplateRepo, [libraryDir], workspaceInfo), false, options?.silent ?? false);
|
|
4305
4388
|
if (libraryResult.exitCode !== 0) {
|
|
4306
|
-
log
|
|
4389
|
+
log.error(`Failed to create default library, exit code: ${libraryResult.exitCode}`);
|
|
4307
4390
|
return libraryResult;
|
|
4308
4391
|
}
|
|
4309
4392
|
const libraryPackageName = workspaceInfo.monorepoScope ? `${workspaceInfo.monorepoScope}/utils` : "utils";
|
|
@@ -4315,17 +4398,6 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4315
4398
|
projectDir: templateInfo.targetDir
|
|
4316
4399
|
};
|
|
4317
4400
|
}
|
|
4318
|
-
const RENAME_FILES = {
|
|
4319
|
-
_gitignore: ".gitignore",
|
|
4320
|
-
_npmrc: ".npmrc",
|
|
4321
|
-
"_yarnrc.yml": ".yarnrc.yml"
|
|
4322
|
-
};
|
|
4323
|
-
function renameFiles(projectDir) {
|
|
4324
|
-
for (const [from, to] of Object.entries(RENAME_FILES)) {
|
|
4325
|
-
const fromPath = path.join(projectDir, from);
|
|
4326
|
-
if (fs.existsSync(fromPath)) fs.renameSync(fromPath, path.join(projectDir, to));
|
|
4327
|
-
}
|
|
4328
|
-
}
|
|
4329
4401
|
function getScopeFromPackageName(packageName) {
|
|
4330
4402
|
if (packageName.startsWith("@")) return packageName.split("/")[0];
|
|
4331
4403
|
return "";
|
|
@@ -4368,6 +4440,14 @@ const helpMessage = renderCliDoc({
|
|
|
4368
4440
|
label: "--editor NAME",
|
|
4369
4441
|
description: "Write editor config files for the specified editor."
|
|
4370
4442
|
},
|
|
4443
|
+
{
|
|
4444
|
+
label: "--git",
|
|
4445
|
+
description: "Initialize a git repository with an initial commit"
|
|
4446
|
+
},
|
|
4447
|
+
{
|
|
4448
|
+
label: "--no-git",
|
|
4449
|
+
description: "Skip git repository initialization"
|
|
4450
|
+
},
|
|
4371
4451
|
{
|
|
4372
4452
|
label: "--hooks",
|
|
4373
4453
|
description: "Set up pre-commit hooks (default in non-interactive mode)"
|
|
@@ -4509,6 +4589,11 @@ const listTemplatesMessage = renderCliDoc({
|
|
|
4509
4589
|
}
|
|
4510
4590
|
]
|
|
4511
4591
|
});
|
|
4592
|
+
function normalizeAgentOption(agent) {
|
|
4593
|
+
if (!Array.isArray(agent)) return agent;
|
|
4594
|
+
if (agent.includes(false)) return false;
|
|
4595
|
+
return agent.filter((value) => typeof value === "string");
|
|
4596
|
+
}
|
|
4512
4597
|
function parseArgs() {
|
|
4513
4598
|
const args = process.argv.slice(3);
|
|
4514
4599
|
const separatorIndex = args.indexOf("--");
|
|
@@ -4522,7 +4607,8 @@ function parseArgs() {
|
|
|
4522
4607
|
"all",
|
|
4523
4608
|
"interactive",
|
|
4524
4609
|
"hooks",
|
|
4525
|
-
"verbose"
|
|
4610
|
+
"verbose",
|
|
4611
|
+
"git"
|
|
4526
4612
|
],
|
|
4527
4613
|
string: [
|
|
4528
4614
|
"directory",
|
|
@@ -4540,8 +4626,9 @@ function parseArgs() {
|
|
|
4540
4626
|
list: parsed.list || false,
|
|
4541
4627
|
help: parsed.help || false,
|
|
4542
4628
|
verbose: parsed.verbose || false,
|
|
4543
|
-
agent: parsed.agent,
|
|
4629
|
+
agent: normalizeAgentOption(parsed.agent),
|
|
4544
4630
|
editor: parsed.editor,
|
|
4631
|
+
git: parsed.git,
|
|
4545
4632
|
hooks: parsed.hooks,
|
|
4546
4633
|
packageManager: parsed["package-manager"]
|
|
4547
4634
|
},
|
|
@@ -4591,19 +4678,32 @@ function getNextCommand(projectDir, command) {
|
|
|
4591
4678
|
if (!projectDir || projectDir === ".") return command;
|
|
4592
4679
|
return `cd ${projectDir} && ${command}`;
|
|
4593
4680
|
}
|
|
4681
|
+
function findGitRoot(startPath) {
|
|
4682
|
+
let dir = startPath;
|
|
4683
|
+
while (true) {
|
|
4684
|
+
if (fs.existsSync(path.join(dir, ".git"))) return dir;
|
|
4685
|
+
const parent = path.dirname(dir);
|
|
4686
|
+
if (parent === dir) return;
|
|
4687
|
+
dir = parent;
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4690
|
+
function getCopilotSetupRoot(projectRoot, isExistingMonorepo) {
|
|
4691
|
+
if (!isExistingMonorepo) return projectRoot;
|
|
4692
|
+
return findGitRoot(projectRoot) ?? projectRoot;
|
|
4693
|
+
}
|
|
4594
4694
|
function showCreateSummary(options) {
|
|
4595
4695
|
const { description, installSummary, nextCommand, packageManager, packageManagerVersion, projectDir } = options;
|
|
4596
|
-
log(`${styleText("magenta", "◇")} Scaffolded ${accent(projectDir)}${description ? ` with ${description}` : ""}`);
|
|
4597
|
-
log(`${styleText("gray", "•")} Node ${process.versions.node} ${packageManager} ${packageManagerVersion}`);
|
|
4598
|
-
if (installSummary?.status === "installed") log(`${styleText("green", "✓")} Dependencies installed in ${formatDuration(installSummary.durationMs)}`);
|
|
4599
|
-
log(`${styleText("blue", "→")} Next: ${accent(nextCommand)}`);
|
|
4696
|
+
log$1(`${styleText("magenta", "◇")} Scaffolded ${accent(projectDir)}${description ? ` with ${description}` : ""}`);
|
|
4697
|
+
log$1(`${styleText("gray", "•")} Node ${process.versions.node} ${packageManager} ${packageManagerVersion}`);
|
|
4698
|
+
if (installSummary?.status === "installed") log$1(`${styleText("green", "✓")} Dependencies installed in ${formatDuration(installSummary.durationMs)}`);
|
|
4699
|
+
log$1(`${styleText("blue", "→")} Next: ${accent(nextCommand)}`);
|
|
4600
4700
|
}
|
|
4601
4701
|
async function main() {
|
|
4602
4702
|
const { templateName, options, templateArgs } = parseArgs();
|
|
4603
4703
|
let compactOutput = !options.verbose;
|
|
4604
4704
|
if (options.help) {
|
|
4605
4705
|
printHeader();
|
|
4606
|
-
log(helpMessage);
|
|
4706
|
+
log$1(helpMessage);
|
|
4607
4707
|
return;
|
|
4608
4708
|
}
|
|
4609
4709
|
if (options.list) {
|
|
@@ -4616,7 +4716,7 @@ async function main() {
|
|
|
4616
4716
|
if (options.directory) {
|
|
4617
4717
|
const formatted = formatTargetDir(options.directory);
|
|
4618
4718
|
if (formatted.error) {
|
|
4619
|
-
log
|
|
4719
|
+
log.error(formatted.error);
|
|
4620
4720
|
cancelAndExit("The --directory option is invalid", 1);
|
|
4621
4721
|
}
|
|
4622
4722
|
targetDir = formatted.directory;
|
|
@@ -4633,6 +4733,7 @@ async function main() {
|
|
|
4633
4733
|
let selectedTemplateName = templateName;
|
|
4634
4734
|
let selectedTemplateArgs = [...templateArgs];
|
|
4635
4735
|
let selectedAgentTargetPaths;
|
|
4736
|
+
let shouldWriteCopilotSetupWorkflow = false;
|
|
4636
4737
|
let selectedEditors;
|
|
4637
4738
|
let selectedParentDir;
|
|
4638
4739
|
let remoteTargetDir;
|
|
@@ -4685,14 +4786,14 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4685
4786
|
if (!isDirectScaffoldTemplate) compactOutput = false;
|
|
4686
4787
|
if (targetDir && !isDirectScaffoldTemplate) cancelAndExit("The --directory option is only available for builtin and bundled @org templates", 1);
|
|
4687
4788
|
if (selectedTemplateName === BuiltinTemplate.monorepo && isMonorepo) {
|
|
4688
|
-
log
|
|
4789
|
+
log.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
|
|
4689
4790
|
cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
|
|
4690
4791
|
}
|
|
4691
4792
|
if (selectedTemplateName === BuiltinTemplate.generator && !isMonorepo) {
|
|
4692
|
-
log
|
|
4793
|
+
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`");
|
|
4693
4794
|
cancelAndExit("Cannot create a generator outside a monorepo", 1);
|
|
4694
4795
|
}
|
|
4695
|
-
if (isInSubdirectory && !compactOutput) log
|
|
4796
|
+
if (isInSubdirectory && !compactOutput) log.info(`Detected monorepo root at ${accent(workspaceInfoOptional.rootDir)}`);
|
|
4696
4797
|
if (isMonorepo && options.interactive && !targetDir) {
|
|
4697
4798
|
let parentDir;
|
|
4698
4799
|
if (workspaceInfoOptional.parentDirs.length > 0 || isInSubdirectory) {
|
|
@@ -4733,7 +4834,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4733
4834
|
selectedParentDir = parentDir;
|
|
4734
4835
|
}
|
|
4735
4836
|
if (isMonorepo && !options.interactive && !targetDir) {
|
|
4736
|
-
if (isInSubdirectory && !compactOutput) log
|
|
4837
|
+
if (isInSubdirectory && !compactOutput) log.info(`Use ${accent("--directory")} to specify a different target location.`);
|
|
4737
4838
|
selectedParentDir = inferParentDir(selectedTemplateName, workspaceInfoOptional) ?? workspaceInfoOptional.parentDirs[0];
|
|
4738
4839
|
}
|
|
4739
4840
|
if (isGitHubUrl(selectedTemplateName)) if (hasExplicitTargetDir(selectedTemplateArgs)) remoteTargetDir = selectedTemplateArgs[0];
|
|
@@ -4741,7 +4842,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4741
4842
|
const inferredTargetDir = inferGitHubRepoName(selectedTemplateName) ?? "template";
|
|
4742
4843
|
const remoteTargetBaseDir = selectedParentDir ? path.join(workspaceInfoOptional.rootDir, selectedParentDir) : workspaceInfoOptional.rootDir;
|
|
4743
4844
|
const defaultTargetDir = suggestAvailableTargetDir(inferredTargetDir, remoteTargetBaseDir);
|
|
4744
|
-
if (defaultTargetDir !== inferredTargetDir && options.interactive) log
|
|
4845
|
+
if (defaultTargetDir !== inferredTargetDir && options.interactive) log.info(` Target directory "${inferredTargetDir}" already exists. Suggested: ${accent(defaultTargetDir)}`);
|
|
4745
4846
|
remoteTargetDir = await promptTargetDir(defaultTargetDir, options.interactive, { cwd: remoteTargetBaseDir });
|
|
4746
4847
|
selectedTemplateArgs = [remoteTargetDir, ...selectedTemplateArgs];
|
|
4747
4848
|
}
|
|
@@ -4754,7 +4855,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4754
4855
|
if (enclosingPackage) cancelAndExit(`Cannot scaffold inside existing package "${enclosingPackage.name}" (${enclosingPackage.path}). Use --directory to specify a different location`, 1);
|
|
4755
4856
|
targetDir = cwdRelativeToRoot;
|
|
4756
4857
|
}
|
|
4757
|
-
log
|
|
4858
|
+
log.info(`Using package name: ${accent(packageName)}`);
|
|
4758
4859
|
} else if (selectedTemplateName === BuiltinTemplate.monorepo) {
|
|
4759
4860
|
const selected = await promptPackageNameAndTargetDir(getRandomProjectName({ fallbackName: "vite-plus-monorepo" }), options.interactive);
|
|
4760
4861
|
packageName = selected.packageName;
|
|
@@ -4769,7 +4870,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4769
4870
|
}
|
|
4770
4871
|
if (options.packageManager && !Object.values(PackageManager).includes(options.packageManager)) {
|
|
4771
4872
|
const valid = Object.values(PackageManager).join(", ");
|
|
4772
|
-
log
|
|
4873
|
+
log.error(`Invalid package manager: ${options.packageManager}. Must be one of: ${valid}`);
|
|
4773
4874
|
cancelAndExit("Invalid --package-manager value", 1);
|
|
4774
4875
|
}
|
|
4775
4876
|
const packageManager = workspaceInfoOptional.packageManager ?? options.packageManager ?? await selectPackageManager(options.interactive, compactOutput);
|
|
@@ -4781,16 +4882,22 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4781
4882
|
downloadPackageManager: downloadResult
|
|
4782
4883
|
};
|
|
4783
4884
|
const existingAgentTargetPaths = options.agent !== void 0 || !options.interactive ? void 0 : detectExistingAgentTargetPaths(workspaceInfoOptional.rootDir);
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4885
|
+
if (existingAgentTargetPaths !== void 0) selectedAgentTargetPaths = existingAgentTargetPaths;
|
|
4886
|
+
else {
|
|
4887
|
+
const agentSelection = await selectAgentTargets({
|
|
4888
|
+
interactive: options.interactive,
|
|
4889
|
+
agent: options.agent,
|
|
4890
|
+
onCancel: () => cancelAndExit()
|
|
4891
|
+
});
|
|
4892
|
+
selectedAgentTargetPaths = agentSelection.targetPaths;
|
|
4893
|
+
shouldWriteCopilotSetupWorkflow = agentSelection.selectedAgents.some((agent) => agent.id === COPILOT_AGENT_ID);
|
|
4894
|
+
}
|
|
4789
4895
|
selectedEditors = (options.editor || !options.interactive ? void 0 : detectExistingEditors(workspaceInfoOptional.rootDir)) ?? await selectEditors({
|
|
4790
4896
|
interactive: options.interactive,
|
|
4791
4897
|
editor: options.editor,
|
|
4792
4898
|
onCancel: () => cancelAndExit()
|
|
4793
4899
|
});
|
|
4900
|
+
const shouldSetupGit = await promptGitInit(options);
|
|
4794
4901
|
if (!isMonorepo) shouldSetupHooks = await promptGitHooks(options);
|
|
4795
4902
|
const createProgress = options.interactive && compactOutput ? spinner({ indicator: "timer" }) : void 0;
|
|
4796
4903
|
let createProgressStarted = false;
|
|
@@ -4840,7 +4947,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4840
4947
|
resumeCreateProgress();
|
|
4841
4948
|
}
|
|
4842
4949
|
if (templateInfo.command === BuiltinTemplate.monorepo || isBundledMonorepo) {
|
|
4843
|
-
let shouldInitGit =
|
|
4950
|
+
let shouldInitGit = shouldSetupGit;
|
|
4844
4951
|
if (options.interactive && !compactOutput) {
|
|
4845
4952
|
pauseCreateProgress();
|
|
4846
4953
|
const selected = await confirm({
|
|
@@ -4849,10 +4956,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4849
4956
|
});
|
|
4850
4957
|
resumeCreateProgress();
|
|
4851
4958
|
if (q(selected)) {
|
|
4852
|
-
log
|
|
4959
|
+
log.info("Operation cancelled. Skipping git initialization");
|
|
4853
4960
|
shouldInitGit = false;
|
|
4854
4961
|
} else shouldInitGit = selected;
|
|
4855
|
-
} else if (!compactOutput) log
|
|
4962
|
+
} else if (shouldInitGit && !compactOutput) log.info("Initializing git repository (default: yes)");
|
|
4856
4963
|
updateCreateProgress("Creating monorepo");
|
|
4857
4964
|
await checkProjectDirExists(path.join(workspaceInfo.rootDir, targetDir), options.interactive);
|
|
4858
4965
|
const result = isBundledMonorepo ? await executeBundledTemplate(workspaceInfo, {
|
|
@@ -4876,11 +4983,11 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4876
4983
|
cwd: fullPath
|
|
4877
4984
|
});
|
|
4878
4985
|
if (gitResult.status === 0) {
|
|
4879
|
-
if (!compactOutput) log
|
|
4986
|
+
if (!compactOutput) log.success("Git repository initialized");
|
|
4880
4987
|
ensureGitignoreNodeModules(fullPath);
|
|
4881
4988
|
} else {
|
|
4882
|
-
log
|
|
4883
|
-
if (gitResult.stderr) log
|
|
4989
|
+
log.warn("Failed to initialize git repository");
|
|
4990
|
+
if (gitResult.stderr) log.info(gitResult.stderr.toString());
|
|
4884
4991
|
}
|
|
4885
4992
|
}
|
|
4886
4993
|
updateCreateProgress("Writing agent instructions");
|
|
@@ -4891,6 +4998,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4891
4998
|
interactive: options.interactive,
|
|
4892
4999
|
silent: compactOutput
|
|
4893
5000
|
});
|
|
5001
|
+
if (shouldWriteCopilotSetupWorkflow) await writeCopilotSetupWorkflow({
|
|
5002
|
+
projectRoot: fullPath,
|
|
5003
|
+
silent: compactOutput
|
|
5004
|
+
});
|
|
4894
5005
|
resumeCreateProgress();
|
|
4895
5006
|
updateCreateProgress("Writing editor configs");
|
|
4896
5007
|
pauseCreateProgress();
|
|
@@ -4901,10 +5012,15 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4901
5012
|
silent: compactOutput,
|
|
4902
5013
|
extraVsCodeSettings: { "npm.scriptRunner": "vp" }
|
|
4903
5014
|
});
|
|
5015
|
+
if (selectedEditors?.includes("vscode")) ensureGitignoreVsCodeEditorConfigs(fullPath);
|
|
4904
5016
|
resumeCreateProgress();
|
|
4905
5017
|
workspaceInfo.rootDir = fullPath;
|
|
4906
5018
|
updateCreateProgress("Integrating monorepo");
|
|
4907
5019
|
rewriteMonorepo(workspaceInfo, void 0, compactOutput);
|
|
5020
|
+
if (shouldSetupGit) {
|
|
5021
|
+
updateCreateProgress("Initializing git repository");
|
|
5022
|
+
await initGitRepository(fullPath);
|
|
5023
|
+
}
|
|
4908
5024
|
if (bundled?.monorepo) injectCreateDefaultTemplate(fullPath, bundled.scope, compactOutput);
|
|
4909
5025
|
if (shouldSetupHooks) installGitHooks(fullPath, compactOutput);
|
|
4910
5026
|
updateCreateProgress("Installing dependencies");
|
|
@@ -4915,6 +5031,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4915
5031
|
});
|
|
4916
5032
|
updateCreateProgress("Formatting code");
|
|
4917
5033
|
await runViteFmt(fullPath, options.interactive, void 0, { silent: compactOutput });
|
|
5034
|
+
if (shouldSetupGit) {
|
|
5035
|
+
updateCreateProgress("Creating initial commit");
|
|
5036
|
+
if (!await createInitialCommit(fullPath)) log.warn("Initial commit failed. Check your git user.name/user.email config");
|
|
5037
|
+
}
|
|
4918
5038
|
clearCreateProgress();
|
|
4919
5039
|
showCreateSummary({
|
|
4920
5040
|
description: describeScaffold(selectedTemplateName, selectedTemplateArgs),
|
|
@@ -4978,6 +5098,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4978
5098
|
interactive: options.interactive,
|
|
4979
5099
|
silent: compactOutput
|
|
4980
5100
|
});
|
|
5101
|
+
if (shouldWriteCopilotSetupWorkflow) await writeCopilotSetupWorkflow({
|
|
5102
|
+
projectRoot: getCopilotSetupRoot(agentInstructionsRoot, isMonorepo),
|
|
5103
|
+
silent: compactOutput
|
|
5104
|
+
});
|
|
4981
5105
|
resumeCreateProgress();
|
|
4982
5106
|
updateCreateProgress("Writing editor configs");
|
|
4983
5107
|
pauseCreateProgress();
|
|
@@ -4988,6 +5112,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4988
5112
|
silent: compactOutput,
|
|
4989
5113
|
extraVsCodeSettings: { "npm.scriptRunner": "vp" }
|
|
4990
5114
|
});
|
|
5115
|
+
if (selectedEditors?.includes("vscode")) ensureGitignoreVsCodeEditorConfigs(fullPath);
|
|
4991
5116
|
resumeCreateProgress();
|
|
4992
5117
|
const shouldMigrateLintFmtTools = detectEslintProject(fullPath).hasDependency || detectPrettierProject(fullPath).hasDependency;
|
|
4993
5118
|
let installSummary;
|
|
@@ -5011,7 +5136,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5011
5136
|
resumeCreateProgress();
|
|
5012
5137
|
};
|
|
5013
5138
|
if (isMonorepo) {
|
|
5014
|
-
if (!compactOutput) log
|
|
5139
|
+
if (!compactOutput) log.step("Monorepo integration...");
|
|
5015
5140
|
if (workspaceInfo.packages.length > 0) {
|
|
5016
5141
|
if (options.interactive) {
|
|
5017
5142
|
pauseCreateProgress();
|
|
@@ -5056,11 +5181,20 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5056
5181
|
});
|
|
5057
5182
|
updateCreateProgress("Formatting code");
|
|
5058
5183
|
await runViteFmt(workspaceInfo.rootDir, options.interactive, [projectDir], { silent: compactOutput });
|
|
5184
|
+
if (shouldSetupGit) {
|
|
5185
|
+
updateCreateProgress("Creating initial commit");
|
|
5186
|
+
await initGitRepository(workspaceInfo.rootDir);
|
|
5187
|
+
await createInitialCommit(workspaceInfo.rootDir);
|
|
5188
|
+
}
|
|
5059
5189
|
} else {
|
|
5060
5190
|
if (shouldMigrateLintFmtTools) await installAndMigrate(fullPath);
|
|
5061
5191
|
updateCreateProgress("Applying Vite+ project setup");
|
|
5062
5192
|
rewriteStandaloneProject(fullPath, workspaceInfo, void 0, compactOutput);
|
|
5063
5193
|
for (const framework of detectFramework(fullPath)) if (!hasFrameworkShim(fullPath, framework)) addFrameworkShim(fullPath, framework);
|
|
5194
|
+
if (shouldSetupGit) {
|
|
5195
|
+
updateCreateProgress("Initializing git repository");
|
|
5196
|
+
await initGitRepository(fullPath);
|
|
5197
|
+
}
|
|
5064
5198
|
if (shouldSetupHooks) installGitHooks(fullPath, compactOutput);
|
|
5065
5199
|
updateCreateProgress("Installing dependencies");
|
|
5066
5200
|
installSummary = await runViteInstall(fullPath, options.interactive, installArgs, {
|
|
@@ -5070,6 +5204,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5070
5204
|
});
|
|
5071
5205
|
updateCreateProgress("Formatting code");
|
|
5072
5206
|
await runViteFmt(fullPath, options.interactive, void 0, { silent: compactOutput });
|
|
5207
|
+
if (shouldSetupGit) {
|
|
5208
|
+
updateCreateProgress("Creating initial commit");
|
|
5209
|
+
if (!await createInitialCommit(fullPath)) log.warn("Initial commit failed. Check your git user.name/user.email config");
|
|
5210
|
+
}
|
|
5073
5211
|
}
|
|
5074
5212
|
clearCreateProgress();
|
|
5075
5213
|
showCreateSummary({
|
|
@@ -5083,10 +5221,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5083
5221
|
}
|
|
5084
5222
|
async function showAvailableTemplates() {
|
|
5085
5223
|
printHeader();
|
|
5086
|
-
log(listTemplatesMessage);
|
|
5224
|
+
log$1(listTemplatesMessage);
|
|
5087
5225
|
}
|
|
5088
5226
|
main().catch((err) => {
|
|
5089
|
-
log
|
|
5227
|
+
log.error(err.message);
|
|
5090
5228
|
console.error(err);
|
|
5091
5229
|
cancelAndExit(`Failed to generate code: ${err.message}`, 1);
|
|
5092
5230
|
});
|