From 314d13051665c42be8a4bcc51c19ce2d5dd45346 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 8 Sep 2021 17:34:55 +0100 Subject: [PATCH 01/36] chore: convert to esm (#103) BREAKING CHANGE: deep imports are no longer possible --- .github/workflows/main.yml | 7 ++- .gitignore | 56 ++++++++++++++----- package.json | 48 ++++++++++------ src/index.js | 52 ++++++++--------- test/index.spec.js | 112 +++++++++++++++++-------------------- tsconfig.json | 16 +++--- 6 files changed, 161 insertions(+), 130 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2822fc0..05587f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,6 +31,7 @@ jobs: with: node-version: ${{ matrix.node }} - run: npm install + - run: npm run pretest - run: npx nyc --reporter=lcov aegir test -t node -- --bail - uses: codecov/codecov-action@v1 test-electron-main: @@ -39,11 +40,13 @@ jobs: steps: - uses: actions/checkout@v2 - run: npm install - - run: npx xvfb-maybe aegir test -t electron-main --bail + - run: npm run pretest + - run: npx xvfb-maybe aegir test -t electron-main --bail -f dist/cjs/node-test/*js test-electron-renderer: needs: check runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - run: npm install - - run: npx xvfb-maybe aegir test -t electron-renderer --bail + - run: npm run pretest + - run: npx xvfb-maybe aegir test -t electron-renderer --bail -f dist/cjs/browser-test/*js diff --git a/.gitignore b/.gitignore index 9691fab..238a04e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,17 @@ -yarn.lock -package-lock.json -**/node_modules/ -**/*.log -test/repo-tests* +dist/ # Logs logs *.log - -coverage +npm-debug.log* +yarn-debug.log* +yarn-error.log* # Runtime data pids *.pid *.seed +*.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov @@ -21,18 +19,48 @@ lib-cov # Coverage directory used by tools like istanbul coverage +# nyc test coverage +.nyc_output + # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt +# Bower dependency directory (https://bower.io/) +bower_components + # node-waf configuration .lock-wscript -build +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ -# Dependency directory -# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git -node_modules +# Optional npm cache directory +.npm -lib -dist -docs +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# while testing npm5 +package-lock.json +yarn.lock +types +docs \ No newline at end of file diff --git a/package.json b/package.json index 8c6031e..829850d 100644 --- a/package.json +++ b/package.json @@ -4,21 +4,28 @@ "description": "Datastore implementation with file system backend", "leadMaintainer": "Alex Potsides ", "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "types/src/index.d.ts", + "type": "module", "files": [ - "src", - "dist" + "*", + "!**/*.tsbuildinfo" ], + "browser": { + "fs": false, + "path": false, + "util": false + }, "scripts": { - "prepare": "aegir build --no-bundle", - "test": "aegir test -t node", - "build": "aegir build", - "lint": "aegir lint", - "release": "aegir release -t node --build false", - "release-minor": "aegir release --type minor -t node --build false", - "release-major": "aegir release --type major -t node --build false", - "coverage": "nyc -s npm run test:node && nyc report --reporter=html", - "dep-check": "aegir dep-check" + "clean": "rimraf dist types", + "prepare": "aegir build --no-bundle && cp -R types dist", + "lint": "aegir ts -p check && aegir lint", + "build": "aegir build --no-bundle", + "release": "aegir release --target node", + "release-minor": "aegir release --type minor --target node", + "release-major": "aegir release --type major --target node", + "pretest": "aegir build --esm-tests", + "test": "aegir test", + "dep-check": "aegir dep-check -i rimraf" }, "repository": { "type": "git", @@ -38,25 +45,30 @@ }, "homepage": "https://github.com/ipfs/js-datastore-fs#readme", "dependencies": { - "datastore-core": "^5.0.0", + "datastore-core": "^6.0.5", "fast-write-atomic": "^0.2.0", - "interface-datastore": "^5.1.1", - "it-glob": "0.0.13", + "interface-datastore": "^6.0.2", + "it-glob": "^1.0.1", "it-map": "^1.0.5", "it-parallel-batch": "^1.0.9", "mkdirp": "^1.0.4" }, "devDependencies": { - "aegir": "^34.0.2", + "@types/mkdirp": "^1.0.2", + "@types/rimraf": "^3.0.2", + "aegir": "^35.0.3", "async-iterator-all": "^1.0.0", "detect-node": "^2.0.4", - "interface-datastore-tests": "^1.0.0", + "interface-datastore-tests": "^2.0.3", "ipfs-utils": "^8.1.3", "memdown": "^6.0.0", "rimraf": "^3.0.2" }, "eslintConfig": { - "extends": "ipfs" + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "contributors": [ "achingbrain ", diff --git a/src/index.js b/src/index.js index e130e98..e500b80 100644 --- a/src/index.js +++ b/src/index.js @@ -1,23 +1,21 @@ -'use strict' +import fs from 'fs' +import glob from 'it-glob' +import mkdirp from 'mkdirp' +import path from 'path' +import { promisify } from 'util' +import { + Key +} from 'interface-datastore' +import { + BaseDatastore, Errors +} from 'datastore-core' +import map from 'it-map' +import parallel from 'it-parallel-batch' +// @ts-ignore no types +import fwa from 'fast-write-atomic' -const fs = require('fs') -const glob = require('it-glob') // @ts-ignore -const mkdirp = require('mkdirp') -const promisify = require('util').promisify -// @ts-ignore -const writeAtomic = promisify(require('fast-write-atomic')) -const path = require('path') -const { - Adapter, Key, Errors -} = require('interface-datastore') -const map = require('it-map') -const parallel = require('it-parallel-batch') - -const noop = () => {} -const fsAccess = promisify(fs.access || noop) -const fsReadFile = promisify(fs.readFile || noop) -const fsUnlink = promisify(fs.unlink || noop) +const writeAtomic = promisify(fwa) /** * @typedef {import('interface-datastore').Datastore} Datastore @@ -40,13 +38,13 @@ const fsUnlink = promisify(fs.unlink || noop) async function writeFile (path, contents) { try { await writeAtomic(path, contents) - } catch (err) { + } catch (/** @type {any} */ err) { if (err.code === 'EPERM' && err.syscall === 'rename') { // fast-write-atomic writes a file to a temp location before renaming it. // On Windows, if the final file already exists this error is thrown. // No such error is thrown on Linux/Mac // Make sure we can read & write to this file - await fsAccess(path, fs.constants.F_OK | fs.constants.W_OK) + await fs.promises.access(path, fs.constants.F_OK | fs.constants.W_OK) // The file was created by another context - this means there were // attempts to write the same block by two different function calls @@ -65,7 +63,7 @@ async function writeFile (path, contents) { * * @implements {Datastore} */ -class FsDatastore extends Adapter { +export class DatastoreFs extends BaseDatastore { /** * @param {string} location * @param {{ createIfMissing?: boolean, errorIfExists?: boolean, extension?: string, putManyConcurrency?: number } | undefined} [opts] @@ -217,7 +215,7 @@ class FsDatastore extends Adapter { let data try { - data = await fsReadFile(file) + data = await fs.promises.readFile(file) } catch (err) { throw Errors.notFoundError(err) } @@ -234,7 +232,7 @@ class FsDatastore extends Adapter { const parts = this._encode(key) let data try { - data = await fsReadFile(parts.file) + data = await fs.promises.readFile(parts.file) } catch (err) { throw Errors.notFoundError(err) } @@ -283,7 +281,7 @@ class FsDatastore extends Adapter { const parts = this._encode(key) try { - await fsAccess(parts.file) + await fs.promises.access(parts.file) } catch (err) { return false } @@ -299,7 +297,7 @@ class FsDatastore extends Adapter { async delete (key) { const parts = this._encode(key) try { - await fsUnlink(parts.file) + await fs.promises.unlink(parts.file) } catch (err) { if (err.code === 'ENOENT') { return @@ -327,7 +325,7 @@ class FsDatastore extends Adapter { for await (const file of files) { try { - const buf = await fsReadFile(file) + const buf = await fs.promises.readFile(file) /** @type {Pair} */ const pair = { @@ -365,5 +363,3 @@ class FsDatastore extends Adapter { yield * map(files, f => this._decode(f)) } } - -module.exports = FsDatastore diff --git a/test/index.spec.js b/test/index.spec.js index 06a1cb1..ee5a383 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -1,30 +1,23 @@ /* eslint-env mocha */ -'use strict' - -const { expect } = require('aegir/utils/chai') -const path = require('path') -const promisify = require('util').promisify -// @ts-ignore -const mkdirp = require('mkdirp') -// @ts-ignore -const rimraf = promisify(require('rimraf')) -const fs = require('fs') -const noop = () => {} -const fsReadFile = promisify(require('fs').readFile || noop) -const Key = require('interface-datastore').Key -const utils = require('interface-datastore').utils -const ShardingStore = require('datastore-core').ShardingDatastore -const sh = require('datastore-core').shard -const { isNode } = require('ipfs-utils/src/env') +import { expect } from 'aegir/utils/chai.js' +import path from 'path' +import { promisify } from 'util' +import mkdirp from 'mkdirp' +import rmrf from 'rimraf' +import fs from 'fs' +import { Key } from 'interface-datastore' +import { ShardingDatastore, shard } from 'datastore-core' +import { isNode, isElectronMain } from 'ipfs-utils/src/env.js' +import { interfaceDatastoreTests } from 'interface-datastore-tests' +import { DatastoreFs } from '../src/index.js' +import tempdir from 'ipfs-utils/src/temp-dir.js' + +const rimraf = promisify(rmrf) const utf8Encoder = new TextEncoder() -// @ts-ignore -const tests = require('interface-datastore-tests') -const FsStore = require('../src') - -describe('FsDatastore', () => { - if (!isNode) { - it('only supports node.js', () => { +describe('DatastoreFs', () => { + if (!(isNode || isElectronMain)) { + it('only supports node.js and electron main', () => { }) @@ -33,34 +26,34 @@ describe('FsDatastore', () => { describe('construction', () => { it('defaults - folder missing', () => { - const dir = utils.tmpdir() + const dir = tempdir() expect( - () => new FsStore(dir) + () => new DatastoreFs(dir) ).to.not.throw() }) it('defaults - folder exists', () => { - const dir = utils.tmpdir() + const dir = tempdir() mkdirp.sync(dir) expect( - () => new FsStore(dir) + () => new DatastoreFs(dir) ).to.not.throw() }) }) describe('open', () => { it('createIfMissing: false - folder missing', () => { - const dir = utils.tmpdir() - const store = new FsStore(dir, { createIfMissing: false }) + const dir = tempdir() + const store = new DatastoreFs(dir, { createIfMissing: false }) expect( () => store.open() ).to.throw() }) it('errorIfExists: true - folder exists', () => { - const dir = utils.tmpdir() + const dir = tempdir() mkdirp.sync(dir) - const store = new FsStore(dir, { errorIfExists: true }) + const store = new DatastoreFs(dir, { errorIfExists: true }) expect( () => store.open() ).to.throw() @@ -68,8 +61,8 @@ describe('FsDatastore', () => { }) it('_encode and _decode', () => { - const dir = utils.tmpdir() - const fs = new FsStore(dir) + const dir = tempdir() + const fs = new DatastoreFs(dir) expect( // @ts-ignore @@ -88,8 +81,8 @@ describe('FsDatastore', () => { }) it('deleting files', async () => { - const dir = utils.tmpdir() - const fs = new FsStore(dir) + const dir = tempdir() + const fs = new DatastoreFs(dir) const key = new Key('1234') await fs.put(key, Uint8Array.from([0, 1, 2, 3])) @@ -98,14 +91,14 @@ describe('FsDatastore', () => { try { await fs.get(key) throw new Error('Should have errored') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NOT_FOUND') } }) it('deleting non-existent files', async () => { - const dir = utils.tmpdir() - const fs = new FsStore(dir) + const dir = tempdir() + const fs = new DatastoreFs(dir) const key = new Key('5678') await fs.delete(key) @@ -119,21 +112,20 @@ describe('FsDatastore', () => { }) it('sharding files', async () => { - const dir = utils.tmpdir() - const fstore = new FsStore(dir) - const shard = new sh.NextToLast(2) - await ShardingStore.create(fstore, shard) + const dir = tempdir() + const fstore = new DatastoreFs(dir) + await ShardingDatastore.create(fstore, new shard.NextToLast(2)) - const file = await fsReadFile(path.join(dir, sh.SHARDING_FN)) + const file = await fs.promises.readFile(path.join(dir, shard.SHARDING_FN)) expect(file.toString()).to.be.eql('/repo/flatfs/shard/v1/next-to-last/2\n') - const readme = await fsReadFile(path.join(dir, sh.README_FN)) - expect(readme.toString()).to.be.eql(sh.readme) + const readme = await fs.promises.readFile(path.join(dir, shard.README_FN)) + expect(readme.toString()).to.be.eql(shard.readme) await rimraf(dir) }) it('query', async () => { - const fs = new FsStore(path.join(__dirname, 'test-repo', 'blocks')) + const fs = new DatastoreFs(path.join(process.cwd(), '/test/test-repo/blocks')) const res = [] for await (const q of fs.query({})) { res.push(q) @@ -142,11 +134,11 @@ describe('FsDatastore', () => { }) it('interop with go', async () => { - const repodir = path.join(__dirname, '/test-repo/blocks') - const fstore = new FsStore(repodir) + const repodir = path.join(process.cwd(), '/test/test-repo/blocks') + const fstore = new DatastoreFs(repodir) const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') const expected = fs.readFileSync(path.join(repodir, 'VO', key.toString() + '.data')) - const flatfs = await ShardingStore.open(fstore) + const flatfs = await ShardingDatastore.open(fstore) const res = await flatfs.get(key) const queryResult = flatfs.query({}) const results = [] @@ -156,11 +148,11 @@ describe('FsDatastore', () => { }) describe('interface-datastore', () => { - const dir = utils.tmpdir() + const dir = tempdir() - tests({ + interfaceDatastoreTests({ setup: () => { - return new FsStore(dir) + return new DatastoreFs(dir) }, teardown: () => { return rimraf(dir) @@ -169,11 +161,11 @@ describe('FsDatastore', () => { }) describe('interface-datastore (sharding(fs))', () => { - const dir = utils.tmpdir() + const dir = tempdir() - tests({ + interfaceDatastoreTests({ setup: () => { - return new ShardingStore(new FsStore(dir), new sh.NextToLast(2)) + return new ShardingDatastore(new DatastoreFs(dir), new shard.NextToLast(2)) }, teardown: () => { return rimraf(dir) @@ -182,8 +174,8 @@ describe('FsDatastore', () => { }) it('can survive concurrent writes', async () => { - const dir = utils.tmpdir() - const fstore = new FsStore(dir) + const dir = tempdir() + const fstore = new DatastoreFs(dir) const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') const value = utf8Encoder.encode('Hello world') @@ -197,8 +189,8 @@ describe('FsDatastore', () => { }) it('can survive putRaw and getRaw with an empty extension', async () => { - const dir = utils.tmpdir() - const fstore = new FsStore(dir, { + const dir = tempdir() + const fstore = new DatastoreFs(dir, { extension: '' }) const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') diff --git a/tsconfig.json b/tsconfig.json index fe3cbd6..376ad55 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { - "extends": "aegir/src/config/tsconfig.aegir.json", - "compilerOptions": { - "outDir": "dist" - }, - "include": [ - "test", - "src" - ] + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "types" + }, + "include": [ + "src", + "test" + ] } From 0816e883c93a079524c56063548a4e774b8b9d2e Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 8 Sep 2021 17:35:49 +0100 Subject: [PATCH 02/36] chore: update contributors --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 829850d..ec33822 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datastore-fs", - "version": "5.0.2", + "version": "6.0.0", "description": "Datastore implementation with file system backend", "leadMaintainer": "Alex Potsides ", "main": "src/index.js", From db993808050bffc5a94fe135721ea6c2d842c1ec Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 8 Sep 2021 17:35:50 +0100 Subject: [PATCH 03/36] chore: release version v6.0.0 --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0145ed..48e99f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# [6.0.0](https://github.com/ipfs/js-datastore-fs/compare/v5.0.2...v6.0.0) (2021-09-08) + + +### chore + +* convert to esm ([#103](https://github.com/ipfs/js-datastore-fs/issues/103)) ([314d130](https://github.com/ipfs/js-datastore-fs/commit/314d13051665c42be8a4bcc51c19ce2d5dd45346)) + + +### BREAKING CHANGES + +* deep imports are no longer possible + + + ## [5.0.2](https://github.com/ipfs/js-datastore-fs/compare/v5.0.1...v5.0.2) (2021-07-23) From 6d0e474915264e7e8b94e1689893a04261ea5f08 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 9 Sep 2021 07:36:10 +0100 Subject: [PATCH 04/36] chore: rename for consistency (#104) --- src/index.js | 2 +- test/index.spec.js | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/index.js b/src/index.js index e500b80..2c43354 100644 --- a/src/index.js +++ b/src/index.js @@ -63,7 +63,7 @@ async function writeFile (path, contents) { * * @implements {Datastore} */ -export class DatastoreFs extends BaseDatastore { +export class FsDatastore extends BaseDatastore { /** * @param {string} location * @param {{ createIfMissing?: boolean, errorIfExists?: boolean, extension?: string, putManyConcurrency?: number } | undefined} [opts] diff --git a/test/index.spec.js b/test/index.spec.js index ee5a383..cd0e7fa 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -9,13 +9,13 @@ import { Key } from 'interface-datastore' import { ShardingDatastore, shard } from 'datastore-core' import { isNode, isElectronMain } from 'ipfs-utils/src/env.js' import { interfaceDatastoreTests } from 'interface-datastore-tests' -import { DatastoreFs } from '../src/index.js' +import { FsDatastore } from '../src/index.js' import tempdir from 'ipfs-utils/src/temp-dir.js' const rimraf = promisify(rmrf) const utf8Encoder = new TextEncoder() -describe('DatastoreFs', () => { +describe('FsDatastore', () => { if (!(isNode || isElectronMain)) { it('only supports node.js and electron main', () => { @@ -28,7 +28,7 @@ describe('DatastoreFs', () => { it('defaults - folder missing', () => { const dir = tempdir() expect( - () => new DatastoreFs(dir) + () => new FsDatastore(dir) ).to.not.throw() }) @@ -36,7 +36,7 @@ describe('DatastoreFs', () => { const dir = tempdir() mkdirp.sync(dir) expect( - () => new DatastoreFs(dir) + () => new FsDatastore(dir) ).to.not.throw() }) }) @@ -44,7 +44,7 @@ describe('DatastoreFs', () => { describe('open', () => { it('createIfMissing: false - folder missing', () => { const dir = tempdir() - const store = new DatastoreFs(dir, { createIfMissing: false }) + const store = new FsDatastore(dir, { createIfMissing: false }) expect( () => store.open() ).to.throw() @@ -53,7 +53,7 @@ describe('DatastoreFs', () => { it('errorIfExists: true - folder exists', () => { const dir = tempdir() mkdirp.sync(dir) - const store = new DatastoreFs(dir, { errorIfExists: true }) + const store = new FsDatastore(dir, { errorIfExists: true }) expect( () => store.open() ).to.throw() @@ -62,7 +62,7 @@ describe('DatastoreFs', () => { it('_encode and _decode', () => { const dir = tempdir() - const fs = new DatastoreFs(dir) + const fs = new FsDatastore(dir) expect( // @ts-ignore @@ -82,7 +82,7 @@ describe('DatastoreFs', () => { it('deleting files', async () => { const dir = tempdir() - const fs = new DatastoreFs(dir) + const fs = new FsDatastore(dir) const key = new Key('1234') await fs.put(key, Uint8Array.from([0, 1, 2, 3])) @@ -98,7 +98,7 @@ describe('DatastoreFs', () => { it('deleting non-existent files', async () => { const dir = tempdir() - const fs = new DatastoreFs(dir) + const fs = new FsDatastore(dir) const key = new Key('5678') await fs.delete(key) @@ -113,7 +113,7 @@ describe('DatastoreFs', () => { it('sharding files', async () => { const dir = tempdir() - const fstore = new DatastoreFs(dir) + const fstore = new FsDatastore(dir) await ShardingDatastore.create(fstore, new shard.NextToLast(2)) const file = await fs.promises.readFile(path.join(dir, shard.SHARDING_FN)) @@ -125,7 +125,7 @@ describe('DatastoreFs', () => { }) it('query', async () => { - const fs = new DatastoreFs(path.join(process.cwd(), '/test/test-repo/blocks')) + const fs = new FsDatastore(path.join(process.cwd(), '/test/test-repo/blocks')) const res = [] for await (const q of fs.query({})) { res.push(q) @@ -135,7 +135,7 @@ describe('DatastoreFs', () => { it('interop with go', async () => { const repodir = path.join(process.cwd(), '/test/test-repo/blocks') - const fstore = new DatastoreFs(repodir) + const fstore = new FsDatastore(repodir) const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') const expected = fs.readFileSync(path.join(repodir, 'VO', key.toString() + '.data')) const flatfs = await ShardingDatastore.open(fstore) @@ -152,7 +152,7 @@ describe('DatastoreFs', () => { interfaceDatastoreTests({ setup: () => { - return new DatastoreFs(dir) + return new FsDatastore(dir) }, teardown: () => { return rimraf(dir) @@ -165,7 +165,7 @@ describe('DatastoreFs', () => { interfaceDatastoreTests({ setup: () => { - return new ShardingDatastore(new DatastoreFs(dir), new shard.NextToLast(2)) + return new ShardingDatastore(new FsDatastore(dir), new shard.NextToLast(2)) }, teardown: () => { return rimraf(dir) @@ -175,7 +175,7 @@ describe('DatastoreFs', () => { it('can survive concurrent writes', async () => { const dir = tempdir() - const fstore = new DatastoreFs(dir) + const fstore = new FsDatastore(dir) const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') const value = utf8Encoder.encode('Hello world') @@ -190,7 +190,7 @@ describe('DatastoreFs', () => { it('can survive putRaw and getRaw with an empty extension', async () => { const dir = tempdir() - const fstore = new DatastoreFs(dir, { + const fstore = new FsDatastore(dir, { extension: '' }) const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') From 957c0df27a109cffbef54dd34355984895f32e39 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 9 Sep 2021 07:37:34 +0100 Subject: [PATCH 05/36] docs: update readme --- README.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3701266..15719c5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# js-datastore-fs +# js-datastore-fs [![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) @@ -13,19 +13,16 @@ > Datastore implementation with file system backend. -## Lead Maintainer +## Lead Maintainer [Alex Potsides](https://github.com/achingbrain) -## Table of Contents +## Table of Contents -- [js-datastore-fs](#js-datastore-fs) - - [Lead Maintainer](#lead-maintainer) - - [Table of Contents](#table-of-contents) - - [Install](#install) - - [Usage](#usage) - - [Contribute](#contribute) - - [License](#license) +- [Install](#install) +- [Usage](#usage) +- [Contribute](#contribute) +- [License](#license) ## Install @@ -36,8 +33,9 @@ $ npm install datastore-fs ## Usage ```js -const FsStore = require('datastore-fs') -const store = new FsStore('path/to/store') +import { FSDatastore } from 'datastore-fs' + +const store = new FSDatastore('path/to/store') ``` ## Contribute From 8a487f3446329e7b58e472f1535b0681be0e8e6a Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 9 Sep 2021 07:38:41 +0100 Subject: [PATCH 06/36] chore: update contributors --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ec33822..a588bf5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datastore-fs", - "version": "6.0.0", + "version": "6.0.1", "description": "Datastore implementation with file system backend", "leadMaintainer": "Alex Potsides ", "main": "src/index.js", From e5cf7ea212c72c5a745c1bd7fdab25a099ab7fe3 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 9 Sep 2021 07:38:42 +0100 Subject: [PATCH 07/36] chore: release version v6.0.1 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48e99f9..be01ca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [6.0.1](https://github.com/ipfs/js-datastore-fs/compare/v6.0.0...v6.0.1) (2021-09-09) + + + # [6.0.0](https://github.com/ipfs/js-datastore-fs/compare/v5.0.2...v6.0.0) (2021-09-08) From 5e306e260727d6fdfdfbd75aae84ca48bb11592f Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 19 Jan 2022 13:06:21 +0000 Subject: [PATCH 08/36] chore: switch to unified ci (#113) BREAKING CHANGE: updates project config to use unified ci --- .github/dependabot.yml | 2 +- .github/workflows/js-test-and-release.yml | 152 +++++++++++++++++ .github/workflows/main.yml | 52 ------ LICENSE | 23 +-- LICENSE-APACHE | 5 + LICENSE-MIT | 19 +++ README.md | 6 +- package.json | 195 ++++++++++++++++------ src/index.js | 14 +- test/index.spec.js | 2 +- 10 files changed, 330 insertions(+), 140 deletions(-) create mode 100644 .github/workflows/js-test-and-release.yml delete mode 100644 .github/workflows/main.yml create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT diff --git a/.github/dependabot.yml b/.github/dependabot.yml index de46e32..290ad02 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,5 +4,5 @@ updates: directory: "/" schedule: interval: daily - time: "11:00" + time: "10:00" open-pull-requests-limit: 10 diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml new file mode 100644 index 0000000..8630dc5 --- /dev/null +++ b/.github/workflows/js-test-and-release.yml @@ -0,0 +1,152 @@ +name: test & maybe release +on: + push: + branches: + - master # with #262 - ${{{ github.default_branch }}} + pull_request: + branches: + - master # with #262 - ${{{ github.default_branch }}} + +jobs: + + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present lint + - run: npm run --if-present dep-check + + test-node: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [16] + fail-fast: true + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:node + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: node + + test-chrome: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: chrome + + test-chrome-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome-webworker + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: chrome-webworker + + test-firefox: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: firefox + + test-firefox-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox-webworker + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: firefox-webworker + + test-electron-main: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-main + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: electron-main + + test-electron-renderer: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-renderer + - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + with: + directory: ./.nyc_output + flags: electron-renderer + + release: + needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer] + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}' + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/docker-login@master + with: + docker-token: ${{ secrets.DOCKER_TOKEN }} + docker-username: ${{ secrets.DOCKER_USERNAME }} + - run: npm run --if-present release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 05587f3..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: ci -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: npm install - - run: npx aegir lint - - uses: gozala/typescript-error-reporter-action@v1.0.8 - - run: npx aegir build --no-bundle - - run: npx aegir dep-check - test-node: - needs: check - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-latest, ubuntu-latest, macos-latest] - node: [14, 16] - fail-fast: true - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node }} - - run: npm install - - run: npm run pretest - - run: npx nyc --reporter=lcov aegir test -t node -- --bail - - uses: codecov/codecov-action@v1 - test-electron-main: - needs: check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: npm install - - run: npm run pretest - - run: npx xvfb-maybe aegir test -t electron-main --bail -f dist/cjs/node-test/*js - test-electron-renderer: - needs: check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: npm install - - run: npm run pretest - - run: npx xvfb-maybe aegir test -t electron-renderer --bail -f dist/cjs/browser-test/*js diff --git a/LICENSE b/LICENSE index 15ede75..20ce483 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,4 @@ -MIT License +This project is dual licensed under MIT and Apache-2.0. -Copyright (c) 2017 IPFS - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..14478a3 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..72dc60d --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 15719c5..4c50240 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) -[![Build Status](https://flat.badgen.net/travis/ipfs/js-datastore-fs)](https://travis-ci.com/ipfs/js-datastore-fs) +[![Build Status](https://github.com/ipfs/js-datastore-fs/actions/workflows/js-test-and-release.yml/badge.svg?branch=master)](https://github.com/ipfs/js-datastore-fs/actions/workflows/js-test-and-release.yml) [![Codecov](https://codecov.io/gh/ipfs/js-datastore-fs/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-datastore-fs) [![Dependency Status](https://david-dm.org/ipfs/js-datastore-fs.svg?style=flat-square)](https://david-dm.org/ipfs/js-datastore-fs) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) @@ -13,10 +13,6 @@ > Datastore implementation with file system backend. -## Lead Maintainer - -[Alex Potsides](https://github.com/achingbrain) - ## Table of Contents - [Install](#install) diff --git a/package.json b/package.json index a588bf5..f9d85b7 100644 --- a/package.json +++ b/package.json @@ -2,50 +2,155 @@ "name": "datastore-fs", "version": "6.0.1", "description": "Datastore implementation with file system backend", - "leadMaintainer": "Alex Potsides ", + "author": "Friedel Ziegelmayer", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-datastore-fs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-datastore-fs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-datastore-fs/issues" + }, + "keywords": [ + "datastore", + "fs", + "interface", + "ipfs", + "key-value" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "main": "src/index.js", - "types": "types/src/index.d.ts", "type": "module", + "types": "types/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "types/*", + "types/src/*" + ], + "types/*": [ + "types/*", + "types/src/*" + ] + } + }, "files": [ "*", "!**/*.tsbuildinfo" ], - "browser": { - "fs": false, - "path": false, - "util": false + "exports": { + ".": { + "import": "./src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "chore", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Trivial Changes" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + [ + "@semantic-release/npm", + { + "pkgRoot": "dist" + } + ], + "@semantic-release/github", + "@semantic-release/git" + ] }, "scripts": { "clean": "rimraf dist types", "prepare": "aegir build --no-bundle && cp -R types dist", "lint": "aegir ts -p check && aegir lint", - "build": "aegir build --no-bundle", - "release": "aegir release --target node", - "release-minor": "aegir release --type minor --target node", - "release-major": "aegir release --type major --target node", - "pretest": "aegir build --esm-tests", + "build": "aegir build --esm-tests", + "release": "semantic-release", "test": "aegir test", + "test:node": "aegir test -t node", "dep-check": "aegir dep-check -i rimraf" }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-datastore-fs.git" - }, - "keywords": [ - "interface", - "key-value", - "ipfs", - "datastore", - "fs" - ], - "author": "Friedel Ziegelmayer", - "license": "MIT", - "bugs": { - "url": "https://github.com/ipfs/js-datastore-fs/issues" - }, - "homepage": "https://github.com/ipfs/js-datastore-fs#readme", "dependencies": { - "datastore-core": "^6.0.5", + "datastore-core": "^7.0.0", "fast-write-atomic": "^0.2.0", "interface-datastore": "^6.0.2", "it-glob": "^1.0.1", @@ -56,35 +161,17 @@ "devDependencies": { "@types/mkdirp": "^1.0.2", "@types/rimraf": "^3.0.2", - "aegir": "^35.0.3", + "aegir": "^36.1.3", "async-iterator-all": "^1.0.0", "detect-node": "^2.0.4", "interface-datastore-tests": "^2.0.3", - "ipfs-utils": "^8.1.3", + "ipfs-utils": "^9.0.4", "memdown": "^6.0.0", "rimraf": "^3.0.2" }, - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, - "contributors": [ - "achingbrain ", - "David Dias ", - "Friedel Ziegelmayer ", - "Jacob Heun ", - "Hugo Dias ", - "Pedro Teixeira ", - "Hector Sanjuan ", - "ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ ", - "Richard Schneider ", - "Vasco Santos ", - "Zane Starr ", - "Stephen Whitmore ", - "Matteo Collina ", - "Dmitriy Ryajov ", - "Bryan Stenson " - ] + "browser": { + "fs": false, + "path": false, + "util": false + } } diff --git a/src/index.js b/src/index.js index 2c43354..6d7c7df 100644 --- a/src/index.js +++ b/src/index.js @@ -92,7 +92,7 @@ export class FsDatastore extends BaseDatastore { throw Errors.dbOpenFailedError(new Error(`Datastore directory: ${this.path} already exists`)) } return Promise.resolve() - } catch (err) { + } catch (/** @type {any} */ err) { if (err.code === 'ERR_NOT_FOUND' && this.opts.createIfMissing) { mkdirp.sync(this.path, { fs: fs }) return Promise.resolve() @@ -177,7 +177,7 @@ export class FsDatastore extends BaseDatastore { try { await mkdirp(parts.dir, { fs: fs }) await writeFile(parts.file, val) - } catch (err) { + } catch (/** @type {any} */ err) { throw Errors.dbWriteFailedError(err) } } @@ -216,7 +216,7 @@ export class FsDatastore extends BaseDatastore { let data try { data = await fs.promises.readFile(file) - } catch (err) { + } catch (/** @type {any} */ err) { throw Errors.notFoundError(err) } return data @@ -233,7 +233,7 @@ export class FsDatastore extends BaseDatastore { let data try { data = await fs.promises.readFile(parts.file) - } catch (err) { + } catch (/** @type {any} */ err) { throw Errors.notFoundError(err) } return data @@ -282,7 +282,7 @@ export class FsDatastore extends BaseDatastore { try { await fs.promises.access(parts.file) - } catch (err) { + } catch (/** @type {any} */ err) { return false } return true @@ -298,7 +298,7 @@ export class FsDatastore extends BaseDatastore { const parts = this._encode(key) try { await fs.promises.unlink(parts.file) - } catch (err) { + } catch (/** @type {any} */ err) { if (err.code === 'ENOENT') { return } @@ -334,7 +334,7 @@ export class FsDatastore extends BaseDatastore { } yield pair - } catch (err) { + } catch (/** @type {any} */ err) { // if keys are removed from the datastore while the query is // running, we may encounter missing files. if (err.code !== 'ENOENT') { diff --git a/test/index.spec.js b/test/index.spec.js index cd0e7fa..d880022 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -106,7 +106,7 @@ describe('FsDatastore', () => { try { await fs.get(key) throw new Error('Should have errored') - } catch (err) { + } catch (/** @type {any} */ err) { expect(err.code).to.equal('ERR_NOT_FOUND') } }) From e591da7089334ec52346637c8ae3e8a0ffd76025 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 19 Jan 2022 13:17:09 +0000 Subject: [PATCH 09/36] chore(release): 7.0.0 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## [7.0.0](https://github.com/ipfs/js-datastore-fs/compare/v6.0.1...v7.0.0) (2022-01-19) ### ⚠ BREAKING CHANGES * updates project config to use unified ci ### Trivial Changes * switch to unified ci ([#113](https://github.com/ipfs/js-datastore-fs/issues/113)) ([5e306e2](https://github.com/ipfs/js-datastore-fs/commit/5e306e260727d6fdfdfbd75aae84ca48bb11592f)) --- CHANGELOG.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be01ca4..d5449d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [7.0.0](https://github.com/ipfs/js-datastore-fs/compare/v6.0.1...v7.0.0) (2022-01-19) + + +### ⚠ BREAKING CHANGES + +* updates project config to use unified ci + +### Trivial Changes + +* switch to unified ci ([#113](https://github.com/ipfs/js-datastore-fs/issues/113)) ([5e306e2](https://github.com/ipfs/js-datastore-fs/commit/5e306e260727d6fdfdfbd75aae84ca48bb11592f)) + ## [6.0.1](https://github.com/ipfs/js-datastore-fs/compare/v6.0.0...v6.0.1) (2021-09-09) @@ -226,6 +237,3 @@ # 0.1.0 (2017-03-15) - - - From 61ec88152e0719cc8472f4700555b23164696029 Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Fri, 28 Jan 2022 16:45:50 +0100 Subject: [PATCH 10/36] sync: update CI config files (#114) Co-authored-by: web3-bot --- .github/workflows/automerge.yml | 53 +++++++++++++++++++++++ .github/workflows/js-test-and-release.yml | 3 ++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/automerge.yml diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000..44fad65 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,53 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + +# Automatically merge pull requests opened by web3-bot, as soon as (and only if) all tests pass. +# This reduces the friction associated with updating with our workflows. + +on: [ pull_request ] +name: Automerge + +jobs: + automerge-check: + if: github.event.pull_request.user.login == 'web3-bot' + runs-on: ubuntu-latest + outputs: + status: ${{ steps.should-automerge.outputs.status }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Check if we should automerge + id: should-automerge + run: | + for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do + committer=$(git show --format=$'%ce' -s $commit) + echo "Committer: $committer" + if [[ "$committer" != "web3-bot@users.noreply.github.com" ]]; then + echo "Commit $commit wasn't committed by web3-bot, but by $committer." + echo "::set-output name=status::false" + exit + fi + done + echo "::set-output name=status::true" + automerge: + needs: automerge-check + runs-on: ubuntu-latest + # The check for the user is redundant here, as this job depends on the automerge-check job, + # but it prevents this job from spinning up, just to be skipped shortly after. + if: github.event.pull_request.user.login == 'web3-bot' && needs.automerge-check.outputs.status == 'true' + steps: + - name: Wait on tests + uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2 + with: + ref: ${{ github.event.pull_request.head.sha }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 + running-workflow-name: 'automerge' # the name of this job + - name: Merge PR + uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + MERGE_LABELS: "" + MERGE_METHOD: "squash" + MERGE_DELETE_BRANCH: true diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 8630dc5..1d6c6eb 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -1,3 +1,6 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + name: test & maybe release on: push: From 229df798b9e48f782c391c9206c126b4bb8365bf Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Mon, 4 Apr 2022 18:42:48 +0200 Subject: [PATCH 11/36] update .github/workflows/automerge.yml (#115) --- .github/workflows/automerge.yml | 50 +++------------------------------ 1 file changed, 4 insertions(+), 46 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 44fad65..3833fc2 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -1,53 +1,11 @@ # File managed by web3-bot. DO NOT EDIT. # See https://github.com/protocol/.github/ for details. -# Automatically merge pull requests opened by web3-bot, as soon as (and only if) all tests pass. -# This reduces the friction associated with updating with our workflows. - -on: [ pull_request ] name: Automerge +on: [ pull_request ] jobs: - automerge-check: - if: github.event.pull_request.user.login == 'web3-bot' - runs-on: ubuntu-latest - outputs: - status: ${{ steps.should-automerge.outputs.status }} - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Check if we should automerge - id: should-automerge - run: | - for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do - committer=$(git show --format=$'%ce' -s $commit) - echo "Committer: $committer" - if [[ "$committer" != "web3-bot@users.noreply.github.com" ]]; then - echo "Commit $commit wasn't committed by web3-bot, but by $committer." - echo "::set-output name=status::false" - exit - fi - done - echo "::set-output name=status::true" automerge: - needs: automerge-check - runs-on: ubuntu-latest - # The check for the user is redundant here, as this job depends on the automerge-check job, - # but it prevents this job from spinning up, just to be skipped shortly after. - if: github.event.pull_request.user.login == 'web3-bot' && needs.automerge-check.outputs.status == 'true' - steps: - - name: Wait on tests - uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2 - with: - ref: ${{ github.event.pull_request.head.sha }} - repo-token: ${{ secrets.GITHUB_TOKEN }} - wait-interval: 10 - running-workflow-name: 'automerge' # the name of this job - - name: Merge PR - uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1 - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - MERGE_LABELS: "" - MERGE_METHOD: "squash" - MERGE_DELETE_BRANCH: true + uses: protocol/.github/.github/workflows/automerge.yml@master + with: + job: 'automerge' From dff3d23ecbbb392bc38dcbf36d0fc29bc960742b Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Wed, 1 Jun 2022 11:36:24 +0200 Subject: [PATCH 12/36] update .github/workflows/js-test-and-release.yml (#124) --- .github/workflows/js-test-and-release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 1d6c6eb..fb87505 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -38,7 +38,7 @@ jobs: node-version: ${{ matrix.node }} - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:node - - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: directory: ./.nyc_output flags: node @@ -53,7 +53,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:chrome - - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: directory: ./.nyc_output flags: chrome @@ -68,7 +68,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:chrome-webworker - - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: directory: ./.nyc_output flags: chrome-webworker @@ -83,7 +83,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:firefox - - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: directory: ./.nyc_output flags: firefox @@ -98,7 +98,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:firefox-webworker - - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: directory: ./.nyc_output flags: firefox-webworker @@ -113,7 +113,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npx xvfb-maybe npm run --if-present test:electron-main - - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: directory: ./.nyc_output flags: electron-main @@ -128,7 +128,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npx xvfb-maybe npm run --if-present test:electron-renderer - - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: directory: ./.nyc_output flags: electron-renderer From 2134c6c76ff836306cb8412f2a3d5ad23b6fd7df Mon Sep 17 00:00:00 2001 From: "ipfs-mgmt-read-write[bot]" <104492829+ipfs-mgmt-read-write[bot]@users.noreply.github.com> Date: Mon, 13 Jun 2022 12:54:51 +0000 Subject: [PATCH 13/36] Add .github/workflows/stale.yml --- .github/workflows/stale.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..297540b --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,26 @@ +name: Close and mark stale issue + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.' + close-issue-message: 'This issue was closed because it is missing author input.' + stale-issue-label: 'kind/stale' + any-of-labels: 'need/author-input' + exempt-issue-labels: 'need/triage,need/community-input,need/maintainer-input,need/maintainers-input,need/analysis' + days-before-issue-stale: 6 + days-before-issue-close: 7 + enable-statistics: true From cd74d295e5aeedbcc3fec649dfdb853f456a4924 Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Thu, 16 Jun 2022 15:21:14 +0200 Subject: [PATCH 14/36] update .github/workflows/js-test-and-release.yml (#128) --- .github/workflows/js-test-and-release.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index fb87505..8030ec6 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -40,7 +40,6 @@ jobs: - run: npm run --if-present test:node - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: - directory: ./.nyc_output flags: node test-chrome: @@ -55,7 +54,6 @@ jobs: - run: npm run --if-present test:chrome - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: - directory: ./.nyc_output flags: chrome test-chrome-webworker: @@ -70,7 +68,6 @@ jobs: - run: npm run --if-present test:chrome-webworker - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: - directory: ./.nyc_output flags: chrome-webworker test-firefox: @@ -85,7 +82,6 @@ jobs: - run: npm run --if-present test:firefox - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: - directory: ./.nyc_output flags: firefox test-firefox-webworker: @@ -100,7 +96,6 @@ jobs: - run: npm run --if-present test:firefox-webworker - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: - directory: ./.nyc_output flags: firefox-webworker test-electron-main: @@ -115,7 +110,6 @@ jobs: - run: npx xvfb-maybe npm run --if-present test:electron-main - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: - directory: ./.nyc_output flags: electron-main test-electron-renderer: @@ -130,7 +124,6 @@ jobs: - run: npx xvfb-maybe npm run --if-present test:electron-renderer - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: - directory: ./.nyc_output flags: electron-renderer release: From ac9fd0d1b492bef7d8807e4bc0b6810b2ddf12d2 Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 27 Jun 2022 10:46:37 +0000 Subject: [PATCH 15/36] Update .github/workflows/stale.yml --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 297540b..6f6d895 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -20,7 +20,7 @@ jobs: close-issue-message: 'This issue was closed because it is missing author input.' stale-issue-label: 'kind/stale' any-of-labels: 'need/author-input' - exempt-issue-labels: 'need/triage,need/community-input,need/maintainer-input,need/maintainers-input,need/analysis' + exempt-issue-labels: 'need/triage,need/community-input,need/maintainer-input,need/maintainers-input,need/analysis,status/blocked,status/in-progress,status/ready,status/deferred,status/inactive' days-before-issue-stale: 6 days-before-issue-close: 7 enable-statistics: true From 94f7d369a9b3285d7be79e794f90fdcc1e80f704 Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 21 Jul 2022 09:54:56 +0000 Subject: [PATCH 16/36] chore: Update .github/workflows/stale.yml [skip ci] From 5896e57fbba4ed47e0ede2ae140f8e757c928148 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Fri, 12 Aug 2022 10:04:21 +0100 Subject: [PATCH 17/36] feat!: publish module as ESM only (#139) BREAKING CHANGE: this module used to be dual published as CJS/ESM, now it is just ESM --- .github/dependabot.yml | 3 +++ README.md | 39 ++++++++++++++++------------ package.json | 58 ++++++++++++++++++++++-------------------- test/index.spec.js | 2 +- tsconfig.json | 3 ++- 5 files changed, 60 insertions(+), 45 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 290ad02..0bc3b42 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,6 @@ updates: interval: daily time: "10:00" open-pull-requests-limit: 10 + commit-message: + prefix: "deps" + prefix-development: "deps(dev)" diff --git a/README.md b/README.md index 4c50240..65c9cd2 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,25 @@ -# js-datastore-fs +# datastore-fs -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) -[![Build Status](https://github.com/ipfs/js-datastore-fs/actions/workflows/js-test-and-release.yml/badge.svg?branch=master)](https://github.com/ipfs/js-datastore-fs/actions/workflows/js-test-and-release.yml) -[![Codecov](https://codecov.io/gh/ipfs/js-datastore-fs/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-datastore-fs) -[![Dependency Status](https://david-dm.org/ipfs/js-datastore-fs.svg?style=flat-square)](https://david-dm.org/ipfs/js-datastore-fs) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) -![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square) -![](https://img.shields.io/badge/Node.js-%3E%3D8.0.0-orange.svg?style=flat-square) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-datastore-fs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-datastore-fs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-datastore-fs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-datastore-fs/actions/workflows/js-test-and-release.yml) -> Datastore implementation with file system backend. +> Datastore implementation with file system backend -## Table of Contents +## Table of contents - [Install](#install) - [Usage](#usage) - [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute-1) ## Install -``` -$ npm install datastore-fs +```console +$ npm i datastore-fs ``` ## Usage @@ -44,4 +40,15 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c ## License -[MIT](LICENSE) +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-importer/issues)! + +This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/package.json b/package.json index f9d85b7..13a41a7 100644 --- a/package.json +++ b/package.json @@ -23,27 +23,33 @@ "node": ">=16.0.0", "npm": ">=7.0.0" }, - "main": "src/index.js", "type": "module", - "types": "types/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ - "types/*", - "types/src/*" + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" ], - "types/*": [ - "types/*", - "types/src/*" + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" ] } }, "files": [ - "*", + "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -80,15 +86,15 @@ "release": "patch" }, { - "type": "chore", + "type": "docs", "release": "patch" }, { - "type": "docs", + "type": "test", "release": "patch" }, { - "type": "test", + "type": "deps", "release": "patch" }, { @@ -118,7 +124,11 @@ }, { "type": "docs", - "section": "Trivial Changes" + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" }, { "type": "test", @@ -129,30 +139,24 @@ } ], "@semantic-release/changelog", - [ - "@semantic-release/npm", - { - "pkgRoot": "dist" - } - ], + "@semantic-release/npm", "@semantic-release/github", "@semantic-release/git" ] }, "scripts": { - "clean": "rimraf dist types", - "prepare": "aegir build --no-bundle && cp -R types dist", - "lint": "aegir ts -p check && aegir lint", - "build": "aegir build --esm-tests", - "release": "semantic-release", + "clean": "aegir clean", + "lint": "aegir lint", + "build": "aegir build", + "release": "aegir release", "test": "aegir test", "test:node": "aegir test -t node", "dep-check": "aegir dep-check -i rimraf" }, "dependencies": { - "datastore-core": "^7.0.0", + "datastore-core": "^8.0.1", "fast-write-atomic": "^0.2.0", - "interface-datastore": "^6.0.2", + "interface-datastore": "^7.0.0", "it-glob": "^1.0.1", "it-map": "^1.0.5", "it-parallel-batch": "^1.0.9", @@ -161,10 +165,10 @@ "devDependencies": { "@types/mkdirp": "^1.0.2", "@types/rimraf": "^3.0.2", - "aegir": "^36.1.3", + "aegir": "^37.5.0", "async-iterator-all": "^1.0.0", "detect-node": "^2.0.4", - "interface-datastore-tests": "^2.0.3", + "interface-datastore-tests": "^3.0.0", "ipfs-utils": "^9.0.4", "memdown": "^6.0.0", "rimraf": "^3.0.2" diff --git a/test/index.spec.js b/test/index.spec.js index d880022..ae5a8e5 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -1,5 +1,5 @@ /* eslint-env mocha */ -import { expect } from 'aegir/utils/chai.js' +import { expect } from 'aegir/chai' import path from 'path' import { promisify } from 'util' import mkdirp from 'mkdirp' diff --git a/tsconfig.json b/tsconfig.json index 376ad55..8708ca6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "aegir/src/config/tsconfig.aegir.json", "compilerOptions": { - "outDir": "types" + "outDir": "dist", + "emitDeclarationOnly": true }, "include": [ "src", From 3c4542efe859814c0bf48a2198b55dd0698f5fe1 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 12 Aug 2022 09:10:59 +0000 Subject: [PATCH 18/36] chore(release): 8.0.0 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## [8.0.0](https://github.com/ipfs/js-datastore-fs/compare/v7.0.0...v8.0.0) (2022-08-12) ### ⚠ BREAKING CHANGES * this module used to be dual published as CJS/ESM, now it is just ESM ### Features * publish module as ESM only ([#139](https://github.com/ipfs/js-datastore-fs/issues/139)) ([5896e57](https://github.com/ipfs/js-datastore-fs/commit/5896e57fbba4ed47e0ede2ae140f8e757c928148)) ### Trivial Changes * Update .github/workflows/stale.yml [skip ci] ([94f7d36](https://github.com/ipfs/js-datastore-fs/commit/94f7d369a9b3285d7be79e794f90fdcc1e80f704)) --- CHANGELOG.md | 16 ++++++++++++++++ package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5449d0..d4115b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## [8.0.0](https://github.com/ipfs/js-datastore-fs/compare/v7.0.0...v8.0.0) (2022-08-12) + + +### ⚠ BREAKING CHANGES + +* this module used to be dual published as CJS/ESM, now it is just ESM + +### Features + +* publish module as ESM only ([#139](https://github.com/ipfs/js-datastore-fs/issues/139)) ([5896e57](https://github.com/ipfs/js-datastore-fs/commit/5896e57fbba4ed47e0ede2ae140f8e757c928148)) + + +### Trivial Changes + +* Update .github/workflows/stale.yml [skip ci] ([94f7d36](https://github.com/ipfs/js-datastore-fs/commit/94f7d369a9b3285d7be79e794f90fdcc1e80f704)) + ## [7.0.0](https://github.com/ipfs/js-datastore-fs/compare/v6.0.1...v7.0.0) (2022-01-19) diff --git a/package.json b/package.json index 13a41a7..7459993 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datastore-fs", - "version": "6.0.1", + "version": "8.0.0", "description": "Datastore implementation with file system backend", "author": "Friedel Ziegelmayer", "license": "Apache-2.0 OR MIT", From 36815594906ae4a78d5c58c375cdba03cd44859f Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Tue, 23 Aug 2022 19:08:45 +0200 Subject: [PATCH 19/36] update .github/workflows/js-test-and-release.yml (#140) --- .github/workflows/js-test-and-release.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 8030ec6..b02826b 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -15,7 +15,7 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v2 with: node-version: lts/* @@ -32,7 +32,7 @@ jobs: node: [16] fail-fast: true steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} @@ -46,7 +46,7 @@ jobs: needs: check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v2 with: node-version: lts/* @@ -60,7 +60,7 @@ jobs: needs: check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v2 with: node-version: lts/* @@ -74,7 +74,7 @@ jobs: needs: check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v2 with: node-version: lts/* @@ -88,7 +88,7 @@ jobs: needs: check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v2 with: node-version: lts/* @@ -102,7 +102,7 @@ jobs: needs: check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v2 with: node-version: lts/* @@ -116,7 +116,7 @@ jobs: needs: check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v2 with: node-version: lts/* @@ -131,7 +131,7 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - uses: actions/setup-node@v2 From d194197ab37a9162afad6b9a1a689c165063e559 Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Mon, 5 Sep 2022 17:07:26 +0200 Subject: [PATCH 20/36] update .github/workflows/js-test-and-release.yml (#141) --- .github/workflows/js-test-and-release.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index b02826b..65d30bd 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master @@ -33,7 +33,7 @@ jobs: fail-fast: true steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} - uses: ipfs/aegir/actions/cache-node-modules@master @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master @@ -61,7 +61,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master @@ -89,7 +89,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master @@ -103,7 +103,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master @@ -117,7 +117,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master @@ -134,7 +134,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master From 196b5675a57e219a8073b114acb6c7613a43da71 Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Mon, 14 Nov 2022 16:19:42 +0100 Subject: [PATCH 21/36] update .github/workflows/js-test-and-release.yml (#145) --- .github/workflows/js-test-and-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 65d30bd..ed17349 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -7,8 +7,6 @@ on: branches: - master # with #262 - ${{{ github.default_branch }}} pull_request: - branches: - - master # with #262 - ${{{ github.default_branch }}} jobs: From 8ba510a5f7c9bc7089100527d9b40ba122a8e4fa Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Fri, 25 Nov 2022 19:13:26 +0100 Subject: [PATCH 22/36] update .github/workflows/js-test-and-release.yml (#146) --- .github/workflows/js-test-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index ed17349..c6897e3 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -27,7 +27,7 @@ jobs: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] - node: [16] + node: [lts/*] fail-fast: true steps: - uses: actions/checkout@v3 From bd41afa9c2131a6a0a94e2e2d450348df96c055e Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Wed, 14 Dec 2022 12:44:03 +0100 Subject: [PATCH 23/36] update .github/workflows/js-test-and-release.yml (#148) --- .github/workflows/js-test-and-release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index c6897e3..da74793 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -144,3 +144,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - run: npm run --if-present docs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 55660e758c1bcaed693ada1ff73e753f4581757b Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Thu, 15 Dec 2022 10:03:37 +0100 Subject: [PATCH 24/36] update .github/workflows/js-test-and-release.yml (#149) --- .github/workflows/js-test-and-release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index da74793..c6897e3 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -144,6 +144,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - run: npm run --if-present docs - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 584f984e8f053dba91d0f42f6ad1c9a4e40cba63 Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Wed, 1 Feb 2023 18:06:13 +0100 Subject: [PATCH 25/36] update .github/workflows/js-test-and-release.yml (#159) --- .github/workflows/js-test-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index c6897e3..55c45a8 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -5,7 +5,7 @@ name: test & maybe release on: push: branches: - - master # with #262 - ${{{ github.default_branch }}} + - master pull_request: jobs: @@ -127,7 +127,7 @@ jobs: release: needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer] runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}' + if: github.event_name == 'push' && github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v3 with: From fecfa40f534523d9439e3cceb59cff6f19aad040 Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:38:24 +0100 Subject: [PATCH 26/36] update .github/workflows/js-test-and-release.yml (#162) --- .github/workflows/js-test-and-release.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 55c45a8..ef28bb0 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -36,7 +36,7 @@ jobs: node-version: ${{ matrix.node }} - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:node - - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 with: flags: node @@ -50,7 +50,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:chrome - - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 with: flags: chrome @@ -64,7 +64,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:chrome-webworker - - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 with: flags: chrome-webworker @@ -78,7 +78,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:firefox - - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 with: flags: firefox @@ -92,7 +92,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present test:firefox-webworker - - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 with: flags: firefox-webworker @@ -106,7 +106,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npx xvfb-maybe npm run --if-present test:electron-main - - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 with: flags: electron-main @@ -120,7 +120,7 @@ jobs: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npx xvfb-maybe npm run --if-present test:electron-renderer - - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 with: flags: electron-renderer @@ -142,5 +142,5 @@ jobs: docker-username: ${{ secrets.DOCKER_USERNAME }} - run: npm run --if-present release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From 1adb27e0999539c8c60a5e2d13c7176297c173a9 Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:03:58 +0100 Subject: [PATCH 27/36] update .github/workflows/js-test-and-release.yml (#168) Co-authored-by: web3-bot --- .github/workflows/js-test-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index ef28bb0..74b2386 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -142,5 +142,5 @@ jobs: docker-username: ${{ secrets.DOCKER_USERNAME }} - run: npm run --if-present release env: - GITHUB_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN || github.token }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From 2ef5f5cf021b1876cb83c53bafebb5f153c77462 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Mon, 13 Mar 2023 20:46:27 +0100 Subject: [PATCH 28/36] deps!: update interface-datastore to 8.x.x (#180) - Updates to latest interface - Converts project to typescript BREAKING CHANGE: interface-datastore 8.x.x has removed the open and close methods as these are implementation specific --- package.json | 39 +- src/index.js | 365 ------------------ src/index.ts | 281 ++++++++++++++ test/index.spec.js | 205 ---------- test/index.spec.ts | 173 +++++++++ ...HSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data | 4 - ...DDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data | 23 -- ...B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data | Bin 101 -> 0 bytes ...7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data | 55 --- ...SIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data | 3 - ...YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data | Bin 309 -> 0 bytes ...LZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data | 4 - ...774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data | Bin 10807 -> 0 bytes ...LJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data | 24 -- ...VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data | 4 - ...WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data | Bin 10765 -> 0 bytes ...AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data | 8 - ...TJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data | 9 - ...33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data | 3 - ...HTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data | Bin 10765 -> 0 bytes ...57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data | 0 ...JOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data | 28 -- ...LP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data | 3 - test/test-repo/blocks/SHARDING | 1 - ...ANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data | Bin 10891 -> 0 bytes ...NH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data | Bin 10765 -> 0 bytes ...LOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data | 114 ------ ...2BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data | 2 - ...2FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data | Bin 10849 -> 0 bytes test/test-repo/blocks/_README | 30 -- test/test-repo/config | 88 ----- test/test-repo/datastore/000002.ldb | Bin 211 -> 0 bytes test/test-repo/datastore/000005.ldb | Bin 1120 -> 0 bytes test/test-repo/datastore/CURRENT | 1 - test/test-repo/datastore/LOCK | 0 test/test-repo/datastore/LOG | 3 - test/test-repo/datastore/LOG.old | 3 - test/test-repo/datastore/MANIFEST-000036 | Bin 201 -> 0 bytes test/test-repo/version | 1 - tsconfig.json | 3 +- 40 files changed, 471 insertions(+), 1006 deletions(-) delete mode 100644 src/index.js create mode 100644 src/index.ts delete mode 100644 test/index.spec.js create mode 100644 test/index.spec.ts delete mode 100644 test/test-repo/blocks/2F/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data delete mode 100644 test/test-repo/blocks/5V/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data delete mode 100644 test/test-repo/blocks/75/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data delete mode 100644 test/test-repo/blocks/7J/CIQKKLBWAIBQZOIS5X7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data delete mode 100644 test/test-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data delete mode 100644 test/test-repo/blocks/AP/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data delete mode 100644 test/test-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data delete mode 100644 test/test-repo/blocks/CY/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data delete mode 100644 test/test-repo/blocks/FN/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data delete mode 100644 test/test-repo/blocks/GQ/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data delete mode 100644 test/test-repo/blocks/HD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data delete mode 100644 test/test-repo/blocks/IL/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data delete mode 100644 test/test-repo/blocks/LG/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data delete mode 100644 test/test-repo/blocks/O6/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data delete mode 100644 test/test-repo/blocks/QF/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data delete mode 100644 test/test-repo/blocks/QV/CIQOHMGEIKMPYHAUTL57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data delete mode 100644 test/test-repo/blocks/R3/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data delete mode 100644 test/test-repo/blocks/S5/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data delete mode 100644 test/test-repo/blocks/SHARDING delete mode 100644 test/test-repo/blocks/TW/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data delete mode 100644 test/test-repo/blocks/UN/CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data delete mode 100644 test/test-repo/blocks/VO/CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data delete mode 100644 test/test-repo/blocks/X3/CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data delete mode 100644 test/test-repo/blocks/XO/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data delete mode 100644 test/test-repo/blocks/_README delete mode 100644 test/test-repo/config delete mode 100644 test/test-repo/datastore/000002.ldb delete mode 100644 test/test-repo/datastore/000005.ldb delete mode 100644 test/test-repo/datastore/CURRENT delete mode 100644 test/test-repo/datastore/LOCK delete mode 100644 test/test-repo/datastore/LOG delete mode 100644 test/test-repo/datastore/LOG.old delete mode 100644 test/test-repo/datastore/MANIFEST-000036 delete mode 100644 test/test-repo/version diff --git a/package.json b/package.json index 7459993..708b112 100644 --- a/package.json +++ b/package.json @@ -147,35 +147,28 @@ "scripts": { "clean": "aegir clean", "lint": "aegir lint", - "build": "aegir build", + "build": "aegir build --bundle false", "release": "aegir release", - "test": "aegir test", + "test": "aegir test -t node -t electron-main", "test:node": "aegir test -t node", - "dep-check": "aegir dep-check -i rimraf" + "test:electron-main": "aegir test -t electron-main", + "dep-check": "aegir dep-check", + "docs": "aegir docs" }, "dependencies": { - "datastore-core": "^8.0.1", + "datastore-core": "^9.0.1", "fast-write-atomic": "^0.2.0", - "interface-datastore": "^7.0.0", - "it-glob": "^1.0.1", - "it-map": "^1.0.5", - "it-parallel-batch": "^1.0.9", - "mkdirp": "^1.0.4" + "interface-datastore": "^8.0.0", + "interface-store": "^4.0.0", + "it-glob": "^2.0.1", + "it-map": "^2.0.1", + "it-parallel-batch": "^2.0.1" }, "devDependencies": { - "@types/mkdirp": "^1.0.2", - "@types/rimraf": "^3.0.2", - "aegir": "^37.5.0", - "async-iterator-all": "^1.0.0", - "detect-node": "^2.0.4", - "interface-datastore-tests": "^3.0.0", - "ipfs-utils": "^9.0.4", - "memdown": "^6.0.0", - "rimraf": "^3.0.2" - }, - "browser": { - "fs": false, - "path": false, - "util": false + "@types/mkdirp": "^2.0.0", + "@types/rimraf": "^4.0.5", + "aegir": "^38.1.7", + "interface-datastore-tests": "^4.0.0", + "ipfs-utils": "^9.0.4" } } diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 6d7c7df..0000000 --- a/src/index.js +++ /dev/null @@ -1,365 +0,0 @@ -import fs from 'fs' -import glob from 'it-glob' -import mkdirp from 'mkdirp' -import path from 'path' -import { promisify } from 'util' -import { - Key -} from 'interface-datastore' -import { - BaseDatastore, Errors -} from 'datastore-core' -import map from 'it-map' -import parallel from 'it-parallel-batch' -// @ts-ignore no types -import fwa from 'fast-write-atomic' - -// @ts-ignore -const writeAtomic = promisify(fwa) - -/** - * @typedef {import('interface-datastore').Datastore} Datastore - * @typedef {import('interface-datastore').Pair} Pair - * @typedef {import('interface-datastore').Query} Query - * @typedef {import('interface-datastore').KeyQuery} KeyQuery - */ - -/** - * @template TEntry - * @typedef {import('interface-store').AwaitIterable} AwaitIterable - */ - -/** - * Write a file atomically - * - * @param {string} path - * @param {Uint8Array} contents - */ -async function writeFile (path, contents) { - try { - await writeAtomic(path, contents) - } catch (/** @type {any} */ err) { - if (err.code === 'EPERM' && err.syscall === 'rename') { - // fast-write-atomic writes a file to a temp location before renaming it. - // On Windows, if the final file already exists this error is thrown. - // No such error is thrown on Linux/Mac - // Make sure we can read & write to this file - await fs.promises.access(path, fs.constants.F_OK | fs.constants.W_OK) - - // The file was created by another context - this means there were - // attempts to write the same block by two different function calls - return - } - - throw err - } -} - -/** - * A datastore backed by the file system. - * - * Keys need to be sanitized before use, as they are written - * to the file system as is. - * - * @implements {Datastore} - */ -export class FsDatastore extends BaseDatastore { - /** - * @param {string} location - * @param {{ createIfMissing?: boolean, errorIfExists?: boolean, extension?: string, putManyConcurrency?: number } | undefined} [opts] - */ - constructor (location, opts) { - super() - - this.path = path.resolve(location) - this.opts = Object.assign({}, { - createIfMissing: true, - errorIfExists: false, - extension: '.data', - deleteManyConcurrency: 50, - getManyConcurrency: 50, - putManyConcurrency: 50 - }, opts) - } - - open () { - try { - if (!fs.existsSync(this.path)) { - throw Errors.notFoundError(new Error(`Datastore directory: ${this.path} does not exist`)) - } - - if (this.opts.errorIfExists) { - throw Errors.dbOpenFailedError(new Error(`Datastore directory: ${this.path} already exists`)) - } - return Promise.resolve() - } catch (/** @type {any} */ err) { - if (err.code === 'ERR_NOT_FOUND' && this.opts.createIfMissing) { - mkdirp.sync(this.path, { fs: fs }) - return Promise.resolve() - } - - throw err - } - } - - close () { - return Promise.resolve() - } - - /** - * Calculate the directory and file name for a given key. - * - * @private - * @param {Key} key - * @returns {{dir:string, file:string}} - */ - _encode (key) { - const parent = key.parent().toString() - const dir = path.join(this.path, parent) - const name = key.toString().slice(parent.length) - const file = path.join(dir, name + this.opts.extension) - - return { - dir: dir, - file: file - } - } - - /** - * Calculate the original key, given the file name. - * - * @private - * @param {string} file - * @returns {Key} - */ - _decode (file) { - const ext = this.opts.extension - if (path.extname(file) !== ext) { - throw new Error(`Invalid extension: ${path.extname(file)}`) - } - - const keyname = file - .slice(this.path.length, -ext.length) - .split(path.sep) - .join('/') - return new Key(keyname) - } - - /** - * Write to the file system without extension. - * - * @param {Key} key - * @param {Uint8Array} val - * @returns {Promise} - */ - async putRaw (key, val) { - const parts = this._encode(key) - let file = parts.file - - if (this.opts.extension.length) { - file = parts.file.slice(0, -this.opts.extension.length) - } - - await mkdirp(parts.dir, { fs: fs }) - await writeFile(file, val) - } - - /** - * Store the given value under the key - * - * @param {Key} key - * @param {Uint8Array} val - * @returns {Promise} - */ - async put (key, val) { - const parts = this._encode(key) - - try { - await mkdirp(parts.dir, { fs: fs }) - await writeFile(parts.file, val) - } catch (/** @type {any} */ err) { - throw Errors.dbWriteFailedError(err) - } - } - - /** - * @param {AwaitIterable} source - * @returns {AsyncIterable} - */ - async * putMany (source) { - yield * parallel( - map(source, ({ key, value }) => { - return async () => { - await this.put(key, value) - - return { key, value } - } - }), - this.opts.putManyConcurrency - ) - } - - /** - * Read from the file system without extension. - * - * @param {Key} key - * @returns {Promise} - */ - async getRaw (key) { - const parts = this._encode(key) - let file = parts.file - - if (this.opts.extension.length) { - file = file.slice(0, -this.opts.extension.length) - } - - let data - try { - data = await fs.promises.readFile(file) - } catch (/** @type {any} */ err) { - throw Errors.notFoundError(err) - } - return data - } - - /** - * Read from the file system. - * - * @param {Key} key - * @returns {Promise} - */ - async get (key) { - const parts = this._encode(key) - let data - try { - data = await fs.promises.readFile(parts.file) - } catch (/** @type {any} */ err) { - throw Errors.notFoundError(err) - } - return data - } - - /** - * @param {AwaitIterable} source - * @returns {AsyncIterable} - */ - async * getMany (source) { - yield * parallel( - map(source, key => { - return async () => { - return this.get(key) - } - }), - this.opts.getManyConcurrency - ) - } - - /** - * @param {AwaitIterable} source - * @returns {AsyncIterable} - */ - async * deleteMany (source) { - yield * parallel( - map(source, key => { - return async () => { - await this.delete(key) - - return key - } - }), - this.opts.deleteManyConcurrency - ) - } - - /** - * Check for the existence of the given key. - * - * @param {Key} key - * @returns {Promise} - */ - async has (key) { - const parts = this._encode(key) - - try { - await fs.promises.access(parts.file) - } catch (/** @type {any} */ err) { - return false - } - return true - } - - /** - * Delete the record under the given key. - * - * @param {Key} key - * @returns {Promise} - */ - async delete (key) { - const parts = this._encode(key) - try { - await fs.promises.unlink(parts.file) - } catch (/** @type {any} */ err) { - if (err.code === 'ENOENT') { - return - } - - throw Errors.dbDeleteFailedError(err) - } - } - - /** - * @param {Query} q - */ - async * _all (q) { - let prefix = q.prefix || '**' - - // strip leading slashes - prefix = prefix.replace(/^\/+/, '') - - const pattern = `${prefix}/*${this.opts.extension}` - .split(path.sep) - .join('/') - const files = glob(this.path, pattern, { - absolute: true - }) - - for await (const file of files) { - try { - const buf = await fs.promises.readFile(file) - - /** @type {Pair} */ - const pair = { - key: this._decode(file), - value: buf - } - - yield pair - } catch (/** @type {any} */ err) { - // if keys are removed from the datastore while the query is - // running, we may encounter missing files. - if (err.code !== 'ENOENT') { - throw err - } - } - } - } - - /** - * @param {KeyQuery} q - */ - async * _allKeys (q) { - let prefix = q.prefix || '**' - - // strip leading slashes - prefix = prefix.replace(/^\/+/, '') - - const pattern = `${prefix}/*${this.opts.extension}` - .split(path.sep) - .join('/') - const files = glob(this.path, pattern, { - absolute: true - }) - - yield * map(files, f => this._decode(f)) - } -} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..ffad858 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,281 @@ +import fs from 'node:fs/promises' +import glob from 'it-glob' +import path from 'node:path' +import { promisify } from 'util' +import { + Key, KeyQuery, Pair, Query +} from 'interface-datastore' +import { + BaseDatastore, Errors +} from 'datastore-core' +import map from 'it-map' +import parallel from 'it-parallel-batch' +// @ts-expect-error no types +import fwa from 'fast-write-atomic' +import type { AwaitIterable } from 'interface-store' + +const writeAtomic = promisify(fwa) + +/** + * Write a file atomically + */ +async function writeFile (path: string, contents: Uint8Array): Promise { + try { + await writeAtomic(path, contents) + } catch (err: any) { + if (err.code === 'EPERM' && err.syscall === 'rename') { + // fast-write-atomic writes a file to a temp location before renaming it. + // On Windows, if the final file already exists this error is thrown. + // No such error is thrown on Linux/Mac + // Make sure we can read & write to this file + await fs.access(path, fs.constants.F_OK | fs.constants.W_OK) + + // The file was created by another context - this means there were + // attempts to write the same block by two different function calls + return + } + + throw err + } +} + +export interface FsDatastoreInit { + createIfMissing?: boolean + errorIfExists?: boolean + extension?: string + putManyConcurrency?: number + getManyConcurrency?: number + deleteManyConcurrency?: number +} + +/** + * A datastore backed by the file system. + * + * Keys need to be sanitized before use, as they are written + * to the file system as is. + */ +export class FsDatastore extends BaseDatastore { + public path: string + private readonly createIfMissing: boolean + private readonly errorIfExists: boolean + private readonly extension: string + private readonly deleteManyConcurrency: number + private readonly getManyConcurrency: number + private readonly putManyConcurrency: number + + constructor (location: string, init: FsDatastoreInit = {}) { + super() + + this.path = path.resolve(location) + this.createIfMissing = init.createIfMissing ?? true + this.errorIfExists = init.errorIfExists ?? false + this.extension = init.extension ?? '.data' + this.deleteManyConcurrency = init.deleteManyConcurrency ?? 50 + this.getManyConcurrency = init.getManyConcurrency ?? 50 + this.putManyConcurrency = init.putManyConcurrency ?? 50 + } + + async open (): Promise { + try { + await fs.access(this.path, fs.constants.F_OK | fs.constants.W_OK) + + if (this.errorIfExists) { + throw Errors.dbOpenFailedError(new Error(`Datastore directory: ${this.path} already exists`)) + } + return + } catch (err: any) { + if (err.code === 'ENOENT') { + if (this.createIfMissing) { + await fs.mkdir(this.path, { recursive: true }) + return + } else { + throw Errors.notFoundError(new Error(`Datastore directory: ${this.path} does not exist`)) + } + } + + throw err + } + } + + async close (): Promise { + + } + + /** + * Calculate the directory and file name for a given key. + */ + _encode (key: Key): { dir: string, file: string } { + const parent = key.parent().toString() + const dir = path.join(this.path, parent) + const name = key.toString().slice(parent.length) + const file = path.join(dir, name + this.extension) + + return { + dir, + file + } + } + + /** + * Calculate the original key, given the file name. + */ + _decode (file: string): Key { + const ext = this.extension + if (path.extname(file) !== ext) { + throw new Error(`Invalid extension: ${path.extname(file)}`) + } + + const keyname = file + .slice(this.path.length, -ext.length) + .split(path.sep) + .join('/') + + return new Key(keyname) + } + + /** + * Store the given value under the key + */ + async put (key: Key, val: Uint8Array): Promise { + const parts = this._encode(key) + + try { + await fs.mkdir(parts.dir, { + recursive: true + }) + await writeFile(parts.file, val) + } catch (err: any) { + throw Errors.dbWriteFailedError(err) + } + } + + async * putMany (source: AwaitIterable): AsyncIterable { + yield * parallel( + map(source, ({ key, value }) => { + return async () => { + await this.put(key, value) + + return { key, value } + } + }), + this.putManyConcurrency + ) + } + + /** + * Read from the file system + */ + async get (key: Key): Promise { + const parts = this._encode(key) + let data + try { + data = await fs.readFile(parts.file) + } catch (err: any) { + throw Errors.notFoundError(err) + } + return data + } + + async * getMany (source: AwaitIterable): AsyncIterable { + yield * parallel( + map(source, key => { + return async () => { + return await this.get(key) + } + }), + this.getManyConcurrency + ) + } + + async * deleteMany (source: AwaitIterable): AsyncIterable { + yield * parallel( + map(source, key => { + return async () => { + await this.delete(key) + + return key + } + }), + this.deleteManyConcurrency + ) + } + + /** + * Check for the existence of the given key + */ + async has (key: Key): Promise { + const parts = this._encode(key) + + try { + await fs.access(parts.file) + } catch (err: any) { + return false + } + return true + } + + /** + * Delete the record under the given key + */ + async delete (key: Key): Promise { + const parts = this._encode(key) + try { + await fs.unlink(parts.file) + } catch (err: any) { + if (err.code === 'ENOENT') { + return + } + + throw Errors.dbDeleteFailedError(err) + } + } + + async * _all (q: Query): AsyncIterable { + let prefix = q.prefix ?? '**' + + // strip leading slashes + prefix = prefix.replace(/^\/+/, '') + + const pattern = `${prefix}/*${this.extension}` + .split(path.sep) + .join('/') + const files = glob(this.path, pattern, { + absolute: true + }) + + for await (const file of files) { + try { + const buf = await fs.readFile(file) + + const pair: Pair = { + key: this._decode(file), + value: buf + } + + yield pair + } catch (err: any) { + // if keys are removed from the datastore while the query is + // running, we may encounter missing files. + if (err.code !== 'ENOENT') { + throw err + } + } + } + } + + async * _allKeys (q: KeyQuery): AsyncIterable { + let prefix = q.prefix ?? '**' + + // strip leading slashes + prefix = prefix.replace(/^\/+/, '') + + const pattern = `${prefix}/*${this.extension}` + .split(path.sep) + .join('/') + const files = glob(this.path, pattern, { + absolute: true + }) + + yield * map(files, f => this._decode(f)) + } +} diff --git a/test/index.spec.js b/test/index.spec.js deleted file mode 100644 index ae5a8e5..0000000 --- a/test/index.spec.js +++ /dev/null @@ -1,205 +0,0 @@ -/* eslint-env mocha */ -import { expect } from 'aegir/chai' -import path from 'path' -import { promisify } from 'util' -import mkdirp from 'mkdirp' -import rmrf from 'rimraf' -import fs from 'fs' -import { Key } from 'interface-datastore' -import { ShardingDatastore, shard } from 'datastore-core' -import { isNode, isElectronMain } from 'ipfs-utils/src/env.js' -import { interfaceDatastoreTests } from 'interface-datastore-tests' -import { FsDatastore } from '../src/index.js' -import tempdir from 'ipfs-utils/src/temp-dir.js' - -const rimraf = promisify(rmrf) -const utf8Encoder = new TextEncoder() - -describe('FsDatastore', () => { - if (!(isNode || isElectronMain)) { - it('only supports node.js and electron main', () => { - - }) - - return - } - - describe('construction', () => { - it('defaults - folder missing', () => { - const dir = tempdir() - expect( - () => new FsDatastore(dir) - ).to.not.throw() - }) - - it('defaults - folder exists', () => { - const dir = tempdir() - mkdirp.sync(dir) - expect( - () => new FsDatastore(dir) - ).to.not.throw() - }) - }) - - describe('open', () => { - it('createIfMissing: false - folder missing', () => { - const dir = tempdir() - const store = new FsDatastore(dir, { createIfMissing: false }) - expect( - () => store.open() - ).to.throw() - }) - - it('errorIfExists: true - folder exists', () => { - const dir = tempdir() - mkdirp.sync(dir) - const store = new FsDatastore(dir, { errorIfExists: true }) - expect( - () => store.open() - ).to.throw() - }) - }) - - it('_encode and _decode', () => { - const dir = tempdir() - const fs = new FsDatastore(dir) - - expect( - // @ts-ignore - fs._encode(new Key('hello/world')) - ).to.eql({ - dir: path.join(dir, 'hello'), - file: path.join(dir, 'hello', 'world.data') - }) - - expect( - // @ts-ignore - fs._decode(fs._encode(new Key('hello/world/test:other')).file) - ).to.eql( - new Key('hello/world/test:other') - ) - }) - - it('deleting files', async () => { - const dir = tempdir() - const fs = new FsDatastore(dir) - const key = new Key('1234') - - await fs.put(key, Uint8Array.from([0, 1, 2, 3])) - await fs.delete(key) - - try { - await fs.get(key) - throw new Error('Should have errored') - } catch (/** @type {any} */ err) { - expect(err.code).to.equal('ERR_NOT_FOUND') - } - }) - - it('deleting non-existent files', async () => { - const dir = tempdir() - const fs = new FsDatastore(dir) - const key = new Key('5678') - - await fs.delete(key) - - try { - await fs.get(key) - throw new Error('Should have errored') - } catch (/** @type {any} */ err) { - expect(err.code).to.equal('ERR_NOT_FOUND') - } - }) - - it('sharding files', async () => { - const dir = tempdir() - const fstore = new FsDatastore(dir) - await ShardingDatastore.create(fstore, new shard.NextToLast(2)) - - const file = await fs.promises.readFile(path.join(dir, shard.SHARDING_FN)) - expect(file.toString()).to.be.eql('/repo/flatfs/shard/v1/next-to-last/2\n') - - const readme = await fs.promises.readFile(path.join(dir, shard.README_FN)) - expect(readme.toString()).to.be.eql(shard.readme) - await rimraf(dir) - }) - - it('query', async () => { - const fs = new FsDatastore(path.join(process.cwd(), '/test/test-repo/blocks')) - const res = [] - for await (const q of fs.query({})) { - res.push(q) - } - expect(res).to.have.length(23) - }) - - it('interop with go', async () => { - const repodir = path.join(process.cwd(), '/test/test-repo/blocks') - const fstore = new FsDatastore(repodir) - const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') - const expected = fs.readFileSync(path.join(repodir, 'VO', key.toString() + '.data')) - const flatfs = await ShardingDatastore.open(fstore) - const res = await flatfs.get(key) - const queryResult = flatfs.query({}) - const results = [] - for await (const result of queryResult) results.push(result) - expect(results).to.have.length(23) - expect(res).to.be.eql(expected) - }) - - describe('interface-datastore', () => { - const dir = tempdir() - - interfaceDatastoreTests({ - setup: () => { - return new FsDatastore(dir) - }, - teardown: () => { - return rimraf(dir) - } - }) - }) - - describe('interface-datastore (sharding(fs))', () => { - const dir = tempdir() - - interfaceDatastoreTests({ - setup: () => { - return new ShardingDatastore(new FsDatastore(dir), new shard.NextToLast(2)) - }, - teardown: () => { - return rimraf(dir) - } - }) - }) - - it('can survive concurrent writes', async () => { - const dir = tempdir() - const fstore = new FsDatastore(dir) - const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') - const value = utf8Encoder.encode('Hello world') - - await Promise.all( - new Array(100).fill(0).map(() => fstore.put(key, value)) - ) - - const res = await fstore.get(key) - - expect(res).to.deep.equal(value) - }) - - it('can survive putRaw and getRaw with an empty extension', async () => { - const dir = tempdir() - const fstore = new FsDatastore(dir, { - extension: '' - }) - const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') - const value = utf8Encoder.encode('Hello world') - - await fstore.putRaw(key, value) - - const res = await fstore.getRaw(key) - - expect(res).to.deep.equal(value) - }) -}) diff --git a/test/index.spec.ts b/test/index.spec.ts new file mode 100644 index 0000000..96d0963 --- /dev/null +++ b/test/index.spec.ts @@ -0,0 +1,173 @@ +/* eslint-env mocha */ +import { expect } from 'aegir/chai' +import path from 'node:path' +import fs from 'node:fs/promises' +import { Key } from 'interface-datastore' +import { ShardingDatastore, shard } from 'datastore-core' +import { interfaceDatastoreTests } from 'interface-datastore-tests' +import { FsDatastore } from '../src/index.js' +import tempdir from 'ipfs-utils/src/temp-dir.js' + +const utf8Encoder = new TextEncoder() + +describe('FsDatastore', () => { + describe('construction', () => { + it('defaults - folder missing', async () => { + const dir = tempdir() + + await expect( + (async () => { + const store = new FsDatastore(dir) + await store.open() + })() + ).to.eventually.be.undefined() + }) + + it('defaults - folder exists', async () => { + const dir = tempdir() + await fs.mkdir(dir, { + recursive: true + }) + + await expect( + (async () => { + const store = new FsDatastore(dir) + await store.open() + })() + ).to.eventually.be.undefined() + }) + }) + + describe('open', () => { + it('createIfMissing: false - folder missing', async () => { + const dir = tempdir() + const store = new FsDatastore(dir, { createIfMissing: false }) + await expect(store.open()).to.eventually.be.rejected + .with.property('code', 'ERR_NOT_FOUND') + }) + + it('errorIfExists: true - folder exists', async () => { + const dir = tempdir() + await fs.mkdir(dir, { + recursive: true + }) + const store = new FsDatastore(dir, { errorIfExists: true }) + await expect(store.open()).to.eventually.be.rejected + .with.property('code', 'ERR_DB_OPEN_FAILED') + }) + }) + + it('_encode and _decode', async () => { + const dir = tempdir() + const fs = new FsDatastore(dir) + await fs.open() + + expect( + fs._encode(new Key('hello/world')) + ).to.eql({ + dir: path.join(dir, 'hello'), + file: path.join(dir, 'hello', 'world.data') + }) + + expect( + fs._decode(fs._encode(new Key('hello/world/test:other')).file) + ).to.eql( + new Key('hello/world/test:other') + ) + }) + + it('deleting files', async () => { + const dir = tempdir() + const fs = new FsDatastore(dir) + await fs.open() + const key = new Key('1234') + + await fs.put(key, Uint8Array.from([0, 1, 2, 3])) + await fs.delete(key) + + try { + await fs.get(key) + throw new Error('Should have errored') + } catch (err: any) { + expect(err.code).to.equal('ERR_NOT_FOUND') + } + }) + + it('deleting non-existent files', async () => { + const dir = tempdir() + const fs = new FsDatastore(dir) + await fs.open() + const key = new Key('5678') + + await fs.delete(key) + + try { + await fs.get(key) + throw new Error('Should have errored') + } catch (err: any) { + expect(err.code).to.equal('ERR_NOT_FOUND') + } + }) + + it('sharding files', async () => { + const dir = tempdir() + const fstore = new FsDatastore(dir) + await fstore.open() + await ShardingDatastore.create(fstore, new shard.NextToLast(2)) + + const file = await fs.readFile(path.join(dir, shard.SHARDING_FN + '.data')) + expect(file.toString()).to.be.eql('/repo/flatfs/shard/v1/next-to-last/2\n') + + await fs.rm(dir, { + recursive: true + }) + }) + + describe('interface-datastore', () => { + interfaceDatastoreTests({ + async setup () { + const store = new FsDatastore(tempdir()) + await store.open() + + return store + }, + async teardown (store) { + await fs.rm(store.path, { + recursive: true + }) + } + }) + }) + + describe('interface-datastore (sharding(fs))', () => { + interfaceDatastoreTests({ + async setup () { + const store = new FsDatastore(tempdir()) + await store.open() + + const shardedStore = new ShardingDatastore(store, new shard.NextToLast(2)) + await shardedStore.open() + + return shardedStore + }, + teardown () { + + } + }) + }) + + it('can survive concurrent writes', async () => { + const dir = tempdir() + const fstore = new FsDatastore(dir) + const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY') + const value = utf8Encoder.encode('Hello world') + + await Promise.all( + new Array(100).fill(0).map(async () => { await fstore.put(key, value) }) + ) + + const res = await fstore.get(key) + + expect(res).to.deep.equal(value) + }) +}) diff --git a/test/test-repo/blocks/2F/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data b/test/test-repo/blocks/2F/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data deleted file mode 100644 index 4145619..0000000 --- a/test/test-repo/blocks/2F/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data +++ /dev/null @@ -1,4 +0,0 @@ - -ys# js-ipfs-repo -Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript -s \ No newline at end of file diff --git a/test/test-repo/blocks/5V/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data b/test/test-repo/blocks/5V/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data deleted file mode 100644 index 951bfe0..0000000 --- a/test/test-repo/blocks/5V/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data +++ /dev/null @@ -1,23 +0,0 @@ - - IPFS Alpha Security Notes - -We try hard to ensure our system is safe and robust, but all software -has bugs, especially new software. This distribution is meant to be an -alpha preview, don't use it for anything mission critical. - -Please note the following: - -- This is alpha software and has not been audited. It is our goal - to conduct a proper security audit once we close in on a 1.0 release. - -- ipfs is a networked program, and may have serious undiscovered - vulnerabilities. It is written in Go, and we do not execute any - user provided data. But please point any problems out to us in a - github issue, or email security@ipfs.io privately. - -- ipfs uses encryption for all communication, but it's NOT PROVEN SECURE - YET! It may be totally broken. For now, the code is included to make - sure we benchmark our operations with encryption in mind. In the future, - there will be an "unsafe" mode for high performance intranet apps. - If this is a blocking feature for you, please contact us. - \ No newline at end of file diff --git a/test/test-repo/blocks/75/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data b/test/test-repo/blocks/75/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data deleted file mode 100644 index c9885c45d7e7c10d02b98208d40cfd7b8bfaed21..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 101 zcmWgA=TZ_+Kwo-;;PadOz%uNME$6+{JHE$$U!OUW!sO)in> z4G}T|X$WFClbv7rFrua5=1<0)Q}=J#b|1g=` -- browsers or extensions can learn to use `ipfs://` directly -- hash-addressed content guarantees authenticity - -IPFS is modular: -- connection layer over any network protocol -- routing layer -- uses a routing layer DHT (kademlia/coral) -- uses a path-based naming service -- uses bittorrent-inspired block exchange - -IPFS uses crypto: -- cryptographic-hash content addressing -- block-level deduplication -- file integrity + versioning -- filesystem-level encryption + signing support - -IPFS is p2p: -- worldwide peer-to-peer file transfers -- completely decentralized architecture -- **no** central point of failure - -IPFS is a cdn: -- add a file to the filesystem locally, and it's now available to the world -- caching-friendly (content-hash naming) -- bittorrent-based bandwidth distribution - -IPFS has a name service: -- IPNS, an SFS inspired name system -- global namespace based on PKI -- serves to build trust chains -- compatible with other NSes -- can map DNS, .onion, .bit, etc to IPNS - \ No newline at end of file diff --git a/test/test-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data b/test/test-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data deleted file mode 100644 index 6860441..0000000 --- a/test/test-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data +++ /dev/null @@ -1,3 +0,0 @@ -/ -" gq6\u8~:6~gZ.directT2 -" 6(%݄.Ӿ5(ab recursiveT \ No newline at end of file diff --git a/test/test-repo/blocks/AP/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data b/test/test-repo/blocks/AP/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data deleted file mode 100644 index 74de75af616ff437b5c7a3a5272281eac2146b6c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 309 zcmWgA<5Ch*SgK>j#LTl(=mjz6J*Z#Z`mUeibke1%>*qt`A@ymo*6O-~wOC)CS z3K@XZPnu<5V|lBKJN>}4>2CTNRSd^0_H1qVw~ozKk4Ii%i@p$ha(-S(VseSZ2}U7Z zkd6rls>-Jxlr$AsHtpiyKm2l@?&p6zQA*^T_KfrP>FKF6gjh0Ca|$F5F$tM~lqa2& z*O|D`YWmh`FN(J=HpxnHW4)f}dn)*>RpfVzsIJ{Y+=Zo?$=SNaC5c5P5({~S^g+6W z__Mw-Uda>Kbm^hob(zph@di$ZR2iSh3b{RB`110NH$rShsfj7MsS@Wngv>!2f{xjg zms)1qHyyK_UR9)g=w{aZf~|kMWdrSdqBHNTyCTF_oSIx(lvz@#o0ngbS}f7b!NtVE F2moEFc%uLS diff --git a/test/test-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data b/test/test-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data deleted file mode 100644 index ecce105..0000000 --- a/test/test-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data +++ /dev/null @@ -1,4 +0,0 @@ -5 -" ׾F_uؔlzS?|ڲPc@ js-ipfs-repo - - \ No newline at end of file diff --git a/test/test-repo/blocks/CY/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data b/test/test-repo/blocks/CY/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data deleted file mode 100644 index bbe6bda78d0a52f6d87da578f452d43718b9aa9f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10807 zcmeI&tqQ_m6vpvsQC>mhU=TmxWeCpZ4H&eDU=nNw5wR?6Yue0K5w>X*qZns5SS{Xw z-hn1RK)egXzn^qC&+{usEM\IzxEElM/fLICENSE1 -" JZXoRX!Fwd87U;SöWw README.md{ - \ No newline at end of file diff --git a/test/test-repo/blocks/HD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data b/test/test-repo/blocks/HD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data deleted file mode 100644 index 5ea0edda6f82982c276a4a3813a50c0e35121c68..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10765 zcmeIzF%AJy6a~;Rm3)!Nk3xb(CK9$mt(wFR^jf72s6=9D)srdd6*gc6EI~I4+fbbT zRX6Y66Q?1IqgQpGAHRd{ss22Q^=&*UXYbW{zqlNV{wBXJW712aODXvf?XV11kq9)T zAq{CrLmJYMhBTxh4QWV28q$!4G^8O7X-GpF(vXHUq#+GyNJARZkcKp*;U8!iTA|tK KY}4Vho$h|}9P~&4 diff --git a/test/test-repo/blocks/IL/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data b/test/test-repo/blocks/IL/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data deleted file mode 100644 index 62d1c29..0000000 --- a/test/test-repo/blocks/IL/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data +++ /dev/null @@ -1,8 +0,0 @@ - -Come hang out in our IRC chat room if you have any questions. - -Contact the ipfs dev team: -- Bugs: https://github.com/ipfs/go-ipfs/issues -- Help: irc.freenode.org/#ipfs -- Email: dev@ipfs.io - \ No newline at end of file diff --git a/test/test-repo/blocks/LG/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data b/test/test-repo/blocks/LG/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data deleted file mode 100644 index 71be805..0000000 --- a/test/test-repo/blocks/LG/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data +++ /dev/null @@ -1,9 +0,0 @@ - -Some helpful resources for finding your way around ipfs: - -- quick-start: a quick show of various ipfs features. -- ipfs commands: a list of all commands -- ipfs --help: every command describes itself -- https://github.com/ipfs/go-ipfs -- the src repository -- #ipfs on irc.freenode.org -- the community irc channel - \ No newline at end of file diff --git a/test/test-repo/blocks/O6/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data b/test/test-repo/blocks/O6/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data deleted file mode 100644 index 7b58d6c..0000000 --- a/test/test-repo/blocks/O6/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data +++ /dev/null @@ -1,3 +0,0 @@ -/ -" @ԆDgA7directT2 -" ;APY0k}E=p  recursiveT \ No newline at end of file diff --git a/test/test-repo/blocks/QF/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data b/test/test-repo/blocks/QF/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data deleted file mode 100644 index a8f98693b7d4797d0a55704b16c15a6aa7d34bd5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10765 zcmeIzF%AJy6a~Szz&}ww{ J&EYejEr0X~^v?hQ diff --git a/test/test-repo/blocks/QV/CIQOHMGEIKMPYHAUTL57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data b/test/test-repo/blocks/QV/CIQOHMGEIKMPYHAUTL57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data deleted file mode 100644 index e69de29..0000000 diff --git a/test/test-repo/blocks/R3/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data b/test/test-repo/blocks/R3/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data deleted file mode 100644 index 389e111..0000000 --- a/test/test-repo/blocks/R3/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data +++ /dev/null @@ -1,28 +0,0 @@ - -Hello and Welcome to IPFS! - -██╗██████╗ ███████╗███████╗ -██║██╔══██╗██╔════╝██╔════╝ -██║██████╔╝█████╗ ███████╗ -██║██╔═══╝ ██╔══╝ ╚════██║ -██║██║ ██║ ███████║ -╚═╝╚═╝ ╚═╝ ╚══════╝ - -If you're seeing this, you have successfully installed -IPFS and are now interfacing with the ipfs merkledag! - - ------------------------------------------------------- -| Warning: | -| This is alpha software. Use at your own discretion! | -| Much is missing or lacking polish. There are bugs. | -| Not yet secure. Read the security notes for more. | - ------------------------------------------------------- - -Check out some of the other files in this directory: - - ./about - ./help - ./quick-start <-- usage examples - ./readme <-- this file - ./security-notes - \ No newline at end of file diff --git a/test/test-repo/blocks/S5/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data b/test/test-repo/blocks/S5/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data deleted file mode 100644 index 3a99c36..0000000 --- a/test/test-repo/blocks/S5/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data +++ /dev/null @@ -1,3 +0,0 @@ -4 -" Y9_)a˹2RmŖke9 js-ipfs-repo - \ No newline at end of file diff --git a/test/test-repo/blocks/SHARDING b/test/test-repo/blocks/SHARDING deleted file mode 100644 index a153331..0000000 --- a/test/test-repo/blocks/SHARDING +++ /dev/null @@ -1 +0,0 @@ -/repo/flatfs/shard/v1/next-to-last/2 diff --git a/test/test-repo/blocks/TW/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data b/test/test-repo/blocks/TW/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data deleted file mode 100644 index 10aa2ae4f1291a62edd84980f1c05b09b95f78ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10891 zcmWgA;8GG&c)a0=(~LhdBC~#fIWaSTr;7SI$0sSXC;Kd!I#aqLXh*0Jg9L-nsLIh$ z8ciXixns0s7%de?YlP9-aI`iYtqn(O!_nGsv^E^A4M%Ik(b{mdHXN-DM{C2;+HkZs z9IXvUYs1mnaI`iYtqn(O!_nGsv^E^A4M%Ik(b{mdHXN-DM{C2;+HkZs9IXvUYs1mn zaI`iYG__&mlom_2c+JFlUxXS??=;#MbToJ7(P`PK4+MoQKg`(u9q~6w(px+ cb8FMhello - ipfs add hello - - -View it: - - ipfs cat - - -Try a directory: - - mkdir foo - mkdir foo/bar - echo "baz" > foo/baz - echo "baz" > foo/bar/baz - ipfs add -r foo - - -View things: - - ipfs ls - ipfs ls /bar - ipfs cat /baz - ipfs cat /bar/baz - ipfs cat /bar - ipfs ls /baz - - -References: - - ipfs refs - ipfs refs -r - ipfs refs --help - - -Get: - - ipfs get foo2 - diff foo foo2 - - -Objects: - - ipfs object get - ipfs object get /foo2 - ipfs object --help - - -Pin + GC: - - ipfs pin -r - ipfs gc - ipfs ls - ipfs unpin -r - ipfs gc - - -Daemon: - - ipfs daemon (in another terminal) - ipfs id - - -Network: - - (must be online) - ipfs swarm peers - ipfs id - ipfs cat - - -Mount: - - (warning: fuse is finicky!) - ipfs mount - cd /ipfs/< - - -Tool: - - ipfs version - ipfs update - ipfs commands - ipfs config --help - open http://localhost:5001/webui - - -Browse: - - webui: - - http://localhost:5001/webui - - video: - - http://localhost:8080/ipfs/QmVc6zuAneKJzicnJpfrqCH9gSy6bz54JhcypfJYhGUFQu/play#/ipfs/QmTKZgRNwDNZwHtJSjCp6r5FYefzpULfy37JvMt9DwvXse - - images: - - http://localhost:8080/ipfs/QmZpc3HvfjEXvLWGQPWbHk3AjD5j8NEN4gmFN8Jmrd5g83/cs - - markdown renderer app: - - http://localhost:8080/ipfs/QmX7M9CiYXjVeFnkfVGf3y5ixTZ2ACeSGyL1vBJY1HvQPp/mdown - \ No newline at end of file diff --git a/test/test-repo/blocks/X3/CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data b/test/test-repo/blocks/X3/CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data deleted file mode 100644 index 9553a94..0000000 --- a/test/test-repo/blocks/X3/CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/test/test-repo/blocks/XO/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data b/test/test-repo/blocks/XO/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data deleted file mode 100644 index d899663bf7a13bb0563304b1d96985a784c2d515..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10849 zcmWgA;8GG&c)a0=(~LhdBC~#fIWaSTr;7SI$0sSXC;Kd!I#aqLXh*0Jg9L-nsLIh$ z8ciXixns0s7%de?YlP9-aI`iYtqn(O!_nGsv^E^A4M%Ik(b{mdHXN-DM{C2;+HkZs z9IXvUYs1mnaI`iYtqn(O!_nGsv^E^A4M%Ik(b{mdHXN-DM{C2;+HkZs9IXvUYs1mn zaI`iYG__&mlom_2c+JFlUxXS??=;#MbToJ7(P`PK4+MoQKg`(u9.data. Where is the -"base32" encoding of the CID (as specified in -https://github.com/multiformats/multibase) without the 'B' prefix. -All the object files are placed in a tree of directories, based on a -function of the CID. This is a form of sharding similar to -the objects directory in git repositories. Previously, we used -prefixes, we now use the next-to-last two charters. - - func NextToLast(base32cid string) { - nextToLastLen := 2 - offset := len(base32cid) - nextToLastLen - 1 - return str[offset : offset+nextToLastLen] - } - -For example, an object with a base58 CIDv1 of - - zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f - -has a base32 CIDv1 of - - BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA - -and will be placed at - - SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data - -with 'SC' being the last-to-next two characters and the 'B' at the -beginning of the CIDv1 string is the multibase prefix that is not -stored in the filename. diff --git a/test/test-repo/config b/test/test-repo/config deleted file mode 100644 index 5811699..0000000 --- a/test/test-repo/config +++ /dev/null @@ -1,88 +0,0 @@ -{ - "Identity": { - "PeerID": "QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A", - "PrivKey": "CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAECggEAZtju/bcKvKFPz0mkHiaJcpycy9STKphorpCT83srBVQi59CdFU6Mj+aL/xt0kCPMVigJw8P3/YCEJ9J+rS8BsoWE+xWUEsJvtXoT7vzPHaAtM3ci1HZd302Mz1+GgS8Epdx+7F5p80XAFLDUnELzOzKftvWGZmWfSeDnslwVONkL/1VAzwKy7Ce6hk4SxRE7l2NE2OklSHOzCGU1f78ZzVYKSnS5Ag9YrGjOAmTOXDbKNKN/qIorAQ1bovzGoCwx3iGIatQKFOxyVCyO1PsJYT7JO+kZbhBWRRE+L7l+ppPER9bdLFxs1t5CrKc078h+wuUr05S1P1JjXk68pk3+kQKBgQDeK8AR11373Mzib6uzpjGzgNRMzdYNuExWjxyxAzz53NAR7zrPHvXvfIqjDScLJ4NcRO2TddhXAfZoOPVH5k4PJHKLBPKuXZpWlookCAyENY7+Pd55S8r+a+MusrMagYNljb5WbVTgN8cgdpim9lbbIFlpN6SZaVjLQL3J8TWH6wKBgQDSChzItkqWX11CNstJ9zJyUE20I7LrpyBJNgG1gtvz3ZMUQCn3PxxHtQzN9n1P0mSSYs+jBKPuoSyYLt1wwe10/lpgL4rkKWU3/m1Myt0tveJ9WcqHh6tzcAbb/fXpUFT/o4SWDimWkPkuCb+8j//2yiXk0a/T2f36zKMuZvujqQKBgC6B7BAQDG2H2B/ijofp12ejJU36nL98gAZyqOfpLJ+FeMz4TlBDQ+phIMhnHXA5UkdDapQ+zA3SrFk+6yGk9Vw4Hf46B+82SvOrSbmnMa+PYqKYIvUzR4gg34rL/7AhwnbEyD5hXq4dHwMNsIDq+l2elPjwm/U9V0gdAl2+r50HAoGALtsKqMvhv8HucAMBPrLikhXP/8um8mMKFMrzfqZ+otxfHzlhI0L08Bo3jQrb0Z7ByNY6M8epOmbCKADsbWcVre/AAY0ZkuSZK/CaOXNX/AhMKmKJh8qAOPRY02LIJRBCpfS4czEdnfUhYV/TYiFNnKRj57PPYZdTzUsxa/yVTmECgYBr7slQEjb5Onn5mZnGDh+72BxLNdgwBkhO0OCdpdISqk0F0Pxby22DFOKXZEpiyI9XYP1C8wPiJsShGm2yEwBPWXnrrZNWczaVuCbXHrZkWQogBDG3HGXNdU4MAWCyiYlyinIBpPpoAJZSzpGLmWbMWh28+RJS6AQX6KHrK1o2uw==" - }, - "Datastore": { - "Type": "", - "Path": "", - "StorageMax": "", - "StorageGCWatermark": 0, - "GCPeriod": "", - "Params": null, - "NoSync": false - }, - "Addresses": { - "Swarm": [ - "/ip4/0.0.0.0/tcp/4001", - "/ip6/::/tcp/4001" - ], - "API": "/ip4/127.0.0.1/tcp/5001", - "Gateway": "/ip4/127.0.0.1/tcp/8080" - }, - "Mounts": { - "IPFS": "/ipfs", - "IPNS": "/ipns", - "FuseAllowOther": false - }, - "Version": { - "Current": "0.4.0-dev", - "Check": "error", - "CheckDate": "0001-01-01T00:00:00Z", - "CheckPeriod": "172800000000000", - "AutoUpdate": "minor" - }, - "Discovery": { - "MDNS": { - "Enabled": true, - "Interval": 10 - } - }, - "Ipns": { - "RepublishPeriod": "", - "RecordLifetime": "", - "ResolveCacheSize": 128 - }, - "Bootstrap": [ - "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", - "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", - "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", - "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", - "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", - "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", - "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", - "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3", - "/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx" - ], - "Tour": { - "Last": "" - }, - "Gateway": { - "HTTPHeaders": null, - "RootRedirect": "", - "Writable": false - }, - "SupernodeRouting": { - "Servers": [ - "/ip4/104.236.176.52/tcp/4002/ipfs/QmXdb7tWTxdFEQEFgWBqkuYSrZd3mXrC7HxkD4krGNYx2U", - "/ip4/104.236.179.241/tcp/4002/ipfs/QmVRqViDByUxjUMoPnjurjKvZhaEMFDtK35FJXHAM4Lkj6", - "/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH", - "/ip4/162.243.248.213/tcp/4002/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP", - "/ip4/128.199.219.111/tcp/4002/ipfs/Qmb3brdCYmKG1ycwqCbo6LUwWxTuo3FisnJV2yir7oN92R", - "/ip4/104.236.76.40/tcp/4002/ipfs/QmdRBCV8Cz2dGhoKLkD3YjPwVFECmqADQkx5ZteF2c6Fy4", - "/ip4/178.62.158.247/tcp/4002/ipfs/QmUdiMPci7YoEUBkyFZAh2pAbjqcPr7LezyiPD2artLw3v", - "/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN" - ] - }, - "API": { - "HTTPHeaders": null - }, - "Swarm": { - "AddrFilters": null - }, - "Log": { - "MaxSizeMB": 250, - "MaxBackups": 1, - "MaxAgeDays": 0 - } -} \ No newline at end of file diff --git a/test/test-repo/datastore/000002.ldb b/test/test-repo/datastore/000002.ldb deleted file mode 100644 index fc04d660e9ab26bb5d27b3b6b33d212bd1e34f0b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 211 zcmZROP}0xIPfpCyPs_|nEiTH>FJWY200SX~$SEzBZ1I|j^S%f*oZe})FX(9Q%%jt? zQy&NlS$>$Y`#n34QbA^3F(V^P!?OjhZT>&P<~cuU%i;RLe(ysy@1_qD4Q&dq4R$uX zbPxoo11sKKRu>QF9Qd?w0|O_M0pouNU?_u2-8}VndNoG}qZmkp00{rx(5+JHej5PO CoIXSV diff --git a/test/test-repo/datastore/000005.ldb b/test/test-repo/datastore/000005.ldb deleted file mode 100644 index 63d9d260b936415ee42b5aeda6c79fb941664398..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1120 zcmZQDSjViNS&&z(FQg!8*qs;0^V3RMWIveo0t|Brg#j3VRkisv@!=|IgJvNC_dNx9y@%e`@arzW`upR#0^RR3Lu1P3 zgny1+s9JOHtH$|N^V2^pIaU+*`j0Vdf^UEA=Y(L*NL7==e45ubJUDbI<}5@1nZ5i@ zU-f@onB_6=BHQa-tVc_VRZiT0AST5ib<){%%1r}PkJe@8+6(<3{`CFeMP?prC*c znwwdgM`+7O$B&?~72w>77RV zf{y0SJUT5q^?{&}<%b!&-?Q^56=dcWGqS)myonCBGLo1n?_9oP$D!cvsdqIm%dJT< zUeCYn&kfrf>=lfOBoQtW6k&$7W$0~c7gOL@IORq4N$7y_CFLmFs-1D4yKkEePa;Yx&V3}9e z6J;wFzbL(7XX!B6*Rdrw=+4dxeU2>!j1QaGe>~sK(>yOETD?v4ss5$s3VXC14~0|~ z@|s=JZrGS)y@`hY)f%XfBnQv@ZgL4too7C-W6;9@lKgp&)Y9xu#YGC zq+Q(oPkf)J&zo^7bJ>~t)Xqs~*IU@HQqP#^{d0FztkiZ*y~k%OjhiRCYiY>$1@7+Z zzc{J2k%`0O*2zuI)9>zn)wWdsh9cXQc|w1;OnM=;)%wQi`6UM;Jtuj8n*Q?qk;X3q zZaf<6!(B7;zLu#kRKLAQM`r(FbFXM+CT2zkqS6H@{24)n$QSJzIOo8pg&P<+nGG2K hLjXe)2VAZvSyQK-gJTMZI7kRT2>;#Cty1cK8vstu!bkuB diff --git a/test/test-repo/datastore/CURRENT b/test/test-repo/datastore/CURRENT deleted file mode 100644 index ecb0b4b..0000000 --- a/test/test-repo/datastore/CURRENT +++ /dev/null @@ -1 +0,0 @@ -MANIFEST-000036 diff --git a/test/test-repo/datastore/LOCK b/test/test-repo/datastore/LOCK deleted file mode 100644 index e69de29..0000000 diff --git a/test/test-repo/datastore/LOG b/test/test-repo/datastore/LOG deleted file mode 100644 index 4e3a829..0000000 --- a/test/test-repo/datastore/LOG +++ /dev/null @@ -1,3 +0,0 @@ -2017/03/13-13:52:56.574311 70000f009000 Recovering log #35 -2017/03/13-13:52:56.575960 70000f009000 Delete type=0 #35 -2017/03/13-13:52:56.576081 70000f009000 Delete type=3 #34 diff --git a/test/test-repo/datastore/LOG.old b/test/test-repo/datastore/LOG.old deleted file mode 100644 index 27029f4..0000000 --- a/test/test-repo/datastore/LOG.old +++ /dev/null @@ -1,3 +0,0 @@ -2017/03/13-13:52:16.502220 70000f6c7000 Recovering log #33 -2017/03/13-13:52:16.503900 70000f6c7000 Delete type=0 #33 -2017/03/13-13:52:16.504085 70000f6c7000 Delete type=3 #32 diff --git a/test/test-repo/datastore/MANIFEST-000036 b/test/test-repo/datastore/MANIFEST-000036 deleted file mode 100644 index 004f1665220cd36d92960c0bbd72f4ebb38b139e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 201 zcmc~;7JhUy10$nUPHI_dPD+xVQ)NkNd1i5{bAE0?Vo_pAei1tZ>jMr0{mg>AVtpY6 zNyF~EIG&$Y$|Cz2)n@4&vblWcO3-zuvpdb_wz++KvXYUN0Sxr?3$lq(&IVD=&cJk; zQ9?f_KRGc+KP@vSwYVrhzl4zqA}b7)D9Fq!W@LnjX@}fT;$UE8Qsrb|R%77+0Kbnu A%m4rY diff --git a/test/test-repo/version b/test/test-repo/version deleted file mode 100644 index 7ed6ff8..0000000 --- a/test/test-repo/version +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/tsconfig.json b/tsconfig.json index 8708ca6..13a3599 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,7 @@ { "extends": "aegir/src/config/tsconfig.aegir.json", "compilerOptions": { - "outDir": "dist", - "emitDeclarationOnly": true + "outDir": "dist" }, "include": [ "src", From 4332006aba3e8e67c80144b110cc81042ce07e03 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Mar 2023 09:04:04 +0100 Subject: [PATCH 29/36] fix: fix exports map --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 708b112..3a184f5 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "exports": { ".": { "types": "./dist/src/index.d.ts", - "import": "./src/index.js" + "import": "./dist/src/index.js" } }, "eslintConfig": { From 62adc6b238e64c6040afb4887bf6999de42cde08 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 14 Mar 2023 09:05:22 +0100 Subject: [PATCH 30/36] chore: update project config --- .gitignore | 71 ++++++---------------------------------------------- README.md | 27 ++++++++++---------- package.json | 16 ------------ 3 files changed, 20 insertions(+), 94 deletions(-) diff --git a/.gitignore b/.gitignore index 238a04e..7ad9e67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,66 +1,9 @@ -dist/ - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Typescript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# while testing npm5 +node_modules +build +dist +.docs +.coverage +node_modules package-lock.json yarn.lock -types -docs \ No newline at end of file +.vscode diff --git a/README.md b/README.md index 65c9cd2..3028612 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ # datastore-fs -[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) -[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![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) [![codecov](https://img.shields.io/codecov/c/github/ipfs/js-datastore-fs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-datastore-fs) -[![CI](https://img.shields.io/github/workflow/status/ipfs/js-datastore-fs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-datastore-fs/actions/workflows/js-test-and-release.yml) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-datastore-fs/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/js-datastore-fs/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) > Datastore implementation with file system backend @@ -12,9 +11,9 @@ - [Install](#install) - [Usage](#usage) -- [Contribute](#contribute) +- [API Docs](#api-docs) - [License](#license) -- [Contribute](#contribute-1) +- [Contribute](#contribute) ## Install @@ -30,13 +29,9 @@ import { FSDatastore } from 'datastore-fs' const store = new FSDatastore('path/to/store') ``` -## Contribute - -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-datastore-fs/issues)! +## API Docs -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). - -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +- ## License @@ -47,8 +42,12 @@ Licensed under either of ## Contribute -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-importer/issues)! +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-datastore-fs/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/package.json b/package.json index 3a184f5..64cf435 100644 --- a/package.json +++ b/package.json @@ -25,22 +25,6 @@ }, "type": "module", "types": "./dist/src/index.d.ts", - "typesVersions": { - "*": { - "*": [ - "*", - "dist/*", - "dist/src/*", - "dist/src/*/index" - ], - "src/*": [ - "*", - "dist/*", - "dist/src/*", - "dist/src/*/index" - ] - } - }, "files": [ "src", "dist", From 946bcbb5b5a1efe71eac36de36b0e9d076917a0c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 14 Mar 2023 08:11:15 +0000 Subject: [PATCH 31/36] chore(release): 9.0.0 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## [9.0.0](https://github.com/ipfs/js-datastore-fs/compare/v8.0.0...v9.0.0) (2023-03-14) ### ⚠ BREAKING CHANGES * interface-datastore 8.x.x has removed the open and close methods as these are implementation specific ### Bug Fixes * fix exports map ([4332006](https://github.com/ipfs/js-datastore-fs/commit/4332006aba3e8e67c80144b110cc81042ce07e03)) ### Dependencies * update interface-datastore to 8.x.x ([#180](https://github.com/ipfs/js-datastore-fs/issues/180)) ([2ef5f5c](https://github.com/ipfs/js-datastore-fs/commit/2ef5f5cf021b1876cb83c53bafebb5f153c77462)) ### Trivial Changes * update project config ([62adc6b](https://github.com/ipfs/js-datastore-fs/commit/62adc6b238e64c6040afb4887bf6999de42cde08)) --- CHANGELOG.md | 21 +++++++++++++++++++++ package.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4115b1..ed04e6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +## [9.0.0](https://github.com/ipfs/js-datastore-fs/compare/v8.0.0...v9.0.0) (2023-03-14) + + +### ⚠ BREAKING CHANGES + +* interface-datastore 8.x.x has removed the open and close methods as these are implementation specific + +### Bug Fixes + +* fix exports map ([4332006](https://github.com/ipfs/js-datastore-fs/commit/4332006aba3e8e67c80144b110cc81042ce07e03)) + + +### Dependencies + +* update interface-datastore to 8.x.x ([#180](https://github.com/ipfs/js-datastore-fs/issues/180)) ([2ef5f5c](https://github.com/ipfs/js-datastore-fs/commit/2ef5f5cf021b1876cb83c53bafebb5f153c77462)) + + +### Trivial Changes + +* update project config ([62adc6b](https://github.com/ipfs/js-datastore-fs/commit/62adc6b238e64c6040afb4887bf6999de42cde08)) + ## [8.0.0](https://github.com/ipfs/js-datastore-fs/compare/v7.0.0...v8.0.0) (2022-08-12) diff --git a/package.json b/package.json index 64cf435..98922a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datastore-fs", - "version": "8.0.0", + "version": "9.0.0", "description": "Datastore implementation with file system backend", "author": "Friedel Ziegelmayer", "license": "Apache-2.0 OR MIT", From e4abb2bdd669ecbe30e85d75b7675c47d2be6903 Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Wed, 15 Mar 2023 11:21:10 +0100 Subject: [PATCH 32/36] update .github/workflows/js-test-and-release.yml (#181) --- .github/workflows/js-test-and-release.yml | 38 ++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 74b2386..4e6d4ec 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -96,6 +96,42 @@ jobs: with: flags: firefox-webworker + test-webkit: + needs: check + runs-on: ${{ matrix.os }} + matrix: + os: [ubuntu-latest, macos-latest] + node: [lts/*] + fail-fast: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:webkit + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: webkit + + test-webkit: + needs: check + runs-on: ${{ matrix.os }} + matrix: + os: [ubuntu-latest, macos-latest] + node: [lts/*] + fail-fast: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:webkit-webworker + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: webkit-webworker + test-electron-main: needs: check runs-on: ubuntu-latest @@ -125,7 +161,7 @@ jobs: flags: electron-renderer release: - needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer] + needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-webkit, test-webkit-webworker, test-electron-main, test-electron-renderer] runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/master' steps: From 5325b5c5adb4fd9707539356da41dbf8d2eb87cf Mon Sep 17 00:00:00 2001 From: web3-bot <81333946+web3-bot@users.noreply.github.com> Date: Wed, 15 Mar 2023 13:56:42 +0100 Subject: [PATCH 33/36] update .github/workflows/js-test-and-release.yml (#182) --- .github/workflows/js-test-and-release.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 4e6d4ec..546f6d4 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -99,7 +99,8 @@ jobs: test-webkit: needs: check runs-on: ${{ matrix.os }} - matrix: + strategy: + matrix: os: [ubuntu-latest, macos-latest] node: [lts/*] fail-fast: true @@ -114,10 +115,11 @@ jobs: with: flags: webkit - test-webkit: + test-webkit-webworker: needs: check runs-on: ${{ matrix.os }} - matrix: + strategy: + matrix: os: [ubuntu-latest, macos-latest] node: [lts/*] fail-fast: true From 803df0bc96860352957fb06fee109a705124a273 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 23 Mar 2023 10:37:09 +0000 Subject: [PATCH 34/36] deps: update interface-store to 5.x.x (#183) --- package.json | 8 ++++---- src/index.ts | 15 ++++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 98922a9..cda89a7 100644 --- a/package.json +++ b/package.json @@ -140,10 +140,10 @@ "docs": "aegir docs" }, "dependencies": { - "datastore-core": "^9.0.1", + "datastore-core": "^9.0.4", "fast-write-atomic": "^0.2.0", - "interface-datastore": "^8.0.0", - "interface-store": "^4.0.0", + "interface-datastore": "^8.1.2", + "interface-store": "^5.0.1", "it-glob": "^2.0.1", "it-map": "^2.0.1", "it-parallel-batch": "^2.0.1" @@ -152,7 +152,7 @@ "@types/mkdirp": "^2.0.0", "@types/rimraf": "^4.0.5", "aegir": "^38.1.7", - "interface-datastore-tests": "^4.0.0", + "interface-datastore-tests": "^5.0.0", "ipfs-utils": "^9.0.4" } } diff --git a/src/index.ts b/src/index.ts index ffad858..a5a5423 100644 --- a/src/index.ts +++ b/src/index.ts @@ -136,7 +136,7 @@ export class FsDatastore extends BaseDatastore { /** * Store the given value under the key */ - async put (key: Key, val: Uint8Array): Promise { + async put (key: Key, val: Uint8Array): Promise { const parts = this._encode(key) try { @@ -144,18 +144,20 @@ export class FsDatastore extends BaseDatastore { recursive: true }) await writeFile(parts.file, val) + + return key } catch (err: any) { throw Errors.dbWriteFailedError(err) } } - async * putMany (source: AwaitIterable): AsyncIterable { + async * putMany (source: AwaitIterable): AsyncIterable { yield * parallel( map(source, ({ key, value }) => { return async () => { await this.put(key, value) - return { key, value } + return key } }), this.putManyConcurrency @@ -176,11 +178,14 @@ export class FsDatastore extends BaseDatastore { return data } - async * getMany (source: AwaitIterable): AsyncIterable { + async * getMany (source: AwaitIterable): AsyncIterable { yield * parallel( map(source, key => { return async () => { - return await this.get(key) + return { + key, + value: await this.get(key) + } } }), this.getManyConcurrency From 2a154413613abb177770fa9a5b668b34c3869c71 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 23 Mar 2023 10:50:16 +0000 Subject: [PATCH 35/36] chore(release): 9.0.1 [skip ci] ## [9.0.1](https://github.com/ipfs/js-datastore-fs/compare/v9.0.0...v9.0.1) (2023-03-23) ### Dependencies * update interface-store to 5.x.x ([#183](https://github.com/ipfs/js-datastore-fs/issues/183)) ([803df0b](https://github.com/ipfs/js-datastore-fs/commit/803df0bc96860352957fb06fee109a705124a273)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed04e6d..cbecfd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [9.0.1](https://github.com/ipfs/js-datastore-fs/compare/v9.0.0...v9.0.1) (2023-03-23) + + +### Dependencies + +* update interface-store to 5.x.x ([#183](https://github.com/ipfs/js-datastore-fs/issues/183)) ([803df0b](https://github.com/ipfs/js-datastore-fs/commit/803df0bc96860352957fb06fee109a705124a273)) + ## [9.0.0](https://github.com/ipfs/js-datastore-fs/compare/v8.0.0...v9.0.0) (2023-03-14) diff --git a/package.json b/package.json index cda89a7..a9d59a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datastore-fs", - "version": "9.0.0", + "version": "9.0.1", "description": "Datastore implementation with file system backend", "author": "Friedel Ziegelmayer", "license": "Apache-2.0 OR MIT", From 53f612cee761295061bbde8bddc5a5902754e86f Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 23 Mar 2023 17:02:54 +0000 Subject: [PATCH 36/36] chore: add moved notice --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3028612..6931a04 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# ⛔️ This module is now part of https://github.com/ipfs/js-stores + # datastore-fs [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)