Skip to content

Commit f18b2a4

Browse files
authored
feat: convert to typescript (#78)
- converts to monorepo - splits daemon into client, server, protocol and cli packages - only cli has a dep on libp2p so is suitable for use for interop testing BREAKING CHANGE: This module is now ESM only
1 parent 13b6f3e commit f18b2a4

Some content is hidden

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

70 files changed

+4784
-2624
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ updates:
44
directory: "/"
55
schedule:
66
interval: daily
7-
time: "11:00"
7+
time: "10:00"
88
open-pull-requests-limit: 10

.github/workflows/automerge.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Automatically merge pull requests opened by web3-bot, as soon as (and only if) all tests pass.
2+
# This reduces the friction associated with updating with our workflows.
3+
4+
on: [ pull_request ]
5+
name: Automerge
6+
7+
jobs:
8+
automerge-check:
9+
if: github.event.pull_request.user.login == 'web3-bot'
10+
runs-on: ubuntu-latest
11+
outputs:
12+
status: ${{ steps.should-automerge.outputs.status }}
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
- name: Check if we should automerge
18+
id: should-automerge
19+
run: |
20+
for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do
21+
committer=$(git show --format=$'%ce' -s $commit)
22+
echo "Committer: $committer"
23+
if [[ "$committer" != "[email protected]" ]]; then
24+
echo "Commit $commit wasn't committed by web3-bot, but by $committer."
25+
echo "::set-output name=status::false"
26+
exit
27+
fi
28+
done
29+
echo "::set-output name=status::true"
30+
automerge:
31+
needs: automerge-check
32+
runs-on: ubuntu-latest
33+
# The check for the user is redundant here, as this job depends on the automerge-check job,
34+
# but it prevents this job from spinning up, just to be skipped shortly after.
35+
if: github.event.pull_request.user.login == 'web3-bot' && needs.automerge-check.outputs.status == 'true'
36+
steps:
37+
- name: Wait on tests
38+
uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2
39+
with:
40+
ref: ${{ github.event.pull_request.head.sha }}
41+
repo-token: ${{ secrets.GITHUB_TOKEN }}
42+
wait-interval: 10
43+
running-workflow-name: 'automerge' # the name of this job
44+
- name: Merge PR
45+
uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1
46+
env:
47+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
48+
MERGE_LABELS: ""
49+
MERGE_METHOD: "squash"
50+
MERGE_DELETE_BRANCH: true
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: test & maybe release
2+
on:
3+
push:
4+
branches:
5+
- master # with #262 - ${{{ github.default_branch }}}
6+
pull_request:
7+
branches:
8+
- master # with #262 - ${{{ github.default_branch }}}
9+
10+
jobs:
11+
12+
check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-node@v2
17+
with:
18+
node-version: lts/*
19+
- uses: ipfs/aegir/actions/cache-node-modules@master
20+
- run: npm run --if-present lint
21+
- run: npm run --if-present dep-check
22+
23+
test-node:
24+
needs: check
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix:
28+
os: [windows-latest, ubuntu-latest, macos-latest]
29+
node: [16]
30+
fail-fast: true
31+
steps:
32+
- uses: actions/checkout@v2
33+
- uses: actions/setup-node@v2
34+
with:
35+
node-version: ${{ matrix.node }}
36+
- uses: ipfs/aegir/actions/cache-node-modules@master
37+
- run: npm run --if-present test:node
38+
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
39+
with:
40+
directory: ./.nyc_output
41+
flags: node
42+
43+
test-chrome:
44+
needs: check
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v2
48+
- uses: actions/setup-node@v2
49+
with:
50+
node-version: lts/*
51+
- uses: ipfs/aegir/actions/cache-node-modules@master
52+
- run: npm run --if-present test:chrome
53+
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
54+
with:
55+
directory: ./.nyc_output
56+
flags: chrome
57+
58+
test-chrome-webworker:
59+
needs: check
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v2
63+
- uses: actions/setup-node@v2
64+
with:
65+
node-version: lts/*
66+
- uses: ipfs/aegir/actions/cache-node-modules@master
67+
- run: npm run --if-present test:chrome-webworker
68+
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
69+
with:
70+
directory: ./.nyc_output
71+
flags: chrome-webworker
72+
73+
test-firefox:
74+
needs: check
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v2
78+
- uses: actions/setup-node@v2
79+
with:
80+
node-version: lts/*
81+
- uses: ipfs/aegir/actions/cache-node-modules@master
82+
- run: npm run --if-present test:firefox
83+
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
84+
with:
85+
directory: ./.nyc_output
86+
flags: firefox
87+
88+
test-firefox-webworker:
89+
needs: check
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v2
93+
- uses: actions/setup-node@v2
94+
with:
95+
node-version: lts/*
96+
- uses: ipfs/aegir/actions/cache-node-modules@master
97+
- run: npm run --if-present test:firefox-webworker
98+
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
99+
with:
100+
directory: ./.nyc_output
101+
flags: firefox-webworker
102+
103+
test-electron-main:
104+
needs: check
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v2
108+
- uses: actions/setup-node@v2
109+
with:
110+
node-version: lts/*
111+
- uses: ipfs/aegir/actions/cache-node-modules@master
112+
- run: npx xvfb-maybe npm run --if-present test:electron-main
113+
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
114+
with:
115+
directory: ./.nyc_output
116+
flags: electron-main
117+
118+
test-electron-renderer:
119+
needs: check
120+
runs-on: ubuntu-latest
121+
steps:
122+
- uses: actions/checkout@v2
123+
- uses: actions/setup-node@v2
124+
with:
125+
node-version: lts/*
126+
- uses: ipfs/aegir/actions/cache-node-modules@master
127+
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
128+
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
129+
with:
130+
directory: ./.nyc_output
131+
flags: electron-renderer
132+
133+
release:
134+
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
135+
runs-on: ubuntu-latest
136+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
137+
steps:
138+
- uses: actions/checkout@v2
139+
with:
140+
fetch-depth: 0
141+
- uses: actions/setup-node@v2
142+
with:
143+
node-version: lts/*
144+
- uses: ipfs/aegir/actions/cache-node-modules@master
145+
- uses: ipfs/aegir/actions/docker-login@master
146+
with:
147+
docker-token: ${{ secrets.DOCKER_TOKEN }}
148+
docker-username: ${{ secrets.DOCKER_USERNAME }}
149+
- run: npm run --if-present release
150+
env:
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/main.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

LICENSE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This project is dual licensed under MIT and Apache-2.0.
2+
3+
MIT: https://www.opensource.org/licenses/mit
4+
Apache-2.0: https://www.apache.org/licenses/license-2.0

LICENSE-APACHE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
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
2+
3+
http://www.apache.org/licenses/LICENSE-2.0
4+
5+
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.

LICENSE-MIT

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,30 @@
1-
libp2p-daemon JavaScript implementation
2-
======
1+
# JS libp2p Interfaces
32

4-
<a href="http://libp2p.io/"><img src="https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square" /></a>
5-
<a href="http://webchat.freenode.net/?channels=%23libp2p"><img src="https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square" /></a>
6-
<a href="https://discuss.libp2p.io"><img src="https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg" /></a>
7-
<a href="https://waffle.io/libp2p/libp2p"><img src="https://img.shields.io/badge/pm-waffle-yellow.svg?style=flat-square" /></a>
3+
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
4+
[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
5+
[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
6+
[![](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)
7+
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-interfaces.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-interfaces)
8+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/ci?label=ci&style=flat-square)](https://github.com/libp2p/js-libp2p-interfaces/actions?query=branch%3Amaster+workflow%3Aci+)
89

9-
> A standalone deployment of a libp2p host, running in its own OS process and installing a set of virtual endpoints to enable co-local applications to: communicate with peers, handle protocols, interact with the DHT, participate in pubsub, etc. no matter the language they are developed in, nor whether a native libp2p implementation exists in that language.
10+
> Contains test suites and interfaces you can use to implement the various components of libp2p
1011
11-
## Lead Maintainer
12+
## Structure
1213

13-
[Jacob Heun](https://github.com/jacobheun)
14+
* [`/packages/libp2p-connection`](./packages/libp2p-connection) An implementation of the Connection interface
15+
* [`/packages/libp2p-interfaces`](./packages/libp2p-interfaces) The interface definitions of various libp2p components
16+
* [`/packages/libp2p-interfaces-compliance-tests`](./packages/libp2p-interfaces-compliance-tests) Tests to ensure adherence of an implementation to the spec
17+
* [`/packages/libp2p-pubsub`](./packages/libp2p-pubsub) An implementation of the Pubsub interface
18+
* [`/packages/libp2p-topology`](./packages/libp2p-topology) An implementation of the Topology interface
1419

15-
## Specs
16-
17-
The specs for the daemon are currently housed in the go implementation. You can read them at [libp2p/go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon/blob/master/specs/README.md)
18-
19-
## Install
20-
21-
```
22-
npm i -g libp2p-daemon
23-
```
24-
25-
## Usage
26-
27-
For a full list of options, you can run help `jsp2pd --help`.
28-
Running the defaults, `jsp2pd`, will start the daemon and bind it to a local unix socket path.
29-
Daemon clients will be able to communicate with the daemon over that unix socket.
30-
31-
As an alternative, you can use this daemon with a different version of libp2p as the one specified in `package.json`. You just need to define its path through an environment variable as follows:
20+
## Contribute
3221

33-
```sh
34-
export LIBP2P_JS=./../../js-libp2p/src/index.js
35-
```
22+
Feel free to join in. All welcome. Open an [issue](https://github.com/libp2p/js-interfaces/issues)!
3623

37-
## Contribute
24+
This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
3825

39-
This module is actively under development. Please check out the issues and submit PRs!
26+
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md)
4027

4128
## License
4229

43-
MIT © Protocol Labs
30+
[Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) © Protocol Labs

lerna.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"lerna": "4.0.0",
3+
"packages": [
4+
"packages/*"
5+
],
6+
"version": "independent",
7+
"command": {
8+
"run": {
9+
"stream": true
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)