refactor: Improve project scaffolding

This commit is contained in:
2026-06-20 19:33:52 +05:30
parent 4318cd8536
commit fce177a0df
10 changed files with 25 additions and 22 deletions

View File

@@ -16,12 +16,15 @@ Bootstrap CLI (`b`) is a bash-based tool installer and system bootstrapper. User
```
bootstrap/
├── installers/ # Individual installer scripts (install_<name>.sh)
├── lib/ # Shared libraries sourced by all installers
├── lib/ # Shared libraries and router sourced by all installers
│ ├── common.sh # Logging, confirm(), has_command(), make_temp_dir()
│ ├── platform.sh # detect_distro(), detect_arch(), pkg_install()
── shell_config.sh # get_shell_configs(), inject_block(), remove_block(), add_alias_if_missing(), add_env_if_missing()
── shell_config.sh # get_shell_configs(), inject_block(), remove_block(), add_alias_if_missing(), add_env_if_missing()
│ ├── registry.sh # Dynamically generated installer registry
│ └── routes.sh # Central router script
├── commands/ # Non-installer commands (help, con, uninstall)
├── routes.sh # Central router + installer registry
├── assets/ # Assets (logo art, etc.)
│ └── pixel_art.ansi
├── bootstrap.sh # Metascript for environment setup + library loading
├── b.sh # The `b` shell function and autocompletion
└── VERSION
@@ -44,7 +47,7 @@ At the top of your new installer script, right below `#!/usr/bin/env bash`, add
# Description: <description>
```
The central router `routes.sh` and autocomplete function in `b.sh` will dynamically parse this metadata from all `install_*.sh` scripts to register the installer and keys automatically! No manual edits to `routes.sh` or `b.sh` are required.
The central router `lib/routes.sh` and autocomplete function in `b.sh` will dynamically parse this metadata from all `install_*.sh` scripts to register the installer and keys automatically! No manual edits to `lib/routes.sh` or `b.sh` are required.
### Step 3: Verify (optional)
@@ -252,7 +255,7 @@ inject_block "$config_file" "<tool> init" 'eval "$(tool init bash)"'
## Rules & Conventions
1. **File naming**: Always `install_<name>.sh` in the `installers/` directory.
2. **Alphabetical order**: Keep `INSTALLERS` entries and `INSTALLER_KEYS` in alphabetical order in `routes.sh`.
2. **Registry generation**: The registry in `lib/registry.sh` is automatically generated by `scripts/generate_registry.sh` (run automatically on commit by the git pre-commit hook).
3. **Confirmation prompts**: Always ask before installing. Check if already installed first.
4. **Idempotent**: Installers must be safe to re-run. Use `inject_block` (not append) for shell configs.
5. **No hardcoded paths**: Use `$HOME`, library functions, and `detect_*` helpers.