From a4e6dec5fcffa5d51a96722a07668bab02336d5f Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Fri, 17 May 2019 13:39:14 +0200 Subject: Download `dhall-json` from `dhall-lang/dhall-haskell` releases --- .gitignore | 2 + .npmrc | 1 + package-lock.json | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 35 +++++++++++++++ preinstall.js | 23 ++++++++++ 5 files changed, 190 insertions(+) create mode 100644 .gitignore create mode 100644 .npmrc create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 preinstall.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed4598e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +bin diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..29a5d41 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +ignore-scripts = true diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..1d1085f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,129 @@ +{ + "name": "dhall-json", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "base64-js": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" + }, + "buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", + "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "chownr": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "follow-redirects": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz", + "integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==", + "requires": { + "debug": "^3.2.6" + } + }, + "fs-minipass": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", + "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", + "requires": { + "minipass": "^2.2.1" + } + }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minipass": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "tar": { + "version": "4.4.8", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", + "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + } + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "unbzip2-stream": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.3.3.tgz", + "integrity": "sha512-fUlAF7U9Ah1Q6EieQ4x4zLNejrRvDWUYmxXUpN3uziFYCHapjWFaCAnreY9bGgxzaMCFAPPpYNng57CypwJVhg==", + "requires": { + "buffer": "^5.2.1", + "through": "^2.3.8" + } + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..c9f735e --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "dhall-json", + "version": "1.0.0", + "description": "NPM package for `dhall-json`, based on https://github.com/justinwoo/npm-psc-package-bin-simple.", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "files": [ + "preinstall.js" + ], + "bin": { + "dhall-to-json": "bin/dhall-to-json", + "dhall-to-yaml": "bin/dhall-to-yaml" + }, + "scripts": { + "preinstall": "node ./preinstall.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/cyrilfretlink/node-dhall-json.git" + }, + "author": "FretLink", + "bugs": { + "url": "https://github.com/cyrilfretlink/node-dhall-json/issues" + }, + "homepage": "https://github.com/cyrilfretlink/node-dhall-json#readme", + "dependencies": { + "follow-redirects": "^1.7.0", + "tar": "^4.4.8", + "unbzip2-stream": "^1.3.3" + } +} diff --git a/preinstall.js b/preinstall.js new file mode 100644 index 0000000..1b859fc --- /dev/null +++ b/preinstall.js @@ -0,0 +1,23 @@ +"use strict"; + +const { https } = require("follow-redirects"); +const tar = require("tar"); +const unbz2 = require("unbzip2-stream"); + +const pkg = require("./package.json"); + +const trim = str => str && String(str).trim(); + +const dhallVersion = trim(pkg["dhall-version"] || process.env.DHALL_VERSION); +if (!dhallVersion) throw new Error("Missing DHALL_VERSION environment variable."); + +const dhallJsonVersion = trim(pkg["dhall-json-version"] || process.env.DHALL_JSON_VERSION); +if (!dhallJsonVersion) throw new Error("Missing DHALL_JSON_VERSION environment variable."); + +const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`; + +const url = `${release}-x86_64-linux.tar.bz2`; +https.get(url, res => { + if (res.statusCode >= 400) throw new Error(`Error fetching ${url}: ${res.statusMessage}`); + res.pipe(unbz2()).pipe(tar.x({ C: __dirname })); +}); -- cgit v1.2.3