From 163d4632708b874b60c5a8de0f77811034557f74 Mon Sep 17 00:00:00 2001 From: mauve Date: Fri, 26 Aug 2022 19:00:25 -0400 Subject: [PATCH] feat!: use aegir for ESM-only build/testing/release BREAKING CHANGE ESM-only publish --- .eslintrc | 15 +- .github/dependabot.yml | 23 +- .github/workflows/automerge.yml | 8 + .github/workflows/js-test-and-release.yml | 145 ++++++++++ .github/workflows/test-and-release.yml | 61 ---- .gitignore | 6 +- LICENSE | 4 + LICENSE-APACHE | 14 +- LICENSE-MIT | 20 +- README.md | 98 ++++--- package.json | 273 ++++++++++-------- test/{test-block.js => test-block.spec.js} | 0 test/{test-bytes.js => test-bytes.spec.js} | 0 test/{test-cid.js => test-cid.spec.js} | 0 ...se-spec.js => test-multibase-spec.spec.js} | 0 ...st-multibase.js => test-multibase.spec.js} | 0 ...-multicodec.js => test-multicodec.spec.js} | 0 ...st-multihash.js => test-multihash.spec.js} | 0 ...st-traversal.js => test-traversal.spec.js} | 0 19 files changed, 398 insertions(+), 269 deletions(-) create mode 100644 .github/workflows/automerge.yml create mode 100644 .github/workflows/js-test-and-release.yml delete mode 100644 .github/workflows/test-and-release.yml create mode 100644 LICENSE rename test/{test-block.js => test-block.spec.js} (100%) rename test/{test-bytes.js => test-bytes.spec.js} (100%) rename test/{test-cid.js => test-cid.spec.js} (100%) rename test/{test-multibase-spec.js => test-multibase-spec.spec.js} (100%) rename test/{test-multibase.js => test-multibase.spec.js} (100%) rename test/{test-multicodec.js => test-multicodec.spec.js} (100%) rename test/{test-multihash.js => test-multihash.spec.js} (100%) rename test/{test-traversal.js => test-traversal.spec.js} (100%) diff --git a/.eslintrc b/.eslintrc index 43f463c6..f105f877 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,13 +1,8 @@ { - "extends": [ - "standard", - "plugin:@typescript-eslint/recommended" - ], - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/ban-ts-comment": "off" + "extends": "ipfs", + "env": { + "browser": true, + "node": true, + "es2020": true } } diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f4689933..0bc3b42d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,16 +1,11 @@ version: 2 updates: - - package-ecosystem: 'github-actions' - directory: '/' - schedule: - interval: 'daily' - commit-message: - prefix: 'chore' - include: 'scope' - - package-ecosystem: 'npm' - directory: '/' - schedule: - interval: 'daily' - commit-message: - prefix: 'chore' - include: 'scope' +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 + commit-message: + prefix: "deps" + prefix-development: "deps(dev)" diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..d57c2a02 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,8 @@ +name: Automerge +on: [ pull_request ] + +jobs: + automerge: + uses: protocol/.github/.github/workflows/automerge.yml@master + with: + job: 'automerge' diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml new file mode 100644 index 00000000..4c19afab --- /dev/null +++ b/.github/workflows/js-test-and-release.yml @@ -0,0 +1,145 @@ +name: test & maybe release +on: + push: + branches: + - esm-migration # with #262 - ${{{ github.default_branch }}} + pull_request: + branches: + - esm-migration # with #262 - ${{{ github.default_branch }}} + +jobs: + + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present lint + - run: npm run --if-present dep-check + + test-node: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [16] + fail-fast: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:node + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: node + + test-chrome: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: chrome + + test-chrome-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome-webworker + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: chrome-webworker + + test-firefox: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: firefox + + test-firefox-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox-webworker + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: firefox-webworker + + test-electron-main: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-main + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: electron-main + + test-electron-renderer: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-renderer + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: electron-renderer + + release: + needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer] + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/esm-migration' # with #262 - 'refs/heads/${{{ github.default_branch }}}' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/docker-login@master + with: + docker-token: ${{ secrets.DOCKER_TOKEN }} + docker-username: ${{ secrets.DOCKER_USERNAME }} + - run: npm run --if-present release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml deleted file mode 100644 index c2f9eb50..00000000 --- a/.github/workflows/test-and-release.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Test & Maybe Release -on: [push, pull_request] -jobs: - test: - strategy: - fail-fast: false - matrix: - node: [14.x, 16.x] - os: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v3.5.0 - with: - node-version: ${{ matrix.node }} - - name: Install Dependencies - run: | - npm install --no-progress - - name: Run tests - run: | - npm config set script-shell bash - npm run test:ci - release: - name: Release - needs: test - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/master' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup Node.js - uses: actions/setup-node@v3.5.0 - with: - node-version: 14 - - name: Install dependencies - run: | - npm install --no-progress --no-package-lock --no-save - - name: Build - run: | - npm run build - - name: Install plugins - run: | - npm install \ - @semantic-release/commit-analyzer \ - conventional-changelog-conventionalcommits \ - @semantic-release/release-notes-generator \ - @semantic-release/npm \ - @semantic-release/github \ - @semantic-release/git \ - @semantic-release/changelog \ - --no-progress --no-package-lock --no-save - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release - diff --git a/.gitignore b/.gitignore index 4f8f0207..16496d32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ -.nyc_output -build -dist -coverage +.coverage package-lock.json node_modules .DS_Store @@ -9,3 +6,4 @@ yarn.lock types test/ts-use/tsconfig.tsbuildinfo test/tsconfig.tsbuildinfo +*.log diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/LICENSE-APACHE b/LICENSE-APACHE index fcd6df33..14478a3b 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -1,13 +1,5 @@ -Copyright 2020 Protocol Labs +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT index 9bddb3e8..72dc60d8 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,7 +1,19 @@ -Copyright 2020 Protocol Labs +The MIT License (MIT) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 613af3dd..5515e280 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,40 @@ -# multiformats - -* [Interfaces](#interfaces) - * [Creating Blocks](#creating-blocks) - * [Multibase Encoders / Decoders / Codecs](#multibase-encoders--decoders--codecs) - * [Multicodec Encoders / Decoders / Codecs](#multicodec-encoders--decoders--codecs) - * [Multihash Hashers](#multihash-hashers) - * [Traversal](#traversal) -* [Legacy interface](#legacy-interface) -* [Implementations](#implementations) - * [Multibase codecs](#multibase-codecs) - * [Multihash hashers](#multihash-hashers-1) - * [IPLD codecs (multicodec)](#ipld-codecs-multicodec) -* [License](#license) - * [Contribution](#contribution) +# multiformats + +[![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io) +[![codecov](https://img.shields.io/codecov/c/github/multiformats/js-multiformats.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-multiformats) +[![CI](https://img.shields.io/github/workflow/status/multiformats/js-multiformats/test%20&%20maybe%20release/esm-migration?style=flat-square)](https://github.com/multiformats/js-multiformats/actions/workflows/js-test-and-release.yml) + +> Interface for multihash, multicodec, multibase and CID + +## Table of contents + +- [Install](#install) +- [Interfaces](#interfaces) + - [Creating Blocks](#creating-blocks) + - [Multibase Encoders / Decoders / Codecs](#multibase-encoders--decoders--codecs) + - [Multicodec Encoders / Decoders / Codecs](#multicodec-encoders--decoders--codecs) + - [Multihash Hashers](#multihash-hashers) + - [Traversal](#traversal) +- [Legacy interface](#legacy-interface) +- [Implementations](#implementations) + - [Multibase codecs](#multibase-codecs) + - [Multihash hashers](#multihash-hashers-1) + - [IPLD codecs (multicodec)](#ipld-codecs-multicodec) +- [License](#license) +- [Contribution](#contribution) + +## Install + +```console +$ npm i multiformats +``` + +## Interfaces This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume. This library provides implementations for most basics and many others can be found in linked repositories. -## Interfaces - ```js import { CID } from 'multiformats/cid' import * as json from 'multiformats/codecs/json' @@ -77,7 +92,6 @@ them as `encoder` and `decoder` properties. For added convenience codecs also implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be used as either or both: - ```js cid.toString(base64) CID.parse(cid.toString(base64), base64) @@ -189,43 +203,43 @@ import the ones you need yourself. ### Multibase codecs -| bases | import | repo | - --- | --- | --- | -`base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | -`base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | -`base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | -`base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | +| bases | import | repo | +| ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- | +| `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | +| `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | +| `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | +| `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`. ### Multihash hashers -| hashes | import | repo | -| --- | --- | --- | -| `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) | -| `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) | -| `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) | -| `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) | -| `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) | +| hashes | import | repo | +| ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ | +| `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) | +| `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) | +| `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) | +| `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) | +| `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) | ### IPLD codecs (multicodec) -| codec | import | repo | -| --- | --- | --- | -| `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | -| `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | -| `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) | -| `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) | -| `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) | -| `dag-jose` | `dag-jose`| [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) | +| codec | import | repo | +| ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ | +| `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | +| `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | +| `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) | +| `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) | +| `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) | +| `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) | ## License Licensed under either of - * Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0) - * MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT) +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -### Contribution +## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/package.json b/package.json index 8c583f77..2a3675d4 100644 --- a/package.json +++ b/package.json @@ -2,167 +2,157 @@ "name": "multiformats", "version": "0.0.0-dev", "description": "Interface for multihash, multicodec, multibase and CID", - "main": "./src/index.js", - "types": "./types/src/index.d.ts", - "type": "module", - "scripts": { - "build": "npm run build:js && npm run build:types", - "build:js": "ipjs build --tests --main && npm run build:copy", - "build:copy": "cp -a tsconfig.json src vendor test dist/ && rm -rf dist/test/ts-use", - "build:types": "npm run build:copy && cd dist && tsc --build", - "build:vendor": "npm run build:vendor:varint && npm run build:vendor:base-x", - "build:vendor:varint": "npm_config_yes=true npx brrp -x varint > vendor/varint.js", - "build:vendor:base-x": "npm_config_yes=true npx brrp -x @multiformats/base-x > vendor/base-x.js", - "lint": "standard", - "test:cjs": "npm run build:js && mocha dist/cjs/node-test/test-*.js && npm run test:cjs:browser", - "test:esm": "npm run build:js && mocha dist/esm/node-test/test-*.js && npm run test:esm:browser", - "test:node": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha test/test-*.js", - "test:cjs:browser": "polendina --page --worker --serviceworker --cleanup dist/cjs/browser-test/test-*.js", - "test:esm:browser": "polendina --page --worker --serviceworker --cleanup dist/esm/browser-test/test-*.js", - "test:ts": "npm run build:types && npm run test --prefix test/ts-use", - "test": "npm run lint && npm run test:node && npm run test:esm && npm run test:ts", - "test:ci": "npm run lint && npm run test:node && npm run test:esm && npm run test:cjs && npm run test:ts", - "coverage": "c8 --reporter=html mocha test/test-*.js && npm_config_yes=true npx st -d coverage -p 8080" + "author": "Mikeal Rogers (https://www.mikealrogers.com/)", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/multiformats/js-multiformats#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/multiformats/js-multiformats.git" }, - "c8": { - "exclude": [ - "test/**", - "vendor/**" - ] + "bugs": { + "url": "https://github.com/multiformats/js-multiformats/issues" }, "keywords": [ "ipfs", "ipld", "multiformats" ], - "author": "Mikeal Rogers (https://www.mikealrogers.com/)", - "license": "(Apache-2.0 AND MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, + "files": [ + "src", + "dist", + "!dist/test", + "!**/*.tsbuildinfo" + ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, - "./cid": { - "import": "./src/cid.js" - }, - "./link": { - "import": "./src/link.js" - }, - "./basics": { - "import": "./src/basics.js" - }, - "./block": { - "import": "./src/block.js" - }, - "./traversal": { - "import": "./src/traversal.js" - }, - "./bases/identity": { - "import": "./src/bases/identity.js" - }, - "./bases/base2": { - "import": "./src/bases/base2.js" - }, - "./bases/base8": { - "import": "./src/bases/base8.js" - }, "./bases/base10": { + "types": "./src/bases/base10.d.ts", "import": "./src/bases/base10.js" }, "./bases/base16": { + "types": "./src/bases/base16.d.ts", "import": "./src/bases/base16.js" }, + "./bases/base2": { + "types": "./src/bases/base2.d.ts", + "import": "./src/bases/base2.js" + }, + "./bases/base256emoji": { + "types": "./src/bases/base256emoji.d.ts", + "import": "./src/bases/base256emoji.js" + }, "./bases/base32": { + "types": "./src/bases/base32.d.ts", "import": "./src/bases/base32.js" }, "./bases/base36": { + "types": "./src/bases/base36.d.ts", "import": "./src/bases/base36.js" }, "./bases/base58": { + "types": "./src/bases/base58.d.ts", "import": "./src/bases/base58.js" }, "./bases/base64": { + "types": "./src/bases/base64.d.ts", "import": "./src/bases/base64.js" }, - "./bases/base256emoji": { - "import": "./src/bases/base256emoji.js" + "./bases/base8": { + "types": "./src/bases/base8.d.ts", + "import": "./src/bases/base8.js" }, - "./hashes/hasher": { - "import": "./src/hashes/hasher.js" + "./bases/identity": { + "types": "./src/bases/identity.d.ts", + "import": "./src/bases/identity.js" }, - "./hashes/digest": { - "import": "./src/hashes/digest.js" + "./basics": { + "types": "./src/basics.d.ts", + "import": "./src/basics.js" }, - "./hashes/sha2": { - "browser": "./src/hashes/sha2-browser.js", - "import": "./src/hashes/sha2.js" + "./block": { + "types": "./src/block.d.ts", + "import": "./src/block.js" }, - "./hashes/identity": { - "import": "./src/hashes/identity.js" + "./bytes": { + "types": "./src/bytes.d.ts", + "import": "./src/bytes.js" + }, + "./cid": { + "types": "./src/cid.d.ts", + "import": "./src/cid.js" }, "./codecs/json": { + "types": "./src/codecs/json.d.ts", "import": "./src/codecs/json.js" }, "./codecs/raw": { + "types": "./src/codecs/raw.d.ts", "import": "./src/codecs/raw.js" }, + "./hashes/digest": { + "types": "./src/hashes/digest.d.ts", + "import": "./src/hashes/digest.js" + }, + "./hashes/hasher": { + "types": "./src/hashes/hasher.d.ts", + "import": "./src/hashes/hasher.js" + }, + "./hashes/identity": { + "types": "./src/hashes/identity.d.ts", + "import": "./src/hashes/identity.js" + }, + "./hashes/sha2": { + "types": "./src/hashes/sha2.d.ts", + "browser": "./src/hashes/sha2-browser.js", + "import": "./src/hashes/sha2.js" + }, "./interface": { + "types": "./src/interface.d.ts", "import": "./src/interface.js" }, - "./bytes": { - "import": "./src/bytes.js" + "./link": { + "types": "./src/link.d.ts", + "import": "./src/link.js" + }, + "./traversal": { + "types": "./src/traversal.d.ts", + "import": "./src/traversal.js" } }, - "devDependencies": { - "@ipld/dag-pb": "^2.1.14", - "@stablelib/sha256": "^1.0.1", - "@stablelib/sha512": "^1.0.1", - "@types/chai": "^4.3.0", - "@types/chai-as-promised": "^7.1.4", - "@types/mocha": "^10.0.0", - "@types/node": "^18.0.0", - "@typescript-eslint/eslint-plugin": "^5.6.0", - "@typescript-eslint/parser": "^5.6.0", - "buffer": "^6.0.3", - "c8": "^7.10.0", - "chai": "^4.3.4", - "chai-as-promised": "^7.1.1", - "cids": "^1.1.9", - "ipjs": "^5.2.0", - "mocha": "^10.0.0", - "polendina": "^3.0.0", - "standard": "^17.0.0", - "typescript": "^4.5.4" - }, - "standard": { - "ignore": [ - "dist", - "vendor" - ] - }, - "directories": { - "test": "test" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/multiformats/js-multiformats.git" - }, - "bugs": { - "url": "https://github.com/multiformats/js-multiformats/issues" - }, - "homepage": "https://github.com/multiformats/js-multiformats#readme", - "typesVersions": { - "*": { - "*": [ - "types/src/*" - ], - "types/*": [ - "types/*" - ] + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" } }, "release": { "branches": [ - "master" + "esm-migration" ], "plugins": [ [ @@ -187,15 +177,15 @@ "release": "patch" }, { - "type": "chore", + "type": "docs", "release": "patch" }, { - "type": "docs", + "type": "test", "release": "patch" }, { - "type": "test", + "type": "deps", "release": "patch" }, { @@ -225,7 +215,11 @@ }, { "type": "docs", - "section": "Trivial Changes" + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" }, { "type": "test", @@ -236,14 +230,47 @@ } ], "@semantic-release/changelog", - [ - "@semantic-release/npm", - { - "pkgRoot": "dist" - } - ], + "@semantic-release/npm", "@semantic-release/github", "@semantic-release/git" ] - } + }, + "scripts": { + "lint": "aegir lint", + "release": "aegir release", + "build": "aegir build", + "test": "aegir test", + "test:node": "aegir test --target node", + "test:browser": "aegir test --target browser" + }, + "devDependencies": { + "@ipld/dag-pb": "^2.1.14", + "@stablelib/sha256": "^1.0.1", + "@stablelib/sha512": "^1.0.1", + "@types/chai": "^4.3.0", + "@types/chai-as-promised": "^7.1.4", + "@types/mocha": "^10.0.0", + "@types/node": "^18.0.0", + "aegir": "^37.5.1", + "buffer": "^6.0.3", + "chai": "^4.3.4", + "chai-as-promised": "^7.1.1", + "cids": "^1.1.9" + }, + "aegir": { + "build": { + "bundle": false + }, + "test": { + "cov": true, + "target": [ + "node", + "browser" + ] + } + }, + "directories": { + "test": "test" + }, + "main": "./src/index.js" } diff --git a/test/test-block.js b/test/test-block.spec.js similarity index 100% rename from test/test-block.js rename to test/test-block.spec.js diff --git a/test/test-bytes.js b/test/test-bytes.spec.js similarity index 100% rename from test/test-bytes.js rename to test/test-bytes.spec.js diff --git a/test/test-cid.js b/test/test-cid.spec.js similarity index 100% rename from test/test-cid.js rename to test/test-cid.spec.js diff --git a/test/test-multibase-spec.js b/test/test-multibase-spec.spec.js similarity index 100% rename from test/test-multibase-spec.js rename to test/test-multibase-spec.spec.js diff --git a/test/test-multibase.js b/test/test-multibase.spec.js similarity index 100% rename from test/test-multibase.js rename to test/test-multibase.spec.js diff --git a/test/test-multicodec.js b/test/test-multicodec.spec.js similarity index 100% rename from test/test-multicodec.js rename to test/test-multicodec.spec.js diff --git a/test/test-multihash.js b/test/test-multihash.spec.js similarity index 100% rename from test/test-multihash.js rename to test/test-multihash.spec.js diff --git a/test/test-traversal.js b/test/test-traversal.spec.js similarity index 100% rename from test/test-traversal.js rename to test/test-traversal.spec.js