-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (25 loc) · 802 Bytes
/
Copy pathindex.js
File metadata and controls
30 lines (25 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* plugins/todo/index.js
*
* TODO Plugin — Minimal lifecycle entry point.
*
* Tools (tools/) and routes (routes/) are auto-discovered by the Hanako
* plugin manager; no manual registration needed here.
*
* This file only ensures the data directory and initial todos.json exist.
*/
import fs from "node:fs";
import path from "node:path";
export default class TodoPlugin {
async onload() {
const { dataDir, log } = this.ctx;
// Ensure data directory
fs.mkdirSync(dataDir, { recursive: true });
// Seed an empty todos.json if it doesn't exist
const storePath = path.join(dataDir, "todos.json");
if (!fs.existsSync(storePath)) {
fs.writeFileSync(storePath, JSON.stringify({ todos: [] }, null, 2), "utf-8");
}
log.info("todo plugin loaded");
}
}