From 622d12bea85ef58b97efbf926da0ec4b1ff411ad Mon Sep 17 00:00:00 2001 From: Janik von Rotz Date: Wed, 14 Oct 2026 17:05:55 +0200 Subject: [PATCH] feat: refactor project init script to be idempotent and update setup output formatting --- .gitignore.template | 4 --- bin/init-project | 56 ++++++++++++++++++++++++++++------------- bin/install-jupyter-lab | 13 ++++++++++ bin/show-project-setup | 12 ++++----- 4 files changed, 58 insertions(+), 27 deletions(-) diff --git a/.gitignore.template b/.gitignore.template index c90ef96..5d0a752 100644 --- a/.gitignore.template +++ b/.gitignore.template @@ -17,10 +17,6 @@ pnpm-workspace.yaml # Obsidian .obsidian/workspace.json -# VitePress -.vitepress/dist -.vitepress/cache - # Python .venv __pycache__ \ No newline at end of file diff --git a/bin/init-project b/bin/init-project index 4da97e5..2f06293 100755 --- a/bin/init-project +++ b/bin/init-project @@ -1,32 +1,54 @@ #!/usr/bin/env bash init-project() { - echo "Init git directory." git init . - echo "Create tmp folder." - mkdir -p tmp + local created=() - echo "Copy gitgnore template." - cp -n "$HOME/taskfile.build/.gitignore.template" ./.gitignore + if [[ ! -d "tmp" ]]; then + mkdir -p tmp + created+=("tmp/") + fi - echo "Copy taskfile template." - cp -n "$HOME/taskfile.build/task.template" ./task + if [[ ! -f ".gitignore" ]]; then + cp "$HOME/taskfile.build/.gitignore.template" ./.gitignore + created+=(".gitignore") + fi - echo "Copy env template." - cp -n "$HOME/taskfile.build/.env.template" ./.env.template + if [[ ! -f "task" ]]; then + cp "$HOME/taskfile.build/task.template" ./task + chmod +x ./task + created+=("task") + fi - echo "Copy agents template." - cp -n "$HOME/taskfile.build/AGENTS.md.template" ./AGENTS.md + if [[ ! -f ".env.template" ]]; then + cp "$HOME/taskfile.build/.env.template" ./.env.template + created+=(".env.template") + fi - echo "Copy changelog template." - cp -n "$HOME/taskfile.build/CHANGELOG.md.template" ./CHANGELOG.md + if [[ ! -f "AGENTS.md" ]]; then + cp "$HOME/taskfile.build/AGENTS.md.template" ./AGENTS.md + created+=("AGENTS.md") + fi - echo "Touch readme file." - touch ./README.md + if [[ ! -f "CHANGELOG.md" ]]; then + cp "$HOME/taskfile.build/CHANGELOG.md.template" ./CHANGELOG.md + created+=("CHANGELOG.md") + fi - echo "Copy license file." - cp "$HOME/taskfile.build/LICENSE" ./LICENSE + if [[ ! -f "README.md" ]]; then + touch ./README.md + created+=("README.md") + fi + + if [[ ! -f "LICENSE" ]] && [[ "$HOME/taskfile.build/LICENSE" != "$PWD/LICENSE" ]]; then + cp "$HOME/taskfile.build/LICENSE" ./LICENSE + created+=("LICENSE") + fi + + if ((${#created[@]} > 0)); then + echo "Created: ${created[*]}" + fi } inp() { init-project "$@" diff --git a/bin/install-jupyter-lab b/bin/install-jupyter-lab index 00df1e7..ebcd539 100755 --- a/bin/install-jupyter-lab +++ b/bin/install-jupyter-lab @@ -15,6 +15,19 @@ install-jupyter-lab() { echo 'Install project dependencies' uv pip install -r "$req_file" + + if [[ -f ".gitignore" ]]; then + if ! grep -q '^\.ipynb_checkpoints$' ".gitignore"; then + echo '' >> ".gitignore" + echo '# Jupyter' >> ".gitignore" + echo '.ipynb_checkpoints' >> ".gitignore" + echo 'Added .ipynb_checkpoints to .gitignore' + else + echo '.ipynb_checkpoints already in .gitignore' + fi + else + echo 'Warning: no .gitignore found; skipping .ipynb_checkpoints entry' + fi } ijl() { diff --git a/bin/show-project-setup b/bin/show-project-setup index f0a438b..191a31d 100755 --- a/bin/show-project-setup +++ b/bin/show-project-setup @@ -23,14 +23,14 @@ show-project-setup() { echo "" echo "Project: $project_name" echo "" - echo "KeePass Database File: $KEEPASS_DATABASE_FILE" - echo "KeePass Database Key File: $KEEPASS_DATABASE_KEY_FILE" - echo "KeePass Entry: $keepass_entry" + echo "KeePass database file: $KEEPASS_DATABASE_FILE" + echo "KeePass database key file: $KEEPASS_DATABASE_KEY_FILE" + echo "KeePass entry: $keepass_entry" echo "" echo "Age key name: $key_name" - echo "Age Key File: $age_key_file" - echo "Age KeePass Entry: $age_keepass_entry" - echo "Age Pass Entry: $age_pass_entry" + echo "Age key file: $age_key_file" + echo "Age KeePass entry: $age_keepass_entry" + echo "Age Pass entry: $age_pass_entry" if [[ -f ".sops.yaml" ]]; then echo "SOPS config:"