Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

feat!: update helia to v3 and multiformats to v13 #147

Merged
merged 2 commits into from
Jan 8, 2024
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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
2 changes: 2 additions & 0 deletions .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</a>
</p>

# @helia/unixfs <!-- omit in toc -->
# @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)
Expand All @@ -13,30 +13,23 @@

> An implementation of Unixfs for Helia

## Table of contents <!-- omit in toc -->

- [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

- <https://ipfs.github.io/helia-unixfs>

## License
# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribute
# Contribute

Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-unixfs/issues).

Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"bugs": {
"url": "https://github.com/ipfs/helia-unixfs/issues"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"keywords": [
"ipfs"
],
Expand Down
22 changes: 5 additions & 17 deletions packages/interop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</a>
</p>

# @helia/unixfs-interop <!-- omit in toc -->
# @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)
Expand All @@ -13,40 +13,28 @@

> Interop tests for @helia/unixfs

## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [API Docs](#api-docs)
- [License](#license)
- [Contribute](#contribute)

## Install
# Install

```console
$ npm i @helia/unixfs-interop
```

### Browser `<script>` tag
## Browser `<script>` tag

Loading this module through a script tag will make it's exports available as `HeliaUnixfsInterop` in the global namespace.

```html
<script src="https://unpkg.com/@helia/unixfs-interop/dist/index.min.js"></script>
```

## API Docs

- <https://ipfs.github.io/helia-unixfs/modules/_helia_unixfs_interop.html>

## License
# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribute
# Contribute

Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-unixfs/issues).

Expand Down
28 changes: 17 additions & 11 deletions packages/interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
"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"
},
"bugs": {
"url": "https://github.com/ipfs/helia-unixfs/issues"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"keywords": [
"IPFS"
],
Expand Down Expand Up @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions packages/interop/test/bitswap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Libp2p>
let unixFs: UnixFS
let kubo: Controller

Expand Down Expand Up @@ -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))
})
Expand Down
7 changes: 4 additions & 3 deletions packages/interop/test/files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Libp2p>
let unixFs: UnixFS
let kubo: Controller

Expand All @@ -26,7 +27,7 @@ describe('unixfs interop', () => {
async function importToKubo (data: FileCandidate, opts?: KuboAddOptions): Promise<CID> {
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<AddOptions> = {}, kuboOpts: KuboAddOptions = {}): Promise<void> {
Expand Down
10 changes: 6 additions & 4 deletions packages/interop/test/fixtures/create-helia.browser.ts
Original file line number Diff line number Diff line change
@@ -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<Helia> {
export async function createHeliaNode (config: Libp2pOptions = {}): Promise<Helia<Libp2p>> {
const blockstore = new MemoryBlockstore()
const datastore = new MemoryDatastore()

Expand All @@ -28,7 +30,7 @@ export async function createHeliaNode (config: Libp2pOptions = {}): Promise<Heli
yamux()
],
services: {
identify: identifyService()
identify: identify()
},
datastore,
connectionGater: {
Expand Down
10 changes: 6 additions & 4 deletions packages/interop/test/fixtures/create-helia.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { identify } from '@libp2p/identify'
import { tcp } from '@libp2p/tcp'
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<Helia> {
export async function createHeliaNode (config: Libp2pOptions = {}): Promise<Helia<Libp2p>> {
const blockstore = new MemoryBlockstore()
const datastore = new MemoryDatastore()

Expand All @@ -25,7 +27,7 @@ export async function createHeliaNode (config: Libp2pOptions = {}): Promise<Heli
],
datastore,
services: {
identify: identifyService()
identify: identify()
},
...config
})
Expand Down
26 changes: 9 additions & 17 deletions packages/unixfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</a>
</p>

# @helia/unixfs <!-- omit in toc -->
# @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)
Expand All @@ -19,7 +19,7 @@

See the interface for all available operations.

## Example
## Example - Creating files and directories

```typescript
import { createHelia } from 'helia'
Expand All @@ -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'
Expand All @@ -56,40 +56,32 @@ for await (const entry of fs.addAll(globSource('path/to/containing/dir', 'glob-p
}
```

## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [API Docs](#api-docs)
- [License](#license)
- [Contribute](#contribute)

## Install
# Install

```console
$ npm i @helia/unixfs
```

### Browser `<script>` tag
## Browser `<script>` tag

Loading this module through a script tag will make it's exports available as `HeliaUnixfs` in the global namespace.

```html
<script src="https://unpkg.com/@helia/unixfs/dist/index.min.js"></script>
```

## API Docs
# API Docs

- <https://ipfs.github.io/helia-unixfs/modules/_helia_unixfs.html>

## License
# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribute
# Contribute

Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-unixfs/issues).

Expand Down
Loading