This repository has been archived by the owner on May 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcreate-fastify-app.js
executable file
·58 lines (50 loc) · 1.63 KB
/
create-fastify-app.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
#!/usr/bin/env node
'use strict'
const fs = require('fs')
const { promisify } = require('util')
const readFile = promisify(fs.readFile)
const path = require('path')
const appGenerator = require('./generators/fastify')
const serviceGenerator = require('./generators/service')
const mongoGenerator = require('./generators/mongodb')
const mysqlGenerator = require('./generators/mysql')
const corsGenerator = require('./generators/cors')
const redisGenerator = require('./generators/redis')
const postgresGenerator = require('./generators/postgres')
const povGenerator = require('./generators/point-of-view')
const commist = require('commist')()
const log = require('./lib/log')
const run = require('./run')
const eject = require('./eject')
require('make-promises-safe')
function stop (err) {
if (err) {
log('error', err)
process.exit(1)
}
process.exit(0)
}
async function showHelp () {
try {
const file = await readFile(path.join(__dirname, 'help', 'usage.txt'), 'utf8')
log('info', file)
} catch (e) {
return stop(e)
}
return stop()
}
commist.register('run', run.cli)
commist.register('eject', eject.cli)
commist.register('generate:project', appGenerator.cli)
commist.register('generate:service', serviceGenerator.cli)
commist.register('add:mysql', mysqlGenerator.cli)
commist.register('add:mongo', mongoGenerator.cli)
commist.register('add:cors', corsGenerator.cli)
commist.register('add:redis', redisGenerator.cli)
commist.register('add:postgres', postgresGenerator.cli)
commist.register('add:pov', povGenerator.cli)
const res = commist.parse(process.argv.splice(2))
if (res) {
// no command was recognized
showHelp()
}