Skip to content

Commit

Permalink
Introduce store-node-fs
Browse files Browse the repository at this point in the history
Remove @cross/env dep
Release 0.4.0
  • Loading branch information
jollytoad committed Jul 12, 2024
1 parent e3c6421 commit 856c739
Show file tree
Hide file tree
Showing 15 changed files with 370 additions and 70 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.0]

### Changed

- [store] remove dep on `@cross/env`

### Added

- [store-node-fs] Node.js compatible file storage

## [0.3.0]

### Changed
Expand Down
27 changes: 14 additions & 13 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"kv"
],
"tasks": {
"test": "deno test --allow-env --allow-read --allow-write --allow-net",
"test": "deno test --allow-env --allow-read --allow-write --allow-net --allow-sys",
"reload": "deno cache --reload **/*.ts jsr:@check/deps",
"check": "deno check **/*.ts",
"lint": "deno lint && deno doc --lint **/*.ts",
Expand All @@ -15,26 +15,27 @@
"noUncheckedIndexedAccess": true,
"verbatimModuleSyntax": true
},
"workspaces": [
"workspace": [
"./store-common",
"./store-deno-fs",
"./store-node-fs",
"./store-deno-kv",
"./store-deno-kv-fs",
"./store-web-storage",
"./store-no-op",
"./store"
],
"imports": {
"@cross/env": "jsr:@cross/env@^1.0.2",
"@jollytoad/store": "jsr:@jollytoad/store@^0.3.0",
"@jollytoad/store-common": "jsr:@jollytoad/store-common@^0.3.0",
"@jollytoad/store-deno-fs": "jsr:@jollytoad/store-deno-fs@^0.3.0",
"@jollytoad/store-deno-kv": "jsr:@jollytoad/store-deno-kv@^0.3.0",
"@jollytoad/store-deno-kv-fs": "jsr:@jollytoad/store-deno-kv-fs@^0.3.0",
"@jollytoad/store-web-storage": "jsr:@jollytoad/store-web-storage@^0.3.0",
"@jollytoad/store-no-op": "jsr:@jollytoad/store-no-op@^0.3.0",
"@std/assert": "jsr:@std/assert@^1.0.0-rc.3",
"@std/fs": "jsr:@std/fs@^1.0.0-rc.3",
"@std/path": "jsr:@std/path@^1.0.0-rc.3"
"@jollytoad/store": "jsr:@jollytoad/store@^0.4.0",
"@jollytoad/store-common": "jsr:@jollytoad/store-common@^0.4.0",
"@jollytoad/store-deno-fs": "jsr:@jollytoad/store-deno-fs@^0.4.0",
"@jollytoad/store-deno-kv": "jsr:@jollytoad/store-deno-kv@^0.4.0",
"@jollytoad/store-deno-kv-fs": "jsr:@jollytoad/store-deno-kv-fs@^0.4.0",
"@jollytoad/store-no-op": "jsr:@jollytoad/store-no-op@^0.4.0",
"@jollytoad/store-web-storage": "jsr:@jollytoad/store-web-storage@^0.4.0",
"@std/assert": "jsr:@std/assert@^1.0.0",
"@std/fs": "jsr:@std/fs@^1.0.0-rc.4",
"@std/path": "jsr:@std/path@^1.0.0-rc.4",
"@types/node": "npm:@types/node@^20.14.10"
}
}
84 changes: 35 additions & 49 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion store-common/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jollytoad/store-common",
"version": "0.3.0",
"version": "0.4.0",
"exports": {
"./key-utils": "./key-utils.ts",
"./test-storage-module": "./test-storage-module.ts",
Expand Down
2 changes: 1 addition & 1 deletion store-deno-fs/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jollytoad/store-deno-fs",
"version": "0.3.0",
"version": "0.4.0",
"exports": {
".": "./mod.ts"
}
Expand Down
2 changes: 1 addition & 1 deletion store-deno-kv-fs/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jollytoad/store-deno-kv-fs",
"version": "0.3.0",
"version": "0.4.0",
"exports": {
".": "./mod.ts"
}
Expand Down
2 changes: 1 addition & 1 deletion store-deno-kv/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jollytoad/store-deno-kv",
"version": "0.3.0",
"version": "0.4.0",
"exports": {
".": "./mod.ts",
"./get-deno-kv": "./get-deno-kv.ts",
Expand Down
2 changes: 1 addition & 1 deletion store-no-op/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jollytoad/store-no-op",
"version": "0.3.0",
"version": "0.4.0",
"exports": {
".": "./mod.ts"
}
Expand Down
32 changes: 32 additions & 0 deletions store-node-fs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Node.js Filesystem Storage Module

See [@jollytoad/store](https://jsr.io/@jollytoad/store) for the bigger picture.

This package provides an implementation of the storage module interface.

This stores values in individual files under a directory hierarchy via
[Node fs](https://nodejs.org/docs/latest/api/fs.html) calls. By default this is
under a `.store` dir under the current working dir. This can be overridden via
the environment var `STORE_FS_ROOT`.

Each level of the key becomes a directory up to the last segment which becomes a
JSON file.

eg: `["one", "two", "three"]` -> `.store/one/two/three.json`

Import mapping: `"$store": "jsr:@jollytoad/store-node-fs"`

**Example**

```ts
import * as store from "jsr:@jollytoad/store-node-fs";
import { assertEquals } from "jsr:@std/assert";

await store.setItem(["foo", "hello"], "world");

assertEquals(await store.hasItem(["foo", "hello"]), true);
assertEquals(await store.getItem(["foo", "hello"]), "world");

await store.clearItems(["foo"]);
assertEquals(await store.hasItem(["foo", "hello"]), false);
```
7 changes: 7 additions & 0 deletions store-node-fs/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@jollytoad/store-node-fs",
"version": "0.4.0",
"exports": {
".": "./mod.ts"
}
}
Loading

0 comments on commit 856c739

Please sign in to comment.