Skip to content

Commit 39038a3

Browse files
authored
chore: update deps (#322)
1 parent 3837cf0 commit 39038a3

51 files changed

Lines changed: 1342 additions & 2534 deletions

Some content is hidden

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

.oxfmtrc.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,17 @@
44
"packages/cli/binding/index.d.ts",
55
"packages/cli/binding/index.js"
66
],
7-
"singleQuote": true
7+
"singleQuote": true,
8+
"experimentalSortImports": {
9+
"groups": [
10+
["type-import"],
11+
["type-builtin", "value-builtin"],
12+
["type-external", "value-external", "type-internal", "value-internal"],
13+
["type-parent", "type-sibling", "type-index", "value-parent", "value-sibling", "value-index"],
14+
["ts-equals-import"],
15+
["unknown"]
16+
],
17+
"newlinesBetween": true,
18+
"order": "asc"
19+
}
820
}

bench/generate-monorepo.ts

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ class MonorepoGenerator {
1616
private readonly PACKAGE_COUNT = 1000;
1717
private readonly MAX_DEPS_PER_PACKAGE = 8;
1818
private readonly MIN_DEPS_PER_PACKAGE = 2;
19-
private readonly SCRIPT_NAMES = [
20-
'build',
21-
'test',
22-
'lint',
23-
'dev',
24-
'start',
25-
'prepare',
26-
'compile',
27-
];
19+
private readonly SCRIPT_NAMES = ['build', 'test', 'lint', 'dev', 'start', 'prepare', 'compile'];
2820
private readonly CATEGORIES = ['core', 'util', 'feature', 'service', 'app'];
2921

3022
constructor(private rootDir: string) {}
@@ -43,10 +35,7 @@ class MonorepoGenerator {
4335
return `${category}-${paddedIndex}`;
4436
}
4537

46-
private generateScriptCommand(
47-
scriptName: string,
48-
packageName: string,
49-
): string {
38+
private generateScriptCommand(scriptName: string, packageName: string): string {
5039
const commands = [
5140
`echo "Running ${scriptName} for ${packageName}"`,
5241
`node scripts/${scriptName}.js`,
@@ -87,14 +76,8 @@ class MonorepoGenerator {
8776
return scripts;
8877
}
8978

90-
private selectDependencies(
91-
currentIndex: number,
92-
availablePackages: string[],
93-
): string[] {
94-
const numDeps = this.getRandomInt(
95-
this.MIN_DEPS_PER_PACKAGE,
96-
this.MAX_DEPS_PER_PACKAGE,
97-
);
79+
private selectDependencies(currentIndex: number, availablePackages: string[]): string[] {
80+
const numDeps = this.getRandomInt(this.MIN_DEPS_PER_PACKAGE, this.MAX_DEPS_PER_PACKAGE);
9881
const dependencies = new Set<string>();
9982

10083
// Create a complex graph by selecting dependencies from different layers
@@ -108,10 +91,7 @@ class MonorepoGenerator {
10891
return [];
10992
}
11093

111-
while (
112-
dependencies.size < numDeps &&
113-
dependencies.size < eligiblePackages.length
114-
) {
94+
while (dependencies.size < numDeps && dependencies.size < eligiblePackages.length) {
11595
const dep = this.getRandomElement(eligiblePackages);
11696
dependencies.add(dep);
11797
}
@@ -147,8 +127,7 @@ class MonorepoGenerator {
147127
const hasVitePlusConfig = Math.random() > 0.3;
148128

149129
// Select dependencies from packages created before this one
150-
const dependencies =
151-
i === 0 ? [] : this.selectDependencies(i, allPackageNames.slice(0, i));
130+
const dependencies = i === 0 ? [] : this.selectDependencies(i, allPackageNames.slice(0, i));
152131

153132
this.packages.set(packageName, {
154133
name: packageName,
@@ -182,15 +161,9 @@ class MonorepoGenerator {
182161

183162
// Create the scenario: A has build, B doesn't, C has build
184163
const scriptName = this.getRandomElement(this.SCRIPT_NAMES);
185-
pkgA.scripts[scriptName] = this.generateScriptCommand(
186-
scriptName,
187-
nameA,
188-
);
164+
pkgA.scripts[scriptName] = this.generateScriptCommand(scriptName, nameA);
189165
delete pkgB.scripts[scriptName]; // B doesn't have the script
190-
pkgC.scripts[scriptName] = this.generateScriptCommand(
191-
scriptName,
192-
nameC,
193-
);
166+
pkgC.scripts[scriptName] = this.generateScriptCommand(scriptName, nameC);
194167
}
195168
}
196169
}
@@ -217,10 +190,7 @@ class MonorepoGenerator {
217190
),
218191
};
219192

220-
fs.writeFileSync(
221-
path.join(packageDir, 'package.json'),
222-
JSON.stringify(packageJson, null, 2),
223-
);
193+
fs.writeFileSync(path.join(packageDir, 'package.json'), JSON.stringify(packageJson, null, 2));
224194

225195
// Write source file
226196
const indexContent = `// ${pkg.name} module
@@ -303,10 +273,7 @@ module.exports = { ${pkg.name.replace('-', '_')} };
303273
const pnpmWorkspace = `packages:
304274
- 'packages/*'
305275
`;
306-
fs.writeFileSync(
307-
path.join(this.rootDir, 'pnpm-workspace.yaml'),
308-
pnpmWorkspace,
309-
);
276+
fs.writeFileSync(path.join(this.rootDir, 'pnpm-workspace.yaml'), pnpmWorkspace);
310277

311278
// Write root vite-plus.json
312279
const rootVitePlusConfig = {
@@ -331,9 +298,7 @@ module.exports = { ${pkg.name.replace('-', '_')} };
331298
JSON.stringify(rootVitePlusConfig, null, 2),
332299
);
333300

334-
console.log(
335-
`Successfully generated monorepo with ${this.PACKAGE_COUNT} packages!`,
336-
);
301+
console.log(`Successfully generated monorepo with ${this.PACKAGE_COUNT} packages!`);
337302
console.log(`Location: ${this.rootDir}`);
338303

339304
// Print some statistics
@@ -362,9 +327,7 @@ module.exports = { ${pkg.name.replace('-', '_')} };
362327
console.log('\nStatistics:');
363328
console.log(`- Total packages: ${this.packages.size}`);
364329
console.log(
365-
`- Average dependencies per package: ${(
366-
totalDeps / this.packages.size
367-
).toFixed(2)}`,
330+
`- Average dependencies per package: ${(totalDeps / this.packages.size).toFixed(2)}`,
368331
);
369332
console.log(`- Max dependencies in a package: ${maxDeps}`);
370333
console.log(`- Packages with vite-plus.json: ${packagesWithVitePlus}`);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vite-plus-monorepo",
33
"license": "BUSL-1.1",
44
"private": true,
5-
"packageManager": "pnpm@10.22.0",
5+
"packageManager": "pnpm@10.23.0",
66
"engines": {
77
"node": "^20.19.0 || >=22.12.0"
88
},
@@ -27,7 +27,8 @@
2727
"oxfmt": "catalog:",
2828
"oxlint": "catalog:",
2929
"typescript": "catalog:",
30-
"vitest": "workspace:@voidzero-dev/vite-plus-test@*"
30+
"vite": "catalog:",
31+
"vitest": "catalog:"
3132
},
3233
"lint-staged": {
3334
"*.@(yml|yaml|md|json|html|toml)": [

packages/cli/binding/__tests__/run-command.spec.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,21 @@ test('should run command successfully', async () => {
1818

1919
// write file on the temp directory
2020
test('should write file on the temp directory', async () => {
21-
const tempDir = await fs.realpath(
22-
await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')),
23-
);
21+
const tempDir = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')));
2422
const result = await runCommand({
2523
binName: 'node',
2624
args: ['-e', `fs.writeFileSync("test.txt", "Hello, world!")`],
2725
envs: {},
2826
cwd: tempDir,
2927
});
3028
expect(result).toMatchSnapshot();
31-
expect(await fs.readFile(path.join(tempDir, 'test.txt'), 'utf-8')).toBe(
32-
'Hello, world!',
33-
);
29+
expect(await fs.readFile(path.join(tempDir, 'test.txt'), 'utf-8')).toBe('Hello, world!');
3430
await fs.rm(tempDir, { recursive: true });
3531
});
3632

3733
// read file on the temp directory
3834
test('should read file on the temp directory', async () => {
39-
const tempDir = await fs.realpath(
40-
await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')),
41-
);
35+
const tempDir = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')));
4236
await fs.writeFile(path.join(tempDir, 'test.txt'), 'Hello, world!');
4337
const result = await runCommand({
4438
binName: 'node',
@@ -52,9 +46,7 @@ test('should read file on the temp directory', async () => {
5246

5347
// write and read file on the temp directory
5448
test('should write and read file on the temp directory', async () => {
55-
const tempDir = await fs.realpath(
56-
await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')),
57-
);
49+
const tempDir = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')));
5850
const result = await runCommand({
5951
binName: 'node',
6052
args: [

packages/cli/binding/index.d.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ export interface CliOptions {
2525
/** Optional working directory override */
2626
cwd?: string;
2727
/** Read the vite.config.ts in the Node.js side and return the `lint` and `fmt` config JSON string back to the Rust side */
28-
resolveUniversalViteConfig: (
29-
err: Error | null,
30-
arg: string,
31-
) => Promise<string>;
28+
resolveUniversalViteConfig: (err: Error | null, arg: string) => Promise<string>;
3229
}
3330

3431
/**
@@ -56,9 +53,7 @@ export interface CliOptions {
5653
* console.log(`Workspace root: ${result.root}`);
5754
* ```
5855
*/
59-
export declare function detectWorkspace(
60-
cwd: string,
61-
): Promise<DetectWorkspaceResult>;
56+
export declare function detectWorkspace(cwd: string): Promise<DetectWorkspaceResult>;
6257

6358
export interface DetectWorkspaceResult {
6459
packageManagerName?: string;
@@ -223,9 +218,7 @@ export declare function run(options: CliOptions): Promise<number>;
223218
* console.log(`Path accesses:`, result.pathAccesses);
224219
* ```
225220
*/
226-
export declare function runCommand(
227-
options: RunCommandOptions,
228-
): Promise<RunCommandResult>;
221+
export declare function runCommand(options: RunCommandOptions): Promise<RunCommandResult>;
229222

230223
/**
231224
* Input parameters for running a command with fspy tracking.

0 commit comments

Comments
 (0)