@prisma/cli-engine 0.3.0 → 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/README.md +2 -0
- package/dist/{engine-CPLGpHh5.js → engine-DaES-DtJ.js} +820 -190
- package/dist/index.d.ts +19 -7
- package/dist/index.js +7 -6
- package/dist/{report-DR2h7YIG.d.ts → report-CCIboNYr.d.ts} +124 -28
- package/dist/testing.d.ts +11 -2
- package/dist/testing.js +11 -5
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as HostProcess, A as Format, At as ActiveAccessTokenOptions, B as Ui, Bt as CredentialRefresher, C as defineSessionCommand, Ct as ArgsSpec, D as OpenUrlRequest, Dt as PositionalSpec, E as OpenUrlOutcome, Et as FlagSpec, F as Span, Ft as CredentialOrigin, G as ConfigSection, H as Severity, Ht as ManagementApiClientConfig, I as Status, It as SERVICE_TOKEN_ENV_VAR, J as ResolvedSection, K as SectionValidation, L as Text, Lt as Session, M as PRESENTED, Mt as Credential, N as Presentations, Nt as CredentialIdentity, O as PromptSurface, Ot as flag, P as PresentedResult, Pt as CredentialManager, Q as Host, R as Tone, Rt as StoredSessions, S as defineServerCommand, St as Args, T as CommandContext, Tt as CommandArgs, U as StreamEvent, Ut as TokenStorage, V as EngineEvent, Vt as ManagementApiClient, W as StreamMeta, X as resolveSectionOverChain, Y as SectionProvenance, Z as resolveSectionPath, _ as ServerCommandDefinition, _t as PackageManagerId, a as RedirectSpec, at as Runtime, b as WorkflowStep, bt as PackageManagerRunner, c as CommandDefinition, ct as RunSummary, d as CommandNeeds, dt as ExitWithChildStatusOptions, et as InputStream, f as CompletedEnvelope, ft as SpawnChild, g as NeedsSpec, gt as exitWithChildStatus, h as HelpSpec, ht as SpawnedChild, i as MountedTree, it as PRISMA_CONFIG_VERSION, j as Outcome, jt as ActiveCredential, k as Block, kt as positional, l as CommandHandler, lt as ChildResult, m as Handler, mt as SpawnRequest, n as CommandFamily, nt as LoadedConfigFile, o as defineCommandFamily, ot as TelemetryPayload, p as ErroredEnvelope, pt as SpawnOptions, q as defineConfigSection, r as CommandRedirect, rt as OutputStream, s as AnyCommand, st as EngineCommandSnapshot, t as TelemetryDeclaration, tt as LoadedConfig, u as CommandHelp, ut as ChildStatusSettlement, v as SessionCommandDefinition, vt as PackageManagerRunRequest, w as BrowserWaitRequest, wt as Char, x as defineCommand, xt as PackageOperations, y as SpawnDeclarations, yt as PackageManagerRunResult, z as TreeNode, zt as CredentialRefreshResult } from "./report-CCIboNYr.js";
|
|
2
2
|
import { n as CliStructuredError } from "./protocol-YjqPCCOG.js";
|
|
3
3
|
|
|
4
4
|
//#region src/active-access-token.d.ts
|
|
@@ -48,12 +48,14 @@ declare function createCli(spec: {
|
|
|
48
48
|
readonly commandFamilies: readonly CommandFamily[];
|
|
49
49
|
readonly groups: Readonly<Record<string, {
|
|
50
50
|
readonly brief: string;
|
|
51
|
-
readonly description?: string;
|
|
51
|
+
readonly description?: string; /** The group's common path, rendered as a `Workflow` section. */
|
|
52
|
+
readonly workflow?: readonly WorkflowStep[];
|
|
52
53
|
}>>;
|
|
53
54
|
readonly commands: MountedTree; /** Words for the root help card; the engine formats. */
|
|
54
55
|
readonly help?: {
|
|
55
56
|
readonly tagline?: string;
|
|
56
|
-
readonly description?: string;
|
|
57
|
+
readonly description?: string; /** The CLI's common path, rendered as a `Workflow` section. */
|
|
58
|
+
readonly workflow?: readonly WorkflowStep[];
|
|
57
59
|
readonly examples?: readonly string[];
|
|
58
60
|
readonly docsUrl?: string;
|
|
59
61
|
};
|
|
@@ -79,9 +81,9 @@ declare function createCli(spec: {
|
|
|
79
81
|
declare function definePrismaConfig<T extends Record<string, unknown>>(config: T): T & {
|
|
80
82
|
readonly $prismaConfig: number;
|
|
81
83
|
};
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
declare
|
|
84
|
+
/** realpath where the path exists; the path itself where it does not
|
|
85
|
+
* (a cwd that is gone, a comparison candidate that was just checked). */
|
|
86
|
+
declare function realpathOr(path: string): string;
|
|
85
87
|
/**
|
|
86
88
|
* The real-disk loader behind Runtime.loadConfig. The bin binds it to
|
|
87
89
|
* the process cwd and its own version; tests hand in fixtures.
|
|
@@ -89,6 +91,16 @@ declare const defineConfig: typeof definePrismaConfig;
|
|
|
89
91
|
* when the 'prisma/config' entry point cannot be resolved; absent, the
|
|
90
92
|
* guidance names no version rather than an example that installs the
|
|
91
93
|
* wrong one.
|
|
94
|
+
*
|
|
95
|
+
* Every path handed onward is absolute — one more thing than either
|
|
96
|
+
* reference repository does, since both are handed an absolute path
|
|
97
|
+
* before they reach c12. Given a relative path, c12 resolves it a
|
|
98
|
+
* second time against its own cwd and looks for a file that is not
|
|
99
|
+
* there, and jiti cannot import a relative specifier at all. Resolving
|
|
100
|
+
* here also makes the file's path in every diagnostic absolute, and
|
|
101
|
+
* makes every chain-path comparison compare like with like. The anchor
|
|
102
|
+
* directory is additionally resolved through symlinks, so discovered
|
|
103
|
+
* files and the errors about them name real paths.
|
|
92
104
|
*/
|
|
93
105
|
declare function loadConfig(cwd: string, configPath?: string, cliVersion?: string): Promise<LoadedConfig>;
|
|
94
106
|
//#endregion
|
|
@@ -213,4 +225,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
|
|
|
213
225
|
*/
|
|
214
226
|
declare function claimedIdentity(token: string): CredentialIdentity | undefined;
|
|
215
227
|
//#endregion
|
|
216
|
-
export { type ActiveAccessTokenOptions, 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 CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, 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 PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, 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 TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily,
|
|
228
|
+
export { type ActiveAccessTokenOptions, 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 CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, type HostProcess, type InputStream, type LoadedConfig, type LoadedConfigFile, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type ResolvedSection, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionProvenance, 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 TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, type WorkflowStep, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as ok, r as notOk, t as CliStructuredError } from "./protocol-TtNVkeVS.js";
|
|
2
|
-
import { C as
|
|
2
|
+
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, O as emptyServiceTokenError, S as claimedIdentity, T as credentialRejectedError, _ as detectCI, a as definePrismaConfig, b as readActiveAccessToken, c as PRISMA_CONFIG_VERSION, d as PRESENTED, f as readUserConfig, g as exitWithChildStatus, h as resolveGating, k as noSessionForWorkspaceError, l as SERVICE_TOKEN_ENV_VAR, m as writeUserConfig, n as resolveSectionOverChain, o as loadConfig, p as userConfigPath, r as resolveSectionPath, s as realpathOr, t as buildEngine, u as WORKSPACE_ID_ENV_VAR, v as flag, w as authServiceError, x as claimedExpiresAt, y as positional } from "./engine-DaES-DtJ.js";
|
|
3
3
|
//#region src/cli.ts
|
|
4
4
|
/**
|
|
5
5
|
* Shell-side construction. Group help is declared with the mount.
|
|
@@ -95,7 +95,8 @@ function defineServerCommand(def) {
|
|
|
95
95
|
function defineConfigSection(spec) {
|
|
96
96
|
return Object.freeze({
|
|
97
97
|
name: spec.name,
|
|
98
|
-
validate: spec.validate
|
|
98
|
+
validate: spec.validate,
|
|
99
|
+
merge: spec.merge
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
//#endregion
|
|
@@ -300,7 +301,7 @@ function consentPresentations(line, json) {
|
|
|
300
301
|
const telemetryStatusCommand = defineCommand({
|
|
301
302
|
help: {
|
|
302
303
|
summary: "Show whether anonymous CLI telemetry is enabled and why",
|
|
303
|
-
description: "Reports whether telemetry is currently enabled or disabled and the reason
|
|
304
|
+
description: "Reports whether telemetry is currently enabled or disabled and the reason (default-on, stored opt-out, environment opt-out, or CI), the path to your user-level config file, and whether an installation ID has been stored. Read-only: never sends an event, never mints an ID, never writes anything.",
|
|
304
305
|
examples: ["telemetry status", "telemetry status --json"]
|
|
305
306
|
},
|
|
306
307
|
handler: async (_args, ctx) => {
|
|
@@ -317,7 +318,7 @@ const telemetryStatusCommand = defineCommand({
|
|
|
317
318
|
const telemetryEnableCommand = defineCommand({
|
|
318
319
|
help: {
|
|
319
320
|
summary: "Enable anonymous CLI telemetry",
|
|
320
|
-
description: "Stores \"enableTelemetry\": true in your user-level config and mints an
|
|
321
|
+
description: "Stores \"enableTelemetry\": true in your user-level config and mints an installation ID if one is not already stored.",
|
|
321
322
|
examples: ["telemetry enable"]
|
|
322
323
|
},
|
|
323
324
|
handler: async (_args, ctx) => {
|
|
@@ -334,7 +335,7 @@ const telemetryEnableCommand = defineCommand({
|
|
|
334
335
|
const telemetryDisableCommand = defineCommand({
|
|
335
336
|
help: {
|
|
336
337
|
summary: "Disable anonymous CLI telemetry",
|
|
337
|
-
description: "Stores \"enableTelemetry\": false in your user-level config. No installation
|
|
338
|
+
description: "Stores \"enableTelemetry\": false in your user-level config. No installation ID is minted and no event is sent.",
|
|
338
339
|
examples: ["telemetry disable"]
|
|
339
340
|
},
|
|
340
341
|
handler: async (_args, ctx) => {
|
|
@@ -378,4 +379,4 @@ Telemetry is on by default (opt-out); see ${options.docsUrl}\nfor what is collec
|
|
|
378
379
|
};
|
|
379
380
|
}
|
|
380
381
|
//#endregion
|
|
381
|
-
export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily,
|
|
382
|
+
export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup };
|
|
@@ -587,13 +587,16 @@ interface Runtime {
|
|
|
587
587
|
*/
|
|
588
588
|
readonly onSignal: (cb: (signal: "SIGINT" | "SIGTERM") => void) => () => void;
|
|
589
589
|
/**
|
|
590
|
-
*
|
|
591
|
-
* the command it is about to run declares a config section,
|
|
592
|
-
* that needs no config never touches
|
|
593
|
-
* file `--config` named: the loader resolves it against the
|
|
594
|
-
* cwd
|
|
595
|
-
*
|
|
596
|
-
*
|
|
590
|
+
* Resolves the prisma.config.ts chain, on demand. The engine calls it
|
|
591
|
+
* only when the command it is about to run declares a config section,
|
|
592
|
+
* so a run that needs no config never touches a file. `configPath` is
|
|
593
|
+
* the file `--config` named: the loader resolves it against the
|
|
594
|
+
* runtime's cwd, reports its absence, makes it the first chain link,
|
|
595
|
+
* and resumes discovery strictly above its directory — a
|
|
596
|
+
* prisma.config.ts beside it is not collected. Absent means
|
|
597
|
+
* discover from cwd, where finding no file is
|
|
598
|
+
* not an error. The bin wires the real disk loader; tests hand in
|
|
599
|
+
* fixtures.
|
|
597
600
|
*/
|
|
598
601
|
readonly loadConfig: (configPath?: string) => Promise<LoadedConfig>;
|
|
599
602
|
/**
|
|
@@ -703,26 +706,33 @@ interface HostProcess {
|
|
|
703
706
|
off(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
|
|
704
707
|
exit(code: number): never;
|
|
705
708
|
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
* or prisma.config.ts in cwd. A loader that found no file still names
|
|
710
|
-
* the file it looked for — with no file there are no sections, and
|
|
711
|
-
* the engine reads the path only to name the file when it reports a
|
|
712
|
-
* top-level key that is not one of the CLI's sections.
|
|
713
|
-
*/
|
|
709
|
+
/** One file on the resolved config chain. */
|
|
710
|
+
interface LoadedConfigFile {
|
|
711
|
+
/** Where the file is, absolute; every diagnostic about it names it. */
|
|
714
712
|
readonly path: string;
|
|
715
713
|
/**
|
|
716
|
-
* Raw section values by name
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
714
|
+
* Raw section values by name — the file's top-level keys minus the
|
|
715
|
+
* engine-reserved ones (`$prismaConfig`, `parent`); validation
|
|
716
|
+
* happens per command via its command family's section token. The
|
|
717
|
+
* engine, not the loader, checks these names against the sections
|
|
718
|
+
* the CLI declares, so the closed set holds whatever loader a host
|
|
719
|
+
* wires.
|
|
720
720
|
*/
|
|
721
721
|
readonly sections: Readonly<Record<string, unknown>>;
|
|
722
|
+
}
|
|
723
|
+
interface LoadedConfig {
|
|
724
|
+
/**
|
|
725
|
+
* The resolved chain, nearest-first: the anchor file (the one
|
|
726
|
+
* `--config` named, or prisma.config.ts discovered from cwd), then
|
|
727
|
+
* each ancestor or declared parent. Empty when discovery found no
|
|
728
|
+
* file at all — the section validators own absence.
|
|
729
|
+
*/
|
|
730
|
+
readonly files: ReadonlyArray<LoadedConfigFile>;
|
|
722
731
|
/**
|
|
723
|
-
* File-level problems (unevaluable module,
|
|
724
|
-
*
|
|
725
|
-
* section
|
|
732
|
+
* File-level problems anywhere on the chain (unevaluable module,
|
|
733
|
+
* missing version marker, a broken `parent` link) carry
|
|
734
|
+
* section: null and fail only commands with a needs.config section;
|
|
735
|
+
* commands with no config need run normally.
|
|
726
736
|
*/
|
|
727
737
|
readonly diagnostics: ReadonlyArray<{
|
|
728
738
|
readonly section: string | null;
|
|
@@ -730,23 +740,84 @@ interface LoadedConfig {
|
|
|
730
740
|
}>;
|
|
731
741
|
}
|
|
732
742
|
/**
|
|
733
|
-
* The config contract version
|
|
743
|
+
* The config contract version definePrismaConfig writes as the structural
|
|
734
744
|
* `$prismaConfig` marker; the loader checks it before interpreting
|
|
735
745
|
* anything.
|
|
736
746
|
*/
|
|
737
747
|
declare const PRISMA_CONFIG_VERSION = 1;
|
|
738
748
|
//#endregion
|
|
749
|
+
//#region src/config-merge.d.ts
|
|
750
|
+
/** Which files a resolved section value came from. */
|
|
751
|
+
interface SectionProvenance {
|
|
752
|
+
/** Paths of the files declaring the section, nearest first. */
|
|
753
|
+
readonly files: readonly string[];
|
|
754
|
+
/**
|
|
755
|
+
* The declaring file per top-level key of the resolved value: the
|
|
756
|
+
* nearest file whose raw section wrote that key. A key no file wrote
|
|
757
|
+
* (a custom merge produced it) is attributed to the nearest file.
|
|
758
|
+
*/
|
|
759
|
+
readonly keys: Readonly<Record<string, string>>;
|
|
760
|
+
}
|
|
761
|
+
type ResolvedSection = {
|
|
762
|
+
readonly ok: true;
|
|
763
|
+
/** undefined when no file on the chain declares the section — the
|
|
764
|
+
* section validator owns absence, exactly as before. */
|
|
765
|
+
readonly value: unknown; /** The files declaring the section, nearest first. */
|
|
766
|
+
readonly contributors: readonly LoadedConfigFile[]; /** Where the value came from, for resolveSectionPath. */
|
|
767
|
+
readonly provenance: SectionProvenance;
|
|
768
|
+
} | {
|
|
769
|
+
/** Reading or merging the section's value threw: the value and a
|
|
770
|
+
* custom merge are user code alike, so this is a config error
|
|
771
|
+
* naming the file, never an engine bug. */
|
|
772
|
+
readonly ok: false;
|
|
773
|
+
readonly file: string;
|
|
774
|
+
readonly cause: unknown;
|
|
775
|
+
};
|
|
776
|
+
/**
|
|
777
|
+
* Resolves `section` over the chain, nearest first: the farthest
|
|
778
|
+
* declaring file's value, folded under each nearer one with the
|
|
779
|
+
* section's own merge or the engine default. A plain-object result is
|
|
780
|
+
* always a fresh, frozen object — the files' exports are never
|
|
781
|
+
* mutated — and the result carries the provenance resolveSectionPath
|
|
782
|
+
* consumes.
|
|
783
|
+
*/
|
|
784
|
+
declare function resolveSectionOverChain(section: ConfigSection<unknown>, files: readonly LoadedConfigFile[]): ResolvedSection;
|
|
785
|
+
/**
|
|
786
|
+
* Resolves a path found under a TOP-LEVEL `key` of a resolved section
|
|
787
|
+
* value against the file that declared that key — never against cwd or
|
|
788
|
+
* the nearest config file. The intended caller is a section validator,
|
|
789
|
+
* which receives the provenance as its second argument and returns the
|
|
790
|
+
* resolved absolute path in its validated value; an absolute path comes
|
|
791
|
+
* back unchanged. Throws on a key the resolved value does not carry at its
|
|
792
|
+
* top level — a silent fallback could resolve against the wrong file,
|
|
793
|
+
* which is the mistake this helper exists to prevent.
|
|
794
|
+
*/
|
|
795
|
+
declare function resolveSectionPath(provenance: SectionProvenance, key: string, path: string): string;
|
|
796
|
+
//#endregion
|
|
739
797
|
//#region src/config-section.d.ts
|
|
740
798
|
/**
|
|
741
799
|
* A command family's named slice of prisma.config.ts. The token couples
|
|
742
800
|
* the section name, its validated type, and its total validator. The
|
|
743
801
|
* validator owns absence: its input is the raw section value, or
|
|
744
802
|
* undefined when the config file has no such section. It returns
|
|
745
|
-
* findings; it never throws.
|
|
803
|
+
* findings; it never throws. Its second argument is the resolved
|
|
804
|
+
* value's provenance: a validator with path-valued keys resolves each
|
|
805
|
+
* through resolveSectionPath(provenance, key, path) and returns
|
|
806
|
+
* absolute paths, so downstream code never resolves against cwd. A
|
|
807
|
+
* one-argument validator stays valid for sections with no paths.
|
|
746
808
|
*/
|
|
747
809
|
interface ConfigSection<T> {
|
|
748
810
|
readonly name: string;
|
|
749
|
-
readonly validate: (raw: unknown | undefined) => SectionValidation<T>;
|
|
811
|
+
readonly validate: (raw: unknown | undefined, provenance: SectionProvenance) => SectionValidation<T>;
|
|
812
|
+
/**
|
|
813
|
+
* How two files' raw values combine when more than one file on the
|
|
814
|
+
* config chain declares the section. `child` is the nearer file's
|
|
815
|
+
* value and wins conflicts. Both inputs may be frozen, so the result
|
|
816
|
+
* must be a fresh value, never a mutation of either. Absent, the
|
|
817
|
+
* engine merges per key at the section's top level and replaces
|
|
818
|
+
* below.
|
|
819
|
+
*/
|
|
820
|
+
readonly merge?: (parent: unknown, child: unknown) => unknown;
|
|
750
821
|
}
|
|
751
822
|
/**
|
|
752
823
|
* Diagnostics on an OK validation are warnings: the engine writes them
|
|
@@ -763,7 +834,8 @@ type SectionValidation<T> = {
|
|
|
763
834
|
};
|
|
764
835
|
declare function defineConfigSection<T>(spec: {
|
|
765
836
|
readonly name: string;
|
|
766
|
-
readonly validate: (raw: unknown | undefined) => SectionValidation<T>;
|
|
837
|
+
readonly validate: (raw: unknown | undefined, provenance: SectionProvenance) => SectionValidation<T>;
|
|
838
|
+
readonly merge?: (parent: unknown, child: unknown) => unknown;
|
|
767
839
|
}): ConfigSection<T>;
|
|
768
840
|
//#endregion
|
|
769
841
|
//#region src/events.d.ts
|
|
@@ -858,7 +930,7 @@ interface StreamMeta {
|
|
|
858
930
|
}
|
|
859
931
|
//#endregion
|
|
860
932
|
//#region src/presentation.d.ts
|
|
861
|
-
type Format = "human" | "json";
|
|
933
|
+
type Format = "human" | "json" | "markdown";
|
|
862
934
|
/**
|
|
863
935
|
* What a command concluded, stated at the return site. `exitCode` is
|
|
864
936
|
* required at every return site iff the command documents exit codes,
|
|
@@ -1022,6 +1094,20 @@ interface CommandContext<TConfig = undefined, TCode extends number = never> {
|
|
|
1022
1094
|
* validator. Commands with no config need get undefined.
|
|
1023
1095
|
*/
|
|
1024
1096
|
readonly config: TConfig;
|
|
1097
|
+
/**
|
|
1098
|
+
* The config chain the needs check resolved, nearest-first — the
|
|
1099
|
+
* same load ctx.config was validated from, including files whose
|
|
1100
|
+
* sections this command did not need. Empty when the command
|
|
1101
|
+
* declares no config need, and when discovery found no file.
|
|
1102
|
+
*/
|
|
1103
|
+
readonly configFiles: ReadonlyArray<LoadedConfigFile>;
|
|
1104
|
+
/**
|
|
1105
|
+
* The file `--config` named, exactly as the user wrote it, or
|
|
1106
|
+
* undefined when the flag was absent. Handlers that load config out
|
|
1107
|
+
* of band (outside needs.config) pass it on, so the file the user
|
|
1108
|
+
* named governs those reads too.
|
|
1109
|
+
*/
|
|
1110
|
+
readonly configPath: string | undefined;
|
|
1025
1111
|
/**
|
|
1026
1112
|
* Builds the PresentedResult for the active format. The only
|
|
1027
1113
|
* constructor of PresentedResult.
|
|
@@ -1229,6 +1315,16 @@ interface PromptSurface {
|
|
|
1229
1315
|
* field is always present, with empty collections and explicit
|
|
1230
1316
|
* undefined instead of conditional properties.
|
|
1231
1317
|
*/
|
|
1318
|
+
/**
|
|
1319
|
+
* One step of a group's common path, rendered under a `Workflow`
|
|
1320
|
+
* heading on the group's help card. `run` follows the example
|
|
1321
|
+
* convention: no binary name, `{bin}` substituted at render time.
|
|
1322
|
+
*/
|
|
1323
|
+
interface WorkflowStep {
|
|
1324
|
+
readonly run: string;
|
|
1325
|
+
/** Short purpose column shown beside the invocation. */
|
|
1326
|
+
readonly brief: string;
|
|
1327
|
+
}
|
|
1232
1328
|
/** The help SPI: words only — the engine formats. */
|
|
1233
1329
|
interface HelpSpec {
|
|
1234
1330
|
/** One line, imperative, shown in listings. */
|
|
@@ -1544,4 +1640,4 @@ interface TelemetryDeclaration {
|
|
|
1544
1640
|
readonly docsUrl: string;
|
|
1545
1641
|
}
|
|
1546
1642
|
//#endregion
|
|
1547
|
-
export {
|
|
1643
|
+
export { HostProcess as $, Format as A, ActiveAccessTokenOptions as At, Ui as B, CredentialRefresher as Bt, defineSessionCommand as C, ArgsSpec as Ct, OpenUrlRequest as D, PositionalSpec as Dt, OpenUrlOutcome as E, FlagSpec as Et, Span as F, CredentialOrigin as Ft, ConfigSection as G, Severity as H, ManagementApiClientConfig as Ht, Status as I, SERVICE_TOKEN_ENV_VAR as It, ResolvedSection as J, SectionValidation as K, Text as L, Session as Lt, PRESENTED as M, Credential as Mt, Presentations as N, CredentialIdentity as Nt, PromptSurface as O, flag as Ot, PresentedResult as P, CredentialManager as Pt, Host as Q, Tone as R, StoredSessions as Rt, defineServerCommand as S, Args as St, CommandContext as T, CommandArgs as Tt, StreamEvent as U, TokenStorage$1 as Ut, EngineEvent as V, ManagementApiClient$1 as Vt, StreamMeta as W, resolveSectionOverChain as X, SectionProvenance as Y, resolveSectionPath as Z, ServerCommandDefinition as _, PackageManagerId as _t, RedirectSpec as a, Runtime as at, WorkflowStep as b, PackageManagerRunner as bt, CommandDefinition as c, RunSummary as ct, CommandNeeds as d, ExitWithChildStatusOptions as dt, InputStream as et, CompletedEnvelope as f, SpawnChild as ft, NeedsSpec as g, exitWithChildStatus as gt, HelpSpec as h, SpawnedChild as ht, MountedTree as i, PRISMA_CONFIG_VERSION as it, Outcome as j, ActiveCredential as jt, Block as k, positional as kt, CommandHandler as l, ChildResult as lt, Handler as m, SpawnRequest as mt, CommandFamily as n, LoadedConfigFile as nt, defineCommandFamily as o, TelemetryPayload as ot, ErroredEnvelope as p, SpawnOptions as pt, defineConfigSection as q, CommandRedirect as r, OutputStream as rt, AnyCommand as s, EngineCommandSnapshot as st, TelemetryDeclaration as t, LoadedConfig as tt, CommandHelp as u, ChildStatusSettlement as ut, SessionCommandDefinition as v, PackageManagerRunRequest as vt, BrowserWaitRequest as w, Char as wt, defineCommand as x, PackageOperations as xt, SpawnDeclarations as y, PackageManagerRunResult as yt, TreeNode as z, CredentialRefreshResult as zt };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as ActiveAccessTokenOptions, Bt as CredentialRefresher, Ht as ManagementApiClientConfig, Lt as Session, Mt as Credential, P as PresentedResult, Pt as CredentialManager, Q as Host, Rt as StoredSessions, U as StreamEvent, Ut as TokenStorage, V as EngineEvent, Vt as ManagementApiClient, _t as PackageManagerId, at as Runtime, b as WorkflowStep, bt as PackageManagerRunner, ct as RunSummary, ft as SpawnChild, i as MountedTree, jt as ActiveCredential, lt as ChildResult, mt as SpawnRequest, n as CommandFamily, ot as TelemetryPayload, t as TelemetryDeclaration } from "./report-CCIboNYr.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
|
|
@@ -174,7 +174,16 @@ declare function createTestCli(spec: {
|
|
|
174
174
|
readonly commands: MountedTree;
|
|
175
175
|
readonly groups?: Readonly<Record<string, {
|
|
176
176
|
readonly brief: string;
|
|
177
|
-
|
|
177
|
+
readonly description?: string;
|
|
178
|
+
readonly workflow?: readonly WorkflowStep[];
|
|
179
|
+
}>>; /** Words for the root help card, exactly as `createCli` takes them. */
|
|
180
|
+
readonly help?: {
|
|
181
|
+
readonly tagline?: string;
|
|
182
|
+
readonly description?: string;
|
|
183
|
+
readonly workflow?: readonly WorkflowStep[];
|
|
184
|
+
readonly examples?: readonly string[];
|
|
185
|
+
readonly docsUrl?: string;
|
|
186
|
+
};
|
|
178
187
|
/** Seeds the sections the config file would have held. The engine
|
|
179
188
|
* asks for them only when the command declares a config section, and
|
|
180
189
|
* checks them as it would a real file's: a section name no mounted
|
package/dist/testing.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, S as claimedIdentity, b as readActiveAccessToken, k as noSessionForWorkspaceError, t as buildEngine, x as claimedExpiresAt } from "./engine-DaES-DtJ.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
|
+
import { resolve } from "node:path";
|
|
3
4
|
//#region src/in-memory-credential-manager.ts
|
|
4
5
|
/**
|
|
5
6
|
* A complete CredentialManager whose state lives in memory rather than
|
|
@@ -367,9 +368,13 @@ function createTestCli(spec) {
|
|
|
367
368
|
apiBaseUrl: managementApiBaseUrl,
|
|
368
369
|
authBaseUrl: "https://auth.test.invalid"
|
|
369
370
|
};
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
/** LoadedConfigFile.path is absolute by contract, so the seeded file
|
|
372
|
+
* lands in the run's cwd — where the real loader would discover it. */
|
|
373
|
+
const loadConfigFor = (cwd) => spec.loadConfig ?? (async (configPath) => ({
|
|
374
|
+
files: [{
|
|
375
|
+
path: resolve(cwd, configPath ?? "prisma.config.ts"),
|
|
376
|
+
sections: spec.config ?? {}
|
|
377
|
+
}],
|
|
373
378
|
diagnostics: []
|
|
374
379
|
}));
|
|
375
380
|
const spawnChild = spec.spawn ?? scriptedSpawn(spec.spawnScript ?? (() => ({
|
|
@@ -384,6 +389,7 @@ function createTestCli(spec) {
|
|
|
384
389
|
commandFamilies: spec.commandFamilies ?? [],
|
|
385
390
|
groups: spec.groups ?? {},
|
|
386
391
|
commands: spec.commands,
|
|
392
|
+
help: spec.help,
|
|
387
393
|
telemetry: spec.telemetry
|
|
388
394
|
},
|
|
389
395
|
/** Waiting is instant under test: browserWait's polling is driven
|
|
@@ -438,7 +444,7 @@ function createTestCli(spec) {
|
|
|
438
444
|
signalListeners.delete(cb);
|
|
439
445
|
};
|
|
440
446
|
},
|
|
441
|
-
loadConfig,
|
|
447
|
+
loadConfig: loadConfigFor(opts?.cwd ?? "/"),
|
|
442
448
|
credentialManager,
|
|
443
449
|
managementApiClientConfig,
|
|
444
450
|
spawn: recordingSpawn(spawnChild, spawns),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/cli-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The execution engine of the unified Prisma CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@prisma/management-api-sdk": "1.69.0",
|
|
55
|
-
"@repo/cli-conformance": "8.0.0-rc.
|
|
56
|
-
"@repo/tsconfig": "8.0.0-rc.
|
|
55
|
+
"@repo/cli-conformance": "8.0.0-rc.15-dev.110",
|
|
56
|
+
"@repo/tsconfig": "8.0.0-rc.15-dev.110",
|
|
57
57
|
"@types/node": "^22.19.19",
|
|
58
58
|
"ci-info": "^4.3.1",
|
|
59
59
|
"tsdown": "^0.21.10",
|