vite-plus 0.1.22 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding/index.cjs +119 -52
- package/binding/index.d.cts +3222 -2
- package/dist/agent-Nuk-9l77.js +2470 -0
- package/dist/bin.js +13 -8
- package/dist/cli-truncate-CWsmbK3p.js +867 -0
- package/dist/{compat-OlmU9EQz.js → compat-DXZgnEyq.js} +1 -1
- package/dist/config/bin.js +18 -5
- package/dist/{constants-kDaYqyWd.js → constants-DCBWlNrn.js} +7 -2
- package/dist/create/bin.d.ts +1 -1
- package/dist/create/bin.js +194 -87
- package/dist/{define-config-IMCGDS2K.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-owlRxmBM.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-NRrY6krx.js → log-update-lyIiuflf.js} +111 -24
- package/dist/migration/bin.js +81 -39
- package/dist/{oxlint-plugin-config-BkQeR4FR.js → oxlint-plugin-config-B89iKTKN.js} +1 -1
- package/dist/oxlint-plugin.d.ts +2 -4
- package/dist/oxlint-plugin.js +1 -1
- package/dist/pack-bin.js +1 -1
- package/dist/pack.d.ts +1 -1
- package/dist/{package-BoLLED6j.js → package-PmBUZ-ve.js} +2 -2
- package/dist/staged/bin.js +157 -424
- package/dist/strip-ansi-C3wrWz9t.js +853 -0
- package/dist/{agent-BWLe0i9g.js → tsconfig-DFb5BKyT.js} +681 -2114
- package/dist/version.js +5 -5
- package/dist/versions.js +7 -7
- package/dist/{workspace-Bi_9spVt.js → workspace-NL-m9wgM.js} +22 -21
- package/dist/wrap-ansi-CeQuiQ31.js +2 -0
- package/dist/{wrap-ansi-DtUeUCjE.js → wrap-ansi-k7Dn4VtV.js} +1 -1
- package/docs/_data/team.ts +3 -3
- package/docs/config/run.md +39 -4
- package/docs/guide/cache.md +10 -1
- package/docs/guide/env.md +3 -0
- package/docs/guide/ide-integration.md +2 -2
- package/docs/guide/index.md +4 -0
- package/docs/guide/install.md +19 -0
- package/docs/guide/migrate.md +1 -1
- package/docs/guide/run.md +2 -0
- package/docs/guide/troubleshooting.md +6 -29
- package/docs/guide/upgrade.md +12 -1
- package/package.json +20 -20
- package/templates/monorepo/_gitignore +1 -0
- package/dist/cli-truncate-B62YnW2m.js +0 -138
- package/dist/dist-DZfItHAr.js +0 -3
- package/dist/slice-ansi-e4todZeH.js +0 -113
- package/dist/strip-ansi-D-eYYcD2.js +0 -198
- package/dist/tsconfig-BVyzXJ_o.js +0 -517
- package/dist/wrap-ansi-3S3qJ7j8.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-CzWdQTt2.js → define-config-BRC7qPNE.js} +0 -0
- /package/dist/{help-DK5wuu34.js → help-YP84FSEz.js} +0 -0
- /package/dist/{lib-DpwyUJWo.js → lib-L3DWSRQp.js} +0 -0
- /package/dist/{main-DhsO6ndq.js → main-DpJl3LoU.js} +0 -0
- /package/dist/{pack-K7H72Cum.d.ts → pack-Ciiho0Tq.d.ts} +0 -0
- /package/dist/{report-CYPv1VK1.js → report-DgSBQUdz.js} +0 -0
- /package/dist/{resolve-vite-config-C5AjksTj.js → resolve-vite-config-TTvhycU1.js} +0 -0
- /package/dist/{terminal-D_Kg-AA6.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 R, 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-DFb5BKyT.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-Nuk-9l77.js";
|
|
8
|
+
import { a as detectExistingEditors, c as writeEditorConfigs, n as updatePackageJsonWithDeps, r as updateWorkspaceConfig, s as selectEditors, t as detectWorkspace$1 } from "../workspace-NL-m9wgM.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";
|
|
@@ -496,7 +496,7 @@ async function pickOrgTemplate(manifest, opts) {
|
|
|
496
496
|
message: `Pick a template from ${manifest.scope}`,
|
|
497
497
|
options
|
|
498
498
|
});
|
|
499
|
-
if (
|
|
499
|
+
if (R(picked)) return ORG_PICKER_CANCEL;
|
|
500
500
|
const found = lookup.get(picked);
|
|
501
501
|
if (found === ESCAPE_HATCH) return ORG_PICKER_BUILTIN_ESCAPE;
|
|
502
502
|
if (!found) throw new Error(`org-picker: prompts.select returned an unregistered value: ${picked}`);
|
|
@@ -3763,6 +3763,19 @@ function getRandomProjectName(options = {}) {
|
|
|
3763
3763
|
}
|
|
3764
3764
|
//#endregion
|
|
3765
3765
|
//#region src/create/utils.ts
|
|
3766
|
+
function hasExplicitEditorOptIn(editor) {
|
|
3767
|
+
return typeof editor === "string" && editor.trim() !== "";
|
|
3768
|
+
}
|
|
3769
|
+
function normalizeEditorOption(editor) {
|
|
3770
|
+
if (!Array.isArray(editor)) return editor;
|
|
3771
|
+
if (editor.includes(false)) return false;
|
|
3772
|
+
return editor.findLast((value) => typeof value === "string");
|
|
3773
|
+
}
|
|
3774
|
+
function shouldConfigureEditorsForCreate({ editor, isMonorepo }) {
|
|
3775
|
+
if (editor === false) return false;
|
|
3776
|
+
if (!isMonorepo) return true;
|
|
3777
|
+
return hasExplicitEditorOptIn(editor);
|
|
3778
|
+
}
|
|
3766
3779
|
function copy(src, dest) {
|
|
3767
3780
|
if (fs.statSync(src).isDirectory()) copyDir(src, dest);
|
|
3768
3781
|
else fs.copyFileSync(src, dest);
|
|
@@ -3870,6 +3883,35 @@ function ensureGitignoreNodeModules(projectDir) {
|
|
|
3870
3883
|
const prefix = content === "" || content.endsWith("\n") ? "" : "\n";
|
|
3871
3884
|
fs.appendFileSync(gitignorePath, `${prefix}node_modules\n`);
|
|
3872
3885
|
}
|
|
3886
|
+
const VSCODE_SETTINGS_PATH = ".vscode/settings.json";
|
|
3887
|
+
const VSCODE_CONFIG_UNIGNORE_BLOCK = [
|
|
3888
|
+
"!.vscode/",
|
|
3889
|
+
`!${VSCODE_SETTINGS_PATH}`,
|
|
3890
|
+
`!.vscode/extensions.json`
|
|
3891
|
+
];
|
|
3892
|
+
/**
|
|
3893
|
+
* Make generated VS Code workspace config trackable when `vp create` writes VS Code config.
|
|
3894
|
+
*/
|
|
3895
|
+
function ensureGitignoreVsCodeEditorConfigs(projectDir) {
|
|
3896
|
+
if (!fs.existsSync(path.join(projectDir, VSCODE_SETTINGS_PATH))) return;
|
|
3897
|
+
const gitignorePath = path.join(projectDir, ".gitignore");
|
|
3898
|
+
let content;
|
|
3899
|
+
try {
|
|
3900
|
+
content = fs.readFileSync(gitignorePath, "utf-8");
|
|
3901
|
+
} catch {
|
|
3902
|
+
return;
|
|
3903
|
+
}
|
|
3904
|
+
appendGitignoreVsCodeEditorConfigsBlock(gitignorePath, content);
|
|
3905
|
+
}
|
|
3906
|
+
function appendGitignoreVsCodeEditorConfigsBlock(gitignorePath, content) {
|
|
3907
|
+
if (content.trimEnd().endsWith(VSCODE_CONFIG_UNIGNORE_BLOCK.join("\n"))) return;
|
|
3908
|
+
appendGitignoreLines(gitignorePath, content, VSCODE_CONFIG_UNIGNORE_BLOCK);
|
|
3909
|
+
}
|
|
3910
|
+
function appendGitignoreLines(gitignorePath, content, lines) {
|
|
3911
|
+
if (lines.length === 0) return;
|
|
3912
|
+
const prefix = content === "" || content.endsWith("\n") ? "" : "\n";
|
|
3913
|
+
fs.appendFileSync(gitignorePath, `${prefix}${lines.join("\n")}\n`);
|
|
3914
|
+
}
|
|
3873
3915
|
function formatDisplayTargetDir(targetDir) {
|
|
3874
3916
|
const normalized = targetDir.split(path.sep).join("/");
|
|
3875
3917
|
if (normalized === "" || normalized === ".") return "./";
|
|
@@ -3901,13 +3943,13 @@ async function promptPackageNameAndTargetDir(defaultPackageName, interactive) {
|
|
|
3901
3943
|
return result?.errors?.[0] ?? result?.warnings?.[0] ?? "Invalid package name";
|
|
3902
3944
|
}
|
|
3903
3945
|
});
|
|
3904
|
-
if (
|
|
3946
|
+
if (R(selected)) cancelAndExit();
|
|
3905
3947
|
packageName = selected;
|
|
3906
3948
|
targetDir = getProjectDirFromPackageName(packageName);
|
|
3907
3949
|
} else {
|
|
3908
3950
|
packageName = defaultPackageName;
|
|
3909
3951
|
targetDir = getProjectDirFromPackageName(packageName);
|
|
3910
|
-
log
|
|
3952
|
+
log.info(`Using default package name: ${accent(packageName)}`);
|
|
3911
3953
|
}
|
|
3912
3954
|
return {
|
|
3913
3955
|
packageName,
|
|
@@ -3923,11 +3965,11 @@ async function promptTargetDir(defaultTargetDir, interactive, options) {
|
|
|
3923
3965
|
defaultValue: defaultTargetDir,
|
|
3924
3966
|
validate: (value) => validateTargetDir(value ?? defaultTargetDir, options?.cwd).error
|
|
3925
3967
|
});
|
|
3926
|
-
if (
|
|
3968
|
+
if (R(selected)) cancelAndExit();
|
|
3927
3969
|
targetDir = validateTargetDir(selected ?? defaultTargetDir, options?.cwd).directory;
|
|
3928
3970
|
} else {
|
|
3929
3971
|
targetDir = validateTargetDir(defaultTargetDir, options?.cwd).directory;
|
|
3930
|
-
log
|
|
3972
|
+
log.info(`Using default target directory: ${accent(targetDir)}`);
|
|
3931
3973
|
}
|
|
3932
3974
|
return targetDir;
|
|
3933
3975
|
}
|
|
@@ -3943,7 +3985,7 @@ function suggestAvailableTargetDir(defaultTargetDir, cwd) {
|
|
|
3943
3985
|
async function checkProjectDirExists(projectDirFullPath, interactive) {
|
|
3944
3986
|
if (isTargetDirAvailable(projectDirFullPath)) return;
|
|
3945
3987
|
if (!interactive) {
|
|
3946
|
-
log
|
|
3988
|
+
log.info("Use --directory to specify a different location or remove the directory first");
|
|
3947
3989
|
cancelAndExit(`Target directory "${projectDirFullPath}" is not empty`, 1);
|
|
3948
3990
|
}
|
|
3949
3991
|
const overwrite = await select({
|
|
@@ -3956,7 +3998,7 @@ async function checkProjectDirExists(projectDirFullPath, interactive) {
|
|
|
3956
3998
|
value: "yes"
|
|
3957
3999
|
}]
|
|
3958
4000
|
});
|
|
3959
|
-
if (
|
|
4001
|
+
if (R(overwrite)) cancelAndExit();
|
|
3960
4002
|
switch (overwrite) {
|
|
3961
4003
|
case "yes":
|
|
3962
4004
|
emptyDir(projectDirFullPath);
|
|
@@ -4031,7 +4073,7 @@ function printNonInteractiveTable(manifest, orgSpec, isMonorepo) {
|
|
|
4031
4073
|
}
|
|
4032
4074
|
function rejectMonorepoEntryInsideMonorepo(entry, isMonorepo) {
|
|
4033
4075
|
if (entry.monorepo && isMonorepo) {
|
|
4034
|
-
log
|
|
4076
|
+
log.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
|
|
4035
4077
|
cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
|
|
4036
4078
|
}
|
|
4037
4079
|
}
|
|
@@ -4068,7 +4110,7 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
4068
4110
|
}
|
|
4069
4111
|
if (!manifest) {
|
|
4070
4112
|
if (orgSpec.name !== void 0) cancelAndExit(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — \`@org:name\` requires one.`, 1);
|
|
4071
|
-
log
|
|
4113
|
+
log.info(`No \`createConfig.templates\` manifest in ${orgSpec.scope}/create — running it as a normal package.`);
|
|
4072
4114
|
return { kind: "passthrough" };
|
|
4073
4115
|
}
|
|
4074
4116
|
if (orgSpec.name === void 0) {
|
|
@@ -4079,7 +4121,7 @@ async function resolveOrgManifestForCreate(args) {
|
|
|
4079
4121
|
const picked = await pickOrgTemplate(manifest, { isMonorepo: args.isMonorepo });
|
|
4080
4122
|
if (picked === ORG_PICKER_CANCEL) cancelAndExit();
|
|
4081
4123
|
if (picked === ORG_PICKER_BUILTIN_ESCAPE) {
|
|
4082
|
-
if (args.isMonorepo && manifest.templates.every((t) => t.monorepo)) log
|
|
4124
|
+
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.`);
|
|
4083
4125
|
return { kind: "escape-hatch" };
|
|
4084
4126
|
}
|
|
4085
4127
|
rejectMonorepoEntryInsideMonorepo(picked.entry, args.isMonorepo);
|
|
@@ -4116,7 +4158,7 @@ async function getConfiguredDefaultTemplate(startDir) {
|
|
|
4116
4158
|
//#endregion
|
|
4117
4159
|
//#region src/create/templates/generator.ts
|
|
4118
4160
|
async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
4119
|
-
if (!options?.silent) log
|
|
4161
|
+
if (!options?.silent) log.step("Creating generator scaffold...");
|
|
4120
4162
|
let description;
|
|
4121
4163
|
if (templateInfo.interactive) {
|
|
4122
4164
|
const defaultDescription = "Generate new components for our monorepo";
|
|
@@ -4125,7 +4167,7 @@ async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
|
4125
4167
|
placeholder: defaultDescription,
|
|
4126
4168
|
defaultValue: defaultDescription
|
|
4127
4169
|
});
|
|
4128
|
-
if (!
|
|
4170
|
+
if (!R(descPrompt)) description = descPrompt;
|
|
4129
4171
|
}
|
|
4130
4172
|
const fullPath = path.join(workspaceInfo.rootDir, templateInfo.targetDir);
|
|
4131
4173
|
copyDir(path.join(templatesDir, "generator"), fullPath);
|
|
@@ -4135,7 +4177,7 @@ async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
|
4135
4177
|
if (description) pkg.description = description;
|
|
4136
4178
|
return pkg;
|
|
4137
4179
|
});
|
|
4138
|
-
if (!options?.silent) log
|
|
4180
|
+
if (!options?.silent) log.success("Generator scaffold created");
|
|
4139
4181
|
return {
|
|
4140
4182
|
exitCode: 0,
|
|
4141
4183
|
projectDir: templateInfo.targetDir
|
|
@@ -4147,14 +4189,14 @@ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
|
4147
4189
|
const { gray, yellow } = import_picocolors.default;
|
|
4148
4190
|
async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
4149
4191
|
const silent = options?.silent ?? false;
|
|
4150
|
-
if (!silent) log
|
|
4192
|
+
if (!silent) log.step("Generating project…");
|
|
4151
4193
|
let isGitHubTemplate = templateInfo.command === "degit";
|
|
4152
4194
|
let result;
|
|
4153
4195
|
if (templateInfo.command === "node") {
|
|
4154
4196
|
const command = templateInfo.command;
|
|
4155
4197
|
const args = templateInfo.args;
|
|
4156
4198
|
const envs = templateInfo.envs;
|
|
4157
|
-
if (!silent) log
|
|
4199
|
+
if (!silent) log.info(`Running: ${gray(`${command} ${args.join(" ")}`)}`);
|
|
4158
4200
|
result = await runCommandAndDetectProjectDir({
|
|
4159
4201
|
command,
|
|
4160
4202
|
args,
|
|
@@ -4164,7 +4206,7 @@ async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4164
4206
|
} else {
|
|
4165
4207
|
if (!isGitHubTemplate) {
|
|
4166
4208
|
if (!await checkNpmPackageExists(templateInfo.command)) {
|
|
4167
|
-
if (!silent) log
|
|
4209
|
+
if (!silent) log.error(`Template "${templateInfo.command}" not found on npm. Run ${yellow("vp create --list")} to see available templates.`);
|
|
4168
4210
|
return { exitCode: 1 };
|
|
4169
4211
|
}
|
|
4170
4212
|
}
|
|
@@ -4172,13 +4214,13 @@ async function executeRemoteTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4172
4214
|
}
|
|
4173
4215
|
const exitCode = result.exitCode;
|
|
4174
4216
|
if (exitCode === 127) {
|
|
4175
|
-
log
|
|
4176
|
-
log
|
|
4217
|
+
log.info(yellow("\nTroubleshooting:"));
|
|
4218
|
+
log.info(` ${gray("•")} Command not found. Make sure Node.js is installed`);
|
|
4177
4219
|
} else if (isGitHubTemplate && exitCode !== 0) {
|
|
4178
|
-
log
|
|
4179
|
-
log
|
|
4180
|
-
log
|
|
4181
|
-
log
|
|
4220
|
+
log.info(yellow("\nTroubleshooting:"));
|
|
4221
|
+
log.info(` ${gray("•")} Make sure the GitHub repository exists`);
|
|
4222
|
+
log.info(` ${gray("•")} Check your internet connection`);
|
|
4223
|
+
log.info(` ${gray("•")} Repository might be private (requires authentication)`);
|
|
4182
4224
|
}
|
|
4183
4225
|
return result;
|
|
4184
4226
|
}
|
|
@@ -4188,7 +4230,7 @@ async function runRemoteTemplateCommand(workspaceInfo, cwd, templateInfo, detect
|
|
|
4188
4230
|
const execArgs = [...templateInfo.args];
|
|
4189
4231
|
const envs = templateInfo.envs;
|
|
4190
4232
|
const { command, args } = formatDlxCommand(remotePackageName, execArgs, workspaceInfo);
|
|
4191
|
-
if (!silent) log
|
|
4233
|
+
if (!silent) log.info(`Running: ${gray(`${command} ${args.join(" ")}`)}`);
|
|
4192
4234
|
if (detectCreatedProjectDir) return await runCommandAndDetectProjectDir({
|
|
4193
4235
|
command,
|
|
4194
4236
|
args,
|
|
@@ -4249,7 +4291,7 @@ async function executeBuiltinTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4249
4291
|
};
|
|
4250
4292
|
}
|
|
4251
4293
|
if (templateInfo.command.startsWith("vite:")) {
|
|
4252
|
-
if (!options?.silent) log
|
|
4294
|
+
if (!options?.silent) log.error(`Unknown builtin template "${templateInfo.command}". Run ${import_picocolors.default.yellow("vp create --list")} to see available templates.`);
|
|
4253
4295
|
return { exitCode: 1 };
|
|
4254
4296
|
}
|
|
4255
4297
|
const result = await runRemoteTemplateCommand(workspaceInfo, workspaceInfo.rootDir, templateInfo, false, options?.silent ?? false);
|
|
@@ -4295,8 +4337,8 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4295
4337
|
workspaceInfo.monorepoScope = getScopeFromPackageName(templateInfo.packageName);
|
|
4296
4338
|
const fullPath = path.join(workspaceInfo.rootDir, templateInfo.targetDir);
|
|
4297
4339
|
if (!options?.silent) {
|
|
4298
|
-
log
|
|
4299
|
-
log
|
|
4340
|
+
log.info(`Target directory: ${formatDisplayTargetDir(templateInfo.targetDir)}`);
|
|
4341
|
+
log.step("Creating Vite+ monorepo...");
|
|
4300
4342
|
}
|
|
4301
4343
|
copyDir(path.join(templatesDir, "monorepo"), fullPath);
|
|
4302
4344
|
renameFiles(fullPath);
|
|
@@ -4329,8 +4371,8 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4329
4371
|
const yarnrcPath = path.join(fullPath, ".yarnrc.yml");
|
|
4330
4372
|
if (fs.existsSync(yarnrcPath)) fs.unlinkSync(yarnrcPath);
|
|
4331
4373
|
}
|
|
4332
|
-
if (!options?.silent) log
|
|
4333
|
-
if (!options?.silent) log
|
|
4374
|
+
if (!options?.silent) log.success("Monorepo template created");
|
|
4375
|
+
if (!options?.silent) log.step("Creating default application in apps/website...");
|
|
4334
4376
|
const appResult = await runRemoteTemplateCommand(workspaceInfo, fullPath, discoverTemplate("create-vite@latest", [
|
|
4335
4377
|
InitialMonorepoAppDir,
|
|
4336
4378
|
"--template",
|
|
@@ -4338,18 +4380,19 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4338
4380
|
"--no-interactive"
|
|
4339
4381
|
], workspaceInfo), false, options?.silent ?? false);
|
|
4340
4382
|
if (appResult.exitCode !== 0) {
|
|
4341
|
-
log
|
|
4383
|
+
log.error(`Failed to create default application: ${appResult.exitCode}`);
|
|
4342
4384
|
return appResult;
|
|
4343
4385
|
}
|
|
4344
4386
|
const appPackageName = workspaceInfo.monorepoScope ? `${workspaceInfo.monorepoScope}/website` : "website";
|
|
4345
4387
|
const appProjectPath = path.join(fullPath, InitialMonorepoAppDir);
|
|
4346
4388
|
setPackageName(appProjectPath, appPackageName);
|
|
4347
4389
|
rewriteMonorepoProject(appProjectPath, workspaceInfo.packageManager, void 0, options?.silent ?? false);
|
|
4348
|
-
|
|
4390
|
+
dropAliasedRuntimeDevDeps(appProjectPath, workspaceInfo.packageManager);
|
|
4391
|
+
if (!options?.silent) log.step("Creating default library in packages/utils...");
|
|
4349
4392
|
const libraryDir = "packages/utils";
|
|
4350
4393
|
const libraryResult = await runRemoteTemplateCommand(workspaceInfo, fullPath, discoverTemplate(LibraryTemplateRepo, [libraryDir], workspaceInfo), false, options?.silent ?? false);
|
|
4351
4394
|
if (libraryResult.exitCode !== 0) {
|
|
4352
|
-
log
|
|
4395
|
+
log.error(`Failed to create default library, exit code: ${libraryResult.exitCode}`);
|
|
4353
4396
|
return libraryResult;
|
|
4354
4397
|
}
|
|
4355
4398
|
const libraryPackageName = workspaceInfo.monorepoScope ? `${workspaceInfo.monorepoScope}/utils` : "utils";
|
|
@@ -4361,6 +4404,30 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4361
4404
|
projectDir: templateInfo.targetDir
|
|
4362
4405
|
};
|
|
4363
4406
|
}
|
|
4407
|
+
/**
|
|
4408
|
+
* Drop the aliased `vite` / `vitest` devDeps that `create-vite` leaves on a
|
|
4409
|
+
* scaffolded sub-package. After migration its scripts already use `vp ...` and
|
|
4410
|
+
* nothing imports `'vite'` directly, so `vite-plus` provides them transitively.
|
|
4411
|
+
*
|
|
4412
|
+
* pnpm is the exception and keeps them: pnpm only surfaces the
|
|
4413
|
+
* pnpm-workspace.yaml `overrides.vite: catalog:` entry through a package that
|
|
4414
|
+
* directly depends on `vite`, so keeping the aliased devDep lets `vp why vite`
|
|
4415
|
+
* reflect the override (resolving to @voidzero-dev/vite-plus-core). npm, yarn,
|
|
4416
|
+
* and bun redirect the transitive/peer vite via their root
|
|
4417
|
+
* overrides/resolutions regardless of a direct dep, so the aliased keys are
|
|
4418
|
+
* dead weight and are dropped.
|
|
4419
|
+
*/
|
|
4420
|
+
function dropAliasedRuntimeDevDeps(appProjectPath, packageManager) {
|
|
4421
|
+
if (packageManager === PackageManager.pnpm) return;
|
|
4422
|
+
editJsonFile(path.join(appProjectPath, "package.json"), (pkg) => {
|
|
4423
|
+
let changed = false;
|
|
4424
|
+
for (const name of ["vite", "vitest"]) if (pkg.devDependencies?.[name]) {
|
|
4425
|
+
delete pkg.devDependencies[name];
|
|
4426
|
+
changed = true;
|
|
4427
|
+
}
|
|
4428
|
+
return changed ? pkg : void 0;
|
|
4429
|
+
});
|
|
4430
|
+
}
|
|
4364
4431
|
function getScopeFromPackageName(packageName) {
|
|
4365
4432
|
if (packageName.startsWith("@")) return packageName.split("/")[0];
|
|
4366
4433
|
return "";
|
|
@@ -4552,6 +4619,11 @@ const listTemplatesMessage = renderCliDoc({
|
|
|
4552
4619
|
}
|
|
4553
4620
|
]
|
|
4554
4621
|
});
|
|
4622
|
+
function normalizeAgentOption(agent) {
|
|
4623
|
+
if (!Array.isArray(agent)) return agent;
|
|
4624
|
+
if (agent.includes(false)) return false;
|
|
4625
|
+
return agent.filter((value) => typeof value === "string");
|
|
4626
|
+
}
|
|
4555
4627
|
function parseArgs() {
|
|
4556
4628
|
const args = process.argv.slice(3);
|
|
4557
4629
|
const separatorIndex = args.indexOf("--");
|
|
@@ -4584,8 +4656,8 @@ function parseArgs() {
|
|
|
4584
4656
|
list: parsed.list || false,
|
|
4585
4657
|
help: parsed.help || false,
|
|
4586
4658
|
verbose: parsed.verbose || false,
|
|
4587
|
-
agent: parsed.agent,
|
|
4588
|
-
editor: parsed.editor,
|
|
4659
|
+
agent: normalizeAgentOption(parsed.agent),
|
|
4660
|
+
editor: normalizeEditorOption(parsed.editor),
|
|
4589
4661
|
git: parsed.git,
|
|
4590
4662
|
hooks: parsed.hooks,
|
|
4591
4663
|
packageManager: parsed["package-manager"]
|
|
@@ -4636,19 +4708,32 @@ function getNextCommand(projectDir, command) {
|
|
|
4636
4708
|
if (!projectDir || projectDir === ".") return command;
|
|
4637
4709
|
return `cd ${projectDir} && ${command}`;
|
|
4638
4710
|
}
|
|
4711
|
+
function findGitRoot(startPath) {
|
|
4712
|
+
let dir = startPath;
|
|
4713
|
+
while (true) {
|
|
4714
|
+
if (fs.existsSync(path.join(dir, ".git"))) return dir;
|
|
4715
|
+
const parent = path.dirname(dir);
|
|
4716
|
+
if (parent === dir) return;
|
|
4717
|
+
dir = parent;
|
|
4718
|
+
}
|
|
4719
|
+
}
|
|
4720
|
+
function getCopilotSetupRoot(projectRoot, isExistingMonorepo) {
|
|
4721
|
+
if (!isExistingMonorepo) return projectRoot;
|
|
4722
|
+
return findGitRoot(projectRoot) ?? projectRoot;
|
|
4723
|
+
}
|
|
4639
4724
|
function showCreateSummary(options) {
|
|
4640
4725
|
const { description, installSummary, nextCommand, packageManager, packageManagerVersion, projectDir } = options;
|
|
4641
|
-
log(`${styleText("magenta", "◇")} Scaffolded ${accent(projectDir)}${description ? ` with ${description}` : ""}`);
|
|
4642
|
-
log(`${styleText("gray", "•")} Node ${process.versions.node} ${packageManager} ${packageManagerVersion}`);
|
|
4643
|
-
if (installSummary?.status === "installed") log(`${styleText("green", "✓")} Dependencies installed in ${formatDuration(installSummary.durationMs)}`);
|
|
4644
|
-
log(`${styleText("blue", "→")} Next: ${accent(nextCommand)}`);
|
|
4726
|
+
log$1(`${styleText("magenta", "◇")} Scaffolded ${accent(projectDir)}${description ? ` with ${description}` : ""}`);
|
|
4727
|
+
log$1(`${styleText("gray", "•")} Node ${process.versions.node} ${packageManager} ${packageManagerVersion}`);
|
|
4728
|
+
if (installSummary?.status === "installed") log$1(`${styleText("green", "✓")} Dependencies installed in ${formatDuration(installSummary.durationMs)}`);
|
|
4729
|
+
log$1(`${styleText("blue", "→")} Next: ${accent(nextCommand)}`);
|
|
4645
4730
|
}
|
|
4646
4731
|
async function main() {
|
|
4647
4732
|
const { templateName, options, templateArgs } = parseArgs();
|
|
4648
4733
|
let compactOutput = !options.verbose;
|
|
4649
4734
|
if (options.help) {
|
|
4650
4735
|
printHeader();
|
|
4651
|
-
log(helpMessage);
|
|
4736
|
+
log$1(helpMessage);
|
|
4652
4737
|
return;
|
|
4653
4738
|
}
|
|
4654
4739
|
if (options.list) {
|
|
@@ -4661,7 +4746,7 @@ async function main() {
|
|
|
4661
4746
|
if (options.directory) {
|
|
4662
4747
|
const formatted = formatTargetDir(options.directory);
|
|
4663
4748
|
if (formatted.error) {
|
|
4664
|
-
log
|
|
4749
|
+
log.error(formatted.error);
|
|
4665
4750
|
cancelAndExit("The --directory option is invalid", 1);
|
|
4666
4751
|
}
|
|
4667
4752
|
targetDir = formatted.directory;
|
|
@@ -4678,6 +4763,7 @@ async function main() {
|
|
|
4678
4763
|
let selectedTemplateName = templateName;
|
|
4679
4764
|
let selectedTemplateArgs = [...templateArgs];
|
|
4680
4765
|
let selectedAgentTargetPaths;
|
|
4766
|
+
let shouldWriteCopilotSetupWorkflow = false;
|
|
4681
4767
|
let selectedEditors;
|
|
4682
4768
|
let selectedParentDir;
|
|
4683
4769
|
let remoteTargetDir;
|
|
@@ -4720,7 +4806,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4720
4806
|
message: "",
|
|
4721
4807
|
options: getInitialTemplateOptions(isMonorepo)
|
|
4722
4808
|
});
|
|
4723
|
-
if (
|
|
4809
|
+
if (R(template)) cancelAndExit();
|
|
4724
4810
|
selectedTemplateName = template;
|
|
4725
4811
|
}
|
|
4726
4812
|
const isBuiltinTemplate = selectedTemplateName.startsWith("vite:");
|
|
@@ -4730,14 +4816,14 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4730
4816
|
if (!isDirectScaffoldTemplate) compactOutput = false;
|
|
4731
4817
|
if (targetDir && !isDirectScaffoldTemplate) cancelAndExit("The --directory option is only available for builtin and bundled @org templates", 1);
|
|
4732
4818
|
if (selectedTemplateName === BuiltinTemplate.monorepo && isMonorepo) {
|
|
4733
|
-
log
|
|
4819
|
+
log.info("You are already in a monorepo workspace.\nUse a different template or run this command outside the monorepo");
|
|
4734
4820
|
cancelAndExit("Cannot create a monorepo inside an existing monorepo", 1);
|
|
4735
4821
|
}
|
|
4736
4822
|
if (selectedTemplateName === BuiltinTemplate.generator && !isMonorepo) {
|
|
4737
|
-
log
|
|
4823
|
+
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`");
|
|
4738
4824
|
cancelAndExit("Cannot create a generator outside a monorepo", 1);
|
|
4739
4825
|
}
|
|
4740
|
-
if (isInSubdirectory && !compactOutput) log
|
|
4826
|
+
if (isInSubdirectory && !compactOutput) log.info(`Detected monorepo root at ${accent(workspaceInfoOptional.rootDir)}`);
|
|
4741
4827
|
if (isMonorepo && options.interactive && !targetDir) {
|
|
4742
4828
|
let parentDir;
|
|
4743
4829
|
if (workspaceInfoOptional.parentDirs.length > 0 || isInSubdirectory) {
|
|
@@ -4761,7 +4847,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4761
4847
|
options: dirOptions,
|
|
4762
4848
|
initialValue: shouldOfferCwdOption ? cwdRelativeToRoot : inferParentDir(selectedTemplateName, workspaceInfoOptional) ?? workspaceInfoOptional.parentDirs[0]
|
|
4763
4849
|
});
|
|
4764
|
-
if (
|
|
4850
|
+
if (R(selected)) cancelAndExit();
|
|
4765
4851
|
if (selected !== "other") parentDir = selected;
|
|
4766
4852
|
}
|
|
4767
4853
|
if (!parentDir) {
|
|
@@ -4772,13 +4858,13 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4772
4858
|
return value ? formatTargetDir(value).error : "Target directory is required";
|
|
4773
4859
|
}
|
|
4774
4860
|
});
|
|
4775
|
-
if (
|
|
4861
|
+
if (R(customTargetDir)) cancelAndExit();
|
|
4776
4862
|
parentDir = customTargetDir;
|
|
4777
4863
|
}
|
|
4778
4864
|
selectedParentDir = parentDir;
|
|
4779
4865
|
}
|
|
4780
4866
|
if (isMonorepo && !options.interactive && !targetDir) {
|
|
4781
|
-
if (isInSubdirectory && !compactOutput) log
|
|
4867
|
+
if (isInSubdirectory && !compactOutput) log.info(`Use ${accent("--directory")} to specify a different target location.`);
|
|
4782
4868
|
selectedParentDir = inferParentDir(selectedTemplateName, workspaceInfoOptional) ?? workspaceInfoOptional.parentDirs[0];
|
|
4783
4869
|
}
|
|
4784
4870
|
if (isGitHubUrl(selectedTemplateName)) if (hasExplicitTargetDir(selectedTemplateArgs)) remoteTargetDir = selectedTemplateArgs[0];
|
|
@@ -4786,7 +4872,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4786
4872
|
const inferredTargetDir = inferGitHubRepoName(selectedTemplateName) ?? "template";
|
|
4787
4873
|
const remoteTargetBaseDir = selectedParentDir ? path.join(workspaceInfoOptional.rootDir, selectedParentDir) : workspaceInfoOptional.rootDir;
|
|
4788
4874
|
const defaultTargetDir = suggestAvailableTargetDir(inferredTargetDir, remoteTargetBaseDir);
|
|
4789
|
-
if (defaultTargetDir !== inferredTargetDir && options.interactive) log
|
|
4875
|
+
if (defaultTargetDir !== inferredTargetDir && options.interactive) log.info(` Target directory "${inferredTargetDir}" already exists. Suggested: ${accent(defaultTargetDir)}`);
|
|
4790
4876
|
remoteTargetDir = await promptTargetDir(defaultTargetDir, options.interactive, { cwd: remoteTargetBaseDir });
|
|
4791
4877
|
selectedTemplateArgs = [remoteTargetDir, ...selectedTemplateArgs];
|
|
4792
4878
|
}
|
|
@@ -4799,7 +4885,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4799
4885
|
if (enclosingPackage) cancelAndExit(`Cannot scaffold inside existing package "${enclosingPackage.name}" (${enclosingPackage.path}). Use --directory to specify a different location`, 1);
|
|
4800
4886
|
targetDir = cwdRelativeToRoot;
|
|
4801
4887
|
}
|
|
4802
|
-
log
|
|
4888
|
+
log.info(`Using package name: ${accent(packageName)}`);
|
|
4803
4889
|
} else if (selectedTemplateName === BuiltinTemplate.monorepo) {
|
|
4804
4890
|
const selected = await promptPackageNameAndTargetDir(getRandomProjectName({ fallbackName: "vite-plus-monorepo" }), options.interactive);
|
|
4805
4891
|
packageName = selected.packageName;
|
|
@@ -4814,7 +4900,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4814
4900
|
}
|
|
4815
4901
|
if (options.packageManager && !Object.values(PackageManager).includes(options.packageManager)) {
|
|
4816
4902
|
const valid = Object.values(PackageManager).join(", ");
|
|
4817
|
-
log
|
|
4903
|
+
log.error(`Invalid package manager: ${options.packageManager}. Must be one of: ${valid}`);
|
|
4818
4904
|
cancelAndExit("Invalid --package-manager value", 1);
|
|
4819
4905
|
}
|
|
4820
4906
|
const packageManager = workspaceInfoOptional.packageManager ?? options.packageManager ?? await selectPackageManager(options.interactive, compactOutput);
|
|
@@ -4826,12 +4912,21 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4826
4912
|
downloadPackageManager: downloadResult
|
|
4827
4913
|
};
|
|
4828
4914
|
const existingAgentTargetPaths = options.agent !== void 0 || !options.interactive ? void 0 : detectExistingAgentTargetPaths(workspaceInfoOptional.rootDir);
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4915
|
+
if (existingAgentTargetPaths !== void 0) selectedAgentTargetPaths = existingAgentTargetPaths;
|
|
4916
|
+
else {
|
|
4917
|
+
const agentSelection = await selectAgentTargets({
|
|
4918
|
+
interactive: options.interactive,
|
|
4919
|
+
agent: options.agent,
|
|
4920
|
+
onCancel: () => cancelAndExit()
|
|
4921
|
+
});
|
|
4922
|
+
selectedAgentTargetPaths = agentSelection.targetPaths;
|
|
4923
|
+
shouldWriteCopilotSetupWorkflow = agentSelection.selectedAgents.some((agent) => agent.id === COPILOT_AGENT_ID);
|
|
4924
|
+
}
|
|
4925
|
+
const shouldConfigureEditors = shouldConfigureEditorsForCreate({
|
|
4926
|
+
editor: options.editor,
|
|
4927
|
+
isMonorepo
|
|
4833
4928
|
});
|
|
4834
|
-
selectedEditors = (options.editor || !options.interactive ? void 0 : detectExistingEditors(workspaceInfoOptional.rootDir)) ?? await selectEditors({
|
|
4929
|
+
if (shouldConfigureEditors) selectedEditors = (options.editor || !options.interactive ? void 0 : detectExistingEditors(workspaceInfoOptional.rootDir)) ?? await selectEditors({
|
|
4835
4930
|
interactive: options.interactive,
|
|
4836
4931
|
editor: options.editor,
|
|
4837
4932
|
onCancel: () => cancelAndExit()
|
|
@@ -4894,11 +4989,11 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4894
4989
|
initialValue: true
|
|
4895
4990
|
});
|
|
4896
4991
|
resumeCreateProgress();
|
|
4897
|
-
if (
|
|
4898
|
-
log
|
|
4992
|
+
if (R(selected)) {
|
|
4993
|
+
log.info("Operation cancelled. Skipping git initialization");
|
|
4899
4994
|
shouldInitGit = false;
|
|
4900
4995
|
} else shouldInitGit = selected;
|
|
4901
|
-
} else if (shouldInitGit && !compactOutput) log
|
|
4996
|
+
} else if (shouldInitGit && !compactOutput) log.info("Initializing git repository (default: yes)");
|
|
4902
4997
|
updateCreateProgress("Creating monorepo");
|
|
4903
4998
|
await checkProjectDirExists(path.join(workspaceInfo.rootDir, targetDir), options.interactive);
|
|
4904
4999
|
const result = isBundledMonorepo ? await executeBundledTemplate(workspaceInfo, {
|
|
@@ -4922,11 +5017,11 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4922
5017
|
cwd: fullPath
|
|
4923
5018
|
});
|
|
4924
5019
|
if (gitResult.status === 0) {
|
|
4925
|
-
if (!compactOutput) log
|
|
5020
|
+
if (!compactOutput) log.success("Git repository initialized");
|
|
4926
5021
|
ensureGitignoreNodeModules(fullPath);
|
|
4927
5022
|
} else {
|
|
4928
|
-
log
|
|
4929
|
-
if (gitResult.stderr) log
|
|
5023
|
+
log.warn("Failed to initialize git repository");
|
|
5024
|
+
if (gitResult.stderr) log.info(gitResult.stderr.toString());
|
|
4930
5025
|
}
|
|
4931
5026
|
}
|
|
4932
5027
|
updateCreateProgress("Writing agent instructions");
|
|
@@ -4937,6 +5032,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4937
5032
|
interactive: options.interactive,
|
|
4938
5033
|
silent: compactOutput
|
|
4939
5034
|
});
|
|
5035
|
+
if (shouldWriteCopilotSetupWorkflow) await writeCopilotSetupWorkflow({
|
|
5036
|
+
projectRoot: fullPath,
|
|
5037
|
+
silent: compactOutput
|
|
5038
|
+
});
|
|
4940
5039
|
resumeCreateProgress();
|
|
4941
5040
|
updateCreateProgress("Writing editor configs");
|
|
4942
5041
|
pauseCreateProgress();
|
|
@@ -4947,6 +5046,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4947
5046
|
silent: compactOutput,
|
|
4948
5047
|
extraVsCodeSettings: { "npm.scriptRunner": "vp" }
|
|
4949
5048
|
});
|
|
5049
|
+
if (selectedEditors?.includes("vscode")) ensureGitignoreVsCodeEditorConfigs(fullPath);
|
|
4950
5050
|
resumeCreateProgress();
|
|
4951
5051
|
workspaceInfo.rootDir = fullPath;
|
|
4952
5052
|
updateCreateProgress("Integrating monorepo");
|
|
@@ -4956,7 +5056,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4956
5056
|
await initGitRepository(fullPath);
|
|
4957
5057
|
}
|
|
4958
5058
|
if (bundled?.monorepo) injectCreateDefaultTemplate(fullPath, bundled.scope, compactOutput);
|
|
4959
|
-
if (shouldSetupHooks) installGitHooks(fullPath, compactOutput);
|
|
5059
|
+
if (shouldSetupHooks) installGitHooks(fullPath, compactOutput, void 0, workspaceInfo.packageManager);
|
|
4960
5060
|
updateCreateProgress("Installing dependencies");
|
|
4961
5061
|
const installSummary = await runViteInstall(fullPath, options.interactive, installArgs, {
|
|
4962
5062
|
silent: compactOutput,
|
|
@@ -4967,7 +5067,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
4967
5067
|
await runViteFmt(fullPath, options.interactive, void 0, { silent: compactOutput });
|
|
4968
5068
|
if (shouldSetupGit) {
|
|
4969
5069
|
updateCreateProgress("Creating initial commit");
|
|
4970
|
-
if (!await createInitialCommit(fullPath)) log
|
|
5070
|
+
if (!await createInitialCommit(fullPath)) log.warn("Initial commit failed. Check your git user.name/user.email config");
|
|
4971
5071
|
}
|
|
4972
5072
|
clearCreateProgress();
|
|
4973
5073
|
showCreateSummary({
|
|
@@ -5032,17 +5132,24 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5032
5132
|
interactive: options.interactive,
|
|
5033
5133
|
silent: compactOutput
|
|
5034
5134
|
});
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
await writeEditorConfigs({
|
|
5039
|
-
projectRoot: fullPath,
|
|
5040
|
-
editorId: selectedEditors,
|
|
5041
|
-
interactive: options.interactive,
|
|
5042
|
-
silent: compactOutput,
|
|
5043
|
-
extraVsCodeSettings: { "npm.scriptRunner": "vp" }
|
|
5135
|
+
if (shouldWriteCopilotSetupWorkflow) await writeCopilotSetupWorkflow({
|
|
5136
|
+
projectRoot: getCopilotSetupRoot(agentInstructionsRoot, isMonorepo),
|
|
5137
|
+
silent: compactOutput
|
|
5044
5138
|
});
|
|
5045
5139
|
resumeCreateProgress();
|
|
5140
|
+
if (shouldConfigureEditors) {
|
|
5141
|
+
updateCreateProgress("Writing editor configs");
|
|
5142
|
+
pauseCreateProgress();
|
|
5143
|
+
await writeEditorConfigs({
|
|
5144
|
+
projectRoot: fullPath,
|
|
5145
|
+
editorId: selectedEditors,
|
|
5146
|
+
interactive: options.interactive,
|
|
5147
|
+
silent: compactOutput,
|
|
5148
|
+
extraVsCodeSettings: { "npm.scriptRunner": "vp" }
|
|
5149
|
+
});
|
|
5150
|
+
if (selectedEditors?.includes("vscode")) ensureGitignoreVsCodeEditorConfigs(fullPath);
|
|
5151
|
+
resumeCreateProgress();
|
|
5152
|
+
}
|
|
5046
5153
|
const shouldMigrateLintFmtTools = detectEslintProject(fullPath).hasDependency || detectPrettierProject(fullPath).hasDependency;
|
|
5047
5154
|
let installSummary;
|
|
5048
5155
|
const installAndMigrate = async (installCwd) => {
|
|
@@ -5065,7 +5172,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5065
5172
|
resumeCreateProgress();
|
|
5066
5173
|
};
|
|
5067
5174
|
if (isMonorepo) {
|
|
5068
|
-
if (!compactOutput) log
|
|
5175
|
+
if (!compactOutput) log.step("Monorepo integration...");
|
|
5069
5176
|
if (workspaceInfo.packages.length > 0) {
|
|
5070
5177
|
if (options.interactive) {
|
|
5071
5178
|
pauseCreateProgress();
|
|
@@ -5080,7 +5187,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5080
5187
|
required: false
|
|
5081
5188
|
});
|
|
5082
5189
|
let selectedDepTypes = [];
|
|
5083
|
-
if (!
|
|
5190
|
+
if (!R(selectedDepTypeOptions)) selectedDepTypes = selectedDepTypeOptions;
|
|
5084
5191
|
for (const selectedDepType of selectedDepTypes) {
|
|
5085
5192
|
const selected = await multiselect({
|
|
5086
5193
|
message: `Which packages should be added as ${selectedDepType} to ${success(projectDir)}?`,
|
|
@@ -5091,7 +5198,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5091
5198
|
required: false
|
|
5092
5199
|
});
|
|
5093
5200
|
let selectedDeps = [];
|
|
5094
|
-
if (!
|
|
5201
|
+
if (!R(selected)) selectedDeps = selected;
|
|
5095
5202
|
if (selectedDeps.length > 0) updatePackageJsonWithDeps(workspaceInfo.rootDir, projectDir, selectedDeps, selectedDepType);
|
|
5096
5203
|
}
|
|
5097
5204
|
resumeCreateProgress();
|
|
@@ -5124,7 +5231,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5124
5231
|
updateCreateProgress("Initializing git repository");
|
|
5125
5232
|
await initGitRepository(fullPath);
|
|
5126
5233
|
}
|
|
5127
|
-
if (shouldSetupHooks) installGitHooks(fullPath, compactOutput);
|
|
5234
|
+
if (shouldSetupHooks) installGitHooks(fullPath, compactOutput, void 0, workspaceInfo.packageManager);
|
|
5128
5235
|
updateCreateProgress("Installing dependencies");
|
|
5129
5236
|
installSummary = await runViteInstall(fullPath, options.interactive, installArgs, {
|
|
5130
5237
|
silent: compactOutput,
|
|
@@ -5135,7 +5242,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5135
5242
|
await runViteFmt(fullPath, options.interactive, void 0, { silent: compactOutput });
|
|
5136
5243
|
if (shouldSetupGit) {
|
|
5137
5244
|
updateCreateProgress("Creating initial commit");
|
|
5138
|
-
if (!await createInitialCommit(fullPath)) log
|
|
5245
|
+
if (!await createInitialCommit(fullPath)) log.warn("Initial commit failed. Check your git user.name/user.email config");
|
|
5139
5246
|
}
|
|
5140
5247
|
}
|
|
5141
5248
|
clearCreateProgress();
|
|
@@ -5150,10 +5257,10 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
|
|
|
5150
5257
|
}
|
|
5151
5258
|
async function showAvailableTemplates() {
|
|
5152
5259
|
printHeader();
|
|
5153
|
-
log(listTemplatesMessage);
|
|
5260
|
+
log$1(listTemplatesMessage);
|
|
5154
5261
|
}
|
|
5155
5262
|
main().catch((err) => {
|
|
5156
|
-
log
|
|
5263
|
+
log.error(err.message);
|
|
5157
5264
|
console.error(err);
|
|
5158
5265
|
cancelAndExit(`Failed to generate code: ${err.message}`, 1);
|
|
5159
5266
|
});
|