@effected/cli 0.25.0 → 0.27.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 +5 -208
- package/bin/effected.js +7 -0
- package/commands/root.js +14 -0
- package/commands/schema/LiveProgress.js +114 -0
- package/commands/schema/build.js +9 -0
- package/commands/schema/check.js +12 -0
- package/commands/schema/errors.js +121 -0
- package/commands/schema/execute.js +141 -0
- package/commands/schema/flags.js +24 -0
- package/commands/schema/index.js +14 -0
- package/commands/schema/validate.js +58 -0
- package/index.d.ts +85 -3906
- package/index.js +4 -26
- package/main.d.ts +51 -0
- package/main.js +61 -0
- package/package.json +18 -50
- package/render/DiffDoc.js +51 -0
- package/tsdoc-metadata.json +1 -1
- package/version.js +11 -0
- package/Cancelled.js +0 -43
- package/CliAudience.js +0 -177
- package/CliColor.js +0 -59
- package/CliEnv.js +0 -101
- package/CliExit.js +0 -64
- package/CliFailure.js +0 -287
- package/CliFormat.js +0 -124
- package/CliInteractive.js +0 -94
- package/CliLinks.js +0 -153
- package/CliLog.js +0 -367
- package/CliLogger.js +0 -91
- package/CliMessage.js +0 -79
- package/CliPrompt.js +0 -110
- package/CliRuntime.js +0 -254
- package/CliTest.js +0 -206
- package/CliTheme.js +0 -142
- package/ConfigIssueRenderer.js +0 -63
- package/Doc.js +0 -548
- package/Fmt.js +0 -335
- package/GithubAnnotation.js +0 -39
- package/Glyphs.js +0 -82
- package/NotInteractive.js +0 -41
- package/Render.js +0 -280
- package/SchemaIssueRenderer.js +0 -47
- package/Status.js +0 -165
- package/TestTerminal.js +0 -101
- package/Token.js +0 -68
- package/internal/ExitRequested.js +0 -21
- package/internal/HelpRouting.js +0 -35
- package/internal/ansi.js +0 -229
- package/internal/autoFormat.js +0 -33
- package/internal/canPrompt.js +0 -14
- package/internal/counts.js +0 -83
- package/internal/diagnostics.js +0 -31
- package/internal/displayPath.js +0 -46
- package/internal/displayWidth.js +0 -42
- package/internal/failureTarget.js +0 -195
- package/internal/fallbackAnswer.js +0 -17
- package/internal/fileSink.js +0 -61
- package/internal/format.js +0 -175
- package/internal/inspect.js +0 -40
- package/internal/isExitCode.js +0 -11
- package/internal/layout.js +0 -249
- package/internal/linkScheme.js +0 -29
- package/internal/linkTarget.js +0 -49
- package/internal/logSafety.js +0 -45
- package/internal/renderAnsi.js +0 -51
- package/internal/renderDoc.js +0 -322
- package/internal/renderGithubLog.js +0 -59
- package/internal/renderMarkdown.js +0 -367
- package/internal/renderPlain.js +0 -49
- package/internal/scanAudience.js +0 -105
- package/internal/splitFrame.js +0 -55
- package/internal/terminalCapabilities.js +0 -23
- package/internal/wizardGate.js +0 -17
- package/testing.d.ts +0 -246
- package/testing.js +0 -4
- package/ui/CliUi.js +0 -507
- package/ui/CliUiDetached.js +0 -36
- package/ui/CliUiLive.js +0 -436
- package/ui/CliUiRouteStream.js +0 -72
- package/ui/Confirm.js +0 -244
- package/ui/DocView.js +0 -76
- package/ui/KeyHelp.js +0 -61
- package/ui/KeyTable.js +0 -198
- package/ui/MultiSelect.js +0 -259
- package/ui/Select.js +0 -229
- package/ui/Tabs.js +0 -201
- package/ui/TextInput.js +0 -289
- package/ui/Toggle.js +0 -31
- package/ui/UiKey.js +0 -48
- package/ui/UiProvider.js +0 -62
- package/ui/UiStreams.js +0 -17
- package/ui/UiTheme.js +0 -147
- package/ui/Viewport.js +0 -203
- package/ui/internal/ErrorBoundary.js +0 -29
- package/ui/internal/Holder.js +0 -73
- package/ui/internal/ScreenContext.js +0 -51
- package/ui/internal/UiProviders.js +0 -38
- package/ui/internal/ink.js +0 -121
- package/ui/internal/inkChalk.js +0 -47
- package/ui/internal/inkConsole.js +0 -150
- package/ui/internal/lazyView.js +0 -73
- package/ui/internal/lineRouter.js +0 -70
- package/ui/internal/lineText.js +0 -18
- package/ui/internal/mountPermit.js +0 -15
- package/ui/internal/processStreams.js +0 -18
- package/ui/internal/renderOptions.js +0 -12
- package/ui/testing/CliUiTest.js +0 -792
- package/ui/testing/fakeStreams.js +0 -104
- package/ui/testing/terminalModel.js +0 -67
- package/ui-testing-serializer.d.ts +0 -12
- package/ui-testing-serializer.js +0 -32
- package/ui-testing.d.ts +0 -558
- package/ui-testing.js +0 -3
- package/ui.d.ts +0 -1990
- package/ui.js +0 -17
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Argument, Flag } from "effect/cli";
|
|
2
|
+
|
|
3
|
+
// src/commands/schema/flags.ts
|
|
4
|
+
/** The optional positional config path; omitted, the config is discovered upward from the working directory. */
|
|
5
|
+
const configArgument = Argument.String("config").pipe(Argument.withDescription("Path to a schemastore config module; omitted, schemastore.config.{ts,mts,js,mjs} is searched upward from the working directory"), Argument.optional);
|
|
6
|
+
/** `--format`: absent, JSON for an agent and human text for everyone else. */
|
|
7
|
+
const formatFlag = Flag.Literals("format", ["human", "json"]).pipe(Flag.withDescription("Output format, by default json for an agent and human otherwise; json writes one document to stdout and moves human text to stderr"), Flag.optional);
|
|
8
|
+
/** `--ignore-version-mismatch`: run on past a config from another `@effected/schemastore`. */
|
|
9
|
+
const ignoreVersionMismatchFlag = Flag.Boolean("ignore-version-mismatch").pipe(Flag.withDefault(false), Flag.withDescription("Run even when the config's values come from a different @effected/schemastore than this tool's; warns loudly"));
|
|
10
|
+
/** What `build` and `check` take. */
|
|
11
|
+
const commandFlags = {
|
|
12
|
+
config: configArgument,
|
|
13
|
+
drift: Flag.Literals("drift", [
|
|
14
|
+
"strict",
|
|
15
|
+
"semantic",
|
|
16
|
+
"allow"
|
|
17
|
+
]).pipe(Flag.withDescription("Drift tolerance for published schemas; overrides every schema's drift"), Flag.optional),
|
|
18
|
+
onDrift: Flag.Literals("on-drift", ["error", "warn"]).pipe(Flag.withDescription("What drift does: refuse every write (error) or write and warn; overrides the config's onDrift"), Flag.optional),
|
|
19
|
+
force: Flag.Boolean("force").pipe(Flag.withDefault(false), Flag.withDescription("Shorthand for --drift=allow")),
|
|
20
|
+
format: formatFlag,
|
|
21
|
+
ignoreVersionMismatch: ignoreVersionMismatchFlag
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { commandFlags, configArgument, formatFlag, ignoreVersionMismatchFlag };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { makeBuildCommand } from "./build.js";
|
|
2
|
+
import { makeCheckCommand } from "./check.js";
|
|
3
|
+
import { makeValidateCommand } from "./validate.js";
|
|
4
|
+
import { Command } from "effect/cli";
|
|
5
|
+
|
|
6
|
+
// src/commands/schema/index.ts
|
|
7
|
+
/** `effected schema`: the group, closed over the process boundary it runs against. */
|
|
8
|
+
const makeSchemaCommand = (deps) => Command.make("schema", {}).pipe(Command.withDescription("Build and check SchemaStore-shaped JSON Schema documents from a schemastore.config.ts, and validate payloads against them"), Command.withSubcommands([
|
|
9
|
+
makeBuildCommand(deps),
|
|
10
|
+
makeCheckCommand(deps),
|
|
11
|
+
makeValidateCommand(deps)
|
|
12
|
+
]));
|
|
13
|
+
|
|
14
|
+
export { makeSchemaCommand };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ValidationFailedError } from "./errors.js";
|
|
2
|
+
import { configFailures, resolveFormat, warnVersionMismatch } from "./execute.js";
|
|
3
|
+
import { configArgument, formatFlag, ignoreVersionMismatchFlag } from "./flags.js";
|
|
4
|
+
import { CliRuntime, Doc } from "@effected/cli-kit";
|
|
5
|
+
import { Argument, Command, Flag } from "effect/cli";
|
|
6
|
+
import { SchemaValidate, ValidateReport } from "@effected/engine/schema";
|
|
7
|
+
import { Console, Effect, Option, Schema } from "effect";
|
|
8
|
+
|
|
9
|
+
// src/commands/schema/validate.ts
|
|
10
|
+
const findingLine = (finding) => {
|
|
11
|
+
const at = finding.location;
|
|
12
|
+
const where = at !== void 0 ? `${at.file}:${at.line}:${at.column}: ` : " ";
|
|
13
|
+
const keyword = finding.keyword !== void 0 ? ` [${finding.keyword}]` : "";
|
|
14
|
+
return `${where}${finding.path === "" ? "(root)" : finding.path}: ${finding.message}${keyword}`;
|
|
15
|
+
};
|
|
16
|
+
const humanLines = (report) => report.valid ? [`valid ${report.payload} against ${report.source}`] : [...report.findings.map(findingLine), `${report.findings.length} finding(s): ${report.payload} does not conform to ${report.$ref}`];
|
|
17
|
+
/** Run one `validate`. */
|
|
18
|
+
const runValidate = Effect.fn("effected.schema.validate")(function* (input, deps) {
|
|
19
|
+
const format = yield* resolveFormat(input.format);
|
|
20
|
+
const report = yield* SchemaValidate.run({
|
|
21
|
+
payload: input.payload,
|
|
22
|
+
versionMismatch: input.ignoreVersionMismatch ? "warn" : "fail",
|
|
23
|
+
...Option.isSome(input.config) ? { config: input.config.value } : {},
|
|
24
|
+
...Option.isSome(input.schema) ? { schema: input.schema.value } : {}
|
|
25
|
+
}, {
|
|
26
|
+
...deps,
|
|
27
|
+
onProgress: (event) => event._tag === "Started" && event.versionMismatch !== void 0 ? warnVersionMismatch(event.versionMismatch) : Effect.void
|
|
28
|
+
}).pipe(Effect.catchTags({
|
|
29
|
+
...configFailures("validate payload.json lib/schemastore.config.ts", input.config),
|
|
30
|
+
VersionMismatchError: (error) => Effect.fail(CliRuntime.reported(error, 2)),
|
|
31
|
+
PayloadError: (error) => Effect.fail(CliRuntime.reported(error, 2)),
|
|
32
|
+
SchemaResolutionError: (error) => Effect.fail(CliRuntime.reported(error, 2)),
|
|
33
|
+
MissingSchemaRefError: (error) => Effect.fail(CliRuntime.reported(error, 64))
|
|
34
|
+
}));
|
|
35
|
+
const lines = humanLines(report);
|
|
36
|
+
if (format === "json") {
|
|
37
|
+
yield* Console.log(JSON.stringify(Schema.encodeSync(ValidateReport.Json)(report)));
|
|
38
|
+
for (const line of lines) yield* Effect.logInfo(line);
|
|
39
|
+
} else yield* Doc.print([Doc.lines(lines.map((line, index) => Doc.text(line, report.valid ? "success" : index === lines.length - 1 ? "emphasis" : "error")), { wrap: false })]);
|
|
40
|
+
if (!report.valid) return yield* Effect.fail(CliRuntime.reported(new ValidationFailedError({
|
|
41
|
+
count: report.findings.length,
|
|
42
|
+
payload: report.payload,
|
|
43
|
+
schema: report.$ref
|
|
44
|
+
}), 1));
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* `effected schema validate`: check a payload against a published schema document, named by `--schema` or the payload's
|
|
48
|
+
* `$schema`: a file path, or an identity the config derives. No network is involved.
|
|
49
|
+
*/
|
|
50
|
+
const makeValidateCommand = (deps) => Command.make("validate", {
|
|
51
|
+
payload: Argument.String("payload").pipe(Argument.withDescription("Path to the JSON payload to validate")),
|
|
52
|
+
schema: Flag.String("schema").pipe(Flag.optional, Flag.withDescription("The document to validate against: a file path, or a $id/url a config schema derives; omitted, the payload's own $schema property")),
|
|
53
|
+
config: configArgument,
|
|
54
|
+
format: formatFlag,
|
|
55
|
+
ignoreVersionMismatch: ignoreVersionMismatchFlag
|
|
56
|
+
}, (input) => runValidate(input, deps)).pipe(Command.withDescription("Validate a JSON payload against a published schema document, resolved by path or by the config's derived $id/url identities"));
|
|
57
|
+
|
|
58
|
+
export { makeValidateCommand, runValidate };
|