@procedures/node 0.2.2 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @procedures/node
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 04cfef8: `node.logs` (roadmap R44) gives the output of a process that `node.spawn` started: the last 64 KiB of stdout and stderr that the process registry of `client-shell` keeps. With `lines`, it gives only the last lines. With `stripAnsi`, it removes the colors. It works also after the process ended, and it only reads (`reads: ["jobs"]`).
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [ddea529]
12
+ - Updated dependencies [b2a3e3a]
13
+ - Updated dependencies [a8c47f1]
14
+ - Updated dependencies [381ce3a]
15
+ - Updated dependencies [0c627f8]
16
+ - Updated dependencies [ae7f05f]
17
+ - Updated dependencies [7873940]
18
+ - Updated dependencies [a70d445]
19
+ - Updated dependencies [bc70357]
20
+ - Updated dependencies [07cc998]
21
+ - Updated dependencies [a6b01a9]
22
+ - Updated dependencies [c799cdd]
23
+ - Updated dependencies [540f8d9]
24
+ - Updated dependencies [b6daaec]
25
+ - Updated dependencies [5b9264e]
26
+ - Updated dependencies [956e88b]
27
+ - Updated dependencies [ff62281]
28
+ - Updated dependencies [d81d0ed]
29
+ - Updated dependencies [aa67cc7]
30
+ - Updated dependencies [061fa22]
31
+ - Updated dependencies [cfb9d69]
32
+ - Updated dependencies [43f7de5]
33
+ - Updated dependencies [b07bb50]
34
+ - Updated dependencies [4a3bfa1]
35
+ - Updated dependencies [bd0b626]
36
+ - Updated dependencies [a6be873]
37
+ - Updated dependencies [fb30718]
38
+ - Updated dependencies [c5528e4]
39
+ - Updated dependencies [fee5d9c]
40
+ - Updated dependencies [21f7743]
41
+ - Updated dependencies [31a0b46]
42
+ - @procedures/client@0.3.0
43
+ - @procedures/shell@0.3.0
44
+
45
+ ## 0.2.3
46
+
47
+ ### Patch Changes
48
+
49
+ - Updated dependencies [15e48cf]
50
+ - @procedures/client@0.2.3
51
+ - @procedures/shell@0.2.3
52
+
3
53
  ## 0.2.2
4
54
 
5
55
  ### Patch Changes
package/README.md CHANGED
@@ -14,6 +14,7 @@ Node.js process management procedures for the client ecosystem. Provides procedu
14
14
  │ await client.exec(["node", "spawn"], { script: "server.js" }) │
15
15
  │ await client.exec(["node", "kill"], { processId: "abc123" }) │
16
16
  │ await client.exec(["node", "status"], {}) │
17
+ │ await client.exec(["node", "logs"], { processId: "abc123", lines: 50 }) │
17
18
  │ │
18
19
  └─────────────────────────────────┬───────────────────────────────────────────┘
19
20
  │
@@ -62,6 +63,8 @@ pnpm add @procedures/node
62
63
 
63
64
  ## Procedures
64
65
 
66
+ The package has 5 procedures. Its register entry (`import "@procedures/node/register"`) registers them: `node.run`, `node.spawn`, `node.kill`, `node.status`, `node.logs`.
67
+
65
68
  ### node.run
66
69
 
67
70
  Run a Node.js script to completion and return the output.
@@ -217,6 +220,28 @@ for (const proc of result.processes) {
217
220
  | `status` | `"running" \| "stopped"` | Process status |
218
221
  | `startedAt` | `string` | ISO timestamp when started |
219
222
 
223
+ ### node.logs
224
+
225
+ The procedure gives the output of one process that `node.spawn` started. The process registry of `client-shell` reads the output of each process and keeps its end: the last 64 KiB of stdout and stderr together. Thus the procedure gives that end, also after the process ended. The registry keeps the records of the last 50 ended processes.
226
+
227
+ ```typescript
228
+ const { status, exitCode, output } = await client.exec(["node", "logs"], {
229
+ processId: "node-abc123-1",
230
+ lines: 50,
231
+ stripAnsi: true,
232
+ });
233
+ ```
234
+
235
+ The input has these fields:
236
+
237
+ - `processId` (necessary): the process ID that `node.spawn` gave.
238
+ - `lines`: give only the last lines of the output.
239
+ - `stripAnsi`: remove the ANSI escape codes (colors) from the output.
240
+
241
+ The output has the `processId`, the `status` (`running`, `exited` or `error`), the `exitCode` of an ended process and the `output`.
242
+
243
+ The procedure knows only the processes of its host. The process writes to two pipes, stdout and stderr. Thus `output` has their lines in the order of their arrival. A process that `node.spawn` did not start is an error. The procedure has no stream: a stream of new output needs a subscription to the process registry of `client-shell`.
244
+
220
245
  ## Process Lifecycle
221
246
 
222
247
  ```