From 5414412b6b228d7922a10210825c9b85b0362af6 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Fri, 24 Apr 2020 16:55:53 +0100 Subject: [PATCH] fix: remove node globals (#52) --- packages/ipfs-unixfs-exporter/package.json | 13 +++++++------ packages/ipfs-unixfs-exporter/src/index.js | 1 + .../src/resolvers/unixfs-v1/content/file.js | 1 + .../src/utils/extract-data-from-block.js | 1 + .../src/utils/find-cid-in-shard.js | 1 + .../test/exporter-sharded.spec.js | 5 +++-- .../test/exporter-subtree.spec.js | 5 +++-- packages/ipfs-unixfs-exporter/test/exporter.spec.js | 7 ++++--- .../test/helpers/create-shard.js | 1 + packages/ipfs-unixfs-importer/package.json | 11 ++++++----- .../src/dag-builder/validate-chunks.js | 1 + packages/ipfs-unixfs-importer/src/dir-sharded.js | 1 + .../ipfs-unixfs-importer/test/benchmark.spec.js | 1 + .../test/builder-dir-sharding.spec.js | 1 + .../test/builder-only-hash.spec.js | 1 + packages/ipfs-unixfs-importer/test/builder.spec.js | 1 + .../test/chunker-custom.spec.js | 2 +- .../test/chunker-fixed-size.spec.js | 1 + .../ipfs-unixfs-importer/test/chunker-rabin.spec.js | 1 + .../test/helpers/collect-leaf-cids.js | 2 ++ .../test/helpers/finite-pseudorandom-byte-stream.js | 2 +- .../test/helpers/random-byte-stream.js | 1 + .../test/import-export-nested-dir.spec.js | 1 + packages/ipfs-unixfs-importer/test/importer.spec.js | 6 +++--- packages/ipfs-unixfs/package.json | 4 ++-- 25 files changed, 47 insertions(+), 25 deletions(-) diff --git a/packages/ipfs-unixfs-exporter/package.json b/packages/ipfs-unixfs-exporter/package.json index b74ce805..299dc117 100644 --- a/packages/ipfs-unixfs-exporter/package.json +++ b/packages/ipfs-unixfs-exporter/package.json @@ -36,23 +36,24 @@ "homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme", "devDependencies": { "abort-controller": "^3.0.0", - "aegir": "^21.3.0", - "async-iterator-all": "^1.0.0", - "async-iterator-buffer-stream": "^1.0.0", - "async-iterator-first": "^1.0.0", + "aegir": "^21.9.0", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "detect-node": "^2.0.4", "dirty-chai": "^2.0.1", "ipfs-unixfs-importer": "^2.0.0", - "ipld": "^0.25.0", + "ipld": "^0.26.1", "ipld-dag-pb": "^0.18.0", - "ipld-in-memory": "^3.0.0", + "ipld-in-memory": "^4.0.0", + "it-all": "^1.0.1", + "it-buffer-stream": "^1.0.2", + "it-first": "^1.0.1", "multicodec": "^1.0.0", "nyc": "^15.0.0", "sinon": "^9.0.1" }, "dependencies": { + "buffer": "^5.6.0", "cids": "^0.8.0", "err-code": "^2.0.0", "hamt-sharding": "^1.0.0", diff --git a/packages/ipfs-unixfs-exporter/src/index.js b/packages/ipfs-unixfs-exporter/src/index.js index b34274a6..1fbe906a 100644 --- a/packages/ipfs-unixfs-exporter/src/index.js +++ b/packages/ipfs-unixfs-exporter/src/index.js @@ -1,5 +1,6 @@ 'use strict' +const { Buffer } = require('buffer') const errCode = require('err-code') const CID = require('cids') const resolve = require('./resolvers') diff --git a/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js b/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js index 20168e5f..5cc6194a 100644 --- a/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js +++ b/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js @@ -1,5 +1,6 @@ 'use strict' +const { Buffer } = require('buffer') const extractDataFromBlock = require('../../../utils/extract-data-from-block') const validateOffsetAndLength = require('../../../utils/validate-offset-and-length') const UnixFS = require('ipfs-unixfs') diff --git a/packages/ipfs-unixfs-exporter/src/utils/extract-data-from-block.js b/packages/ipfs-unixfs-exporter/src/utils/extract-data-from-block.js index 1796e9c9..403c8f8d 100644 --- a/packages/ipfs-unixfs-exporter/src/utils/extract-data-from-block.js +++ b/packages/ipfs-unixfs-exporter/src/utils/extract-data-from-block.js @@ -1,4 +1,5 @@ 'use strict' +const { Buffer } = require('buffer') module.exports = function extractDataFromBlock (block, blockStart, requestedStart, requestedEnd) { const blockLength = block.length diff --git a/packages/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.js b/packages/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.js index bcf97c7d..3a7cfa1e 100644 --- a/packages/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.js +++ b/packages/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.js @@ -1,5 +1,6 @@ 'use strict' +const { Buffer } = require('buffer') const Bucket = require('hamt-sharding/src/bucket') const multihashing = require('multihashing-async') diff --git a/packages/ipfs-unixfs-exporter/test/exporter-sharded.spec.js b/packages/ipfs-unixfs-exporter/test/exporter-sharded.spec.js index d9112156..dfdba0af 100644 --- a/packages/ipfs-unixfs-exporter/test/exporter-sharded.spec.js +++ b/packages/ipfs-unixfs-exporter/test/exporter-sharded.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const chai = require('chai') chai.use(require('dirty-chai')) const expect = chai.expect @@ -9,9 +10,9 @@ const inMemory = require('ipld-in-memory') const UnixFS = require('ipfs-unixfs') const mh = require('multihashing-async').multihash const mc = require('multicodec') -const all = require('async-iterator-all') +const all = require('it-all') const last = require('it-last') -const randomBytes = require('async-iterator-buffer-stream') +const randomBytes = require('it-buffer-stream') const exporter = require('../src') const importer = require('ipfs-unixfs-importer') const { diff --git a/packages/ipfs-unixfs-exporter/test/exporter-subtree.spec.js b/packages/ipfs-unixfs-exporter/test/exporter-subtree.spec.js index ca1892d2..ffda69a5 100644 --- a/packages/ipfs-unixfs-exporter/test/exporter-subtree.spec.js +++ b/packages/ipfs-unixfs-exporter/test/exporter-subtree.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const chai = require('chai') chai.use(require('dirty-chai')) const expect = chai.expect @@ -8,10 +9,10 @@ const IPLD = require('ipld') const inMemory = require('ipld-in-memory') const importer = require('ipfs-unixfs-importer') const mc = require('multicodec') -const all = require('async-iterator-all') +const all = require('it-all') const last = require('it-last') -const randomBytes = require('async-iterator-buffer-stream') const blockApi = require('./helpers/block') +const randomBytes = require('it-buffer-stream') const ONE_MEG = Math.pow(1024, 2) diff --git a/packages/ipfs-unixfs-exporter/test/exporter.spec.js b/packages/ipfs-unixfs-exporter/test/exporter.spec.js index 5f89c9d2..172b90d4 100644 --- a/packages/ipfs-unixfs-exporter/test/exporter.spec.js +++ b/packages/ipfs-unixfs-exporter/test/exporter.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const chai = require('chai') chai.use(require('dirty-chai')) chai.use(require('chai-as-promised')) @@ -17,10 +18,10 @@ const mh = require('multihashing-async').multihash const mc = require('multicodec') const exporter = require('../src') const importer = require('ipfs-unixfs-importer') -const all = require('async-iterator-all') +const all = require('it-all') const last = require('it-last') -const first = require('async-iterator-first') -const randomBytes = require('async-iterator-buffer-stream') +const first = require('it-first') +const randomBytes = require('it-buffer-stream') const AbortController = require('abort-controller') const blockApi = require('./helpers/block') diff --git a/packages/ipfs-unixfs-exporter/test/helpers/create-shard.js b/packages/ipfs-unixfs-exporter/test/helpers/create-shard.js index 8cea7702..f51b7c72 100644 --- a/packages/ipfs-unixfs-exporter/test/helpers/create-shard.js +++ b/packages/ipfs-unixfs-exporter/test/helpers/create-shard.js @@ -1,5 +1,6 @@ 'use strict' +const { Buffer } = require('buffer') const importer = require('ipfs-unixfs-importer') const SHARD_SPLIT_THRESHOLD = 10 diff --git a/packages/ipfs-unixfs-importer/package.json b/packages/ipfs-unixfs-importer/package.json index c5285f72..c325746c 100644 --- a/packages/ipfs-unixfs-importer/package.json +++ b/packages/ipfs-unixfs-importer/package.json @@ -35,23 +35,24 @@ }, "homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme", "devDependencies": { - "aegir": "^21.3.0", + "aegir": "^21.9.0", "chai": "^4.2.0", "cids": "^0.8.0", - "deep-extend": "^0.6.0", "detect-node": "^2.0.4", "dirty-chai": "^2.0.1", "ipfs-unixfs-exporter": "^2.0.0", - "ipld": "^0.25.0", - "ipld-in-memory": "^3.0.0", - "it-buffer-stream": "^1.0.0", + "ipld": "^0.26.1", + "ipld-in-memory": "^4.0.0", + "it-buffer-stream": "^1.0.2", "it-last": "^1.0.1", + "merge-options": "^2.0.0", "multicodec": "^1.0.0", "nyc": "^15.0.0", "sinon": "^9.0.1" }, "dependencies": { "bl": "^4.0.0", + "buffer": "^5.6.0", "err-code": "^2.0.0", "hamt-sharding": "^1.0.0", "ipfs-unixfs": "^1.0.1", diff --git a/packages/ipfs-unixfs-importer/src/dag-builder/validate-chunks.js b/packages/ipfs-unixfs-importer/src/dag-builder/validate-chunks.js index bf3037d3..e6f430d5 100644 --- a/packages/ipfs-unixfs-importer/src/dag-builder/validate-chunks.js +++ b/packages/ipfs-unixfs-importer/src/dag-builder/validate-chunks.js @@ -1,6 +1,7 @@ 'use strict' const errCode = require('err-code') +const { Buffer } = require('buffer') // make sure the content only emits buffer-a-likes async function * validateChunks (source) { diff --git a/packages/ipfs-unixfs-importer/src/dir-sharded.js b/packages/ipfs-unixfs-importer/src/dir-sharded.js index 4378d289..22b5e1cb 100644 --- a/packages/ipfs-unixfs-importer/src/dir-sharded.js +++ b/packages/ipfs-unixfs-importer/src/dir-sharded.js @@ -4,6 +4,7 @@ const { DAGLink, DAGNode } = require('ipld-dag-pb') +const { Buffer } = require('buffer') const UnixFS = require('ipfs-unixfs') const multihashing = require('multihashing-async') const Dir = require('./dir') diff --git a/packages/ipfs-unixfs-importer/test/benchmark.spec.js b/packages/ipfs-unixfs-importer/test/benchmark.spec.js index fae3f483..aa85e56e 100644 --- a/packages/ipfs-unixfs-importer/test/benchmark.spec.js +++ b/packages/ipfs-unixfs-importer/test/benchmark.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const importer = require('../src') const IPLD = require('ipld') diff --git a/packages/ipfs-unixfs-importer/test/builder-dir-sharding.spec.js b/packages/ipfs-unixfs-importer/test/builder-dir-sharding.spec.js index 1107fdc6..523e92f2 100644 --- a/packages/ipfs-unixfs-importer/test/builder-dir-sharding.spec.js +++ b/packages/ipfs-unixfs-importer/test/builder-dir-sharding.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const importer = require('../src') const exporter = require('ipfs-unixfs-exporter') diff --git a/packages/ipfs-unixfs-importer/test/builder-only-hash.spec.js b/packages/ipfs-unixfs-importer/test/builder-only-hash.spec.js index 3592c4a2..4c28967b 100644 --- a/packages/ipfs-unixfs-importer/test/builder-only-hash.spec.js +++ b/packages/ipfs-unixfs-importer/test/builder-only-hash.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const chai = require('chai') chai.use(require('dirty-chai')) const expect = chai.expect diff --git a/packages/ipfs-unixfs-importer/test/builder.spec.js b/packages/ipfs-unixfs-importer/test/builder.spec.js index dba989cf..fc1655ff 100644 --- a/packages/ipfs-unixfs-importer/test/builder.spec.js +++ b/packages/ipfs-unixfs-importer/test/builder.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const chai = require('chai') chai.use(require('dirty-chai')) const expect = chai.expect diff --git a/packages/ipfs-unixfs-importer/test/chunker-custom.spec.js b/packages/ipfs-unixfs-importer/test/chunker-custom.spec.js index 0c571215..36e0b40f 100644 --- a/packages/ipfs-unixfs-importer/test/chunker-custom.spec.js +++ b/packages/ipfs-unixfs-importer/test/chunker-custom.spec.js @@ -2,7 +2,7 @@ 'use strict' const importer = require('../src') - +const { Buffer } = require('buffer') const chai = require('chai') chai.use(require('dirty-chai')) const expect = chai.expect diff --git a/packages/ipfs-unixfs-importer/test/chunker-fixed-size.spec.js b/packages/ipfs-unixfs-importer/test/chunker-fixed-size.spec.js index 276702ab..61193957 100644 --- a/packages/ipfs-unixfs-importer/test/chunker-fixed-size.spec.js +++ b/packages/ipfs-unixfs-importer/test/chunker-fixed-size.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const chunker = require('../src/chunker/fixed-size') const chai = require('chai') chai.use(require('dirty-chai')) diff --git a/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js b/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js index 9f9a4aff..3cf78a49 100644 --- a/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js +++ b/packages/ipfs-unixfs-importer/test/chunker-rabin.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const chunker = require('../src/chunker/rabin') const chai = require('chai') chai.use(require('dirty-chai')) diff --git a/packages/ipfs-unixfs-importer/test/helpers/collect-leaf-cids.js b/packages/ipfs-unixfs-importer/test/helpers/collect-leaf-cids.js index 4ef6a4e9..9ee910d5 100644 --- a/packages/ipfs-unixfs-importer/test/helpers/collect-leaf-cids.js +++ b/packages/ipfs-unixfs-importer/test/helpers/collect-leaf-cids.js @@ -1,5 +1,7 @@ 'use strict' +const { Buffer } = require('buffer') + module.exports = function (cid, ipld) { async function * traverse (cid) { const node = await ipld.get(cid) diff --git a/packages/ipfs-unixfs-importer/test/helpers/finite-pseudorandom-byte-stream.js b/packages/ipfs-unixfs-importer/test/helpers/finite-pseudorandom-byte-stream.js index 3b07c734..9051f1cd 100644 --- a/packages/ipfs-unixfs-importer/test/helpers/finite-pseudorandom-byte-stream.js +++ b/packages/ipfs-unixfs-importer/test/helpers/finite-pseudorandom-byte-stream.js @@ -1,5 +1,5 @@ 'use strict' - +const { Buffer } = require('buffer') const REPEATABLE_CHUNK_SIZE = 300000 module.exports = function * (maxSize, seed) { diff --git a/packages/ipfs-unixfs-importer/test/helpers/random-byte-stream.js b/packages/ipfs-unixfs-importer/test/helpers/random-byte-stream.js index 776ae90f..5d6c87fc 100644 --- a/packages/ipfs-unixfs-importer/test/helpers/random-byte-stream.js +++ b/packages/ipfs-unixfs-importer/test/helpers/random-byte-stream.js @@ -1,5 +1,6 @@ 'use strict' +const { Buffer } = require('buffer') module.exports = function * randomByteStream (seed) { while (true) { const r = Math.floor(random(seed) * 256) diff --git a/packages/ipfs-unixfs-importer/test/import-export-nested-dir.spec.js b/packages/ipfs-unixfs-importer/test/import-export-nested-dir.spec.js index 7587cf55..d6f6142f 100644 --- a/packages/ipfs-unixfs-importer/test/import-export-nested-dir.spec.js +++ b/packages/ipfs-unixfs-importer/test/import-export-nested-dir.spec.js @@ -1,6 +1,7 @@ /* eslint-env mocha */ 'use strict' +const { Buffer } = require('buffer') const chai = require('chai') chai.use(require('dirty-chai')) const expect = chai.expect diff --git a/packages/ipfs-unixfs-importer/test/importer.spec.js b/packages/ipfs-unixfs-importer/test/importer.spec.js index 665e7798..69b5a576 100644 --- a/packages/ipfs-unixfs-importer/test/importer.spec.js +++ b/packages/ipfs-unixfs-importer/test/importer.spec.js @@ -3,8 +3,8 @@ const importer = require('../src') const exporter = require('ipfs-unixfs-exporter') - -const extend = require('deep-extend') +const { Buffer } = require('buffer') +const extend = require('merge-options') const chai = require('chai') chai.use(require('dirty-chai')) const expect = chai.expect @@ -287,7 +287,7 @@ strategies.forEach((strategy) => { }) }, strategyOverrides[strategy]) - const expected = extend({}, defaultResults, strategies[strategy]) + const expected = extend({}, defaultResults) const expectFiles = (actualFiles, expectedFiles) => { expect(actualFiles.length).to.equal(expectedFiles.length) diff --git a/packages/ipfs-unixfs/package.json b/packages/ipfs-unixfs/package.json index 43e8353c..e813c140 100644 --- a/packages/ipfs-unixfs/package.json +++ b/packages/ipfs-unixfs/package.json @@ -35,13 +35,13 @@ }, "homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme", "devDependencies": { - "aegir": "^21.3.0", + "aegir": "^21.9.0", "chai": "^4.2.0", "dirty-chai": "^2.0.1", "nyc": "^15.0.0" }, "dependencies": { "err-code": "^2.0.0", - "protons": "^1.1.0" + "protons": "^1.0.2" } }