@makano/rew 1.5.0 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ const cachepath = path.join(conf({}).create('').root, '.cache');
10
10
  const localBinPath = path.join(binpath, '../../../', 'bin');
11
11
 
12
12
  const FILE_DL_EXTRACT_REGEX = /^file\+sha\(([^)]+)\)\+([a-zA-Z0-9_-]+)(\([^\)]*\))?:(.*)$|^file\+([a-zA-Z0-9_-]+)(\([^\)]*\))?:(.*)$/;
13
-
13
+ const HTTP_REGEX = /^https?:\/\/(www\.)?[a-zA-Z0-9\-._~:\/?#@!$&'()*+,;=%]+$/
14
14
 
15
15
  if (!fs.existsSync(CONFIG_PATH) || !fs.existsSync(CONFIG_PATH + '/repos.yaml')) {
16
16
  fs.mkdirSync(CONFIG_PATH, { recursive: true });
@@ -70,5 +70,6 @@ module.exports = {
70
70
  npm_package_name,
71
71
  getAllPipeInput,
72
72
  hashTags,
73
- FILE_DL_EXTRACT_REGEX
73
+ FILE_DL_EXTRACT_REGEX,
74
+ HTTP_REGEX
74
75
  }
@@ -22,7 +22,8 @@ const {
22
22
  cachepath,
23
23
  localBinPath,
24
24
  hashTags,
25
- FILE_DL_EXTRACT_REGEX
25
+ FILE_DL_EXTRACT_REGEX,
26
+ HTTP_REGEX
26
27
  } = require('./helpers');
27
28
  const { input } = require('../functions/stdout');
28
29
 
@@ -203,7 +204,7 @@ module.exports = {
203
204
  }
204
205
  }
205
206
  },
206
- installApp(pathname, opts, rmidir, rmidiri) {
207
+ installApp(pathname, opts, rmidir) {
207
208
  if (!pathname) {
208
209
  return;
209
210
  }
@@ -282,6 +283,9 @@ module.exports = {
282
283
  }
283
284
 
284
285
  log(' Installed '.green + pname.cyan.bold, ':end');
286
+ if(rmidir){
287
+ fs.rmdirSync(apppath);
288
+ }
285
289
  }
286
290
  rl.close();
287
291
  } else {
@@ -587,8 +591,10 @@ module.exports = {
587
591
  process.exit(1);
588
592
  }
589
593
 
594
+ const isUrl = HTTP_REGEX.test(url);
595
+
590
596
  const fileName = path.basename(url);
591
- const filePath = path.join(pathToDownloadInto, fileName);
597
+ const filePath = isUrl ? path.join(pathToDownloadInto, fileName) : url;
592
598
 
593
599
  const extractPath = path.join(pathToDownloadInto, 'extract');
594
600
  if(opts.c || opts.clean || opts.u){
@@ -604,13 +610,15 @@ module.exports = {
604
610
  );
605
611
 
606
612
  if(opts.verbose){
607
- log('Download started for'.cyan, url.yellow, 'at'.cyan, filePath.yellow, shaHash ? 'with sha'.cyan : '', shaHash ? shaHash.yellow : '');
613
+ if(isUrl) log('Download started for'.cyan, url.yellow, 'at'.cyan, filePath.yellow, shaHash ? 'with sha'.cyan : '', shaHash ? shaHash.yellow : '');
608
614
  } else {
609
- log(`Downloading`.cyan, fileName.yellow);
615
+ if(isUrl) log(`Downloading`.cyan, fileName.yellow);
610
616
  }
611
- const downloaded = fs.existsSync(extractPath) ? true : this.downloadFileFromUrl(url, filePath, shaHash, opts);
617
+ const downloaded = isUrl ? (
618
+ fs.existsSync(extractPath) ? true : this.downloadFileFromUrl(url, filePath, shaHash, opts)
619
+ ) : true;
612
620
  if(downloaded){
613
- log(`Download Complete for`.cyan, fileName.yellow);
621
+ if(isUrl) log(`Download Complete for`.cyan, fileName.yellow);
614
622
  log('Extracting'.cyan, fileName.yellow);
615
623
  if(opts.verbose){
616
624
  log('Running command:'.cyan, command.green.bold, 'for'.cyan, filePath.yellow, 'at'.cyan, extractPath.yellow);
@@ -631,16 +639,16 @@ module.exports = {
631
639
  return null;
632
640
  }
633
641
 
634
- return extractPath;
642
+ return [extractPath, opts, !isUrl];
635
643
  } else {
636
- return null;
644
+ return [null, opts];
637
645
  }
638
646
  },
639
647
  async installAppFrom(path, opts) {
640
- if (path.startsWith('github:')) this.installApp(await this.cloneGit(path, opts), opts, true);
641
- if (path.match(FILE_DL_EXTRACT_REGEX)) this.installApp(this.downloadFile(path, opts), opts, true);
648
+ if (path.startsWith('github:')) this.installApp(await this.cloneGit(path, opts), opts);
649
+ else if (path.match(FILE_DL_EXTRACT_REGEX)) this.installApp(...this.downloadFile(path, opts));
642
650
  else if (path.startsWith('@')) this.fromRepo(path, opts);
643
- else this.installApp(path, opts, null, null);
651
+ else this.installApp(path, opts);
644
652
  },
645
653
  uninstall(packageName, all) {
646
654
  const confPath = path.join(CONFIG_PATH, packageName);
@@ -29,6 +29,7 @@ module.exports.prepareContext = function (
29
29
  if (mainFile == "") mainFile = filepath;
30
30
  /** @type {Record<string, any>} */
31
31
  let context = {
32
+ TextDecoder,
32
33
  module: {
33
34
  exports: null,
34
35
  filepath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {