Skip to content

Commit 10b003b

Browse files
committed
#50 搜索功能增加-S参数
1 parent 16a2b06 commit 10b003b

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

i18n/lang.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,8 @@ NO_MATCHED_RESULTS:
228228

229229
SEARCH_RESULTS:
230230
en_US: "Search results\n{0}"
231-
zh_CN: "搜索结果\n{0}"
231+
zh_CN: "搜索结果\n{0}"
232+
233+
ERROR_INVALID_COMPONENT:
234+
en_US: "Invalid component: {0}"
235+
zh_CN: "无效的组件: {0}"

lib/cli.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,14 @@ cli.run = function (env) {
118118
.command('search <pattern>')
119119
.alias('s')
120120
.option('-O, --owner', 'search components by owner')
121+
.option('-S, --semantic', 'show semantic component name')
121122
.description(fecom.i18n('SEARCH_COMPONENTS'))
122123
.action(function () {
123124
var search = require('./search');
124125
var args = [].slice.call(arguments);
125126
var options = args.pop();
126127
var pattern = args[0];
127-
options = _(options).pick(['owner']).value();
128+
options = _(options).pick(['owner', 'semantic']).value();
128129
// fecom.logger.info('Listing component versions...');
129130
search(pattern, options);
130131
});
@@ -187,7 +188,7 @@ cli.run = function (env) {
187188
.action(function () {
188189
var update = require('./update');
189190
var args = [].slice.call(arguments);
190-
var options = args.pop();
191+
var options = {};
191192
var semList = args[0];
192193
options = {};
193194
// fecom.logger.info(fecom.i18n('INSTALLING_COMPONENTS'));

lib/component/Component.js

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var Component = function (parsed, type, options) {
3838
this.author = '';
3939
this.args = parsed.args || '';
4040
this.script = '';
41+
this.main = '';
4142

4243
this.specified = !!parsed.specified;
4344
this.conflict = !!parsed.conflict;
@@ -82,6 +83,7 @@ Component.prototype = {
8283
self.version = json.version;
8384
self.author = json.author;
8485
self.exclude = json.exclude || [];
86+
self.main = json.main || 'index.js';
8587
}
8688

8789
self.tree = new Tree(model);

lib/remote/gitlab.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ GitlabRepo.prototype = {
9090
.then(function (json) {
9191

9292
if (json.version !== latestTag) {
93-
return null;
93+
throw new Error(fecom.i18n('ERROR_INVALID_COMPONENT', projectName));
9494
}
9595

9696
return json;

lib/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = function (pattern, options) {
1414
return gitlabRepo.searchComponents(pattern, options.owner)
1515
.then(function (results) {
1616
var lines = results.map(function (result) {
17-
return fecom.stringify(result) + ': ' + result.description;
17+
return (options.semantic ? fecom.stringify(result) : result.name) + ': ' + result.description;
1818
}).join('\n');
1919

2020
if (!lines) {

0 commit comments

Comments
 (0)