-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathbuild-cli.js
More file actions
33 lines (27 loc) · 825 Bytes
/
build-cli.js
File metadata and controls
33 lines (27 loc) · 825 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
27
28
29
30
31
32
33
import { execSync } from 'node:child_process';
import { mkdirSync, writeFileSync } from 'node:fs';
import path from 'node:path';
const rootDir = process.cwd();
function runTsc() {
console.log('Building CLI with TypeScript (npx tsc)...');
execSync('npx tsc -p tsconfig.json', {
stdio: 'inherit',
});
}
function createEntry() {
const distDir = path.join(rootDir, 'dist');
mkdirSync(distDir, { recursive: true });
const entry = `#!/usr/bin/env node
import('./src/blade.js')
.then((m) => (typeof m.main === 'function' ? m.main() : undefined))
.catch((err) => {
console.error(err);
process.exit(1);
});
`;
const entryPath = path.join(distDir, 'blade.js');
writeFileSync(entryPath, entry, { mode: 0o755 });
console.log('✓ CLI entry created at dist/blade.js');
}
runTsc();
createEntry();