fis-command-install
Advanced tools
Comparing version 0.1.0-beta to 0.1.0-beta2
@@ -13,2 +13,9 @@ /* | ||
var logger = require('./lib/logger'); | ||
var factory = require('./lib/remotes/factory.js'); | ||
var _ = require('./lib/util.js'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var exists = fs.existsSync; | ||
var write = fs.writeFileSync; | ||
exports.register = function(commander) { | ||
@@ -62,4 +69,2 @@ | ||
.then(function() { | ||
var path = require('path'); | ||
var exists = require('fs').existsSync; | ||
var filepath = path.join(settings.root, 'fis-conf.js'); | ||
@@ -98,4 +103,2 @@ | ||
.then(function(ret) { | ||
var _ = require('./lib/util.js'); | ||
settings.config = ret; | ||
@@ -118,4 +121,2 @@ | ||
var factory = require('./lib/remotes/factory.js'); | ||
factory.setSettings(settings); | ||
@@ -125,16 +126,3 @@ | ||
// 过滤掉不能识别的依赖。 | ||
return components | ||
.map(function(component) { | ||
var type = factory.detect(component); | ||
if (!type) { | ||
logger.warn('`%s` is not a valid repository.', component); | ||
return null; | ||
} | ||
return factory(component); | ||
}) | ||
.filter(function(item) { | ||
return item != null; | ||
}); | ||
return strToRemote(components); | ||
}) | ||
@@ -153,3 +141,2 @@ | ||
.then(function(components) { | ||
var _ = require('./lib/util.js'); | ||
@@ -240,2 +227,3 @@ // 过滤掉本地的仓库。已经同名的包。 | ||
console.log('Installed\n%s', arrs.join('\n')); | ||
return components; | ||
}); | ||
@@ -246,5 +234,25 @@ }); | ||
// 保存 components.json | ||
.then(function() { | ||
// todo | ||
.then(function(installed) { | ||
// 如果指定了 --save, 则需要把数据写入到 components.josn 文件里面。 | ||
if (settings.save && args.length && installed && installed.length) { | ||
var config = settings.config; | ||
var specified = strToRemote(args.concat()); | ||
config.dependencies = config.dependencies || []; | ||
var oldList = strToRemote(config.dependencies); | ||
specified.forEach(function(item) { | ||
var idx; | ||
if (!~_.indexOfArray('name', item.name, oldList) && ~(idx = _.indexOfArray('name', item.name, installed))) { | ||
var found = installed[idx]; | ||
config.dependencies.push(found.type + ':' + found.address + '@' + found.version); | ||
} | ||
}); | ||
var componentJson = path.join(settings.root, 'component.json'); | ||
write(componentJson, JSON.stringify(config, null, 2)); | ||
} | ||
}) | ||
@@ -260,2 +268,20 @@ | ||
}); | ||
}; | ||
}; | ||
function strToRemote(components, ignoreInvalid) { | ||
return components | ||
.map(function(component) { | ||
var type = factory.detect(component); | ||
if (!type) { | ||
ignoreInvalid || logger.warn('`%s` is not a valid repository.', component); | ||
return null; | ||
} | ||
return factory(component); | ||
}) | ||
.filter(function(item) { | ||
return item != null; | ||
}); | ||
} |
{ | ||
"name": "fis-command-install", | ||
"description": "fis install command.", | ||
"version": "0.1.0-beta", | ||
"version": "0.1.0-beta2", | ||
"author": "FIS Team <fis@baidu.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "http://fis.baidu.com/", |
@@ -8,4 +8,6 @@ # fis-command-install | ||
Options: | ||
-h, --help output usage information | ||
-r, --repos <url> repository url | ||
--save save component(s) dependencies into `components.json` file. | ||
-r, --repos <url> repository url | ||
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
39859
893
13
0