From 001247c6fc38ff3d810736371de901e5e1099f26 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Mon, 8 Jan 2024 08:46:26 +0100 Subject: [PATCH] feat!: update helia to v3 and multiformats to v13 (#147) Updates all deps and fixes linting errors. BREAKING CHANGE: uses multiformats v13 and helia v3 --- .github/dependabot.yml | 2 +- .github/workflows/js-test-and-release.yml | 2 ++ .github/workflows/semantic-pull-request.yml | 12 ++++++++ README.md | 17 ++++------- package.json | 4 +++ packages/interop/README.md | 22 ++++----------- packages/interop/package.json | 28 +++++++++++-------- packages/interop/test/bitswap.spec.ts | 6 ++-- packages/interop/test/files.spec.ts | 7 +++-- .../test/fixtures/create-helia.browser.ts | 10 ++++--- .../interop/test/fixtures/create-helia.ts | 10 ++++--- packages/unixfs/README.md | 26 ++++++----------- packages/unixfs/package.json | 22 +++++++++------ packages/unixfs/src/index.ts | 6 ++-- 14 files changed, 91 insertions(+), 83 deletions(-) create mode 100644 .github/workflows/semantic-pull-request.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0bc3b42..d401a77 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ updates: schedule: interval: daily time: "10:00" - open-pull-requests-limit: 10 + open-pull-requests-limit: 20 commit-message: prefix: "deps" prefix-development: "deps(dev)" diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 35d87d1..1d7ff79 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -9,7 +9,9 @@ on: permissions: contents: write + id-token: write packages: write + pull-requests: write concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }} diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml new file mode 100644 index 0000000..bd00f09 --- /dev/null +++ b/.github/workflows/semantic-pull-request.yml @@ -0,0 +1,12 @@ +name: Semantic PR + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + uses: pl-strflt/.github/.github/workflows/reusable-semantic-pull-request.yml@v0.3 diff --git a/README.md b/README.md index 871658f..a7d9d1c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

-# @helia/unixfs +# @helia/unixfs [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) @@ -13,30 +13,23 @@ > An implementation of Unixfs for Helia -## Table of contents - -- [Structure](#structure) -- [API Docs](#api-docs) -- [License](#license) -- [Contribute](#contribute) - -## Structure +# Packages - [`/packages/interop`](./packages/interop) Interop tests for @helia/unixfs - [`/packages/unixfs`](./packages/unixfs) A Helia-compatible wrapper for UnixFS -## API Docs +# API Docs - -## License +# License Licensed under either of - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) - MIT ([LICENSE-MIT](LICENSE-MIT) / ) -## Contribute +# Contribute Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-unixfs/issues). diff --git a/package.json b/package.json index 6960c4c..5979579 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,10 @@ "bugs": { "url": "https://github.com/ipfs/helia-unixfs/issues" }, + "publishConfig": { + "access": "public", + "provenance": true + }, "keywords": [ "ipfs" ], diff --git a/packages/interop/README.md b/packages/interop/README.md index bb31762..32d069a 100644 --- a/packages/interop/README.md +++ b/packages/interop/README.md @@ -4,7 +4,7 @@

-# @helia/unixfs-interop +# @helia/unixfs-interop [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) @@ -13,21 +13,13 @@ > Interop tests for @helia/unixfs -## Table of contents - -- [Install](#install) - - [Browser ` ``` -## API Docs - -- - -## License +# License Licensed under either of - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) - MIT ([LICENSE-MIT](LICENSE-MIT) / ) -## Contribute +# Contribute Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-unixfs/issues). diff --git a/packages/interop/package.json b/packages/interop/package.json index c75c60f..db25629 100644 --- a/packages/interop/package.json +++ b/packages/interop/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "description": "Interop tests for @helia/unixfs", "license": "Apache-2.0 OR MIT", - "homepage": "https://github.com/ipfs/helia-unixfs/tree/master/packages/interop#readme", + "homepage": "https://github.com/ipfs/helia-unixfs/tree/main/packages/interop#readme", "repository": { "type": "git", "url": "git+https://github.com/ipfs/helia-unixfs.git" @@ -11,6 +11,10 @@ "bugs": { "url": "https://github.com/ipfs/helia-unixfs/issues" }, + "publishConfig": { + "access": "public", + "provenance": true + }, "keywords": [ "IPFS" ], @@ -48,25 +52,27 @@ "test:electron-main": "aegir test -t electron-main" }, "devDependencies": { - "@chainsafe/libp2p-noise": "^13.0.1", - "@chainsafe/libp2p-yamux": "^5.0.0", - "@helia/interface": "^2.0.0", + "@chainsafe/libp2p-noise": "^14.1.0", + "@chainsafe/libp2p-yamux": "^6.0.1", + "@helia/interface": "^3.0.0", "@helia/unixfs": "^1.0.0", - "@libp2p/tcp": "^8.0.6", - "@libp2p/websockets": "^7.0.6", - "aegir": "^41.0.0", + "@libp2p/identify": "^1.0.9", + "@libp2p/interface": "^1.1.1", + "@libp2p/tcp": "^9.0.7", + "@libp2p/websockets": "^8.0.7", + "aegir": "^42.0.1", "blockstore-core": "^4.0.1", "datastore-core": "^9.0.3", - "kubo": "^0.24.0", - "helia": "^2.0.1", + "helia": "^3.0.0", "ipfs-core-types": "^0.14.0", "ipfs-unixfs-importer": "^15.1.0", "ipfsd-ctl": "^13.0.0", "it-to-buffer": "^4.0.1", + "kubo": "^0.25.0", "kubo-rpc-client": "^3.0.0", - "libp2p": "^0.46.10", + "libp2p": "^1.0.10", "merge-options": "^3.0.4", - "multiformats": "^12.1.1", + "multiformats": "^13.0.0", "wherearewe": "^2.0.1" }, "browser": { diff --git a/packages/interop/test/bitswap.spec.ts b/packages/interop/test/bitswap.spec.ts index 9104246..7990e7d 100644 --- a/packages/interop/test/bitswap.spec.ts +++ b/packages/interop/test/bitswap.spec.ts @@ -3,14 +3,16 @@ import { type UnixFS, unixfs } from '@helia/unixfs' import { expect } from 'aegir/chai' import toBuffer from 'it-to-buffer' +import { CID } from 'multiformats/cid' import { createHeliaNode } from './fixtures/create-helia.js' import { createKuboNode } from './fixtures/create-kubo.js' import type { Helia } from '@helia/interface' +import type { Libp2p } from '@libp2p/interface' import type { FileCandidate } from 'ipfs-unixfs-importer' import type { Controller } from 'ipfsd-ctl' describe('unixfs bitswap interop', () => { - let helia: Helia + let helia: Helia let unixFs: UnixFS let kubo: Controller @@ -74,7 +76,7 @@ describe('unixfs bitswap interop', () => { const { cid } = await kubo.api.add(candidate.content) - const bytes = await toBuffer(unixFs.cat(cid)) + const bytes = await toBuffer(unixFs.cat(CID.parse(cid.toString()))) expect(bytes).to.equalBytes(toBuffer(input)) }) diff --git a/packages/interop/test/files.spec.ts b/packages/interop/test/files.spec.ts index 4988f3a..db329bf 100644 --- a/packages/interop/test/files.spec.ts +++ b/packages/interop/test/files.spec.ts @@ -4,16 +4,17 @@ import { type AddOptions, type UnixFS, unixfs } from '@helia/unixfs' import { expect } from 'aegir/chai' import { fixedSize } from 'ipfs-unixfs-importer/chunker' import { balanced } from 'ipfs-unixfs-importer/layout' +import { CID } from 'multiformats/cid' import { createHeliaNode } from './fixtures/create-helia.js' import { createKuboNode } from './fixtures/create-kubo.js' import type { Helia } from '@helia/interface' +import type { Libp2p } from '@libp2p/interface' import type { AddOptions as KuboAddOptions } from 'ipfs-core-types/src/root.js' import type { FileCandidate } from 'ipfs-unixfs-importer' import type { Controller } from 'ipfsd-ctl' -import type { CID } from 'multiformats/cid' describe('unixfs interop', () => { - let helia: Helia + let helia: Helia let unixFs: UnixFS let kubo: Controller @@ -26,7 +27,7 @@ describe('unixfs interop', () => { async function importToKubo (data: FileCandidate, opts?: KuboAddOptions): Promise { const result = await kubo.api.add(data.content, opts) - return result.cid + return CID.parse(result.cid.toString()) } async function expectSameCid (data: () => FileCandidate, heliaOpts: Partial = {}, kuboOpts: KuboAddOptions = {}): Promise { diff --git a/packages/interop/test/fixtures/create-helia.browser.ts b/packages/interop/test/fixtures/create-helia.browser.ts index f94bc9d..0dce051 100644 --- a/packages/interop/test/fixtures/create-helia.browser.ts +++ b/packages/interop/test/fixtures/create-helia.browser.ts @@ -1,16 +1,18 @@ import { noise } from '@chainsafe/libp2p-noise' import { yamux } from '@chainsafe/libp2p-yamux' +import { identify } from '@libp2p/identify' import { webSockets } from '@libp2p/websockets' import { all } from '@libp2p/websockets/filters' import { MemoryBlockstore } from 'blockstore-core' import { MemoryDatastore } from 'datastore-core' import { createHelia } from 'helia' import { bitswap } from 'helia/block-brokers' -import { createLibp2p, type Libp2pOptions } from 'libp2p' -import { identifyService } from 'libp2p/identify' +import { createLibp2p } from 'libp2p' import type { Helia } from '@helia/interface' +import type { Libp2p } from '@libp2p/interface' +import type { Libp2pOptions } from 'libp2p' -export async function createHeliaNode (config: Libp2pOptions = {}): Promise { +export async function createHeliaNode (config: Libp2pOptions = {}): Promise> { const blockstore = new MemoryBlockstore() const datastore = new MemoryDatastore() @@ -28,7 +30,7 @@ export async function createHeliaNode (config: Libp2pOptions = {}): Promise { +export async function createHeliaNode (config: Libp2pOptions = {}): Promise> { const blockstore = new MemoryBlockstore() const datastore = new MemoryDatastore() @@ -25,7 +27,7 @@ export async function createHeliaNode (config: Libp2pOptions = {}): Promise

-# @helia/unixfs +# @helia/unixfs [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) @@ -19,7 +19,7 @@ See the interface for all available operations. -## Example +## Example - Creating files and directories ```typescript import { createHelia } from 'helia' @@ -44,9 +44,9 @@ for await (const entry of fs.addAll([{ } ``` -## Example +## Example - Recursively adding a directory -Recursively adding a directory (Node.js-compatibly environments only): +Node.js-compatibly environments only: ```typescript import { globSource } from '@helia/unixfs' @@ -56,21 +56,13 @@ for await (const entry of fs.addAll(globSource('path/to/containing/dir', 'glob-p } ``` -## Table of contents - -- [Install](#install) - - [Browser ` ``` -## API Docs +# API Docs - -## License +# License Licensed under either of - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) - MIT ([LICENSE-MIT](LICENSE-MIT) / ) -## Contribute +# Contribute Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-unixfs/issues). diff --git a/packages/unixfs/package.json b/packages/unixfs/package.json index 23f0993..1bda316 100644 --- a/packages/unixfs/package.json +++ b/packages/unixfs/package.json @@ -3,7 +3,7 @@ "version": "1.4.3", "description": "A Helia-compatible wrapper for UnixFS", "license": "Apache-2.0 OR MIT", - "homepage": "https://github.com/ipfs/helia-unixfs/tree/master/packages/unixfs#readme", + "homepage": "https://github.com/ipfs/helia-unixfs/tree/main/packages/unixfs#readme", "repository": { "type": "git", "url": "git+https://github.com/ipfs/helia-unixfs.git" @@ -11,6 +11,10 @@ "bugs": { "url": "https://github.com/ipfs/helia-unixfs/issues" }, + "publishConfig": { + "access": "public", + "provenance": true + }, "keywords": [ "IPFS" ], @@ -155,13 +159,12 @@ "release": "aegir release" }, "dependencies": { - "@helia/interface": "^2.0.0", + "@helia/interface": "^3.0.0", "@ipld/dag-pb": "^4.0.0", - "@libp2p/interface": "^0.1.2", - "@libp2p/logger": "^3.0.2", + "@libp2p/interface": "^1.0.2", + "@libp2p/logger": "^4.0.2", "@multiformats/murmur3": "^2.1.2", "hamt-sharding": "^3.0.2", - "interface-blockstore": "^5.0.0", "ipfs-unixfs": "^11.0.0", "ipfs-unixfs-exporter": "^13.1.0", "ipfs-unixfs-importer": "^15.1.0", @@ -169,20 +172,21 @@ "it-last": "^3.0.1", "it-pipe": "^3.0.1", "merge-options": "^3.0.4", - "multiformats": "^12.1.1", + "multiformats": "^13.0.0", "progress-events": "^1.0.0", - "sparse-array": "^1.3.2" + "sparse-array": "^1.3.2", + "uint8arrays": "^5.0.1" }, "devDependencies": { - "aegir": "^41.0.0", + "aegir": "^42.0.1", "blockstore-core": "^4.0.1", "delay": "^6.0.0", + "interface-blockstore": "^5.2.9", "iso-url": "^1.2.1", "it-all": "^3.0.1", "it-drain": "^3.0.1", "it-first": "^3.0.1", "it-to-buffer": "^4.0.1", - "uint8arrays": "^4.0.3", "wherearewe": "^2.0.1" }, "browser": { diff --git a/packages/unixfs/src/index.ts b/packages/unixfs/src/index.ts index 6019dff..57eb0f6 100644 --- a/packages/unixfs/src/index.ts +++ b/packages/unixfs/src/index.ts @@ -5,7 +5,7 @@ * * See the {@link UnixFS UnixFS interface} for all available operations. * - * @example + * @example Creating files and directories * * ```typescript * import { createHelia } from 'helia' @@ -30,9 +30,9 @@ * } * ``` * - * @example + * @example Recursively adding a directory * - * Recursively adding a directory (Node.js-compatibly environments only): + * Node.js-compatibly environments only: * * ```typescript * import { globSource } from '@helia/unixfs'