opencode-sync-plugin 0.1.5 → 0.1.6

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.
@@ -1,33 +1,42 @@
1
1
  // src/index.ts
2
- import Conf from "conf";
3
2
  import { homedir } from "os";
4
3
  import { join } from "path";
5
- var _config = null;
6
- function getConfInstance() {
7
- if (!_config) {
8
- _config = new Conf({
9
- projectName: "opencode-sync",
10
- cwd: join(homedir(), ".config", "opencode-sync"),
11
- configName: "config"
12
- });
4
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
5
+ var CONFIG_DIR = join(homedir(), ".config", "opencode-sync");
6
+ var CONFIG_FILE = join(CONFIG_DIR, "config.json");
7
+ function readConfigFile() {
8
+ try {
9
+ if (!existsSync(CONFIG_FILE)) return null;
10
+ const content = readFileSync(CONFIG_FILE, "utf8");
11
+ return JSON.parse(content);
12
+ } catch {
13
+ return null;
14
+ }
15
+ }
16
+ function writeConfigFile(config) {
17
+ try {
18
+ if (!existsSync(CONFIG_DIR)) {
19
+ mkdirSync(CONFIG_DIR, { recursive: true });
20
+ }
21
+ writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), "utf8");
22
+ } catch {
13
23
  }
14
- return _config;
15
24
  }
16
25
  function getConfig() {
17
- const conf = getConfInstance();
18
- const url = conf.get("convexUrl");
19
- const key = conf.get("apiKey");
20
- if (!url) return null;
21
- return { convexUrl: url, apiKey: key || "" };
26
+ const config = readConfigFile();
27
+ if (!config || !config.convexUrl) return null;
28
+ return config;
22
29
  }
23
30
  function setConfig(cfg) {
24
- const conf = getConfInstance();
25
- conf.set("convexUrl", cfg.convexUrl);
26
- conf.set("apiKey", cfg.apiKey);
31
+ writeConfigFile(cfg);
27
32
  }
28
33
  function clearConfig() {
29
- const conf = getConfInstance();
30
- conf.clear();
34
+ try {
35
+ if (existsSync(CONFIG_FILE)) {
36
+ writeFileSync(CONFIG_FILE, "{}", "utf8");
37
+ }
38
+ } catch {
39
+ }
31
40
  }
32
41
  function getApiKey() {
33
42
  const cfg = getConfig();
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  clearConfig,
4
4
  getConfig,
5
5
  setConfig
6
- } from "./chunk-PAZWJPY7.js";
6
+ } from "./chunk-46RJJUZ6.js";
7
7
 
8
8
  // src/cli.ts
9
9
  import { readFileSync, existsSync } from "fs";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  clearConfig,
4
4
  getConfig,
5
5
  setConfig
6
- } from "./chunk-PAZWJPY7.js";
6
+ } from "./chunk-46RJJUZ6.js";
7
7
  export {
8
8
  OpenCodeSyncPlugin,
9
9
  clearConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sync-plugin",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Sync your OpenCode sessions to the cloud",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,9 +35,6 @@
35
35
  "url": "https://github.com/waynesutton/opencode-sync-plugin"
36
36
  },
37
37
  "license": "MIT",
38
- "dependencies": {
39
- "conf": "^12.0.0"
40
- },
41
38
  "devDependencies": {
42
39
  "@types/node": "^20.0.0",
43
40
  "tsup": "^8.0.0",