diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index a8fa64b..489639c 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -1,4 +1,4 @@ -name: orbit-db-feed tests +name: feed-db tests on: push: branches: diff --git a/README.md b/README.md index f752252..208635a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# orbit-db-feed +# @orbitdb/feed-db Feed database type for orbit-db. -[![orbit-db-feed tests](https://github.com/orbitdb/feed/actions/workflows/run-test.yml/badge.svg?branch=main)](https://github.com/orbitdb/feed/actions/workflows/run-test.yml) +[![feed-db tests](https://github.com/orbitdb/feed/actions/workflows/run-test.yml/badge.svg?branch=main)](https://github.com/orbitdb/feed/actions/workflows/run-test.yml) [![codecov](https://codecov.io/gh/orbitdb/feed/graph/badge.svg?token=7OZK4BJDej)](https://codecov.io/gh/orbitdb/feed) ## Installation @@ -13,6 +13,11 @@ $ pnpm add @constl/orbit-db-feed ## Examples ```ts +import { createOrbit } from "@orbitdb/core"; +import { registerFeed } from "@orbitdb/feed-db"; + +// Register database type. IMPORTANT - must call before creating orbit instance ! +registerFeed(); const db = await orbit.open({ type: "feed" }); await db.add({ a: 1, b: "c" }); diff --git a/package.json b/package.json index 26b5616..ed4bb28 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@orbitdb/feed", + "name": "@orbitdb/feed-db", "version": "1.0.0", "description": "Feed database type for orbit-db.", "author": "Julien Jean Malard-Adam", @@ -53,7 +53,8 @@ "rimraf": "^5.0.5", "ts-patch": "^3.1.2", "typescript": "^5.3.3", - "typescript-transform-paths": "^3.4.6" + "typescript-transform-paths": "^3.4.6", + "wherearewe": "^2.0.1" }, "jest": { "transform": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 82ba133..7c6e88e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -88,6 +88,9 @@ devDependencies: typescript-transform-paths: specifier: ^3.4.6 version: 3.4.6(typescript@5.3.3) + wherearewe: + specifier: ^2.0.1 + version: 2.0.1 packages: diff --git a/test/feed.spec.ts b/test/feed.spec.ts index 7baf64f..e6a0f57 100644 --- a/test/feed.spec.ts +++ b/test/feed.spec.ts @@ -1,11 +1,13 @@ import { type Helia } from "helia"; -import { rimraf } from "rimraf"; +import { Identities, Identity, KeyStore, KeyStoreType } from "@orbitdb/core"; import Feed, { FeedDatabaseType } from "@/feed.js"; +import { DBElements } from "@/types.js"; import { createTestHelia } from "./config.js"; -import { Identities, Identity, KeyStore, KeyStoreType } from "@orbitdb/core"; +import { isBrowser } from "wherearewe"; import { expect } from "aegir/chai"; -import { DBElements } from "@/types.js"; + +const rimrafImport = import("rimraf"); const keysPath = "./testkeys"; @@ -19,7 +21,7 @@ describe("Feed Database", () => { const databaseId = "feed-AAA"; before(async () => { - ipfs = await createTestHelia({ directory: "./ipfs1" }); + ipfs = await createTestHelia(); keystore = await KeyStore({ path: keysPath }); identities = await Identities({ keystore }); @@ -35,9 +37,12 @@ describe("Feed Database", () => { await keystore.close(); } - await rimraf(keysPath); - await rimraf("./orbitdb"); - await rimraf("./ipfs1"); + if (!isBrowser) { + const { rimraf } = await rimrafImport; + await rimraf(keysPath); + await rimraf("./orbitdb"); + await rimraf("./ipfsOKV"); + } }); describe("Creating a Feed database", () => {