@aurodesignsystem-dev/auro-cli 0.0.0-pr341.0 → 0.0.0-pr344.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.
@@ -1,9 +1,9 @@
1
- import{cemSorterPlugin as h}from"@wc-toolkit/cem-sorter";import{jsxTypesPlugin as E}from"@wc-toolkit/jsx-types";import P from"node:fs/promises";function m(){return{name:"add-dts-exports-plugin",packageLinkPhase({customElementsManifest:n}){let r=n.modules.filter(t=>t.path.endsWith("src/index.js"));if(r.length===0){console.warn("No module found with path ending in 'src/index.js'. Skipping export statement addition.");return}let o=[],e=r[0];if(!e.exports||e.exports.length===0){console.warn("No exports found for 'src/index.js'. Skipping export statement addition.");return}e.exports.forEach(t=>{o.push(t.name)});let s=`declare global {
1
+ import{deprecatedProseToFieldPlugin as K}from"@aurodesignsystem/auro-library/scripts/build/deprecatedProseToFieldPlugin.mjs";import{cemSorterPlugin as z}from"@wc-toolkit/cem-sorter";import{jsxTypesPlugin as J}from"@wc-toolkit/jsx-types";function P({name:t,tagNames:r,toFields:e,packageLinkPhase:n}){let i=new WeakMap,a=o=>{console.warn(`[${t}] ${o}`)},u=new RegExp(`\\{@(${r.join("|")})(?=[\\s:}])[:\\s]*([^}]*)\\}`,"gu"),p=o=>(o??"").trim().replace(/^:\s*/u,""),y=(o,c)=>{let s=c.parent;for(;s;){if(o.isClassDeclaration(s)||o.isClassExpression(s))return s.name?.text;s=s.parent}},l=(o,c)=>{let s=o.isReturnStatement(c.parent)?c.parent.parent?.parent:c.parent;return!!s&&(o.isGetAccessorDeclaration(s)||o.isPropertyDeclaration(s))&&s.name?.getText()==="properties"&&!!s.modifiers?.some(m=>m.kind===o.SyntaxKind.StaticKeyword)},$=(o,c)=>{if(o.isPropertyAssignment(c)&&l(o,c.parent))return c.name.getText().replace(/^['"]|['"]$/gu,"");if(o.isPropertyDeclaration(c)||o.isGetAccessorDeclaration(c)||o.isSetAccessorDeclaration(c))return c.name.getText();if(o.isExpressionStatement(c)&&o.isBinaryExpression(c.expression)){let{left:s}=c.expression;if(o.isPropertyAccessExpression(s)&&s.expression.kind===o.SyntaxKind.ThisKeyword)return s.name.getText()}},g={name:t,analyzePhase({ts:o,node:c,moduleDoc:s}){let m=o.getJSDocTags(c).filter(f=>r.includes(f.tagName.text)),d=m.length?$(o,c):void 0,x=d?y(o,c):void 0;if(x){let f=e(m.map(h=>({name:h.tagName.text,text:p(o.getTextOfJSDocComment(h.comment))})),{warn:h=>a(`${s.path}: ${x}.${d} ${h}`)});if(Object.keys(f).length){let h=i.get(s)??[];h.push({className:x,propName:d,fields:f}),i.set(s,h)}}},moduleLinkPhase({moduleDoc:o}){(i.get(o)??[]).forEach(({className:c,propName:s,fields:m})=>{let d=(o.declarations??[]).find(f=>f.name===c),x=d?.members?.find(f=>f.kind==="field"&&f.name===s);x?(Object.assign(x,m),(d.attributes??[]).filter(f=>f.fieldName===s).forEach(f=>{Object.assign(f,m)})):a(`${o.path}: no field "${s}" found on ${c}; @${r.join("/@")} not applied.`)}),(o.declarations??[]).forEach(c=>{(c.slots??[]).filter(s=>typeof s.description=="string").forEach(s=>{let m=[...s.description.matchAll(u)].map(d=>({name:d[1],text:p(d[2])}));m.length&&(s.description=s.description.replace(u,"").replace(/\s{2,}/gu," ").trim(),Object.assign(s,e(m,{warn:d=>a(`${o.path}: ${c.name} slot "${s.name}" ${d}`)})))})})}};return n&&(g.packageLinkPhase=({customElementsManifest:o})=>n({customElementsManifest:o,warn:a})),g}function A(){return P({name:"category",tagNames:["category"],toFields(t,{warn:r}){t.length>1&&r(`has ${t.length} @category tags; only one is allowed. Using "${t[0].text}".`);let[{text:e}]=t;return e===""?(r("has an empty @category; skipping."),{}):{category:e}}})}function C(){return P({name:"internal",tagNames:["internal"],toFields:()=>({internal:!0}),packageLinkPhase({customElementsManifest:t}){for(let r of t.modules??[])for(let e of r.declarations??[])Array.isArray(e.members)&&(e.members=e.members.filter(n=>!n.internal)),Array.isArray(e.attributes)&&(e.attributes=e.attributes.filter(n=>!n.internal))}})}function j(){return P({name:"numeric-bounds",tagNames:["minimum","maximum"],toFields(t,{warn:r}){let e={};return t.forEach(n=>{let i=Number(n.text);n.text===""||!Number.isFinite(i)?r(`has a non-numeric @${n.name} "${n.text}"; skipping.`):e[n.name]=i}),e}})}function T(){return{name:"private-attributes",packageLinkPhase({customElementsManifest:t}){for(let r of t.modules??[])for(let e of r.declarations??[])if(Array.isArray(e.attributes)){let n=new Set((e.members??[]).filter(i=>i.kind==="field"&&i.privacy==="private").map(i=>i.name));e.attributes=e.attributes.filter(i=>!n.has(i.fieldName))}}}}function S(){return{name:"readonly-attributes",packageLinkPhase({customElementsManifest:t}){for(let r of t.modules??[])for(let e of r.declarations??[])if(Array.isArray(e.attributes)){let n=new Set((e.members??[]).filter(i=>i.kind==="field"&&i.readonly).map(i=>i.name));e.attributes=e.attributes.filter(i=>!i.readonly&&!n.has(i.fieldName))}}}}var F="[A-Za-z_$][\\w$]*",L=new RegExp(`^(!?)(${F})$`,"u"),O=new RegExp(`^(${F})\\s*(===|!==)\\s*(.+)$`,"u"),k=Symbol("invalid"),q=t=>{let r=t.match(/^(?<quote>['"])(?<inner>.*)\k<quote>$/u),e={true:!0,false:!1,null:null,undefined:void 0};return r?r.groups.inner:Object.hasOwn(e,t)?e[t]:/^-?\d+(?:\.\d+)?$/u.test(t)?Number(t):/^[\w$.-]+$/u.test(t)?t:k},b=t=>typeof t=="string"?t.includes("'")?`"${t}"`:`'${t}'`:String(t),M=t=>{let r=t.match(L);if(r)return{property:r[2],negated:r[1]==="!"};let e=t.match(O),n=e?q(e[3].trim()):k;if(n!==k)return{property:e[1],operator:e[2],value:n}},W=t=>t.operator?`${t.property} ${t.operator} ${b(t.value)}`:`${t.negated?"!":""}${t.property}`,R=(t,r)=>{if(!t.operator)return r==="boolean"?void 0:`that field is typed "${r??"unknown"}", not "boolean"`;let{value:e}=t;if(!r||e===null||e===void 0)return;let n=r.split("|").map(u=>u.trim()),i=typeof e;if(n.includes(i)||n.includes(b(e))||n.includes(`"${e}"`))return;let a=n.filter(u=>/^(?<quote>['"]).*\k<quote>$/u.test(u));return i==="string"&&a.length?`${b(e)} is not one of ${a.join(" | ")}`:`that field is typed "${r}", which does not accept ${i} ${b(e)}`};function E({name:t,tagName:r,keywords:e=[]}){let n=[...e.map(i=>`"${i}"`),'"prop", "!prop", "prop === value", or "prop !== value"'].join(" or ");return P({name:t,tagNames:[r],toFields(i,{warn:a}){i.length>1&&a(`has ${i.length} @${r} tags; only one is allowed. Using "${i[0].text}".`);let[{text:u}]=i;if(e.includes(u))return{[r]:u};let p=M(u);return p?{[r]:W(p)}:(a(`has an invalid @${r} "${u}"; expected ${n}. Skipping.`),{})},packageLinkPhase({customElementsManifest:i,warn:a}){(i.modules??[]).forEach(u=>{(u.declarations??[]).forEach(p=>{[...(p.members??[]).map(l=>({entry:l,label:`${p.name}.${l.name}`})),...(p.slots??[]).map(l=>({entry:l,label:`${p.name} slot "${l.name}"`}))].filter(({entry:l})=>l[r]&&!e.includes(l[r])&&!l.inheritedFrom).forEach(({entry:l,label:$})=>{let g=M(l[r]),o=(p.members??[]).find(m=>m.kind==="field"&&m.name===g.property),c=`${u.path}: ${$} is @${r} "${l[r]}", but`,s=o?R(g,o.type?.text):`${p.name} has no field named "${g.property}"`;s&&a(`${c} ${s}.`)})})})}})}function N(){return E({name:"relevant-when",tagName:"relevantWhen"})}function D(){return E({name:"required-when",tagName:"requiredWhen",keywords:["always"]})}import B from"node:fs/promises";function v(){return{name:"add-dts-exports-plugin",packageLinkPhase({customElementsManifest:t}){let r=t.modules.filter(a=>a.path.endsWith("src/index.js"));if(r.length===0){console.warn("No module found with path ending in 'src/index.js'. Skipping export statement addition.");return}let e=[],n=r[0];if(!n.exports||n.exports.length===0){console.warn("No exports found for 'src/index.js'. Skipping export statement addition.");return}n.exports.forEach(a=>{e.push(a.name)});let i=`declare global {
2
2
  namespace svelteHTML {
3
3
  interface IntrinsicElements extends CustomElements {}
4
4
  }
5
5
  }
6
6
 
7
7
 
8
- export { ${o.join(", ")} } from "./index.js";
9
- `;P.appendFile("dist/index.d.ts",s).then(()=>{console.info("Appended export statements to index.d.ts")}).catch(t=>{console.error(`Error appending to index.d.ts: ${t.message}`)})}}}import{toCamelCase as x}from"@wc-toolkit/cem-utilities";function c(){return{name:"force-private-plugin",packageLinkPhase({customElementsManifest:n,context:r}){!r.forcePrivateProperties||r.forcePrivateProperties.size===0||n.modules?.forEach(o=>{o.declarations?.forEach(e=>{let s=r.forcePrivateProperties.get(e.name);if(s&&s.length>0&&("members"in e&&e.members&&e.members.forEach(t=>{s.includes(t.name)&&(console.log(`\rFound member '${t.name}' in ${e.name}, marking as private`),t.privacy="private")}),"attributes"in e&&e.attributes&&"customElement"in e&&e.customElement)){let t=e;t.attributes&&(t.attributes=t.attributes.filter(i=>{let a=x(i.name);return s.includes(a)||s.includes(i.name)?(console.log(`\rFound attribute '${i.name}' in ${e.name}, removing from manifest`),!1):!0}))}})})},analyzePhase({ts:n,node:r,context:o}){if(r.kind!==n.SyntaxKind.ClassDeclaration)return;let e=r.name?.getText();if(!e)return;let s=(t,i)=>{t?.forEach(a=>{a?.tags?.forEach(p=>{if(p.tagName.getText()==="forcePrivate"){let{comment:u}=p,f=[];if(typeof u=="string"){let l=u.match(/['"]([^'"]+)['"]/g);l&&(f=l.map(g=>g.replace(/['"]/g,"")))}o.forcePrivateProperties||(o.forcePrivateProperties=new Map);let d=o.forcePrivateProperties.get(e)||[];o.forcePrivateProperties.set(e,[...d,...f])}})})};s(r?.jsDoc,"class"),r.members?.forEach(t=>{s(t?.jsDoc,"member")})}}}var N={globs:["src/**/*.*js","scripts/wca/**/*.*js"],litelement:!0,packagejson:!0,dependencies:!0,quiet:!0,plugins:[h({deprecatedLast:!0}),E({fileName:"index.d.ts",outdir:"dist",excludeCssCustomProperties:!0}),m(),c()]};export{N as default};
8
+ export { ${e.join(", ")} } from "./index.js";
9
+ `;B.appendFile("dist/index.d.ts",i).then(()=>{console.info("Appended export statements to index.d.ts")}).catch(a=>{console.error(`Error appending to index.d.ts: ${a.message}`)})}}}import{toCamelCase as I}from"@wc-toolkit/cem-utilities";function w(){return{name:"force-private-plugin",packageLinkPhase({customElementsManifest:t,context:r}){!r.forcePrivateProperties||r.forcePrivateProperties.size===0||t.modules?.forEach(e=>{e.declarations?.forEach(n=>{let i=r.forcePrivateProperties.get(n.name);if(i&&i.length>0&&("members"in n&&n.members&&n.members.forEach(a=>{i.includes(a.name)&&(console.log(`\rFound member '${a.name}' in ${n.name}, marking as private`),a.privacy="private")}),"attributes"in n&&n.attributes&&"customElement"in n&&n.customElement)){let a=n;a.attributes&&(a.attributes=a.attributes.filter(u=>{let p=I(u.name);return i.includes(p)||i.includes(u.name)?(console.log(`\rFound attribute '${u.name}' in ${n.name}, removing from manifest`),!1):!0}))}})})},analyzePhase({ts:t,node:r,context:e}){if(r.kind!==t.SyntaxKind.ClassDeclaration)return;let n=r.name?.getText();if(!n)return;let i=(a,u)=>{a?.forEach(p=>{p?.tags?.forEach(y=>{if(y.tagName.getText()==="forcePrivate"){let{comment:l}=y,$=[];if(typeof l=="string"){let o=l.match(/['"]([^'"]+)['"]/g);o&&($=o.map(c=>c.replace(/['"]/g,"")))}e.forcePrivateProperties||(e.forcePrivateProperties=new Map);let g=e.forcePrivateProperties.get(n)||[];e.forcePrivateProperties.set(n,[...g,...$])}})})};i(r?.jsDoc,"class"),r.members?.forEach(a=>{i(a?.jsDoc,"member")})}}}var Ee={globs:["src/**/*.*js","scripts/wca/**/*.*js"],litelement:!0,packagejson:!0,dependencies:!0,quiet:!0,plugins:[K(),j(),D(),N(),A(),S(),T(),C(),z({deprecatedLast:!0}),J({fileName:"index.d.ts",outdir:"dist",excludeCssCustomProperties:!0}),v(),w()]};export{Ee as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurodesignsystem-dev/auro-cli",
3
- "version": "0.0.0-pr341.0",
3
+ "version": "0.0.0-pr344.0",
4
4
  "description": "A cli tool to support the Auro Design System",
5
5
  "repository": {
6
6
  "type": "git",