New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

neco

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neco - npm Package Compare versions

Comparing version 0.0.3-alpha1 to 0.0.4

data/config.json

375

bin/neco.js
#!/usr/bin/env node
require.paths.shift('../deps');
var list = require('../cmd/list.js'),

@@ -11,3 +13,3 @@ find = require('../cmd/find.js'),

var parsePkgConfig = require('../lib/config.js').parsePkgConfig,
var filterConfig = require('../lib/config.js').filterConfig,
parseUserConfig = require('../lib/config.js').parseUserConfig,

@@ -18,6 +20,9 @@ parseGlobalConfig = require('../lib/config.js').parseGlobalConfig,

var envReady = require('../lib/inception.js').envReady,
toolReady = require('../lib/inception.js').toolReady,
rootReady = require('../lib/inception.js').rootReady,
recordReady = require('../lib/inception.js').recordReady,
activateReady = require('../lib/inception.js').activateReady;
upgradeReady = require('../lib/inception.js').upgradeReady;
var parseArgv = require('../lib/parser.js').parseArgv;
var idUnique = require('../lib/validation.js').idUnique,

@@ -34,204 +39,155 @@ idExsit = require('../lib/validation.js').idExsit,

var argv = process.argv, id, target, cmd = argv[2];
var argv = parseArgv();
//var argv = process.argv, id, target, cmd = argv[2];
if (cmd === undefined) {
error = 'Missing command';
// Set global varialbles namae space;
process.neco = {};
// Try catch all errors
process.on('uncaughException', function(err) {
log.emit('error', err);
});
if (argv.cmd === undefined) {
message = 'Missing command';
suggestion = 'Available commands: howto, create, remove, list, find, activate, deactivate';
example = 'neco howto, neco create <id>, neco list';
log('error', error, suggestion, example);
} else if (!cmdValid(cmd)) {
error = 'Not a valid command';
log.emit('exit', message, suggestion, example);
} else if (!cmdValid(argv.cmd)) {
message = 'Not a valid command';
suggestion = 'Available commands: howto, create, remove, list, find, activate, deactivate';
example = 'neco hwoto, neco create <id>, neco list';
log('error', error, suggestion, example);
log.emit('exit', message, suggestion, example);
} else {
// Subcommand create
if (cmd === 'create') {
if (argv.length < 4) {
message = 'Missing ID';
suggestion = 'Please specific at least one ID( and the version of node, if you will).';
example = 'neco create <id> [stable, latest, node-version]';
log('message', message, suggestion, example);
} else {
id = argv[3], target = argv[4] || 'stable'; // defaut target is stable
parseGlobalConfig(function(config) {
config.id = id, config.cmd = cmd, config.target = target;
parsePkgConfig(config, function(config) {
parseUserConfig(config, function(config) {
envReady(config, function(config) {
rootReady(config, function(config) {
activateReady(config, function(config) {
recordReady(config, function(exists, config) {
if (!exists) {
create.run(config);
} else {
if (!idValid(config)) {
message = 'The given id '+id+' is one of the reserved words in neco.';
suggestion = 'Please choose another one.';
log('message', message, suggestion);
} else if (!idUnique(config)) {
message = 'The given id '+id+' has already been used.';
suggestion = 'Please choose another one instead.';
log('message', message, suggestion);
} else {
create.run(config);
}
parseGlobalConfig(function() { parseUserConfig(function() {
envReady(argv.cmd, function() { toolReady(function() {
rootReady(function() { upgradeReady(function() {
// Subcommand create
if (argv.cmd === 'create') {
if (!argv.id) {
message = 'Missing ID';
suggestion = 'Please specific at least one ID( and the version of node, if you will).';
example = 'neco create <id> [stable, latest, node-version]';
log.emit('exit', message, suggestion, example);
} else {
filterConfig(function() {
recordReady(argv.cmd, function(exists) {
if (!exists) {
create.run(argv);
} else {
if (!idValid(argv.id)) {
message = 'The given id '+argv.id+' is one of the reserved words in neco.';
suggestion = 'Please choose another one.';
log.emit('exit', message, suggestion);
} else if (!idUnique(argv.id)) {
message = 'The given id '+argv.id+' has already been used.';
suggestion = 'Please choose another one instead.';
log.emit('message', message, suggestion);
} else {
create.run(argv);
}
});
}
});
});
});
});
});
});
}
}
}
}
// Subcommand list
else if (cmd === 'list') {
parseGlobalConfig(function(config) {
config.cmd = cmd;
parsePkgConfig(config, function(config) {
parseUserConfig(config, function(config) {
envReady(config, function(config) {
rootReady(config, function(config) {
activateReady(config, function(config) {
recordReady(config, function(exists, config) {
if (argv.length >= 4) {
id = argv[3], config.id = target;
if (ecosystemExist(config)) {
list.run(config);
// Subcommand list
else if (argv.cmd === 'list') {
filterConfig(function() {
recordReady(argv.cmd, function(exists) {
if (argv.id) {
if (ecosystemExist(argv.id)) {
list.run(argv);
} else {
error = 'The desired ecosystem '+id+' is not exists.';
message = 'The desired ecosystem '+argv.id+' is not exists.';
suggestion = 'Find out all the existing ecosystem.';
example = 'neco list';
log('error', error, suggestion, example);
log.emit('exit', message, suggestion, example);
}
} else {
list.run(config)
list.run(argv)
}
});
});
});
});
});
});
});
}
}
// Subcommand find
else if (cmd === 'find') {
parseGlobalConfig(function(config) {
config.cmd = cmd;
parsePkgConfig(config, function(config) {
parseUserConfig(config, function(config) {
envReady(config, function(config) {
rootReady(config, function(config) {
activateReady(config, function(config) {
recordReady(config, function(exists, config) {
if (argv.length >= 4) {
target = argv[3], config.target = target;
if (releaseExist(config)) {
find.run(config);
} else {
error = 'The desired release '+target+' is not available.';
suggestion = 'Find out all the available releases.';
example = 'neco find [stable, latest, node-version]';
log('error', error, suggestion, example);
}
// Subcommand find
else if (argv.cmd === 'find') {
filterConfig(function() {
recordReady(argv.cmd, function(exists) {
if (argv.target) {
if (releaseExist(argv.target)) {
find.run(argv);
} else {
find.run(config);
message = 'The desired release '+argv.target+' is not available.';
suggestion = 'Find out all the available releases.';
example = 'neco find [stable, latest, node-version]';
log.emit('exit', message, suggestion, example);
}
});
} else {
find.run(argv);
}
});
});
});
});
});
});
}
}
// Subcommand help
else if (cmd === 'howto') {
parseGlobalConfig(function(config) {
parsePkgConfig(config, function(config) {
parseUserConfig(config, function(config) {
howto.run(config);
});
});
});
}
// Subcommand howto
else if (argv.cmd === 'howto') {
filterConfig(function() {
howto.run(argv);
});
}
// Subcommand activate
else if (cmd === 'activate') {
if (argv.length < 4) {
message = 'Missing ID';
suggestion = 'Please specify the id of the ecosystem you want to activate.';
example = 'neco activate <id>';
log('message', message, suggestion, example);
} else {
id = process.argv[3];
parseGlobalConfig(function(config) {
config.id = id, config.cmd = cmd;
parseEcosystemConfig(config, function(config) {
parsePkgConfig(config, function(config) {
parseUserConfig(config, function(config) {
envReady(config, function(config) {
rootReady(config, function(config) {
activateReady(config, function(config) {
recordReady(config, function(exists, config) {
if (ecosystemActive(config)) {
warning = 'The node ecosystem with id '+id+' is already active.';
suggstion = 'Please use type deact in your shell to deactivate it.';
log('warning', warning, suggestion, example);
} else if (!idExsit(config)) {
warning = 'The node ecosystem with id '+id+' is not exists.';
suggestion = 'You can use neco list command to find out all existing ecosystem.';
example = 'neco create <id> [node-version]';
log('warning', warning, suggestion, example);
} else {
activate.run(config);
}
});
// Subcommand activate
else if (argv.cmd === 'activate') {
if (!argv.id) {
message = 'Missing ID';
suggestion = 'Please specify the id of the ecosystem you want to activate.';
example = 'neco activate <id>';
log.emit('exit', message, suggestion, example);
} else {
parseEcosystemConfig(argv.id, function() {
filterConfig(function() {
recordReady(argv.cmd, function(exists) {
if (ecosystemActive(argv.id)) {
message = 'The node ecosystem with id '+argv.id+' is already active.';
suggstion = 'Please use type deact in your shell to deactivate it.';
log.emit('exit', message, suggestion, example);
} else if (!idExsit(argv.id)) {
messge = 'The node ecosystem with id '+argv.id+' is not exists.';
suggestion = 'You can use neco list command to find out all existing ecosystem.';
example = 'neco create <id> [node-version]';
log.emit('exit', message, suggestion, example);
} else {
activate.run(argv);
}
});
});
});
});
});
});
});
}
}
}
}
// Subcommand deactvate
else if (cmd === 'deactivate') {
if (argv.length < 4) {
message = 'Missing ID';
suggestion = 'Please specify the id of the ecosystem you want to deactivate.';
example = 'neco deactivate <id>';
log('message', message, suggestion, example);
} else {
id = process.argv[3];
parseGlobalConfig(function(config) {
config.id = id, config.cmd = cmd;
parseEcosystemConfig(config, function(config) {
parsePkgConfig(config, function(config) {
parseUserConfig(config, function(config) {
envReady(config, function(config) {
rootReady(config, function(config) {
activateReady(config, function(config) {
recordReady(config, function(exists, config) {
if (!idExsit(config)) {
error = 'The node ecosystem with id '+id+' is not exists.';
// Subcommand deactvate
else if (argv.cmd === 'deactivate') {
if (!argv.id) {
message = 'Missing ID';
suggestion = 'Please specify the id of the ecosystem you want to deactivate.';
example = 'neco deactivate <id>';
log.emit('exit', message, suggestion, example);
} else {
parseEcosystemConfig(argv.id, function() {
filterConfig(function() {
recordReady(argv.cmd, function(exists) {
if (!idExsit(argv.id)) {
message = 'The node ecosystem with id '+argv.id+' is not exists.';
suggestion = 'You can use neco list command to find out all existing ecosystem.';
example = 'neco list';
log('error', error, suggestion, example);
} else if (!ecosystemActive(config)) {
error = 'The node ecosystem with id '+id+' is not active.';
log.emit('exit', message, suggestion, example);
} else if (!ecosystemActive(argv.id)) {
message = 'The node ecosystem with id '+argv.id+' is not active.';
suggestion = 'Use neco activate command to activate it first.';
example = 'neco_activate '+ id;
log('error', error, suggestion, example);
example = 'neco_activate '+ argv.id;
log.emit('exit', message, suggestion, example);
} else {
deactivate.run(config);
deactivate.run(argv);
}

@@ -241,52 +197,39 @@ });

});
});
});
});
});
});
}
}
}
}
// Subcommand remove
else if (cmd === 'remove') {
if (argv.length < 4) {
message = 'Missing ID';
suggestion = 'Please specific the ID of the ecosystem that you want to remove.';
example = 'neco remove <id>';
log('message', message, suggestion, example);
} else {
id = argv[3];
parseGlobalConfig(function(config) {
config.id = id, config.cmd = cmd;
parseEcosystemConfig(config, function(config) {
parsePkgConfig(config, function(config) {
parseUserConfig(config, function(config) {
envReady(config, function(config) {
rootReady(config, function(config) {
activateReady(config, function(config) {
recordReady(config, function(exists, config) {
if (!idExsit(config)) {
message = 'The given id '+id+' is not exist.';
suggestion = 'Find out all existing ecosystem.';
example = 'neco list'
log('message', message, suggestion, example);
} else if (ecosystemActive(config)) {
message = 'The given ecosystem with id '+id+' is in active.';
suggestion = 'Please deactivate it first.';
example = 'neco_deactivate'
log('message', message, suggestion, example);
} else {
remove.run(config);
}
});
// Subcommand remove
else if (argv.cmd === 'remove') {
if (!argv.id) {
message = 'Missing ID';
suggestion = 'Please specific the ID of the ecosystem that you want to remove.';
example = 'neco remove <id>';
log.emit('exit', message, suggestion, example);
} else {
parseEcosystemConfig(argv.id, function() {
filterConfig(function() {
recordReady(argv.cmd, function(exists) {
if (!idExsit(argv.id)) {
message = 'The given id '+argv.id+' is not exist.';
suggestion = 'Find out all existing ecosystem.';
example = 'neco list'
log.emit('exit', message, suggestion, example);
} else if (ecosystemActive(argv.id)) {
message = 'The given ecosystem with id '+argv.id+' is in active.';
suggestion = 'Please deactivate it first.';
example = 'neco_deactivate'
log.emit('exit', message, suggestion, example);
} else {
remove.run(argv);
}
});
});
});
});
});
});
});
}
}
}
}
});});
});});
});});
}
var path = require('path'),
color = require('ansi-color').set;
exports.run = function(config) {
var shell = color('source '+config.globalActivateFile, 'bold+yellow');
var deactivate = color('neco_deactivate', 'bold+yellow');
exports.run = function(argv) {
var config = process.neco.config, id = argv.id,
shell = color('source '+config.globalActivateFile, 'bold+yellow');
deactivate = color('neco_deactivate', 'bold+yellow');
console.log('add \''+shell+'\' to your .bashrc or .zshrc file, :)');
console.log('Then run '+color('neco_activate '+config.id, 'bold+yellow')+' in you shell.');
console.log('Then run '+color('neco_activate '+id, 'bold+yellow')+' in you shell.');
console.log('To deactivate it, run \''+deactivate+'\' in you shell.');
};

@@ -11,3 +11,3 @@ var fs = require('fs'),

findlongestID = require('../lib/utils.js').findlongestID,
writeGlobalConfigFile = require('../lib/assistant.js').writeGlobalConfigFile,
writeLocalConfigFile = require('../lib/assistant.js').writeLocalConfigFile,
writeEcosystemConfigFile = require('../lib/assistant.js').writeEcosystemConfigFile,

@@ -22,23 +22,25 @@ getNodeInstallScript = require('../lib/assistant.js').getNodeInstallScript,

function installNode(config, callback) {
var error, version, link, install,
destDir = config.destDir, script = getNodeInstallScript(config);
function installNode(release, destDir, next) {
var error, version, link, install,
config = process.neco.config,
root = config.root,
script = getNodeInstallScript();
path.exists(config.root, function(exists) {
path.exists(root, function(exists) {
if (!exists) {
fs.mkdirSync(config.root, mode=0777);
fs.mkdirSync(root, mode=0777);
} else {
if (config.release.realver) {
version = config.release.realver;
if (release.realver) {
version = release.realver;
} else {
version = config.release.version;
version = release.version;
}
link = config.release.link;
link = release.link;
install = spawn('sh', [script, version, link, destDir]);
install.stdout.on('data', function(data) {
log('stdout',data);
log.emit('stdout',data);
});
install.stderr.on('data', function(data) {
log('stdout',data);
log.emit('stdout',data);
});

@@ -49,5 +51,5 @@

error = new Error('Installing node exit wich code ' + code);
callback(error, config);
next(error);
} else {
callback(error, config);
next(error);
}

@@ -59,12 +61,14 @@ });

function installNPM(config, callback) {
var error, destDir = config.destDir, pkgDir = config.pkgDir,
script = getNPMInstallScript(config), npmVer = config.npmVer;
function installNPM(destDir, npmVer, next) {
var error,
config = process.neco.config,
pkgDir = config.pkgDir,
script = getNPMInstallScript(),
install = spawn('sh', [script, pkgDir, destDir, npmVer]);
install.stdout.on('data', function(data) {
log('stdout', data);
log.emit('stdout', data);
});
install.stderr.on('data', function(data) {
log('stdout', data);
log.emit('stdout', data);
});

@@ -74,5 +78,5 @@ install.on('exit', function(code) {

error = new Error('Installing NPM exit with code ' + code);
callback(error, config);
next(error);
} else {
callback(error, config);
next(error);
}

@@ -82,13 +86,26 @@ });

function installActivate(config, callback) {
var error, id = config.id, version = config.release.version,
pkgDir = config.pkgDir, destDir = config.destDir,
script = getActivateInstallScript(config),
function makeAppDirectory(id, next) {
var config = process.neco.config,
root = config.root,
// appDir = path.join(root, '.neco', id, 'application'),
appDir = path.join(root, id);
fs.mkdir(appDir, mode=0777, function(err) {
next(err);
});
}
function installActivate(id, release, destDir, next) {
var error,
config = process.neco.config,
version = release.version,
pkgDir = config.pkgDir,
script = getActivateInstallScript(),
install = spawn('sh', [script, id, pkgDir, destDir, version]);
install.stdout.on('data', function(data) {
log('stdout', data);
log.emit('stdout', data);
});
install.stderr.on('data', function(data) {
log('stdout', data);
log.emit('stdout', data);
});

@@ -98,5 +115,5 @@ install.on('exit', function(code) {

error = new Error('Installing Activate exit with code ' + code);
callback(error, config);
next(error);
} else {
callback(error, config);
next(error);
}

@@ -106,8 +123,10 @@ });

function makeRecord(config) {
var error, npmVer = config.npmVer || 'none',
id = config.id, version = config.release.version,
record, recordData, createdDate, ecosystems, newEcosystem,
recordFile = path.join(config.root, '.neco', 'record.json'),
date = getDateTime(config);
function makeRecord(id, release, npmVer, next) {
var error,
config = process.neco.config,
date = getDateTime(),
version = release.version,
root = config.root,
recordFile = path.join(root, '.neco', 'record.json'),
record, recordData, createdDate, ecosystems, newEcosystem;

@@ -130,9 +149,3 @@ path.exists(recordFile, function(exists) {

fs.writeFile(recordFile, recordData, 'utf8', function(err) {
if (err) {throw err;}
message = 'New node ecosystem has been created sucessfully!';
log('message', message);
writeGlobalConfigFile(config, function(err, config) {
if (err) {throw err;}
writeEcosystemConfigFile(config);
});
next(err);
});

@@ -142,33 +155,92 @@ });

exports.run = function(config) {
config.release = getRelease(config);
if (!config.release) {
error = 'The desired release '+config.target+' not found or neco can\'t handle it.';
function makeConfigFiles(argv, next) {
process.neco.ecosystemConfig = {};
process.neco.ecosystemConfig.id = argv.id;
process.neco.ecosystemConfig.app = argv.app;
process.neco.ecosystemConfig.description = argv.d;
writeLocalConfigFile(argv.id, function(err) {
if (err) {log.emit('error', err);}
writeEcosystemConfigFile(argv, next);
});
}
exports.run = function(argv) {
var config = process.neco.config,
id = argv.id, target = argv.target || 'stable',
release = getRelease(target), npmVer = 'none',
destDir = path.join(config.root, '.neco', id);
if (!release) {
message = 'The desired release '+target+' not found or neco can\'t handle it.';
suggestion = 'Try a newer version.';
example = 'neco create <id> stable OR neco create <id> latest';
log('error', error, suggestion, example);
log.emit('message', message, suggestion, example);
} else {
// If the version of release smaller and equal to 0.1,9,
// add 'v' prefix to version laterial
if (notSmaller(config.release.version, vStartsFrom) >= 0) {
config.release.realver = 'v'.concat(config.release.version);
}
config.destDir = path.join(config.root, '.neco', config.id);
installNode(config, function(err, config) {
if (err) {throw err;}
if (config.installNPM && getSuitedNPM(config)) {
config.npmVer = getSuitedNPM(config);
installNPM(config, function(err, config) {
if (err) {throw err;}
installActivate(config, function(err, config) {
if (err) {throw err;}
makeRecord(config);
});
release.realver = (notSmaller(release.version, vStartsFrom) >= 0) ? 'v'.concat(release.version) : null;
installNode(release, destDir, function(err) {
if (err) {log.emit('error',err);}
message = 'Nodejs '+release.version+' has been installed sucessfully!';
log.emit('message', message);
if ((config.installNPM || argv.npm) && getSuitedNPM(release)) {
npmVer = getSuitedNPM(release);
installNPM(destDir, npmVer, function(err) {
if (err) {log.emit('error', err);}
message = 'NPM '+npmVer+' has been installed sucessfully!';
log.emit('message', message);
if (argv.app) {
makeAppDirectory(id, function(err) {
if (err) {log.emit('error', err);}
message = 'The applicaton directory has been created sucessfully!';
log.emit('message', message);
installActivate(id, release, destDir, function(err) {
if (err) {log.emit('error', err);}
message = 'New activate file has been installed sucessfully!';
log.emit('message', message);
makeRecord(id, release, npmVer, function(err) {
if (err) {log.emit('error', err);}
message = 'Record file has been edited sucessfully!';
log.emit('message', message);
makeConfigFiles(argv, function(err) {
if (err) {log.emit('error', err);}
message = 'New node ecosystem has been created sucessfully!';
log.emit('message', message);
});
});
});
});
} else {
installActivate(id, release, destDir, function(err) {
if (err) {log.emit('error', err);}
message = 'New activate file has been installed sucessfully!';
log.emit('message', message);
makeRecord(id, release, npmVer, function(err) {
if (err) {log.emit('error', err);}
message = 'Record file has been edited sucessfully!';
log.emit('message', message);
makeConfigFiles(argv, function(err) {
if (err) {log.emit('error', err);}
message = 'New node ecosystem has been created sucessfully!';
log.emit('message', message);
});
});
});
}
});
} else {
installActivate(config, function(err, config) {
if (err) {throw err;}
makeRecord(config);
installActivate(id, release, destDir, function(err) {
message = 'New activate file has been created sucessfully!';
log.emit('message', message);
if (err) {log.emit('error', err);}
makeRecord(id, release, npmVer, function(err) {
if (err) {log.emit('error', err);}
message = 'Record file has been edited sucessfully!';
log.emit('message', message);
makeConfigFiles(argv, function(err) {
if (err) {log.emit('error', err);}
message = 'New node ecosystem has been created sucessfully!';
log.emit('message', message);
});
});
});

@@ -175,0 +247,0 @@ }

var path = require('path'),
color = require('ansi-color').set;
exports.run = function(config) {
var shell = color('neco_deactivate', 'bold+yellow');
exports.run = function(argv) {
var id = argv.id,
shell = color('neco_deactivate', 'bold+yellow');
console.log('run \''+shell+' command in your shell, :)');
};
var fs = require('fs'),
path = require('path'),
show = require('../lib/display.js').showReleases,
log = require('../lib/display.js').lo9,
show = require('../lib/display.js').show,
getRelease = require('../lib/assistant.js').getRelease;
exports.run = function(config) {
var release;
config.releases = [];
fs.readFile(config.distFile, 'utf8', function(err, data) {
if (err) {throw err;}
if (config.target) {
release = getRelease(config);
config.releases[0] = release;
exports.run = function(argv) {
var target = argv.target,
release, releases = [],
config = process.neco.config;
fs.readFile(config.localDistFile, 'utf8', function(err, data) {
if (err) {log.emit('error', err);}
if (target) {
release = getRelease(target);
releases[0] = release;
} else {
config.releases = JSON.parse(data).history;
releases = JSON.parse(data).history;
}
show(config);
show.emit('releases', releases);
});
};
var path = require('path');
exports.run = function(config) {
if (config.cmd === undefined) {
exports.run = function(argv) {
if (argv.target === undefined) {
console.log('neco - Nodejs Ecosystem COordinator, like virtualenv for python.');
console.log('');
console.log('Usage:\n neco <command>');

@@ -7,0 +8,0 @@ console.log('');

var fs = require('fs'),
path = require('path'),
log = require('../lib/display.js').log,
getEcosystem = require('../lib/assistant.js').getEcosystem,
show = require('../lib/display.js').showEcosystems;
show = require('../lib/display.js').show;
exports.run = function(config) {
var ecosystem;
config.ecosystems = [];
exports.run = function(argv) {
var config = process.neco.config,
ecosystem, ecosystems = [];
fs.readFile(config.recordFile, 'utf8', function(err, data) {
if (err) {throw err;}
if (config.target) {
ecosystem = getEcosystem(config);
config.ecosystems[0] = ecosystem;
if (err) {log.emit('error', err);}
if (argv.id) {
ecosystem = getEcosystem(argv.id);
ecosystems[0] = ecosystem;
} else {
config.ecosystems = JSON.parse(data).ecosystems;
ecosystems = JSON.parse(data).ecosystems;
}
show(config);
show.emit('ecosystems', ecosystems);
});
};
var fs = require('fs'),
path = require('path'),
spawn = require('child_process').spawn,
log = require('../lib/display.js').log,
removeEcosystem = require('../lib/utils.js').removeEcosystem,
getEcosystem = require('../lib/assistant.js').getEcosystem,
writeGlobalConfigFile = require('../lib/assistant.js').writeGlobalConfigFile;
writeLocalConfigFile = require('../lib/assistant.js').writeLocalConfigFile;

@@ -11,5 +12,5 @@ var log = require('../lib/display.js').log;

function removeDir(config, next) {
var error, remove, targetDir;
targetDir = path.join(config.root, '.neco', config.id);
function removeDir(id, next) {
var error, remove, config = process.neco.config,
root = config.root, targetDir = path.join(root, '.neco', id);

@@ -23,6 +24,6 @@ path.exists(targetDir, function(exists) {

remove.stdout.on('data', function(data) {
log('stdout', data);
log.emit('stdout', data);
});
remove.stderr.on('data', function(data) {
log('stdout', data);
log.emit('stdout', data);
});

@@ -32,5 +33,5 @@ remove.on('exit', function(code) {

err = new Error('Remove exit with code '+code);
next(error, config);
next(error);
} else {
next(error, config);
next(error);
}

@@ -42,5 +43,8 @@ });

function editRecord(config, next) {
var error, index, record, ecosystem, recordData,
id = config.id, recordFile = config.recordFile;
function editRecord(id, next) {
var error, index, record,
ecosystem, recordData,
config = process.neco.config,
recordFile = config.recordFile;
path.exists(recordFile, function(exists) {

@@ -52,3 +56,3 @@ if (!exists) {

fs.readFile(recordFile, 'utf8', function(err, data) {
if (err) {throw err;}
if (err) {log.emit('error', err);}
record = JSON.parse(data);

@@ -59,3 +63,3 @@ record.ecosystems = removeEcosystem(record.ecosystems, id);

error = err;
next(error, config);
next(error);
});

@@ -67,19 +71,25 @@ });

function editConfig(config) {
var id = config.id;
writeGlobalConfigFile(config, function(err, config) {
if (err) {throw err;}
message = 'ecosystem '+id+' has been removed sucessfully.';
log('message', message);
function editConfig(id) {
var config = process.neco.config;
writeLocalConfigFile(id, function(err, id) {
if (err) {log.emit('error', err);}
message = 'Ecosystem '+id+' has been removed sucessfully!';
log.emit('exit', message);
});
}
exports.run = function(config) {
removeDir(config, function(err) {
if (err) {throw err;}
editRecord(config, function(err, config) {
if (err) {throw err;}
editConfig(config);
exports.run = function(argv) {
var id = argv.id;
removeDir(id, function(err) {
if (err) {log.emit('error', err);}
message = 'Target directory has been removeed sucessfully!';
log.emit('message', message);
editRecord(id, function(err) {
if (err) {log.emit('error', err);}
message = 'Ecosystems record file has been edited sucessfully!';
log.emit('message', message);
editConfig(id);
});
});
};

@@ -1,4 +0,4 @@

{ "releases":69,
{ "releases":71,
"stable":"0.2.6",
"latest":"0.3.5",
"latest":"0.3.7",
"history":[

@@ -53,4 +53,6 @@ {"version":"latest","link":"http://nodejs.org/dist/node-latest.tar.gz","released":"31-Dec-2010 05:02","size":4010320},

{"version":"0.3.4","link":"http://nodejs.org/dist/node-v0.3.4.tar.gz","released":"08-Jan-2011 23:50","size":4610441},
{"version":"0.3.5","link":"http://nodejs.org/dist/node-v0.3.5.tar.gz","released":"16-Jan-2011 23:15","size":4655131}
{"version":"0.3.5","link":"http://nodejs.org/dist/node-v0.3.5.tar.gz","released":"16-Jan-2011 23:15","size":4655131},
{"version":"0.3.6","link":"http://nodejs.org/dist/node-v0.3.6.tar.gz","released":"22-Jan-2011 02:19","size":4727071},
{"version":"0.3.7","link":"http://nodejs.org/dist/node-v0.3.7.tar.gz","released":"28-Jan-2011 04:54","size":4748183}
]
}

@@ -1,4 +0,5 @@

{ "releases":69,
{ "releases":71,
"stable":"0.2.6",
"unstable":"0.3.5"
"unstable":"0.3.7"
"latest":"latest",
"history":[

@@ -73,4 +74,6 @@ {"version":"latest","link":"http://nodejs.org/dist/node-latest.tar.gz","released":"31-Dec-2010 05:02","size":4010320},

{"version":"0.3.4","link":"http://nodejs.org/dist/node-v0.3.4.tar.gz","released":"08-Jan-2011 23:50","size":4610441},
{"version":"0.3.5","link":"http://nodejs.org/dist/node-v0.3.5.tar.gz","released":"16-Jan-2011 23:15","size":4655131}
{"version":"0.3.5","link":"http://nodejs.org/dist/node-v0.3.5.tar.gz","released":"16-Jan-2011 23:15","size":4655131},
{"version":"0.3.6","link":"http://nodejs.org/dist/node-v0.3.6.tar.gz","released":"22-Jan-2011 02:19","size":4727071},
{"version":"0.3.7","link":"http://nodejs.org/dist/node-v0.3.7.tar.gz","released":"28-Jan-2011 04:54","size":4748183}
]
}
{
"coulps":
[
{"node":"0.2.3", "npm":"0.2.14-6"}
{"node":"0.2.3", "npm":"0.2.16"}
]
}

@@ -7,4 +7,3 @@

var mkdir = require("./utils/mkdir-p")
, npm = require("../npm")
var npm = require("../npm")
, fs = require("./utils/graceful-fs")

@@ -11,0 +10,0 @@ , log = require("./utils/log")

@@ -186,3 +186,4 @@

if (er) return cb(new Error(
"Required package: "+req.name+"("+req.version+") not found."))
"Required package: "+req.name+"("+req.version+") not found."+
"\n(required by: "+pkg._id+")"))
// TODO: Get the "stable" version if there is one.

@@ -194,3 +195,4 @@ // Look that up from the registry.

"Required package: "+req.name+"("+req.version+") not found. "+
"(Found: "+JSON.stringify(versions)+")"))
"(Found: "+JSON.stringify(versions)+")"+
"\n(required by: "+pkg._id+")"))
})

@@ -228,3 +230,2 @@ }, function (er, found) {

function dependencyLink (pkg, cb) {
pkg.link = pkg.link || {}
var dependencies = path.join(npm.dir, pkg.name, pkg.version, "node_modules")

@@ -251,9 +252,2 @@ , depBin = path.join(npm.dir, pkg.name, pkg.version, "dep-bin")

linkBins(dep, depBin, false, cb)
}, function (dep, cb) {
var linkToLib = (pkg.link || {}).hasOwnProperty(dep.name)
? path.join( npm.dir, pkg.name, pkg.version
, "package", pkg.link[dep.name]
)
: null
linkToLib ? linkModules(dep, linkToLib, cb) : cb()
}, cb)

@@ -260,0 +254,0 @@ })

@@ -13,2 +13,3 @@

, rm = require("./utils/rm-rf")
, url = require("url")
, notAllowed = [ "adduser", "build", "bundle", "config", "init", "link"

@@ -75,15 +76,12 @@ , "owner", "publish", "restart", "start", "stop", "tag"

mkdir(npm.dir, function(er) {
if (er) return log.er(cb, "Error creating "+npm.dir+" for bundling")(er)
if (typeof cmd === "function") {
return cmd(args, cb)
}
if (typeof cmd === "function") {
return cmd(args, cb)
}
// no command given, just install the local deps.
// just read the package.json from the directory to
// avoid adding the whole package to the cache
readJson(path.join(pkg, "package.json"), function (er, data) {
if (er) return log.er(cb, "Error reading "+pkg+"/package.json")(er)
install(data, location, cb)
})
// no command given, just install the local deps.
// just read the package.json from the directory to
// avoid adding the whole package to the cache
readJson(path.join(pkg, "package.json"), function (er, data) {
if (er) return log.er(cb, "Error reading "+pkg+"/package.json")(er)
install(data, location, cb)
})

@@ -101,2 +99,6 @@ })

if (v === "*") v = ""
var u = url.parse(v)
if (u && u.protocol && u.host) {
return u.href
}
return v ? d + "@" + v : d

@@ -103,0 +105,0 @@ })

@@ -190,5 +190,7 @@

}
function addRemoteTarball (url, shasum, cb) {
function addRemoteTarball (url, shasum, name, cb) {
if (!cb) cb = name, name = ""
if (!cb) cb = shasum, shasum = null
log.verbose([url, shasum], "addRemoteTarball")
if (!cb) cb = shasum, shasum = null
// todo: take a shasum, and validate it.

@@ -207,5 +209,6 @@ var tmp = path.join(npm.tmp, Date.now()+"-"+Math.random(), "tmp.tgz")

if (er) return cb(er)
addLocalTarball(tmp, cb)
addLocalTarball(tmp, name, cb)
}
}
function addNameVersion (name, ver, cb) {

@@ -226,3 +229,3 @@ registry.get(name, ver, function (er, data, json, response) {

return addRemoteTarball( data.dist.tarball.replace(/^https/,'http')
, data.dist.shasum, cb)
, data.dist.shasum, name+"-"+ver, cb)
}

@@ -232,14 +235,17 @@ })

function addLocal (p, cb) {
function addLocal (p, name, cb) {
if (!cb) cb = name, name = ""
// figure out if this is a folder or file.
fs.stat(p, function (er, s) {
if (er) return log.er(cb, "Doesn't exist: "+p)(er)
if (s.isDirectory()) addLocalDirectory(p, cb)
else addLocalTarball(p, cb)
if (s.isDirectory()) addLocalDirectory(p, name, cb)
else addLocalTarball(p, name, cb)
})
}
function addLocalTarball (p, cb) {
function addLocalTarball (p, name, cb) {
if (!cb) cb = name, name = ""
// if it's a tar, and not in place,
// then unzip to .tmp, add the tmp folder, and clean up tmp
if (p.indexOf(npm.tmp) === 0) return addTmpTarball(p, cb)
if (p.indexOf(npm.tmp) === 0) return addTmpTarball(p, name, cb)

@@ -249,7 +255,8 @@ if (p.indexOf(npm.cache) === 0) {

"Not a valid cache tarball name: "+p))
return addPlacedTarball(p, cb)
return addPlacedTarball(p, name, cb)
}
// just copy it over and then add the temp tarball file.
var tmp = path.join(npm.tmp, Date.now() + "-" + Math.random(), "tmp.tgz")
var tmp = path.join(npm.tmp, name + Date.now()
+ "-" + Math.random(), "tmp.tgz")
mkdir(path.dirname(tmp), function (er) {

@@ -270,3 +277,3 @@ if (er) return cb(er)

if (er) return cb(er)
addTmpTarball(tmp, cb)
addTmpTarball(tmp, name, cb)
})

@@ -277,3 +284,5 @@ })

}
function addPlacedTarball (p, cb) {
function addPlacedTarball (p, name, cb) {
if (!cb) cb = name, name = ""
// now we know it's in place already as .cache/name/ver/package.tgz

@@ -307,3 +316,5 @@ // unpack to .cache/name/ver/package/, read the package.json,

}
function addLocalDirectory (p, cb) {
function addLocalDirectory (p, name, cb) {
if (!cb) cb = name, name = ""
// if it's a folder, then read the package.json,

@@ -326,7 +337,9 @@ // tar it to the proper place, and add the cache tar

if (er) return log.er(cb,"couldn't pack "+p+ " to "+tgz)(er)
addLocalTarball(tgz, cb)
addLocalTarball(tgz, name, cb)
})
})
}
function addTmpTarball (tgz, cb) {
function addTmpTarball (tgz, name, cb) {
if (!cb) cb = name, name = ""
var contents = path.join(path.dirname(tgz),"contents")

@@ -350,3 +363,3 @@ unpackTar(tgz, contents, function (er) {

if (er) return log.er(cb, "couldn't rename "+folder+" to package")(er)
addLocalDirectory(newName, cb)
addLocalDirectory(newName, name, cb)
})

@@ -353,0 +366,0 @@ })

@@ -11,4 +11,3 @@

var mkdir = require("./utils/mkdir-p")
, npm = require("../npm")
var npm = require("../npm")
, fs = require("./utils/graceful-fs")

@@ -15,0 +14,0 @@ , log = require("./utils/log")

@@ -38,3 +38,2 @@

, fetch = require("./utils/fetch")
, mkdir = require("./utils/mkdir-p")
, readJson = require("./utils/read-json")

@@ -41,0 +40,0 @@ , log = require("./utils/log")

@@ -10,3 +10,2 @@

, rm = require("./utils/rm-rf")
, mkdir = require("./utils/mkdir-p")
, path = require("path")

@@ -13,0 +12,0 @@ , crypto

@@ -183,3 +183,7 @@

var stdio = process.binding("stdio")
, cols = stdio.isatty(stdio.stdoutFD) ? stdio.getColumns() : Infinity
, cols = stdio.isatty(stdio.stdoutFD) ?
( stdio.getColumns ? stdio.getColumns()
: stdio.getWindowSize ? stdio.getWindowSize()[1]
: Infinity )
: Infinity
}

@@ -190,4 +194,4 @@ catch (ex) { cols = Infinity }

return (line.name + (space.substr(0, addSpace) || "") + " "
+ line.attrs + " "
+ (line.description ? line.description + " " : "")
+ line.attrs
+ (line.keywords.length ? " " + line.keywords.join(" ") : ""))

@@ -229,4 +233,10 @@ .substr(0, cols)

merged[p].versions[v].tags = []
var descs = remote[p].descriptions
if (descs && descs[v] && descs[v] !== remote[p].description) {
merged[p].versions[v].description = descs[v]
}
Object.keys(remote[p]["dist-tags"]).forEach(function (tag) {
if (remote[p]["dist-tags"][tag] === v) merged[p].versions[v].tags.push(tag)
if (remote[p]["dist-tags"][tag] === v) {
merged[p].versions[v].tags.push(tag)
}
})

@@ -233,0 +243,0 @@ }

@@ -62,7 +62,8 @@ /*

if (er) return log.verbose(pkg, "not in registry", cb)
try {
Object.keys(data.versions).forEach(function (v) {
readJson.processJson(data.versions[v])
})
} catch (er) { return cb(er) }
Object.keys(data.versions).forEach(function (v) {
try {
data.versions[v] = readJson.processJson(data.versions[v])
} catch (er) { delete data.versions[v] }
})
log.silly(data.versions, (data._id || data.name)+" versions")
var latest = data["dist-tags"] && data["dist-tags"][tag]

@@ -69,0 +70,0 @@ , have = Object.keys(inst[pkg]).sort(semver.sort)

@@ -5,3 +5,3 @@

var npm = require("../npm")
, registry = require("./utils/registry")
, rpub = require("./utils/registry/publish")
, log = require("./utils/log")

@@ -20,4 +20,4 @@

if (!data) return cb(new Error("no package.json file found"))
registry.publish(data, npm.config.get("registry"), cb)
rpub(data, cb)
})
}

@@ -1,1 +0,21 @@

module.exports = require("./utils/lifecycle").cmd("test")
module.exports = test
var lifecycle = require("./utils/lifecycle")
, cmd = lifecycle.cmd("test")
, path = require("path")
, readJson = require("./utils/read-json")
, chain = require("./utils/chain")
test.usage = cmd.usage
function test (args, cb) {
if (!args.length) {
readJson(path.join(process.cwd(), "package.json"), function (er, d) {
if (er) return cb(test.usage)
chain(["pretest", "test", "posttest"].map(function (s) {
return [lifecycle, d, s, process.cwd()]
}).concat(cb))
})
}
else cmd(args, cb)
}

@@ -25,3 +25,2 @@

, semver = require("./utils/semver")
, mkdir = require("./utils/mkdir-p")
, asyncMap = require("./utils/async-map")

@@ -35,2 +34,3 @@ , loadPackageDefaults = require("./utils/load-package-defaults")

// this way, it won't whine about not being able to remove anything, ever.
if (!args.length) return rmCwdPkg(cb)
unpackArgs(args, function (er, args) {

@@ -56,2 +56,9 @@ if (args.length) log.verbose(args, "removing")

function rmCwdPkg (cb) {
readJson(path.join(process.cwd(), "package.json"), function (er, d) {
if (er) return cb(uninstall.usage)
return uninstall([d._id], cb)
})
}
// if any deps are found, and are valid (have a package.json),

@@ -258,17 +265,12 @@ // and are not also on the list, then yell about it.

var dependsOn = path.join(npm.dir, data.name, data.version, "dependson")
// TODO: remove this mkdir kludge
// A workaround for the fact that this dir didn't exist prior to 0.1.20
mkdir(dependsOn, function (er) {
if (er) return cb() // meh
fs.readdir(dependsOn, function (er, deps) {
if (er) return cb(er)
asyncMap(deps, function (dep, cb) {
// <3 symlinks
var p = path.join(dependsOn, dep, "dependents", data.name)
, v = data.version
// todo: remove this kludge v0.1.28
// just do the "@" only.
asyncMap([p+"@"+v, p+"-"+v], rm, cb)
}, cb)
})
fs.readdir(dependsOn, function (er, deps) {
if (er) return cb() // no deps, or a fossil.
asyncMap(deps, function (dep, cb) {
// <3 symlinks
var p = path.join(dependsOn, dep, "dependents", data.name)
, v = data.version
// todo: remove this kludge v0.1.28
// just do the "@" only.
asyncMap([p+"@"+v, p+"-"+v], rm, cb)
}, cb)
})

@@ -275,0 +277,0 @@ }

@@ -7,2 +7,4 @@

, npm = require("../npm")
, readJson = require("./utils/read-json")
, path = require("path")

@@ -20,3 +22,14 @@ unpublish.usage = "npm unpublish <project>[@<version>]"

, version = thing.join("@")
if (!project) return cb("Usage:\n"+unpublish.usage)
if (!project) {
// if there's a package.json in the current folder, then
// read the package name and version out of that.
var cwdJson = path.join(process.cwd(), "package.json")
return readJson(cwdJson, function (er, data) {
if (er) return cb("Usage:\n"+unpublish.usage)
gotProject(data.name, data.version, cb)
})
}
return gotProject(project, version, cb)
}
function gotProject (project, version, cb) {
// remove from the cache first

@@ -23,0 +36,0 @@ npm.commands.cache(["clean", project, version], function (er) {

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�_���"�"com.macromates.caret{
Mac OS X  2��ATTR䁛��"�"com.macromates.caret{
column = 41;
line = 1;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�_���"�"com.macromates.caret{
Mac OS X  2��ATTR䁪��"�"com.macromates.caret{
column = 0;
line = 18;
}

@@ -16,3 +16,3 @@

function asyncMap (list) {
function asyncMap () {
var steps = Array.prototype.slice.call(arguments)

@@ -23,2 +23,3 @@ , list = steps.shift() || []

"No callback provided to asyncMap")
if (!list) return cb_(null, [])
if (!Array.isArray(list)) list = [list]

@@ -25,0 +26,0 @@ var n = steps.length

@@ -15,2 +15,4 @@ /**

, consts
, path = require("path")
, mkdir = require("./mkdir-p")

@@ -28,2 +30,9 @@ try {

log.verbose(local, "fetch to")
mkdir(path.dirname(local), function (er) {
if (er) return cb(er)
fetch_(remote, local, headers, cb)
})
}
function fetch_ (remote, local, headers, cb) {
var r = url.parse(remote)

@@ -109,3 +118,2 @@ headers.host = r.hostname + (r.port ? ":"+r.port : "")

, "http://nodejs.org/dist/node-latest.tar.gz"
]

@@ -112,0 +120,0 @@ , path = require("path")

@@ -37,3 +37,2 @@ // Create a chain of config objects, in this priority order:

, privateKey = null
, mkdir = require("./mkdir-p")
, chain = require("./chain")

@@ -77,16 +76,4 @@ , log = require("./log")

cl.push(dc)
// make sure that the root folder exists
// This is a bit of a kludge, but until we can abstract out
// file read/write in a clean way, this is the only single
// gateway where we can ensure that these folders exist.
var npmdir = path.join(cl.get("root"), ".npm")
chain
( cl.get("binroot") && [mkdir, cl.get("binroot")]
, [mkdir, path.join(npmdir, ".tmp")]
, [mkdir, path.join(npmdir, ".cache")]
, function (er) {
exports.resolved = true
cb(er)
}
)
exports.resolved = true
cb()
})

@@ -245,6 +232,6 @@ })

, configList.list[TRANS[which]]
, cb
)
, which === "user" ? 0600 : 0644
, cb )
}
function saveConfigfile (file, config, cb) {
function saveConfigfile (file, config, mode, cb) {
encryptAuth(config, function () { // ignore errors

@@ -256,12 +243,13 @@ var data = {}

data = ini.stringify({"-":data}).trim()
return (data) ? writeConfigfile(file, data+"\n", cb)
return (data) ? writeConfigfile(file, data+"\n", mode, cb)
: rmConfigfile(file, cb)
})
}
function writeConfigfile (configfile, data, cb) {
function writeConfigfile (configfile, data, mode, cb) {
fs.writeFile
( configfile, data, "utf8"
, function (er) {
if (er) log(er, "Failed saving "+configfile)
cb()
if (er) log(er, "Failed saving "+configfile, cb)
else if (mode) fs.chmod(configfile, mode, cb)
else cb()
}

@@ -268,0 +256,0 @@ )

@@ -20,2 +20,4 @@

wd = validWd(wd || path.join(npm.dir, pkg.name, pkg.version, "package"))
// set the env variables, then run scripts as a child process.

@@ -37,3 +39,3 @@ var env = makeEnv(pkg)

chain
( [addDepsToEnv, pkg, env]
( [addDepsToEnv, pkg, env, wd]
, packageLifecycle && [runPackageLifecycle, pkg, env, wd]

@@ -47,12 +49,11 @@ , [runHookLifecycle, pkg, env, wd]

// if it fails, then just leave it blank.
function addDepsToEnv (pkg, env, cb_) {
function addDepsToEnv (pkg, env, wd, cb_) {
if (pkg._resolvedDeps && pkg._bundledDeps) {
return cb(null, pkg._resolvedDeps, pkg._bundledDeps)
}
else readDeps(pkg, cb)
else readDeps(pkg, wd, cb)
function cb (er, deps, bundled) {
if (er) return cb_(er)
pkg._bundledDeps = bundled
var bundledir = path.join(npm.dir, pkg.name, pkg.version
,"package", "node_modules", ".npm")
var bundledir = path.join(wd, "node_modules", ".npm")
deps.forEach(add(npm.dir, "npm_dependency_"))

@@ -70,6 +71,6 @@ bundled.forEach(add(bundledir, "npm_dependency_"))

function readDeps (pkg, cb) {
function readDeps (pkg, wd, cb) {
var pkgdir = path.join(npm.dir, pkg.name, pkg.version)
, depdir = path.join(pkgdir, "dependson")
, bundledir = path.join(pkgdir, "package", "node_modules", ".npm")
, bundledir = path.join(wd, "node_modules", ".npm")
fs.readdir(depdir, function (er, dn) {

@@ -123,6 +124,4 @@ done(er ? [] : dn.map(function (dn) {

var stage = env.npm_lifecycle_event
var d = wd || path.join(npm.dir, pkg.name, pkg.version, "package")
d = validWd(d)
exec("sh", ["-c", env.npm_lifecycle_script], env, true, d,
exec("sh", ["-c", env.npm_lifecycle_script], env, true, wd,
function (er, code, stdout, stderr) {

@@ -152,8 +151,6 @@ if (er && !npm.ROLLBACK) {

var stage = env.npm_lifecycle_event
var hook = path.join(npm.dir, ".hooks", stage)
var d = wd || path.join(npm.dir, pkg.name, pkg.version, "package")
d = validWd(d)
, hook = path.join(npm.dir, ".hooks", stage)
fs.stat(hook, function (er) {
if (er) return cb()
exec(hook, [], env, true, d, function (er) {
exec(hook, [], env, true, wd, function (er) {
if (er) {

@@ -160,0 +157,0 @@ er.message += "\nFailed to exec "+stage+" hook script"

@@ -15,4 +15,6 @@

function doColor (stream) {
if (!npm.config.get("color")) return false
return isatty(stream)
var conf = npm.config.get("color")
return (!conf) ? false
: (conf === "always") ? true
: isatty(stream)
}

@@ -19,0 +21,0 @@ function isatty (stream) {

@@ -24,3 +24,3 @@ // info about each config option.

, browser : String
, color : Boolean
, color : ["always", Boolean]
, description : Boolean

@@ -27,0 +27,0 @@ , dev : Boolean

@@ -19,3 +19,4 @@

fs.readdir(npm.dir, function (er, packages) {
if (er) return cb(er)
// if an error, just assume nothing is installed.
if (er) return cb(null, {})
packages = packages.filter(function (dir) {

@@ -22,0 +23,0 @@ return (showAll || args.indexOf(dir) !== -1) && dir.charAt(0) !== "."

@@ -22,5 +22,15 @@

}
opts.file = jsonFile
if (!opts.tag) {
var parsedPath = jsonFile.indexOf(npm.dir) === 0 && jsonFile.match(
/\/([^\/]+)\/([^\/]+)\/package\/package\.json$/)
if (parsedPath && semver.valid(parsedPath[2])) {
// this is a package.json in some installed package.
// infer the opts.tag so that linked packages behave right.
opts.tag = parsedPath[2]
}
}
fs.readFile( path.join(path.dirname(jsonFile), "wscript")
, function (er, data) {
opts.file = jsonFile
if (er) opts.wscript = false

@@ -30,2 +40,6 @@ else opts.wscript = data.toString().match(/(^|\n)def build\b/)

fs.readFile(jsonFile, processJson(opts, function (er, data) {
if (er) return cb(er)
var doLoad = !(jsonFile.indexOf(npm.cache) === 0 &&
path.basename(path.dirname(jsonFile)) !== "package")
if (!doLoad) return cb(er, data)
loadPackageDefaults(data, path.dirname(jsonFile), cb)

@@ -133,3 +147,3 @@ }))

// don't fail if it was unexpected, just try.
scripts.preinstall = "node-waf configure build"
scripts.preinstall = "node-waf clean configure build"
}

@@ -136,0 +150,0 @@ }

// utilities for working with the js-registry site.
exports.publish = require("./registry/publish")
exports.unpublish = require("./registry/unpublish")
exports.tag = require("./registry/tag")
exports.adduser = require("./registry/adduser")
exports.get = require("./registry/get")
exports.request = require("./registry/request")
var cached = {}
function lazyGet (p) { return function () {
return cached[p] || (cached[p] = require("./registry/"+p))
}}
function setLazyGet (p) {
Object.defineProperty(exports, p,
{ get : lazyGet(p)
, enumerable : true })
}
; ["publish", "unpublish", "tag", "adduser", "get", "request"]
.forEach(setLazyGet)

@@ -16,3 +16,3 @@

function publish (data, registry, cb) {
function publish (data, cb) {
// add the dist-url to the data, pointing at the tarball.

@@ -19,0 +19,0 @@ // if the {name} isn't there, then create it.

@@ -30,2 +30,13 @@

// Since there are multiple places where an error could occur,
// don't let the cb be called more than once.
cb = (function (cb) {
var errState = null
return function (er) {
if (errState) return
if (er) errState = er
cb.apply(null, arguments)
}
})(cb)
var adduserChange = /^\/?-\/user\/org\.couchdb\.user:([^\/]+)\/-rev/

@@ -32,0 +43,0 @@ , adduserNew = /^\/?-\/user\/org\.couchdb\.user:([^\/]+)/

@@ -36,6 +36,7 @@

if (!versionPublic) return cb()
var latestVer = data["dist-tags"].latest
for (var tag in data["dist-tags"]) {
if (data["dist-tags"][tag] === ver) delete data["dist-tags"][tag]
}
if (data["dist-tags"].latest === ver) {
if (latestVer === ver) {
data["dist-tags"].latest =

@@ -42,0 +43,0 @@ Object.getOwnPropertyNames(versions).sort(semver.compare).pop()

@@ -54,3 +54,3 @@

if (er) return cb(er)
fs.writeFile(to, code, "ascii", function (er, ok) {
fs.writeFile(to, code, "utf8", function (er, ok) {
if (er) return cb(er)

@@ -57,0 +57,0 @@ fs.chmod(to, 0755, cb)

@@ -61,3 +61,7 @@ // npm view [pkg [pkg ...]]

Object.keys(data.versions).forEach(function (v) {
data.versions[v] = readJson.processJson(data.versions[v])
try {
data.versions[v] = readJson.processJson(data.versions[v])
} catch (ex) {
delete data.versions[v]
}
if (semver.satisfies(v, version)) args.forEach(function (args) {

@@ -64,0 +68,0 @@ results.push(showFields(data, data.versions[v], args))

@@ -21,3 +21,2 @@

, path = require("path")
, mkdir = require("./lib/utils/mkdir-p")
, abbrev = require("./lib/utils/abbrev")

@@ -50,2 +49,4 @@ , which = require("./lib/utils/which")

, "list" : "ls"
, "search" : "ls"
, "find" : "ls"
, "ln" : "link"

@@ -133,3 +134,3 @@ , "i" : "install"

loadListeners.forEach(function (cb) {
cb(er, npm)
process.nextTick(function () { cb(er, npm) })
})

@@ -144,6 +145,3 @@ loadListeners.length = 0

}
ini.resolveConfigs(conf, function (er) {
if (er) return cb(er)
mkdir(npm.tmp, cb)
})
ini.resolveConfigs(conf, cb)
})

@@ -150,0 +148,0 @@ }

{ "name" : "npm"
, "description" : "A package manager for node"
, "keywords" : [ "package manager", "modules", "install", "package.json" ]
, "version" : "0.2.14-6"
, "version" : "0.2.16"
, "homepage" : "http://npmjs.org/"

@@ -6,0 +6,0 @@ , "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)"

@@ -10,7 +10,17 @@ exports.vStartsFrom = '0.1.14';

exports.npmVerLenStandard = 8;
exports.spareGlobalProperties = ['cmd', 'target', 'release', 'releases',
'ecosystems', 'ecosystem', 'pkgDir','id',
'docsDir', 'shellDir', 'pkgActivateFile',
'idLenStandard', 'distFile', 'fullDistFile',
'npmVer', 'destDir'];
exports.spareEcosystemProperties = ['version'];
// spare Global Properties
exports.sgps = ['cmd', 'target', 'release', 'releases', 'ecosystems',
'ecosystem', 'pkgDir','npmVer','destDir', 'pkgDocsDir',
'pkgShellDir', 'pkgDocsDir','pkgConfigFile', 'pkgActivateFile',
'pkgDistFile', 'pkgFullDistFile', 'idLenStandard',
'globalConfig', 'globalDistFile', 'globalActivateFile'];
// spare Ecosystem Properties
exports.seps = exports.sgps.concat(['version', 'localConfigFile', 'localDistFile',
'localActivateFile', 'timeFormat', 'root',
'recordFile', 'installNPM']);
exports.issues = 'http://github.com/kuno/neco/issues';
exports.validFlags = ['--app', '--npm'];
exports.validOptions = ['-d'];

@@ -7,9 +7,8 @@ var os = require('os'),

notSmaller = require('./utils.js').compareVersions,
cleanGlobalConfig = require('./utils.js').cleanGloalConfig,
cleanLocalConfig = require('./utils.js').cleanGloalConfig,
cleanEcosystemConfig = require('./utils.js').cleanEcosystemConfig;
exports.getRelease = function(config) {
var dist, distFile, version, release, target;
target = config.target;
distFile = config.distFile;
exports.getRelease = function(target) {
var config = process.neco.config,
version, release, distFile = config.localDistFile,
dist = JSON.parse(fs.readFileSync(distFile, 'utf8'));

@@ -42,5 +41,6 @@

exports.getEcosystem = function(config) {
var id = config.id, ecosystem = null;
var ecosystems = JSON.parse(fs.readFileSync(config.recordFile, 'utf8')).ecosystems;
exports.getEcosystem = function(id) {
var config = process.neco.config,
recordFile = config.recordFile, ecosystem = null,
ecosystems = JSON.parse(fs.readFileSync(recordFile, 'utf8')).ecosystems;

@@ -56,11 +56,14 @@ ecosystems.forEach(function(e) {

exports.getDateTime = function(config) {
var date = new Date(), time = date.getTime();
if (config.timeFormat === 'GMT') {
exports.getDateTime = function() {
var config = process.neco.config,
date = new Date(), time = date.getTime(),
timeFormat = config.timeFormat;
if (timeFormat === 'GMT') {
time = date.toGMTString(time);
} else if (config.timeFormat === 'ISO') {
} else if (timeFormat === 'ISO') {
tiime = date.toISOString(time);
} else if (config.timeFormat === 'UTC') {
} else if (timeFormat === 'UTC') {
time = date.toUTCString(time);
} else if (config.timeFormat === 'date') {
} else if (timeFormat === 'date') {
time = date.toDateString(time);

@@ -74,11 +77,10 @@ } else {

exports.getSuitedNPM = function(config) {
var len, minima, npm = null;
var target = config.release.version;
exports.getSuitedNPM = function(release) {
var config = process.neco.config,
minima, npm = null, pkgDir = config.pkgDir,
dataFile = path.join(pkgDir, 'data/npm.json'),
coulps = JSON.parse(fs.readFileSync(dataFile, 'utf8')).coulps,
target = release.version, len = coulps.length, i;
var dataFile = path.join(config.pkgDir, 'data/npm.json');
var coulps = JSON.parse(fs.readFileSync(dataFile, 'utf8')).coulps;
len = coulps.length;
for (var i = 0; i < len; ++i) {
for (i = 0; i < len; ++i) {
minima = coulps[i].node;

@@ -94,4 +96,4 @@ if (notSmaller(target, minima) >= 0) {

exports.getNodeInstallScript = function(config) {
var script = null, shellDir = config.shellDir;
exports.getNodeInstallScript = function() {
var script = null, shellDir = process.neco.config.pkgShellDir;
var type = os.type(), release = os.release();

@@ -124,4 +126,4 @@

exports.getNPMInstallScript = function(config) {
var shellDir = config.shellDir,
exports.getNPMInstallScript = function() {
var shellDir = process.neco.config.pkgShellDir,
script = path.join(shellDir, 'install_npm.sh');

@@ -132,4 +134,4 @@

exports.getActivateInstallScript = function(config) {
var shellDir = config.shellDir,
exports.getActivateInstallScript = function() {
var shellDir = process.neco.config.pkgShellDir,
script = path.join(shellDir, 'install_activate.sh');

@@ -140,29 +142,36 @@

exports.writeGlobalConfigFile = function(config, next) {
var error, root = config.root, id = config.id,
cleannedConfig = cleanGlobalConfig(config),
configData = JSON.stringify(cleannedConfig),
globalConfigFile = path.join(root, '.neco', 'config.json');
exports.writeLocalConfigFile = function(id, next) {
var config = process.neco.config,
globalConfig = process.neco.globalConfig,
root = config.root,localConfigFile = config.localConfigFile,
cleannedConfig = cleanLocalConfig(globalConfig),
configData = JSON.stringify(cleannedConfig);
fs.writeFile(globalConfigFile, configData, 'utf8', function(err) {
error = err;
config.id = id;
next(error, config);
fs.writeFile(localConfigFile, configData, 'utf8', function(err) {
next(err, id);
});
};
exports.writeEcosystemConfigFile = function(config) {
var root = config.root, id = config.id,
cleannedConfig = cleanEcosystemConfig(config),
configData = JSON.stringify(cleannedConfig),
ecosystemConfigFile = path.join(root, '.neco', id, 'config.json');
exports.writeEcosystemConfigFile = function(argv, next) {
var config = process.neco.config,
configData, root = config.root, ecosystemConfigFile;
if (process.neco.ecosystemConfig) {
cleannedConfig = cleanEcosystemConfig(process.neco.ecosystemConfig);
} else {
cleannedConfig = cleanEcosystemConfig(process.neco.globalConfig);
}
//cleannedConfig.id = id;
configData = JSON.stringify(cleannedConfig);
ecosystemConfigFile = path.join(root, '.neco', argv.id, 'config.json');
fs.writeFile(ecosystemConfigFile, configData, 'utf8', function(err) {
if (err) {throw err;}
next(err);
});
};
exports.findlongestID = function(config) {
var longest = 0, ecosystems, data,
recordFile = config.recordFile;
exports.findlongestID = function() {
var config = process.neco.config,longest = 0,
ecosystems, data, recordFile = config.recordFile;
data = JSON.parse(fs.readFileSync(recordFile, 'utf8'));

@@ -169,0 +178,0 @@

@@ -6,14 +6,18 @@ var os = require('os'),

ecosystem = process.env.NODE_ECOSYSTEM,
pkgDir = path.join(__dirname, '..'),
docsDir = path.join(pkgDir, 'docs'),
distFile = path.join(pkgDir, 'data/dist.json'),
shellDir = path.join(pkgDir, 'shell'),
recordFile = path.join(root, '.neco/record.json'),
fullDistFile = path.join(pkgDir, 'data/fullDist.json'),
userConfigFile = path.join(process.env.HOME, '.neconfig');
var pkgDir = path.join(__dirname, '..'),
pkgDocsDir = path.join(pkgDir, 'docs'),
pkgDistFile = path.join(pkgDir, 'data/dist.json'),
pkgShellDir = path.join(pkgDir, 'shell'),
pkgActivateFile = path.join(pkgDir, 'shell/activate.sh'),
globalActivateFile = path.join(root, '.neco', 'activate.sh'),
defaultConfigFile = path.join(pkgDir, 'data/defaultConfig.json'),
globalConfigFile = path.join(root, '.neco/config.json'),
userConfigFile = path.join(process.env.HOME, '.neconfig'),
normalizeValue = require('./utils.js').normalizeValue,
pkgConfigFile = path.join(pkgDir, 'data/config.json'),
pkgFullDistFile = path.join(pkgDir, 'data/fullDist.json');
var recordFile = path.join(root, '.neco/record.json'),
localDistFile = path.join(root, '.neco/dist.json'),
localConfigFile = path.join(root, '.neco/config.json'),
localActivateFile = path.join(root, '.neco/activate.sh');
var normalizeValue = require('./utils.js').normalizeValue,
findlongestID = require('./assistant.js').findlongestID,

@@ -27,9 +31,10 @@ cleanGloalConfig = require('./utils.js').cleanGloalConfig,

exports.parseGlobalConfig = function(next) {
var config = {};
path.exists(globalConfigFile, function(exists) {
path.exists(localConfigFile, function(exists) {
if (exists) {
config = JSON.parse(fs.readFileSync(globalConfigFile, 'utf8'));
process.neco.globalConfig = JSON.parse(fs.readFileSync(localConfigFile, 'utf8'));
} else {
process.neco.globalConfig = {};
}
content = JSON.parse(fs.readFileSync(globalConfigFile, 'utf8'));
content = JSON.parse(fs.readFileSync(pkgConfigFile, 'utf8'));
keys = Object.keys(content);

@@ -39,10 +44,21 @@ keys.forEach(function(k) {

value = content[k];
Object.defineProperty(config, key, {value:value, writable:true, enumerable:true, configurable:true});
Object.defineProperty(process.neco.globalConfig, key, {value:value, writable:true, enumerable:true, configurable:true});
});
config.root = root;
config.ecosystem = ecosystem;
config.recordFile = recordFile;
config.globalActivateFile = globalActivateFile;
next(config);
process.neco.globalConfig.pkgDir = pkgDir;
process.neco.globalConfig.pkgDocsDir = pkgDocsDir;
process.neco.globalConfig.pkgDistFile = pkgDistFile;
process.neco.globalConfig.pkgShellDir = pkgShellDir;
process.neco.globalConfig.pkgConfigFile = pkgConfigFile;
process.neco.globalConfig.pkgFullDistFile = pkgFullDistFile;
process.neco.globalConfig.pkgActivateFile = pkgActivateFile;
process.neco.globalConfig.root = root;
process.neco.globalConfig.ecosystem = ecosystem;
process.neco.globalConfig.recordFile = recordFile;
process.neco.globalConfig.localDistFile = localDistFile;
process.neco.globalConfig.localConfigFile = localConfigFile;
process.neco.globalConfig.localActivateFile = localActivateFile;
next();
});

@@ -52,4 +68,5 @@ };

exports.parseEcosystemConfig = function(config, next) {
var ecosystemConfigFile, id = config.id;
exports.parseEcosystemConfig = function(id, next) {
var ecosystemConfigFile;
process.neco.ecosystemConfig = {};
if (id) {

@@ -64,28 +81,16 @@ ecosystemConfigFile = path.join(root, '.neco', id, 'config.json');

value = content[k];
Object.defineProperty(config, key, {value:value, writable:true,enumerable:true, configurable:true});
Object.defineProperty(process.neco.ecosystemConfig, key, {value:value, writable:true,enumerable:true, configurable:true});
});
next(config);
next();
} else {
next(config);
next();
}
});
} else {
next(config);
next();
}
};
exports.parsePkgConfig = function(config, next) {
config.pkgDir = pkgDir;
config.docsDir = docsDir;
config.distFile = distFile;
config.shellDir = shellDir;
config.distFile = distFile;
config.recordFile = recordFile;
config.fullDistFile = fullDistFile;
config.pkgActivateFile = pkgActivateFile;
next(config);
};
exports.parseUserConfig = function(config, next) {
exports.parseUserConfig = function(next) {
process.neco.userConfig = {};
path.exists(userConfigFile, function(exists) {

@@ -98,10 +103,26 @@ if (exists) {

value = normalizeValue(c.split('=')[1].trim());
Object.defineProperty(config, key, {value:value, writable:true, enumerable:true, configurable:true});
Object.defineProperty(process.neco.userConfig, key, {value:value, writable:true, enumerable:true, configurable:true});
}
});
next(config);
next();
} else {
next(config);
next();
}
});
};
exports.filterConfig = function(next) {
process.neco.config = {};
if (process.neco.ecosystemConfig) {
process.neco.ecosystemConfig.__proto__ = process.neco.globalConfig;
process.neco.userConfig.__proto__ = process.neco.ecosystemConfig;
process.neco.config.__proto__ = process.neco.userConfig;
} else {
process.neco.userConfig.__proto__ = process.neco.globalConfig;
process.neco.config.__proto__ = process.neco.userConfig;
}
// Set the longest length of id for display
process.neco.config.idLenStandard = findlongestID();
next();
};

@@ -1,2 +0,5 @@

var util, color = require('ansi-color').set,
var log, show,
util, color = require('ansi-color').set,
issues = require('../include/default.js').issues,
EventEmitter = require('events').EventEmitter,
toMB = require('../lib/utils.js').toMB,

@@ -10,3 +13,4 @@ fillSpace = require('../lib/utils.js').fillSpace,

wrgHead = leftParentheses+color('Neco Warning', 'yellow+bold')+rightParentheses, wrgBody,
errHead = leftParentheses+color('Neco Error', 'red+bold')+rightParentheses, errBody,
errHead = leftParentheses+color('Neco Error', 'red+bold')+rightParentheses, errBody,
stkHead = leftParentheses+color('Stack','cyan')+rightParentheses, stkBody,
sgtHead = leftParentheses+color('Suggestion', 'cyan')+rightParentheses, stgBody,

@@ -23,38 +27,83 @@ expHead = leftParentheses+color('Examples', 'cyan')+rightParentheses, expBody,

exports.log = function(type, information, suggestion, example, cmd) {
if (type === 'stdout') {
util.print(''+information);
} else {
if (type === 'message') {
console.log(msgHead+' '+color(information, 'magenta'));
} else if (type === 'warning') {
console.log(wrgHead+' '+color(information, 'magenta'));
} else if (type === 'error') {
console.log(errHead+' '+color(information, 'magenta'));
}
function _logMessage(information, suggestion, example, cmd) {
console.log(msgHead+' '+color(information, 'magenta'));
console.log('');
if (suggestion !== undefined) {
console.log(sgtHead+' '+color(suggestion, 'magenta'));
console.log('');
}
if (suggestion !== undefined) {
console.log(sgtHead+' '+color(suggestion, 'magenta'));
console.log('');
}
if (example !== undefined) {
console.log(expHead+' '+color(example, 'magenta'));
console.log('');
}
if (example !== undefined) {
console.log(expHead+' '+color(example, 'magenta'));
console.log('');
}
}
if (cmd === undefined) {
console.log(hlpHead+hlp+hlpTail);
} else {
console.log(hlpHead+hlp+color(cmd+' ', 'magenta')+hlpTail);
}
function _logExit(information, suggestion, example, cmd) {
console.log(msgHead+' '+color(information, 'magenta'));
console.log('');
if (suggestion !== undefined) {
console.log(sgtHead+' '+color(suggestion, 'magenta'));
console.log('');
}
};
exports.showEcosystems = function(config) {
var standard = config.idLenStandard, ecosystem;
var len = config.ecosystems.length;
var idHead = color('ID: ', 'green'), id,
if (example !== undefined) {
console.log(expHead+' '+color(example, 'magenta'));
console.log('');
}
if (cmd === undefined) {
console.log(hlpHead+hlp+hlpTail);
} else {
console.log(hlpHead+hlp+color(cmd+' ', 'magenta')+hlpTail);
}
}
function _logStdout(information) {
util.print(''+information);
}
function _logWarning(information, suggestion, example, cmd) {
console.log(wrgHead+' '+color(information, 'magenta'));
console.log('');
if (suggestion !== undefined) {
console.log(sgtHead+' '+color(suggestion, 'magenta'));
console.log('');
}
if (example !== undefined) {
console.log(expHead+' '+color(example, 'magenta'));
console.log('');
}
}
function _logError (error) {
var stack = error.stack;
var message = error.message;
errBody = error.message;
stkBody = stack;
sgtBody = 'Report all these information to ' + color(issues, 'yellow+bold');
console.log(errHead+' '+errBody);
console.log('');
console.log(stkHead+' '+stkBody);
console.log('');
console.log(sgtHead+' '+sgtBody);
process.exit(1);
}
function _showEcosystems (ecosystems) {
var ecosystem, config = process.neco.config,
len = ecosystems.length, standard = config.idLenStandard,
idHead = color('ID: ', 'green'), id,
nvHead = color('Node: ', 'cyan'), nv,

@@ -67,3 +116,3 @@ cdHead = color('Created: ', 'cyan'), cd,

console.log(color('All ecosystems: '+len, 'bold'));
config.ecosystems.forEach(function(e) {
ecosystems.forEach(function(e) {
id = color('[', 'yellow') + idHead + color(fillSpace('id', e.id, standard), 'bold+yellow') + color('] ', 'yellow');

@@ -76,3 +125,3 @@ nv = nvHead + color(e.nv, 'magenta');

} else {
ecosystem = config.ecosystems[0];
ecosystem = ecosystems[0];
id = color('[', 'yellow') + idHead + color(ecosystem.id, 'yellow+bold') + color('] ', 'yellow');

@@ -84,6 +133,6 @@ nv = nvHead + color(ecosystem.nv, 'magenta');

}
};
}
exports.showReleases = function(config) {
var len = config.releases.length, release;
function _showReleases(releases) {
var len = releases.length, release;
var verHead = color('Version: ', 'cyan'), version,

@@ -97,3 +146,3 @@ linkHead = color('Link: ', 'cyan'), link,

console.log(color('Available releases: '+len, 'bold'));
config.releases.forEach(function(r) {
releases.forEach(function(r) {
version = verHead + color(fillSpace('version', r.version), 'magenta');

@@ -106,3 +155,3 @@ link = linkHead + color(fillSpace('link', r.link), 'magenta');

} else {
release = config.releases[0];
release = releases[0];
version = verHead + color(release.version, 'magenta');

@@ -114,2 +163,16 @@ link = linkHead + color(release.link, 'magenta');

}
};
}
log = new EventEmitter;
log.on('message', _logMessage);
log.on('warning', _logWarning);
log.on('stdout', _logStdout);
log.on('error', _logError);
log.on('exit', _logExit);
show = new EventEmitter;
show.on('ecosystems', _showEcosystems);
show.on('releases', _showReleases);
exports.log = log;
exports.show = show;
var fs = require('fs'),
path = require('path'),
log = require('./display.js').log,
root = process.env.NECO_ROOT,
copyFile = require('./utils.js').copyFile,
isBigger = require('./utils.js').compareVersions,
findlongestID = require('./assistant.js').findlongestID;
var root = process.env.NECO_ROOT,
pkgDir = path.join(__dirname, '..'),
ecosystem = process.env.NODE_ECOSYSTEM,
recordFile = path.join(root, '.neco', 'record.json'),
recordFile = path.join(root, '.neco/record.json'),
pkgDistFile = path.join(pkgDir, 'data/dist.json'),
pkgConfigFile = path.join(pkgDir, 'data/config.json'),
pkgActivateFile = path.join(pkgDir, 'shell/activate.sh'),
globalActivateFile = path.join(root, '.neco', 'activate.sh'),
findlongestID = require('./assistant.js').findlongestID;
localDistFile = path.join(root, '.neco/dist.json'),
localConfigFile = path.join(root, '.neco/config.json'),
localActivateFile = path.join(root, '.neco', 'activate.sh');
var message, warning, error, suggestion, example;
exports.envReady = function(config, next) {
var root = config.root, ecosystem = config.ecosystem, cmd = config.cmd;
exports.toolReady = function(next) {
var paths, err, missing, count,
tools = {python:['/usr/bin/python', '/usr/bin/python2'],
wget:['/usr/bin/wget'],
tar:['/bin/tar', '/usr/bin/tar'],
sed:['/bin/sed', '/usr/bin/sed'],
make:['/usr/bin/make', '/usr/local/bin/make'],
install:['/bin/install','/usr/bin/install']};
var keys = Object.keys(tools);
keys.forEach(function(k) {
paths = tools[k];
missing = 0;
count = paths.length;
paths.forEach(function(p) {
if (!path.existsSync(p)) {
missing += 1;
if (missing === count) {
err = new Error('Missing tool: '+k);
log.emit('error', err);
}
}
});
});
next();
};
exports.envReady = function(cmd, next) {
if (root === undefined || ecosystem !== undefined) {

@@ -28,20 +62,20 @@ if (root === undefined) {

} else {
next(config);
next();
}
}
} else {
next(config);
next();
}
};
exports.rootReady = function(config, next) {
var rootDir = path.join(config.root, '.neco');
path.exists(rootDir, function(exists) {
exports.rootReady = function(next) {
var workDir = path.join(root, '.neco');
path.exists(workDir, function(exists) {
if (!exists) {
fs.mkdir(rootDir, mode=0777, function(err) {
fs.mkdir(workDir, mode=0777, function(err) {
if (err) {throw err;}
next(config);
next();
});
} else {
next(config);
next();
}

@@ -51,5 +85,3 @@ });

exports.recordReady = function(config, next) {
var cmd = config.cmd, recordFile = config.recordFile,
ecosystems;
exports.recordReady = function(cmd, next) {
path.exists(recordFile, function(exists) {

@@ -63,3 +95,3 @@ if (!exists) {

} else {
next(exists, config);
next(exists);
}

@@ -74,4 +106,4 @@ } else {

} else {
config.idLenStandard = findlongestID(config);
next(exists, config);
//process.config.idLenStandard = findlongestID(config);
next(exists);
}

@@ -82,18 +114,22 @@ }

exports.activateReady = function(config, next) {
var globalActivateFile = config.globalActivateFile,
pkgActivateFile = config.pkgActivateFile;
path.exists(globalActivateFile, function(exists) {
exports.upgradeReady = function(next) {
var pkgVer, localVer;
path.exists(localConfigFile, function(exists) {
if (!exists) {
fs.readFile(pkgActivateFile, 'utf8', function(err, data) {
if (err) {throw err;}
fs.writeFile(globalActivateFile, data, 'utf8', function(err) {
if (err) {throw err;}
next(config);
});
});
copyFile(pkgConfigFile, localConfigFile);
copyFile(pkgActivateFile, localActivateFile);
copyFile(pkgDistFile, localDistFile);
} else {
next(config);
pkgVer = JSON.parse(fs.readFileSync(pkgConfigFile,'utf8')).version;
localVer = JSON.parse(fs.readFileSync(localConfigFile,'utf8')).version;
if (isBigger(pkgVer, localVer) > 0) {
copyFile(pkgConfigFile, localConfigFile);
copyFile(pkgActivateFile, localActivateFile);
copyFile(pkgDistFile, localDistFile);
}
}
next();
});
};
}

@@ -6,45 +6,32 @@ var os = require('os'),

pkgDir = path.join(__dirname, '..'),
userConfigFile = path.join(process.env.HOME, '.neconfig'),
normalizeValue = require('./utils.js').normalizeValue;
validFlags = require('../include/default.js').validFlags,
validOptions = require('../include/default.js').validOptions;
exports.parseUserConfigFile = function(next) {
var f = userConfigFile;
var config = {}, content, key, value;
exports.parseArgv = function() {
var argv = {}, flags;
path.exists(f, function(exists) {
if (!exists) {
next(config);
argv.cmd = process.argv[2];
if (!/^-.*/.test(process.argv[3])) {
if (argv.cmd === 'find') {
argv.target = process.argv[3];
} else {
content = fs.readFileSync(f, 'utf8').trim().split('\n');
content.forEach(function(c) {
if (c.match(/\=/)) {
key = c.split('=')[0].trim();
value = normalizeValue(c.split('=')[1].trim());
Object.defineProperty(config, key, {value:value, writable:true, enumerable:true, configurable:true});
}
});
next(config);
argv.id = process.argv[3];
}
}
if (!/^-.*/.test(process.argv[4])) {
if (argv.cmd !== 'find' && argv.cmd !== 'list') {
argv.target = process.argv[4];
}
}
flags = process.argv.slice(2, process.argv.length);
flags.forEach(function(f) {
if (/^-\w/.test(f) && validOptions.indexOf(f)) {
argv[f.replace(/-+/,'')] = flags[flags.indexOf(f)+1];
} else if (/^--\w/.test(f) && validFlags.indexOf(f)) {
argv[f.replace(/-+/,'')] = true;
}
});
};
exports.parseEcosystemConfigFile = function(id, next) {
var f = path.join(root, '.neco', id, 'config');
var config = {}, content, key, value;
path.exists(f, function(exists) {
if (!exists) {
next(config);
} else {
content = fs.readFileSync(f, 'utf8').trim().split('\n');
content.forEach(function(c) {
if (c.match(/\=/)) {
key = c.split('=')[0].trim();
value = normalizeValue(c.split('=')[1].trim());
Object.defineProperty(config, key, {value:value, writable:true, enumerable:true, configurable:true});
}
});
next(config);
}
});
return argv;
};

@@ -10,4 +10,4 @@ var os = require('os'),

npmVerLenStandard = require('../include/default.js').npmVerLenStandard,
spareGlobalProperties = require('../include/default.js').spareGlobalProperties,
spareEcosystemProperties = require('../include/default.js').spareEcosystemProperties;
spareGlobalProperties = require('../include/default.js').sgps,
spareEcosystemProperties = require('../include/default.js').seps;

@@ -17,4 +17,4 @@ var message, warning, error, suggestion, example;

exports.compareVersions = function(versionA, versionB) {
var arrayA = versionA.split('-'), arrayB = versionB.split('-'),
mainA = arrayA[0].split('.'), mainB = arrayB[0].split('.'), notSmaller,
var notSmaller, arrayA = versionA.split('-'), arrayB = versionB.split('-'),
minorA, minorB, mainA = arrayA[0].split('.'), mainB = arrayB[0].split('.'),
len = (mainA.length <= mainB.length) ? mainA.length : mainB.length;

@@ -35,15 +35,20 @@

notSmaller = 0;
} else if (arrayA.length > arrayB.length) {
notSmaller = 1;
} else if (arrayA.length < arrayA.length) {
notSmaller = -1;
} else {
if (parseInt(arrayA[-1], 10) < parseInt(arrayB[-1], 10)) {
minorA = arrayA.reverse()[0].replace(/[a-zA-Z]+/,'');
minorB = arrayB.reverse()[0].replace(/[a-zA-Z]+/,'');
if (minorA.length !== minorB.length) {
notSmaller = ((minorA.length - minorB.length) > 0) ? 1 : -1;
} else if (parseInt(minorA, 10) === parseInt(minorB, 10)) {
notSmaller = 0;
} else if (parseInt(minorA, 10) > parseInt(minorB, 10)) {
notSmaller = 1;
} else if (parseInt(minorA, 10) < parseInt(minorB, 10)) {
notSmaller = -1;
break;
} else if (parseInt(arrayA[-1], 10) > parseInt(arrayB[-1], 10)) {
notSmaller = 1;
break;
} else {
notSmaller = 0;
}
}
}
else {
} else {
notSmaller = -1;

@@ -54,3 +59,3 @@ }

return notSmaller;
return notSmaller;
};

@@ -131,1 +136,10 @@

};
exports.copyFile = function(source, dest) {
fs.readFile(source, 'utf8', function(err, data) {
if (err) {throw err;}
fs.writeFile(dest, data, 'utf8', function(err) {
if (err) {throw err;}
});
});
};

@@ -6,8 +6,10 @@ var fs = require('fs'),

exports.idUnique = function(config) {
var unique = true, data, ecosystems,
exports.idUnique = function(id) {
var unique = true, data, ecosystems,
config = process.neco.config,
recordFile = config.recordFile;
data = JSON.parse(fs.readFileSync(recordFile, 'utf8'));
data.ecosystems.forEach(function(e) {
if (e.id === config.id) {
if (e.id === id) {
unique = false;

@@ -19,6 +21,6 @@ }

exports.idValid = function(config) {
exports.idValid = function(id) {
var valid = true;
reservedWords.forEach(function(w) {
if (w === config.id) {
if (w === id) {
valid = false;

@@ -30,6 +32,6 @@ }

exports.cmdValid = function(command) {
exports.cmdValid = function(cmd) {
var valid = false;
cmdList.forEach(function(c) {
if (c === command) {
if (c === cmd) {
valid = true;

@@ -41,8 +43,10 @@ }

exports.idExsit = function(config) {
var exist = null, ecosystems, data;
exports.idExsit = function(id) {
var exist = null, ecosystems, data,
config = process.neco.config,
recordFile = config.recordFile;
data = JSON.parse(fs.readFileSync(recordFile, 'utf8'));
data.ecosystems.forEach(function(e) {
if (e.id === config.id) {
if (e.id === id) {
exist = true;

@@ -54,4 +58,7 @@ }

exports.ecosystemActive = function(config) {
var basename, id = config.id, ecosystem = config.ecosystem;
exports.ecosystemActive = function(id) {
var basename,
config = process.neco.config,
ecosystem = config.ecosystem;
if (ecosystem === undefined) {

@@ -58,0 +65,0 @@ return false;

@@ -5,3 +5,3 @@ {

"keywords":["virtualenv", "ecosystem", "install", "npm"],
"version": "0.0.3-alpha1",
"version": "0.0.4",
"homepage":"",

@@ -27,9 +27,17 @@ "author":"Guan 'kuno' Qing <neokuno AT gmail DOT com>",

{
"bin":"./bin","docs":"/.docs","man":"./man", "lib":"./lib",
"cmd":"./cmd","data":"./data","deps":"./deps","include":"./include",
"sample":"./sample","shell":"./shell", "test":"./test"
"bin":"./bin",
"docs":"/.docs",
"man":"./man",
"lib":"./lib",
"cmd":"./cmd",
"data":"./data",
"deps":"./deps",
"include":"./include",
"sample":"./sample",
"shell":"./shell",
"test":"./test"
},
"bin":{"neco":"./bin/neco.js"},
"main":"neco",
"engines": {"node":">=0.3.4"},
"engines": {"node":">=0.3.7"},
"scripts":{},

@@ -36,0 +44,0 @@ "licenses":

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc