Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: typedef generation & type checking #261

Merged
merged 15 commits into from
Mar 9, 2021
Merged
46 changes: 27 additions & 19 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
'use strict'
const path = require('path')

module.exports = {
bundlesize: { maxSize: '68kB' },
karma: {
files: [{
pattern: 'test/test-data/**/*',
watched: false,
served: true,
included: false
}]
},
webpack: {
node: {
// needed by ipfs-repo-migrations
path: true,

// needed by dependencies of peer-id
stream: true,
/** @type {import('aegir').Options["build"]["config"]} */
const esbuild = {
// this will inject all the named exports from 'node-globals.js' as globals
inject: [require.resolve('./scripts/node-globals.js')],
plugins: [
{
name: 'node built ins', // this will make the bundler resolve node builtins to the respective browser polyfill
setup (build) {
build.onResolve({ filter: /^stream$/ }, () => {
return { path: require.resolve('readable-stream') }
})
}
}
]
}

// needed by core-util-is
Buffer: true
/** @type {import('aegir').PartialOptions} */
module.exports = {
test: {
browser :{
config: {
buildConfig: esbuild
}
}
},
build: {
bundlesize: { maxSize: '68kB' },
config: esbuild
}
}
78 changes: 78 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: ci
on:
push:
branches:
- master
- 'release/**'
pull_request:
branches:
- master
- 'release/**'

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir lint
- run: npx aegir build
- run: npx aegir dep-check
- uses: ipfs/aegir/actions/bundle-size@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [14, 15]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- 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
- uses: microsoft/playwright-github-action@v1
- run: npm install
- run: npx aegir test -t browser -t webworker --bail # add --cov later when its fixed
- uses: codecov/codecov-action@v1
test-firefox:
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 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 --timeout 10000 -- --browser webkit
test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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: npm install
- run: npx xvfb-maybe aegir test -t electron-renderer --bail
27 changes: 27 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
hugomrdias marked this conversation as resolved.
Show resolved Hide resolved
push:
branches:
- master
- main
- default
pull_request:
branches:
- '**'

name: Typecheck
jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Typecheck
uses: gozala/typescript-error-reporter-action@v1.0.8
59 changes: 0 additions & 59 deletions .travis.yml

This file was deleted.

82 changes: 54 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,38 @@
"./test/utils/create-libp2p-node": false,
"./test/utils/create-temp-repo-nodejs.js": "./test/utils/create-temp-repo-browser.js"
},
"types": "dist/src/index.d.ts",
"typesVersions": {
Gozala marked this conversation as resolved.
Show resolved Hide resolved
"*": {
"src/*": [
"dist/src/*",
"dist/src/*/index"
],
"src/": [
"dist/src/index"
]
}
},
"eslintConfig": {
"extends": "ipfs",
"ignorePatterns": ["scripts/*"]
},
"files": [
"dist",
"src"
],
"scripts": {
"prepare": "aegir build --no-bundle",
"test": "aegir test",
"test:browser": "aegir test -t browser -t webworker",
"test:node": "aegir test -t node",
"lint": "aegir lint",
"check": "aegir ts -p check",
"release": "aegir release",
"release-minor": "aegir release --type minor",
"release-major": "aegir release --type major",
"bench": "node benchmarks/index",
"build": "aegir build",
"coverage": "aegir coverage --provider codecov",
"coverage": "aegir test -t node --cov && nyc report --reporter=html",
"docs": "aegir docs",
"benchmarks": "node test/benchmarks/get-many"
},
Expand All @@ -43,50 +60,58 @@
"homepage": "https://github.com/ipfs/js-ipfs-bitswap#readme",
"devDependencies": {
"@nodeutils/defaults-deep": "^1.1.0",
"aegir": "^28.1.0",
"@types/debug": "^4.1.5",
"aegir": "^31.0.4",
"assert": "^2.0.0",
"benchmark": "^2.1.4",
"delay": "^4.3.0",
"delay": "^5.0.0",
"ipfs-repo": "^7.0.0",
"ipfs-utils": "^6.0.0",
"ipfs-utils": "^6.0.1",
"iso-random-stream": "^1.1.1",
"it-all": "^1.0.2",
"it-drain": "^1.0.1",
"libp2p": "^0.30.5",
"libp2p-kad-dht": "^0.20.0",
"libp2p-mplex": "^0.10.0",
"libp2p-secio": "^0.13.0",
"libp2p-tcp": "^0.15.0",
"it-all": "^1.0.5",
"it-drain": "^1.0.4",
"libp2p": "^0.30.9",
"libp2p-kad-dht": "^0.21.0",
"libp2p-mplex": "^0.10.2",
"libp2p-secio": "^0.13.1",
"libp2p-tcp": "^0.15.3",
"lodash.difference": "^4.5.0",
"lodash.flatten": "^4.4.0",
"lodash.range": "^3.2.0",
"lodash.without": "^4.4.0",
"p-defer": "^3.0.0",
"p-event": "^4.1.0",
"p-wait-for": "^3.1.0",
"peer-id": "^0.14.0",
"p-event": "^4.2.0",
"p-wait-for": "^3.2.0",
"peer-id": "^0.14.3",
"promisify-es6": "^1.0.3",
"rimraf": "^3.0.0",
"sinon": "^9.0.0",
"rimraf": "^3.0.2",
"sinon": "^9.2.4",
"stats-lite": "^2.2.0",
"uuid": "^8.0.0"
"uuid": "^8.3.2"
},
"dependencies": {
"abort-controller": "^3.0.0",
"any-signal": "^2.1.1",
"any-signal": "^2.1.2",
"bignumber.js": "^9.0.0",
"cids": "^1.0.0",
"debug": "^4.1.0",
"cids": "^1.1.6",
"debug": "^4.2.0",
"ipfs-core-types": "^0.3.0",
"ipld-block": "^0.11.0",
"it-length-prefixed": "^3.0.0",
"it-length-prefixed": "^3.1.0",
"it-pipe": "^1.1.0",
"just-debounce-it": "^1.1.0",
"libp2p-interfaces": "^0.8.3",
"moving-average": "^1.0.0",
"multicodec": "^2.0.0",
"multihashing-async": "^2.0.1",
"moving-average": "git://github.com/gozala/moving-average#types",
"multicodec": "^3.0.1",
"multihashing-async": "^2.1.2",
"native-abort-controller": "^1.0.3",
"process": "^0.11.10",
"protons": "^2.0.0",
"streaming-iterables": "^5.0.2",
"uint8arrays": "^2.0.5",
"readable-stream": "^3.6.0",
"streaming-iterables": "^5.0.4",
"uint8arrays": "^2.1.3",
"url": "^0.11.0",
"util": "^0.12.3",
"varint-decoder": "^1.0.0"
},
"pre-push": [
Expand Down Expand Up @@ -114,6 +139,7 @@
"dmitriy ryajov <dryajov@dmitriys-MBP.HomeNET>",
"Dmitriy Ryajov <dryajov@gmail.com>",
"Bryan Stenson <bryan.stenson@gmail.com>",
"Richard Schneider <makaretu@gmail.com>"
"Richard Schneider <makaretu@gmail.com>",
"Irakli Gozalishvili <dev@gozala.io>"
]
}
4 changes: 4 additions & 0 deletions scripts/node-globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Buffer } from 'buffer'
import process from "process/browser"

export { Buffer, process }
Loading