-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild-cli.js
More file actions
26 lines (20 loc) · 742 Bytes
/
build-cli.js
File metadata and controls
26 lines (20 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env node
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
// Compile TypeScript
console.log('📦 Compiling CLI...');
execSync('tsc bin/cli.ts --outDir bin --module commonjs --target es2020 --esModuleInterop --resolveJsonModule', {
stdio: 'inherit'
});
// Read the compiled file
const cliPath = path.join(__dirname, 'bin', 'cli.js');
let content = fs.readFileSync(cliPath, 'utf-8');
// Remove any existing shebang and add one at the top
content = content.replace(/^#!.*\n/gm, '');
content = '#!/usr/bin/env node\n' + content;
// Write back
fs.writeFileSync(cliPath, content);
// Make executable
fs.chmodSync(cliPath, '755');
console.log('✅ CLI built successfully!');