diff --git a/inquirer.js b/inquirer.js index 3daf1b1..259fd37 100644 --- a/inquirer.js +++ b/inquirer.js @@ -14,7 +14,8 @@ var inq = {}; module.exports = inq; inq.ask = function ask(prompts, cb) { - inquirer.prompt(prompts, + inquirer.prompt(prompts) + .then( function(answers) { if (!answers.appName) { // empty space so that everyone can see this error msg @@ -147,7 +148,7 @@ inq.ask = function ask(prompts, cb) { if (file.basename[0] === '_') { file.basename = '.' + file.basename.slice(1); } - // we don't need special test folders if there is no phantomjs + // we don't need special test folders if there is no phantomjs if (answers.tests && !answers.phantomjs) { if (file.dirname.substring(0, 9) === "test/unit") { file.dirname = file.dirname.replace("unit", ""); @@ -162,6 +163,7 @@ inq.ask = function ask(prompts, cb) { var prepub = function() { var spawn = require('child_process').spawn; var proc = spawn('npm', ['install']); + //var proc = spawn('ls', ['-l']); proc.stdout.pipe(process.stdout); proc.stderr.pipe(process.stderr); proc.on("close", function(){ @@ -174,7 +176,8 @@ inq.ask = function ask(prompts, cb) { prepub(); } }) - }); + } + ); }; inq.showHelp = function(answers) { diff --git a/package.json b/package.json index 4f0699a..5659aa3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "slush-biojs", - "version": "0.7.17", + "version": "0.8.0", "description": "A slush generator for BioJS modules", "keywords": [ "slushgenerator", @@ -24,17 +24,17 @@ "main": "slushfile.js", "dependencies": { "client-http": "0.0.7", - "colors": "^1.0.3", - "fullname": "^2.0.1", - "gulp": "~3.9.0", + "colors": "^1.1.2", + "fullname": "^3.0.0", + "gulp": "~3.9.1", "gulp-conflict": "^0.4.0", - "gulp-rename": "~1.2.0", - "gulp-template": "~3.0.0", - "inquirer": "^0.11.0", - "rc": "^1.1.5", - "underscore": "^1.7.0", - "underscore.string": "^3.2.2", - "username": "^1.0.0" + "gulp-rename": "~1.2.2", + "gulp-template": "~4.0.0", + "inquirer": "^1.0.2", + "rc": "^1.1.6", + "underscore": "^1.8.3", + "underscore.string": "^3.3.4", + "username": "^2.1.0" }, "devDependencies": {}, "engines": { diff --git a/questions.js b/questions.js index 7221039..5a0d76b 100644 --- a/questions.js +++ b/questions.js @@ -19,6 +19,7 @@ module.exports.getPrompts = function(prev, opts){ gulp: false, phantomjs: false, vis: true, + browserify: false, testsNonVis: true, testsVisComponents: false, css: false, @@ -76,6 +77,14 @@ module.exports.getPrompts = function(prev, opts){ if( prev.vis !== undefined) return prev.vis; return conf.vis; } + }, { + name: 'browserify', + type: "confirm", + message: 'Are you going to use browserify?', + default: function() { + if( prev.browserify !== undefined) return prev.browserify; + return conf.browserify; + } }, { name: 'tests', type: "confirm", diff --git a/slushfile.js b/slushfile.js index 4213c1d..9aeeef8 100644 --- a/slushfile.js +++ b/slushfile.js @@ -32,55 +32,60 @@ gulp.task('default', function(done) { var http = require('client-http'); // check whether slush-biojs is up-to-date + show("Checking you are using the latest slush-biojs..."); http.get(npmURL, function(data) { - if (typeof data != "undefined") { - // TODO: download failed + if (typeof data == "undefined" || data==null || data.search("version")==-1) { + show("We could'n check if there is a new version of slush-biojs".red); + show(("We will continue using the currently installed version ["+pkgVersion+"]").red); } else { var pkg = JSON.parse(data); var currentVersion = pkg.version; if (currentVersion != pkgVersion) { - console.log(); - console.log(); show("YOUR slush-biojs version is OUTDATED ".red + "(current: " + currentVersion + ", installed: " + pkgVersion + ")"); show("PLEASE UPDATE slush-biojs".red); show("RUN: npm install -g slush-biojs"); process.exit(1); + } else { + show(("We will use the currently installed version ["+pkgVersion+"]").red); } } + execute_tasks(); }); - usernameTask(function(err, name) { - opts.username = name; - }); - fullnameTask(function(err, name) { - opts.fullname = name; - }); - exec('git config --global user.email', function(err, stdout) { - opts.email = stdout.trim(); - }); + var execute_tasks = function() { + usernameTask(function(err, name) { + opts.username = name; + }); + fullnameTask(function(err, name) { + opts.fullname = name; + }); + exec('git config --global user.email', function(err, stdout) { + opts.email = stdout.trim(); + }); - exec('npm -v ', function(err, stdout) { - var parts = stdout.split("."); - if (parts[0] < 2) { - console.log(); - console.log("Your npm version is outdated. Please update"); - console.log("https://github.com/joyent/node/wiki/installing-node.js-via-package-manager"); - process.exit(1); - } - }); + exec('npm -v ', function(err, stdout) { + var parts = stdout.split("."); + if (parts[0] < 2) { + console.log(); + console.log("Your npm version is outdated. Please update"); + console.log("https://nodejs.org/en/download/"); + process.exit(1); + } + }); - var prev = {}; - var prompts = questions.getPrompts(prev, opts); - var repeater = function(answers, repeat) { - prev = _.pick(answers, questions.getKeys(prompts)); - prompts = questions.getPrompts(prev, opts); - if (repeat) { - inquirer.ask(prompts, repeater); - } else { - done(); - // TODO: save some answers as default - } + var prev = {}; + var prompts = questions.getPrompts(prev, opts); + var repeater = function(answers, repeat) { + prev = _.pick(answers, questions.getKeys(prompts)); + prompts = questions.getPrompts(prev, opts); + if (repeat) { + inquirer.ask(prompts, repeater); + } else { + done(); + // TODO: save some answers as default + } + }; + inquirer.ask(prompts, repeater); }; - inquirer.ask(prompts, repeater); }); diff --git a/templates/package.json b/templates/package.json index 429f59e..de41cba 100644 --- a/templates/package.json +++ b/templates/package.json @@ -35,10 +35,15 @@ } }, <% } %><% if(vis){ %> "sniper": { + <% if (!browserify){ %>"noBrowserify": true,<% } %> "js": [ "/build/<%= appNameShort %>.js"],<% if (css){ %> "css": ["/build/bundle.css"], <% } %> "snippets": ["examples"], "first": "simple" - }, <% } %> + }, <% } else { %> + "biojs": { + <% if (!browserify){ %>"noBrowserify": true,<% } %> + "js": [ "/build/<%= appNameShort %>.js"] + }, <% } %> "keywords": <%= keywordList %> }