Skip to content

Commit

Permalink
feat: convert to typescript
Browse files Browse the repository at this point in the history
Converts this module to typescript with ESM-only publishing.

Part of the wider effor to move libp2p to the bright new future of proper types and ESM: libp2p/js-libp2p#1021
  • Loading branch information
achingbrain committed Dec 17, 2021
1 parent 5f1e3d6 commit 6c2591f
Show file tree
Hide file tree
Showing 21 changed files with 448 additions and 645 deletions.
148 changes: 74 additions & 74 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir lint
- run: npx aegir ts -p check
- 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 --bail --cov
- run: npx aegir test -t webworker --bail
- 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 -- --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
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm run lint
- run: npm run build
- run: npm run 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@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run build
- run: npm run test:node -- --bail --cov
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: npm run build
- run: npm run test:browser -- -t browser -t webworker --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: npm run build
- run: npm run test:browser -- -t browser -t webworker --bail -- --browser firefox
test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: npm run build
- run: npx xvfb-maybe npm run test:electron --bail
# test-electron-renderer:
# needs: check
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v2
# with:
# node-version: 16
# - run: npm install
# - run: npx xvfb-maybe aegir test -t electron-renderer --bail
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ test/test-data/go-ipfs-repo/LOG.old

# while testing npm5
package-lock.json
yarn.lock
yarn.lock
.nyc_output
59 changes: 29 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,35 @@
"name": "multiaddr",
"version": "10.0.1",
"description": "multiaddr implementation (binary + string representation of network addresses)",
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"scripts": {
"lint": "aegir lint",
"test": "npm run test:node && npm run test:browser",
"test:node": "aegir test --ts -t node",
"test:browser": "aegir test -t browser",
"prepare": "aegir build",
"release": "aegir release",
"release-minor": "aegir release --type minor",
"release-major": "aegir release --type major",
"docs": "aegir docs",
"size": "aegir build -b"
},
"type": "module",
"types": "./dist/src/index.d.ts",
"files": [
"src",
"dist"
"dist/src",
"!**/*.tsbuildinfo"
],
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"sourceType": "module"
}
},
"scripts": {
"pretest": "npm run build",
"test": "aegir test -f ./dist/test/**/*.js",
"test:browser": "aegir test -t browser -f ./dist/test/**/*.js",
"test:node": "aegir test -t node -f ./dist/test/**/*.js",
"test:electron": "aegir test -t electron-main -f ./dist/test/**/*.js",
"lint": "aegir ts -p check && aegir lint",
"release": "aegir release --docs",
"release-minor": "aegir release --target node --type minor --docs",
"release-major": "aegir release --type major --docs",
"build": "tsc",
"dep-check": "aegir dep-check dist/src/**/*.js dist/test/**/*.js"
},
"browser": {
"./dist/src/resolvers/dns.js": "./dist/src/resolvers/dns.browser.js"
},
"repository": "github:multiformats/js-multiaddr",
"keywords": [
"multiaddr",
Expand All @@ -30,11 +40,8 @@
"license": "MIT",
"bugs": "https://github.com/multiformats/js-multiaddr/issues",
"homepage": "https://github.com/multiformats/js-multiaddr",
"browser": {
"./src/resolvers/dns.js": "./src/resolvers/dns.browser.js"
},
"dependencies": {
"dns-over-http-resolver": "^1.2.3",
"dns-over-http-resolver": "^2.0.1",
"err-code": "^3.0.1",
"is-ip": "^3.1.0",
"multiformats": "^9.4.5",
Expand All @@ -43,18 +50,10 @@
},
"devDependencies": {
"@types/varint": "^6.0.0",
"aegir": "^35.0.1",
"sinon": "^11.1.1",
"aegir": "^36.1.1",
"sinon": "^12.0.1",
"util": "^0.12.3"
},
"aegir": {
"build": {
"bundlesizeMax": "22kB"
}
},
"eslintConfig": {
"extends": "ipfs"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
"Jacob Heun <jacobheun@gmail.com>",
Expand Down
Loading

0 comments on commit 6c2591f

Please sign in to comment.