Skip to content

Commit

Permalink
Update tests, actions and README
Browse files Browse the repository at this point in the history
  • Loading branch information
julienmalard committed Jan 20, 2024
1 parent b381a62 commit 4d819cb
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 730 deletions.
34 changes: 1 addition & 33 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
import path, { dirname } from "path";
import { fileURLToPath } from "url";
import { createRequire } from "module";

const require = createRequire(import.meta.url);

const __dirname = dirname(fileURLToPath(import.meta.url));

// https://github.com/node-webrtc/node-webrtc/issues/636#issuecomment-774171409
process.on("beforeExit", (code) => process.exit(code));

// https://github.com/ipfs/aegir/blob/master/md/migration-to-v31.md
const esbuild = {
// this will inject all the named exports from 'node-globals.js' as globals
inject: [path.join(__dirname, "./scripts/node-globals.js")],
external: ["fs", "path", "os", "chokidar", "url", "zlib", "rimraf"],
plugins: [
{
name: "node built ins", // this will make the bundler resolve node builtins to the respective browser polyfill
setup(build) {
build.onResolve({ filter: /^stream$/ }, () => {
return { path: require.resolve("stream-browserify") };
});
build.onResolve({ filter: /^os$/ }, () => {
return { path: require.resolve("os-browserify") };
});
build.onResolve({ filter: /^crypto$/ }, () => {
return { path: require.resolve("crypto-browserify") };
});
build.onResolve({ filter: /^fs/ }, () => {
return { path: require.resolve("browserify-fs") };
});
},
},
],
external: ["rimraf"],
};

/** @type {import('aegir').PartialOptions} */
Expand Down
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/requ-te-de-fonctionnalit-.md

This file was deleted.

34 changes: 0 additions & 34 deletions .github/ISSUE_TEMPLATE/signaler-un-probl-me.md

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/npm-publish-next.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Node.js Package (next tag)

on:
push:
branches:
- main

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
registry-url: https://registry.npmjs.org/
- run: pnpm install
- run: pnpm test
- run: |
pnpm version prerelease --no-git-tag-version \
--preid=`git rev-parse --short HEAD`
pnpm publish --tag next
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
21 changes: 21 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Node.js Package

on:
push:
tags:
- 'v*'

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 'lts/*'
registry-url: https://registry.npmjs.org/
- run: pnpm install
- run: pnpm release
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Orbit-db Kuiper tests
name: orbit-db-ordered-keyvalue tests
on:
push:
branches:
Expand All @@ -7,14 +7,14 @@ on:
branches:
- main
jobs:
tests-et-couverture:
test-node:
name: Node.js test
runs-on: ubuntu-latest
steps:
- name: Préparation de Node.js
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 21

- name: Installer pnpm
uses: pnpm/action-setup@v2.4.0
Expand All @@ -28,7 +28,7 @@ jobs:
run: pnpm install --lockfile=false

- name: Vérifier les tests
run: pnpm test
run: pnpm test:node

- name: Envoyer couverture à Codecov
uses: codecov/codecov-action@v3
52 changes: 9 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,27 @@
# Kuiper
Additional database types for orbit-db.
# @orbitdb/ordered-keyvalue-db
Ordered keyvalue database type for orbit-db.

[![Orbit-db Kuiper tests](https://github.com/reseau-constellation/orbit-db-kuiper/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/reseau-constellation/orbit-db-kuiper/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/reseau-constellation/orbit-db-kuiper/graph/badge.svg?token=7OZK4BJDej)](https://codecov.io/gh/reseau-constellation/orbit-db-kuiper)
[![Tests](https://github.com/orbitdb/ordered-keyvalue/actions/workflows/run-test.yml/badge.svg?branch=main)](https://github.com/orbitdb/ordered-keyvalue/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/orbitdb/ordered-keyvalue/graph/badge.svg?token=7OZK4BJDej)](https://codecov.io/gh/orbitdb/ordered-keyvalue)

## Installation
```
$ pnpm add @constl/orbit-db-kuiper
$ pnpm add @orbitdb/ordered-keyvalue
```
## Introduction
`Kuiper` brings additional database types to `orbit-db`.

* `Feed`: For those feeling nostalgic for orbit-db v.0.x. But honestly, you're probably better off with a `KeyValue` or a `Set`.
* `Set`: Like `Feed`, but each value can only be present once. Works for primitive types as well as more complex objects.
* `OrderedKeyValue`: A `KeyValue` database where you can move entries around. Ideal for situations where order is important (e.g., lists of tabs in a spreadsheet, etc.).
A `KeyValue` database where you can move entries around. Ideal for situations where order is important (e.g., lists of tabs in a spreadsheet, etc.).

## Examples

### Set
As simple example with `Set`:
```ts
import { createOrbit } from "@orbitdb/core";
import { registerAll } from "@constl/orbit-db-kuiper";
import { registerOrderedKeyValue } from "@orbitdb/ordered-keyvalue";

// Register Kuiper database types. IMPORTANT - must call before creating orbit instance !
registerAll();
// Register database type. IMPORTANT - must call before creating orbit instance !
registerOrderedKeyValue();

const orbit = await createOrbit({ ipfs })

const db = await orbit.open({ type: "set" });

await db.add(1);
await db.add(2);

const all = await db.all(); // [1, 2]

await db.add(1);
await db.all() // Yay !! Still [1, 2]
```

### Feed
```ts
const db = await orbit.open({ type: "feed" });

await db.add({ a: 1, b: "c" });

const all = await db.all(); // [{ value: { a: 1, b: "c" }, hash: "..." }]

await db.add({ a: 1, b: "c" });
await db.all();
// [{ value: { a: 1, b: "c" }, hash: "..." }, { value: { a: 1, b: "c" }, hash: "..." }]
```

### OrderedKeyValue

```ts

const db = await orbit.open({ type: "ordered-keyvalue" });

await db.put("a", "some value");
Expand Down
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@orbitdb/ordered-keyvalue",
"name": "@orbitdb/ordered-keyvalue-db",
"version": "1.0.0",
"description": "Ordered keyvalue database type for orbit-db.",
"author": "Julien Jean Malard-Adam",
Expand All @@ -17,7 +17,9 @@
"scripts": {
"clean": "rimraf dist",
"compile": "pnpm updateVersion && pnpm format && pnpm clean && pnpm tspc -p tsconfig.build.json",
"test": "pnpm compile && pnpm aegir test -t node --cov -- --exit",
"test": "pnpm test:node && pnpm test:browser",
"test:node": "pnpm compile && pnpm aegir test -t node --cov -- --exit",
"test:browser": "pnpm compile && pnpm aegir test -t browser --cov -- --exit",
"format": "pnpm prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\" && pnpm eslint --ext .js,.ts src",
"release": "pnpm test && (git commit -a -m 'version' || true) && pnpm publish",
"updateVersion": "pnpm genversion --es6 --semi src/version.ts"
Expand All @@ -36,30 +38,24 @@
"@libp2p/identify": "^1.0.11",
"@libp2p/webrtc": "^4.0.16",
"@libp2p/websockets": "^8.0.12",
"@types/fs-extra": "^11.0.4",
"@types/mocha": "^10.0.6",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"aegir": "^42.2.2",
"blockstore-core": "^4.3.10",
"blockstore-level": "^1.1.7",
"browserify-fs": "^1.0.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"fs-extra": "^11.2.0",
"genversion": "^3.2.0",
"libp2p": "^1.2.0",
"mocha": "^10.2.0",
"os-browserify": "^0.3.0",
"prettier": "^3.2.4",
"process": "^0.11.10",
"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": {
Expand Down
Loading

0 comments on commit 4d819cb

Please sign in to comment.