@fern-api/generator-cli 0.9.50 → 0.9.52
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.js +66 -43
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -22214,7 +22214,7 @@ var init_diff3 = __esm({
|
|
|
22214
22214
|
}
|
|
22215
22215
|
});
|
|
22216
22216
|
|
|
22217
|
-
// ../../node_modules/.pnpm/@fern-api+replay@0.19.
|
|
22217
|
+
// ../../node_modules/.pnpm/@fern-api+replay@0.19.2/node_modules/@fern-api/replay/dist/index.js
|
|
22218
22218
|
var dist_exports = {};
|
|
22219
22219
|
__export(dist_exports, {
|
|
22220
22220
|
CREDENTIAL_PATTERNS: () => CREDENTIAL_PATTERNS,
|
|
@@ -24295,7 +24295,7 @@ function status(outputDir) {
|
|
|
24295
24295
|
}
|
|
24296
24296
|
var import_promises4, import_os, import_path7, import_fs6, import_path8, import_yaml, import_crypto, import_path9, import_promises5, import_os2, import_path10, import_promises6, import_path11, import_promises7, import_path12, import_fs7, import_promises8, import_path13, import_fs8, import_path14, import_promises9, import_os3, import_path15, import_child_process3, import_crypto2, import_fs9, import_path16, import_yaml2, import_crypto3, import_fs10, import_path17, import_fs11, import_promises10, import_path18, __defProp3, __getOwnPropNames3, __esm3, __export3, GitClient_exports, GitClient, init_GitClient, HybridReconstruction_exports, init_HybridReconstruction, PatchApplyTheirs_exports, init_PatchApplyTheirs, CREDENTIAL_PATTERNS, SENSITIVE_FILE_PATTERNS, FERN_BOT_NAME, FERN_BOT_EMAIL, FERN_BOT_LOGIN, FERN_SUPPORT_NAMES, LOCKFILE_HEADER, LockfileNotFoundError, LockfileManager, BINARY_EXTENSIONS, INFRASTRUCTURE_FILES, ReplayDetector, MergeAccumulator, CONFLICT_OPENER, CONFLICT_SEPARATOR, CONFLICT_CLOSER, AUTOVERSION_PLACEHOLDERS, VERSION_TOKEN, VERSION_MASK, ReplayApplicator, ReplayCommitter, FileOwnership, FirstGenerationFlow, SkipApplicationFlow, NoPatchesFlow, NormalRegenerationFlow, ReplayService, FernignoreMigrator, REPLAY_FERNIGNORE_ENTRIES, GITATTRIBUTES_ENTRIES, EMPTY_RESULT;
|
|
24297
24297
|
var init_dist3 = __esm({
|
|
24298
|
-
"../../node_modules/.pnpm/@fern-api+replay@0.19.
|
|
24298
|
+
"../../node_modules/.pnpm/@fern-api+replay@0.19.2/node_modules/@fern-api/replay/dist/index.js"() {
|
|
24299
24299
|
"use strict";
|
|
24300
24300
|
init_esm4();
|
|
24301
24301
|
import_promises4 = require("fs/promises");
|
|
@@ -26248,7 +26248,9 @@ Patches absorbed by generator (${buckets.absorbed.length}):`;
|
|
|
26248
26248
|
}
|
|
26249
26249
|
async prepare(options) {
|
|
26250
26250
|
const preLock = this.service.lockManager.read();
|
|
26251
|
-
const previousGenerationSha =
|
|
26251
|
+
const previousGenerationSha = await this.service.resolveReachablePreviousGeneration(
|
|
26252
|
+
preLock.current_generation ?? null
|
|
26253
|
+
);
|
|
26252
26254
|
let { patches: newPatches, revertedPatchIds } = await this.service.detector.detectNewPatches();
|
|
26253
26255
|
const detectorWarnings = [...this.service.detector.warnings];
|
|
26254
26256
|
const detectorDegraded = [...this.service.detector.degradedReasons];
|
|
@@ -26384,7 +26386,9 @@ Patches absorbed by generator (${buckets.absorbed.length}):`;
|
|
|
26384
26386
|
}
|
|
26385
26387
|
async prepare(options) {
|
|
26386
26388
|
const preLock = this.service.lockManager.read();
|
|
26387
|
-
const previousGenerationSha =
|
|
26389
|
+
const previousGenerationSha = await this.service.resolveReachablePreviousGeneration(
|
|
26390
|
+
preLock.current_generation ?? null
|
|
26391
|
+
);
|
|
26388
26392
|
if (options?.dryRun) {
|
|
26389
26393
|
const existingPatches2 = this.service.lockManager.getPatches();
|
|
26390
26394
|
const { patches: newPatches2, revertedPatchIds: dryRunReverted } = await this.service.detector.detectNewPatches();
|
|
@@ -26613,6 +26617,37 @@ Patches absorbed by generator (${buckets.absorbed.length}):`;
|
|
|
26613
26617
|
this.committer = new ReplayCommitter(git, outputDir);
|
|
26614
26618
|
this.fileOwnership = new FileOwnership(git);
|
|
26615
26619
|
}
|
|
26620
|
+
/**
|
|
26621
|
+
* Resolve the previous-generation SHA to export on
|
|
26622
|
+
* `ReplayPreparation.previousGenerationSha`.
|
|
26623
|
+
*
|
|
26624
|
+
* `current_generation` is the SHA of a LOCALLY-created `[fern-generated]` commit.
|
|
26625
|
+
* generator-cli's signed-commit push (`pushSignedCommit`) recreates that commit under a
|
|
26626
|
+
* new remote SHA, and a squash-merge collapses it away, so the recorded value can be
|
|
26627
|
+
* unreachable in a later clone (org "Natural": autoVersion then diffed against a phantom
|
|
26628
|
+
* baseline and silently reported NO_CHANGE — or, pre-a38bbc6, shipped
|
|
26629
|
+
* `0.0.0-fern-placeholder`). Consumers (generator-cli's autoVersion) diff against this
|
|
26630
|
+
* baseline, so it MUST resolve to a real commit.
|
|
26631
|
+
*
|
|
26632
|
+
* Prefer the recorded SHA while it still resolves — the healthy case, and the pristine
|
|
26633
|
+
* prior `[fern-generated]` tree. Otherwise re-anchor on the most recent reachable
|
|
26634
|
+
* generation boundary in first-parent history: the SAME value the detector already
|
|
26635
|
+
* derives for its own scan boundary (`findPreviousGenerationFromHistory`, whose
|
|
26636
|
+
* `isGenerationBoundary` matches squash-merge subjects like `SDK Generation (#N)`). Fall
|
|
26637
|
+
* back to the recorded SHA only when no boundary is reachable at all — no worse than the
|
|
26638
|
+
* prior behavior. ADR 0002 (generator-cli) allows replay to expose this reconciled value;
|
|
26639
|
+
* the consumer stays independently resilient.
|
|
26640
|
+
*
|
|
26641
|
+
* MUST be called before the new `[fern-generated]` commit is created, while HEAD is still
|
|
26642
|
+
* the pre-generation (customer) state, so the walk anchors on the PREVIOUS generation.
|
|
26643
|
+
*/
|
|
26644
|
+
async resolveReachablePreviousGeneration(recordedSha) {
|
|
26645
|
+
if (recordedSha != null && await this.git.commitExists(recordedSha)) {
|
|
26646
|
+
return recordedSha;
|
|
26647
|
+
}
|
|
26648
|
+
const derived = await this.detector.findPreviousGenerationFromHistory();
|
|
26649
|
+
return derived ?? recordedSha;
|
|
26650
|
+
}
|
|
26616
26651
|
/**
|
|
26617
26652
|
* Phase 1 of the two-phase replay flow. Runs preGenerationRebase (when applicable),
|
|
26618
26653
|
* detects new patches, and creates the `[fern-generated]` commit. Leaves HEAD at
|
|
@@ -41162,56 +41197,44 @@ var AutoVersioningService = class _AutoVersioningService {
|
|
|
41162
41197
|
}
|
|
41163
41198
|
/**
|
|
41164
41199
|
* Removes paired - and + lines where the only difference is the magic version.
|
|
41200
|
+
*
|
|
41201
|
+
* Matching is done across the whole section rather than only between adjacent lines.
|
|
41202
|
+
* Unified diffs group every deletion before every addition within a hunk, so when
|
|
41203
|
+
* several version-bearing lines change together (e.g. `X-Fern-SDK-Version` and
|
|
41204
|
+
* `User-Agent` on consecutive lines) an adjacency-only pass leaves the interleaved
|
|
41205
|
+
* deletions behind. Once the magic-version additions are stripped, those orphaned
|
|
41206
|
+
* deletions reach the AI analyzer as apparent removals — which is why a routine
|
|
41207
|
+
* version bump was reported as the `User-Agent` header being dropped. Pairing each
|
|
41208
|
+
* version-change deletion with any unused version-change addition in the section and
|
|
41209
|
+
* dropping both keeps the diff balanced regardless of layout.
|
|
41165
41210
|
*/
|
|
41166
41211
|
removeVersionChangePairs(lines, mappedMagicVersion) {
|
|
41167
|
-
const
|
|
41168
|
-
let
|
|
41169
|
-
|
|
41170
|
-
|
|
41171
|
-
if (!currentLine) {
|
|
41172
|
-
lineIndex++;
|
|
41212
|
+
const removed = /* @__PURE__ */ new Set();
|
|
41213
|
+
for (let deletionIndex = 0; deletionIndex < lines.length; deletionIndex++) {
|
|
41214
|
+
const deletionLine = lines[deletionIndex];
|
|
41215
|
+
if (deletionLine == null || removed.has(deletionIndex) || !this.isDeletionLine(deletionLine)) {
|
|
41173
41216
|
continue;
|
|
41174
41217
|
}
|
|
41175
|
-
|
|
41176
|
-
|
|
41177
|
-
|
|
41178
|
-
|
|
41179
|
-
|
|
41180
|
-
|
|
41181
|
-
|
|
41182
|
-
|
|
41218
|
+
for (let additionIndex = 0; additionIndex < lines.length; additionIndex++) {
|
|
41219
|
+
if (additionIndex === deletionIndex || removed.has(additionIndex)) {
|
|
41220
|
+
continue;
|
|
41221
|
+
}
|
|
41222
|
+
const additionLine = lines[additionIndex];
|
|
41223
|
+
if (additionLine == null || !this.isAdditionLine(additionLine)) {
|
|
41224
|
+
continue;
|
|
41225
|
+
}
|
|
41226
|
+
if (this.isVersionChangePair(deletionLine, additionLine, mappedMagicVersion)) {
|
|
41227
|
+
removed.add(deletionIndex);
|
|
41228
|
+
removed.add(additionIndex);
|
|
41229
|
+
break;
|
|
41183
41230
|
}
|
|
41184
|
-
} else {
|
|
41185
|
-
result.push(currentLine);
|
|
41186
|
-
lineIndex++;
|
|
41187
41231
|
}
|
|
41188
41232
|
}
|
|
41189
|
-
return
|
|
41233
|
+
return lines.filter((_2, index) => !removed.has(index));
|
|
41190
41234
|
}
|
|
41191
41235
|
isDeletionLine(line) {
|
|
41192
41236
|
return line.startsWith("-") && !_AutoVersioningService.isDiffHeader(line);
|
|
41193
41237
|
}
|
|
41194
|
-
findMatchingAdditionLine(lines, startIndex, mappedMagicVersion) {
|
|
41195
|
-
const startLine = lines[startIndex];
|
|
41196
|
-
if (!startLine) {
|
|
41197
|
-
return -1;
|
|
41198
|
-
}
|
|
41199
|
-
for (let nextIndex = startIndex + 1; nextIndex < lines.length; nextIndex++) {
|
|
41200
|
-
const nextLine = lines[nextIndex];
|
|
41201
|
-
if (!nextLine) {
|
|
41202
|
-
continue;
|
|
41203
|
-
}
|
|
41204
|
-
if (this.shouldStopSearching(nextLine)) {
|
|
41205
|
-
break;
|
|
41206
|
-
}
|
|
41207
|
-
if (this.isAdditionLine(nextLine)) {
|
|
41208
|
-
if (this.isVersionChangePair(startLine, nextLine, mappedMagicVersion)) {
|
|
41209
|
-
return nextIndex;
|
|
41210
|
-
}
|
|
41211
|
-
}
|
|
41212
|
-
}
|
|
41213
|
-
return -1;
|
|
41214
|
-
}
|
|
41215
41238
|
isAdditionLine(line) {
|
|
41216
41239
|
return line.startsWith("+") && !_AutoVersioningService.isDiffHeader(line);
|
|
41217
41240
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fern-api/generator-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.52",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/fern-api/fern.git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@boundaryml/baml": "^0.219.0",
|
|
26
|
-
"@fern-api/replay": "0.19.
|
|
26
|
+
"@fern-api/replay": "0.19.2",
|
|
27
27
|
"@octokit/rest": "^22.0.1",
|
|
28
28
|
"es-toolkit": "^1.45.1",
|
|
29
29
|
"semver": "^7.6.3",
|