@principal-ai/quality-lens-cli 0.1.64 → 0.1.65

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.
Files changed (2) hide show
  1. package/dist/cli.js +1 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -986,7 +986,7 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
986
986
  `);return k!==-1&&(c=kpt(c,S,h,k)),h+c+S};Object.defineProperties(b$.prototype,oM);var Afr=b$(),CPr=b$({level:wpt?wpt.level:0});var Yv=Afr;var Hoe=class{report(c){console.log(Yv.bold(`
987
987
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`)),console.log(Yv.bold("Quality Lens Results")),console.log(Yv.bold(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
988
988
  `));let f=this.groupByPackage(c);Object.entries(f).forEach(([M,G])=>{console.log(Yv.bold.blue(`\u{1F4E6} ${M}`)),G.forEach(ne=>{let fe=ne.result?.success?"\u2713":"\u2717",pe=ne.result?.success?Yv.green:Yv.red,xe=ne.result?.duration?`(${ne.result.duration}ms)`:"";if(console.log(` ${pe(fe)} ${ne.lens}: ${ne.command} ${Yv.gray(xe)}`),ne.result?.lensResult?.issues&&ne.result.lensResult.issues.length>0){let $=ne.result.lensResult.issues.filter(Oe=>Oe.severity==="error").length,He=ne.result.lensResult.issues.filter(Oe=>Oe.severity==="warning").length;$>0&&console.log(` ${Yv.red(`${$} error(s)`)}`),He>0&&console.log(` ${Yv.yellow(`${He} warning(s)`)}`)}ne.error&&console.log(` ${Yv.red("Error:")} ${ne.error}`)}),console.log("")});let h=c.length,S=c.filter(M=>M.result?.success).length,k=h-S;console.log(Yv.bold("Summary:")),console.log(` Total: ${h}`),console.log(` ${Yv.green("Passed:")} ${S}`),console.log(` ${Yv.red("Failed:")} ${k}`),console.log("")}groupByPackage(c){return c.reduce((f,h)=>{let S=f[h.package]??[];return S.push(h),f[h.package]=S,f},{})}};var C$=class{static buildTreeFromPaths(c,f=""){let h=f.endsWith("/")?f.slice(0,-1):f,S=new Map,k=[],M=[],G=new Set;c.forEach(pe=>{let xe=pe.split("/");for(let $=1;$<xe.length;$++)G.add(xe.slice(0,$).join("/"))}),Array.from(G).forEach(pe=>{let xe=pe.split("/"),$=xe[xe.length-1]||"",He=xe.length-1,Oe={path:pe,name:$,children:[],fileCount:0,totalSize:0,depth:He,relativePath:this.calculateRelativePath(pe,h)};S.set(pe,Oe),M.push(Oe)}),c.forEach(pe=>{let xe=pe.split("/"),$=xe[xe.length-1]||"",He=this.extractExtension($),Oe=xe.slice(0,-1).join("/"),je={path:pe,name:$,extension:He,size:0,lastModified:new Date,isDirectory:!1,relativePath:this.calculateRelativePath(pe,h)};k.push(je);let yt=S.get(Oe);yt&&"children"in yt&&(yt.children.push(je),yt.fileCount++)}),Array.from(G).sort((pe,xe)=>xe.length-pe.length).forEach(pe=>{let xe=pe.split("/");if(xe.length>1){let $=xe.slice(0,-1).join("/"),He=S.get($),Oe=S.get(pe);He&&Oe&&"children"in He&&He.children.push(Oe)}});let ne=h&&h.split("/").pop()||"root",fe=[];return M.forEach(pe=>{pe.path.split("/").length===1&&fe.push(pe)}),k.forEach(pe=>{pe.path.split("/").length===1&&fe.push(pe)}),{root:{path:h||".",name:ne,children:fe,fileCount:k.length,totalSize:0,depth:0,relativePath:""},allFiles:k,allDirectories:M}}static buildTreeFromFileInfos(c,f=""){let h=f.endsWith("/")?f.slice(0,-1):f,S=new Map,k=[],M=new Set;c.forEach(fe=>{let pe=fe.path.split("/");for(let xe=1;xe<pe.length;xe++)M.add(pe.slice(0,xe).join("/"))}),Array.from(M).forEach(fe=>{let pe=fe.split("/"),xe=pe[pe.length-1]||"",$={path:fe,name:xe,children:[],fileCount:0,totalSize:0,depth:pe.length-1,relativePath:this.calculateRelativePath(fe,h)};S.set(fe,$),k.push($)}),c.forEach(fe=>{let pe=fe.path.split("/").slice(0,-1).join("/"),xe=S.get(pe);xe&&(xe.children.push(fe),xe.fileCount++,xe.totalSize+=fe.size||0)}),Array.from(M).sort((fe,pe)=>pe.length-fe.length).forEach(fe=>{let pe=fe.split("/");if(pe.length>1){let xe=pe.slice(0,-1).join("/"),$=S.get(xe),He=S.get(fe);$&&He&&($.children.push(He),$.fileCount+=He.fileCount,$.totalSize+=He.totalSize)}});let G=h&&h.split("/").pop()||"root",ne=[];return k.forEach(fe=>{fe.path.split("/").length===1&&ne.push(fe)}),c.forEach(fe=>{fe.path.split("/").length===1&&ne.push(fe)}),{root:{path:h||".",name:G,children:ne,fileCount:c.length,totalSize:c.reduce((fe,pe)=>fe+(pe.size||0),0),depth:0,relativePath:""},allFiles:c,allDirectories:k}}static calculateStats(c,f){return{totalFiles:c.length,totalDirectories:f.length,totalSize:c.reduce((h,S)=>h+(S.size||0),0),maxDepth:this.calculateMaxDepth(f)}}static calculateMaxDepth(c){return c.length===0?0:Math.max(...c.map(f=>f.depth||0))}static extractExtension(c){if(!c.includes("."))return"";let f=c.split(".");return"."+f[f.length-1].toLowerCase()}static calculateRelativePath(c,f){if(!f||f===""||f===".")return c;if(c===f)return"";if(c.startsWith(f)){let h=c.substring(f.length);return h.startsWith("/")?h.substring(1):h}return c}static hashPaths(c){let f=[...c].sort().join(`
989
- `),h=0;for(let S=0;S<f.length;S++){let k=f.charCodeAt(S);h=(h<<5)-h+k,h=h&h}return`paths-${Math.abs(h).toString(36)}`}static simpleHash(c){let f=0;for(let h=0;h<c.length;h++){let S=c.charCodeAt(h);f=(f<<5)-f+S,f=f&f}return Math.abs(f).toString(36)}},v6e=class{generateTimestampId(){return Date.now().toString(36)}simpleHash(c){let f=0;for(let h=0;h<c.length;h++){let S=c.charCodeAt(h);f=(f<<5)-f+S,f=f&f}return Math.abs(f).toString(36)}},Qoe=class extends v6e{build(c){let{files:f,rootPath:h=""}=c,{root:S,allFiles:k,allDirectories:M}=C$.buildTreeFromPaths(f,h),G=C$.calculateStats(k,M);return{sha:this.calculateSha(c),metadata:this.generateMetadata(c),root:S,allFiles:k,allDirectories:M,stats:G}}generateMetadata(c){let{files:f,rootPath:h=""}=c,S=this.calculateSha(c);return{id:`paths-${S}-${this.generateTimestampId()}`,timestamp:new Date,sourceType:"paths",sourceSha:S,sourceInfo:{fileCount:f.length,rootPath:h||"."}}}calculateSha(c){return C$.hashPaths(c.files)}};var W_=jm(woe()),FC=jm(require("fs/promises")),Yoe=jm(require("fs")),Uy=jm(require("path")),b6e=require("child_process");function Ffr(_){let f={eslint:()=>new W_.ESLintLens,lint:()=>new W_.ESLintLens,jest:()=>new W_.JestLens,test:()=>new W_.JestLens,typescript:()=>new W_.TypeScriptLens,typecheck:()=>new W_.TypeScriptLens,tsc:()=>new W_.TypeScriptLens,knip:()=>new W_.KnipLens,prettier:()=>new W_.PrettierLens,format:()=>new W_.PrettierLens,alexandria:()=>new W_.AlexandriaLens,docs:()=>new W_.AlexandriaLens,"bun-test":()=>new W_.BunTestLens,bun:()=>new W_.BunTestLens,vitest:()=>new W_.VitestLens,biome:()=>new W_.BiomeLens,"biome-lint":()=>{let h=new W_.BiomeLens;return h.setMode("lint"),h},"biome-format":()=>{let h=new W_.BiomeLens;return h.setMode("format"),h}}[_.toLowerCase()];return f?f():null}function Npt(_,c){if(!c||c===""||c===".")return _;let f={..._};if(f.issues&&Array.isArray(f.issues)&&(f.issues=f.issues.map(h=>({...h,file:h.file?`${c}/${h.file}`:h.file}))),f.fileMetrics&&Array.isArray(f.fileMetrics)&&(f.fileMetrics=f.fileMetrics.map(h=>({...h,file:h.file?`${c}/${h.file}`:h.file}))),f.coverage&&typeof f.coverage=="object"){let h=f.coverage,S=h.files;S&&Array.isArray(S)&&(h.files=S.map(k=>({...k,file:k.file?`${c}/${k.file}`:k.file})))}return f}function kfr(_,c,f,h,S){let k=Ffr(_);if(k)try{k.configure({cwd:S,tool:{name:_,command:_,args:[],cwd:S,available:!0}});let M={stdout:c,stderr:f,exitCode:h,duration:0},G=k.parse(M);return{...k.format(G),success:!0,raw:{stdout:c,stderr:f,exitCode:h}}}catch(M){console.log(` [parse] Could not parse ${_} output: ${M instanceof Error?M.message:"unknown error"}`);return}}var Ifr=`name: Quality Lens Analysis
989
+ `),h=0;for(let S=0;S<f.length;S++){let k=f.charCodeAt(S);h=(h<<5)-h+k,h=h&h}return`paths-${Math.abs(h).toString(36)}`}static simpleHash(c){let f=0;for(let h=0;h<c.length;h++){let S=c.charCodeAt(h);f=(f<<5)-f+S,f=f&f}return Math.abs(f).toString(36)}},v6e=class{generateTimestampId(){return Date.now().toString(36)}simpleHash(c){let f=0;for(let h=0;h<c.length;h++){let S=c.charCodeAt(h);f=(f<<5)-f+S,f=f&f}return Math.abs(f).toString(36)}},Qoe=class extends v6e{build(c){let{files:f,rootPath:h=""}=c,{root:S,allFiles:k,allDirectories:M}=C$.buildTreeFromPaths(f,h),G=C$.calculateStats(k,M);return{sha:this.calculateSha(c),metadata:this.generateMetadata(c),root:S,allFiles:k,allDirectories:M,stats:G}}generateMetadata(c){let{files:f,rootPath:h=""}=c,S=this.calculateSha(c);return{id:`paths-${S}-${this.generateTimestampId()}`,timestamp:new Date,sourceType:"paths",sourceSha:S,sourceInfo:{fileCount:f.length,rootPath:h||"."}}}calculateSha(c){return C$.hashPaths(c.files)}};var W_=jm(woe()),FC=jm(require("fs/promises")),Yoe=jm(require("fs")),Uy=jm(require("path")),b6e=require("child_process");function Ffr(_){let f={eslint:()=>new W_.ESLintLens,lint:()=>new W_.ESLintLens,jest:()=>new W_.JestLens,test:()=>new W_.JestLens,typescript:()=>new W_.TypeScriptLens,typecheck:()=>new W_.TypeScriptLens,tsc:()=>new W_.TypeScriptLens,knip:()=>new W_.KnipLens,prettier:()=>new W_.PrettierLens,format:()=>new W_.PrettierLens,alexandria:()=>new W_.AlexandriaLens,docs:()=>new W_.AlexandriaLens,"bun-test":()=>new W_.BunTestLens,bun:()=>new W_.BunTestLens,vitest:()=>new W_.VitestLens,biome:()=>new W_.BiomeLens,"biome-lint":()=>{let h=new W_.BiomeLens;return h.setMode("lint"),h},"biome-format":()=>{let h=new W_.BiomeLens;return h.setMode("format"),h}}[_.toLowerCase()];return f?f():null}function Npt(_,c){if(!c||c===""||c===".")return _;let f=S=>!S||S.startsWith(c+"/")||S===c?S:`${c}/${S}`,h={..._};if(h.issues&&Array.isArray(h.issues)&&(h.issues=h.issues.map(S=>({...S,file:f(S.file)}))),h.fileMetrics&&Array.isArray(h.fileMetrics)&&(h.fileMetrics=h.fileMetrics.map(S=>({...S,file:f(S.file)}))),h.coverage&&typeof h.coverage=="object"){let S=h.coverage,k=S.files;k&&Array.isArray(k)&&(S.files=k.map(M=>({...M,file:M.file?f(M.file):M.file})))}return h}function kfr(_,c,f,h,S){let k=Ffr(_);if(k)try{k.configure({cwd:S,tool:{name:_,command:_,args:[],cwd:S,available:!0}});let M={stdout:c,stderr:f,exitCode:h,duration:0},G=k.parse(M);return{...k.format(G),success:!0,raw:{stdout:c,stderr:f,exitCode:h}}}catch(M){console.log(` [parse] Could not parse ${_} output: ${M instanceof Error?M.message:"unknown error"}`);return}}var Ifr=`name: Quality Lens Analysis
990
990
 
991
991
  on:
992
992
  push:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principal-ai/quality-lens-cli",
3
- "version": "0.1.64",
3
+ "version": "0.1.65",
4
4
  "description": "CLI tool for running quality lenses on codebases in CI/CD pipelines",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",