Permalink
Browse files

[fix] many

  • Loading branch information...
1 parent 25b2810 commit 5122d70df80a17e50882814f2a4d6b63867c84fd @bmeck committed Mar 23, 2013
View
0 .gitignore 100644 → 100755
File mode changed.
View
0 Readme.md 100644 → 100755
File mode changed.
View
0 integrations/Readme.md 100644 → 100755
File mode changed.
View
0 integrations/checkout.js 100644 → 100755
File mode changed.
View
0 integrations/config.js 100644 → 100755
File mode changed.
View
0 integrations/grunt.js 100644 → 100755
File mode changed.
View
56 integrations/node-versions.js 100644 → 100755
@@ -0,0 +1,56 @@
+//
+// Some basic security for user / group permissions (not sufficient on Windows)
+//
+var semver = require('semver');
+var child_process = require('child_process');
+var path = require('path');
+exports.name = 'node-versions';
+exports.actions = {
+ //
+ // When prepping for real use, bootstrap in the appropriate files
+ //
+ 'task.checkout.scaffold': function secure(scaffold, options, next) {
+ var pkg = require(path.join(scaffold.directories.moduledir, 'package.json'));
+ //
+ // Guess what people thought engine was supposed to be
+ //
+ var engine =
+ pkg.engines && pkg.engines.node ||
+ pkg.engine && pkg.engine.node ||
+ pkg.engines ||
+ pkg.engine;
+
+ child_process.exec('give remote-ls', function (err, stdout, stderr) {
+ if (err) {
+ next(err, scaffold, options);
+ return;
+ }
+ var remote_versions = stdout.split(/\r?\n/g).map(function (x) {
+ return x.replace(/^v/,'');
+ });
+ function finish (err) {
+ next(err, scaffold, options);
+ }
+ var resolved_engine = engine ? semver.maxSatisfying(remote_versions, engine) : semver.maxSatisfying(remote_versions.filter(function (x) {
+ return /\d+\.\d+[02468]\.\d+/.test(x);
+ }), '*');
+ if (!resolved_engine) {
+ next(new Error('Unknown node version '+engine), scaffold, options);
+ return;
+ }
+ child_process.spawn('give', ['install', 'v'+resolved_engine], {
+ stdio: 'inherit',
+ env:{
+ NODE_PREFIX: scaffold.directories.rootdir,
+ PATH: process.env.PATH
+ }
+ }).on('exit', function (code) {
+ if (code) {
+ finish(new Error('Could not install node version '+resolved_engine+' installer exited with code '+code));
+ return;
+ }
+ finish(null);
+ }).on('error', finish);
+ });
+ }
+}
View
32 integrations/npm.js
@@ -1,32 +0,0 @@
-//
-// Add `npm` task with basic options
-//
-var getNPMSpawnOptions = require('npm-script').getSpawnOptions;
-exports.name = 'npm';
-exports.dependencies = [require('tract-run')];
-exports.tasks = {
- npm: function (args, options, cb) {
- var scaffold = this;
- var lifecycle = args[0];
- getNPMSpawnOptions(scaffold.directories.moduledir, lifecycle, {
- defaultScript: {
- start: 'node server.js',
- preinstall: process.platform !== 'win32'
- ? '[ -f wscript] && (node-waf clean || true; node-waf configure build)'
- : 'IF EXIST wscript (node-waf clean || true; node-waf configure build)'
- }[lifecycle],
- env: {
- PATH: options.env.PATH || process.env.PATH
- }
- }, function (err, spawnOptions) {
- if (err) {
- cb(err);
- return;
- }
- var argv = spawnOptions[1];
- argv.unshift(spawnOptions[0]);
- spawnOptions.unshift('run');
- scaffold.task.apply(scaffold, spawnOptions.concat(cb));
- });
- }
-}
View
2 integrations/run.js 100644 → 100755
@@ -18,7 +18,7 @@ exports.tasks = {
var separator = process.platform === 'win32' ? ';' : ':';
function addStringToEnv(name, str) {
var base = env[name] || process.env[name] || '';
- env[name] = (base ? base + separator : '') + str;
+ env[name] = str + (base ? separator + base : '');
}
switch (process.platform) {
case "win32":
View
7 integrations/security.js 100644 → 100755
@@ -2,6 +2,7 @@
// Some basic security for user / group permissions (not sufficient on Windows)
//
var uidNumber = require('uid-number');
+var chmodr = require('chmodr');
exports.name = 'security';
exports.schema = {
properties: {
@@ -39,11 +40,11 @@ exports.actions = {
var gid = options.config.get('group') || process.getgid();
uidNumber(uid, gid, function (err, uid, gid) {
if (err) {
- next(err);
+ next(err, scaffold, options);
return;
}
chmodr(scaffold.directories.rootdir, uid, gid, function (err) {
- next(err, scaffold);
+ next(err, scaffold, options);
});
});
},
@@ -61,7 +62,7 @@ exports.actions = {
var gid = options.config.get('group');
function setids(err, uid, gid) {
if (err) {
- next(err);
+ next(err, cmd, args, options);
return;
}
if (uid) options.uid = '#'+uid;
View
0 integrations/snapshot.js
No changes.
View
9 lib/nam.js 100644 → 100755
@@ -13,10 +13,11 @@ function NodeApplicationManager(options) {
this.config = options.config || new nconf.Provider();
this.directories = merge.recursive({
rootdir: process.cwd()
- }, this.config.get('directories') || {}, {
- NodeApplicationManagerir: './build/package',
- packagedir: './build',
- tmpdir: './tmp'
+ }, this.config.get('directories') || {});
+ merge.recursive(this.directories, {
+ moduledir: path.join(this.directories.rootdir,'./build/package'),
+ packagedir: path.join(this.directories.rootdir,'./build'),
+ tmpdir: path.join(this.directories.rootdir,'./tmp')
});
this.tasks = {};
options.builtins = options.builtins || [require('../integrations/security'),require('../integrations/config'),require('../integrations/run')];
View
4 package.json 100644 → 100755
@@ -8,6 +8,8 @@
"main": "lib/nam.js",
"license": "MIT",
"dependencies": {
- "uid-number": "0.0.3"
+ "uid-number": "0.0.3",
+ "semver": "~1.1.4",
+ "chmodr": "~0.1.0"
}
}

0 comments on commit 5122d70

Please sign in to comment.