-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·67 lines (55 loc) · 1.47 KB
/
cli.js
File metadata and controls
executable file
·67 lines (55 loc) · 1.47 KB
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
64
65
66
67
#! /usr/bin/env node
const path = require('path')
const mkdirp = require('mkdirp')
const auth = require('./src/auth')
const mvc = require('./src/mvc')
const static = require('./src/static')
const argv = require('yargs/yargs')(process.argv.slice(2))
.usage('Welcome to the Architect Generator Beta')
.command('mvc', 'generates mvc example')
.command('auth', 'generates auth example')
.command('static', 'generates static example')
.options({
'd': {
alias: 'dest',
demandOption: false,
default: './',
describe: 'destination path',
type: 'string'
}
})
.help('help').alias('help', 'h')
.demandCommand(1, '')
.argv
if (require.main === module) {
(async function main (){
await cli()
})()
}
module.exports = cli
async function cli () {
if (argv._[0] === 'auth') {
let tmp = path.join(process.cwd(), argv.dest)
await mkdirp(tmp)
await auth({ dest: tmp })
console.log('created auth example')
}
if (argv._[0] === 'mvc') {
let tmp = path.join(process.cwd(), argv.dest)
await mkdirp(tmp)
await mvc({
dest: tmp,
model: 'post',
hashkey: 'postID',
plural: 'posts',
rest: [ { name: 'title', type: 'string' }, { name: 'content', type: 'text' } ]
})
console.log('created mvc example')
}
if (argv._[0] === 'static') {
let tmp = path.join(process.cwd(), argv.dest)
await mkdirp(tmp)
await static({ dest: tmp })
console.log('created static example')
}
}