Skip to content

Commit fe594ce

Browse files
committed
fix: replace rsync and rm commands with Node.js for Windows compatibility
- Replace rsync with Node.js script (scripts/copy-assets.mjs) for copying assets - Replace 'rm -rf' with Node.js fs.rmSync for clean script - Fix AGENTS.md exclusion to only apply at root level, preserving src/assets/agents/AGENTS.md - Ensures build works on Windows without requiring Unix tools
1 parent 559ca15 commit fe594ce

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build": "npm run build:lib && npm run build:cli && npm run build:assets",
2121
"build:lib": "tsc -p tsconfig.build.json",
2222
"build:cli": "node esbuild.config.mjs",
23-
"build:assets": "rsync -a --exclude='/AGENTS.md' src/assets/ dist/assets/",
23+
"build:assets": "node scripts/copy-assets.mjs",
2424
"cli": "npx tsx src/cli/index.ts",
2525
"typecheck": "tsc --noEmit",
2626
"lint": "eslint src/",
@@ -29,7 +29,7 @@
2929
"format:check": "prettier --check .",
3030
"secrets:check": "secretlint '**/*'",
3131
"security:audit": "npm audit --audit-level=high",
32-
"clean": "rm -rf dist",
32+
"clean": "node -e \"require('fs').rmSync('dist', {recursive: true, force: true})\"",
3333
"prepare": "husky",
3434
"test": "vitest run",
3535
"test:watch": "vitest",

scripts/copy-assets.mjs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import * as fs from 'fs';
2+
import * as path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
const srcDir = path.join(__dirname, '..', 'src', 'assets');
9+
const destDir = path.join(__dirname, '..', 'dist', 'assets');
10+
11+
/**
12+
* Recursively copy directory contents, excluding specified files at root level only
13+
* @param {string} src - Source directory
14+
* @param {string} dest - Destination directory
15+
* @param {string[]} excludeAtRoot - Files to exclude only at the root level (e.g., 'AGENTS.md')
16+
* @param {boolean} isRoot - Whether this is the root level call
17+
*/
18+
function copyDir(src, dest, excludeAtRoot = [], isRoot = true) {
19+
// Create destination directory if it doesn't exist
20+
if (!fs.existsSync(dest)) {
21+
fs.mkdirSync(dest, { recursive: true });
22+
}
23+
24+
const entries = fs.readdirSync(src, { withFileTypes: true });
25+
26+
for (const entry of entries) {
27+
const srcPath = path.join(src, entry.name);
28+
const destPath = path.join(dest, entry.name);
29+
30+
// Skip excluded files only at root level
31+
if (isRoot && excludeAtRoot.includes(entry.name)) {
32+
continue;
33+
}
34+
35+
if (entry.isDirectory()) {
36+
copyDir(srcPath, destPath, excludeAtRoot, false);
37+
} else {
38+
fs.copyFileSync(srcPath, destPath);
39+
}
40+
}
41+
}
42+
43+
try {
44+
console.log('Copying assets...');
45+
copyDir(srcDir, destDir, ['AGENTS.md']);
46+
console.log('Assets copied successfully!');
47+
} catch (error) {
48+
console.error('Error copying assets:', error);
49+
process.exit(1);
50+
}

0 commit comments

Comments
 (0)