Skip to content

Commit a380e35

Browse files
authored
ci: upgrade oxlint/oxfmt/oxnode in upgrade-deps CI (#456)
<!-- CURSOR_SUMMARY --> > [!NOTE] > - **CI upgrade automation**: Extends `.github/scripts/upgrade-deps.mjs` to fetch and update versions for `oxfmt`, `oxlint`, `oxlint-tsgolint`, `@oxc-node/cli`, `@oxc-node/core`, plus existing `vitest`/`tsdown`; switches to top-level execution with a single `updatePnpmWorkspace({ ... })` call. > - **Dependency bumps**: Updates workspace catalog and usages to `oxfmt@^0.24.0`, `oxlint@^1.39.0`, and `oxlint-tsgolint@^0.11.1` (lockfile changes omitted here). > - **Build pipeline changes**: In `packages/cli/build.ts` and `packages/global/build.ts`, replace batch `formatEmbeddedCode` invocation with per-file `oxfmt.format(..., { embeddedCode: true })` using settings from `vite.config`; simplify fs usage. > - **Type/config updates**: > - Replace local `OxfmtConfig` with `oxfmt`'s exported `FormatOptions` and re-export types from `oxfmt`. > - Revise `oxlint-config.ts` types to align with newer oxlint schema (adds `$schema`, fixes `writable`, supports JS plugin entries, tweaks settings/docs). > - In `src/index.ts`, change `fmt?: OxfmtConfig` to `fmt?: FormatOptions`. > - **Config and docs**: Update `vite.config.ts` (rename `lint.excludePatterns` to `ignorePatterns`, tweak `fmt.experimentalSort*`), remove obsolete `vite.config.json`, and refresh CLI help snapshots to match new `fmt`/`lint` options. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c536e39. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 9ab32c5 commit a380e35

11 files changed

Lines changed: 542 additions & 959 deletions

File tree

.github/scripts/upgrade-deps.mjs

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,42 @@ async function updateUpstreamVersions() {
5656
}
5757

5858
// ============ Update pnpm-workspace.yaml ============
59-
async function updatePnpmWorkspace(vitestVersion, tsdownVersion) {
59+
async function updatePnpmWorkspace(versions) {
6060
const filePath = path.join(ROOT, 'pnpm-workspace.yaml');
6161
let content = fs.readFileSync(filePath, 'utf8');
6262

6363
// Update vitest-dev override (handle pre-release versions like -beta.1, -rc.0)
6464
content = content.replace(
6565
/vitest-dev: 'npm:vitest@\^[\d.]+(-[\w.]+)?'/,
66-
`vitest-dev: 'npm:vitest@^${vitestVersion}'`,
66+
`vitest-dev: 'npm:vitest@^${versions.vitest}'`,
6767
);
6868

6969
// Update tsdown in catalog (handle pre-release versions)
70-
content = content.replace(/tsdown: \^[\d.]+(-[\w.]+)?/, `tsdown: ^${tsdownVersion}`);
70+
content = content.replace(/tsdown: \^[\d.]+(-[\w.]+)?/, `tsdown: ^${versions.tsdown}`);
71+
72+
// Update @oxc-node/cli in catalog
73+
content = content.replace(
74+
/'@oxc-node\/cli': \^[\d.]+(-[\w.]+)?/,
75+
`'@oxc-node/cli': ^${versions.oxcNodeCli}`,
76+
);
77+
78+
// Update @oxc-node/core in catalog
79+
content = content.replace(
80+
/'@oxc-node\/core': \^[\d.]+(-[\w.]+)?/,
81+
`'@oxc-node/core': ^${versions.oxcNodeCore}`,
82+
);
83+
84+
// Update oxfmt in catalog
85+
content = content.replace(/oxfmt: \^[\d.]+(-[\w.]+)?/, `oxfmt: ^${versions.oxfmt}`);
86+
87+
// Update oxlint in catalog (but not oxlint-tsgolint)
88+
content = content.replace(/oxlint: \^[\d.]+(-[\w.]+)?\n/, `oxlint: ^${versions.oxlint}\n`);
89+
90+
// Update oxlint-tsgolint in catalog
91+
content = content.replace(
92+
/oxlint-tsgolint: \^[\d.]+(-[\w.]+)?/,
93+
`oxlint-tsgolint: ^${versions.oxlintTsgolint}`,
94+
);
7195

7296
fs.writeFileSync(filePath, content);
7397
console.log('Updated pnpm-workspace.yaml');
@@ -113,29 +137,48 @@ async function updateCorePackage(devtoolsVersion) {
113137
console.log('Updated packages/core/package.json');
114138
}
115139

116-
// ============ Main ============
117-
async function main() {
118-
console.log('Fetching latest versions...');
119-
120-
const [vitestVersion, tsdownVersion, devtoolsVersion] = await Promise.all([
121-
getLatestNpmVersion('vitest'),
122-
getLatestNpmVersion('tsdown'),
123-
getLatestNpmVersion('@vitejs/devtools'),
124-
]);
125-
126-
console.log(`vitest: ${vitestVersion}`);
127-
console.log(`tsdown: ${tsdownVersion}`);
128-
console.log(`@vitejs/devtools: ${devtoolsVersion}`);
129-
130-
await updateUpstreamVersions();
131-
await updatePnpmWorkspace(vitestVersion, tsdownVersion);
132-
await updateTestPackage(vitestVersion);
133-
await updateCorePackage(devtoolsVersion);
134-
135-
console.log('Done!');
136-
}
137-
138-
main().catch((err) => {
139-
console.error(err);
140-
process.exit(1);
140+
console.log('Fetching latest versions...');
141+
142+
const [
143+
vitestVersion,
144+
tsdownVersion,
145+
devtoolsVersion,
146+
oxcNodeCliVersion,
147+
oxcNodeCoreVersion,
148+
oxfmtVersion,
149+
oxlintVersion,
150+
oxlintTsgolintVersion,
151+
] = await Promise.all([
152+
getLatestNpmVersion('vitest'),
153+
getLatestNpmVersion('tsdown'),
154+
getLatestNpmVersion('@vitejs/devtools'),
155+
getLatestNpmVersion('@oxc-node/cli'),
156+
getLatestNpmVersion('@oxc-node/core'),
157+
getLatestNpmVersion('oxfmt'),
158+
getLatestNpmVersion('oxlint'),
159+
getLatestNpmVersion('oxlint-tsgolint'),
160+
]);
161+
162+
console.log(`vitest: ${vitestVersion}`);
163+
console.log(`tsdown: ${tsdownVersion}`);
164+
console.log(`@vitejs/devtools: ${devtoolsVersion}`);
165+
console.log(`@oxc-node/cli: ${oxcNodeCliVersion}`);
166+
console.log(`@oxc-node/core: ${oxcNodeCoreVersion}`);
167+
console.log(`oxfmt: ${oxfmtVersion}`);
168+
console.log(`oxlint: ${oxlintVersion}`);
169+
console.log(`oxlint-tsgolint: ${oxlintTsgolintVersion}`);
170+
171+
await updateUpstreamVersions();
172+
await updatePnpmWorkspace({
173+
vitest: vitestVersion,
174+
tsdown: tsdownVersion,
175+
oxcNodeCli: oxcNodeCliVersion,
176+
oxcNodeCore: oxcNodeCoreVersion,
177+
oxfmt: oxfmtVersion,
178+
oxlint: oxlintVersion,
179+
oxlintTsgolint: oxlintTsgolintVersion,
141180
});
181+
await updateTestPackage(vitestVersion);
182+
await updateCorePackage(devtoolsVersion);
183+
184+
console.log('Done!');

packages/cli/build.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
* Native binding is built first because TypeScript may depend on generated binding types.
1616
*/
1717

18-
import { existsSync, mkdirSync, readdirSync, statSync, writeFileSync } from 'node:fs';
18+
import { existsSync, readdirSync, statSync } from 'node:fs';
1919
import { copyFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
2020
import { dirname, join } from 'node:path';
2121
import { fileURLToPath } from 'node:url';
2222

2323
import { createBuildCommand, NapiCli } from '@napi-rs/cli';
24-
import { format, formatEmbeddedCode } from 'oxfmt';
24+
import { format } from 'oxfmt';
2525
import {
2626
createCompilerHost,
2727
createProgram,
@@ -79,20 +79,22 @@ async function buildNapiBinding() {
7979
});
8080

8181
const outputs = await task;
82-
const fmtConfigPath = join(projectDir, '../../node_modules/.vite/task-cache/.oxfmtrc.json');
83-
if (!existsSync(fmtConfigPath)) {
84-
const viteConfig = await import('../../vite.config');
85-
mkdirSync(dirname(fmtConfigPath), { recursive: true });
86-
writeFileSync(fmtConfigPath, JSON.stringify(viteConfig.default.fmt, null, 2));
82+
const viteConfig = await import('../../vite.config');
83+
for (const output of outputs) {
84+
if (output.kind !== 'node') {
85+
const { code, errors } = await format(output.path, await readFile(output.path, 'utf8'), {
86+
...viteConfig.default.fmt,
87+
embeddedCode: true,
88+
});
89+
if (errors.length > 0) {
90+
for (const error of errors) {
91+
console.error(error);
92+
}
93+
process.exit(1);
94+
}
95+
await writeFile(output.path, code);
96+
}
8797
}
88-
await format(
89-
[
90-
'-c',
91-
'../../node_modules/.vite/task-cache/.oxfmtrc.json',
92-
...outputs.filter((o) => o.kind !== 'node').map((o) => o.path),
93-
],
94-
formatEmbeddedCode,
95-
);
9698
}
9799

98100
async function buildCli() {

packages/cli/snap-tests/command-helper/snap.txt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,19 @@ Options:
7575
> vite fmt -h # fmt help message
7676
Usage: [-c=PATH] [PATH]...
7777

78-
Output Options
79-
--check Check mode - check if files are formatted, also show statistics
80-
--list-different List mode - list files that would be changed
78+
Mode Options:
79+
--init Initialize `.oxfmtrc.json` with default values
80+
--migrate=SOURCE Migrate configuration to `.oxfmtrc.json` from specified source
81+
Available sources: prettier
82+
--lsp Start language server protocol (LSP) server
83+
--stdin-filepath=PATH Specify the file name to use to infer which parser to use
84+
85+
Output Options:
86+
--write Format and write files in place (default)
87+
--check Check if files are formatted, also show statistics
88+
--list-different List files that would be changed
8189

82-
Basic Options
90+
Config Options
8391
-c, --config=PATH Path to the configuration file
8492

8593
Ignore Options
@@ -88,8 +96,7 @@ Ignore Options
8896
used.
8997
--with-node-modules Format code in node_modules directory (skipped by default)
9098

91-
Misc Options
92-
--lsp Start language server protocol (LSP) server
99+
Runtime Options
93100
--no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched
94101
--threads=INT Number of threads to use. Set to 1 for using only 1 CPU core.
95102

@@ -138,8 +145,9 @@ Enable/Disable Plugins
138145
--disable-unicorn-plugin Disable unicorn plugin, which is turned on by default
139146
--disable-oxc-plugin Disable oxc unique rules, which is turned on by default
140147
--disable-typescript-plugin Disable TypeScript plugin, which is turned on by default
141-
--import-plugin Enable import plugin and detect ESM problems. It is recommended to use
142-
alongside the `--tsconfig` option.
148+
--import-plugin Enable import plugin and detect ESM problems. It should be used with
149+
the `--tsconfig` flag if your project has a tsconfig with a name other
150+
than `tsconfig.json`.
143151
--react-plugin Enable react plugin, which is turned off by default
144152
--jsdoc-plugin Enable jsdoc plugin and detect JSDoc problems
145153
--jest-plugin Enable the Jest plugin and detect test problems
@@ -150,7 +158,6 @@ Enable/Disable Plugins
150158
problems
151159
--promise-plugin Enable the promise plugin and detect promise usage problems
152160
--node-plugin Enable the node plugin and detect node usage problems
153-
--regex-plugin Enable the regex plugin and detect regex usage problems
154161
--vue-plugin Enable the vue plugin and detect vue usage problems
155162

156163
Fix Problems

packages/cli/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig } from '@voidzero-dev/vite-plus-test/config';
22

33
import type { LibUserConfig } from './lib';
4-
import type { OxfmtConfig } from './oxfmt-config';
4+
import type { FormatOptions } from './oxfmt-config';
55
import type { OxlintConfig } from './oxlint-config';
66

77
declare module '@voidzero-dev/vite-plus-core' {
@@ -11,7 +11,7 @@ declare module '@voidzero-dev/vite-plus-core' {
1111
*/
1212
lint?: OxlintConfig;
1313

14-
fmt?: OxfmtConfig;
14+
fmt?: FormatOptions;
1515

1616
lib?: LibUserConfig | LibUserConfig[];
1717

0 commit comments

Comments
 (0)