-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
cli.js
executable file
·61 lines (54 loc) · 1.17 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
#!/usr/bin/env node
import process from 'node:process';
import path from 'node:path';
import meow from 'meow';
import createInkApp from './index.js';
const cli = meow(
`
Options
--typescript Use TypeScript React template
Usage
$ create-ink-app <project-directory>
Examples
$ create-ink-app my-cli
$ create-ink-app .
`,
{
importMeta: import.meta,
flags: {
typescript: {
type: 'boolean',
},
},
},
);
const projectDirectoryPath = path.resolve(process.cwd(), cli.input[0] || '.');
try {
console.log();
await createInkApp(projectDirectoryPath, cli.flags);
const pkgName = path.basename(projectDirectoryPath);
const relativePath = path.relative(process.cwd(), projectDirectoryPath);
console.log(
[
'',
`Ink app created in ${relativePath ?? 'the current directory'}:`,
relativePath ? ` $ cd ${relativePath}` : undefined,
relativePath ? '' : undefined,
'Build:',
' $ npm run build',
'',
'Watch and rebuild:',
' $ npm run dev',
'',
'Run:',
` $ ${pkgName}`,
'',
]
.filter(line => line !== undefined)
.map(line => ` ${line}`)
.join('\n'),
);
} catch (error) {
console.error(error.stack);
process.exit(1);
}