- commit
- 88745def3687e7dc48236e4ec3fe5a91b33b0274
- parent
- 54d857fd619d929fc4761fafc0fdd9eb6fecc2f8
- author
- Dami <dami.etoile@gmail.com>
| M | README.md | 6 | +++++- |
| M | cli/ | 6 | ++++++ |
| M | cli/ | 17 | ++++++++++++++--- |
| A | cli/ | 31 | ++++++++++++++++++++++++++++++ |
| M | skills/ | 13 | +++++++++---- |
@@ -24,12 +24,15 @@ your `PATH`:
2424 2525 ```sh2626 deno install -g -A -f -n nzip jsr:@nzip/cli27+nzip --version2728 nzip auth --server https://share.demo.dev2829 nzip site push ./site work:demo2930 ```3031 3132 `nzip auth` prompts for omitted values and saves configuration to `~/.config/nzip/config.json` with32-mode 0600. Try the CLI without installing it with `deno run -A jsr:@nzip/cli --help`.33+mode 0600. `nzip --version` reports the installed JSR release without requiring authentication; add34+`--json` for machine-readable output. Try the CLI without installing it with35+`deno run -A jsr:@nzip/cli --help`.3336 3437 On another machine, install the CLI and authenticate with the same server and token. Hosted vaults3538 and sites are already available; only the `nzip site where` breadcrumb registry is machine-local.@@ -77,6 +80,7 @@ Aliases such as `work:demo` are resolved by the authenticated API; public URLs d
7780 7881 ```text7982 nzip83+├─ --version [--json] show the installed CLI version8084 ├─ auth [--server URL] [--token T] authenticate and save config8185 ├─ status show server and vault status8286 ├─ vault@@ -13,6 +13,7 @@ Requires [Deno](https://docs.deno.com/runtime/) on your `PATH`.
1313 1414 ```sh1515 deno install -g -A -f -n nzip jsr:@nzip/cli16+nzip --version1617 ```1718 1819 Try it without installing:@@ -34,10 +35,15 @@ Config is saved to `~/.config/nzip/config.json` (mode 0600), so later commands j
3435 second machine, install from JSR and re-run `nzip auth` with the same server and token; every vault3536 and site is already there.3637 38+`nzip --version` prints the installed release without reading saved configuration. Use39+`nzip --version --json` to receive a single JSON object with a `version` field for scripts and40+agents.41+3742 ## Commands3843 3944 ```text4045 nzip46+├─ --version [--json] show the installed CLI version4147 ├─ auth [--server URL] [--token T] authenticate and save config4248 ├─ status show server and vault status4349 ├─ vault@@ -17,6 +17,7 @@
1717 // nzip — push HTML and get a tiny URL back.1818 1919 import { parseArgs } from "@std/cli/parse-args";20+import { VERSION } from "@nzip/shared";2021 import { cmdAuth } from "./commands/auth.ts";2122 import { cmdNotify } from "./commands/notify.ts";2223 import { cmdSiteGroup } from "./commands/site.ts";@@ -27,6 +28,10 @@ import { fail, setJsonMode } from "./lib/fmt.ts";
2728 2829 const HELP = `nzip — html share tool2930 31+global:32+ nzip --help show this command guide33+ nzip --version [--json] show the installed CLI version34+3035 commands:3136 nzip3237 ├─ auth [--server URL] [--token T] authenticate against the server@@ -65,8 +70,8 @@ notification privacy: titles and bodies may appear on a lock screen; never inclu
6570 passwords, tokens, private URLs, or sensitive personal data.6671 `;6772 68-async function main(): Promise<void> {69- const args = parseArgs(Deno.args, {73+export async function main(argv = Deno.args): Promise<void> {74+ const args = parseArgs(argv, {7075 string: [7176 "ttl",7277 "to",@@ -84,17 +89,23 @@ async function main(): Promise<void> {
8489 "yes",8590 "list",8691 "help",92+ "version",8793 "no-password",8894 "overwrite",8995 "json",9096 "no-description",9197 "all",9298 ],93- alias: { h: "help", y: "yes" },99+ alias: { h: "help", V: "version", y: "yes" },94100 });95101 setJsonMode(args.json);96102 const [command, ...rest] = args._.map(String);97103 104+ if (args.version) {105+ console.log(args.json ? JSON.stringify({ version: VERSION }) : `nzip ${VERSION}`);106+ return;107+ }108+98109 if (args.help || !command) {99110 console.log(HELP);100111 return;@@ -0,0 +1,31 @@
1+import { VERSION } from "@nzip/shared";2+import { main } from "./main.ts";3+4+async function captureStdout(argv: string[]): Promise<string[]> {5+ const lines: string[] = [];6+ const original = console.log;7+ console.log = (...args: unknown[]) => lines.push(args.map(String).join(" "));8+ try {9+ await main(argv);10+ } finally {11+ console.log = original;12+ }13+ return lines;14+}15+16+Deno.test("version prints the installed CLI version without configuration", async () => {17+ const lines = await captureStdout(["--version"]);18+ if (lines.length !== 1 || lines[0] !== `nzip ${VERSION}`) {19+ throw new Error(`unexpected version output: ${JSON.stringify(lines)}`);20+ }21+});22+23+Deno.test("version supports agent-readable JSON", async () => {24+ const lines = await captureStdout(["--version", "--json"]);25+ if (lines.length !== 1) throw new Error(`unexpected version output: ${JSON.stringify(lines)}`);26+27+ const output = JSON.parse(lines[0]);28+ if (output.version !== VERSION) {29+ throw new Error(`unexpected version JSON: ${lines[0]}`);30+ }31+});@@ -11,7 +11,8 @@ exists, but do not clone or download the nzip repository merely to install the C
1111 1212 ## Setup1313 14-1. Check for the user CLI with `command -v nzip` and `nzip --help`.14+1. Check for the user CLI with `command -v nzip`, then capture its release with15+ `nzip --version --json`.1516 2. If it is missing and Deno is available, install the latest JSR release globally:1617 1718 ```sh@@ -58,9 +59,12 @@ Only perform these repository steps when creating or revising a local artifact:
5859 Run checks in this order and stop at the first failure that needs user input:5960 6061 1. `command -v nzip` — if missing, follow the JSR installation in Setup.61-2. `nzip --help` — confirm the installed command starts and inspect its supported command surface.62-3. `nzip status --json` — verify saved authentication, server reachability, and token validity.63-4. `nzip vault ls --json` — verify available vaults and the default vault.62+2. `nzip --version --json` — record the installed release without requiring authentication. If the63+ option is unsupported, the CLI predates version reporting; upgrade it from JSR before relying on64+ newer commands.65+3. `nzip --help` — confirm the installed command starts and inspect its supported command surface.66+4. `nzip status --json` — verify saved authentication, server reachability, and token validity.67+5. `nzip vault ls --json` — verify available vaults and the default vault.6468 6569 Use the JSON `error` and `hint` fields as the primary diagnosis. Re-run `nzip auth` for missing or6670 rejected credentials, correct the configured server for reachability failures, and ask the user to@@ -99,6 +103,7 @@ Prefer `--json` when consuming command output programmatically.
99103 100104 ```text101105 nzip106+├─ --version [--json]102107 ├─ auth [--server URL] [--token T]103108 ├─ status104109 ├─ vault