-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.ts
64 lines (58 loc) · 1.74 KB
/
cli.ts
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bun
import yargs from 'yargs';
import {hideBin } from 'yargs/helpers';
import build from './commands/build.ts';
import create from './commands/create.ts';
import run from './commands/run.ts';
import add from './commands/add.ts';
yargs(hideBin(process.argv))
.command('create [name]', 'Creates an empty Buntralino project', (yargs) => {
return yargs.positional('name', {
type: 'string',
describe: 'The name for the created project',
default: 'buntralino-app'
});
}, async (argv) => {
const name = argv.name ?? 'buntralino-app';
await create(name, 'new');
})
.command('add', 'Adds Buntralino to the existing Neutralino.js project', (yargs) => {
return yargs;
}, async () => {
await add();
})
.command(['run [indexPath]', 'start'], 'Runs the Buntralino project.', (yargs) => {
return yargs.positional('indexPath', {
type: 'string',
describe: 'Path to the main Bun file',
default: 'index.ts'
});
}, async (argv) => {
await run(argv.indexPath);
})
.command('build [indexPath]', 'Builds the project for distribution', (yargs) => {
return yargs.positional('indexPath', {
type: 'string',
describe: 'Path to the main Bun file',
default: 'index.ts'
}).epilog(
'Use -- to add additional flags to Bun builder. Example: `buntralino build -- --external original-fs`' + '\n' +
'Buntralino already passes `--compile`, `--target`, `--outfile` and minification flags.'
);
}, async argv => {
await build(argv.indexPath, argv._.slice(1));
})
.demandCommand(1)
.recommendCommands()
.scriptName('buntralino')
.help()
.parse();
process.on('SIGINT', () => {
console.log(':c');
process.exit();
});
export {
build,
create,
run
};