opencode-sync-plugin 0.2.3 → 0.2.4
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-JPPDGYOB.js +43 -0
- package/dist/cli.js +1 -1
- package/dist/config.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-SFEFUAIN.js +0 -55
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
var CONFIG_DIR = join(homedir(), ".opensync");
|
|
6
|
+
var CONFIG_FILE = join(CONFIG_DIR, "credentials.json");
|
|
7
|
+
function getConfig() {
|
|
8
|
+
try {
|
|
9
|
+
if (!existsSync(CONFIG_FILE)) return null;
|
|
10
|
+
const content = readFileSync(CONFIG_FILE, "utf8");
|
|
11
|
+
const config = JSON.parse(content);
|
|
12
|
+
if (!config || !config.convexUrl) return null;
|
|
13
|
+
return config;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error("Error reading config:", e);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function setConfig(cfg) {
|
|
20
|
+
try {
|
|
21
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
22
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(cfg, null, 2), "utf8");
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error("Error saving config:", e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function clearConfig() {
|
|
30
|
+
try {
|
|
31
|
+
if (existsSync(CONFIG_FILE)) {
|
|
32
|
+
writeFileSync(CONFIG_FILE, "{}", "utf8");
|
|
33
|
+
}
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error("Error clearing config:", e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
getConfig,
|
|
41
|
+
setConfig,
|
|
42
|
+
clearConfig
|
|
43
|
+
};
|
package/dist/cli.js
CHANGED
package/dist/config.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
package/dist/chunk-SFEFUAIN.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/config.ts
|
|
9
|
-
function getConfigPaths() {
|
|
10
|
-
const { homedir } = __require("os");
|
|
11
|
-
const { join } = __require("path");
|
|
12
|
-
const configDir = join(homedir(), ".opensync");
|
|
13
|
-
const configFile = join(configDir, "credentials.json");
|
|
14
|
-
return { configDir, configFile };
|
|
15
|
-
}
|
|
16
|
-
function getConfig() {
|
|
17
|
-
try {
|
|
18
|
-
const { existsSync, readFileSync } = __require("fs");
|
|
19
|
-
const { configFile } = getConfigPaths();
|
|
20
|
-
if (!existsSync(configFile)) return null;
|
|
21
|
-
const content = readFileSync(configFile, "utf8");
|
|
22
|
-
const config = JSON.parse(content);
|
|
23
|
-
if (!config || !config.convexUrl) return null;
|
|
24
|
-
return config;
|
|
25
|
-
} catch {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function setConfig(cfg) {
|
|
30
|
-
try {
|
|
31
|
-
const { existsSync, writeFileSync, mkdirSync } = __require("fs");
|
|
32
|
-
const { configDir, configFile } = getConfigPaths();
|
|
33
|
-
if (!existsSync(configDir)) {
|
|
34
|
-
mkdirSync(configDir, { recursive: true });
|
|
35
|
-
}
|
|
36
|
-
writeFileSync(configFile, JSON.stringify(cfg, null, 2), "utf8");
|
|
37
|
-
} catch {
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function clearConfig() {
|
|
41
|
-
try {
|
|
42
|
-
const { existsSync, writeFileSync } = __require("fs");
|
|
43
|
-
const { configFile } = getConfigPaths();
|
|
44
|
-
if (existsSync(configFile)) {
|
|
45
|
-
writeFileSync(configFile, "{}", "utf8");
|
|
46
|
-
}
|
|
47
|
-
} catch {
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export {
|
|
52
|
-
getConfig,
|
|
53
|
-
setConfig,
|
|
54
|
-
clearConfig
|
|
55
|
-
};
|