Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

No browserify #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions inquirer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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", "");
Expand All @@ -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(){
Expand All @@ -174,7 +176,8 @@ inq.ask = function ask(prompts, cb) {
prepub();
}
})
});
}
);
};

inq.showHelp = function(answers) {
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slush-biojs",
"version": "0.7.17",
"version": "0.8.0",
"description": "A slush generator for BioJS modules",
"keywords": [
"slushgenerator",
Expand All @@ -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": {
Expand Down
9 changes: 9 additions & 0 deletions questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports.getPrompts = function(prev, opts){
gulp: false,
phantomjs: false,
vis: true,
browserify: false,
testsNonVis: true,
testsVisComponents: false,
css: false,
Expand Down Expand Up @@ -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",
Expand Down
73 changes: 39 additions & 34 deletions slushfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
7 changes: 6 additions & 1 deletion templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
}