vite-plus 0.3.2 → 1.0.0-rc.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/LICENSE +35 -146
- package/README.md +3 -3
- package/binding/index.cjs +140 -55
- package/binding/index.d.cts +49 -0
- package/dist/{agent-C59HKB4Y.js → agent-Dinpyd-k.js} +6 -5
- package/dist/bin.js +48 -18
- package/dist/config/bin.js +2 -2
- package/dist/constants-CiKwrA0v.js +356 -0
- package/dist/create/bin.js +96 -71
- package/dist/{define-config-DPNEJxPz.d.ts → define-config-B9usMnEa.d.ts} +51 -10
- package/dist/{define-config-DpAPETDf.cjs → define-config-CBccpane.cjs} +173 -44
- package/dist/{define-config-DAaCa0U_.js → define-config-jhuYJ7Tb.js} +158 -42
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.d.ts +1 -1
- package/dist/define-config.js +1 -1
- package/dist/documentation-DqcZSthV.js +11 -0
- package/dist/{editor-QOIGtmH4.js → editor-DMBczTdj.js} +216 -152
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-cULBl7Pi.js → json-JP24qHUF.js} +14 -6
- package/dist/lint-plugins.cjs +1 -1
- package/dist/migration/bin.js +3122 -15
- package/dist/{oxlint-plugin-config-BU42tr8y.js → oxlint-plugin-config-BgsDA6ua.js} +1 -1
- package/dist/oxlint-plugin.js +9 -7
- package/dist/pack-bin.js +1 -1
- package/dist/{package-BB-Jh_z3.js → package-B85H2Nw0.js} +6 -2
- package/dist/{vitest-ecosystem-BiRqcaRI.js → package-overrides-Dpn4scvN.js} +1 -7
- package/dist/{prompts-CujFOJXu.js → prompts-CQobX7uP.js} +2 -2
- package/dist/{resolve-vite-config-CHHjsjKJ.js → resolve-vite-config-BUFUmi8h.js} +2 -2
- package/dist/{resolve-vite-config-6Nox70uP.js → resolve-vite-config-I8fmpR7I.js} +1 -1
- package/dist/staged/bin.js +1205 -3317
- package/dist/sync-versions/bin.js +3 -2
- package/dist/sync-versions/bin.mjs +17 -2
- package/dist/test/browser/context.js +1 -1
- package/dist/test/browser/providers/playwright/context.js +1 -1
- package/dist/test/browser/providers/preview/context.js +1 -1
- package/dist/test/browser-playwright/context.js +1 -1
- package/dist/test/browser-preview/context.js +1 -1
- package/dist/test/context.d.ts +2 -942
- package/dist/test/context.js +1 -1
- package/dist/test/internal/traces.js +1 -0
- package/dist/test/locators.d.ts +2 -294
- package/dist/test/matchers.d.ts +2 -29
- package/dist/test/mocker.d.ts +2 -0
- package/dist/test/mocker.js +1 -0
- package/dist/test/{browser-webdriverio/context.js → plugins/browser-context.d.ts} +1 -0
- package/dist/test/plugins/browser-context.js +1 -1
- package/dist/test/plugins/browser-locators.d.ts +2 -0
- package/dist/test/plugins/browser-playwright.d.ts +2 -0
- package/dist/test/plugins/browser-preview.d.ts +2 -0
- package/dist/test/plugins/browser.d.ts +2 -0
- package/dist/test/plugins/mocker-automock.d.ts +2 -0
- package/dist/test/plugins/mocker-browser.d.ts +2 -0
- package/dist/test/plugins/mocker-node.d.ts +2 -0
- package/dist/test/plugins/mocker-redirect.d.ts +2 -0
- package/dist/test/plugins/mocker-register.d.ts +2 -0
- package/dist/test/plugins/mocker-transforms.d.ts +2 -0
- package/dist/test/plugins/mocker.d.ts +2 -0
- package/dist/test/plugins/pretty-format.d.ts +2 -0
- package/dist/test/plugins/snapshot-environment.d.ts +2 -0
- package/dist/test/plugins/snapshot-manager.d.ts +2 -0
- package/dist/test/plugins/snapshot.d.ts +2 -0
- package/dist/test/plugins/spy.d.ts +2 -0
- package/dist/test/plugins/utils-constants.d.ts +2 -0
- package/dist/test/plugins/utils-diff.d.ts +2 -0
- package/dist/test/plugins/utils-display.d.ts +2 -0
- package/dist/test/plugins/utils-error.d.ts +2 -0
- package/dist/test/plugins/utils-helpers.d.ts +2 -0
- package/dist/test/plugins/utils-offset.d.ts +2 -0
- package/dist/test/plugins/utils-resolver.d.ts +2 -0
- package/dist/test/plugins/utils-serialize.d.ts +2 -0
- package/dist/test/plugins/utils-source-map-node.d.ts +2 -0
- package/dist/test/plugins/utils-source-map.d.ts +2 -0
- package/dist/test/plugins/utils-timers.d.ts +2 -0
- package/dist/test/plugins/utils.d.ts +2 -0
- package/dist/toolchain.js +10 -10
- package/dist/toolchain.json +10 -10
- package/dist/{tsconfig-DCtWfQPA.js → tsconfig-Buo0RSzz.js} +8 -4
- package/dist/{tsconfig-MXktI3SX.js → tsconfig-C1VeTG9k.js} +1 -1
- package/dist/version.js +5 -3
- package/dist/versions.js +5 -5
- package/dist/vitest-ecosystem-BU0AqZq-.js +23 -0
- package/dist/vitest-v5-entry-points-DthU1e_O.js +25 -0
- package/docs/config/fmt.md +2 -2
- package/docs/config/lint.md +2 -2
- package/docs/config/run.md +1 -1
- package/docs/config/staged.md +1 -2
- package/docs/guide/check.md +2 -0
- package/docs/guide/ci.md +28 -31
- package/docs/guide/commit-hooks.md +18 -34
- package/docs/guide/create.md +1 -2
- package/docs/guide/docker.md +20 -68
- package/docs/guide/env.md +47 -32
- package/docs/guide/fmt.md +4 -2
- package/docs/guide/global-cli.md +426 -0
- package/docs/guide/ide-integration.md +1 -2
- package/docs/guide/implode.md +14 -1
- package/docs/guide/index.md +38 -35
- package/docs/guide/install.md +18 -20
- package/docs/guide/lint.md +6 -10
- package/docs/guide/local-cli.md +123 -0
- package/docs/guide/migrate-rules.md +104 -297
- package/docs/guide/migrate.md +82 -59
- package/docs/guide/monorepo.md +5 -1
- package/docs/guide/run.md +1 -1
- package/docs/guide/test.md +2 -0
- package/docs/guide/troubleshooting.md +6 -11
- package/docs/guide/upgrade-project.md +61 -0
- package/docs/guide/upgrade.md +17 -62
- package/docs/guide/vitest-v5.md +221 -0
- package/package.json +67 -90
- package/bin/oxfmt +0 -33
- package/bin/oxlint +0 -38
- package/dist/cli-truncate-Bg3RDXpi.js +0 -865
- package/dist/constants-IhOditRA.js +0 -80
- package/dist/is-fullwidth-code-point-BUNlIICg.js +0 -8
- package/dist/log-update-CoW8Z4Dl.js +0 -491
- package/dist/strip-ansi-C3wrWz9t.js +0 -853
- package/dist/test/browser/providers/webdriverio/context.d.ts +0 -1
- package/dist/test/browser/providers/webdriverio/context.js +0 -1
- package/dist/test/browser/providers/webdriverio.d.ts +0 -77
- package/dist/test/browser/providers/webdriverio.js +0 -1
- package/dist/test/browser-webdriverio/context.d.ts +0 -1
- package/dist/test/browser-webdriverio.d.ts +0 -77
- package/dist/test/browser-webdriverio.js +0 -1
- package/dist/test/coverage.d.ts +0 -2
- package/dist/test/coverage.js +0 -1
- package/dist/test/environments.d.ts +0 -2
- package/dist/test/environments.js +0 -1
- package/dist/test/plugins/browser-webdriverio.js +0 -1
- package/dist/test/plugins/expect.js +0 -1
- package/dist/test/plugins/runner-types.js +0 -1
- package/dist/test/plugins/runner-utils.js +0 -1
- package/dist/test/plugins/runner.js +0 -1
- package/dist/test/reporters.d.ts +0 -2
- package/dist/test/reporters.js +0 -1
- package/dist/test/runners.d.ts +0 -2
- package/dist/test/runners.js +0 -1
- package/dist/test/snapshot.d.ts +0 -2
- package/dist/test/snapshot.js +0 -1
- package/dist/test/suite.d.ts +0 -2
- package/dist/test/suite.js +0 -1
- package/dist/tsgolint-path-CbDReEOx.js +0 -34
- package/dist/tsgolint-path.d.ts +0 -7
- package/dist/tsgolint-path.js +0 -2
- package/dist/wrap-ansi-DNjkuBEp.js +0 -157
- package/dist/wrap-ansi-DUi52C6W.js +0 -2
- package/docs/guide/installer-env-vars.md +0 -286
package/dist/create/bin.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { r as __toESM, t as __commonJSMin } from "../rolldown-runtime-CMFfr-1z.js";
|
|
2
|
+
import { t as documentationUrl$1 } from "../documentation-DqcZSthV.js";
|
|
2
3
|
import { t as renderCliDoc } from "../help-BmKpeOP9.js";
|
|
3
4
|
import { a as muted, i as log, o as printHeader, r as formatDuration, s as success, t as accent } from "../terminal-MKGAuy-p.js";
|
|
4
|
-
import { u as VITE_PLUS_NAME } from "../constants-
|
|
5
|
-
import { i as readJsonFile, n as editJsonFile } from "../json-
|
|
6
|
-
import { o as fetchNpmResource, r as getScopeFromPackageName, s as getNpmRegistry, t as checkNpmPackageExists } from "../package-
|
|
7
|
-
import { i as hasViteConfig, o as resolveViteConfig, r as findWorkspaceRoot, t as findViteConfig } from "../resolve-vite-config-
|
|
8
|
-
import { C as multiselect, D as text, E as spinner, O as require_picocolors, S as log$1, T as select, a as resolveGitInit, c as selectPackageManager, d as readYamlFile, h as resolveApproveBuildTargets, i as promptGitHooks, k as isCancel, 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, x as intro, y as PackageManager } from "../prompts-
|
|
5
|
+
import { u as VITE_PLUS_NAME } from "../constants-CiKwrA0v.js";
|
|
6
|
+
import { i as readJsonFile, n as editJsonFile } from "../json-JP24qHUF.js";
|
|
7
|
+
import { o as fetchNpmResource, r as getScopeFromPackageName, s as getNpmRegistry, t as checkNpmPackageExists } from "../package-B85H2Nw0.js";
|
|
8
|
+
import { i as hasViteConfig, o as resolveViteConfig, r as findWorkspaceRoot, t as findViteConfig } from "../resolve-vite-config-BUFUmi8h.js";
|
|
9
|
+
import { C as multiselect, D as text, E as spinner, O as require_picocolors, S as log$1, T as select, a as resolveGitInit, c as selectPackageManager, d as readYamlFile, h as resolveApproveBuildTargets, i as promptGitHooks, k as isCancel, 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, x as intro, y as PackageManager } from "../prompts-CQobX7uP.js";
|
|
9
10
|
import { t as require_semver } from "../semver-CaDAb8vV.js";
|
|
10
|
-
import { a as selectAgentTargets, c as writeCopilotSetupWorkflow, d as templatesDir, l as displayRelative, r as detectExistingAgentTargetPaths, s as writeAgentInstructions, t as COPILOT_AGENT_ID } from "../agent-
|
|
11
|
-
import {
|
|
11
|
+
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-Dinpyd-k.js";
|
|
12
|
+
import { B as addFrameworkShim, F as updateWorkspaceConfig, H as hasFrameworkShim, K as promptTsupMigration, L as findGitRoot, M as detectWorkspace$1, N as isBingoTemplate, P as updatePackageJsonWithDeps, R as initGitRepository, V as detectFramework, W as detectTsupProject, Y as detectPrettierProject, Z as promptPrettierMigration, _ as installGitHooks, a as selectEditors, b as injectCreateDefaultTemplate, c as rewriteMonorepoProject, et as detectEslintProject, h as setPackageManager, j as supportsCatalog, l as rewriteStandaloneProject, n as detectExistingEditors, o as writeEditorConfigs, rt as promptEslintMigration, s as rewriteMonorepo, y as shouldSkipStagedMigrationForHooks } from "../editor-DMBczTdj.js";
|
|
12
13
|
import { n as runCommandSilently, t as runCommand$1 } from "../command-CguLh2KL.js";
|
|
13
14
|
import { t as unwrapCliParseOutcome } from "../cli-parse-DHE8NrBU.js";
|
|
14
15
|
import path from "node:path";
|
|
15
|
-
import { getVpDirs, parseCreateArgs, runCommand, upsertJsonConfig, vitePlusHeader } from "../../binding/index.js";
|
|
16
|
+
import { getVpDirs, parseCreateArgs, removeConfigKey, runCommand, upsertJsonConfig, vitePlusHeader } from "../../binding/index.js";
|
|
16
17
|
import { styleText } from "node:util";
|
|
17
18
|
import fs from "node:fs";
|
|
18
19
|
import os from "node:os";
|
|
@@ -618,6 +619,7 @@ var CreateConfigSchemaError = class extends Error {
|
|
|
618
619
|
this.name = "CreateConfigSchemaError";
|
|
619
620
|
}
|
|
620
621
|
};
|
|
622
|
+
const makeCreateConfigError = (message) => new CreateConfigSchemaError(message);
|
|
621
623
|
/**
|
|
622
624
|
* Validate `create.templates` from `vite.config.ts`. Returns `[]` when the field
|
|
623
625
|
* is absent or an empty array; throws {@link CreateConfigSchemaError} when present
|
|
@@ -626,10 +628,9 @@ var CreateConfigSchemaError = class extends Error {
|
|
|
626
628
|
function validateCreateTemplates(templates) {
|
|
627
629
|
if (templates === void 0) return [];
|
|
628
630
|
if (!Array.isArray(templates)) throw new CreateConfigSchemaError("create.templates must be an array");
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
if (validated.name.startsWith("vite:")) throw makeError(`create.templates[${index}].name uses the reserved \`vite:\` prefix`);
|
|
631
|
+
return validateTemplateEntries(templates, "create.templates", makeCreateConfigError, (entry, index) => {
|
|
632
|
+
const validated = validateTemplateEntry(entry, index, "create.templates", makeCreateConfigError);
|
|
633
|
+
if (validated.name.startsWith("vite:")) throw makeCreateConfigError(`create.templates[${index}].name uses the reserved \`vite:\` prefix`);
|
|
633
634
|
return validated;
|
|
634
635
|
});
|
|
635
636
|
}
|
|
@@ -4379,6 +4380,11 @@ async function executeGeneratorScaffold(workspaceInfo, templateInfo, options) {
|
|
|
4379
4380
|
fs.chmodSync(path.join(fullPath, "bin/index.ts"), "755");
|
|
4380
4381
|
editJsonFile(path.join(fullPath, "package.json"), (pkg) => {
|
|
4381
4382
|
pkg.name = templateInfo.packageName;
|
|
4383
|
+
if (!supportsCatalog(workspaceInfo.packageManager, workspaceInfo.downloadPackageManager.version, workspaceInfo.isMonorepo)) {
|
|
4384
|
+
const { catalog } = readYamlFile(path.join(templatesDir, "monorepo/pnpm-workspace.yaml"));
|
|
4385
|
+
const devDependencies = pkg.devDependencies;
|
|
4386
|
+
for (const [name, spec] of Object.entries(devDependencies)) if (spec === "catalog:" && catalog[name]) devDependencies[name] = catalog[name];
|
|
4387
|
+
}
|
|
4382
4388
|
if (description) pkg.description = description;
|
|
4383
4389
|
return pkg;
|
|
4384
4390
|
});
|
|
@@ -4476,64 +4482,6 @@ function autoFixRemoteTemplateCommand(templateInfo, workspaceInfo) {
|
|
|
4476
4482
|
}
|
|
4477
4483
|
}
|
|
4478
4484
|
//#endregion
|
|
4479
|
-
//#region src/create/templates/builtin.ts
|
|
4480
|
-
async function executeBuiltinTemplate(workspaceInfo, templateInfo, options) {
|
|
4481
|
-
assert(templateInfo.targetDir, "targetDir is required");
|
|
4482
|
-
assert(templateInfo.packageName, "packageName is required");
|
|
4483
|
-
if (templateInfo.command === BuiltinTemplate.generator) return await executeGeneratorScaffold(workspaceInfo, templateInfo, options);
|
|
4484
|
-
if (templateInfo.command === BuiltinTemplate.application) {
|
|
4485
|
-
templateInfo.command = "create-vite@latest";
|
|
4486
|
-
if (!templateInfo.interactive) templateInfo.args.push("--no-interactive");
|
|
4487
|
-
templateInfo.args.unshift(templateInfo.targetDir);
|
|
4488
|
-
} else if (templateInfo.command === BuiltinTemplate.library) {
|
|
4489
|
-
const libraryTemplateInfo = discoverTemplate(LibraryTemplateRepo, [templateInfo.targetDir], workspaceInfo);
|
|
4490
|
-
const result = await runRemoteTemplateCommand(workspaceInfo, workspaceInfo.rootDir, libraryTemplateInfo, false, options?.silent ?? false);
|
|
4491
|
-
if (result.exitCode !== 0) return { exitCode: result.exitCode };
|
|
4492
|
-
setPackageName(path.join(workspaceInfo.rootDir, templateInfo.targetDir), templateInfo.packageName);
|
|
4493
|
-
return {
|
|
4494
|
-
...result,
|
|
4495
|
-
projectDir: templateInfo.targetDir
|
|
4496
|
-
};
|
|
4497
|
-
}
|
|
4498
|
-
if (templateInfo.command.startsWith("vite:")) {
|
|
4499
|
-
if (!options?.silent) log$1.error(`Unknown builtin template "${templateInfo.command}". Run ${import_picocolors.default.yellow("vp create --list")} to see available templates.`);
|
|
4500
|
-
return { exitCode: 1 };
|
|
4501
|
-
}
|
|
4502
|
-
const result = await runRemoteTemplateCommand(workspaceInfo, workspaceInfo.rootDir, templateInfo, false, options?.silent ?? false);
|
|
4503
|
-
if (result.exitCode !== 0) return { exitCode: result.exitCode };
|
|
4504
|
-
setPackageName(path.join(workspaceInfo.rootDir, templateInfo.targetDir), templateInfo.packageName);
|
|
4505
|
-
return {
|
|
4506
|
-
...result,
|
|
4507
|
-
projectDir: templateInfo.targetDir
|
|
4508
|
-
};
|
|
4509
|
-
}
|
|
4510
|
-
//#endregion
|
|
4511
|
-
//#region src/create/templates/bundled.ts
|
|
4512
|
-
/**
|
|
4513
|
-
* Scaffold a bundled template by copying the pre-extracted directory at
|
|
4514
|
-
* `localPath` into `workspaceInfo.rootDir/targetDir`.
|
|
4515
|
-
*/
|
|
4516
|
-
async function executeBundledTemplate(workspaceInfo, templateInfo) {
|
|
4517
|
-
assert(templateInfo.localPath, "localPath is required for bundled templates");
|
|
4518
|
-
assert(templateInfo.targetDir, "targetDir is required");
|
|
4519
|
-
assert(templateInfo.packageName, "packageName is required");
|
|
4520
|
-
const destDir = path.join(workspaceInfo.rootDir, templateInfo.targetDir);
|
|
4521
|
-
try {
|
|
4522
|
-
copyDir(templateInfo.localPath, destDir);
|
|
4523
|
-
} catch (error) {
|
|
4524
|
-
if (error.code === "ENOENT") throw new Error(`bundled template directory not found: ${templateInfo.localPath}`, { cause: error });
|
|
4525
|
-
throw error;
|
|
4526
|
-
}
|
|
4527
|
-
renameFiles(destDir);
|
|
4528
|
-
try {
|
|
4529
|
-
setPackageName(destDir, templateInfo.packageName);
|
|
4530
|
-
} catch {}
|
|
4531
|
-
return {
|
|
4532
|
-
exitCode: 0,
|
|
4533
|
-
projectDir: templateInfo.targetDir
|
|
4534
|
-
};
|
|
4535
|
-
}
|
|
4536
|
-
//#endregion
|
|
4537
4485
|
//#region src/create/templates/monorepo.ts
|
|
4538
4486
|
const InitialMonorepoAppDir = "apps/website";
|
|
4539
4487
|
async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
@@ -4603,6 +4551,7 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4603
4551
|
const libraryPackageName = workspaceInfo.monorepoScope ? `${workspaceInfo.monorepoScope}/utils` : "utils";
|
|
4604
4552
|
const libraryProjectPath = path.join(fullPath, libraryDir);
|
|
4605
4553
|
setPackageName(libraryProjectPath, libraryPackageName);
|
|
4554
|
+
removeNestedLibraryToolConfig(libraryProjectPath);
|
|
4606
4555
|
rewriteMonorepoProject(libraryProjectPath, workspaceInfo.packageManager, void 0, options?.silent ?? false);
|
|
4607
4556
|
alignMonorepoTypeScriptVersion(fullPath, appProjectPath, libraryProjectPath);
|
|
4608
4557
|
return {
|
|
@@ -4611,6 +4560,22 @@ async function executeMonorepoTemplate(workspaceInfo, templateInfo, options) {
|
|
|
4611
4560
|
};
|
|
4612
4561
|
}
|
|
4613
4562
|
/**
|
|
4563
|
+
* Remove the root-only lint and format options shipped by the standalone library template.
|
|
4564
|
+
*
|
|
4565
|
+
* The same remote template is also used by `vite:library`, where this config is
|
|
4566
|
+
* valid. A library created as a workspace member, however, gets its lint and
|
|
4567
|
+
* format config from the monorepo root, so retaining them here creates invalid
|
|
4568
|
+
* nested config.
|
|
4569
|
+
*/
|
|
4570
|
+
function removeNestedLibraryToolConfig(projectPath) {
|
|
4571
|
+
const configPath = path.join(projectPath, "vite.config.ts");
|
|
4572
|
+
if (!fs.existsSync(configPath)) return;
|
|
4573
|
+
for (const configKey of ["lint", "fmt"]) {
|
|
4574
|
+
const result = removeConfigKey(configPath, configKey);
|
|
4575
|
+
if (result.updated) fs.writeFileSync(configPath, result.content);
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4578
|
+
/**
|
|
4614
4579
|
* Keep every scaffolded workspace member on the same TypeScript version.
|
|
4615
4580
|
*
|
|
4616
4581
|
* The app and library come from independently updated remote templates. If
|
|
@@ -4668,11 +4633,71 @@ function dropAliasedRuntimeDevDeps(appProjectPath, packageManager) {
|
|
|
4668
4633
|
});
|
|
4669
4634
|
}
|
|
4670
4635
|
//#endregion
|
|
4636
|
+
//#region src/create/templates/builtin.ts
|
|
4637
|
+
async function executeBuiltinTemplate(workspaceInfo, templateInfo, options) {
|
|
4638
|
+
assert(templateInfo.targetDir, "targetDir is required");
|
|
4639
|
+
assert(templateInfo.packageName, "packageName is required");
|
|
4640
|
+
if (templateInfo.command === BuiltinTemplate.generator) return await executeGeneratorScaffold(workspaceInfo, templateInfo, options);
|
|
4641
|
+
if (templateInfo.command === BuiltinTemplate.application) {
|
|
4642
|
+
templateInfo.command = "create-vite@latest";
|
|
4643
|
+
if (!templateInfo.interactive) templateInfo.args.push("--no-interactive");
|
|
4644
|
+
templateInfo.args.unshift(templateInfo.targetDir);
|
|
4645
|
+
} else if (templateInfo.command === BuiltinTemplate.library) {
|
|
4646
|
+
const libraryTemplateInfo = discoverTemplate(LibraryTemplateRepo, [templateInfo.targetDir], workspaceInfo);
|
|
4647
|
+
const result = await runRemoteTemplateCommand(workspaceInfo, workspaceInfo.rootDir, libraryTemplateInfo, false, options?.silent ?? false);
|
|
4648
|
+
if (result.exitCode !== 0) return { exitCode: result.exitCode };
|
|
4649
|
+
const fullPath = path.join(workspaceInfo.rootDir, templateInfo.targetDir);
|
|
4650
|
+
setPackageName(fullPath, templateInfo.packageName);
|
|
4651
|
+
if (workspaceInfo.isMonorepo) removeNestedLibraryToolConfig(fullPath);
|
|
4652
|
+
return {
|
|
4653
|
+
...result,
|
|
4654
|
+
projectDir: templateInfo.targetDir
|
|
4655
|
+
};
|
|
4656
|
+
}
|
|
4657
|
+
if (templateInfo.command.startsWith("vite:")) {
|
|
4658
|
+
if (!options?.silent) log$1.error(`Unknown builtin template "${templateInfo.command}". Run ${import_picocolors.default.yellow("vp create --list")} to see available templates.`);
|
|
4659
|
+
return { exitCode: 1 };
|
|
4660
|
+
}
|
|
4661
|
+
const result = await runRemoteTemplateCommand(workspaceInfo, workspaceInfo.rootDir, templateInfo, false, options?.silent ?? false);
|
|
4662
|
+
if (result.exitCode !== 0) return { exitCode: result.exitCode };
|
|
4663
|
+
setPackageName(path.join(workspaceInfo.rootDir, templateInfo.targetDir), templateInfo.packageName);
|
|
4664
|
+
return {
|
|
4665
|
+
...result,
|
|
4666
|
+
projectDir: templateInfo.targetDir
|
|
4667
|
+
};
|
|
4668
|
+
}
|
|
4669
|
+
//#endregion
|
|
4670
|
+
//#region src/create/templates/bundled.ts
|
|
4671
|
+
/**
|
|
4672
|
+
* Scaffold a bundled template by copying the pre-extracted directory at
|
|
4673
|
+
* `localPath` into `workspaceInfo.rootDir/targetDir`.
|
|
4674
|
+
*/
|
|
4675
|
+
async function executeBundledTemplate(workspaceInfo, templateInfo) {
|
|
4676
|
+
assert(templateInfo.localPath, "localPath is required for bundled templates");
|
|
4677
|
+
assert(templateInfo.targetDir, "targetDir is required");
|
|
4678
|
+
assert(templateInfo.packageName, "packageName is required");
|
|
4679
|
+
const destDir = path.join(workspaceInfo.rootDir, templateInfo.targetDir);
|
|
4680
|
+
try {
|
|
4681
|
+
copyDir(templateInfo.localPath, destDir);
|
|
4682
|
+
} catch (error) {
|
|
4683
|
+
if (error.code === "ENOENT") throw new Error(`bundled template directory not found: ${templateInfo.localPath}`, { cause: error });
|
|
4684
|
+
throw error;
|
|
4685
|
+
}
|
|
4686
|
+
renameFiles(destDir);
|
|
4687
|
+
try {
|
|
4688
|
+
setPackageName(destDir, templateInfo.packageName);
|
|
4689
|
+
} catch {}
|
|
4690
|
+
return {
|
|
4691
|
+
exitCode: 0,
|
|
4692
|
+
projectDir: templateInfo.targetDir
|
|
4693
|
+
};
|
|
4694
|
+
}
|
|
4695
|
+
//#endregion
|
|
4671
4696
|
//#region src/create/bin.ts
|
|
4672
4697
|
const listTemplatesMessage = renderCliDoc({
|
|
4673
4698
|
usage: "vp create --list",
|
|
4674
4699
|
summary: "List available builtin and popular project templates.",
|
|
4675
|
-
documentationUrl: "
|
|
4700
|
+
documentationUrl: documentationUrl$1("/guide/create"),
|
|
4676
4701
|
sections: [
|
|
4677
4702
|
{
|
|
4678
4703
|
title: "Vite+ Built-in Templates",
|
|
@@ -155,15 +155,56 @@ type RunConfig = {
|
|
|
155
155
|
enablePrePostScripts?: boolean;
|
|
156
156
|
};
|
|
157
157
|
//#endregion
|
|
158
|
-
//#region ../../node_modules/.pnpm/lint-staged@
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/config.d.ts
|
|
159
|
+
/**
|
|
160
|
+
* A single task that will be spawned
|
|
161
|
+
*
|
|
162
|
+
* @example "eslint --fix"
|
|
163
|
+
*/
|
|
164
|
+
type SpawnedTask = string;
|
|
165
|
+
type SyncGenerateTask = (files: readonly string[]) => string | string[];
|
|
166
|
+
type AsyncGenerateTask = (files: readonly string[]) => Promise<string | string[]>;
|
|
167
|
+
/**
|
|
168
|
+
* A function that returns one or more tasks that will be spawned and run sequentially, in order.
|
|
169
|
+
* The function receives list of the matched staged files as its argument. Can be sync or async.
|
|
170
|
+
*
|
|
171
|
+
* @example <caption>Return a command after manipulating list of staged files</caption>
|
|
172
|
+
* (files: string) => `eslint --fix ${files.map((f) => `'${f}'`).join(' ')}`
|
|
173
|
+
*
|
|
174
|
+
* @example <caption>Ignore staged files and run "tsc" and "vitest" without any arguments</caption>
|
|
175
|
+
* () => ['tsc', 'vitest']
|
|
176
|
+
*/
|
|
161
177
|
type GenerateTask = SyncGenerateTask | AsyncGenerateTask;
|
|
178
|
+
/**
|
|
179
|
+
* List of tasks that will be run in parallel
|
|
180
|
+
*
|
|
181
|
+
* @example ["prettier --write", "eslint --fix"]
|
|
182
|
+
*/
|
|
183
|
+
type ParallelTasks = (SpawnedTask | GenerateTask)[];
|
|
184
|
+
/**
|
|
185
|
+
* List of tasks that will be run sequentially, in order
|
|
186
|
+
*
|
|
187
|
+
* @example ["prettier --write", "eslint --fix"]
|
|
188
|
+
*/
|
|
189
|
+
type SequentialTasks = (SpawnedTask | GenerateTask | ParallelTasks)[];
|
|
190
|
+
/**
|
|
191
|
+
* A single Node.js/JavaScript task that defines its title and the function which will be
|
|
192
|
+
* run with the list of the matched staged files as its argument.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* {
|
|
196
|
+
* title: 'Log staged files',
|
|
197
|
+
* task: (files: readonly string[]) => {
|
|
198
|
+
* console.log('Staged files:', files)
|
|
199
|
+
* }
|
|
200
|
+
* }
|
|
201
|
+
*/
|
|
162
202
|
type TaskFunction = {
|
|
163
203
|
title: string;
|
|
164
|
-
task: (
|
|
204
|
+
task: (filepaths: readonly string[]) => void | Promise<void>;
|
|
165
205
|
};
|
|
166
|
-
|
|
206
|
+
/** An entire `lint-staged` configuration, or a function that returns one */
|
|
207
|
+
type Configuration = Record<string, SpawnedTask | TaskFunction | GenerateTask | SequentialTasks> | GenerateTask;
|
|
167
208
|
//#endregion
|
|
168
209
|
//#region src/staged-config.d.ts
|
|
169
210
|
type StagedConfig = Configuration;
|
|
@@ -266,10 +307,9 @@ declare function isVitestFamilySpecifier(id: string): boolean;
|
|
|
266
307
|
* Absent packages are silently skipped so the server-deps optimizer never
|
|
267
308
|
* tries to resolve a name that does not exist in the project's node_modules.
|
|
268
309
|
*
|
|
269
|
-
* The
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* time (which can differ in workspace / monorepo setups).
|
|
310
|
+
* The environment hook adds installed packages to the module-runner options
|
|
311
|
+
* inherited by shared-server projects. The resolved-config hook also handles
|
|
312
|
+
* independent project servers, using each project's resolved root.
|
|
273
313
|
*
|
|
274
314
|
* Exported for unit testing.
|
|
275
315
|
*/
|
|
@@ -284,10 +324,11 @@ declare const AUTO_INLINE_DEPS: ReadonlyArray<string>;
|
|
|
284
324
|
*
|
|
285
325
|
* Exported for unit testing. The `_createRequire` parameter lets tests inject
|
|
286
326
|
* a controlled resolver without needing to spy on Node's ESM module namespace.
|
|
327
|
+
* Callers may share installation results for the same root within one config load.
|
|
287
328
|
*/
|
|
288
329
|
declare function computeAutoInlineList(existingInline: (string | RegExp)[] | true | undefined, projectRoot: string, _createRequire?: (from: string) => {
|
|
289
330
|
resolve: (id: string) => string;
|
|
290
|
-
}): (string | RegExp)[] | null;
|
|
331
|
+
}, installedPackages?: Map<string, boolean>): (string | RegExp)[] | null;
|
|
291
332
|
/**
|
|
292
333
|
* Resolve the coverage provider package name that should be version-checked, or
|
|
293
334
|
* `null` when no check applies (coverage off, or a `custom`/unknown provider
|