@prisma/cli-engine 0.0.7 → 0.0.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/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TreeNode, A as BrowserWaitRequest, B as SpawnRequest, C as defineSessionCommand, Ct as FlagSpec, D as OutputStream, E as LoadedConfig, Et as positional, F as ChildResult, G as Outcome, H as exitWithChildStatus, I as ChildStatusSettlement, J as PresentedResult, K as PRESENTED, L as ExitWithChildStatusOptions, M as OpenUrlOutcome, N as OpenUrlRequest, O as PRISMA_CONFIG_VERSION, P as PromptSurface, Q as Tone, R as SpawnChild, S as defineServerCommand, St as CommandArgs, T as InputStream, Tt as flag, U as Block, V as SpawnedChild, W as Format, X as Status, Y as Span, Z as Text, _ as NeedsSpec, _t as SectionValidation, a as MountedTree, at as ActiveCredential, b as SpawnDeclarations, bt as ArgsSpec, c as AnyCommand, ct as CredentialManager, d as CommandHelp, dt as Session, et as Ui, f as CommandNeeds, ft as StoredSessions, g as HelpSpec, gt as ConfigSection, h as Handler, ht as TokenStorage, i as CommandRedirect, it as StreamMeta, j as CommandContext, k as Runtime, l as CommandDefinition, lt as CredentialOrigin, m as ErroredEnvelope, mt as ManagementApiClientConfig, n as RunSummary, nt as Severity, o as RedirectSpec, ot as Credential, p as CompletedEnvelope, pt as ManagementApiClient, q as Presentations, r as CommandFamily, rt as StreamEvent, s as defineCommandFamily, st as CredentialIdentity, t as EngineCommandSnapshot, tt as EngineEvent, u as CommandHandler, ut as SERVICE_TOKEN_ENV_VAR, v as ServerCommandDefinition, vt as defineConfigSection, w as HostProcess, wt as PositionalSpec, x as defineCommand, xt as Char, y as SessionCommandDefinition, yt as Args, z as SpawnOptions } from "./run-summary-CVHIRjTS.js";
|
|
2
2
|
import { n as CliStructuredError } from "./protocol-CpZLdxML.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cli.d.ts
|
|
@@ -135,4 +135,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
|
|
|
135
135
|
*/
|
|
136
136
|
declare function claimedIdentity(token: string): CredentialIdentity | undefined;
|
|
137
137
|
//#endregion
|
|
138
|
-
export { type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CommandRedirect, type CompletedEnvelope, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type HostProcess, type InputStream, type LoadedConfig, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type StoredSessions, type StreamEvent, type StreamMeta, type TokenStorage, type TreeNode, type Ui, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, defineServerCommand, defineSessionCommand, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional };
|
|
138
|
+
export { type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CommandRedirect, type CompletedEnvelope, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type HostProcess, type InputStream, type LoadedConfig, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type Span, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type Status, type StoredSessions, type StreamEvent, type StreamMeta, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, defineServerCommand, defineSessionCommand, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as PRESENTED, b as positional, c as PRISMA_CONFIG_VERSION, d as authServiceError, f as credentialRejectedError, g as noSessionForWorkspaceError, h as emptyServiceTokenError, i as buildEngine, l as SERVICE_TOKEN_ENV_VAR, m as credentialsRequiredError, n as claimedIdentity, o as defineConfig, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, s as loadConfig, t as claimedExpiresAt, u as WORKSPACE_ID_ENV_VAR, v as exitWithChildStatus, y as flag } from "./token-claims-
|
|
1
|
+
import { _ as PRESENTED, b as positional, c as PRISMA_CONFIG_VERSION, d as authServiceError, f as credentialRejectedError, g as noSessionForWorkspaceError, h as emptyServiceTokenError, i as buildEngine, l as SERVICE_TOKEN_ENV_VAR, m as credentialsRequiredError, n as claimedIdentity, o as defineConfig, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, s as loadConfig, t as claimedExpiresAt, u as WORKSPACE_ID_ENV_VAR, v as exitWithChildStatus, y as flag } from "./token-claims-_AF7BYbq.js";
|
|
2
2
|
import { t as CliStructuredError } from "./protocol-C1JQcGl9.js";
|
|
3
3
|
//#region src/cli.ts
|
|
4
4
|
/**
|
|
@@ -439,6 +439,34 @@ interface Presentations {
|
|
|
439
439
|
readonly json?: () => unknown;
|
|
440
440
|
readonly next?: () => readonly NextAction[];
|
|
441
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* What happened: it selects the glyph (✔ ✘ ⚠ ℹ) and carries a default
|
|
444
|
+
* Tone of the same name. Separate from Tone because a failure can be
|
|
445
|
+
* painted in a colour that is not `error` — a tree node in its branch
|
|
446
|
+
* lane's hue, say — and a colour can be chosen where nothing happened.
|
|
447
|
+
*/
|
|
448
|
+
type Status = "ok" | "error" | "warn" | "info";
|
|
449
|
+
/**
|
|
450
|
+
* What colour to paint, and nothing else. Semantic names and indexed
|
|
451
|
+
* colours in one union: a command asks for meaning where it has one and
|
|
452
|
+
* for a distinguishable colour where it does not. The indexed colours
|
|
453
|
+
* are for telling adjacent things apart — one per branch lane in a
|
|
454
|
+
* graph, say — and deliberately exclude red so no series member reads
|
|
455
|
+
* as an error.
|
|
456
|
+
*/
|
|
457
|
+
type Tone = "ok" | "warn" | "error" | "info" | "heading" | "identifier" | "ref" | "placeholder" | "link" | "emphasis" | "muted" | "structure" | "highlight" | "color-1" | "color-2" | "color-3" | "color-4" | "color-5" | "color-6";
|
|
458
|
+
/**
|
|
459
|
+
* A run of text and the meaning of its colour. A handler never emits
|
|
460
|
+
* escape sequences: the engine measures width from `text`, so colour
|
|
461
|
+
* cannot break alignment, and the same spans can be re-themed or
|
|
462
|
+
* stripped without re-rendering.
|
|
463
|
+
*/
|
|
464
|
+
interface Span {
|
|
465
|
+
readonly text: string;
|
|
466
|
+
readonly tone?: Tone;
|
|
467
|
+
}
|
|
468
|
+
/** Display text anywhere a block or Ui takes it. A bare string is untoned. */
|
|
469
|
+
type Text = string | readonly Span[];
|
|
442
470
|
/**
|
|
443
471
|
* Deliberately small; grows by the same evidence rule as events.
|
|
444
472
|
* Recorded findings are NOT a Block — they are the outcome's
|
|
@@ -447,35 +475,64 @@ interface Presentations {
|
|
|
447
475
|
*/
|
|
448
476
|
type Block = {
|
|
449
477
|
readonly kind: "summary";
|
|
450
|
-
readonly
|
|
451
|
-
readonly
|
|
478
|
+
readonly status: Status; /** Overrides the colour the status implies. Never the glyph. */
|
|
479
|
+
readonly tone?: Tone;
|
|
480
|
+
readonly text: Text;
|
|
452
481
|
} | {
|
|
482
|
+
/** A key/value card: the engine pads the keys so every value
|
|
483
|
+
* starts in the same column. */
|
|
453
484
|
readonly kind: "fields";
|
|
454
485
|
readonly rows: ReadonlyArray<{
|
|
455
|
-
readonly label:
|
|
456
|
-
readonly value:
|
|
486
|
+
readonly label: Text;
|
|
487
|
+
readonly value: Text;
|
|
457
488
|
readonly sensitive?: boolean;
|
|
458
489
|
}>;
|
|
490
|
+
/** Draws the dim `│` rail down the left of the card. A command
|
|
491
|
+
* knows whether it is drawing a header card or a plain one, so
|
|
492
|
+
* this is per block rather than a global setting. */
|
|
493
|
+
readonly rail?: boolean;
|
|
459
494
|
} | {
|
|
460
|
-
readonly kind: "table";
|
|
461
|
-
readonly columns: readonly
|
|
462
|
-
readonly rows: ReadonlyArray<readonly
|
|
495
|
+
/** The engine sizes every column to its widest cell. */readonly kind: "table";
|
|
496
|
+
readonly columns: readonly Text[];
|
|
497
|
+
readonly rows: ReadonlyArray<readonly Text[]>;
|
|
463
498
|
} | {
|
|
464
499
|
readonly kind: "list";
|
|
465
|
-
readonly items: readonly
|
|
500
|
+
readonly items: readonly Text[];
|
|
466
501
|
} | {
|
|
467
502
|
readonly kind: "tree";
|
|
468
503
|
readonly roots: readonly TreeNode[];
|
|
504
|
+
} | {
|
|
505
|
+
/**
|
|
506
|
+
* Lines of spans, rendered verbatim — no layout, no reflow, no
|
|
507
|
+
* truncation. For output whose two-dimensional structure the
|
|
508
|
+
* engine cannot derive, such as a migration graph's lane gutter,
|
|
509
|
+
* where the same hue has to reach the gutter cell, the node glyph
|
|
510
|
+
* and the label alike.
|
|
511
|
+
*/
|
|
512
|
+
readonly kind: "drawing";
|
|
513
|
+
readonly lines: readonly Text[];
|
|
469
514
|
};
|
|
470
515
|
interface TreeNode {
|
|
471
|
-
readonly label:
|
|
516
|
+
readonly label: Text;
|
|
517
|
+
/** Renders its glyph before the label. */
|
|
518
|
+
readonly status?: Status;
|
|
519
|
+
/** Colours the glyph and the label; defaults to the status. */
|
|
520
|
+
readonly tone?: Tone;
|
|
472
521
|
readonly children?: readonly TreeNode[];
|
|
473
522
|
}
|
|
474
523
|
/** Styling helpers usable inside block text; no direct writing. */
|
|
475
524
|
interface Ui {
|
|
525
|
+
/**
|
|
526
|
+
* How much room the command has: stderr's terminal width, or
|
|
527
|
+
* Number.POSITIVE_INFINITY when stderr is not a terminal. Only the
|
|
528
|
+
* command knows what to sacrifice, so the engine hands over the number
|
|
529
|
+
* and prints an overrun unmodified.
|
|
530
|
+
*/
|
|
531
|
+
readonly width: number;
|
|
476
532
|
readonly emphasize: (text: string) => string;
|
|
477
533
|
readonly dim: (text: string) => string;
|
|
478
534
|
readonly code: (text: string) => string;
|
|
535
|
+
readonly tone: (tone: Tone, text: string) => string;
|
|
479
536
|
}
|
|
480
537
|
//#endregion
|
|
481
538
|
//#region src/spawn.d.ts
|
|
@@ -747,6 +804,10 @@ interface PromptSurface {
|
|
|
747
804
|
/** Minimal structural stream types; no NodeJS.* in the public surface. */
|
|
748
805
|
interface OutputStream {
|
|
749
806
|
write(text: string): void;
|
|
807
|
+
/** The stream's terminal width, absent when it is not a terminal.
|
|
808
|
+
* The engine reads it at render time rather than caching it, so a
|
|
809
|
+
* terminal resized mid-run is respected by the next thing drawn. */
|
|
810
|
+
readonly columns?: number;
|
|
750
811
|
}
|
|
751
812
|
/**
|
|
752
813
|
* Byte-oriented, so server commands can implement byte-counted
|
|
@@ -845,6 +906,7 @@ interface HostProcess {
|
|
|
845
906
|
readonly stderr: {
|
|
846
907
|
write(text: string): unknown;
|
|
847
908
|
isTTY?: boolean;
|
|
909
|
+
columns?: number;
|
|
848
910
|
};
|
|
849
911
|
readonly stdin: {
|
|
850
912
|
isTTY?: boolean;
|
|
@@ -1249,4 +1311,4 @@ interface RunSummary {
|
|
|
1249
1311
|
readonly snapshot: EngineCommandSnapshot;
|
|
1250
1312
|
}
|
|
1251
1313
|
//#endregion
|
|
1252
|
-
export {
|
|
1314
|
+
export { TreeNode as $, BrowserWaitRequest as A, SpawnRequest as B, defineSessionCommand as C, FlagSpec as Ct, OutputStream as D, LoadedConfig as E, positional as Et, ChildResult as F, Outcome as G, exitWithChildStatus as H, ChildStatusSettlement as I, PresentedResult as J, PRESENTED as K, ExitWithChildStatusOptions as L, OpenUrlOutcome as M, OpenUrlRequest as N, PRISMA_CONFIG_VERSION as O, PromptSurface as P, Tone as Q, SpawnChild as R, defineServerCommand as S, CommandArgs as St, InputStream as T, flag as Tt, Block as U, SpawnedChild as V, Format as W, Status as X, Span as Y, Text as Z, NeedsSpec as _, SectionValidation as _t, MountedTree as a, ActiveCredential as at, SpawnDeclarations as b, ArgsSpec as bt, AnyCommand as c, CredentialManager as ct, CommandHelp as d, Session as dt, Ui as et, CommandNeeds as f, StoredSessions as ft, HelpSpec as g, ConfigSection as gt, Handler as h, TokenStorage$1 as ht, CommandRedirect as i, StreamMeta as it, CommandContext as j, Runtime as k, CommandDefinition as l, CredentialOrigin as lt, ErroredEnvelope as m, ManagementApiClientConfig as mt, RunSummary as n, Severity as nt, RedirectSpec as o, Credential as ot, CompletedEnvelope as p, ManagementApiClient$1 as pt, Presentations as q, CommandFamily as r, StreamEvent as rt, defineCommandFamily as s, CredentialIdentity as st, EngineCommandSnapshot as t, EngineEvent as tt, CommandHandler as u, SERVICE_TOKEN_ENV_VAR as ut, ServerCommandDefinition as v, defineConfigSection as vt, HostProcess as w, PositionalSpec as wt, defineCommand as x, Char as xt, SessionCommandDefinition as y, Args as yt, SpawnOptions as z };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as SpawnRequest, F as ChildResult, J as PresentedResult, R as SpawnChild, a as MountedTree, at as ActiveCredential, ct as CredentialManager, dt as Session, ft as StoredSessions, ht as TokenStorage, k as Runtime, mt as ManagementApiClientConfig, n as RunSummary, ot as Credential, pt as ManagementApiClient, r as CommandFamily, rt as StreamEvent, tt as EngineEvent } from "./run-summary-CVHIRjTS.js";
|
|
2
2
|
|
|
3
3
|
//#region src/in-memory-credential-manager.d.ts
|
|
4
4
|
/** A stored session with its credential material — what the manager
|
|
@@ -130,6 +130,11 @@ interface TestCli {
|
|
|
130
130
|
stdout?: boolean;
|
|
131
131
|
stderr?: boolean;
|
|
132
132
|
};
|
|
133
|
+
/** Terminal width, as the stream would report it. Absent means
|
|
134
|
+
* not a terminal, which is what ui.width reads as unbounded. */
|
|
135
|
+
readonly columns?: {
|
|
136
|
+
stderr?: number;
|
|
137
|
+
};
|
|
133
138
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
134
139
|
}): Promise<{
|
|
135
140
|
readonly exitCode: number;
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as noSessionForWorkspaceError, i as buildEngine, m as credentialsRequiredError, n as claimedIdentity, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, t as claimedExpiresAt } from "./token-claims-
|
|
1
|
+
import { g as noSessionForWorkspaceError, i as buildEngine, m as credentialsRequiredError, n as claimedIdentity, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, t as claimedExpiresAt } from "./token-claims-_AF7BYbq.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
3
|
//#region src/in-memory-credential-manager.ts
|
|
4
4
|
/**
|
|
@@ -378,9 +378,12 @@ function createTestCli(spec) {
|
|
|
378
378
|
stdout: { write: (text) => {
|
|
379
379
|
stdoutText += text;
|
|
380
380
|
} },
|
|
381
|
-
stderr: {
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
stderr: {
|
|
382
|
+
write: (text) => {
|
|
383
|
+
stderrText += text;
|
|
384
|
+
},
|
|
385
|
+
columns: opts?.columns?.stderr
|
|
386
|
+
},
|
|
384
387
|
stdin: inputStreamFromString(opts?.stdin ?? ""),
|
|
385
388
|
cwd: opts?.cwd ?? "/",
|
|
386
389
|
env: spec.environmentCredential === void 0 ? opts?.env ?? {} : {
|
|
@@ -3,6 +3,8 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { FlagNotFoundError, buildApplication, buildCommand, buildRouteMap, run, text_en } from "@stricli/core";
|
|
4
4
|
import { existsSync, realpathSync } from "node:fs";
|
|
5
5
|
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { createColors } from "colorette";
|
|
7
|
+
import stringWidth from "string-width";
|
|
6
8
|
import { Readable, Writable } from "node:stream";
|
|
7
9
|
import { Buffer } from "node:buffer";
|
|
8
10
|
//#region src/args.ts
|
|
@@ -892,9 +894,20 @@ function applySharedFlags(state, shared, runtime) {
|
|
|
892
894
|
state.confirmValues = [...shared.confirm ?? []];
|
|
893
895
|
state.interactive = shared.interactive ?? defaultInteractive(runtime);
|
|
894
896
|
state.logLevel = resolveLogLevel(shared);
|
|
895
|
-
state.colorEnabled = shared
|
|
897
|
+
state.colorEnabled = resolveColorEnabled(shared, runtime);
|
|
896
898
|
state.configPath = shared.config;
|
|
897
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* Explicit flag, then the environment, then the stream. The stream is
|
|
902
|
+
* stderr because that is where blocks render: keying off stdout meant
|
|
903
|
+
* `cmd > file` lost colour a human was watching and `cmd 2> file` kept
|
|
904
|
+
* colour nobody could see.
|
|
905
|
+
*/
|
|
906
|
+
function resolveColorEnabled(shared, runtime) {
|
|
907
|
+
if (shared.color !== void 0) return shared.color;
|
|
908
|
+
if (runtime.env.NO_COLOR !== void 0) return false;
|
|
909
|
+
return runtime.isTty.stderr;
|
|
910
|
+
}
|
|
898
911
|
/** Interactive iff TTY stdin outside CI; --interactive and
|
|
899
912
|
* --no-interactive override in either direction. Format never decides
|
|
900
913
|
* interactivity (operator ruling, 2026-08-09): an interactive json run
|
|
@@ -1100,6 +1113,72 @@ function matchFlagRedirect(table, commandPath, typedFlags) {
|
|
|
1100
1113
|
}
|
|
1101
1114
|
}
|
|
1102
1115
|
//#endregion
|
|
1116
|
+
//#region src/execution/palette.ts
|
|
1117
|
+
/**
|
|
1118
|
+
* Tones into bytes, and text into a display width. Basic 16-colour SGR
|
|
1119
|
+
* only — no 256-colour, no truecolor, and therefore no colour-depth
|
|
1120
|
+
* detection to own.
|
|
1121
|
+
*/
|
|
1122
|
+
/**
|
|
1123
|
+
* Every rendering is taken from a shipping implementation rather than
|
|
1124
|
+
* chosen fresh: the platform shell's semantic colours
|
|
1125
|
+
* (`packages/cli/src/shell/ui.ts`) and the ORM CLI's formatters. The
|
|
1126
|
+
* indexed colours are the ORM's lane rotation, in order, which excludes
|
|
1127
|
+
* red so a lane cannot be mistaken for an error.
|
|
1128
|
+
*
|
|
1129
|
+
* `heading` and `identifier` both render cyan because both shipping
|
|
1130
|
+
* CLIs use cyan for both. They stay separately named so a later
|
|
1131
|
+
* re-theme can separate them without touching a single command.
|
|
1132
|
+
*/
|
|
1133
|
+
const TONE_VERB = {
|
|
1134
|
+
ok: "greenBright",
|
|
1135
|
+
warn: "yellow",
|
|
1136
|
+
error: "redBright",
|
|
1137
|
+
info: "blue",
|
|
1138
|
+
heading: "cyan",
|
|
1139
|
+
identifier: "cyan",
|
|
1140
|
+
ref: "green",
|
|
1141
|
+
placeholder: "dim",
|
|
1142
|
+
link: "blue",
|
|
1143
|
+
emphasis: "bold",
|
|
1144
|
+
muted: "dim",
|
|
1145
|
+
structure: "dim",
|
|
1146
|
+
highlight: "greenBright",
|
|
1147
|
+
"color-1": "white",
|
|
1148
|
+
"color-2": "cyan",
|
|
1149
|
+
"color-3": "yellow",
|
|
1150
|
+
"color-4": "blueBright",
|
|
1151
|
+
"color-5": "magenta",
|
|
1152
|
+
"color-6": "green"
|
|
1153
|
+
};
|
|
1154
|
+
const COLORED = createColors({ useColor: true });
|
|
1155
|
+
const PLAIN = createColors({ useColor: false });
|
|
1156
|
+
function makePaint(colorEnabled) {
|
|
1157
|
+
const colors = colorEnabled ? COLORED : PLAIN;
|
|
1158
|
+
return (tone, text) => colors[TONE_VERB[tone]](text);
|
|
1159
|
+
}
|
|
1160
|
+
function renderText(text, paint) {
|
|
1161
|
+
if (typeof text === "string") return text;
|
|
1162
|
+
let rendered = "";
|
|
1163
|
+
for (const span of text) rendered += span.tone === void 0 ? span.text : paint(span.tone, span.text);
|
|
1164
|
+
return rendered;
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* The display width of what the reader sees, measured on the text the
|
|
1168
|
+
* spans carry rather than on the rendered bytes: colour cannot change a
|
|
1169
|
+
* column's width, and a CJK name is two cells wide, not one.
|
|
1170
|
+
*/
|
|
1171
|
+
function textWidth(text) {
|
|
1172
|
+
return stringWidth(plainText(text));
|
|
1173
|
+
}
|
|
1174
|
+
/** The text a reader sees, with every tone dropped. */
|
|
1175
|
+
function plainText(text) {
|
|
1176
|
+
if (typeof text === "string") return text;
|
|
1177
|
+
let plain = "";
|
|
1178
|
+
for (const span of text) plain += span.text;
|
|
1179
|
+
return plain;
|
|
1180
|
+
}
|
|
1181
|
+
//#endregion
|
|
1103
1182
|
//#region src/execution/rendering.ts
|
|
1104
1183
|
function firstLine(text) {
|
|
1105
1184
|
const newline = text.indexOf("\n");
|
|
@@ -1107,7 +1186,7 @@ function firstLine(text) {
|
|
|
1107
1186
|
}
|
|
1108
1187
|
const STEP_OUTCOME_SYMBOL = {
|
|
1109
1188
|
ok: "✔",
|
|
1110
|
-
failed: "
|
|
1189
|
+
failed: "✘",
|
|
1111
1190
|
skipped: "↷",
|
|
1112
1191
|
warning: "⚠"
|
|
1113
1192
|
};
|
|
@@ -1145,40 +1224,125 @@ function renderEventHuman(invocation, event) {
|
|
|
1145
1224
|
return;
|
|
1146
1225
|
}
|
|
1147
1226
|
}
|
|
1148
|
-
|
|
1227
|
+
/**
|
|
1228
|
+
* The four Status glyphs. The step-outcome map above and the
|
|
1229
|
+
* diagnostic-severity map below answer different questions, but the
|
|
1230
|
+
* three draw the same characters on purpose: one run must not report a
|
|
1231
|
+
* failure with one mark and explain it with another.
|
|
1232
|
+
*/
|
|
1233
|
+
const STATUS_SYMBOL = {
|
|
1149
1234
|
ok: "✔",
|
|
1150
|
-
error: "
|
|
1235
|
+
error: "✘",
|
|
1151
1236
|
warn: "⚠",
|
|
1152
1237
|
info: "ℹ"
|
|
1153
1238
|
};
|
|
1154
|
-
|
|
1239
|
+
const MASK = "********";
|
|
1240
|
+
const COLUMN_GAP = " ";
|
|
1241
|
+
const RAIL = "│";
|
|
1242
|
+
const BRANCH = "├─";
|
|
1243
|
+
const LAST_BRANCH = "└─";
|
|
1244
|
+
const TRAILING_SPACES = / +$/;
|
|
1245
|
+
/**
|
|
1246
|
+
* The engine draws; a command describes. Every escape sequence in the
|
|
1247
|
+
* output originates here, which is what makes width measurable and
|
|
1248
|
+
* alignment safe: a handler hands over spans, never bytes.
|
|
1249
|
+
*/
|
|
1250
|
+
function renderBlock(block, paint, write) {
|
|
1155
1251
|
switch (block.kind) {
|
|
1156
1252
|
case "summary":
|
|
1157
|
-
write(`${
|
|
1253
|
+
write(`${paint(block.tone ?? block.status, STATUS_SYMBOL[block.status])} ${renderText(block.text, paint)}`);
|
|
1158
1254
|
return;
|
|
1159
1255
|
case "fields":
|
|
1160
|
-
|
|
1256
|
+
writeFields(block.rows, block.rail === true, paint, write);
|
|
1161
1257
|
return;
|
|
1162
1258
|
case "table":
|
|
1163
|
-
|
|
1164
|
-
for (const row of block.rows) write(row.join(" "));
|
|
1259
|
+
writeTable(block.columns, block.rows, paint, write);
|
|
1165
1260
|
return;
|
|
1166
1261
|
case "list":
|
|
1167
|
-
for (const item of block.items) write(`- ${item}`);
|
|
1262
|
+
for (const item of block.items) write(`- ${renderText(item, paint)}`);
|
|
1168
1263
|
return;
|
|
1169
1264
|
case "tree":
|
|
1170
|
-
|
|
1265
|
+
for (const root of block.roots) {
|
|
1266
|
+
write(treeLabel(root, paint));
|
|
1267
|
+
writeBranches(root.children ?? [], "", paint, write);
|
|
1268
|
+
}
|
|
1269
|
+
return;
|
|
1270
|
+
case "drawing":
|
|
1271
|
+
for (const line of block.lines) write(renderText(line, paint));
|
|
1171
1272
|
return;
|
|
1172
1273
|
}
|
|
1173
1274
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1275
|
+
/** Appends to the text's last span, so a pad or a colon inherits the
|
|
1276
|
+
* tone of the run it extends — which is what makes a padded key one
|
|
1277
|
+
* continuous coloured field, as the legacy card drew it. */
|
|
1278
|
+
function extend(text, suffix) {
|
|
1279
|
+
if (suffix === "") return text;
|
|
1280
|
+
if (typeof text === "string") return `${text}${suffix}`;
|
|
1281
|
+
const last = text.at(-1);
|
|
1282
|
+
if (last === void 0) return suffix;
|
|
1283
|
+
return [...text.slice(0, -1), {
|
|
1284
|
+
...last,
|
|
1285
|
+
text: `${last.text}${suffix}`
|
|
1286
|
+
}];
|
|
1287
|
+
}
|
|
1288
|
+
function padTo(text, width) {
|
|
1289
|
+
const gap = width - textWidth(text);
|
|
1290
|
+
return gap > 0 ? extend(text, " ".repeat(gap)) : text;
|
|
1291
|
+
}
|
|
1292
|
+
/** The tone a cell falls back to when it states none of its own. */
|
|
1293
|
+
function toned(text, tone) {
|
|
1294
|
+
if (typeof text === "string") return [{
|
|
1295
|
+
text,
|
|
1296
|
+
tone
|
|
1297
|
+
}];
|
|
1298
|
+
return text.map((span) => span.tone === void 0 ? {
|
|
1299
|
+
...span,
|
|
1300
|
+
tone
|
|
1301
|
+
} : span);
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* The legacy card, restored: `${label}:` padded to a common width so
|
|
1305
|
+
* every value starts in the same column, the label in the accent
|
|
1306
|
+
* colour, two spaces between the two.
|
|
1307
|
+
*/
|
|
1308
|
+
function writeFields(rows, rail, paint, write) {
|
|
1309
|
+
const cells = rows.map((row) => ({
|
|
1310
|
+
label: toned(extend(row.label, ":"), "heading"),
|
|
1311
|
+
value: row.sensitive === true ? MASK : row.value
|
|
1312
|
+
}));
|
|
1313
|
+
const width = Math.max(0, ...cells.map((cell) => textWidth(cell.label)));
|
|
1314
|
+
const prefix = rail ? `${paint("structure", RAIL)}${COLUMN_GAP}` : "";
|
|
1315
|
+
for (const cell of cells) write(`${prefix}${renderText(padTo(cell.label, width), paint)}${COLUMN_GAP}${renderText(cell.value, paint)}`);
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Every column as wide as its widest cell, measured on the text rather
|
|
1319
|
+
* than the bytes so colour cannot shift a column. The last column is
|
|
1320
|
+
* never padded, so no line carries trailing whitespace.
|
|
1321
|
+
*/
|
|
1322
|
+
function writeTable(columns, rows, paint, write) {
|
|
1323
|
+
const all = [columns.map((column) => toned(column, "heading")), ...rows];
|
|
1324
|
+
const widths = [];
|
|
1325
|
+
for (const row of all) for (const [index, cell] of row.entries()) widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
|
|
1326
|
+
for (const row of all) write(row.map((cell, index) => renderText(index === row.length - 1 ? cell : padTo(cell, widths[index]), paint)).join(COLUMN_GAP).replace(TRAILING_SPACES, ""));
|
|
1327
|
+
}
|
|
1328
|
+
/** Roots carry no connector; every level below is drawn from its
|
|
1329
|
+
* parent's prefix, so a deep branch stays under its own lane. */
|
|
1330
|
+
function writeBranches(nodes, prefix, paint, write) {
|
|
1331
|
+
for (const [index, node] of nodes.entries()) {
|
|
1332
|
+
const last = index === nodes.length - 1;
|
|
1333
|
+
write(`${prefix}${paint("structure", last ? LAST_BRANCH : BRANCH)} ${treeLabel(node, paint)}`);
|
|
1334
|
+
const continuation = last ? " " : `${paint("structure", RAIL)}${COLUMN_GAP}`;
|
|
1335
|
+
writeBranches(node.children ?? [], `${prefix}${continuation}`, paint, write);
|
|
1178
1336
|
}
|
|
1179
1337
|
}
|
|
1338
|
+
function treeLabel(node, paint) {
|
|
1339
|
+
const tone = node.tone ?? node.status;
|
|
1340
|
+
const label = renderText(tone === void 0 ? node.label : toned(node.label, tone), paint);
|
|
1341
|
+
if (node.status === void 0) return label;
|
|
1342
|
+
return `${paint(node.tone ?? node.status, STATUS_SYMBOL[node.status])} ${label}`;
|
|
1343
|
+
}
|
|
1180
1344
|
const DIAGNOSTIC_SYMBOL = {
|
|
1181
|
-
error: "
|
|
1345
|
+
error: "✘",
|
|
1182
1346
|
warn: "⚠",
|
|
1183
1347
|
info: "ℹ"
|
|
1184
1348
|
};
|
|
@@ -1214,7 +1378,8 @@ function withDocsUrl(state, diagnostic) {
|
|
|
1214
1378
|
* payload on stdout, always — human mode stays pipe-clean. */
|
|
1215
1379
|
function renderCompletedHuman(invocation, presented) {
|
|
1216
1380
|
const { runtime, state } = invocation;
|
|
1217
|
-
|
|
1381
|
+
const paint = makePaint(state.colorEnabled);
|
|
1382
|
+
for (const block of presented.presentation.human) renderBlock(block, paint, (line) => runtime.stderr.write(`${line}\n`));
|
|
1218
1383
|
for (const action of presented.presentation.next) runtime.stderr.write(`${renderNextAction(action)}\n`);
|
|
1219
1384
|
for (const diagnostic of presented.diagnostics) writeDiagnostic(runtime.stderr, withDocsUrl(state, diagnostic));
|
|
1220
1385
|
for (const line of presented.presentation.stdout) runtime.stdout.write(`${line}\n`);
|
|
@@ -1237,7 +1402,7 @@ function eventDisplaySeverity(event) {
|
|
|
1237
1402
|
* so the only surface left is a stderr note — throwing here would
|
|
1238
1403
|
* surface as an unhandled rejection in a detached async context. */
|
|
1239
1404
|
function reportAfterResolution(invocation) {
|
|
1240
|
-
invocation.runtime.stderr.write("
|
|
1405
|
+
invocation.runtime.stderr.write("✘ [CLI.INTERNAL_ERROR] @prisma/cli-engine: report() was called after the handler resolved\n");
|
|
1241
1406
|
}
|
|
1242
1407
|
function reportEvent(invocation, event) {
|
|
1243
1408
|
const state = invocation.state;
|
|
@@ -2030,16 +2195,26 @@ function spawnFailedError(command, cause) {
|
|
|
2030
2195
|
}
|
|
2031
2196
|
//#endregion
|
|
2032
2197
|
//#region src/execution/command-context.ts
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2198
|
+
/** Unbounded off-terminal, so the arithmetic a renderer already does —
|
|
2199
|
+
* Math.min(x, ui.width), ui.width - gutter — stays correct with no
|
|
2200
|
+
* special case. */
|
|
2201
|
+
function availableWidth(stream) {
|
|
2202
|
+
const columns = stream.columns;
|
|
2203
|
+
return columns !== void 0 && columns > 0 ? columns : Number.POSITIVE_INFINITY;
|
|
2204
|
+
}
|
|
2205
|
+
/** Blocks render to stderr, so both the width and the colour decision
|
|
2206
|
+
* are stderr's. `width` is a getter because the contract reads it per
|
|
2207
|
+
* render rather than caching it. */
|
|
2208
|
+
function makeUi(colorEnabled, stderr) {
|
|
2209
|
+
const paint = makePaint(colorEnabled);
|
|
2039
2210
|
return {
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2211
|
+
get width() {
|
|
2212
|
+
return availableWidth(stderr);
|
|
2213
|
+
},
|
|
2214
|
+
emphasize: (text) => paint("emphasis", text),
|
|
2215
|
+
dim: (text) => paint("muted", text),
|
|
2216
|
+
code: (text) => `\`${text}\``,
|
|
2217
|
+
tone: paint
|
|
2043
2218
|
};
|
|
2044
2219
|
}
|
|
2045
2220
|
/** Materializes ONLY the active format's presentation functions, at the
|
|
@@ -2060,7 +2235,7 @@ function materializePresentation(state, ui, presentations) {
|
|
|
2060
2235
|
}
|
|
2061
2236
|
function makeContext(invocation, def, config, managesCredentials) {
|
|
2062
2237
|
const state = invocation.state;
|
|
2063
|
-
const ui = makeUi(state.colorEnabled);
|
|
2238
|
+
const ui = makeUi(state.colorEnabled, invocation.runtime.stderr);
|
|
2064
2239
|
const present = (outcome, presentations) => {
|
|
2065
2240
|
if (state.delegatedTerminal !== void 0) throw constructionError(`command '${state.commandId}' called ctx.present while a child owned the terminal`);
|
|
2066
2241
|
const exitCode = outcome.exitCode ?? 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/cli-engine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "The execution engine of the unified Prisma CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -49,7 +49,9 @@
|
|
|
49
49
|
"@clack/prompts": "1.5.0",
|
|
50
50
|
"@prisma/management-api-sdk": "1.55.0",
|
|
51
51
|
"@stricli/core": "1.3.0",
|
|
52
|
-
"c12": "3.3.4"
|
|
52
|
+
"c12": "3.3.4",
|
|
53
|
+
"colorette": "^2.0.20",
|
|
54
|
+
"string-width": "^8.2.1"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
57
|
"@repo/tsconfig": "workspace:8.0.0-rc.1",
|