@dahch/heimdall 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +188 -0
- package/dist/cli.js +2227 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Heimdall (`hmd`)
|
|
2
|
+
|
|
3
|
+
> A dynamic, resilient, and modern CLI to inspect, validate, and update system packages, runtimes, and global tools across macOS and Linux.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@dahch/heimdall)
|
|
6
|
+
[](https://github.com/dahch/heimdall/actions/workflows/publish.yml)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
[](https://vitest.dev/)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## β¨ Features
|
|
15
|
+
|
|
16
|
+
- π **Dynamic Discovery**: Automatically identifies which package managers are installed on the host operating system without requiring static machine configuration.
|
|
17
|
+
- π‘ **Extremely Resilient**: Network timeouts, missing binaries, or individual package build errors are isolated gracefully. If one package or manager encounters an issue, all other managers continue uninterrupted.
|
|
18
|
+
- π **Two-Phase Workflow**:
|
|
19
|
+
1. **Detection & Bounded Scan**: Available package managers are checked concurrently using an internal worker pool (concurrency limit of 4) to query pending updates without overloading CPU or network.
|
|
20
|
+
2. **Aggregated Review & Confirmation**: Shows an interactive tabular overview comparing current and latest package versions across all managers, prompting for confirmation before modifying the system.
|
|
21
|
+
- π§ͺ **True Simulated Dry-Run (`--dry-run`)**: Traverses the full engine lifecycle, formats outdated packages, and executes mock update routines step-by-step with real-time feedback without touching system files.
|
|
22
|
+
- β‘ **High-Speed Registry Queries**: Yarn and pipx bypass heavy CLI subprocess spawning by querying the npm Registry and PyPI JSON APIs directly over HTTP with strict 3-second abort timeouts.
|
|
23
|
+
- π **Non-Interactive Sudo Pre-Checks**: Privileged managers (MacPorts, Linux APT) verify cached credentials using `sudo -n true` beforehand, preventing terminal lockups and password prompt hangs.
|
|
24
|
+
- π¨ **Modern Minimalist UX**: Terminal interface powered by `@clack/prompts`, micro-border tabular layouts with directional version transitions (`current β latest`), persistent real-time step progression with elapsed durations, and actionable error extraction.
|
|
25
|
+
- π· **Dynamic Version Resolution**: Reads package name and version dynamically from `package.json` at runtime via `import.meta.url`, ensuring banners and `--version` flags remain in sync with repository releases.
|
|
26
|
+
- β **Flexible Targeting**: Run interactively, execute non-interactively with `--yes`, or filter target managers using `--only` and `--exclude`.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## π¦ Supported Package Managers
|
|
31
|
+
|
|
32
|
+
Heimdall (`hmd`) supports 13 package managers across system, runtime, language, and application store categories:
|
|
33
|
+
|
|
34
|
+
| Manager | Icon | Category | Detection Strategy | Update Routine & Resilience Rules |
|
|
35
|
+
| :--- | :---: | :---: | :--- | :--- |
|
|
36
|
+
| **[Homebrew](https://brew.sh)** | πΊ | `system` | `brew outdated --json=v2` (JSON parsing with raw text fallback) | 1. `brew update`<br>2. Selective upgrade based on pending item types: `brew upgrade --cask` (if only casks), `brew upgrade --formula` (if only formulae), or full `brew upgrade` (if both)<br>3. `brew cleanup` |
|
|
37
|
+
| **[npm (global)](https://www.npmjs.com)** | π¦ | `runtime` | `npm outdated -g --json` (tolerates exit code 1) | 1. Targeted install: `npm install -g --legacy-peer-deps -- <targets>` (batched if multiple, direct if single)<br>2. *Fallback*: If batch install hits peer conflicts, falls back to isolated per-package installs.<br>3. *Script Resilience*: Retries failing packages with `--ignore-scripts -- <target>` if install lifecycle hooks fail (e.g. `only-allow pnpm`). |
|
|
38
|
+
| **[pnpm (global)](https://pnpm.io)** | β‘ | `runtime` | `pnpm outdated -g --format json` (extracts embedded JSON chunks) | `pnpm update -g --latest` |
|
|
39
|
+
| **[Bun](https://bun.sh)** | π | `runtime` | `bun outdated -g` (ASCII table column parser) | 1. `bun add -g <pkg>@latest` (bypasses global semver pin lockouts)<br>2. `bun update -g`<br>3. `bun upgrade` (automatically skipped if Bun is managed via Homebrew) |
|
|
40
|
+
| **[Yarn (global)](https://yarnpkg.com)** | π§Ά | `runtime` | `yarn global list --depth=0` + native npm registry HTTP checks | 1. `yarn global add <pkg>@latest` (bypasses global semver lockouts)<br>2. `yarn global upgrade` |
|
|
41
|
+
| **[Python (pip user)](https://pip.pypa.io)** | π | `language` | `pip3 list --user --outdated --format=json` (targets user site-packages) | `pip3 install --user --upgrade <pkgs>` (complies with PEP 668 externally managed environment protections) |
|
|
42
|
+
| **[pipx](https://pipx.pypa.io)** | π¦ | `language` | `pipx list --json` + native PyPI JSON API lookups | `pipx upgrade-all` |
|
|
43
|
+
| **[Rust (Cargo & Rustup)](https://doc.rust-lang.org/cargo/)** | π¦ | `language` | `rustup check` (toolchains) + `cargo install-update -l` (crates) | 1. `rustup update` (if `rustup` exists)<br>2. `cargo install-update -a` (if `cargo-update` is installed) |
|
|
44
|
+
| **[Ruby Gem](https://rubygems.org)** | π | `language` | `gem outdated` (skips deprecated Apple System Ruby `/usr/bin/gem`) | 1. `gem update --user-install`<br>2. `gem cleanup` |
|
|
45
|
+
| **[MacPorts](https://www.macports.org)** | β | `system` | `port outdated` + non-interactive `sudo -n true` verification | 1. `sudo port selfupdate`<br>2. `sudo port upgrade outdated` |
|
|
46
|
+
| **[Mac App Store (mas)](https://github.com/mas-cli/mas)** | π | `appstore` | `mas outdated` | `mas upgrade` |
|
|
47
|
+
| **[APT (Debian/Ubuntu)](https://wiki.debian.org/Apt)** | π§ | `system` | `apt list --upgradable` + non-interactive `sudo -n true` check | 1. `sudo apt-get update -y`<br>2. `sudo apt-get upgrade -y`<br>3. `sudo apt-get autoremove -y` |
|
|
48
|
+
| **[Flatpak](https://flatpak.org)** | π¦ | `system` | `flatpak remote-ls --updates` | `flatpak update -y --noninteractive` |
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## π Installation & Setup
|
|
53
|
+
|
|
54
|
+
### Global Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install -g @dahch/heimdall
|
|
58
|
+
# or
|
|
59
|
+
bun add -g @dahch/heimdall
|
|
60
|
+
# or
|
|
61
|
+
pnpm add -g @dahch/heimdall
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Prerequisites
|
|
65
|
+
- Node.js >= 20.0.0
|
|
66
|
+
- Bun or pnpm or npm
|
|
67
|
+
|
|
68
|
+
### Local Development Setup
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Clone repository
|
|
72
|
+
git clone https://github.com/dahch/heimdall.git
|
|
73
|
+
cd heimdall
|
|
74
|
+
|
|
75
|
+
# Install dependencies
|
|
76
|
+
bun install
|
|
77
|
+
# or: pnpm install
|
|
78
|
+
|
|
79
|
+
# Build binary with tsup
|
|
80
|
+
bun run build
|
|
81
|
+
# or: pnpm build
|
|
82
|
+
|
|
83
|
+
# Link binary globally
|
|
84
|
+
npm link
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
After linking, both `hmd` (primary short command) and `heimdall` (canonical alias) will be available in your terminal.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## π» CLI Usage
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
hmd [options]
|
|
95
|
+
# Or using the canonical alias:
|
|
96
|
+
heimdall [options]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Options Reference
|
|
100
|
+
|
|
101
|
+
| Flag | Long Flag | Description | Default |
|
|
102
|
+
| :--- | :--- | :--- | :--- |
|
|
103
|
+
| `-y` | `--yes` | Skip confirmation prompt and apply all detected updates automatically | `false` |
|
|
104
|
+
| `-d` | `--dry-run` | Inspect outdated packages and simulate update execution without modifying the host | `false` |
|
|
105
|
+
| `-o` | `--only <mgrs>` | Comma-separated list of managers to include (e.g. `brew,npm,bun`) | *All available* |
|
|
106
|
+
| `-x` | `--exclude <mgrs>` | Comma-separated list of managers to exclude (e.g. `gem,macports`) | *None* |
|
|
107
|
+
| `-t` | `--timeout <ms>` | Network/subprocess timeout per check phase in milliseconds | `25000` |
|
|
108
|
+
| `-v` | `--verbose` | Output detailed diagnostic messages and skipped manager listings | `false` |
|
|
109
|
+
| `-h` | `--help` | Display command help and option summary | β |
|
|
110
|
+
| `-V` | `--version` | Output CLI version (dynamically resolved from `package.json`) | Dynamic |
|
|
111
|
+
|
|
112
|
+
### Usage Examples
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# 1. Standard Interactive Workflow
|
|
116
|
+
# Discovers managers, scans updates, presents color table, prompts for choice
|
|
117
|
+
hmd
|
|
118
|
+
|
|
119
|
+
# 2. Dry-run Mode
|
|
120
|
+
# Discovers managers, scans updates, runs simulated steps through the engine
|
|
121
|
+
hmd --dry-run
|
|
122
|
+
|
|
123
|
+
# 3. Automated Routine (ideal for CI, cron jobs, or shell scripts)
|
|
124
|
+
hmd --yes
|
|
125
|
+
|
|
126
|
+
# 4. Target Specific Package Managers
|
|
127
|
+
hmd --only brew,npm,bun
|
|
128
|
+
|
|
129
|
+
# 5. Exclude Slow or Privileged Managers
|
|
130
|
+
hmd --exclude macports,apt
|
|
131
|
+
|
|
132
|
+
# 6. Adjust Check Timeout & Enable Verbose Diagnostic Logging
|
|
133
|
+
hmd --timeout 40000 --verbose
|
|
134
|
+
|
|
135
|
+
# 7. Using the Canonical Alias
|
|
136
|
+
heimdall --dry-run
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## π§ͺ Testing
|
|
142
|
+
|
|
143
|
+
The test suite is powered by [Vitest](https://vitest.dev/) and provides comprehensive unit coverage for parser routines, engine concurrency, timeout isolation, and manager fallback logic:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Run test suite (Vitest)
|
|
147
|
+
bun run test # or: pnpm test
|
|
148
|
+
|
|
149
|
+
# Run static typecheck
|
|
150
|
+
bun run typecheck
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Test coverage includes:
|
|
154
|
+
- JSON and text parser edge cases (npm exit code 1, mixed pnpm CLI output, bun table formats).
|
|
155
|
+
- Error extraction and sanitization ([`extractErrorMessage`](src/utils/formatting.ts#L6)) handling npm warnings, command failure chains, and clean truncation.
|
|
156
|
+
- Concurrency pool bounds and error isolation in [`UpdaterEngine`](src/core/engine.ts).
|
|
157
|
+
- `NpmManager` targeted batch installation, fallback trigger handling, and `--ignore-scripts` resilience.
|
|
158
|
+
- `HomebrewManager` selective formula vs. cask execution branches.
|
|
159
|
+
- Pre-check behaviors (skipping `/usr/bin/gem`, sudo privilege checks for MacPorts and APT).
|
|
160
|
+
- HTTP registry lookup error handling for Yarn and pipx.
|
|
161
|
+
- Formatting renderers (micro-border table, directional version diffs, execution summary metrics).
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## π Release & Publishing Pipeline
|
|
166
|
+
|
|
167
|
+
Heimdall employs an automated GitHub Actions CI/CD workflow ([`.github/workflows/publish.yml`](.github/workflows/publish.yml)) for publishing to npm:
|
|
168
|
+
|
|
169
|
+
1. **Tag-Driven Trigger**: Releases trigger on git tag pushes matching `v*` (e.g. `v1.0.0`).
|
|
170
|
+
2. **Version Verification**: Verifies tag name strictly matches the `version` field in `package.json`.
|
|
171
|
+
3. **Reproducible Build**: Installs dependencies with `bun install --frozen-lockfile` and builds the bundle via `bun run build`.
|
|
172
|
+
4. **Verification Gates**: Runs the test suite and static typecheck via `bun run test && bun run typecheck`.
|
|
173
|
+
5. **NPM Provenance**: Publishes to npm under `@dahch/heimdall` with cryptographic provenance attestations (`npm publish --provenance`) via OpenID Connect (OIDC).
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## π Documentation
|
|
178
|
+
|
|
179
|
+
- [SPEC.md](SPEC.md): Technical specification, CLI contract, data models, and exit codes.
|
|
180
|
+
- [DESIGN.md](DESIGN.md): System architecture, Two-Phase workflow, Engine concurrency pool, and Mermaid diagrams.
|
|
181
|
+
- [ADR.md](ADR.md): Architectural Decision Records (ADR-001 through ADR-009) documenting key engineering decisions.
|
|
182
|
+
- [AGENTS.md](AGENTS.md): Developer and AI agent reference manual for maintaining and extending the codebase.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## π License
|
|
187
|
+
|
|
188
|
+
MIT Β© [Daniel HernΓ‘ndez](https://github.com)
|