Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

feat!: convert to typescript #151

Merged
merged 27 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f4f1b58
feat: convert to typescript
vogdb Mar 9, 2022
c60d910
introduce WebRTCDirectDialOptions
vogdb Mar 10, 2022
734f8f4
mandatory options
vogdb Mar 16, 2022
c9a7d2b
Rename `channelOptions` to `peerOptions`. Describe it thoroughly.
vogdb Mar 16, 2022
e8a6d29
feat: convert to typescript
achingbrain Mar 19, 2022
48fd4d9
chore: catch stream errors
achingbrain Mar 19, 2022
81ac205
chore: remove main
achingbrain Mar 19, 2022
7e47e26
chore: update release scripts
achingbrain Mar 19, 2022
9238fdd
chore: catch more errors when we close streams we are not interested in
achingbrain Mar 19, 2022
0b20efe
fix: remove catches from tests
achingbrain Mar 20, 2022
fa366bf
chore: implement skipped tests
achingbrain Mar 20, 2022
e280645
chore: update published files
achingbrain Mar 21, 2022
fd9b93e
chore: slow ci is slow
achingbrain Mar 24, 2022
8fe3908
chore: remove extra timeouts
achingbrain Mar 24, 2022
3916137
chore: ci
achingbrain Mar 24, 2022
fc31bdd
chore: ci
achingbrain Mar 24, 2022
f865164
chore: slow ci is not that slow, also add debug for windows
achingbrain Mar 25, 2022
b044ceb
chore: only debug during test run
achingbrain Mar 25, 2022
4c8e23d
chore: just install
achingbrain Mar 25, 2022
aae00f1
chore: run all tests
achingbrain Mar 25, 2022
430041e
chore: ci y u no ci
achingbrain Mar 25, 2022
b9f6a37
chore: update deps
achingbrain Mar 25, 2022
0c3a349
chore: ci
achingbrain Mar 25, 2022
3b5ad46
chore: ci
achingbrain Mar 25, 2022
bc0a19d
chore: remove debug
achingbrain Mar 25, 2022
30c0482
chore: ci
achingbrain Mar 25, 2022
3fbfa2d
chore: ci
achingbrain Mar 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .aegir.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict'

const wrtc = require('wrtc')

// TODO: Temporary fix per wrtc issue
// https://github.com/node-webrtc/node-webrtc/issues/636#issuecomment-774171409
process.on('beforeExit', (code) => process.exit(code))

const ECHO_PROTOCOL = '/echo/1.0.0'

async function before () {
const { WebRTCDirect } = await import('./dist/src/index.js')
const { pipe } = await import('it-pipe')
const { Multiaddr } = await import('@multiformats/multiaddr')
const { mockUpgrader, mockRegistrar } = await import('@libp2p/interface-compliance-tests/mocks')

const REMOTE_MULTIADDR_IP4 = new Multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
const REMOTE_MULTIADDR_IP6 = new Multiaddr('/ip6/::1/tcp/12346/http/p2p-webrtc-direct')

const registrar = mockRegistrar()
void registrar.handle(ECHO_PROTOCOL, ({ stream }) => {
void pipe(
stream,
stream
).catch()
})
const upgrader = mockUpgrader({
registrar
})

const wd = new WebRTCDirect({
wrtc
})

const listeners = await Promise.all(
[REMOTE_MULTIADDR_IP4, REMOTE_MULTIADDR_IP6].map(async ma => {
const listener = wd.createListener({
upgrader
})
await listener.listen(ma)

return listener
})
)

return {
listeners
}
}

async function after (testOptions, beforeReturn) {
await Promise.all(
beforeReturn.listeners.map(listener => listener.close())
)
}

/** @type {import('aegir').PartialOptions} */
module.exports = {
test: {
before,
after
}
}
40 changes: 0 additions & 40 deletions .aegir.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ updates:
directory: "/"
schedule:
interval: daily
time: "11:00"
time: "10:00"
open-pull-requests-limit: 10
60 changes: 30 additions & 30 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,40 @@ jobs:
outputs:
status: ${{ steps.should-automerge.outputs.status }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check if we should automerge
id: should-automerge
run: |
for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do
committer=$(git show --format=$'%ce' -s $commit)
echo "Committer: $committer"
if [[ "$committer" != "[email protected]" ]]; then
echo "Commit $commit wasn't committed by web3-bot, but by $committer."
echo "::set-output name=status::false"
exit
fi
done
echo "::set-output name=status::true"
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check if we should automerge
id: should-automerge
run: |
for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do
committer=$(git show --format=$'%ce' -s $commit)
echo "Committer: $committer"
if [[ "$committer" != "[email protected]" ]]; then
echo "Commit $commit wasn't committed by web3-bot, but by $committer."
echo "::set-output name=status::false"
exit
fi
done
echo "::set-output name=status::true"
automerge:
needs: automerge-check
runs-on: ubuntu-latest
# The check for the user is redundant here, as this job depends on the automerge-check job,
# but it prevents this job from spinning up, just to be skipped shortly after.
if: github.event.pull_request.user.login == 'web3-bot' && needs.automerge-check.outputs.status == 'true'
steps:
- name: Wait on tests
uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
running-workflow-name: 'automerge' # the name of this job
- name: Merge PR
uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: ""
MERGE_METHOD: "squash"
MERGE_DELETE_BRANCH: true
- name: Wait on tests
uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
running-workflow-name: 'automerge' # the name of this job
- name: Merge PR
uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: ""
MERGE_METHOD: "squash"
MERGE_DELETE_BRANCH: true
33 changes: 8 additions & 25 deletions .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- run: npm install -g @mapbox/node-pre-gyp
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present lint
- run: npm run --if-present dep-check
- uses: actions/checkout@v2
- 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
Expand All @@ -34,29 +33,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: npm install -g @mapbox/node-pre-gyp
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:node
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
directory: ./.nyc_output
flags: node

test-browser:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:browser
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
directory: ./.nyc_output
flags: browser

test-chrome:
needs: check
runs-on: ubuntu-latest
Expand Down Expand Up @@ -148,7 +131,7 @@ jobs:
flags: electron-renderer

release:
needs: [test-node, test-browser, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
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:
Expand Down
23 changes: 3 additions & 20 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
MIT License
This project is dual licensed under MIT and Apache-2.0.

Copyright (c) 2017 libp2p

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.
MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
5 changes: 5 additions & 0 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 19 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -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.
Loading