-
-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathnextron-init.ts
executable file
·47 lines (38 loc) · 1.27 KB
/
nextron-init.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
import path from 'path'
import execa from 'execa'
import arg from 'arg'
import chalk from 'chalk'
const args = arg({
'--help': Boolean,
'--version': Boolean,
'--template': String,
'--example': '--template',
'-h': '--help',
'-v': '--version',
'-t': '--template',
'-e': '--template',
})
if (args['--version']) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg = require(path.resolve(__dirname, '../package.json'))
console.log(`nextron v${pkg.version}`)
process.exit(0)
}
if (args['--help'] || !args._[0]) {
console.log(chalk`
{bold.cyan nextron} - ⚡ Electron + NEXT.js ⚡
{bold USAGE}
{bold $} {cyan nextron init} --help
{bold $} {cyan nextron init} {underline my-app}
{bold $} {cyan nextron init} {underline my-app} [--example {underline example_folder_name}]
{bold OPTIONS}
--help, -h shows this help message
--version, -v displays the current version of nextron
--example, -e {underline example_folder_name} sets the example as a template
`)
process.exit(0)
}
const example = args['--template'] || args['--example'] || 'basic-javascript'
execa.sync('npx', ['create-nextron-app', args._[0], '--example', example], {
stdio: 'inherit',
})