From 446f5db9974a92339b789d7a6c5061c282af6f7c Mon Sep 17 00:00:00 2001 From: Robophil Date: Wed, 11 Oct 2017 17:19:38 +0100 Subject: [PATCH] feat(packgage.json): add package.json for project init --- bin/cmd/new.js | 16 ++++++++++++++-- files/action/package.json | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 files/action/package.json diff --git a/bin/cmd/new.js b/bin/cmd/new.js index fb04d65..fca124a 100644 --- a/bin/cmd/new.js +++ b/bin/cmd/new.js @@ -1,5 +1,6 @@ const fs = require('fs-extra') const path = require('path') +const replace = require('replace-in-file') const cwd = process.cwd() const postfixName = '-service' @@ -24,8 +25,19 @@ module.exports = (name, options) => { const src = path.resolve(__dirname, '..', '..', 'files/action') const dest = `${cwd}/${name}` - return fs.copy(src, dest) + const configSrc = path.resolve(__dirname, '..', '..', 'files/config') + const configDest = `${cwd}/${name}/config` + + return Promise.all([fs.copy(src, dest), fs.copy(configSrc, configDest)]) }).then(() => { - console.log('made new projject') + console.log(`\n\tNew Project has been created at '${name}'`) + const dest = `${cwd}/${name}/package.json` + return replace({ + files: `${dest}`, + from: /microservice-lite/g, + to: `${name}` + }).then(() => { + console.log(`\tcd into ${name} and run 'npm install'\n\trun 'mslite help' for assistance and \n\trun 'npm start' to see your project up and running\n`) + }) }) } diff --git a/files/action/package.json b/files/action/package.json new file mode 100644 index 0000000..44f9990 --- /dev/null +++ b/files/action/package.json @@ -0,0 +1,27 @@ +{ + "name": "microservice-lite", + "version": "0.1.0", + "description": "A tiny microservice built using mslite", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node index.js" + }, + "keywords": [ + "microservices", + "cote.js", + "cote", + "javascript", + "node", + "microservicelite", + "mslite" + ], + "author": "Balogun Oghenerobo Philip ", + "license": "MIT", + "dependencies": { + "require-all": "^2.2.0", + "fs-extra": "^4.0.2", + "sails-disk": "^0.10.10", + "waterline": "^0.11.11" + } +}