-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·63 lines (56 loc) · 1.87 KB
/
index.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
62
63
#!/usr/bin/env node
const fs = require('fs-extra')
const path = require('path')
const {green, cyan} = require('colors/safe')
const argv = require('yargs')
.boolean('jsx')
.boolean('tsx')
.demandCommand(1)
.argv
const Shell = require('meshell')
const appName = argv._[0]
const appDir = path.resolve(process.cwd(), appName)
fs.ensureDirSync(appDir)
let templateDir
if (argv.tsx) {
templateDir = path.resolve(__dirname, 'template', 'tsx')
} else {
const sharedTemplateDir = path.resolve(__dirname, 'template', 'js', 'shared')
fs.copySync(sharedTemplateDir, appDir)
templateDir = path.resolve(__dirname, 'template', 'js', argv.jsx ? 'jsx' : 'js')
}
fs.copySync(templateDir, appDir)
fs.renameSync(`${appDir}/_gitignore`, `${appDir}/.gitignore`)
const sh = new Shell({cwd: appDir})
sh('git init').then(async () => {
await sh(`perl -pi -e 's/appName/${appName}/g' README.md`)
await sh('git add .')
}).then(() => {
console.info('')
// @ts-ignore
console.info(green.bold('Success!'), `Created ${appName} at ${appDir}`)
console.info('Inside that directory, you can run several commands:')
console.info('')
console.info(' ', cyan('yarn dev'))
console.info(' ', 'Starts the development server with live reload.')
console.info('')
console.info(' ', cyan('yarn test'))
console.info(' ', 'Runs fullstack/browser tests in electron.')
console.info('')
console.info(' ', cyan('yarn start'))
console.info(' ', 'Starts server.')
console.info('')
console.info(' ', cyan('yarn build'))
console.info(' ', 'Bundles the app into static files for production.')
console.info('')
console.info(' ', cyan('yarn lint'))
console.info(' ', 'Lints with eslint.')
console.info('')
console.info('Get started with:')
console.info('')
console.info(` cd ${appDir} && yarn install`)
console.info('')
}).catch(e => {
console.error(e)
process.exit(1)
})