@fern-api/fern-api-dev 5.23.3-1768-g87d295561fa → 5.23.3-1773-g28a9626f350

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 +263 -44
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -100959,8 +100959,8 @@ var require_graceful_fs = __commonJS({
100959
100959
  }
100960
100960
  }
100961
100961
  var fs$writeFile = fs35.writeFile;
100962
- fs35.writeFile = writeFile102;
100963
- function writeFile102(path120, data2, options2, cb) {
100962
+ fs35.writeFile = writeFile103;
100963
+ function writeFile103(path120, data2, options2, cb) {
100964
100964
  if (typeof options2 === "function")
100965
100965
  cb = options2, options2 = null;
100966
100966
  return go$writeFile(path120, data2, options2, cb);
@@ -460369,13 +460369,13 @@ async function removeInvalidAiExamples({ sourceFilePath, context: context3 }) {
460369
460369
  }
460370
460370
  }
460371
460371
  }
460372
- const { writeFile: writeFile102 } = await import("fs/promises");
460372
+ const { writeFile: writeFile103 } = await import("fs/promises");
460373
460373
  const yamlContent = index_vite_proxy_tmp_default.dump(parsed, {
460374
460374
  indent: 2,
460375
460375
  lineWidth: -1,
460376
460376
  noRefs: true
460377
460377
  });
460378
- await writeFile102(overrideFilePath, yamlContent, "utf-8");
460378
+ await writeFile103(overrideFilePath, yamlContent, "utf-8");
460379
460379
  context3.logger.info(`Removed ${validationResult.invalidCount} invalid AI examples from ai_examples_override.yml`);
460380
460380
  return {
460381
460381
  removedCount: validationResult.invalidCount,
@@ -483704,8 +483704,8 @@ var require_graceful_fs2 = __commonJS({
483704
483704
  }
483705
483705
  }
483706
483706
  var fs$writeFile = fs35.writeFile;
483707
- fs35.writeFile = writeFile102;
483708
- function writeFile102(path120, data2, options2, cb) {
483707
+ fs35.writeFile = writeFile103;
483708
+ function writeFile103(path120, data2, options2, cb) {
483709
483709
  if (typeof options2 === "function")
483710
483710
  cb = options2, options2 = null;
483711
483711
  return go$writeFile(path120, data2, options2, cb);
@@ -568242,6 +568242,7 @@ var require_VersionUtils = __commonJS({
568242
568242
  exports2.maxVersionBump = maxVersionBump3;
568243
568243
  exports2.isAutoVersion = isAutoVersion5;
568244
568244
  exports2.isValidSemver = isValidSemver;
568245
+ exports2.isPlaceholderVersion = isPlaceholderVersion2;
568245
568246
  exports2.incrementVersion = incrementVersion;
568246
568247
  exports2.extractPreviousVersionFromDiffLine = extractPreviousVersionFromDiffLine;
568247
568248
  var semver_1 = __importDefault2(require_semver2());
@@ -568321,11 +568322,18 @@ var require_VersionUtils = __commonJS({
568321
568322
  function isValidSemver(version7) {
568322
568323
  return SEMVER_PATTERN.test(version7);
568323
568324
  }
568325
+ function isPlaceholderVersion2(version7) {
568326
+ const withoutPrefix = version7.startsWith("v") ? version7.slice(1) : version7;
568327
+ return withoutPrefix === exports2.MAGIC_VERSION || withoutPrefix.startsWith(`${exports2.MAGIC_VERSION}.`) || withoutPrefix === exports2.MAGIC_VERSION_PYTHON || withoutPrefix.startsWith(`${exports2.MAGIC_VERSION_PYTHON}.`);
568328
+ }
568324
568329
  function incrementVersion(currentVersion, versionBump) {
568325
568330
  const matcher = currentVersion.match(SEMVER_PATTERN);
568326
568331
  if (!matcher) {
568327
568332
  throw new AutoVersioningService_js_1.AutoVersioningException("Invalid semantic version format: " + currentVersion);
568328
568333
  }
568334
+ if (isPlaceholderVersion2(currentVersion)) {
568335
+ throw new AutoVersioningService_js_1.AutoVersioningException("Refusing to increment the magic placeholder version: " + currentVersion + ". A real previous version must be resolved first.");
568336
+ }
568329
568337
  const prefix2 = matcher[1] ?? "";
568330
568338
  const versionWithoutPrefix = currentVersion.slice(prefix2.length);
568331
568339
  const preRelease = matcher[5];
@@ -568366,7 +568374,7 @@ var require_autoversion = __commonJS({
568366
568374
  "../../generator-cli/lib/autoversion/index.js"(exports2) {
568367
568375
  "use strict";
568368
568376
  Object.defineProperty(exports2, "__esModule", { value: true });
568369
- exports2.VersionBump = exports2.maxVersionBump = exports2.mapMagicVersionForLanguage = exports2.MAX_RAW_DIFF_BYTES = exports2.MAX_CHUNKS = exports2.MAX_AI_DIFF_BYTES = exports2.MAGIC_VERSION_PYTHON = exports2.MAGIC_VERSION = exports2.isValidSemver = exports2.isAutoVersion = exports2.incrementVersion = exports2.extractPreviousVersionFromDiffLine = exports2.extractLanguageFromGeneratorName = exports2.AUTO_VERSION = exports2.prependChangelogBlock = exports2.changelogContainsVersion = exports2.formatSizeKB = exports2.countFilesInDiff = exports2.AutoVersioningService = exports2.AutoVersioningException = exports2.AutoVersioningCache = void 0;
568377
+ exports2.VersionBump = exports2.maxVersionBump = exports2.mapMagicVersionForLanguage = exports2.MAX_RAW_DIFF_BYTES = exports2.MAX_CHUNKS = exports2.MAX_AI_DIFF_BYTES = exports2.MAGIC_VERSION_PYTHON = exports2.MAGIC_VERSION = exports2.isValidSemver = exports2.isPlaceholderVersion = exports2.isAutoVersion = exports2.incrementVersion = exports2.extractPreviousVersionFromDiffLine = exports2.extractLanguageFromGeneratorName = exports2.AUTO_VERSION = exports2.prependChangelogBlock = exports2.changelogContainsVersion = exports2.formatSizeKB = exports2.countFilesInDiff = exports2.AutoVersioningService = exports2.AutoVersioningException = exports2.AutoVersioningCache = void 0;
568370
568378
  var AutoVersioningCache_js_1 = require_AutoVersioningCache();
568371
568379
  Object.defineProperty(exports2, "AutoVersioningCache", { enumerable: true, get: function() {
568372
568380
  return AutoVersioningCache_js_1.AutoVersioningCache;
@@ -568407,6 +568415,9 @@ var require_autoversion = __commonJS({
568407
568415
  Object.defineProperty(exports2, "isAutoVersion", { enumerable: true, get: function() {
568408
568416
  return VersionUtils_js_1.isAutoVersion;
568409
568417
  } });
568418
+ Object.defineProperty(exports2, "isPlaceholderVersion", { enumerable: true, get: function() {
568419
+ return VersionUtils_js_1.isPlaceholderVersion;
568420
+ } });
568410
568421
  Object.defineProperty(exports2, "isValidSemver", { enumerable: true, get: function() {
568411
568422
  return VersionUtils_js_1.isValidSemver;
568412
568423
  } });
@@ -569237,7 +569248,8 @@ var require_AutoVersionStep = __commonJS({
569237
569248
  }
569238
569249
  async handleFirstGeneration(params2) {
569239
569250
  const { service, language, mappedMagicVersion, commit } = params2;
569240
- const initialVersion = this.config.baseVersion ?? (mappedMagicVersion.startsWith("v") ? "v0.0.1" : "0.0.1");
569251
+ const configuredBaseVersion = this.usableVersion(this.config.baseVersion, "baseVersion");
569252
+ const initialVersion = configuredBaseVersion ?? (mappedMagicVersion.startsWith("v") ? "v0.0.1" : "0.0.1");
569241
569253
  if (!(0, index_1.isValidSemver)(initialVersion)) {
569242
569254
  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.`;
569243
569255
  this.logger.error(errorMessage);
@@ -569547,12 +569559,13 @@ var require_AutoVersionStep = __commonJS({
569547
569559
  */
569548
569560
  async resolvePreviousVersionNonReplay(params2) {
569549
569561
  const { service, rawDiff, mappedMagicVersion, baseVersion } = params2;
569550
- if (baseVersion != null && (0, index_1.isValidSemver)(baseVersion)) {
569551
- this.logger.debug(`AutoVersionStep (non-replay): previous version from pipeline baseVersion: ${baseVersion}`);
569552
- return this.normalizeVersionPrefix(baseVersion, mappedMagicVersion);
569562
+ const usableBaseVersion = this.usableVersion(baseVersion, "baseVersion");
569563
+ if (usableBaseVersion != null && (0, index_1.isValidSemver)(usableBaseVersion)) {
569564
+ this.logger.debug(`AutoVersionStep (non-replay): previous version from pipeline baseVersion: ${usableBaseVersion}`);
569565
+ return this.normalizeVersionPrefix(usableBaseVersion, mappedMagicVersion);
569553
569566
  }
569554
569567
  try {
569555
- const extracted = service.extractPreviousVersion(rawDiff, mappedMagicVersion);
569568
+ const extracted = this.usableVersion(service.extractPreviousVersion(rawDiff, mappedMagicVersion) ?? void 0, "diff");
569556
569569
  if (extracted != null) {
569557
569570
  this.logger.debug(`AutoVersionStep (non-replay): previous version from diff: ${extracted}`);
569558
569571
  return extracted;
@@ -569563,12 +569576,12 @@ var require_AutoVersionStep = __commonJS({
569563
569576
  }
569564
569577
  this.logger.info("AutoVersionStep (non-replay): magic version not in diff; trying metadata + git tags.");
569565
569578
  }
569566
- const metadataVersion = this.readVersionFromMetadataAtHead();
569579
+ const metadataVersion = this.usableVersion(this.readVersionFromMetadataAtHead(), "metadata.json");
569567
569580
  if (metadataVersion != null) {
569568
569581
  return this.normalizeVersionPrefix(metadataVersion, mappedMagicVersion);
569569
569582
  }
569570
569583
  try {
569571
- const tagVersion = await service.getLatestVersionFromGitTags(this.outputDir);
569584
+ const tagVersion = this.usableVersion(await service.getLatestVersionFromGitTags(this.outputDir) ?? void 0, "git tags");
569572
569585
  if (tagVersion != null) {
569573
569586
  return this.normalizeVersionPrefix(tagVersion, mappedMagicVersion);
569574
569587
  }
@@ -569579,12 +569592,13 @@ var require_AutoVersionStep = __commonJS({
569579
569592
  }
569580
569593
  async resolvePreviousVersion(params2) {
569581
569594
  const { service, rawDiff, mappedMagicVersion, baseVersion } = params2;
569582
- if (baseVersion != null && (0, index_1.isValidSemver)(baseVersion)) {
569583
- this.logger.debug(`AutoVersionStep: previous version from pipeline baseVersion: ${baseVersion}`);
569584
- return this.normalizeVersionPrefix(baseVersion, mappedMagicVersion);
569595
+ const usableBaseVersion = this.usableVersion(baseVersion, "baseVersion");
569596
+ if (usableBaseVersion != null && (0, index_1.isValidSemver)(usableBaseVersion)) {
569597
+ this.logger.debug(`AutoVersionStep: previous version from pipeline baseVersion: ${usableBaseVersion}`);
569598
+ return this.normalizeVersionPrefix(usableBaseVersion, mappedMagicVersion);
569585
569599
  }
569586
569600
  try {
569587
- const extracted = service.extractPreviousVersion(rawDiff, mappedMagicVersion);
569601
+ const extracted = this.usableVersion(service.extractPreviousVersion(rawDiff, mappedMagicVersion) ?? void 0, "diff");
569588
569602
  if (extracted != null) {
569589
569603
  this.logger.debug(`AutoVersionStep: previous version from diff: ${extracted}`);
569590
569604
  return extracted;
@@ -569595,12 +569609,12 @@ var require_AutoVersionStep = __commonJS({
569595
569609
  }
569596
569610
  this.logger.info("AutoVersionStep: magic version not found in diff; falling back to metadata + git tags.");
569597
569611
  }
569598
- const metadataVersion = await this.readVersionFromMetadata();
569612
+ const metadataVersion = this.usableVersion(await this.readVersionFromMetadata(), "metadata.json");
569599
569613
  if (metadataVersion != null) {
569600
569614
  return this.normalizeVersionPrefix(metadataVersion, mappedMagicVersion);
569601
569615
  }
569602
569616
  try {
569603
- const tagVersion = await service.getLatestVersionFromGitTags(this.outputDir);
569617
+ const tagVersion = this.usableVersion(await service.getLatestVersionFromGitTags(this.outputDir) ?? void 0, "git tags");
569604
569618
  if (tagVersion != null) {
569605
569619
  return this.normalizeVersionPrefix(tagVersion, mappedMagicVersion);
569606
569620
  }
@@ -569622,6 +569636,25 @@ var require_AutoVersionStep = __commonJS({
569622
569636
  return void 0;
569623
569637
  }
569624
569638
  }
569639
+ /**
569640
+ * Drops candidate previous versions that are the magic placeholder. SDK repos
569641
+ * that derive their published version at release time keep the placeholder
569642
+ * committed, so every resolution source (baseVersion, diff extraction,
569643
+ * metadata.json, git tags) can hand back the sentinel; incrementing it would
569644
+ * emit a mutated placeholder such as `0.0.0-fern-placeholder.0` instead of a
569645
+ * real version. Returning undefined lets the caller fall through to the next
569646
+ * source, and ultimately to the first-generation path.
569647
+ */
569648
+ usableVersion(version7, source2) {
569649
+ if (version7 == null) {
569650
+ return void 0;
569651
+ }
569652
+ if ((0, index_1.isPlaceholderVersion)(version7)) {
569653
+ this.logger.info(`AutoVersionStep: ignoring placeholder version ${version7} from ${source2}; trying the next previous-version source.`);
569654
+ return void 0;
569655
+ }
569656
+ return version7;
569657
+ }
569625
569658
  normalizeVersionPrefix(version7, mappedMagicVersion) {
569626
569659
  const stripped = version7.startsWith("v") ? version7.slice(1) : version7;
569627
569660
  return mappedMagicVersion.startsWith("v") ? `v${stripped}` : stripped;
@@ -626889,7 +626922,7 @@ var require_jsonfile = __commonJS({
626889
626922
  const str2 = stringify5(obj, options2);
626890
626923
  await universalify.fromCallback(fs34.writeFile)(file4, str2, options2);
626891
626924
  }
626892
- var writeFile102 = universalify.fromPromise(_writeFile);
626925
+ var writeFile103 = universalify.fromPromise(_writeFile);
626893
626926
  function writeFileSync9(file4, obj, options2 = {}) {
626894
626927
  const fs34 = options2.fs || _fs;
626895
626928
  const str2 = stringify5(obj, options2);
@@ -626898,7 +626931,7 @@ var require_jsonfile = __commonJS({
626898
626931
  module4.exports = {
626899
626932
  readFile: readFile121,
626900
626933
  readFileSync: readFileSync19,
626901
- writeFile: writeFile102,
626934
+ writeFile: writeFile103,
626902
626935
  writeFileSync: writeFileSync9
626903
626936
  };
626904
626937
  }
@@ -694418,7 +694451,7 @@ var AccessTokenPosthogManager = class {
694418
694451
  properties: {
694419
694452
  ...event,
694420
694453
  ...event.properties,
694421
- version: "5.23.3-1768-g87d295561fa",
694454
+ version: "5.23.3-1773-g28a9626f350",
694422
694455
  usingAccessToken: true,
694423
694456
  ...getRunIdProperties()
694424
694457
  }
@@ -694484,7 +694517,7 @@ var UserPosthogManager = class {
694484
694517
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
694485
694518
  event: "CLI",
694486
694519
  properties: {
694487
- version: "5.23.3-1768-g87d295561fa",
694520
+ version: "5.23.3-1773-g28a9626f350",
694488
694521
  ...event,
694489
694522
  ...event.properties,
694490
694523
  usingAccessToken: false,
@@ -875614,7 +875647,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
875614
875647
  var LOGS_FOLDER_NAME = "logs";
875615
875648
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
875616
875649
  function getCliSource() {
875617
- const version7 = "5.23.3-1768-g87d295561fa";
875650
+ const version7 = "5.23.3-1773-g28a9626f350";
875618
875651
  return `cli@${version7}`;
875619
875652
  }
875620
875653
  var DebugLogger = class {
@@ -908324,7 +908357,7 @@ var LegacyDocsPublisher = class {
908324
908357
  previewId,
908325
908358
  disableTemplates: void 0,
908326
908359
  skipUpload,
908327
- cliVersion: "5.23.3-1768-g87d295561fa",
908360
+ cliVersion: "5.23.3-1773-g28a9626f350",
908328
908361
  loginCommand: "fern auth login"
908329
908362
  });
908330
908363
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -961942,16 +961975,16 @@ var LocalTaskHandler = class {
961942
961975
  }
961943
961976
  let previousVersion;
961944
961977
  try {
961945
- previousVersion = autoVersioningService.extractPreviousVersion(diffContent, mappedMagicVersion);
961978
+ previousVersion = this.usableVersion(autoVersioningService.extractPreviousVersion(diffContent, mappedMagicVersion) ?? void 0, "diff");
961946
961979
  } catch (e2) {
961947
961980
  if (!(e2 instanceof import_autoversion2.AutoVersioningException) || !e2.magicVersionAbsent) {
961948
961981
  throw e2;
961949
961982
  }
961950
961983
  this.context.logger.info(`Magic version not found in diff, trying fallbacks: ${e2}`);
961951
- previousVersion = await this.getVersionFromLocalMetadata();
961984
+ previousVersion = this.usableVersion(await this.getVersionFromLocalMetadata(), "metadata.json");
961952
961985
  if (previousVersion == null) {
961953
961986
  const tagVersion = await autoVersioningService.getLatestVersionFromGitTags(this.absolutePathToLocalOutput);
961954
- previousVersion = this.normalizeVersionPrefix(tagVersion);
961987
+ previousVersion = this.usableVersion(this.normalizeVersionPrefix(tagVersion), "git tags");
961955
961988
  }
961956
961989
  if (previousVersion == null) {
961957
961990
  this.context.logger.info("No git tags found \u2014 treating as new SDK repository");
@@ -961971,10 +962004,10 @@ var LocalTaskHandler = class {
961971
962004
  const cleanedFileCount = (0, import_autoversion2.countFilesInDiff)(cleanedDiff);
961972
962005
  this.context.logger.debug(`Generated diff size: ${rawDiffSizeKB}KB (${diffContent.length} chars), ${rawFileCount} files changed. Cleaned diff size: ${cleanedDiffSizeKB}KB (${cleanedDiff.length} chars), ${cleanedFileCount} files remaining`);
961973
962006
  if (previousVersion == null) {
961974
- previousVersion = await this.getVersionFromLocalMetadata();
962007
+ previousVersion = this.usableVersion(await this.getVersionFromLocalMetadata(), "metadata.json");
961975
962008
  if (previousVersion == null) {
961976
962009
  const rawTagVersion = await autoVersioningService.getLatestVersionFromGitTags(this.absolutePathToLocalOutput);
961977
- const normalizedTag = this.normalizeVersionPrefix(rawTagVersion);
962010
+ const normalizedTag = this.usableVersion(this.normalizeVersionPrefix(rawTagVersion), "git tags");
961978
962011
  if (normalizedTag != null) {
961979
962012
  this.context.logger.info(`No previous version from diff; using git tag: ${normalizedTag}`);
961980
962013
  previousVersion = normalizedTag;
@@ -962244,6 +962277,24 @@ var LocalTaskHandler = class {
962244
962277
  return void 0;
962245
962278
  }
962246
962279
  }
962280
+ /**
962281
+ * Drops candidate previous versions that are the magic placeholder. SDK repos
962282
+ * that derive their published version at release time keep the placeholder
962283
+ * committed, so any resolution source can hand back the sentinel; bumping it
962284
+ * would publish a mutated placeholder rather than a real version. Returning
962285
+ * undefined lets the caller fall through to the next source, and ultimately to
962286
+ * the initial-version path.
962287
+ */
962288
+ usableVersion(version7, source2) {
962289
+ if (version7 == null) {
962290
+ return void 0;
962291
+ }
962292
+ if ((0, import_autoversion2.isPlaceholderVersion)(version7)) {
962293
+ this.context.logger.info(`Ignoring placeholder version ${version7} from ${source2}; trying the next previous-version source.`);
962294
+ return void 0;
962295
+ }
962296
+ return version7;
962297
+ }
962247
962298
  /**
962248
962299
  * Normalizes a version string's `v` prefix to match the convention used by
962249
962300
  * the magic version for this generator's language. Git tags may use `v1.2.3`
@@ -975214,7 +975265,7 @@ function getAutomationContextFromEnv() {
975214
975265
  config_branch: process.env.FERN_CONFIG_BRANCH,
975215
975266
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
975216
975267
  trigger: process.env.GITHUB_EVENT_NAME,
975217
- cli_version: "5.23.3-1768-g87d295561fa"
975268
+ cli_version: "5.23.3-1773-g28a9626f350"
975218
975269
  };
975219
975270
  }
975220
975271
  function isAutomationMode() {
@@ -976046,7 +976097,7 @@ var CliContext = class _CliContext {
976046
976097
  if (false) {
976047
976098
  this.logger.error("CLI_VERSION is not defined");
976048
976099
  }
976049
- return "5.23.3-1768-g87d295561fa";
976100
+ return "5.23.3-1773-g28a9626f350";
976050
976101
  }
976051
976102
  getCliName() {
976052
976103
  if (false) {
@@ -977858,7 +977909,8 @@ async function packLocalOutputForGroup({
977858
977909
  context: context3,
977859
977910
  mode = "host",
977860
977911
  runner,
977861
- packOnly = false
977912
+ packOnly = false,
977913
+ version: version7
977862
977914
  }) {
977863
977915
  const failures = [];
977864
977916
  for (const generator of group.generators) {
@@ -977880,7 +977932,8 @@ async function packLocalOutputForGroup({
977880
977932
  outputPath,
977881
977933
  context: context3,
977882
977934
  mode,
977883
- runner: runner ?? "docker"
977935
+ runner: runner ?? "docker",
977936
+ version: version7
977884
977937
  });
977885
977938
  if (packOnly) {
977886
977939
  if (artifactProduced) {
@@ -977907,7 +977960,8 @@ async function packOutputForLanguage({
977907
977960
  outputPath,
977908
977961
  context: context3,
977909
977962
  mode,
977910
- runner
977963
+ runner,
977964
+ version: version7
977911
977965
  }) {
977912
977966
  const distDir = join8(outputPath, RelativeFilePath2.of(PACK_OUTPUT_DIRECTORY));
977913
977967
  const run = async (commands) => {
@@ -977916,26 +977970,103 @@ async function packOutputForLanguage({
977916
977970
  switch (language) {
977917
977971
  case "typescript": {
977918
977972
  await (0, import_promises168.mkdir)(distDir, { recursive: true });
977919
- const commands = [["npm", "install"]];
977973
+ await run([["npm", "install"]]);
977920
977974
  if (await hasNpmScript({ outputPath, script: "build" })) {
977921
- commands.push(["npm", "run", "build"]);
977975
+ await run([["npx", "--yes", "pnpm", "run", "build"]]);
977976
+ } else {
977977
+ const tsconfig = await findTsconfig(outputPath);
977978
+ if (tsconfig != null) {
977979
+ try {
977980
+ await run([["npx", "--yes", "--package", "typescript", "tsc", "--project", tsconfig]]);
977981
+ } catch (error50) {
977982
+ if (!await hasEmittedCompilerOutput({ outputPath, tsconfig })) {
977983
+ throw error50;
977984
+ }
977985
+ context3.logger.warn(
977986
+ `tsc reported errors while compiling ${tsconfig}; packing the emitted output anyway.`
977987
+ );
977988
+ }
977989
+ }
977990
+ }
977991
+ const npmignorePath = join8(outputPath, RelativeFilePath2.of(".npmignore"));
977992
+ const shouldWriteNpmignore = !await doesPathExist(npmignorePath) && !await hasPackageJsonFilesField(outputPath) && await doesPathExist(join8(outputPath, RelativeFilePath2.of(".gitignore")));
977993
+ if (shouldWriteNpmignore) {
977994
+ await (0, import_promises168.writeFile)(npmignorePath, `${PACK_OUTPUT_DIRECTORY}/
977995
+ `);
977996
+ }
977997
+ try {
977998
+ await run([["npm", "pack", "--pack-destination", PACK_OUTPUT_DIRECTORY]]);
977999
+ } finally {
978000
+ if (shouldWriteNpmignore) {
978001
+ await (0, import_promises168.rm)(npmignorePath, { force: true });
978002
+ }
977922
978003
  }
977923
- commands.push(["npm", "pack", "--pack-destination", PACK_OUTPUT_DIRECTORY]);
977924
- await run(commands);
977925
978004
  logArtifacts({ distDir, context: context3 });
977926
978005
  return true;
977927
978006
  }
977928
978007
  case "python": {
977929
978008
  await (0, import_promises168.mkdir)(distDir, { recursive: true });
977930
- await run([["python3", "-m", "pip", "wheel", ".", "--no-deps", "--wheel-dir", PACK_OUTPUT_DIRECTORY]]);
978009
+ const pipWheelCommand = [
978010
+ "python3",
978011
+ "-m",
978012
+ "pip",
978013
+ "wheel",
978014
+ ".",
978015
+ "--no-deps",
978016
+ "--wheel-dir",
978017
+ PACK_OUTPUT_DIRECTORY
978018
+ ];
978019
+ if (mode === "host") {
978020
+ try {
978021
+ await run([pipWheelCommand]);
978022
+ } catch {
978023
+ context3.logger.warn(
978024
+ "pip wheel failed on the host toolchain; retrying in an isolated build environment (python -m venv + python -m build)."
978025
+ );
978026
+ const venvDirectory = ".fern-pack-venv";
978027
+ const venvPython = process.platform === "win32" ? `${venvDirectory}/Scripts/python` : `${venvDirectory}/bin/python`;
978028
+ try {
978029
+ await run([
978030
+ ["python3", "-m", "venv", venvDirectory],
978031
+ [venvPython, "-m", "pip", "install", "--quiet", "build"],
978032
+ [venvPython, "-m", "build", "--wheel", "--outdir", PACK_OUTPUT_DIRECTORY]
978033
+ ]);
978034
+ } finally {
978035
+ await (0, import_promises168.rm)(join8(outputPath, RelativeFilePath2.of(venvDirectory)), {
978036
+ recursive: true,
978037
+ force: true
978038
+ });
978039
+ }
978040
+ }
978041
+ } else {
978042
+ await run([pipWheelCommand]);
978043
+ }
977931
978044
  logArtifacts({ distDir, context: context3 });
977932
978045
  return true;
977933
978046
  }
977934
978047
  case "java": {
977935
978048
  await (0, import_promises168.mkdir)(distDir, { recursive: true });
977936
- await run([["gradle", "jar", "-x", "test"]]);
978049
+ const initScriptName = ".fern-pack-pom-init.gradle";
978050
+ const initScriptPath = join8(outputPath, RelativeFilePath2.of(initScriptName));
978051
+ await (0, import_promises168.writeFile)(initScriptPath, getJavaPomInitScript({ fallbackVersion: version7 ?? "0.0.0" }));
978052
+ try {
978053
+ await run([
978054
+ [
978055
+ "gradle",
978056
+ "--init-script",
978057
+ initScriptName,
978058
+ "jar",
978059
+ `generatePomFileFor${JAVA_POM_PUBLICATION_NAME_CAPITALIZED}Publication`,
978060
+ "-x",
978061
+ "test"
978062
+ ]
978063
+ ]);
978064
+ } finally {
978065
+ await (0, import_promises168.rm)(initScriptPath, { force: true });
978066
+ }
977937
978067
  const libsDir = join8(outputPath, RelativeFilePath2.of("build/libs"));
977938
978068
  await copyMatchingFiles({ fromDir: libsDir, toDir: distDir, extension: ".jar" });
978069
+ await copyGeneratedPom({ outputPath, distDir, context: context3 });
977939
978070
  logArtifacts({ distDir, context: context3 });
977940
978071
  return true;
977941
978072
  }
@@ -978017,7 +978148,8 @@ async function runPackCommands({
978017
978148
  if (image3 == null) {
978018
978149
  throw new Error(`No Docker toolchain image is configured for ${language}.`);
978019
978150
  }
978020
- const containerArgs = ["run", "--rm", "-v", `${outputPath}:/workspace`, "-w", "/workspace", "-e", "HOME=/tmp"];
978151
+ const workdir = `/workspace/${(0, import_path110.basename)(outputPath)}`;
978152
+ const containerArgs = ["run", "--rm", "-v", `${outputPath}:${workdir}`, "-w", workdir, "-e", "HOME=/tmp"];
978021
978153
  if (process.getuid != null && process.getgid != null) {
978022
978154
  containerArgs.push("--user", `${process.getuid()}:${process.getgid()}`);
978023
978155
  }
@@ -978083,6 +978215,86 @@ async function removeDistDirIfEmpty(outputPath) {
978083
978215
  } catch {
978084
978216
  }
978085
978217
  }
978218
+ var JAVA_POM_PUBLICATION_NAME = "fernLocalPack";
978219
+ var JAVA_POM_PUBLICATION_NAME_CAPITALIZED = "FernLocalPack";
978220
+ function getJavaPomInitScript({ fallbackVersion }) {
978221
+ return `allprojects { project ->
978222
+ project.plugins.withId("java") {
978223
+ project.apply plugin: "maven-publish"
978224
+ project.afterEvaluate {
978225
+ if (project.group == null || project.group.toString().isEmpty()) {
978226
+ project.group = project.name
978227
+ }
978228
+ if (project.version == null || project.version.toString() == "unspecified") {
978229
+ project.version = "${fallbackVersion}"
978230
+ }
978231
+ if (project.publishing.publications.findByName("${JAVA_POM_PUBLICATION_NAME}") == null) {
978232
+ project.publishing.publications.create("${JAVA_POM_PUBLICATION_NAME}", MavenPublication) {
978233
+ from project.components.java
978234
+ }
978235
+ }
978236
+ }
978237
+ }
978238
+ }
978239
+ `;
978240
+ }
978241
+ async function copyGeneratedPom({
978242
+ outputPath,
978243
+ distDir,
978244
+ context: context3
978245
+ }) {
978246
+ const pomPath = join8(
978247
+ outputPath,
978248
+ RelativeFilePath2.of(`build/publications/${JAVA_POM_PUBLICATION_NAME}/pom-default.xml`)
978249
+ );
978250
+ if (!await doesPathExist(pomPath)) {
978251
+ context3.logger.warn(
978252
+ "No POM was generated for the Java package; the JAR is packaged without dependency metadata."
978253
+ );
978254
+ return;
978255
+ }
978256
+ const jarNames = (await (0, import_promises168.readdir)(distDir)).filter((file4) => file4.endsWith(".jar"));
978257
+ const jarName = jarNames.find((file4) => !file4.endsWith("-sources.jar") && !file4.endsWith("-javadoc.jar")) ?? jarNames[0];
978258
+ const pomName = jarName != null ? `${jarName.slice(0, -".jar".length)}.pom` : "pom.xml";
978259
+ await (0, import_promises168.copyFile)(pomPath, join8(distDir, RelativeFilePath2.of(pomName)));
978260
+ }
978261
+ async function hasEmittedCompilerOutput({
978262
+ outputPath,
978263
+ tsconfig
978264
+ }) {
978265
+ let outDir = "dist";
978266
+ try {
978267
+ const parsed = JSON.parse(await (0, import_promises168.readFile)(join8(outputPath, RelativeFilePath2.of(tsconfig)), "utf-8"));
978268
+ if (typeof parsed === "object" && parsed != null && "compilerOptions" in parsed) {
978269
+ const compilerOptions = parsed.compilerOptions;
978270
+ if (typeof compilerOptions === "object" && compilerOptions != null && "outDir" in compilerOptions && typeof compilerOptions.outDir === "string") {
978271
+ outDir = compilerOptions.outDir;
978272
+ }
978273
+ }
978274
+ } catch {
978275
+ }
978276
+ const outDirPath = join8(outputPath, RelativeFilePath2.of(outDir));
978277
+ if (!await doesPathExist(outDirPath)) {
978278
+ return false;
978279
+ }
978280
+ return (await (0, import_promises168.readdir)(outDirPath)).length > 0;
978281
+ }
978282
+ async function findTsconfig(outputPath) {
978283
+ for (const candidate of ["tsconfig.cjs.json", "tsconfig.json"]) {
978284
+ if (await doesPathExist(join8(outputPath, RelativeFilePath2.of(candidate)))) {
978285
+ return candidate;
978286
+ }
978287
+ }
978288
+ return void 0;
978289
+ }
978290
+ async function hasPackageJsonFilesField(outputPath) {
978291
+ const packageJsonPath = join8(outputPath, RelativeFilePath2.of("package.json"));
978292
+ if (!await doesPathExist(packageJsonPath)) {
978293
+ return false;
978294
+ }
978295
+ const parsed = JSON.parse(await (0, import_promises168.readFile)(packageJsonPath, "utf-8"));
978296
+ return typeof parsed === "object" && parsed != null && "files" in parsed;
978297
+ }
978086
978298
  async function hasNpmScript({
978087
978299
  outputPath,
978088
978300
  script
@@ -978376,7 +978588,14 @@ async function generateWorkspace({
978376
978588
  });
978377
978589
  }
978378
978590
  if (pack) {
978379
- await packLocalOutputForGroup({ group, context: groupContext, mode: packMode, runner, packOnly });
978591
+ await packLocalOutputForGroup({
978592
+ group,
978593
+ context: groupContext,
978594
+ mode: packMode,
978595
+ runner,
978596
+ packOnly,
978597
+ version: version7
978598
+ });
978380
978599
  }
978381
978600
  })
978382
978601
  )
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.23.3-1768-g87d295561fa",
2
+ "version": "5.23.3-1773-g28a9626f350",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",