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 { Astal, Gtk } from "ags/gtk4";
|
||||||
import { execAsync } from "ags/process";
|
import { execAsync } from "ags/process";
|
||||||
import css from "./homelab.css";
|
import css from "./homelab.css";
|
||||||
|
import { writeFile } from "ags/file";
|
||||||
import GLib from "gi://GLib";
|
import GLib from "gi://GLib";
|
||||||
|
|
||||||
let hasConfig = false;
|
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) {
|
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`;
|
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 {
|
try {
|
||||||
GLib.mkdir_with_parents(GLib.path_get_dirname(CONFIG_PATH), 0o755);
|
writeFile(CONFIG_PATH, yaml);
|
||||||
const ok = GLib.file_set_contents(CONFIG_PATH, yaml);
|
|
||||||
print(`[homelab] save: dir created, write=${ok}`);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(`[homelab] save error: ${e}`);
|
print(`[homelab] save error: ${e}`);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user