add webi to npm as @root/webi@v0.5.0
authorAJ ONeal <coolaj86@gmail.com>
Tue, 14 Jul 2020 06:36:44 +0000 (00:36 -0600)
committerAJ ONeal <coolaj86@gmail.com>
Tue, 14 Jul 2020 06:36:44 +0000 (00:36 -0600)
_npm/README.md [new file with mode: 0644]
_npm/lib/exec.js [new file with mode: 0644]
_npm/package-lock.json [new file with mode: 0644]
_npm/package.json [new file with mode: 0644]
_npm/scripts/install-webi.js [new file with mode: 0755]

diff --git a/_npm/README.md b/_npm/README.md
new file mode 100644 (file)
index 0000000..2e2df0a
--- /dev/null
@@ -0,0 +1,36 @@
+# [webi](https://webinstall.dev)
+
+Effortlessly install developer tools with easy-to-remember URLs.
+
+`webi` is an easy-to-remember cross-platform way to
+
+- install things quickly
+- without being `root` or Admin
+- without touching system files or permissions
+- without looking up docs
+
+## Example: Installing node
+
+Mac & Linux:
+
+```bash
+curl -fsS https://webinstall.dev/node | bash
+```
+
+Windows 10 (includes `curl.exe` and PowerShell by default):
+
+```bash
+curl.exe -fsSA "MS" https://webinstall.dev/node | powershell
+```
+
+## Example: Switching node versions
+
+```bash
+webi node@stable
+webi node@lts
+webi node@v10
+```
+
+## Meta Package
+
+This is a meta package for [webi™](https://webinstall.dev/webi).
diff --git a/_npm/lib/exec.js b/_npm/lib/exec.js
new file mode 100644 (file)
index 0000000..7b70ce4
--- /dev/null
@@ -0,0 +1,30 @@
+'use strict';
+
+var pkg = require('../package.json');
+var spawn = require('child_process').spawn;
+var os = require('os');
+var path = require('path');
+
+function spawner(args) {
+  return new Promise(function (resolve, reject) {
+    var bin = args.shift();
+    var runner = spawn(bin, args, {
+      windowsHide: true
+    });
+    runner.stdout.on('data', function (chunk) {
+      console.info(chunk.toString('utf8'));
+    });
+    runner.stderr.on('data', function (chunk) {
+      console.error(chunk.toString('utf8'));
+    });
+    runner.on('exit', function (code) {
+      if (0 !== code) {
+        reject(new Error("exited with non-zero status code '" + code + "'"));
+        return;
+      }
+      resolve({ code: code });
+    });
+  });
+}
+
+module.exports = spawner;
diff --git a/_npm/package-lock.json b/_npm/package-lock.json
new file mode 100644 (file)
index 0000000..0c8e157
--- /dev/null
@@ -0,0 +1,13 @@
+{
+  "name": "@root/webi",
+  "version": "0.5.0",
+  "lockfileVersion": 1,
+  "requires": true,
+  "dependencies": {
+    "@root/request": {
+      "version": "1.6.1",
+      "resolved": "https://registry.npmjs.org/@root/request/-/request-1.6.1.tgz",
+      "integrity": "sha512-8wrWyeBLRp7T8J36GkT3RODJ6zYmL0/maWlAUD5LOXT28D3TDquUepyYDKYANNA3Gc8R5ZCgf+AXvSTYpJEWwQ=="
+    }
+  }
+}
diff --git a/_npm/package.json b/_npm/package.json
new file mode 100644 (file)
index 0000000..2086e7e
--- /dev/null
@@ -0,0 +1,28 @@
+{
+  "name": "@root/webi",
+  "version": "0.5.0",
+  "description": "Effortlessly install developer tools with easy-to-remember URLs",
+  "main": "index.js",
+  "homepage": "https://webinstall.dev",
+  "files": [
+    "scripts/"
+  ],
+  "scripts": {
+    "postinstall": "node scripts/webi.js",
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/webinstall/packages"
+  },
+  "keywords": [
+    "webi",
+    "webinstall",
+    "install"
+  ],
+  "author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
+  "license": "MPL-2.0",
+  "dependencies": {
+    "@root/request": "^1.6.1"
+  }
+}
diff --git a/_npm/scripts/install-webi.js b/_npm/scripts/install-webi.js
new file mode 100755 (executable)
index 0000000..0718c1f
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/env node
+
+'use strict';
+
+//var pkg = require('../package.json');
+var os = require('os');
+//var request = require('@root/request');
+//var promisify = require('util').promisify;
+//var exec = promisify(require('child_process').exec);
+var exec = require('child_process').exec;
+
+if (/^win/i.test(os.platform())) {
+  console.warn('');
+  console.warn("This npm installer doesn't work on windows yet.");
+  console.warn('Copy and paste this into cmd.exe or PowerShell instead:');
+  console.warn('');
+  console.warn(
+    "    curl.exe -fsSA 'MS' https://webinstall.dev/webi | powershell"
+  );
+  console.warn('');
+  return;
+}
+
+exec('curl -fsS https://webinstall.dev/webi | bash', function (
+  err,
+  stdout,
+  stderr
+) {
+  if (err) {
+    console.error(err);
+  }
+  if (stdout) {
+    console.info(stdout);
+  }
+  if (stderr) {
+    console.error(stderr);
+  }
+});
+/*
+  .then(function () {
+    // nada
+  })
+  .catch(function (err) {
+    console.error(err);
+  });
+*/