16 Commits
v1.1.0 ... main

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
nicwands
2684c0f27e 1.5.0 2026-02-24 14:21:12 -05:00
nicwands
28b17d4f08 bump version 2026-02-24 14:20:53 -05:00
nicwands
177eeebc36 1.4.0 2026-02-24 14:18:14 -05:00
nicwands
2c0d357d5d bump api version 2026-02-24 14:17:45 -05:00
nicwands
4982549d7d 1.3.0 2026-02-24 14:07:41 -05:00
nicwands
1f3c7adccb bump api version 2026-02-24 14:07:22 -05:00
nicwands
79a5534440 1.2.0 2026-02-24 13:50:25 -05:00
nicwands
38a1319f2d remove electron dependency 2026-02-24 13:50:13 -05:00
11 changed files with 1103 additions and 850 deletions

1842
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +1,28 @@
{ {
"name": "takerofnotes-plugin-filesystem", "name": "@takerofnotes/plugin-filesystem",
"version": "1.1.0", "version": "0.2.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/nicwands/takerofnotes-plugin-filesystem.git" "url": "git+https://github.com/nicwands/takerofnotes-plugin-filesystem.git"
}, },
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",
"exports": { "exports": "./dist/index.js",
".": "./dist/index.js"
},
"scripts": { "scripts": {
"build": "rollup -c", "build": "rollup -c",
"test": "vitest",
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"author": "nicwands", "author": "nicwands",
"license": "MIT", "license": "MIT",
"description": "Filesystem storage plugin for Taker of Notes", "description": "Filesystem storage plugin for Taker of Notes",
"dependencies": { "dependencies": {
"electron": "^40.6.0", "@takerofnotes/plugin-sdk": "^0.3.1"
"gray-matter": "^4.0.3",
"takerofnotes-plugin-sdk": "^0.1.0"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^29.0.0", "@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-node-resolve": "^16.0.3", "@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 resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs' import commonjs from '@rollup/plugin-commonjs'

View File

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

View File

@@ -1,20 +1,18 @@
import path from 'path'
import { app } from 'electron'
import FileSystemAdapter from './FileSystemAdapter' import FileSystemAdapter from './FileSystemAdapter'
import { definePlugin } from 'takerofnotes-plugin-sdk' import { definePlugin } from '@takerofnotes/plugin-sdk'
export default definePlugin({ export default definePlugin({
id: 'filesystem', id: 'filesystem',
name: 'Filesystem', name: 'Filesystem',
description: 'Store notes as markdown files on your local filesystem', description: 'Store notes as markdown files on your local filesystem',
version: '1.0.0', version: '0.1.0',
apiVersion: '0.1.0', apiVersion: '0.3.1',
configSchema: [ configSchema: [
{ {
key: 'notesDir', key: 'notesDir',
label: 'Notes Directory', label: 'Notes Directory',
type: 'directory', type: 'directory',
default: path.join(app.getPath('userData'), 'notes'), default: '__DEFAULT_USER_DATA__/notes',
required: true, required: true,
}, },
], ],

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,
},
})