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

Commit cbaef20

Browse files
authored
feat!: switch to ESM-only (#109)
Updates project config to publish as ESM-only. BREAKING CHANGE: this module is now ESM-only
1 parent 55e8e56 commit cbaef20

12 files changed

+95
-72
lines changed

.github/dependabot.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ updates:
66
interval: daily
77
time: "10:00"
88
open-pull-requests-limit: 10
9+
commit-message:
10+
prefix: "deps"
11+
prefix-development: "deps(dev)"

README.md

+27-21
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
# js-datastore-core <!-- omit in toc -->
1+
# datastore-core <!-- omit in toc -->
22

3-
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
4-
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
5-
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
3+
[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io)
4+
[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
5+
[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs)
66
[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-datastore-core.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-datastore-core)
7-
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ipfs/js-datastore-core/ci?label=ci&style=flat-square)](https://github.com/ipfs/js-datastore-core/actions?query=branch%3Amaster+workflow%3Aci+)
7+
[![CI](https://img.shields.io/github/workflow/status/ipfs/js-datastore-core/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-datastore-core/actions/workflows/js-test-and-release.yml)
88

9-
> Implementations for [interface-datastore](https://github.com/ipfs/js-ipfs-interfaces/packages/interface-datastore).
9+
> Wrapper implementation for interface-datastore
1010
11-
## Lead Maintainer <!-- omit in toc -->
11+
## Table of contents <!-- omit in toc -->
1212

13-
[Alex Potsides](https://github.com/achingbrain)
14-
15-
## Table of Contents <!-- omit in toc -->
16-
17-
- [Implementations](#implementations)
1813
- [Install](#install)
14+
- [Implementations](#implementations)
1915
- [Usage](#usage)
2016
- [BaseDatastore](#basedatastore)
2117
- [Wrapping Stores](#wrapping-stores)
2218
- [Contribute](#contribute)
2319
- [License](#license)
20+
- [Contribute](#contribute-1)
21+
22+
## Install
23+
24+
```console
25+
$ npm i datastore-core
26+
```
2427

2528
## Implementations
2629

@@ -31,21 +34,14 @@
3134
- Tiered: [`src/tiered`](src/tirered.js)
3235
- Namespace: [`src/namespace`](src/namespace.js)
3336

34-
## Install
35-
36-
```
37-
$ npm install datastore-core
38-
```
39-
4037
## Usage
4138

42-
4339
### BaseDatastore
4440

4541
An base store is made available to make implementing your own datastore easier:
4642

4743
```javascript
48-
const { BaseDatastore } from 'datastore-core')
44+
import { BaseDatastore } from 'datastore-core'
4945

5046
class MyDatastore extends BaseDatastore {
5147
constructor () {
@@ -88,5 +84,15 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c
8884

8985
## License
9086

91-
[MIT](LICENSE)
87+
Licensed under either of
88+
89+
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
90+
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
91+
92+
## Contribute
9293

94+
Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-importer/issues)!
95+
96+
This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
97+
98+
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)

package.json

+46-37
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,69 @@
2222
"node": ">=16.0.0",
2323
"npm": ">=7.0.0"
2424
},
25-
"main": "src/index.js",
2625
"type": "module",
27-
"types": "types/src/index.d.ts",
26+
"types": "./dist/src/index.d.ts",
2827
"typesVersions": {
2928
"*": {
3029
"*": [
31-
"types/*",
32-
"types/src/*"
30+
"*",
31+
"dist/*",
32+
"dist/src/*",
33+
"dist/src/*/index"
3334
],
34-
"types/*": [
35-
"types/*",
36-
"types/src/*"
35+
"src/*": [
36+
"*",
37+
"dist/*",
38+
"dist/src/*",
39+
"dist/src/*/index"
3740
]
3841
}
3942
},
4043
"files": [
41-
"*",
44+
"src",
45+
"dist",
46+
"!dist/test",
4247
"!**/*.tsbuildinfo"
4348
],
4449
"exports": {
4550
".": {
51+
"types": "./dist/src/index.d.ts",
4652
"import": "./src/index.js"
4753
},
4854
"./base": {
55+
"types": "./src/base.d.ts",
4956
"import": "./src/base.js"
5057
},
5158
"./errors": {
59+
"types": "./src/errors.d.ts",
5260
"import": "./src/errors.js"
5361
},
5462
"./keytransform": {
63+
"types": "./src/keytransform.d.ts",
5564
"import": "./src/keytransform.js"
5665
},
5766
"./memory": {
67+
"types": "./src/memory.d.ts",
5868
"import": "./src/memory.js"
5969
},
6070
"./mount": {
71+
"types": "./src/mount.d.ts",
6172
"import": "./src/mount.js"
6273
},
6374
"./namespace": {
75+
"types": "./src/namespace.d.ts",
6476
"import": "./src/namespace.js"
6577
},
6678
"./shard": {
79+
"types": "./src/shard.d.ts",
6780
"import": "./src/shard.js"
6881
},
6982
"./sharding": {
83+
"types": "./src/sharding.d.ts",
7084
"import": "./src/sharding.js"
7185
},
7286
"./tiered": {
87+
"types": "./src/tiered.d.ts",
7388
"import": "./src/tiered.js"
7489
}
7590
},
@@ -106,15 +121,15 @@
106121
"release": "patch"
107122
},
108123
{
109-
"type": "chore",
124+
"type": "docs",
110125
"release": "patch"
111126
},
112127
{
113-
"type": "docs",
128+
"type": "test",
114129
"release": "patch"
115130
},
116131
{
117-
"type": "test",
132+
"type": "deps",
118133
"release": "patch"
119134
},
120135
{
@@ -144,7 +159,11 @@
144159
},
145160
{
146161
"type": "docs",
147-
"section": "Trivial Changes"
162+
"section": "Documentation"
163+
},
164+
{
165+
"type": "deps",
166+
"section": "Dependencies"
148167
},
149168
{
150169
"type": "test",
@@ -155,51 +174,41 @@
155174
}
156175
],
157176
"@semantic-release/changelog",
158-
[
159-
"@semantic-release/npm",
160-
{
161-
"pkgRoot": "dist"
162-
}
163-
],
177+
"@semantic-release/npm",
164178
"@semantic-release/github",
165179
"@semantic-release/git"
166180
]
167181
},
168182
"scripts": {
169-
"clean": "rimraf dist types",
170-
"prepare": "aegir build --no-bundle && cp -R types dist",
171-
"lint": "aegir ts -p check && aegir lint",
172-
"build": "aegir build --esm-tests",
173-
"release": "semantic-release",
183+
"clean": "aegir clean",
184+
"lint": "aegir lint",
185+
"build": "aegir build",
186+
"release": "aegir release",
174187
"test": "aegir test",
175-
"test:node": "aegir test -t node",
176-
"test:chrome": "aegir test -t browser",
188+
"test:node": "aegir test -t node --cov",
189+
"test:chrome": "aegir test -t browser --cov",
177190
"test:chrome-webworker": "aegir test -t webworker",
178191
"test:firefox": "aegir test -t browser -- --browser firefox",
179192
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
180-
"test:electron-main": "aegir test -t electron-main -f dist/cjs/node-test/*js",
181-
"test:electron-renderer": "aegir test -t electron-renderer -f dist/cjs/node-test/*js",
182-
"dep-check": "aegir dep-check -i rimraf"
193+
"test:electron-main": "aegir test -t electron-main",
194+
"dep-check": "aegir dep-check"
183195
},
184196
"dependencies": {
185-
"debug": "^4.1.1",
197+
"@libp2p/logger": "^2.0.0",
186198
"err-code": "^3.0.1",
187199
"interface-datastore": "^6.0.2",
200+
"it-all": "^1.0.4",
188201
"it-drain": "^1.0.4",
189202
"it-filter": "^1.0.2",
190203
"it-map": "^1.0.5",
191204
"it-merge": "^1.0.1",
192-
"it-pipe": "^1.1.0",
193-
"it-pushable": "^1.4.2",
205+
"it-pipe": "^2.0.3",
206+
"it-pushable": "^3.0.0",
194207
"it-take": "^1.0.1",
195208
"uint8arrays": "^3.0.0"
196209
},
197210
"devDependencies": {
198-
"@types/debug": "^4.1.5",
199-
"aegir": "^36.1.3",
200-
"interface-datastore-tests": "^2.0.3",
201-
"it-all": "^1.0.4",
202-
"rimraf": "^3.0.2",
203-
"util": "^0.12.4"
211+
"aegir": "^37.4.5",
212+
"interface-datastore-tests": "^2.0.3"
204213
}
205214
}

src/tiered.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { BaseDatastore } from './base.js'
22
import * as Errors from './errors.js'
3-
import debug from 'debug'
4-
import pushable from 'it-pushable'
3+
import { logger } from '@libp2p/logger'
4+
import { pushable } from 'it-pushable'
55
import drain from 'it-drain'
66

7-
const log = debug('datastore:core:tiered')
7+
const log = logger('datastore:core:tiered')
88

99
/**
1010
* @typedef {import('interface-datastore').Datastore} Datastore
@@ -69,7 +69,7 @@ export class TieredDatastore extends BaseDatastore {
6969
const res = await store.get(key, options)
7070
if (res) return res
7171
} catch (err) {
72-
log(err)
72+
log.error(err)
7373
}
7474
}
7575
throw Errors.notFoundError()
@@ -109,7 +109,9 @@ export class TieredDatastore extends BaseDatastore {
109109
async * putMany (source, options = {}) {
110110
let error
111111
const pushables = this.stores.map(store => {
112-
const source = pushable()
112+
const source = pushable({
113+
objectMode: true
114+
})
113115

114116
drain(store.putMany(source, options))
115117
.catch(err => {
@@ -143,7 +145,9 @@ export class TieredDatastore extends BaseDatastore {
143145
async * deleteMany (source, options = {}) {
144146
let error
145147
const pushables = this.stores.map(store => {
146-
const source = pushable()
148+
const source = pushable({
149+
objectMode: true
150+
})
147151

148152
drain(store.deleteMany(source, options))
149153
.catch(err => {

test/keytransform.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env mocha */
22

3-
import { expect } from 'aegir/utils/chai.js'
3+
import { expect } from 'aegir/chai'
44
import all from 'it-all'
55
import { Key } from 'interface-datastore/key'
66
import { MemoryDatastore } from '../src/memory.js'

test/mount.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-env mocha */
22
/* eslint max-nested-callbacks: ["error", 8] */
33

4-
import { expect, assert } from 'aegir/utils/chai.js'
4+
import { expect, assert } from 'aegir/chai'
55
import all from 'it-all'
66
import { Key } from 'interface-datastore/key'
77
import { MemoryDatastore } from '../src/memory.js'

test/namespace.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env mocha */
22

3-
import { expect } from 'aegir/utils/chai.js'
3+
import { expect } from 'aegir/chai'
44
import all from 'it-all'
55
import { Key } from 'interface-datastore/key'
66
import { MemoryDatastore } from '../src/memory.js'

test/shard.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env mocha */
22

3-
import { expect } from 'aegir/utils/chai.js'
3+
import { expect } from 'aegir/chai'
44
import {
55
Prefix,
66
Suffix,

test/sharding.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env mocha */
22

3-
import { expect } from 'aegir/utils/chai.js'
3+
import { expect } from 'aegir/chai'
44
import { Key } from 'interface-datastore/key'
55
import { MemoryDatastore } from '../src/memory.js'
66
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'

test/tiered.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env mocha */
22

3-
import { expect } from 'aegir/utils/chai.js'
3+
import { expect } from 'aegir/chai'
44
import { Key } from 'interface-datastore/key'
55
import { MemoryDatastore } from '../src/memory.js'
66
import { TieredDatastore } from '../src/tiered.js'

test/utils.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env mocha */
22

3-
import { expect } from 'aegir/utils/chai.js'
3+
import { expect } from 'aegir/chai'
44
import * as utils from '../src/utils.js'
55
import filter from 'it-filter'
66
import take from 'it-take'

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "aegir/src/config/tsconfig.aegir.json",
33
"compilerOptions": {
4-
"outDir": "types"
4+
"outDir": "dist",
5+
"emitDeclarationOnly": true
56
},
67
"include": [
78
"test",

0 commit comments

Comments
 (0)