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

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 +457 -286
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -596568,12 +596568,13 @@ var OneOfSchemaConverter = class extends AbstractConverter {
596568
596568
  });
596569
596569
  const rawSchemaName = reference4.split("/").pop() ?? typeId;
596570
596570
  const schemaTitle = resolvedSchema.resolved ? resolvedSchema.value.title : void 0;
596571
+ const schemaDescription = resolvedSchema.resolved ? resolvedSchema.value.description : void 0;
596571
596572
  const variantDisplayName = schemaTitle ?? discriminant21 ?? rawSchemaName;
596572
596573
  if (convertedSchema.schema?.typeDeclaration != null && schemaTitle != null) {
596573
596574
  convertedSchema.schema.typeDeclaration.name.displayName = schemaTitle;
596574
596575
  }
596575
596576
  unionTypes.push({
596576
- docs: void 0,
596577
+ docs: schemaDescription,
596577
596578
  discriminantValue: nameAndWireValue,
596578
596579
  availability: convertedSchema.availability,
596579
596580
  displayName: variantDisplayName,
@@ -596685,9 +596686,14 @@ var OneOfSchemaConverter = class extends AbstractConverter {
596685
596686
  }
596686
596687
  }
596687
596688
  if (maybeTypeReference.ok) {
596689
+ const resolvedSchema = this.context.resolveReference({
596690
+ reference: subSchema,
596691
+ breadcrumbs: this.breadcrumbs
596692
+ });
596693
+ const schemaDescription = resolvedSchema.resolved ? resolvedSchema.value.description : void 0;
596688
596694
  unionTypes.push({
596689
596695
  type: maybeTypeReference.reference,
596690
- docs: subSchema.description
596696
+ docs: schemaDescription
596691
596697
  });
596692
596698
  }
596693
596699
  const typeId = this.context.getTypeIdFromSchemaReference(subSchema);
@@ -614276,7 +614282,7 @@ var AccessTokenPosthogManager = class {
614276
614282
  properties: {
614277
614283
  ...event,
614278
614284
  ...event.properties,
614279
- version: "4.79.4",
614285
+ version: "4.80.0-1-g796a68387d5",
614280
614286
  usingAccessToken: true
614281
614287
  }
614282
614288
  });
@@ -614330,7 +614336,7 @@ var UserPosthogManager = class {
614330
614336
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
614331
614337
  event: "CLI",
614332
614338
  properties: {
614333
- version: "4.79.4",
614339
+ version: "4.80.0-1-g796a68387d5",
614334
614340
  ...event,
614335
614341
  ...event.properties,
614336
614342
  usingAccessToken: false,
@@ -831611,7 +831617,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
831611
831617
  var LOGS_FOLDER_NAME = "logs";
831612
831618
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
831613
831619
  function getCliSource() {
831614
- const version7 = "4.79.4";
831620
+ const version7 = "4.80.0-1-g796a68387d5";
831615
831621
  return `cli@${version7}`;
831616
831622
  }
831617
831623
  var DebugLogger = class {
@@ -843125,7 +843131,7 @@ var LegacyDocsPublisher = class {
843125
843131
  previewId,
843126
843132
  disableTemplates: void 0,
843127
843133
  skipUpload,
843128
- cliVersion: "4.79.4"
843134
+ cliVersion: "4.80.0-1-g796a68387d5"
843129
843135
  });
843130
843136
  if (taskContext.getResult() === TaskResult.Failure) {
843131
843137
  return { success: false };
@@ -918206,7 +918212,7 @@ var CliContext = class _CliContext {
918206
918212
  if (false) {
918207
918213
  this.logger.error("CLI_VERSION is not defined");
918208
918214
  }
918209
- return "4.79.4";
918215
+ return "4.80.0-1-g796a68387d5";
918210
918216
  }
918211
918217
  getCliName() {
918212
918218
  if (false) {
@@ -919792,6 +919798,253 @@ async function addGeneratorToWorkspaces({
919792
919798
  );
919793
919799
  }
919794
919800
 
919801
+ // src/commands/generate/shouldSkipGenerator.ts
919802
+ function shouldSkipGenerator({
919803
+ generator,
919804
+ rootAutorelease
919805
+ }) {
919806
+ if (!generator.automation.generate) {
919807
+ return true;
919808
+ }
919809
+ if (generator.absolutePathToLocalOutput != null) {
919810
+ return true;
919811
+ }
919812
+ if (generator.raw?.autorelease === false) {
919813
+ return true;
919814
+ }
919815
+ if (generator.raw?.autorelease == null && rootAutorelease === false) {
919816
+ return true;
919817
+ }
919818
+ return false;
919819
+ }
919820
+
919821
+ // src/commands/automations/listGenerateCommands.ts
919822
+ function listGenerateCommands({
919823
+ workspaces,
919824
+ groupFilter,
919825
+ version: version7,
919826
+ autoMerge
919827
+ }) {
919828
+ const commands = [];
919829
+ for (const workspace of workspaces) {
919830
+ const generatorsConfiguration = workspace.generatorsConfiguration;
919831
+ const groups2 = generatorsConfiguration?.groups ?? [];
919832
+ const rootAutorelease = generatorsConfiguration?.rawConfiguration.autorelease;
919833
+ for (const group of groups2) {
919834
+ if (groupFilter != null && group.groupName !== groupFilter) {
919835
+ continue;
919836
+ }
919837
+ for (let i9 = 0; i9 < group.generators.length; i9++) {
919838
+ const generator = group.generators[i9];
919839
+ if (generator == null || shouldSkipGenerator({ generator, rootAutorelease })) {
919840
+ continue;
919841
+ }
919842
+ const parts = ["fern", "automations", "generate"];
919843
+ if (workspace.workspaceName != null) {
919844
+ parts.push("--api", workspace.workspaceName);
919845
+ }
919846
+ parts.push("--group", group.groupName);
919847
+ parts.push("--generator", String(i9));
919848
+ if (version7 != null) {
919849
+ parts.push("--version", version7);
919850
+ }
919851
+ if (autoMerge) {
919852
+ parts.push("--auto-merge");
919853
+ }
919854
+ commands.push(parts.join(" "));
919855
+ }
919856
+ }
919857
+ }
919858
+ return commands;
919859
+ }
919860
+
919861
+ // src/commands/sdk-preview/overrideOutputForPreview.ts
919862
+ var PREVIEW_REGISTRY_URL = process.env.FERN_PREVIEW_REGISTRY_URL ?? "https://npm.buildwithfern.com";
919863
+ var SUPPORTED_TYPESCRIPT_GENERATORS = /* @__PURE__ */ new Set([
919864
+ "fernapi/fern-typescript-node-sdk",
919865
+ "fernapi/fern-typescript-browser-sdk",
919866
+ "fernapi/fern-typescript-sdk"
919867
+ ]);
919868
+ function isNpmGenerator(generatorName) {
919869
+ return SUPPORTED_TYPESCRIPT_GENERATORS.has(generatorName);
919870
+ }
919871
+ function getGithubOwnerRepo(outputMode) {
919872
+ return outputMode._visit({
919873
+ downloadFiles: () => void 0,
919874
+ github: (val) => ({ owner: val.owner, repo: val.repo }),
919875
+ githubV2: (val) => val._visit({
919876
+ push: (v6) => ({ owner: v6.owner, repo: v6.repo }),
919877
+ commitAndRelease: (v6) => ({ owner: v6.owner, repo: v6.repo }),
919878
+ pullRequest: (v6) => ({ owner: v6.owner, repo: v6.repo }),
919879
+ _other: () => void 0
919880
+ }),
919881
+ publish: () => void 0,
919882
+ // publishV2 is registry-only (npmOverride, mavenOverride, pypiOverride, etc.)
919883
+ // and does not carry github owner/repo info. GitHub publish info is only
919884
+ // available on githubV2 variants via the publishInfo field.
919885
+ publishV2: () => void 0,
919886
+ _other: () => void 0
919887
+ });
919888
+ }
919889
+ function createNpmOverrideOutputMode({
919890
+ registryUrl: registryUrl2,
919891
+ packageName,
919892
+ token
919893
+ }) {
919894
+ return api_exports4.OutputMode.publishV2(
919895
+ api_exports4.remoteGen.PublishOutputModeV2.npmOverride({
919896
+ registryUrl: registryUrl2,
919897
+ packageName,
919898
+ token,
919899
+ downloadSnippets: false
919900
+ })
919901
+ );
919902
+ }
919903
+ function overrideGroupOutputForDownload({
919904
+ group
919905
+ }) {
919906
+ const modifiedGenerators = group.generators.map((generator) => ({
919907
+ ...generator,
919908
+ outputMode: api_exports4.remoteGen.OutputMode.downloadFiles({}),
919909
+ absolutePathToLocalOutput: void 0
919910
+ }));
919911
+ return {
919912
+ ...group,
919913
+ generators: modifiedGenerators
919914
+ };
919915
+ }
919916
+ function overrideGroupOutputForPreview({
919917
+ group,
919918
+ packageName,
919919
+ token,
919920
+ registryUrl: registryUrl2
919921
+ }) {
919922
+ const modifiedGenerators = group.generators.map((generator) => ({
919923
+ ...generator,
919924
+ outputMode: createNpmOverrideOutputMode({ registryUrl: registryUrl2, packageName, token }),
919925
+ absolutePathToLocalOutput: void 0
919926
+ }));
919927
+ return {
919928
+ ...group,
919929
+ generators: modifiedGenerators
919930
+ };
919931
+ }
919932
+ function getGithubPublishInfoWithoutToken(outputMode) {
919933
+ const publishInfo = outputMode._visit({
919934
+ downloadFiles: () => void 0,
919935
+ github: () => void 0,
919936
+ githubV2: (val) => val._visit({
919937
+ push: (v6) => v6.publishInfo,
919938
+ commitAndRelease: (v6) => v6.publishInfo,
919939
+ pullRequest: (v6) => v6.publishInfo,
919940
+ _other: () => void 0
919941
+ }),
919942
+ publish: () => void 0,
919943
+ publishV2: () => void 0,
919944
+ _other: () => void 0
919945
+ });
919946
+ if (publishInfo == null) {
919947
+ return void 0;
919948
+ }
919949
+ return stripPublishInfoCredentials(publishInfo);
919950
+ }
919951
+ function stripPublishInfoCredentials(publishInfo) {
919952
+ return publishInfo._visit({
919953
+ npm: (val) => api_exports4.GithubPublishInfo.npm({
919954
+ registryUrl: val.registryUrl,
919955
+ packageName: val.packageName,
919956
+ token: void 0
919957
+ }),
919958
+ maven: (val) => api_exports4.GithubPublishInfo.maven({
919959
+ registryUrl: val.registryUrl,
919960
+ coordinate: val.coordinate,
919961
+ credentials: void 0,
919962
+ signature: void 0
919963
+ }),
919964
+ postman: () => void 0,
919965
+ pypi: (val) => api_exports4.GithubPublishInfo.pypi({
919966
+ registryUrl: val.registryUrl,
919967
+ packageName: val.packageName,
919968
+ credentials: void 0,
919969
+ pypiMetadata: val.pypiMetadata
919970
+ }),
919971
+ nuget: (val) => api_exports4.GithubPublishInfo.nuget({
919972
+ registryUrl: val.registryUrl,
919973
+ packageName: val.packageName,
919974
+ apiKey: void 0
919975
+ }),
919976
+ rubygems: (val) => api_exports4.GithubPublishInfo.rubygems({
919977
+ registryUrl: val.registryUrl,
919978
+ packageName: val.packageName,
919979
+ apiKey: void 0
919980
+ }),
919981
+ crates: (val) => api_exports4.GithubPublishInfo.crates({
919982
+ registryUrl: val.registryUrl,
919983
+ packageName: val.packageName,
919984
+ token: void 0
919985
+ }),
919986
+ _other: () => void 0
919987
+ });
919988
+ }
919989
+ function overrideGroupOutputForDiffBranch({
919990
+ group
919991
+ }) {
919992
+ const modifiedGenerators = group.generators.map((generator) => {
919993
+ const githubInfo = getGithubOwnerRepo(generator.outputMode);
919994
+ if (githubInfo == null) {
919995
+ return void 0;
919996
+ }
919997
+ return {
919998
+ ...generator,
919999
+ outputMode: api_exports4.OutputMode.githubV2(
920000
+ api_exports4.GithubOutputModeV2.push({
920001
+ owner: githubInfo.owner,
920002
+ repo: githubInfo.repo,
920003
+ branch: void 0,
920004
+ license: void 0,
920005
+ publishInfo: getGithubPublishInfoWithoutToken(generator.outputMode),
920006
+ downloadSnippets: false
920007
+ })
920008
+ ),
920009
+ absolutePathToLocalOutput: void 0
920010
+ };
920011
+ }).filter((g8) => g8 != null);
920012
+ return {
920013
+ ...group,
920014
+ generators: modifiedGenerators
920015
+ };
920016
+ }
920017
+
920018
+ // src/commands/automations/listPreviewGroups.ts
920019
+ function listPreviewGroups({
920020
+ workspaces,
920021
+ groupFilter
920022
+ }) {
920023
+ const results = [];
920024
+ for (const workspace of workspaces) {
920025
+ const generatorsConfiguration = workspace.generatorsConfiguration;
920026
+ if (generatorsConfiguration == null) {
920027
+ continue;
920028
+ }
920029
+ for (const group of generatorsConfiguration.groups) {
920030
+ if (groupFilter != null && group.groupName !== groupFilter) {
920031
+ continue;
920032
+ }
920033
+ const firstPreviewable = group.generators.find(
920034
+ (generator) => generator.automation.preview && isNpmGenerator(generator.name)
920035
+ );
920036
+ if (firstPreviewable != null) {
920037
+ results.push({
920038
+ groupName: group.groupName,
920039
+ apiName: workspace.workspaceName ?? null,
920040
+ generator: firstPreviewable.name
920041
+ });
920042
+ }
920043
+ }
920044
+ }
920045
+ return results;
920046
+ }
920047
+
919795
920048
  // src/commands/diff/diff.ts
919796
920049
  init_lib4();
919797
920050
  init_lib6();
@@ -928313,26 +928566,6 @@ function getExcludeRules(brokenLinks, strictBrokenLinks) {
928313
928566
  return excludeRules;
928314
928567
  }
928315
928568
 
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
928569
  // src/commands/generate-dynamic-ir/generateDynamicIrForWorkspaces.ts
928337
928570
  init_lib6();
928338
928571
  var import_path88 = __toESM(require("path"), 1);
@@ -930326,163 +930559,6 @@ function generateRandomId() {
930326
930559
  return (0, import_crypto12.randomBytes)(4).toString("hex");
930327
930560
  }
930328
930561
 
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
930562
  // src/commands/sdk-preview/toPreviewPackageName.ts
930487
930563
  function toPreviewPackageName(packageName, org) {
930488
930564
  const scopeMatch = packageName.match(/^@[^/]+\/(.+)$/);
@@ -930502,7 +930578,6 @@ async function sdkPreview({
930502
930578
  groupName,
930503
930579
  generatorFilter,
930504
930580
  apiName,
930505
- json: json3,
930506
930581
  output: output2,
930507
930582
  local,
930508
930583
  pushDiff
@@ -930513,17 +930588,20 @@ async function sdkPreview({
930513
930588
  let publishToRegistry = true;
930514
930589
  try {
930515
930590
  if (pushDiff && local) {
930516
- return cliContext.failAndThrow(
930517
- "--push-diff requires remote generation and cannot be combined with --local."
930518
- );
930591
+ return {
930592
+ status: "error",
930593
+ message: "--push-diff requires remote generation and cannot be combined with --local."
930594
+ };
930519
930595
  }
930520
930596
  const token = await cliContext.runTask(async (context3) => {
930521
930597
  return askToLogin(context3);
930522
930598
  });
930523
930599
  if (token == null) {
930524
- return cliContext.failAndThrow("Authentication required. Run 'fern login' or set FERN_TOKEN.", void 0, {
930600
+ return {
930601
+ status: "error",
930602
+ message: "Authentication required. Run 'fern login' or set FERN_TOKEN.",
930525
930603
  code: CliError.Code.AuthError
930526
- });
930604
+ };
930527
930605
  }
930528
930606
  const project = await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
930529
930607
  commandLineApiWorkspace: apiName,
@@ -930574,27 +930652,27 @@ async function sdkPreview({
930574
930652
  }
930575
930653
  const groupNameOrDefault = groupName ?? workspace.generatorsConfiguration.defaultGroup;
930576
930654
  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
- );
930655
+ return {
930656
+ status: "error",
930657
+ message: `No group specified. Use the --${GROUP_CLI_OPTION} option, or set "${DEFAULT_GROUP_GENERATORS_CONFIG_KEY}" in ${GENERATORS_CONFIGURATION_FILENAME}`,
930658
+ code: CliError.Code.ConfigError
930659
+ };
930582
930660
  }
930583
930661
  const group = workspace.generatorsConfiguration.groups.find((g8) => g8.groupName === groupNameOrDefault);
930584
930662
  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
- );
930663
+ return {
930664
+ status: "error",
930665
+ message: `Group '${groupNameOrDefault}' does not exist in ${GENERATORS_CONFIGURATION_FILENAME}`,
930666
+ code: CliError.Code.ConfigError
930667
+ };
930590
930668
  }
930591
930669
  const generators = generatorFilter != null ? group.generators.filter((g8) => g8.name === generatorFilter) : group.generators;
930592
930670
  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
- );
930671
+ return {
930672
+ status: "error",
930673
+ message: `Generator '${generatorFilter}' not found in group '${groupNameOrDefault}' in ${GENERATORS_CONFIGURATION_FILENAME}`,
930674
+ code: CliError.Code.ConfigError
930675
+ };
930598
930676
  }
930599
930677
  const npmGenerators = generators.filter((g8) => isNpmGenerator(g8.name));
930600
930678
  const skippedGenerators = generators.filter((g8) => !isNpmGenerator(g8.name));
@@ -930604,20 +930682,20 @@ async function sdkPreview({
930604
930682
  );
930605
930683
  }
930606
930684
  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
- );
930685
+ return {
930686
+ status: "error",
930687
+ message: `No supported generators found in group '${groupNameOrDefault}'. SDK preview currently only supports TypeScript/npm generators.`,
930688
+ code: CliError.Code.ConfigError
930689
+ };
930612
930690
  }
930613
930691
  for (const generator of npmGenerators) {
930614
930692
  const originalPackageName = getPackageNameFromGeneratorConfig(generator);
930615
930693
  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
- );
930694
+ return {
930695
+ status: "error",
930696
+ message: `Could not determine package name for generator '${generator.name}'. Ensure 'output.package-name' is set in ${GENERATORS_CONFIGURATION_FILENAME}.`,
930697
+ code: CliError.Code.ConfigError
930698
+ };
930621
930699
  }
930622
930700
  const previewPackageName = toPreviewPackageName(originalPackageName, project.config.organization);
930623
930701
  const previewVersion = computePreviewVersion({ previewId });
@@ -930738,51 +930816,12 @@ async function sdkPreview({
930738
930816
  }
930739
930817
  }
930740
930818
  } 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
930819
+ return {
930820
+ status: "error",
930821
+ message: error50 instanceof Error ? error50.message : String(error50)
930757
930822
  };
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
930823
  }
930824
+ return { status: "success", org: organization ?? "", previews };
930786
930825
  }
930787
930826
 
930788
930827
  // src/commands/self-update/selfUpdate.ts
@@ -938696,6 +938735,7 @@ function addAutomationsCommand(cli, cliContext) {
938696
938735
  cli.command("automations", false, (yargs) => {
938697
938736
  addAutomationsListCommand(yargs, cliContext);
938698
938737
  addAutomationsGenerateCommand(yargs, cliContext);
938738
+ addAutomationsPreviewCommand(yargs, cliContext);
938699
938739
  return yargs.demandCommand();
938700
938740
  });
938701
938741
  }
@@ -938729,37 +938769,116 @@ function addAutomationsListGenerateCommand(cli, cliContext) {
938729
938769
  commandLineApiWorkspace: argv.api,
938730
938770
  defaultToAllApiWorkspaces: true
938731
938771
  });
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;
938772
+ const commands = listGenerateCommands({
938773
+ workspaces: project.apiWorkspaces,
938774
+ groupFilter: argv.group,
938775
+ version: argv.version,
938776
+ autoMerge: argv["auto-merge"]
938777
+ });
938778
+ process.stdout.write(JSON.stringify(commands));
938779
+ }
938780
+ );
938781
+ }
938782
+ function addAutomationsPreviewCommand(cli, cliContext) {
938783
+ cli.command(
938784
+ "preview",
938785
+ false,
938786
+ // hidden
938787
+ (yargs) => yargs.option("group", {
938788
+ type: "string",
938789
+ description: "Filter to a specific generator group (e.g. 'sdk'). Omit to preview all eligible groups."
938790
+ }).option("json", {
938791
+ boolean: true,
938792
+ default: false,
938793
+ description: "Output results as JSON (for machine consumption)."
938794
+ }).option("push-diff", {
938795
+ boolean: true,
938796
+ default: false,
938797
+ description: "Push a preview diff branch (fern-preview-{version}) to each SDK repo in addition to publishing to the preview registry."
938798
+ }),
938799
+ async (argv) => {
938800
+ cliContext.instrumentPostHogEvent({
938801
+ command: "fern automations preview"
938802
+ });
938803
+ const project = await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
938804
+ commandLineApiWorkspace: void 0,
938805
+ defaultToAllApiWorkspaces: true
938806
+ });
938807
+ const groups2 = listPreviewGroups({
938808
+ workspaces: project.apiWorkspaces,
938809
+ groupFilter: argv.group
938810
+ });
938811
+ if (groups2.length === 0) {
938812
+ if (argv.json) {
938813
+ process.stdout.write(JSON.stringify({ results: [] }, null, 2) + "\n");
938814
+ } else {
938815
+ cliContext.logger.info("No eligible generator groups found for preview.");
938816
+ }
938817
+ return;
938818
+ }
938819
+ cliContext.logger.info(
938820
+ `Found ${groups2.length} previewable group(s): ${groups2.map((g8) => g8.groupName).join(", ")}`
938821
+ );
938822
+ const results = [];
938823
+ for (const group of groups2) {
938824
+ const apiLabel = group.apiName != null ? ` (api: ${group.apiName})` : "";
938825
+ cliContext.logger.info(`Running preview for ${group.groupName}${apiLabel}...`);
938826
+ try {
938827
+ const result = await sdkPreview({
938828
+ cliContext,
938829
+ groupName: group.groupName,
938830
+ generatorFilter: void 0,
938831
+ apiName: group.apiName ?? void 0,
938832
+ output: void 0,
938833
+ local: false,
938834
+ pushDiff: argv["push-diff"]
938835
+ });
938836
+ if (result.status === "success") {
938837
+ results.push({
938838
+ groupName: group.groupName,
938839
+ apiName: group.apiName,
938840
+ status: "success",
938841
+ org: result.org,
938842
+ previews: result.previews
938843
+ });
938844
+ } else {
938845
+ results.push({
938846
+ groupName: group.groupName,
938847
+ apiName: group.apiName,
938848
+ status: "error",
938849
+ error: result.message
938850
+ });
938740
938851
  }
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");
938852
+ } catch (error50) {
938853
+ const message = error50 instanceof Error ? error50.message : String(error50);
938854
+ cliContext.logger.warn(`Preview failed for group '${group.groupName}': ${message}`);
938855
+ results.push({
938856
+ groupName: group.groupName,
938857
+ apiName: group.apiName,
938858
+ status: "error",
938859
+ error: message
938860
+ });
938861
+ }
938862
+ }
938863
+ if (argv.json) {
938864
+ process.stdout.write(JSON.stringify({ results }, null, 2) + "\n");
938865
+ } else {
938866
+ for (const groupResult of results) {
938867
+ if (groupResult.status === "success" && groupResult.previews != null) {
938868
+ for (const preview of groupResult.previews) {
938869
+ if (preview.install) {
938870
+ cliContext.logger.info(`${groupResult.groupName}: ${preview.install}`);
938871
+ }
938757
938872
  }
938758
- commands.push(parts.join(" "));
938873
+ } else if (groupResult.status === "error") {
938874
+ cliContext.logger.warn(`${groupResult.groupName}: ${groupResult.error}`);
938759
938875
  }
938760
938876
  }
938761
938877
  }
938762
- process.stdout.write(JSON.stringify(commands));
938878
+ const hasErrors = results.some((r5) => r5.status === "error");
938879
+ if (hasErrors) {
938880
+ process.exitCode = 1;
938881
+ }
938763
938882
  }
938764
938883
  );
938765
938884
  }
@@ -938857,19 +938976,71 @@ function addSdkPreviewCommand(cli, cliContext) {
938857
938976
  command: "fern sdk preview"
938858
938977
  });
938859
938978
  const generatorFilter = argv.generator != null ? warnAndCorrectIncorrectDockerOrg(argv.generator, cliContext) : void 0;
938860
- await sdkPreview({
938979
+ const result = await sdkPreview({
938861
938980
  cliContext,
938862
938981
  groupName: argv.group,
938863
938982
  generatorFilter,
938864
938983
  apiName: argv.api,
938865
- json: argv.json,
938866
938984
  output: argv.output,
938867
938985
  local: argv.local,
938868
938986
  pushDiff: argv.pushDiff
938869
938987
  });
938988
+ writeSdkPreviewOutput({ result, json: argv.json, cliContext });
938870
938989
  }
938871
938990
  );
938872
938991
  }
938992
+ function writeSdkPreviewOutput({
938993
+ result,
938994
+ json: json3,
938995
+ cliContext
938996
+ }) {
938997
+ if (json3) {
938998
+ process.stdout.write(JSON.stringify(result, null, 2) + "\n");
938999
+ if (result.status === "error") {
939000
+ process.exitCode = 1;
939001
+ }
939002
+ return;
939003
+ }
939004
+ if (result.status === "error") {
939005
+ return cliContext.failAndThrow(
939006
+ result.message,
939007
+ void 0,
939008
+ result.code != null ? { code: result.code } : void 0
939009
+ );
939010
+ }
939011
+ if (result.previews.length > 0) {
939012
+ cliContext.logger.info("");
939013
+ const hasRegistry = result.previews.some((p9) => p9.registry_url !== "");
939014
+ if (hasRegistry) {
939015
+ cliContext.logger.info(
939016
+ `Published ${result.previews.length} preview package${result.previews.length > 1 ? "s" : ""}:`
939017
+ );
939018
+ for (const preview of result.previews) {
939019
+ cliContext.logger.info("");
939020
+ cliContext.logger.info(` ${preview.package_name}@${preview.version}`);
939021
+ cliContext.logger.info(` Install: ${preview.install}`);
939022
+ if (preview.diff_url) {
939023
+ cliContext.logger.info(` Diff: ${preview.diff_url}`);
939024
+ }
939025
+ if (preview.output_path) {
939026
+ cliContext.logger.info(` Output: ${preview.output_path}`);
939027
+ }
939028
+ }
939029
+ } else {
939030
+ cliContext.logger.info(
939031
+ `Generated ${result.previews.length} preview SDK${result.previews.length > 1 ? "s" : ""}:`
939032
+ );
939033
+ for (const preview of result.previews) {
939034
+ cliContext.logger.info("");
939035
+ cliContext.logger.info(` ${preview.package_name}@${preview.version}`);
939036
+ if (preview.diff_url) {
939037
+ cliContext.logger.info(` Diff: ${preview.diff_url}`);
939038
+ }
939039
+ cliContext.logger.info(` Output: ${preview.output_path}`);
939040
+ }
939041
+ }
939042
+ }
939043
+ }
938873
939044
  function addBetaCommand(cli, cliContext) {
938874
939045
  cli.command(
938875
939046
  "beta",
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.79.4",
2
+ "version": "4.80.0-1-g796a68387d5",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",