UNPKG

sleek.js

Version:

Sleek.js is an MVC wrapper Framework implemented from Node.JS, built-in with base dependency on handlebars.js, express.js. Sleek.js architecture follows common format of MVC which makes it easy to handle and build better web apps with pluggable modules &

86 lines (66 loc) 3.07 kB
#! /usr/bin/env node /* * sleek.js * http://www.sleekjs.com * * Licensed under the MIT license. 8 author: robin@cubettech.com */ 'use strict'; var userArgs = process.argv.slice(2); var action = userArgs[0]; var destination = userArgs[1]; var fs = require('fs'); var ncp = require('ncp').ncp; var path = require('path'); var stdin = process.stdin, stdout = process.stdout; ncp.limit = 16; if(action == 'create') { if(!destination) { return console.error('Please provide a directory to create your project!'); } console.log('creating your project..'); ncp(path.join(__dirname,'../app'), destination, function (err) { if (err) { return console.error(err); } console.log('creating "var" directory..'); if(!fs.existsSync(path.join(destination,'application', 'var'))){ fs.mkdirSync(path.join(destination,'application', 'var'),'0777'); } console.log('creating "tmp" directory..'); if(!fs.existsSync(path.join(destination,'application', 'var', 'tmp'))){ fs.mkdirSync(path.join(destination,'application', 'var', 'tmp'),'0777'); } console.log("You're done! Go to your project root, run 'npm install' and then 'grunt'"); console.log("Happy Coding!!"); }); } else if (action == 'update') { console.log('updating your project..'); ncp(path.join(__dirname,'../app/system'), path.join(destination,'system'), function (err) { if (err) { return console.error(err); } var grite = fs.createReadStream(path.join(__dirname,'../app/Gruntfile.js')).pipe(fs.createWriteStream(path.join(destination,'Gruntfile.js'))); stdin.resume(); stdout.write("Do you want to replace your project's 'app.js' and 'package.json' files ? [y/n]: ");     stdin.once('data', function(data) {    data = data.toString().trim();      if (data.toLowerCase() == 'y') { var rite = fs.createReadStream(path.join(__dirname,'../app/app.js')).pipe(fs.createWriteStream(path.join(destination,'app.js'))); console.log("Project Updated! Please run 'npm install' and then 'grunt' to run the project. See changelogs at http://www.sleekjs.com/change-log"); rite.on('close', function () { var rite2 = fs.createReadStream(path.join(__dirname,'../app/package.json')).pipe(fs.createWriteStream(path.join(destination,'package.json'))); rite2.on('close', function () { process.exit(); }); });    } else { console.log("Project Updated! Please run 'npm install' and then 'grunt' to run the project. see changelog at http://www.sleekjs.com/change-log"); process.exit(); }  }); }); } else { console.log('Sorry! Unknown command. Please use,'); console.log('"sleek create /path/dir" to create new project'); console.log('"sleek update /path/sleekdir" to update existing projects.'); }