@ninhache/probe 0.2.0 → 0.3.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 +13 -8
- package/dist/cli.js +11 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,23 +27,25 @@ Use the full name with `npx`: `npx probe` is another package.
|
|
|
27
27
|
|
|
28
28
|
## Quick start
|
|
29
29
|
|
|
30
|
-
1. `probe init` creates `.probe
|
|
30
|
+
1. `probe init` creates `.probe/`.
|
|
31
31
|
2. `probe add api -p 3000 --path /health` declares a service.
|
|
32
|
-
3. `probe check`
|
|
33
|
-
4. Commit `.probe/config.yml
|
|
32
|
+
3. `probe check` checks everything. Exit code is 1 if a service is down.
|
|
33
|
+
4. Commit `.probe/config.yml`.
|
|
34
|
+
|
|
35
|
+
Want `make check` too? See [Makefile](#makefile): it is optional.
|
|
34
36
|
|
|
35
37
|
## Commands
|
|
36
38
|
|
|
37
39
|
| Command | What it does |
|
|
38
40
|
| --------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
39
|
-
| `probe init` | Create `.probe
|
|
41
|
+
| `probe init` | Create `.probe/` and the `.gitignore` entries |
|
|
40
42
|
| `probe add <name> -p <port> [--host] [--path] [--expect]` | Add a service |
|
|
41
43
|
| `probe rm <name>` | Remove a service |
|
|
42
44
|
| `probe ls` | List services |
|
|
43
45
|
| `probe check [name...] [--json] [--timeout <seconds>]` | Check all services, or the named ones |
|
|
44
46
|
| `probe wait [name...] [--json] [--timeout <seconds>]` | Check again until every service is up, or give up after the timeout |
|
|
45
47
|
| `probe status` | CLI version, pending migration, Makefile block state, available update |
|
|
46
|
-
| `probe sync` |
|
|
48
|
+
| `probe sync` | Add or regenerate the Makefile block (optional) |
|
|
47
49
|
| `probe migrate` | Migrate `.probe/config.yml` to the current schema |
|
|
48
50
|
|
|
49
51
|
Exit codes: `0` all up, `1` a service is down, `2` usage or config error.
|
|
@@ -104,15 +106,15 @@ is judged as is.
|
|
|
104
106
|
Files in `.probe/`:
|
|
105
107
|
|
|
106
108
|
- `config.yml`: services. Commit it.
|
|
107
|
-
- `lock.yml`: CLI version and hash of the Makefile block. Commit it.
|
|
109
|
+
- `lock.yml`: CLI version and hash of the Makefile block. Only there once `probe sync` has run. Commit it.
|
|
108
110
|
- `local.yml`: per-machine values (dashboard settings, skipped services). Ignored by git.
|
|
109
111
|
|
|
110
112
|
Never put secrets in `config.yml` or `lock.yml`.
|
|
111
113
|
|
|
112
114
|
## Makefile
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
never touched.
|
|
116
|
+
Optional. `probe sync` writes a block between two markers, in a new `Makefile` or at the end of yours. Everything
|
|
117
|
+
outside the block is yours and is never touched. Without a block, no command creates or changes a `Makefile`.
|
|
116
118
|
|
|
117
119
|
```make
|
|
118
120
|
# >>> probe (generated - do not edit, run `probe sync`)
|
|
@@ -120,6 +122,9 @@ never touched.
|
|
|
120
122
|
# <<< probe
|
|
121
123
|
```
|
|
122
124
|
|
|
125
|
+
Once the block is there, `probe add` and `probe rm` keep it up to date. Commit the `Makefile` and
|
|
126
|
+
`.probe/lock.yml`.
|
|
127
|
+
|
|
123
128
|
Targets: `help`, `check`, `status` and one `check-<name>` per service. The block uses `probe` when it is in
|
|
124
129
|
your `PATH`, else `npx -y @ninhache/probe@latest`. It works with GNU Make 3.81 (the macOS default).
|
|
125
130
|
|
package/dist/cli.js
CHANGED
|
@@ -305,7 +305,7 @@ async function writeLock(paths, lock) {
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
// src/version.ts
|
|
308
|
-
var CLI_VERSION = true ? "0.
|
|
308
|
+
var CLI_VERSION = true ? "0.3.0" : "0.0.0-dev";
|
|
309
309
|
|
|
310
310
|
// src/makefile/generator.ts
|
|
311
311
|
import { createHash } from "crypto";
|
|
@@ -419,9 +419,10 @@ function rawServices(loaded) {
|
|
|
419
419
|
return loaded.raw.services ?? {};
|
|
420
420
|
}
|
|
421
421
|
async function saveServices(loaded, services) {
|
|
422
|
-
const
|
|
422
|
+
const block = await blockState(loaded.paths, loaded.config);
|
|
423
423
|
const saved = await saveConfig(loaded, { ...loaded.raw, services });
|
|
424
|
-
if (
|
|
424
|
+
if (block === "missing") return;
|
|
425
|
+
if (block !== "modified") {
|
|
425
426
|
await syncMakefile(saved.paths, saved.config);
|
|
426
427
|
return;
|
|
427
428
|
}
|
|
@@ -625,7 +626,7 @@ async function ignoreLocalFiles(root) {
|
|
|
625
626
|
var init_default = defineCommand3({
|
|
626
627
|
meta: {
|
|
627
628
|
name: "init",
|
|
628
|
-
description: "Create .probe
|
|
629
|
+
description: "Create .probe/ and the .gitignore entries"
|
|
629
630
|
},
|
|
630
631
|
async run() {
|
|
631
632
|
const paths = pathsFor(process.cwd());
|
|
@@ -635,9 +636,7 @@ var init_default = defineCommand3({
|
|
|
635
636
|
await mkdir(paths.dir);
|
|
636
637
|
await writeFile5(paths.config, INITIAL_CONFIG);
|
|
637
638
|
await ignoreLocalFiles(paths.root);
|
|
638
|
-
|
|
639
|
-
await syncMakefile(paths, config);
|
|
640
|
-
console.log(`Created ${PROBE_DIR}/ and the Makefile block. Next: probe add api -p 3000`);
|
|
639
|
+
console.log(`Created ${PROBE_DIR}/. Next: probe add api -p 3000`);
|
|
641
640
|
}
|
|
642
641
|
});
|
|
643
642
|
|
|
@@ -768,7 +767,7 @@ function describeBlock(state, colors) {
|
|
|
768
767
|
case "outdated":
|
|
769
768
|
return colors.yellow("out of date \u2192 run `probe sync`");
|
|
770
769
|
case "missing":
|
|
771
|
-
return colors.
|
|
770
|
+
return colors.dim("no probe block (optional) \u2192 `probe sync` adds one");
|
|
772
771
|
}
|
|
773
772
|
}
|
|
774
773
|
function describeUpdate(colors) {
|
|
@@ -802,7 +801,10 @@ var status_default = defineCommand7({
|
|
|
802
801
|
import { relative as relative2 } from "path";
|
|
803
802
|
import { defineCommand as defineCommand8 } from "citty";
|
|
804
803
|
var sync_default = defineCommand8({
|
|
805
|
-
meta: {
|
|
804
|
+
meta: {
|
|
805
|
+
name: "sync",
|
|
806
|
+
description: "Add or regenerate the probe block of the Makefile (optional)"
|
|
807
|
+
},
|
|
806
808
|
async run() {
|
|
807
809
|
const { config, paths } = await openProject();
|
|
808
810
|
const { created, changed } = await syncMakefile(paths, config);
|