fern-api 0.16.8 → 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.
- package/bundle.cjs +122 -79
- 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.
|
|
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.
|
|
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.
|
|
761178
|
+
if ("0.16.9" == null) {
|
|
761179
761179
|
this.logger.error("CLI_VERSION is not defined");
|
|
761180
761180
|
}
|
|
761181
|
-
return "0.16.
|
|
761181
|
+
return "0.16.9";
|
|
761182
761182
|
}
|
|
761183
761183
|
getCliName() {
|
|
761184
761184
|
if ("fern" == null) {
|
|
@@ -768845,38 +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
|
-
|
|
768849
|
-
|
|
768850
|
-
|
|
768851
|
-
|
|
768852
|
-
|
|
768853
|
-
|
|
768854
|
-
|
|
768855
|
-
|
|
768856
|
-
|
|
768857
|
-
|
|
768858
|
-
|
|
768859
|
-
|
|
768860
|
-
|
|
768861
|
-
|
|
768862
|
-
|
|
768863
|
-
|
|
768864
|
-
|
|
768865
|
-
|
|
768866
|
-
|
|
768867
|
-
|
|
768868
|
-
return itemStr;
|
|
768869
|
-
})
|
|
768870
|
-
],
|
|
768871
|
-
title: violation.message
|
|
768872
|
-
})
|
|
768873
|
-
);
|
|
768874
|
-
}
|
|
768875
|
-
if (violationsContainError) {
|
|
768876
|
-
context.failAndThrow();
|
|
768877
|
-
} else {
|
|
768878
|
-
context.logger.info(source_default.green("\u2713 All checks passed"));
|
|
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
|
+
});
|
|
768879
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
|
+
);
|
|
768880
768890
|
}
|
|
768881
768891
|
function getLogLevelForSeverity(severity) {
|
|
768882
768892
|
switch (severity) {
|
|
@@ -768886,6 +768896,60 @@ function getLogLevelForSeverity(severity) {
|
|
|
768886
768896
|
return LogLevel.Warn;
|
|
768887
768897
|
}
|
|
768888
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
|
+
}
|
|
768889
768953
|
|
|
768890
768954
|
// pnp:/home/circleci/project/packages/cli/cli/src/commands/generate-ir/generateIrForFernWorkspace.ts
|
|
768891
768955
|
async function generateIrForFernWorkspace({
|
|
@@ -768894,7 +768958,7 @@ async function generateIrForFernWorkspace({
|
|
|
768894
768958
|
generationLanguage,
|
|
768895
768959
|
audiences
|
|
768896
768960
|
}) {
|
|
768897
|
-
await validateAPIWorkspaceAndLogIssues(workspace, context);
|
|
768961
|
+
await validateAPIWorkspaceAndLogIssues({ workspace, context, logWarnings: false });
|
|
768898
768962
|
return generateIntermediateRepresentation({
|
|
768899
768963
|
workspace,
|
|
768900
768964
|
generationLanguage,
|
|
@@ -776384,7 +776448,7 @@ async function generateWorkspace({
|
|
|
776384
776448
|
if (group == null) {
|
|
776385
776449
|
return context.failAndThrow(`Group '${groupNameOrDefault}' does not exist.`);
|
|
776386
776450
|
}
|
|
776387
|
-
await validateAPIWorkspaceAndLogIssues(workspace, context);
|
|
776451
|
+
await validateAPIWorkspaceAndLogIssues({ workspace, context, logWarnings: false });
|
|
776388
776452
|
if (useLocalDocker) {
|
|
776389
776453
|
await runLocalGenerationForWorkspace({
|
|
776390
776454
|
organization,
|
|
@@ -801946,42 +802010,15 @@ async function runRulesOnDocsWorkspace({ workspace, rules, logger }) {
|
|
|
801946
802010
|
}
|
|
801947
802011
|
|
|
801948
802012
|
// pnp:/home/circleci/project/packages/cli/cli/src/commands/validate/validateDocsWorkspaceAndLogIssues.ts
|
|
801949
|
-
async function validateDocsWorkspaceAndLogIssues(
|
|
802013
|
+
async function validateDocsWorkspaceAndLogIssues({
|
|
802014
|
+
workspace,
|
|
802015
|
+
context,
|
|
802016
|
+
logWarnings
|
|
802017
|
+
}) {
|
|
801950
802018
|
const violations = await validateDocsWorkspace(workspace, context.logger);
|
|
801951
|
-
|
|
801952
|
-
|
|
801953
|
-
if (!violationsContainError && violation.severity === "error") {
|
|
801954
|
-
violationsContainError = true;
|
|
801955
|
-
}
|
|
801956
|
-
context.logger.log(
|
|
801957
|
-
getLogLevelForSeverity2(violation.severity),
|
|
801958
|
-
formatLog({
|
|
801959
|
-
breadcrumbs: [
|
|
801960
|
-
violation.relativeFilepath,
|
|
801961
|
-
...violation.nodePath.map((nodePathItem) => {
|
|
801962
|
-
let itemStr = typeof nodePathItem === "string" ? nodePathItem : nodePathItem.key;
|
|
801963
|
-
if (typeof nodePathItem !== "string" && nodePathItem.arrayIndex != null) {
|
|
801964
|
-
itemStr += `[${nodePathItem.arrayIndex}]`;
|
|
801965
|
-
}
|
|
801966
|
-
return itemStr;
|
|
801967
|
-
})
|
|
801968
|
-
],
|
|
801969
|
-
title: violation.message
|
|
801970
|
-
})
|
|
801971
|
-
);
|
|
801972
|
-
}
|
|
801973
|
-
if (violationsContainError) {
|
|
802019
|
+
const { hasErrors } = logViolations({ violations, context, logWarnings });
|
|
802020
|
+
if (hasErrors) {
|
|
801974
802021
|
context.failAndThrow();
|
|
801975
|
-
} else {
|
|
801976
|
-
context.logger.info(source_default.green("\u2713 All checks passed"));
|
|
801977
|
-
}
|
|
801978
|
-
}
|
|
801979
|
-
function getLogLevelForSeverity2(severity) {
|
|
801980
|
-
switch (severity) {
|
|
801981
|
-
case "error":
|
|
801982
|
-
return LogLevel.Error;
|
|
801983
|
-
case "warning":
|
|
801984
|
-
return LogLevel.Warn;
|
|
801985
802022
|
}
|
|
801986
802023
|
}
|
|
801987
802024
|
|
|
@@ -802013,7 +802050,7 @@ async function generateDocsWorkspace({
|
|
|
802013
802050
|
command: "fern generate --docs"
|
|
802014
802051
|
});
|
|
802015
802052
|
await cliContext.runTaskForWorkspace(docsWorkspace, async (context) => {
|
|
802016
|
-
await validateDocsWorkspaceAndLogIssues(docsWorkspace, context);
|
|
802053
|
+
await validateDocsWorkspaceAndLogIssues({ workspace: docsWorkspace, context, logWarnings: false });
|
|
802017
802054
|
const fernWorkspaces = await Promise.all(
|
|
802018
802055
|
project.apiWorkspaces.map(async (workspace) => {
|
|
802019
802056
|
return workspace.type === "fern" ? workspace : await convertOpenApiWorkspaceToFernWorkspace(workspace, context);
|
|
@@ -802336,7 +802373,7 @@ async function previewDocsWorkspace({
|
|
|
802336
802373
|
command: "fern preview --docs"
|
|
802337
802374
|
});
|
|
802338
802375
|
await cliContext.runTaskForWorkspace(docsWorkspace, async (context) => {
|
|
802339
|
-
await validateDocsWorkspaceAndLogIssues(docsWorkspace, context);
|
|
802376
|
+
await validateDocsWorkspaceAndLogIssues({ workspace: docsWorkspace, context, logWarnings: false });
|
|
802340
802377
|
await runPreviewServer({
|
|
802341
802378
|
docsWorkspace,
|
|
802342
802379
|
context,
|
|
@@ -804552,12 +804589,13 @@ async function upgrade({
|
|
|
804552
804589
|
// pnp:/home/circleci/project/packages/cli/cli/src/commands/validate/validateWorkspaces.ts
|
|
804553
804590
|
async function validateWorkspaces({
|
|
804554
804591
|
project,
|
|
804555
|
-
cliContext
|
|
804592
|
+
cliContext,
|
|
804593
|
+
logWarnings
|
|
804556
804594
|
}) {
|
|
804557
804595
|
const docsWorkspace = project.docsWorkspaces;
|
|
804558
804596
|
if (docsWorkspace != null) {
|
|
804559
804597
|
await cliContext.runTaskForWorkspace(docsWorkspace, async (context) => {
|
|
804560
|
-
await validateDocsWorkspaceAndLogIssues(docsWorkspace, context);
|
|
804598
|
+
await validateDocsWorkspaceAndLogIssues({ workspace: docsWorkspace, context, logWarnings });
|
|
804561
804599
|
});
|
|
804562
804600
|
}
|
|
804563
804601
|
await Promise.all(
|
|
@@ -804565,9 +804603,9 @@ async function validateWorkspaces({
|
|
|
804565
804603
|
await cliContext.runTaskForWorkspace(workspace, async (context) => {
|
|
804566
804604
|
if (workspace.type === "openapi") {
|
|
804567
804605
|
const fernWorkspace = await convertOpenApiWorkspaceToFernWorkspace(workspace, context);
|
|
804568
|
-
await validateAPIWorkspaceAndLogIssues(fernWorkspace, context);
|
|
804606
|
+
await validateAPIWorkspaceAndLogIssues({ workspace: fernWorkspace, context, logWarnings });
|
|
804569
804607
|
} else {
|
|
804570
|
-
await validateAPIWorkspaceAndLogIssues(workspace, context);
|
|
804608
|
+
await validateAPIWorkspaceAndLogIssues({ workspace, context, logWarnings });
|
|
804571
804609
|
}
|
|
804572
804610
|
});
|
|
804573
804611
|
})
|
|
@@ -805075,10 +805113,14 @@ function addRegisterV2Command(cli, cliContext) {
|
|
|
805075
805113
|
function addValidateCommand(cli, cliContext) {
|
|
805076
805114
|
cli.command(
|
|
805077
805115
|
"check",
|
|
805078
|
-
"Validates your Fern Definition",
|
|
805116
|
+
"Validates your Fern Definition. Logs errors.",
|
|
805079
805117
|
(yargs) => yargs.option("api", {
|
|
805080
805118
|
string: true,
|
|
805081
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
|
|
805082
805124
|
}),
|
|
805083
805125
|
async (argv) => {
|
|
805084
805126
|
await validateWorkspaces({
|
|
@@ -805086,7 +805128,8 @@ function addValidateCommand(cli, cliContext) {
|
|
|
805086
805128
|
commandLineApiWorkspace: argv.api,
|
|
805087
805129
|
defaultToAllApiWorkspaces: true
|
|
805088
805130
|
}),
|
|
805089
|
-
cliContext
|
|
805131
|
+
cliContext,
|
|
805132
|
+
logWarnings: argv.warnings
|
|
805090
805133
|
});
|
|
805091
805134
|
}
|
|
805092
805135
|
);
|