From fb1ebaccac5d96c543ce54c812b32feb4414a5e7 Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Sun, 30 Jan 2022 17:23:50 +0000 Subject: [PATCH 1/9] Add package-lock=false in .npmrc --- .npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false From 024f98f4c1c729f0bb232d35d385c2d72c06477f Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Sun, 30 Jan 2022 15:40:50 +0000 Subject: [PATCH 2/9] Minimal Node.js version in v12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ee07534..0b7aaaf 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "install-purescript": "index.js" }, "engines": { - "node": ">=8.3.0" + "node": ">=12" }, "dependencies": { "arch": "^2.1.1", From fc5b66720349ea26a0294d3efa5c1e11a4a8fd8e Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Sat, 11 Jun 2022 07:30:18 +0800 Subject: [PATCH 3/9] Upgrade tap --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0b7aaaf..463e23d 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "zen-observable": "^0.8.14" }, "devDependencies": { - "tap": "^14.2.3" + "tap": "^16.2.0" }, "scripts": { "test": "tap" From 97e1c1b0a33df98b29f8931f7f53869ede252ef1 Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Mon, 31 Jan 2022 10:01:28 +0800 Subject: [PATCH 4/9] Drop mkdirp dependency --- dl-tar/index.js | 8 +++----- package.json | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dl-tar/index.js b/dl-tar/index.js index aa2ebe8..b0b0ed3 100644 --- a/dl-tar/index.js +++ b/dl-tar/index.js @@ -1,18 +1,16 @@ 'use strict'; -const {inspect, promisify} = require('util'); +const {inspect} = require('util'); const {resolve} = require('path'); const {Transform} = require('stream'); +const {promises: fs} = require('fs'); const cancelablePump = require('../cancelable-pump/index.js'); const {Unpack} = require('tar'); const isPlainObj = require('is-plain-obj'); const request = require('request'); -const mkdirp = require('mkdirp'); const Observable = require('zen-observable'); -const promisifiedMkdirp = promisify(mkdirp); - class InternalUnpack extends Unpack { constructor(options) { super({ @@ -173,7 +171,7 @@ module.exports = function dlTar(...args) { (async () => { try { if (absoluteDest !== cwd) { - await promisifiedMkdirp(absoluteDest); + await fs.mkdir(absoluteDest, {recursive: true}); } if (ended) { diff --git a/package.json b/package.json index 463e23d..6f1b36d 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "log-symbols": "^3.0.0", "log-update": "^3.2.0", "minimist": "^1.2.0", - "mkdirp": "^0.5.1", "ms": "^2.1.2", "once": "^1.4.0", "pump": "^3.0.0", From 760598db4665e9f85d9bab8a757d6205a657635e Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Sun, 30 Jan 2022 15:41:26 +0000 Subject: [PATCH 5/9] Upgrade tar --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f1b36d..6b719c0 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "request": "^2.88.0", "rimraf": "^2.6.3", "semver": "^7.3.7", - "tar": "^4.4.6", + "tar": "^6.1.11", "which": "^1.3.1", "zen-observable": "^0.8.14" }, From ff0fe0688f38b507813acf2d468981127bc2aefb Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Tue, 1 Feb 2022 05:20:23 +0800 Subject: [PATCH 6/9] Replace request with make-fetch-happen --- dl-tar/index.js | 31 +++++++++++++++++-------------- package.json | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/dl-tar/index.js b/dl-tar/index.js index b0b0ed3..e9a610e 100644 --- a/dl-tar/index.js +++ b/dl-tar/index.js @@ -8,7 +8,7 @@ const {promises: fs} = require('fs'); const cancelablePump = require('../cancelable-pump/index.js'); const {Unpack} = require('tar'); const isPlainObj = require('is-plain-obj'); -const request = require('request'); +const fetch = require('make-fetch-happen'); const Observable = require('zen-observable'); class InternalUnpack extends Unpack { @@ -184,21 +184,24 @@ module.exports = function dlTar(...args) { observer }); - const pipe = [ - request({url, ...options, encoding: null}) - .on('response', function(response) { - if (response.statusCode < 200 || 299 < response.statusCode) { - this.emit('error', new Error(`${response.statusCode} ${response.statusMessage}`)); - return; - } + const {baseUrl, headers} = options; + const {href} = new URL(url, baseUrl); - if (typeof response.headers['content-length'] === 'string') { - response.headers['content-length'] = Number(response.headers['content-length']); - } + const res = await fetch(href, {headers}).then(response => { - unpackStream.url = response.request.uri.href; - unpackStream.responseHeaders = response.headers; - }), + if (response.ok !== true) { + throw new Error(`${response.status} ${response.statusText}`); + } + + unpackStream.url = response.url; + unpackStream.responseHeaders = response.headers; + + return response; + + }); + + const pipe = [ + res.body, new Transform({ transform(chunk, encoding, cb) { unpackStream.responseBytes += chunk.length; diff --git a/package.json b/package.json index 6b719c0..79ddf31 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ "is-plain-obj": "^2.0.0", "log-symbols": "^3.0.0", "log-update": "^3.2.0", + "make-fetch-happen": "^10.0.0", "minimist": "^1.2.0", "ms": "^2.1.2", "once": "^1.4.0", "pump": "^3.0.0", - "request": "^2.88.0", "rimraf": "^2.6.3", "semver": "^7.3.7", "tar": "^6.1.11", From 09b950db7f7c9bd5e02fb84c787f29373fd644da Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Mon, 31 Jan 2022 02:16:55 +0800 Subject: [PATCH 7/9] Upgrade log-update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79ddf31..b83ec44 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "filesize": "^4.1.2", "is-plain-obj": "^2.0.0", "log-symbols": "^3.0.0", - "log-update": "^3.2.0", + "log-update": "^4.0.0", "make-fetch-happen": "^10.0.0", "minimist": "^1.2.0", "ms": "^2.1.2", From f7b045ca3724c7956cea41fbaf0714f6cb236942 Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Wed, 2 Feb 2022 06:42:16 +0800 Subject: [PATCH 8/9] Replace pump with pipeline --- cancelable-pump/index.js | 2 +- install-purescript/index.js | 3 +-- package.json | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cancelable-pump/index.js b/cancelable-pump/index.js index 4a329bf..7a8b86e 100644 --- a/cancelable-pump/index.js +++ b/cancelable-pump/index.js @@ -1,6 +1,6 @@ 'use strict'; -const pump = require('pump'); +const {pipeline: pump} = require('stream'); const cancel = new Error('Canceled.'); diff --git a/install-purescript/index.js b/install-purescript/index.js index 1f16a02..ab4f3e9 100644 --- a/install-purescript/index.js +++ b/install-purescript/index.js @@ -4,14 +4,13 @@ const fs = require('fs'); const {execFile} = require('child_process'); const path = require('path'); const {inspect, promisify} = require('util'); -const {Writable} = require('stream'); +const {pipeline: pump} = require('stream'); const arch = require('arch'); const {create, Unpack} = require('tar'); const cacache = require('cacache'); const isPlainObj = require('is-plain-obj'); const Observable = require('zen-observable'); -const pump = require('pump'); const envPaths = require('env-paths'); const downloadOrBuildPurescript = require('../download-or-build-purescript/index.js'); diff --git a/package.json b/package.json index b83ec44..a83b2c9 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "minimist": "^1.2.0", "ms": "^2.1.2", "once": "^1.4.0", - "pump": "^3.0.0", "rimraf": "^2.6.3", "semver": "^7.3.7", "tar": "^6.1.11", From be0c0f6c2e027a0b1a3f9a7cf399c61b45291a2e Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Sat, 11 Jun 2022 07:27:20 +0800 Subject: [PATCH 9/9] refine CI --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fbea26..017be26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,12 +16,12 @@ jobs: build: runs-on: "ubuntu-latest" steps: - - uses: "actions/checkout@v2" + - uses: "actions/checkout@v3" - - uses: "actions/setup-node@v2" + - uses: "actions/setup-node@v3" with: node-version: "14.x" - - run: npm install + - run: npm install --ignore-scripts --no-fund - - run: node test/index.js + - run: npm test -- --no-check-coverage --timeout=60