-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from arethetypeswrong/cli-expose-renderer
Expose CLI renderer
- Loading branch information
Showing
11 changed files
with
100 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@arethetypeswrong/cli": patch | ||
--- | ||
|
||
Expose internal renderer and exit code API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { CheckResult } from "@arethetypeswrong/core"; | ||
import { problemFlags } from "./problemUtils.js"; | ||
import type { RenderOptions } from "./render/index.js"; | ||
|
||
export function getExitCode(analysis: CheckResult, opts?: RenderOptions): number { | ||
if (!analysis.types) { | ||
return 0; | ||
} | ||
if (!opts?.ignoreRules) { | ||
return analysis.problems.length > 0 ? 1 : 0; | ||
} | ||
return analysis.problems.some((problem) => !opts.ignoreRules!.includes(problemFlags[problem.kind])) ? 1 : 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
import type { problemFlags } from "../problemUtils.js"; | ||
|
||
export type Format = "auto" | "table" | "table-flipped" | "ascii" | "json"; | ||
export interface RenderOptions { | ||
ignoreRules?: (typeof problemFlags)[keyof typeof problemFlags][]; | ||
format?: Format; | ||
color?: boolean; | ||
summary?: boolean; | ||
emoji?: boolean; | ||
} | ||
|
||
export * from "./typed.js"; | ||
export * from "./untyped.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as core from "@arethetypeswrong/core"; | ||
|
||
export function untyped(analysis: core.UntypedResult) { | ||
console.log("This package does not contain types.\nDetails: ", analysis); | ||
return "This package does not contain types.\nDetails: " + JSON.stringify(analysis, null, 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.