fern-api 0.16.7 → 0.16.9

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/bundle.cjs +125 -78
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -736685,7 +736685,7 @@ var AccessTokenPosthogManager = class {
736685
736685
  properties: {
736686
736686
  ...event,
736687
736687
  ...event.properties,
736688
- version: "0.16.7",
736688
+ version: "0.16.9",
736689
736689
  usingAccessToken: true
736690
736690
  }
736691
736691
  });
@@ -736747,7 +736747,7 @@ var UserPosthogManager = class {
736747
736747
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
736748
736748
  event: "CLI",
736749
736749
  properties: {
736750
- version: "0.16.7",
736750
+ version: "0.16.9",
736751
736751
  ...event,
736752
736752
  ...event.properties
736753
736753
  }
@@ -761175,10 +761175,10 @@ var CliContext = class {
761175
761175
  return "fern-api";
761176
761176
  }
761177
761177
  getPackageVersion() {
761178
- if ("0.16.7" == null) {
761178
+ if ("0.16.9" == null) {
761179
761179
  this.logger.error("CLI_VERSION is not defined");
761180
761180
  }
761181
- return "0.16.7";
761181
+ return "0.16.9";
761182
761182
  }
761183
761183
  getCliName() {
761184
761184
  if ("fern" == null) {
@@ -768845,36 +768845,48 @@ async function validatePackageMarker({ relativeFilepath, contents, allRuleVisito
768845
768845
 
768846
768846
  // pnp:/home/circleci/project/packages/cli/cli/src/commands/validate/validateAPIWorkspaceAndLogIssues.ts
768847
768847
  var import_validate_npm_package_name = __toESM(require_lib15());
768848
- async function validateAPIWorkspaceAndLogIssues(workspace, context) {
768849
- if (!(0, import_validate_npm_package_name.default)(workspace.name).validForNewPackages) {
768850
- context.failAndThrow("Workspace name is not valid.");
768851
- }
768852
- const violations = await validateFernWorkspace(workspace, context.logger);
768853
- let violationsContainError = false;
768854
- for (const violation of violations) {
768855
- if (!violationsContainError && violation.severity === "error") {
768856
- violationsContainError = true;
768857
- }
768858
- context.logger.log(
768859
- getLogLevelForSeverity(violation.severity),
768860
- formatLog({
768861
- breadcrumbs: [
768862
- violation.relativeFilepath,
768863
- ...violation.nodePath.map((nodePathItem) => {
768864
- let itemStr = typeof nodePathItem === "string" ? nodePathItem : nodePathItem.key;
768865
- if (typeof nodePathItem !== "string" && nodePathItem.arrayIndex != null) {
768866
- itemStr += `[${nodePathItem.arrayIndex}]`;
768867
- }
768868
- return itemStr;
768869
- })
768870
- ],
768871
- title: violation.message
768872
- })
768873
- );
768874
- }
768875
- if (violationsContainError) {
768876
- context.failAndThrow();
768848
+
768849
+ // pnp:/home/circleci/project/packages/cli/cli/src/commands/validate/logViolations.ts
768850
+ function logViolations({
768851
+ context,
768852
+ violations,
768853
+ logWarnings
768854
+ }) {
768855
+ const stats = getViolationStats(violations);
768856
+ logViolationsSummary({ context, stats, logWarnings });
768857
+ violations.forEach((violation) => {
768858
+ if (violation.severity === "error") {
768859
+ logViolation({ violation, context });
768860
+ }
768861
+ });
768862
+ if (logWarnings) {
768863
+ violations.forEach((violation) => {
768864
+ if (violation.severity === "warning") {
768865
+ logViolation({ violation, context });
768866
+ }
768867
+ });
768877
768868
  }
768869
+ return {
768870
+ hasErrors: stats.numErrors > 0
768871
+ };
768872
+ }
768873
+ function logViolation({ violation, context }) {
768874
+ context.logger.log(
768875
+ getLogLevelForSeverity(violation.severity),
768876
+ formatLog({
768877
+ breadcrumbs: [
768878
+ violation.relativeFilepath,
768879
+ ...violation.nodePath.map((nodePathItem) => {
768880
+ let itemStr = typeof nodePathItem === "string" ? nodePathItem : nodePathItem.key;
768881
+ if (typeof nodePathItem !== "string" && nodePathItem.arrayIndex != null) {
768882
+ itemStr += `[${nodePathItem.arrayIndex}]`;
768883
+ }
768884
+ return itemStr;
768885
+ })
768886
+ ],
768887
+ title: violation.message
768888
+ })
768889
+ );
768878
768890
  }
768879
768891
  function getLogLevelForSeverity(severity) {
768880
768892
  switch (severity) {
@@ -768884,6 +768896,60 @@ function getLogLevelForSeverity(severity) {
768884
768896
  return LogLevel.Warn;
768885
768897
  }
768886
768898
  }
768899
+ function logViolationsSummary({
768900
+ stats,
768901
+ context,
768902
+ logWarnings
768903
+ }) {
768904
+ const { numErrors, numWarnings } = stats;
768905
+ let message = `Found ${numErrors} errors and ${numWarnings} warnings.`;
768906
+ if (!logWarnings) {
768907
+ message += " Run fern check --warnings to print out the warnings.";
768908
+ }
768909
+ if (numErrors > 0) {
768910
+ context.logger.error(message);
768911
+ } else if (numWarnings > 0) {
768912
+ context.logger.warn(message);
768913
+ } else {
768914
+ context.logger.info(source_default.green("\u2713 All checks passed"));
768915
+ }
768916
+ }
768917
+ function getViolationStats(violations) {
768918
+ let numErrors = 0;
768919
+ let numWarnings = 0;
768920
+ for (const violation of violations) {
768921
+ switch (violation.severity) {
768922
+ case "error":
768923
+ numErrors += 1;
768924
+ continue;
768925
+ case "warning":
768926
+ numWarnings += 1;
768927
+ continue;
768928
+ default:
768929
+ assertNever(violation.severity);
768930
+ }
768931
+ }
768932
+ return {
768933
+ numErrors,
768934
+ numWarnings
768935
+ };
768936
+ }
768937
+
768938
+ // pnp:/home/circleci/project/packages/cli/cli/src/commands/validate/validateAPIWorkspaceAndLogIssues.ts
768939
+ async function validateAPIWorkspaceAndLogIssues({
768940
+ workspace,
768941
+ context,
768942
+ logWarnings
768943
+ }) {
768944
+ if (!(0, import_validate_npm_package_name.default)(workspace.name).validForNewPackages) {
768945
+ context.failAndThrow("Workspace name is not valid.");
768946
+ }
768947
+ const violations = await validateFernWorkspace(workspace, context.logger);
768948
+ const { hasErrors } = logViolations({ violations, context, logWarnings });
768949
+ if (hasErrors) {
768950
+ context.failAndThrow();
768951
+ }
768952
+ }
768887
768953
 
768888
768954
  // pnp:/home/circleci/project/packages/cli/cli/src/commands/generate-ir/generateIrForFernWorkspace.ts
768889
768955
  async function generateIrForFernWorkspace({
@@ -768892,7 +768958,7 @@ async function generateIrForFernWorkspace({
768892
768958
  generationLanguage,
768893
768959
  audiences
768894
768960
  }) {
768895
- await validateAPIWorkspaceAndLogIssues(workspace, context);
768961
+ await validateAPIWorkspaceAndLogIssues({ workspace, context, logWarnings: false });
768896
768962
  return generateIntermediateRepresentation({
768897
768963
  workspace,
768898
768964
  generationLanguage,
@@ -776382,7 +776448,7 @@ async function generateWorkspace({
776382
776448
  if (group == null) {
776383
776449
  return context.failAndThrow(`Group '${groupNameOrDefault}' does not exist.`);
776384
776450
  }
776385
- await validateAPIWorkspaceAndLogIssues(workspace, context);
776451
+ await validateAPIWorkspaceAndLogIssues({ workspace, context, logWarnings: false });
776386
776452
  if (useLocalDocker) {
776387
776453
  await runLocalGenerationForWorkspace({
776388
776454
  organization,
@@ -801944,42 +802010,17 @@ async function runRulesOnDocsWorkspace({ workspace, rules, logger }) {
801944
802010
  }
801945
802011
 
801946
802012
  // pnp:/home/circleci/project/packages/cli/cli/src/commands/validate/validateDocsWorkspaceAndLogIssues.ts
801947
- async function validateDocsWorkspaceAndLogIssues(workspace, context) {
802013
+ async function validateDocsWorkspaceAndLogIssues({
802014
+ workspace,
802015
+ context,
802016
+ logWarnings
802017
+ }) {
801948
802018
  const violations = await validateDocsWorkspace(workspace, context.logger);
801949
- let violationsContainError = false;
801950
- for (const violation of violations) {
801951
- if (!violationsContainError && violation.severity === "error") {
801952
- violationsContainError = true;
801953
- }
801954
- context.logger.log(
801955
- getLogLevelForSeverity2(violation.severity),
801956
- formatLog({
801957
- breadcrumbs: [
801958
- violation.relativeFilepath,
801959
- ...violation.nodePath.map((nodePathItem) => {
801960
- let itemStr = typeof nodePathItem === "string" ? nodePathItem : nodePathItem.key;
801961
- if (typeof nodePathItem !== "string" && nodePathItem.arrayIndex != null) {
801962
- itemStr += `[${nodePathItem.arrayIndex}]`;
801963
- }
801964
- return itemStr;
801965
- })
801966
- ],
801967
- title: violation.message
801968
- })
801969
- );
801970
- }
801971
- if (violationsContainError) {
802019
+ const { hasErrors } = logViolations({ violations, context, logWarnings });
802020
+ if (hasErrors) {
801972
802021
  context.failAndThrow();
801973
802022
  }
801974
802023
  }
801975
- function getLogLevelForSeverity2(severity) {
801976
- switch (severity) {
801977
- case "error":
801978
- return LogLevel.Error;
801979
- case "warning":
801980
- return LogLevel.Warn;
801981
- }
801982
- }
801983
802024
 
801984
802025
  // pnp:/home/circleci/project/packages/cli/cli/src/commands/generate/generateDocsWorkspace.ts
801985
802026
  async function generateDocsWorkspace({
@@ -802009,7 +802050,7 @@ async function generateDocsWorkspace({
802009
802050
  command: "fern generate --docs"
802010
802051
  });
802011
802052
  await cliContext.runTaskForWorkspace(docsWorkspace, async (context) => {
802012
- await validateDocsWorkspaceAndLogIssues(docsWorkspace, context);
802053
+ await validateDocsWorkspaceAndLogIssues({ workspace: docsWorkspace, context, logWarnings: false });
802013
802054
  const fernWorkspaces = await Promise.all(
802014
802055
  project.apiWorkspaces.map(async (workspace) => {
802015
802056
  return workspace.type === "fern" ? workspace : await convertOpenApiWorkspaceToFernWorkspace(workspace, context);
@@ -802332,7 +802373,7 @@ async function previewDocsWorkspace({
802332
802373
  command: "fern preview --docs"
802333
802374
  });
802334
802375
  await cliContext.runTaskForWorkspace(docsWorkspace, async (context) => {
802335
- await validateDocsWorkspaceAndLogIssues(docsWorkspace, context);
802376
+ await validateDocsWorkspaceAndLogIssues({ workspace: docsWorkspace, context, logWarnings: false });
802336
802377
  await runPreviewServer({
802337
802378
  docsWorkspace,
802338
802379
  context,
@@ -804548,12 +804589,13 @@ async function upgrade({
804548
804589
  // pnp:/home/circleci/project/packages/cli/cli/src/commands/validate/validateWorkspaces.ts
804549
804590
  async function validateWorkspaces({
804550
804591
  project,
804551
- cliContext
804592
+ cliContext,
804593
+ logWarnings
804552
804594
  }) {
804553
804595
  const docsWorkspace = project.docsWorkspaces;
804554
804596
  if (docsWorkspace != null) {
804555
804597
  await cliContext.runTaskForWorkspace(docsWorkspace, async (context) => {
804556
- await validateDocsWorkspaceAndLogIssues(docsWorkspace, context);
804598
+ await validateDocsWorkspaceAndLogIssues({ workspace: docsWorkspace, context, logWarnings });
804557
804599
  });
804558
804600
  }
804559
804601
  await Promise.all(
@@ -804561,9 +804603,9 @@ async function validateWorkspaces({
804561
804603
  await cliContext.runTaskForWorkspace(workspace, async (context) => {
804562
804604
  if (workspace.type === "openapi") {
804563
804605
  const fernWorkspace = await convertOpenApiWorkspaceToFernWorkspace(workspace, context);
804564
- await validateAPIWorkspaceAndLogIssues(fernWorkspace, context);
804606
+ await validateAPIWorkspaceAndLogIssues({ workspace: fernWorkspace, context, logWarnings });
804565
804607
  } else {
804566
- await validateAPIWorkspaceAndLogIssues(workspace, context);
804608
+ await validateAPIWorkspaceAndLogIssues({ workspace, context, logWarnings });
804567
804609
  }
804568
804610
  });
804569
804611
  })
@@ -804580,16 +804622,15 @@ async function writeDefinitionForWorkspaces({
804580
804622
  project.apiWorkspaces.map(async (workspace) => {
804581
804623
  await cliContext.runTaskForWorkspace(workspace, async (context) => {
804582
804624
  if (workspace.type !== "openapi") {
804583
- context.failAndThrow("Cannot write definition for non-OpenAPI workspace.");
804584
804625
  return;
804585
804626
  }
804586
804627
  const fernWorkspace = await convertOpenApiWorkspaceToFernWorkspace(workspace, context);
804587
- await writeDefinitionForWorkspace(fernWorkspace);
804628
+ await writeDefinitionForWorkspace({ workspace: fernWorkspace, context });
804588
804629
  });
804589
804630
  })
804590
804631
  );
804591
804632
  }
804592
- async function writeDefinitionForWorkspace(workspace) {
804633
+ async function writeDefinitionForWorkspace({ workspace, context }) {
804593
804634
  const directoryOfDefinition = join(workspace.absoluteFilepath, RelativeFilePath.of(DEFINITION_DIRECTORY));
804594
804635
  await (0, import_promises65.mkdir)(directoryOfDefinition);
804595
804636
  await (0, import_promises65.writeFile)(
@@ -804606,6 +804647,7 @@ async function writeDefinitionForWorkspace(workspace) {
804606
804647
  await (0, import_promises65.mkdir)(dirname5, { recursive: true });
804607
804648
  await (0, import_promises65.writeFile)(absoluteFilepath, fileContents);
804608
804649
  }
804650
+ context.logger.info(source_default.green(`Wrote definition to ${directoryOfDefinition}`));
804609
804651
  }
804610
804652
 
804611
804653
  // pnp:/home/circleci/project/packages/cli/cli/src/utils/isUrl.ts
@@ -805071,10 +805113,14 @@ function addRegisterV2Command(cli, cliContext) {
805071
805113
  function addValidateCommand(cli, cliContext) {
805072
805114
  cli.command(
805073
805115
  "check",
805074
- "Validates your Fern Definition",
805116
+ "Validates your Fern Definition. Logs errors.",
805075
805117
  (yargs) => yargs.option("api", {
805076
805118
  string: true,
805077
805119
  description: "Only run the command on the provided API"
805120
+ }).option("warnings", {
805121
+ boolean: true,
805122
+ description: "Log warnings in addition to errors.",
805123
+ default: false
805078
805124
  }),
805079
805125
  async (argv) => {
805080
805126
  await validateWorkspaces({
@@ -805082,7 +805128,8 @@ function addValidateCommand(cli, cliContext) {
805082
805128
  commandLineApiWorkspace: argv.api,
805083
805129
  defaultToAllApiWorkspaces: true
805084
805130
  }),
805085
- cliContext
805131
+ cliContext,
805132
+ logWarnings: argv.warnings
805086
805133
  });
805087
805134
  }
805088
805135
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.16.7",
3
+ "version": "0.16.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",