tarsk 0.0.4 → 0.0.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/README.md +2 -2
- package/dist/.tarsk/settings.json +1 -0
- package/dist/api/settings.js +4 -2
- package/dist/utils/json-file.js +14 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ZFkdBv23EIOiqPE5DA1g0Q==:B5Nkd/BgquDAp5/PR1HrgnW4DfJkBVknC3WHAh625GN+2RgPV4sQNrs6MryEYeO4CIhgPJ5SKT2SFhsiMInVlN4eK/VFS+UpjkJtIOb9w4PU4vahU73Eg5WYu+paIEdRdJYE5x7zi19CPCiIGZ2R0JMPJlBrmINKHC8PPwMqReg=
|
package/dist/api/settings.js
CHANGED
|
@@ -31,9 +31,11 @@ export async function api_save_settings(c) {
|
|
|
31
31
|
return c.json(getSettings());
|
|
32
32
|
}
|
|
33
33
|
export function getSettings() {
|
|
34
|
-
const
|
|
34
|
+
const defaultSettings = {
|
|
35
35
|
openRouterApiKey: "",
|
|
36
36
|
openRouterURL: defaultOpenRouterURL,
|
|
37
|
-
|
|
37
|
+
defaultModel: defaultModel
|
|
38
|
+
};
|
|
39
|
+
const settings = getJSON("settings", defaultSettings);
|
|
38
40
|
return settings;
|
|
39
41
|
}
|
package/dist/utils/json-file.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import { tarskFolder } from "../api/utils.js";
|
|
3
|
-
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
3
|
+
import { existsSync, mkdir, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
4
4
|
import { decryptString, encryptString } from "../api/encryption.js";
|
|
5
5
|
export function getJSON(name, defaultValue) {
|
|
6
6
|
const filename = join(tarskFolder(), name + '.json');
|
|
7
7
|
if (!existsSync(filename)) {
|
|
8
|
-
|
|
8
|
+
if (!existsSync(tarskFolder())) {
|
|
9
|
+
mkdirSync(tarskFolder(), { recursive: true });
|
|
10
|
+
}
|
|
11
|
+
setJSON(name, defaultValue);
|
|
9
12
|
return defaultValue;
|
|
10
13
|
}
|
|
11
14
|
else {
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
try {
|
|
16
|
+
const data = readFileSync(filename, 'utf-8');
|
|
17
|
+
return JSON.parse(decryptString(data));
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
setJSON(name, defaultValue);
|
|
21
|
+
//console.error(`Error reading ${name}.json: ${e}`);
|
|
22
|
+
return defaultValue;
|
|
23
|
+
}
|
|
14
24
|
}
|
|
15
25
|
}
|
|
16
26
|
export function setJSON(name, value) {
|
package/package.json
CHANGED