update to new sdk

This commit is contained in:
nicwands
2026-03-24 13:56:52 -04:00
parent 406f8ddb74
commit f1c19d453a
4 changed files with 14 additions and 31 deletions

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
22

View File

@@ -45,6 +45,15 @@ export default class FileSystemAdapter extends BaseNotesAdapter {
await fs.unlink(filePath) await fs.unlink(filePath)
} }
async testConnection() {
try {
await fs.access(this.notesDir)
return true
} catch (error) {
return false
}
}
async _write(note) { async _write(note) {
const filePath = path.join(this.notesDir, `${note.id}.json`) const filePath = path.join(this.notesDir, `${note.id}.json`)

View File

@@ -1,7 +1,6 @@
import { describe, it } from 'vitest' import { describe, it } from 'vitest'
import { runPluginTests } from '@takerofnotes/plugin-sdk' import { describePluginTests } from '@takerofnotes/plugin-sdk'
import plugin from './src/index.js' import plugin from './src/index.js'
import FileSystemAdapter from './src/FileSystemAdapter.js'
import path from 'path' import path from 'path'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'url'
import fs from 'fs' import fs from 'fs'
@@ -13,33 +12,6 @@ if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
} }
const adapter = new FileSystemAdapter({ notesDir: testDir }) const adapter = plugin.createAdapter({ notesDir: testDir })
const tests = runPluginTests({ plugin, adapter })
describe('Plugin Validation', () => { describePluginTests({ plugin, adapter }, describe, it, expect)
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

@@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config'
export default defineConfig({ export default defineConfig({
test: { test: {
globals: true, globals: true,
testTimeout: 30000,
}, },
}) })