Skip to content

Commit c1ab1e6

Browse files
committed
chore: add lerna publish config
1 parent 16347de commit c1ab1e6

File tree

5 files changed

+60
-7
lines changed

5 files changed

+60
-7
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "JS implementation of the IPFS UnixFS",
55
"scripts": {
66
"reset": "lerna run clean && rimraf packages/*/node_modules node_modules packages/*/package-lock.json package-lock.json",
7+
"postinstall": "lerna link",
78
"test": "lerna run test",
89
"coverage": "lerna run coverage",
910
"prepare": "lerna run prepare",

packages/ipfs-unixfs-exporter/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"fs": false
1010
},
1111
"scripts": {
12-
"prepare": "aegir build --no-bundle",
12+
"prepare": "aegir build --no-bundle --esm-tests",
1313
"test": "aegir test",
1414
"build": "aegir build --esm-tests",
1515
"clean": "rimraf ./dist",
@@ -33,6 +33,9 @@
3333
"npm": ">=7.0.0"
3434
},
3535
"homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme",
36+
"publishConfig": {
37+
"directory": "dist"
38+
},
3639
"devDependencies": {
3740
"@types/mocha": "^8.2.1",
3841
"@types/sinon": "^10.0.0",
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
1-
/** @type {() => import('interface-blockstore').Blockstore} */
2-
// @ts-expect-error no types for this deep import
3-
import block from 'ipfs-unixfs-importer/test/helpers/block.js'
1+
import errCode from 'err-code'
2+
import { BlockstoreAdapter } from 'interface-blockstore'
3+
import { base58btc } from 'multiformats/bases/base58'
44

5-
export default block
5+
/**
6+
* @typedef {import('multiformats/cid').CID} CID
7+
*/
8+
9+
function createBlockApi () {
10+
class MockBlockstore extends BlockstoreAdapter {
11+
constructor () {
12+
super()
13+
14+
/** @type {{[key: string]: Uint8Array}} */
15+
this._blocks = {}
16+
}
17+
18+
/**
19+
* @param {CID} cid
20+
* @param {Uint8Array} block
21+
* @param {any} [options]
22+
*/
23+
async put (cid, block, options = {}) {
24+
this._blocks[base58btc.encode(cid.multihash.bytes)] = block
25+
}
26+
27+
/**
28+
* @param {CID} cid
29+
* @param {any} [options]
30+
*/
31+
async get (cid, options = {}) {
32+
const bytes = this._blocks[base58btc.encode(cid.multihash.bytes)]
33+
34+
if (bytes === undefined) {
35+
throw errCode(new Error(`Could not find data for CID '${cid}'`), 'ERR_NOT_FOUND')
36+
}
37+
38+
return bytes
39+
}
40+
}
41+
42+
/** @type {import('interface-blockstore').Blockstore} */
43+
const bs = new MockBlockstore()
44+
45+
return bs
46+
}
47+
48+
export default createBlockApi

packages/ipfs-unixfs-importer/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"fs": false
1010
},
1111
"scripts": {
12-
"prepare": "aegir build --no-bundle",
12+
"prepare": "aegir build --no-bundle --esm-tests",
1313
"test": "aegir test",
1414
"build": "aegir build --esm-tests",
1515
"clean": "rimraf ./dist",
@@ -33,6 +33,9 @@
3333
"npm": ">=7.0.0"
3434
},
3535
"homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme",
36+
"publishConfig": {
37+
"directory": "dist"
38+
},
3639
"devDependencies": {
3740
"@types/mocha": "^8.2.1",
3841
"aegir": "https://gitpkg.now.sh/ipfs/aegir?feat/build-esm-modules-follow-up-with-dist",

packages/ipfs-unixfs/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"fs": false
1010
},
1111
"scripts": {
12-
"prepare": "aegir build",
12+
"prepare": "aegir build --esm-tests",
1313
"prepare:proto": "pbjs -t static-module -w es6 -r ipfs-unixfs --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/unixfs.js ./src/unixfs.proto",
1414
"prepare:proto-types": "pbts -o src/unixfs.d.ts src/unixfs.js",
1515
"prepare:types": "aegir build --no-bundle",
@@ -36,6 +36,9 @@
3636
"npm": ">=7.0.0"
3737
},
3838
"homepage": "https://github.com/ipfs/js-ipfs-unixfs#readme",
39+
"publishConfig": {
40+
"directory": "dist"
41+
},
3942
"devDependencies": {
4043
"@types/mocha": "^8.2.1",
4144
"aegir": "https://gitpkg.now.sh/ipfs/aegir?feat/build-esm-modules-follow-up-with-dist",

0 commit comments

Comments
 (0)