1 | #!/usr/bin/env node
|
2 |
|
3 | const { inquirer, dotenv } = require('sherry-utils')
|
4 | const { bootstrap } = require('sherry-cli')
|
5 | const sherry = require('../index')()
|
6 | const pkg = require('../package')
|
7 |
|
8 | async function corePluginProcessor({ outDir, ...restOptions }, start) {
|
9 | if (outDir === process.cwd()) {
|
10 | const { continueGenerate } = await inquirer.prompt({
|
11 | name: 'continueGenerate',
|
12 | message: 'Are you sure you want to create a new project in the current directory?',
|
13 | choices: ['Y', 'N'],
|
14 | type: 'list',
|
15 | default: 'Y'
|
16 | })
|
17 | if (continueGenerate === 'N') {
|
18 | return console.log(`Cancelled\n`)
|
19 | }
|
20 | }
|
21 | const options = {
|
22 | outDir,
|
23 | updateCheck: true,
|
24 | ...restOptions
|
25 | }
|
26 |
|
27 | start(options)
|
28 | }
|
29 |
|
30 | const plugins = [
|
31 | { name: 'core', path: require.resolve('sherry-plugin-core'), options: { process: corePluginProcessor } },
|
32 | { name: 'init', path: require.resolve('sherry-plugin-init') },
|
33 | { name: 'view-generators', path: require.resolve('sherry-plugin-view-generators') },
|
34 | { name: 'view-cache', path: require.resolve('sherry-plugin-view-cache') },
|
35 | { name: 'alias', path: require.resolve('sherry-plugin-alias') }
|
36 |
|
37 | ]
|
38 |
|
39 |
|
40 | dotenv.config()
|
41 |
|
42 | bootstrap({
|
43 | sherry,
|
44 | plugins,
|
45 | beforeParse(cli) {
|
46 | cli.version(pkg.version)
|
47 | cli.help()
|
48 | }
|
49 | })
|