@fern-api/fern-api-dev 4.62.3-18-gaf2c775a876 → 4.62.3-19-g218ebd6b5a4

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.
Files changed (2) hide show
  1. package/cli.cjs +327 -20
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -363452,9 +363452,9 @@ var require_diff3 = __commonJS({
363452
363452
  }
363453
363453
  });
363454
363454
 
363455
- // ../../../node_modules/.pnpm/@fern-api+replay@0.9.0/node_modules/@fern-api/replay/dist/index.cjs
363455
+ // ../../../node_modules/.pnpm/@fern-api+replay@0.9.1/node_modules/@fern-api/replay/dist/index.cjs
363456
363456
  var require_dist11 = __commonJS({
363457
- "../../../node_modules/.pnpm/@fern-api+replay@0.9.0/node_modules/@fern-api/replay/dist/index.cjs"(exports2, module4) {
363457
+ "../../../node_modules/.pnpm/@fern-api+replay@0.9.1/node_modules/@fern-api/replay/dist/index.cjs"(exports2, module4) {
363458
363458
  "use strict";
363459
363459
  var __defProp4 = Object.defineProperty;
363460
363460
  var __getOwnPropDesc4 = Object.getOwnPropertyDescriptor;
@@ -363579,6 +363579,14 @@ var require_dist11 = __commonJS({
363579
363579
  return false;
363580
363580
  }
363581
363581
  }
363582
+ async treeExists(treeHash) {
363583
+ try {
363584
+ const type8 = await this.exec(["cat-file", "-t", treeHash]);
363585
+ return type8.trim() === "tree";
363586
+ } catch {
363587
+ return false;
363588
+ }
363589
+ }
363582
363590
  async getCommitBody(commitSha) {
363583
363591
  return this.exec(["log", "-1", "--format=%B", commitSha]);
363584
363592
  }
@@ -363588,6 +363596,253 @@ var require_dist11 = __commonJS({
363588
363596
  };
363589
363597
  }
363590
363598
  });
363599
+ var HybridReconstruction_exports = {};
363600
+ __export4(HybridReconstruction_exports, {
363601
+ assembleHybrid: () => assembleHybrid,
363602
+ locateHunksInOurs: () => locateHunksInOurs,
363603
+ parseHunks: () => parseHunks,
363604
+ reconstructFromGhostPatch: () => reconstructFromGhostPatch
363605
+ });
363606
+ function parseHunks(fileDiff) {
363607
+ const lines = fileDiff.split("\n");
363608
+ const hunks = [];
363609
+ let currentHunk = null;
363610
+ for (const line of lines) {
363611
+ const headerMatch = line.match(
363612
+ /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/
363613
+ );
363614
+ if (headerMatch) {
363615
+ if (currentHunk) {
363616
+ hunks.push(currentHunk);
363617
+ }
363618
+ currentHunk = {
363619
+ oldStart: parseInt(headerMatch[1], 10),
363620
+ oldCount: headerMatch[2] != null ? parseInt(headerMatch[2], 10) : 1,
363621
+ newStart: parseInt(headerMatch[3], 10),
363622
+ newCount: headerMatch[4] != null ? parseInt(headerMatch[4], 10) : 1,
363623
+ lines: []
363624
+ };
363625
+ continue;
363626
+ }
363627
+ if (!currentHunk) continue;
363628
+ if (line.startsWith("diff --git") || line.startsWith("index ") || line.startsWith("---") || line.startsWith("+++") || line.startsWith("old mode") || line.startsWith("new mode") || line.startsWith("similarity index") || line.startsWith("rename from") || line.startsWith("rename to") || line.startsWith("new file mode") || line.startsWith("deleted file mode")) {
363629
+ continue;
363630
+ }
363631
+ if (line === "\") {
363632
+ continue;
363633
+ }
363634
+ if (line.startsWith("-")) {
363635
+ currentHunk.lines.push({ type: "remove", content: line.slice(1) });
363636
+ } else if (line.startsWith("+")) {
363637
+ currentHunk.lines.push({ type: "add", content: line.slice(1) });
363638
+ } else if (line.startsWith(" ") || line === "") {
363639
+ currentHunk.lines.push({
363640
+ type: "context",
363641
+ content: line.startsWith(" ") ? line.slice(1) : line
363642
+ });
363643
+ }
363644
+ }
363645
+ if (currentHunk) {
363646
+ hunks.push(currentHunk);
363647
+ }
363648
+ return hunks;
363649
+ }
363650
+ function extractLeadingContext(hunk) {
363651
+ const result = [];
363652
+ for (const line of hunk.lines) {
363653
+ if (line.type !== "context") break;
363654
+ result.push(line.content);
363655
+ }
363656
+ return result;
363657
+ }
363658
+ function extractTrailingContext(hunk) {
363659
+ const result = [];
363660
+ for (let i11 = hunk.lines.length - 1; i11 >= 0; i11--) {
363661
+ if (hunk.lines[i11].type !== "context") break;
363662
+ result.unshift(hunk.lines[i11].content);
363663
+ }
363664
+ return result;
363665
+ }
363666
+ function countOursLinesBeforeTrailing(hunk) {
363667
+ let count = 0;
363668
+ const trailingStart = findTrailingContextStart(hunk);
363669
+ for (let i11 = 0; i11 < trailingStart; i11++) {
363670
+ if (hunk.lines[i11].type === "context") count++;
363671
+ }
363672
+ return count;
363673
+ }
363674
+ function findTrailingContextStart(hunk) {
363675
+ let i11 = hunk.lines.length - 1;
363676
+ while (i11 >= 0 && hunk.lines[i11].type === "context") {
363677
+ i11--;
363678
+ }
363679
+ return i11 + 1;
363680
+ }
363681
+ function matchesAt(needle, haystack, offset2) {
363682
+ for (let i11 = 0; i11 < needle.length; i11++) {
363683
+ if (haystack[offset2 + i11] !== needle[i11]) return false;
363684
+ }
363685
+ return true;
363686
+ }
363687
+ function findContextInOurs(contextLines, oursLines, minIndex, hint) {
363688
+ const SEARCH_WINDOW = 200;
363689
+ const maxStart = oursLines.length - contextLines.length;
363690
+ const clampedHint = Math.max(minIndex, Math.min(hint, maxStart));
363691
+ if (clampedHint >= minIndex && clampedHint <= maxStart) {
363692
+ if (matchesAt(contextLines, oursLines, clampedHint)) {
363693
+ return clampedHint;
363694
+ }
363695
+ }
363696
+ for (let delta = 1; delta <= SEARCH_WINDOW; delta++) {
363697
+ for (const sign2 of [1, -1]) {
363698
+ const idx = clampedHint + delta * sign2;
363699
+ if (idx < minIndex || idx > maxStart) continue;
363700
+ if (matchesAt(contextLines, oursLines, idx)) {
363701
+ return idx;
363702
+ }
363703
+ }
363704
+ }
363705
+ return -1;
363706
+ }
363707
+ function computeOursSpan(hunk, oursLines, oursOffset) {
363708
+ const leading = extractLeadingContext(hunk);
363709
+ const trailing = extractTrailingContext(hunk);
363710
+ if (trailing.length === 0) {
363711
+ const contextCount2 = hunk.lines.filter(
363712
+ (l14) => l14.type === "context"
363713
+ ).length;
363714
+ return Math.min(contextCount2, oursLines.length - oursOffset);
363715
+ }
363716
+ const searchStart = oursOffset + leading.length;
363717
+ for (let i11 = searchStart; i11 <= oursLines.length - trailing.length; i11++) {
363718
+ if (matchesAt(trailing, oursLines, i11)) {
363719
+ return i11 + trailing.length - oursOffset;
363720
+ }
363721
+ }
363722
+ const contextCount = hunk.lines.filter(
363723
+ (l14) => l14.type === "context"
363724
+ ).length;
363725
+ return Math.min(contextCount, oursLines.length - oursOffset);
363726
+ }
363727
+ function locateHunksInOurs(hunks, oursLines) {
363728
+ const located = [];
363729
+ let minOursIndex = 0;
363730
+ for (const hunk of hunks) {
363731
+ const contextLines = extractLeadingContext(hunk);
363732
+ let oursOffset;
363733
+ if (contextLines.length > 0) {
363734
+ const found = findContextInOurs(
363735
+ contextLines,
363736
+ oursLines,
363737
+ minOursIndex,
363738
+ hunk.newStart - 1
363739
+ );
363740
+ if (found === -1) {
363741
+ const trailingContext = extractTrailingContext(hunk);
363742
+ if (trailingContext.length > 0) {
363743
+ const trailingFound = findContextInOurs(
363744
+ trailingContext,
363745
+ oursLines,
363746
+ minOursIndex,
363747
+ hunk.newStart - 1
363748
+ );
363749
+ if (trailingFound === -1) return null;
363750
+ const nonTrailingCount = countOursLinesBeforeTrailing(hunk);
363751
+ oursOffset = trailingFound - nonTrailingCount;
363752
+ if (oursOffset < minOursIndex) return null;
363753
+ } else {
363754
+ return null;
363755
+ }
363756
+ } else {
363757
+ oursOffset = found;
363758
+ }
363759
+ } else if (hunk.oldStart === 1 && hunk.oldCount === 0) {
363760
+ oursOffset = 0;
363761
+ } else {
363762
+ oursOffset = Math.max(hunk.newStart - 1, minOursIndex);
363763
+ }
363764
+ const oursSpan = computeOursSpan(hunk, oursLines, oursOffset);
363765
+ located.push({ hunk, oursOffset, oursSpan });
363766
+ minOursIndex = oursOffset + oursSpan;
363767
+ }
363768
+ return located;
363769
+ }
363770
+ function assembleHybrid(locatedHunks, oursLines) {
363771
+ const baseLines = [];
363772
+ const theirsLines = [];
363773
+ let oursCursor = 0;
363774
+ for (const { hunk, oursOffset, oursSpan } of locatedHunks) {
363775
+ if (oursOffset > oursCursor) {
363776
+ const gapLines = oursLines.slice(oursCursor, oursOffset);
363777
+ baseLines.push(...gapLines);
363778
+ theirsLines.push(...gapLines);
363779
+ }
363780
+ for (const line of hunk.lines) {
363781
+ switch (line.type) {
363782
+ case "context":
363783
+ baseLines.push(line.content);
363784
+ theirsLines.push(line.content);
363785
+ break;
363786
+ case "remove":
363787
+ baseLines.push(line.content);
363788
+ break;
363789
+ case "add":
363790
+ theirsLines.push(line.content);
363791
+ break;
363792
+ }
363793
+ }
363794
+ oursCursor = oursOffset + oursSpan;
363795
+ }
363796
+ if (oursCursor < oursLines.length) {
363797
+ const gapLines = oursLines.slice(oursCursor);
363798
+ baseLines.push(...gapLines);
363799
+ theirsLines.push(...gapLines);
363800
+ }
363801
+ return {
363802
+ base: baseLines.join("\n"),
363803
+ theirs: theirsLines.join("\n")
363804
+ };
363805
+ }
363806
+ function reconstructFromGhostPatch(fileDiff, ours) {
363807
+ const hunks = parseHunks(fileDiff);
363808
+ if (hunks.length === 0) {
363809
+ return null;
363810
+ }
363811
+ const isPureAddition = hunks.every(
363812
+ (h14) => h14.oldCount === 0 && h14.lines.every((l14) => l14.type !== "remove")
363813
+ );
363814
+ if (isPureAddition) {
363815
+ return null;
363816
+ }
363817
+ const isPureDeletion = hunks.every(
363818
+ (h14) => h14.newCount === 0 && h14.lines.every((l14) => l14.type !== "add")
363819
+ );
363820
+ if (isPureDeletion) {
363821
+ const baseLines = [];
363822
+ for (const hunk of hunks) {
363823
+ for (const line of hunk.lines) {
363824
+ if (line.type === "context" || line.type === "remove") {
363825
+ baseLines.push(line.content);
363826
+ }
363827
+ }
363828
+ }
363829
+ return {
363830
+ base: baseLines.join("\n"),
363831
+ theirs: ""
363832
+ };
363833
+ }
363834
+ const oursLines = ours.split("\n");
363835
+ const located = locateHunksInOurs(hunks, oursLines);
363836
+ if (!located) {
363837
+ return null;
363838
+ }
363839
+ return assembleHybrid(located, oursLines);
363840
+ }
363841
+ var init_HybridReconstruction = __esm3({
363842
+ "src/HybridReconstruction.ts"() {
363843
+ "use strict";
363844
+ }
363845
+ });
363591
363846
  var index_exports = {};
363592
363847
  __export4(index_exports, {
363593
363848
  FERN_BOT_EMAIL: () => FERN_BOT_EMAIL,
@@ -364092,6 +364347,7 @@ var require_dist11 = __commonJS({
364092
364347
  lockManager;
364093
364348
  outputDir;
364094
364349
  renameCache = /* @__PURE__ */ new Map();
364350
+ treeExistsCache = /* @__PURE__ */ new Map();
364095
364351
  fileTheirsAccumulator = /* @__PURE__ */ new Map();
364096
364352
  constructor(git, lockManager, outputDir) {
364097
364353
  this.git = git;
@@ -364288,14 +364544,33 @@ var require_dist11 = __commonJS({
364288
364544
  }
364289
364545
  const oursPath = (0, import_node_path210.join)(this.outputDir, resolvedPath);
364290
364546
  const ours = await (0, import_promises181.readFile)(oursPath, "utf-8").catch(() => null);
364291
- let theirs = await this.applyPatchToContent(
364292
- base4,
364293
- patch5.patch_content,
364294
- filePath,
364295
- tempGit,
364296
- tempDir2,
364297
- renameSourcePath
364298
- );
364547
+ let ghostReconstructed = false;
364548
+ let theirs = null;
364549
+ if (!base4 && ours && !renameSourcePath) {
364550
+ const treeReachable = await this.isTreeReachable(baseGen.tree_hash);
364551
+ if (!treeReachable) {
364552
+ const fileDiff = this.extractFileDiff(patch5.patch_content, filePath);
364553
+ if (fileDiff) {
364554
+ const { reconstructFromGhostPatch: reconstructFromGhostPatch2 } = await Promise.resolve().then(() => (init_HybridReconstruction(), HybridReconstruction_exports));
364555
+ const result = reconstructFromGhostPatch2(fileDiff, ours);
364556
+ if (result) {
364557
+ base4 = result.base;
364558
+ theirs = result.theirs;
364559
+ ghostReconstructed = true;
364560
+ }
364561
+ }
364562
+ }
364563
+ }
364564
+ if (!ghostReconstructed) {
364565
+ theirs = await this.applyPatchToContent(
364566
+ base4,
364567
+ patch5.patch_content,
364568
+ filePath,
364569
+ tempGit,
364570
+ tempDir2,
364571
+ renameSourcePath
364572
+ );
364573
+ }
364299
364574
  let useAccumulatorAsMergeBase = false;
364300
364575
  const accumulatorEntry = this.fileTheirsAccumulator.get(resolvedPath);
364301
364576
  if (!theirs && accumulatorEntry) {
@@ -364328,13 +364603,13 @@ var require_dist11 = __commonJS({
364328
364603
  baseMismatchSkipped = true;
364329
364604
  }
364330
364605
  }
364331
- if (!base4 && !ours && effective_theirs) {
364606
+ if (base4 == null && !ours && effective_theirs) {
364332
364607
  const outDir2 = (0, import_node_path210.dirname)(oursPath);
364333
364608
  await (0, import_promises181.mkdir)(outDir2, { recursive: true });
364334
364609
  await (0, import_promises181.writeFile)(oursPath, effective_theirs);
364335
364610
  return { file: resolvedPath, status: "merged", reason: "new-file" };
364336
364611
  }
364337
- if (!base4 && ours && effective_theirs) {
364612
+ if (base4 == null && ours && effective_theirs) {
364338
364613
  const merged2 = threeWayMerge("", ours, effective_theirs);
364339
364614
  const outDir2 = (0, import_node_path210.dirname)(oursPath);
364340
364615
  await (0, import_promises181.mkdir)(outDir2, { recursive: true });
@@ -364357,7 +364632,7 @@ var require_dist11 = __commonJS({
364357
364632
  reason: "missing-content"
364358
364633
  };
364359
364634
  }
364360
- if (!base4 && !useAccumulatorAsMergeBase || !ours) {
364635
+ if (base4 == null && !useAccumulatorAsMergeBase || !ours) {
364361
364636
  return {
364362
364637
  file: resolvedPath,
364363
364638
  status: "skipped",
@@ -364400,6 +364675,14 @@ var require_dist11 = __commonJS({
364400
364675
  };
364401
364676
  }
364402
364677
  }
364678
+ async isTreeReachable(treeHash) {
364679
+ let result = this.treeExistsCache.get(treeHash);
364680
+ if (result === void 0) {
364681
+ result = await this.git.treeExists(treeHash);
364682
+ this.treeExistsCache.set(treeHash, result);
364683
+ }
364684
+ return result;
364685
+ }
364403
364686
  isExcluded(patch5) {
364404
364687
  const config5 = this.lockManager.getCustomizationsConfig();
364405
364688
  if (!config5.exclude) return false;
@@ -365466,6 +365749,7 @@ CLI Version: ${options2.cliVersion}`;
365466
365749
  }
365467
365750
  lockManager.save();
365468
365751
  const fernignoreUpdated = ensureFernignoreEntries(outputDir);
365752
+ ensureGitattributesEntries(outputDir);
365469
365753
  if (migrator.fernignoreExists() && fernignorePatterns.length > 0) {
365470
365754
  const action = options2?.fernignoreAction ?? "skip";
365471
365755
  if (action === "migrate") {
@@ -365547,7 +365831,7 @@ CLI Version: ${options2.cliVersion}`;
365547
365831
  return { sha, authorName, authorEmail, message };
365548
365832
  });
365549
365833
  }
365550
- var REPLAY_FERNIGNORE_ENTRIES = [".fern/replay.lock", ".fern/replay.yml"];
365834
+ var REPLAY_FERNIGNORE_ENTRIES = [".fern/replay.lock", ".fern/replay.yml", ".gitattributes"];
365551
365835
  function ensureFernignoreEntries(outputDir) {
365552
365836
  const fernignorePath = (0, import_node_path52.join)(outputDir, ".fernignore");
365553
365837
  let content5 = "";
@@ -365571,6 +365855,29 @@ CLI Version: ${options2.cliVersion}`;
365571
365855
  (0, import_node_fs42.writeFileSync)(fernignorePath, content5, "utf-8");
365572
365856
  return true;
365573
365857
  }
365858
+ var GITATTRIBUTES_ENTRIES = [".fern/replay.lock linguist-generated=true"];
365859
+ function ensureGitattributesEntries(outputDir) {
365860
+ const gitattributesPath = (0, import_node_path52.join)(outputDir, ".gitattributes");
365861
+ let content5 = "";
365862
+ if ((0, import_node_fs42.existsSync)(gitattributesPath)) {
365863
+ content5 = (0, import_node_fs42.readFileSync)(gitattributesPath, "utf-8");
365864
+ }
365865
+ const lines = content5.split("\n");
365866
+ const toAdd = [];
365867
+ for (const entry of GITATTRIBUTES_ENTRIES) {
365868
+ if (!lines.some((line) => line.trim() === entry)) {
365869
+ toAdd.push(entry);
365870
+ }
365871
+ }
365872
+ if (toAdd.length === 0) {
365873
+ return;
365874
+ }
365875
+ if (content5 && !content5.endsWith("\n")) {
365876
+ content5 += "\n";
365877
+ }
365878
+ content5 += toAdd.join("\n") + "\n";
365879
+ (0, import_node_fs42.writeFileSync)(gitattributesPath, content5, "utf-8");
365880
+ }
365574
365881
  function computeContentHash(patchContent) {
365575
365882
  const normalized = patchContent.split("\n").filter((line) => !line.startsWith("From ") && !line.startsWith("index ") && !line.startsWith("Date: ")).join("\n");
365576
365883
  return `sha256:${(0, import_node_crypto32.createHash)("sha256").update(normalized).digest("hex")}`;
@@ -603138,7 +603445,7 @@ var AccessTokenPosthogManager = class {
603138
603445
  properties: {
603139
603446
  ...event,
603140
603447
  ...event.properties,
603141
- version: "4.62.3-18-gaf2c775a876",
603448
+ version: "4.62.3-19-g218ebd6b5a4",
603142
603449
  usingAccessToken: true
603143
603450
  }
603144
603451
  });
@@ -603189,7 +603496,7 @@ var UserPosthogManager = class {
603189
603496
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
603190
603497
  event: "CLI",
603191
603498
  properties: {
603192
- version: "4.62.3-18-gaf2c775a876",
603499
+ version: "4.62.3-19-g218ebd6b5a4",
603193
603500
  ...event,
603194
603501
  ...event.properties,
603195
603502
  usingAccessToken: false,
@@ -753177,7 +753484,7 @@ var V66_TO_V65_MIGRATION = {
753177
753484
  [GeneratorName.JAVA_SDK]: GeneratorWasNeverUpdatedToConsumeNewIR,
753178
753485
  [GeneratorName.JAVA_SPRING]: GeneratorWasNeverUpdatedToConsumeNewIR,
753179
753486
  [GeneratorName.OPENAPI_PYTHON_CLIENT]: GeneratorWasNeverUpdatedToConsumeNewIR,
753180
- [GeneratorName.OPENAPI]: GeneratorWasNeverUpdatedToConsumeNewIR,
753487
+ [GeneratorName.OPENAPI]: "0.4.0-rc.0",
753181
753488
  [GeneratorName.PYTHON_FASTAPI]: GeneratorWasNeverUpdatedToConsumeNewIR,
753182
753489
  [GeneratorName.PYTHON_PYDANTIC]: GeneratorWasNeverUpdatedToConsumeNewIR,
753183
753490
  [GeneratorName.PYTHON_SDK]: GeneratorWasNeverUpdatedToConsumeNewIR,
@@ -840485,7 +840792,7 @@ var import_path54 = __toESM(require("path"), 1);
840485
840792
  var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
840486
840793
  var LOGS_FOLDER_NAME = "logs";
840487
840794
  function getCliSource() {
840488
- const version7 = "4.62.3-18-gaf2c775a876";
840795
+ const version7 = "4.62.3-19-g218ebd6b5a4";
840489
840796
  return `cli@${version7}`;
840490
840797
  }
840491
840798
  var DebugLogger = class {
@@ -851593,7 +851900,7 @@ var LegacyDocsPublisher = class {
851593
851900
  previewId,
851594
851901
  disableTemplates: void 0,
851595
851902
  skipUpload,
851596
- cliVersion: "4.62.3-18-gaf2c775a876"
851903
+ cliVersion: "4.62.3-19-g218ebd6b5a4"
851597
851904
  });
851598
851905
  if (taskContext.getResult() === TaskResult.Failure) {
851599
851906
  return { success: false };
@@ -924893,7 +925200,7 @@ var CliContext = class {
924893
925200
  if (false) {
924894
925201
  this.logger.error("CLI_VERSION is not defined");
924895
925202
  }
924896
- return "4.62.3-18-gaf2c775a876";
925203
+ return "4.62.3-19-g218ebd6b5a4";
924897
925204
  }
924898
925205
  getCliName() {
924899
925206
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.62.3-18-gaf2c775a876",
2
+ "version": "4.62.3-19-g218ebd6b5a4",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",