@kaynooo/cli-dl 0.0.1 → 0.0.4
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 +10 -2
- package/dist/cli.js +1095 -215
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @kaynooo/cli-dl
|
|
2
2
|
|
|
3
|
-
`dl` downloads a file into a folder of its own and checks its sha256. It can then extract the file, install it as a command, or run it as a script once a sha256 pins it.
|
|
3
|
+
`dl` downloads a file into a folder of its own and checks its sha256, and its signature when asked. It can then extract the file, install it as a command, or run it as a script once a sha256 pins it.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
bun add -g @kaynooo/cli-dl
|
|
@@ -11,19 +11,25 @@ bun add -g @kaynooo/cli-dl
|
|
|
11
11
|
| Command | What it does |
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| `dl <url>` | downloads into a new folder under the temp folder (`-o <dir>` to choose one, never overwriting), and prints the path, size, final URL, type, sha256 and how it compares with the last download of that URL |
|
|
14
|
+
| `dl gh:owner/repo[@tag]`, `dl fj:owner/repo[@tag]` | the same for a GitHub release, or one on git.kaynooo.fr: the newest at least two weeks old (`--fresh` the newest), the asset built for this OS, arch and libc (`--asset <part of its name>` when it cannot tell), checked against the checksums file the release ships, else the sha256 GitHub gives (a release with neither installs with a warning); `--key` alone checks the signature shipped beside it. `GITHUB_TOKEN` lifts GitHub's 60 requests an hour |
|
|
14
15
|
| `dl ls` | the commands `dl` installed and the scripts it ran, with where each came from and when |
|
|
16
|
+
| `dl outdated [name...]` | asks each one's source whether it changed since (a conditional request when the server gave an ETag or Last-Modified, else the sha256 of a new download; for a release, whether a later one is two weeks old; one installed with `@tag` stays on it), lists those that did with the age of the install, exit 1 when one did or its source cannot be reached; `--bins` the commands only, `--json` |
|
|
17
|
+
| `dl update [name...]` | downloads again what changed, every one without names, checked as at install (`--sums`, `--sig`), then installs it or shows the script's diff and runs it with its arguments; a script only a sha256 pinned runs with `--yes`. `doctor` lists the commands behind, `dl update <name>` as the fix |
|
|
15
18
|
|
|
16
19
|
| Option | What it does |
|
|
17
20
|
| --- | --- |
|
|
18
21
|
| `--sha256 <hex>` | the sha256 the file must have; on a mismatch the file is deleted |
|
|
19
22
|
| `--sums <url>` | a checksums file (`SHA256SUMS`, `sha256sum` or BSD style, or a lone hash) giving the file's sha256 |
|
|
23
|
+
| `--sig <url> --key <key>` | a detached signature of the file, or of the `--sums` file when there is one, checked before the file is kept; `--key` is a gpg fingerprint of your keyring or a gpg key file, a minisign key or key file, or a cosign PEM file, and that tool must be on PATH |
|
|
20
24
|
| `--extract`, `-x` | unpacks the archive into a new folder beside it |
|
|
21
25
|
| `--bin [name]` | installs the file, or the one executable its archive holds, into `~/.local/bin`; `--force` replaces a command already there |
|
|
22
|
-
| `--exec` | lists what the script does, then runs it only when `--sha256` or `--
|
|
26
|
+
| `--exec` | lists what the script does, then runs it only when `--sha256`, `--sums` or `--sig` pins it, or with `--yes`; arguments after `--` go to the script |
|
|
23
27
|
| `--max-size <size>` | the largest download taken, `2G` by default |
|
|
24
28
|
|
|
25
29
|
An HTML page arriving where a file was expected (an error or sign-in page answered with 200) fails instead of being kept.
|
|
26
30
|
|
|
31
|
+
A download that breaks off keeps its bytes under `~/.local/state/kaynooo-cli/dl`, and the next `dl` of the same URL resumes it with a Range request, when the server gave an ETag or Last-Modified to tell the file did not change; a changed file or a server without ranges starts over, and the sha256 covers the whole file either way. A part left a week unresumed is dropped.
|
|
32
|
+
|
|
27
33
|
## Install scripts
|
|
28
34
|
|
|
29
35
|
`curl -fsSL https://bun.sh/install | bash` runs code nobody read. With `dl`:
|
|
@@ -37,4 +43,6 @@ dl https://bun.sh/install --exec --sha256 <sha> # runs exactly what was
|
|
|
37
43
|
|
|
38
44
|
Every URL is remembered under `~/.local/state/kaynooo-cli/dl`. Downloading the same URL again says whether it changed, and a text file under 1 MB shows its diff against the last version, so a script you read before only needs its changes read again.
|
|
39
45
|
|
|
46
|
+
A checksums file fetched from the same server as the file only proves the download arrived whole; a signature proves who published it. Most projects sign the checksums file, so `--sums` and `--sig` together check both.
|
|
47
|
+
|
|
40
48
|
Exits 0 on success, 1 when the download, a check, an extraction, an install or the script fails, or a script nothing pins was not run, 2 on a usage error.
|