@fern-api/generator-cli 0.6.4 → 0.6.6

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 (3) hide show
  1. package/dist/api.js +31 -19
  2. package/dist/cli.js +31 -19
  3. package/package.json +2 -2
package/dist/api.js CHANGED
@@ -5541,6 +5541,10 @@ var ClonedRepository = class _ClonedRepository {
5541
5541
  await this.git.push("origin", branch, { "--set-upstream": null });
5542
5542
  }
5543
5543
  }
5544
+ async fetch(args) {
5545
+ await this.git.cwd(this.clonePath);
5546
+ await this.git.fetch(args);
5547
+ }
5544
5548
  async pull(branch) {
5545
5549
  await this.git.cwd(this.clonePath);
5546
5550
  await this.git.pull("origin", branch);
@@ -5666,12 +5670,13 @@ var ClonedRepository = class _ClonedRepository {
5666
5670
  await this.git.push("origin", branch, { "--set-upstream": null });
5667
5671
  }
5668
5672
  // Only used by replay's PR mode to push synthetic divergent commits to a fern-bot/ branch.
5669
- // Uses --force-with-lease (not --force) so we fail safely if the branch was updated
5670
- // by someone else since we cloned. Never targets main or user branches.
5673
+ // These branches are exclusively owned by the pipeline — no human pushes to them.
5674
+ // Uses --force (not --force-with-lease) because the lease check fails after
5675
+ // git fetch --unshallow updates remote refs. Never targets main or user branches.
5671
5676
  async forcePush() {
5672
5677
  await this.git.cwd(this.clonePath);
5673
5678
  const currentBranch = await this.getCurrentBranch();
5674
- await this.git.push("origin", currentBranch, ["--force-with-lease"]);
5679
+ await this.git.push("origin", currentBranch, ["--force"]);
5675
5680
  }
5676
5681
  async createBranchFromHead(branchName) {
5677
5682
  await this.git.cwd(this.clonePath);
@@ -9666,16 +9671,19 @@ var consolePipelineLogger = {
9666
9671
  `)
9667
9672
  };
9668
9673
 
9669
- // src/pipeline/steps/GithubStep.ts
9670
- var import_rest2 = require("@octokit/rest");
9671
- var import_promises2 = require("fs/promises");
9672
- var import_path3 = require("path");
9674
+ // src/pipeline/PostGenerationPipeline.ts
9675
+ var import_child_process4 = require("child_process");
9673
9676
 
9674
9677
  // src/pipeline/github/constants.ts
9675
9678
  var FERN_BOT_NAME = "fern-api";
9676
9679
  var FERN_BOT_EMAIL = "115122769+fern-api[bot]@users.noreply.github.com";
9677
9680
  var FERN_BOT_LOGIN = "fern-api[bot]";
9678
9681
 
9682
+ // src/pipeline/steps/GithubStep.ts
9683
+ var import_rest2 = require("@octokit/rest");
9684
+ var import_promises2 = require("fs/promises");
9685
+ var import_path3 = require("path");
9686
+
9679
9687
  // src/pipeline/github/createReplayBranch.ts
9680
9688
  async function createReplayBranch(repository, branchName, commitMessage, replayConflictInfo, logger) {
9681
9689
  if (replayConflictInfo?.hasConflicts) {
@@ -9835,10 +9843,10 @@ function logReplaySummary(result, logger) {
9835
9843
  `Replay: flow=${result.flow}, detected=${result.patchesDetected ?? 0}, applied=${applied}, absorbed=${absorbed}, conflicts=${conflicts2}`
9836
9844
  );
9837
9845
  if (preserved > 0) {
9838
- const absorbedNote = absorbed > 0 ? ` (${plural(absorbed, "customization")} now part of generated code)` : "";
9839
- logger.info(`Replay: ${plural(preserved, "customization")} preserved${absorbedNote}`);
9846
+ const absorbedNote = absorbed > 0 ? ` (some customizations now part of generated code)` : "";
9847
+ logger.info(`Replay: customizations preserved${absorbedNote}`);
9840
9848
  } else if (absorbed > 0) {
9841
- logger.info(`Replay: ${plural(absorbed, "customization")} now part of generated code`);
9849
+ logger.info(`Replay: customizations now part of generated code`);
9842
9850
  }
9843
9851
  if (conflicts2 > 0) {
9844
9852
  const totalFiles = (result.conflictDetails ?? []).reduce((sum, d) => sum + d.files.length, 0);
@@ -9869,10 +9877,10 @@ function formatReplayPrBody(result, options) {
9869
9877
  }
9870
9878
  const parts = [];
9871
9879
  if (preserved > 0 && conflicts2 === 0) {
9872
- parts.push(`\u2705 ${plural(preserved, "customization")} automatically preserved in this update.`);
9880
+ parts.push(`\u2705 Customizations automatically preserved in this update.`);
9873
9881
  } else if (preserved > 0) {
9874
9882
  parts.push(
9875
- `\u2705 ${plural(preserved, "customization")} automatically preserved, but ${plural(conflicts2, "file")} ${conflicts2 === 1 ? "needs" : "need"} your attention.`
9883
+ `\u2705 Customizations automatically preserved, but ${plural(conflicts2, "file")} ${conflicts2 === 1 ? "needs" : "need"} your attention.`
9876
9884
  );
9877
9885
  }
9878
9886
  if (conflicts2 > 0) {
@@ -10031,16 +10039,13 @@ var GithubStep = class extends BaseStep {
10031
10039
  try {
10032
10040
  this.logger.debug("Starting GitHub self-hosted flow in directory: " + this.outputDir);
10033
10041
  const repository = ClonedRepository.createAtPath(this.outputDir);
10034
- const now = /* @__PURE__ */ new Date();
10035
- const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace("Z", "").replace(".", "_");
10036
- const newPrBranch = `fern-bot/${formattedDate}`;
10037
10042
  try {
10038
- await repository.setUserAndEmail({
10039
- name: FERN_BOT_NAME,
10040
- email: FERN_BOT_EMAIL
10041
- });
10043
+ await repository.fetch(["--unshallow"]);
10042
10044
  } catch {
10043
10045
  }
10046
+ const now = /* @__PURE__ */ new Date();
10047
+ const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace("Z", "").replace(".", "_");
10048
+ const newPrBranch = `fern-bot/${formattedDate}`;
10044
10049
  const mode = this.config.mode;
10045
10050
  switch (mode) {
10046
10051
  case "pull-request":
@@ -10728,6 +10733,13 @@ var PostGenerationPipeline = class {
10728
10733
  }
10729
10734
  steps = [];
10730
10735
  async run() {
10736
+ if (this.config.github?.enabled) {
10737
+ try {
10738
+ (0, import_child_process4.execFileSync)("git", ["config", "user.name", FERN_BOT_NAME], { cwd: this.config.outputDir });
10739
+ (0, import_child_process4.execFileSync)("git", ["config", "user.email", FERN_BOT_EMAIL], { cwd: this.config.outputDir });
10740
+ } catch {
10741
+ }
10742
+ }
10731
10743
  const result = {
10732
10744
  success: true,
10733
10745
  steps: {}
package/dist/cli.js CHANGED
@@ -19327,7 +19327,7 @@ var init_diff3 = __esm({
19327
19327
  }
19328
19328
  });
19329
19329
 
19330
- // ../../node_modules/.pnpm/@fern-api+replay@0.6.1/node_modules/@fern-api/replay/dist/index.js
19330
+ // ../../node_modules/.pnpm/@fern-api+replay@0.6.2/node_modules/@fern-api/replay/dist/index.js
19331
19331
  var dist_exports = {};
19332
19332
  __export(dist_exports, {
19333
19333
  FERN_BOT_EMAIL: () => FERN_BOT_EMAIL2,
@@ -19686,7 +19686,7 @@ function status(outputDir) {
19686
19686
  }
19687
19687
  var import_fs6, import_path8, import_yaml, import_crypto, import_promises4, import_os, import_path9, import_fs7, import_path10, import_crypto2, import_fs8, import_path11, import_yaml2, import_crypto3, import_fs9, import_path12, import_fs10, __defProp3, __getOwnPropNames3, __esm3, __export3, GitClient_exports, GitClient, init_GitClient, FERN_BOT_NAME2, FERN_BOT_EMAIL2, FERN_BOT_LOGIN2, FERN_SUPPORT_NAMES, LOCKFILE_HEADER, LockfileManager, INFRASTRUCTURE_FILES, ReplayDetector, BINARY_EXTENSIONS, ReplayApplicator, ReplayCommitter, ReplayService, FernignoreMigrator, REPLAY_FERNIGNORE_ENTRIES;
19688
19688
  var init_dist = __esm({
19689
- "../../node_modules/.pnpm/@fern-api+replay@0.6.1/node_modules/@fern-api/replay/dist/index.js"() {
19689
+ "../../node_modules/.pnpm/@fern-api+replay@0.6.2/node_modules/@fern-api/replay/dist/index.js"() {
19690
19690
  "use strict";
19691
19691
  init_esm4();
19692
19692
  import_fs6 = require("fs");
@@ -20560,12 +20560,12 @@ CLI Version: ${options.cliVersion}`;
20560
20560
  await this.git.exec(["commit", "-m", fullMessage]);
20561
20561
  return (await this.git.exec(["rev-parse", "HEAD"])).trim();
20562
20562
  }
20563
- async commitReplay(patchCount, patches) {
20563
+ async commitReplay(_patchCount, patches) {
20564
20564
  await this.stageAll();
20565
20565
  if (!await this.hasStagedChanges()) {
20566
20566
  return (await this.git.exec(["rev-parse", "HEAD"])).trim();
20567
20567
  }
20568
- let fullMessage = `[fern-replay] Applied ${patchCount} customization(s)`;
20568
+ let fullMessage = `[fern-replay] Applied customizations`;
20569
20569
  if (patches && patches.length > 0) {
20570
20570
  fullMessage += "\n\nPatches replayed:";
20571
20571
  for (const patch of patches) {
@@ -22992,6 +22992,10 @@ var ClonedRepository = class _ClonedRepository {
22992
22992
  await this.git.push("origin", branch, { "--set-upstream": null });
22993
22993
  }
22994
22994
  }
22995
+ async fetch(args) {
22996
+ await this.git.cwd(this.clonePath);
22997
+ await this.git.fetch(args);
22998
+ }
22995
22999
  async pull(branch) {
22996
23000
  await this.git.cwd(this.clonePath);
22997
23001
  await this.git.pull("origin", branch);
@@ -23117,12 +23121,13 @@ var ClonedRepository = class _ClonedRepository {
23117
23121
  await this.git.push("origin", branch, { "--set-upstream": null });
23118
23122
  }
23119
23123
  // Only used by replay's PR mode to push synthetic divergent commits to a fern-bot/ branch.
23120
- // Uses --force-with-lease (not --force) so we fail safely if the branch was updated
23121
- // by someone else since we cloned. Never targets main or user branches.
23124
+ // These branches are exclusively owned by the pipeline — no human pushes to them.
23125
+ // Uses --force (not --force-with-lease) because the lease check fails after
23126
+ // git fetch --unshallow updates remote refs. Never targets main or user branches.
23122
23127
  async forcePush() {
23123
23128
  await this.git.cwd(this.clonePath);
23124
23129
  const currentBranch = await this.getCurrentBranch();
23125
- await this.git.push("origin", currentBranch, ["--force-with-lease"]);
23130
+ await this.git.push("origin", currentBranch, ["--force"]);
23126
23131
  }
23127
23132
  async createBranchFromHead(branchName) {
23128
23133
  await this.git.cwd(this.clonePath);
@@ -30827,15 +30832,18 @@ var consolePipelineLogger = {
30827
30832
  `)
30828
30833
  };
30829
30834
 
30830
- // src/pipeline/steps/GithubStep.ts
30831
- var import_promises3 = require("fs/promises");
30832
- var import_path7 = require("path");
30835
+ // src/pipeline/PostGenerationPipeline.ts
30836
+ var import_child_process4 = require("child_process");
30833
30837
 
30834
30838
  // src/pipeline/github/constants.ts
30835
30839
  var FERN_BOT_NAME = "fern-api";
30836
30840
  var FERN_BOT_EMAIL = "115122769+fern-api[bot]@users.noreply.github.com";
30837
30841
  var FERN_BOT_LOGIN = "fern-api[bot]";
30838
30842
 
30843
+ // src/pipeline/steps/GithubStep.ts
30844
+ var import_promises3 = require("fs/promises");
30845
+ var import_path7 = require("path");
30846
+
30839
30847
  // src/pipeline/github/createReplayBranch.ts
30840
30848
  async function createReplayBranch(repository, branchName, commitMessage, replayConflictInfo, logger) {
30841
30849
  if (replayConflictInfo?.hasConflicts) {
@@ -30996,10 +31004,10 @@ function formatReplayPrBody(result, options) {
30996
31004
  }
30997
31005
  const parts = [];
30998
31006
  if (preserved > 0 && conflicts2 === 0) {
30999
- parts.push(`\u2705 ${plural(preserved, "customization")} automatically preserved in this update.`);
31007
+ parts.push(`\u2705 Customizations automatically preserved in this update.`);
31000
31008
  } else if (preserved > 0) {
31001
31009
  parts.push(
31002
- `\u2705 ${plural(preserved, "customization")} automatically preserved, but ${plural(conflicts2, "file")} ${conflicts2 === 1 ? "needs" : "need"} your attention.`
31010
+ `\u2705 Customizations automatically preserved, but ${plural(conflicts2, "file")} ${conflicts2 === 1 ? "needs" : "need"} your attention.`
31003
31011
  );
31004
31012
  }
31005
31013
  if (conflicts2 > 0) {
@@ -31158,16 +31166,13 @@ var GithubStep = class extends BaseStep {
31158
31166
  try {
31159
31167
  this.logger.debug("Starting GitHub self-hosted flow in directory: " + this.outputDir);
31160
31168
  const repository = ClonedRepository.createAtPath(this.outputDir);
31161
- const now = /* @__PURE__ */ new Date();
31162
- const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace("Z", "").replace(".", "_");
31163
- const newPrBranch = `fern-bot/${formattedDate}`;
31164
31169
  try {
31165
- await repository.setUserAndEmail({
31166
- name: FERN_BOT_NAME,
31167
- email: FERN_BOT_EMAIL
31168
- });
31170
+ await repository.fetch(["--unshallow"]);
31169
31171
  } catch {
31170
31172
  }
31173
+ const now = /* @__PURE__ */ new Date();
31174
+ const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace("Z", "").replace(".", "_");
31175
+ const newPrBranch = `fern-bot/${formattedDate}`;
31171
31176
  const mode = this.config.mode;
31172
31177
  switch (mode) {
31173
31178
  case "pull-request":
@@ -31855,6 +31860,13 @@ var PostGenerationPipeline = class {
31855
31860
  }
31856
31861
  steps = [];
31857
31862
  async run() {
31863
+ if (this.config.github?.enabled) {
31864
+ try {
31865
+ (0, import_child_process4.execFileSync)("git", ["config", "user.name", FERN_BOT_NAME], { cwd: this.config.outputDir });
31866
+ (0, import_child_process4.execFileSync)("git", ["config", "user.email", FERN_BOT_EMAIL], { cwd: this.config.outputDir });
31867
+ } catch {
31868
+ }
31869
+ }
31858
31870
  const result = {
31859
31871
  success: true,
31860
31872
  steps: {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fern-api/generator-cli",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fern-api/fern.git",
@@ -22,7 +22,7 @@
22
22
  "**"
23
23
  ],
24
24
  "dependencies": {
25
- "@fern-api/replay": "^0.6.1",
25
+ "@fern-api/replay": "^0.6.2",
26
26
  "@octokit/rest": "^22.0.1",
27
27
  "es-toolkit": "^1.39.10",
28
28
  "tmp-promise": "^3.0.3"