Skip to content

Commit 8506414

Browse files
authored
chore: config types and dependencies update (#904)
BREAKING CHANGES: top level types were updated, [email protected] is used, dialer and keychain internal property names changed and connectionManager minPeers is not supported anymore
1 parent 8e1743c commit 8506414

File tree

114 files changed

+4609
-837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+4609
-837
lines changed

.aegir.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const path = require('path')
34
const Libp2p = require('./src')
45
const { MULTIADDRS_WEBSOCKETS } = require('./test/fixtures/browser')
56
const Peers = require('./test/fixtures/peers')
@@ -47,16 +48,23 @@ const after = async () => {
4748
await libp2p.stop()
4849
}
4950

51+
/** @type {import('aegir').Options["build"]["config"]} */
52+
const esbuild = {
53+
inject: [path.join(__dirname, './scripts/node-globals.js')]
54+
}
55+
56+
/** @type {import('aegir').PartialOptions} */
5057
module.exports = {
51-
bundlesize: { maxSize: '223kB' },
52-
hooks: {
53-
pre: before,
54-
post: after
58+
build: {
59+
bundlesizeMax: '253kB'
5560
},
56-
webpack: {
57-
node: {
58-
// needed by bcrypto
59-
Buffer: true
61+
test: {
62+
before,
63+
after,
64+
browser: {
65+
config: {
66+
buildConfig: esbuild
67+
}
6068
}
6169
}
6270
}

.github/workflows/examples.yml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: examples
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- '**'
9+
10+
jobs:
11+
check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- run: npm install
16+
- run: npx aegir lint
17+
- run: npx aegir ts -p check
18+
- run: npx aegir build
19+
test-auto-relay-example:
20+
needs: check
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v2
24+
- run: npm install
25+
- run: cd examples && yarn && npm run test -- auto-relay
26+
test-chat-example:
27+
needs: check
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
- run: npm install
32+
- run: cd examples && yarn && npm run test -- chat
33+
test-connection-encryption-example:
34+
needs: check
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v2
38+
- run: npm install
39+
- run: cd examples && yarn && npm run test -- connection-encryption
40+
test-discovery-mechanisms-example:
41+
needs: check
42+
runs-on: macos-latest
43+
steps:
44+
- uses: actions/checkout@v2
45+
- run: npm install
46+
- run: cd examples && yarn && npm run test -- discovery-mechanisms
47+
test-echo-example:
48+
needs: check
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v2
52+
- run: npm install
53+
- run: cd examples && yarn && npm run test -- echo
54+
test-libp2p-in-the-browser-example:
55+
needs: check
56+
runs-on: macos-latest
57+
steps:
58+
- uses: actions/checkout@v2
59+
- run: npm install
60+
- run: cd examples && yarn && npm run test -- libp2p-in-the-browser
61+
test-peer-and-content-routing-example:
62+
needs: check
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v2
66+
- run: npm install
67+
- run: cd examples && yarn && npm run test -- peer-and-content-routing
68+
test-pnet-example:
69+
needs: check
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v2
73+
- run: npm install
74+
- run: cd examples && yarn && npm run test -- pnet
75+
test-protocol-and-stream-muxing-example:
76+
needs: check
77+
runs-on: ubuntu-latest
78+
steps:
79+
- uses: actions/checkout@v2
80+
- run: npm install
81+
- run: cd examples && yarn && npm run test -- protocol-and-stream-muxing
82+
test-pubsub-example:
83+
needs: check
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v2
87+
- run: npm install
88+
- run: cd examples && yarn && npm run test -- pubsub
89+
test-transports-example:
90+
needs: check
91+
runs-on: ubuntu-latest
92+
steps:
93+
- uses: actions/checkout@v2
94+
- run: npm install
95+
- run: cd examples && yarn && npm run test -- transports
96+
test-webrtc-direct-example:
97+
needs: check
98+
runs-on: ubuntu-latest
99+
steps:
100+
- uses: actions/checkout@v2
101+
- run: npm install
102+
- run: cd examples && yarn && npm run test -- webrtc-direct

.github/workflows/main.yml

+15-92
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15-
- run: yarn
16-
- run: yarn lint
15+
- run: npm install
16+
- run: npx aegir lint
1717
- uses: gozala/[email protected]
18-
- run: yarn build
19-
- run: yarn aegir dep-check
18+
- run: npx aegir build
19+
- run: npx aegir dep-check
2020
- uses: ipfs/aegir/actions/bundle-size@master
2121
name: size
2222
with:
@@ -34,111 +34,34 @@ jobs:
3434
- uses: actions/setup-node@v1
3535
with:
3636
node-version: ${{ matrix.node }}
37-
- run: yarn
38-
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
37+
- run: npm install
38+
- run: npx aegir test -t node --cov --bail
3939
- uses: codecov/codecov-action@v1
4040
test-chrome:
4141
needs: check
4242
runs-on: ubuntu-latest
4343
steps:
4444
- uses: actions/checkout@v2
45-
- run: yarn
45+
- run: npm install
4646
- run: npx aegir test -t browser -t webworker --bail
4747
test-firefox:
4848
needs: check
4949
runs-on: ubuntu-latest
5050
steps:
5151
- uses: actions/checkout@v2
52-
- run: yarn
53-
- run: npx aegir test -t browser -t webworker --bail -- --browsers FirefoxHeadless
54-
test-interop:
55-
needs: check
56-
runs-on: ubuntu-latest
57-
steps:
58-
- uses: actions/checkout@v2
59-
- run: yarn
60-
- run: cd node_modules/interop-libp2p && yarn && LIBP2P_JS=${GITHUB_WORKSPACE}/src/index.js npx aegir test -t node --bail
61-
test-auto-relay-example:
62-
needs: check
63-
runs-on: ubuntu-latest
64-
steps:
65-
- uses: actions/checkout@v2
66-
- run: yarn
67-
- run: cd examples && yarn && npm run test -- auto-relay
68-
test-chat-example:
69-
needs: check
70-
runs-on: ubuntu-latest
71-
steps:
72-
- uses: actions/checkout@v2
73-
- run: yarn
74-
- run: cd examples && yarn && npm run test -- chat
75-
test-connection-encryption-example:
76-
needs: check
77-
runs-on: ubuntu-latest
78-
steps:
79-
- uses: actions/checkout@v2
80-
- run: yarn
81-
- run: cd examples && yarn && npm run test -- connection-encryption
82-
test-discovery-mechanisms-example:
83-
needs: check
84-
runs-on: macos-latest
85-
steps:
86-
- uses: actions/checkout@v2
87-
- run: yarn
88-
- run: cd examples && yarn && npm run test -- discovery-mechanisms
89-
test-echo-example:
90-
needs: check
91-
runs-on: ubuntu-latest
92-
steps:
93-
- uses: actions/checkout@v2
94-
- run: yarn
95-
- run: cd examples && yarn && npm run test -- echo
96-
test-libp2p-in-the-browser-example:
97-
needs: check
98-
runs-on: macos-latest
99-
steps:
100-
- uses: actions/checkout@v2
101-
- run: yarn
102-
- run: cd examples && yarn && npm run test -- libp2p-in-the-browser
103-
test-peer-and-content-routing-example:
104-
needs: check
105-
runs-on: ubuntu-latest
106-
steps:
107-
- uses: actions/checkout@v2
108-
- run: yarn
109-
- run: cd examples && yarn && npm run test -- peer-and-content-routing
110-
test-pnet-example:
52+
- run: npm install
53+
- run: npx aegir test -t browser -t webworker --bail -- --browser firefox
54+
test-ts:
11155
needs: check
11256
runs-on: ubuntu-latest
11357
steps:
11458
- uses: actions/checkout@v2
115-
- run: yarn
116-
- run: cd examples && yarn && npm run test -- pnet
117-
test-protocol-and-stream-muxing-example:
118-
needs: check
119-
runs-on: ubuntu-latest
120-
steps:
121-
- uses: actions/checkout@v2
122-
- run: yarn
123-
- run: cd examples && yarn && npm run test -- protocol-and-stream-muxing
124-
test-pubsub-example:
125-
needs: check
126-
runs-on: ubuntu-latest
127-
steps:
128-
- uses: actions/checkout@v2
129-
- run: yarn
130-
- run: cd examples && yarn && npm run test -- pubsub
131-
test-transports-example:
132-
needs: check
133-
runs-on: ubuntu-latest
134-
steps:
135-
- uses: actions/checkout@v2
136-
- run: yarn
137-
- run: cd examples && yarn && npm run test -- transports
138-
test-webrtc-direct-example:
59+
- run: npm install
60+
- run: npm run test:ts
61+
test-interop:
13962
needs: check
14063
runs-on: ubuntu-latest
14164
steps:
14265
- uses: actions/checkout@v2
143-
- run: yarn
144-
- run: cd examples && yarn && npm run test -- webrtc-direct
66+
- run: npm install
67+
- run: cd node_modules/interop-libp2p && yarn && LIBP2P_JS=${GITHUB_WORKSPACE}/src/index.js npx aegir test -t node --bail

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ docs
44
test/repo-tests*
55
**/bundle.js
66
.cache
7+
.parcel-cache
78

89
# Logs
910
logs

doc/CONFIGURATION.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ const TCP = require('libp2p-tcp')
599599
const MPLEX = require('libp2p-mplex')
600600
const { NOISE } = require('libp2p-noise')
601601

602-
const { FaultTolerance } = require('libp2p/src/transport-manager')}
602+
const { FaultTolerance } = require('libp2p/src/transport-manager')
603603

604604
const node = await Libp2p.create({
605605
modules: {

examples/libp2p-in-the-browser/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "libp2p-in-browser",
33
"version": "1.0.0",
44
"description": "A libp2p node running in the browser",
5-
"main": "index.js",
5+
"main": "dist/index.html",
66
"browserslist": [
77
"last 2 Chrome versions"
88
],
@@ -20,15 +20,15 @@
2020
"libp2p-bootstrap": "^0.12.1",
2121
"libp2p-mplex": "^0.10.0",
2222
"libp2p-noise": "^2.0.0",
23-
"libp2p-webrtc-star": "^0.20.0",
24-
"libp2p-websockets": "^0.14.0"
23+
"libp2p-webrtc-star": "^0.22.0",
24+
"libp2p-websockets": "^0.15.0"
2525
},
2626
"devDependencies": {
2727
"@babel/cli": "^7.13.10",
2828
"@babel/core": "^7.13.0",
2929
"babel-plugin-syntax-async-functions": "^6.13.0",
3030
"babel-plugin-transform-regenerator": "^6.26.0",
3131
"babel-polyfill": "^6.26.0",
32-
"parcel-bundler": "1.12.3"
32+
"parcel": "next"
3333
}
3434
}

examples/libp2p-in-the-browser/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ async function run() {
1717
const out = chunk.toString()
1818

1919
if (out.includes('Server running at')) {
20-
url = out.replace('Server running at ', '')
20+
url = out.split('Server running at ')[1]
2121
}
2222

23-
if (out.includes('Built in ')) {
23+
if (out.includes('Built in')) {
2424
try {
2525
const browser = await chromium.launch();
2626
const page = await browser.newPage();

examples/webrtc-direct/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.1",
44
"private": true,
55
"description": "",
6+
"main": "dist/index.html",
67
"scripts": {
78
"test": "echo \"Error: no test specified\" && exit 1",
89
"build": "parcel build index.html",
@@ -15,14 +16,15 @@
1516
"babel-plugin-syntax-async-functions": "^6.13.0",
1617
"babel-plugin-transform-regenerator": "^6.26.0",
1718
"babel-polyfill": "^6.26.0",
18-
"parcel-bundler": "1.12.3"
19+
"parcel-bundler": "1.12.3",
20+
"util": "^0.12.3"
1921
},
2022
"dependencies": {
2123
"libp2p": "../../",
2224
"libp2p-bootstrap": "^0.12.1",
2325
"libp2p-mplex": "^0.10.1",
2426
"libp2p-noise": "^2.0.1",
25-
"libp2p-webrtc-direct": "^0.5.0",
27+
"libp2p-webrtc-direct": "^0.6.0",
2628
"peer-id": "^0.14.3"
2729
},
2830
"browser": {

examples/webrtc-direct/test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ async function test () {
5050
const out = chunk.toString()
5151

5252
if (out.includes('Server running at')) {
53-
dialerUrl = out.replace('Server running at ', '')
53+
dialerUrl = out.split('Server running at ')[1]
5454
}
5555

56-
if (out.includes('✨ Built in ')) {
56+
57+
if (out.includes('Built in ')) {
58+
5759
try {
5860
const browser = await chromium.launch();
5961
const page = await browser.newPage();

0 commit comments

Comments
 (0)