@okfit/cli 0.6.6 → 0.6.8
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 +5 -3
- package/commands/context.js +2 -2
- package/commands/graph.js +2 -2
- package/commands/init.js +3 -2
- package/commands/lint.js +5 -4
- package/commands/stale.js +2 -2
- package/commands/sync.js +2 -2
- package/commands/validate.js +5 -4
- package/commands/verify.js +2 -2
- package/errors.js +5 -3
- package/index.d.ts +5 -3
- package/internal/versionFormatter.js +18 -14
- package/main.d.ts +12 -1
- package/main.js +19 -7
- package/package.json +5 -4
- package/version.js +1 -1
- package/internal/distribution.js +0 -21
- package/internal/tty.js +0 -13
package/README.md
CHANGED
|
@@ -389,9 +389,11 @@ that one case.
|
|
|
389
389
|
|
|
390
390
|
Every message `okfit` prints is lowercase, starts `error:` or `warning:`,
|
|
391
391
|
never ends with a trailing period, and renders a path relative to the
|
|
392
|
-
current directory when the path is under it, absolute otherwise. Colour,
|
|
393
|
-
stdout is a TTY and `NO_COLOR` is
|
|
394
|
-
|
|
392
|
+
current directory when the path is under it, absolute otherwise. Colour,
|
|
393
|
+
when stdout is a TTY and `NO_COLOR` is unset or empty (the
|
|
394
|
+
[no-color.org](https://no-color.org) rule: any non-empty `NO_COLOR` value
|
|
395
|
+
disables colour), wraps only the severity word — never the code, the
|
|
396
|
+
path, or the message text.
|
|
395
397
|
|
|
396
398
|
## License
|
|
397
399
|
|
package/commands/context.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Distribution } from "../internal/distribution.js";
|
|
2
1
|
import { setExitCode } from "../internal/exit.js";
|
|
3
2
|
import { humanContext } from "../render/context.js";
|
|
4
3
|
import { CLI_VERSION } from "../version.js";
|
|
5
4
|
import { Argument, Command, Flag } from "effect/unstable/cli";
|
|
5
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
6
6
|
import { ContextEnvelope, contextEnvelope, jsonError, provideConfig, resolveProjectConfig, runContext } from "@okfit/engine";
|
|
7
7
|
import { Console, Effect, Option, Schema } from "effect";
|
|
8
8
|
|
|
@@ -36,7 +36,7 @@ const contextCommand = Command.make("context", {
|
|
|
36
36
|
}, (input) => Effect.gen(function* () {
|
|
37
37
|
const cwd = process.cwd();
|
|
38
38
|
const discoveryCwd = Option.getOrElse(input.path, () => cwd);
|
|
39
|
-
const distribution = yield*
|
|
39
|
+
const distribution = yield* CurrentDistribution;
|
|
40
40
|
const body = Effect.gen(function* () {
|
|
41
41
|
const { projectRoot, bundleRoot, config: merged, profile, profileName, discovered } = yield* resolveProjectConfig({
|
|
42
42
|
pathArg: input.path,
|
package/commands/graph.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Distribution } from "../internal/distribution.js";
|
|
2
1
|
import { setExitCode } from "../internal/exit.js";
|
|
3
2
|
import { CLI_VERSION } from "../version.js";
|
|
4
3
|
import { Argument, Command, Flag } from "effect/unstable/cli";
|
|
4
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
5
5
|
import { GraphEnvelope, graphEnvelope, jsonError, provideConfig, resolveProjectConfig, runGraph } from "@okfit/engine";
|
|
6
6
|
import { Console, Effect, Option, Schema } from "effect";
|
|
7
7
|
import { OKF_SPEC_VERSION } from "@okfit/core";
|
|
@@ -40,7 +40,7 @@ const graphCommand = Command.make("graph", {
|
|
|
40
40
|
}, (input) => Effect.gen(function* () {
|
|
41
41
|
const cwd = process.cwd();
|
|
42
42
|
const discoveryCwd = Option.getOrElse(input.path, () => cwd);
|
|
43
|
-
const distribution = yield*
|
|
43
|
+
const distribution = yield* CurrentDistribution;
|
|
44
44
|
const body = Effect.gen(function* () {
|
|
45
45
|
const { bundleRoot, config: merged, profile } = yield* resolveProjectConfig({
|
|
46
46
|
pathArg: input.path,
|
package/commands/init.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { setExitCode } from "../internal/exit.js";
|
|
2
|
-
import { useColor } from "../internal/tty.js";
|
|
3
2
|
import { displayRoot, human, summary } from "../render/human.js";
|
|
4
3
|
import { Argument, Command, Flag } from "effect/unstable/cli";
|
|
5
4
|
import { CONFIG_RELATIVE_PATH, InitOverwriteError, Now, collect, configValue, files, forDiagnostics, provideConfig, resolveBundleRoot, resolveProjectRoot, run, targetPaths } from "@okfit/engine";
|
|
6
5
|
import { Console, DateTime, Effect, FileSystem, Layer, Option, Path } from "effect";
|
|
7
6
|
import { OKF_SPEC_VERSION, OkfitConfig, OkfitConfigFile, SCHEMA_DIRECTIVE } from "@okfit/core";
|
|
7
|
+
import { CliColor } from "@effected/cli";
|
|
8
8
|
import { Git } from "@effected/git";
|
|
9
9
|
import { GitHistory, Profiles } from "@okfit/profiles";
|
|
10
10
|
|
|
@@ -159,7 +159,8 @@ const initCommand = Command.make("init", {
|
|
|
159
159
|
now
|
|
160
160
|
}).pipe(Effect.provide(Layer.mergeAll(Git.layer, GitHistory.layer)));
|
|
161
161
|
const diagnostics = collect(result.report.conformance, result.report.lint, result.profileDiagnostics);
|
|
162
|
-
|
|
162
|
+
const color = yield* CliColor.enabled;
|
|
163
|
+
for (const line of human(diagnostics, { color })) yield* Console.log(line);
|
|
163
164
|
yield* Console.error(summary(countsOf(diagnostics, result.bundle.concepts.size), displayRoot(cwd, bundleRoot, path)));
|
|
164
165
|
setExitCode(forDiagnostics(diagnostics));
|
|
165
166
|
}));
|
package/commands/lint.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Distribution } from "../internal/distribution.js";
|
|
2
1
|
import { setExitCode } from "../internal/exit.js";
|
|
3
2
|
import { CLI_VERSION } from "../version.js";
|
|
4
|
-
import { useColor } from "../internal/tty.js";
|
|
5
3
|
import { displayRoot, human, summary } from "../render/human.js";
|
|
6
4
|
import { Argument, Command, Flag } from "effect/unstable/cli";
|
|
5
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
7
6
|
import { JsonEnvelope, Now, collect, forDiagnostics, json, jsonError, provideConfig, resolveProjectConfig, run } from "@okfit/engine";
|
|
8
7
|
import { Console, Effect, Layer, Option, Path, Schema } from "effect";
|
|
9
8
|
import { OKF_SPEC_VERSION } from "@okfit/core";
|
|
9
|
+
import { CliColor } from "@effected/cli";
|
|
10
10
|
import { Git } from "@effected/git";
|
|
11
11
|
import { GitHistory } from "@okfit/profiles";
|
|
12
12
|
|
|
@@ -43,7 +43,7 @@ const lintCommand = Command.make("lint", {
|
|
|
43
43
|
const discoveryCwd = Option.getOrElse(input.path, () => cwd);
|
|
44
44
|
const now = yield* Now;
|
|
45
45
|
const path = yield* Path.Path;
|
|
46
|
-
const distribution = yield*
|
|
46
|
+
const distribution = yield* CurrentDistribution;
|
|
47
47
|
const body = Effect.gen(function* () {
|
|
48
48
|
const { bundleRoot, config: merged, profile } = yield* resolveProjectConfig({
|
|
49
49
|
pathArg: input.path,
|
|
@@ -76,7 +76,8 @@ const lintCommand = Command.make("lint", {
|
|
|
76
76
|
});
|
|
77
77
|
yield* Console.log(JSON.stringify(Schema.encodeSync(JsonEnvelope)(envelope)));
|
|
78
78
|
} else {
|
|
79
|
-
|
|
79
|
+
const color = yield* CliColor.enabled;
|
|
80
|
+
for (const diagnosticLine of human(diagnostics, { color })) yield* Console.log(diagnosticLine);
|
|
80
81
|
const counts = {
|
|
81
82
|
errors: diagnostics.filter((d) => d.severity === "error").length,
|
|
82
83
|
warnings: diagnostics.filter((d) => d.severity === "warning").length,
|
package/commands/stale.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Distribution } from "../internal/distribution.js";
|
|
2
1
|
import { setExitCode } from "../internal/exit.js";
|
|
3
2
|
import { CLI_VERSION } from "../version.js";
|
|
4
3
|
import { displayRoot } from "../render/human.js";
|
|
5
4
|
import { humanStale, staleSummary } from "../render/stale.js";
|
|
6
5
|
import { Argument, Command, Flag } from "effect/unstable/cli";
|
|
6
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
7
7
|
import { Now, StaleEnvelope, jsonError, provideConfig, resolveProjectConfig, runStale, staleEnvelope } from "@okfit/engine";
|
|
8
8
|
import { Console, Effect, Option, Path, Schema } from "effect";
|
|
9
9
|
import { OKF_SPEC_VERSION } from "@okfit/core";
|
|
@@ -36,7 +36,7 @@ const staleCommand = Command.make("stale", {
|
|
|
36
36
|
const discoveryCwd = Option.getOrElse(input.path, () => cwd);
|
|
37
37
|
const now = yield* Now;
|
|
38
38
|
const path = yield* Path.Path;
|
|
39
|
-
const distribution = yield*
|
|
39
|
+
const distribution = yield* CurrentDistribution;
|
|
40
40
|
const body = Effect.gen(function* () {
|
|
41
41
|
const { bundleRoot, config: merged, profile } = yield* resolveProjectConfig({
|
|
42
42
|
pathArg: input.path,
|
package/commands/sync.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Distribution } from "../internal/distribution.js";
|
|
2
1
|
import { setExitCode } from "../internal/exit.js";
|
|
3
2
|
import { CLI_VERSION } from "../version.js";
|
|
4
3
|
import { displayRoot } from "../render/human.js";
|
|
5
4
|
import { humanSync } from "../render/sync.js";
|
|
6
5
|
import { Argument, Command, Flag } from "effect/unstable/cli";
|
|
6
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
7
7
|
import { Now, SyncEnvelope, jsonError, provideConfig, resolveProjectConfig, runSync, syncEnvelope } from "@okfit/engine";
|
|
8
8
|
import { Console, DateTime, Effect, Layer, Option, Path, Schema } from "effect";
|
|
9
9
|
import { Git } from "@effected/git";
|
|
@@ -77,7 +77,7 @@ const syncCommand = Command.make("sync", {
|
|
|
77
77
|
}, (input) => Effect.gen(function* () {
|
|
78
78
|
const cwd = process.cwd();
|
|
79
79
|
const discoveryCwd = Option.getOrElse(input.path, () => cwd);
|
|
80
|
-
const distribution = yield*
|
|
80
|
+
const distribution = yield* CurrentDistribution;
|
|
81
81
|
const body = Effect.gen(function* () {
|
|
82
82
|
const path = yield* Path.Path;
|
|
83
83
|
const resolved = yield* resolveProjectConfig({
|
package/commands/validate.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Distribution } from "../internal/distribution.js";
|
|
2
1
|
import { setExitCode } from "../internal/exit.js";
|
|
3
2
|
import { CLI_VERSION } from "../version.js";
|
|
4
|
-
import { useColor } from "../internal/tty.js";
|
|
5
3
|
import { displayRoot, human, summary } from "../render/human.js";
|
|
6
4
|
import { readDocumentText } from "../internal/stdin.js";
|
|
7
5
|
import { Argument, Command, Flag } from "effect/unstable/cli";
|
|
6
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
8
7
|
import { JsonEnvelope, Now, collect, forDiagnostics, json, jsonError, provideConfig, provideDocuments, resolveProjectConfig, run } from "@okfit/engine";
|
|
9
8
|
import { Console, Effect, Layer, Option, Path, Schema } from "effect";
|
|
10
9
|
import { OKF_SPEC_VERSION } from "@okfit/core";
|
|
10
|
+
import { CliColor } from "@effected/cli";
|
|
11
11
|
import { Git } from "@effected/git";
|
|
12
12
|
import { GitHistory } from "@okfit/profiles";
|
|
13
13
|
|
|
@@ -46,7 +46,7 @@ const validateCommand = Command.make("validate", {
|
|
|
46
46
|
const discoveryCwd = Option.getOrElse(input.path, () => cwd);
|
|
47
47
|
const now = yield* Now;
|
|
48
48
|
const path = yield* Path.Path;
|
|
49
|
-
const distribution = yield*
|
|
49
|
+
const distribution = yield* CurrentDistribution;
|
|
50
50
|
const body = Effect.gen(function* () {
|
|
51
51
|
const { bundleRoot, config: merged, profile } = yield* resolveProjectConfig({
|
|
52
52
|
pathArg: input.path,
|
|
@@ -83,7 +83,8 @@ const validateCommand = Command.make("validate", {
|
|
|
83
83
|
});
|
|
84
84
|
yield* Console.log(JSON.stringify(Schema.encodeSync(JsonEnvelope)(envelope)));
|
|
85
85
|
} else {
|
|
86
|
-
|
|
86
|
+
const color = yield* CliColor.enabled;
|
|
87
|
+
for (const diagnosticLine of human(diagnostics, { color })) yield* Console.log(diagnosticLine);
|
|
87
88
|
const counts = {
|
|
88
89
|
errors: diagnostics.filter((d) => d.severity === "error").length,
|
|
89
90
|
warnings: diagnostics.filter((d) => d.severity === "warning").length,
|
package/commands/verify.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Distribution } from "../internal/distribution.js";
|
|
2
1
|
import { setExitCode } from "../internal/exit.js";
|
|
3
2
|
import { CLI_VERSION } from "../version.js";
|
|
4
3
|
import { displayRoot } from "../render/human.js";
|
|
5
4
|
import { humanVerify, humanVerifyBatch } from "../render/verify.js";
|
|
6
5
|
import { Argument, Command, Flag } from "effect/unstable/cli";
|
|
6
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
7
7
|
import { Now, VerifyBatchEnvelope, VerifyEnvelope, VerifySelectionError, jsonError, provideConfig, resolveProjectConfig, runVerify, runVerifyBatch, verifyBatchEnvelope, verifyEnvelope } from "@okfit/engine";
|
|
8
8
|
import { Console, DateTime, Effect, Option, Path, Schema } from "effect";
|
|
9
9
|
import { Timestamp } from "@okfit/core";
|
|
@@ -59,7 +59,7 @@ const verifyCommand = Command.make("verify", {
|
|
|
59
59
|
const batch = input.all || input.type.length > 0;
|
|
60
60
|
const effectivePath = batch && Option.isSome(input.id) && Option.isNone(input.path) ? input.id : input.path;
|
|
61
61
|
const discoveryCwd = Option.getOrElse(effectivePath, () => cwd);
|
|
62
|
-
const distribution = yield*
|
|
62
|
+
const distribution = yield* CurrentDistribution;
|
|
63
63
|
const body = Effect.gen(function* () {
|
|
64
64
|
const path = yield* Path.Path;
|
|
65
65
|
const resolved = yield* resolveProjectConfig({
|
package/errors.js
CHANGED
|
@@ -20,9 +20,11 @@ const relativeToCwd = (path, cwd) => {
|
|
|
20
20
|
* 1. A `ShowHelp` (any `_tag === "ShowHelp"`) renders as `[]` — the empty
|
|
21
21
|
* array. `Command.runWith` has already rendered the help document and any
|
|
22
22
|
* parse errors before re-failing, so a second rendering here would print
|
|
23
|
-
* "Help requested" after the help text.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* "Help requested" after the help text. In practice this branch is
|
|
24
|
+
* defensive only: `@effected/cli`'s `CliRuntime.main`/`reportFailures`
|
|
25
|
+
* already handles a `ShowHelp` before `render` is ever called
|
|
26
|
+
* (`main.ts`'s own doc comment), so `renderFailure` never actually sees
|
|
27
|
+
* one on the path this package uses.
|
|
26
28
|
* 2. `ConfigPathNotFoundError` renders as its own `error: <message>` line;
|
|
27
29
|
* `InitOverwriteError` renders as the K-51 header, one two-space-indented
|
|
28
30
|
* relativised path per conflict, and the literal `Nothing was written.`.
|
package/index.d.ts
CHANGED
|
@@ -33,9 +33,11 @@ export declare const rootCommand: Command.Command<"okfit", {} | {}, {}, import("
|
|
|
33
33
|
* 1. A `ShowHelp` (any `_tag === "ShowHelp"`) renders as `[]` — the empty
|
|
34
34
|
* array. `Command.runWith` has already rendered the help document and any
|
|
35
35
|
* parse errors before re-failing, so a second rendering here would print
|
|
36
|
-
* "Help requested" after the help text.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* "Help requested" after the help text. In practice this branch is
|
|
37
|
+
* defensive only: `@effected/cli`'s `CliRuntime.main`/`reportFailures`
|
|
38
|
+
* already handles a `ShowHelp` before `render` is ever called
|
|
39
|
+
* (`main.ts`'s own doc comment), so `renderFailure` never actually sees
|
|
40
|
+
* one on the path this package uses.
|
|
39
41
|
* 2. `ConfigPathNotFoundError` renders as its own `error: <message>` line;
|
|
40
42
|
* `InitOverwriteError` renders as the K-51 header, one two-space-indented
|
|
41
43
|
* relativised path per conflict, and the literal `Nothing was written.`.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CliOutput } from "effect/unstable/cli";
|
|
1
|
+
import { CurrentDistribution, distributionSuffix } from "@effected/engine";
|
|
3
2
|
import { ENGINE_VERSION } from "@okfit/engine";
|
|
3
|
+
import { Effect, Layer } from "effect";
|
|
4
4
|
import { CONFIG_SCHEMA_VERSION, OKF_SPEC_VERSION } from "@okfit/core";
|
|
5
|
+
import { CliColor } from "@effected/cli";
|
|
5
6
|
|
|
6
7
|
//#region src/internal/versionFormatter.ts
|
|
7
8
|
/**
|
|
@@ -13,20 +14,23 @@ import { CONFIG_SCHEMA_VERSION, OKF_SPEC_VERSION } from "@okfit/core";
|
|
|
13
14
|
* exactly `okfit <CLI_VERSION>`; this appends the engine, okf, and
|
|
14
15
|
* distribution parts.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* Built on `@effected/cli`'s `CliColor.formatterLayer` (the kit's one
|
|
18
|
+
* colour-decision point, read through the ambient `ConfigProvider`, never
|
|
19
|
+
* `process` directly) and `@effected/engine`'s `distributionSuffix` for the
|
|
20
|
+
* `via <name> <version>` segment -- the shape `effect-v4-cli`'s
|
|
21
|
+
* `recipes.md#version-formatter` teaches. Only `formatVersion` is
|
|
22
|
+
* overridden; every other `Formatter` method (help, error rendering) is
|
|
23
|
+
* `CliColor.formatterLayer`'s own default, so help/error output stays
|
|
24
|
+
* consistent with the rest of the program's colour decision.
|
|
25
|
+
*
|
|
26
|
+
* `Layer.unwrap` around `Effect.map(CurrentDistribution, ...)` reads the
|
|
27
|
+
* distribution once, from the ambient `CurrentDistribution` reference
|
|
28
|
+
* `main.ts` provides, rather than threading it in as a constructor argument
|
|
29
|
+
* the way the hand-rolled formatter used to.
|
|
21
30
|
*
|
|
22
31
|
* @internal
|
|
23
32
|
*/
|
|
24
|
-
const
|
|
25
|
-
...CliOutput.defaultFormatter({ colors: useColor() }),
|
|
26
|
-
formatVersion: (name, version) => {
|
|
27
|
-
return `${name} ${version}${distribution === void 0 ? "" : ` via ${distribution.name} ${distribution.version}`} (engine ${ENGINE_VERSION}, okf ${OKF_SPEC_VERSION}, config-schema ${CONFIG_SCHEMA_VERSION})`;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
33
|
+
const versionFormatterLayer = Layer.unwrap(Effect.map(CurrentDistribution, (distribution) => CliColor.formatterLayer({ formatVersion: (name, version) => `${name} ${version}${distributionSuffix(distribution)} (engine ${ENGINE_VERSION}, okf ${OKF_SPEC_VERSION}, config-schema ${CONFIG_SCHEMA_VERSION})` })));
|
|
30
34
|
|
|
31
35
|
//#endregion
|
|
32
|
-
export {
|
|
36
|
+
export { versionFormatterLayer };
|
package/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Distribution } from "@
|
|
1
|
+
import { Distribution } from "@effected/engine";
|
|
2
2
|
//#region src/main.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Options `@okfit/plugin`'s bin shims (and only they, today) pass to
|
|
@@ -15,6 +15,17 @@ export interface MainOptions {
|
|
|
15
15
|
* Run the okfit CLI. Owns the process: installs the runtime teardown and
|
|
16
16
|
* sets the exit code. `NodeRuntime.runMain` does not return a promise.
|
|
17
17
|
*
|
|
18
|
+
* Assembled with `@effected/cli`'s `CliRuntime.main` (`effect-v4-cli`'s
|
|
19
|
+
* `recipes.md#the-main-assembly`), which already provides
|
|
20
|
+
* `platform` INSIDE failure reporting, a fresh `CliExit` cell, and the
|
|
21
|
+
* logger outermost -- the same order this package used to assemble by
|
|
22
|
+
* hand. `CliRuntime.main`/`reportFailures` also already remap a
|
|
23
|
+
* `CliError.ShowHelp` carrying parse errors to `usageExitCode` (64) and
|
|
24
|
+
* leave a bare `--help`/root invocation at 0 (`Command.runWith` has
|
|
25
|
+
* already rendered the help document either way), so the hand-rolled
|
|
26
|
+
* `catchTag("ShowHelp", ...)` remap this package used to carry is gone --
|
|
27
|
+
* it duplicated what the kit's own assembly already does.
|
|
28
|
+
*
|
|
18
29
|
* @public
|
|
19
30
|
*/
|
|
20
31
|
export declare const main: (options?: MainOptions) => void;
|
package/main.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Distribution } from "./internal/distribution.js";
|
|
2
1
|
import { CLI_VERSION } from "./version.js";
|
|
3
2
|
import { rootCommand } from "./commands/root.js";
|
|
4
3
|
import { renderFailure } from "./errors.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { versionFormatterLayer } from "./internal/versionFormatter.js";
|
|
5
|
+
import { Command } from "effect/unstable/cli";
|
|
6
|
+
import { CurrentDistribution } from "@effected/engine";
|
|
7
7
|
import { Now, OkfitPlatform } from "@okfit/engine";
|
|
8
8
|
import { DateTime, Effect, Option } from "effect";
|
|
9
|
-
import {
|
|
9
|
+
import { CliRuntime } from "@effected/cli";
|
|
10
10
|
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
11
11
|
|
|
12
12
|
//#region src/main.ts
|
|
@@ -29,18 +29,30 @@ const nowEffect = Option.fromNullishOr(process.env.OKFIT_NOW).pipe(Option.flatMa
|
|
|
29
29
|
* Run the okfit CLI. Owns the process: installs the runtime teardown and
|
|
30
30
|
* sets the exit code. `NodeRuntime.runMain` does not return a promise.
|
|
31
31
|
*
|
|
32
|
+
* Assembled with `@effected/cli`'s `CliRuntime.main` (`effect-v4-cli`'s
|
|
33
|
+
* `recipes.md#the-main-assembly`), which already provides
|
|
34
|
+
* `platform` INSIDE failure reporting, a fresh `CliExit` cell, and the
|
|
35
|
+
* logger outermost -- the same order this package used to assemble by
|
|
36
|
+
* hand. `CliRuntime.main`/`reportFailures` also already remap a
|
|
37
|
+
* `CliError.ShowHelp` carrying parse errors to `usageExitCode` (64) and
|
|
38
|
+
* leave a bare `--help`/root invocation at 0 (`Command.runWith` has
|
|
39
|
+
* already rendered the help document either way), so the hand-rolled
|
|
40
|
+
* `catchTag("ShowHelp", ...)` remap this package used to carry is gone --
|
|
41
|
+
* it duplicated what the kit's own assembly already does.
|
|
42
|
+
*
|
|
32
43
|
* @public
|
|
33
44
|
*/
|
|
34
45
|
const main = (options = {}) => {
|
|
35
46
|
const distribution = Option.fromNullishOr(options.distribution);
|
|
36
47
|
const program = Effect.gen(function* () {
|
|
37
48
|
const now = yield* nowEffect;
|
|
38
|
-
return yield* Command.run(rootCommand, { version: CLI_VERSION }).pipe(Effect.provideService(Now, now)
|
|
39
|
-
}).pipe(Effect.provide(
|
|
49
|
+
return yield* Command.run(rootCommand, { version: CLI_VERSION }).pipe(Effect.provideService(Now, now));
|
|
50
|
+
}).pipe(Effect.provide(versionFormatterLayer), Effect.provideService(CurrentDistribution, distribution));
|
|
51
|
+
NodeRuntime.runMain(CliRuntime.main(program, {
|
|
52
|
+
platform: OkfitPlatform,
|
|
40
53
|
exitCode: 3,
|
|
41
54
|
render: renderFailure
|
|
42
55
|
}));
|
|
43
|
-
NodeRuntime.runMain(program.pipe(Effect.provide(CliLogger.layer())));
|
|
44
56
|
};
|
|
45
57
|
|
|
46
58
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okfit/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The okfit command line: validate, lint, index, and inspect Open Knowledge Format (OKF) bundles.",
|
|
6
6
|
"keywords": [
|
|
@@ -43,17 +43,18 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@effect/platform-node": "4.0.0-rc.117",
|
|
46
|
-
"@effected/cli": "^0.
|
|
46
|
+
"@effected/cli": "^0.9.0",
|
|
47
47
|
"@effected/config-file": "^0.12.0",
|
|
48
|
+
"@effected/engine": "^0.1.0",
|
|
48
49
|
"@effected/git": "^0.17.0",
|
|
49
50
|
"@effected/glob": "^0.8.0",
|
|
50
51
|
"@effected/jsonc": "^0.13.0",
|
|
51
|
-
"@effected/markdown": "^0.12.
|
|
52
|
+
"@effected/markdown": "^0.12.1",
|
|
52
53
|
"@effected/toml": "^0.9.0",
|
|
53
54
|
"@effected/walker": "^0.12.0",
|
|
54
55
|
"@effected/yaml": "^0.17.0",
|
|
55
56
|
"@okfit/core": "0.8.0",
|
|
56
|
-
"@okfit/engine": "0.
|
|
57
|
+
"@okfit/engine": "0.9.0",
|
|
57
58
|
"@okfit/profiles": "0.8.0",
|
|
58
59
|
"effect": "4.0.0-rc.117"
|
|
59
60
|
},
|
package/version.js
CHANGED
package/internal/distribution.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Context, Option } from "effect";
|
|
2
|
-
|
|
3
|
-
//#region src/internal/distribution.ts
|
|
4
|
-
/**
|
|
5
|
-
* The meta-package this run's bins were installed through (currently only
|
|
6
|
-
* `@okfit/plugin`), threaded from `main(options)` down to every command
|
|
7
|
-
* that builds a JSON envelope or the custom `--version` formatter (okfit
|
|
8
|
-
* #137). Defaults to `Option.none()` for a direct install of `@okfit/cli`;
|
|
9
|
-
* `main()` provides `Option.some(options.distribution)` exactly once, at
|
|
10
|
-
* the top of the command tree, when the caller supplied one.
|
|
11
|
-
*
|
|
12
|
-
* A `Context.Reference`, not a `Context.Service` (unlike `Now`): it carries
|
|
13
|
-
* its own default, so a command can read it with no explicit provision at
|
|
14
|
-
* all when no distribution was given.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
const Distribution = Context.Reference("@okfit/cli/Distribution", { defaultValue: () => Option.none() });
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { Distribution };
|
package/internal/tty.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/internal/tty.ts
|
|
2
|
-
/**
|
|
3
|
-
* K-19: exactly the framework's own colour rule. Evaluated once per run at
|
|
4
|
-
* the command boundary and passed to the renderers as a boolean, so every
|
|
5
|
-
* renderer stays pure. The only reader of `process.stdout.isTTY`/`NO_COLOR`
|
|
6
|
-
* in this package.
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
const useColor = () => process.stdout.isTTY === true && process.env.NO_COLOR !== "1";
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { useColor };
|