@kaynooo/cli-docker 0.2.0 → 0.4.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 +7 -1
- package/dist/dc-cli.js +14 -3
- package/dist/dlog-cli.js +1164 -0
- package/dist/dx-cli.js +103 -57
- package/dist/sf-cli.js +1339 -0
- package/package.json +10 -5
- package/src/dlog-cli.ts +8 -0
- package/src/dlog.ts +179 -0
- package/src/dx.ts +5 -5
- package/src/picker.ts +15 -45
- package/src/sf-cli.ts +8 -0
- package/src/sf.ts +368 -0
- package/src/stack.ts +19 -5
- package/src/history.ts +0 -48
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# docker
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Four helpers: `dc` runs compose on the stack found here, `dx` lists a stack's services and opens a shell in one, follows its logs, restarts, stops or rebuilds it, `dlog` shows every service's health and recent errors, `sf` picks a Symfony console command and runs it.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
bun install -g @kaynooo/cli-docker
|
|
@@ -15,6 +15,12 @@ bun install -g @kaynooo/cli-docker
|
|
|
15
15
|
| `dx` | picks a service with fzf: enter opens its shell (or brings it up), ctrl-l follows its logs, ctrl-r restarts, ctrl-x stops, ctrl-b rebuilds; the ones acted on last come first. Without fzf or a terminal it lists them with their state, ports and image (`--json` for the full record) |
|
|
16
16
|
| `dx -` | the last action again |
|
|
17
17
|
| `dx <service> [action]` | `shell` (the default, `up` for a stopped service), `logs`, `restart`, `up`, `stop` or `build` |
|
|
18
|
+
| `dlog [service...]` | one line per service with its state and health, then the last distinct error lines of its logs (`-n` per service, `--since 1h`), a repeated message once with `×N` and secrets masked as `redact` does; `--all` adds the last lines of a quiet service. Exits 1 when a service is down or unhealthy or logged an error |
|
|
19
|
+
| `sf` | picks a Symfony console command with fzf and runs it, asking for each required argument; the commands run last come first, and the picker opens on the list cached from the last run. It runs in the php service of the nearest compose stack, else with the local php. Without fzf or a terminal it lists the commands |
|
|
20
|
+
| `sf -` | the last command again, with the arguments it ran with |
|
|
21
|
+
| `sf <command> [args...]` | runs without the picker; a name the list does not hold goes to the console as is, which resolves `c:c` to `cache:clear` itself |
|
|
22
|
+
|
|
23
|
+
`sf` finds the nearest `bin/console` up to the repository root, then those of the child folders (keyed `api/cache:clear`).
|
|
18
24
|
|
|
19
25
|
`dc` takes no option of its own, every word reaches compose as typed. With several stacks that only have containers here and no name, it asks with `pick` when that is installed and a terminal is attached, and otherwise lists the projects. When it picked the stack through its containers it prints the compose command it stands for on stderr.
|
|
20
26
|
|
package/dist/dc-cli.js
CHANGED
|
@@ -349,6 +349,9 @@ function optionRows(options, colors = paint(process3.stdout)) {
|
|
|
349
349
|
|
|
350
350
|
// ../kit/src/text.ts
|
|
351
351
|
var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[\\d;?]*[a-z]`, "gi");
|
|
352
|
+
function stripAnsi(text) {
|
|
353
|
+
return text.replace(ANSI, "");
|
|
354
|
+
}
|
|
352
355
|
function distance(a, b) {
|
|
353
356
|
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
354
357
|
for (const [i, left] of [...a].entries()) {
|
|
@@ -745,7 +748,7 @@ var {Glob } = globalThis.Bun;
|
|
|
745
748
|
var SESSION_FILES = new Glob("*.json");
|
|
746
749
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
747
750
|
// package.json
|
|
748
|
-
var version = "0.
|
|
751
|
+
var version = "0.4.0";
|
|
749
752
|
|
|
750
753
|
// src/dc.ts
|
|
751
754
|
import process8 from "process";
|
|
@@ -827,9 +830,17 @@ async function recordedNearby() {
|
|
|
827
830
|
const dirs = new Set([...up("."), ...children()].map((dir) => resolve(dir)));
|
|
828
831
|
return (await labels()).filter((stack) => dirs.has(stack.workdir));
|
|
829
832
|
}
|
|
830
|
-
async function
|
|
833
|
+
async function attempt(stack, args) {
|
|
831
834
|
const proc = Bun.spawn([...stack.list.argv, ...args], { cwd: stack.list.cwd, env: stack.list.env, stdout: "pipe", stderr: "pipe" });
|
|
832
|
-
|
|
835
|
+
const [text, stderr, code] = await Promise.all([new Response(proc.stdout).text(), new Response(proc.stderr).text(), proc.exited]);
|
|
836
|
+
if (code === 0)
|
|
837
|
+
return { text, error: undefined };
|
|
838
|
+
const last = stderr.trim().split(`
|
|
839
|
+
`).at(-1) ?? "";
|
|
840
|
+
return { text: "", error: last === "" ? `exit ${code}` : last };
|
|
841
|
+
}
|
|
842
|
+
async function output(stack, args) {
|
|
843
|
+
return (await attempt(stack, args)).text;
|
|
833
844
|
}
|
|
834
845
|
function containers(text) {
|
|
835
846
|
const trimmed = text.trim();
|