@fern-api/fern-api-dev 4.79.4 → 4.80.0

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 +449 -284
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -614276,7 +614276,7 @@ var AccessTokenPosthogManager = class {
614276
614276
  properties: {
614277
614277
  ...event,
614278
614278
  ...event.properties,
614279
- version: "4.79.4",
614279
+ version: "4.80.0",
614280
614280
  usingAccessToken: true
614281
614281
  }
614282
614282
  });
@@ -614330,7 +614330,7 @@ var UserPosthogManager = class {
614330
614330
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
614331
614331
  event: "CLI",
614332
614332
  properties: {
614333
- version: "4.79.4",
614333
+ version: "4.80.0",
614334
614334
  ...event,
614335
614335
  ...event.properties,
614336
614336
  usingAccessToken: false,
@@ -831611,7 +831611,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
831611
831611
  var LOGS_FOLDER_NAME = "logs";
831612
831612
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
831613
831613
  function getCliSource() {
831614
- const version7 = "4.79.4";
831614
+ const version7 = "4.80.0";
831615
831615
  return `cli@${version7}`;
831616
831616
  }
831617
831617
  var DebugLogger = class {
@@ -843125,7 +843125,7 @@ var LegacyDocsPublisher = class {
843125
843125
  previewId,
843126
843126
  disableTemplates: void 0,
843127
843127
  skipUpload,
843128
- cliVersion: "4.79.4"
843128
+ cliVersion: "4.80.0"
843129
843129
  });
843130
843130
  if (taskContext.getResult() === TaskResult.Failure) {
843131
843131
  return { success: false };
@@ -918206,7 +918206,7 @@ var CliContext = class _CliContext {
918206
918206
  if (false) {
918207
918207
  this.logger.error("CLI_VERSION is not defined");
918208
918208
  }
918209
- return "4.79.4";
918209
+ return "4.80.0";
918210
918210
  }
918211
918211
  getCliName() {
918212
918212
  if (false) {
@@ -919792,6 +919792,253 @@ async function addGeneratorToWorkspaces({
919792
919792
  );
919793
919793
  }
919794
919794
 
919795
+ // src/commands/generate/shouldSkipGenerator.ts
919796
+ function shouldSkipGenerator({
919797
+ generator,
919798
+ rootAutorelease
919799
+ }) {
919800
+ if (!generator.automation.generate) {
919801
+ return true;
919802
+ }
919803
+ if (generator.absolutePathToLocalOutput != null) {
919804
+ return true;
919805
+ }
919806
+ if (generator.raw?.autorelease === false) {
919807
+ return true;
919808
+ }
919809
+ if (generator.raw?.autorelease == null && rootAutorelease === false) {
919810
+ return true;
919811
+ }
919812
+ return false;
919813
+ }
919814
+
919815
+ // src/commands/automations/listGenerateCommands.ts
919816
+ function listGenerateCommands({
919817
+ workspaces,
919818
+ groupFilter,
919819
+ version: version7,
919820
+ autoMerge
919821
+ }) {
919822
+ const commands = [];
919823
+ for (const workspace of workspaces) {
919824
+ const generatorsConfiguration = workspace.generatorsConfiguration;
919825
+ const groups2 = generatorsConfiguration?.groups ?? [];
919826
+ const rootAutorelease = generatorsConfiguration?.rawConfiguration.autorelease;
919827
+ for (const group of groups2) {
919828
+ if (groupFilter != null && group.groupName !== groupFilter) {
919829
+ continue;
919830
+ }
919831
+ for (let i9 = 0; i9 < group.generators.length; i9++) {
919832
+ const generator = group.generators[i9];
919833
+ if (generator == null || shouldSkipGenerator({ generator, rootAutorelease })) {
919834
+ continue;
919835
+ }
919836
+ const parts = ["fern", "automations", "generate"];
919837
+ if (workspace.workspaceName != null) {
919838
+ parts.push("--api", workspace.workspaceName);
919839
+ }
919840
+ parts.push("--group", group.groupName);
919841
+ parts.push("--generator", String(i9));
919842
+ if (version7 != null) {
919843
+ parts.push("--version", version7);
919844
+ }
919845
+ if (autoMerge) {
919846
+ parts.push("--auto-merge");
919847
+ }
919848
+ commands.push(parts.join(" "));
919849
+ }
919850
+ }
919851
+ }
919852
+ return commands;
919853
+ }
919854
+
919855
+ // src/commands/sdk-preview/overrideOutputForPreview.ts
919856
+ var PREVIEW_REGISTRY_URL = process.env.FERN_PREVIEW_REGISTRY_URL ?? "https://npm.buildwithfern.com";
919857
+ var SUPPORTED_TYPESCRIPT_GENERATORS = /* @__PURE__ */ new Set([
919858
+ "fernapi/fern-typescript-node-sdk",
919859
+ "fernapi/fern-typescript-browser-sdk",
919860
+ "fernapi/fern-typescript-sdk"
919861
+ ]);
919862
+ function isNpmGenerator(generatorName) {
919863
+ return SUPPORTED_TYPESCRIPT_GENERATORS.has(generatorName);
919864
+ }
919865
+ function getGithubOwnerRepo(outputMode) {
919866
+ return outputMode._visit({
919867
+ downloadFiles: () => void 0,
919868
+ github: (val) => ({ owner: val.owner, repo: val.repo }),
919869
+ githubV2: (val) => val._visit({
919870
+ push: (v6) => ({ owner: v6.owner, repo: v6.repo }),
919871
+ commitAndRelease: (v6) => ({ owner: v6.owner, repo: v6.repo }),
919872
+ pullRequest: (v6) => ({ owner: v6.owner, repo: v6.repo }),
919873
+ _other: () => void 0
919874
+ }),
919875
+ publish: () => void 0,
919876
+ // publishV2 is registry-only (npmOverride, mavenOverride, pypiOverride, etc.)
919877
+ // and does not carry github owner/repo info. GitHub publish info is only
919878
+ // available on githubV2 variants via the publishInfo field.
919879
+ publishV2: () => void 0,
919880
+ _other: () => void 0
919881
+ });
919882
+ }
919883
+ function createNpmOverrideOutputMode({
919884
+ registryUrl: registryUrl2,
919885
+ packageName,
919886
+ token
919887
+ }) {
919888
+ return api_exports4.OutputMode.publishV2(
919889
+ api_exports4.remoteGen.PublishOutputModeV2.npmOverride({
919890
+ registryUrl: registryUrl2,
919891
+ packageName,
919892
+ token,
919893
+ downloadSnippets: false
919894
+ })
919895
+ );
919896
+ }
919897
+ function overrideGroupOutputForDownload({
919898
+ group
919899
+ }) {
919900
+ const modifiedGenerators = group.generators.map((generator) => ({
919901
+ ...generator,
919902
+ outputMode: api_exports4.remoteGen.OutputMode.downloadFiles({}),
919903
+ absolutePathToLocalOutput: void 0
919904
+ }));
919905
+ return {
919906
+ ...group,
919907
+ generators: modifiedGenerators
919908
+ };
919909
+ }
919910
+ function overrideGroupOutputForPreview({
919911
+ group,
919912
+ packageName,
919913
+ token,
919914
+ registryUrl: registryUrl2
919915
+ }) {
919916
+ const modifiedGenerators = group.generators.map((generator) => ({
919917
+ ...generator,
919918
+ outputMode: createNpmOverrideOutputMode({ registryUrl: registryUrl2, packageName, token }),
919919
+ absolutePathToLocalOutput: void 0
919920
+ }));
919921
+ return {
919922
+ ...group,
919923
+ generators: modifiedGenerators
919924
+ };
919925
+ }
919926
+ function getGithubPublishInfoWithoutToken(outputMode) {
919927
+ const publishInfo = outputMode._visit({
919928
+ downloadFiles: () => void 0,
919929
+ github: () => void 0,
919930
+ githubV2: (val) => val._visit({
919931
+ push: (v6) => v6.publishInfo,
919932
+ commitAndRelease: (v6) => v6.publishInfo,
919933
+ pullRequest: (v6) => v6.publishInfo,
919934
+ _other: () => void 0
919935
+ }),
919936
+ publish: () => void 0,
919937
+ publishV2: () => void 0,
919938
+ _other: () => void 0
919939
+ });
919940
+ if (publishInfo == null) {
919941
+ return void 0;
919942
+ }
919943
+ return stripPublishInfoCredentials(publishInfo);
919944
+ }
919945
+ function stripPublishInfoCredentials(publishInfo) {
919946
+ return publishInfo._visit({
919947
+ npm: (val) => api_exports4.GithubPublishInfo.npm({
919948
+ registryUrl: val.registryUrl,
919949
+ packageName: val.packageName,
919950
+ token: void 0
919951
+ }),
919952
+ maven: (val) => api_exports4.GithubPublishInfo.maven({
919953
+ registryUrl: val.registryUrl,
919954
+ coordinate: val.coordinate,
919955
+ credentials: void 0,
919956
+ signature: void 0
919957
+ }),
919958
+ postman: () => void 0,
919959
+ pypi: (val) => api_exports4.GithubPublishInfo.pypi({
919960
+ registryUrl: val.registryUrl,
919961
+ packageName: val.packageName,
919962
+ credentials: void 0,
919963
+ pypiMetadata: val.pypiMetadata
919964
+ }),
919965
+ nuget: (val) => api_exports4.GithubPublishInfo.nuget({
919966
+ registryUrl: val.registryUrl,
919967
+ packageName: val.packageName,
919968
+ apiKey: void 0
919969
+ }),
919970
+ rubygems: (val) => api_exports4.GithubPublishInfo.rubygems({
919971
+ registryUrl: val.registryUrl,
919972
+ packageName: val.packageName,
919973
+ apiKey: void 0
919974
+ }),
919975
+ crates: (val) => api_exports4.GithubPublishInfo.crates({
919976
+ registryUrl: val.registryUrl,
919977
+ packageName: val.packageName,
919978
+ token: void 0
919979
+ }),
919980
+ _other: () => void 0
919981
+ });
919982
+ }
919983
+ function overrideGroupOutputForDiffBranch({
919984
+ group
919985
+ }) {
919986
+ const modifiedGenerators = group.generators.map((generator) => {
919987
+ const githubInfo = getGithubOwnerRepo(generator.outputMode);
919988
+ if (githubInfo == null) {
919989
+ return void 0;
919990
+ }
919991
+ return {
919992
+ ...generator,
919993
+ outputMode: api_exports4.OutputMode.githubV2(
919994
+ api_exports4.GithubOutputModeV2.push({
919995
+ owner: githubInfo.owner,
919996
+ repo: githubInfo.repo,
919997
+ branch: void 0,
919998
+ license: void 0,
919999
+ publishInfo: getGithubPublishInfoWithoutToken(generator.outputMode),
920000
+ downloadSnippets: false
920001
+ })
920002
+ ),
920003
+ absolutePathToLocalOutput: void 0
920004
+ };
920005
+ }).filter((g8) => g8 != null);
920006
+ return {
920007
+ ...group,
920008
+ generators: modifiedGenerators
920009
+ };
920010
+ }
920011
+
920012
+ // src/commands/automations/listPreviewGroups.ts
920013
+ function listPreviewGroups({
920014
+ workspaces,
920015
+ groupFilter
920016
+ }) {
920017
+ const results = [];
920018
+ for (const workspace of workspaces) {
920019
+ const generatorsConfiguration = workspace.generatorsConfiguration;
920020
+ if (generatorsConfiguration == null) {
920021
+ continue;
920022
+ }
920023
+ for (const group of generatorsConfiguration.groups) {
920024
+ if (groupFilter != null && group.groupName !== groupFilter) {
920025
+ continue;
920026
+ }
920027
+ const firstPreviewable = group.generators.find(
920028
+ (generator) => generator.automation.preview && isNpmGenerator(generator.name)
920029
+ );
920030
+ if (firstPreviewable != null) {
920031
+ results.push({
920032
+ groupName: group.groupName,
920033
+ apiName: workspace.workspaceName ?? null,
920034
+ generator: firstPreviewable.name
920035
+ });
920036
+ }
920037
+ }
920038
+ }
920039
+ return results;
920040
+ }
920041
+
919795
920042
  // src/commands/diff/diff.ts
919796
920043
  init_lib4();
919797
920044
  init_lib6();
@@ -928313,26 +928560,6 @@ function getExcludeRules(brokenLinks, strictBrokenLinks) {
928313
928560
  return excludeRules;
928314
928561
  }
928315
928562
 
928316
- // src/commands/generate/shouldSkipGenerator.ts
928317
- function shouldSkipGenerator({
928318
- generator,
928319
- rootAutorelease
928320
- }) {
928321
- if (!generator.automation.generate) {
928322
- return true;
928323
- }
928324
- if (generator.absolutePathToLocalOutput != null) {
928325
- return true;
928326
- }
928327
- if (generator.raw?.autorelease === false) {
928328
- return true;
928329
- }
928330
- if (generator.raw?.autorelease == null && rootAutorelease === false) {
928331
- return true;
928332
- }
928333
- return false;
928334
- }
928335
-
928336
928563
  // src/commands/generate-dynamic-ir/generateDynamicIrForWorkspaces.ts
928337
928564
  init_lib6();
928338
928565
  var import_path88 = __toESM(require("path"), 1);
@@ -930326,163 +930553,6 @@ function generateRandomId() {
930326
930553
  return (0, import_crypto12.randomBytes)(4).toString("hex");
930327
930554
  }
930328
930555
 
930329
- // src/commands/sdk-preview/overrideOutputForPreview.ts
930330
- var PREVIEW_REGISTRY_URL = process.env.FERN_PREVIEW_REGISTRY_URL ?? "https://npm.buildwithfern.com";
930331
- var SUPPORTED_TYPESCRIPT_GENERATORS = /* @__PURE__ */ new Set([
930332
- "fernapi/fern-typescript-node-sdk",
930333
- "fernapi/fern-typescript-browser-sdk",
930334
- "fernapi/fern-typescript-sdk"
930335
- ]);
930336
- function isNpmGenerator(generatorName) {
930337
- return SUPPORTED_TYPESCRIPT_GENERATORS.has(generatorName);
930338
- }
930339
- function getGithubOwnerRepo(outputMode) {
930340
- return outputMode._visit({
930341
- downloadFiles: () => void 0,
930342
- github: (val) => ({ owner: val.owner, repo: val.repo }),
930343
- githubV2: (val) => val._visit({
930344
- push: (v6) => ({ owner: v6.owner, repo: v6.repo }),
930345
- commitAndRelease: (v6) => ({ owner: v6.owner, repo: v6.repo }),
930346
- pullRequest: (v6) => ({ owner: v6.owner, repo: v6.repo }),
930347
- _other: () => void 0
930348
- }),
930349
- publish: () => void 0,
930350
- // publishV2 is registry-only (npmOverride, mavenOverride, pypiOverride, etc.)
930351
- // and does not carry github owner/repo info. GitHub publish info is only
930352
- // available on githubV2 variants via the publishInfo field.
930353
- publishV2: () => void 0,
930354
- _other: () => void 0
930355
- });
930356
- }
930357
- function createNpmOverrideOutputMode({
930358
- registryUrl: registryUrl2,
930359
- packageName,
930360
- token
930361
- }) {
930362
- return api_exports4.OutputMode.publishV2(
930363
- api_exports4.remoteGen.PublishOutputModeV2.npmOverride({
930364
- registryUrl: registryUrl2,
930365
- packageName,
930366
- token,
930367
- downloadSnippets: false
930368
- })
930369
- );
930370
- }
930371
- function overrideGroupOutputForDownload({
930372
- group
930373
- }) {
930374
- const modifiedGenerators = group.generators.map((generator) => ({
930375
- ...generator,
930376
- outputMode: api_exports4.remoteGen.OutputMode.downloadFiles({}),
930377
- absolutePathToLocalOutput: void 0
930378
- }));
930379
- return {
930380
- ...group,
930381
- generators: modifiedGenerators
930382
- };
930383
- }
930384
- function overrideGroupOutputForPreview({
930385
- group,
930386
- packageName,
930387
- token,
930388
- registryUrl: registryUrl2
930389
- }) {
930390
- const modifiedGenerators = group.generators.map((generator) => ({
930391
- ...generator,
930392
- outputMode: createNpmOverrideOutputMode({ registryUrl: registryUrl2, packageName, token }),
930393
- absolutePathToLocalOutput: void 0
930394
- }));
930395
- return {
930396
- ...group,
930397
- generators: modifiedGenerators
930398
- };
930399
- }
930400
- function getGithubPublishInfoWithoutToken(outputMode) {
930401
- const publishInfo = outputMode._visit({
930402
- downloadFiles: () => void 0,
930403
- github: () => void 0,
930404
- githubV2: (val) => val._visit({
930405
- push: (v6) => v6.publishInfo,
930406
- commitAndRelease: (v6) => v6.publishInfo,
930407
- pullRequest: (v6) => v6.publishInfo,
930408
- _other: () => void 0
930409
- }),
930410
- publish: () => void 0,
930411
- publishV2: () => void 0,
930412
- _other: () => void 0
930413
- });
930414
- if (publishInfo == null) {
930415
- return void 0;
930416
- }
930417
- return stripPublishInfoCredentials(publishInfo);
930418
- }
930419
- function stripPublishInfoCredentials(publishInfo) {
930420
- return publishInfo._visit({
930421
- npm: (val) => api_exports4.GithubPublishInfo.npm({
930422
- registryUrl: val.registryUrl,
930423
- packageName: val.packageName,
930424
- token: void 0
930425
- }),
930426
- maven: (val) => api_exports4.GithubPublishInfo.maven({
930427
- registryUrl: val.registryUrl,
930428
- coordinate: val.coordinate,
930429
- credentials: void 0,
930430
- signature: void 0
930431
- }),
930432
- postman: () => void 0,
930433
- pypi: (val) => api_exports4.GithubPublishInfo.pypi({
930434
- registryUrl: val.registryUrl,
930435
- packageName: val.packageName,
930436
- credentials: void 0,
930437
- pypiMetadata: val.pypiMetadata
930438
- }),
930439
- nuget: (val) => api_exports4.GithubPublishInfo.nuget({
930440
- registryUrl: val.registryUrl,
930441
- packageName: val.packageName,
930442
- apiKey: void 0
930443
- }),
930444
- rubygems: (val) => api_exports4.GithubPublishInfo.rubygems({
930445
- registryUrl: val.registryUrl,
930446
- packageName: val.packageName,
930447
- apiKey: void 0
930448
- }),
930449
- crates: (val) => api_exports4.GithubPublishInfo.crates({
930450
- registryUrl: val.registryUrl,
930451
- packageName: val.packageName,
930452
- token: void 0
930453
- }),
930454
- _other: () => void 0
930455
- });
930456
- }
930457
- function overrideGroupOutputForDiffBranch({
930458
- group
930459
- }) {
930460
- const modifiedGenerators = group.generators.map((generator) => {
930461
- const githubInfo = getGithubOwnerRepo(generator.outputMode);
930462
- if (githubInfo == null) {
930463
- return void 0;
930464
- }
930465
- return {
930466
- ...generator,
930467
- outputMode: api_exports4.OutputMode.githubV2(
930468
- api_exports4.GithubOutputModeV2.push({
930469
- owner: githubInfo.owner,
930470
- repo: githubInfo.repo,
930471
- branch: void 0,
930472
- license: void 0,
930473
- publishInfo: getGithubPublishInfoWithoutToken(generator.outputMode),
930474
- downloadSnippets: false
930475
- })
930476
- ),
930477
- absolutePathToLocalOutput: void 0
930478
- };
930479
- }).filter((g8) => g8 != null);
930480
- return {
930481
- ...group,
930482
- generators: modifiedGenerators
930483
- };
930484
- }
930485
-
930486
930556
  // src/commands/sdk-preview/toPreviewPackageName.ts
930487
930557
  function toPreviewPackageName(packageName, org) {
930488
930558
  const scopeMatch = packageName.match(/^@[^/]+\/(.+)$/);
@@ -930502,7 +930572,6 @@ async function sdkPreview({
930502
930572
  groupName,
930503
930573
  generatorFilter,
930504
930574
  apiName,
930505
- json: json3,
930506
930575
  output: output2,
930507
930576
  local,
930508
930577
  pushDiff
@@ -930513,17 +930582,20 @@ async function sdkPreview({
930513
930582
  let publishToRegistry = true;
930514
930583
  try {
930515
930584
  if (pushDiff && local) {
930516
- return cliContext.failAndThrow(
930517
- "--push-diff requires remote generation and cannot be combined with --local."
930518
- );
930585
+ return {
930586
+ status: "error",
930587
+ message: "--push-diff requires remote generation and cannot be combined with --local."
930588
+ };
930519
930589
  }
930520
930590
  const token = await cliContext.runTask(async (context3) => {
930521
930591
  return askToLogin(context3);
930522
930592
  });
930523
930593
  if (token == null) {
930524
- return cliContext.failAndThrow("Authentication required. Run 'fern login' or set FERN_TOKEN.", void 0, {
930594
+ return {
930595
+ status: "error",
930596
+ message: "Authentication required. Run 'fern login' or set FERN_TOKEN.",
930525
930597
  code: CliError.Code.AuthError
930526
- });
930598
+ };
930527
930599
  }
930528
930600
  const project = await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
930529
930601
  commandLineApiWorkspace: apiName,
@@ -930574,27 +930646,27 @@ async function sdkPreview({
930574
930646
  }
930575
930647
  const groupNameOrDefault = groupName ?? workspace.generatorsConfiguration.defaultGroup;
930576
930648
  if (groupNameOrDefault == null) {
930577
- return cliContext.failAndThrow(
930578
- `No group specified. Use the --${GROUP_CLI_OPTION} option, or set "${DEFAULT_GROUP_GENERATORS_CONFIG_KEY}" in ${GENERATORS_CONFIGURATION_FILENAME}`,
930579
- void 0,
930580
- { code: CliError.Code.ConfigError }
930581
- );
930649
+ return {
930650
+ status: "error",
930651
+ message: `No group specified. Use the --${GROUP_CLI_OPTION} option, or set "${DEFAULT_GROUP_GENERATORS_CONFIG_KEY}" in ${GENERATORS_CONFIGURATION_FILENAME}`,
930652
+ code: CliError.Code.ConfigError
930653
+ };
930582
930654
  }
930583
930655
  const group = workspace.generatorsConfiguration.groups.find((g8) => g8.groupName === groupNameOrDefault);
930584
930656
  if (group == null) {
930585
- return cliContext.failAndThrow(
930586
- `Group '${groupNameOrDefault}' does not exist in ${GENERATORS_CONFIGURATION_FILENAME}`,
930587
- void 0,
930588
- { code: CliError.Code.ConfigError }
930589
- );
930657
+ return {
930658
+ status: "error",
930659
+ message: `Group '${groupNameOrDefault}' does not exist in ${GENERATORS_CONFIGURATION_FILENAME}`,
930660
+ code: CliError.Code.ConfigError
930661
+ };
930590
930662
  }
930591
930663
  const generators = generatorFilter != null ? group.generators.filter((g8) => g8.name === generatorFilter) : group.generators;
930592
930664
  if (generatorFilter != null && generators.length === 0) {
930593
- return cliContext.failAndThrow(
930594
- `Generator '${generatorFilter}' not found in group '${groupNameOrDefault}' in ${GENERATORS_CONFIGURATION_FILENAME}`,
930595
- void 0,
930596
- { code: CliError.Code.ConfigError }
930597
- );
930665
+ return {
930666
+ status: "error",
930667
+ message: `Generator '${generatorFilter}' not found in group '${groupNameOrDefault}' in ${GENERATORS_CONFIGURATION_FILENAME}`,
930668
+ code: CliError.Code.ConfigError
930669
+ };
930598
930670
  }
930599
930671
  const npmGenerators = generators.filter((g8) => isNpmGenerator(g8.name));
930600
930672
  const skippedGenerators = generators.filter((g8) => !isNpmGenerator(g8.name));
@@ -930604,20 +930676,20 @@ async function sdkPreview({
930604
930676
  );
930605
930677
  }
930606
930678
  if (npmGenerators.length === 0) {
930607
- return cliContext.failAndThrow(
930608
- `No supported generators found in group '${groupNameOrDefault}'. SDK preview currently only supports TypeScript/npm generators.`,
930609
- void 0,
930610
- { code: CliError.Code.ConfigError }
930611
- );
930679
+ return {
930680
+ status: "error",
930681
+ message: `No supported generators found in group '${groupNameOrDefault}'. SDK preview currently only supports TypeScript/npm generators.`,
930682
+ code: CliError.Code.ConfigError
930683
+ };
930612
930684
  }
930613
930685
  for (const generator of npmGenerators) {
930614
930686
  const originalPackageName = getPackageNameFromGeneratorConfig(generator);
930615
930687
  if (originalPackageName == null) {
930616
- return cliContext.failAndThrow(
930617
- `Could not determine package name for generator '${generator.name}'. Ensure 'output.package-name' is set in ${GENERATORS_CONFIGURATION_FILENAME}.`,
930618
- void 0,
930619
- { code: CliError.Code.ConfigError }
930620
- );
930688
+ return {
930689
+ status: "error",
930690
+ message: `Could not determine package name for generator '${generator.name}'. Ensure 'output.package-name' is set in ${GENERATORS_CONFIGURATION_FILENAME}.`,
930691
+ code: CliError.Code.ConfigError
930692
+ };
930621
930693
  }
930622
930694
  const previewPackageName = toPreviewPackageName(originalPackageName, project.config.organization);
930623
930695
  const previewVersion = computePreviewVersion({ previewId });
@@ -930738,51 +930810,12 @@ async function sdkPreview({
930738
930810
  }
930739
930811
  }
930740
930812
  } catch (error50) {
930741
- if (json3) {
930742
- const result = {
930743
- status: "error",
930744
- message: error50 instanceof Error ? error50.message : String(error50)
930745
- };
930746
- process.stdout.write(JSON.stringify(result, null, 2) + "\n");
930747
- process.exitCode = 1;
930748
- return;
930749
- }
930750
- throw error50;
930751
- }
930752
- if (json3) {
930753
- const result = {
930754
- status: "success",
930755
- org: organization ?? "",
930756
- previews
930813
+ return {
930814
+ status: "error",
930815
+ message: error50 instanceof Error ? error50.message : String(error50)
930757
930816
  };
930758
- process.stdout.write(JSON.stringify(result, null, 2) + "\n");
930759
- } else if (previews.length > 0) {
930760
- cliContext.logger.info("");
930761
- if (publishToRegistry) {
930762
- cliContext.logger.info(`Published ${previews.length} preview package${previews.length > 1 ? "s" : ""}:`);
930763
- for (const preview of previews) {
930764
- cliContext.logger.info("");
930765
- cliContext.logger.info(` ${preview.package_name}@${preview.version}`);
930766
- cliContext.logger.info(` Install: ${preview.install}`);
930767
- if (preview.diff_url) {
930768
- cliContext.logger.info(` Diff: ${preview.diff_url}`);
930769
- }
930770
- if (preview.output_path) {
930771
- cliContext.logger.info(` Output: ${preview.output_path}`);
930772
- }
930773
- }
930774
- } else {
930775
- cliContext.logger.info(`Generated ${previews.length} preview SDK${previews.length > 1 ? "s" : ""}:`);
930776
- for (const preview of previews) {
930777
- cliContext.logger.info("");
930778
- cliContext.logger.info(` ${preview.package_name}@${preview.version}`);
930779
- if (preview.diff_url) {
930780
- cliContext.logger.info(` Diff: ${preview.diff_url}`);
930781
- }
930782
- cliContext.logger.info(` Output: ${preview.output_path}`);
930783
- }
930784
- }
930785
930817
  }
930818
+ return { status: "success", org: organization ?? "", previews };
930786
930819
  }
930787
930820
 
930788
930821
  // src/commands/self-update/selfUpdate.ts
@@ -938696,6 +938729,7 @@ function addAutomationsCommand(cli, cliContext) {
938696
938729
  cli.command("automations", false, (yargs) => {
938697
938730
  addAutomationsListCommand(yargs, cliContext);
938698
938731
  addAutomationsGenerateCommand(yargs, cliContext);
938732
+ addAutomationsPreviewCommand(yargs, cliContext);
938699
938733
  return yargs.demandCommand();
938700
938734
  });
938701
938735
  }
@@ -938729,37 +938763,116 @@ function addAutomationsListGenerateCommand(cli, cliContext) {
938729
938763
  commandLineApiWorkspace: argv.api,
938730
938764
  defaultToAllApiWorkspaces: true
938731
938765
  });
938732
- const commands = [];
938733
- for (const workspace of project.apiWorkspaces) {
938734
- const generatorsConfiguration = workspace.generatorsConfiguration;
938735
- const groups2 = generatorsConfiguration?.groups ?? [];
938736
- const rootAutorelease = generatorsConfiguration?.rawConfiguration.autorelease;
938737
- for (const group of groups2) {
938738
- if (argv.group != null && group.groupName !== argv.group) {
938739
- continue;
938766
+ const commands = listGenerateCommands({
938767
+ workspaces: project.apiWorkspaces,
938768
+ groupFilter: argv.group,
938769
+ version: argv.version,
938770
+ autoMerge: argv["auto-merge"]
938771
+ });
938772
+ process.stdout.write(JSON.stringify(commands));
938773
+ }
938774
+ );
938775
+ }
938776
+ function addAutomationsPreviewCommand(cli, cliContext) {
938777
+ cli.command(
938778
+ "preview",
938779
+ false,
938780
+ // hidden
938781
+ (yargs) => yargs.option("group", {
938782
+ type: "string",
938783
+ description: "Filter to a specific generator group (e.g. 'sdk'). Omit to preview all eligible groups."
938784
+ }).option("json", {
938785
+ boolean: true,
938786
+ default: false,
938787
+ description: "Output results as JSON (for machine consumption)."
938788
+ }).option("push-diff", {
938789
+ boolean: true,
938790
+ default: false,
938791
+ description: "Push a preview diff branch (fern-preview-{version}) to each SDK repo in addition to publishing to the preview registry."
938792
+ }),
938793
+ async (argv) => {
938794
+ cliContext.instrumentPostHogEvent({
938795
+ command: "fern automations preview"
938796
+ });
938797
+ const project = await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
938798
+ commandLineApiWorkspace: void 0,
938799
+ defaultToAllApiWorkspaces: true
938800
+ });
938801
+ const groups2 = listPreviewGroups({
938802
+ workspaces: project.apiWorkspaces,
938803
+ groupFilter: argv.group
938804
+ });
938805
+ if (groups2.length === 0) {
938806
+ if (argv.json) {
938807
+ process.stdout.write(JSON.stringify({ results: [] }, null, 2) + "\n");
938808
+ } else {
938809
+ cliContext.logger.info("No eligible generator groups found for preview.");
938810
+ }
938811
+ return;
938812
+ }
938813
+ cliContext.logger.info(
938814
+ `Found ${groups2.length} previewable group(s): ${groups2.map((g8) => g8.groupName).join(", ")}`
938815
+ );
938816
+ const results = [];
938817
+ for (const group of groups2) {
938818
+ const apiLabel = group.apiName != null ? ` (api: ${group.apiName})` : "";
938819
+ cliContext.logger.info(`Running preview for ${group.groupName}${apiLabel}...`);
938820
+ try {
938821
+ const result = await sdkPreview({
938822
+ cliContext,
938823
+ groupName: group.groupName,
938824
+ generatorFilter: void 0,
938825
+ apiName: group.apiName ?? void 0,
938826
+ output: void 0,
938827
+ local: false,
938828
+ pushDiff: argv["push-diff"]
938829
+ });
938830
+ if (result.status === "success") {
938831
+ results.push({
938832
+ groupName: group.groupName,
938833
+ apiName: group.apiName,
938834
+ status: "success",
938835
+ org: result.org,
938836
+ previews: result.previews
938837
+ });
938838
+ } else {
938839
+ results.push({
938840
+ groupName: group.groupName,
938841
+ apiName: group.apiName,
938842
+ status: "error",
938843
+ error: result.message
938844
+ });
938740
938845
  }
938741
- for (let i9 = 0; i9 < group.generators.length; i9++) {
938742
- const generator = group.generators[i9];
938743
- if (generator == null || shouldSkipGenerator({ generator, rootAutorelease })) {
938744
- continue;
938745
- }
938746
- const parts = ["fern", "automations", "generate"];
938747
- if (workspace.workspaceName != null) {
938748
- parts.push("--api", workspace.workspaceName);
938749
- }
938750
- parts.push("--group", group.groupName);
938751
- parts.push("--generator", String(i9));
938752
- if (argv.version != null) {
938753
- parts.push("--version", argv.version);
938754
- }
938755
- if (argv["auto-merge"]) {
938756
- parts.push("--auto-merge");
938846
+ } catch (error50) {
938847
+ const message = error50 instanceof Error ? error50.message : String(error50);
938848
+ cliContext.logger.warn(`Preview failed for group '${group.groupName}': ${message}`);
938849
+ results.push({
938850
+ groupName: group.groupName,
938851
+ apiName: group.apiName,
938852
+ status: "error",
938853
+ error: message
938854
+ });
938855
+ }
938856
+ }
938857
+ if (argv.json) {
938858
+ process.stdout.write(JSON.stringify({ results }, null, 2) + "\n");
938859
+ } else {
938860
+ for (const groupResult of results) {
938861
+ if (groupResult.status === "success" && groupResult.previews != null) {
938862
+ for (const preview of groupResult.previews) {
938863
+ if (preview.install) {
938864
+ cliContext.logger.info(`${groupResult.groupName}: ${preview.install}`);
938865
+ }
938757
938866
  }
938758
- commands.push(parts.join(" "));
938867
+ } else if (groupResult.status === "error") {
938868
+ cliContext.logger.warn(`${groupResult.groupName}: ${groupResult.error}`);
938759
938869
  }
938760
938870
  }
938761
938871
  }
938762
- process.stdout.write(JSON.stringify(commands));
938872
+ const hasErrors = results.some((r5) => r5.status === "error");
938873
+ if (hasErrors) {
938874
+ process.exitCode = 1;
938875
+ }
938763
938876
  }
938764
938877
  );
938765
938878
  }
@@ -938857,19 +938970,71 @@ function addSdkPreviewCommand(cli, cliContext) {
938857
938970
  command: "fern sdk preview"
938858
938971
  });
938859
938972
  const generatorFilter = argv.generator != null ? warnAndCorrectIncorrectDockerOrg(argv.generator, cliContext) : void 0;
938860
- await sdkPreview({
938973
+ const result = await sdkPreview({
938861
938974
  cliContext,
938862
938975
  groupName: argv.group,
938863
938976
  generatorFilter,
938864
938977
  apiName: argv.api,
938865
- json: argv.json,
938866
938978
  output: argv.output,
938867
938979
  local: argv.local,
938868
938980
  pushDiff: argv.pushDiff
938869
938981
  });
938982
+ writeSdkPreviewOutput({ result, json: argv.json, cliContext });
938870
938983
  }
938871
938984
  );
938872
938985
  }
938986
+ function writeSdkPreviewOutput({
938987
+ result,
938988
+ json: json3,
938989
+ cliContext
938990
+ }) {
938991
+ if (json3) {
938992
+ process.stdout.write(JSON.stringify(result, null, 2) + "\n");
938993
+ if (result.status === "error") {
938994
+ process.exitCode = 1;
938995
+ }
938996
+ return;
938997
+ }
938998
+ if (result.status === "error") {
938999
+ return cliContext.failAndThrow(
939000
+ result.message,
939001
+ void 0,
939002
+ result.code != null ? { code: result.code } : void 0
939003
+ );
939004
+ }
939005
+ if (result.previews.length > 0) {
939006
+ cliContext.logger.info("");
939007
+ const hasRegistry = result.previews.some((p9) => p9.registry_url !== "");
939008
+ if (hasRegistry) {
939009
+ cliContext.logger.info(
939010
+ `Published ${result.previews.length} preview package${result.previews.length > 1 ? "s" : ""}:`
939011
+ );
939012
+ for (const preview of result.previews) {
939013
+ cliContext.logger.info("");
939014
+ cliContext.logger.info(` ${preview.package_name}@${preview.version}`);
939015
+ cliContext.logger.info(` Install: ${preview.install}`);
939016
+ if (preview.diff_url) {
939017
+ cliContext.logger.info(` Diff: ${preview.diff_url}`);
939018
+ }
939019
+ if (preview.output_path) {
939020
+ cliContext.logger.info(` Output: ${preview.output_path}`);
939021
+ }
939022
+ }
939023
+ } else {
939024
+ cliContext.logger.info(
939025
+ `Generated ${result.previews.length} preview SDK${result.previews.length > 1 ? "s" : ""}:`
939026
+ );
939027
+ for (const preview of result.previews) {
939028
+ cliContext.logger.info("");
939029
+ cliContext.logger.info(` ${preview.package_name}@${preview.version}`);
939030
+ if (preview.diff_url) {
939031
+ cliContext.logger.info(` Diff: ${preview.diff_url}`);
939032
+ }
939033
+ cliContext.logger.info(` Output: ${preview.output_path}`);
939034
+ }
939035
+ }
939036
+ }
939037
+ }
938873
939038
  function addBetaCommand(cli, cliContext) {
938874
939039
  cli.command(
938875
939040
  "beta",
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.79.4",
2
+ "version": "4.80.0",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",