@principal-ai/quality-lens-cli 0.1.43 → 0.1.44
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/cli.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1103,7 +1103,7 @@ jobs:
|
|
|
1103
1103
|
name: quality-lens-results-\${{ github.sha }}
|
|
1104
1104
|
path: results.json
|
|
1105
1105
|
if-no-files-found: warn
|
|
1106
|
-
`,y6e={eslint:{bin:"eslint",args:[".","--
|
|
1106
|
+
`,y6e={eslint:{bin:"eslint",args:[".","--format","json"]},lint:{bin:"eslint",args:[".","--format","json"]},typescript:{bin:"tsc",args:["--noEmit","--pretty","false","--listFiles"]},typecheck:{bin:"tsc",args:["--noEmit","--pretty","false","--listFiles"]},jest:{bin:"jest",args:["--passWithNoTests","--json","--no-colors","--coverage"]},test:{bin:"jest",args:["--passWithNoTests","--json","--no-colors","--coverage"]},prettier:{bin:"prettier",args:["--check",".","--no-error-on-unmatched-pattern","--no-color","--log-level","debug"]},format:{bin:"prettier",args:["--check",".","--no-error-on-unmatched-pattern","--no-color","--log-level","debug"]},knip:{bin:"knip",args:["--reporter","json"]},alexandria:{bin:"alexandria",args:["coverage","--json"]},docs:{bin:"alexandria",args:["coverage","--json"]}},Koe={eslint:["npx","--yes","eslint",".","--format","json"],lint:["npx","--yes","eslint",".","--format","json"],typescript:["npx","--yes","tsc","--noEmit","--pretty","false","--listFiles"],typecheck:["npx","--yes","tsc","--noEmit","--pretty","false","--listFiles"],jest:["npx","--yes","jest","--passWithNoTests","--json","--no-colors","--coverage"],test:["npx","--yes","jest","--passWithNoTests","--json","--no-colors","--coverage"],prettier:["npx","--yes","prettier","--check",".","--no-error-on-unmatched-pattern","--no-color","--log-level","debug"],format:["npx","--yes","prettier","--check",".","--no-error-on-unmatched-pattern","--no-color","--log-level","debug"],knip:["npx","--yes","knip","--reporter","json"],alexandria:["npx","--yes","@principal-ai/alexandria-cli","coverage","--json"],docs:["npx","--yes","@principal-ai/alexandria-cli","coverage","--json"]};async function kfr(_,c){let f=AC.join(_,"node_modules",".bin",c);try{return await jT.access(f),!0}catch{return!1}}function Ifr(_,c){let f=Date.now(),g=y6e[_];return g?new Promise(S=>{let k="",j="",le=`"${AC.join(c,"node_modules",".bin",g.bin)}" ${g.args.join(" ")}`,me=(0,D6e.spawn)(le,[],{cwd:c,shell:!0});me.stdout&&me.stdout.on("data",De=>{k+=De.toString()}),me.stderr&&me.stderr.on("data",De=>{j+=De.toString()}),me.on("close",De=>{S({success:De!==null&&De!==127,stdout:k,stderr:j,duration:Date.now()-f,exitCode:De??1})}),me.on("error",De=>{S({success:!1,stdout:k,stderr:j||De.message,duration:Date.now()-f,exitCode:1})})}):Promise.resolve({success:!1,stdout:"",stderr:`No local command defined for lens: ${_}`,duration:Date.now()-f,exitCode:1})}function wfr(_,c){let f=Date.now(),g=Koe[_];return g?new Promise(S=>{let k="",j="",Z=g.join(" "),le=(0,D6e.spawn)(Z,[],{cwd:c,shell:!0});le.stdout&&le.stdout.on("data",me=>{k+=me.toString()}),le.stderr&&le.stderr.on("data",me=>{j+=me.toString()}),le.on("close",me=>{S({success:me!==null&&me!==127,stdout:k,stderr:j,duration:Date.now()-f,exitCode:me??1})}),le.on("error",me=>{S({success:!1,stdout:k,stderr:j||me.message,duration:Date.now()-f,exitCode:1})})}):Promise.resolve({success:!1,stdout:"",stderr:`No npx command defined for lens: ${_}`,duration:Date.now()-f,exitCode:1})}async function v6e(_){let c=await Ppt(_,"");return new Qoe().build({files:c,rootPath:_})}async function Ppt(_,c){let f=[],g=await jT.readdir(_,{withFileTypes:!0});for(let S of g){if(Pfr(S.name))continue;let k=AC.join(_,S.name),j=c?`${c}/${S.name}`:S.name;if(S.isDirectory()){let Z=await Ppt(k,j);f.push(...Z)}else S.isFile()&&f.push(j)}return f}function Pfr(_){return["node_modules",".git",".next",".nuxt","dist","build","coverage",".turbo",".cache"].includes(_)||_.startsWith(".")}async function Nfr(_){let c=new iM,f=new zoe,g=new Woe,S=new Hoe;try{let k=AC.resolve(_.path);console.log(`Scanning repository: ${k}`);let j=await v6e(k);g.setFileTree(j);let Z=await c.extractPackages(j,k);Z.length===0&&(console.warn("No packages found in repository"),process.exit(1)),console.log(`Found ${Z.length} package(s)`);let le=_.lenses?_.lenses.split(",").map(Fe=>Fe.trim()):null,me=[];for(let Fe of Z){let Q=Fe.packageData.availableCommands?.filter(je=>!(!je.isLensCommand||le&&!le.includes(je.lensId||"")||je.name.includes("watch")||je.name.includes(":dev")));if(!Q||Q.length===0){console.log(`Skipping ${Fe.packageData.name} (no lens commands)`);continue}console.log(`
|
|
1107
1107
|
Running lenses for ${Fe.packageData.name}...`);let et=Fe.packageData.path||"",ze=et?AC.join(k,et):k;for(let je of Q){let Ct=je.lensId||"unknown";console.log(` - ${Ct}: ${je.name}`);try{let Ut;if(_.install&&(y6e[Ct]||Koe[Ct])){let Fr=y6e[Ct],Sr=Fr?await kfr(ze,Fr.bin):!1,Kn,Li;Sr&&Fr?(console.log(` [local] Using installed ${Fr.bin}`),Kn=await Ifr(Ct,ze),Li=`node_modules/.bin/${Fr.bin} ${Fr.args.join(" ")}`):Koe[Ct]?(console.log(" [npx] Tool not installed locally, using npx"),Kn=await wfr(Ct,ze),Li=Koe[Ct].join(" ")):(Kn={success:!1,stdout:"",stderr:`No command available for lens: ${Ct}`,duration:0,exitCode:1},Li="none");let Ln=Afr(Ct,Kn.stdout,Kn.stderr,Kn.exitCode,ze);Ut={success:Kn.success,toolName:Ct,command:Li,packagePath:et,exitCode:Kn.exitCode,duration:Kn.duration,stdout:Kn.stdout,stderr:Kn.stderr,lensResult:Ln}}else Ut=await f.executeTool({repoPath:k,packageLayer:Fe,packageCommand:je});me.push({package:Fe.packageData.name,packagePath:Fe.packageData.path,lens:Ct,command:je.name,result:Ut,timestamp:Date.now()}),console.log(` ${Ut.success?"\u2713":"\u2717"} ${Ut.success?"Success":"Failed"} (${Ut.duration}ms)`)}catch(Ut){let Fr=Ut instanceof Error?Ut.message:String(Ut);console.error(` \u2717 Error: ${Fr}`),me.push({package:Fe.packageData.name,packagePath:Fe.packageData.path,lens:Ct,command:je.name,error:Fr,timestamp:Date.now()})}}}if(_.format==="json"){let Fe=g.format(me);_.output?(await jT.writeFile(_.output,Fe,"utf-8"),console.log(`
|
|
1108
1108
|
Results written to: ${_.output}`)):console.log(`
|
|
1109
1109
|
`+Fe)}else S.report(me);let De=me.some(Fe=>Fe.error||!Fe.result?.success);process.exit(De?1:0)}catch(k){let j=k instanceof Error?k.message:String(k);console.error("Fatal error:",j),process.exit(1)}}UQe(cxe(process.argv)).command("run [path]","Run quality lenses on repository",_=>_.positional("path",{describe:"Repository path",type:"string",default:process.cwd()}).option("output",{alias:"o",describe:"Output file for results",type:"string"}).option("lenses",{describe:"Specific lenses to run (comma-separated)",type:"string",example:"eslint,jest,typescript"}).option("format",{describe:"Output format",choices:["json","console"],default:"console"}).option("install",{alias:"i",describe:"Run tools via npx (no local dependencies required)",type:"boolean",default:!1}),_=>Nfr(_)).command("list [path]","List available lenses in repository",_=>_.positional("path",{describe:"Repository path",type:"string",default:process.cwd()}),async _=>{let c=AC.resolve(_.path??process.cwd()),f=new iM;console.log(`Scanning repository: ${c}`);let g=await v6e(c);(await f.extractPackages(g,c)).forEach(k=>{console.log(`
|