-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.ts
More file actions
35 lines (28 loc) · 911 Bytes
/
cli.ts
File metadata and controls
35 lines (28 loc) · 911 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
34
35
import prompts from 'prompts';
import { exec } from 'child_process';
const backends = ['hono'];
const frontends = ['next', 'vue3', 'react'];
async function main() {
const { backend } = await prompts({
type: 'select',
name: 'backend',
message: 'Choose a backend',
choices: backends.map((b) => ({ title: b, value: b })),
});
const { frontend } = await prompts({
type: 'select',
name: 'frontend',
message: 'Choose a frontend',
choices: frontends.map((f) => ({ title: f, value: f })),
});
if (!backend || !frontend) {
console.log('Selection cancelled.');
return;
}
const command = `pnpm concurrently -n "${backend},${frontend}" -c "auto" "pnpm run be:${backend} dev" "pnpm run fe:${frontend} dev"`;
console.log(`Running: ${command}`);
const child = exec(command);
child.stdout?.pipe(process.stdout);
child.stderr?.pipe(process.stderr);
}
main();