Skip to content

Commit

Permalink
feat(cmd): now makes project with necessary dir and files included
Browse files Browse the repository at this point in the history
  • Loading branch information
robophil committed Oct 13, 2017
1 parent eeaeceb commit 93e0824
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions bin/cmd/new.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
const fs = require('fs-extra')
const path = require('path')
const cwd = process.cwd()

const postfixName = '-service'
const makeProject = (name) => {
const newDir = []
newDir.push(fs.ensureDir(`${cwd}/${name}/`))
newDir.push(fs.ensureDir(`${cwd}/${name}/src/models/`))
newDir.push(fs.ensureDir(`${cwd}/${name}/src/app/requester/`))
newDir.push(fs.ensureDir(`${cwd}/${name}/src/app/responder/`))
newDir.push(fs.ensureDir(`${cwd}/${name}/src/app/publisher/`))
newDir.push(fs.ensureDir(`${cwd}/${name}/src/app/subscriber/`))

return Promise.all(newDir)
}

module.exports = (name, options) => {
if (name === undefined) throw new Error(`No name passed\nRun 'mslite help'`)
if (options.postfix) {
console.log(`\nNew microservice project created '${name + postfixName}'\n`)
} else {
console.log(`\nNew microservice project created '${name}'\n`)
name += postfixName
}
makeProject(name).then(() => {
const src = path.resolve(__dirname, '..', '..', 'files/action')
const dest = `${cwd}/${name}`

return fs.copy(src, dest)
}).then(() => {
console.log('made new projject')
})
}

0 comments on commit 93e0824

Please sign in to comment.