@ninhache/probe 0.6.0 → 0.8.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 CHANGED
@@ -41,7 +41,7 @@ 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>` | Remove a service |
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 |
@@ -64,10 +64,31 @@ longest one. Unlike `check --timeout`, which is the time given to each service,
64
64
  wait; each check inside it still gets 3 s, or the service's own `timeout`. Progress goes to stderr, the final
65
65
  report to stdout; exit code `1` names the services still down.
66
66
 
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
+ On a terminal, `probe init` and `probe add` alone first show the services they find in the project, as a list to
71
+ tick. Nothing is ticked at first, and nothing is written unless you tick it. They look at:
72
+
73
+ - the compose file (`compose.yaml`, `compose.yml`, `docker-compose.yaml` or `docker-compose.yml`) and its
74
+ `override` file: the ports a service publishes (`"8080:80"`), under the name of the service. A variable in a
75
+ port takes its value from `.env`. Https, mail, database, cache and broker ports are left out.
76
+ - `.env` and `.env.local`: `PORT`, and the `*_URL` that point to `http://localhost`. Only the host, the port and
77
+ the path are kept: no other value is kept, shown or written.
78
+ - `package.json`: the port a script names (`--port 4000`), or the usual one of its dev server (vite, next, nuxt,
79
+ astro, angular).
80
+ - the local ports 3000, 3001, 4200, 4321, 5173, 8000 and 8080, when an HTTP server answers there (one `GET /`
81
+ each, redirects not followed).
82
+ `PROBE_DETECT_PORTS=4000,4001` tries other ports, `PROBE_DETECT_PORTS=` none.
83
+
84
+ `probe rm` is the one command that deletes something. On a terminal it asks first, with "No" selected: `--yes`
85
+ (`-y`) skips the question. Off a terminal, in a script or in CI, it removes at once, as before.
86
+
67
87
  `probe open` uses `open` on macOS and `xdg-open` elsewhere. Without it, the URL is printed and the exit code is
68
88
  `1`. `probe curl api` prints a command to copy, or to run: `probe curl api | sh`.
69
89
 
70
- `probe` works from any sub-directory: it walks up to the nearest `.probe/`.
90
+ `probe` works from any sub-directory: it walks up to the nearest `.probe/`. When there is none, on a terminal,
91
+ it offers to create it where you are, then runs your command. Off a terminal it stops with exit code `2`.
71
92
 
72
93
  ## Completion
73
94
 
@@ -30,6 +30,9 @@ var REFRESH_COMMAND = "__refresh-update-cache";
30
30
  var COMPLETE_COMMAND = "__complete";
31
31
  var EXIT_DOWN = 1;
32
32
  var EXIT_ERROR = 2;
33
+ var DETECT_PORTS = [3e3, 3001, 4200, 4321, 5173, 8e3, 8080];
34
+ var DETECT_PORTS_ENV = "PROBE_DETECT_PORTS";
35
+ var DETECT_TIMEOUT_MS = 300;
33
36
 
34
37
  // src/errors.ts
35
38
  var ProbeError = class extends Error {
@@ -359,14 +362,17 @@ export {
359
362
  COMPLETE_COMMAND,
360
363
  EXIT_DOWN,
361
364
  EXIT_ERROR,
365
+ DETECT_PORTS,
366
+ DETECT_PORTS_ENV,
367
+ DETECT_TIMEOUT_MS,
362
368
  ProbeError,
369
+ targetUrl,
370
+ curlCommand,
363
371
  createColors,
364
372
  detectTerminal,
365
373
  isInteractive,
366
374
  truncate,
367
375
  stripStyles,
368
- targetUrl,
369
- curlCommand,
370
376
  runChecks,
371
377
  formatCheckResults,
372
378
  formatServices