From 2fd69cc5953ca743734e0938dda3414cbf9c4f04 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Sat, 25 Apr 2026 16:43:53 +0200 Subject: [PATCH] feat(init): Templates handling --- commands/init.py | 19 ++++++++++++++----- config.schema.json | 19 +++++++++++++++++++ templates/README.md | 3 +++ templates/config/config.yml | 0 templates/config/system/boot.yml | 0 templates/config/system/git.yml | 0 templates/config/system/pkgs.yml | 0 templates/config/system/theme.yml | 0 templates/config/system/users.yml | 0 templates/config/templates/colors.yml | 0 templates/config/templates/hypr.yml | 0 11 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 templates/README.md create mode 100644 templates/config/config.yml create mode 100644 templates/config/system/boot.yml create mode 100644 templates/config/system/git.yml create mode 100644 templates/config/system/pkgs.yml create mode 100644 templates/config/system/theme.yml create mode 100644 templates/config/system/users.yml create mode 100644 templates/config/templates/colors.yml create mode 100644 templates/config/templates/hypr.yml diff --git a/commands/init.py b/commands/init.py index a67ff07..1694080 100644 --- a/commands/init.py +++ b/commands/init.py @@ -1,19 +1,28 @@ import os +import shutil import commands.util.git as git +from commands.util.input_mgr import confirm def init(force: bool = False): dir = os.getcwd() + script_dir = os.path.dirname(os.path.realpath(__file__)) if force: - [os.remove(dir) for dir in os.listdir(dir)] + if confirm(False, "Do you really want to IRREVERSIBLY DELETE the contents of this folder and redo setup?"): + [os.remove(file) for file in os.listdir(dir)] git.init(dir) os.mkdir(dir + "/config") - os.mkdir(dir + "/etc") - with open(dir + "/config.yaml") as file: - file.write("") + os.mkdir(dir + "/db") + os.mkdir(dir + "/system") + os.mkdir(dir + "/includes") + shutil.copy(script_dir + "/templates/config/config.yml", dir + "/config.yml") + shutil.copy(script_dir + "/templates/config/system/", dir + "/includes/system/") + shutil.copy(script_dir + "/templates/config/templates/", dir + "/includes/templates/") + shutil.copy(script_dir + "/templates/README.md", dir + "/README.md") print("Initialized a new archmgr repository") + # TODO: For the files, store the permissions in a db # TODO: Warn user to not delete .config/archmgr repo # TODO: Set up that repo (where to put it? /usr/share?) - # TODO: Consider collecting function + # TODO: Consider collecting function -> If no files present, will only collect the pkgs, else also the files # TODO: Config folder instead of single config file # TODO: Also store the folder name of the config folder in that repo (needs to be easily changeable for user!) diff --git a/config.schema.json b/config.schema.json index e081743..18e1a9b 100644 --- a/config.schema.json +++ b/config.schema.json @@ -279,6 +279,25 @@ "additionalProperties": false } }, + "symlinks": { + "type": "array", + "description": "Symlinks to create", + "items": { + "type": "object", + "properties": { + "destination": { + "type": "string", + "description": "The directory the link should point to", + "pattern": "^(^(~|\\.|\\.\\.)?\\/)?([\\w\\/.-]+(?!.*[^\\w\\/.-]+))" + }, + "location": { + "type": "string", + "description": "What to call the link", + "pattern": "^(^(~|\\.|\\.\\.)?\\/)?([\\w\\/.-]+(?!.*[^\\w\\/.-]+))" + } + } + } + }, "cmds": { "type": "object", "properties": { diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 0000000..ac13077 --- /dev/null +++ b/templates/README.md @@ -0,0 +1,3 @@ +# archmgr data folder +archmgr is a nixos-inspired package and config manager for Arch Linux. +To function, it needs both a configuration file (or multiple) and diff --git a/templates/config/config.yml b/templates/config/config.yml new file mode 100644 index 0000000..e69de29 diff --git a/templates/config/system/boot.yml b/templates/config/system/boot.yml new file mode 100644 index 0000000..e69de29 diff --git a/templates/config/system/git.yml b/templates/config/system/git.yml new file mode 100644 index 0000000..e69de29 diff --git a/templates/config/system/pkgs.yml b/templates/config/system/pkgs.yml new file mode 100644 index 0000000..e69de29 diff --git a/templates/config/system/theme.yml b/templates/config/system/theme.yml new file mode 100644 index 0000000..e69de29 diff --git a/templates/config/system/users.yml b/templates/config/system/users.yml new file mode 100644 index 0000000..e69de29 diff --git a/templates/config/templates/colors.yml b/templates/config/templates/colors.yml new file mode 100644 index 0000000..e69de29 diff --git a/templates/config/templates/hypr.yml b/templates/config/templates/hypr.yml new file mode 100644 index 0000000..e69de29