@fern-api/replay 0.19.1 → 0.19.2
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/cli.cjs +37 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +37 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3300,7 +3300,9 @@ var NoPatchesFlow = class {
|
|
|
3300
3300
|
}
|
|
3301
3301
|
async prepare(options) {
|
|
3302
3302
|
const preLock = this.service.lockManager.read();
|
|
3303
|
-
const previousGenerationSha =
|
|
3303
|
+
const previousGenerationSha = await this.service.resolveReachablePreviousGeneration(
|
|
3304
|
+
preLock.current_generation ?? null
|
|
3305
|
+
);
|
|
3304
3306
|
let { patches: newPatches, revertedPatchIds } = await this.service.detector.detectNewPatches();
|
|
3305
3307
|
const detectorWarnings = [...this.service.detector.warnings];
|
|
3306
3308
|
const detectorDegraded = [...this.service.detector.degradedReasons];
|
|
@@ -3438,7 +3440,9 @@ var NormalRegenerationFlow = class {
|
|
|
3438
3440
|
}
|
|
3439
3441
|
async prepare(options) {
|
|
3440
3442
|
const preLock = this.service.lockManager.read();
|
|
3441
|
-
const previousGenerationSha =
|
|
3443
|
+
const previousGenerationSha = await this.service.resolveReachablePreviousGeneration(
|
|
3444
|
+
preLock.current_generation ?? null
|
|
3445
|
+
);
|
|
3442
3446
|
if (options?.dryRun) {
|
|
3443
3447
|
const existingPatches2 = this.service.lockManager.getPatches();
|
|
3444
3448
|
const { patches: newPatches2, revertedPatchIds: dryRunReverted } = await this.service.detector.detectNewPatches();
|
|
@@ -3676,6 +3680,37 @@ var ReplayService = class {
|
|
|
3676
3680
|
this.committer = new ReplayCommitter(git, outputDir);
|
|
3677
3681
|
this.fileOwnership = new FileOwnership(git);
|
|
3678
3682
|
}
|
|
3683
|
+
/**
|
|
3684
|
+
* Resolve the previous-generation SHA to export on
|
|
3685
|
+
* `ReplayPreparation.previousGenerationSha`.
|
|
3686
|
+
*
|
|
3687
|
+
* `current_generation` is the SHA of a LOCALLY-created `[fern-generated]` commit.
|
|
3688
|
+
* generator-cli's signed-commit push (`pushSignedCommit`) recreates that commit under a
|
|
3689
|
+
* new remote SHA, and a squash-merge collapses it away, so the recorded value can be
|
|
3690
|
+
* unreachable in a later clone (org "Natural": autoVersion then diffed against a phantom
|
|
3691
|
+
* baseline and silently reported NO_CHANGE — or, pre-a38bbc6, shipped
|
|
3692
|
+
* `0.0.0-fern-placeholder`). Consumers (generator-cli's autoVersion) diff against this
|
|
3693
|
+
* baseline, so it MUST resolve to a real commit.
|
|
3694
|
+
*
|
|
3695
|
+
* Prefer the recorded SHA while it still resolves — the healthy case, and the pristine
|
|
3696
|
+
* prior `[fern-generated]` tree. Otherwise re-anchor on the most recent reachable
|
|
3697
|
+
* generation boundary in first-parent history: the SAME value the detector already
|
|
3698
|
+
* derives for its own scan boundary (`findPreviousGenerationFromHistory`, whose
|
|
3699
|
+
* `isGenerationBoundary` matches squash-merge subjects like `SDK Generation (#N)`). Fall
|
|
3700
|
+
* back to the recorded SHA only when no boundary is reachable at all — no worse than the
|
|
3701
|
+
* prior behavior. ADR 0002 (generator-cli) allows replay to expose this reconciled value;
|
|
3702
|
+
* the consumer stays independently resilient.
|
|
3703
|
+
*
|
|
3704
|
+
* MUST be called before the new `[fern-generated]` commit is created, while HEAD is still
|
|
3705
|
+
* the pre-generation (customer) state, so the walk anchors on the PREVIOUS generation.
|
|
3706
|
+
*/
|
|
3707
|
+
async resolveReachablePreviousGeneration(recordedSha) {
|
|
3708
|
+
if (recordedSha != null && await this.git.commitExists(recordedSha)) {
|
|
3709
|
+
return recordedSha;
|
|
3710
|
+
}
|
|
3711
|
+
const derived = await this.detector.findPreviousGenerationFromHistory();
|
|
3712
|
+
return derived ?? recordedSha;
|
|
3713
|
+
}
|
|
3679
3714
|
/**
|
|
3680
3715
|
* Phase 1 of the two-phase replay flow. Runs preGenerationRebase (when applicable),
|
|
3681
3716
|
* detects new patches, and creates the `[fern-generated]` commit. Leaves HEAD at
|