Comparing version 0.4.3 to 0.5.0
@@ -46,3 +46,5 @@ /** | ||
' --repository Source repository URL (otherwise uses values in kansorc)\n' + | ||
' --package-dir Output directory (defaults to "./packages")'; | ||
' --package-dir Output directory (defaults to "./packages")\n' + | ||
' --source-dir Local directory to source dependencies from, \n' + | ||
' accepts colon delimited list of directories'; | ||
@@ -60,3 +62,4 @@ | ||
'repository': {match: '--repository', value: true}, | ||
'target_dir': {match: '--package-dir', value: true} | ||
'target_dir': {match: '--package-dir', value: true}, | ||
'source_dir': {match: '--source-dir', value: true} | ||
}); | ||
@@ -67,2 +70,5 @@ | ||
if (opt.source_dir) { | ||
opt.source_dir = opt.source_dir.split(':').reverse(); | ||
} | ||
opt.repositories = settings.repositories; | ||
@@ -122,6 +128,8 @@ if (a.options.repository) { | ||
/** | ||
* Creates a source function to check packages already in local target_dir. | ||
* Creates a source function to check packages on the local filesystem | ||
* either already in target_dir or elsewhere. | ||
* This can be used in conjunction with the tree module. | ||
* | ||
* @param {String} target_dir - the directory we're installing packages to | ||
* @param {String} type - 'local' for target_dir and 'tmp' for elsewhere | ||
* @returns {Function} | ||
@@ -131,5 +139,6 @@ */ | ||
// TODO: also check package_paths (not just target_dir) for available versions? | ||
exports.dirSource = function (target_dir) { | ||
exports.dirSource = function (target_dir, type) { | ||
type = type || 'local'; | ||
return function (name, callback) { | ||
packages.availableVersions([path.join(target_dir, name)], callback); | ||
packages.availableVersions([path.join(target_dir, name)], type, callback); | ||
}; | ||
@@ -207,5 +216,10 @@ }; | ||
var sources = [ | ||
exports.dirSource(opt.target_dir), | ||
exports.dirSource(opt.target_dir, 'local'), | ||
exports.repoSource(opt.repositories) | ||
]; | ||
if (opt.source_dir) { | ||
opt.source_dir.forEach(function(dir) { | ||
sources.unshift(exports.dirSource(dir, 'tmp')); | ||
}); | ||
} | ||
var pkg = { | ||
@@ -283,5 +297,10 @@ config: cfg, | ||
var sources = [ | ||
exports.dirSource(opt.target_dir), | ||
exports.dirSource(opt.target_dir, 'local'), | ||
exports.repoSource(opt.repositories) | ||
]; | ||
if (opt.source_dir) { | ||
opt.source_dir.forEach(function(dir) { | ||
sources.unshift(exports.dirSource(dir, 'tmp')); | ||
}); | ||
} | ||
var pkg1 = { | ||
@@ -506,5 +525,10 @@ config: cfg, | ||
var sources = [ | ||
exports.dirSource(opt.target_dir), | ||
exports.dirSource(opt.target_dir, 'local'), | ||
exports.repoSource(opt.repositories) | ||
]; | ||
if (opt.source_dir) { | ||
opt.source_dir.forEach(function(dir) { | ||
sources.unshift(exports.dirSource(dir, 'tmp')); | ||
}); | ||
} | ||
var packages = exports.prepareTree(cfg, filename, tdir); | ||
@@ -511,0 +535,0 @@ var root = { |
@@ -30,3 +30,5 @@ /** | ||
' --repository Source repository URL (otherwise uses values in kansorc)\n' + | ||
' --package-dir Package directory (defaults to "./packages")'; | ||
' --package-dir Package directory (defaults to "./packages")\n' + | ||
' --source-dir Local directory to source dependencies from, \n' + | ||
' accepts colon delimited list of directories'; | ||
@@ -44,3 +46,4 @@ | ||
'repository': {match: '--repository', value: true}, | ||
'target_dir': {match: '--package-dir', value: true} | ||
'target_dir': {match: '--package-dir', value: true}, | ||
'source_dir': {match: '--source-dir', value: true} | ||
}); | ||
@@ -51,2 +54,5 @@ | ||
if (opt.source_dir) { | ||
opt.source_dir = opt.source_dir.split(':').reverse(); | ||
} | ||
opt.target_dir = opt.target_dir || utils.abspath('packages'); | ||
@@ -110,3 +116,3 @@ opt.repositories = settings.repositories; | ||
var local_sources = [ | ||
install.dirSource(opt.target_dir), | ||
install.dirSource(opt.target_dir, 'local'), | ||
install.repoSource(opt.repositories) | ||
@@ -126,9 +132,20 @@ ]; | ||
install.repoSource(opt.repositories), | ||
install.dirSource(opt.target_dir) | ||
install.dirSource(opt.target_dir, 'local') | ||
]; | ||
var dependency_sources = [ | ||
// check local source first to keep local version if possible | ||
install.dirSource(opt.target_dir), | ||
install.dirSource(opt.target_dir, 'local'), | ||
install.repoSource(opt.repositories) | ||
]; | ||
if (opt.source_dir) { | ||
opt.source_dir.forEach(function(dir) { | ||
update_sources.unshift(install.dirSource(dir, 'tmp')); | ||
}); | ||
// create a reversed copy since we're adding from another end | ||
// to keep the search order the same | ||
Array.prototype.slice.call(opt.source_dir).reverse().forEach( | ||
function(dir) { | ||
dependency_sources.push(install.dirSource(dir, 'tmp')); | ||
}); | ||
} | ||
if (!deps || !deps.length) { | ||
@@ -195,3 +212,9 @@ // update all packages if none specified | ||
if (!local[name] && updated[name] || lversion !== uversion) { | ||
return {name: name, version: uversion, old: lversion}; | ||
return { | ||
name: name, | ||
version: uversion, | ||
old: lversion, | ||
source: updated[name].versions[uversion].source || null, | ||
path: updated[name].versions[uversion].path || null | ||
}; | ||
} | ||
@@ -230,4 +253,8 @@ }); | ||
} | ||
install.installRepo(dep.name, dep.version, opt, cb); | ||
if (dep.source && dep.source === 'tmp') { | ||
install.cpDir(dep.name, dep.version, false, dep.path, opt, cb); | ||
} else { | ||
install.installRepo(dep.name, dep.version, opt, cb); | ||
} | ||
}, callback); | ||
}; |
@@ -439,6 +439,8 @@ /** | ||
* @param {Array} candidates - an array of possible package paths | ||
* @param {String} type - 'local' for the package already in target_dir or | ||
* 'tmp' for package located elsewhere | ||
* @param {Function} callback | ||
*/ | ||
exports.availableVersions = function (candidates, callback) { | ||
exports.availableVersions = function (candidates, type, callback) { | ||
var versions = {}; | ||
@@ -456,3 +458,3 @@ async.forEach(candidates, function (c, cb) { | ||
config: doc, | ||
source: 'local' | ||
source: type | ||
}; | ||
@@ -491,3 +493,3 @@ } | ||
exports.availableVersions(candidates, function (err, matches) { | ||
exports.availableVersions(candidates, 'local', function (err, matches) { | ||
if (err) { | ||
@@ -494,0 +496,0 @@ return callback(err); |
@@ -475,3 +475,3 @@ /** | ||
pattern: /^[yYnN]$/, | ||
description: msg + ' [Y/n]: ' | ||
description: msg + ' [Y/n]:' | ||
} | ||
@@ -494,3 +494,3 @@ } | ||
password: { | ||
description: 'Password: ', | ||
description: 'Password:', | ||
hidden: true | ||
@@ -512,3 +512,3 @@ } | ||
username: { | ||
description: 'Username: ' | ||
description: 'Username:' | ||
} | ||
@@ -515,0 +515,0 @@ }}; |
@@ -36,3 +36,3 @@ { | ||
}, | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"repository": { | ||
@@ -39,0 +39,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
238962
6794