@fern-api/generator-cli 0.6.14 → 0.8.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/dist/api.d.ts +13 -16
- package/dist/api.js +12 -52
- package/dist/cli.js +738 -506
- package/package.json +3 -3
package/dist/api.d.ts
CHANGED
|
@@ -617,16 +617,12 @@ declare function formatReplayPrBody(result: ReplayStepResult | undefined, option
|
|
|
617
617
|
interface ReplayInitParams {
|
|
618
618
|
/** GitHub repo URI (e.g., "fern-demo/fern-replay-testbed-java-sdk") */
|
|
619
619
|
githubRepo: string;
|
|
620
|
-
/** GitHub token
|
|
620
|
+
/** GitHub token for clone (read access) */
|
|
621
621
|
token: string;
|
|
622
622
|
/** Report what would happen but don't create PR */
|
|
623
623
|
dryRun?: boolean;
|
|
624
624
|
/** Max commits to scan for generation history */
|
|
625
625
|
maxCommitsToScan?: number;
|
|
626
|
-
/** Title for the PR */
|
|
627
|
-
prTitle?: string;
|
|
628
|
-
/** Body for the PR */
|
|
629
|
-
prBody?: string;
|
|
630
626
|
/** Overwrite existing lockfile if present. Default: false */
|
|
631
627
|
force?: boolean;
|
|
632
628
|
/** Scan git history for existing patches (migration). Default: false */
|
|
@@ -635,25 +631,26 @@ interface ReplayInitParams {
|
|
|
635
631
|
interface ReplayInitResult {
|
|
636
632
|
/** Bootstrap result from fern-replay */
|
|
637
633
|
bootstrap: BootstrapResult;
|
|
638
|
-
/**
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
|
|
634
|
+
/** Raw lockfile YAML content, present when bootstrap succeeded and not dry-run */
|
|
635
|
+
lockfileContent?: string;
|
|
636
|
+
/** Raw replay.yml content, present only when fernignore migration created it */
|
|
637
|
+
replayYmlContent?: string;
|
|
638
|
+
/** Fernignore entries that the server should ensure exist */
|
|
639
|
+
fernignoreEntries: string[];
|
|
640
|
+
/** Generated PR body markdown for the server to use */
|
|
641
|
+
prBody?: string;
|
|
642
642
|
}
|
|
643
643
|
/**
|
|
644
644
|
* Initialize Replay for an SDK repository.
|
|
645
645
|
*
|
|
646
|
-
*
|
|
646
|
+
* Runs bootstrap locally (read-only) and returns the lockfile content
|
|
647
|
+
* for the caller to send to Fiddle for server-side PR creation.
|
|
647
648
|
*
|
|
648
649
|
* Flow:
|
|
649
|
-
* 1. Clone the SDK repo
|
|
650
|
+
* 1. Clone the SDK repo (read-only)
|
|
650
651
|
* 2. Run bootstrap() to scan history and create lockfile
|
|
651
652
|
* 3. Ensure .fernignore has replay entries
|
|
652
|
-
* 4.
|
|
653
|
-
* 5. Push branch and open PR
|
|
654
|
-
*
|
|
655
|
-
* The [fern-replay] commit message prefix ensures the bootstrap commit
|
|
656
|
-
* is NOT treated as a user customization patch by ReplayDetector.
|
|
653
|
+
* 4. Read lockfile content from disk and return it
|
|
657
654
|
*/
|
|
658
655
|
declare function replayInit(params: ReplayInitParams): Promise<ReplayInitResult>;
|
|
659
656
|
interface BootstrapLogEntry {
|
package/dist/api.js
CHANGED
|
@@ -10189,7 +10189,7 @@ var import_path5 = require("path");
|
|
|
10189
10189
|
var import_fs2 = require("fs");
|
|
10190
10190
|
var import_promises3 = require("fs/promises");
|
|
10191
10191
|
var import_path4 = require("path");
|
|
10192
|
-
var REPLAY_FERNIGNORE_ENTRIES = [".fern/replay.lock"
|
|
10192
|
+
var REPLAY_FERNIGNORE_ENTRIES = [".fern/replay.lock"];
|
|
10193
10193
|
async function ensureReplayFernignoreEntries(outputDir) {
|
|
10194
10194
|
const fernignorePath = (0, import_path4.join)(outputDir, ".fernignore");
|
|
10195
10195
|
let content = "";
|
|
@@ -10490,7 +10490,6 @@ var PostGenerationPipeline = class {
|
|
|
10490
10490
|
|
|
10491
10491
|
// src/replay/replay-init.ts
|
|
10492
10492
|
var import_replay2 = require("@fern-api/replay");
|
|
10493
|
-
var import_rest3 = require("@octokit/rest");
|
|
10494
10493
|
var import_fs4 = require("fs");
|
|
10495
10494
|
var import_path6 = require("path");
|
|
10496
10495
|
var import_tmp_promise2 = __toESM(require("tmp-promise"));
|
|
@@ -10498,12 +10497,11 @@ async function replayInit(params) {
|
|
|
10498
10497
|
const { githubRepo, token, dryRun } = params;
|
|
10499
10498
|
const tmpDir = await import_tmp_promise2.default.dir({ unsafeCleanup: true });
|
|
10500
10499
|
const repoPath = tmpDir.path;
|
|
10501
|
-
|
|
10500
|
+
await cloneRepository({
|
|
10502
10501
|
githubRepository: githubRepo,
|
|
10503
10502
|
installationToken: token,
|
|
10504
10503
|
targetDirectory: repoPath
|
|
10505
10504
|
});
|
|
10506
|
-
const defaultBranch = await repository.getDefaultBranch();
|
|
10507
10505
|
const bootstrapResult = await (0, import_replay2.bootstrap)(repoPath, {
|
|
10508
10506
|
dryRun,
|
|
10509
10507
|
fernignoreAction: "skip",
|
|
@@ -10512,52 +10510,22 @@ async function replayInit(params) {
|
|
|
10512
10510
|
importHistory: params.importHistory
|
|
10513
10511
|
});
|
|
10514
10512
|
if (!bootstrapResult.generationCommit) {
|
|
10515
|
-
return { bootstrap: bootstrapResult };
|
|
10513
|
+
return { bootstrap: bootstrapResult, fernignoreEntries: [] };
|
|
10516
10514
|
}
|
|
10517
10515
|
if (dryRun) {
|
|
10518
|
-
return { bootstrap: bootstrapResult };
|
|
10516
|
+
return { bootstrap: bootstrapResult, fernignoreEntries: [] };
|
|
10519
10517
|
}
|
|
10520
10518
|
ensureReplayFernignoreEntriesSync(repoPath);
|
|
10521
|
-
const
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
const filesToAdd = [".fern/replay.lock", ".fern/replay.yml", ".fernignore"].filter(
|
|
10526
|
-
(f) => (0, import_fs4.existsSync)((0, import_path6.join)(repoPath, f))
|
|
10527
|
-
);
|
|
10528
|
-
const branchName = `fern-replay/init-${Date.now()}`;
|
|
10529
|
-
await repository.checkoutOrCreateLocal(branchName);
|
|
10530
|
-
const git = new import_replay2.GitClient(repoPath);
|
|
10531
|
-
await git.exec(["add", ...filesToAdd]);
|
|
10532
|
-
await git.exec([
|
|
10533
|
-
"-c",
|
|
10534
|
-
`user.name=${import_replay2.FERN_BOT_NAME}`,
|
|
10535
|
-
"-c",
|
|
10536
|
-
`user.email=${import_replay2.FERN_BOT_EMAIL}`,
|
|
10537
|
-
"-c",
|
|
10538
|
-
"commit.gpgsign=false",
|
|
10539
|
-
"commit",
|
|
10540
|
-
"--no-verify",
|
|
10541
|
-
"-m",
|
|
10542
|
-
commitMessage
|
|
10543
|
-
]);
|
|
10544
|
-
await repository.pushUpstream(branchName);
|
|
10545
|
-
const parsed = parseRepository(githubRepo);
|
|
10546
|
-
const octokit = new import_rest3.Octokit({ auth: token });
|
|
10547
|
-
const prTitle = params.prTitle ?? "[fern-replay] Initialize Replay for SDK customizations";
|
|
10548
|
-
const prBody = params.prBody ?? buildPrBody(bootstrapResult);
|
|
10549
|
-
const { data: pr } = await octokit.pulls.create({
|
|
10550
|
-
owner: parsed.owner,
|
|
10551
|
-
repo: parsed.repo,
|
|
10552
|
-
head: branchName,
|
|
10553
|
-
base: defaultBranch,
|
|
10554
|
-
title: prTitle,
|
|
10555
|
-
body: prBody
|
|
10556
|
-
});
|
|
10519
|
+
const lockfilePath = (0, import_path6.join)(repoPath, ".fern", "replay.lock");
|
|
10520
|
+
const lockfileContent = (0, import_fs4.existsSync)(lockfilePath) ? (0, import_fs4.readFileSync)(lockfilePath, "utf-8") : void 0;
|
|
10521
|
+
const replayYmlPath = (0, import_path6.join)(repoPath, ".fern", "replay.yml");
|
|
10522
|
+
const replayYmlContent = (0, import_fs4.existsSync)(replayYmlPath) ? (0, import_fs4.readFileSync)(replayYmlPath, "utf-8") : void 0;
|
|
10557
10523
|
return {
|
|
10558
10524
|
bootstrap: bootstrapResult,
|
|
10559
|
-
|
|
10560
|
-
|
|
10525
|
+
lockfileContent,
|
|
10526
|
+
replayYmlContent,
|
|
10527
|
+
fernignoreEntries: REPLAY_FERNIGNORE_ENTRIES,
|
|
10528
|
+
prBody: buildPrBody(bootstrapResult)
|
|
10561
10529
|
};
|
|
10562
10530
|
}
|
|
10563
10531
|
function formatBootstrapSummary(result) {
|
|
@@ -10616,14 +10584,6 @@ function formatBootstrapSummary(result) {
|
|
|
10616
10584
|
entries2.push({ level: "warn", message: ` ${w}` });
|
|
10617
10585
|
}
|
|
10618
10586
|
}
|
|
10619
|
-
if (result.prUrl) {
|
|
10620
|
-
entries2.push({ level: "info", message: `
|
|
10621
|
-
PR created: ${result.prUrl}` });
|
|
10622
|
-
entries2.push({ level: "info", message: "Merge the PR to enable Replay for this repository." });
|
|
10623
|
-
} else if (result.branch) {
|
|
10624
|
-
entries2.push({ level: "info", message: `
|
|
10625
|
-
Pushed to branch: ${result.branch}` });
|
|
10626
|
-
}
|
|
10627
10587
|
return entries2;
|
|
10628
10588
|
}
|
|
10629
10589
|
function buildPrBody(result) {
|