@fern-api/generator-cli 0.9.10 → 0.9.13
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/api.d.ts +178 -30
- package/dist/api.js +2106 -423
- package/dist/cli.js +10916 -4636
- package/package.json +4 -2
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ForgetOptions, ForgetResult, BootstrapResult, ResolveResult,
|
|
1
|
+
import { ReplayService, ReplayPreparation, ReplayReport, ForgetOptions, ForgetResult, BootstrapResult, ResolveResult, StatusResult } from '@fern-api/replay';
|
|
2
2
|
export { ConflictDetail, DiffStat, ForgetOptions, ForgetResult, MatchedPatch, ReplayReport, ResolveResult, StatusGeneration, StatusPatch, StatusResult } from '@fern-api/replay';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
|
|
@@ -496,9 +496,69 @@ interface PipelineLogger {
|
|
|
496
496
|
*/
|
|
497
497
|
declare const consolePipelineLogger: PipelineLogger;
|
|
498
498
|
|
|
499
|
+
interface ReplayRunParams {
|
|
500
|
+
outputDir: string;
|
|
501
|
+
cliVersion?: string;
|
|
502
|
+
generatorVersions?: Record<string, string>;
|
|
503
|
+
/** Don't commit, just stage changes. Default: false */
|
|
504
|
+
stageOnly?: boolean;
|
|
505
|
+
/** Generator name for namespaced tag lookup (e.g. "fernapi/fern-typescript-node-sdk") */
|
|
506
|
+
generatorName?: string;
|
|
507
|
+
/** Commit generation + update lockfile, skip patch detection/application */
|
|
508
|
+
skipApplication?: boolean;
|
|
509
|
+
/** Optional logger for diagnostic output */
|
|
510
|
+
logger?: PipelineLogger;
|
|
511
|
+
}
|
|
512
|
+
interface ReplayRunResult {
|
|
513
|
+
/** null if replay wasn't initialized (no lockfile) */
|
|
514
|
+
report: ReplayReport | null;
|
|
515
|
+
/** Whether .fernignore was updated */
|
|
516
|
+
fernignoreUpdated: boolean;
|
|
517
|
+
/** SHA of the [fern-generated] commit before this replay run (null if first generation or unreadable) */
|
|
518
|
+
previousGenerationSha: string | null;
|
|
519
|
+
/** SHA of the [fern-generated] commit created by this replay run (null if replay didn't run or unreadable) */
|
|
520
|
+
currentGenerationSha: string | null;
|
|
521
|
+
/** SHA of main's HEAD before replay ran. Always on main's lineage, stable after squash merges. */
|
|
522
|
+
baseBranchHead: string | null;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Opaque handle returned by `replayPrepare()` and consumed by `replayApply()`.
|
|
526
|
+
*
|
|
527
|
+
* Between prepare and apply, HEAD is at the new `[fern-generated]` commit (or unchanged
|
|
528
|
+
* for dry-run / skip-application terminals). Consumers MAY land additional commits on
|
|
529
|
+
* HEAD (e.g. `[fern-autoversion]`) — apply will run patches on top of current HEAD at
|
|
530
|
+
* call time while rebasing stored patches against the pure `[fern-generated]` tree.
|
|
531
|
+
*
|
|
532
|
+
* If apply is never reached, the working tree has the new `[fern-generated]` commit
|
|
533
|
+
* but the lockfile is stale. Callers MUST either call apply (which advances the
|
|
534
|
+
* lockfile) or reset HEAD to `previousGenerationSha`.
|
|
535
|
+
*/
|
|
536
|
+
interface PreparedReplay {
|
|
537
|
+
/** @internal Service instance carrying in-memory state across phases. */
|
|
538
|
+
_service: ReplayService;
|
|
539
|
+
/** @internal Preparation state handed to the service's apply phase. */
|
|
540
|
+
_preparation: ReplayPreparation;
|
|
541
|
+
/** Working tree / git repo the replay operates on. */
|
|
542
|
+
outputDir: string;
|
|
543
|
+
/** Flow selected by the service during prepare. */
|
|
544
|
+
flow: ReplayPreparation["flow"];
|
|
545
|
+
/** SHA of the `[fern-generated]` commit before this run; null if no prior generation. */
|
|
546
|
+
previousGenerationSha: string | null;
|
|
547
|
+
/** SHA of the new `[fern-generated]` commit created by prepare (or prior HEAD for dry-run terminals). */
|
|
548
|
+
currentGenerationSha: string;
|
|
549
|
+
/** SHA of main's HEAD captured before prepare mutated anything. */
|
|
550
|
+
baseBranchHead: string | null;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Backwards-compatible atomic entry point. Composes `replayPrepare` +
|
|
554
|
+
* `replayApply` with byte-identical behavior for existing callers.
|
|
555
|
+
*/
|
|
556
|
+
declare function replayRun(params: ReplayRunParams): Promise<ReplayRunResult>;
|
|
557
|
+
|
|
499
558
|
interface PipelineConfig {
|
|
500
559
|
outputDir: string;
|
|
501
560
|
replay?: ReplayStepConfig;
|
|
561
|
+
autoVersion?: AutoVersionStepConfig;
|
|
502
562
|
fernignore?: FernignoreStepConfig;
|
|
503
563
|
github?: GithubStepConfig;
|
|
504
564
|
cliVersion?: string;
|
|
@@ -507,15 +567,64 @@ interface PipelineConfig {
|
|
|
507
567
|
}
|
|
508
568
|
interface PipelineContext {
|
|
509
569
|
previousStepResults: {
|
|
570
|
+
generationCommit?: GenerationCommitStepResult;
|
|
510
571
|
replay?: ReplayStepResult;
|
|
572
|
+
autoVersion?: AutoVersionStepResult;
|
|
511
573
|
fernignore?: FernignoreStepResult;
|
|
512
574
|
};
|
|
513
575
|
}
|
|
576
|
+
/**
|
|
577
|
+
* Result of running replayPrepare(). Holds the opaque PreparedReplay handle that
|
|
578
|
+
* downstream steps (AutoVersionStep, ReplayStep) consume.
|
|
579
|
+
*
|
|
580
|
+
* `preparedReplay` is null when replay isn't initialized for this repo (no
|
|
581
|
+
* lockfile) or when prepare failed — the pipeline proceeds without replay in
|
|
582
|
+
* both cases.
|
|
583
|
+
*/
|
|
584
|
+
interface GenerationCommitStepResult extends StepResult {
|
|
585
|
+
/** Opaque handle consumed by ReplayStep's apply phase. Imported at the import site to avoid circular deps. */
|
|
586
|
+
preparedReplay?: PreparedReplay | null;
|
|
587
|
+
previousGenerationSha?: string;
|
|
588
|
+
currentGenerationSha?: string;
|
|
589
|
+
baseBranchHead?: string;
|
|
590
|
+
/** Flow selected by the replay service during prepare. */
|
|
591
|
+
flow?: "first-generation" | "no-patches" | "normal-regeneration" | "skip-application";
|
|
592
|
+
}
|
|
514
593
|
interface ReplayStepConfig {
|
|
515
594
|
enabled: boolean;
|
|
516
595
|
stageOnly?: boolean;
|
|
517
596
|
skipApplication?: boolean;
|
|
518
597
|
}
|
|
598
|
+
interface AutoVersionStepConfig {
|
|
599
|
+
enabled: boolean;
|
|
600
|
+
/** Generator language: typescript | python | java | go | ruby | csharp | php | swift | rust | kotlin */
|
|
601
|
+
language: string;
|
|
602
|
+
/** Existing changelog content passed to the AI for context. */
|
|
603
|
+
priorChangelog?: string;
|
|
604
|
+
/** Fallback version when no prior generation exists (first run). Defaults to "0.0.1" (or "v0.0.1" for Go). */
|
|
605
|
+
baseVersion?: string;
|
|
606
|
+
/**
|
|
607
|
+
* BAML AI service configuration (provider + model). Required when `enabled: true` — without it,
|
|
608
|
+
* AnalyzeSdkDiff calls will fail and the step will fall back to a PATCH bump.
|
|
609
|
+
* Shape matches `generatorsYml.AiServicesSchema` from @fern-api/configuration; typed structurally
|
|
610
|
+
* to avoid pulling the configuration package into generator-cli's dep graph.
|
|
611
|
+
*/
|
|
612
|
+
ai?: AutoVersionAiConfig;
|
|
613
|
+
/** Optional Fern API token passed through to BAML client configuration if needed by the provider. */
|
|
614
|
+
fernToken?: string;
|
|
615
|
+
/** Spec repository commit message included as additional AI context. */
|
|
616
|
+
specCommitMessage?: string;
|
|
617
|
+
/** When true, strips "🌿 Generated with Fern" trailers from commit messages (whitelabel customers). */
|
|
618
|
+
isWhitelabel?: boolean;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Minimal shape for the BAML AI service configuration. Structural equivalent of
|
|
622
|
+
* `generatorsYml.AiServicesSchema` from @fern-api/configuration.
|
|
623
|
+
*/
|
|
624
|
+
interface AutoVersionAiConfig {
|
|
625
|
+
provider: string;
|
|
626
|
+
model: string;
|
|
627
|
+
}
|
|
519
628
|
interface FernignoreStepConfig {
|
|
520
629
|
enabled: boolean;
|
|
521
630
|
customContents?: string;
|
|
@@ -555,8 +664,10 @@ interface GithubStepConfig {
|
|
|
555
664
|
previousGenerationSha: string;
|
|
556
665
|
currentGenerationSha: string;
|
|
557
666
|
};
|
|
558
|
-
/** When true: separate PRs per generation,
|
|
667
|
+
/** When true: separate PRs per generation, automerge support, run_id in body */
|
|
559
668
|
automationMode?: boolean;
|
|
669
|
+
/** When true: skip opening a PR / pushing when the generated output has no diff from the base branch. */
|
|
670
|
+
skipIfNoDiff?: boolean;
|
|
560
671
|
/** Enable GitHub automerge on the PR (only effective when automationMode && !hasBreakingChanges) */
|
|
561
672
|
autoMerge?: boolean;
|
|
562
673
|
/** Pre-computed: version bump is MAJOR (from --version AUTO AI analysis) */
|
|
@@ -569,7 +680,9 @@ interface GithubStepConfig {
|
|
|
569
680
|
interface PipelineResult {
|
|
570
681
|
success: boolean;
|
|
571
682
|
steps: {
|
|
683
|
+
generationCommit?: GenerationCommitStepResult;
|
|
572
684
|
replay?: ReplayStepResult;
|
|
685
|
+
autoVersion?: AutoVersionStepResult;
|
|
573
686
|
fernignore?: FernignoreStepResult;
|
|
574
687
|
github?: GithubStepResult;
|
|
575
688
|
};
|
|
@@ -602,6 +715,24 @@ interface ReplayStepResult extends StepResult {
|
|
|
602
715
|
interface FernignoreStepResult extends StepResult {
|
|
603
716
|
pathsPreserved?: string[];
|
|
604
717
|
}
|
|
718
|
+
interface AutoVersionStepResult extends StepResult {
|
|
719
|
+
/** The new version to use (e.g. "1.2.3"). Field name matches fiddle's Java AutoVersionResult DTO. */
|
|
720
|
+
version?: string;
|
|
721
|
+
/** Commit subject for the `[fern-autoversion]` commit. */
|
|
722
|
+
commitMessage?: string;
|
|
723
|
+
/** User-facing changelog entry appended to changelog.md. */
|
|
724
|
+
changelogEntry?: string;
|
|
725
|
+
/** Prior SDK version before this change (e.g. "1.2.2"). */
|
|
726
|
+
previousVersion?: string;
|
|
727
|
+
/** The version bump level determined by FAI. */
|
|
728
|
+
versionBump?: "MAJOR" | "MINOR" | "PATCH" | "NO_CHANGE";
|
|
729
|
+
/** Structured PR description with Before/After code fences for breaking changes. */
|
|
730
|
+
prDescription?: string;
|
|
731
|
+
/** One-sentence justification for WHY the version bump was chosen. */
|
|
732
|
+
versionBumpReason?: string;
|
|
733
|
+
/** SHA of the `[fern-autoversion]` commit once it's been made. TS-only; no fiddle counterpart. */
|
|
734
|
+
commitSha?: string;
|
|
735
|
+
}
|
|
605
736
|
interface GithubStepResult extends StepResult {
|
|
606
737
|
commitSha?: string;
|
|
607
738
|
branchUrl?: string;
|
|
@@ -700,37 +831,54 @@ interface ReplayResolveParams {
|
|
|
700
831
|
}
|
|
701
832
|
declare function replayResolve(params: ReplayResolveParams): Promise<ResolveResult>;
|
|
702
833
|
|
|
703
|
-
interface ReplayRunParams {
|
|
704
|
-
outputDir: string;
|
|
705
|
-
cliVersion?: string;
|
|
706
|
-
generatorVersions?: Record<string, string>;
|
|
707
|
-
/** Don't commit, just stage changes. Default: false */
|
|
708
|
-
stageOnly?: boolean;
|
|
709
|
-
/** Generator name for namespaced tag lookup (e.g. "fernapi/fern-typescript-node-sdk") */
|
|
710
|
-
generatorName?: string;
|
|
711
|
-
/** Commit generation + update lockfile, skip patch detection/application */
|
|
712
|
-
skipApplication?: boolean;
|
|
713
|
-
/** Optional logger for diagnostic output */
|
|
714
|
-
logger?: PipelineLogger;
|
|
715
|
-
}
|
|
716
|
-
interface ReplayRunResult {
|
|
717
|
-
/** null if replay wasn't initialized (no lockfile) */
|
|
718
|
-
report: ReplayReport | null;
|
|
719
|
-
/** Whether .fernignore was updated */
|
|
720
|
-
fernignoreUpdated: boolean;
|
|
721
|
-
/** SHA of the [fern-generated] commit before this replay run (null if first generation or unreadable) */
|
|
722
|
-
previousGenerationSha: string | null;
|
|
723
|
-
/** SHA of the [fern-generated] commit created by this replay run (null if replay didn't run or unreadable) */
|
|
724
|
-
currentGenerationSha: string | null;
|
|
725
|
-
/** SHA of main's HEAD before replay ran. Always on main's lineage, stable after squash merges. */
|
|
726
|
-
baseBranchHead: string | null;
|
|
727
|
-
}
|
|
728
|
-
declare function replayRun(params: ReplayRunParams): Promise<ReplayRunResult>;
|
|
729
|
-
|
|
730
834
|
interface ReplayStatusParams {
|
|
731
835
|
/** Directory containing the SDK (where .fern/replay.lock lives) */
|
|
732
836
|
outputDir: string;
|
|
733
837
|
}
|
|
734
838
|
declare function replayStatus(params: ReplayStatusParams): StatusResult;
|
|
735
839
|
|
|
736
|
-
|
|
840
|
+
interface SubmitReplayInitParams {
|
|
841
|
+
/** Fiddle API origin (e.g. "https://fiddle.buildwithfern.com") */
|
|
842
|
+
fiddleOrigin: string;
|
|
843
|
+
/** Fern auth token */
|
|
844
|
+
fernToken: string;
|
|
845
|
+
/** GitHub repository (e.g. "owner/repo" or full URL) */
|
|
846
|
+
githubRepo: string;
|
|
847
|
+
/** Result from replayInit() */
|
|
848
|
+
initResult: ReplayInitResult;
|
|
849
|
+
}
|
|
850
|
+
interface SubmitReplayInitResult {
|
|
851
|
+
/** URL of the PR created by Fiddle */
|
|
852
|
+
prUrl: string;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Submits a Replay init lockfile to the Fiddle API for server-side PR creation.
|
|
856
|
+
*
|
|
857
|
+
* Extracts owner/repo from the GitHub repository string, posts the lockfile
|
|
858
|
+
* and related metadata to the Fiddle remote-gen endpoint, and returns the
|
|
859
|
+
* resulting PR URL.
|
|
860
|
+
*
|
|
861
|
+
* This function is shared between CLI v1 and CLI v2 to avoid duplicating
|
|
862
|
+
* the Fiddle submission logic.
|
|
863
|
+
*/
|
|
864
|
+
declare function submitReplayInit(params: SubmitReplayInitParams): Promise<SubmitReplayInitResult>;
|
|
865
|
+
/**
|
|
866
|
+
* Parses a GitHub repository string into owner and repo components.
|
|
867
|
+
* Accepts formats: "owner/repo", "github.com/owner/repo",
|
|
868
|
+
* "https://github.com/owner/repo", "https://github.com/owner/repo.git"
|
|
869
|
+
*/
|
|
870
|
+
declare function parseOwnerRepo(githubRepo: string): {
|
|
871
|
+
owner: string;
|
|
872
|
+
repo: string;
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* Error thrown when submitting a Replay init to Fiddle fails.
|
|
876
|
+
* Consumers can inspect `statusCode` to distinguish between
|
|
877
|
+
* different failure modes (e.g. 404 = GitHub App not installed).
|
|
878
|
+
*/
|
|
879
|
+
declare class ReplaySubmitError extends Error {
|
|
880
|
+
readonly statusCode: number | undefined;
|
|
881
|
+
constructor(message: string, statusCode?: number);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
export { type BootstrapLogEntry, type GenerateReadmeParams, type GenerateReadmeToStreamParams, type GenerateReferenceParams, type GenerateReferenceToStreamParams, type GithubPrParams, type GithubPushParams, type GithubReleaseParams, type GithubStepConfig, type GithubStepResult, type PipelineConfig, type PipelineContext, type PipelineLogger, type PipelineResult, PostGenerationPipeline, type ReplayForgetParams, type ReplayInitParams, type ReplayInitResult, type ReplayResolveParams, type ReplayRunParams, type ReplayRunResult, type ReplayStatusParams, type ReplayStepResult, ReplaySubmitError, type SubmitReplayInitParams, type SubmitReplayInitResult, consolePipelineLogger, formatBootstrapSummary, formatReplayPrBody, generateReadme, generateReadmeToStream, generateReference, generateReferenceToStream, githubPr, githubPush, githubRelease, logReplaySummary, parseOwnerRepo, replayForget, replayInit, replayResolve, replayRun, replayStatus, submitReplayInit };
|