@makano/rew 1.2.38 → 1.2.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/rew CHANGED
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
+ global.fileName = __filename;
2
3
  require("../lib/rew/cli/cli.js");
@@ -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(
@@ -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') {
@@ -11,6 +11,8 @@ const { print, input, clear } = require('../functions/stdout');
11
11
  const { curl } = require('../functions/curl');
12
12
  const { wait } = require('../functions/wait');
13
13
  const { scheduleFrame } = require('../functions/misc');
14
+ const { jsons, yaml, json, yamls } = require('../functions/json');
15
+ const { generateRandomID } = require('../functions/id');
14
16
 
15
17
  module.exports = {
16
18
  cenum,
@@ -43,6 +45,13 @@ module.exports = {
43
45
  compose,
44
46
  curry,
45
47
 
48
+ json,
49
+ jsons,
50
+ yaml,
51
+ yamls,
52
+
53
+ genID: generateRandomID,
54
+
46
55
  curl,
47
56
 
48
57
  print,
@@ -1,5 +1,5 @@
1
- module.exports.generateRandomID = function generateRandomID(length = 12) {
2
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
1
+ module.exports.generateRandomID = function generateRandomID(length = 12, characters) {
2
+ const characters = characters || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
3
3
  const charactersLength = characters.length;
4
4
  let randomID = '';
5
5
 
@@ -0,0 +1,27 @@
1
+ const jsYaml = require("js-yaml");
2
+
3
+
4
+
5
+ function json(thing){
6
+ return JSON.parse(thing);
7
+ }
8
+
9
+ function jsons(thing){
10
+ return JSON.stringify(thing);
11
+ }
12
+
13
+
14
+ function yaml(thing){
15
+ return jsYaml.loadAll(thing)[0];
16
+ }
17
+
18
+ function yamls(thing){
19
+ return jsYaml.dump(thing);
20
+ }
21
+
22
+ module.exports = {
23
+ yaml,
24
+ yamls,
25
+ json,
26
+ jsons
27
+ }
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.38",
3
+ "version": "1.2.41",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {