Skip to content

Commit 3a21f8a

Browse files
committed
fix: more types and aegir v31
1 parent 9d9ffb2 commit 3a21f8a

12 files changed

+154
-86
lines changed

.aegir.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
'use strict'
2+
const path = require('path')
23

3-
module.exports = {
4-
webpack: {
5-
node: {
6-
// this is needed until level stops using node buffers in browser code
7-
Buffer: true,
4+
/** @type {import('aegir').Options["build"]["config"]} */
5+
const esbuild = {
6+
inject: [path.join(__dirname, 'scripts/node-globals.js')],
7+
plugins: [
8+
{
9+
name: 'node built ins',
10+
setup (build) {
11+
build.onResolve({ filter: /^stream$/ }, () => {
12+
return { path: require.resolve('readable-stream') }
13+
})
14+
}
15+
}
16+
]
17+
}
818

9-
// needed by binary-parse-stream
10-
stream: true
19+
/** @type {import('aegir').PartialOptions} */
20+
module.exports = {
21+
test: {
22+
browser: {
23+
config: {
24+
buildConfig: esbuild
25+
}
1126
}
27+
},
28+
build: {
29+
bundlesizeMax: '132kB',
30+
config: esbuild
1231
}
1332
}

.github/workflows/main.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
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+
# or
19+
# - uses: gozala/[email protected]
20+
- run: npx aegir build
21+
- run: npx aegir dep-check
22+
- uses: ipfs/aegir/actions/bundle-size@master
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
test-node:
26+
needs: check
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
matrix:
30+
os: [windows-latest, ubuntu-latest, macos-latest]
31+
node: [12, 14]
32+
fail-fast: true
33+
steps:
34+
- uses: actions/checkout@v2
35+
- uses: actions/setup-node@v1
36+
with:
37+
node-version: ${{ matrix.node }}
38+
- run: npm install
39+
- run: npx aegir test -t node --bail --cov
40+
- uses: codecov/codecov-action@v1
41+
test-chrome:
42+
needs: check
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v2
46+
- uses: microsoft/playwright-github-action@v1
47+
- run: npm install
48+
- run: npx aegir test -t browser -t webworker --bail --cov
49+
- uses: codecov/codecov-action@v1
50+
test-firefox:
51+
needs: check
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v2
55+
- uses: microsoft/playwright-github-action@v1
56+
- run: npm install
57+
- run: npx aegir test -t browser -t webworker --bail -- --browser firefox
58+
test-webkit:
59+
needs: check
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v2
63+
- uses: microsoft/playwright-github-action@v1
64+
- run: npm install
65+
- run: npx aegir test -t browser -t webworker --bail -- --browser webkit
66+
test-electron-main:
67+
needs: check
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v2
71+
- run: npm install
72+
- run: npx xvfb-maybe aegir test -t electron-main --bail
73+
test-electron-renderer:
74+
needs: check
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v2
78+
- run: npm install
79+
- run: npx xvfb-maybe aegir test -t electron-renderer --bail

.travis.yml

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

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-repo)](https://travis-ci.com/ipfs/js-ipfs-repo)
88
[![codecov](https://codecov.io/gh/ipfs/js-ipfs-repo/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-ipfs-repo) [![Dependency Status](https://david-dm.org/ipfs/js-ipfs-repo.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-repo)
99
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
10-
![](https://img.shields.io/badge/npm-%3E%3D6.0.0-orange.svg?style=flat-square)
11-
![](https://img.shields.io/badge/Node.js-%3E%3D10.0.0-orange.svg?style=flat-square)
1210

1311
> Implementation of the IPFS repo spec (https://github.com/ipfs/specs/blob/master/REPO.md) in JavaScript
1412
@@ -137,8 +135,6 @@ Loading this module through a script tag will make the `IpfsRepo` obj available
137135

138136
```html
139137
<script src="https://unpkg.com/ipfs-repo/dist/index.min.js"></script>
140-
<!-- OR -->
141-
<script src="https://unpkg.com/ipfs-repo/dist/index.js"></script>
142138
```
143139

144140
## Usage

example.js

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

package.json

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "IPFS Repo implementation",
55
"leadMaintainer": "Alex Potsides <[email protected]>",
66
"main": "src/index.js",
7+
"types": "dist/src/index.d.ts",
78
"files": [
89
"src",
910
"dist"
@@ -21,10 +22,10 @@
2122
"test:webworker": "aegir test -t webworker",
2223
"build": "aegir build",
2324
"lint": "aegir lint",
24-
"release": "aegir release --docs",
25-
"release-minor": "aegir release --type minor --docs",
26-
"release-major": "aegir release --type major --docs",
27-
"coverage": "nyc -s npm run test:node && nyc report --reporter=html",
25+
"release": "aegir release",
26+
"release-minor": "aegir release --type minor",
27+
"release-major": "aegir release --type major",
28+
"coverage": "aegir test -t node --cov && nyc report --reporter=html",
2829
"dep-check": "aegir dep-check",
2930
"docs": "aegir docs"
3031
},
@@ -39,8 +40,8 @@
3940
],
4041
"homepage": "https://github.com/ipfs/js-ipfs-repo",
4142
"engines": {
42-
"node": ">=10.0.0",
43-
"npm": ">=3.0.0"
43+
"node": ">=14.0.0",
44+
"npm": ">=6.0.0"
4445
},
4546
"devDependencies": {
4647
"@types/bytes": "^3.1.0",
@@ -50,43 +51,52 @@
5051
"@types/ncp": "^2.0.4",
5152
"@types/proper-lockfile": "^4.1.1",
5253
"@types/rimraf": "^3.0.0",
53-
"aegir": "ipfs/aegir#feat/docs2.0",
54+
"aegir": "^31.0.1",
55+
"assert": "^2.0.0",
56+
"events": "^3.3.0",
5457
"it-all": "^1.0.2",
5558
"it-drain": "^1.0.1",
5659
"it-first": "^1.0.2",
5760
"just-range": "^2.1.0",
5861
"memdown": "^5.1.0",
59-
"multihashing-async": "multiformats/js-multihashing-async#feat/types",
62+
"multihashing-async": "^2.1.0",
6063
"ncp": "^2.0.0",
64+
"process": "^0.11.10",
65+
"readable-stream": "^3.6.0",
6166
"rimraf": "^3.0.0",
62-
"sinon": "^9.0.2"
67+
"sinon": "^9.0.2",
68+
"url": "^0.11.0",
69+
"util": "^0.12.3"
6370
},
6471
"dependencies": {
6572
"bignumber.js": "^9.0.0",
6673
"bytes": "^3.1.0",
6774
"cids": "^1.0.0",
6875
"datastore-core": "^3.0.0",
6976
"datastore-fs": "^3.0.0",
70-
"datastore-level": "^3.0.0",
77+
"datastore-level": "^4.0.0",
7178
"debug": "^4.1.0",
72-
"err-code": "^2.0.0",
79+
"err-code": "^3.0.1",
7380
"interface-datastore": "^3.0.3",
74-
"ipfs-repo-migrations": "^5.0.3",
81+
"ipfs-repo-migrations": "^6.0.0",
7582
"ipfs-utils": "^6.0.0",
7683
"ipld-block": "^0.11.0",
7784
"it-map": "^1.0.2",
7885
"it-pushable": "^1.4.0",
7986
"just-safe-get": "^2.0.0",
8087
"just-safe-set": "^2.1.0",
8188
"merge-options": "^3.0.4",
82-
"multibase": "^3.0.0",
89+
"multibase": "^4.0.1",
8390
"p-queue": "^6.0.0",
8491
"proper-lockfile": "^4.0.0",
8592
"sort-keys": "^4.0.0",
86-
"uint8arrays": "^2.0.5"
93+
"uint8arrays": "^2.1.3"
8794
},
8895
"eslintConfig": {
89-
"extends": "ipfs"
96+
"extends": "ipfs",
97+
"ignorePatterns": [
98+
"!.aegir.js"
99+
]
90100
},
91101
"license": "MIT",
92102
"contributors": [

scripts/node-globals.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @ts-nocheck
2+
export const { Buffer } = require('buffer')
3+
export const process = require('process/browser')

src/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ const lockers = {
3131
memory: require('./lock-memory'),
3232
fs: require('./lock')
3333
}
34+
3435
/**
3536
* @typedef {import("./types").Options} Options
3637
* @typedef {import("./types").Lock} Lock
3738
* @typedef {import("./types").LockCloser} LockCloser
3839
* @typedef {import("./types").Stat} Stat
3940
* @typedef {import("ipld-block")} Block
40-
* @typedef {import("interface-datastore").Datastore} Datastore}
41+
* @typedef {import("interface-datastore").Datastore} Datastore
4142
*/
4243

4344
/**
@@ -57,6 +58,9 @@ class IpfsRepo {
5758
this.closed = true
5859
this.path = repoPath
5960

61+
/**
62+
* @private
63+
*/
6064
this._locker = this._getLocker()
6165
this.root = backends.create('root', this.path, this.options)
6266
this.datastore = backends.create('datastore', pathJoin(this.path, 'datastore'), this.options)
@@ -332,6 +336,9 @@ class IpfsRepo {
332336
})
333337
}
334338

339+
/**
340+
* @private
341+
*/
335342
async _isAutoMigrationEnabled () {
336343
if (this.options.autoMigrate !== undefined) {
337344
return this.options.autoMigrate
@@ -376,6 +383,9 @@ class IpfsRepo {
376383
}
377384
}
378385

386+
/**
387+
* @private
388+
*/
379389
async _storageMaxStat () {
380390
try {
381391
const max = /** @type {number} */(await this.config.get('Datastore.StorageMax'))
@@ -385,6 +395,9 @@ class IpfsRepo {
385395
}
386396
}
387397

398+
/**
399+
* @private
400+
*/
388401
async _blockStat () {
389402
let count = new Big(0)
390403
let size = new Big(0)
File renamed without changes.

test/blockstore-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ module.exports = (repo) => {
185185
return new Uint8Array()
186186
}
187187

188+
async open () {}
189+
188190
async close () {}
189191
}
190192
},
@@ -300,6 +302,8 @@ module.exports = (repo) => {
300302
return new Uint8Array()
301303
}
302304

305+
async open () {}
306+
303307
async close () {}
304308

305309
/**

test/migrations-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const { expect } = require('aegir/utils/chai')
66
const sinon = require('sinon')
77

8+
// @ts-ignore
89
const migrator = require('ipfs-repo-migrations')
910
const constants = require('../src/constants')
1011
const errors = require('../src/errors')

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "aegir/src/config/tsconfig.aegir.json",
2+
"extends": "./node_modules/aegir/src/config/tsconfig.aegir.json",
33
"compilerOptions": {
44
"outDir": "dist",
55
"baseUrl": "./",
@@ -8,7 +8,7 @@
88
}
99
},
1010
"include": [
11-
"types/**/*.d.ts",
11+
"types",
1212
"test", // remove this line if you don't want to type-check tests
1313
"src"
1414
]

0 commit comments

Comments
 (0)