@effected/cli 0.4.1 → 0.5.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/CliRuntime.js CHANGED
@@ -87,21 +87,13 @@ var CliRuntime = class CliRuntime {
87
87
  return yield* Effect.fail(CliRuntime.reported(error, chooseExitCode(error, options.exitCode)));
88
88
  });
89
89
  }));
90
- /**
91
- * Mark an error as already reported, carrying an exit code.
92
- *
93
- * @remarks
94
- * Exported because a program that reports a failure itself — a validation
95
- * command that prints its own diagnostics, say — needs the same two marks
96
- * and should not have to rediscover the inverted polarity.
97
- */
98
- static reported = (error, exitCode = 1) => {
90
+ static reported(error, exitCode = 1) {
99
91
  const marked = error instanceof Error ? error : new Error(String(error));
100
92
  return Object.assign(marked, {
101
93
  [Runtime.errorReported]: false,
102
94
  [Runtime.errorExitCode]: exitCode
103
95
  });
104
- };
96
+ }
105
97
  };
106
98
 
107
99
  //#endregion
package/README.md CHANGED
@@ -101,7 +101,7 @@ ConfigValidationError: Config validation failed at "/home/me/.config/app/config.
101
101
  - `CliLogger.layer(options?)` — replaces the default logger with plain lines, routing `Error` and above to stderr. The threshold is the `stderrFrom` option, compared ordinally, so a level added upstream lands on the right stream without a change here.
102
102
  - `CliLogger.make(options?)` — the `Logger` itself, for composing into a logger set you already have.
103
103
  - `CliRuntime.reportFailures(options?)` — reports through your logger, then re-fails with an exit code and the mark that stops the runtime reporting it a second time.
104
- - `CliRuntime.reported(error, exitCode?)` — marks an error you reported yourself, so the runtime stays quiet about it.
104
+ - `CliRuntime.reported(error, exitCode?)` — marks an error you reported yourself, so the runtime stays quiet about it. A typed `Error` comes back as its own type (the marks are added in place) when it passes `instanceof Error` at runtime; any other value — including one that only satisfies `Error`'s shape structurally — is wrapped in a plain `Error`.
105
105
  - `SchemaIssueRenderer.render(issue)` — a `SchemaIssue` tree becomes one line per rejected value.
106
106
  - `ConfigIssueRenderer.render(error)` — the same rendering, reading `issue` off a `ConfigValidationError`.
107
107
 
package/index.d.ts CHANGED
@@ -189,8 +189,22 @@ export declare class CliRuntime {
189
189
  * Exported because a program that reports a failure itself — a validation
190
190
  * command that prints its own diagnostics, say — needs the same two marks
191
191
  * and should not have to rediscover the inverted polarity.
192
+ *
193
+ * The marks are added in place, so a typed error comes back as its own
194
+ * type: the `E` overload returns the very instance it was given, and a
195
+ * program failing with it keeps `catchTags` narrowing downstream without a
196
+ * cast. Any other value takes the `unknown` fallback and is wrapped in a
197
+ * plain `Error`.
198
+ *
199
+ * The `E extends Error` constraint is structural, not nominal — TypeScript
200
+ * cannot express "is really an `Error`", so the guarantee holds only when
201
+ * the argument passes `instanceof Error` at runtime. A value that merely
202
+ * satisfies `Error`'s shape (an object `implements Error`, or an error
203
+ * revived from JSON) still takes the wrapping branch and comes back as a
204
+ * fresh, stripped `Error` typed as `E`.
192
205
  */
193
- static readonly reported: (error: unknown, exitCode?: number) => Error;
206
+ static reported<E extends Error>(error: E, exitCode?: number): E;
207
+ static reported(error: unknown, exitCode?: number): Error;
194
208
  }
195
209
  //#endregion
196
210
  //#region src/ConfigIssueRenderer.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/cli",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "description": "The boundary layer of an effect/unstable/cli program: plain CLI output, failure reporting, and schema-issue rendering",
6
6
  "keywords": [