@ninhache/probe 0.5.0 → 0.7.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 +34 -3
- package/dist/{chunk-4VXL4OTD.js → chunk-YTTYVEYF.js} +10 -0
- package/dist/cli.js +467 -92
- package/dist/dist-SITQEC3X.js +2894 -0
- package/dist/{open-WH6VGPQT.js → open-T3OQH2O4.js} +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -41,13 +41,16 @@ Want `make check` too? See [Makefile](#makefile): it is optional.
|
|
|
41
41
|
| --------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
42
42
|
| `probe init` | Create `.probe/` and the `.gitignore` entries |
|
|
43
43
|
| `probe add <name> -p <port> [--host] [--path] [--expect]` | Add a service (`--timeout <seconds>` gives it its own timeout) |
|
|
44
|
-
| `probe rm <name
|
|
44
|
+
| `probe rm <name> [--yes]` | Remove a service |
|
|
45
45
|
| `probe ls` | List services |
|
|
46
46
|
| `probe check [name...] [--json] [--timeout <seconds>]` | Check all services, or the named ones |
|
|
47
47
|
| `probe wait [name...] [--json] [--timeout <seconds>]` | Check again until every service is up, or give up after the timeout |
|
|
48
|
+
| `probe open <name>` | Open the URL of a service in the browser |
|
|
49
|
+
| `probe curl <name>` | Print the curl command that requests a service |
|
|
48
50
|
| `probe status` | CLI version, pending migration, Makefile block state, available update |
|
|
49
51
|
| `probe sync` | Add or regenerate the Makefile block (optional) |
|
|
50
52
|
| `probe migrate` | Migrate `.probe/config.yml` to the current schema |
|
|
53
|
+
| `probe completion <zsh\|bash\|fish>` | Print the shell completion script |
|
|
51
54
|
|
|
52
55
|
Exit codes: `0` all up, `1` a service is down, `2` usage or config error.
|
|
53
56
|
|
|
@@ -61,7 +64,31 @@ longest one. Unlike `check --timeout`, which is the time given to each service,
|
|
|
61
64
|
wait; each check inside it still gets 3 s, or the service's own `timeout`. Progress goes to stderr, the final
|
|
62
65
|
report to stdout; exit code `1` names the services still down.
|
|
63
66
|
|
|
64
|
-
`probe`
|
|
67
|
+
`probe add` alone, on a terminal, asks for the name, the port, the path and the expected status, one at a time:
|
|
68
|
+
Enter alone keeps the default, Ctrl+C adds nothing. Off a terminal it needs its arguments, as before.
|
|
69
|
+
|
|
70
|
+
`probe rm` is the one command that deletes something. On a terminal it asks first, with "No" selected: `--yes`
|
|
71
|
+
(`-y`) skips the question. Off a terminal, in a script or in CI, it removes at once, as before.
|
|
72
|
+
|
|
73
|
+
`probe open` uses `open` on macOS and `xdg-open` elsewhere. Without it, the URL is printed and the exit code is
|
|
74
|
+
`1`. `probe curl api` prints a command to copy, or to run: `probe curl api | sh`.
|
|
75
|
+
|
|
76
|
+
`probe` works from any sub-directory: it walks up to the nearest `.probe/`. When there is none, on a terminal,
|
|
77
|
+
it offers to create it where you are, then runs your command. Off a terminal it stops with exit code `2`.
|
|
78
|
+
|
|
79
|
+
## Completion
|
|
80
|
+
|
|
81
|
+
Tab completes the commands, their options and the names of your services (`probe check a<Tab>`).
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
eval "$(probe completion zsh)" # in ~/.zshrc, after compinit
|
|
85
|
+
eval "$(probe completion bash)" # in ~/.bashrc (macOS: ~/.bash_profile)
|
|
86
|
+
probe completion fish | source # in ~/.config/fish/config.fish
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
In zsh you can also save it once instead: `probe completion zsh > ~/.zfunc/_probe`, with `~/.zfunc` in your
|
|
90
|
+
`fpath`; in fish, `probe completion fish > ~/.config/fish/completions/probe.fish`. It works with the bash 3.2
|
|
91
|
+
of macOS.
|
|
65
92
|
|
|
66
93
|
## Dashboard
|
|
67
94
|
|
|
@@ -142,12 +169,16 @@ outside the block is yours and is never touched. Without a block, no command cre
|
|
|
142
169
|
Once the block is there, `probe add` and `probe rm` keep it up to date. Commit the `Makefile` and
|
|
143
170
|
`.probe/lock.yml`.
|
|
144
171
|
|
|
145
|
-
Targets: `help`, `check`, `status` and one `check-<name>` per
|
|
172
|
+
Targets: `help`, `check`, `status`, `probe` (opens the [dashboard](#dashboard)) and one `check-<name>` per
|
|
173
|
+
service. The block uses `probe` when it is in
|
|
146
174
|
your `PATH`, else `npx -y @ninhache/probe@latest`. It works with GNU Make 3.81 (the macOS default).
|
|
147
175
|
|
|
148
176
|
Edited the block by hand? `probe status` says so and `probe add` / `probe rm` leave it alone. `probe sync`
|
|
149
177
|
restores it.
|
|
150
178
|
|
|
179
|
+
A newer `probe` can add targets to the block: `make probe` came with 0.6.0. A block written before that is
|
|
180
|
+
reported as `outdated` by `probe status`. Run `probe sync` once to get the new targets.
|
|
181
|
+
|
|
151
182
|
## Migrations
|
|
152
183
|
|
|
153
184
|
`config.yml` carries a `schemaVersion`. When a newer `probe` needs a newer schema, the first command you run:
|
|
@@ -27,6 +27,7 @@ var REGISTRY_TIMEOUT_MS = 5e3;
|
|
|
27
27
|
var UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
28
28
|
var UPDATE_CACHE_FILE = "latest.json";
|
|
29
29
|
var REFRESH_COMMAND = "__refresh-update-cache";
|
|
30
|
+
var COMPLETE_COMMAND = "__complete";
|
|
30
31
|
var EXIT_DOWN = 1;
|
|
31
32
|
var EXIT_ERROR = 2;
|
|
32
33
|
|
|
@@ -164,6 +165,12 @@ function targetUrl(service) {
|
|
|
164
165
|
const host = bareIpv6 ? `[${service.host}]` : service.host;
|
|
165
166
|
return `http://${host}:${service.port}${service.path}`;
|
|
166
167
|
}
|
|
168
|
+
var shellQuoted = (text) => `'${text.replaceAll("'", "'\\''")}'`;
|
|
169
|
+
function curlCommand(service) {
|
|
170
|
+
const follow = expectsRedirect(service.expect) ? "" : " -L";
|
|
171
|
+
const seconds = service.timeout ?? DEFAULT_TIMEOUT_SECONDS;
|
|
172
|
+
return `curl -i${follow} --max-time ${seconds} ${shellQuoted(targetUrl(service))}`;
|
|
173
|
+
}
|
|
167
174
|
function isExpected(expect, status) {
|
|
168
175
|
if (expect === void 0) return status >= 200 && status < 300;
|
|
169
176
|
return Array.isArray(expect) ? expect.includes(status) : expect === status;
|
|
@@ -349,6 +356,7 @@ export {
|
|
|
349
356
|
UPDATE_CHECK_TTL_MS,
|
|
350
357
|
UPDATE_CACHE_FILE,
|
|
351
358
|
REFRESH_COMMAND,
|
|
359
|
+
COMPLETE_COMMAND,
|
|
352
360
|
EXIT_DOWN,
|
|
353
361
|
EXIT_ERROR,
|
|
354
362
|
ProbeError,
|
|
@@ -357,6 +365,8 @@ export {
|
|
|
357
365
|
isInteractive,
|
|
358
366
|
truncate,
|
|
359
367
|
stripStyles,
|
|
368
|
+
targetUrl,
|
|
369
|
+
curlCommand,
|
|
360
370
|
runChecks,
|
|
361
371
|
formatCheckResults,
|
|
362
372
|
formatServices
|