From bf3727ff7fedc2b3c0d027f0916faf5f40e51e44 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Tue, 2 Mar 2021 12:41:31 +0000 Subject: [PATCH 1/4] fix: update to aegir 31 and others deps --- .github/workflows/main.yml | 44 ++++++++++++++++++++++++-------------- package.json | 8 +++---- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b94c65e..a8241e9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,13 +12,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: yarn - - run: yarn lint - - run: yarn build - - uses: gozala/typescript-error-reporter-action@v1.0.4 - - run: yarn aegir dep-check -- -i aegir + - run: npm install + - run: npx aegir lint + - run: npx aegir ts -p check + # or + # - uses: gozala/typescript-error-reporter-action@v1.0.8 + - run: npx aegir build + - run: npx aegir dep-check - uses: ipfs/aegir/actions/bundle-size@master - name: size with: github_token: ${{ secrets.GITHUB_TOKEN }} test-node: @@ -34,34 +35,45 @@ jobs: - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} - - run: yarn - - run: npx nyc --reporter=lcov npm run test:node -- --bail + - run: npm install + - run: npx aegir test -t node --bail --cov - uses: codecov/codecov-action@v1 test-chrome: needs: check runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: yarn - - run: yarn aegir test -t browser -t webworker + - uses: microsoft/playwright-github-action@v1 + - run: npm install + - run: npx aegir test -t browser -t webworker --bail --cov + - uses: codecov/codecov-action@v1 test-firefox: needs: check runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: yarn - - run: yarn aegir test -t browser -t webworker -- --browsers FirefoxHeadless + - uses: microsoft/playwright-github-action@v1 + - run: npm install + - run: npx aegir test -t browser -t webworker --bail -- --browser firefox + test-webkit: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: microsoft/playwright-github-action@v1 + - run: npm install + - run: npx aegir test -t browser -t webworker --bail -- --browser webkit test-electron-main: needs: check runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: yarn - - run: npx xvfb-maybe yarn aegir test -t electron-main --bail + - run: npm install + - run: npx xvfb-maybe aegir test -t electron-main --bail test-electron-renderer: needs: check runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: yarn - - run: npx xvfb-maybe yarn aegir test -t electron-renderer --bail \ No newline at end of file + - run: npm install + - run: npx xvfb-maybe aegir test -t electron-renderer --bail \ No newline at end of file diff --git a/package.json b/package.json index b3859b9..2f5984d 100644 --- a/package.json +++ b/package.json @@ -40,10 +40,10 @@ "url": "https://github.com/multiformats/js-cid/issues" }, "dependencies": { - "multibase": "^3.0.1", - "multicodec": "^2.1.0", - "multihashes": "^3.1.0", - "uint8arrays": "^2.0.5" + "multibase": "^4.0.1", + "multicodec": "^2.1.1", + "multihashes": "^4.0.1", + "uint8arrays": "^2.1.3" }, "devDependencies": { "@sinonjs/samsam": "^5.3.0", From 91379323cfb42c33188970ab07cf2d18b40ce094 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Tue, 2 Mar 2021 12:47:05 +0000 Subject: [PATCH 2/4] fix: fix types --- src/index.js | 8 ++++---- test/index.spec.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 6f6e77c..0030633 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ const mh = require('multihashes') const multibase = require('multibase') const multicodec = require('multicodec') -const { baseTable: codecs } = require('multicodec/src/base-table.js') +const { baseTable: codecs } = require('multicodec/src/generated-table') const CIDUtil = require('./cid-util') const uint8ArrayConcat = require('uint8arrays/concat') const uint8ArrayToString = require('uint8arrays/to-string') @@ -12,7 +12,7 @@ const uint8ArrayEquals = require('uint8arrays/equals') const codecInts = /** @type {CodecName[]} */(Object.keys(codecs)).reduce((p, name) => { p[codecs[name]] = name return p -}, /** @type {Record} */({})) +}, /** @type {Record} */({})) const symbol = Symbol.for('@ipld/js-cid/CID') @@ -26,7 +26,7 @@ const symbol = Symbol.for('@ipld/js-cid/CID') * @typedef {0|1} CIDVersion * @typedef {import('multibase').BaseNameOrCode} BaseNameOrCode * @typedef {import('multicodec').CodecName} CodecName - * @typedef {import('multicodec').CodecNumber} CodecNumber + * @typedef {import('multicodec').CodecCode} CodecCode */ /** @@ -221,7 +221,7 @@ class CID { /** * The codec of the CID in its number form. * - * @returns {CodecNumber} + * @returns {CodecCode} */ get code () { return codecs[this.codec] diff --git a/test/index.spec.js b/test/index.spec.js index 1cc9387..fc9d3ec 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -238,7 +238,7 @@ describe('CID', () => { expect(() => { new CID(1, 'this-codec-doesnt-exist', hash).toBaseEncodedString() }).to.throw( - 'Codec `this-codec-doesnt-exist` not found' + 'Codec "this-codec-doesnt-exist" not found' ) }) From 7e37af6d647934bd33cc6f86fd5862a121ae2e04 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Tue, 2 Mar 2021 15:40:59 +0000 Subject: [PATCH 3/4] fix: update multicodec --- package.json | 2 +- src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2f5984d..f360c16 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "dependencies": { "multibase": "^4.0.1", - "multicodec": "^2.1.1", + "multicodec": "^3.0.1", "multihashes": "^4.0.1", "uint8arrays": "^2.1.3" }, diff --git a/src/index.js b/src/index.js index 0030633..2562c54 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ const mh = require('multihashes') const multibase = require('multibase') const multicodec = require('multicodec') -const { baseTable: codecs } = require('multicodec/src/generated-table') +const { nameToCode: codecs } = require('multicodec') const CIDUtil = require('./cid-util') const uint8ArrayConcat = require('uint8arrays/concat') const uint8ArrayToString = require('uint8arrays/to-string') From 221dc3cc5b7ebaab6f4c672e476e9adf4aea1562 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Tue, 2 Mar 2021 15:50:02 +0000 Subject: [PATCH 4/4] fix: multicodec import --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 2562c54..e9c25dc 100644 --- a/src/index.js +++ b/src/index.js @@ -3,12 +3,12 @@ const mh = require('multihashes') const multibase = require('multibase') const multicodec = require('multicodec') -const { nameToCode: codecs } = require('multicodec') const CIDUtil = require('./cid-util') const uint8ArrayConcat = require('uint8arrays/concat') const uint8ArrayToString = require('uint8arrays/to-string') const uint8ArrayEquals = require('uint8arrays/equals') +const codecs = multicodec.nameToCode const codecInts = /** @type {CodecName[]} */(Object.keys(codecs)).reduce((p, name) => { p[codecs[name]] = name return p