From df562e70b246d01bac681023859a39dda7a4ca16 Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 22 Nov 2026 22:25:31 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat(create):=20use=20Cloudflare=E2=80=99s?= =?UTF-8?q?=20Oxlint=20preset=20in=20new=20monorepos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../snapshots/create_missing_typecheck.md | 13 +++++++- .../fixtures/new_vite_monorepo/snapshots.toml | 2 ++ .../snapshots/new_vite_monorepo.md | 32 ++++++++++++++++++- .../snapshots/new_vite_monorepo_bun.md | 1 + .../tests/cli_snapshots/main.rs | 9 +++++- packages/cli/package.json | 1 + packages/cli/templates/monorepo/package.json | 3 ++ .../cli/templates/monorepo/vite.config.ts | 16 ++++++++++ pnpm-lock.yaml | 3 ++ 9 files changed, 77 insertions(+), 3 deletions(-) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md index adbba82220..febd0b9a6d 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md @@ -35,6 +35,7 @@ create monorepo check monorepo root vite.config.ts has typeAware and typeCheck ``` +import cloudflare from "@cloudflare/oxlint-config/vite-plus"; import { defineConfig } from "vite-plus"; export default defineConfig({ @@ -43,9 +44,19 @@ export default defineConfig({ }, fmt: {}, lint: { + extends: [cloudflare], + env: cloudflare.env, + ignorePatterns: cloudflare.ignorePatterns, + options: { typeCheck: true }, jsPlugins: [{ name: "vite-plus", specifier: "vite-plus/oxlint-plugin" }], rules: { "vite-plus/prefer-vite-plus-imports": "error" }, - options: { typeAware: true, typeCheck: true }, + overrides: [ + { + // The create-vite demo asserts that its two DOM elements exist. + files: ["apps/website/src/main.ts"], + rules: { "typescript/no-non-null-assertion": "off" }, + }, + ], }, run: { cache: true, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots.toml index 7ddb799a7c..ff5e618846 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots.toml @@ -8,6 +8,8 @@ steps = [ { argv = ["vpt", "list-dir", "vite-plus-monorepo"], comment = "check files created", continue-on-failure = true }, { argv = ["vpt", "print-file", "vite-plus-monorepo/package.json"], comment = "check package.json", continue-on-failure = true }, { argv = ["vpt", "print-file", "vite-plus-monorepo/vite.config.ts"], comment = "check vite config has cache enabled", continue-on-failure = true }, + { argv = ["vpt", "write-file", "vite-plus-monorepo/equality.js", "export const isMissing = (value) => value == null;"], snapshot = false }, + { argv = ["vp", "lint", "--format", "unix", "equality.js"], cwd = "vite-plus-monorepo", comment = "the Cloudflare preset rejects loose equality with null", continue-on-failure = true }, { argv = ["vpt", "print-file", "vite-plus-monorepo/pnpm-workspace.yaml"], comment = "check workspace config", continue-on-failure = true }, { argv = ["vpt", "stat-file", "vite-plus-monorepo/.gitignore", "--assert", "file"], comment = "verify gitignore renamed from _gitignore", continue-on-failure = true }, { argv = ["vpt", "stat-file", "vite-plus-monorepo/.yarnrc.yml", "--assert-not", "file"], comment = "verify no yarn config for pnpm", continue-on-failure = true }, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md index 69c94fd352..a75e9218d0 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md @@ -36,6 +36,7 @@ check package.json "prepare": "vp config" }, "devDependencies": { + "@cloudflare/oxlint-config": "https://github.com/cloudflare/oxlint-config/archive/d6b32c7a334d6215a3eddc92f4d856a724f054ab.tar.gz", "vite-plus": "catalog:" }, "devEngines": { @@ -56,6 +57,7 @@ check package.json check vite config has cache enabled ``` +import cloudflare from "@cloudflare/oxlint-config/vite-plus"; import { defineConfig } from "vite-plus"; export default defineConfig({ @@ -64,9 +66,19 @@ export default defineConfig({ }, fmt: {}, lint: { + extends: [cloudflare], + env: cloudflare.env, + ignorePatterns: cloudflare.ignorePatterns, + options: { typeCheck: true }, jsPlugins: [{ name: "vite-plus", specifier: "vite-plus/oxlint-plugin" }], rules: { "vite-plus/prefer-vite-plus-imports": "error" }, - options: { typeAware: true, typeCheck: true }, + overrides: [ + { + // The create-vite demo asserts that its two DOM elements exist. + files: ["apps/website/src/main.ts"], + rules: { "typescript/no-non-null-assertion": "off" }, + }, + ], }, run: { cache: true, @@ -74,6 +86,23 @@ export default defineConfig({ }); ``` +## `vpt write-file vite-plus-monorepo/equality.js 'export const isMissing = (value) => value == null;'` + + +## `cd vite-plus-monorepo && vp lint --format unix equality.js` + +the Cloudflare preset rejects loose equality with null + +**Exit code:** 1 + +``` +VITE+ - The Unified Toolchain for the Web + +equality.js:1:43: Expected === and instead saw == [Error/eslint(eqeqeq)] + +1 problem +``` + ## `vpt print-file vite-plus-monorepo/pnpm-workspace.yaml` check workspace config @@ -408,6 +437,7 @@ check package.json "prepare": "vp config" }, "devDependencies": { + "@cloudflare/oxlint-config": "https://github.com/cloudflare/oxlint-config/archive/d6b32c7a334d6215a3eddc92f4d856a724f054ab.tar.gz", "vite-plus": "catalog:" }, "devEngines": { diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo_bun/snapshots/new_vite_monorepo_bun.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo_bun/snapshots/new_vite_monorepo_bun.md index 44f28f460d..d6ae61c24c 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo_bun/snapshots/new_vite_monorepo_bun.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo_bun/snapshots/new_vite_monorepo_bun.md @@ -40,6 +40,7 @@ check package.json with catalog "prepare": "vp config" }, "devDependencies": { + "@cloudflare/oxlint-config": "https://github.com/cloudflare/oxlint-config/archive/d6b32c7a334d6215a3eddc92f4d856a724f054ab.tar.gz", "vite": "catalog:", "vite-plus": "catalog:" }, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/main.rs b/crates/vp_cli_snapshots/tests/cli_snapshots/main.rs index 292fd28c79..03174ce14a 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/main.rs +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/main.rs @@ -1798,7 +1798,7 @@ fn main() { // configs resolve to the checkout packages via Node's upward walk (the // staged workspaces have no node_modules of their own); the linked // packages' own dependencies then resolve at their real location. - // Anything else a fixture imports must be vendored inside the fixture. + // Vendor any additional fixture-specific dependencies inside the fixture. { let repo_root = flavor::repo_root(); let node_modules = tmp_dir_path.join("node_modules"); @@ -1809,6 +1809,13 @@ fn main() { // `vite` resolves to the core package, matching the vite -> core // override installed in migrated projects. flavor::link_dir(&repo_root.join("packages/core"), &node_modules.join("vite")); + // Monorepo creation formats the generated config even when fixtures skip installation. + let cloudflare = node_modules.join("@cloudflare"); + std::fs::create_dir_all(&cloudflare).unwrap(); + flavor::link_dir( + &repo_root.join("packages/cli/node_modules/@cloudflare/oxlint-config"), + &cloudflare.join("oxlint-config"), + ); } let fixtures_dir = flavor::manifest_dir().join("tests/cli_snapshots/fixtures"); diff --git a/packages/cli/package.json b/packages/cli/package.json index eccba3487a..e787b7d9ef 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -369,6 +369,7 @@ "vitest": "catalog:" }, "devDependencies": { + "@cloudflare/oxlint-config": "catalog:", "@emnapi/core": "catalog:", "@emnapi/runtime": "catalog:", "@napi-rs/cli": "catalog:", diff --git a/packages/cli/templates/monorepo/package.json b/packages/cli/templates/monorepo/package.json index e55475eb17..9e4c5b1442 100644 --- a/packages/cli/templates/monorepo/package.json +++ b/packages/cli/templates/monorepo/package.json @@ -12,6 +12,9 @@ "ready": "vp check && vp run -r test && vp run -r build", "dev": "vp run website#dev" }, + "devDependencies": { + "@cloudflare/oxlint-config": "https://github.com/cloudflare/oxlint-config/archive/d6b32c7a334d6215a3eddc92f4d856a724f054ab.tar.gz" + }, "engines": { "node": ">=22.18.0" } diff --git a/packages/cli/templates/monorepo/vite.config.ts b/packages/cli/templates/monorepo/vite.config.ts index ad49909606..19aa9cf2c3 100644 --- a/packages/cli/templates/monorepo/vite.config.ts +++ b/packages/cli/templates/monorepo/vite.config.ts @@ -1,6 +1,22 @@ +import cloudflare from '@cloudflare/oxlint-config/vite-plus'; import { defineConfig } from 'vite-plus'; export default defineConfig({ + lint: { + extends: [cloudflare], + env: cloudflare.env, + ignorePatterns: cloudflare.ignorePatterns, + options: { typeCheck: true }, + jsPlugins: [{ name: 'vite-plus', specifier: 'vite-plus/oxlint-plugin' }], + rules: { 'vite-plus/prefer-vite-plus-imports': 'error' }, + overrides: [ + { + // The create-vite demo asserts that its two DOM elements exist. + files: ['apps/website/src/main.ts'], + rules: { 'typescript/no-non-null-assertion': 'off' }, + }, + ], + }, run: { cache: true, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b02b21028b..87e38c7c59 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -483,6 +483,9 @@ importers: specifier: 'catalog:' version: 5.1.1(@edge-runtime/vm@5.0.0)(@opentelemetry/api@1.9.0)(@types/node@24.10.3)(@vitest/browser-playwright@5.1.1)(@vitest/browser-preview@5.1.1)(@vitest/browser-webdriverio@5.0.0)(@vitest/ui@5.1.1)(happy-dom@20.0.10)(jsdom@27.2.0(supports-color@8.1.1))(vite@packages+core) devDependencies: + '@cloudflare/oxlint-config': + specifier: 'catalog:' + version: 0.2.0(eslint@9.39.5(jiti@2.7.0)(supports-color@8.1.1))(oxlint@1.95.0(vite-plus@packages+cli))(tsrs@7.1.0-beta.tsrs5)(vite-plus@packages+cli) '@emnapi/core': specifier: 'catalog:' version: 2.0.0-beta.2 From 2022aa79cabee5e3b3269d1186c894da9d1bc8ba Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 23 Nov 2026 18:11:27 +0800 Subject: [PATCH 2/6] deps(create): use the published Cloudflare Oxlint preset --- .../fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md | 4 ++-- .../new_vite_monorepo_bun/snapshots/new_vite_monorepo_bun.md | 2 +- packages/cli/templates/monorepo/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md index a75e9218d0..7e0db6088b 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md @@ -36,7 +36,7 @@ check package.json "prepare": "vp config" }, "devDependencies": { - "@cloudflare/oxlint-config": "https://github.com/cloudflare/oxlint-config/archive/d6b32c7a334d6215a3eddc92f4d856a724f054ab.tar.gz", + "@cloudflare/oxlint-config": "^0.2.0", "vite-plus": "catalog:" }, "devEngines": { @@ -437,7 +437,7 @@ check package.json "prepare": "vp config" }, "devDependencies": { - "@cloudflare/oxlint-config": "https://github.com/cloudflare/oxlint-config/archive/d6b32c7a334d6215a3eddc92f4d856a724f054ab.tar.gz", + "@cloudflare/oxlint-config": "^0.2.0", "vite-plus": "catalog:" }, "devEngines": { diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo_bun/snapshots/new_vite_monorepo_bun.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo_bun/snapshots/new_vite_monorepo_bun.md index d6ae61c24c..a36289ab0d 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo_bun/snapshots/new_vite_monorepo_bun.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo_bun/snapshots/new_vite_monorepo_bun.md @@ -40,7 +40,7 @@ check package.json with catalog "prepare": "vp config" }, "devDependencies": { - "@cloudflare/oxlint-config": "https://github.com/cloudflare/oxlint-config/archive/d6b32c7a334d6215a3eddc92f4d856a724f054ab.tar.gz", + "@cloudflare/oxlint-config": "^0.2.0", "vite": "catalog:", "vite-plus": "catalog:" }, diff --git a/packages/cli/templates/monorepo/package.json b/packages/cli/templates/monorepo/package.json index 9e4c5b1442..9e9e5486ee 100644 --- a/packages/cli/templates/monorepo/package.json +++ b/packages/cli/templates/monorepo/package.json @@ -13,7 +13,7 @@ "dev": "vp run website#dev" }, "devDependencies": { - "@cloudflare/oxlint-config": "https://github.com/cloudflare/oxlint-config/archive/d6b32c7a334d6215a3eddc92f4d856a724f054ab.tar.gz" + "@cloudflare/oxlint-config": "^0.2.0" }, "engines": { "node": ">=22.18.0" From e15819feb0d9f646fb82ec805ceb641dd1275e98 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 24 Nov 2026 17:14:25 +0800 Subject: [PATCH 3/6] fix(create): support npm preview builds and lint new workspace members --- .../snapshots/create_missing_typecheck.md | 4 ++-- .../fixtures/new_vite_monorepo/snapshots.toml | 3 ++- .../snapshots/new_vite_monorepo.md | 13 +++++++++---- packages/cli/src/create/templates/monorepo.ts | 10 +++++++++- packages/cli/templates/generator/bin/index.ts | 3 ++- packages/cli/templates/monorepo/vite.config.ts | 4 ++-- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md index febd0b9a6d..4a0dfa7ecb 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md @@ -52,8 +52,8 @@ export default defineConfig({ rules: { "vite-plus/prefer-vite-plus-imports": "error" }, overrides: [ { - // The create-vite demo asserts that its two DOM elements exist. - files: ["apps/website/src/main.ts"], + // create-vite's vanilla-ts entry point asserts that its two DOM elements exist. + files: ["**/*/src/main.ts"], rules: { "typescript/no-non-null-assertion": "off" }, }, ], diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots.toml index ff5e618846..bb3b3dea50 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots.toml @@ -27,8 +27,9 @@ steps = [ { argv = ["vpt", "list-dir", "vite-plus-monorepo/apps"], comment = "check apps directory created", continue-on-failure = true }, { argv = ["vpt", "list-dir", "vite-plus-monorepo/apps/vite-plus-application/package.json"], comment = "check vite-plus-application package.json", continue-on-failure = true }, { argv = ["vpt", "stat-file", "vite-plus-monorepo/apps/vite-plus-application/.vscode", "--assert", "missing"], comment = "monorepo package create without --editor should not write VS Code config", continue-on-failure = true }, - { argv = ["vp", "create", "--no-interactive", "vite:application", "--directory", "apps/no-editor", "--no-editor"], cwd = "vite-plus-monorepo", comment = "create application with explicit editor opt-out inside monorepo", snapshot = false, continue-on-failure = true }, + { argv = ["vp", "create", "--no-interactive", "vite:application", "--directory", "apps/no-editor", "--no-editor", "--", "--template", "vanilla-ts"], cwd = "vite-plus-monorepo", comment = "create a vanilla-ts application with explicit editor opt-out inside monorepo", snapshot = false, continue-on-failure = true }, { argv = ["vpt", "stat-file", "vite-plus-monorepo/apps/no-editor/.vscode", "--assert", "missing"], comment = "--no-editor should not write VS Code config", continue-on-failure = true }, + { argv = ["vp", "lint", "--format", "unix", "apps/no-editor/src/main.ts"], cwd = "vite-plus-monorepo", comment = "the additional vanilla-ts app passes the workspace lint rules", snapshot = false }, { argv = ["vp", "create", "--no-interactive", "vite:application", "--directory", "apps/editor-opt-in", "--editor", "vscode"], cwd = "vite-plus-monorepo", comment = "create application with explicit editor opt-in inside monorepo", snapshot = false, continue-on-failure = true }, { argv = ["vpt", "stat-file", "vite-plus-monorepo/apps/editor-opt-in/.vscode/settings.json", "--assert", "file"], comment = "explicit --editor should write VS Code settings", continue-on-failure = true }, { argv = ["vpt", "stat-file", "vite-plus-monorepo/apps/editor-opt-in/.vscode/extensions.json", "--assert", "file"], comment = "explicit --editor should write VS Code extensions", continue-on-failure = true }, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md index 7e0db6088b..0ce603901c 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md @@ -74,8 +74,8 @@ export default defineConfig({ rules: { "vite-plus/prefer-vite-plus-imports": "error" }, overrides: [ { - // The create-vite demo asserts that its two DOM elements exist. - files: ["apps/website/src/main.ts"], + // create-vite's vanilla-ts entry point asserts that its two DOM elements exist. + files: ["**/*/src/main.ts"], rules: { "typescript/no-non-null-assertion": "off" }, }, ], @@ -300,9 +300,9 @@ monorepo package create without --editor should not write VS Code config vite-plus-monorepo/apps/vite-plus-application/.vscode: missing ``` -## `cd vite-plus-monorepo && vp create --no-interactive vite:application --directory apps/no-editor --no-editor` +## `cd vite-plus-monorepo && vp create --no-interactive vite:application --directory apps/no-editor --no-editor -- --template vanilla-ts` -create application with explicit editor opt-out inside monorepo +create a vanilla-ts application with explicit editor opt-out inside monorepo ## `vpt stat-file vite-plus-monorepo/apps/no-editor/.vscode --assert missing` @@ -313,6 +313,11 @@ create application with explicit editor opt-out inside monorepo vite-plus-monorepo/apps/no-editor/.vscode: missing ``` +## `cd vite-plus-monorepo && vp lint --format unix apps/no-editor/src/main.ts` + +the additional vanilla-ts app passes the workspace lint rules + + ## `cd vite-plus-monorepo && vp create --no-interactive vite:application --directory apps/editor-opt-in --editor vscode` create application with explicit editor opt-in inside monorepo diff --git a/packages/cli/src/create/templates/monorepo.ts b/packages/cli/src/create/templates/monorepo.ts index a0e5035d1a..8a69a47be5 100644 --- a/packages/cli/src/create/templates/monorepo.ts +++ b/packages/cli/src/create/templates/monorepo.ts @@ -8,11 +8,13 @@ import { removeConfigKey } from '../../../binding/index.js'; import { rewriteMonorepoProject, supportsCatalog } from '../../migration/migrator.ts'; import type { WorkspaceInfo } from '../../types/index.ts'; import { PackageManager } from '../../types/index.ts'; +import { VITE_PLUS_VERSION } from '../../utils/constants.ts'; import type { JsonObject } from '../../utils/json-value.ts'; import { isObjectValue } from '../../utils/json-value.ts'; import { editJsonFile, readJsonFile } from '../../utils/json.ts'; import { getScopeFromPackageName } from '../../utils/package.ts'; import { templatesDir } from '../../utils/path.ts'; +import { isPreviewVitePlusVersion } from '../../utils/preview-registry.ts'; import { editYamlFile, readYamlFile } from '../../utils/yaml.ts'; import type { ExecutionWithProjectDir } from '../command.ts'; import { discoverTemplate } from '../discovery.ts'; @@ -45,9 +47,15 @@ export async function executeMonorepoTemplate( copyDir(templateDir, fullPath); renameFiles(fullPath); - // set project name editJsonFile(path.join(fullPath, 'package.json'), (pkg) => { pkg.name = templateInfo.packageName; + if ( + workspaceInfo.packageManager === PackageManager.npm && + (VITE_PLUS_VERSION === '0.0.0' || isPreviewVitePlusVersion(VITE_PLUS_VERSION)) + ) { + // npm checks the preset's optional Vite+ peer against the CI or preview version. + pkg.overrides = { '@cloudflare/oxlint-config': { 'vite-plus': '$vite-plus' } }; + } return pkg; }); diff --git a/packages/cli/templates/generator/bin/index.ts b/packages/cli/templates/generator/bin/index.ts index 111b3462f1..5223296bf4 100755 --- a/packages/cli/templates/generator/bin/index.ts +++ b/packages/cli/templates/generator/bin/index.ts @@ -54,6 +54,7 @@ async function main() { try { process.exitCode = await main(); } catch (error) { - console.error(error instanceof Error ? error.message : String(error)); + const message = error instanceof Error ? error.message : String(error); + process.stderr.write(`${message}\n`); process.exitCode = 1; } diff --git a/packages/cli/templates/monorepo/vite.config.ts b/packages/cli/templates/monorepo/vite.config.ts index 19aa9cf2c3..15eb31e44a 100644 --- a/packages/cli/templates/monorepo/vite.config.ts +++ b/packages/cli/templates/monorepo/vite.config.ts @@ -11,8 +11,8 @@ export default defineConfig({ rules: { 'vite-plus/prefer-vite-plus-imports': 'error' }, overrides: [ { - // The create-vite demo asserts that its two DOM elements exist. - files: ['apps/website/src/main.ts'], + // create-vite's vanilla-ts entry point asserts that its two DOM elements exist. + files: ['**/*/src/main.ts'], rules: { 'typescript/no-non-null-assertion': 'off' }, }, ], From a9c0f932852d3fb450a2c823249fce31d9c83721 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 24 Nov 2026 23:32:03 +0800 Subject: [PATCH 4/6] test(cli): skip the flaky build profile snapshot on macOS --- .../fixtures/command_build_vite_flags/snapshots.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_build_vite_flags/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_build_vite_flags/snapshots.toml index 0be4fd1d5e..af3d36e2bb 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_build_vite_flags/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_build_vite_flags/snapshots.toml @@ -11,6 +11,8 @@ steps = [ [[case]] name = "command_build_profile" vp = "local" +# `vp build --profile` intermittently times out after 120s on macOS CI. +skip-platforms = ["macos"] steps = [ { argv = ["vp", "build", "--profile"], comment = "--profile records a CPU profile of the build" }, { argv = ["vpt", "stat-file", "vite-profile-0.cpuprofile", "--assert", "file"], comment = "the profile is written to the project root" }, From 92b00af193c1df7ba86c77ba82c13d5c7471bd1b Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Nov 2026 09:58:27 +0800 Subject: [PATCH 5/6] fix(create): allow non-null assertions by default in new monorepos --- .../snapshots/create_missing_typecheck.md | 12 ++++-------- .../new_vite_monorepo/snapshots/new_vite_monorepo.md | 12 ++++-------- packages/cli/templates/monorepo/vite.config.ts | 12 ++++-------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md index 4a0dfa7ecb..ea22706aaf 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md @@ -49,14 +49,10 @@ export default defineConfig({ ignorePatterns: cloudflare.ignorePatterns, options: { typeCheck: true }, jsPlugins: [{ name: "vite-plus", specifier: "vite-plus/oxlint-plugin" }], - rules: { "vite-plus/prefer-vite-plus-imports": "error" }, - overrides: [ - { - // create-vite's vanilla-ts entry point asserts that its two DOM elements exist. - files: ["**/*/src/main.ts"], - rules: { "typescript/no-non-null-assertion": "off" }, - }, - ], + rules: { + "typescript/no-non-null-assertion": "off", + "vite-plus/prefer-vite-plus-imports": "error", + }, }, run: { cache: true, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md index 0ce603901c..6deb9d5d95 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md @@ -71,14 +71,10 @@ export default defineConfig({ ignorePatterns: cloudflare.ignorePatterns, options: { typeCheck: true }, jsPlugins: [{ name: "vite-plus", specifier: "vite-plus/oxlint-plugin" }], - rules: { "vite-plus/prefer-vite-plus-imports": "error" }, - overrides: [ - { - // create-vite's vanilla-ts entry point asserts that its two DOM elements exist. - files: ["**/*/src/main.ts"], - rules: { "typescript/no-non-null-assertion": "off" }, - }, - ], + rules: { + "typescript/no-non-null-assertion": "off", + "vite-plus/prefer-vite-plus-imports": "error", + }, }, run: { cache: true, diff --git a/packages/cli/templates/monorepo/vite.config.ts b/packages/cli/templates/monorepo/vite.config.ts index 15eb31e44a..cb5006f902 100644 --- a/packages/cli/templates/monorepo/vite.config.ts +++ b/packages/cli/templates/monorepo/vite.config.ts @@ -8,14 +8,10 @@ export default defineConfig({ ignorePatterns: cloudflare.ignorePatterns, options: { typeCheck: true }, jsPlugins: [{ name: 'vite-plus', specifier: 'vite-plus/oxlint-plugin' }], - rules: { 'vite-plus/prefer-vite-plus-imports': 'error' }, - overrides: [ - { - // create-vite's vanilla-ts entry point asserts that its two DOM elements exist. - files: ['**/*/src/main.ts'], - rules: { 'typescript/no-non-null-assertion': 'off' }, - }, - ], + rules: { + 'typescript/no-non-null-assertion': 'off', + 'vite-plus/prefer-vite-plus-imports': 'error', + }, }, run: { cache: true, From 13ef70d2497294118d39daa364c0a601e3e7b3cc Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Nov 2026 10:33:41 +0800 Subject: [PATCH 6/6] fix(create): allow console.error in new monorepos --- .../snapshots/create_missing_typecheck.md | 1 + .../fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md | 1 + packages/cli/templates/generator/bin/index.ts | 3 +-- packages/cli/templates/monorepo/vite.config.ts | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md index ea22706aaf..e8a27b4301 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_missing_typecheck/snapshots/create_missing_typecheck.md @@ -50,6 +50,7 @@ export default defineConfig({ options: { typeCheck: true }, jsPlugins: [{ name: "vite-plus", specifier: "vite-plus/oxlint-plugin" }], rules: { + "no-console": ["error", { allow: ["error"] }], "typescript/no-non-null-assertion": "off", "vite-plus/prefer-vite-plus-imports": "error", }, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md index 6deb9d5d95..766d5d87bb 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/new_vite_monorepo/snapshots/new_vite_monorepo.md @@ -72,6 +72,7 @@ export default defineConfig({ options: { typeCheck: true }, jsPlugins: [{ name: "vite-plus", specifier: "vite-plus/oxlint-plugin" }], rules: { + "no-console": ["error", { allow: ["error"] }], "typescript/no-non-null-assertion": "off", "vite-plus/prefer-vite-plus-imports": "error", }, diff --git a/packages/cli/templates/generator/bin/index.ts b/packages/cli/templates/generator/bin/index.ts index 5223296bf4..111b3462f1 100755 --- a/packages/cli/templates/generator/bin/index.ts +++ b/packages/cli/templates/generator/bin/index.ts @@ -54,7 +54,6 @@ async function main() { try { process.exitCode = await main(); } catch (error) { - const message = error instanceof Error ? error.message : String(error); - process.stderr.write(`${message}\n`); + console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; } diff --git a/packages/cli/templates/monorepo/vite.config.ts b/packages/cli/templates/monorepo/vite.config.ts index cb5006f902..4dac3bbf2a 100644 --- a/packages/cli/templates/monorepo/vite.config.ts +++ b/packages/cli/templates/monorepo/vite.config.ts @@ -9,6 +9,7 @@ export default defineConfig({ options: { typeCheck: true }, jsPlugins: [{ name: 'vite-plus', specifier: 'vite-plus/oxlint-plugin' }], rules: { + 'no-console': ['error', { allow: ['error'] }], 'typescript/no-non-null-assertion': 'off', 'vite-plus/prefer-vite-plus-imports': 'error', },