@webority/repo-checks 0.114.0 → 0.115.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.
@@ -107,4 +107,4 @@ fi
107
107
  `).length-1:t.split(`
108
108
  `).length;return n>800?[{rule:`oversize`,line:1,text:`over 800 lines: split it along its concerns`,hint:null}]:n>600?[{rule:`oversize`,line:1,text:`over 600 lines`,hint:null}]:[]}var wo=`rename-wrapper`,To=`@webority/ui-react`,Eo=`["']${To}["']`,B=e=>e.replace(/[^\n]/g,` `);function V(e,t,n){let r=e.slice(0,t).split(`
109
109
  `).length;return{rule:wo,line:r,text:e.split(`
110
- `)[r-1].trim(),hint:n}}function Do(e){return e.replace(/\/\*[\s\S]*?\*\//g,B).replace(/\/\/[^\n]*/g,B)}function Oo(e){let t=new Map,n=RegExp(`import\\s+(?:type\\s+)?([\\s\\S]*?)\\s+from\\s*${Eo}`,`g`);for(let r of e.matchAll(n)){let e=r[1],n=e.match(/\{([^}]*)\}/);if(n)for(let e of n[1].split(`,`)){let n=e.trim().replace(/^type\s+/,``).split(/\s+as\s+/);n[0]&&t.set(n[n.length-1],n[0])}let i=e.match(/\*\s*as\s+(\w+)/);i&&t.set(i[1],`*`);let a=e.replace(/\{[^}]*\}/,``).replace(/\*\s*as\s+\w+/,``);for(let e of a.split(`,`)){let n=e.trim();/^\w+$/.test(n)&&t.set(n,`default`)}}return t}function ko(e){let t=RegExp(`^[ \\t]*export\\s+(?:type\\s+)?(?:\\*(?:\\s+as\\s+\\w+)?|\\{[^}]*\\})\\s*from\\s*${Eo}`,`gm`);return[...e.matchAll(t)].map(t=>V(e,t.index,`Import the name from ${To} where it is used; a file that only re-exports it adds nothing.`))}function Ao(e,t){let n=[];if(t.size===0)return n;let r=`Import the name from ${To} where it is used instead of exporting it through this file.`;for(let i of e.matchAll(/^[ \t]*export\s*\{([^}]*)\}(?!\s*from)/gm))i[1].split(`,`).some(e=>t.has(e.trim().replace(/^type\s+/,``).split(/\s+as\s+/)[0]))&&n.push(V(e,i.index,r));for(let i of e.matchAll(/^[ \t]*export\s+default\s+(\w+)\s*;?[ \t]*$/gm))t.has(i[1])&&n.push(V(e,i.index,r));return n}function jo(e,t,n,r){if(!/\.(jsx|tsx)$/.test(e))return[];let i=Do(t);if(/\buse[A-Z]\w*\s*[(<]/.test(i)||/\b(if|switch)\s*\(/.test(i)||[...i.matchAll(/\breturn\b/g)].length>1)return[];let a=i.match(/(?:\breturn|=>)\s*\(?\s*<([A-Za-z][\w.]*)/);if(!a)return[];let o=a[1],s=r.get(o);return!s||s===`*`||!n.has(s)||[...i.matchAll(/<([A-Za-z][\w.]*)/g)].length!==1||/[?]|&&|\|\|/.test(i.slice(a.index))?[]:[V(t,a.index,`Import ${s} from ${To} and use it where this component is used instead of a wrapper.`)]}function Mo(e,t){let n=e.split(/[\\/]/).pop();if(!n.startsWith(`_`)||!n.endsWith(`.cshtml`))return[];let r=t.replace(/@\*[\s\S]*?\*@/g,B).replace(/<!--[\s\S]*?-->/g,B).replace(/^[ \t]*@(?:model|using)\b[^\n]*/gm,B),i=r.search(/\S/);if(i<0)return[];let a=r.slice(i).trimEnd(),o=a.match(/^<(app-[a-z0-9-]+)/);return!o||!a.endsWith(`/>`)&&!a.endsWith(`</${o[1]}>`)||(a.match(/<[A-Za-z]/g)||[]).length!==1?[]:[V(t,i,`Render the <${o[1]}> tag directly where the partial is used instead of a partial that only renders it.`)]}function No(e,t,n){let r=Oo(t);return[...ko(t),...Ao(t,r),...jo(e,t,n,r),...Mo(e,t)]}var Po=()=>new Set(to),Fo=[`*.js`,`*.jsx`,`*.ts`,`*.tsx`,`*.cshtml`];function Io(e){let n=[];for(let i of I(e,[`package.json`])){if(!t(l(e,i)))continue;let a;try{a=JSON.parse(r(l(e,i),`utf8`))}catch{continue}if(Pi(a)!==`mobile`)continue;let o=d.dirname(i);n.push(o===`.`?`src/`:`${o}/src/`)}return n}function Lo(e,n=null){let i=n?n.map(t=>Ai(e,t)):null,a=Io(e),o=e=>!i||i.some(t=>t===`.`||e===t||e.startsWith(`${t}/`)),s=I(e,Object.keys(ye).map(e=>`*${e}`)).filter(n=>t(l(e,n))&&!Ae(n,e)&&o(n)),u=[],d=Po(),f=Yi(e);for(let t of s){let n=c(t).toLowerCase(),i=ye[n],o=r(l(e,t),`utf8`),s=t.startsWith(`packages/`)||t.startsWith(`samples/`),p=()=>s?[]:[...co(o,i),...No(t,o,f)],m=[];if(i===`scss`||i===`css`||i===`markup`)m=Rt(o,i),(i===`scss`||i===`css`)&&!s&&m.push(...eo(o,i,d)),i===`markup`&&m.push(...p(),...s?[]:Za(o),...s?[]:So(o,`markup`),...Co(t,o));else if(i===`script`){let e=!s&&a.some(e=>t.startsWith(e)),r=dn(o)||e;if(be.includes(n)&&!r)continue;let i=s?[]:va(o,{phone:_a(o)});m=[...fn(o,{phone:r,colourLiterals:e}),...i],e&&a.some(e=>t===`${e}assets/theme/settings.js`)&&(m=m.filter(e=>e.rule!==`raw-colour`)),(n===`.jsx`||n===`.tsx`)&&m.push(...p(),...Co(t,o))}else i===`csharp`&&(s||(m=So(o,`csharp`)));for(let e of m)u.push({id:`${e.rule}:${t}`,line:e.line,text:e.text,hint:e.hint})}let p=I(e,Fo).filter(n=>t(l(e,n)));for(let t of za(e,p)){let n=t.file.startsWith(`packages/`)||t.file.startsWith(`samples/`);o(t.file)&&!Ae(t.file,e)&&!n&&u.push({id:`${t.rule}:${t.file}`,line:t.line,text:t.text,hint:t.hint})}return u.sort((e,t)=>e.id<t.id?-1:e.id>t.id?1:e.line-t.line)}function Ro(e){let t={};for(let n of e)t[n.id]=(t[n.id]||0)+1;return t}var H=process.argv.slice(2),zo=new Set(H.flatMap((e,t)=>e===`--baseline-accept`||e===`--reason`?[t+1]:[])),U=new Set(H.filter((e,t)=>e.startsWith(`--`)&&!zo.has(t))),W=H.filter((e,t)=>!e.startsWith(`--`)&&!zo.has(t)),Bo=U.has(`--sync-hook`),Vo=e=>H.includes(e)?H[H.indexOf(e)+1]:void 0,Ho=Vo(`--baseline-accept`),Uo=Vo(`--reason`),Wo=Vo(`--baseline-adopt`)?.split(`,`).map(e=>e.trim()).filter(Boolean),Go=e=>typeof e==`string`&&e.trim()!==``,G=e=>process.stdout.write(`${e}\n`),K=e=>process.stderr.write(`${e}\n`);U.has(`--json`)&&(console.log=(...e)=>console.error(...e));var Ko=new Set([`--json`,`--baseline-init`,`--baseline-shrink`,`--baseline-accept`,`--reason`,`--sync-hook`,`--baseline-adopt`]),qo=[...U].filter(e=>!Ko.has(e)),Jo=U.has(`--baseline-accept`),Yo=(Jo||U.has(`--reason`))&&!(Go(Ho)&&Go(Uo)),Xo=Jo&&(U.has(`--baseline-init`)||U.has(`--baseline-shrink`)||Bo||U.has(`--baseline-adopt`)),Zo=U.has(`--baseline-adopt`)&&(U.has(`--baseline-init`)||U.has(`--baseline-shrink`)||U.has(`--baseline-accept`)||Bo);(qo.length||U.has(`--baseline-init`)&&U.has(`--baseline-shrink`)||Bo&&(U.size>1||W.length)||Yo||Xo||Zo)&&(K(`repo-checks: unknown or conflicting options ${qo.join(` `)}`.trim()),K(`usage: webority-repo-checks [--json] [--baseline-init | --baseline-shrink] [--baseline-accept <folder> --reason <text>] [--baseline-adopt <rule,...>] [app folder ...]`),K(` webority-repo-checks --sync-hook`),process.exit(2));var q=Mi(process.cwd());if(q||(K(`repo-checks: not inside a git repository.`),process.exit(2)),Bo){let t=l(q,aa);n(s(t),{recursive:!0}),a(t,Re),e(t,493),G(`repo-checks: wrote ${t}`),process.exit(0)}var Qo=sa(q,W.length?W.map(e=>p(process.cwd(),e)):null).sort((e,t)=>e.pkg===t.pkg?0:e.pkg<t.pkg?-1:1),$o=Qo.filter(e=>e.warning),es=Qo.filter(e=>!e.warning),ts=es.filter(e=>e.id.startsWith(`lint:`)),ns=es.filter(e=>!e.id.startsWith(`lint:`)),rs=Lo(q,W.length?W.map(e=>p(process.cwd(),e)):null),J={findings:ns.map(e=>y(e.pkg,e.id)),counts:Ro(rs)},is=new Map(ns.map(e=>[y(e.pkg,e.id),e]));if(U.has(`--baseline-init`)){W.length&&(K(`repo-checks: --baseline-init reads the whole repository; run it without folder arguments.`),process.exit(2)),t(l(q,`.webority/baselines/repo-checks-baseline.json`))&&(K(`repo-checks: ${g} already exists. It only shrinks: fix a new finding, or run --baseline-shrink after fixing old ones.`),process.exit(2)),x(q,ie(J));let e=Object.keys(J.counts).length;G(`repo-checks: recorded ${ns.length} finding(s) and ${e} counted file(s) (${rs.length} code finding(s)) in ${g}.`),process.exit(0)}var Y=(()=>{try{return ee(q)}catch(e){throw e instanceof v&&(K(`repo-checks: ${e.message}`),process.exit(2)),e}})();if(U.has(`--baseline-shrink`)){W.length&&(K(`repo-checks: --baseline-shrink reads the whole repository; run it without folder arguments.`),process.exit(2)),Y===null&&(K(`repo-checks: no ${g}; run webority-repo-checks --baseline-init first.`),process.exit(2));let e=se(Y,J);x(q,ce(Y,J)),G(`repo-checks: dropped ${e.stale.length} fixed finding(s) and lowered ${e.fallen.length} count(s) in ${g}.`),process.exit(0)}if(Jo){W.length&&(K(`repo-checks: --baseline-accept reads the whole repository; run it without folder arguments.`),process.exit(2)),Y===null&&(K(`repo-checks: no ${g}; run webority-repo-checks --baseline-init first.`),process.exit(2));let e=le(Y,J,Ho,Uo),t=new Set(Y.findings),n=e.findings.filter(e=>!t.has(e)).length,r=Object.keys(e.counts).filter(t=>(Y.counts[t]??0)<e.counts[t]).length;x(q,e),G(`repo-checks: accepted ${n} finding(s) and ${r} count(s) under ${Ho} (${Uo}).`),process.exit(0)}if(U.has(`--baseline-adopt`)){W.length&&(K(`repo-checks: --baseline-adopt reads the whole repository; run it without folder arguments.`),process.exit(2)),Y===null&&(K(`repo-checks: no ${g}; run webority-repo-checks --baseline-init first.`),process.exit(2)),Wo?.length||(K(`repo-checks: --baseline-adopt needs a comma-separated list of rule ids.`),process.exit(2));let e;try{e=ae(Y,J,Wo)}catch(e){throw e instanceof v&&(K(`repo-checks: ${e.message}`),process.exit(2)),e}x(q,e);let t=new Set(Y.findings);for(let n of Wo){let r=e.findings.filter(e=>!t.has(e)&&b(e)[1].split(`:`)[0]===n).length,i=Object.keys(e.counts).filter(e=>!(e in Y.counts)&&e.split(`:`)[0]===n).length;G(`repo-checks: adopted ${r} finding(s) and ${i} count(s) for ${n} in ${g}.`)}process.exit(0)}var as=new Set(W.map(e=>f(q,p(process.cwd(),e)).split(`\\`).join(`/`)||`.`)),os=W.length?{pkgs:as,dirs:[...as]}:null,X=se(oe(Y??{version:2,findings:[],counts:{}},os),J),ss={"raw-measure":je,"palette-read":Pe,"raw-colour":Me,"root-font-size":Ne,"missing-canvas-key":Fe,"repeated-canvas-key":Ie},cs=e=>ss[e.slice(0,e.indexOf(`:`))],Z=[...X.fresh.map(e=>is.get(e)),...ts],ls=X.known.map(e=>is.get(e)),us=e=>[`${e.current} found, ${e.baseline} recorded.`,cs(e.id)].filter(Boolean).join(` `),ds=e=>mi(e.id.split(`:`)[0]),Q=X.over.filter(ds).map(e=>({pkg:`.`,id:e.id,message:us(e),lines:rs.filter(t=>t.id===e.id).map(({line:e,text:t,hint:n})=>({line:e,text:t,hint:n}))})),fs=X.over.filter(e=>!ds(e)).map(e=>({pkg:`.`,id:e.id,message:us(e)})),ps=X.within.map(e=>({pkg:`.`,id:e.id,message:`${e.current} found, ${e.baseline} recorded.`})),ms=[...X.stale.map(b),...X.fallen.map(e=>[`.`,e.id])],$=[...$o,...fs];if(U.has(`--json`)||(()=>{if($.length!==0){K(`repo-checks: ${$.length} warning(s), not enforced yet. Name a rule in REPO_CHECKS_ENFORCE (comma list, or all) to fail on it:`);for(let e of $)K(` - ${e.pkg} ${e.id}: ${e.message}`)}})(),U.has(`--json`)){let e={root:q,new:[...Z,...Q],known:[...ls,...ps],stale:ms,warnings:$.map(e=>({pkg:e.pkg,id:e.id,message:e.message}))};G(JSON.stringify(e,null,2)),process.exitCode=Z.length||Q.length?1:0}else if(Z.length||Q.length){if(Z.length){K(`repo-checks: ${Z.length} new finding(s)`);let e=null;for(let t of Z)t.pkg!==e&&(e=t.pkg,K(` ${e}`)),K(` - ${t.id}: ${t.message}`)}if(Q.length){K(`repo-checks: ${Q.length} file(s) above their recorded count`);for(let e of Q){K(` ${e.id}: ${e.message}`);for(let t of e.lines)K(` ${t.line}: ${t.text}`),t.hint!==null&&K(` ${t.hint}`)}}process.exitCode=1}else{if(G(`repo-checks: no new findings.`),ls.length||ps.length){let e=X.within.reduce((e,t)=>e+t.current,0);G(`repo-checks: ${ls.length} known finding(s) and ${e} counted code finding(s) in ${ps.length} file(s) recorded in ${g}.`)}if(X.stale.length){G(`repo-checks: ${X.stale.length} baseline entr${X.stale.length===1?`y is`:`ies are`} fixed; drop them with webority-repo-checks --baseline-shrink:`);for(let e of X.stale.map(b))G(` ${e[0]} ${e[1]}`)}if(X.fallen.length){G(`repo-checks: ${X.fallen.length} count(s) fell; record them with webority-repo-checks --baseline-shrink:`);for(let e of X.fallen)G(` ${e.id} ${e.baseline} -> ${e.current}`)}}export{};
110
+ `)[r-1].trim(),hint:n}}function Do(e){return e.replace(/\/\*[\s\S]*?\*\//g,B).replace(/\/\/[^\n]*/g,B)}function Oo(e){let t=new Map,n=RegExp(`import\\s+(?:type\\s+)?([\\s\\S]*?)\\s+from\\s*${Eo}`,`g`);for(let r of e.matchAll(n)){let e=r[1],n=e.match(/\{([^}]*)\}/);if(n)for(let e of n[1].split(`,`)){let n=e.trim().replace(/^type\s+/,``).split(/\s+as\s+/);n[0]&&t.set(n[n.length-1],n[0])}let i=e.match(/\*\s*as\s+(\w+)/);i&&t.set(i[1],`*`);let a=e.replace(/\{[^}]*\}/,``).replace(/\*\s*as\s+\w+/,``);for(let e of a.split(`,`)){let n=e.trim();/^\w+$/.test(n)&&t.set(n,`default`)}}return t}function ko(e){let t=RegExp(`^[ \\t]*export\\s+(?:type\\s+)?(?:\\*(?:\\s+as\\s+\\w+)?|\\{[^}]*\\})\\s*from\\s*${Eo}`,`gm`);return[...e.matchAll(t)].map(t=>V(e,t.index,`Import the name from ${To} where it is used; a file that only re-exports it adds nothing.`))}function Ao(e,t){let n=[];if(t.size===0)return n;let r=`Import the name from ${To} where it is used instead of exporting it through this file.`;for(let i of e.matchAll(/^[ \t]*export\s*\{([^}]*)\}(?!\s*from)/gm))i[1].split(`,`).some(e=>t.has(e.trim().replace(/^type\s+/,``).split(/\s+as\s+/)[0]))&&n.push(V(e,i.index,r));for(let i of e.matchAll(/^[ \t]*export\s+default\s+(\w+)\s*;?[ \t]*$/gm))t.has(i[1])&&n.push(V(e,i.index,r));return n}function jo(e,t,n,r){if(!/\.(jsx|tsx)$/.test(e))return[];let i=Do(t);if(/\buse[A-Z]\w*\s*[(<]/.test(i)||/\b(if|switch)\s*\(/.test(i)||[...i.matchAll(/\breturn\b/g)].length>1)return[];let a=i.match(/(?:\breturn|=>)\s*\(?\s*<([A-Za-z][\w.]*)/);if(!a)return[];let o=a[1],s=r.get(o);return!s||s===`*`||!n.has(s)||[...i.matchAll(/<([A-Za-z][\w.]*)/g)].length!==1||/[?]|&&|\|\|/.test(i.slice(a.index))?[]:[V(t,a.index,`Import ${s} from ${To} and use it where this component is used instead of a wrapper.`)]}function Mo(e,t){let n=e.split(/[\\/]/).pop();if(!n.startsWith(`_`)||!n.endsWith(`.cshtml`))return[];let r=t.replace(/@\*[\s\S]*?\*@/g,B).replace(/<!--[\s\S]*?-->/g,B).replace(/^[ \t]*@(?:model|using)\b[^\n]*/gm,B),i=r.search(/\S/);if(i<0)return[];let a=r.slice(i).trimEnd(),o=a.match(/^<(app-[a-z0-9-]+)/);return!o||!a.endsWith(`/>`)&&!a.endsWith(`</${o[1]}>`)||(a.match(/<[A-Za-z]/g)||[]).length!==1?[]:[V(t,i,`Render the <${o[1]}> tag directly where the partial is used instead of a partial that only renders it.`)]}function No(e,t,n){let r=Oo(t);return[...ko(t),...Ao(t,r),...jo(e,t,n,r),...Mo(e,t)]}var Po=()=>new Set(to),Fo=[`*.js`,`*.jsx`,`*.ts`,`*.tsx`,`*.cshtml`];function Io(e){let n=[];for(let i of I(e,[`package.json`])){if(!t(l(e,i)))continue;let a;try{a=JSON.parse(r(l(e,i),`utf8`))}catch{continue}if(Pi(a)!==`mobile`)continue;let o=d.dirname(i);n.push(o===`.`?`src/`:`${o}/src/`)}return n}function Lo(e,n=null){let i=n?n.map(t=>Ai(e,t)):null,a=Io(e),o=e=>!i||i.some(t=>t===`.`||e===t||e.startsWith(`${t}/`)),s=I(e,Object.keys(ye).map(e=>`*${e}`)).filter(n=>t(l(e,n))&&!Ae(n,e)&&o(n)),u=[],d=Po(),f=Yi(e);for(let t of s){let n=c(t).toLowerCase(),i=ye[n],o=r(l(e,t),`utf8`),s=t.startsWith(`packages/`)||t.startsWith(`samples/`),p=()=>s?[]:[...co(o,i),...No(t,o,f)],m=[];if(i===`scss`||i===`css`||i===`markup`)m=Rt(o,i),(i===`scss`||i===`css`)&&!s&&m.push(...eo(o,i,d)),i===`markup`&&m.push(...p(),...s?[]:Za(o),...s?[]:So(o,`markup`),...Co(t,o));else if(i===`script`){let e=!s&&a.some(e=>t.startsWith(e)),r=dn(o)||e;if(be.includes(n)&&!r)continue;let i=s?[]:va(o,{phone:_a(o)});m=[...fn(o,{phone:r,colourLiterals:e}),...i],e&&a.some(e=>t===`${e}assets/theme/settings.js`)&&(m=m.filter(e=>e.rule!==`raw-colour`)),(n===`.jsx`||n===`.tsx`)&&m.push(...p(),...Co(t,o))}else i===`csharp`&&(s||(m=So(o,`csharp`)));for(let e of m)u.push({id:`${e.rule}:${t}`,line:e.line,text:e.text,hint:e.hint})}let p=I(e,Fo).filter(n=>t(l(e,n)));for(let t of za(e,p)){let n=t.file.startsWith(`packages/`)||t.file.startsWith(`samples/`);o(t.file)&&!Ae(t.file,e)&&!n&&u.push({id:`${t.rule}:${t.file}`,line:t.line,text:t.text,hint:t.hint})}return u.sort((e,t)=>e.id<t.id?-1:e.id>t.id?1:e.line-t.line)}function Ro(e){let t={};for(let n of e)t[n.id]=(t[n.id]||0)+1;return t}var H=process.argv.slice(2),zo=new Set([`--baseline-accept`,`--reason`,`--baseline-adopt`]),Bo=new Set(H.flatMap((e,t)=>zo.has(e)?[t+1]:[])),U=new Set(H.filter((e,t)=>e.startsWith(`--`)&&!Bo.has(t))),W=H.filter((e,t)=>!e.startsWith(`--`)&&!Bo.has(t)),Vo=U.has(`--sync-hook`),Ho=e=>H.includes(e)?H[H.indexOf(e)+1]:void 0,Uo=Ho(`--baseline-accept`),Wo=Ho(`--reason`),Go=Ho(`--baseline-adopt`)?.split(`,`).map(e=>e.trim()).filter(Boolean),Ko=e=>typeof e==`string`&&e.trim()!==``,G=e=>process.stdout.write(`${e}\n`),K=e=>process.stderr.write(`${e}\n`);U.has(`--json`)&&(console.log=(...e)=>console.error(...e));var qo=new Set([`--json`,`--baseline-init`,`--baseline-shrink`,`--baseline-accept`,`--reason`,`--sync-hook`,`--baseline-adopt`]),Jo=[...U].filter(e=>!qo.has(e)),Yo=U.has(`--baseline-accept`),Xo=(Yo||U.has(`--reason`))&&!(Ko(Uo)&&Ko(Wo)),Zo=Yo&&(U.has(`--baseline-init`)||U.has(`--baseline-shrink`)||Vo||U.has(`--baseline-adopt`)),Qo=U.has(`--baseline-adopt`)&&(U.has(`--baseline-init`)||U.has(`--baseline-shrink`)||U.has(`--baseline-accept`)||Vo);(Jo.length||U.has(`--baseline-init`)&&U.has(`--baseline-shrink`)||Vo&&(U.size>1||W.length)||Xo||Zo||Qo)&&(K(`repo-checks: unknown or conflicting options ${Jo.join(` `)}`.trim()),K(`usage: webority-repo-checks [--json] [--baseline-init | --baseline-shrink] [--baseline-accept <folder> --reason <text>] [--baseline-adopt <rule,...>] [app folder ...]`),K(` webority-repo-checks --sync-hook`),process.exit(2));var q=Mi(process.cwd());if(q||(K(`repo-checks: not inside a git repository.`),process.exit(2)),Vo){let t=l(q,aa);n(s(t),{recursive:!0}),a(t,Re),e(t,493),G(`repo-checks: wrote ${t}`),process.exit(0)}var $o=sa(q,W.length?W.map(e=>p(process.cwd(),e)):null).sort((e,t)=>e.pkg===t.pkg?0:e.pkg<t.pkg?-1:1),es=$o.filter(e=>e.warning),ts=$o.filter(e=>!e.warning),ns=ts.filter(e=>e.id.startsWith(`lint:`)),rs=ts.filter(e=>!e.id.startsWith(`lint:`)),is=Lo(q,W.length?W.map(e=>p(process.cwd(),e)):null),J={findings:rs.map(e=>y(e.pkg,e.id)),counts:Ro(is)},as=new Map(rs.map(e=>[y(e.pkg,e.id),e]));if(U.has(`--baseline-init`)){W.length&&(K(`repo-checks: --baseline-init reads the whole repository; run it without folder arguments.`),process.exit(2)),t(l(q,`.webority/baselines/repo-checks-baseline.json`))&&(K(`repo-checks: ${g} already exists. It only shrinks: fix a new finding, or run --baseline-shrink after fixing old ones.`),process.exit(2)),x(q,ie(J));let e=Object.keys(J.counts).length;G(`repo-checks: recorded ${rs.length} finding(s) and ${e} counted file(s) (${is.length} code finding(s)) in ${g}.`),process.exit(0)}var Y=(()=>{try{return ee(q)}catch(e){throw e instanceof v&&(K(`repo-checks: ${e.message}`),process.exit(2)),e}})();if(U.has(`--baseline-shrink`)){W.length&&(K(`repo-checks: --baseline-shrink reads the whole repository; run it without folder arguments.`),process.exit(2)),Y===null&&(K(`repo-checks: no ${g}; run webority-repo-checks --baseline-init first.`),process.exit(2));let e=se(Y,J);x(q,ce(Y,J)),G(`repo-checks: dropped ${e.stale.length} fixed finding(s) and lowered ${e.fallen.length} count(s) in ${g}.`),process.exit(0)}if(Yo){W.length&&(K(`repo-checks: --baseline-accept reads the whole repository; run it without folder arguments.`),process.exit(2)),Y===null&&(K(`repo-checks: no ${g}; run webority-repo-checks --baseline-init first.`),process.exit(2));let e=le(Y,J,Uo,Wo),t=new Set(Y.findings),n=e.findings.filter(e=>!t.has(e)).length,r=Object.keys(e.counts).filter(t=>(Y.counts[t]??0)<e.counts[t]).length;x(q,e),G(`repo-checks: accepted ${n} finding(s) and ${r} count(s) under ${Uo} (${Wo}).`),process.exit(0)}if(U.has(`--baseline-adopt`)){W.length&&(K(`repo-checks: --baseline-adopt reads the whole repository; run it without folder arguments.`),process.exit(2)),Y===null&&(K(`repo-checks: no ${g}; run webority-repo-checks --baseline-init first.`),process.exit(2)),Go?.length||(K(`repo-checks: --baseline-adopt needs a comma-separated list of rule ids.`),process.exit(2));let e;try{e=ae(Y,J,Go)}catch(e){throw e instanceof v&&(K(`repo-checks: ${e.message}`),process.exit(2)),e}x(q,e);let t=new Set(Y.findings);for(let n of Go){let r=e.findings.filter(e=>!t.has(e)&&b(e)[1].split(`:`)[0]===n).length,i=Object.keys(e.counts).filter(e=>!(e in Y.counts)&&e.split(`:`)[0]===n).length;G(`repo-checks: adopted ${r} finding(s) and ${i} count(s) for ${n} in ${g}.`)}process.exit(0)}var os=new Set(W.map(e=>f(q,p(process.cwd(),e)).split(`\\`).join(`/`)||`.`)),ss=W.length?{pkgs:os,dirs:[...os]}:null,X=se(oe(Y??{version:2,findings:[],counts:{}},ss),J),cs={"raw-measure":je,"palette-read":Pe,"raw-colour":Me,"root-font-size":Ne,"missing-canvas-key":Fe,"repeated-canvas-key":Ie},ls=e=>cs[e.slice(0,e.indexOf(`:`))],Z=[...X.fresh.map(e=>as.get(e)),...ns],us=X.known.map(e=>as.get(e)),ds=e=>[`${e.current} found, ${e.baseline} recorded.`,ls(e.id)].filter(Boolean).join(` `),fs=e=>mi(e.id.split(`:`)[0]),Q=X.over.filter(fs).map(e=>({pkg:`.`,id:e.id,message:ds(e),lines:is.filter(t=>t.id===e.id).map(({line:e,text:t,hint:n})=>({line:e,text:t,hint:n}))})),ps=X.over.filter(e=>!fs(e)).map(e=>({pkg:`.`,id:e.id,message:ds(e)})),ms=X.within.map(e=>({pkg:`.`,id:e.id,message:`${e.current} found, ${e.baseline} recorded.`})),hs=[...X.stale.map(b),...X.fallen.map(e=>[`.`,e.id])],$=[...es,...ps];if(U.has(`--json`)||(()=>{if($.length!==0){K(`repo-checks: ${$.length} warning(s), not enforced yet. Name a rule in REPO_CHECKS_ENFORCE (comma list, or all) to fail on it:`);for(let e of $)K(` - ${e.pkg} ${e.id}: ${e.message}`)}})(),U.has(`--json`)){let e={root:q,new:[...Z,...Q],known:[...us,...ms],stale:hs,warnings:$.map(e=>({pkg:e.pkg,id:e.id,message:e.message}))};G(JSON.stringify(e,null,2)),process.exitCode=Z.length||Q.length?1:0}else if(Z.length||Q.length){if(Z.length){K(`repo-checks: ${Z.length} new finding(s)`);let e=null;for(let t of Z)t.pkg!==e&&(e=t.pkg,K(` ${e}`)),K(` - ${t.id}: ${t.message}`)}if(Q.length){K(`repo-checks: ${Q.length} file(s) above their recorded count`);for(let e of Q){K(` ${e.id}: ${e.message}`);for(let t of e.lines)K(` ${t.line}: ${t.text}`),t.hint!==null&&K(` ${t.hint}`)}}process.exitCode=1}else{if(G(`repo-checks: no new findings.`),us.length||ms.length){let e=X.within.reduce((e,t)=>e+t.current,0);G(`repo-checks: ${us.length} known finding(s) and ${e} counted code finding(s) in ${ms.length} file(s) recorded in ${g}.`)}if(X.stale.length){G(`repo-checks: ${X.stale.length} baseline entr${X.stale.length===1?`y is`:`ies are`} fixed; drop them with webority-repo-checks --baseline-shrink:`);for(let e of X.stale.map(b))G(` ${e[0]} ${e[1]}`)}if(X.fallen.length){G(`repo-checks: ${X.fallen.length} count(s) fell; record them with webority-repo-checks --baseline-shrink:`);for(let e of X.fallen)G(` ${e.id} ${e.baseline} -> ${e.current}`)}}export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/repo-checks",
3
- "version": "0.114.0",
3
+ "version": "0.115.0",
4
4
  "description": "Repository checks for Webority React web portals, React Native apps and Razor sites: banned and required dependencies, pnpm only, exact pins, the shared Biome preset, and token use in style, markup and component code. Run before a push; existing findings and per-file counts sit in a baseline that only shrinks.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "vite": "^8.0.12",
26
- "@webority/theme": "0.114.0"
26
+ "@webority/theme": "0.115.0"
27
27
  },
28
28
  "scripts": {
29
29
  "prebuild": "node scripts/gen-library-classes.mjs",