Skip to content

Commit

Permalink
chore: switch to ESM (#39)
Browse files Browse the repository at this point in the history
- Converts packages to just have interfaces
- Fixes circular dependency between datastore and datastore-tests

BREAKING CHANGE: deep requires/imports are no longer possible, moves adapters/in-memory impls etc to core packages
  • Loading branch information
achingbrain committed Sep 8, 2021
1 parent e246d97 commit c04aa80
Show file tree
Hide file tree
Showing 35 changed files with 139 additions and 1,243 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ dist
node_modules
package-lock.json
docs
types
.nyc_output
1 change: 0 additions & 1 deletion .nyc_output/coverage-final.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/interface-blockstore-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
## Usage

```js
const MyBlockstore = require('./path/to/my-blockstore')
const suite = require('interface-blockstore-tests')
const MyBlockstore from './path/to/my-blockstore')
const suite from 'interface-blockstore-tests')

describe('MyBlockstore', () => {
describe('interface-blockstore compliance tests', () => {
Expand Down
11 changes: 8 additions & 3 deletions packages/interface-blockstore-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
"description": "Compliance tests for the blockstore interface",
"leadMaintainer": "Alex Potsides <alex.potsides@protocol.ai>",
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"types": "types/src/index.d.ts",
"files": [
"src",
"dist"
],
"scripts": {
"build": "aegir build",
"lint": "aegir ts -p check && aegir lint",
"test": "echo \"No tests configured\"",
"dep-check": "aegir dep-check"
},
"repository": {
Expand Down Expand Up @@ -40,6 +39,12 @@
"uint8arrays": "^3.0.0"
},
"eslintConfig": {
"extends": "ipfs"
"extends": "ipfs",
"parserOptions": {
"sourceType": "module"
}
},
"publishConfig": {
"directory": "dist"
}
}
25 changes: 12 additions & 13 deletions packages/interface-blockstore-tests/src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/* eslint-env mocha */
'use strict'

const { expect } = require('aegir/utils/chai')
const all = require('it-all')
const drain = require('it-drain')
const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
const { CID } = require('multiformats/cid')
const { sha256 } = require('multiformats/hashes/sha2')
const { base32 } = require('multiformats/bases/base32')
const raw = require('multiformats/codecs/raw')
const length = require('it-length')

import { expect } from 'aegir/utils/chai.js'
import all from 'it-all'
import drain from 'it-drain'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { CID } from 'multiformats/cid'
import { sha256 } from 'multiformats/hashes/sha2'
import { base32 } from 'multiformats/bases/base32'
import * as raw from 'multiformats/codecs/raw'
import length from 'it-length'

/**
* @typedef {import('interface-blockstore').Blockstore} Blockstore
Expand Down Expand Up @@ -43,7 +42,7 @@ async function getKeyValuePairs (count) {
/**
* @param {{ teardown: () => void; setup: () => Blockstore; }} test
*/
module.exports = (test) => {
export function interfaceBlockstoreTests (test) {
/**
* @param {Blockstore} store
*/
Expand Down Expand Up @@ -309,7 +308,7 @@ module.exports = (test) => {
try {
base32.decode(keyStr.substring(0, j))
prefix = keyStr.substring(0, j)
} catch (err) {
} catch (/** @type {any} */ err) {
if (err.message !== 'Unexpected end of data') {
throw err
}
Expand Down
11 changes: 9 additions & 2 deletions packages/interface-blockstore-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{
"extends": "aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "types"
},
"include": [
"test",
"src"
],
"exclude": [
"dist"
],
"references": [
{
"path": "../interface-blockstore"
}
]
}
15 changes: 5 additions & 10 deletions packages/interface-blockstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
"name": "interface-blockstore",
"version": "1.0.2",
"description": "An interface for storing and retrieving blocks",
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"types": "types/src/index.d.ts",
"scripts": {
"build": "aegir build",
"test": "echo \"No tests configured\"",
"lint": "aegir ts -p check && aegir lint",
"dep-check": "aegir dep-check"
"lint": "aegir ts -p check && aegir lint"
},
"license": "(Apache-2.0 OR MIT)",
"homepage": "https://github.com/ipfs/js-ipfs-interfaces/tree/master/packages/interface-blockstore#readme",
Expand All @@ -18,15 +15,13 @@
"url": "git+https://github.com/ipfs/js-ipfs-interfaces.git"
},
"dependencies": {
"err-code": "^3.0.1",
"interface-store": "^1.0.2",
"it-all": "^1.0.5",
"it-drain": "^1.0.4",
"it-filter": "^1.0.2",
"it-take": "^1.0.1",
"multiformats": "^9.0.4"
},
"devDependencies": {
"aegir": "^35.0.0"
},
"publishConfig": {
"directory": "dist"
}
}
245 changes: 0 additions & 245 deletions packages/interface-blockstore/src/adapter.js

This file was deleted.

Loading

0 comments on commit c04aa80

Please sign in to comment.