8 Commits

Author SHA1 Message Date
nicwands
406f8ddb74 0.2.0 2026-03-02 11:58:01 -05:00
nicwands
cf8574664f remove md test files 2026-03-02 11:57:56 -05:00
nicwands
036a19bf88 update adapter to encrypted format 2026-03-02 11:57:30 -05:00
nicwands
8f86e354c0 0.1.1 2026-02-25 22:15:04 -05:00
nicwands
55598053b9 fix sdk import 2026-02-25 22:14:49 -05:00
nicwands
8a0b27992c reset version/package 2026-02-25 22:12:30 -05:00
nicwands
6ec688b994 1.6.0 2026-02-24 14:28:39 -05:00
nicwands
990ed9dcec esm only 2026-02-24 14:28:27 -05:00
11 changed files with 1173 additions and 130 deletions

1197
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +1,28 @@
{
"name": "takerofnotes-plugin-filesystem",
"version": "1.5.0",
"name": "@takerofnotes/plugin-filesystem",
"version": "0.2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/nicwands/takerofnotes-plugin-filesystem.git"
},
"type": "module",
"main": "dist/index.js",
"exports": {
".": "./dist/index.js"
},
"exports": "./dist/index.js",
"scripts": {
"build": "rollup -c",
"test": "vitest",
"prepublishOnly": "npm run build"
},
"author": "nicwands",
"license": "MIT",
"description": "Filesystem storage plugin for Taker of Notes",
"dependencies": {
"gray-matter": "^4.0.3",
"takerofnotes-plugin-sdk": "^0.4.0"
"@takerofnotes/plugin-sdk": "^0.3.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"rollup": "^4.59.0"
"rollup": "^4.59.0",
"vitest": "^3.0.0"
}
}

View File

@@ -1,3 +1,4 @@
// rollup.config.js
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'

View File

@@ -1,5 +1,4 @@
import { BaseNotesAdapter } from 'takerofnotes-plugin-sdk'
import matter from 'gray-matter'
import { BaseNotesAdapter } from '@takerofnotes/plugin-sdk'
import fs from 'fs/promises'
import path from 'path'
@@ -21,16 +20,13 @@ export default class FileSystemAdapter extends BaseNotesAdapter {
const notes = []
for (const file of files) {
if (!file.endsWith('.md')) continue
if (!file.endsWith('.json')) continue
const fullPath = path.join(this.notesDir, file)
const raw = await fs.readFile(fullPath, 'utf8')
const parsed = matter(raw)
const fileContent = await fs.readFile(fullPath, 'utf8')
const parsedFile = JSON.parse(fileContent)
notes.push({
...parsed.data,
content: parsed.content,
})
notes.push(parsedFile)
}
return notes
@@ -45,21 +41,15 @@ export default class FileSystemAdapter extends BaseNotesAdapter {
}
async delete(id) {
const filePath = path.join(this.notesDir, `${id}.md`)
const filePath = path.join(this.notesDir, `${id}.json`)
await fs.unlink(filePath)
}
async _write(note) {
const filePath = path.join(this.notesDir, `${note.id}.md`)
const filePath = path.join(this.notesDir, `${note.id}.json`)
const fileContent = matter.stringify(note.content, {
id: note.id,
title: note.title,
category: note.category ?? null,
createdAt: note.createdAt,
updatedAt: note.updatedAt,
})
const stringifiedNote = JSON.stringify(note)
await fs.writeFile(filePath, fileContent, 'utf8')
await fs.writeFile(filePath, stringifiedNote, 'utf8')
}
}

View File

@@ -1,12 +1,12 @@
import FileSystemAdapter from './FileSystemAdapter'
import { definePlugin } from 'takerofnotes-plugin-sdk'
import { definePlugin } from '@takerofnotes/plugin-sdk'
export default definePlugin({
id: 'filesystem',
name: 'Filesystem',
description: 'Store notes as markdown files on your local filesystem',
version: '1.5.0',
apiVersion: '0.4.0',
version: '0.1.0',
apiVersion: '0.3.1',
configSchema: [
{
key: 'notesDir',

45
test/plugin.test.js Normal file
View File

@@ -0,0 +1,45 @@
import { describe, it } from 'vitest'
import { runPluginTests } from '@takerofnotes/plugin-sdk'
import plugin from './src/index.js'
import FileSystemAdapter from './src/FileSystemAdapter.js'
import path from 'path'
import { fileURLToPath } from 'url'
import fs from 'fs'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const testDir = path.join(__dirname, 'test-notes')
if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true })
}
const adapter = new FileSystemAdapter({ notesDir: testDir })
const tests = runPluginTests({ plugin, adapter })
describe('Plugin Validation', () => {
tests.validatePlugin(it, (a, b) => expect(a).toBe(b))
})
describe('Adapter: init()', () => {
tests.init(it)
})
describe('Adapter: getAll()', () => {
tests.getAll(it)
})
describe('Adapter: create()', () => {
tests.create(it)
})
describe('Adapter: update()', () => {
tests.update(it)
})
describe('Adapter: delete()', () => {
tests.delete(it)
})
describe('Full CRUD Cycle', () => {
tests.crudCycle(it)
})

View File

@@ -0,0 +1 @@
{"id":"test-create-note","data":"test-data"}

View File

@@ -0,0 +1 @@
{"id":"test-note-1","data":"test-data"}

View File

@@ -0,0 +1 @@
{"id":"test-update-note-2","data":"Updated data v2"}

View File

@@ -0,0 +1 @@
{"id":"test-update-note","data":"Updated data"}

7
vitest.config.js Normal file
View File

@@ -0,0 +1,7 @@
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
globals: true,
},
})