Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ jobs:
strategy:
matrix:
node-version:
# for the sake of it
- 18
- 20
- 22
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 'latest'
- name: Setup node ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
Expand Down
4 changes: 3 additions & 1 deletion bench/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { Readable } from 'stream'
import { CarWriter } from '@ipld/car'
// eslint-disable-next-line no-unused-vars
import * as API from '../src/api.js'
// eslint-disable-next-line no-unused-vars
import { get, entries } from '../src/index.js'
// eslint-disable-next-line no-unused-vars
import { MemoryBlockstore } from '../src/block.js'
import { ShardFetcher } from '../src/shard.js'

Expand Down Expand Up @@ -50,7 +52,7 @@ export const collectMetrics = async (blocks, root) => {
if (!Array.isArray(v)) {
totalEntries++
maxDepth = depth > maxDepth ? depth : maxDepth
totalDepth += depth
totalDepth += depth
return
}
if (v[1]) totalEntries++
Expand Down
3 changes: 3 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ async function openPail (path) {
if (!isShardLink(header.roots[0])) throw new Error(`not a shard: ${header.roots[0]}`)
return { root: header.roots[0], blocks }
} catch (err) {
// @ts-ignore
if (err.code !== 'ENOENT') throw new Error('failed to open bucket', { cause: err })
const rootblk = await ShardBlock.create()
blocks.put(rootblk.cid, rootblk.bytes)
Expand Down Expand Up @@ -207,12 +208,14 @@ async function updatePail (path, blocks, root, { additions, removals }) {
try {
await fs.promises.rename(path, old)
} catch (err) {
// @ts-ignore
if (err.code !== 'ENOENT') throw err
}
await fs.promises.rename(tmp, path)
try {
await fs.promises.rm(old)
} catch (err) {
// @ts-ignore
if (err.code !== 'ENOENT') throw err
}
}
137 changes: 49 additions & 88 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,130 +2,77 @@
"name": "@web3-storage/pail",
"version": "0.6.0",
"description": "DAG based key value store.",
"main": "src/index.js",
"main": "./dist/src/index.js",
"type": "module",
"types": "./dist/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"dist/*"
],
"dist/src/index.d.ts": [
"dist/src/index.d.ts"
],
"api": [
"dist/src/api.d.ts"
],
"batch": [
"dist/src/batch/index.d.ts"
],
"batch/api": [
"dist/src/batch/api.d.ts"
],
"block": [
"dist/src/block.d.ts"
],
"clock": [
"dist/src/clock/index.d.ts"
],
"clock/api": [
"dist/src/clock/api.d.ts"
],
"crdt": [
"dist/src/crdt/index.d.ts"
],
"crdt/api": [
"dist/src/crdt/api.d.ts"
],
"crdt/batch": [
"dist/src/crdt/batch/index.d.ts"
],
"crdt/batch/api": [
"dist/src/crdt/batch/api.d.ts"
],
"diff": [
"dist/src/diff.d.ts"
],
"link": [
"dist/src/link.d.ts"
],
"merge": [
"dist/src/merge.d.ts"
],
"shard": [
"dist/src/shard.d.ts"
]
}
},
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"import": "./src/index.js"
"import": "./dist/src/index.js"
},
"./api": {
"types": "./dist/src/api.d.ts",
"import": "./src/api.js"
"import": "./dist/src/api.js"
},
"./batch": {
"types": "./dist/src/batch/index.d.ts",
"import": "./src/batch/index.js"
"import": "./dist/src/batch/index.js"
},
"./batch/api": {
"types": "./dist/src/batch/api.d.ts",
"import": "./src/batch/api.js"
"import": "./dist/src/batch/api.js"
},
"./block": {
"types": "./dist/src/block.d.ts",
"import": "./src/block.js"
"import": "./dist/src/block.js"
},
"./clock": {
"types": "./dist/src/clock/index.d.ts",
"import": "./src/clock/index.js"
"import": "./dist/src/clock/index.js"
},
"./clock/api": {
"types": "./dist/src/clock/api.d.ts",
"import": "./src/clock/api.js"
"import": "./dist/src/clock/api.js"
},
"./crdt": {
"types": "./dist/src/crdt/index.d.ts",
"import": "./src/crdt/index.js"
"import": "./dist/src/crdt/index.js"
},
"./crdt/api": {
"types": "./dist/src/crdt/api.d.ts",
"import": "./src/crdt/api.js"
"import": "./dist/src/crdt/api.js"
},
"./crdt/batch": {
"types": "./dist/src/crdt/batch/index.d.ts",
"import": "./src/crdt/batch/index.js"
"import": "./dist/src/crdt/batch/index.js"
},
"./crdt/batch/api": {
"types": "./dist/src/crdt/batch/api.d.ts",
"import": "./src/crdt/batch/api.js"
"import": "./dist/src/crdt/batch/api.js"
},
"./diff": {
"types": "./dist/src/diff.d.ts",
"import": "./src/diff.js"
},
"./link": {
"types": "./dist/src/link.d.ts",
"import": "./src/link.js"
"import": "./dist/src/diff.js"
},
"./merge": {
"types": "./dist/src/merge.d.ts",
"import": "./src/merge.js"
"import": "./dist/src/merge.js"
},
"./shard": {
"types": "./dist/src/shard.d.ts",
"import": "./src/shard.js"
"import": "./dist/src/shard.js"
}
},
"bin": {
"pail": "./cli.js"
"pail": "./dist/cli.js",
"pail-propernames": "./scripts/propernames/gen.sh",
"pail-gen": "./dist/scripts/words/gen.js",
"pail-randomcid": "./dist/scripts/randomcid.js"
},
"scripts": {
"build": "tsc --build",
"test": "mocha test/*.test.js",
"coverage": "c8 -r html -r text npm test",
"test": "vitest --run",
"coverage": "vitest --run --coverage",
"lint": "standard"
},
"keywords": [
Expand All @@ -139,23 +86,25 @@
"author": "Alan Shaw",
"license": "Apache-2.0 OR MIT",
"files": [
"src",
"dist"
],
"dependencies": {
"@ipld/dag-cbor": "^9.2.0",
"multiformats": "^13.1.0"
},
"devDependencies": {
"@ipld/dag-cbor": "^9.2.2",
"cli-color": "^2.0.3",
"@ipld/car": "^5.4.0",
"archy": "^1.0.0",
"c8": "^8.0.1",
"carstream": "^2.0.0",
"cli-color": "^2.0.3",
"mocha": "^10.2.0",
"nanoid": "^4.0.0",
"sade": "^1.8.1",
"standard": "^17.0.0",
"typescript": "^5.0.2"
"multiformats": "^13.3.2",
"sade": "^1.8.1"
},
"devDependencies": {
"@types/archy": "^0.0.36",
"@types/cli-color": "^2.0.6",
"@types/node": "^22.13.17",
"@vitest/coverage-v8": "^3.1.1",
"standard": "^17.1.2",
"typescript": "^5.8.2",
"vitest": "^3.1.1"
},
"repository": {
"type": "git",
Expand All @@ -166,8 +115,20 @@
},
"homepage": "https://github.com/web3-storage/pail#readme",
"standard": {
"ignore": [
"*.ts"
"globals": [
"describe",
"before",
"after",
"beforeEach",
"afterEach",
"it",
"assert"
]
},
"pnpm": {
"onlyBuiltDependencies": [
"es5-ext",
"esbuild"
]
}
}
Loading