Skip to content

Commit 85e2951

Browse files
authored
feat(!): convert to typescript (#94)
Converts module to typescript, updates build to use GH actions with auto release, updates license, changes module name. BREAKING CHANGE: no more default exports, no more CJS, only ESM
1 parent d919e52 commit 85e2951

12 files changed

+271
-258
lines changed

.aegir.js .aegir.cjs

File renamed without changes.

.github/workflows/main.yml

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: test & maybe release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
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@v1
39+
40+
test-chrome:
41+
needs: check
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v2
45+
- uses: actions/setup-node@v2
46+
with:
47+
node-version: lts/*
48+
- uses: ipfs/aegir/actions/cache-node-modules@master
49+
- run: npm run --if-present test:chrome
50+
51+
test-chrome-webworker:
52+
needs: check
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v2
56+
- uses: actions/setup-node@v2
57+
with:
58+
node-version: lts/*
59+
- uses: ipfs/aegir/actions/cache-node-modules@master
60+
- run: npm run --if-present test:chrome-webworker
61+
62+
test-firefox:
63+
needs: check
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v2
67+
- uses: actions/setup-node@v2
68+
with:
69+
node-version: lts/*
70+
- uses: ipfs/aegir/actions/cache-node-modules@master
71+
- run: npm run --if-present test:firefox
72+
73+
test-firefox-webworker:
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-webworker
83+
84+
test-electron-main:
85+
needs: check
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v2
89+
- uses: actions/setup-node@v2
90+
with:
91+
node-version: lts/*
92+
- uses: ipfs/aegir/actions/cache-node-modules@master
93+
- run: npx xvfb-maybe npm run --if-present test:electron-main
94+
95+
test-electron-renderer:
96+
needs: check
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v2
100+
- uses: actions/setup-node@v2
101+
with:
102+
node-version: lts/*
103+
- uses: ipfs/aegir/actions/cache-node-modules@master
104+
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
105+
106+
release:
107+
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
108+
runs-on: ubuntu-latest
109+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
110+
steps:
111+
- uses: actions/checkout@v2.4.0
112+
with:
113+
fetch-depth: 0
114+
- uses: actions/setup-node@v2
115+
with:
116+
node-version: lts/*
117+
- uses: ipfs/aegir/actions/cache-node-modules@master
118+
- uses: ipfs/aegir/actions/docker-login@master
119+
with:
120+
docker-token: ${{ secrets.DOCKER_USERNAME }}
121+
docker-username: ${{ secrets.DOCKER_USERNAME }}
122+
- run: npm run --if-present release
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.travis.yml

-50
This file was deleted.

LICENSE

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
MIT: https://www.opensource.org/licenses/mit
2+
Apache-2.0: https://www.apache.org/licenses/license-2.0

LICENSE-APACHE

+5
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

+19
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

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
js-mafmt
2-
========
1+
# js-mafmt
32

43
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
54
[![](https://img.shields.io/badge/project-multiformats-blue.svg?style=flat-square)](https://github.com/multiformats/multiformats)
@@ -10,20 +9,16 @@ js-mafmt
109

1110
> Javascript implementation of multiaddr validation
1211
13-
## Lead Maintainer
14-
15-
[Vasco Santos](https://github.com/vasco-santos).
16-
1712
## Install
1813

1914
```sh
20-
npm install mafmt
15+
npm install @multiformats/mafmt
2116
```
2217

2318
## Usage
2419

2520
```js
26-
const mafmt = require('mafmt')
21+
import * as mafmt from 'multiformats/mafmt'
2722

2823
mafmt.DNS.matches('/dns4/ipfs.io') // true
2924
```

package.json

+36-45
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,53 @@
11
{
2-
"name": "mafmt",
2+
"name": "@multiformats/mafmt",
33
"version": "10.0.0",
44
"description": "A multiaddr validator",
5-
"leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>",
6-
"main": "src/index.js",
7-
"types": "dist/src/index.d.ts",
8-
"scripts": {
9-
"lint": "aegir ts -p check && aegir lint",
10-
"build": "aegir build",
11-
"test": "aegir test",
12-
"test:node": "aegir test --target node",
13-
"test:browser": "aegir test --target browser",
14-
"test:types": "npx tsc",
15-
"release": "aegir release",
16-
"release-minor": "aegir release --type minor",
17-
"release-major": "aegir release --type major",
18-
"coverage": "aegir coverage",
19-
"coverage-publish": "aegir coverage publish"
5+
"type": "module",
6+
"types": "./dist/src/index.d.ts",
7+
"exports": {
8+
".": {
9+
"import": "./dist/src/index.js"
10+
}
2011
},
21-
"pre-push": [
22-
"lint"
12+
"files": [
13+
"src",
14+
"dist/src",
15+
"!dist/test",
16+
"!**/*.tsbuildinfo"
2317
],
18+
"eslintConfig": {
19+
"extends": "ipfs",
20+
"parserOptions": {
21+
"sourceType": "module"
22+
}
23+
},
24+
"scripts": {
25+
"lint": "aegir lint",
26+
"dep-check": "aegir dep-check dist/src/**/*.js dist/test/**/*.js",
27+
"build": "tsc",
28+
"pretest": "npm run build",
29+
"test": "aegir test -f ./dist/test/**/*.js",
30+
"test:chrome": "npm run test -- -t browser",
31+
"test:chrome-webworker": "npm run test -- -t webworker",
32+
"test:firefox": "npm run test -- -t browser -- --browser firefox",
33+
"test:firefox-webworker": "npm run test -- -t webworker -- --browser firefox",
34+
"test:node": "npm run test -- -t node --cov",
35+
"test:electron-main": "npm run test -- -t electron-main",
36+
"release": "semantic-release"
37+
},
2438
"repository": "github:multiformats/js-mafmt",
2539
"keywords": [
2640
"multiaddr"
2741
],
28-
"license": "MIT",
42+
"license": "(Apache-2.0 OR MIT)",
2943
"bugs": "https://github.com/multiformats/js-mafmt/issues",
3044
"homepage": "https://github.com/multiformats/js-mafmt#readme",
3145
"devDependencies": {
32-
"aegir": "^35.0.1",
46+
"aegir": "^36.1.3",
3347
"uint8arrays": "^3.0.0",
3448
"util": "^0.12.3"
3549
},
3650
"dependencies": {
37-
"multiaddr": "^10.0.0"
38-
},
39-
"files": [
40-
"src",
41-
"dist",
42-
"!dist/*.tsbuildinfo"
43-
],
44-
"contributors": [
45-
"David Dias <daviddias.p@gmail.com>",
46-
"Vasco Santos <vasco.santos@moxy.studio>",
47-
"Jacob Heun <jacobheun@gmail.com>",
48-
"dmitriy ryajov <dryajov@dmitriys-MBP.HomeNET>",
49-
"Jeromy Johnson <whyrusleeping@users.noreply.github.com>",
50-
"Maciej Krüger <mkg20001@gmail.com>",
51-
"Alan Shaw <alan@tableflip.io>",
52-
"Alex Potsides <alex@achingbrain.net>",
53-
"Jeromy <jeromyj@gmail.com>",
54-
"dignifiedquire <dignifiedquire@gmail.com>",
55-
"victorbjelkholm <victorbjelkholm@gmail.com>",
56-
"Hugo Dias <mail@hugodias.me>",
57-
"Cayman <caymannava@gmail.com>",
58-
"wqsz7xn <67990210+wqsz7xn@users.noreply.github.com>",
59-
"Marcin Rataj <lidel@lidel.org>",
60-
"João Antunes <me@jgantunes.com>"
61-
]
51+
"@multiformats/multiaddr": "^10.1.1"
52+
}
6253
}

0 commit comments

Comments
 (0)