mejora 2.3.4 → 2.3.6
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/dist/{check-registry-DHd4j450.mjs → check-registry-BJlMzCIV.mjs} +1 -1
- package/dist/{index-Dr3lmWeD.d.mts → index-DL3YfUFl.d.mts} +4 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/run.mjs +19 -19
- package/dist/workers/check.d.mts +1 -1
- package/dist/workers/check.mjs +1 -1
- package/package.json +1 -5
- /package/dist/{typescript-sQ82Cu7A.mjs → typescript-JQUGT569.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./typescript-
|
|
1
|
+
import{r as e,t}from"./typescript-JQUGT569.mjs";var n=class{runners=new Map;static getRequiredTypes(e){return new Set(Object.values(e).map(e=>e.type))}get(e){let t=this.runners.get(e);if(!t)throw Error(`Unknown check type: ${e}`);return t}getTypes(){return new Set(this.runners.keys())}has(e){return this.runners.has(e)}init(n={}){if(this.register(new e),this.register(new t),n.runners)for(let e of n.runners)this.register(e)}register(e){if(this.runners.has(e.type))throw Error(`Check runner already registered: ${e.type}`);this.runners.set(e.type,e)}async setup(e){await this.runLifecycle(e,`setup`)}async validate(e){await this.runLifecycle(e,`validate`)}async runLifecycle(e,t){let n=[];for(let r of e){let e=this.get(r)[t]?.();e&&n.push(e)}await Promise.all(n)}};export{n as t};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as eslint from "eslint";
|
|
2
2
|
import { Linter } from "eslint";
|
|
3
|
-
import * as
|
|
3
|
+
import * as typescript from "typescript";
|
|
4
4
|
import { CompilerOptions } from "typescript";
|
|
5
5
|
|
|
6
6
|
//#region src/types.d.ts
|
|
@@ -336,7 +336,7 @@ declare class ESLintCheckRunner implements CheckRunner {
|
|
|
336
336
|
declare function eslintCheck(config: ESLintCheckConfig): {
|
|
337
337
|
concurrency?: "auto" | "off" | number;
|
|
338
338
|
files: string[];
|
|
339
|
-
overrides?:
|
|
339
|
+
overrides?: eslint.Linter.Config | eslint.Linter.Config[];
|
|
340
340
|
type: "eslint";
|
|
341
341
|
};
|
|
342
342
|
//#endregion
|
|
@@ -362,7 +362,7 @@ declare class TypeScriptCheckRunner implements CheckRunner {
|
|
|
362
362
|
*/
|
|
363
363
|
declare function typescriptCheck(config: TypeScriptCheckConfig): {
|
|
364
364
|
overrides?: {
|
|
365
|
-
compilerOptions?:
|
|
365
|
+
compilerOptions?: typescript.CompilerOptions;
|
|
366
366
|
};
|
|
367
367
|
tsconfig?: string;
|
|
368
368
|
type: "typescript";
|
|
@@ -407,7 +407,6 @@ declare class RegexCheckRunner implements CheckRunner {
|
|
|
407
407
|
type: "items";
|
|
408
408
|
}>;
|
|
409
409
|
setup(): Promise<void>;
|
|
410
|
-
validate(): Promise<void>;
|
|
411
410
|
}
|
|
412
411
|
declare const regexRunner: () => RegexCheckRunner;
|
|
413
412
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as eslintCheck, c as Issue, d as Snapshot, i as typescriptCheck, l as IssueInput, n as regexRunner, o as CheckRunner, r as defineConfig, s as Config, t as regexCheck, u as RawSnapshot } from "./index-
|
|
1
|
+
import { a as eslintCheck, c as Issue, d as Snapshot, i as typescriptCheck, l as IssueInput, n as regexRunner, o as CheckRunner, r as defineConfig, s as Config, t as regexCheck, u as RawSnapshot } from "./index-DL3YfUFl.mjs";
|
|
2
2
|
export { CheckRunner, Config, Issue, IssueInput, RawSnapshot, Snapshot, defineConfig, eslintCheck as eslint, eslintCheck, regexCheck as regex, regexCheck, regexRunner, typescriptCheck as typescript, typescriptCheck };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,h as n,i as r,l as i,n as a,o,p as s,s as c}from"./typescript-
|
|
1
|
+
import{a as e,c as t,h as n,i as r,l as i,n as a,o,p as s,s as c}from"./typescript-JQUGT569.mjs";import{glob as l,mkdir as u}from"node:fs/promises";import{createReadStream as d}from"node:fs";import{createInterface as f}from"node:readline/promises";const p=[`**/node_modules/**`,`**/dist/**`,`**/.git/**`];function m(e,t){if(t?.length)return t;let n=e.map(e=>/^([^*]+\/)/.exec(e)?.[1]).filter(e=>e!==void 0);return[...p,...n.flatMap(e=>p.map(t=>t.replace(/^\*\*\//,e)))]}async function h(e,t,n){let r=Array.from({length:e.length}),i=0;return await Promise.all(Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let t=i++;r[t]=await n(e[t])}})),r}var g=class{type=`regex`;async run(n){let r=process.cwd(),a=Array.isArray(n.files)?n.files:[n.files],u=m(a,n.ignore),p=new Set;for(let e of a){let t=l(e,{cwd:r,exclude:u});for await(let e of t)p.add(e)}let g=[...p],_=n.patterns.map(({message:e,pattern:t,rule:n})=>{let r=t.flags.includes(`g`)?t.flags:`${t.flags}g`;return{message:e,regex:new RegExp(t.source,r),ruleText:n??t.source}}),v=s(o(this.type,r),`${e(n)}.json`),y=await t(v),b={},x=await h(g,n.concurrency??10,async e=>{let t=s(r,e),n=await c(t);if(!n)return[];let i=y[e];if(i?.hash===n)return b[e]=i,i.items;try{let r=[],i=f({crlfDelay:1/0,input:d(t,{encoding:`utf8`})}),a=0;try{for await(let t of i){a++;for(let n of _){n.regex.lastIndex=0;let i;for(;(i=n.regex.exec(t))!==null;){let t=i.index+1,o=typeof n.message==`function`?n.message(i):n.message??`Pattern matched: ${i[0]}`;r.push({column:t,file:e,line:a,message:o,rule:n.ruleText})}}}}finally{i.close()}return b[e]={hash:n,items:r},r}catch{return[]}}),S=[];for(let e of x)S.push(...e);return await i(v,b),{items:S,type:`items`}}async setup(){let e=process.cwd();await u(o(this.type,e),{recursive:!0})}};const _=()=>new g;function v(e){return{type:`regex`,...e}}export{n as defineConfig,r as eslint,r as eslintCheck,v as regex,v as regexCheck,_ as regexRunner,a as typescript,a as typescriptCheck};
|
package/dist/run.mjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{d as e,f as t,g as n,m as r,u as i}from"./typescript-
|
|
3
|
-
`).slice(1).map(e=>
|
|
2
|
+
import{d as e,f as t,g as n,m as r,u as i}from"./typescript-JQUGT569.mjs";import{t as a}from"./check-registry-BJlMzCIV.mjs";import{fileURLToPath as o}from"node:url";import{mkdir as s,readFile as c,writeFile as l}from"node:fs/promises";import{inspect as u,parseArgs as d,styleText as f}from"node:util";import{Tinypool as p}from"tinypool";import{env as m}from"node:process";const h=e=>t=>f(e,typeof t==`number`?t.toString():t),g=h(`blue`),_=h(`bold`),v=h(`cyan`),y=h(`dim`),b=h(`green`),x=h(`red`),S=h(`gray`),ee=h(`underline`),te=h(`yellow`);function ne(e){let t=[e.message];if(e.stack){let n=e.stack.split(`
|
|
3
|
+
`).slice(1).map(e=>y(e.trim())).join(`
|
|
4
4
|
`);t.push(n)}return t.join(`
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
`)}function
|
|
8
|
-
`);let o=
|
|
9
|
-
`)}function
|
|
5
|
+
`)}function C(...e){return e.map(e=>typeof e==`string`?e:e instanceof Error?ne(e):u(e,{colors:!1,depth:10})).join(` `)}const w={error:(...e)=>{console.error(x(`✖`),C(...e))},log:(...e)=>{console.log(C(...e))},start:(...e)=>{console.log(v(`◐`),C(...e))},success:(...e)=>{console.log(b(`✔`),C(...e))}};function T(e,t){return e.file===t.file?e.line===t.line?e.column-t.column:e.line-t.line:e.file.localeCompare(t.file)}function re(e){let t=Map.groupBy(e,e=>e.signature),n=[];for(let[e,r]of t){r.sort(T);for(let[t,{signature:a,...o}]of r.entries())n.push({...o,id:i(`${e}:${t}`)})}return n}function E(e){return{items:re(e.items.map(e=>({...e,signature:`${e.file} - ${e.rule}: ${e.message}`}))).toSorted(T),type:`items`}}function D(e,t){return e===1?t:`${t}s`}const O=`__unparsable__`;function k(e){return e.replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`[`,`[`).replaceAll(`]`,`]`)}function A(e,t,n){let i=r(t,e);return n?`${i}#L${n}`:i}function j(e,t){return`[${e}](${t})`}function ie(e,t){let n=A(e.file,t,e.line);return`- ${j(e.line?`Line ${e.line}`:e.file,n)} - ${`${e.rule}: ${k(e.message)}`}`}function ae(e){let t=Object.groupBy(e,e=>e.file||O);return Object.entries(t).map(([e,t=[]])=>({filePath:e,items:t})).toSorted((e,t)=>e.filePath===O?1:t.filePath===O?-1:e.filePath.localeCompare(t.filePath))}function oe(e,t){let n=e.length,r=D(n,`issue`),i=[`\n### Other Issues · ${t}\n`];for(let t of e)i.push(`- ${t.rule}: ${k(t.message)}`);return i.push(`\n${n} ${r} in Other Issues`,``),i.join(`
|
|
6
|
+
`)}function M(e,t,n){if(e.filePath===O)return oe(e.items,n);let r=A(e.filePath,t),i=j(e.filePath,r),a=e.items.length,o=D(a,`issue`),s=[`\n### ${i} · ${n}\n`];for(let n of e.items)s.push(ie(n,t));return s.push(`\n${a} ${o} in ${e.filePath}`,``),s.join(`
|
|
7
|
+
`)}function se(e,t,n){let r=t.length,i=D(r,`issue`),a=[`\n## ${e}\n`];if(t.length===0)return a.push(`No issues`),a.join(`
|
|
8
|
+
`);let o=ae(t);for(let t of o)a.push(M(t,n,e));return a.push(`---\n${r} total ${i} for ${e}`),a.join(`
|
|
9
|
+
`)}function ce(e){return`${e.replaceAll(/\n{3,}/g,`
|
|
10
10
|
|
|
11
|
-
`).trimEnd()}\n`}function
|
|
11
|
+
`).trimEnd()}\n`}function N(e,t){let n=[`<!-- prettier-ignore-start -->
|
|
12
12
|
`,`# Mejora Baseline
|
|
13
|
-
`,`This file represents the current accepted state of the codebase.`];for(let[r,{items:i=[]}]of Object.entries(e.checks))n.push(
|
|
14
|
-
<!-- prettier-ignore-end -->`),
|
|
15
|
-
`))}function ue(){return{hasImprovement:!1,hasRegression:!1,hasRelocation:!1,isInitial:!0,newIssues:[],removedIssues:[]}}function de(e,t,n){return{hasImprovement:t.length>0,hasRegression:e.length>0,hasRelocation:n,isInitial:!1,newIssues:e.toSorted((e,t)=>e.id.localeCompare(t.id)),removedIssues:t.toSorted((e,t)=>e.id.localeCompare(t.id))}}function
|
|
16
|
-
}`.repeat(t)}`}function
|
|
13
|
+
`,`This file represents the current accepted state of the codebase.`];for(let[r,{items:i=[]}]of Object.entries(e.checks))n.push(se(r,i,t));return n.push(`
|
|
14
|
+
<!-- prettier-ignore-end -->`),ce(n.join(`
|
|
15
|
+
`))}const le=[`CI`,`CONTINUOUS_INTEGRATION`].some(e=>m[e]&&m[e]!==`0`&&m[e]!==`false`);function ue(){return{hasImprovement:!1,hasRegression:!1,hasRelocation:!1,isInitial:!0,newIssues:[],removedIssues:[]}}function de(e,t,n){return{hasImprovement:t.length>0,hasRegression:e.length>0,hasRelocation:n,isInitial:!1,newIssues:e.toSorted((e,t)=>e.id.localeCompare(t.id)),removedIssues:t.toSorted((e,t)=>e.id.localeCompare(t.id))}}function P(e=[]){return new Map(e.map(e=>[e.id,e]))}function F(e){return new Set(e.keys())}function I(e,t){let n=[];for(let r of t){let t=e.get(r);n.push(t)}return n}function L(e,t){for(let[n,r]of e){let e=t.get(n);if(e&&(r.line!==e.line||r.column!==e.column))return!0}return!1}function R(e,t){let n=P(e.items),r=P(t.items),i=F(n),a=F(r),o=i.difference(a),s=a.difference(i);return de(I(n,o),I(r,s),i.size>o.size?L(n,r):!1)}function z(e,t){return t?R(e,t):ue()}const B=(e,t)=>{if(!t)return!1;let n=e.items,r=t.items;if(n.length!==r.length)return!1;let i=n.toSorted((e,t)=>e.id.localeCompare(t.id)),a=r.toSorted((e,t)=>e.id.localeCompare(t.id));return i.every((e,t)=>{let n=a[t];return e.id===n.id&&e.file===n.file&&e.line===n.line&&e.column===n.column&&e.rule===n.rule&&e.message===n.message})};function V(e,t){let n=e;for(let e=0;e<t;e++){let e=n.trimEnd();if(!e.endsWith(`}`))break;n=e.slice(0,-1)}return n}function H(e,t){return`${e}${`
|
|
16
|
+
}`.repeat(t)}`}function fe(e){let t=(e.match(/\{/g)?.length??0)-(e.match(/\}/g)?.length??0);return t===0?e:t<0?V(e,-t):H(e,t)}function pe(e){try{return JSON.parse(e)}catch{return}}function U(e){let t=e.trim();return t.endsWith(`,`)?t.slice(0,-1):t}function me(e){return`{
|
|
17
17
|
"version": 2,
|
|
18
18
|
${U(e)}
|
|
19
|
-
}`}function W(e){if(typeof e!=`object`||!e)throw TypeError(`Baseline must be an object`);if(`checks`in e&&e.checks&&typeof e.checks==`object`)return{checks:e.checks,version:2};let t={};for(let[n,r]of Object.entries(e))n!==`version`&&(t[n]=r);return{checks:t,version:2}}function G(e){try{let t=
|
|
20
|
-
`,r=e.snapshot.items.length,i=[`${n}${g(`ℹ`)} ${e.checkId}:`,` Initial baseline created with ${g(r)} ${D(r,`issue`)}`];return e.snapshot.items.length>0&&i.push(...X(e.snapshot.items,`initial`)),i.push(``,...Z(e)),i}function
|
|
21
|
-
`}${e.hasRegression?
|
|
22
|
-
`,r=e.snapshot.items.length;return e.duration===void 0?[`${n}${
|
|
23
|
-
`)}function
|
|
24
|
-
`)}const{values:$}=d({allowPositionals:!1,options:{force:{default:!1,short:`f`,type:`boolean`},help:{short:`h`,type:`boolean`},json:{default:!1,type:`boolean`},only:{type:`string`},skip:{type:`string`}},strict:!0});$.help&&(
|
|
19
|
+
}`}function W(e){if(typeof e!=`object`||!e)throw TypeError(`Baseline must be an object`);if(`checks`in e&&e.checks&&typeof e.checks==`object`)return{checks:e.checks,version:2};let t={};for(let[n,r]of Object.entries(e))n!==`version`&&(t[n]=r);return{checks:t,version:2}}function G(e){try{let t=pe(e.trim());if(t)return W(t);let n=me(fe(U(e)));return W(JSON.parse(n))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to parse baseline during conflict resolution: ${t}`,{cause:e})}}function he(e){let t=[...e.matchAll(/<<<<<<< .*\n([\s\S]*?)\n=======\n([\s\S]*?)\n>>>>>>> .*$/gm)];if(t.length===0)throw Error(`Could not parse conflict markers in baseline`);return t.map(([,e=``,t=``])=>({ours:e,theirs:t}))}function ge(e){let t=new Map;for(let n of e)for(let[e,{items:r=[]}]of Object.entries(n.checks)){if(r.length===0)continue;let n=t.get(e);n||(n=new Map,t.set(e,n));for(let e of r)n.set(e.id,e)}let n={};for(let[e,r]of t)n[e]={items:[...r.values()].toSorted((e,t)=>e.id.localeCompare(t.id)),type:`items`};return{checks:n,version:2}}function _e(e){let t=he(e),n=[];for(let{ours:e,theirs:r}of t)n.push(G(e),G(r));return ge(n)}var K=class e{baselinePath;constructor(e=`.mejora/baseline.json`){this.baselinePath=e}static create(e){return{checks:e,version:2}}static getEntry(e,t){return e?.checks[t]}static update(t,n,r){let i=t??e.create({}),a=i.checks[n];return B(r,a)?i:{...i,checks:{...i.checks,[n]:r}}}async load(){try{let e=await c(this.baselinePath,`utf8`);if(e.includes(`<<<<<<<`)){w.start(`Merge conflict detected in baseline, auto-resolving...`);let t=_e(e);return await this.save(t,!0),w.success(`Baseline conflict resolved`),t}return await this.resolveMarkdownConflictIfNeeded(e),JSON.parse(e)}catch(e){if(e.code===`ENOENT`)return null;throw e}}async save(e,n=!1){if(le&&!n)return;let r=`${JSON.stringify(e,null,2)}\n`,i=this.baselinePath.replace(`.json`,`.md`),a=N(e,t(this.baselinePath));await s(t(this.baselinePath),{recursive:!0}),await Promise.all([l(this.baselinePath,r,`utf8`),l(i,a,`utf8`)])}async resolveMarkdownConflictIfNeeded(e){let n=this.baselinePath.replace(`.json`,`.md`);try{(await c(n,`utf8`)).includes(`<<<<<<<`)&&(w.start(`Merge conflict detected in markdown report, regenerating...`),await l(n,N(JSON.parse(e),t(this.baselinePath)),`utf8`),w.success(`Markdown report regenerated`))}catch{}}};const ve=o(new URL(`workers/check.mjs`,import.meta.url));var ye=class e{baselineManager;registry;constructor(e,t){this.registry=e,this.baselineManager=new K(t)}static async executeChecksParallel(e,t){let n=Object.keys(e),r=new p({filename:ve});try{let e=n.map(async e=>{let n=await r.run({checkId:e}),i=E(n.snapshot),a=K.getEntry(t,e),o=z(i,a);return{baseline:a,checkId:e,duration:n.duration,hasImprovement:o.hasImprovement,hasRegression:o.hasRegression,hasRelocation:o.hasRelocation,isInitial:o.isInitial,newIssues:o.newIssues,removedIssues:o.removedIssues,snapshot:i}});return await Promise.all(e)}catch(e){return w.error(`Parallel execution failed:`,e),null}finally{await r.destroy()}}static filterChecks=(t,n)=>{let r=n.only?e.resolveRegex(n.only,`--only`):null,i=n.skip?e.resolveRegex(n.skip,`--skip`):null;return!r&&!i?t:Object.fromEntries(Object.entries(t).filter(([e])=>!(r&&!r.test(e)||i?.test(e))))};static resolveRegex(e,t){try{return new RegExp(e)}catch{throw Error(`Invalid regex pattern for ${t}: "${e}"`)}}async run(t,n={}){let r=performance.now(),i=await this.baselineManager.load(),a=e.filterChecks(t.checks,n),o=Object.keys(a).length;w.start(`Running ${o} check${o===1?``:`s`}...`);let s=o>1?await e.executeChecksParallel(a,i):await this.executeChecksSequential(a,i);if(!s)return{exitCode:2,hasImprovement:!1,hasRegression:!0,results:[],totalDuration:performance.now()-r};let c=i,l=!1,u=!1,d=!1;for(let e of s)e.hasRegression&&(l=!0),e.hasImprovement&&(u=!0),e.isInitial&&(d=!0),(e.hasImprovement||e.hasRelocation||n.force||e.isInitial)&&(c=K.update(c,e.checkId,{items:e.snapshot.items,type:e.snapshot.type}));return c&&c!==i&&(!l||n.force||d)&&await this.baselineManager.save(c,n.force),{exitCode:l&&!n.force?1:0,hasImprovement:u,hasRegression:l,results:s,totalDuration:performance.now()-r}}async executeChecksSequential(e,t){try{let t=a.getRequiredTypes(e);await Promise.all([this.registry.setup(t),this.registry.validate(t)])}catch(e){return w.error(`Setup failed:`,e),null}let n=[];for(let[r,i]of Object.entries(e))try{let e=performance.now(),a=await this.registry.get(i.type).run(i),o=performance.now()-e,s=E(a),c=K.getEntry(t,r),l=z(s,c);n.push({baseline:c,checkId:r,duration:o,hasImprovement:l.hasImprovement,hasRegression:l.hasRegression,hasRelocation:l.hasRelocation,isInitial:l.isInitial,newIssues:l.newIssues,removedIssues:l.removedIssues,snapshot:s})}catch(e){return w.error(`Error running check "${r}":`,e),null}return n}};function q(e,t){if(!(e===void 0||t===0))return e/t}function be(e){let{results:t,totalDuration:n}=e,r=t.length,i=[],a=[],o=[],s=[],c=0,l=0,u=0,d=0,f=0,p=[];for(let e of t){let t=e.snapshot.items.length;f+=t,e.isInitial?(u+=t,o.push(e.checkId)):(e.hasImprovement&&(c+=e.removedIssues.length,i.push(e.checkId)),e.hasRegression&&(l+=e.newIssues.length,a.push(e.checkId)),!e.hasImprovement&&!e.hasRegression&&(d+=t,s.push(e.checkId))),p.push({checkId:e.checkId,duration:e.duration,hasImprovement:e.hasImprovement,hasRegression:e.hasRegression,isInitial:e.isInitial,newIssues:e.newIssues,removedIssues:e.removedIssues,totalIssues:t})}let m={checks:p,exitCode:e.exitCode,hasImprovement:e.hasImprovement,hasRegression:e.hasRegression,summary:{avgDuration:q(n,r),checksRun:r,improvementChecks:i,improvements:c,initial:u,initialChecks:o,regressionChecks:a,regressions:l,totalIssues:f,unchanged:d,unchangedChecks:s},totalDuration:n};return JSON.stringify(m,null,2)}function xe(e){if(e<1e3)return`${e}ms`;let t=e/1e3;if(t<60)return t%1==0?`${t}s`:`${t.toFixed(1)}s`;let n=e/6e4;if(n<60)return n%1==0?`${n}m`:`${n.toFixed(1)}m`;let r=e/36e5;return r%1==0?`${r}h`:`${r.toFixed(1)}h`}function J(e){let t=Math.round(e);return t<1?`<1ms`:xe(t)}const Y=` `,Se=`${Y} `;function Ce(e){return e===`initial`?y(`→`):e===`improvement`?b(`↑`):x(`↓`)}function we(n,r,i){let a=t(n),o=e(n),s=r>0?`:${r}:${i>0?i:1}`:``;return`${a===`.`?``:y(`${a}/`)}${ee(o)}${s?y(s):``}`}function Te(e,t){return[`${Ce(t)} ${we(e.file,e.line,e.column)} ${y(e.rule)}`,e.message]}function X(e,t){let n=[],r=e.slice(0,10);for(let e of r){let[r,i]=Te(e,t);n.push(`${Y}${r}`,`${Se}${i}`)}let i=e.length-r.length;return i>0&&n.push(`${Y}${y(`... and ${i} more`)}`),n}function Ee(e){return e===void 0?[]:[` ${y(`Duration`)} ${J(e)}`]}function De(e){return[` ${y(`Issues`)} ${_(e)}`]}function Z(e){return[...Ee(e.duration),...De(e.snapshot.items.length)]}function Oe(e){if(!e.hasRegression)return[];let t=e.newIssues.length;return[` ${x(t)} new ${D(t,`issue`)} (${D(t,`regression`)}):`,...X(e.newIssues,`regression`)]}function Q(e){if(!e.hasImprovement)return[];let t=e.removedIssues.length;return[` ${b(t)} ${D(t,`issue`)} fixed (${D(t,`improvement`)}):`,...X(e.removedIssues,`improvement`)]}function ke(e,t){let n=t?``:`
|
|
20
|
+
`,r=e.snapshot.items.length,i=[`${n}${g(`ℹ`)} ${e.checkId}:`,` Initial baseline created with ${g(r)} ${D(r,`issue`)}`];return e.snapshot.items.length>0&&i.push(...X(e.snapshot.items,`initial`)),i.push(``,...Z(e)),i}function Ae(e,t){return[`${t?``:`
|
|
21
|
+
`}${e.hasRegression?x(`✖`):b(`✔`)} ${e.checkId}:`,...Oe(e),...Q(e),``,...Z(e)]}function je(e,t){let n=t?``:`
|
|
22
|
+
`,r=e.snapshot.items.length;return e.duration===void 0?[`${n}${S(`ℹ`)} ${e.checkId} (${_(r)})`]:[`${n}${S(`ℹ`)} ${e.checkId} (${_(r)}) ${y(J(e.duration))}`]}function Me(e,t){return e.isInitial?ke(e,t):e.hasRegression||e.hasImprovement?Ae(e,t):je(e,t)}function Ne(e,t,n){return t?g(`✔ Initial baseline created successfully`):e.hasRegression?n?te(`⚠ Regressions detected (forced)`):`${x(`✗ Regressions detected`)} - Run failed`:e.hasImprovement?`${b(`✔ Improvements detected`)} - Baseline updated`:b(`✔ All checks passed`)}function Pe(e,t){let n={hasAnyInitial:!1,totalImprovements:0,totalInitial:0,totalIssues:0,totalRegressions:0};for(let t of e.results){let e=t.snapshot.items.length;if(n.totalIssues+=e,t.isInitial){n.hasAnyInitial=!0,n.totalInitial+=e;continue}let{hasImprovement:r,hasRegression:i}=t;r&&(n.totalImprovements+=t.removedIssues.length),i&&(n.totalRegressions+=t.newIssues.length)}let r=[` ${y(`Improvements`)} ${b(n.totalImprovements)}`,` ${y(`Regressions`)} ${x(n.totalRegressions)}`,` ${y(`Initial`)} ${g(n.totalInitial)}`,` ${y(`Checks`)} ${e.results.length}`,` ${y(`Issues`)} ${_(n.totalIssues)}`],i=q(e.totalDuration,e.results.length);return e.totalDuration!==void 0&&i!==void 0&&r.push(` ${y(`Duration`)} ${J(e.totalDuration)} ${S(`(avg ${J(i)})`)}`),r.push(``,Ne(e,n.hasAnyInitial,t)),r.join(`
|
|
23
|
+
`)}function Fe(e,t){let n=[];for(let[t,r]of e.results.entries())n.push(...Me(r,t===0));return n.length>0&&n.push(``),n.push(Pe(e,t)),n.join(`
|
|
24
|
+
`)}const{values:$}=d({allowPositionals:!1,options:{force:{default:!1,short:`f`,type:`boolean`},help:{short:`h`,type:`boolean`},json:{default:!1,type:`boolean`},only:{type:`string`},skip:{type:`string`}},strict:!0});$.help&&(w.log(`
|
|
25
25
|
mejora - Prevent regressions by allowing only improvement
|
|
26
26
|
|
|
27
27
|
Usage:
|
|
@@ -40,4 +40,4 @@ Examples:
|
|
|
40
40
|
mejora --json
|
|
41
41
|
mejora --only "eslint > *"
|
|
42
42
|
mejora --skip typescript
|
|
43
|
-
`),process.exit(0));try{let e=new a,t=await n();e.init(t);let r=await new
|
|
43
|
+
`),process.exit(0));try{let e=new a,t=await n();e.init(t);let r=await new ye(e).run(t,{force:$.force,json:$.json,only:$.only,skip:$.skip});$.json?w.log(be(r)):(w.log(``),w.log(Fe(r,$.force))),process.exit(r.exitCode)}catch(e){e instanceof Error?w.error(e.message):w.error(e),process.exit(2)}export{};
|
package/dist/workers/check.d.mts
CHANGED
package/dist/workers/check.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e}from"../typescript-
|
|
1
|
+
import{g as e}from"../typescript-JQUGT569.mjs";import{t}from"../check-registry-BJlMzCIV.mjs";let n=null,r=null;const i=new Map;async function a({checkId:a}){n||(r??=(async()=>{n=await e()})(),await r);let o=n?.checks[a];if(!o)throw Error(`Check not found in config: ${a}`);let s=i.get(o.type);if(!s){s=new t,s.init(n);let e=new Set([o.type]);await Promise.all([s.setup(e),s.validate(e)]),i.set(o.type,s)}let c=performance.now(),l=await s.get(o.type).run(o);return{duration:performance.now()-c,snapshot:l}}export{a as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mejora",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.6",
|
|
4
4
|
"description": "Prevent regressions. Allow improvement.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"regression",
|
|
@@ -41,16 +41,12 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"eslint": "^9.34.0",
|
|
44
|
-
"tinyglobby": "^0.2.0",
|
|
45
44
|
"typescript": "^5.0.0"
|
|
46
45
|
},
|
|
47
46
|
"peerDependenciesMeta": {
|
|
48
47
|
"eslint": {
|
|
49
48
|
"optional": true
|
|
50
49
|
},
|
|
51
|
-
"tinyglobby": {
|
|
52
|
-
"optional": true
|
|
53
|
-
},
|
|
54
50
|
"typescript": {
|
|
55
51
|
"optional": true
|
|
56
52
|
}
|
|
File without changes
|