@fern-api/fern-api-dev 5.23.3-661-g00511f12e23 → 5.23.3-664-g6ef41bc5988

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 +241 -33
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -422153,30 +422153,30 @@ var require_AutoVersionStep = __commonJS({
422153
422153
  }
422154
422154
  async execute(context3) {
422155
422155
  const prepared = context3.previousStepResults.generationCommit?.preparedReplay;
422156
- if (!prepared) {
422157
- this.logger.info("AutoVersionStep: no replay preparation available (replay uninitialized or prepare failed); skipping.");
422158
- return { executed: true, success: true };
422159
- }
422160
- if (prepared.flow === "skip-application") {
422161
- this.logger.info("AutoVersionStep: replay flow is skip-application; skipping autoversion.");
422162
- return { executed: true, success: true };
422163
- }
422164
- const language = this.config.language;
422165
- const mappedMagicVersion = (0, index_1.mapMagicVersionForLanguage)(index_1.MAGIC_VERSION, language);
422166
- const service = new index_1.AutoVersioningService({ logger: this.toTaskLogger() });
422167
- if (prepared.previousGenerationSha == null) {
422168
- return await this.handleFirstGeneration({ service, language, mappedMagicVersion });
422156
+ if (prepared) {
422157
+ if (prepared.flow === "skip-application") {
422158
+ this.logger.info("AutoVersionStep: replay flow is skip-application; skipping autoversion.");
422159
+ return { executed: true, success: true };
422160
+ }
422161
+ const language = this.config.language;
422162
+ const mappedMagicVersion = (0, index_1.mapMagicVersionForLanguage)(index_1.MAGIC_VERSION, language);
422163
+ const service = new index_1.AutoVersioningService({ logger: this.toTaskLogger() });
422164
+ if (prepared.previousGenerationSha == null) {
422165
+ return await this.handleFirstGeneration({ service, language, mappedMagicVersion, commit: true });
422166
+ }
422167
+ return await this.handleNormalFlow({
422168
+ prepared,
422169
+ service,
422170
+ language,
422171
+ mappedMagicVersion,
422172
+ previousGenerationSha: prepared.previousGenerationSha
422173
+ });
422169
422174
  }
422170
- return await this.handleNormalFlow({
422171
- prepared,
422172
- service,
422173
- language,
422174
- mappedMagicVersion,
422175
- previousGenerationSha: prepared.previousGenerationSha
422176
- });
422175
+ this.logger.info("AutoVersionStep: running in non-replay mode (git diff HEAD).");
422176
+ return await this.handleNonReplayFlow();
422177
422177
  }
422178
422178
  async handleFirstGeneration(params2) {
422179
- const { service, language, mappedMagicVersion } = params2;
422179
+ const { service, language, mappedMagicVersion, commit } = params2;
422180
422180
  const initialVersion = this.config.baseVersion ?? (mappedMagicVersion.startsWith("v") ? "v0.0.1" : "0.0.1");
422181
422181
  if (!(0, index_1.isValidSemver)(initialVersion)) {
422182
422182
  const errorMessage = `AutoVersionStep: baseVersion ${JSON.stringify(initialVersion)} is not a valid semver string (expected e.g. "1.2.3" or "v1.2.3"). Refusing to run to avoid shell injection into the placeholder-rewrite step.`;
@@ -422193,7 +422193,7 @@ var require_AutoVersionStep = __commonJS({
422193
422193
  await service.addGoMajorVersionSuffix(this.outputDir, initialVersion);
422194
422194
  }
422195
422195
  const commitMessage = this.brandMessage("Initial SDK generation");
422196
- const commitSha = this.commitAutoversion(commitMessage);
422196
+ const commitSha = commit ? this.commitAutoversion(commitMessage) : void 0;
422197
422197
  return {
422198
422198
  executed: true,
422199
422199
  success: true,
@@ -422212,7 +422212,7 @@ var require_AutoVersionStep = __commonJS({
422212
422212
  baseVersion: this.config.baseVersion
422213
422213
  });
422214
422214
  if (previousVersion == null) {
422215
- return await this.handleFirstGeneration({ service, language, mappedMagicVersion });
422215
+ return await this.handleFirstGeneration({ service, language, mappedMagicVersion, commit: true });
422216
422216
  }
422217
422217
  if (rawDiff.trim().length === 0) {
422218
422218
  this.logger.info(`AutoVersionStep: empty diff between generations; rewriting placeholder to ${previousVersion}.`);
@@ -422283,6 +422283,94 @@ var require_AutoVersionStep = __commonJS({
422283
422283
  analysis
422284
422284
  });
422285
422285
  }
422286
+ /**
422287
+ * Non-replay autoversion: diffs HEAD (committed SDK) vs the working tree
422288
+ * (freshly generated files). Does NOT commit — GithubStep will commit all
422289
+ * changes (including the rewritten placeholder) in a single generation commit.
422290
+ */
422291
+ async handleNonReplayFlow() {
422292
+ const language = this.config.language;
422293
+ const mappedMagicVersion = (0, index_1.mapMagicVersionForLanguage)(index_1.MAGIC_VERSION, language);
422294
+ const service = new index_1.AutoVersioningService({ logger: this.toTaskLogger() });
422295
+ const rawDiff = this.gitDiffHead();
422296
+ const previousVersion = await this.resolvePreviousVersionNonReplay({
422297
+ service,
422298
+ rawDiff,
422299
+ mappedMagicVersion,
422300
+ baseVersion: this.config.baseVersion
422301
+ });
422302
+ if (previousVersion == null) {
422303
+ return await this.handleFirstGeneration({ service, language, mappedMagicVersion, commit: false });
422304
+ }
422305
+ if (rawDiff.trim().length === 0) {
422306
+ this.logger.info(`AutoVersionStep: empty diff (non-replay); rewriting placeholder to ${previousVersion}.`);
422307
+ return await this.finalizeNoChangeNonReplay({
422308
+ service,
422309
+ language,
422310
+ mappedMagicVersion,
422311
+ previousVersion,
422312
+ reason: "no diff between generations"
422313
+ });
422314
+ }
422315
+ const cleanedDiff = service.cleanDiffForAI(rawDiff, mappedMagicVersion);
422316
+ const rawBytes = Buffer.byteLength(rawDiff, "utf-8");
422317
+ const cleanedBytes = Buffer.byteLength(cleanedDiff, "utf-8");
422318
+ this.logger.debug(`AutoVersionStep (non-replay): 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)`);
422319
+ if (cleanedDiff.trim().length === 0) {
422320
+ this.logger.info(`AutoVersionStep: cleaned diff empty (non-replay); rewriting placeholder to ${previousVersion}.`);
422321
+ return await this.finalizeNoChangeNonReplay({
422322
+ service,
422323
+ language,
422324
+ mappedMagicVersion,
422325
+ previousVersion,
422326
+ reason: "no semantic changes"
422327
+ });
422328
+ }
422329
+ if (cleanedBytes > index_1.MAX_RAW_DIFF_BYTES) {
422330
+ this.logger.warn(`AutoVersionStep (non-replay): diff too large (${(0, index_1.formatSizeKB)(cleanedBytes)}KB). Falling back to PATCH.`);
422331
+ return await this.finalizeWithBumpNonReplay({
422332
+ service,
422333
+ language,
422334
+ mappedMagicVersion,
422335
+ previousVersion,
422336
+ analysis: { versionBump: "PATCH", message: this.brandMessage("SDK regeneration") }
422337
+ });
422338
+ }
422339
+ let analysis;
422340
+ try {
422341
+ if (this.config.ai == null && this.config.fernToken != null) {
422342
+ analysis = await this.analyzeViaFaiService(cleanedDiff, language, previousVersion);
422343
+ } else {
422344
+ const chunks = service.chunkDiff(cleanedDiff, index_1.MAX_AI_DIFF_BYTES);
422345
+ const cappedChunks = chunks.slice(0, index_1.MAX_CHUNKS);
422346
+ const skippedChunks = chunks.length - cappedChunks.length;
422347
+ if (chunks.length > 1) {
422348
+ this.logger.info(`AutoVersionStep (non-replay): split diff into ${chunks.length} chunks` + (skippedChunks > 0 ? ` (capped at ${index_1.MAX_CHUNKS}, skipping ${skippedChunks})` : ""));
422349
+ }
422350
+ analysis = cappedChunks.length <= 1 ? await this.analyzeSingle(cleanedDiff, language, previousVersion) : await this.analyzeChunks(cappedChunks, language, previousVersion);
422351
+ }
422352
+ } catch (error50) {
422353
+ this.logger.warn(`AutoVersionStep (non-replay): FAI analysis failed (${String(error50)}); falling back to PATCH bump.`);
422354
+ analysis = { versionBump: "PATCH", message: this.brandMessage("SDK regeneration") };
422355
+ }
422356
+ if (analysis == null) {
422357
+ this.logger.info(`AutoVersionStep (non-replay): FAI returned NO_CHANGE; rewriting placeholder to ${previousVersion}.`);
422358
+ return await this.finalizeNoChangeNonReplay({
422359
+ service,
422360
+ language,
422361
+ mappedMagicVersion,
422362
+ previousVersion,
422363
+ reason: "FAI returned NO_CHANGE"
422364
+ });
422365
+ }
422366
+ return await this.finalizeWithBumpNonReplay({
422367
+ service,
422368
+ language,
422369
+ mappedMagicVersion,
422370
+ previousVersion,
422371
+ analysis
422372
+ });
422373
+ }
422286
422374
  /**
422287
422375
  * Terminal path for runs that determine no semver bump is needed. The
422288
422376
  * current working tree still contains `0.0.0-fern-placeholder` from this
@@ -422340,6 +422428,94 @@ var require_AutoVersionStep = __commonJS({
422340
422428
  commitSha
422341
422429
  };
422342
422430
  }
422431
+ /**
422432
+ * Non-replay variant of finalizeNoChange. Rewrites the placeholder to
422433
+ * `previousVersion` but does NOT commit — GithubStep handles the commit.
422434
+ */
422435
+ async finalizeNoChangeNonReplay(params2) {
422436
+ const { service, language, mappedMagicVersion, previousVersion, reason } = params2;
422437
+ if (!(0, index_1.isValidSemver)(previousVersion)) {
422438
+ const errorMessage = `AutoVersionStep: resolved previousVersion ${JSON.stringify(previousVersion)} is not a valid semver string. Refusing to rewrite placeholder to avoid shell injection.`;
422439
+ this.logger.error(errorMessage);
422440
+ return { executed: true, success: false, errorMessage };
422441
+ }
422442
+ await service.replaceMagicVersion(this.outputDir, mappedMagicVersion, previousVersion);
422443
+ if (language === "go") {
422444
+ await service.addGoMajorVersionSuffix(this.outputDir, previousVersion);
422445
+ }
422446
+ const commitMessage = this.brandMessage(`SDK regeneration (no semver change: ${reason})`);
422447
+ return {
422448
+ executed: true,
422449
+ success: true,
422450
+ version: previousVersion,
422451
+ previousVersion,
422452
+ versionBump: "NO_CHANGE",
422453
+ commitMessage
422454
+ };
422455
+ }
422456
+ /**
422457
+ * Non-replay variant of finalizeWithBump. Rewrites the placeholder to
422458
+ * the bumped version but does NOT commit — GithubStep handles the commit.
422459
+ */
422460
+ async finalizeWithBumpNonReplay(params2) {
422461
+ const { service, language, mappedMagicVersion, previousVersion, analysis } = params2;
422462
+ const newVersion = (0, index_1.incrementVersion)(previousVersion, analysis.versionBump);
422463
+ this.logger.info(`AutoVersionStep (non-replay): ${analysis.versionBump} bump: ${previousVersion} \u2192 ${newVersion}`);
422464
+ await service.replaceMagicVersion(this.outputDir, mappedMagicVersion, newVersion);
422465
+ if (language === "go") {
422466
+ await service.addGoMajorVersionSuffix(this.outputDir, newVersion);
422467
+ }
422468
+ if (analysis.changelogEntry && analysis.changelogEntry.trim().length > 0) {
422469
+ await this.prependChangelogEntry({ version: newVersion, entry: analysis.changelogEntry });
422470
+ }
422471
+ return {
422472
+ executed: true,
422473
+ success: true,
422474
+ version: newVersion,
422475
+ commitMessage: analysis.message,
422476
+ changelogEntry: analysis.changelogEntry,
422477
+ previousVersion,
422478
+ versionBump: analysis.versionBump,
422479
+ prDescription: analysis.prDescription,
422480
+ versionBumpReason: analysis.versionBumpReason
422481
+ };
422482
+ }
422483
+ /**
422484
+ * Resolves the previous version for non-replay mode. Reads HEAD:.fern/metadata.json
422485
+ * (not HEAD~1, since no generation commit exists yet) as the primary fallback.
422486
+ */
422487
+ async resolvePreviousVersionNonReplay(params2) {
422488
+ const { service, rawDiff, mappedMagicVersion, baseVersion } = params2;
422489
+ if (baseVersion != null && (0, index_1.isValidSemver)(baseVersion)) {
422490
+ this.logger.debug(`AutoVersionStep (non-replay): previous version from pipeline baseVersion: ${baseVersion}`);
422491
+ return this.normalizeVersionPrefix(baseVersion, mappedMagicVersion);
422492
+ }
422493
+ try {
422494
+ const extracted = service.extractPreviousVersion(rawDiff, mappedMagicVersion);
422495
+ if (extracted != null) {
422496
+ this.logger.debug(`AutoVersionStep (non-replay): previous version from diff: ${extracted}`);
422497
+ return extracted;
422498
+ }
422499
+ } catch (error50) {
422500
+ if (!(error50 instanceof index_1.AutoVersioningException) || !error50.magicVersionAbsent) {
422501
+ throw error50;
422502
+ }
422503
+ this.logger.info("AutoVersionStep (non-replay): magic version not in diff; trying metadata + git tags.");
422504
+ }
422505
+ const metadataVersion = this.readVersionFromMetadataAtHead();
422506
+ if (metadataVersion != null) {
422507
+ return this.normalizeVersionPrefix(metadataVersion, mappedMagicVersion);
422508
+ }
422509
+ try {
422510
+ const tagVersion = await service.getLatestVersionFromGitTags(this.outputDir);
422511
+ if (tagVersion != null) {
422512
+ return this.normalizeVersionPrefix(tagVersion, mappedMagicVersion);
422513
+ }
422514
+ } catch (error50) {
422515
+ this.logger.debug(`AutoVersionStep (non-replay): git-tags fallback failed (${String(error50)}); ignoring.`);
422516
+ }
422517
+ return null;
422518
+ }
422343
422519
  async resolvePreviousVersion(params2) {
422344
422520
  const { service, rawDiff, mappedMagicVersion, baseVersion } = params2;
422345
422521
  if (baseVersion != null && (0, index_1.isValidSemver)(baseVersion)) {
@@ -422389,6 +422565,42 @@ var require_AutoVersionStep = __commonJS({
422389
422565
  const stripped = version7.startsWith("v") ? version7.slice(1) : version7;
422390
422566
  return mappedMagicVersion.startsWith("v") ? `v${stripped}` : stripped;
422391
422567
  }
422568
+ /**
422569
+ * Reads the sdkVersion from the committed (HEAD) .fern/metadata.json.
422570
+ * Used by the non-replay path where no generation commit exists yet,
422571
+ * so HEAD is the unmodified SDK repository.
422572
+ */
422573
+ readVersionFromMetadataAtHead() {
422574
+ try {
422575
+ const output2 = (0, child_process_1.execFileSync)("git", ["show", "HEAD:.fern/metadata.json"], {
422576
+ cwd: this.outputDir,
422577
+ encoding: "utf-8",
422578
+ stdio: "pipe"
422579
+ });
422580
+ const parsed = JSON.parse(output2);
422581
+ return parsed.sdkVersion ?? void 0;
422582
+ } catch (error50) {
422583
+ this.logger.debug(`AutoVersionStep: failed to read HEAD:.fern/metadata.json (${String(error50)})`);
422584
+ return void 0;
422585
+ }
422586
+ }
422587
+ /**
422588
+ * Computes a diff between HEAD (committed SDK) and the working tree (new
422589
+ * generation). Marks untracked files as intent-to-add so they appear in
422590
+ * the diff, matching LocalTaskHandler.generateDiffFile() behavior.
422591
+ */
422592
+ gitDiffHead() {
422593
+ (0, child_process_1.execFileSync)("git", ["add", "-N", "."], {
422594
+ cwd: this.outputDir,
422595
+ stdio: "pipe"
422596
+ });
422597
+ return (0, child_process_1.execFileSync)("git", ["diff", "HEAD", "--", ".", ":(exclude).fern/metadata.json"], {
422598
+ cwd: this.outputDir,
422599
+ encoding: "utf-8",
422600
+ stdio: "pipe",
422601
+ maxBuffer: 256 * 1024 * 1024
422602
+ });
422603
+ }
422392
422604
  gitDiff(from4, to10) {
422393
422605
  return (0, child_process_1.execFileSync)("git", ["diff", from4, to10, "--", ".", ":(exclude).fern/metadata.json"], {
422394
422606
  cwd: this.outputDir,
@@ -438844,10 +439056,6 @@ var require_PostGenerationPipeline = __commonJS({
438844
439056
  this.logger.warn(`Replay is not supported with GitHub ${config5.github.mode} mode. Disabling replay to prevent push to base branch.`);
438845
439057
  replayEnabled = false;
438846
439058
  }
438847
- if (autoVersionEnabled && !replayEnabled) {
438848
- this.logger.warn("AutoVersion requires Replay to be enabled. Disabling AutoVersion for this run.");
438849
- autoVersionEnabled = false;
438850
- }
438851
439059
  if (replayEnabled && config5.replay != null) {
438852
439060
  this.steps.push(new GenerationCommitStep_1.GenerationCommitStep(config5.outputDir, this.logger, { enabled: true, skipApplication: config5.replay.skipApplication }, config5.cliVersion, config5.generatorVersions));
438853
439061
  }
@@ -669270,7 +669478,7 @@ var AccessTokenPosthogManager = class {
669270
669478
  properties: {
669271
669479
  ...event,
669272
669480
  ...event.properties,
669273
- version: "5.23.3-661-g00511f12e23",
669481
+ version: "5.23.3-664-g6ef41bc5988",
669274
669482
  usingAccessToken: true,
669275
669483
  ...getRunIdProperties()
669276
669484
  }
@@ -669334,7 +669542,7 @@ var UserPosthogManager = class {
669334
669542
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
669335
669543
  event: "CLI",
669336
669544
  properties: {
669337
- version: "5.23.3-661-g00511f12e23",
669545
+ version: "5.23.3-664-g6ef41bc5988",
669338
669546
  ...event,
669339
669547
  ...event.properties,
669340
669548
  usingAccessToken: false,
@@ -861072,7 +861280,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
861072
861280
  var LOGS_FOLDER_NAME = "logs";
861073
861281
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
861074
861282
  function getCliSource() {
861075
- const version7 = "5.23.3-661-g00511f12e23";
861283
+ const version7 = "5.23.3-664-g6ef41bc5988";
861076
861284
  return `cli@${version7}`;
861077
861285
  }
861078
861286
  var DebugLogger = class {
@@ -892164,7 +892372,7 @@ var LegacyDocsPublisher = class {
892164
892372
  previewId,
892165
892373
  disableTemplates: void 0,
892166
892374
  skipUpload,
892167
- cliVersion: "5.23.3-661-g00511f12e23",
892375
+ cliVersion: "5.23.3-664-g6ef41bc5988",
892168
892376
  loginCommand: "fern auth login"
892169
892377
  });
892170
892378
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -957354,7 +957562,7 @@ function getAutomationContextFromEnv() {
957354
957562
  config_branch: process.env.FERN_CONFIG_BRANCH,
957355
957563
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
957356
957564
  trigger: process.env.GITHUB_EVENT_NAME,
957357
- cli_version: "5.23.3-661-g00511f12e23"
957565
+ cli_version: "5.23.3-664-g6ef41bc5988"
957358
957566
  };
957359
957567
  }
957360
957568
  function isAutomationMode() {
@@ -958180,7 +958388,7 @@ var CliContext = class _CliContext {
958180
958388
  if (false) {
958181
958389
  this.logger.error("CLI_VERSION is not defined");
958182
958390
  }
958183
- return "5.23.3-661-g00511f12e23";
958391
+ return "5.23.3-664-g6ef41bc5988";
958184
958392
  }
958185
958393
  getCliName() {
958186
958394
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.23.3-661-g00511f12e23",
2
+ "version": "5.23.3-664-g6ef41bc5988",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",