@makano/rew 1.2.38 → 1.2.39
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/rew +1 -0
- package/lib/rew/cli/cli.js +5 -1
- package/lib/rew/cli/utils.js +4 -1
- package/lib/rew/modules/context.js +1 -0
- package/package.json +1 -1
package/bin/rew
CHANGED
package/lib/rew/cli/cli.js
CHANGED
@@ -296,9 +296,13 @@ yargs(hideBin(process.argv))
|
|
296
296
|
describe: 'url of the repo',
|
297
297
|
type: 'string',
|
298
298
|
});
|
299
|
+
yargs.option('json', {
|
300
|
+
describe: 'Return a json output',
|
301
|
+
type: 'boolean',
|
302
|
+
});
|
299
303
|
},
|
300
304
|
async (argv) => {
|
301
|
-
utils.repo(argv.command, argv.name, argv.url);
|
305
|
+
utils.repo(argv.command, argv.name, argv.url, argv);
|
302
306
|
},
|
303
307
|
)
|
304
308
|
.command(
|
package/lib/rew/cli/utils.js
CHANGED
@@ -438,7 +438,7 @@ module.exports = {
|
|
438
438
|
}
|
439
439
|
}
|
440
440
|
},
|
441
|
-
async repo(command, key, value) {
|
441
|
+
async repo(command, key, value, options) {
|
442
442
|
const confInstance = conf({}).create('').optionCenter('repos') || {};
|
443
443
|
|
444
444
|
if (command === 'add' || command === 'set') {
|
@@ -447,6 +447,7 @@ module.exports = {
|
|
447
447
|
if (key) {
|
448
448
|
console.log(confInstance.get(key) || 'Not found');
|
449
449
|
} else {
|
450
|
+
if(options.json) return console.log(JSON.stringify(confInstance.getAll()));
|
450
451
|
console.log(Object.keys(confInstance.getAll()).join('\n'));
|
451
452
|
}
|
452
453
|
} else if (command === 'view') {
|
@@ -454,11 +455,13 @@ module.exports = {
|
|
454
455
|
const url = confInstance.get(key);
|
455
456
|
if (!url) return log(' Repo not found'.red.bold, ':end');
|
456
457
|
const json = await this.getRepoJson(url);
|
458
|
+
if(options.json) return console.log(JSON.stringify(json));
|
457
459
|
if (json.name) log(json.name);
|
458
460
|
log('Packages:'.yellow)
|
459
461
|
if (json.packages) Object.keys(json.packages).forEach(name => log(name)) || log(`${Object.keys(json.packages).length} Packages in ${key}`, ':end');
|
460
462
|
else log('None'.blue, ':end')
|
461
463
|
} else {
|
464
|
+
if(options.json) return JSON.stringify(confInstance.getAll());
|
462
465
|
console.log(Object.keys(confInstance.getAll()).join('\n'));
|
463
466
|
}
|
464
467
|
} else if (command === 'delete') {
|
@@ -53,6 +53,7 @@ module.exports.prepareContext = function (
|
|
53
53
|
off: (event, listener) => process.off(event, listener),
|
54
54
|
emit: (event, code) => process.emit(event, code),
|
55
55
|
},
|
56
|
+
__execFile: global.fileName,
|
56
57
|
env: process.env,
|
57
58
|
cwd: () => process.cwd(),
|
58
59
|
arch: process.arch,
|