diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .npmrc | 1 | ||||
-rw-r--r-- | package-lock.json | 129 | ||||
-rw-r--r-- | package.json | 35 | ||||
-rw-r--r-- | preinstall.js | 23 |
5 files changed, 190 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed4598e --- /dev/null +++ b/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | node_modules | ||
2 | bin | ||
@@ -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 @@ | |||
1 | { | ||
2 | "name": "dhall-json", | ||
3 | "version": "1.0.0", | ||
4 | "lockfileVersion": 1, | ||
5 | "requires": true, | ||
6 | "dependencies": { | ||
7 | "base64-js": { | ||
8 | "version": "1.3.0", | ||
9 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", | ||
10 | "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" | ||
11 | }, | ||
12 | "buffer": { | ||
13 | "version": "5.2.1", | ||
14 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", | ||
15 | "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", | ||
16 | "requires": { | ||
17 | "base64-js": "^1.0.2", | ||
18 | "ieee754": "^1.1.4" | ||
19 | } | ||
20 | }, | ||
21 | "chownr": { | ||
22 | "version": "1.1.1", | ||
23 | "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", | ||
24 | "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" | ||
25 | }, | ||
26 | "debug": { | ||
27 | "version": "3.2.6", | ||
28 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", | ||
29 | "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", | ||
30 | "requires": { | ||
31 | "ms": "^2.1.1" | ||
32 | } | ||
33 | }, | ||
34 | "follow-redirects": { | ||
35 | "version": "1.7.0", | ||
36 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz", | ||
37 | "integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==", | ||
38 | "requires": { | ||
39 | "debug": "^3.2.6" | ||
40 | } | ||
41 | }, | ||
42 | "fs-minipass": { | ||
43 | "version": "1.2.6", | ||
44 | "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", | ||
45 | "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", | ||
46 | "requires": { | ||
47 | "minipass": "^2.2.1" | ||
48 | } | ||
49 | }, | ||
50 | "ieee754": { | ||
51 | "version": "1.1.13", | ||
52 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", | ||
53 | "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" | ||
54 | }, | ||
55 | "minimist": { | ||
56 | "version": "0.0.8", | ||
57 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", | ||
58 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" | ||
59 | }, | ||
60 | "minipass": { | ||
61 | "version": "2.3.5", | ||
62 | "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", | ||
63 | "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", | ||
64 | "requires": { | ||
65 | "safe-buffer": "^5.1.2", | ||
66 | "yallist": "^3.0.0" | ||
67 | } | ||
68 | }, | ||
69 | "minizlib": { | ||
70 | "version": "1.2.1", | ||
71 | "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", | ||
72 | "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", | ||
73 | "requires": { | ||
74 | "minipass": "^2.2.1" | ||
75 | } | ||
76 | }, | ||
77 | "mkdirp": { | ||
78 | "version": "0.5.1", | ||
79 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", | ||
80 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", | ||
81 | "requires": { | ||
82 | "minimist": "0.0.8" | ||
83 | } | ||
84 | }, | ||
85 | "ms": { | ||
86 | "version": "2.1.1", | ||
87 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", | ||
88 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" | ||
89 | }, | ||
90 | "safe-buffer": { | ||
91 | "version": "5.1.2", | ||
92 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", | ||
93 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" | ||
94 | }, | ||
95 | "tar": { | ||
96 | "version": "4.4.8", | ||
97 | "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", | ||
98 | "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", | ||
99 | "requires": { | ||
100 | "chownr": "^1.1.1", | ||
101 | "fs-minipass": "^1.2.5", | ||
102 | "minipass": "^2.3.4", | ||
103 | "minizlib": "^1.1.1", | ||
104 | "mkdirp": "^0.5.0", | ||
105 | "safe-buffer": "^5.1.2", | ||
106 | "yallist": "^3.0.2" | ||
107 | } | ||
108 | }, | ||
109 | "through": { | ||
110 | "version": "2.3.8", | ||
111 | "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", | ||
112 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" | ||
113 | }, | ||
114 | "unbzip2-stream": { | ||
115 | "version": "1.3.3", | ||
116 | "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.3.3.tgz", | ||
117 | "integrity": "sha512-fUlAF7U9Ah1Q6EieQ4x4zLNejrRvDWUYmxXUpN3uziFYCHapjWFaCAnreY9bGgxzaMCFAPPpYNng57CypwJVhg==", | ||
118 | "requires": { | ||
119 | "buffer": "^5.2.1", | ||
120 | "through": "^2.3.8" | ||
121 | } | ||
122 | }, | ||
123 | "yallist": { | ||
124 | "version": "3.0.3", | ||
125 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", | ||
126 | "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" | ||
127 | } | ||
128 | } | ||
129 | } | ||
diff --git a/package.json b/package.json new file mode 100644 index 0000000..c9f735e --- /dev/null +++ b/package.json | |||
@@ -0,0 +1,35 @@ | |||
1 | { | ||
2 | "name": "dhall-json", | ||
3 | "version": "1.0.0", | ||
4 | "description": "NPM package for `dhall-json`, based on https://github.com/justinwoo/npm-psc-package-bin-simple.", | ||
5 | "os": [ | ||
6 | "linux" | ||
7 | ], | ||
8 | "cpu": [ | ||
9 | "x64" | ||
10 | ], | ||
11 | "files": [ | ||
12 | "preinstall.js" | ||
13 | ], | ||
14 | "bin": { | ||
15 | "dhall-to-json": "bin/dhall-to-json", | ||
16 | "dhall-to-yaml": "bin/dhall-to-yaml" | ||
17 | }, | ||
18 | "scripts": { | ||
19 | "preinstall": "node ./preinstall.js" | ||
20 | }, | ||
21 | "repository": { | ||
22 | "type": "git", | ||
23 | "url": "git+https://github.com/cyrilfretlink/node-dhall-json.git" | ||
24 | }, | ||
25 | "author": "FretLink", | ||
26 | "bugs": { | ||
27 | "url": "https://github.com/cyrilfretlink/node-dhall-json/issues" | ||
28 | }, | ||
29 | "homepage": "https://github.com/cyrilfretlink/node-dhall-json#readme", | ||
30 | "dependencies": { | ||
31 | "follow-redirects": "^1.7.0", | ||
32 | "tar": "^4.4.8", | ||
33 | "unbzip2-stream": "^1.3.3" | ||
34 | } | ||
35 | } | ||
diff --git a/preinstall.js b/preinstall.js new file mode 100644 index 0000000..1b859fc --- /dev/null +++ b/preinstall.js | |||
@@ -0,0 +1,23 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | const { https } = require("follow-redirects"); | ||
4 | const tar = require("tar"); | ||
5 | const unbz2 = require("unbzip2-stream"); | ||
6 | |||
7 | const pkg = require("./package.json"); | ||
8 | |||
9 | const trim = str => str && String(str).trim(); | ||
10 | |||
11 | const dhallVersion = trim(pkg["dhall-version"] || process.env.DHALL_VERSION); | ||
12 | if (!dhallVersion) throw new Error("Missing DHALL_VERSION environment variable."); | ||
13 | |||
14 | const dhallJsonVersion = trim(pkg["dhall-json-version"] || process.env.DHALL_JSON_VERSION); | ||
15 | if (!dhallJsonVersion) throw new Error("Missing DHALL_JSON_VERSION environment variable."); | ||
16 | |||
17 | const release = `https://github.com/dhall-lang/dhall-haskell/releases/download/${dhallVersion}/dhall-json-${dhallJsonVersion}`; | ||
18 | |||
19 | const url = `${release}-x86_64-linux.tar.bz2`; | ||
20 | https.get(url, res => { | ||
21 | if (res.statusCode >= 400) throw new Error(`Error fetching ${url}: ${res.statusMessage}`); | ||
22 | res.pipe(unbz2()).pipe(tar.x({ C: __dirname })); | ||
23 | }); | ||