From e6d3e0a3adc1d2bf2892d965220295f4cfc8fecf Mon Sep 17 00:00:00 2001 From: achingbrain Date: Sat, 15 Oct 2022 17:55:28 +0100 Subject: [PATCH] feat!: publish as esm-only Following on from the conversation in https://github.com/ipld/ipld/issues/224 this converts this repo to use the latest aegir with Unified CI. 1. Remove all build related dev deps apart from `aegir` 1. Run the `npx aegir check-project` command to update project config 1. Remove non-Unified-CI github actions 1. Update imports to import from `src/index.js` instead of `@ipld/dag-pb` 1. Rename `test/*.js` to `test/*.spec.js` so aegir can find them 1. Update `tsconfig.json` to extend config from `aegir` 1. Remove `"main"` and other unused fields from `package.json` 1. Use `chai` from `aegir` pre-configured with plugins we use 1. Fixes everything the linter complains about This will need a follow up PR to `protocol/.github` to add this repo to the Unified CI [config file](https://github.com/protocol/.github/blob/master/configs/js.json) so it'll get automated config updates in the future. Apologies that this PR is so noisy, most of it is from the `check-project` command --- .github/dependabot.yml | 23 +-- .github/workflows/automerge.yml | 8 + .github/workflows/js-test-and-release.yml | 145 +++++++++++++ .github/workflows/test-and-release.yml | 63 ------ LICENSE | 24 +-- LICENSE-APACHE | 5 + LICENSE-MIT | 19 ++ README.md | 31 ++- package.json | 205 ++++++------------- index.js => src/index.js | 3 +- test/fixtures/array-link.js | 5 +- test/fixtures/empty-array.js | 3 +- test/fixtures/empty-obj.js | 3 +- test/fixtures/expected.js | 5 +- test/fixtures/foo.js | 5 +- test/fixtures/obj-no-link.js | 3 +- test/fixtures/obj-with-link.js | 5 +- test/{test-basics.js => test-basics.spec.js} | 9 +- tsconfig.json | 35 +--- 19 files changed, 308 insertions(+), 291 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-APACHE create mode 100644 LICENSE-MIT rename index.js => src/index.js (97%) rename test/{test-basics.js => test-basics.spec.js} (96%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f468993..0bc3b42 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 0000000..d57c2a0 --- /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 0000000..d155996 --- /dev/null +++ b/.github/workflows/js-test-and-release.yml @@ -0,0 +1,145 @@ +name: test & maybe release +on: + push: + branches: + - master # with #262 - ${{{ github.default_branch }}} + pull_request: + branches: + - master # with #262 - ${{{ github.default_branch }}} + +jobs: + + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + 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@v3 + 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@v3 + 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@v3 + 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@v3 + 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@v3 + 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@v3 + 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@v3 + 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/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v3 + 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 636846f..0000000 --- a/.github/workflows/test-and-release.yml +++ /dev/null @@ -1,63 +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.1 - 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 - - name: Typecheck - uses: gozala/typescript-error-reporter-action@v1.0.8 - 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.1 - 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/LICENSE b/LICENSE index 59a33ba..20ce483 100644 --- a/LICENSE +++ b/LICENSE @@ -1,22 +1,4 @@ -The MIT License (MIT) - -Copyright (c) 2015 David Dias - -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 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. +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 new file mode 100644 index 0000000..14478a3 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,5 @@ +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 + +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 new file mode 100644 index 0000000..72dc60d --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,19 @@ +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: + +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. diff --git a/README.md b/README.md index 9c460a4..16e7cc5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,22 @@ -# @ipld/dag-cbor +# @ipld/dag-cbor -JS implementation of `dag-cbor`. +[![codecov](https://img.shields.io/codecov/c/github/ipld/js-dag-cbor.svg?style=flat-square)](https://codecov.io/gh/ipld/js-dag-cbor) +[![CI](https://img.shields.io/github/workflow/status/ipld/js-dag-cbor/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipld/js-dag-cbor/actions/workflows/js-test-and-release.yml) + +> JS implementation of DAG-CBOR + +## Table of contents + +- - [Install](#install) +- [Spec](#spec) + - [License](#license) + - [Contribute](#contribute) + +## Install + +```console +$ npm i @ipld/dag-cbor +``` This is the *new* interface meant for use by itself or with `multiformats` and `@ipld/block`. It is not used by `js-ipld-format` which is currently @@ -32,3 +48,14 @@ CID.asCID(decoded.z.a) // cid instance # Spec The [`dag-cbor` specification is in the IPLD specs repo](https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-cbor.md). + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +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 7988549..d48c738 100644 --- a/package.json +++ b/package.json @@ -2,160 +2,89 @@ "name": "@ipld/dag-cbor", "version": "0.0.0-dev", "description": "JS implementation of DAG-CBOR", - "main": "index.js", - "types": "./types/index.d.ts", - "type": "module", - "scripts": { - "lint": "standard *.js test/*.js", - "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 index.js dist/ && mkdir -p dist/test && cp test/*.js dist/test/", - "build:types": "npm run build:copy && cd dist && tsc --build", - "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": "Rod (http://r.va.gg/)", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipld/js-dag-cbor#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipld/js-dag-cbor.git" + }, + "bugs": { + "url": "https://github.com/ipld/js-dag-cbor/issues" }, "keywords": [ "ipfs", "ipld", "multiformats" ], - "author": "Rod (http://r.va.gg/)", - "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": { - "import": "./index.js" + ".": { + "types": "./dist/src/index.d.ts", + "import": "./src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + }, + "ignorePatterns": [ + "test/ts-use" + ] + }, + "scripts": { + "clean": "aegir clean", + "lint": "aegir lint", + "build": "aegir build", + "release": "aegir release", + "test": "aegir test -t node -t browser -t webworker -t electron-main", + "test:ts": "npm run test --prefix test/ts-use", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "test:electron-main": "aegir test -t electron-main", + "dep-check": "aegir dep-check" }, "dependencies": { "cborg": "^1.6.0", "multiformats": "^9.5.4" }, "devDependencies": { + "aegir": "^37.5.6", "buffer": "^6.0.3", - "c8": "^7.10.0", - "chai": "^4.3.4", - "ipjs": "^5.2.0", - "ipld-garbage": "^5.0.0", - "mocha": "^10.0.0", - "polendina": "~3.1.0", - "standard": "^17.0.0", - "typescript": "~4.8.2" - }, - "standard": { - "ignore": [ - "dist" - ] + "ipld-garbage": "^5.0.0" }, "directories": { "test": "test" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipld/js-dag-cbor.git" - }, - "bugs": { - "url": "https://github.com/ipld/js-dag-cbor/issues" - }, - "homepage": "https://github.com/ipld/js-dag-cbor#readme", - "typesVersions": { - "*": { - "*": [ - "types/*" - ], - "types/*": [ - "types/*" - ] - } - }, - "release": { - "branches": [ - "master" - ], - "plugins": [ - [ - "@semantic-release/commit-analyzer", - { - "preset": "conventionalcommits", - "releaseRules": [ - { - "breaking": true, - "release": "major" - }, - { - "revert": true, - "release": "patch" - }, - { - "type": "feat", - "release": "minor" - }, - { - "type": "fix", - "release": "patch" - }, - { - "type": "chore", - "release": "patch" - }, - { - "type": "docs", - "release": "patch" - }, - { - "type": "test", - "release": "patch" - }, - { - "scope": "no-release", - "release": false - } - ] - } - ], - [ - "@semantic-release/release-notes-generator", - { - "preset": "conventionalcommits", - "presetConfig": { - "types": [ - { - "type": "feat", - "section": "Features" - }, - { - "type": "fix", - "section": "Bug Fixes" - }, - { - "type": "chore", - "section": "Trivial Changes" - }, - { - "type": "docs", - "section": "Trivial Changes" - }, - { - "type": "test", - "section": "Tests" - } - ] - } - } - ], - "@semantic-release/changelog", - [ - "@semantic-release/npm", - { - "pkgRoot": "dist" - } - ], - "@semantic-release/github", - "@semantic-release/git" - ] } } diff --git a/index.js b/src/index.js similarity index 97% rename from index.js rename to src/index.js index fa07652..4bd9466 100644 --- a/index.js +++ b/src/index.js @@ -7,7 +7,7 @@ const CID_CBOR_TAG = 42 /** * @template T * @typedef {import('multiformats/codecs/interface').ByteView} ByteView -*/ + */ /** * cidEncoder will receive all Objects during encode, it needs to filter out @@ -35,6 +35,7 @@ function cidEncoder (obj) { ] } +// eslint-disable-next-line jsdoc/require-returns-check /** * Intercept all `undefined` values from an object walk and reject the entire * object if we find one. diff --git a/test/fixtures/array-link.js b/test/fixtures/array-link.js index 5865247..3fe2a78 100755 --- a/test/fixtures/array-link.js +++ b/test/fixtures/array-link.js @@ -1,7 +1,6 @@ -'use strict' - +// @ts-expect-error no types const CID = require('cids') -module.exports = [ +export default [ new CID('QmRgutAxd8t7oGkSm4wmeuByG6M51wcTso6cubDdQtuEfL') ] diff --git a/test/fixtures/empty-array.js b/test/fixtures/empty-array.js index d0c6276..c928842 100755 --- a/test/fixtures/empty-array.js +++ b/test/fixtures/empty-array.js @@ -1,3 +1,2 @@ -'use strict' -module.exports = [] +export default [] diff --git a/test/fixtures/empty-obj.js b/test/fixtures/empty-obj.js index 545992e..9a676e8 100755 --- a/test/fixtures/empty-obj.js +++ b/test/fixtures/empty-obj.js @@ -1,3 +1,2 @@ -'use strict' -module.exports = {} +export default {} diff --git a/test/fixtures/expected.js b/test/fixtures/expected.js index b10a6cb..e8dd483 100755 --- a/test/fixtures/expected.js +++ b/test/fixtures/expected.js @@ -1,8 +1,7 @@ -'use strict' - +// @ts-expect-error no types const CID = require('cids') -module.exports = { +export default { arrayLink: new CID('zdpuAsZ8roJvCazJFXUnSULspbXfxrLkUkNxy6SToaiDpEiap'), emptyArray: new CID('zdpuAtQy7GSHNcZxdBfmtowdL1d2WAFjJBwb6WAEfFJ6T4Gbi'), emptyObj: new CID('zdpuAyTBnYSugBZhqJuLsNpzjmAjSmxDqBbtAqXMtsvxiN2v3'), diff --git a/test/fixtures/foo.js b/test/fixtures/foo.js index 69f6004..ec3701c 100755 --- a/test/fixtures/foo.js +++ b/test/fixtures/foo.js @@ -1,8 +1,7 @@ -'use strict' - +// @ts-expect-error no types const CID = require('cids') -module.exports = { +export default { foo: 'bar', cats: [ new CID('QmRgutAxd8t7oGkSm4wmeuByG6M51wcTso6cubDdQtuEfL'), diff --git a/test/fixtures/obj-no-link.js b/test/fixtures/obj-no-link.js index 3ed7000..f710d4f 100755 --- a/test/fixtures/obj-no-link.js +++ b/test/fixtures/obj-no-link.js @@ -1,5 +1,4 @@ -'use strict' -module.exports = { +export default { sassafras: 'and cats' } diff --git a/test/fixtures/obj-with-link.js b/test/fixtures/obj-with-link.js index 2b4db36..b501aa6 100755 --- a/test/fixtures/obj-with-link.js +++ b/test/fixtures/obj-with-link.js @@ -1,7 +1,6 @@ -'use strict' - +// @ts-expect-error no types const CID = require('cids') -module.exports = { +export default { foo: new CID('QmRgutAxd8t7oGkSm4wmeuByG6M51wcTso6cubDdQtuEfL') } diff --git a/test/test-basics.js b/test/test-basics.spec.js similarity index 96% rename from test/test-basics.js rename to test/test-basics.spec.js index 26c16a6..4e77661 100644 --- a/test/test-basics.js +++ b/test/test-basics.spec.js @@ -2,12 +2,11 @@ import { Buffer } from 'buffer' import { garbage } from 'ipld-garbage' -import chai from 'chai' -import * as dagcbor from '../index.js' +import { assert } from 'aegir/chai' +import * as dagcbor from '../src/index.js' import { bytes, CID } from 'multiformats' const { encode, decode } = dagcbor -const { assert } = chai const test = it const same = assert.deepStrictEqual @@ -32,7 +31,7 @@ describe('dag-cbor', () => { // Check for the tag 42 // d8 = tag, 2a = 42 - same(bytes.toHex(serializedObj).match(/d82a/g).length, 4) + same(bytes.toHex(serializedObj).match(/d82a/g)?.length, 4) const deserializedObj = decode(serializedObj) same(deserializedObj, obj) @@ -140,7 +139,7 @@ describe('dag-cbor', () => { same(s1, s2) - const verify = (s) => { + const verify = (/** @type {{ data: Uint8Array }} */ s) => { same(typeof s, 'object') same(Object.keys(s), ['data']) assert(s.data instanceof Uint8Array) diff --git a/tsconfig.json b/tsconfig.json index 58e8c8d..4805fbc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,37 +1,14 @@ { + "extends": "aegir/src/config/tsconfig.aegir.json", "compilerOptions": { - "allowJs": true, - "checkJs": true, - "forceConsistentCasingInFileNames": true, - "noImplicitReturns": false, - "noImplicitAny": true, - "noImplicitThis": true, - "noFallthroughCasesInSwitch": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "strictFunctionTypes": false, - "strictNullChecks": true, - "strictPropertyInitialization": true, - "strictBindCallApply": true, - "strict": true, - "alwaysStrict": true, - "esModuleInterop": true, - "target": "ES2018", - "moduleResolution": "node", - "declaration": true, - "declarationMap": true, - "outDir": "types", - "skipLibCheck": true, - "stripInternal": true, - "resolveJsonModule": true, - "baseUrl": ".", + "outDir": "dist", "emitDeclarationOnly": true }, "include": [ - "index.js" + "src", + "test" ], "exclude": [ - "node_modules" - ], - "compileOnSave": false + "test/ts-use" + ] }