From 1fa3f8899725223250e36bd4fe92fa0661aa5491 Mon Sep 17 00:00:00 2001 From: prash3r Date: Fri, 16 Sep 2022 10:25:31 +0200 Subject: [PATCH] adds the 'cbpi create' command to vscode. also initilizes plugin names with dashes instead of underscores. everything now runs as root inside the dev container (otherwise the permissions for cbpi create wouldnt be sufficient). --- .devcontainer/devcontainer.json | 2 +- .gitignore | 4 +++- .vscode/launch.json | 8 ++++++++ cbpi/cli.py | 2 +- cbpi/configFolder.py | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 08f216c..ae59030 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -47,5 +47,5 @@ //"postCreateCommand": "pip3 install -r ./requirements.txt", // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" + // "remoteUser": "vscode" } diff --git a/.gitignore b/.gitignore index 20ad518..32b01ba 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,6 @@ node_modules config/* logs/ .coverage -.devcontainer/cbpi-dev-config/* \ No newline at end of file +.devcontainer/cbpi-dev-config/* +cbpi4-* +temp* \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index a3c07c1..1dd8992 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,6 +14,14 @@ "preLaunchTask": "copy default cbpi config files if dev config files dont exist" }, + { + "name": "create CraftBeerPi4 plugin", + "type": "python", + "request": "launch", + "module": "run", + "args": ["--config-folder-path=./.devcontainer/cbpi-dev-config", "create"] + }, + { "name": "setup CraftBeerPi4: create config folder structure", "type": "python", diff --git a/cbpi/cli.py b/cbpi/cli.py index 1496764..fcec9de 100644 --- a/cbpi/cli.py +++ b/cbpi/cli.py @@ -87,7 +87,7 @@ class CraftBeerPiCli(): answers = prompt(questions) - name = "cbpi4_" + answers["name"] + name = "cbpi4-" + str(answers["name"]).replace('_', '-').replace(' ', '-') if os.path.exists(os.path.join(".", name)) is True: print("Cant create Plugin. Folder {} already exists ".format(name)) return diff --git a/cbpi/configFolder.py b/cbpi/configFolder.py index 88ee8b8..954f1a3 100644 --- a/cbpi/configFolder.py +++ b/cbpi/configFolder.py @@ -97,6 +97,7 @@ class ConfigFolder: ['dashboard/widgets', 'folder'], ['dashboard', 'folder'], ['fermenterrecipes', 'folder'], + [self.logsFolderPath, 'folder'], ['recipes', 'folder'], ['upload', 'folder'] ] @@ -172,6 +173,7 @@ class ConfigFolder: def create_folders(self): pathlib.Path(self.configFolderPath).mkdir(parents=True, exist_ok=True) + pathlib.Path(self.logsFolderPath).mkdir(parents=True, exist_ok=True) pathlib.Path(os.path.join(self.configFolderPath, 'dashboard', 'widgets')).mkdir(parents=True, exist_ok=True) pathlib.Path(os.path.join(self.configFolderPath, 'recipes')).mkdir(parents=True, exist_ok=True) pathlib.Path(os.path.join(self.configFolderPath, 'fermenterrecipes')).mkdir(parents=True, exist_ok=True)