Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -43,9 +44,16 @@ 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 },
rules: {
"no-console": ["error", { allow: ["error"] }],
"typescript/no-non-null-assertion": "off",
"vite-plus/prefer-vite-plus-imports": "error",
},
},
run: {
cache: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -25,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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ check package.json
"prepare": "vp config"
},
"devDependencies": {
"@cloudflare/oxlint-config": "^0.2.0",
"vite-plus": "catalog:"
},
"devEngines": {
Expand All @@ -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({
Expand All @@ -64,16 +66,40 @@ 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 },
rules: {
"no-console": ["error", { allow: ["error"] }],
"typescript/no-non-null-assertion": "off",
"vite-plus/prefer-vite-plus-imports": "error",
},
},
run: {
cache: true,
},
});
```

## `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
Expand Down Expand Up @@ -271,9 +297,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`
Expand All @@ -284,6 +310,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
Expand Down Expand Up @@ -408,6 +439,7 @@ check package.json
"prepare": "vp config"
},
"devDependencies": {
"@cloudflare/oxlint-config": "^0.2.0",
"vite-plus": "catalog:"
},
"devEngines": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ check package.json with catalog
"prepare": "vp config"
},
"devDependencies": {
"@cloudflare/oxlint-config": "^0.2.0",
"vite": "catalog:",
"vite-plus": "catalog:"
},
Expand Down
9 changes: 8 additions & 1 deletion crates/vp_cli_snapshots/tests/cli_snapshots/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
"vitest": "catalog:"
},
"devDependencies": {
"@cloudflare/oxlint-config": "catalog:",
"@emnapi/core": "catalog:",
"@emnapi/runtime": "catalog:",
"@napi-rs/cli": "catalog:",
Expand Down
10 changes: 9 additions & 1 deletion packages/cli/src/create/templates/monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
});

Expand Down
3 changes: 3 additions & 0 deletions packages/cli/templates/monorepo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"ready": "vp check && vp run -r test && vp run -r build",
"dev": "vp run website#dev"
},
"devDependencies": {
"@cloudflare/oxlint-config": "^0.2.0"
},
"engines": {
"node": ">=22.18.0"
}
Expand Down
13 changes: 13 additions & 0 deletions packages/cli/templates/monorepo/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
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: {
'no-console': ['error', { allow: ['error'] }],
'typescript/no-non-null-assertion': 'off',
'vite-plus/prefer-vite-plus-imports': 'error',
},
},
run: {
cache: true,
},
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading