@mahjongg/mern-mvc
Version:
A CLI that will build a MERN stack application using create-react-app
51 lines (44 loc) • 1.35 kB
JavaScript
const colors = require("../constants.js");
const updateNotifier = require('update-notifier');
const pkg = require('../package.json');
const create = (name, options = {})=>{
const logic = require("../logic")(options);
logic.addFolders(name, options)
.then(()=>logic.createReactApp(name, options))
.then(()=>logic.installPackages(name, options))
.then(()=>logic.addComponents(name, options))
.then(()=>logic.editApp(name, options))
.then(()=>{
logic.makeServer(name, options);
logic.addScripts(name, options);
if(options.noPassport) {
logic.makeModels(name, options);
} else {
logic.configPassport(name, options);
}
logic.makeRoutes(name, options);
return logic.serverLogic(name, options);
})
.then(()=>{
console.log(colors.CYAN);
console.log(colors.BRIGHT);
console.log(`All done! You can run 'cd ${name}/' and 'yarn start' to see your App in action.`);
console.log(colors.RESET);
updateNotifier({pkg,isGlobal:true}).notify();
})
.catch((err)=>{
if(err) {
console.log(colors.RED);
console.log(err.message);
console.log(colors.RESET);
};
});
}
const routes = (name, options) => {
const {buildRoute} = require("../logic/routeBuilder.js");
buildRoute(name, options);
};
module.exports = {
create,
routes
};