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.
- package/dist/{chunk-PAZWJPY7.js → chunk-46RJJUZ6.js} +29 -20
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -4
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
25
|
-
conf.set("convexUrl", cfg.convexUrl);
|
|
26
|
-
conf.set("apiKey", cfg.apiKey);
|
|
31
|
+
writeConfigFile(cfg);
|
|
27
32
|
}
|
|
28
33
|
function clearConfig() {
|
|
29
|
-
|
|
30
|
-
|
|
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
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-sync-plugin",
|
|
3
|
-
"version": "0.1.
|
|
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",
|