|
1 | 1 | # drx |
2 | 2 |
|
3 | | -`drx` is a Dart-first `npx`/`uvx`-style tool runner. |
| 3 | +`drx` runs CLI tools on demand, similar to `npx` / `uvx`. |
4 | 4 |
|
5 | | -- `pub` source: runs Dart package executables. |
6 | | -- `gh` source: runs precompiled binaries from public GitHub Releases. |
7 | | - (language-agnostic: Go/Rust/C/C++/etc. all work) |
| 5 | +- Use `pub.dev` packages when Dart SDK is available. |
| 6 | +- Use GitHub release binaries when Dart SDK is not available. |
8 | 7 |
|
9 | | -## Command Forms |
| 8 | +## Install |
10 | 9 |
|
11 | | -Default source is `pub`: |
12 | | - |
13 | | -```bash |
14 | | -drx <package[@version]> [--] [args...] |
15 | | -drx <package:executable[@version]> [--] [args...] |
16 | | -``` |
17 | | - |
18 | | -Explicit source: |
19 | | - |
20 | | -```bash |
21 | | -drx --from pub:<package[@version]> <command> [--] [args...] |
22 | | -drx --from gh:<owner>/<repo[@tag]> <command> [--] [args...] |
23 | | -drx cache [list|clean|prune] [--json] |
24 | | -drx versions <package|pub:pkg|gh:owner/repo> [--limit N] [--json] |
25 | | -``` |
26 | | - |
27 | | -Examples: |
| 10 | +### With Dart SDK (pub.dev) |
28 | 11 |
|
29 | 12 | ```bash |
30 | | -drx melos -- --version |
31 | | -drx mason_cli:mason -- --help |
32 | | -drx --from pub:very_good_cli very_good -- --help |
33 | | -drx --from gh:cli/cli@v2.70.0 gh -- version |
34 | | -drx --from gh:BurntSushi/ripgrep rg -- --version |
35 | | -drx --from gh:junegunn/fzf fzf -- --version |
36 | | -drx --from gh:charmbracelet/gum gum -- --version |
37 | | -drx --allow-unsigned --from gh:sharkdp/fd fd -- --version |
38 | | -drx --allow-unsigned --from gh:sharkdp/bat bat -- --version |
39 | | -drx --allow-unsigned --from gh:dandavison/delta delta -- --version |
40 | | -drx versions melos --limit 5 |
41 | | -drx versions gh:cli/cli --limit 10 |
42 | | -drx cache list |
43 | | -drx cache prune --max-age-days 30 --max-size-mb 2048 |
| 13 | +dart pub global activate drx |
| 14 | +drx --version |
44 | 15 | ``` |
45 | 16 |
|
46 | | -Note: some repositories do not publish checksums. Those require |
47 | | -`--allow-unsigned` as shown above. |
48 | | - |
49 | | -## Cross-Platform Support |
50 | | - |
51 | | -- Linux: `x64`, `arm64` |
52 | | -- macOS: `x64` (Intel), `arm64` (Apple Silicon) |
53 | | -- Windows: `x64`, `arm64` |
54 | | - |
55 | | -`drx` handles Windows executable resolution (`.exe`, `.cmd`, `.bat`) and |
56 | | -Unix executable permissions for downloaded binaries. |
57 | | - |
58 | | -## Flags |
59 | | - |
60 | | -- `--runtime auto|jit|aot`: runtime mode for pub executables. |
61 | | -- `--refresh`: refresh cached artifacts. |
62 | | -- `--isolated`: use temporary, non-persistent caches. |
63 | | -- `--asset <name>`: force a specific GitHub asset name. |
64 | | -- `--allow-unsigned`: allow GH assets without checksum manifests. |
65 | | -- `--json`: machine-readable output for `cache` and `versions`. |
66 | | -- `--verbose`: enable verbose logging (currently minimal). |
67 | | - |
68 | | -## Cache And Version Commands |
69 | | - |
70 | | -- `drx cache list`: show cache location, entry counts, and size. |
71 | | -- `drx cache clean`: remove all cached artifacts and lock files. |
72 | | -- `drx cache prune`: remove old cache entries and optionally enforce size limits. |
73 | | - - `--max-age-days N`: remove entries older than N days (default: 30 for prune). |
74 | | - - `--max-size-mb N`: keep cache under N MB by removing oldest entries. |
75 | | - - `--json`: output prune/list/clean results as JSON. |
76 | | -- `drx versions <target>`: list available versions from pub.dev or GH releases. |
77 | | - - falls back to repository tags when GH releases are not present. |
78 | | - - `--json`: output version list as JSON. |
79 | | - - pub targets: `melos`, `pub:melos`, `mason_cli:mason` |
80 | | - - gh targets: `gh:cli/cli` |
81 | | - |
82 | | -## Runtime Behavior |
83 | | - |
84 | | -- `jit`: uses `dart run package:executable`. |
85 | | -- `aot`: compiles with `dart compile exe` and runs cached native output. |
86 | | -- `auto`: prefers AOT, falls back to JIT when AOT is unsupported or fails. |
87 | | - |
88 | | -`package:cli_launcher` wrappers (for example, recent `melos`) are not compatible |
89 | | -with reliable AOT execution in this model. In `auto` mode, drx falls back to JIT. |
90 | | - |
91 | | -When run without arguments, `drx` shows the help screen. |
92 | | - |
93 | | -Global flags can be placed before utility commands, for example: |
| 17 | +If PATH is not set for pub executables: |
94 | 18 |
|
95 | 19 | ```bash |
96 | | -drx --json versions gh:cli/cli |
97 | | -drx --verbose cache list |
| 20 | +dart pub global run drx:drx --version |
98 | 21 | ``` |
99 | 22 |
|
100 | | -## Security Policy |
101 | | - |
102 | | -- GH asset checksum verification is required by default. |
103 | | -- If no checksum manifest is present, execution is blocked. |
104 | | -- `--allow-unsigned` explicitly bypasses that block. |
105 | | - |
106 | | -## Make Your Tool drx-Compatible |
107 | | - |
108 | | -See the maintainer guide: |
109 | | -[`doc/compatibility.md`](https://github.com/leehack/drx/blob/main/doc/compatibility.md). |
110 | | - |
111 | | -It covers: |
112 | | - |
113 | | -- pub.dev executable compatibility requirements |
114 | | -- GitHub Releases binary compatibility requirements |
115 | | -- checksum formats and naming conventions |
116 | | -- validation commands for both `pub` and `gh` sources |
117 | | - |
118 | | -## Publish To pub.dev |
| 23 | +### Without Dart SDK (precompiled binary) |
119 | 24 |
|
120 | | -Dry-run validation: |
| 25 | +Linux / macOS: |
121 | 26 |
|
122 | 27 | ```bash |
123 | | -dart pub publish --dry-run |
| 28 | +curl -fsSL "https://raw.githubusercontent.com/leehack/drx/main/tool/install.sh" | DRX_REPO=leehack/drx sh |
124 | 29 | ``` |
125 | 30 |
|
126 | | -Publish: |
| 31 | +Windows (PowerShell): |
127 | 32 |
|
128 | | -```bash |
129 | | -dart pub publish |
| 33 | +```powershell |
| 34 | +$env:DRX_REPO = "leehack/drx" |
| 35 | +iwr "https://raw.githubusercontent.com/leehack/drx/main/tool/install.ps1" -UseBasicParsing | iex |
130 | 36 | ``` |
131 | 37 |
|
132 | | -`drx` is intended as the publish name on pub.dev. |
| 38 | +Both installers verify checksums before installing. |
133 | 39 |
|
134 | | -## Install With Dart SDK (pub.dev) |
| 40 | +## Quick Usage |
135 | 41 |
|
136 | | -Install globally with pub: |
| 42 | +Default source is `pub`: |
137 | 43 |
|
138 | 44 | ```bash |
139 | | -dart pub global activate drx |
| 45 | +drx <package[@version]> [--] [args...] |
| 46 | +drx <package:executable[@version]> [--] [args...] |
140 | 47 | ``` |
141 | 48 |
|
142 | | -Install a specific version: |
| 49 | +Explicit source selection: |
143 | 50 |
|
144 | 51 | ```bash |
145 | | -dart pub global activate drx 0.3.0 |
| 52 | +drx --from pub:<package[@version]> <command> [--] [args...] |
| 53 | +drx --from gh:<owner>/<repo[@tag]> <command> [--] [args...] |
146 | 54 | ``` |
147 | 55 |
|
148 | | -Run it: |
| 56 | +Examples: |
149 | 57 |
|
150 | 58 | ```bash |
151 | | -drx --version |
152 | | -``` |
| 59 | +drx melos -- --version |
| 60 | +drx mason_cli:mason -- --help |
| 61 | +drx --from pub:very_good_cli very_good -- --help |
153 | 62 |
|
154 | | -If your PATH is not configured for pub global executables: |
| 63 | +drx --from gh:cli/cli@v2.70.0 gh -- version |
| 64 | +drx --from gh:BurntSushi/ripgrep rg -- --version |
| 65 | +drx --from gh:junegunn/fzf fzf -- --version |
| 66 | +drx --from gh:charmbracelet/gum gum -- --version |
155 | 67 |
|
156 | | -```bash |
157 | | -dart pub global run drx:drx --version |
| 68 | +# Some repos do not publish checksums: |
| 69 | +drx --allow-unsigned --from gh:sharkdp/fd fd -- --version |
158 | 70 | ``` |
159 | 71 |
|
160 | | -Uninstall: |
| 72 | +## Useful Commands |
161 | 73 |
|
162 | 74 | ```bash |
163 | | -dart pub global deactivate drx |
164 | | -``` |
165 | | - |
166 | | -## Install Without Dart SDK (Binary Options) |
167 | | - |
168 | | -For users without Dart installed, publish precompiled binaries in GitHub |
169 | | -Releases and provide platform-specific one-liner installers. |
170 | | - |
171 | | -Recommended options: |
172 | | - |
173 | | -1. `curl | sh` installer for Linux/macOS |
174 | | -2. PowerShell installer for Windows |
175 | | -3. Package managers (Homebrew tap, Scoop, winget, apt/rpm) as follow-ups |
176 | | - |
177 | | -Typical one-liner patterns: |
| 75 | +drx cache list |
| 76 | +drx cache clean |
| 77 | +drx cache prune --max-age-days 30 --max-size-mb 2048 |
178 | 78 |
|
179 | | -```bash |
180 | | -# Linux/macOS |
181 | | -curl -fsSL "https://raw.githubusercontent.com/leehack/drx/main/tool/install.sh" | DRX_REPO=leehack/drx sh |
182 | | -``` |
| 79 | +drx versions melos --limit 5 |
| 80 | +drx versions gh:cli/cli --limit 10 |
183 | 81 |
|
184 | | -```powershell |
185 | | -# Windows PowerShell |
186 | | -$env:DRX_REPO = "leehack/drx" |
187 | | -iwr "https://raw.githubusercontent.com/leehack/drx/main/tool/install.ps1" -UseBasicParsing | iex |
| 82 | +drx --json versions gh:cli/cli |
| 83 | +drx --json cache list |
188 | 84 | ``` |
189 | 85 |
|
190 | | -Install scripts download and verify the matching `.sha256` checksum before |
191 | | -installing binaries. |
| 86 | +## Runtime Modes (pub source) |
192 | 87 |
|
193 | | -The repository includes ready workflows for CI and binary release publishing: |
| 88 | +- `--runtime auto` (default): prefer AOT, fallback to JIT |
| 89 | +- `--runtime jit`: `dart run` |
| 90 | +- `--runtime aot`: compile and run native executable |
194 | 91 |
|
195 | | -- `.github/workflows/ci.yml` |
196 | | -- `.github/workflows/installer-smoke.yml` |
197 | | -- `.github/workflows/release-binaries.yml` |
| 92 | +## Security Defaults |
198 | 93 |
|
199 | | -`release-binaries.yml` runs on pushed tags (`v*`) and also supports manual |
200 | | -dispatch with a required `tag` input. |
| 94 | +- GitHub assets require checksum verification by default. |
| 95 | +- Unsigned assets are blocked unless you pass `--allow-unsigned`. |
201 | 96 |
|
202 | | -`installer-smoke.yml` validates one-liner install scripts on Linux/macOS/Windows |
203 | | -across `x64` and `arm64` runners. |
204 | | - |
205 | | -## Development |
206 | | - |
207 | | -```bash |
208 | | -dart pub get |
209 | | -dart analyze |
210 | | -dart test |
211 | | -``` |
| 97 | +## Platform Support |
212 | 98 |
|
213 | | -### Coverage |
| 99 | +- Linux: `x64`, `arm64` |
| 100 | +- macOS: `x64` (Intel), `arm64` (Apple Silicon) |
| 101 | +- Windows: `x64`, `arm64` |
214 | 102 |
|
215 | | -```bash |
216 | | -dart test --coverage=coverage |
217 | | -dart run coverage:format_coverage --packages=.dart_tool/package_config.json --report-on=lib --in=coverage --out=coverage/lcov.info --lcov --fail-under=80 |
218 | | -dart run tool/check_coverage.dart 80 coverage/lcov.info |
219 | | -``` |
| 103 | +## More Docs |
220 | 104 |
|
221 | | -The repository enforces 80%+ line coverage for `lib/`. |
| 105 | +- Tool maintainer compatibility guide: [`doc/compatibility.md`](https://github.com/leehack/drx/blob/main/doc/compatibility.md) |
| 106 | +- Project maintenance / release notes: [`doc/maintainers.md`](https://github.com/leehack/drx/blob/main/doc/maintainers.md) |
0 commit comments