clikit-plugin 0.2.16 → 0.2.17
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.
|
@@ -27,5 +27,5 @@ export declare function isTypeScriptFile(filePath: unknown): boolean;
|
|
|
27
27
|
export declare function findTsConfig(projectDir: unknown, override?: string): string | undefined;
|
|
28
28
|
export declare function hasTscInstalled(projectDir: unknown): boolean;
|
|
29
29
|
export declare function runTypeCheck(filePath: unknown, projectDir: unknown, config?: TypeCheckConfig): TypeCheckResult;
|
|
30
|
-
export declare function formatTypeCheckWarning(result: TypeCheckResult): string;
|
|
30
|
+
export declare function formatTypeCheckWarning(result: TypeCheckResult | unknown): string;
|
|
31
31
|
//# sourceMappingURL=typecheck-gate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typecheck-gate.d.ts","sourceRoot":"","sources":["../../src/hooks/typecheck-gate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"typecheck-gate.d.ts","sourceRoot":"","sources":["../../src/hooks/typecheck-gate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AA4BD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAG3D;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBvF;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAY5D;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,OAAO,EACjB,UAAU,EAAE,OAAO,EACnB,MAAM,CAAC,EAAE,eAAe,GACvB,eAAe,CAiCjB;AAsCD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,GAAG,MAAM,CAgBhF"}
|
package/dist/index.js
CHANGED
|
@@ -4383,6 +4383,22 @@ function formatAutoFormatLog(result) {
|
|
|
4383
4383
|
import * as fs6 from "fs";
|
|
4384
4384
|
import * as path6 from "path";
|
|
4385
4385
|
import { execSync as execSync3 } from "child_process";
|
|
4386
|
+
function normalizeTypeCheckResult(result) {
|
|
4387
|
+
if (!result || typeof result !== "object") {
|
|
4388
|
+
return { clean: true, errors: [], checkedFile: "" };
|
|
4389
|
+
}
|
|
4390
|
+
const raw = result;
|
|
4391
|
+
const errors = Array.isArray(raw.errors) ? raw.errors.filter((item) => !!item && typeof item === "object").map((item) => ({
|
|
4392
|
+
file: typeof item.file === "string" ? item.file : "",
|
|
4393
|
+
line: typeof item.line === "number" ? item.line : 0,
|
|
4394
|
+
column: typeof item.column === "number" ? item.column : 0,
|
|
4395
|
+
code: typeof item.code === "string" ? item.code : "TS0000",
|
|
4396
|
+
message: typeof item.message === "string" ? item.message : "Unknown typecheck error"
|
|
4397
|
+
})) : [];
|
|
4398
|
+
const checkedFile = typeof raw.checkedFile === "string" ? raw.checkedFile : "";
|
|
4399
|
+
const clean = typeof raw.clean === "boolean" ? raw.clean : errors.length === 0;
|
|
4400
|
+
return { clean, errors, checkedFile };
|
|
4401
|
+
}
|
|
4386
4402
|
var TS_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
|
|
4387
4403
|
function isTypeScriptFile(filePath) {
|
|
4388
4404
|
if (typeof filePath !== "string")
|
|
@@ -4462,15 +4478,16 @@ function parseTscOutput(output, filterFile) {
|
|
|
4462
4478
|
return diagnostics;
|
|
4463
4479
|
}
|
|
4464
4480
|
function formatTypeCheckWarning(result) {
|
|
4465
|
-
|
|
4466
|
-
|
|
4481
|
+
const safeResult = normalizeTypeCheckResult(result);
|
|
4482
|
+
if (safeResult.clean) {
|
|
4483
|
+
return `[CliKit:typecheck] ${safeResult.checkedFile} \u2014 no type errors`;
|
|
4467
4484
|
}
|
|
4468
|
-
const lines = [`[CliKit:typecheck] ${
|
|
4469
|
-
for (const err of
|
|
4485
|
+
const lines = [`[CliKit:typecheck] ${safeResult.errors.length} type error(s) in ${safeResult.checkedFile}:`];
|
|
4486
|
+
for (const err of safeResult.errors.slice(0, 10)) {
|
|
4470
4487
|
lines.push(` ${err.file}:${err.line}:${err.column} ${err.code}: ${err.message}`);
|
|
4471
4488
|
}
|
|
4472
|
-
if (
|
|
4473
|
-
lines.push(` ... and ${
|
|
4489
|
+
if (safeResult.errors.length > 10) {
|
|
4490
|
+
lines.push(` ... and ${safeResult.errors.length - 10} more`);
|
|
4474
4491
|
}
|
|
4475
4492
|
return lines.join(`
|
|
4476
4493
|
`);
|