-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcli.ts
51 lines (41 loc) · 1.25 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
#!/usr/bin/env node
import generateCmd from '#commands/generate';
import generateLoaderCmd from '#commands/generate-loader';
import initCmd from '#commands/init';
import newCmd from '#commands/new';
import { createColors } from 'colorette';
import { Command } from 'commander';
import { readFile } from 'node:fs/promises';
import { URL } from 'node:url';
createColors({ useColor: true });
const sapphire = new Command();
const packageFile = new URL('../package.json', import.meta.url);
const packageJson = JSON.parse(await readFile(packageFile, 'utf-8'));
sapphire //
.name('sapphire')
.version(packageJson.version);
sapphire
.command('new')
.description('creates a new Sapphire project')
.alias('n')
.argument('[name]', 'project name')
.option('-v, --verbose')
.action(newCmd);
sapphire
.command('generate')
.description('generates a component/piece')
.alias('g')
.argument('<component>', 'component/piece name')
.argument('<name>', 'file name')
.action(generateCmd);
sapphire //
.command('generate-loader')
.description('generates a piece loader')
.alias('gl')
.action(generateLoaderCmd);
sapphire //
.command('init')
.description('creates a config file on an existing Sapphire project')
.alias('i')
.action(initCmd);
sapphire.parse(process.argv);