@mindtnv/todoist-cli 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +44 -51
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -657,66 +657,59 @@ function createPaletteRegistry() {
657
657
  }
658
658
 
659
659
  // src/plugins/storage.ts
660
- import { Database } from "bun:sqlite";
661
- import { mkdirSync as mkdirSync3, existsSync as existsSync3 } from "fs";
660
+ import { mkdirSync as mkdirSync3, existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
662
661
  import { join as join3 } from "path";
662
+ function loadJson(path, fallback) {
663
+ if (!existsSync3(path))
664
+ return fallback;
665
+ try {
666
+ return JSON.parse(readFileSync3(path, "utf-8"));
667
+ } catch {
668
+ return fallback;
669
+ }
670
+ }
671
+ function saveJson(path, data) {
672
+ writeFileSync3(path, JSON.stringify(data, null, 2) + `
673
+ `);
674
+ }
663
675
  function createPluginStorage(dataDir) {
664
676
  if (!existsSync3(dataDir)) {
665
677
  mkdirSync3(dataDir, { recursive: true });
666
678
  }
667
- const dbPath = join3(dataDir, "data.db");
668
- const db = new Database(dbPath);
669
- db.run("CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, value TEXT)");
670
- db.run("CREATE TABLE IF NOT EXISTS task_data (task_id TEXT, key TEXT, value TEXT, PRIMARY KEY (task_id, key))");
671
- const getStmt = db.prepare("SELECT value FROM kv WHERE key = ?");
672
- const setStmt = db.prepare("INSERT OR REPLACE INTO kv (key, value) VALUES (?, ?)");
673
- const delStmt = db.prepare("DELETE FROM kv WHERE key = ?");
674
- const listStmt = db.prepare("SELECT key FROM kv WHERE key LIKE ? ESCAPE '\\'");
675
- const getTaskStmt = db.prepare("SELECT value FROM task_data WHERE task_id = ? AND key = ?");
676
- const setTaskStmt = db.prepare("INSERT OR REPLACE INTO task_data (task_id, key, value) VALUES (?, ?, ?)");
679
+ const kvPath = join3(dataDir, "kv.json");
680
+ const taskDataPath = join3(dataDir, "task-data.json");
681
+ let kv = loadJson(kvPath, {});
682
+ let taskData = loadJson(taskDataPath, {});
677
683
  return {
678
684
  async get(key) {
679
- const row = getStmt.get(key);
680
- if (!row)
681
- return null;
682
- try {
683
- return JSON.parse(row.value);
684
- } catch {
685
- console.warn("[plugin-storage] Corrupted data for key:", key);
686
- return null;
687
- }
685
+ const value = kv[key];
686
+ return value !== undefined ? value : null;
688
687
  },
689
688
  async set(key, value) {
690
- const serialized = JSON.stringify(value);
691
- setStmt.run(key, serialized);
689
+ kv[key] = value;
690
+ saveJson(kvPath, kv);
692
691
  },
693
692
  async delete(key) {
694
- delStmt.run(key);
693
+ delete kv[key];
694
+ saveJson(kvPath, kv);
695
695
  },
696
696
  async list(prefix) {
697
- const escapedPrefix = prefix ? prefix.replace(/[%_\\]/g, (ch) => `\\${ch}`) : "";
698
- const pattern = prefix ? `${escapedPrefix}%` : "%";
699
- const rows = listStmt.all(pattern);
700
- return rows.map((r) => r.key);
697
+ const keys = Object.keys(kv);
698
+ if (!prefix)
699
+ return keys;
700
+ return keys.filter((k) => k.startsWith(prefix));
701
701
  },
702
702
  async getTaskData(taskId, key) {
703
- const row = getTaskStmt.get(taskId, key);
704
- if (!row)
705
- return null;
706
- try {
707
- return JSON.parse(row.value);
708
- } catch {
709
- console.warn("[plugin-storage] Corrupted data for key:", `${taskId}:${key}`);
710
- return null;
711
- }
703
+ const value = taskData[taskId]?.[key];
704
+ return value !== undefined ? value : null;
712
705
  },
713
706
  async setTaskData(taskId, key, value) {
714
- const serialized = JSON.stringify(value);
715
- setTaskStmt.run(taskId, key, serialized);
707
+ if (!taskData[taskId])
708
+ taskData[taskId] = {};
709
+ taskData[taskId][key] = value;
710
+ saveJson(taskDataPath, taskData);
716
711
  },
717
- close() {
718
- db.close();
719
- }
712
+ close() {}
720
713
  };
721
714
  }
722
715
  var init_storage = () => {};
@@ -795,7 +788,7 @@ var init_api_proxy = __esm(() => {
795
788
 
796
789
  // src/plugins/loader.ts
797
790
  import { join as join4 } from "path";
798
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
791
+ import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
799
792
  import { homedir as homedir3 } from "os";
800
793
  function createLogger(pluginName) {
801
794
  return {
@@ -843,7 +836,7 @@ async function loadPlugins(hooks, views, extensions, palette) {
843
836
  let manifest = null;
844
837
  if (existsSync4(manifestPath)) {
845
838
  try {
846
- manifest = JSON.parse(readFileSync3(manifestPath, "utf-8"));
839
+ manifest = JSON.parse(readFileSync4(manifestPath, "utf-8"));
847
840
  } catch (parseErr) {
848
841
  console.warn(`[plugins] Invalid plugin.json for "${name}":`, parseErr instanceof Error ? parseErr.message : parseErr);
849
842
  }
@@ -8482,13 +8475,13 @@ Examples:
8482
8475
  }
8483
8476
  let description = opts.description;
8484
8477
  if (opts.editor) {
8485
- const { writeFileSync: writeFileSync3, readFileSync: readFileSync4 } = await import("node:fs");
8478
+ const { writeFileSync: writeFileSync4, readFileSync: readFileSync5 } = await import("node:fs");
8486
8479
  const { spawnSync } = await import("node:child_process");
8487
8480
  const tmpFile = `/tmp/todoist-desc-${Date.now()}.md`;
8488
- writeFileSync3(tmpFile, description ?? "");
8481
+ writeFileSync4(tmpFile, description ?? "");
8489
8482
  const editor = process.env.EDITOR || process.env.VISUAL || "vi";
8490
8483
  spawnSync(editor, [tmpFile], { stdio: "inherit" });
8491
- description = readFileSync4(tmpFile, "utf-8");
8484
+ description = readFileSync5(tmpFile, "utf-8");
8492
8485
  if (description.trim() === "")
8493
8486
  description = undefined;
8494
8487
  }
@@ -9465,12 +9458,12 @@ function registerSectionCommand(program) {
9465
9458
 
9466
9459
  // src/cli/completion.ts
9467
9460
  init_config();
9468
- import { existsSync as existsSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
9461
+ import { existsSync as existsSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
9469
9462
  import { join as join5 } from "path";
9470
9463
  import chalk18 from "chalk";
9471
9464
  var COMPLETION_CACHE_PATH = join5(CONFIG_DIR, ".completion-cache.json");
9472
9465
  function saveCompletionCache(cache) {
9473
- writeFileSync3(COMPLETION_CACHE_PATH, JSON.stringify(cache, null, 2), "utf-8");
9466
+ writeFileSync4(COMPLETION_CACHE_PATH, JSON.stringify(cache, null, 2), "utf-8");
9474
9467
  }
9475
9468
  var BASH_COMPLETION = `#!/usr/bin/env bash
9476
9469
  # todoist CLI bash completion
@@ -10226,7 +10219,7 @@ import chalk25 from "chalk";
10226
10219
  // src/plugins/installer.ts
10227
10220
  init_config();
10228
10221
  import { join as join6, resolve } from "path";
10229
- import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync5, rmSync, symlinkSync, lstatSync } from "fs";
10222
+ import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync6, rmSync, symlinkSync, lstatSync } from "fs";
10230
10223
  import { homedir as homedir4 } from "os";
10231
10224
  import { execSync } from "child_process";
10232
10225
  var PLUGINS_DIR2 = join6(homedir4(), ".config", "todoist-cli", "plugins");
@@ -10276,7 +10269,7 @@ async function installPlugin(source) {
10276
10269
  const manifestPath = join6(targetDir, "plugin.json");
10277
10270
  let manifest = null;
10278
10271
  if (existsSync6(manifestPath)) {
10279
- manifest = JSON.parse(readFileSync5(manifestPath, "utf-8"));
10272
+ manifest = JSON.parse(readFileSync6(manifestPath, "utf-8"));
10280
10273
  name = manifest.name;
10281
10274
  }
10282
10275
  setPluginEntry(name, { source });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindtnv/todoist-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "A fast, keyboard-driven Todoist client for the terminal — interactive TUI and scriptable CLI",
5
5
  "type": "module",
6
6
  "bin": {