@effected/cli 0.24.0 → 0.25.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/CliPrompt.js CHANGED
@@ -61,7 +61,7 @@ var CliPrompt = class {
61
61
  * stdin, which drops piped input and puts a TTY stdin into raw mode. Core's `withFallbackPrompt`, a `Prompt.run`
62
62
  * in a handler and the command wizard all do so whether or not anyone is there to answer. Not interactive, this
63
63
  * terminal's input is an already-ended queue, its `readLine` fails as quit and its `display` writes nothing, so
64
- * any such prompt is quit at once and the real terminal is never read. Its `columns` and `rows` always come
64
+ * any such prompt is quit at once and the real terminal is never read. Its `columns`, `rows` and `size` always come
65
65
  * from the real one, so layout keeps working. Interactive, every call passes through to the real terminal.
66
66
  *
67
67
  * The decision is made on every call, not when the layer is built, so a scope that narrows `CliInteractive`
@@ -79,6 +79,7 @@ var CliPrompt = class {
79
79
  return Terminal.make({
80
80
  columns: real.columns,
81
81
  rows: real.rows,
82
+ size: real.size,
82
83
  readInput: Effect.flatMap(CliInteractive, (interactive) => interactive ? real.readInput : endedInput),
83
84
  readLine: Effect.flatMap(CliInteractive, (interactive) => interactive ? real.readLine : Effect.fail(new Terminal.QuitError({}))),
84
85
  display: (text) => Effect.flatMap(CliInteractive, (interactive) => interactive ? real.display(text) : Effect.void)
package/README.md CHANGED
@@ -8,10 +8,10 @@
8
8
  The presentation boundary of a command-line program built on `effect/cli`: who the output is for, and how it reaches them. Plain log lines on the right stream. Colour, glyphs and links only where the terminal and the reader can use them. Documents rendered for a person, an agent or a CI log. Failures reported through your own logger with the right exit code. Prompts that know when there is nobody to ask. Interactive screens and live progress views drawn with Ink. `effect/cli` still owns argument parsing, flags, the command tree and help; this package adds no parser and no command model.
9
9
 
10
10
  > **Pre-`1.0.0`.** This package is part of the `@effected/*` kit, built on stable
11
- > Effect v4 (`effect` `^4.0.0`) and still in `0.x` development. Stable Effect
11
+ > Effect v4 (`effect` `~4.1.0`) and still in `0.x` development. Stable Effect
12
12
  > makes a kit `1.0.0` possible, not automatic. To keep your `effect` and
13
13
  > `@effect/*` versions on the line the kit is built and tested against, install
14
- > [`@effected/pnpm-plugin-effect`](https://www.npmjs.com/package/@effected/pnpm-plugin-effect).
14
+ > [`@effected/pnpm-plugin-effected`](https://www.npmjs.com/package/@effected/pnpm-plugin-effected).
15
15
  >
16
16
  > **Stability: unstable.** This package's API surface is not yet considered
17
17
  > complete and may change across `0.x` releases. Pin an exact version — even a
package/TestTerminal.js CHANGED
@@ -5,7 +5,9 @@ import { Effect, Layer, Option, Queue, Terminal } from "effect";
5
5
  * A scripted `Terminal` for testing prompts and anything that reads the terminal.
6
6
  *
7
7
  * @remarks
8
- * Queue keys with `input` or `type`, run the program under `layer`, then read `output`. To assert that a code path
8
+ * Queue keys with `input` or `type`, run the program under `layer`, then read `output`. `size` behaves as a real
9
+ * terminal's does: each subscription starts with the current size, receives every `resize`, keeps only the latest,
10
+ * and ends when its scope closes. To assert that a code path
9
11
  * did NOT touch the terminal, queue some keys first and check `reads` is all zero (no subscription, no key, no
10
12
  * line) and `pending` is unchanged afterwards. Only
11
13
  * available from `@effected/cli/testing`.
@@ -25,13 +27,26 @@ var TestTerminal = class {
25
27
  let offered = 0;
26
28
  let lines = 0;
27
29
  let subscriptions = 0;
30
+ let current = {
31
+ columns: options?.columns ?? 80,
32
+ rows: options?.rows ?? 24
33
+ };
34
+ const sizeSubscribers = /* @__PURE__ */ new Set();
28
35
  const offer = (inputs) => Effect.suspend(() => {
29
36
  offered += inputs.length;
30
37
  return Queue.offerAll(queue, inputs);
31
38
  }).pipe(Effect.asVoid);
32
39
  const terminal = Terminal.make({
33
- columns: Effect.succeed(options?.columns ?? 80),
34
- rows: Effect.succeed(options?.rows ?? 24),
40
+ columns: Effect.sync(() => current.columns),
41
+ rows: Effect.sync(() => current.rows),
42
+ size: Effect.acquireRelease(Effect.flatMap(Queue.sliding(1), (subscriber) => Effect.sync(() => {
43
+ Queue.offerUnsafe(subscriber, current);
44
+ sizeSubscribers.add(subscriber);
45
+ return subscriber;
46
+ })), (subscriber) => Effect.sync(() => {
47
+ sizeSubscribers.delete(subscriber);
48
+ Queue.endUnsafe(subscriber);
49
+ })),
35
50
  readInput: Effect.sync(() => {
36
51
  subscriptions++;
37
52
  return queue;
@@ -65,6 +80,13 @@ var TestTerminal = class {
65
80
  }
66
81
  }))),
67
82
  end: Queue.end(queue).pipe(Effect.asVoid),
83
+ resize: (size) => Effect.sync(() => {
84
+ current = {
85
+ columns: size.columns,
86
+ rows: size.rows
87
+ };
88
+ for (const subscriber of sizeSubscribers) Queue.offerUnsafe(subscriber, current);
89
+ }),
68
90
  output: Effect.sync(() => written.join("")),
69
91
  pending: Queue.size(queue),
70
92
  reads: Effect.map(Queue.size(queue), (size) => ({
package/index.d.ts CHANGED
@@ -2709,7 +2709,7 @@ export declare class CliPrompt {
2709
2709
  * stdin, which drops piped input and puts a TTY stdin into raw mode. Core's `withFallbackPrompt`, a `Prompt.run`
2710
2710
  * in a handler and the command wizard all do so whether or not anyone is there to answer. Not interactive, this
2711
2711
  * terminal's input is an already-ended queue, its `readLine` fails as quit and its `display` writes nothing, so
2712
- * any such prompt is quit at once and the real terminal is never read. Its `columns` and `rows` always come
2712
+ * any such prompt is quit at once and the real terminal is never read. Its `columns`, `rows` and `size` always come
2713
2713
  * from the real one, so layout keeps working. Interactive, every call passes through to the real terminal.
2714
2714
  *
2715
2715
  * The decision is made on every call, not when the layer is built, so a scope that narrows `CliInteractive`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/cli",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "private": false,
5
5
  "description": "The presentation boundary of an effect/cli program: audience-aware output, a document IR and renderers, editor links, failure reports and logging, plus opt-in Ink screens, widgets and a live view",
6
6
  "keywords": [
@@ -57,17 +57,17 @@
57
57
  "./package.json": "./package.json"
58
58
  },
59
59
  "dependencies": {
60
- "@effected/commands": "^0.18.0",
61
- "@effected/engine": "^0.10.0",
62
- "@effected/github-commands": "^0.7.0"
60
+ "@effected/commands": "^0.19.0",
61
+ "@effected/engine": "^0.11.0",
62
+ "@effected/github-commands": "^0.8.0"
63
63
  },
64
64
  "peerDependencies": {
65
- "@effected/config-file": "^0.22.0",
66
- "@effected/env": "^0.7.0",
67
- "@effected/glob": "^0.16.0",
68
- "@effected/walker": "^0.22.0",
65
+ "@effected/config-file": "^0.23.0",
66
+ "@effected/env": "^0.9.0",
67
+ "@effected/glob": "^0.17.0",
68
+ "@effected/walker": "^0.24.0",
69
69
  "@types/react": "^19.3.0",
70
- "effect": "^4.0.0",
70
+ "effect": "~4.1.0",
71
71
  "ink": "^8.0.0",
72
72
  "react": "^19.3.0"
73
73
  },
package/testing.d.ts CHANGED
@@ -198,6 +198,11 @@ interface TestTerminalHandle {
198
198
  readonly end: Effect.Effect<void>;
199
199
  /** Everything written to the terminal so far, prompt frames and escape codes included. */
200
200
  readonly output: Effect.Effect<string>;
201
+ /**
202
+ * Resize the terminal: `columns` and `rows` report the new size from now on, and every open `size`
203
+ * subscription receives it.
204
+ */
205
+ readonly resize: (size: Terminal.Size) => Effect.Effect<void>;
201
206
  /** How many queued key presses nobody has taken yet. */
202
207
  readonly pending: Effect.Effect<number>;
203
208
  /**
@@ -216,7 +221,9 @@ interface TestTerminalHandle {
216
221
  * A scripted `Terminal` for testing prompts and anything that reads the terminal.
217
222
  *
218
223
  * @remarks
219
- * Queue keys with `input` or `type`, run the program under `layer`, then read `output`. To assert that a code path
224
+ * Queue keys with `input` or `type`, run the program under `layer`, then read `output`. `size` behaves as a real
225
+ * terminal's does: each subscription starts with the current size, receives every `resize`, keeps only the latest,
226
+ * and ends when its scope closes. To assert that a code path
220
227
  * did NOT touch the terminal, queue some keys first and check `reads` is all zero (no subscription, no key, no
221
228
  * line) and `pending` is unchanged afterwards. Only
222
229
  * available from `@effected/cli/testing`.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.4"
8
+ "packageVersion": "7.60.0"
9
9
  }
10
10
  ]
11
11
  }