-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcli.js
executable file
·55 lines (47 loc) · 1.62 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
#!/usr/bin/env node
const path = require('path')
const sao = require('sao')
const cac = require('cac')
const chalk = require('chalk')
const envinfo = require('envinfo')
const { version } = require('./package.json')
const generator = path.resolve(__dirname, './')
const cli = cac('create-nuxt-typo3')
const showEnvInfo = async () => {
console.log(chalk.bold('\nEnvironment Info:'))
const result = await envinfo
.run({
System: ['OS', 'CPU'],
Binaries: ['Node', 'Yarn', 'npm'],
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
npmGlobalPackages: ['nuxt', 'create-typo3-nuxt-app']
})
console.log(result)
process.exit(1)
}
cli
.command('[out-dir]', 'Generate in a custom directory or current directory')
.option('-e, --edge', 'To install `nuxt-edge` instead of `nuxt`')
.option('-i, --info', 'Print out debugging information relating to the local environment')
.option('--answers <json>', 'Skip all the prompts and use the provided answers')
.option('--verbose', 'Show debug logs')
.action((outDir = '.', cliOptions) => {
if (cliOptions.info) {
return showEnvInfo()
}
console.log()
console.log(chalk`{cyan create-nuxt-typo3 v${version}}`)
console.log(chalk`✨ Generating TYPO3 PWA based on Nuxt.js project in {cyan ${outDir}}`)
const { verbose, answers } = cliOptions
const logLevel = verbose ? 4 : 2
// See https://saojs.org/api.html#standalone-cli
sao({ generator, outDir, logLevel, answers, cliOptions })
.run()
.catch((err) => {
console.trace(err)
process.exit(1)
})
})
cli.help()
cli.version(version)
cli.parse()