@arethetypeswrong/cli
Advanced tools
Comparing version 0.13.9 to 0.13.10
import * as core from "@arethetypeswrong/core"; | ||
import type { RenderOptions } from "./index.js"; | ||
export declare function typed(analysis: core.Analysis, opts: RenderOptions): Promise<string>; | ||
export declare function typed(analysis: core.Analysis, { emoji, summary, format, ignoreRules }: RenderOptions): Promise<string>; | ||
//# sourceMappingURL=typed.d.ts.map |
@@ -10,5 +10,5 @@ import * as core from "@arethetypeswrong/core"; | ||
import { asciiTable } from "./asciiTable.js"; | ||
export async function typed(analysis, opts) { | ||
export async function typed(analysis, { emoji = true, summary = true, format = "auto", ignoreRules = [] }) { | ||
let output = ""; | ||
const problems = analysis.problems.filter((problem) => !opts.ignoreRules || !opts.ignoreRules.includes(problemFlags[problem.kind])); | ||
const problems = analysis.problems.filter((problem) => !ignoreRules || !ignoreRules.includes(problemFlags[problem.kind])); | ||
const grouped = groupProblemsByKind(problems); | ||
@@ -33,12 +33,11 @@ const entrypoints = Object.keys(analysis.entrypoints); | ||
} | ||
if (opts.ignoreRules && opts.ignoreRules.length) { | ||
out(chalk.gray(` (ignoring rules: ${opts.ignoreRules.map((rule) => `'${rule}'`).join(", ")})\n`)); | ||
if (ignoreRules && ignoreRules.length) { | ||
out(chalk.gray(` (ignoring rules: ${ignoreRules.map((rule) => `'${rule}'`).join(", ")})\n`)); | ||
} | ||
if (opts.summary) { | ||
const defaultSummary = marked(!opts.emoji ? " No problems found" : " No problems found 🌟"); | ||
if (summary) { | ||
const defaultSummary = marked(!emoji ? " No problems found" : " No problems found 🌟"); | ||
const summaryTexts = Object.keys(grouped).map((kind) => { | ||
const info = problemKindInfo[kind]; | ||
const emoji = opts.emoji ? `${info.emoji} ` : ""; | ||
const description = marked(`${info.description} ${info.docsUrl}`); | ||
return `${emoji}${description}`; | ||
return `${emoji ? `${info.emoji} ` : ""}${description}`; | ||
}); | ||
@@ -61,13 +60,13 @@ out(summaryTexts.join("") || defaultSummary); | ||
return kinds | ||
.map((kind) => (opts.emoji ? `${problemKindInfo[kind].emoji} ` : "") + problemKindInfo[kind].shortDescription) | ||
.map((kind) => (emoji ? `${problemKindInfo[kind].emoji} ` : "") + problemKindInfo[kind].shortDescription) | ||
.join("\n"); | ||
} | ||
const jsonResult = !opts.emoji ? "OK (JSON)" : "🟢 (JSON)"; | ||
const jsonResult = !emoji ? "OK (JSON)" : "🟢 (JSON)"; | ||
const moduleResult = entrypoint.isWildcard | ||
? "(wildcard)" | ||
: (!opts.emoji ? "OK " : "🟢 ") + | ||
: (!emoji ? "OK " : "🟢 ") + | ||
moduleKinds[((_c = (_a = analysis.programInfo[getResolutionOption(resolutionKind)].moduleKinds) === null || _a === void 0 ? void 0 : _a[(_b = resolution === null || resolution === void 0 ? void 0 : resolution.fileName) !== null && _b !== void 0 ? _b : ""]) === null || _c === void 0 ? void 0 : _c.detectedKind) || ""]; | ||
return (resolution === null || resolution === void 0 ? void 0 : resolution.isJson) ? jsonResult : moduleResult; | ||
}); | ||
const flippedTable = opts.format === "auto" || opts.format === "table-flipped" | ||
const flippedTable = format === "auto" || format === "table-flipped" | ||
? new Table({ | ||
@@ -85,3 +84,3 @@ head: ["", ...allResolutionKinds.map((kind) => chalk.reset(resolutionKinds[kind]))], | ||
} | ||
const table = opts.format === "auto" || !flippedTable | ||
const table = format === "auto" || !flippedTable | ||
? new Table({ | ||
@@ -96,3 +95,3 @@ head: ["", ...entrypointHeaders], | ||
} | ||
switch (opts.format) { | ||
switch (format) { | ||
case "table": | ||
@@ -99,0 +98,0 @@ out(table.toString()); |
{ | ||
"name": "@arethetypeswrong/cli", | ||
"version": "0.13.9", | ||
"version": "0.13.10", | ||
"description": "A CLI tool for arethetypeswrong.github.io", | ||
@@ -5,0 +5,0 @@ "author": "Andrew Branch & ej-shafran", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49294
461