Skip to content

Commit 95e937f

Browse files
committed
fix(migrate): protect Oxc references and recover interrupted migrations
1 parent 5973b90 commit 95e937f

114 files changed

Lines changed: 5217 additions & 26 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.typos.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ PUNICODE = "PUNICODE"
99
Jod = "Jod" # Node.js v22 LTS codename
1010
flate = "flate" # flate2 crate name (gzip/deflate compression)
1111
fpr = "fpr" # GPG colon-format record name for a key fingerprint
12+
sigle = "sigle" # Ecosystem repository name used in migration regression fixtures
1213

1314
[default.extend-identifiers]
1415
# Yarn Plug'n'Play — tokenizer splits `PnP` into the word `Pn`, which typos
1516
# otherwise wants to autocorrect to `On`. Whitelist the full identifier so
1617
# the parts aren't tokenized.
1718
PnP = "PnP"
19+
# Tests pass an attached config path: `-c` followed by `custom.json`.
20+
ccustom = "ccustom"
1821

1922
[files]
2023
extend-exclude = [

‎crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_monorepo_local_template_shorthand/snapshots.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ vp = "local"
44
steps = [
55
{ argv = ["vp", "create", "starter", "--no-interactive", "--no-agent", "--", "--directory", "my-app"], comment = "run the local create.templates entry; generated pkg declares fmt/lint via shorthand", continue-on-failure = true },
66
{ argv = ["vpt", "print-file", "packages/my-app/vite.config.ts"], comment = "fmt/lint stay shorthand only, no injected duplicate inline fmt:/lint: blocks (#1836)", continue-on-failure = true },
7-
{ argv = ["vpt", "stat-file", "packages/my-app/.oxlintrc.json", "--assert-not", "file"], comment = "standalone lint config merge-skipped and removed", continue-on-failure = true },
8-
{ argv = ["vpt", "stat-file", "packages/my-app/.oxfmtrc.json", "--assert-not", "file"], comment = "standalone fmt config merge-skipped and removed", continue-on-failure = true },
7+
{ argv = ["vpt", "stat-file", "packages/my-app/.oxlintrc.json", "--assert", "file"], comment = "standalone lint config preserved", continue-on-failure = true },
8+
{ argv = ["vpt", "stat-file", "packages/my-app/.oxfmtrc.json", "--assert", "file"], comment = "standalone fmt config preserved", continue-on-failure = true },
99
]

‎crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/create_monorepo_local_template_shorthand/snapshots/create_monorepo_local_template_shorthand.md‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ run the local create.templates entry; generated pkg declares fmt/lint via shorth
99
● Running: node <workspace>/packages/starter-template/bin/index.mjs --directory my-app
1010
cloned starter-template to my-app
1111
◇ Monorepo integration...
12-
● lint config already present in packages/my-app/vite.config.ts — removed redundant packages/my-app/.oxlintrc.json
13-
● fmt config already present in packages/my-app/vite.config.ts — removed redundant packages/my-app/.oxfmtrc.json
1412
● Formatting code...
1513
● Code formatted
1614
◇ Scaffolded packages/my-app
@@ -37,18 +35,18 @@ export default defineConfig(({ mode }) => {
3735
});
3836
```
3937

40-
## `vpt stat-file packages/my-app/.oxlintrc.json --assert-not file`
38+
## `vpt stat-file packages/my-app/.oxlintrc.json --assert file`
4139

42-
standalone lint config merge-skipped and removed
40+
standalone lint config preserved
4341

4442
```
45-
packages/my-app/.oxlintrc.json: missing
43+
packages/my-app/.oxlintrc.json: file
4644
```
4745

48-
## `vpt stat-file packages/my-app/.oxfmtrc.json --assert-not file`
46+
## `vpt stat-file packages/my-app/.oxfmtrc.json --assert file`
4947

50-
standalone fmt config merge-skipped and removed
48+
standalone fmt config preserved
5149

5250
```
53-
packages/my-app/.oxfmtrc.json: missing
51+
packages/my-app/.oxfmtrc.json: file
5452
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "migration-existing-oxc-configs",
3+
"private": true,
4+
"type": "module",
5+
"packageManager": "pnpm@12.3.4",
6+
"devDependencies": {
7+
"vite-plus": "latest"
8+
}
9+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
[[case]]
2+
name = "migration_existing_oxc_configs"
3+
vp = "global"
4+
steps = [
5+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "finish a leftover Oxfmt config even when Vite+ is already installed" },
6+
["vpt", "print-file", "vite.config.ts"],
7+
["vpt", "stat-file", ".oxfmtrc.json", "--assert-not", "file"],
8+
{ argv = ["vp", "fmt", "src/index.ts"], comment = "the migrated options must affect formatting" },
9+
["vpt", "print-file", "src/index.ts"],
10+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "a completed migration should be a no-op on retry" },
11+
["vpt", "print-file", "vite.config.ts"],
12+
["vpt", "stat-file", "AGENTS.md", "--assert-not", "file"],
13+
["vpt", "stat-file", ".vite-hooks", "--assert-not", "dir"],
14+
["vpt", "stat-file", ".vscode", "--assert-not", "dir"],
15+
]
16+
17+
[[case]]
18+
name = "migration_existing_oxc_configs_unreferenced_lint"
19+
vp = "global"
20+
steps = [
21+
{ argv = ["vpt", "write-file", ".oxlintrc.json", "{\"rules\":{\"no-console\":\"error\"},\"options\":{\"typeAware\":false,\"typeCheck\":false}}\n"], snapshot = false },
22+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "finish both unreferenced Oxc configs in a project that already uses Vite+" },
23+
["vpt", "stat-file", ".oxlintrc.json", "--assert-not", "file"],
24+
["vpt", "stat-file", ".oxfmtrc.json", "--assert-not", "file"],
25+
["vpt", "print-file", "vite.config.ts"],
26+
["vp", "fmt", "src/index.ts"],
27+
["vpt", "print-file", "src/index.ts"],
28+
["vp", "lint", "src/index.ts"],
29+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "the restored finalization must remain a no-op on retry" },
30+
["vpt", "print-file", "vite.config.ts"],
31+
["vp", "fmt", "--check", "src/index.ts"],
32+
{ argv = ["vpt", "write-file", "src/index.ts", "console.log('hello')\n"], snapshot = false },
33+
{ argv = ["vp", "lint", "src/index.ts"], comment = "the merged lint rule must apply after the JSON config is removed", continue-on-failure = true },
34+
]
35+
36+
[[case]]
37+
name = "migration_existing_oxc_configs_inline_fmt"
38+
vp = "global"
39+
steps = [
40+
{ argv = ["vpt", "write-file", "vite.config.ts", "export default { fmt: { singleQuote: false, semi: false } };\n"], snapshot = false },
41+
{ argv = ["vp", "fmt", "src/index.ts"], comment = "the existing inline fmt config takes precedence over the standalone config" },
42+
["vpt", "print-file", "src/index.ts"],
43+
{ argv = ["vpt", "write-file", "src/index.ts", "export const message = \"preserved\";\n"], snapshot = false },
44+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "keep the standalone config when fmt is already configured" },
45+
["vpt", "print-file", "vite.config.ts"],
46+
["vpt", "stat-file", ".oxfmtrc.json", "--assert", "file"],
47+
{ argv = ["vp", "fmt", "src/index.ts"], comment = "formatting must still use the existing inline options after migration" },
48+
["vpt", "print-file", "src/index.ts"],
49+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "retrying the completed migration should be a no-op" },
50+
["vpt", "print-file", "vite.config.ts"],
51+
]
52+
53+
[[case]]
54+
name = "migration_existing_oxc_configs_imported"
55+
vp = "global"
56+
steps = [
57+
{ argv = ["vpt", "write-file", "vite.config.ts", "import fmt from './.oxfmtrc.json' with { type: 'json' };\nimport { readFileSync } from 'node:fs';\nconst lint = JSON.parse(readFileSync(new URL('./.oxlintrc.json', import.meta.url), 'utf8'));\nexport default { fmt, lint };\n"], snapshot = false },
58+
{ argv = ["vpt", "write-file", ".oxlintrc.json", "{\"rules\":{\"no-debugger\":\"error\"}}\n"], snapshot = false },
59+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "preserve JSON configs loaded with imports and readFileSync" },
60+
["vpt", "print-file", ".oxfmtrc.json"],
61+
["vpt", "print-file", ".oxlintrc.json"],
62+
["vp", "fmt", "src/index.ts"],
63+
["vpt", "print-file", "src/index.ts"],
64+
["vp", "lint", "src/index.ts"],
65+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "retry preserves both imported configs" },
66+
["vp", "fmt", "--check", "src/index.ts"],
67+
["vp", "lint", "src/index.ts"],
68+
]
69+
70+
[[case]]
71+
name = "migration_existing_oxc_configs_script"
72+
vp = "global"
73+
steps = [
74+
{ argv = ["vpt", "json-edit", "package.json", "scripts.fmt", "vp fmt -c .oxfmtrc.json src/index.ts"], snapshot = false },
75+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "preserve the config passed explicitly by a package script" },
76+
["vpt", "stat-file", ".oxfmtrc.json", "--assert", "file"],
77+
["vpt", "print-file", "vite.config.ts"],
78+
["vp", "run", "fmt"],
79+
["vpt", "print-file", "src/index.ts"],
80+
]
81+
82+
[[case]]
83+
name = "migration_existing_oxc_configs_extends"
84+
vp = ["global", "local"]
85+
steps = [
86+
{ argv = ["vpt", "write-file", ".oxlintrc.json", '{"extends":["./lint-base.json"]}'], snapshot = false },
87+
{ argv = ["vpt", "write-file", "lint-base.json", '{"rules":{"no-console":"error"},"options":{"typeAware":false,"typeCheck":false}}'], snapshot = false },
88+
{ argv = ["vpt", "write-file", "src/index.ts", "console.log('hello');\n"], snapshot = false },
89+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "recover an interrupted inheritance migration using shared TypeScript configs" },
90+
["vpt", "stat-file", ".oxlintrc.json", "--assert", "missing"],
91+
["vpt", "print-file", "vite.config.ts"],
92+
["vpt", "print-file", "lint-base.ts"],
93+
{ argv = ["vp", "lint", "src/index.ts"], comment = "plain lint must enforce the inherited no-console error", continue-on-failure = true },
94+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], continue-on-failure = true },
95+
["vpt", "print-file", "vite.config.ts"],
96+
{ argv = ["vp", "lint", "src/index.ts"], comment = "a second migration must preserve the inherited error", continue-on-failure = true },
97+
]
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# migration_existing_oxc_configs
2+
3+
## `vp migrate --no-interactive --no-hooks --no-agent --no-editor`
4+
5+
finish a leftover Oxfmt config even when Vite+ is already installed
6+
7+
```
8+
VITE+ - The Unified Toolchain for the Web
9+
10+
◇ Updated . to Vite+ <version>
11+
• Node <version> pnpm <version>
12+
• Dependencies:
13+
vite-plus latest → <version>
14+
vite → <version>
15+
• 1 config update applied
16+
• Package manager settings configured
17+
```
18+
19+
## `vpt print-file vite.config.ts`
20+
21+
```
22+
export default {
23+
fmt: {
24+
"singleQuote": true,
25+
"semi": false
26+
},
27+
28+
}
29+
```
30+
31+
## `vpt stat-file .oxfmtrc.json --assert-not file`
32+
33+
```
34+
.oxfmtrc.json: missing
35+
```
36+
37+
## `vp fmt src/index.ts`
38+
39+
the migrated options must affect formatting
40+
41+
```
42+
VITE+ - The Unified Toolchain for the Web
43+
44+
Finished in <duration> on 1 files using <n> threads.
45+
```
46+
47+
## `vpt print-file src/index.ts`
48+
49+
```
50+
export const message = 'preserved'
51+
```
52+
53+
## `vp migrate --no-interactive --no-hooks --no-agent --no-editor`
54+
55+
a completed migration should be a no-op on retry
56+
57+
```
58+
VITE+ - The Unified Toolchain for the Web
59+
60+
This project is already using Vite+! Happy coding!
61+
```
62+
63+
## `vpt print-file vite.config.ts`
64+
65+
```
66+
export default {
67+
fmt: {
68+
"singleQuote": true,
69+
"semi": false
70+
},
71+
72+
}
73+
```
74+
75+
## `vpt stat-file AGENTS.md --assert-not file`
76+
77+
```
78+
AGENTS.md: missing
79+
```
80+
81+
## `vpt stat-file .vite-hooks --assert-not dir`
82+
83+
```
84+
.vite-hooks: missing
85+
```
86+
87+
## `vpt stat-file .vscode --assert-not dir`
88+
89+
```
90+
.vscode: missing
91+
```

0 commit comments

Comments
 (0)