diff --git a/.gitignore b/.gitignore index 328d5dc9..09e08a1c 100644 --- a/.gitignore +++ b/.gitignore @@ -54,10 +54,6 @@ coverage.xml # any locally generated log stuff: *.log -# Flask stuff: -instance/ -.webassets-cache - # PyBuilder target/ diff --git a/.pre-commit-config.yml b/.pre-commit-config.yaml similarity index 90% rename from .pre-commit-config.yml rename to .pre-commit-config.yaml index ec09eca7..c9f81ebb 100644 --- a/.pre-commit-config.yml +++ b/.pre-commit-config.yaml @@ -5,4 +5,4 @@ repos: # make sure the poetry config does not get committed in a broken state - id: poetry-check # make sure the lock file is up-to-date when committing changes - - id: poetry-lock + # - id: poetry-lock diff --git a/onboardme/__init__.py b/onboardme/__init__.py index 6c127308..4cb83001 100755 --- a/onboardme/__init__.py +++ b/onboardme/__init__.py @@ -91,17 +91,17 @@ def setup_logger(level="", log_file=""): @option('--remote_host', '-r', metavar="IP_ADDR", multiple=True, help=HELP['remote_host']) @option('--version', is_flag=True, help=HELP['version']) -def main(log_level: str = "WARN", - log_file: str = "", - steps: str = STEPS.join(','), - git_url: str = "https://github.com/jessebot/dot_files.git", - git_branch: str = "main", - overwrite: bool = False, - pkg_managers: str = PKG_MNGRS.join(','), - pkg_groups: str = "default", - firewall: bool = False, - remote_host: str = "", - version: bool = False): +def main(log_level: str = USR_CONFIG_FILE['log']['level'], + log_file: str = USR_CONFIG_FILE['log']['file'], + steps: str = USR_CONFIG_FILE['steps'][OS[0]], + git_url: str = USR_CONFIG_FILE['dot_files']['git_url'], + git_branch: str = USR_CONFIG_FILE['dot_files']['git_branch'], + overwrite: bool = USR_CONFIG_FILE['dot_files']['overwrite'], + pkg_managers: str = USR_CONFIG_FILE['package']['managers'][OS[0]], + pkg_groups: str = USR_CONFIG_FILE['package']['groups'], + firewall: bool = USR_CONFIG_FILE['firewall'], + remote_host=USR_CONFIG_FILE['remote_hosts'], + version=False) -> bool: """ If present, config: XDG_CONFIG_HOME/onboardme/[packages.yml, config.yml] If run with no options on Linux, it will install brew, pip3.11, apt, @@ -157,7 +157,7 @@ def main(log_level: str = "WARN", configure_firewall(remote_host) print_manual_steps() - return + return True if __name__ == '__main__': diff --git a/onboardme/constants.py b/onboardme/constants.py index ef1574c0..382e9159 100644 --- a/onboardme/constants.py +++ b/onboardme/constants.py @@ -8,6 +8,9 @@ from importlib.metadata import version as get_version from xdg_base_dirs import xdg_config_home from os import getenv, path, uname +from pathlib import Path +import wget +import yaml # version of onboardme @@ -15,7 +18,6 @@ # pathing XDG_CONFIG_DIR = xdg_config_home() -ONBOARDME_CONFIG_DIR = path.join(xdg_config_home(), 'onboardme') PWD = path.dirname(__file__) HOME_DIR = getenv("HOME") @@ -33,3 +35,26 @@ PKG_MNGRS = ['brew','pip3.11'] if OS[0] == 'Linux': PKG_MNGRS.extend(['apt','snap','flatpak']) + + +default_dotfiles = ("https://raw.githubusercontent.com/jessebot/dot_files/" + "main/.config/onboardme/") + + +def load_cfg(config_file='config.yml') -> dict: + """ + load yaml config files for onboardme + """ + config_dir = path.join(xdg_config_home(), 'onboardme') + config_full_path = path.join(config_dir, config_file) + + # defaults + if not path.exists(config_full_path): + Path(config_dir).mkdir(exist_ok=True) + wget.download(default_dotfiles + config_file, config_full_path) + + with open(config_full_path, 'r') as yaml_file: + return yaml.safe_load(yaml_file) + + +USR_CONFIG_FILE = load_cfg() diff --git a/onboardme/env_config.py b/onboardme/env_config.py index 211cf951..079734fe 100755 --- a/onboardme/env_config.py +++ b/onboardme/env_config.py @@ -4,42 +4,13 @@ import logging as log -# for system data, environment data, and checking/joining paths -from os import path -from pathlib import Path - # rich helps pretty print everything from rich.prompt import Confirm -import yaml # custom libs -from .constants import OS, ONBOARDME_CONFIG_DIR +from .constants import OS, USR_CONFIG_FILE from .console_logging import print_panel -import wget - - -default_dotfiles = ("https://raw.githubusercontent.com/jessebot/dot_files/" - "main/.config/onboardme/") - - -def load_cfg(config_file: str) -> dict: - """ - load yaml config files for onboardme - """ - config_full_path = path.join(ONBOARDME_CONFIG_DIR, config_file) - - # defaults - if not path.exists(config_full_path): - Path(ONBOARDME_CONFIG_DIR).mkdir(exist_ok=True) - wget.download(default_dotfiles + config_file, config_full_path) - - with open(config_full_path, 'r') as yaml_file: - return yaml.safe_load(yaml_file) - - -USR_CONFIG_FILE = load_cfg("config.yml") - def check_os_support(): """