@fern-api/generator-cli 0.9.9 → 0.9.10
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.js +55 -18
- package/dist/cli.js +55 -18
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -10377,13 +10377,17 @@ var GithubStep = class extends BaseStep {
|
|
|
10377
10377
|
});
|
|
10378
10378
|
switch (branchAction) {
|
|
10379
10379
|
case "replay-branch":
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10380
|
+
if (shouldPushGenerationBaseTag(replayResult)) {
|
|
10381
|
+
generationBaseSha = await createReplayBranch(
|
|
10382
|
+
repository,
|
|
10383
|
+
prBranch,
|
|
10384
|
+
this.config.commitMessage,
|
|
10385
|
+
replayConflictInfo,
|
|
10386
|
+
this.logger
|
|
10387
|
+
);
|
|
10388
|
+
} else {
|
|
10389
|
+
await repository.createBranchFromHead(prBranch);
|
|
10390
|
+
}
|
|
10387
10391
|
break;
|
|
10388
10392
|
case "create-from-head":
|
|
10389
10393
|
await repository.createBranchFromHead(prBranch);
|
|
@@ -10592,6 +10596,9 @@ _Fern Run ID: \`${config.runId}\`_`;
|
|
|
10592
10596
|
function shouldEnableAutomerge(config) {
|
|
10593
10597
|
return config.automationMode === true && config.autoMerge === true && config.hasBreakingChanges !== true;
|
|
10594
10598
|
}
|
|
10599
|
+
function shouldPushGenerationBaseTag(replayResult) {
|
|
10600
|
+
return (replayResult?.patchesWithConflicts ?? 0) > 0;
|
|
10601
|
+
}
|
|
10595
10602
|
function resolveBranchAction({
|
|
10596
10603
|
automationMode,
|
|
10597
10604
|
skipCommit,
|
|
@@ -10730,18 +10737,24 @@ async function replayRun(params) {
|
|
|
10730
10737
|
}
|
|
10731
10738
|
}
|
|
10732
10739
|
if (shouldSync && tagSha != null) {
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
|
|
10740
|
+
if (!isTagMergedIntoHead(outputDir, tagSha)) {
|
|
10741
|
+
logger?.warn(
|
|
10742
|
+
`fern-generation-base tag ${tagSha} is not reachable from HEAD \u2014 skipping divergent-merge sync. The tag likely points at an unmerged generation (PR closed without merge).`
|
|
10743
|
+
);
|
|
10744
|
+
} else {
|
|
10745
|
+
const syncService = new import_replay.ReplayService(outputDir, { enabled: true });
|
|
10746
|
+
await syncService.syncFromDivergentMerge(tagSha, {
|
|
10747
|
+
cliVersion,
|
|
10748
|
+
generatorVersions,
|
|
10749
|
+
baseBranchHead: baseBranchHead ?? void 0
|
|
10750
|
+
});
|
|
10751
|
+
try {
|
|
10752
|
+
const freshLockManager = new import_replay.LockfileManager(outputDir);
|
|
10753
|
+
if (freshLockManager.exists()) {
|
|
10754
|
+
previousGenerationSha = freshLockManager.read().current_generation;
|
|
10755
|
+
}
|
|
10756
|
+
} catch {
|
|
10743
10757
|
}
|
|
10744
|
-
} catch {
|
|
10745
10758
|
}
|
|
10746
10759
|
}
|
|
10747
10760
|
}
|
|
@@ -10791,6 +10804,30 @@ async function replayRun(params) {
|
|
|
10791
10804
|
baseBranchHead: resolvedBaseBranchHead
|
|
10792
10805
|
};
|
|
10793
10806
|
}
|
|
10807
|
+
function isTagMergedIntoHead(cwd2, tagSha) {
|
|
10808
|
+
try {
|
|
10809
|
+
(0, import_child_process3.execFileSync)("git", ["merge-base", "--is-ancestor", tagSha, "HEAD"], {
|
|
10810
|
+
cwd: cwd2,
|
|
10811
|
+
stdio: "pipe"
|
|
10812
|
+
});
|
|
10813
|
+
return true;
|
|
10814
|
+
} catch {
|
|
10815
|
+
}
|
|
10816
|
+
const tagTree = gitRevParse(cwd2, `${tagSha}^{tree}`);
|
|
10817
|
+
if (tagTree == null) {
|
|
10818
|
+
return false;
|
|
10819
|
+
}
|
|
10820
|
+
try {
|
|
10821
|
+
const trees = (0, import_child_process3.execFileSync)("git", ["log", "HEAD", "--format=%T", "--max-count=500"], {
|
|
10822
|
+
cwd: cwd2,
|
|
10823
|
+
encoding: "utf-8",
|
|
10824
|
+
stdio: "pipe"
|
|
10825
|
+
});
|
|
10826
|
+
return trees.split("\n").some((t2) => t2.trim() === tagTree);
|
|
10827
|
+
} catch {
|
|
10828
|
+
return false;
|
|
10829
|
+
}
|
|
10830
|
+
}
|
|
10794
10831
|
function gitRevParse(cwd2, rev) {
|
|
10795
10832
|
try {
|
|
10796
10833
|
return (0, import_child_process3.execFileSync)("git", ["rev-parse", "--verify", rev], {
|
package/dist/cli.js
CHANGED
|
@@ -33772,13 +33772,17 @@ var GithubStep = class extends BaseStep {
|
|
|
33772
33772
|
});
|
|
33773
33773
|
switch (branchAction) {
|
|
33774
33774
|
case "replay-branch":
|
|
33775
|
-
|
|
33776
|
-
|
|
33777
|
-
|
|
33778
|
-
|
|
33779
|
-
|
|
33780
|
-
|
|
33781
|
-
|
|
33775
|
+
if (shouldPushGenerationBaseTag(replayResult)) {
|
|
33776
|
+
generationBaseSha = await createReplayBranch(
|
|
33777
|
+
repository,
|
|
33778
|
+
prBranch,
|
|
33779
|
+
this.config.commitMessage,
|
|
33780
|
+
replayConflictInfo,
|
|
33781
|
+
this.logger
|
|
33782
|
+
);
|
|
33783
|
+
} else {
|
|
33784
|
+
await repository.createBranchFromHead(prBranch);
|
|
33785
|
+
}
|
|
33782
33786
|
break;
|
|
33783
33787
|
case "create-from-head":
|
|
33784
33788
|
await repository.createBranchFromHead(prBranch);
|
|
@@ -33987,6 +33991,9 @@ _Fern Run ID: \`${config.runId}\`_`;
|
|
|
33987
33991
|
function shouldEnableAutomerge(config) {
|
|
33988
33992
|
return config.automationMode === true && config.autoMerge === true && config.hasBreakingChanges !== true;
|
|
33989
33993
|
}
|
|
33994
|
+
function shouldPushGenerationBaseTag(replayResult) {
|
|
33995
|
+
return (replayResult?.patchesWithConflicts ?? 0) > 0;
|
|
33996
|
+
}
|
|
33990
33997
|
function resolveBranchAction({
|
|
33991
33998
|
automationMode,
|
|
33992
33999
|
skipCommit,
|
|
@@ -34125,18 +34132,24 @@ async function replayRun(params) {
|
|
|
34125
34132
|
}
|
|
34126
34133
|
}
|
|
34127
34134
|
if (shouldSync && tagSha != null) {
|
|
34128
|
-
|
|
34129
|
-
|
|
34130
|
-
|
|
34131
|
-
|
|
34132
|
-
|
|
34133
|
-
|
|
34134
|
-
|
|
34135
|
-
|
|
34136
|
-
|
|
34137
|
-
|
|
34135
|
+
if (!isTagMergedIntoHead(outputDir, tagSha)) {
|
|
34136
|
+
logger?.warn(
|
|
34137
|
+
`fern-generation-base tag ${tagSha} is not reachable from HEAD \u2014 skipping divergent-merge sync. The tag likely points at an unmerged generation (PR closed without merge).`
|
|
34138
|
+
);
|
|
34139
|
+
} else {
|
|
34140
|
+
const syncService = new ReplayService(outputDir, { enabled: true });
|
|
34141
|
+
await syncService.syncFromDivergentMerge(tagSha, {
|
|
34142
|
+
cliVersion,
|
|
34143
|
+
generatorVersions,
|
|
34144
|
+
baseBranchHead: baseBranchHead ?? void 0
|
|
34145
|
+
});
|
|
34146
|
+
try {
|
|
34147
|
+
const freshLockManager = new LockfileManager(outputDir);
|
|
34148
|
+
if (freshLockManager.exists()) {
|
|
34149
|
+
previousGenerationSha = freshLockManager.read().current_generation;
|
|
34150
|
+
}
|
|
34151
|
+
} catch {
|
|
34138
34152
|
}
|
|
34139
|
-
} catch {
|
|
34140
34153
|
}
|
|
34141
34154
|
}
|
|
34142
34155
|
}
|
|
@@ -34186,6 +34199,30 @@ async function replayRun(params) {
|
|
|
34186
34199
|
baseBranchHead: resolvedBaseBranchHead
|
|
34187
34200
|
};
|
|
34188
34201
|
}
|
|
34202
|
+
function isTagMergedIntoHead(cwd2, tagSha) {
|
|
34203
|
+
try {
|
|
34204
|
+
(0, import_child_process3.execFileSync)("git", ["merge-base", "--is-ancestor", tagSha, "HEAD"], {
|
|
34205
|
+
cwd: cwd2,
|
|
34206
|
+
stdio: "pipe"
|
|
34207
|
+
});
|
|
34208
|
+
return true;
|
|
34209
|
+
} catch {
|
|
34210
|
+
}
|
|
34211
|
+
const tagTree = gitRevParse(cwd2, `${tagSha}^{tree}`);
|
|
34212
|
+
if (tagTree == null) {
|
|
34213
|
+
return false;
|
|
34214
|
+
}
|
|
34215
|
+
try {
|
|
34216
|
+
const trees = (0, import_child_process3.execFileSync)("git", ["log", "HEAD", "--format=%T", "--max-count=500"], {
|
|
34217
|
+
cwd: cwd2,
|
|
34218
|
+
encoding: "utf-8",
|
|
34219
|
+
stdio: "pipe"
|
|
34220
|
+
});
|
|
34221
|
+
return trees.split("\n").some((t2) => t2.trim() === tagTree);
|
|
34222
|
+
} catch {
|
|
34223
|
+
return false;
|
|
34224
|
+
}
|
|
34225
|
+
}
|
|
34189
34226
|
function gitRevParse(cwd2, rev) {
|
|
34190
34227
|
try {
|
|
34191
34228
|
return (0, import_child_process3.execFileSync)("git", ["rev-parse", "--verify", rev], {
|