Skip to content

Commit

Permalink
feat: export binary from @helia/interop (#384)
Browse files Browse the repository at this point in the history
To prevent things like transient deps breaking Kubo interop tests,
export a bin to allow installing the interop tests from npm and
running them in an easy-to-digest way.
  • Loading branch information
achingbrain authored Jan 17, 2024
1 parent c8d2fac commit 3477b27
Show file tree
Hide file tree
Showing 28 changed files with 50 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/interop/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as kuboRpcClient from 'kubo-rpc-client'
/** @type {import('aegir').PartialOptions} */
export default {
test: {
files: './dist/src/*.spec.js',
before: async (options) => {
if (options.runner !== 'node') {
const ipfsdPort = await getPort()
Expand Down
11 changes: 11 additions & 0 deletions packages/interop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@

> Interop tests for Helia
# About

Runs interop tests between Helia and Kubo.

## Example - Testing a new Kubo release

```console
$ npm i @helia/interop
$ KUBO_BINARY=/path/to/kubo helia-interop
```

# Install

```console
Expand Down
10 changes: 7 additions & 3 deletions packages/interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"keywords": [
"IPFS"
],
"bin": {
"helia-interop": "./dist/src/bin.js"
},
"type": "module",
"types": "./dist/src/index.d.ts",
"files": [
Expand Down Expand Up @@ -52,7 +55,7 @@
"test:node": "aegir test -t node --cov",
"test:electron-main": "aegir test -t electron-main"
},
"devDependencies": {
"dependencies": {
"@helia/block-brokers": "^1.0.0",
"@helia/car": "^2.0.1",
"@helia/dag-cbor": "^2.0.1",
Expand Down Expand Up @@ -88,8 +91,9 @@
"wherearewe": "^2.0.1"
},
"browser": {
"./dist/test/fixtures/create-helia.js": "./dist/test/fixtures/create-helia.browser.js",
"./dist/test/fixtures/create-kubo.js": "./dist/test/fixtures/create-kubo.browser.js",
"./dist/src/fixtures/create-helia.js": "./dist/src/fixtures/create-helia.browser.js",
"./dist/src/fixtures/create-kubo.js": "./dist/src/fixtures/create-kubo.browser.js",
"./dist/src/bin.js": "./dist/src/index.js",
"kubo": false
}
}
18 changes: 18 additions & 0 deletions packages/interop/src/bin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /usr/bin/env node
/* eslint-disable no-console */

import { spawn } from 'node:child_process'

const test = spawn('npx', ['aegir', 'test'])

test.stdout.on('data', (data) => {
process.stdout.write(data)
})

test.stderr.on('data', (data) => {
process.stderr.write(data)
})

test.on('close', (code) => {
process.exit(code ?? 0)
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions packages/interop/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
/**
* @packageDocumentation
*
* Runs interop tests between Helia and Kubo.
*
* @example Testing a new Kubo release
*
* ```console
* $ npm i @helia/interop
* $ KUBO_BINARY=/path/to/kubo helia-interop
* ```
*/

export {}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions packages/interop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
{
"path": "../helia"
},
{
"path": "../interface"
},
{
"path": "../ipns"
},
Expand Down

0 comments on commit 3477b27

Please sign in to comment.