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

Commit 89cc2ef

Browse files
authored
feat: convert to typescript (#32)
- Converts to typescript - Only named exports - No more CJS, only ESM - Runs tests on all supported environments - Adds auto-publish - Adds dependabot BREAKING CHANGE: switch to named exports, ESM only
1 parent 2aa4307 commit 89cc2ef

28 files changed

+512
-445
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "10:00"
8+
open-pull-requests-limit: 10

LICENSE

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
1-
MIT License
1+
This project is dual licensed under MIT and Apache-2.0.
22

3-
Copyright (c) 2017 libp2p
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
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: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@
66
[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)
77
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
88
[![Coverage Status](https://coveralls.io/repos/github/libp2p/js-libp2p-record/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-record?branch=master)
9-
[![Travis CI](https://travis-ci.org/libp2p/js-libp2p-record.svg?branch=master)](https://travis-ci.org/libp2p/js-libp2p-record)
10-
[![Circle CI](https://circleci.com/gh/libp2p/js-libp2p-record.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-record)
9+
[![Build Status](https://github.com/libp2p/js-libp2p-record/actions/workflows/js-test-and-release.yml/badge.svg?branch=main)](https://github.com/libp2p/js-libp2p-record/actions/workflows/js-test-and-release.yml)
1110
[![Dependency Status](https://david-dm.org/libp2p/js-libp2p-record.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-record) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
1211
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
1312
![](https://img.shields.io/badge/Node.js-%3E%3D6.0.0-orange.svg?style=flat-square)
1413

1514
> JavaScript implementation of libp2p record.
1615
17-
## Lead Maintainer
18-
19-
[Vasco Santos](https://github.com/vasco-santos).
20-
2116
## Description
2217

2318
Implementation of [go-libp2p-record](https://github.com/libp2p/go-libp2p-record) in JavaScript.
@@ -26,6 +21,20 @@ Implementation of [go-libp2p-record](https://github.com/libp2p/go-libp2p-record)
2621

2722
See https://libp2p.github.io/js-libp2p-record/
2823

24+
## Contribute
25+
26+
The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out:
27+
28+
- Go through the modules and **check out existing issues**. This is especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
29+
- **Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
30+
2931
## License
3032

31-
MIT
33+
Licensed under either of
34+
35+
* Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0)
36+
* MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT)
37+
38+
### Contribution
39+
40+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

package.json

Lines changed: 146 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,174 @@
11
{
2-
"name": "libp2p-record",
2+
"name": "@libp2p/record",
33
"version": "0.10.6",
44
"description": "libp2p record implementation",
5-
"leadMaintainer": "Vasco Santos <[email protected]>",
6-
"main": "src/index.js",
7-
"scripts": {
8-
"test": "aegir test",
9-
"lint": "aegir lint",
10-
"test:node": "aegir test -t node",
11-
"test:browser": "aegir test -t browser -t webworker",
12-
"prepare": "npm run build",
13-
"build": "run-s build:*",
14-
"build:types": "aegir build --no-bundle",
15-
"build:proto": "pbjs -t static-module -w commonjs -r libp2p-record --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/record.js ./src/record/record.proto",
16-
"build:proto-types": "pbts -o src/record/record.d.ts src/record/record.js",
17-
"docs": "aegir docs",
18-
"release": "aegir release",
19-
"release-minor": "aegir release --type minor",
20-
"release-major": "aegir release --type major",
21-
"coverage": "aegir coverage"
22-
},
5+
"author": "Friedel Ziegelmayer <[email protected]>",
6+
"license": "Apache-2.0 OR MIT",
7+
"homepage": "https://github.com/libp2p/js-libp2p-record#readme",
238
"repository": {
249
"type": "git",
25-
"url": "https://github.com/libp2p/js-libp2p-record.git"
10+
"url": "git+https://github.com/libp2p/js-libp2p-record.git"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/libp2p/js-libp2p-record/issues"
2614
},
2715
"keywords": [
2816
"IPFS"
2917
],
3018
"engines": {
31-
"node": ">=14.0.0"
19+
"node": ">=16.0.0",
20+
"npm": ">=7.0.0"
3221
},
33-
"pre-push": [
34-
"lint"
35-
],
36-
"author": "Friedel Ziegelmayer <[email protected]>",
37-
"license": "MIT",
38-
"bugs": {
39-
"url": "https://github.com/libp2p/js-libp2p-record/issues"
22+
"type": "module",
23+
"types": "./dist/src/index.d.ts",
24+
"typesVersions": {
25+
"*": {
26+
"*": [
27+
"*",
28+
"dist/*",
29+
"dist/src/*",
30+
"dist/src/*/index"
31+
],
32+
"src/*": [
33+
"*",
34+
"dist/*",
35+
"dist/src/*",
36+
"dist/src/*/index"
37+
]
38+
}
4039
},
41-
"homepage": "https://github.com/libp2p/js-libp2p-record",
4240
"files": [
4341
"src",
44-
"dist"
42+
"dist/src",
43+
"!dist/test",
44+
"!**/*.tsbuildinfo"
4545
],
46+
"exports": {
47+
".": {
48+
"import": "./dist/src/index.js"
49+
},
50+
"./selectors": {
51+
"import": "./dist/src/selectors.js"
52+
},
53+
"./validators": {
54+
"import": "./dist/src/validators.js"
55+
}
56+
},
4657
"eslintConfig": {
4758
"extends": "ipfs",
59+
"parserOptions": {
60+
"sourceType": "module"
61+
},
4862
"ignorePatterns": [
49-
"src/record/record.d.ts"
63+
"src/record.d.ts"
5064
]
5165
},
52-
"types": "dist/src/index.d.ts",
53-
"devDependencies": {
54-
"aegir": "^35.0.1",
55-
"libp2p-crypto": "^0.19.6",
56-
"libp2p-interfaces": "^1.0.1",
57-
"npm-run-all": "^4.1.5",
58-
"peer-id": "^0.15.2",
59-
"util": "^0.12.4"
66+
"release": {
67+
"branches": [
68+
"master"
69+
],
70+
"plugins": [
71+
[
72+
"@semantic-release/commit-analyzer",
73+
{
74+
"preset": "conventionalcommits",
75+
"releaseRules": [
76+
{
77+
"breaking": true,
78+
"release": "major"
79+
},
80+
{
81+
"revert": true,
82+
"release": "patch"
83+
},
84+
{
85+
"type": "feat",
86+
"release": "minor"
87+
},
88+
{
89+
"type": "fix",
90+
"release": "patch"
91+
},
92+
{
93+
"type": "chore",
94+
"release": "patch"
95+
},
96+
{
97+
"type": "docs",
98+
"release": "patch"
99+
},
100+
{
101+
"type": "test",
102+
"release": "patch"
103+
},
104+
{
105+
"scope": "no-release",
106+
"release": false
107+
}
108+
]
109+
}
110+
],
111+
[
112+
"@semantic-release/release-notes-generator",
113+
{
114+
"preset": "conventionalcommits",
115+
"presetConfig": {
116+
"types": [
117+
{
118+
"type": "feat",
119+
"section": "Features"
120+
},
121+
{
122+
"type": "fix",
123+
"section": "Bug Fixes"
124+
},
125+
{
126+
"type": "chore",
127+
"section": "Trivial Changes"
128+
},
129+
{
130+
"type": "docs",
131+
"section": "Trivial Changes"
132+
},
133+
{
134+
"type": "test",
135+
"section": "Tests"
136+
}
137+
]
138+
}
139+
}
140+
],
141+
"@semantic-release/changelog",
142+
"@semantic-release/npm",
143+
"@semantic-release/github",
144+
"@semantic-release/git"
145+
]
146+
},
147+
"scripts": {
148+
"lint": "aegir lint",
149+
"pretest": "npm run build",
150+
"test": "aegir test -f ./dist/test",
151+
"test:node": "npm run test -- -t node",
152+
"test:chrome": "npm run test -- -t browser",
153+
"test:chrome-webworker": "npm run test -- -t webworker",
154+
"test:firefox": "npm run test -- -t browser -- --browser firefox",
155+
"test:firefox-webworker": "npm run test -- -t webworker -- --browser firefox",
156+
"build": "tsc",
157+
"postbuild": "npm run build:copy-proto-files",
158+
"generate:proto": "pbjs -t static-module -w es6 -r libp2p-record --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/record.js ./src/record/record.proto",
159+
"generate:proto-types": "pbts -o src/record/record.d.ts src/record/record.js",
160+
"build:copy-proto-files": "cp src/record* dist/src",
161+
"release": "semantic-release"
60162
},
61163
"dependencies": {
62164
"err-code": "^3.0.1",
63165
"multiformats": "^9.4.5",
64166
"protobufjs": "^6.11.2",
65167
"uint8arrays": "^3.0.0"
66168
},
67-
"contributors": [
68-
"Vasco Santos <[email protected]>",
69-
"David Dias <[email protected]>",
70-
"Alex Potsides <[email protected]>",
71-
"Hugo Dias <[email protected]>",
72-
"Jacob Heun <[email protected]>",
73-
"Friedel Ziegelmayer <[email protected]>",
74-
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <[email protected]>",
75-
"Matt Joiner <[email protected]>",
76-
"dirkmc <[email protected]>",
77-
"Alan Shaw <[email protected]>"
78-
]
169+
"devDependencies": {
170+
"@libp2p/crypto": "^0.22.7",
171+
"@libp2p/interfaces": "^1.3.3",
172+
"aegir": "^36.1.3"
173+
}
79174
}

src/index.js

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

0 commit comments

Comments
 (0)