Skip to content

Commit

Permalink
fix: more types and aegir v31
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Mar 2, 2021
1 parent f7d68cc commit 4596d0a
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 84 deletions.
33 changes: 26 additions & 7 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
'use strict'
const path = require('path')

module.exports = {
webpack: {
node: {
// this is needed until level stops using node buffers in browser code
Buffer: true,
/** @type {import('aegir').Options["build"]["config"]} */
const esbuild = {
inject: [path.join(__dirname, 'scripts/node-globals.js')],
plugins: [
{
name: 'node built ins',
setup (build) {
build.onResolve({ filter: /^stream$/ }, () => {
return { path: require.resolve('readable-stream') }
})
}
}
]
}

// needed by binary-parse-stream
stream: true
/** @type {import('aegir').PartialOptions} */
module.exports = {
test: {
browser: {
config: {
buildConfig: esbuild
}
}
},
build: {
bundlesizeMax: '132kB',
config: esbuild
}
}
79 changes: 79 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir lint
- run: npx aegir ts -p check
# or
# - uses: gozala/[email protected]
- run: npx aegir build
- run: npx aegir dep-check
- uses: ipfs/aegir/actions/bundle-size@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [12, 14]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npx aegir test -t node --bail --cov
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- run: npm install
- run: npx aegir test -t browser -t webworker --bail --cov
- uses: codecov/codecov-action@v1
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browser firefox
test-webkit:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browser webkit
test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx xvfb-maybe aegir test -t electron-main --bail
test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx xvfb-maybe aegir test -t electron-renderer --bail
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-repo)](https://travis-ci.com/ipfs/js-ipfs-repo)
[![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)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
![](https://img.shields.io/badge/npm-%3E%3D6.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D10.0.0-orange.svg?style=flat-square)

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

```html
<script src="https://unpkg.com/ipfs-repo/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/ipfs-repo/dist/index.js"></script>
```

## Usage
Expand Down
11 changes: 0 additions & 11 deletions example.js

This file was deleted.

36 changes: 23 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "IPFS Repo implementation",
"leadMaintainer": "Alex Potsides <[email protected]>",
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"files": [
"src",
"dist"
Expand All @@ -21,10 +22,10 @@
"test:webworker": "aegir test -t webworker",
"build": "aegir build",
"lint": "aegir lint",
"release": "aegir release --docs",
"release-minor": "aegir release --type minor --docs",
"release-major": "aegir release --type major --docs",
"coverage": "nyc -s npm run test:node && nyc report --reporter=html",
"release": "aegir release",
"release-minor": "aegir release --type minor",
"release-major": "aegir release --type major",
"coverage": "aegir test -t node --cov && nyc report --reporter=html",
"dep-check": "aegir dep-check",
"docs": "aegir docs"
},
Expand All @@ -39,8 +40,8 @@
],
"homepage": "https://github.com/ipfs/js-ipfs-repo",
"engines": {
"node": ">=10.0.0",
"npm": ">=3.0.0"
"node": ">=14.0.0",
"npm": ">=6.0.0"
},
"devDependencies": {
"@types/bytes": "^3.1.0",
Expand All @@ -50,16 +51,22 @@
"@types/ncp": "^2.0.4",
"@types/proper-lockfile": "^4.1.1",
"@types/rimraf": "^3.0.0",
"aegir": "ipfs/aegir#feat/docs2.0",
"aegir": "^31.0.1",
"assert": "^2.0.0",
"events": "^3.3.0",
"it-all": "^1.0.2",
"it-drain": "^1.0.1",
"it-first": "^1.0.2",
"just-range": "^2.1.0",
"memdown": "^5.1.0",
"multihashing-async": "multiformats/js-multihashing-async#feat/types",
"multihashing-async": "^2.1.0",
"ncp": "^2.0.0",
"process": "^0.11.10",
"readable-stream": "^3.6.0",
"rimraf": "^3.0.0",
"sinon": "^9.0.2"
"sinon": "^9.0.2",
"url": "^0.11.0",
"util": "^0.12.3"
},
"dependencies": {
"bignumber.js": "^9.0.0",
Expand All @@ -69,7 +76,7 @@
"datastore-fs": "^3.0.0",
"datastore-level": "^4.0.0",
"debug": "^4.1.0",
"err-code": "^2.0.0",
"err-code": "^3.0.1",
"interface-datastore": "^3.0.3",
"ipfs-repo-migrations": "^6.0.0",
"ipfs-utils": "^6.0.0",
Expand All @@ -79,14 +86,17 @@
"just-safe-get": "^2.0.0",
"just-safe-set": "^2.1.0",
"merge-options": "^3.0.4",
"multibase": "^3.0.0",
"multibase": "^4.0.1",
"p-queue": "^6.0.0",
"proper-lockfile": "^4.0.0",
"sort-keys": "^4.0.0",
"uint8arrays": "^2.0.5"
"uint8arrays": "^2.1.3"
},
"eslintConfig": {
"extends": "ipfs"
"extends": "ipfs",
"ignorePatterns": [
"!.aegir.js"
]
},
"license": "MIT",
"contributors": [
Expand Down
3 changes: 3 additions & 0 deletions scripts/node-globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @ts-nocheck
export const { Buffer } = require('buffer')
export const process = require('process/browser')
15 changes: 14 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ const lockers = {
memory: require('./lock-memory'),
fs: require('./lock')
}

/**
* @typedef {import("./types").Options} Options
* @typedef {import("./types").Lock} Lock
* @typedef {import("./types").LockCloser} LockCloser
* @typedef {import("./types").Stat} Stat
* @typedef {import("ipld-block")} Block
* @typedef {import("interface-datastore").Datastore} Datastore}
* @typedef {import("interface-datastore").Datastore} Datastore
*/

/**
Expand All @@ -57,6 +58,9 @@ class IpfsRepo {
this.closed = true
this.path = repoPath

/**
* @private
*/
this._locker = this._getLocker()
this.root = backends.create('root', this.path, this.options)
this.datastore = backends.create('datastore', pathJoin(this.path, 'datastore'), this.options)
Expand Down Expand Up @@ -332,6 +336,9 @@ class IpfsRepo {
})
}

/**
* @private
*/
async _isAutoMigrationEnabled () {
if (this.options.autoMigrate !== undefined) {
return this.options.autoMigrate
Expand Down Expand Up @@ -376,6 +383,9 @@ class IpfsRepo {
}
}

/**
* @private
*/
async _storageMaxStat () {
try {
const max = /** @type {number} */(await this.config.get('Datastore.StorageMax'))
Expand All @@ -385,6 +395,9 @@ class IpfsRepo {
}
}

/**
* @private
*/
async _blockStat () {
let count = new Big(0)
let size = new Big(0)
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions test/blockstore-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ module.exports = (repo) => {
return new Uint8Array()
}

async open () {}

async close () {}
}
},
Expand Down Expand Up @@ -300,6 +302,8 @@ module.exports = (repo) => {
return new Uint8Array()
}

async open () {}

async close () {}

/**
Expand Down
1 change: 1 addition & 0 deletions test/migrations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const { expect } = require('aegir/utils/chai')
const sinon = require('sinon')

// @ts-ignore
const migrator = require('ipfs-repo-migrations')
const constants = require('../src/constants')
const errors = require('../src/errors')
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "aegir/src/config/tsconfig.aegir.json",
"extends": "./node_modules/aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist",
"baseUrl": "./",
Expand All @@ -8,7 +8,7 @@
}
},
"include": [
"types/**/*.d.ts",
"types",
"test", // remove this line if you don't want to type-check tests
"src"
]
Expand Down

0 comments on commit 4596d0a

Please sign in to comment.