laxy-verify 1.2.2 → 1.3.0

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.
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.runTypecheck = runTypecheck;
37
+ /**
38
+ * TypeScript type-check verification.
39
+ *
40
+ * Runs `tsc --noEmit` to catch type errors that may slip through a
41
+ * lenient build pipeline. If no tsconfig.json is found the check is
42
+ * skipped gracefully.
43
+ */
44
+ const node_child_process_1 = require("node:child_process");
45
+ const fs = __importStar(require("node:fs"));
46
+ const path = __importStar(require("node:path"));
47
+ async function runTypecheck(projectDir, timeoutMs = 60000) {
48
+ const tsconfigPath = path.join(projectDir, "tsconfig.json");
49
+ if (!fs.existsSync(tsconfigPath)) {
50
+ return { passed: true, errorCount: 0, errors: [], skipped: true, durationMs: 0 };
51
+ }
52
+ console.log(" Running TypeScript type check (tsc --noEmit)...");
53
+ const start = Date.now();
54
+ return new Promise((resolve) => {
55
+ const chunks = [];
56
+ const proc = process.platform === "win32"
57
+ ? (0, node_child_process_1.spawn)(process.env.ComSpec || "cmd.exe", ["/d", "/c", "npx tsc --noEmit"], { stdio: ["ignore", "pipe", "pipe"], cwd: projectDir, shell: false })
58
+ : (0, node_child_process_1.spawn)("npx", ["tsc", "--noEmit"], {
59
+ shell: true,
60
+ stdio: ["ignore", "pipe", "pipe"],
61
+ cwd: projectDir,
62
+ });
63
+ const timer = setTimeout(() => {
64
+ try {
65
+ proc.kill();
66
+ }
67
+ catch { }
68
+ resolve({
69
+ passed: false,
70
+ errorCount: -1,
71
+ errors: ["Typecheck timed out"],
72
+ skipped: false,
73
+ durationMs: Date.now() - start,
74
+ });
75
+ }, timeoutMs);
76
+ proc.stdout?.on("data", (chunk) => chunks.push(chunk.toString()));
77
+ proc.stderr?.on("data", (chunk) => chunks.push(chunk.toString()));
78
+ proc.on("exit", (code) => {
79
+ clearTimeout(timer);
80
+ const durationMs = Date.now() - start;
81
+ const output = chunks.join("");
82
+ const passed = code === 0;
83
+ if (passed) {
84
+ console.log(" TypeScript: OK (no type errors)");
85
+ resolve({ passed: true, errorCount: 0, errors: [], skipped: false, durationMs });
86
+ return;
87
+ }
88
+ const lines = output.split("\n").filter((l) => l.trim().length > 0);
89
+ const errorLines = lines.filter((l) => /error TS\d+/i.test(l));
90
+ const errorCount = errorLines.length || lines.length;
91
+ const errors = errorLines.slice(0, 10);
92
+ console.log(` TypeScript: ${errorCount} type error(s)`);
93
+ for (const err of errors.slice(0, 3)) {
94
+ console.error(` ${err.trim()}`);
95
+ }
96
+ resolve({ passed: false, errorCount, errors, skipped: false, durationMs });
97
+ });
98
+ });
99
+ }