UNPKG

1.36 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3const { inquirer, dotenv } = require('sherry-utils')
4const { bootstrap } = require('sherry-cli')
5const sherry = require('../index')()
6const pkg = require('../package')
7
8async 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
30const 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 // { name: 'build', path: require.resolve('sherry-plugin-build') },
37]
38
39// Load .env
40dotenv.config()
41
42bootstrap({
43 sherry,
44 plugins,
45 beforeParse(cli) {
46 cli.version(pkg.version)
47 cli.help()
48 }
49})