-
Notifications
You must be signed in to change notification settings - Fork 328
/
Copy pathcli.js
73 lines (63 loc) · 2.32 KB
/
cli.js
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
65
66
67
68
69
70
71
72
73
import { Command } from 'commander';
import { config } from './commands/config.js';
import { init } from './commands/init.js';
import { setInstance } from './commands/set-instance.js';
import { setRoot } from './commands/set-root.js';
import { setup } from './commands/setup.js';
import { watch } from './commands/watch.js';
import { getPackageVersion } from './utils/getPackageVersion.js';
export default function cli() {
const program = new Command();
program.name('clerk-dev').description('CLI to make developing Clerk packages easier').version(getPackageVersion());
program
.command('init')
.description('Perform initial one-time machine setup')
.action(async () => {
await init();
});
program
.command('config')
.description('Open the clerk-dev config file in EDITOR or VISUAL')
.action(async () => {
await config();
});
program
.command('set-root')
.description(
'Set the location of your checkout of the clerk/javascript repository to the current working directory',
)
.action(async () => {
await setRoot();
});
program
.command('set-instance')
.description('Set the active instance to the provided instance name')
.argument('<name>', 'name of instance listed in dev.json')
.action(async instance => {
await setInstance({ instance });
});
program
.command('setup')
.description(
'Install the monorepo versions of Clerk packages listed in the package.json file and perform framework configuration for the current working directory',
)
.option('--no-js', 'do not customize the clerkJSUrl')
.option('--skip-install', 'only perform framework configuration; do not install monorepo versions of packages')
.action(async ({ js, skipInstall }) => {
await setup({ js, skipInstall });
});
program
.command('watch')
.description(
'Start the dev tasks for all Clerk packages listed in the package.json file in the current working directory, including clerk-js (unless --no-js is specified)',
)
.option('--js', 'only start the watcher for clerk-js')
.option('--no-js', 'do not spawn the clerk-js watcher (macOS only)')
.action(async ({ js }) => {
await watch({ js });
});
program.parseAsync().catch(err => {
console.error(err.message);
process.exit(1);
});
}