@fern-api/fern-api-dev 4.81.0-4-g68a17190a26 → 4.81.0-8-gd28a2402e04

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 +165 -56
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -535712,7 +535712,7 @@ async function validateSchema({ schema: schema2, value: value2, context: context
535712
535712
  });
535713
535713
  });
535714
535714
  const errorMessage = [`Failed to parse file: ${import_path20.default.relative(process.cwd(), filepathBeingParsed)}`, ...issues].join("\n");
535715
- return context3.failAndThrow(errorMessage);
535715
+ return context3.failAndThrow(errorMessage, void 0, { code: CliError.Code.ConfigError });
535716
535716
  }
535717
535717
  function joinZodPath(arr) {
535718
535718
  return arr.reduce((acc, value2) => {
@@ -535745,7 +535745,9 @@ async function convertDependenciesConfiguration({ absolutePathToWorkspace, rawDe
535745
535745
  path: versionOrPath
535746
535746
  };
535747
535747
  } else {
535748
- context3.failWithoutThrowing(`Path to ${coordinate} dependency does not exist: ${pathToApi}`);
535748
+ context3.failWithoutThrowing(`Path to ${coordinate} dependency does not exist: ${pathToApi}`, void 0, {
535749
+ code: CliError.Code.ConfigError
535750
+ });
535749
535751
  }
535750
535752
  } else {
535751
535753
  const unprefixedCoordinate = coordinate.substring(1);
@@ -535760,12 +535762,14 @@ async function convertDependenciesConfiguration({ absolutePathToWorkspace, rawDe
535760
535762
  version: versionOrPath
535761
535763
  };
535762
535764
  } else {
535763
- context3.failWithoutThrowing(`Failed to parse dependency: ${coordinate}`);
535765
+ context3.failWithoutThrowing(`Failed to parse dependency: ${coordinate}`, void 0, {
535766
+ code: CliError.Code.ConfigError
535767
+ });
535764
535768
  }
535765
535769
  }
535766
535770
  }
535767
535771
  if (context3.getResult() === TaskResult.Failure) {
535768
- context3.failAndThrow();
535772
+ context3.failAndThrow(void 0, void 0, { code: CliError.Code.ConfigError });
535769
535773
  }
535770
535774
  return {
535771
535775
  dependencies
@@ -535921,7 +535925,7 @@ function getColorInstanceFromRawConfigOrThrow(raw, context3, key2, theme) {
535921
535925
  }
535922
535926
  const instance = tinycolor(color3);
535923
535927
  if (!instance.isValid()) {
535924
- context3.failAndThrow(`'${typeof raw === "string" ? key2 : `colors.${key2}.${theme}`}' should be a hex color of the format #FFFFFF`);
535928
+ context3.failAndThrow(`'${typeof raw === "string" ? key2 : `colors.${key2}.${theme}`}' should be a hex color of the format #FFFFFF`, void 0, { code: CliError.Code.ConfigError });
535925
535929
  }
535926
535930
  return instance;
535927
535931
  }
@@ -536535,7 +536539,7 @@ async function parseContext7File({ rawPath, absoluteFilepathToDocsConfig, contex
536535
536539
  try {
536536
536540
  JSON.parse(contents);
536537
536541
  } catch (error50) {
536538
- context3.failAndThrow(`Invalid JSON in Context7 config file: ${rawPath}`, error50 instanceof Error ? error50.message : String(error50));
536542
+ context3.failAndThrow(`Invalid JSON in Context7 config file: ${rawPath}`, error50 instanceof Error ? error50.message : String(error50), { code: CliError.Code.ConfigError });
536539
536543
  }
536540
536544
  return absolutePath;
536541
536545
  }
@@ -536695,7 +536699,10 @@ async function getNavigationConfiguration({ tabs, products, versions, navigation
536695
536699
  featureFlags: convertFeatureFlag(product.featureFlag)
536696
536700
  });
536697
536701
  } else {
536698
- throw new Error(`Invalid product configuration: product must have either 'path' or valid 'href' property`);
536702
+ throw new CliError({
536703
+ message: `Invalid product configuration: product must have either 'path' or valid 'href' property`,
536704
+ code: CliError.Code.ConfigError
536705
+ });
536699
536706
  }
536700
536707
  }
536701
536708
  return {
@@ -536710,7 +536717,10 @@ async function getNavigationConfiguration({ tabs, products, versions, navigation
536710
536717
  folderTitleSource
536711
536718
  });
536712
536719
  }
536713
- throw new Error("Unexpected. Docs have neither navigation or versions defined.");
536720
+ throw new CliError({
536721
+ message: "Unexpected. Docs have neither navigation or versions defined.",
536722
+ code: CliError.Code.ConfigError
536723
+ });
536714
536724
  }
536715
536725
  function convertFeatureFlag(flag) {
536716
536726
  if (flag == null) {
@@ -536808,7 +536818,10 @@ function parseWeight(weight) {
536808
536818
  async function convertNavigationTabConfiguration({ tabs, item, absolutePathToFernFolder, absolutePathToConfig, context: context3, folderTitleSource }) {
536809
536819
  const tab2 = tabs[item.tab];
536810
536820
  if (tab2 == null) {
536811
- throw new Error(`Tab ${item.tab} is not defined in the tabs config.`);
536821
+ throw new CliError({
536822
+ message: `Tab ${item.tab} is not defined in the tabs config.`,
536823
+ code: CliError.Code.ConfigError
536824
+ });
536812
536825
  }
536813
536826
  if (tabbedNavigationItemHasVariants(item)) {
536814
536827
  const variants = await Promise.all(item.variants.map(async (variant) => {
@@ -536937,7 +536950,9 @@ var DEFAULT_CHANGELOG_TITLE = "Changelog";
536937
536950
  async function expandFolderConfiguration({ rawConfig, absolutePathToFernFolder, absolutePathToConfig, context: context3, folderTitleSource }) {
536938
536951
  const folderPath = resolveFilepath(rawConfig.folder, absolutePathToConfig);
536939
536952
  if (!await doesPathExist(folderPath)) {
536940
- context3.failAndThrow(`Folder not found: ${rawConfig.folder}`);
536953
+ context3.failAndThrow(`Folder not found: ${rawConfig.folder}`, void 0, {
536954
+ code: CliError.Code.ConfigError
536955
+ });
536941
536956
  }
536942
536957
  validateCollapsibleConfig({
536943
536958
  context: context3,
@@ -537260,7 +537275,10 @@ function parseLibrariesConfiguration(libraries) {
537260
537275
  const result = {};
537261
537276
  for (const [name2, config5] of Object.entries(libraries)) {
537262
537277
  if (!isGitLibraryInput(config5.input)) {
537263
- throw new Error(`Library '${name2}' uses 'path' input which is not yet supported. Please use 'git' input.`);
537278
+ throw new CliError({
537279
+ message: `Library '${name2}' uses 'path' input which is not yet supported. Please use 'git' input.`,
537280
+ code: CliError.Code.ConfigError
537281
+ });
537264
537282
  }
537265
537283
  result[name2] = {
537266
537284
  input: {
@@ -537449,10 +537467,10 @@ function parseAudiences(raw) {
537449
537467
  }
537450
537468
  function validateCollapsibleConfig({ context: context3, sectionTitle, collapsed, collapsible, collapsedByDefault }) {
537451
537469
  if (collapsible != null && collapsed != null) {
537452
- context3.failAndThrow(`Section "${sectionTitle}": cannot use both "collapsible" and the deprecated "collapsed" property. Please use "collapsible" and "collapsed-by-default" instead.`);
537470
+ context3.failAndThrow(`Section "${sectionTitle}": cannot use both "collapsible" and the deprecated "collapsed" property. Please use "collapsible" and "collapsed-by-default" instead.`, void 0, { code: CliError.Code.ConfigError });
537453
537471
  }
537454
537472
  if (collapsedByDefault != null && collapsible !== true) {
537455
- context3.failAndThrow(`Section "${sectionTitle}": "collapsed-by-default" requires "collapsible: true". "collapsed-by-default" has no effect on a non-collapsible section.`);
537473
+ context3.failAndThrow(`Section "${sectionTitle}": "collapsed-by-default" requires "collapsible: true". "collapsed-by-default" has no effect on a non-collapsible section.`, void 0, { code: CliError.Code.ConfigError });
537456
537474
  }
537457
537475
  }
537458
537476
 
@@ -537727,7 +537745,9 @@ function removeDefaultDockerOrgIfPresent(generatorName) {
537727
537745
  function getGeneratorNameOrThrow(generatorName, context3) {
537728
537746
  const normalizedGeneratorName = normalizeGeneratorName(generatorName);
537729
537747
  if (normalizedGeneratorName == null) {
537730
- return context3.failAndThrow("Unrecognized generator: " + generatorName);
537748
+ return context3.failAndThrow("Unrecognized generator: " + generatorName, void 0, {
537749
+ code: CliError.Code.ConfigError
537750
+ });
537731
537751
  }
537732
537752
  return normalizedGeneratorName;
537733
537753
  }
@@ -537854,9 +537874,9 @@ async function updateGeneratorGroup({ generatorsConfiguration, groupName = gener
537854
537874
  const availableGroups = Object.keys(generatorsConfiguration.groups ?? {});
537855
537875
  if (availableGroups.length > 0) {
537856
537876
  const message = "No group specified. Use the --group option:\n" + availableGroups.map((name2) => ` \u203A ${name2}`).join("\n");
537857
- return context3.failAndThrow(message);
537877
+ return context3.failAndThrow(message, void 0, { code: CliError.Code.ConfigError });
537858
537878
  }
537859
- return context3.failAndThrow("No group specified.");
537879
+ return context3.failAndThrow("No group specified.", void 0, { code: CliError.Code.ConfigError });
537860
537880
  }
537861
537881
  const groups2 = generatorsConfiguration.groups ??= {};
537862
537882
  const group = groups2[groupName];
@@ -537880,7 +537900,9 @@ async function addGenerator({ generatorName, generatorsConfiguration, groupName
537880
537900
  context: context3,
537881
537901
  update: async (group) => {
537882
537902
  if (group.generators.some((generator) => addDefaultDockerOrgIfNotPresent("image" in generator ? generator.image.name : generator.name) === normalizedGeneratorName)) {
537883
- context3.failAndThrow(`${generatorName} is already installed in group ${groupName}.`);
537903
+ context3.failAndThrow(`${generatorName} is already installed in group ${groupName}.`, void 0, {
537904
+ code: CliError.Code.ConfigError
537905
+ });
537884
537906
  }
537885
537907
  const latestVersion2 = await getLatestGeneratorVersion({
537886
537908
  cliVersion,
@@ -544443,7 +544465,10 @@ function parseRemoveDiscriminantsFromSchemas(option) {
544443
544465
  } else if (option === "never") {
544444
544466
  return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
544445
544467
  }
544446
- throw new Error(`Unknown value for generators.yml API setting: remove-discriminants-from-schemas: ${option}`);
544468
+ throw new CliError({
544469
+ message: `Unknown value for generators.yml API setting: remove-discriminants-from-schemas: ${option}`,
544470
+ code: CliError.Code.ConfigError
544471
+ });
544447
544472
  }
544448
544473
  function mergeSettings(base4, override) {
544449
544474
  return {
@@ -545010,7 +545035,10 @@ async function getGithubLicense({ absolutePathToGeneratorsConfiguration, githubL
545010
545035
  function getGithubPublishInfo(output2, maybeGroupLevelMetadata, maybeTopLevelMetadata) {
545011
545036
  switch (output2.location) {
545012
545037
  case "local-file-system":
545013
- throw new Error("Cannot use local-file-system with github publishing");
545038
+ throw new CliError({
545039
+ message: "Cannot use local-file-system with github publishing",
545040
+ code: CliError.Code.ConfigError
545041
+ });
545014
545042
  case "npm":
545015
545043
  return api_exports4.GithubPublishInfo.npm({
545016
545044
  registryUrl: output2.url ?? "https://registry.npmjs.org",
@@ -545203,7 +545231,10 @@ async function loadRawGeneratorsConfiguration({ absolutePathToWorkspace, context
545203
545231
  if (parsed.ok) {
545204
545232
  return parsed.value;
545205
545233
  }
545206
- throw new Error(parsed.errors.map((e5) => e5.message).join("\n"));
545234
+ throw new CliError({
545235
+ message: parsed.errors.map((e5) => e5.message).join("\n"),
545236
+ code: CliError.Code.ConfigError
545237
+ });
545207
545238
  } catch (e5) {
545208
545239
  if (e5 instanceof jsYaml.YAMLException) {
545209
545240
  const relativePath = import_path24.default.relative(process.cwd(), filepath);
@@ -545225,7 +545256,7 @@ ${e5.mark.snippet}`;
545225
545256
  errorMessage += '\n\nHint: Values starting with "@" (such as scoped npm packages) must be wrapped in quotes.\n Example: package-name: "@scope/package"';
545226
545257
  }
545227
545258
  }
545228
- context3.failAndThrow(errorMessage);
545259
+ context3.failAndThrow(errorMessage, void 0, { code: CliError.Code.ConfigError });
545229
545260
  } else {
545230
545261
  throw e5;
545231
545262
  }
@@ -614356,7 +614387,7 @@ var AccessTokenPosthogManager = class {
614356
614387
  properties: {
614357
614388
  ...event,
614358
614389
  ...event.properties,
614359
- version: "4.81.0-4-g68a17190a26",
614390
+ version: "4.81.0-8-gd28a2402e04",
614360
614391
  usingAccessToken: true
614361
614392
  }
614362
614393
  });
@@ -614410,7 +614441,7 @@ var UserPosthogManager = class {
614410
614441
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
614411
614442
  event: "CLI",
614412
614443
  properties: {
614413
- version: "4.81.0-4-g68a17190a26",
614444
+ version: "4.81.0-8-gd28a2402e04",
614414
614445
  ...event,
614415
614446
  ...event.properties,
614416
614447
  usingAccessToken: false,
@@ -615614,7 +615645,10 @@ var PlatformKeyring = class {
615614
615645
  await this.setPasswordWindows(service, account, password);
615615
615646
  break;
615616
615647
  default:
615617
- throw new Error(`Unsupported platform: ${process.platform}`);
615648
+ throw new CliError({
615649
+ message: `Unsupported platform: ${process.platform}`,
615650
+ code: CliError.Code.EnvironmentError
615651
+ });
615618
615652
  }
615619
615653
  }
615620
615654
  async getPassword(service, account) {
@@ -615626,7 +615660,10 @@ var PlatformKeyring = class {
615626
615660
  case "win32":
615627
615661
  return this.getPasswordWindows(service, account);
615628
615662
  default:
615629
- throw new Error(`Unsupported platform: ${process.platform}`);
615663
+ throw new CliError({
615664
+ message: `Unsupported platform: ${process.platform}`,
615665
+ code: CliError.Code.EnvironmentError
615666
+ });
615630
615667
  }
615631
615668
  }
615632
615669
  async deletePassword(service, account) {
@@ -615638,7 +615675,10 @@ var PlatformKeyring = class {
615638
615675
  case "win32":
615639
615676
  return this.deletePasswordWindows(service, account);
615640
615677
  default:
615641
- throw new Error(`Unsupported platform: ${process.platform}`);
615678
+ throw new CliError({
615679
+ message: `Unsupported platform: ${process.platform}`,
615680
+ code: CliError.Code.EnvironmentError
615681
+ });
615642
615682
  }
615643
615683
  }
615644
615684
  async findCredentials(service) {
@@ -615650,7 +615690,10 @@ var PlatformKeyring = class {
615650
615690
  case "win32":
615651
615691
  return this.findCredentialsWindows(service);
615652
615692
  default:
615653
- throw new Error(`Unsupported platform: ${process.platform}`);
615693
+ throw new CliError({
615694
+ message: `Unsupported platform: ${process.platform}`,
615695
+ code: CliError.Code.EnvironmentError
615696
+ });
615654
615697
  }
615655
615698
  }
615656
615699
  async setPasswordDarwin(service, account, password) {
@@ -617763,7 +617806,10 @@ var FileFinder = class {
617763
617806
  async findOrThrow({ filename, remediationMessage }) {
617764
617807
  const filepath = await this.find({ filename });
617765
617808
  if (filepath == null) {
617766
- throw new Error(`${filename} file not found in any parent directory from ${this.from}`);
617809
+ throw new CliError({
617810
+ message: `${filename} file not found in any parent directory from ${this.from}`,
617811
+ code: CliError.Code.InternalError
617812
+ });
617767
617813
  }
617768
617814
  return filepath;
617769
617815
  }
@@ -617805,7 +617851,10 @@ var FernYmlSchemaLoader = class {
617805
617851
  async loadOrThrow() {
617806
617852
  const loadResult = await this.load();
617807
617853
  if (loadResult.type === "notFound") {
617808
- throw new Error(`${FILENAME2} file not found in any parent directory; did you forget to run \`fern init\`?`);
617854
+ throw new CliError({
617855
+ message: `${FILENAME2} file not found in any parent directory; did you forget to run \`fern init\`?`,
617856
+ code: CliError.Code.InternalError
617857
+ });
617809
617858
  }
617810
617859
  if (loadResult.type === "failure") {
617811
617860
  throw new SourcedValidationError(loadResult.issues);
@@ -617876,7 +617925,10 @@ var TelemetryClient = class _TelemetryClient {
617876
617925
  if (sentryDsn != null && sentryDsn.length > 0 && isTelemetryEnabled) {
617877
617926
  const sentryEnvironment = "development";
617878
617927
  if (sentryEnvironment == null || sentryEnvironment.length === 0) {
617879
- throw new Error("SENTRY_ENVIRONMENT must be set when SENTRY_DSN is configured");
617928
+ throw new CliError({
617929
+ message: "SENTRY_ENVIRONMENT must be set when SENTRY_DSN is configured",
617930
+ code: CliError.Code.ConfigError
617931
+ });
617880
617932
  }
617881
617933
  this.sentry = init2({
617882
617934
  dsn: sentryDsn,
@@ -618176,7 +618228,10 @@ var ApiDefinitionConverter = class {
618176
618228
  sourced
618177
618229
  });
618178
618230
  }
618179
- throw new Error(`Unknown spec type: ${JSON.stringify(spec)}`);
618231
+ throw new CliError({
618232
+ message: `Unknown spec type: ${JSON.stringify(spec)}`,
618233
+ code: CliError.Code.InternalError
618234
+ });
618180
618235
  }
618181
618236
  async convertOpenApiSpec({ absoluteFernYmlPath, spec, sourced }) {
618182
618237
  const result = {
@@ -619536,7 +619591,10 @@ var LegacyApiSpecAdapter = class {
619536
619591
  if (isOpenRpcSpec(spec)) {
619537
619592
  return this.adaptOpenRpcSpec(spec);
619538
619593
  }
619539
- throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
619594
+ throw new CliError({
619595
+ message: `Unsupported spec type: ${JSON.stringify(spec)}`,
619596
+ code: CliError.Code.InternalError
619597
+ });
619540
619598
  }
619541
619599
  convertAll(specs) {
619542
619600
  return specs.map((spec) => this.adapt(spec));
@@ -746685,7 +746743,10 @@ var LegacyFernWorkspaceAdapter = class {
746685
746743
  generatorsConfiguration: apiConfig != null ? this.buildGeneratorsConfiguration(apiConfig) : void 0
746686
746744
  });
746687
746745
  if (ossWorkspace == null) {
746688
- throw new Error("Internal error; failed to build API definitions");
746746
+ throw new CliError({
746747
+ message: "Internal error; failed to build API definitions",
746748
+ code: CliError.Code.InternalError
746749
+ });
746689
746750
  }
746690
746751
  return ossWorkspace.toFernWorkspace({ context: this.taskContext });
746691
746752
  }
@@ -747842,7 +747903,10 @@ function addSplitCommand(cli) {
747842
747903
  description: `Output format: '${OVERLAY_NAME}' (OpenAPI Overlay 1.0.0) or '${OVERRIDES_NAME}' (Fern deep-merge)`
747843
747904
  }).coerce("format", (value2) => {
747844
747905
  if (!ALL_FORMAT_NAMES.includes(value2)) {
747845
- throw new Error(`Invalid format '${value2}'. Expected one of: ${OVERLAY_NAME}, ${OVERRIDES_NAME}`);
747906
+ throw new CliError({
747907
+ message: `Invalid format '${value2}'. Expected one of: ${OVERLAY_NAME}, ${OVERRIDES_NAME}`,
747908
+ code: CliError.Code.ValidationError
747909
+ });
747846
747910
  }
747847
747911
  return value2;
747848
747912
  }));
@@ -827894,7 +827958,7 @@ var DocsWorkspaceValidator = class {
827894
827958
  const startTime = performance.now();
827895
827959
  if (workspace.config.settings?.substituteEnvVars) {
827896
827960
  workspace.config = replaceEnvVariables(workspace.config, {
827897
- onError: (error50) => this.taskContext.failAndThrow(error50)
827961
+ onError: (error50) => this.taskContext.failAndThrow(error50, void 0, { code: CliError.Code.ConfigError })
827898
827962
  });
827899
827963
  }
827900
827964
  const violations = await validateDocsWorkspace(workspace, this.taskContext, apiWorkspaces, ossWorkspaces, false, excludeRules);
@@ -831728,7 +831792,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
831728
831792
  var LOGS_FOLDER_NAME = "logs";
831729
831793
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
831730
831794
  function getCliSource() {
831731
- const version7 = "4.81.0-4-g68a17190a26";
831795
+ const version7 = "4.81.0-8-gd28a2402e04";
831732
831796
  return `cli@${version7}`;
831733
831797
  }
831734
831798
  var DebugLogger = class {
@@ -843295,7 +843359,7 @@ var LegacyDocsPublisher = class {
843295
843359
  previewId,
843296
843360
  disableTemplates: void 0,
843297
843361
  skipUpload,
843298
- cliVersion: "4.81.0-4-g68a17190a26"
843362
+ cliVersion: "4.81.0-8-gd28a2402e04"
843299
843363
  });
843300
843364
  if (taskContext.getResult() === TaskResult.Failure) {
843301
843365
  return { success: false };
@@ -843770,7 +843834,10 @@ var DocsTask = class {
843770
843834
  getTask() {
843771
843835
  const task = this.taskGroup.getTask(this.id);
843772
843836
  if (task == null) {
843773
- throw new Error(`Internal error; task '${this.id}' does not exist`);
843837
+ throw new CliError({
843838
+ message: `Internal error; task '${this.id}' does not exist`,
843839
+ code: CliError.Code.InternalError
843840
+ });
843774
843841
  }
843775
843842
  return task;
843776
843843
  }
@@ -845042,7 +845109,10 @@ var Wizard = class {
845042
845109
  async fetchApiFromUrl(url3, specFormat) {
845043
845110
  const response = await fetch(url3, { signal: AbortSignal.timeout(FETCH_API_SPEC_REQUEST_TIMEOUT_MS) });
845044
845111
  if (!response.ok) {
845045
- throw new Error(`HTTP ${response.status} ${response.statusText}`);
845112
+ throw new CliError({
845113
+ message: `HTTP ${response.status} ${response.statusText}`,
845114
+ code: CliError.Code.NetworkError
845115
+ });
845046
845116
  }
845047
845117
  const content5 = await response.text();
845048
845118
  const filename = this.resolveFilenameFromUrl({ url: url3, specFormat });
@@ -846572,20 +846642,29 @@ var ApiSpecDetector = class {
846572
846642
  async detect({ absoluteFilePath, reference: reference4, content: content5 }) {
846573
846643
  const parsed = this.parseOrThrow({ content: content5, reference: reference4 });
846574
846644
  if (typeof parsed !== "object" || parsed == null) {
846575
- throw new Error(`Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`);
846645
+ throw new CliError({
846646
+ message: `Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`,
846647
+ code: CliError.Code.InternalError
846648
+ });
846576
846649
  }
846577
846650
  for (const specType of DETECTABLE_SPEC_TYPES) {
846578
846651
  if (specType in parsed) {
846579
846652
  return specType;
846580
846653
  }
846581
846654
  }
846582
- throw new Error(`Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`);
846655
+ throw new CliError({
846656
+ message: `Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`,
846657
+ code: CliError.Code.InternalError
846658
+ });
846583
846659
  }
846584
846660
  parseOrThrow({ content: content5, reference: reference4 }) {
846585
846661
  try {
846586
846662
  return jsYaml.load(content5);
846587
846663
  } catch {
846588
- throw new Error(`Could not parse "${reference4}" as YAML or JSON. Ensure the file is a valid OpenAPI or AsyncAPI specification.`);
846664
+ throw new CliError({
846665
+ message: `Could not parse "${reference4}" as YAML or JSON. Ensure the file is a valid OpenAPI or AsyncAPI specification.`,
846666
+ code: CliError.Code.ParseError
846667
+ });
846589
846668
  }
846590
846669
  }
846591
846670
  };
@@ -846623,7 +846702,10 @@ var ApiSpecResolver = class {
846623
846702
  async resolveLocal({ reference: reference4 }) {
846624
846703
  const absoluteFilePath = resolve6(this.context.cwd, reference4);
846625
846704
  if (!await doesPathExist(absoluteFilePath)) {
846626
- throw new Error(`API spec file does not exist: ${reference4}`);
846705
+ throw new CliError({
846706
+ message: `API spec file does not exist: ${reference4}`,
846707
+ code: CliError.Code.ConfigError
846708
+ });
846627
846709
  }
846628
846710
  const content5 = await (0, import_promises92.readFile)(absoluteFilePath, "utf-8");
846629
846711
  const specType = await this.detector.detect({ absoluteFilePath, content: content5, reference: reference4 });
@@ -846636,11 +846718,17 @@ var ApiSpecResolver = class {
846636
846718
  async fetchContent({ url: url3 }) {
846637
846719
  const response = await fetch(url3, { signal: AbortSignal.timeout(FETCH_API_SPEC_REQUEST_TIMEOUT_MS) });
846638
846720
  if (!response.ok) {
846639
- throw new Error(`Failed to fetch "${url3}": HTTP ${response.status} ${response.statusText}`);
846721
+ throw new CliError({
846722
+ message: `Failed to fetch "${url3}": HTTP ${response.status} ${response.statusText}`,
846723
+ code: CliError.Code.NetworkError
846724
+ });
846640
846725
  }
846641
846726
  const contentType = response.headers.get("content-type") ?? "";
846642
846727
  if (contentType.includes("text/html")) {
846643
- throw new Error(`The URL "${url3}" returned HTML content. Ensure you're pointing to a raw spec URL, not a documentation page.`);
846728
+ throw new CliError({
846729
+ message: `The URL "${url3}" returned HTML content. Ensure you're pointing to a raw spec URL, not a documentation page.`,
846730
+ code: CliError.Code.ConfigError
846731
+ });
846644
846732
  }
846645
846733
  const content5 = await response.text();
846646
846734
  return { content: content5, contentType };
@@ -846665,7 +846753,10 @@ var ApiSpecResolver = class {
846665
846753
  case "asyncapi":
846666
846754
  return { asyncapi: absoluteFilePath, origin: origin2 };
846667
846755
  default:
846668
- throw new Error(`Unsupported spec type for flags mode: "${specType}". Supported: openapi, asyncapi`);
846756
+ throw new CliError({
846757
+ message: `Unsupported spec type for flags mode: "${specType}". Supported: openapi, asyncapi`,
846758
+ code: CliError.Code.ConfigError
846759
+ });
846669
846760
  }
846670
846761
  }
846671
846762
  isUrl(reference4) {
@@ -897467,7 +897558,10 @@ var LegacyGeneratorInvocationAdapter = class {
897467
897558
  }
897468
897559
  const absolutePath = join8(this.context.cwd, RelativeFilePath2.of(license));
897469
897560
  if (!await doesPathExist(absolutePath, "file")) {
897470
- throw new Error(`Custom license file "${absolutePath}" does not exist; did you mean to use either MIT or Apache-2.0?`);
897561
+ throw new CliError({
897562
+ message: `Custom license file "${absolutePath}" does not exist; did you mean to use either MIT or Apache-2.0?`,
897563
+ code: CliError.Code.InternalError
897564
+ });
897471
897565
  }
897472
897566
  const contents = await (0, import_promises106.readFile)(absolutePath, "utf-8");
897473
897567
  return api_exports4.GithubLicense.custom({ contents });
@@ -897975,7 +898069,10 @@ var SdkTask = class {
897975
898069
  getTask() {
897976
898070
  const task = this.taskGroup.getTask(this.id);
897977
898071
  if (task == null) {
897978
- throw new Error(`Internal error; task '${this.id}' does not exist`);
898072
+ throw new CliError({
898073
+ message: `Internal error; task '${this.id}' does not exist`,
898074
+ code: CliError.Code.InternalError
898075
+ });
897979
898076
  }
897980
898077
  return task;
897981
898078
  }
@@ -898207,7 +898304,7 @@ var GenerateCommand = class {
898207
898304
  }
898208
898305
  async runGeneration({ context: context3, workspace, targets: targets2, args, forceLocal }) {
898209
898306
  if (workspace.sdks == null) {
898210
- throw new Error("No SDKs configured");
898307
+ throw new CliError({ message: "No SDKs configured", code: CliError.Code.InternalError });
898211
898308
  }
898212
898309
  const apisToCheck = [...new Set(targets2.map((t3) => t3.api))];
898213
898310
  const apiChecker = new ApiChecker({
@@ -898889,7 +898986,10 @@ var GeneratorMigrator = class _GeneratorMigrator {
898889
898986
  const packageJsonContent = await (0, import_promises110.readFile)(packageJsonPath, "utf-8");
898890
898987
  const packageJson2 = JSON.parse(packageJsonContent);
898891
898988
  if (packageJson2.main == null) {
898892
- throw new Error(`No main field found in package.json for ${MIGRATION_PACKAGE_NAME}`);
898989
+ throw new CliError({
898990
+ message: `No main field found in package.json for ${MIGRATION_PACKAGE_NAME}`,
898991
+ code: CliError.Code.InternalError
898992
+ });
898893
898993
  }
898894
898994
  const packageEntryPoint = (0, import_path80.join)(packageDir, packageJson2.main);
898895
898995
  const { migrations } = await import((0, import_url8.pathToFileURL)(packageEntryPoint).href);
@@ -899004,11 +899104,14 @@ var GeneratorMigrator = class _GeneratorMigrator {
899004
899104
  this.logger.debug(`No migration package found for ${generatorName}.`);
899005
899105
  return void 0;
899006
899106
  }
899007
- throw new Error(`Failed to load generator migrations for ${generatorName}.
899107
+ throw new CliError({
899108
+ message: `Failed to load generator migrations for ${generatorName}.
899008
899109
 
899009
899110
  Reason: ${errorMessage}
899010
899111
 
899011
- Please check your internet connection and npm configuration, then try again.`);
899112
+ Please check your internet connection and npm configuration, then try again.`,
899113
+ code: CliError.Code.InternalError
899114
+ });
899012
899115
  }
899013
899116
  }
899014
899117
  /**
@@ -899037,7 +899140,10 @@ Please check your internet connection and npm configuration, then try again.`);
899037
899140
  const aVersion = import_semver14.default.parse(a4.version);
899038
899141
  const bVersion = import_semver14.default.parse(b7.version);
899039
899142
  if (aVersion == null || bVersion == null) {
899040
- throw new Error(`Internal error: Invalid migration version found during sort. Version A: ${a4.version}, Version B: ${b7.version}. This should not happen as invalid versions are filtered out.`);
899143
+ throw new CliError({
899144
+ message: `Internal error: Invalid migration version found during sort. Version A: ${a4.version}, Version B: ${b7.version}. This should not happen as invalid versions are filtered out.`,
899145
+ code: CliError.Code.InternalError
899146
+ });
899041
899147
  }
899042
899148
  return import_semver14.default.compare(aVersion, bVersion);
899043
899149
  });
@@ -899055,11 +899161,14 @@ Please check your internet connection and npm configuration, then try again.`);
899055
899161
  appliedVersions.push(migration23.version);
899056
899162
  } catch (error50) {
899057
899163
  const errorMessage = extractErrorMessage(error50);
899058
- throw new Error(`Failed to apply migration for version ${migration23.version}.
899164
+ throw new CliError({
899165
+ message: `Failed to apply migration for version ${migration23.version}.
899059
899166
 
899060
899167
  Reason: ${errorMessage}
899061
899168
 
899062
- Please report this issue at: https://github.com/fern-api/fern/issues`);
899169
+ Please report this issue at: https://github.com/fern-api/fern/issues`,
899170
+ code: CliError.Code.InternalError
899171
+ });
899063
899172
  }
899064
899173
  }
899065
899174
  return {
@@ -918415,7 +918524,7 @@ var CliContext = class _CliContext {
918415
918524
  if (false) {
918416
918525
  this.logger.error("CLI_VERSION is not defined");
918417
918526
  }
918418
- return "4.81.0-4-g68a17190a26";
918527
+ return "4.81.0-8-gd28a2402e04";
918419
918528
  }
918420
918529
  getCliName() {
918421
918530
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.81.0-4-g68a17190a26",
2
+ "version": "4.81.0-8-gd28a2402e04",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",