@fern-api/fern-api-dev 4.90.0-13-g88979a56bb3 → 4.90.0-14-g871c1a60e90

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 +101 -36
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -332867,21 +332867,33 @@ var require_AutoVersionStep = __commonJS({
332867
332867
  async handleNormalFlow(params2) {
332868
332868
  const { prepared, service, language, mappedMagicVersion, previousGenerationSha } = params2;
332869
332869
  const rawDiff = this.gitDiff(previousGenerationSha, prepared.currentGenerationSha);
332870
- if (rawDiff.trim().length === 0) {
332871
- this.logger.info("AutoVersionStep: empty diff between generations; skipping autoversion.");
332872
- return { executed: true, success: true };
332873
- }
332874
332870
  const previousVersion = await this.resolvePreviousVersion({ service, rawDiff, mappedMagicVersion });
332875
332871
  if (previousVersion == null) {
332876
332872
  return await this.handleFirstGeneration({ service, language, mappedMagicVersion });
332877
332873
  }
332874
+ if (rawDiff.trim().length === 0) {
332875
+ this.logger.info(`AutoVersionStep: empty diff between generations; rewriting placeholder to ${previousVersion}.`);
332876
+ return await this.finalizeNoChange({
332877
+ service,
332878
+ language,
332879
+ mappedMagicVersion,
332880
+ previousVersion,
332881
+ reason: "no diff between generations"
332882
+ });
332883
+ }
332878
332884
  const cleanedDiff = service.cleanDiffForAI(rawDiff, mappedMagicVersion);
332879
332885
  const rawBytes = Buffer.byteLength(rawDiff, "utf-8");
332880
332886
  const cleanedBytes = Buffer.byteLength(cleanedDiff, "utf-8");
332881
332887
  this.logger.debug(`AutoVersionStep: raw=${(0, index_1.formatSizeKB)(rawBytes)}KB (${(0, index_1.countFilesInDiff)(rawDiff)} files), cleaned=${(0, index_1.formatSizeKB)(cleanedBytes)}KB (${(0, index_1.countFilesInDiff)(cleanedDiff)} files)`);
332882
332888
  if (cleanedDiff.trim().length === 0) {
332883
- this.logger.info("AutoVersionStep: cleaned diff is empty; no semantic changes.");
332884
- return { executed: true, success: true };
332889
+ this.logger.info(`AutoVersionStep: cleaned diff is empty; no semantic changes \u2014 rewriting placeholder to ${previousVersion}.`);
332890
+ return await this.finalizeNoChange({
332891
+ service,
332892
+ language,
332893
+ mappedMagicVersion,
332894
+ previousVersion,
332895
+ reason: "no semantic changes"
332896
+ });
332885
332897
  }
332886
332898
  if (cleanedBytes > index_1.MAX_RAW_DIFF_BYTES) {
332887
332899
  this.logger.warn(`AutoVersionStep: diff too large for FAI (${(0, index_1.formatSizeKB)(cleanedBytes)}KB, limit ${(0, index_1.formatSizeKB)(index_1.MAX_RAW_DIFF_BYTES)}KB). Falling back to PATCH.`);
@@ -332907,13 +332919,14 @@ var require_AutoVersionStep = __commonJS({
332907
332919
  analysis = { versionBump: "PATCH", message: this.brandMessage("SDK regeneration") };
332908
332920
  }
332909
332921
  if (analysis == null) {
332910
- this.logger.info("AutoVersionStep: FAI returned NO_CHANGE; skipping autoversion commit.");
332911
- return {
332912
- executed: true,
332913
- success: true,
332922
+ this.logger.info(`AutoVersionStep: FAI returned NO_CHANGE; rewriting placeholder to ${previousVersion}.`);
332923
+ return await this.finalizeNoChange({
332924
+ service,
332925
+ language,
332926
+ mappedMagicVersion,
332914
332927
  previousVersion,
332915
- versionBump: "NO_CHANGE"
332916
- };
332928
+ reason: "FAI returned NO_CHANGE"
332929
+ });
332917
332930
  }
332918
332931
  return await this.finalizeWithBump({
332919
332932
  service,
@@ -332923,6 +332936,38 @@ var require_AutoVersionStep = __commonJS({
332923
332936
  analysis
332924
332937
  });
332925
332938
  }
332939
+ /**
332940
+ * Terminal path for runs that determine no semver bump is needed. The
332941
+ * current working tree still contains `0.0.0-fern-placeholder` from this
332942
+ * run's generator output, so we must rewrite it to `previousVersion`
332943
+ * before exiting — otherwise the SDK ships with the placeholder embedded
332944
+ * in manifests (package.json, pyproject.toml, .fern/metadata.json) and
332945
+ * user-agent strings (e.g. `X-Fern-SDK-Version`). Commits the rewrite as
332946
+ * `[fern-autoversion]` so the replay + github steps see a stable base.
332947
+ */
332948
+ async finalizeNoChange(params2) {
332949
+ const { service, language, mappedMagicVersion, previousVersion, reason } = params2;
332950
+ if (!(0, index_1.isValidSemver)(previousVersion)) {
332951
+ const errorMessage = `AutoVersionStep: resolved previousVersion ${JSON.stringify(previousVersion)} is not a valid semver string. Refusing to rewrite placeholder to avoid shell injection.`;
332952
+ this.logger.error(errorMessage);
332953
+ return { executed: true, success: false, errorMessage };
332954
+ }
332955
+ await service.replaceMagicVersion(this.outputDir, mappedMagicVersion, previousVersion);
332956
+ if (language === "go") {
332957
+ await service.addGoMajorVersionSuffix(this.outputDir, previousVersion);
332958
+ }
332959
+ const commitMessage = this.brandMessage(`SDK regeneration (no semver change: ${reason})`);
332960
+ const commitSha = this.commitAutoversion(commitMessage);
332961
+ return {
332962
+ executed: true,
332963
+ success: true,
332964
+ version: previousVersion,
332965
+ previousVersion,
332966
+ versionBump: "NO_CHANGE",
332967
+ commitMessage,
332968
+ commitSha
332969
+ };
332970
+ }
332926
332971
  async finalizeWithBump(params2) {
332927
332972
  const { service, language, mappedMagicVersion, previousVersion, analysis } = params2;
332928
332973
  const newVersion = (0, index_1.incrementVersion)(previousVersion, analysis.versionBump);
@@ -343160,6 +343205,7 @@ var require_GithubStep = __commonJS({
343160
343205
  "use strict";
343161
343206
  Object.defineProperty(exports2, "__esModule", { value: true });
343162
343207
  exports2.GithubStep = void 0;
343208
+ exports2.resolvePrFields = resolvePrFields;
343163
343209
  exports2.enrichPrBodyForAutomation = enrichPrBodyForAutomation;
343164
343210
  exports2.shouldEnableAutomerge = shouldEnableAutomerge;
343165
343211
  exports2.shouldCheckNoDiff = shouldCheckNoDiff;
@@ -343185,8 +343231,10 @@ var require_GithubStep = __commonJS({
343185
343231
  }
343186
343232
  async execute(context3) {
343187
343233
  const replayResult = context3.previousStepResults.replay;
343234
+ const autoVersionResult = context3.previousStepResults.autoVersion;
343188
343235
  const skipCommit = this.config.skipCommit ?? this.deriveSkipCommit(replayResult);
343189
343236
  const replayConflictInfo = this.config.replayConflictInfo ?? this.deriveReplayConflictInfo(replayResult);
343237
+ const resolvedPrFields = this.resolvePrFields(autoVersionResult);
343190
343238
  try {
343191
343239
  this.logger.debug("Starting GitHub self-hosted flow in directory: " + this.outputDir);
343192
343240
  const repository = github_1.ClonedRepository.createAtPath(this.outputDir);
@@ -343200,9 +343248,9 @@ var require_GithubStep = __commonJS({
343200
343248
  const mode = this.config.mode;
343201
343249
  switch (mode) {
343202
343250
  case "pull-request":
343203
- return await this.executePullRequestMode(repository, newPrBranch, skipCommit, replayConflictInfo, replayResult);
343251
+ return await this.executePullRequestMode(repository, newPrBranch, skipCommit, replayConflictInfo, replayResult, resolvedPrFields);
343204
343252
  case "push":
343205
- return await this.executePushMode(repository);
343253
+ return await this.executePushMode(repository, resolvedPrFields);
343206
343254
  default: {
343207
343255
  const exhaustive = mode;
343208
343256
  throw new Error(`Unexpected GitHub mode: ${String(exhaustive)}`);
@@ -343218,7 +343266,7 @@ var require_GithubStep = __commonJS({
343218
343266
  };
343219
343267
  }
343220
343268
  }
343221
- async executePullRequestMode(repository, newPrBranch, skipCommit, replayConflictInfo, replayResult) {
343269
+ async executePullRequestMode(repository, newPrBranch, skipCommit, replayConflictInfo, replayResult, resolved) {
343222
343270
  const baseBranch = this.config.branch ?? await repository.getDefaultBranch();
343223
343271
  const octokit = new rest_1.Octokit({ auth: this.config.token });
343224
343272
  const { owner, repo } = (0, github_1.parseRepository)(this.config.uri);
@@ -343245,7 +343293,7 @@ var require_GithubStep = __commonJS({
343245
343293
  switch (branchAction) {
343246
343294
  case "replay-branch":
343247
343295
  if (shouldPushGenerationBaseTag(replayResult)) {
343248
- generationBaseSha = await (0, createReplayBranch_1.createReplayBranch)(repository, prBranch, this.config.commitMessage, replayConflictInfo, this.logger);
343296
+ generationBaseSha = await (0, createReplayBranch_1.createReplayBranch)(repository, prBranch, resolved.commitMessage, replayConflictInfo, this.logger);
343249
343297
  } else {
343250
343298
  await repository.createBranchFromHead(prBranch);
343251
343299
  }
@@ -343264,8 +343312,7 @@ var require_GithubStep = __commonJS({
343264
343312
  if (!skipCommit) {
343265
343313
  await this.ensureFernignore();
343266
343314
  this.logger.debug("Committing changes...");
343267
- const finalCommitMessage2 = this.config.commitMessage ?? "SDK Generation";
343268
- await repository.commitAllChanges(finalCommitMessage2);
343315
+ await repository.commitAllChanges(resolved.commitMessage);
343269
343316
  this.logger.debug(`Committed changes to local copy of GitHub repository at ${this.outputDir}`);
343270
343317
  }
343271
343318
  if (shouldCheckNoDiff(this.config)) {
@@ -343305,13 +343352,12 @@ var require_GithubStep = __commonJS({
343305
343352
  }
343306
343353
  }
343307
343354
  }
343308
- const finalCommitMessage = this.config.commitMessage ?? "SDK Generation";
343309
343355
  const headSha = await repository.getHeadSha();
343310
- const changelogUrl = this.config.changelogEntry ? `https://github.com/${this.config.uri}/blob/${headSha}/changelog.md` : void 0;
343311
- const { prTitle, prBody } = (0, parseCommitMessage_1.parseCommitMessageForPR)(finalCommitMessage, this.config.changelogEntry, this.config.prDescription, this.config.versionBumpReason, this.config.previousVersion, this.config.newVersion, this.config.versionBump, changelogUrl);
343356
+ const changelogUrl = resolved.changelogEntry ? `https://github.com/${this.config.uri}/blob/${headSha}/changelog.md` : void 0;
343357
+ const { prTitle, prBody } = (0, parseCommitMessage_1.parseCommitMessageForPR)(resolved.commitMessage, resolved.changelogEntry, resolved.prDescription, resolved.versionBumpReason, resolved.previousVersion, resolved.newVersion, resolved.versionBump, changelogUrl);
343312
343358
  const replaySection = (0, replay_summary_1.formatReplayPrBody)(replayResult, { branchName: prBranch, repoUri: this.config.uri });
343313
343359
  let enrichedBody = replaySection != null ? prBody + "\n\n---\n\n" + replaySection : prBody;
343314
- enrichedBody = enrichPrBodyForAutomation(enrichedBody, this.config);
343360
+ enrichedBody = enrichPrBodyForAutomation(enrichedBody, this.config, resolved);
343315
343361
  if (isUpdatingExistingPR && existingPR != null) {
343316
343362
  this.logger.info(`Updated existing pull request: ${existingPR.htmlUrl}`);
343317
343363
  result.prUrl = existingPR.htmlUrl;
@@ -343342,7 +343388,7 @@ var require_GithubStep = __commonJS({
343342
343388
  this.logger.info(`Created pull request: ${pullRequest.html_url}`);
343343
343389
  result.prUrl = pullRequest.html_url;
343344
343390
  result.prNumber = pullRequest.number;
343345
- if (shouldEnableAutomerge(this.config) && pullRequest.node_id) {
343391
+ if (shouldEnableAutomerge(this.config, resolved) && pullRequest.node_id) {
343346
343392
  try {
343347
343393
  await octokit.graphql(`mutation($pullRequestId: ID!) {
343348
343394
  enablePullRequestAutoMerge(input: {
@@ -343367,7 +343413,7 @@ var require_GithubStep = __commonJS({
343367
343413
  }
343368
343414
  return result;
343369
343415
  }
343370
- async executePushMode(repository) {
343416
+ async executePushMode(repository, resolved) {
343371
343417
  const baseBranch = this.config.branch ?? await repository.getDefaultBranch();
343372
343418
  if (this.config.branch != null) {
343373
343419
  this.logger.debug(`Checking out branch ${this.config.branch}`);
@@ -343375,8 +343421,7 @@ var require_GithubStep = __commonJS({
343375
343421
  }
343376
343422
  await this.ensureFernignore();
343377
343423
  this.logger.debug("Committing changes...");
343378
- const finalCommitMessage = this.config.commitMessage ?? "SDK Generation";
343379
- await repository.commitAllChanges(finalCommitMessage);
343424
+ await repository.commitAllChanges(resolved.commitMessage);
343380
343425
  this.logger.debug(`Committed changes to local copy of GitHub repository at ${this.outputDir}`);
343381
343426
  if (shouldCheckNoDiff(this.config)) {
343382
343427
  const noDiff = await repository.treeHashEquals(`origin/${baseBranch}`);
@@ -343439,15 +343484,34 @@ var require_GithubStep = __commonJS({
343439
343484
  }
343440
343485
  return void 0;
343441
343486
  }
343487
+ resolvePrFields(autoVersion) {
343488
+ return resolvePrFields(this.config, autoVersion);
343489
+ }
343442
343490
  };
343443
343491
  exports2.GithubStep = GithubStep;
343444
- function enrichPrBodyForAutomation(body, config5) {
343492
+ function resolvePrFields(config5, autoVersion) {
343493
+ const autoVersionBreaking = autoVersion?.versionBump === "MAJOR";
343494
+ return {
343495
+ commitMessage: config5.commitMessage ?? autoVersion?.commitMessage ?? "SDK Generation",
343496
+ changelogEntry: config5.changelogEntry ?? autoVersion?.changelogEntry,
343497
+ prDescription: config5.prDescription ?? autoVersion?.prDescription,
343498
+ versionBumpReason: config5.versionBumpReason ?? autoVersion?.versionBumpReason,
343499
+ previousVersion: config5.previousVersion ?? autoVersion?.previousVersion,
343500
+ newVersion: config5.newVersion ?? autoVersion?.version,
343501
+ versionBump: config5.versionBump ?? autoVersion?.versionBump,
343502
+ hasBreakingChanges: config5.hasBreakingChanges ?? autoVersionBreaking,
343503
+ breakingChangesSummary: config5.breakingChangesSummary ?? autoVersion?.prDescription
343504
+ };
343505
+ }
343506
+ function enrichPrBodyForAutomation(body, config5, breaking = {}) {
343445
343507
  if (!config5.automationMode) {
343446
343508
  return body;
343447
343509
  }
343510
+ const hasBreakingChanges = breaking.hasBreakingChanges ?? config5.hasBreakingChanges;
343511
+ const breakingChangesSummary = breaking.breakingChangesSummary ?? config5.breakingChangesSummary;
343448
343512
  let result = body;
343449
- if (config5.hasBreakingChanges && config5.breakingChangesSummary) {
343450
- result += "\n\n---\n\n## \u26A0\uFE0F Breaking Changes\n\nThis release contains breaking changes that require manual review:\n\n" + config5.breakingChangesSummary;
343513
+ if (hasBreakingChanges && breakingChangesSummary) {
343514
+ result += "\n\n---\n\n## \u26A0\uFE0F Breaking Changes\n\nThis release contains breaking changes that require manual review:\n\n" + breakingChangesSummary;
343451
343515
  }
343452
343516
  if (config5.runId) {
343453
343517
  result += `
@@ -343458,8 +343522,9 @@ _Fern Run ID: \`${config5.runId}\`_`;
343458
343522
  }
343459
343523
  return result;
343460
343524
  }
343461
- function shouldEnableAutomerge(config5) {
343462
- return config5.automationMode === true && config5.autoMerge === true && config5.hasBreakingChanges !== true;
343525
+ function shouldEnableAutomerge(config5, breaking = {}) {
343526
+ const hasBreakingChanges = breaking.hasBreakingChanges ?? config5.hasBreakingChanges;
343527
+ return config5.automationMode === true && config5.autoMerge === true && hasBreakingChanges !== true;
343463
343528
  }
343464
343529
  function shouldCheckNoDiff(config5) {
343465
343530
  return config5.skipIfNoDiff === true;
@@ -618177,7 +618242,7 @@ var AccessTokenPosthogManager = class {
618177
618242
  properties: {
618178
618243
  ...event,
618179
618244
  ...event.properties,
618180
- version: "4.90.0-13-g88979a56bb3",
618245
+ version: "4.90.0-14-g871c1a60e90",
618181
618246
  usingAccessToken: true
618182
618247
  }
618183
618248
  });
@@ -618231,7 +618296,7 @@ var UserPosthogManager = class {
618231
618296
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
618232
618297
  event: "CLI",
618233
618298
  properties: {
618234
- version: "4.90.0-13-g88979a56bb3",
618299
+ version: "4.90.0-14-g871c1a60e90",
618235
618300
  ...event,
618236
618301
  ...event.properties,
618237
618302
  usingAccessToken: false,
@@ -835799,7 +835864,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
835799
835864
  var LOGS_FOLDER_NAME = "logs";
835800
835865
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
835801
835866
  function getCliSource() {
835802
- const version7 = "4.90.0-13-g88979a56bb3";
835867
+ const version7 = "4.90.0-14-g871c1a60e90";
835803
835868
  return `cli@${version7}`;
835804
835869
  }
835805
835870
  var DebugLogger = class {
@@ -847550,7 +847615,7 @@ var LegacyDocsPublisher = class {
847550
847615
  previewId,
847551
847616
  disableTemplates: void 0,
847552
847617
  skipUpload,
847553
- cliVersion: "4.90.0-13-g88979a56bb3"
847618
+ cliVersion: "4.90.0-14-g871c1a60e90"
847554
847619
  });
847555
847620
  if (taskContext.getResult() === TaskResult.Failure) {
847556
847621
  return { success: false };
@@ -921588,7 +921653,7 @@ var CliContext = class _CliContext {
921588
921653
  if (false) {
921589
921654
  this.logger.error("CLI_VERSION is not defined");
921590
921655
  }
921591
- return "4.90.0-13-g88979a56bb3";
921656
+ return "4.90.0-14-g871c1a60e90";
921592
921657
  }
921593
921658
  getCliName() {
921594
921659
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.90.0-13-g88979a56bb3",
2
+ "version": "4.90.0-14-g871c1a60e90",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",