fix: writeFile aus ags/file statt raw GLib — erstellt verzeichnisse automatisch
This commit is contained in:
@@ -2,6 +2,7 @@ import app from "ags/gtk4/app";
|
||||
import { Astal, Gtk } from "ags/gtk4";
|
||||
import { execAsync } from "ags/process";
|
||||
import css from "./homelab.css";
|
||||
import { writeFile } from "ags/file";
|
||||
import GLib from "gi://GLib";
|
||||
|
||||
let hasConfig = false;
|
||||
@@ -10,9 +11,7 @@ const CONFIG_PATH = GLib.getenv("HOMELAB_CONFIG") || `${GLib.getenv("HOME")}/.co
|
||||
function saveConfig(host: string, user: string, port: string) {
|
||||
const yaml = `# Homelab Configuration\ngenerated_by: Omeron\n\nserver:\n address: "${host}"\n username: "${user}"\n port: ${port}\n\ncontrol_center:\n refresh_interval: 5\n theme: "dark"\n\nfeatures:\n docker: true\n services: true\n storage: true\n network: true\n monitoring: true\n`;
|
||||
try {
|
||||
GLib.mkdir_with_parents(GLib.path_get_dirname(CONFIG_PATH), 0o755);
|
||||
const ok = GLib.file_set_contents(CONFIG_PATH, yaml);
|
||||
print(`[homelab] save: dir created, write=${ok}`);
|
||||
writeFile(CONFIG_PATH, yaml);
|
||||
} catch (e) {
|
||||
print(`[homelab] save error: ${e}`);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user