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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"nx": "22.5.4",
"prettier": "3.2.5",
"reflect-metadata": "0.2.2",
"rimraf": "6.1.3",
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rimraf is added to devDependencies but doesn't appear to be used anywhere in the repo (search only finds it in package.json / lockfile). This increases install surface area unnecessarily; either remove the dependency or switch the directory-removal implementation to use rimraf so the dependency is justified.

Copilot uses AI. Check for mistakes.
"ts-jest": "29.4.2",
"ts-node": "10.9.1",
"typescript": "5.9.2",
Expand Down
57 changes: 22 additions & 35 deletions pnpm-lock.yaml

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

45 changes: 24 additions & 21 deletions tools/cook/infra.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { workspaceRoot } from '@nx/devkit';
import inquirer from 'enquirer';
import {
mkdirSync,
readdirSync,
readFileSync,
renameSync,
rmSync,
writeFileSync,
} from 'fs';
import { readFileSync, writeFileSync } from 'fs';
import { execSync } from 'node:child_process';
import { mkdirSync, readdirSync, renameSync, rmSync } from 'node:fs';
Comment on lines +2 to +4
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file mixes node:fs and fs imports (readdirSync/rmSync vs readFileSync/writeFileSync). Using a single module specifier (preferably node:fs) improves consistency and also makes it easier to mock fs in Vitest (a vi.mock('node:fs') won’t affect imports from 'fs').

Suggested change
import { readFileSync, writeFileSync } from 'fs';
import { execSync } from 'node:child_process';
import { mkdirSync, readdirSync, renameSync, rmSync } from 'node:fs';
import { execSync } from 'node:child_process';
import {
mkdirSync,
readFileSync,
readdirSync,
renameSync,
rmSync,
writeFileSync,
} from 'node:fs';

Copilot uses AI. Check for mistakes.
import { basename, join, relative } from 'node:path';

const { prompt } = inquirer;

const TRASH_PATH = join(process.cwd(), 'tmp', 'trash');
export class CommandRunner {
executeCommand(
command: string,
Expand All @@ -29,8 +23,6 @@ export class CommandRunner {
}
}

export const TRASH_PATH = join(workspaceRoot, 'tmp', 'trash');

export class FileSystemAdapter {
readFile(path: string): string {
return readFileSync(path, {
Expand All @@ -48,18 +40,29 @@ export class FileSystemAdapter {
return readdirSync(path);
}

/**
* Windows antiviruses can be a pain (e.g. EBUSY errors).
* This method will try to remove the folder multiple times,
* then if it fails, it will try to move the folder to tmp/trash,
* and finally if that fails, it will warn the user that they may need to remove it manually.
*
* Note that I've tried to use rimraf and its backoff but that wasn't enough.
*/
removeDir(path: string): void {
mkdirSync(TRASH_PATH, { recursive: true });
const targetPath = join(TRASH_PATH, `${basename(path)}-${Date.now()}`);
renameSync(path, targetPath);
try {
Comment on lines +43 to 52
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileSystemAdapter.removeDir now relies on fs.rmSync retry behavior and intentionally downgrades failures to warnings. There isn’t test coverage for this behavior (e.g., verifying it doesn’t throw when rmSync fails and that a warning is emitted), and the previous integration-style test for removal behavior was removed. Adding a focused unit test (mocking rmSync) would help prevent regressions, especially on Windows EBUSY scenarios.

Copilot uses AI. Check for mistakes.
rmSync(targetPath, { maxRetries: 5, recursive: true });
} catch (error: unknown) {
const relativeTargetPath = relative(workspaceRoot, targetPath);
const reason = error instanceof Error ? error.message : error;
console.warn(
`⚠️ Failed to remove ${relativeTargetPath}. You may need to remove it manually. Reason: ${reason}`,
);
rmSync(path, { maxRetries: 10, recursive: true });
} catch {
try {
mkdirSync(TRASH_PATH, { recursive: true });
const targetPath = join(TRASH_PATH, `${basename(path)}-${Date.now()}`);
renameSync(path, targetPath);
} catch (error: unknown) {
const relativeTargetPath = relative(process.cwd(), path);
const reason = error instanceof Error ? error.message : error;
console.warn(
`⚠️ Failed to remove ${relativeTargetPath}. You may need to remove it manually. Reason: ${reason}`,
);
}
}
}
}
Expand Down
33 changes: 0 additions & 33 deletions tools/cook/infra.wide.spec.ts

This file was deleted.

20 changes: 1 addition & 19 deletions tools/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { defineConfig, mergeConfig } from 'vitest/config';
import viteConfig from './vite.config.mjs';

const narrowTestPatterns = ['**/!(*.wide).spec.ts'];
const wideTestPatterns = ['**/*.wide.spec.ts'];

export default mergeConfig(
viteConfig,
defineConfig({
Expand All @@ -15,25 +12,10 @@ export default mergeConfig(
provider: 'v8',
},
environment: 'node',
include: ['**/*.spec.ts'],
watch: false,
pool: 'threads',
isolate: false,
projects: [
{
extends: true,
test: {
name: 'narrow',
include: narrowTestPatterns,
},
},
{
extends: true,
test: {
name: 'wide',
include: wideTestPatterns,
},
},
],
},
}),
);
Loading