@aurodesignsystem-dev/auro-cli 0.0.0-pr359.0 → 0.0.0-pr361.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.
- package/dist/auro-cli.js +116 -103
- package/dist/auro-cli.js.map +4 -4
- package/package.json +1 -1
package/dist/auro-cli.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{program as
|
|
2
|
+
import{program as Dr}from"commander";import Zi from"figlet";import{mind as Qi}from"gradient-string";var Pr=()=>Qi(Zi.textSync("Auro CLI"));import Mr from"node:fs";import Nr from"node:path";import{fileURLToPath as ea}from"node:url";function qe(e){process.env.DEBUG&&console.log(`[DEBUG] ${e}`)}function an(){try{let e=ea(import.meta.url),t=Nr.dirname(e);qe(`Current module path: ${t}`);let n=Nr.resolve(t,"..","package.json");return qe(`Checking package.json at: ${n}`),Mr.existsSync(n)?(qe(`Found package.json at: ${n}`),JSON.parse(Mr.readFileSync(n,"utf8")).version):(qe("Could not find package.json in the standard installed module location, using default version"),"0.0.0")}catch(e){return console.error("Error retrieving package version:",e),"0.0.0"}}import{program as oc}from"commander";import lo from"ora";function Ye(e){return e.option("-m, --module-paths [paths...]","Path(s) to node_modules folder").option("-w, --watch","Watches for changes").option("--skip-docs","Skip documentation generation",!1).option("-r, --readme-template <url>","URL to the README template file").option("--wca-input [files...]","Source file(s) to analyze for API documentation").option("--wca-output [files...]","Output file(s) for API documentation")}function Xe(e){return e.option("-s, --serve","Starts a server").option("-p, --port <number>","Port for the server").option("-o, --open","Open the browser after starting the server")}import ec from"@rollup/plugin-terser";import{watch as tc}from"rollup";import{existsSync as to,readFileSync as Ua,rmSync as Ha,writeFileSync as Ja}from"node:fs";import{basename as Va,dirname as za,join as Ie,resolve as ct}from"node:path";import{pathToFileURL as no}from"node:url";import{glob as Ka}from"glob";import bn from"ora";import{rollup as yn}from"rollup";import*as ro from"sass";import Ne from"ora";import{spawn as ta}from"node:child_process";import na from"ora";var F=(e,t)=>{let n=`${e} ${t?t.join(" "):""}`,r=na(),o=e,s=t||[];if(!t&&typeof e=="string"){let l=e.split(" ");o=l[0],s=l.slice(1)}let i=n.includes("--watch")||n.includes(" -w"),c=ta(o,s,{stdio:i?"inherit":["inherit","pipe","pipe"],shell:!0});if(!i){let l=[];c.stdout?.on("data",u=>{let m=u.toString();l.push(m),process.stdout.write(m)}),c.stderr?.on("data",u=>{let m=u.toString();l.push(m),process.stderr.write(m)})}return new Promise((l,u)=>{c.on("close",m=>{m!==0?i?(r.info(`Watch mode terminated with code ${m}`),l()):(r.fail(`${n} failed (code ${m})`),u(new Error(`Command failed with exit code ${m}`))):(r.succeed(`${n} completed successfully`),l())})})};import Ze from"node:fs";import ra from"node:path";import{markdownTable as Or}from"markdown-table";var Qe=e=>typeof e=="number"&&Number.isFinite(e),oa=[{header:"Category",render:({category:e})=>typeof e=="string"?e:""},{header:"Required",render:({requiredWhen:e})=>typeof e!="string"||!e?"":e==="always"?"Yes":`\`${e}\``},{header:"Relevant when",render:({relevantWhen:e})=>typeof e=="string"&&e?`\`${e}\``:""},{header:"Range",render:({minimum:e,maximum:t})=>Qe(e)&&Qe(t)?`${e}\u2013${t}`:Qe(e)?`\u2265 ${e}`:Qe(t)?`\u2264 ${t}`:""}],Re=class e{static{this.manifest={schemaVersion:"1.0.0",readme:"",modules:[]}}static generate(t={}){let{outDir:n="./docs",outFile:r="api.md",manifestPath:o="./custom-elements.json"}=t,{getElements:s,renderAllElements:i}=e;if(o)try{let m=Ze.readFileSync(o,"utf8");e.manifest=JSON.parse(m)}catch(m){throw console.error(`Error reading manifest file at ${o}:`,m),m}let a=s(),c=n;Ze.existsSync(c)||Ze.mkdirSync(c,{recursive:!0});let l=i(a),u=ra.join(c,r);Ze.writeFileSync(u,l),console.log(`Generated combined API documentation at ${u}`)}static getElements(){let t=e.manifest.modules.filter(e.isWcaModule);return e.manifest.modules.reduce((n,r)=>n.concat(r.declarations?.filter(o=>"customElement"in o&&o.customElement===!0&&"tagName"in o&&(t.length>0?e.isWcaModule(r):!0))??[]),[])}static isWcaModule(t){let{path:n}=t;return n?n.startsWith("scripts/wca/auro-")&&n.endsWith(".js"):!1}static renderAllElements(t){return`${t.sort((n,r)=>(n.tagName||"").localeCompare(r.tagName||"")).map(n=>e.renderElement(n,!0)).join(`
|
|
3
3
|
|
|
4
|
-
`)}`}static renderElement(t,n=!0){let r=[],{renderTable:o,renderPropertiesAttributesTable:
|
|
4
|
+
`)}`}static renderElement(t,n=!0){let r=[],{renderTable:o,renderPropertiesAttributesTable:s,renderParameters:i,getType:a}=e;r.push(n?`# ${t.tagName}`:""),t.description&&r.push(t.description);let c=s(t);c&&r.push(c.trim());let l=o("Methods",["name","parameters","return","description"],(t.members||[]).filter(f=>f.kind==="method"&&("privacy"in f?f.privacy!=="private":!0)&&f.name[0]!=="_").map(f=>({...f,parameters:i("parameters"in f?f.parameters:void 0),return:"return"in f&&f.return?a(f.return):""})));l&&r.push(l.trim());let u=o("Events",["name","description"],t.events);u&&r.push(u.trim());let m=o("Slots",[["name","(default)"],"description"],t.slots,!0);m&&r.push(m.trim());let d=o("CSS shadow parts",["name","description"],t.cssParts,!0);d&&r.push(d.trim());let p=o("CSS custom properties",["name","description"],t.cssProperties,!0);return p&&r.push(p.trim()),r.join(`
|
|
5
5
|
|
|
6
|
-
`)}static renderPropertiesAttributesTable(t){let{getType:n,escapeMarkdown:r,addTagColumns:o}=e,
|
|
6
|
+
`)}static renderPropertiesAttributesTable(t){let{getType:n,escapeMarkdown:r,addTagColumns:o}=e,s=t.members?.filter(d=>d.kind==="field"&&("privacy"in d?d.privacy!=="private":!0)&&d.name[0]!=="_")||[],i=t.attributes||[],a=[],c=new Set;if(s.forEach(d=>{if(d.description?.trim()){let p=n(d)||"",h=("return"in d&&d.return?n(d.return):"")||p,g=i.find(y=>y.fieldName===d.name||"attribute"in d&&y.name===d.attribute);a.push({name:d.name,properties:d.name,attributes:("attribute"in d?d.attribute:"")||"",modifiers:"readonly"in d&&d.readonly?"readonly":"",type:h,default:("default"in d?d.default:"")||"",description:d.description||"",tags:{...g,...d}})}c.add(d.name),"attribute"in d&&d.attribute&&c.add(d.attribute)}),i.forEach(d=>{!c.has(d.name)&&d.description?.trim()&&a.push({name:d.name,properties:"",attributes:d.name,modifiers:"",type:n(d)||"",default:d.default||"",description:d.description||"",tags:d})}),a.length===0)return"";let l=["Properties","Attributes","Modifiers","Type","Default","Description"],u=a.map(d=>{let g=(d.default||"").trim().replace(/^'([^']+)'$/,"$1").replace(/^"([^"]+)"$/,"$1"),y=g?g.startsWith("`")&&g.endsWith("`")?g:`\`${g}\``:"";return[r(d.properties),r(d.attributes),r(d.modifiers),r(d.type),r(y),r(d.description)]});return`### Properties and attributes
|
|
7
7
|
|
|
8
|
-
${
|
|
9
|
-
`}static renderParameters(t){let{escapeMarkdown:n,getType:r}=e;return!t||t.length===0?"None":t.map(o=>{let
|
|
8
|
+
${Or(o(l,u,a.map(d=>d.tags)))}
|
|
9
|
+
`}static renderParameters(t){let{escapeMarkdown:n,getType:r}=e;return!t||t.length===0?"None":t.map(o=>{let s=r(o)||"any",i=o.description?` - ${o.description}`:"";return`\`${o.name}\` (${n(s)})${n(i)}`}).join("<br>")}static renderTable(t,n,r,o=!1){let{escapeMarkdown:s,get:i,capitalize:a,addTagColumns:c}=e;if(r===void 0||r.length===0)return"";let l=r.filter(p=>{let{description:f}=p;return typeof f=="string"&&f.trim()});if(l.length===0)return"";let u=n.map(p=>a((Array.isArray(p)?p[0]:p).split(".")[0])),m=l.map(p=>n.map(f=>{let h=i(p,f);return s(String(h||""))})),d=Or(o?c(u,m,l):[u,...m]);return`### ${t}
|
|
10
10
|
|
|
11
|
-
${
|
|
12
|
-
`}static addTagColumns(t,n,r){let o=
|
|
13
|
-
${
|
|
14
|
-
`)}`)}var
|
|
11
|
+
${d}
|
|
12
|
+
`}static addTagColumns(t,n,r){let o=oa.map(({header:m,render:d})=>({header:m,cells:r.map(p=>e.escapeMarkdown(d(p)))})).filter(({cells:m})=>m.some(Boolean)),s=t.length-1,i=(m,d)=>[...m.slice(0,s),...d,...m.slice(s)],a=r.map(({category:m})=>typeof m=="string"&&m?m:void 0),c=[...new Set(a.filter(Boolean))],l=m=>{let d=a[m];return d===void 0?c.length:c.indexOf(d)},u=n.map((m,d)=>({row:i(m,o.map(({cells:p})=>p[d]??"")),rank:l(d)})).sort((m,d)=>m.rank-d.rank).map(({row:m})=>m);return[i(t,o.map(({header:m})=>m)),...u]}static escapeMarkdown(t){return t.replace(/\\/g,"\\\\").replace(/\n/g,"<br>").replace(/\|/g,"\\|")}static getType(t){if(!t||!t.type)return"";let{type:n}=t,r=s=>s.replace(/\s*\|\s*/g," | ").replace(/'([^']+)'/g,"`$1`");if(typeof n=="string")return r(n);if(n.text)return r(n.text);if(Array.isArray(n))return n.map(s=>typeof s=="string"?s:s.text?s.text:s.name?s.name:String(s)).join(" \\| ");if(n.name)return r(n.name);if(n.references&&Array.isArray(n.references))return n.references.map(s=>s.name||String(s)).join(" \\| ");let o=String(n);return r(o)}static get(t,n){let r="",o=n;Array.isArray(n)&&([o,r]=n);let s=o.split("."),i=t;for(;i&&s.length;)i=i[s.shift()];return i==null||i===""?r:String(i)}static capitalize(t){return t.replace(/([A-Z])/g," $1").replace(/^./,n=>n.toUpperCase()).trim()}};import sa from"node:fs";import ia from"node:os";import et from"node:path";import cn from"node:process";function aa(){let e=ia.homedir()||cn.env.HOME||cn.env.USERPROFILE;if(!e)throw new Error("Unable to determine user home directory");return et.join(e,".auro")}function ln(...e){return et.join(aa(),...e)}function un(...e){let t=sa.realpathSync(cn.argv[1]),n=et.dirname(t);return et.resolve(n,...e)}var Ir=e=>un("configs",e);import{copyFileSync as ca,existsSync as jr,mkdirSync as la}from"node:fs";import{join as ua,resolve as mn}from"node:path";function tt(){let e=process.cwd(),t=mn(e,"README.md"),n=ua(mn(e,"demo"),"readme.md");if(!jr(t))return;let r=mn(e,"demo");jr(r)||la(r,{recursive:!0}),ca(t,n)}import ma from"ora";var Fr=[];function De(e){Fr.push(e)}var _r=!1;function nt(){_r||(_r=!0,process.on("SIGINT",()=>{let e=ma("Wrapping up...").start();for(let t of Fr)t.close();e.succeed("All done! See you next time. \u2728"),process.exit(0)}))}import{Logger as da}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{generateReadmeUrl as pa,processContentForFile as fa,templateFiller as pn}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";import L from"node:fs";import{readFileSync as fn,existsSync as dn}from"node:fs";import H from"node:path";var ga="/docs/pages",Gr={overwriteLocalCopies:!0,remoteReadmeVersion:"master",remoteReadmeVariant:"_updated_paths",monorepoName:void 0,extraVars:{}};function I(e){return`${process.cwd()}/${e}`}function ha(e=process.cwd()){let t=e;for(;;){let n=H.join(t,"package.json");if(dn(n))try{if(JSON.parse(fn(n,"utf8")).workspaces)return t}catch{}let r=H.dirname(t);if(r===t)break;t=r}return e}async function ya(e,t=!1){let n=[];if(!t){let o=e.localReadmePath?e.localReadmePath:{remoteUrl:e.remoteReadmeUrl||pa(e.remoteReadmeVersion,e.remoteReadmeVariant),fileName:I("/docTemplates/README.md"),overwrite:e.overwriteLocalCopies};n.push({identifier:"README.md",input:o,output:I("/README.md")})}Br("/docs/partials/index.md")&&n.push({identifier:"index.md",input:I("/docs/partials/index.md"),output:I("/demo/index.md"),mdMagicConfig:{output:{directory:I("/demo")}}}),Br("/docs/partials/api.md")&&n.push({identifier:"api.md",input:I("/docs/partials/api.md"),output:I("/demo/api.md"),preProcessors:[pn.formatApiTable]});let r=I(ga);if(L.existsSync(r)){let s=(await L.promises.readdir(r)).map(i=>({identifier:i,input:H.join(r,i),output:I(`/demo/${i}`)}));n.push(...s)}return n}async function ba(e=Gr,t=!1){await pn.extractNames();let n=await ya(e,t),r=e.monorepoName;if(!r)try{let i=H.join(ha(),"package.json");r=JSON.parse(fn(i,"utf8")).name?.replace(/^@[^/]+\//,"")}catch{}let o={...r?{monorepoName:r}:{},...e.extraVars||{}},s=[];for(let i of n)try{if(await fa({...i,extraVars:o,preProcessors:[...i.preProcessors??[],a=>Ur(a,o)]}),i.output.endsWith(".md")){await Sa(i.output,o);let a=Ea(await L.promises.readFile(i.output,"utf8"));if(a.length>0)throw new Error(`Unreplaced template placeholders: ${a.join(", ")}`)}}catch(a){da.error(`Error processing ${i.identifier}: ${a.message}`),s.push(`${i.identifier}: ${a.message}`)}if(s.length>0)throw new Error(`Failed to generate ${s.length} docs file(s):
|
|
13
|
+
${s.map(i=>` - ${i}`).join(`
|
|
14
|
+
`)}`)}var wa=["name","Name","namespace","Namespace","Version","dtVersion","wcssVersion","monorepoName"],ka=["capitalize","withAuroNamespace","packageName"],va=/^~?(?:[#/^!>&{*]|\s*else\b)/,Wr=/<pre\b[\s\S]*?<\/pre>|<code\b[\s\S]*?<\/code>|^[ \t]*(`{3,}|~{3,})[^\n]*\n[\s\S]*?^[ \t]*\1[ \t]*$|`[^`\n]*`/gim;function $a(e,t,n){if(va.test(e))return!n;let[r,...o]=e.replace(/^~?\s*|\s*~?$/g,"").split(/\s+/);return ka.includes(r)?o.every(s=>t.has(s)||/^(["']).*\1$/.test(s)):o.length===0&&t.has(r)}function Ur(e,t={}){let n=new Set([...wa,...Object.keys(t)]),r=(i,a)=>i.replace(/(?<![\\{])\{\{([\s\S]*?)\}\}/g,(c,l)=>$a(l,n,a)?c:`\\${c}`),o="",s=0;for(let i of e.matchAll(Wr))o+=r(e.slice(s,i.index),!1)+r(i[0],!0),s=i.index+i[0].length;return o+r(e.slice(s),!1)}function Lr(e,t){return pn.replaceTemplateValues(Ur(e,t),t)}function Ea(e){return e.replace(Wr,"").match(/\{\{[\s\S]*?\}\}/g)??[]}async function Sa(e,t={}){let n=H.dirname(e),r=await L.promises.readFile(e,"utf8"),o=/^[ \t]*<!-- AURO-GENERATED-CONTENT:START \((FILE|CODE):src=([^)]+)\) -->\n[ \t]*<!-- AURO-GENERATED-CONTENT:END -->/gm,s,i=!1,a=I("demo"),c=[];for(;(s=o.exec(r))!==null;){let[p,f,h]=s,g=H.resolve(n,h),y=H.resolve(a,h),k=dn(g)?g:dn(y)?y:null;if(k){let $=fn(k,"utf8"),C;if(f==="FILE")C=`<!-- AURO-GENERATED-CONTENT:START (FILE:src=${h}) -->
|
|
15
15
|
<!-- The below content is automatically added from ${h} -->
|
|
16
|
-
${
|
|
17
|
-
<!-- AURO-GENERATED-CONTENT:END -->`;else{let
|
|
18
|
-
</code></pre>`,t);
|
|
16
|
+
${Lr($,t).trimEnd()}
|
|
17
|
+
<!-- AURO-GENERATED-CONTENT:END -->`;else{let v=H.extname(h).slice(1)||"html",b=$.trimEnd().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),w=Lr(`<pre class="language-${v}"><code class="language-${v}">${b}
|
|
18
|
+
</code></pre>`,t);C=`<!-- AURO-GENERATED-CONTENT:START (CODE:src=${h}) -->
|
|
19
19
|
<!-- The below code snippet is automatically added from ${h} -->
|
|
20
20
|
${w}
|
|
21
|
-
<!-- AURO-GENERATED-CONTENT:END -->`}r=r.replace(
|
|
22
|
-
</code></pre>`});u!==r&&await
|
|
23
|
-
`}`).join("");return f+
|
|
24
|
-
`),
|
|
25
|
-
`))}async function
|
|
26
|
-
`).start();try{let n={port:Number(e.port)||void 0,open:e.open?"/":void 0,watch:e.watch??Re.watch,nodeResolve:e.nodeResolve??Re.nodeResolve,basePath:e.basePath??Re.basePath,rootDir:e.rootDir??Re.rootDir,middleware:[function(i,s){return!i.url.endsWith("/")&&!i.url.includes(".")&&(i.url+=".html"),s()}],plugins:[pa(),fa(),la({include:e.hmrInclude??Re.hmrInclude})]},r=await ca({config:n,readCliArgs:!1,readFileConfig:!1});return t.stop(),r}catch(n){throw t.fail("Server snag! Couldn't start dev server."),console.error("Error starting development server:",n),new Error(`Development server failed to start: ${n.message}`)}}async function tt(){let e=Pe("Generating Custom Elements Manifest...").start();try{await _(`npx --package=@custom-elements-manifest/analyzer -y -- cem analyze --config '${Sr("custom-elements-manifest.config.mjs")}'`),e.succeed("Custom Elements Manifest generated successfully!")}catch(t){let n=t instanceof Error?t.message:String(t);e.warn("CEM analyzer completed with warnings: "+n)}}async function nt(){let e=Pe("Generating API md file...").start();try{await Ae.generate(),e.succeed("API md file generated successfully!")}catch(t){let n=t instanceof Error?t.message:String(t);throw e.fail("Failed to generate API md file: "+n),t}}async function Or(e={},{build:t=Te,demo:n=jr}={}){let r=Pe("Compiling documentation...").start(),o;try{await t(e),r.succeed("Documentation compiled successfully!")}catch(i){let s=i instanceof Error?i.message:String(i);r.fail("Failed to compile MD documentation: "+s),o=i}if(await n(e),o)throw o}async function jr(e={}){Xe(),await re(),await Lr(e)}async function _r(e={}){await et(e)}async function Fr(e={}){let t=await import("chokidar"),n=["./src/**/*","./docs/**/*","./docTemplates/**/*","./apiExamples/**/*","./demo/**/*.scss"],r=["**/demo/*.min.js","**/demo/*.min.css","**/demo/*.md","**/demo/readme.md","**/docs/api.md","**/custom-elements.json","**/node_modules/**","**/dist/**","**/.git/**"],o=t.watch(n,{ignoreInitial:!0,ignored:r,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100}}),i=Pe("Waiting for changes...");i.spinner="bouncingBar",i.color="green",i.start();let s=null,a=!1,c=!1;async function l(u){if(a){c=!0;return}a=!0,o.unwatch(n);let m=Pe(`Change detected: ${u}`).start();try{let p;try{await Te(e)}catch(d){p=d}if(await jr(e),p)throw p;m.succeed("Docs rebuilt!")}catch(p){let d=p instanceof Error?p.message:String(p);m.fail("Rebuild failed: "+d)}finally{setTimeout(()=>{o.add(n),a=!1,c&&(c=!1,l("queued changes"))},1e3)}}o.on("all",(u,m)=>{a||(s&&clearTimeout(s),s=setTimeout(()=>{l(m)},1e3))}),xe(o),Ze()}async function rt(){await tt(),await nt()}import{basename as ya,join as Br,resolve as ba}from"node:path";import wa from"@rollup/plugin-commonjs";import{nodeResolve as va}from"@rollup/plugin-node-resolve";import{glob as ka}from"glob";import{litScss as $a}from"rollup-plugin-scss-lit";import ga from"node:path";import{glob as ha}from"glob";function Gr(e){return{name:"watch-globs",buildStart(){let t=Array.isArray(e)?e:[e];for(let n of t)try{for(let r of ha.sync(ga.resolve(n)))this.addWatchFile(r)}catch(r){this.error(`Error watching glob pattern "${n}": ${r.message}`)}}}}var sn={moduleDirectories:["node_modules"],modulePaths:["../../node_modules","../node_modules","node_modules"],watchPatterns:["./apiExamples/**/*","./docs/**/*"]};function Wr(e=[],t={}){let{watchPatterns:n=sn.watchPatterns,dedupe:r=["lit","lit-element","lit-html"],dev:o=!1}=t,i=[...sn.modulePaths,...e],s=process.cwd(),a=z.map(c=>ba(s,c));return[va({dedupe:r,preferBuiltins:!1,moduleDirectories:sn.moduleDirectories,modulePaths:a}),wa(),$a({minify:o?!1:{fast:!0},options:{loadPaths:[...i,Br(process.cwd(),"src","styles"),Br(process.cwd(),"src")]}}),Gr(n)]}function an(e={}){let{modulePaths:t=[],watch:n=!1,input:r=["./src/index.js","./src/registered.js"],outputDir:o="./dist",format:i="esm",dev:s=!1}=e;return{name:"Main",config:{input:r,output:{format:i,dir:o,entryFileNames:a=>s||["index","registered"].includes(a.name)?"[name].js":"[name]-[hash].js",chunkFileNames:s?"[name].js":"[name]-[hash].js",assetFileNames:s?"[name][extname]":"[name]-[hash][extname]"},external:Ea(),plugins:Wr(t,{dev:s}),watch:Ur(n)}}}function De(e={}){let{modulePaths:t=[],watch:n=!1,globPattern:r="./demo/*.js",ignorePattern:o=["./demo/*.min.js"],outputDir:i="./demo",dev:s=!1}=e,a=ka.sync(r,{ignore:o}),c=Wr(t,{dev:s}),l=Ur(n);return{name:"Demo",configs:a.map(m=>({input:{[ya(m,".js")]:m},output:{format:"esm",dir:i,entryFileNames:"[name].min.js",chunkFileNames:"[name].min.js",assetFileNames:s?"[name][extname]":"[name]-[hash][extname]",inlineDynamicImports:!0},plugins:c,onwarn(d,f){if(d.code==="UNRESOLVED_IMPORT")throw new Error(`Unresolved import "${d.exporter??d.source}" in ${d.id??m}. Make sure workspace dependencies are built before bundling demos.`);f(d)},watch:l}))}}function Ur(e){if(!e)return!1;let t=typeof e=="object"?e:{};return{clearScreen:t.clearScreen??!0,buildDelay:t.buildDelay??500,chokidar:{ignoreInitial:!0,ignored:t.ignored??["**/dist/**/*.d.ts","**/custom-elements.json","**/demo/*.md","**/demo/**/*.min.js","**/demo/**/*.min.css","**/docs/api.md","**/node_modules/**","**/.git/**"],awaitWriteFinish:t.awaitWriteFinish??{stabilityThreshold:1e3,pollInterval:100}},include:t.include??["./src/**/*.scss","./src/**/*.js","./src/**/*.ts","./demo/**/*.js","./apiExamples/**/*","./docs/**/*.md"],exclude:t.exclude??["./dist/**/*","./node_modules/**/*"]}}function Ea(e=[]){return[...[/node_modules\/lit/,/node_modules\/lit-element/,/node_modules\/lit-html/,/node_modules\/@lit/],...e]}function Vr(){let e=Me("./dist"),t=ln("Cleaning dist folder...").start();try{return Ca(e,{recursive:!0,force:!0}),t.succeed("All clean! Dist folder wiped."),!0}catch(n){return t.fail(`Oops! Couldn't clean dist/ folder: ${n.message}`),console.error(n),!1}}async function st(e,t,n,r){let o=ln(e).start();try{let i=await t();return o.succeed(n),i}catch(i){throw o.fail(r),console.error(`Error: ${i.message}`),i}}async function Kr(e,t){return st(`Bundling ${e.name||"main"} and demo...`,async()=>{let n=await cn(e);await n.write(e.output),await n.close();for(let r of t){let o=await cn(r);await o.write(r.output),await o.close()}},`Bundles ready! ${e.name||"Main"} and demo built.`,"Bundle hiccup! Build failed.")}async function it(e){let{wcaInput:t,wcaOutput:n,skipDocs:r}=e;if(r){let o=ln("Skipping docs generation...").start();setTimeout(()=>{o.succeed("Docs generation skipped.")},0);return}return st("Analyzing components and making docs...",async()=>{await rt(t,n),await Te(e),Xe()},"Docs ready! Looking good.","Doc troubles!")}function Pa(){let e=process.cwd();function t(o){return[o,`${o}.scss`,`${o}.css`,Me(Ta(o),`_${xa(o)}.scss`),Me(o,"_index.scss"),Me(o,"index.scss")].find(s=>Hr(s))}function n(o){for(let s of z){let a=t(ot(e,s,o));if(a)return a}let i=r(o);return i||null}function r(o){let i,s;if(o.startsWith("@")){let a=o.split("/");if(a.length<3)return null;i=`${a[0]}/${a[1]}`,s=`./${a.slice(2).join("/")}`}else{let a=o.indexOf("/");if(a===-1)return null;i=o.slice(0,a),s=`./${o.slice(a+1)}`}for(let a of z){let c=ot(e,a,i,"package.json");if(Hr(c))try{let u=JSON.parse(Sa(c,"utf-8")).exports;if(!u||typeof u!="object")continue;let m=u[s];if(!m)continue;let p=typeof m=="string"?m:m.default||m.import;if(!p)continue;let d=t(ot(e,a,i,p));if(d)return d}catch{continue}}return null}return{findFileUrl(o){if(o.includes("/node_modules/")){let i=o.lastIndexOf("/node_modules/"),s=o.slice(i+14),a=n(s);if(a)return Jr(a)}if(!o.startsWith(".")&&!o.startsWith("/")&&!o.startsWith("file:")){let i=n(o);if(i)return Jr(i)}return null}}}async function re(e="./demo"){return st("Compiling demo SCSS...",async()=>{let t=Ra.sync(Me(e,"**/*.scss")),n=Pa(),r=process.cwd(),o=z.map(i=>ot(r,i));for(let i of t){let s=zr.compile(i,{importers:[n],loadPaths:o,silenceDeprecations:["import"],style:"compressed"}),a=i.replace(/\.scss$/,".min.css");Aa(a,s.css)}return t.length},"Demo SCSS compiled.","SCSS compilation failed.")}async function Lr(e={}){let{configs:t}=De(e);return st("Bundling demo JS...",async()=>{for(let n of t){let r=await cn(n);await r.write(n.output),await r.close()}},"Demo JS bundled.","Demo JS bundling failed.")}import qr from"node:path";import oe from"ora";import"rollup";var Ne=!1,Da={analyze:{active:!1,lastTime:0},docs:{active:!1,lastTime:0},scss:{active:!1,lastTime:0}},Ma=5e3,at=new Set,Na=["/dist/index.d.ts","/custom-elements.json","/demo/api.md","/docs/api.md","/demo/index.min.js"];function Ia(e){if(!e||typeof e!="string")return!1;try{let t=qr.normalize(e);return Na.some(n=>t.endsWith(n))||t.includes("/dist/")||t.endsWith(".min.js")||t.endsWith(".min.css")||t.endsWith(".d.ts")}catch(t){return console.error(`Error checking path (${typeof e}):`,t.message),!1}}async function un(e,t){let n=Da[e];if(n.active||Date.now()-n.lastTime<Ma)return!1;try{return n.active=!0,n.lastTime=Date.now(),await t()}catch(r){return console.error(`Error in ${e} task:`,r),!1}finally{n.active=!1}}async function Yr(e,t,n,{analyze:r=rt,docs:o=it,scss:i=re}={}){let s=!0,a={analyze:!1,docs:!1,scss:!1},c=null,l,u=oe("Activating watch mode...").start(),m={analyze:async()=>{let{wcaInput:f,wcaOutput:h,skipDocs:g}=t;if(g){let v=oe("Skipping component analysis...").start();return setTimeout(()=>{v.succeed("Component analysis skipped.")},0),!0}let y=oe("Detective work: analyzing components...").start();try{return await r(f,h),y.succeed("Component analysis complete! API generated."),!0}catch(v){return y.fail("Analysis hiccup! Something went wrong."),console.error("Component analysis error:",v),!1}},docs:async()=>{if(Ne)return!1;if(t.skipDocs){let h=oe("Skipping docs generation...").start();return setTimeout(()=>{h.succeed("Docs generation skipped.")},0),!0}let f=oe("Refreshing docs...").start();try{await o(t),f.succeed("Documentation refreshed!")}catch(h){f.fail("Docs stumble! Couldn't refresh."),console.error("Documentation rebuild error:",h)}return!0},scss:async()=>{if(Ne)return!1;try{return await i(),!0}catch(f){return console.error("Demo SCSS compilation error:",f),!1}}},p=()=>{s&&a.analyze&&a.docs&&a.scss&&typeof n=="function"&&(s=!1,n())};function d(f=1e3){c&&clearTimeout(c),c=setTimeout(async()=>{setTimeout(async()=>{a.analyze=await un("analyze",m.analyze),setTimeout(async()=>{a.docs=await un("docs",m.docs),setTimeout(async()=>{a.scss=await un("scss",m.scss),p()},500)},1e3)},1e3)},f)}e.on("event",async f=>{switch(f.code){case"START":u.succeed("Watch mode active! Eyes peeled.");break;case"BUNDLE_START":if(at.clear(),f.input)try{let h=Array.isArray(f.input)?f.input:typeof f.input=="string"?[f.input]:typeof f.input=="object"&&f.input!==null?Object.values(f.input):[];for(let g of h)typeof g=="string"&&!Ia(g)&&at.add(qr.normalize(g))}catch(h){console.error("Error processing input paths:",h)}l=oe("Weaving bundles...").start(),Ne=!0;break;case"BUNDLE_END":l&&l.succeed(`Bundle ${Array.isArray(f.input)?`of ${f.input.join("& ")} `:""}done in ${f.duration}ms! \u{1F680}`),Ne=!1,at.size>0&&d();break;case"END":break;case"ERROR":Ne=!1,l?l.fail(`Oops! Bundle hit a snag: ${f.error.message}`):oe().fail(`Watch mode hiccup: ${f.error.message}`),at.clear();break}})}function Xr(e,t){return xe(e),t&&xe(t),Ze(),e}async function _a(e){let t=an(e),n=De(e);e.dev||t.config.plugins.push(Oa()),await it(e),await re(),await Kr(t.config,n.configs)}async function Fa(e){let{dev:t}=e,n=an({...e,watch:!0}),r=De({...e,watch:!0}),o=ja([n.config,...r.configs]);Yr(o,e,t?async()=>et(e):void 0);let i=await import("chokidar"),s=!1,a=!1,c=null,l=i.watch("./demo/**/*.scss",{ignoreInitial:!0,ignored:["**/demo/**/*.min.css"],awaitWriteFinish:{stabilityThreshold:500,pollInterval:100}});return l.on("all",()=>{c&&clearTimeout(c),c=setTimeout(async()=>{if(s){a=!0;return}s=!0;try{await re()}catch(u){console.error("Demo SCSS watch compilation error:",u)}finally{s=!1,a&&(a=!1,l.emit("all"))}},500)}),Xr(o,l),o}async function ct(e={}){try{let{watch:t}=e;return Vr(),t?await Fa(e):await _a(e)}catch(t){throw new Error(`Build failed: ${t.message}`)}}var Ie=La.command("dev").description("Runs development server for auro components");Ie=ze(Ie);Ie=Ve(Ie);var zf=Ie.action(async e=>{try{let t=Zr("Initializing...");e.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=e.docs===!1?"Building component (docs disabled)":"Building component",t.start(),e.watch||t.succeed("Build completed!"),await ct({...e,dev:!0,watch:e.watch})}catch(t){Zr().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{program as Ga}from"commander";import Qr from"ora";var mn=Ga.command("build").description("Builds auro components");mn=ze(mn);var Zf=mn.action(async e=>{try{let t=Qr("Initializing...");e.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=e.docs===!1?"Building component (docs disabled)":"Building component",t.start(),await ct(e),e.watch||t.succeed("Build completed!")}catch(t){Qr().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{exec as Ba}from"node:child_process";import eo from"node:path";import Wa from"node:process";import{fileURLToPath as Ua}from"node:url";import Ha from"node:util";import{program as Ja}from"commander";import za from"inquirer";var cg=Ja.command("migrate").description("Script runner to perform repetitive code change tasks").requiredOption("-i, --id <string>","Select the migration you would like to run by id").option("-m, --multi-gitter","Run the migration on all repositories in the multi-gitter config").action(async e=>{let t=Ua(import.meta.url),n=eo.dirname(t),r=eo.resolve(n,"migrations",e.id);if(e.multiGitter){let o=Ha.promisify(Ba);try{await o("command -v multi-gitter")}catch{console.error("multi-gitter is not installed."),Wa.exit(1)}(await za.prompt([{type:"confirm",name:"dryRun",message:"Run migration in dry-run mode? (no changes will be committed)",default:!0}])).dryRun?_(`multi-gitter run ${r}/script.sh --config "${r}/multi-gitter.yml" --dry-run`):_(`multi-gitter run ${r}/script.sh --config "${r}/multi-gitter.yml"`)}else _(`${r}/script.sh`)});import so from"node:process";import{program as Xa}from"commander";import{readFile as Za,writeFile as Qa}from"node:fs/promises";import{Logger as Oe}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import pn from"node:fs/promises";import dn from"node:path";import{Octokit as Va}from"@octokit/rest";import L from"ora";import{processContentForFile as Ka,templateFiller as qa}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";async function to(e,t){let n=new Va({auth:process.env.GITHUB_TOKEN||""});try{let o=(await n.request("GET /repos/{owner}/{repo}/contents/{path}",{ref:t,owner:"AlaskaAirlines",repo:"auro-templates",path:e,headers:{"X-GitHub-Api-Version":"2022-11-28"}})).data;if(typeof o!="object"||!Array.isArray(o)){let i=`Unexpected response format: ${JSON.stringify(o)}`;throw L().start().fail(i),new Error("Failed to retrieve folder items")}return o}catch(r){let o=L().start();throw r.status===404?o.fail(`Template '${e.split("/")[1]}' not found`):o.fail(`Error accessing template: ${r.message}`),r}}async function no({folderItems:e,templatePathToReplace:t,rootDir:n,ref:r}){let o=[];for(let i of e){if(i.type=="dir"){let l=L(`Processing directory: ${i.path}`).start(),u=await to(i.path,r);l.succeed(`Found ${u.length} additional items in ${i.path}`);let m=await no({folderItems:u,templatePathToReplace:t,rootDir:n,ref:r});o.push(...m);continue}let s=i.path.replace(`${t}/`,""),a=`${n}/.github/${s}`,c={identifier:i.name,input:{remoteUrl:i.download_url||"",fileName:a,overwrite:!0},output:a};o.push(c)}return o}async function Ya(e){try{await pn.rm(e,{recursive:!0,force:!0}),L().start().succeed(`Successfully removed directory: ${e}`)}catch(t){throw L().start().fail(`Error removing directory ${e}: ${t.message}`),t}}async function ro(e,t="",n=!0){try{let r=await pn.stat(e),o=dn.basename(e);if(!r.isDirectory())return`${t}${n?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}
|
|
27
|
-
`;let
|
|
28
|
-
`;try{let a=(await
|
|
29
|
-
`}return
|
|
30
|
-
`}}async function
|
|
21
|
+
<!-- AURO-GENERATED-CONTENT:END -->`}r=r.replace(p,()=>C),o.lastIndex=0,i=!0}else c.includes(h)||c.push(h)}if(c.length>0)throw new Error(`Included file(s) not found: ${c.join(", ")}`);i&&await L.promises.writeFile(e,r),r=await L.promises.readFile(e,"utf8");let l=/^[ \t]*```(\w*)\n([\s\S]*?)^[ \t]*```[ \t]*$/gm,u=r.replace(l,(p,f,h)=>{let g=f||"html",y=h.trimEnd().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return`<pre class="language-${g}"><code class="language-${g}">${y}
|
|
22
|
+
</code></pre>`});u!==r&&await L.promises.writeFile(e,u),r=await L.promises.readFile(e,"utf8"),r=r.replace(/(<pre[^>]*><code[^>]*>)([\s\S]*?)(<\/code><\/pre>)/g,(p,f,h,g)=>{let y=h.split(/\r?\n/),k=y.filter(b=>b.trim().length>0);if(k.length===0)return p;let $=Math.min(...k.map(b=>{let w=b.match(/^[ \t]*/);return w?w[0].length:0})),C=y.map(b=>$>0?b.substring($):b);for(;C.length>0&&C[C.length-1].trim()==="";)C.pop();let v=C.map((b,w)=>w===C.length-1?b:`${b}${b.trim()===""?" ":`
|
|
23
|
+
`}`).join("");return f+v+g});let m=r.split(`
|
|
24
|
+
`),d=!1;for(let p=0;p<m.length;p++)/<pre[\s>]/i.test(m[p])&&(d=!0),d||(m[p]=m[p].replace(/^[ \t]+(?=<)/,"")),/<\/pre>/i.test(m[p])&&(d=!1);await L.promises.writeFile(e,m.join(`
|
|
25
|
+
`))}async function Pe(e={}){let t=e.readmeTemplate,n=t&&!t.startsWith("http");await ba({...Gr,...n?{localReadmePath:H.resolve(process.cwd(),t)}:{remoteReadmeUrl:t||"https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/README.md"}},e.skipReadme)}function Br(e){return L.existsSync(I(e))}import{existsSync as Hr,readFileSync as xa}from"node:fs";import{builtinModules as Aa}from"node:module";import{resolve as rt}from"node:path";import{startDevServer as Ca}from"@web/dev-server";import{hmrPlugin as Ta}from"@web/dev-server-hmr";import*as Jr from"esbuild";import Ra from"ora";var K=["node_modules","../node_modules","../../node_modules","../../../node_modules"];var Da=/^\/__wds-outside-root__\/(\d+)\/(.+)$/;function Pa(){return{name:"node-modules-css",serve(e){if(!e.path.endsWith(".css")||!e.path.startsWith("/@")&&!/^\/[a-z]/i.test(e.path))return;let t=e.path.slice(1),n=process.cwd();for(let r of K){let o=rt(n,r,t);if(Hr(o))return{body:xa(o,"utf-8"),type:"css"}}}}}function Ma(e,t){let n=e.match(Da);return n?rt(t,"../".repeat(Number.parseInt(n[1],10)),n[2]):rt(t,`.${e}`)}function Na(){let e=/\b(require\s*\(|module\.exports\b|exports\.\w)/,t=new Map,n;return{name:"cjs-to-esm",async serverStart({config:r}){n=rt(r.rootDir)},async transform(r){if(!r.path.includes("node_modules")||!r.path.endsWith(".js")&&!r.path.endsWith(".cjs")||typeof r.body!="string"||!e.test(r.body))return;let o=Ma(r.path,n);if(t.has(o))return t.get(o);if(Hr(o))try{let i={body:(await Jr.build({entryPoints:[o],bundle:!0,format:"esm",platform:"browser",write:!1,logLevel:"silent",external:Aa})).outputFiles[0].text};return t.set(o,i),i}catch(s){console.error(`CJS-to-ESM bundling failed for ${r.path}:`,s.message)}}}}var Me={watch:!0,nodeResolve:!0,basePath:"/",rootDir:"./demo",hmrInclude:["src/**/*","demo/**/*","apiExamples/**/*","docs/**/*"]};async function ot(e={}){if(!e.serve)return;let t=Ra(`Firing up dev server...
|
|
26
|
+
`).start();try{let n={port:Number(e.port)||void 0,open:e.open?"/":void 0,watch:e.watch??Me.watch,nodeResolve:e.nodeResolve??Me.nodeResolve,basePath:e.basePath??Me.basePath,rootDir:e.rootDir??Me.rootDir,middleware:[function(s,i){return!s.url.endsWith("/")&&!s.url.includes(".")&&(s.url+=".html"),i()}],plugins:[Pa(),Na(),Ta({include:e.hmrInclude??Me.hmrInclude})]},r=await Ca({config:n,readCliArgs:!1,readFileConfig:!1});return t.stop(),r}catch(n){throw t.fail("Server snag! Couldn't start dev server."),console.error("Error starting development server:",n),new Error(`Development server failed to start: ${n.message}`)}}async function st(){let e=Ne("Generating Custom Elements Manifest...").start();try{await F(`npx --package=@custom-elements-manifest/analyzer -y -- cem analyze --config '${Ir("custom-elements-manifest.config.mjs")}'`),e.succeed("Custom Elements Manifest generated successfully!")}catch(t){let n=t instanceof Error?t.message:String(t);e.warn("CEM analyzer completed with warnings: "+n)}}async function it(){let e=Ne("Generating API md file...").start();try{await Re.generate(),e.succeed("API md file generated successfully!")}catch(t){let n=t instanceof Error?t.message:String(t);throw e.fail("Failed to generate API md file: "+n),t}}async function Vr(e={},{build:t=Pe,demo:n=zr}={}){let r=Ne("Compiling documentation...").start(),o;try{await t(e),r.succeed("Documentation compiled successfully!")}catch(s){let i=s instanceof Error?s.message:String(s);r.fail("Failed to compile MD documentation: "+i),o=s}if(await n(e),o)throw o}async function zr(e={}){tt(),await ie(),await Yr(e)}async function Kr(e={}){await ot(e)}async function qr(e={}){let t=await import("chokidar"),n=["./src/**/*","./docs/**/*","./docTemplates/**/*","./apiExamples/**/*","./demo/**/*.scss"],r=["**/demo/*.min.js","**/demo/*.min.css","**/demo/*.md","**/demo/readme.md","**/docs/api.md","**/custom-elements.json","**/node_modules/**","**/dist/**","**/.git/**"],o=t.watch(n,{ignoreInitial:!0,ignored:r,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100}}),s=Ne("Waiting for changes...");s.spinner="bouncingBar",s.color="green",s.start();let i=null,a=!1,c=!1;async function l(u){if(a){c=!0;return}a=!0,o.unwatch(n);let m=Ne(`Change detected: ${u}`).start();try{let d;try{await Pe(e)}catch(p){d=p}if(await zr(e),d)throw d;m.succeed("Docs rebuilt!")}catch(d){let p=d instanceof Error?d.message:String(d);m.fail("Rebuild failed: "+p)}finally{setTimeout(()=>{o.add(n),a=!1,c&&(c=!1,l("queued changes"))},1e3)}}o.on("all",(u,m)=>{a||(i&&clearTimeout(i),i=setTimeout(()=>{l(m)},1e3))}),De(o),nt()}async function at(){await st(),await it()}import{basename as ja,join as Zr,resolve as _a}from"node:path";import Fa from"@rollup/plugin-commonjs";import{nodeResolve as La}from"@rollup/plugin-node-resolve";import{glob as Ba}from"glob";import{litScss as Ga}from"rollup-plugin-scss-lit";import Oa from"node:path";import{glob as Ia}from"glob";function Xr(e){return{name:"watch-globs",buildStart(){let t=Array.isArray(e)?e:[e];for(let n of t)try{for(let r of Ia.sync(Oa.resolve(n)))this.addWatchFile(r)}catch(r){this.error(`Error watching glob pattern "${n}": ${r.message}`)}}}}var gn={moduleDirectories:["node_modules"],modulePaths:["../../node_modules","../node_modules","node_modules"],watchPatterns:["./apiExamples/**/*","./docs/**/*"]};function Qr(e=[],t={}){let{watchPatterns:n=gn.watchPatterns,dedupe:r=["lit","lit-element","lit-html"],dev:o=!1}=t,s=[...gn.modulePaths,...e],i=process.cwd(),a=K.map(c=>_a(i,c));return[La({dedupe:r,preferBuiltins:!1,moduleDirectories:gn.moduleDirectories,modulePaths:a}),Fa(),Ga({minify:o?!1:{fast:!0},options:{loadPaths:[...s,Zr(process.cwd(),"src","styles"),Zr(process.cwd(),"src")]}}),Xr(n)]}function hn(e={}){let{modulePaths:t=[],watch:n=!1,input:r=["./src/index.js","./src/registered.js"],outputDir:o="./dist",format:s="esm",dev:i=!1}=e;return{name:"Main",config:{input:r,output:{format:s,dir:o,entryFileNames:a=>i||["index","registered"].includes(a.name)?"[name].js":"[name]-[hash].js",chunkFileNames:i?"[name].js":"[name]-[hash].js",assetFileNames:i?"[name][extname]":"[name]-[hash][extname]"},external:Wa(),plugins:Qr(t,{dev:i}),watch:eo(n)}}}function Oe(e={}){let{modulePaths:t=[],watch:n=!1,globPattern:r="./demo/*.js",ignorePattern:o=["./demo/*.min.js"],outputDir:s="./demo",dev:i=!1}=e,a=Ba.sync(r,{ignore:o}),c=Qr(t,{dev:i}),l=eo(n);return{name:"Demo",configs:a.map(m=>({input:{[ja(m,".js")]:m},output:{format:"esm",dir:s,entryFileNames:"[name].min.js",chunkFileNames:"[name].min.js",assetFileNames:i?"[name][extname]":"[name]-[hash][extname]",inlineDynamicImports:!0},plugins:c,onwarn(p,f){if(p.code==="UNRESOLVED_IMPORT")throw new Error(`Unresolved import "${p.exporter??p.source}" in ${p.id??m}. Make sure workspace dependencies are built before bundling demos.`);f(p)},watch:l}))}}function eo(e){if(!e)return!1;let t=typeof e=="object"?e:{};return{clearScreen:t.clearScreen??!0,buildDelay:t.buildDelay??500,chokidar:{ignoreInitial:!0,ignored:t.ignored??["**/dist/**/*.d.ts","**/custom-elements.json","**/demo/*.md","**/demo/**/*.min.js","**/demo/**/*.min.css","**/docs/api.md","**/node_modules/**","**/.git/**"],awaitWriteFinish:t.awaitWriteFinish??{stabilityThreshold:1e3,pollInterval:100}},include:t.include??["./src/**/*.scss","./src/**/*.js","./src/**/*.ts","./demo/**/*.js","./apiExamples/**/*","./docs/**/*.md"],exclude:t.exclude??["./dist/**/*","./node_modules/**/*"]}}function Wa(e=[]){return[...[/node_modules\/lit/,/node_modules\/lit-element/,/node_modules\/lit-html/,/node_modules\/@lit/],...e]}function oo(){let e=Ie("./dist"),t=bn("Cleaning dist folder...").start();try{return Ha(e,{recursive:!0,force:!0}),t.succeed("All clean! Dist folder wiped."),!0}catch(n){return t.fail(`Oops! Couldn't clean dist/ folder: ${n.message}`),console.error(n),!1}}async function lt(e,t,n,r){let o=bn(e).start();try{let s=await t();return o.succeed(n),s}catch(s){throw o.fail(r),console.error(`Error: ${s.message}`),s}}async function so(e,t){return lt(`Bundling ${e.name||"main"} and demo...`,async()=>{let n=await yn(e);await n.write(e.output),await n.close();for(let r of t){let o=await yn(r);await o.write(r.output),await o.close()}},`Bundles ready! ${e.name||"Main"} and demo built.`,"Bundle hiccup! Build failed.")}async function ut(e){let{wcaInput:t,wcaOutput:n,skipDocs:r}=e;if(r){let o=bn("Skipping docs generation...").start();setTimeout(()=>{o.succeed("Docs generation skipped.")},0);return}return lt("Analyzing components and making docs...",async()=>{await at(t,n),await Pe(e),tt()},"Docs ready! Looking good.","Doc troubles!")}function qa(){let e=process.cwd();function t(o){return[o,`${o}.scss`,`${o}.css`,Ie(za(o),`_${Va(o)}.scss`),Ie(o,"_index.scss"),Ie(o,"index.scss")].find(i=>to(i))}function n(o){for(let i of K){let a=t(ct(e,i,o));if(a)return a}let s=r(o);return s||null}function r(o){let s,i;if(o.startsWith("@")){let a=o.split("/");if(a.length<3)return null;s=`${a[0]}/${a[1]}`,i=`./${a.slice(2).join("/")}`}else{let a=o.indexOf("/");if(a===-1)return null;s=o.slice(0,a),i=`./${o.slice(a+1)}`}for(let a of K){let c=ct(e,a,s,"package.json");if(to(c))try{let u=JSON.parse(Ua(c,"utf-8")).exports;if(!u||typeof u!="object")continue;let m=u[i];if(!m)continue;let d=typeof m=="string"?m:m.default||m.import;if(!d)continue;let p=t(ct(e,a,s,d));if(p)return p}catch{continue}}return null}return{findFileUrl(o){if(o.includes("/node_modules/")){let s=o.lastIndexOf("/node_modules/"),i=o.slice(s+14),a=n(i);if(a)return no(a)}if(!o.startsWith(".")&&!o.startsWith("/")&&!o.startsWith("file:")){let s=n(o);if(s)return no(s)}return null}}}async function ie(e="./demo"){return lt("Compiling demo SCSS...",async()=>{let t=Ka.sync(Ie(e,"**/*.scss")),n=qa(),r=process.cwd(),o=K.map(s=>ct(r,s));for(let s of t){let i=ro.compile(s,{importers:[n],loadPaths:o,silenceDeprecations:["import"],style:"compressed"}),a=s.replace(/\.scss$/,".min.css");Ja(a,i.css)}return t.length},"Demo SCSS compiled.","SCSS compilation failed.")}async function Yr(e={}){let{configs:t}=Oe(e);return lt("Bundling demo JS...",async()=>{for(let n of t){let r=await yn(n);await r.write(n.output),await r.close()}},"Demo JS bundled.","Demo JS bundling failed.")}import io from"node:path";import ae from"ora";import"rollup";var je=!1,Ya={analyze:{active:!1,lastTime:0},docs:{active:!1,lastTime:0},scss:{active:!1,lastTime:0}},Xa=5e3,mt=new Set,Za=["/dist/index.d.ts","/custom-elements.json","/demo/api.md","/docs/api.md","/demo/index.min.js"];function Qa(e){if(!e||typeof e!="string")return!1;try{let t=io.normalize(e);return Za.some(n=>t.endsWith(n))||t.includes("/dist/")||t.endsWith(".min.js")||t.endsWith(".min.css")||t.endsWith(".d.ts")}catch(t){return console.error(`Error checking path (${typeof e}):`,t.message),!1}}async function wn(e,t){let n=Ya[e];if(n.active||Date.now()-n.lastTime<Xa)return!1;try{return n.active=!0,n.lastTime=Date.now(),await t()}catch(r){return console.error(`Error in ${e} task:`,r),!1}finally{n.active=!1}}async function ao(e,t,n,{analyze:r=at,docs:o=ut,scss:s=ie}={}){let i=!0,a={analyze:!1,docs:!1,scss:!1},c=null,l,u=ae("Activating watch mode...").start(),m={analyze:async()=>{let{wcaInput:f,wcaOutput:h,skipDocs:g}=t;if(g){let k=ae("Skipping component analysis...").start();return setTimeout(()=>{k.succeed("Component analysis skipped.")},0),!0}let y=ae("Detective work: analyzing components...").start();try{return await r(f,h),y.succeed("Component analysis complete! API generated."),!0}catch(k){return y.fail("Analysis hiccup! Something went wrong."),console.error("Component analysis error:",k),!1}},docs:async()=>{if(je)return!1;if(t.skipDocs){let h=ae("Skipping docs generation...").start();return setTimeout(()=>{h.succeed("Docs generation skipped.")},0),!0}let f=ae("Refreshing docs...").start();try{await o(t),f.succeed("Documentation refreshed!")}catch(h){f.fail("Docs stumble! Couldn't refresh."),console.error("Documentation rebuild error:",h)}return!0},scss:async()=>{if(je)return!1;try{return await s(),!0}catch(f){return console.error("Demo SCSS compilation error:",f),!1}}},d=()=>{i&&a.analyze&&a.docs&&a.scss&&typeof n=="function"&&(i=!1,n())};function p(f=1e3){c&&clearTimeout(c),c=setTimeout(async()=>{setTimeout(async()=>{a.analyze=await wn("analyze",m.analyze),setTimeout(async()=>{a.docs=await wn("docs",m.docs),setTimeout(async()=>{a.scss=await wn("scss",m.scss),d()},500)},1e3)},1e3)},f)}e.on("event",async f=>{switch(f.code){case"START":u.succeed("Watch mode active! Eyes peeled.");break;case"BUNDLE_START":if(mt.clear(),f.input)try{let h=Array.isArray(f.input)?f.input:typeof f.input=="string"?[f.input]:typeof f.input=="object"&&f.input!==null?Object.values(f.input):[];for(let g of h)typeof g=="string"&&!Qa(g)&&mt.add(io.normalize(g))}catch(h){console.error("Error processing input paths:",h)}l=ae("Weaving bundles...").start(),je=!0;break;case"BUNDLE_END":l&&l.succeed(`Bundle ${Array.isArray(f.input)?`of ${f.input.join("& ")} `:""}done in ${f.duration}ms! \u{1F680}`),je=!1,mt.size>0&&p();break;case"END":break;case"ERROR":je=!1,l?l.fail(`Oops! Bundle hit a snag: ${f.error.message}`):ae().fail(`Watch mode hiccup: ${f.error.message}`),mt.clear();break}})}function co(e,t){return De(e),t&&De(t),nt(),e}async function nc(e){let t=hn(e),n=Oe(e);e.dev||t.config.plugins.push(ec()),await ut(e),await ie(),await so(t.config,n.configs)}async function rc(e){let{dev:t}=e,n=hn({...e,watch:!0}),r=Oe({...e,watch:!0}),o=tc([n.config,...r.configs]);ao(o,e,t?async()=>ot(e):void 0);let s=await import("chokidar"),i=!1,a=!1,c=null,l=s.watch("./demo/**/*.scss",{ignoreInitial:!0,ignored:["**/demo/**/*.min.css"],awaitWriteFinish:{stabilityThreshold:500,pollInterval:100}});return l.on("all",()=>{c&&clearTimeout(c),c=setTimeout(async()=>{if(i){a=!0;return}i=!0;try{await ie()}catch(u){console.error("Demo SCSS watch compilation error:",u)}finally{i=!1,a&&(a=!1,l.emit("all"))}},500)}),co(o,l),o}async function dt(e={}){try{let{watch:t}=e;return oo(),t?await rc(e):await nc(e)}catch(t){throw new Error(`Build failed: ${t.message}`)}}var _e=oc.command("dev").description("Runs development server for auro components");_e=Ye(_e);_e=Xe(_e);var Ng=_e.action(async e=>{try{let t=lo("Initializing...");e.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=e.docs===!1?"Building component (docs disabled)":"Building component",t.start(),e.watch||t.succeed("Build completed!"),await dt({...e,dev:!0,watch:e.watch})}catch(t){lo().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{program as sc}from"commander";import uo from"ora";var kn=sc.command("build").description("Builds auro components");kn=Ye(kn);var Lg=kn.action(async e=>{try{let t=uo("Initializing...");e.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=e.docs===!1?"Building component (docs disabled)":"Building component",t.start(),await dt(e),e.watch||t.succeed("Build completed!")}catch(t){uo().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{exec as ic}from"node:child_process";import mo from"node:path";import ac from"node:process";import{fileURLToPath as cc}from"node:url";import lc from"node:util";import{program as uc}from"commander";import mc from"inquirer";var qg=uc.command("migrate").description("Script runner to perform repetitive code change tasks").requiredOption("-i, --id <string>","Select the migration you would like to run by id").option("-m, --multi-gitter","Run the migration on all repositories in the multi-gitter config").action(async e=>{let t=cc(import.meta.url),n=mo.dirname(t),r=mo.resolve(n,"migrations",e.id);if(e.multiGitter){let o=lc.promisify(ic);try{await o("command -v multi-gitter")}catch{console.error("multi-gitter is not installed."),ac.exit(1)}(await mc.prompt([{type:"confirm",name:"dryRun",message:"Run migration in dry-run mode? (no changes will be committed)",default:!0}])).dryRun?F(`multi-gitter run ${r}/script.sh --config "${r}/multi-gitter.yml" --dry-run`):F(`multi-gitter run ${r}/script.sh --config "${r}/multi-gitter.yml"`)}else F(`${r}/script.sh`)});import yo from"node:process";import{program as hc}from"commander";import{readFile as yc,writeFile as bc}from"node:fs/promises";import{Logger as Fe}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import vn from"node:fs/promises";import $n from"node:path";import{Octokit as dc}from"@octokit/rest";import B from"ora";import{processContentForFile as pc,templateFiller as fc}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";async function po(e,t){let n=new dc({auth:process.env.GITHUB_TOKEN||""});try{let o=(await n.request("GET /repos/{owner}/{repo}/contents/{path}",{ref:t,owner:"AlaskaAirlines",repo:"auro-templates",path:e,headers:{"X-GitHub-Api-Version":"2022-11-28"}})).data;if(typeof o!="object"||!Array.isArray(o)){let s=`Unexpected response format: ${JSON.stringify(o)}`;throw B().start().fail(s),new Error("Failed to retrieve folder items")}return o}catch(r){let o=B().start();throw r.status===404?o.fail(`Template '${e.split("/")[1]}' not found`):o.fail(`Error accessing template: ${r.message}`),r}}async function fo({folderItems:e,templatePathToReplace:t,rootDir:n,ref:r}){let o=[];for(let s of e){if(s.type=="dir"){let l=B(`Processing directory: ${s.path}`).start(),u=await po(s.path,r);l.succeed(`Found ${u.length} additional items in ${s.path}`);let m=await fo({folderItems:u,templatePathToReplace:t,rootDir:n,ref:r});o.push(...m);continue}let i=s.path.replace(`${t}/`,""),a=`${n}/.github/${i}`,c={identifier:s.name,input:{remoteUrl:s.download_url||"",fileName:a,overwrite:!0},output:a};o.push(c)}return o}async function gc(e){try{await vn.rm(e,{recursive:!0,force:!0}),B().start().succeed(`Successfully removed directory: ${e}`)}catch(t){throw B().start().fail(`Error removing directory ${e}: ${t.message}`),t}}async function go(e,t="",n=!0){try{let r=await vn.stat(e),o=$n.basename(e);if(!r.isDirectory())return`${t}${n?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}
|
|
27
|
+
`;let s=`${t}${n?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}/
|
|
28
|
+
`;try{let a=(await vn.readdir(e)).sort();for(let c=0;c<a.length;c++){let l=a[c],u=$n.join(e,l),m=c===a.length-1,d=t+(n?" ":"\u2502 ");s+=await go(u,d,m)}}catch{s+=`${t}${n?" ":"\u2502 "}\u2514\u2500\u2500 [Permission denied or error reading directory]
|
|
29
|
+
`}return s}catch(r){return`${t}${n?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}[Error: ${r}]
|
|
30
|
+
`}}async function ho(e,t="main",n="default"){if(!e)throw B().start().fail("Root directory must be specified"),new Error("Root directory must be specified");if(await fc.extractNames(),!process.env.GITHUB_TOKEN)throw B().start().fail("GITHUB_TOKEN environment variable is not set."),new Error("GITHUB_TOKEN environment variable is not set");let r=`templates/${n}/.github`,o=await po(r,t),s=".github",i=B("Removing existing .github directory...").start();try{await gc(s),i.succeed(".github directory removed successfully")}catch(l){throw i.fail(`Error removing .github directory: ${l.message}`),new Error(`Failed to remove .github directory: ${l.message}`)}let a=await fo({folderItems:o,templatePathToReplace:r,rootDir:e,ref:t}),c=B("Processing all files...").start();try{await Promise.all(a.map(u=>pc(u))),c.succeed("All files processed.");let l=B("Generating directory tree...").start();try{let u=$n.join(e,".github"),m=await go(u);l.succeed("Synced .github directory structure:"),console.log(m)}catch(u){l.fail(`Error generating directory tree: ${u.message}`)}}catch(l){throw c.fail(`Error processing files: ${l.message}`),new Error(`Failed to process files: ${l.message}`)}}var ch=hc.command("sync").option("-r, --ref <branch/tag/commit>","Git reference (branch/tag/commit) to use","main").option("-t, --template <name>","Template based on which to sync","default").description("Script runner to synchronize local repository configuration files").action(async e=>{Fe.info("Synchronizing repository configuration files..."),Fe.warn("Note: sync does not create a new git branch. Changes are added to the current branch.");let t=yo.cwd();try{await ho(t,e.ref,e.template);try{let n=`${t}/.github/CODEOWNERS`,o=(await yc(n,{encoding:"utf-8"})).replace(/\r\n/gu,`
|
|
31
31
|
`).replace(/\n\n/gu,`
|
|
32
|
-
`);await
|
|
32
|
+
`);await bc(n,o,{encoding:"utf-8"}),(o.includes("\r")||o.includes(`
|
|
33
33
|
|
|
34
|
-
`))&&
|
|
34
|
+
`))&&Fe.error("CODEOWNERS file still has Windows line endings.")}catch(n){throw Fe.error(`Error processing CODEOWNERS file: ${n.message}`),n}}catch(n){Fe.error(`Sync operation failed: ${n.message}`),yo.exit(1)}});import pt from"node:fs";import Le from"node:path";import{Logger as wo}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as wc}from"commander";import{glob as kc}from"glob";var bo=(e,t)=>{let n=(e.match(/static register\(name \= (.+)\)/)||e.match(/customElements.get\((.+?)\)/))[1],r=e.match(/export class (.+) extends/)?.[1],o=e.match(/\/\*\*((.|\n)*?)(\*\n|\*\/|[@])/)?.[1]||"";return!n||!r?e:`
|
|
35
35
|
import { ${r} } from '${t}';
|
|
36
36
|
|
|
37
37
|
/**${o}*/
|
|
@@ -40,33 +40,33 @@ class ${r}WCA extends ${r} {}
|
|
|
40
40
|
if (!customElements.get(${n})) {
|
|
41
41
|
customElements.define(${n}, ${r}WCA);
|
|
42
42
|
}
|
|
43
|
-
`};var
|
|
44
|
-
`).filter(
|
|
45
|
-
`);if(
|
|
46
|
-
|
|
47
|
-
${
|
|
48
|
-
${t}`),n
|
|
49
|
-
`,o=""),o=`${o}${
|
|
50
|
-
`)}import*as
|
|
43
|
+
`};var ft=Le.resolve(process.cwd(),"./scripts/wca");async function vc(e){try{return(await Promise.all(e.map(n=>kc(n)))).flat()}catch(t){throw console.error("Error processing glob patterns:",t),t}}async function $c(e){pt.existsSync(ft)||await pt.promises.mkdir(ft,{recursive:!0});for(let t of e){let n=Le.resolve(process.cwd(),t),r=await pt.promises.readFile(n,"utf-8"),o=Le.resolve(ft,`${Le.basename(t)}`),s=bo(r,Le.relative(ft,t));await pt.promises.writeFile(o,s)}}async function Ec(){let e=await vc(["./src/auro-*.js"]);await $c(e)}var yh=wc.command("wca-setup").description("Set up WCA (Web Component Analyzer) for the project").action(()=>{Ec().then(()=>{wo.success("WCA setup completed successfully.")}).catch(e=>{wo.error(`WCA setup failed: ${e.message}`)})});import{program as Nc}from"commander";import Eo from"chalk";import So from"ora";import{appendFile as Sc,readFile as xc}from"node:fs/promises";import{Logger as E}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{simpleGit as Ac}from"simple-git";var S;try{S=Ac({baseDir:process.cwd(),binary:"git",maxConcurrentProcesses:1})}catch(e){E.error(`Failed to initialize git: ${e}`),S={}}var q=class e{static async checkGitignore(t){if(t==="")return!1;try{return(await xc(".gitignore","utf-8")).includes(t)}catch(n){return E.error(`Error reading file: ${n}`),!1}}static async getCommitMessages(t=""){try{let n=t;n||(n=(await S.branchLocal()).current);let r="main",o="";if(!!process.env.GITHUB_ACTIONS){r=process.env.GITHUB_BASE_REF||"main";try{if(await S.fetch("origin",r),n!=="HEAD")try{await S.raw(["rev-parse","--verify",`origin/${n}`])}catch{await S.fetch("origin",n)}let i=n==="HEAD"?"HEAD":`origin/${n}`;o=`${(await S.raw(["merge-base",`origin/${r}`,i])).trim()}..${i}`}catch(i){E.warn(`Error setting up commit range in CI: ${i}`);let a=n==="HEAD"?"HEAD":`origin/${n}`;o=`origin/${r}..${a}`}}else try{try{await S.raw(["rev-parse","--verify",`origin/${r}`])}catch{E.info(`Fetching ${r} from origin`),await S.fetch("origin",r)}if(n!=="HEAD")try{await S.raw(["rev-parse","--verify",n])}catch{await S.fetch("origin",n)}o=`${(await S.raw(["merge-base",`origin/${r}`,n])).trim()}..${n}`}catch(i){E.warn(`Error determining commits locally: ${i}`),o=`${n}~10..${n}`}return await e.getFormattedCommits(o)}catch(n){return E.error(`Error getting commit messages: ${n}`),[]}}static async getRepoOwnerAndName(){try{let t=await S.getRemotes(!0);if(t.length===0)return E.warn("No remotes found"),null;let n=t.find(o=>o.name==="origin")||t[0],r=n.refs.fetch||n.refs.push;return e.parseGitUrl(r)}catch(t){return E.error(`Error getting repo owner and name: ${t}`),null}}static async getCurrentBranchName(){try{return(await S.branchLocal()).current||null}catch(t){return E.error(`Error getting current branch name: ${t}`),null}}static parseGitUrl(t){let n;return t.includes("@")&&t.includes(":")&&(n=t.match(/@([^:]+):([^/]+)\/(.+?)(?:\.git)?$/),n)?{owner:n[2],repo:n[3]}:(n=t.match(/https?:\/\/(?:[^@]+@)?[^/]+\/([^/]+)\/(.+?)(?:\.git)?$/),n?{owner:n[1],repo:n[2]}:(E.warn(`Could not parse git URL: ${t}`),null))}static async getFormattedCommits(t){let r=(await S.raw(["log","--pretty=format:COMMIT_START%n%H%n%ad%n%an%n%s%n%b%nCOMMIT_END","--date=short",t])).split(`COMMIT_START
|
|
44
|
+
`).filter(s=>s.trim()!==""),o=[];for(let s of r){let i=s.split(`
|
|
45
|
+
`);if(i.length>=4){let a=i[0],c=i[1],l=i[2],u=i[3],m=i.slice(4).filter(g=>g!=="COMMIT_END"),d=m.length>0?m.join(""):"",p=a.substring(0,7),f=u.match(/^(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?:/),h=f?f[1]:"unknown";d.includes("BREAKING CHANGE")&&(h="breaking"),o.push({type:h,hash:p,date:c,subject:u,body:d,message:`${u}${d?`
|
|
46
|
+
|
|
47
|
+
${d}`:""}`,author_name:l})}}return o}static async addToGitignore(t,n=!0){await e.checkGitignore(t).then(async r=>{if(r)E.warn(`${t} already exists`);else try{await Sc(".gitignore",`
|
|
48
|
+
${t}`),n&&E.success(`${t} added to .gitignore`)}catch(o){E.error(o)}})}static async removeFromGitCache(t){try{await S.rmKeepLocal(t),E.success(`${t.join(", ")} are removed from git cache`)}catch(n){E.error(n)}}static async createBranch(t){try{await S.checkoutLocalBranch(t),E.success(`Created and switched to ${t} branch`)}catch(n){E.error(n)}}static async commitStagedFiles(t){try{await S.add("."),await S.commit(t),E.success(`Committed with message: ${t}`)}catch(n){E.error(n)}}};import A from"chalk";var Cc=60,Tc=100;function Be(e){switch(e){case"breaking":return A.bold.red(e);case"feat":return A.bold.green(e);case"fix":return A.bold.green(e);case"perf":return A.bold.green(e);case"docs":return A.bold.cyan(e);case"style":return A.bold.cyan(e);case"refactor":return A.bold.cyan(e);case"test":return A.bold.cyan(e);case"build":return A.bold.cyan(e);case"ci":return A.bold.cyan(e);case"chore":return A.bold.cyan(e);default:return A.bold.white(e)}}function ko(e,t){if(!e)return"";if(e.length<=t)return e;let n=e.split(" "),r="",o="";for(let s of n)(o+s).length>t&&o.length>0&&(r+=`${o.trim()}
|
|
49
|
+
`,o=""),o=`${o}${s} `;return o.length>0&&(r+=o.trim()),r}function vo(e){for(let t of e){console.log("\u2500".repeat(60));let n=ko(t.subject,Cc),r=ko(t.body,Tc);console.log(A.bold(`${Be(t.type)}`)),console.log(A.dim(`${t.hash} | ${t.date} | ${t.author_name}`)),console.log(A.bold(`${A.white(n)}`)),t.body&&console.log(A.dim(r))}console.log("\u2500".repeat(60)),console.log(`
|
|
50
|
+
`)}import*as Ge from"@actions/github";async function En(){try{let e=process.env.GITHUB_TOKEN;if(!e)throw new Error("GITHUB_TOKEN environment variable is not set");if(!process.env.GITHUB_REPOSITORY||!process.env.GITHUB_EVENT_PATH)throw new Error("This function can only be used in a GitHub Actions environment");let t=Ge.getOctokit(e),{context:n}=Ge;if(!n.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[r,o]=process.env.GITHUB_REPOSITORY.split("/"),s=n.payload.pull_request.number,{data:i}=await t.rest.issues.listLabelsOnIssue({owner:r,repo:o,issue_number:s});return i.map(a=>a.name)}catch(e){throw e instanceof Error?new Error(`Failed to get existing labels: ${e.message}`):e}}async function $o(e){try{let t=process.env.GITHUB_TOKEN;if(!t)throw new Error("GITHUB_TOKEN environment variable is not set");if(!process.env.GITHUB_REPOSITORY||!process.env.GITHUB_EVENT_PATH)throw new Error("This function can only be used in a GitHub Actions environment");let n=Ge.getOctokit(t),{context:r}=Ge;if(!r.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[o,s]=process.env.GITHUB_REPOSITORY.split("/"),i=r.payload.pull_request.number,a=`semantic-status: ${e}`,c=await En();if(c.includes(a))return;let l=c.filter(u=>u.startsWith("semantic-status:")&&u!==a);for(let u of l)await n.rest.issues.removeLabel({owner:o,repo:s,issue_number:i,name:u});await n.rest.issues.addLabels({owner:o,repo:s,issue_number:i,labels:[a]});return}catch(t){throw t instanceof Error?new Error(`Failed to apply label: ${t.message}`):t}}var Rc=["feat","fix","breaking","perf"];function Dc(e,t=!0){let n=`### In this release
|
|
51
51
|
`;for(let r of e)if(n+=`- ${r.hash} ${r.subject}
|
|
52
|
-
`,r.body?.trim()){let
|
|
53
|
-
`),r}async function
|
|
54
|
-
`).start();try{let o=await
|
|
52
|
+
`,r.body?.trim()){let s=r.body.trim().split(/\n+/).map(i=>i.trim()).filter(i=>i.length>0);for(let i of s){let a=i;a=a.replace(/([^\s])(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)/g,"$1 $2"),a=a.replace(/(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)([^\s])/g,"$1 $2"),n+=` - ${a}`}}return e.length===0?"":(t&&console.log(Eo.green(`\u2713 Generating release notes for ${e.length} commits`)),n)}function Pc(e,t=!0){let n=e.filter(o=>Rc.includes(o.type)),r;return t?r=n.length>0?n:e:r=n,r.length===0&&console.log(`No commits found to include in release notes.
|
|
53
|
+
`),r}async function xo(e=!1,t=!1,n=!1){let r=So(`Checking commits...
|
|
54
|
+
`).start();try{let o=await q.getCommitMessages();if(n){r.succeed(`Total commits analyzed: ${o.length}`);let s=Pc(o);console.log(Dc(s));return}if(e&&vo(o),r.succeed(`Total commits analyzed: ${o.length}`),o.length!==0){let s=o.map(c=>c.type),a=Array.from(new Set(s)).map(c=>Be(c)).join(", ");r.succeed(`Found commit types: ${a}`)}else r.info(`The list of commits is created by comparing the current branch
|
|
55
55
|
with the main branch. If you are on a new branch, please
|
|
56
|
-
make sure to commit some changes before running this command.`);t&&await
|
|
57
|
-
`,"utf8"),r.succeed(`Package.json updated to use ${
|
|
56
|
+
make sure to commit some changes before running this command.`);t&&await Mc(o,r)}catch(o){r.fail("Error getting commit messages"),console.error(o)}}async function Mc(e,t){let n=["breaking","feat","fix","perf","docs","style","refactor","test","build","ci","chore"],r=e.map(i=>i.type).filter(i=>n.includes(i)),o=null,s=Number.POSITIVE_INFINITY;for(let i of r){let a=n.indexOf(i);a<s&&(s=a,o=i)}if(o){let i=So("Checking existing labels on pull request...").start();try{if((await En()).includes(`semantic-status: ${o}`)){i.info(`Label "semantic-status: ${Be(o)}" already exists on the pull request.`);return}i.text="Applying label to pull request...",await $o(o),i.succeed(`Label "semantic-status: ${Be(o)}" applied to the pull request.`)}catch(a){let c=a instanceof Error?a.message:String(a);i.fail(c)}}else t.warn(Eo.yellow("No semantic commit type found to apply as label."))}var Oh=Nc.command("check-commits").alias("cc").option("-l, --set-label","Set label on the pull request based on the commit message type").option("-d, --debug","Display detailed commit information for debugging").option("-r, --release-notes","Generate release notes based on commit messages").description("Check commits in the local repository for the types of semantic commit messages made and return the results.").action(async e=>{await xo(e.debug,e.setLabel,e.releaseNotes)});import Ao from"node:fs";import{get as Co}from"node:https";import ce from"chalk";import{program as Oc}from"commander";import Ic from"ora";var Gh=Oc.command("pr-release").option("-n, --namespace <package-namespace>","Set namespace of the package release","@aurodesignsystem-dev").option("-p, --pr-number <number>","Set pull request number for the release","0").description("Generate the package version based off of PR number then update the package.json file. Note: this does not publish the package.").action(async e=>{await jc(e)}),jc=async e=>{let{namespace:t,prNumber:n}=e,r=Ic("Updating package.json").start();try{let o="package.json",s=JSON.parse(Ao.readFileSync(o,"utf8"));r.text="Checking npm registry for version information...";let i=`0.0.0-pr${n}`,a=s.name.split("/")[1],c=`${t}/${a}`,l=await _c(i,c,r),u=`${i}.${l}`;s.name=c,s.version=u,r.text="Writing updated package.json...",Ao.writeFileSync(o,`${JSON.stringify(s,null,2)}
|
|
57
|
+
`,"utf8"),r.succeed(`Package.json updated to use ${ce.green(u)} and ${ce.green(c)}`),process.exit(0)}catch(o){r.fail(`Failed to update package.json: ${o}`),process.exit(1)}},_c=(e,t,n)=>new Promise(r=>{try{let a=function(c){if(c.statusCode!==200){n.info(`Package not found. Status code: ${ce.red(c.statusCode)}, defaulting to version 0`),r(0);return}n.text="Processing version information...";let l="";c.on("data",u=>{l+=u}),c.on("end",()=>{try{let u=JSON.parse(l),m=u.versions?Object.keys(u.versions):[];n.text="Calculating next version number...";let d=-1,p=new RegExp(`^${e}\\.(\\d+)$`);for(let f of m){let h=f.match(p);if(h){let g=Number.parseInt(h[1],10);d=Math.max(d,g)}}d>=0?n.info(`Found existing version ${ce.green(`${e}.${d}`)}. Incrementing to ${ce.green(`${e}.${d+1}`)}`):n.info(`No existing version found for ${ce.green(e)}. Starting with ${ce.green(`${e}.0`)}`),r(d+1)}catch(u){n.warn(`Failed to parse NPM registry response: ${u instanceof Error?u.message:"Unknown error"}, defaulting to version 0`),r(0)}})};var o=a;let s=`https://registry.npmjs.org/${t}`,i=Co(s,{headers:{Accept:"application/json"}},c=>{if((c.statusCode===301||c.statusCode===302)&&c.headers.location){n.info(`Following redirect to ${c.headers.location}...`);try{Co(c.headers.location,{headers:{Accept:"application/json"}},a).on("error",l=>{n.warn(`Error following redirect: ${l.message}, defaulting to version 0`),r(0)}).end()}catch(l){n.warn(`Redirect request failed: ${l instanceof Error?l.message:"Unknown error"}, defaulting to version 0`),r(0)}return}a(c)});i.on("error",c=>{n.warn(`Request error: ${c.message}, defaulting to version 0`),r(0)}),i.end()}catch{n.warn("Error checking version in npm registry, defaulting to version 0"),r(0)}});import Sn from"node:path";import{fileURLToPath as Fc}from"node:url";import{program as Lc}from"commander";import Bc from"open";var Gc=Fc(import.meta.url),Wc=Sn.resolve(Sn.dirname(Gc),".."),Kh=Lc.command("test").option("-w, --watch","Set watch number for the test").option("-c, --coverage-report","Generate coverage report").option("-o, --open","Open the coverage report in the browser").option("-f, --files <String|String[]>","Test files glob pattern").description("Run the web test runner to test the component library").action(async e=>{let n=`npx wtr --config "${Sn.join(Wc,"dist","configs","web-test-runner.config.mjs")}"`,r=`${process.cwd()}/coverage/index.html`;if(e.coverageReport&&(n+=" --coverage"),e.watch&&(n+=" --watch"),e.files){let o=Array.isArray(e.files)?e.files.join(" "):e.files;n+=` --files "${o}"`}F(n),e.open&&await Bc(r)});import Tn from"node:fs/promises";import Do from"node:path";import{program as qc}from"commander";import Yc from"inquirer";import Rn from"ora";import Uc from"node:fs/promises";import Hc from"node:path";import Jc from"ora";var Vc={"auth-type":"workspace-token","author-email":null,"author-name":null,"base-branch":"main","base-url":null,"clone-dir":".gitter-temp","code-search":null,concurrent:4,"conflict-strategy":"replace",draft:!1,"dry-run":!0,"fetch-depth":1,fork:!1,"fork-owner":null,"git-type":"go",group:null,"include-subgroups":!1,insecure:!1,interactive:!1,labels:null,"log-file":"'-'","log-format":"'text'","log-level":"'error'","max-reviewers":0,"max-team-reviewers":0,org:null,output:"'-'","plain-output":!1,platform:"github",project:null,"push-only":!1,repo:["AlaskaAirlines/auro-accordion","AlaskaAirlines/auro-alert","AlaskaAirlines/auro-avatar","AlaskaAirlines/auro-background","AlaskaAirlines/auro-backtotop","AlaskaAirlines/auro-button","AlaskaAirlines/auro-badge","AlaskaAirlines/auro-banner","AlaskaAirlines/auro-card","AlaskaAirlines/auro-carousel","AlaskaAirlines/auro-datetime","AlaskaAirlines/auro-dialog","AlaskaAirlines/auro-drawer","AlaskaAirlines/auro-flight","AlaskaAirlines/auro-flightline","AlaskaAirlines/auro-header","AlaskaAirlines/auro-hyperlink","AlaskaAirlines/auro-icon","AlaskaAirlines/auro-loader","AlaskaAirlines/auro-lockup","AlaskaAirlines/auro-nav","AlaskaAirlines/auro-pane","AlaskaAirlines/auro-popover","AlaskaAirlines/auro-sidenav","AlaskaAirlines/auro-skeleton","AlaskaAirlines/auro-slideshow","AlaskaAirlines/auro-table","AlaskaAirlines/auro-tabs","AlaskaAirlines/auro-toast"],"repo-exclude":null,"repo-include":null,"repo-search":null,reviewers:null,"skip-forks":!1,"skip-pr":!1,"skip-repo":null,"ssh-auth":!1,"team-reviewers":null};function zc(e){return Object.entries(e).map(([t,n])=>Array.isArray(n)?`${t}:
|
|
58
58
|
- ${n.join(`
|
|
59
59
|
- `)}`:typeof n=="object"&&n!==null?`${t}:
|
|
60
60
|
${Object.entries(n).map(([r,o])=>` ${r}: ${o}`).join(`
|
|
61
61
|
`)}`:`${t}: ${n}`).join(`
|
|
62
|
-
`)}async function
|
|
63
|
-
${
|
|
62
|
+
`)}async function To(e){let t=Jc("Writing multi-gitter configuration...").start(),n=zc(Vc),r=Hc.join(e,"multi-gitter_DEPENDENCY_TREE.yml");try{await Uc.writeFile(r,n,"utf8"),t.succeed(`Multi-gitter configuration written to ${r}`)}catch(o){t.fail("Error writing multi-gitter configuration:"),console.error(o)}}import xn from"node:fs";function gt(e){let t={},n=[],r=[],o=[];for(let s in e)t[s]=e[s].dependsOn.length;for(let s in t)t[s]===0&&o.push(s);for(;o.length>0;){r=[];let s=o.length;for(let i=0;i<s;i++){let a=o.shift();r.push(a);for(let c of e[a].dependentPackages)t[c]--,t[c]===0&&o.push(c)}n.push(r)}if(n.flat().length!==Object.keys(e).length)throw new Error("Circular dependency detected!");return n}function Kc(e){return xn.readdirSync(e).filter(t=>t.endsWith(".json"))}async function Ro(e,t=[]){console.log(t);let n={},r=Kc(e);for(let o of r){if(o==="dependencyTree.json")continue;let s=xn.readFileSync(`${e}/${o}`,"utf-8"),i=JSON.parse(s),a=i.name,c=Object.keys(i.peerDependencies),l=Object.keys(i.devDependencies),u=Object.keys(i.dependencies);n[a]||(n[a]={dependsOn:[],dependentPackages:[]});let m=[...c,...l,...u];n[a].dependsOn=[...new Set(m)];for(let d of m)n[d]||(n[d]={dependsOn:[],dependentPackages:[]}),n[d].dependentPackages.includes(a)||n[d].dependentPackages.push(a)}if(t.length){let o=new Set;for(let[i,a]of Object.entries(n))a.dependsOn.some(c=>t.includes(c))&&o.add(i);for(let i of t)n[i]&&o.add(i);let s={};for(let i of o)s[i]={dependsOn:n[i].dependsOn.filter(a=>o.has(a)),dependentPackages:n[i].dependentPackages.filter(a=>o.has(a))};n=s}else console.log("No target dependencies provided - using all packages.");return xn.writeFileSync(`${e}/dependencyTree.json`,JSON.stringify(n,null,2)),n}var j=["@aurodesignsystem/auro-accordion","@aurodesignsystem/auro-alert","@aurodesignsystem/auro-avatar","@aurodesignsystem/auro-background","@aurodesignsystem/auro-backtotop","@aurodesignsystem/auro-badge","@aurodesignsystem/auro-banner","@aurodesignsystem/auro-button","@aurodesignsystem/auro-card","@aurodesignsystem/auro-carousel","@aurodesignsystem/auro-checkbox","@aurodesignsystem/auro-combobox","@aurodesignsystem/auro-datepicker","@aurodesignsystem/auro-datetime","@aurodesignsystem/auro-dialog","@aurodesignsystem/auro-drawer","@aurodesignsystem/auro-dropdown","@aurodesignsystem/auro-flight","@aurodesignsystem/auro-flightline","@aurodesignsystem/auro-form","@aurodesignsystem/auro-formkit","@aurodesignsystem/auro-header","@aurodesignsystem/auro-hyperlink","@aurodesignsystem/auro-icon","@aurodesignsystem/auro-input","@aurodesignsystem/auro-loader","@aurodesignsystem/auro-lockup","@aurodesignsystem/auro-menu","@aurodesignsystem/auro-nav","@aurodesignsystem/auro-pane","@aurodesignsystem/auro-popover","@aurodesignsystem/auro-radio","@aurodesignsystem/auro-select","@aurodesignsystem/auro-sidenav","@aurodesignsystem/auro-skeleton","@aurodesignsystem/auro-slideshow","@aurodesignsystem/auro-table","@aurodesignsystem/auro-tabs","@aurodesignsystem/auro-tail","@aurodesignsystem/auro-toast","@aurodesignsystem/auro-tokenlist"];var An=ln("run-migrations","config"),Cn=ln("run-migrations","outputs");var py=[...j,"@aurodesignsystem/auro-library","@aurodesignsystem/WebCoreStyleSheets","@aurodesignsystem/AuroDesignTokens","@aurodesignsystem/auro-cli","@alaskaairux/icons"];async function Xc(e){try{await Tn.mkdir(Cn,{recursive:!0}),await Tn.mkdir(An,{recursive:!0})}catch(o){console.error("Failed to create output or config directories:",o),process.exit(1)}let t=Rn("Creating dependency tree...").start();t.text="Creating multi-gitter dependency tree configuration...",await To(An),t.text="Scraping dependencies from Auro packages...";let r=`multi-gitter run "node ${un("static","getAuroDeps.js")}" --config ${Do.join(An,"multi-gitter_DEPENDENCY_TREE.yml")}`;try{await F(r)}catch(o){t.fail("Failed to generate dependency tree:"),console.error(o),process.exit(1)}return t.text="Generating dependency tree JSON file using packages...",await Ro(Cn,e),t.succeed("Dependency tree generated successfully."),Do.join(Cn,"dependencyTree.json")}var Zc=async e=>{let t=Rn("Loading dependency tree...").start(),n=JSON.parse(await Tn.readFile(e,"utf-8"));t.text="Processing dependency tree...";let r=gt(n);return t.succeed("Dependency batches created successfully."),r},fy=qc.command("agent").action(async e=>{let t=await Yc.prompt([{type:"select",name:"agentAction",message:"What agent action do you want to perform?",choices:[{name:"Run a migration on auro components",value:"run-migration"}],default:["run-migration"]},{type:"input",name:"migrationId",message:"What migration id do you want to run?",when:n=>n.agentAction==="run-migration",validate:n=>n.trim()!==""||"Migration id cannot be empty."},{type:"confirm",name:"useExisting",message:"Would you like to specify starting packages?",default:!0,transformer:n=>n?"Yes = Packages related to selections":"No = All packages",when:n=>n.agentAction==="run-migration"},{type:"checkbox",name:"startWithComponents",message:"Enter the components to start with (comma-separated, blank for all):",choices:j.map(n=>({name:n.replace("@aurodesignsystem/",""),value:n})),when:n=>n.agentAction==="run-migration"&&n.useExisting}]);switch(t.agentAction){case"run-migration":{let n=Rn("Running migration...").start(),r=await Xc(t.startWithComponents);n.text="Getting dependency batches from tree...";let s=(await Zc(r)).map((i,a)=>`Batch ${a+1}
|
|
63
|
+
${i.map(c=>` - ${c.replace("@aurodesignsystem","AlaskaAirlines").replace("@alaskaairux/icons","AlaskaAirlines/Icons")}`).join(`
|
|
64
64
|
`)}`).join(`
|
|
65
65
|
|
|
66
|
-
`);console.log(
|
|
67
|
-
`,"utf-8")}catch(a){let c=a instanceof Error?a.message:String(a);t.fail(`Failed to write ${e.output}: ${c}`),
|
|
66
|
+
`);console.log(s),n.text="Running migrations on dependency batches...",new Promise(i=>setTimeout(i,2e3)),n.succeed("Migration process completed successfully.");break}default:console.error("Unknown action selected.")}});import{writeFile as sl}from"node:fs/promises";import il from"node:path";import ht from"node:process";import{Logger as _o}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as al}from"commander";import cl from"ora";import{readFile as Po}from"node:fs/promises";import le from"node:path";import Qc from"node:process";var el="https://unpkg.com",tl="https://registry.npmjs.org",Dn=1e4;function nl(e){let t=e.lastIndexOf("@");return t>0?{pkg:e.slice(0,t),ref:e.slice(t+1)}:{pkg:e}}function Mo(e,t){let n=le.relative(e,t);return n===""||!n.startsWith("..")&&!le.isAbsolute(n)}async function rl(e){let t=le.join(Qc.cwd(),"node_modules"),n=le.join(t,...e.split("/"));if(!Mo(t,n))return null;let r,o="custom-elements.json";try{let s=JSON.parse(await Po(le.join(n,"package.json"),"utf-8"));typeof s.version=="string"&&(r=s.version),typeof s.customElements=="string"&&Mo(n,le.resolve(n,s.customElements))&&(o=s.customElements)}catch{return null}try{let s=JSON.parse(await Po(le.join(n,o),"utf-8"));return{target:e,manifest:s,source:"local",version:r}}catch{return null}}async function _(e,t={}){let{preferLocal:n=!0,allowNetwork:r=!0}=t,{ref:o}=nl(e);if(n&&!o){let a=await rl(e);if(a)return{...a,target:e}}if(!r)return{target:e,manifest:null,reason:"not installed locally and network fetching is disabled"};let s=`${el}/${e}/custom-elements.json`,i;try{i=await fetch(s,{signal:AbortSignal.timeout(Dn)})}catch(a){let l=a instanceof DOMException&&a.name==="TimeoutError"?`timed out after ${Dn/1e3}s`:a instanceof Error?a.message:String(a);return{target:e,manifest:null,reason:`request failed (${l})`,transient:!0}}if(i.status===404)return{target:e,manifest:null,reason:"no custom-elements.json published"};if(!i.ok)return{target:e,manifest:null,reason:`HTTP ${i.status}`,transient:!0};try{return{target:e,manifest:await i.json(),source:"unpkg"}}catch{return{target:e,manifest:null,reason:"custom-elements.json is not valid JSON",transient:!0}}}function No(e){let t=e.filter(n=>!n.manifest);return{skipped:t,transientFailures:t.filter(n=>n.transient)}}async function Oo(e){try{let t=await fetch(`${tl}/${e}/latest`,{signal:AbortSignal.timeout(Dn)});if(!t.ok)return null;let n=await t.json();return typeof n.version=="string"?n.version:null}catch{return null}}import{Logger as ol}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";function Pn(e,t){if(Array.isArray(e))return e.map(n=>Pn(n,t));if(e&&typeof e=="object"){let n=e,r={};for(let[o,s]of Object.entries(n))o==="module"&&typeof s=="string"&&n.package==null?r[o]=`${t}/${s}`:r[o]=Pn(s,t);return r}return e}function Io(e,t=ol.warn){let n=[];for(let{pkg:o,manifest:s}of e)for(let i of s.modules??[]){let a=Pn(i,o);typeof i.path=="string"&&(a.path=`${o}/${i.path}`),n.push(a)}let r=new Set(e.map(o=>o.manifest.schemaVersion).filter(Boolean));return r.size>1&&t(`Merging mixed CEM schema versions: ${[...r].join(", ")}`),{schemaVersion:e[0]?.manifest.schemaVersion??"1.0.0",modules:n}}async function jo(e,t={}){let n=await Promise.all(e.map(i=>_(i,t))),r=[];for(let i of n)i.manifest&&r.push({pkg:i.target,manifest:i.manifest});let{skipped:o,transientFailures:s}=No(n);return{manifest:Io(r),sources:r,skipped:o,transientFailures:s}}async function ll(e){let t=cl(`Fetching manifests for ${j.length} components...`).start(),{manifest:n,sources:r,skipped:o,transientFailures:s}=await jo(j,{preferLocal:!1});r.length===0&&(t.fail("No component manifests could be fetched."),ht.exit(1));let i=il.resolve(ht.cwd(),e.output);try{await sl(i,`${JSON.stringify(n,null,2)}
|
|
67
|
+
`,"utf-8")}catch(a){let c=a instanceof Error?a.message:String(a);t.fail(`Failed to write ${e.output}: ${c}`),ht.exit(1)}t.succeed(`Aggregated ${r.length}/${j.length} component manifests (${n.modules?.length??0} modules) to ${e.output}`);for(let a of o)a.transient||_o.info(`Skipped ${a.target}: ${a.reason}`);s.length>0&&(_o.error(`${s.length} component(s) failed to fetch transiently; the aggregate may be incomplete. Re-run to retry.`),ht.exit(1))}var Ny=al.command("cem").description("Fetch every published Auro component's custom-elements.json and merge them into a single aggregated manifest").option("-o, --output <file>","Path to write the aggregated manifest","custom-elements.aggregate.json").action(ll);import{readFileSync as ts}from"node:fs";import{dirname as ns,join as vu,resolve as Jn}from"node:path";import xt from"node:process";import{program as $u}from"commander";import Eu from"ora";import{mkdtempSync as ul,rmSync as ml}from"node:fs";import{tmpdir as dl}from"node:os";import{join as pl}from"node:path";function Nn(e){return e.replace(/(['"`])(?:\\.|(?!\1)[\s\S])*\1/gu," ")}function On(e){let t={")":"(","]":"[","}":"{",">":"<"},n=[],r="";for(let o of Nn(e)){if(o===">"&&r==="="){r=o;continue}if(o==="("||o==="["||o==="{"||o==="<")n.push(o);else if((o===")"||o==="]"||o==="}"||o===">")&&n.pop()!==t[o])return!1;r=o}return n.length===0}function Mn(e){let t=e.type?.text;if(typeof t=="string"&&t!==""&&!On(t)){let{type:n,...r}=e;return r}return e}function In(e,t){let{fieldName:n,description:r}=e;if(typeof n!="string"||n===""||typeof r=="string"&&r!=="")return!1;if(!t.has(n))return!0;let o=t.get(n);return o==="private"||o==="protected"}function fl(e){let t=o=>typeof o.name=="string",n=e.members?.filter(t).map(Mn),r=new Map((n??[]).map(o=>[o.name,o.privacy]));return{...e,...n&&{members:n},...e.attributes&&{attributes:e.attributes.filter(t).filter(o=>!In(o,r)).map(Mn)},...e.slots&&{slots:e.slots.filter(t)},...e.events&&{events:e.events.filter(t).map(Mn)},...e.cssParts&&{cssParts:e.cssParts.filter(t)},...e.cssProperties&&{cssProperties:e.cssProperties.filter(t)}}}function jn(e,t){return t.get(e.tagName)??e.tagName}function Lo(e){return new Map(e.map(t=>[t.declaration.name,t.importPath]))}function be(e,t){return{schemaVersion:"1.0.0",modules:e.map(n=>{let r=fl({...n.declaration,tagName:t?jn(n,t):n.tagName});return{kind:"javascript-module",path:n.importPath,declarations:[r],exports:[{kind:"js",name:r.name,declaration:{name:r.name,module:n.importPath}}]}})}}function Y(e){let t=ul(pl(dl(),"auro-editors-"));try{return e(t)}finally{try{ml(t,{recursive:!0,force:!0,maxRetries:10,retryDelay:100})}catch{}}}function X(e){return e.endsWith(`
|
|
68
68
|
`)?e:`${e}
|
|
69
|
-
`}var
|
|
69
|
+
`}var gl=` /** Identifies the currently active descendant of a composite widget. */
|
|
70
70
|
"aria-activedescendant"?: string;
|
|
71
71
|
/** Whether assistive technologies present all, or only parts of, changed regions. */
|
|
72
72
|
"aria-atomic"?: boolean | "true" | "false";
|
|
@@ -174,19 +174,19 @@ ${s.map(c=>` - ${c.replace("@aurodesignsystem","AlaskaAirlines").replace("@alas
|
|
|
174
174
|
"aria-valuetext"?: string;
|
|
175
175
|
/** Custom data-* attributes for the element. */
|
|
176
176
|
[key: \`data-\${string}\`]: string | number | boolean | null | undefined;
|
|
177
|
-
`,
|
|
177
|
+
`,Fo=/(type BaseProps(?:<[^>]*>)? = \{\n)/,hl=` /** Defines the element's semantic role for accessibility APIs. */
|
|
178
178
|
role?: string;
|
|
179
179
|
/** The position of the element in the sequential keyboard navigation order. */
|
|
180
180
|
tabindex?: number;
|
|
181
|
-
`;function
|
|
181
|
+
`;function yt(e,{svelteGlobals:t}){if(!Fo.test(e))throw new Error("the JSX/Svelte generator no longer emits a recognizable `type BaseProps = {` block; the global-attribute injection in manifest.ts must be updated to match.");let n=`${t?hl:""}${gl}`;return e.replace(Fo,`$1${n}`)}function _n(e){let t=[];for(let n of e)n.source==="local"&&n.manifest&&n.version&&t.push({pkg:n.target,version:n.version,manifest:n.manifest});return t}async function Bo(e=j){let t=await Promise.all(e.map(n=>_(n,{allowNetwork:!1})));return _n(t)}function Fn(e){return(e.modules??[]).flatMap(t=>t.declarations??[]).filter(t=>t.customElement&&t.tagName)}function Ln(e){let t=[],n=new Map,r=new Set;for(let{pkg:s,version:i,manifest:a}of e){let c=Fn(a),l=c.length>1;for(let u of c){let m=u.tagName,d=n.get(m);d?d.includes(s)||d.push(s):n.set(m,[s]),!r.has(m)&&(r.add(m),t.push({pkg:s,version:i,tagName:m,declaration:u,importPath:l?`${s}/${m}`:s,isMonorepo:l}))}}let o=[];for(let[s,i]of n)i.length>1&&o.push({tagName:s,packages:i});return{components:t,duplicates:o}}async function Go(e){let t=await Bo(e);return Ln(t)}var yl=new Set(["variant","shape","size","type","appearance"]),bl=new Set(["string","String","any"]),wl=new Map([["array","use `unknown[]`, `T[]`, or `Array<T>`"],["function","use `Function` or an explicit call signature `(\u2026) => \u2026`"]]),kl=new Map([["Array","Array<T>"],["ReadonlyArray","ReadonlyArray<T>"],["Promise","Promise<T>"],["Map","Map<K, V>"],["WeakMap","WeakMap<K, V>"],["Set","Set<T>"],["WeakSet","WeakSet<T>"],["Record","Record<K, V>"]]),vl=new Set(["object","Object"]),$l=[...wl].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*:)`,"u")})),El=[...kl].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*[<:])`,"u")}));function Wo(e,t){return e===t?`\`type.text\` is \`${t}\``:`\`type.text\` (${JSON.stringify(e)}) uses \`${t}\``}var Sl=[/^[\s>*_~([-]*@?deprecated\b/iu,/[([]\s*deprecated\b/iu,/\*\*\s*deprecated\b/iu,/@deprecated\b/iu];function Vo(...e){return e.some(t=>typeof t=="string"&&Sl.some(n=>n.test(t.trim())))}function zo(e){return e===!0||We(e)}function Uo(e,t,n,r){!zo(r.deprecated)&&Vo(r.description,r.summary)&&e.push({rule:"deprecated-prose-unflagged",severity:"warn",element:t,path:n,message:"described as deprecated but missing the `deprecated` field \u2014 add an `@deprecated` JSDoc tag so the generated JSX/Svelte types surface it with a strikethrough. (VS Code HTML custom-data has no deprecation field, so vanilla-HTML editors won't show it.)"})}function Ho(e,t,n,r,o){!zo(o.deprecated)&&Vo(o.description,o.summary)&&e.push({rule:"deprecated-prose-unsupported",severity:"warn",element:t,path:r,message:`this ${n} reads as deprecated in prose, but the analyzer (v0.11.0) does not emit a \`deprecated\` field for inline \`@${n}\` tags \u2014 editors cannot surface it. Track upstream or a mapping plugin; suppress this warning if the prose is intentional.`})}function bt(e,t,n,r){r.deprecated===!0&&e.push({rule:"deprecated-no-detail",severity:"warn",element:t,path:n,message:"`deprecated` is set but carries no message \u2014 editors show a strikethrough with no migration target. Prefer `@deprecated <what to use instead>`."})}function We(e){return typeof e=="string"&&e!==""}function we(e,t,n,r){r?.forEach((o,s)=>{typeof o.name!="string"&&e.push({rule:"name-required",severity:"error",element:t,path:`${n}[${s}].name`,message:`${n}[${s}] has no string \`name\` \u2014 community generators call \`.name.startsWith(\u2026)\` and throw mid-generation.`})})}function Bn(e,t,n,r){let o=r.type?.text;typeof o=="string"&&o!==""&&!On(o)&&e.push({rule:"type-parseable",severity:"error",element:t,path:`${n}.type.text`,message:`\`type.text\` has unbalanced delimiters: ${JSON.stringify(o)} \u2014 the generated \`.d.ts\` would not parse.`})}function Gn(e,t,n,r){let o=r.type?.text;if(typeof o!="string")return;let s=o.trim();if(s==="")return;let i=Nn(s);for(let{token:a,re:c,fix:l}of $l)if(c.test(i)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${n}.type.text`,message:`${Wo(s,a)}, which is not a TypeScript type \u2014 ${l}. The generated \`.d.ts\` would not compile.`});return}for(let{token:a,re:c,fix:l}of El)if(c.test(i)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${n}.type.text`,message:`${Wo(s,a)}, a generic that requires a type argument \u2014 write \`${l}\`. The generated \`.d.ts\` would not compile.`});return}vl.has(s)&&e.push({rule:"type-imprecise",severity:"warn",element:t,path:`${n}.type.text`,message:`\`type.text\` is \`${s}\` \u2014 a valid type, but it exposes no properties so nothing completes. Prefer an explicit shape (e.g. \`{ id: string }\`).`})}function xl(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r--)n++;return n%2===1}function Al(e){let t=[],n=0,r=null,o=0;for(let s=0;s<e.length;s++){let i=e[s];r!==null?i===r&&!xl(e,s)&&(r=null):i==='"'||i==="'"||i==="`"?r=i:i==="("||i==="["||i==="{"||i==="<"?n++:i===")"||i==="]"||i==="}"?n--:i===">"?s>0&&e[s-1]!=="="&&n--:i==="|"&&n===0&&(t.push(e.slice(o,s).trim()),o=s+1)}return t.push(e.slice(o).trim()),t.filter(s=>s!=="")}function Cl(e){return/^(['"`]).*\1$/u.test(e)}function Tl(e,t,n,r){let o=r.type?.text?.trim();if(typeof o!="string"||!o.includes("|"))return;let s=Al(o),i=s.some(Cl),a=s.some(c=>c==="string"||c==="String");i&&a&&e.push({rule:"union-widened-by-string",severity:"warn",element:t,path:`${n}.type.text`,message:`\`type.text\` (${JSON.stringify(o)}) unions string literals with a bare \`string\`, which widens the whole type back to \`string\` \u2014 drop the \`string\` member so the literals validate and complete.`})}function Jo(e){return typeof e!="string"||e.trim()===""}function Wn(e,t,n,r,o){Jo(o.description)&&Jo(o.summary)&&e.push({rule:"missing-description",severity:"warn",element:t,...r===void 0?{}:{path:r},message:`${n} has no description or summary \u2014 editors show no hover documentation for it. Add a JSDoc description.`})}function Rl(e,t){let n=We(t.tagName)?t.tagName:"<unknown>";typeof t.name!="string"&&e.push({rule:"name-required",severity:"error",element:n,path:"name",message:"registered element has no string `name` \u2014 its generated import/export identity is undefined."}),Wn(e,n,"this component",void 0,t);let r=t.members??[],o=t.attributes??[],s=t.events??[],i=t.slots??[];we(e,n,"members",r),we(e,n,"attributes",o),we(e,n,"slots",t.slots),we(e,n,"events",s),we(e,n,"cssParts",t.cssParts),we(e,n,"cssProperties",t.cssProperties),r.forEach((c,l)=>{Bn(e,n,`members[${l}]`,c),Gn(e,n,`members[${l}]`,c),Uo(e,n,`members[${l}]`,c),bt(e,n,`members[${l}]`,c)}),o.forEach((c,l)=>{Bn(e,n,`attributes[${l}]`,c),Gn(e,n,`attributes[${l}]`,c),Tl(e,n,`attributes[${l}]`,c),Wn(e,n,"attribute",`attributes[${l}]`,c),Uo(e,n,`attributes[${l}]`,c),bt(e,n,`attributes[${l}]`,c)}),s.forEach((c,l)=>{Bn(e,n,`events[${l}]`,c),Gn(e,n,`events[${l}]`,c),Wn(e,n,"event",`events[${l}]`,c),Ho(e,n,"event",`events[${l}]`,c),bt(e,n,`events[${l}]`,c)}),i.forEach((c,l)=>{Ho(e,n,"slot",`slots[${l}]`,c),bt(e,n,`slots[${l}]`,c)});let a=new Map(r.filter(c=>typeof c.name=="string").map(c=>[c.name,c.privacy]));o.forEach((c,l)=>{We(c.name)&&/[A-Z]/u.test(c.name)&&e.push({rule:"attribute-name-not-lowercase",severity:"warn",element:n,path:`attributes[${l}].name`,message:`attribute \`${c.name}\` has uppercase letters \u2014 HTML lowercases attribute names, so it never binds as written. Use \`${c.name.toLowerCase()}\` (the camelCase property name belongs in \`fieldName\`).`}),We(c.name)&&yl.has(c.name)&&bl.has(c.type?.text?.trim()??"")&&e.push({rule:"enumerated-union",severity:"warn",element:n,path:`attributes[${l}].type.text`,message:`\`${c.name}\` is typed as bare \`${JSON.stringify(c.type?.text??"")}\` \u2014 an enumerated attribute should carry a string-literal union (e.g. \`"primary" | "secondary"\`) so values validate and complete.`}),In(c,a)&&e.push({rule:"private-reflection",severity:"warn",element:n,path:`attributes[${l}]`,message:`\`${c.name??"<unnamed>"}\` reflects a private/omitted member and has no description \u2014 it leaks into editor autocomplete as a settable attribute (add a description if it is genuinely public).`})})}function Ko(e){let t=[];We(e.schemaVersion)||t.push({rule:"schema-version",severity:"warn",message:"manifest has no `schemaVersion` \u2014 declare the CEM schema version it targets."});for(let n of Fn(e))Rl(t,n);return t}import{execFileSync as Vl}from"node:child_process";import{mkdirSync as Hn,writeFileSync as Et}from"node:fs";import{createRequire as zl}from"node:module";import{dirname as Kl,join as ke}from"node:path";import ql from"node:process";import{generateJsxTypes as Pl}from"@wc-toolkit/jsx-types";var T=".vscode",ue="settings.json",qo="auro.html-custom-data.json",P="html.customData",J=`./${T}/${qo}`,me=`${T}/${qo}`,Dl="auro.code-snippets",wt=`${T}/${Dl}`,Ue="auro-types",Un="auro-jsx.d.ts",kt="auro-svelte.d.ts",de=`${Ue}/${Un}`,pe=`${Ue}/${kt}`,M="include",V=Ue;function vt(e,t){let n=be(e),r=Lo(e),o=Y(s=>Pl(n,{outdir:s,fileName:Un,tagFormatter:i=>t.get(i)??i,componentTypePath:i=>r.get(i)??i,useCemTypes:!0,includeDefaultDOMEvents:!0}));if(typeof o!="string")throw new Error("JSX type generation returned no output for the resolved components.");return{filename:de,contents:X(yt(o,{svelteGlobals:!1}))}}import{readFileSync as Ml}from"node:fs";import{join as Nl}from"node:path";import{generateSvelteTypes as Ol}from"custom-element-svelte-integration";var Yo=`declare namespace svelteHTML {
|
|
182
182
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
183
183
|
interface IntrinsicElements extends CustomElements {}
|
|
184
|
-
}`,
|
|
184
|
+
}`,Il=`declare global {
|
|
185
185
|
namespace svelteHTML {
|
|
186
186
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
187
187
|
interface IntrinsicElements extends CustomElements {}
|
|
188
188
|
}
|
|
189
|
-
}`,
|
|
189
|
+
}`,jl=`
|
|
190
190
|
// Mouse events
|
|
191
191
|
"on:click"?: (e: MouseEvent) => void;
|
|
192
192
|
"on:contextmenu"?: (e: MouseEvent) => void;
|
|
@@ -234,32 +234,32 @@ ${s.map(c=>` - ${c.replace("@aurodesignsystem","AlaskaAirlines").replace("@alas
|
|
|
234
234
|
"on:copy"?: (e: ClipboardEvent) => void;
|
|
235
235
|
"on:cut"?: (e: ClipboardEvent) => void;
|
|
236
236
|
"on:paste"?: (e: ClipboardEvent) => void;
|
|
237
|
-
`,
|
|
238
|
-
${n}"on${r}"${o}`)}var
|
|
239
|
-
${
|
|
240
|
-
};`})}function
|
|
237
|
+
`,_l=/^([ \t]*)"on:([^"]+)"(\?:.*=> void;)$/gmu;function Fl(e){return e.replace(_l,(t,n,r,o)=>`${n}"on:${r}"${o}
|
|
238
|
+
${n}"on${r}"${o}`)}var Ll=/^(\s*"[^"]+": Partial<)(\w+)Props & BaseProps & BaseEvents(>;)$/gm;function Bl(e){let t=!1,n=e.replace(Ll,(r,o,s,i)=>(t=!0,`${o}Omit<${s}Props, keyof BaseProps> & BaseProps & Omit<BaseEvents, keyof ${s}Props>${i}`));if(!t)throw new Error("custom-element-svelte-integration no longer emits the expected `Partial<<Name>Props & BaseProps & BaseEvents>` element mapping; the base-member collision rewrite in svelteTypes.ts must be updated to match the new output.");return n}var Gl=/^type (\w+)Props = \{\n([\s\S]*?)\n\};$/gm,Wl=/\/\*\* /g;function Ul(e,t){return e.replace(Gl,(n,r,o)=>{let s=t.get(r);if(s===void 0)return n;let i=o.replace(Wl,`/** \u3010${s}\u3011 `);return`type ${r}Props = {
|
|
239
|
+
${i}
|
|
240
|
+
};`})}function Hl(e,t){return new Map(e.map(n=>{let r=n.tagName,o=t.get(r)??r,s=o===r?n.declaration.name:o;return[n.declaration.name,s]}))}function Jl(e){if(!e.includes(Yo))throw new Error("custom-element-svelte-integration no longer emits the expected `declare namespace svelteHTML` block; the global-augmentation rewrite in svelteTypes.ts must be updated to match the new output.");return e.replace(Yo,Il)}function $t(e,t){let n=be(e,t),r=Hl(e,t),o=Y(s=>(Ol(n,{outdir:s,fileName:kt,hideLogs:!0,globalEvents:jl}),Ml(Nl(s,kt),"utf-8")));return{filename:pe,contents:X(Jl(Bl(yt(Fl(Ul(o,r)),{svelteGlobals:!0}))))}}var Yl=zl(import.meta.url),Xl=Yl.resolve("typescript/bin/tsc"),Zl=`declare namespace JSX {
|
|
241
241
|
type Element = unknown;
|
|
242
242
|
interface CSSProperties {}
|
|
243
243
|
}
|
|
244
|
-
`;function
|
|
245
|
-
${
|
|
244
|
+
`;function Ql(e){return`${e.replace(/[^a-zA-Z0-9]+/gu,"_")}.d.ts`}function eu(e){let t=new Map,n=/^[ \t]*import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/gmu;for(let r of e.matchAll(n)){let o=r[1].split(",").map(i=>i.trim().split(/\s+as\s+/u)[0].trim()).filter(Boolean);if(o.length===0)continue;let s=t.get(r[2])??new Set;for(let i of o)s.add(i);t.set(r[2],s)}return t}function Xo(e,t,n){Et(ke(e,"tsconfig.json"),JSON.stringify({compilerOptions:{noEmit:!0,skipLibCheck:!1,strict:!1,strictFunctionTypes:!0,target:"ES2020",module:"ESNext",moduleResolution:"bundler",...n&&{baseUrl:".",paths:n},lib:["ES2020","DOM"],types:[]},include:t},null,2),"utf-8")}function tu(e,t){let n=ke(e,t.filename);Hn(Kl(n),{recursive:!0}),Et(n,t.contents,"utf-8")}function Zo(e,t,n){return Y(r=>{tu(r,t),n(r);try{return Vl(ql.execPath,[Xl,"-p","tsconfig.json"],{cwd:r,stdio:"pipe"}),null}catch(o){let s=o,i=`${s.stdout?.toString()??""}${s.stderr?.toString()??""}`;return{rule:"generation-smoke",severity:"error",element:e,message:`the generated ${e} \`.d.ts\` does not type-check \u2014 this CEM breaks the editor tooling:
|
|
245
|
+
${i.trim()}`}}})}function Qo(e){if(e.length===0)return[];let t=new Map(e.map(r=>[r.tagName,r.tagName])),n=[];try{let r=vt(e,t),o=eu(r.contents),s=Zo("JSX",r,i=>{Hn(ke(i,"stubs"),{recursive:!0});let a={},c=[r.filename];for(let[l,u]of o){let m=Ql(l);Et(ke(i,"stubs",m),`${[...u].map(d=>`export declare class ${d} extends HTMLElement {}`).join(`
|
|
246
246
|
`)}
|
|
247
|
-
`,"utf-8"),a[l]=[`./stubs/${m}`],c.push(`stubs/${m}`)}
|
|
248
|
-
`).map(a=>a.replace(/^\s*\*?\s?/u,"").trimEnd()),following:e.slice(
|
|
249
|
-
`),
|
|
250
|
-
`)[0].trim();
|
|
251
|
-
`):[]}var
|
|
247
|
+
`,"utf-8"),a[l]=[`./stubs/${m}`],c.push(`stubs/${m}`)}Xo(i,c,a)});s&&n.push(s)}catch(r){n.push({rule:"generation-build",severity:"error",element:"JSX",message:`JSX type generation threw for this CEM: ${r.message}`})}try{let r=$t(e,t),o=Zo("Svelte",r,s=>{Hn(ke(s,"stubs"),{recursive:!0}),Et(ke(s,"stubs","jsx-shim.d.ts"),Zl,"utf-8"),Xo(s,[r.filename,"stubs/jsx-shim.d.ts"])});o&&n.push(o)}catch(r){n.push({rule:"generation-build",severity:"error",element:"Svelte",message:`Svelte type generation threw for this CEM: ${r.message}`})}return n}import{readFileSync as nu}from"node:fs";import{resolve as ru}from"node:path";var ou=/\/\*\*(?!\/)([\s\S]*?)\*\//gu,su=/\.[cm]?[jt]s$/u,iu=400;function au(e,t){let n=1;for(let r=0;r<t;r++)e.charCodeAt(r)===10&&n++;return n}function cu(e){let t=[...e.matchAll(ou)];return t.map((n,r)=>{let o=n.index??0,s=o+n[0].length,i=t[r+1]?.index??e.length;return{line:au(e,o),lines:(n[1]??"").split(`
|
|
248
|
+
`).map(a=>a.replace(/^\s*\*?\s?/u,"").trimEnd()),following:e.slice(s,Math.min(i,s+iu))}})}var lu=/^@default\s+false$/u,uu=/^@type\s+\{\s*boolean\s*\}/iu,mu=[/^\s*[\w$]+\s*:\s*\{[^}]*?\btype\s*:\s*Boolean\b/u,/^\s*@property\(\s*\{[^}]*?\btype\s*:\s*Boolean\b/u];function du(e){return e.lines.some(t=>uu.test(t))||mu.some(t=>t.test(e.following))}function pu(e,t,n){let r=n.lines.findIndex(o=>lu.test(o.trim()));r===-1||!du(n)||e.push({rule:"redundant-boolean-default",severity:"warn",path:`${t}:${n.line+r}`,message:"`@default false` on a boolean property is redundant \u2014 a boolean that isn't set is already off, and the manifest picks up a constructor's `false` on its own. Remove the tag (content guidelines \u203A Defaults)."})}var fu=new Set(["category","customElement","default","forcePrivate","internal","maximum","minimum","private","relevantWhen","requiredWhen","see","type"]),gu=[/`[^`]*`/gu,/\bhttps?:\/\/\S+/gu,/\{@[^}]*\}/gu];function hu(e){let t=[],n=!1,r=!1;return e.lines.forEach((o,s)=>{let i=o.trim();if(i.startsWith("```")){r=!r;return}let a=/^@(\w+)/u.exec(i)?.[1];a!==void 0&&(n=a==="example",n||fu.has(a))||r||n||i===""||t.push({index:s,text:gu.reduce((c,l)=>c.replace(l," "),i)})}),t}function St(e,t,n,r,o,s){e.push({rule:o,severity:"warn",path:`${t}:${n.line+r.index}`,message:s})}var yu=[{pattern:/\be\.g\./iu,message:'uses "e.g." \u2014 write "for example" or "such as". Some tools also end the summary at its first period (content guidelines \u203A Word choices).'},{pattern:/\bi\.e\./iu,message:'uses "i.e." \u2014 write "that is". Some tools also end the summary at its first period (content guidelines \u203A Word choices).'},{pattern:/\bHTML5\b/u,message:'uses "HTML5" \u2014 name the element instead, such as "the inner `<button>` element" (content guidelines \u203A Word choices).'},{pattern:/\ba11y\b/iu,message:'uses "a11y" \u2014 write "accessibility", or name the people affected, such as "screen reader users" (content guidelines \u203A Word choices).'}],bu=/^(?:This (?:property|attribute|Boolean|boolean)\b|Used to\b)/u;function wu(e){return e.flatMap((t,n)=>{if(t.text.startsWith("@")){let r=t.text.indexOf(" - ");return r===-1?[]:[{index:t.index,text:t.text.slice(r+3).trim()}]}return n===0?[t]:[]})}function ku(e,t,n){let r=hu(n);for(let o of r){for(let{pattern:s,message:i}of yu)s.test(o.text)&&St(e,t,n,o,"word-choice",i);o.text.includes(" \u2014 ")&&St(e,t,n,o,"spaced-em-dash",'has a spaced em dash (" \u2014 ") \u2014 use a colon or a new sentence, or an em dash with no spaces (content guidelines \u203A Formatting \u203A Dashes).'),/\bDEPRECATED\b/u.test(o.text)&&St(e,t,n,o,"deprecated-casing",'writes "DEPRECATED" in capitals \u2014 use "Deprecated:" in sentence case, followed by what to use instead (content guidelines \u203A Deprecations).')}for(let o of wu(r))bu.test(o.text)&&St(e,t,n,o,"filler-opener",'starts with filler ("This property \u2026" or "Used to \u2026") \u2014 start with a verb that says what it does, such as "Sets the \u2026" (content guidelines \u203A Structure \u203A No filler openers).')}function es(e,t){let n=[],r=new Set;for(let o of e.modules??[]){let s=o.path;if(typeof s!="string"||!su.test(s)||r.has(s))continue;r.add(s);let i;try{i=nu(ru(t,s),"utf-8")}catch{continue}for(let a of cu(i))pu(n,s,a),ku(n,s,a)}return n}function Su(e){try{let t=ts(vu(ns(Jn(e)),"package.json"),"utf-8"),n=JSON.parse(t);return{pkg:typeof n.name=="string"?n.name:"cem-check-subject",version:typeof n.version=="string"?n.version:"0.0.0"}}catch{return{pkg:"cem-check-subject",version:"0.0.0"}}}function xu(e){let t=e.severity==="error"?"\u2716":"\u26A0",n=[e.element,e.path].filter(Boolean).join(" "),r=n?` ${n}`:"";return`${t} [${e.rule}]${r}: ${e.message}`}var Au="custom-elements.json";async function Cu(e=Au,t={}){let n=t.json?null:Eu(`Checking ${e} against the CEM contract...`).start(),r=h=>{n?n.fail(h):console.error(h),xt.exit(1)},o;try{o=JSON.parse(ts(Jn(e),"utf-8"))}catch(h){r(`Could not read or parse ${e}: ${h.message}`)}(typeof o!="object"||o===null||Array.isArray(o))&&r(`Could not read or parse ${e}: not a CEM object.`);let s=o,{pkg:i,version:a}=Su(e),c=[{pkg:i,version:a,manifest:s}],{components:l}=Ln(c),u=[...Ko(s),...Qo(l),...es(s,ns(Jn(e)))],m=u.filter(h=>h.severity==="error"),d=u.filter(h=>h.severity==="warn"),p=m.length>0||!!t.strict&&d.length>0;if(t.json){xt.stdout.write(`${JSON.stringify(u,null,2)}
|
|
249
|
+
`),p&&xt.exit(1);return}let f=`${m.length} error${m.length===1?"":"s"}, ${d.length} warning${d.length===1?"":"s"}`;p?n?.fail(`CEM contract failed \u2014 ${f}.`):d.length>0?n?.warn(`CEM contract passed with warnings \u2014 ${f}.`):n?.succeed("CEM contract clean \u2014 no violations.");for(let h of[...m,...d])console.error(xu(h));p&&xt.exit(1)}var xb=$u.command("cem-check [path]").description("Validate a custom-elements.json against the CEM contract (structural + parseability rules, an end-to-end generation smoke, and documentation rules on the JSDoc in the source files it lists). Defaults to ./custom-elements.json.").option("--json","Output the findings as a JSON array on stdout",!1).option("--strict","Treat warnings as errors (any finding fails)",!1).action(Cu);import ir from"node:process";import{program as hm}from"commander";import ym from"ora";var ve={none:0,patch:1,minor:2,major:3};function rs(e){let t="none";for(let n of e)ve[n]>ve[t]&&(t=n);return t}function os(e,t){return ve[e]<ve[t]?"fail":t==="none"&&e!=="none"?"warn":"pass"}function ss(e){let t=new Set;return e.map((n,r)=>({change:n,index:r})).sort((n,r)=>ve[r.change.bump]-ve[n.change.bump]||n.index-r.index).map(({change:n})=>n).filter(n=>t.has(n.message)?!1:(t.add(n.message),!0))}import{existsSync as Tu,readFileSync as zn}from"node:fs";import{createRequire as cs}from"node:module";import{join as At}from"node:path";import{pathToFileURL as Ru}from"node:url";var Ct="@semantic-release/commit-analyzer",Vn={preset:"conventionalcommits",releaseRules:[{type:"docs",scope:"README",release:"patch"},{type:"refactor",release:"patch"},{type:"style",release:"patch"}]};function Du(e){for(let t of[".releaserc",".releaserc.json"]){let n=At(e,t);if(Tu(n))try{return{config:JSON.parse(zn(n,"utf-8")),file:t}}catch{}}try{let t=JSON.parse(zn(At(e,"package.json"),"utf-8"));if(t.release&&typeof t.release=="object")return{config:t.release,file:"package.json#release"}}catch{}return null}function is(e){for(let t of e??[]){if(t===Ct)return{};if(Array.isArray(t)&&t[0]===Ct)return t[1]??{}}return null}function ls(e){let t=Du(e);if(!t)return{options:Vn,source:"default"};let n=is(t.config.plugins);if(n)return{options:n,source:t.file};if(t.config.plugins)return{options:Vn,source:"default"};let r=cs(At(e,"package.json")),o=[t.config.extends??[]].flat().reverse();for(let s of o)try{let i=r.resolve(s),a=JSON.parse(zn(i,"utf-8")),c=is(a.plugins);if(c)return{options:c,source:s}}catch{}return{options:Vn,source:"default"}}async function Pu(e){let t;try{t=cs(At(e,"package.json")).resolve(Ct)}catch{throw new Error(`${Ct} isn't installed in ${e}. The declared bump is read with the repo's own analyzer, so the check matches the release; run \`npm ci\` first.`)}return(await import(Ru(t).href)).analyzeCommits}var Mu={log:()=>{}};function as(e){return e==="major"||e==="minor"||e==="patch"?e:"none"}function Nu(e){let t=/^(\w+)(?:\([^)]*\))?(!?):/u.exec(e);return t?`${t[1]}${t[2]}`:null}async function us(e,t,n){if(e.length===0)return{bump:"none",commits:[]};let r=await Pu(n),o={cwd:n,logger:Mu},s=as(await r(t.options,{...o,commits:e})),i=[];for(let a of[...e].reverse()){let c=a.message.split(`
|
|
250
|
+
`)[0].trim();i.push({hash:a.hash,subject:c,type:Nu(c),bump:as(await r(t.options,{...o,commits:[a]}))})}return{bump:s,commits:i}}import{execFile as Ou,execFileSync as Iu,spawn as ju}from"node:child_process";import{existsSync as ds,rmSync as _u}from"node:fs";import{mkdtemp as Fu,readFile as Yn,rm as Lu}from"node:fs/promises";import{constants as Bu,tmpdir as Gu}from"node:os";import{join as z}from"node:path";import{promisify as Wu}from"node:util";var Uu=Wu(Ou);async function fe(e,t){let{stdout:n}=await Uu("git",t,{cwd:e,maxBuffer:67108864});return n.trim()}function Xn(e,t){return fe(e,["rev-parse","--verify",`${t}^{commit}`])}function ps(e,t,n){return fe(e,["merge-base",t,n])}async function Rt(e,t,n){try{return await fe(e,["show",`${t}:${n}`])}catch{return null}}async function fs(e,t,n){let r=await fe(e,["diff","--name-only","--no-renames",t,n]);return r?r.split(`
|
|
251
|
+
`):[]}var Hu=/^Merge (pull request|branch|remote-tracking branch) /u;async function gs(e,t,n){return(await fe(e,["log","--no-merges","--format=%H%x1f%B%x1e",`${t}..${n}`])).split("").map(o=>o.trim()).filter(Boolean).map(o=>{let[s,i=""]=o.split("");return{hash:s.trim(),message:i.trim()}}).filter(o=>!Hu.test(o.message))}var He=new Map,Tt=new Set,hs=["SIGINT","SIGTERM"];function ys(e){for(let t of Tt)Ju(t);for(let[t,n]of He){try{Iu("git",["worktree","remove","--force",t],{cwd:n,stdio:"ignore"})}catch{}_u(t,{recursive:!0,force:!0})}process.exit(128+(Bu.signals[e]??0))}var bs=process.platform!=="win32";function Ju(e){try{bs&&e.pid?process.kill(-e.pid,"SIGKILL"):e.kill("SIGKILL")}catch{}}function Vu(e,t){if(He.size===0)for(let n of hs)process.on(n,ys);He.set(e,t)}function zu(e){if(He.delete(e),He.size===0)for(let t of hs)process.off(t,ys)}function Kn(e,t){return new Promise((n,r)=>{let o=ju(e,{cwd:t,shell:!0,detached:bs,stdio:["ignore","pipe","pipe"],env:{...process.env,HUSKY:"0"}});Tt.add(o);let s=[];o.stdout?.on("data",i=>s.push(String(i))),o.stderr?.on("data",i=>s.push(String(i))),o.on("error",i=>{Tt.delete(o),r(i)}),o.on("close",i=>{if(Tt.delete(o),i===0){n();return}let a=s.join("").trim().split(`
|
|
252
252
|
`).slice(-20).join(`
|
|
253
|
-
`);r(new Error(`\`${e}\` exited with ${
|
|
254
|
-
${a}`))})})}var Ct="@aurodesignsystem/auro-cli",Un="@custom-elements-manifest/analyzer";function Gn(e,t){for(let n of[J(e,"node_modules",t),J(e,"node_modules",Ct,"node_modules",t)])if(ns(J(n,"package.json")))return n;return null}async function ts(e,t){let n=Gn(e,t);if(n)return JSON.parse(await Bn(J(n,"package.json"),"utf-8")).version}function ls(e,t){return e.auroCli!==t.auroCli||e.analyzer!==t.analyzer}async function Ru(e){let t=await ts(e,Ct),n=await ts(e,Un);return t||n?{auroCli:t,analyzer:n}:null}async function Pu(e){if(JSON.parse(await Bn(J(e,"package.json"),"utf-8")).scripts?.analyze)return"npm run analyze";let n=Gn(e,Ct),r=Gn(e,Un),o=n?J(n,"dist","configs","custom-elements-manifest.config.mjs"):null;return!o||!ns(o)||!r?null:`node "${J(r,"cem.js")}" analyze --config "${o}"`}async function At(e,t,n,r,o){let i=await wu(J($u(),"auro-api-diff-"));xu(i,e);try{if(await me(e,["worktree","add","--detach","--force",i,t]),await Ln(r.install,i),o){let c=[o.auroCli&&`${Ct}@${o.auroCli}`,o.analyzer&&`${Un}@${o.analyzer}`].filter(Boolean);await Ln(`${r.pin} ${c.join(" ")}`,i)}let s=await Ru(i),a=o?await Pu(i):null;return await Ln(a??r.build,i),{manifest:JSON.parse(await Bn(J(i,n),"utf-8")),generator:s}}finally{await me(e,["worktree","remove","--force",i]).catch(()=>{}),await vu(i,{recursive:!0,force:!0}).catch(()=>{}),Tu(i)}}function us(e){let t=new Map;for(let n of e.modules??[])for(let r of n.declarations??[]){let{tagName:o}=r;o&&!t.has(o)&&t.set(o,{tagName:o,className:r.name,declaration:r})}return t}function we(e){return e.privacy===void 0||e.privacy==="public"}function Du(e){return e.static?`static ${e.name}`:e.name}function Hn(e){let t=e.kind==="field"?"property":e.kind;return e.static?`static ${t}`:t}function Tt(e){return e.replace(/['`]/gu,'"').replace(/\s+/gu," ").trim()}function Mu(e){let t=Tt(e),n=/^\{\s*("[^"]*"|-?\d+(?:\.\d+)?|true|false|null|undefined)\s*\}$/u.exec(t);return n?n[1]:t}function ms(e){let t=[],n=0,r=null,o="";for(let s of e){if(r)s===r&&(r=null);else if(s==='"'||s==="'"||s==="`")r=s;else if("([{<".includes(s))n++;else if(")]}>".includes(s)&&!(s===">"&&o.endsWith("=")))n--;else if((s==="|"||s===",")&&n===0){t.push(o),o="";continue}o+=s}t.push(o);let i={String:"string",Number:"number",Boolean:"boolean"};return t.map(Tt).filter(s=>s.length>0).map(s=>i[s]??s)}function Nu(e){return/^".*"$/u.test(e)?"string":/^-?\d+(?:\.\d+)?$/u.test(e)?"number":e==="true"||e==="false"?"boolean":null}function ps(e,t){let n=Nu(t);return e.includes(t)||n!==null&&e.includes(n)}function Jn(e,t,n){if(t===void 0||n===void 0)return null;let r=ms(t),o=ms(n),i=r.filter(c=>!ps(o,c)),s=o.filter(c=>!ps(r,c));if(i.length===0&&s.length===0)return null;let a=c=>c.map(l=>`\`${l}\``).join(", ");return i.length>0&&s.length>0?{bump:"major",source:"manifest",message:`Changed type of ${e} from \`${Tt(t)}\` to \`${Tt(n)}\``}:i.length>0?{bump:"major",source:"manifest",message:`Narrowed type of ${e} (removed ${a(i)})`}:{bump:"minor",source:"manifest",message:`Widened type of ${e} (added ${a(s)})`}}function gs(e,t,n){let r=s=>{let a=s===void 0?void 0:Mu(s);return a==="undefined"?void 0:a},o=r(t),i=r(n);return o===i?null:o===void 0?{bump:"minor",source:"manifest",message:`Added default \`${i}\` to ${e}`}:i===void 0?{bump:"minor",source:"manifest",message:`Removed default \`${o}\` from ${e}`}:{bump:"major",source:"manifest",message:`Changed default of ${e} from \`${o}\` to \`${i}\``}}function zn(e){return typeof e.name=="string"&&e.name!==""}function Vn(e,t,n){let r=[],o=(c,l)=>r.push({bump:c,source:"manifest",message:l}),i=t.requiredWhen,s=n.requiredWhen;i!==s&&(i===void 0?o("major",`Made ${e} required when \`${s}\``):s===void 0?o("minor",`Made ${e} no longer required`):i==="always"?o("minor",`Made ${e} required only when \`${s}\``):o("major",`Changed when ${e} is required from \`${i}\` to \`${s}\``));let a=(c,l)=>{let u=t[c],m=n[c];if(u===m)return;let p=c==="minimum"?"minimum":"maximum";u===void 0?o("major",`Added ${p} \`${m}\` to ${e}`):m===void 0?o("minor",`Removed ${p} \`${u}\` from ${e}`):l(m,u)?o("major",`Tightened ${p} of ${e} from \`${u}\` to \`${m}\``):o("minor",`Loosened ${p} of ${e} from \`${u}\` to \`${m}\``)};a("minimum",(c,l)=>c>l),a("maximum",(c,l)=>c<l),!t.readonly&&n.readonly?o("major",`Made ${e} read-only`):t.readonly&&!n.readonly&&o("minor",`Made ${e} writable`),!t.deprecated&&n.deprecated?o("minor",`Deprecated ${e}`):t.deprecated&&!n.deprecated&&o("minor",`Removed the deprecation of ${e}`);for(let c of["relevantWhen","category"]){let l=t[c],u=n[c];l!==u&&(l===void 0?o("minor",`Added \`${c}\` \`${u}\` to ${e}`):u===void 0?o("minor",`Removed \`${c}\` \`${l}\` from ${e}`):o("minor",`Changed \`${c}\` of ${e} from \`${l}\` to \`${u}\``))}return r}function Iu(e,t=[],n=[]){let r=[],o=(s,a)=>r.push({bump:s,source:"manifest",message:a}),i=s=>!!(s.optional||s.rest);for(let s=0;s<Math.max(t.length,n.length);s++){let a=t[s],c=n[s];if(a&&!c)o("major",`Removed parameter \`${a.name}\` from ${e}`);else if(!a&&c)o(i(c)?"minor":"major",`Added ${i(c)?"optional":"required"} parameter \`${c.name}\` to ${e}`);else if(a&&c){let l=`parameter \`${c.name}\` of ${e}`;i(a)&&!i(c)?o("major",`Made ${l} required`):!i(a)&&i(c)&&o("minor",`Made ${l} optional`);let u=Jn(l,a.type?.text,c.type?.text);u&&r.push(u)}}return r}function ds(e){let t=new Map;for(let n of e.members??[])zn(n)&&t.set(Du(n),n);return t}function fs(e,t){let n=new Map;for(let r of e.attributes??[]){let o=r.fieldName?t.get(r.fieldName):void 0;!zn(r)||r.internal||o&&!we(o)||n.set(r.name.toLowerCase(),r)}return n}function Ou(e,t,n){let r=[],o=`\`<${e}>\``;for(let[i,s]of t){if(!we(s))continue;let a=n.get(i),c=Hn(s);if(!a){r.push({bump:"major",source:"manifest",message:`Removed ${c} \`${s.name}\` from ${o}`});continue}if(!we(a)){r.push({bump:"major",source:"manifest",message:`Made ${c} \`${s.name}\` on ${o} ${a.privacy}`});continue}if(a.kind!==s.kind){r.push({bump:"major",source:"manifest",message:`Changed \`${s.name}\` on ${o} from a ${c} to a ${Hn(a)}`});continue}let l=`${c} \`${s.name}\` on ${o}`;if(r.push(...Vn(l,s,a)),s.kind==="method"&&r.push(...Iu(l,s.parameters,a.parameters)),s.kind==="field"){s.reflects&&!a.reflects&&r.push({bump:"major",source:"manifest",message:`Attribute \`${s.attribute??s.name}\` on ${o} no longer reflects`});for(let u of[Jn(l,s.type?.text,a.type?.text),gs(l,s.default,a.default)])u&&r.push(u)}}for(let[i,s]of n){if(!we(s))continue;let a=t.get(i),c=Hn(s);a?we(a)||r.push({bump:"minor",source:"manifest",message:`Made ${a.privacy} ${c} \`${s.name}\` on ${o} public`}):r.push({bump:"minor",source:"manifest",message:`Added ${c} \`${s.name}\` to ${o}`})}return r}function ju(e,t,n,r,o){let i=[],s=`\`<${e}>\``,a=fs(t,r),c=fs(n,o),l=d=>new Set((d.attributes??[]).filter(zn).map(f=>f.name.toLowerCase())),u=l(n),m=l(t),p=(d,f)=>{let h=d.fieldName?f.get(d.fieldName):void 0;return h!==void 0&&we(h)};for(let[d,f]of a){let{name:h}=f,g=c.get(d);if(!g){i.push({bump:"major",source:"manifest",message:u.has(d)?`Made attribute \`${h}\` on ${s} private`:`Removed attribute \`${h}\` from ${s}`});continue}if(p(f,r)||p(g,o))continue;let y=`attribute \`${h}\` on ${s}`;for(let v of[Jn(y,f.type?.text,g.type?.text),gs(y,f.default,g.default)])v&&i.push(v);i.push(...Vn(y,f,g))}for(let[d,{name:f}]of c)a.has(d)||i.push({bump:"minor",source:"manifest",message:m.has(d)?`Made private attribute \`${f}\` on ${s} public`:`Added attribute \`${f}\` to ${s}`});return i}function xt(e,t,n,r){let o=u=>t==="slot"&&u===""?"default slot":`${t} \`${u}\``,i=`\`<${e}>\``,s=u=>new Set((u??[]).map(m=>m.name).filter(m=>typeof m=="string")),a=s(n),c=s(r),l=[];for(let u of a)c.has(u)||l.push({bump:"major",source:"manifest",message:`Removed ${o(u)} from ${i}`});for(let u of c)a.has(u)||l.push({bump:"minor",source:"manifest",message:`Added ${o(u)} to ${i}`});return l}var _u=[{key:"slots",describe:(e,t)=>e===""?`default slot of \`<${t}>\``:`slot \`${e}\` on \`<${t}>\``},{key:"cssParts",describe:(e,t)=>`CSS part \`${e}\` on \`<${t}>\``},{key:"cssProperties",describe:(e,t)=>`CSS custom property \`${e}\` on \`<${t}>\``}];function Fu(e,t,n){return _u.flatMap(({key:r,describe:o})=>{let i=new Map((n[r]??[]).map(s=>[s.name,s]));return(t[r]??[]).flatMap(s=>{let a=i.get(s.name);return typeof s.name!="string"||!a?[]:Vn(o(s.name,e),s,a)})})}function Lu(e,t,n){let r=ds(t),o=ds(n);return[...Fu(e,t,n),...ju(e,t,n,r,o),...Ou(e,r,o),...xt(e,"event",t.events,n.events),...xt(e,"slot",t.slots,n.slots),...xt(e,"CSS part",t.cssParts,n.cssParts),...xt(e,"CSS custom property",t.cssProperties,n.cssProperties)]}function Kn(e,t){let n=us(e),r=us(t),o=[],i=new Map;for(let[a,c]of n){if(r.has(a))continue;let l=[...r.values()].find(u=>u.className===c.className&&!n.has(u.tagName));l&&i.set(a,l.tagName)}let s=new Set(i.values());for(let[a,c]of n){let l=r.get(a);if(l){o.push(...Lu(a,c.declaration,l.declaration));continue}let u=i.get(a);o.push({bump:"major",source:"manifest",message:u?`Renamed element \`<${a}>\` to \`<${u}>\``:`Removed element \`<${a}>\``})}for(let a of r.keys())!n.has(a)&&!s.has(a)&&o.push({bump:"minor",source:"manifest",message:`Added element \`<${a}>\``});return o}import Rt from"semver";function hs(e){if(e==null)return new Set;if(typeof e=="object"&&!Array.isArray(e)){let t=Object.keys(e);if(t.every(n=>n.startsWith(".")))return new Set(t)}return new Set(["."])}function Gu(e,t){let n=e;if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let i=e;Object.keys(i).every(s=>s.startsWith("."))&&(n=i[t])}let r=[],o=i=>{typeof i=="string"?r.push(i):Array.isArray(i)?i.forEach(o):i&&typeof i=="object"&&Object.values(i).forEach(o)};return o(n),r}var Bu=/^(package-lock\.json|\.npmrc|node_modules\/|\.git\/)/u,Wu=/^(package\.json|readme(\.[^/]*)?|licen[cs]e(\.[^/]*)?)$/iu;function ys(e){let t=e.indexOf("*");return t===-1?e:e.slice(0,t)}function Uu(e,t){let n=e.replace(/^\.\//u,"");if(Bu.test(n))return!1;if(!t||Wu.test(n))return!0;let r=ys(n);return t.some(o=>{let i=o.replace(/^\.\//u,"").replace(/\/$/u,"");return i.includes("*")?r.startsWith(ys(i)):n===i||n.startsWith(`${i}/`)})}function bs(e,t){return Gu(e.exports,t).some(n=>Uu(n,e.files))}function ws(e){try{let t=Rt.minVersion(e);return t?t.major>0?`${t.major}`:`0.${t.minor}`:null}catch{return null}}function vs(e,t={},n={}){let r=[];for(let[o,i]of Object.entries(n)){let s=t[o];if(s===void 0)continue;let a=ws(s),c=ws(i);a!==null&&c!==null&&a!==c&&r.push({bump:"major",source:"package",message:`Bumped ${e} \`${o}\` from \`${s}\` to \`${i}\``})}return r}function Hu(e={},t={}){let n=[];for(let[r,o]of Object.entries(t)){let i=e[r],s=`engine \`${r}\``;if(i===void 0){n.push({bump:"major",source:"package",message:`Added ${s} requirement \`${o}\``});continue}let a=null,c=null;try{a=Rt.minVersion(i),c=Rt.minVersion(o)}catch{continue}a&&c&&Rt.gt(c,a)&&n.push({bump:"major",source:"package",message:`Tightened ${s} from \`${i}\` to \`${o}\``})}return n}function ks(e,t){let n=[],r=hs(e.exports),o=hs(t.exports),i=e.exports===void 0&&t.exports!==void 0;i&&n.push({bump:"major",source:"package",message:"Added `exports`, which blocks imports of unlisted paths"});for(let a of r)o.has(a)||n.push(bs(e,a)?{bump:"major",source:"package",message:`Removed export \`${a}\``}:{bump:"patch",source:"package",message:`Removed export \`${a}\`, which never resolved: its target isn't in the published package`});for(let a of o)!i&&!r.has(a)&&n.push(bs(t,a)?{bump:"minor",source:"package",message:`Added export \`${a}\``}:{bump:"patch",source:"package",message:`Added export \`${a}\`, which won't resolve: its target isn't in the published package`});for(let a of["main","types","typings"])e[a]!==void 0&&t[a]===void 0&&n.push({bump:"major",source:"package",message:`Removed \`${a}\` (\`${e[a]}\`)`});let s=new Set(t.files??[]);for(let a of e.files??[])s.has(a)||n.push({bump:"major",source:"package",message:`Removed \`files\` entry \`${a}\``});return n.push(...vs("peer dependency",e.peerDependencies,t.peerDependencies),...vs("dependency",e.dependencies,t.dependencies),...Hu(e.engines,t.engines)),n}var Ju=["test/","tests/",".github/","docs/"];function qn(e){return Ju.some(t=>e.startsWith(t))}function zu(e){return qn(e)?!1:/(^|\/)(src|demo)\//u.test(e)||/(^|\/)README\.md$/u.test(e)}function $s(e){let t=e.filter(zu);if(t.length===0)return[];let n=t.slice(0,5).map(o=>`\`${o}\``),r=t.length>n.length?` and ${t.length-n.length} more`:"";return[{bump:"patch",source:"files",message:`Changed published files: ${n.join(", ")}${r}`}]}var Pt={install:"npm ci --no-audit --no-fund",build:"npm run build",pin:"npm install --no-save --no-audit --no-fund"},Vu="custom-elements.json";function Yn(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function Ku(e){return e.charAt(0).toLowerCase()+e.slice(1)}function qu(e,t,n,r){let o="Commits declare no release.";if(e!=="none"){let c=[...new Set(r.filter(u=>u.bump===e).map(u=>u.type??"breaking change"))];o=`Commits declare ${c.length?c.map(u=>`\`${u}\``).join(", "):"a release"} (${e}).`}if(t==="none")return`${o} Code requires no release.`;let i=n.filter(c=>c.bump===t).map(c=>Ku(c.message)),s=i.slice(0,3).join("; "),a=i.length>3?`; and ${i.length-3} more`:"";return`${o} Code requires ${t}: ${s}${a}.`}async function Yu(e,t,n){let{baseSha:r,headSha:o,manifestPath:i,rebuild:s,commands:a}=t,c=async d=>Yn(await St(e,d,i)),l={manifests:null,baseWithHeadGenerator:null,generators:null};if(!s){let d=await c(o),f=await c(r);return!d||!f?(n.push(`No ${i} at the ${d?"base":"head"} ref, so the public API wasn't compared.`),l):{...l,manifests:{base:f,head:d}}}let u;try{u=await At(e,o,i,a)}catch(d){throw new Error(`Could not build ${i} at the head ref: ${d.message}`)}let m=null;try{m=await At(e,r,i,a)}catch(d){let f=await c(r);if(n.push(f?`The base ref didn't build, so its committed ${i} was used: ${d.message.split(`
|
|
255
|
-
`)[0]}`:`The base ref didn't build and has no committed ${
|
|
256
|
-
`)[0]}`)}return{manifests:{base:m.manifest,head:u.manifest},baseWithHeadGenerator:
|
|
257
|
-
`);else{if(r?.stop(),console.error(`${
|
|
258
|
-
Changes:`);for(let
|
|
259
|
-
Commits:`);for(let
|
|
260
|
-
\u26A0 ${
|
|
261
|
-
|---|---|---|`,
|
|
262
|
-
`)}var
|
|
253
|
+
`);r(new Error(`\`${e}\` exited with ${i}
|
|
254
|
+
${a}`))})})}var Dt="@aurodesignsystem/auro-cli",Zn="@custom-elements-manifest/analyzer";function qn(e,t){for(let n of[z(e,"node_modules",t),z(e,"node_modules",Dt,"node_modules",t)])if(ds(z(n,"package.json")))return n;return null}async function ms(e,t){let n=qn(e,t);if(n)return JSON.parse(await Yn(z(n,"package.json"),"utf-8")).version}function ws(e,t){return e.auroCli!==t.auroCli||e.analyzer!==t.analyzer}async function Ku(e){let t=await ms(e,Dt),n=await ms(e,Zn);return t||n?{auroCli:t,analyzer:n}:null}async function qu(e){if(JSON.parse(await Yn(z(e,"package.json"),"utf-8")).scripts?.analyze)return"npm run analyze";let n=qn(e,Dt),r=qn(e,Zn),o=n?z(n,"dist","configs","custom-elements-manifest.config.mjs"):null;return!o||!ds(o)||!r?null:`node "${z(r,"cem.js")}" analyze --config "${o}"`}async function Pt(e,t,n,r,o){let s=await Fu(z(Gu(),"auro-api-diff-"));Vu(s,e);try{if(await fe(e,["worktree","add","--detach","--force",s,t]),await Kn(r.install,s),o){let c=[o.auroCli&&`${Dt}@${o.auroCli}`,o.analyzer&&`${Zn}@${o.analyzer}`].filter(Boolean);await Kn(`${r.pin} ${c.join(" ")}`,s)}let i=await Ku(s),a=o?await qu(s):null;return await Kn(a??r.build,s),{manifest:JSON.parse(await Yn(z(s,n),"utf-8")),generator:i}}finally{await fe(e,["worktree","remove","--force",s]).catch(()=>{}),await Lu(s,{recursive:!0,force:!0}).catch(()=>{}),zu(s)}}function ks(e){let t=new Map;for(let n of e.modules??[])for(let r of n.declarations??[]){let{tagName:o}=r;o&&!t.has(o)&&t.set(o,{tagName:o,className:r.name,declaration:r})}return t}function $e(e){return e.privacy===void 0||e.privacy==="public"}function Yu(e){return e.static?`static ${e.name}`:e.name}function Qn(e){let t=e.kind==="field"?"property":e.kind;return e.static?`static ${t}`:t}function Nt(e){return e.replace(/['`]/gu,'"').replace(/\s+/gu," ").trim()}function Xu(e){let t=Nt(e),n=/^\{\s*("[^"]*"|-?\d+(?:\.\d+)?|true|false|null|undefined)\s*\}$/u.exec(t);return n?n[1]:t}function vs(e){let t=[],n=0,r=null,o="";for(let i of e){if(r)i===r&&(r=null);else if(i==='"'||i==="'"||i==="`")r=i;else if("([{<".includes(i))n++;else if(")]}>".includes(i)&&!(i===">"&&o.endsWith("=")))n--;else if((i==="|"||i===",")&&n===0){t.push(o),o="";continue}o+=i}t.push(o);let s={String:"string",Number:"number",Boolean:"boolean"};return t.map(Nt).filter(i=>i.length>0).map(i=>s[i]??i)}function Zu(e){return/^".*"$/u.test(e)?"string":/^-?\d+(?:\.\d+)?$/u.test(e)?"number":e==="true"||e==="false"?"boolean":null}function $s(e,t){let n=Zu(t);return e.includes(t)||n!==null&&e.includes(n)}function er(e,t,n){if(t===void 0||n===void 0)return null;let r=vs(t),o=vs(n),s=r.filter(c=>!$s(o,c)),i=o.filter(c=>!$s(r,c));if(s.length===0&&i.length===0)return null;let a=c=>c.map(l=>`\`${l}\``).join(", ");return s.length>0&&i.length>0?{bump:"major",source:"manifest",message:`Changed type of ${e} from \`${Nt(t)}\` to \`${Nt(n)}\``}:s.length>0?{bump:"major",source:"manifest",message:`Narrowed type of ${e} (removed ${a(s)})`}:{bump:"minor",source:"manifest",message:`Widened type of ${e} (added ${a(i)})`}}function xs(e,t,n){let r=i=>{let a=i===void 0?void 0:Xu(i);return a==="undefined"?void 0:a},o=r(t),s=r(n);return o===s?null:o===void 0?{bump:"minor",source:"manifest",message:`Added default \`${s}\` to ${e}`}:s===void 0?{bump:"minor",source:"manifest",message:`Removed default \`${o}\` from ${e}`}:{bump:"major",source:"manifest",message:`Changed default of ${e} from \`${o}\` to \`${s}\``}}function tr(e){return typeof e.name=="string"&&e.name!==""}function nr(e,t,n){let r=[],o=(c,l)=>r.push({bump:c,source:"manifest",message:l}),s=t.requiredWhen,i=n.requiredWhen;s!==i&&(s===void 0?o("major",`Made ${e} required when \`${i}\``):i===void 0?o("minor",`Made ${e} no longer required`):s==="always"?o("minor",`Made ${e} required only when \`${i}\``):o("major",`Changed when ${e} is required from \`${s}\` to \`${i}\``));let a=(c,l)=>{let u=t[c],m=n[c];if(u===m)return;let d=c==="minimum"?"minimum":"maximum";u===void 0?o("major",`Added ${d} \`${m}\` to ${e}`):m===void 0?o("minor",`Removed ${d} \`${u}\` from ${e}`):l(m,u)?o("major",`Tightened ${d} of ${e} from \`${u}\` to \`${m}\``):o("minor",`Loosened ${d} of ${e} from \`${u}\` to \`${m}\``)};a("minimum",(c,l)=>c>l),a("maximum",(c,l)=>c<l),!t.readonly&&n.readonly?o("major",`Made ${e} read-only`):t.readonly&&!n.readonly&&o("minor",`Made ${e} writable`),!t.deprecated&&n.deprecated?o("minor",`Deprecated ${e}`):t.deprecated&&!n.deprecated&&o("minor",`Removed the deprecation of ${e}`);for(let c of["relevantWhen","category"]){let l=t[c],u=n[c];l!==u&&(l===void 0?o("minor",`Added \`${c}\` \`${u}\` to ${e}`):u===void 0?o("minor",`Removed \`${c}\` \`${l}\` from ${e}`):o("minor",`Changed \`${c}\` of ${e} from \`${l}\` to \`${u}\``))}return r}function Qu(e,t=[],n=[]){let r=[],o=(i,a)=>r.push({bump:i,source:"manifest",message:a}),s=i=>!!(i.optional||i.rest);for(let i=0;i<Math.max(t.length,n.length);i++){let a=t[i],c=n[i];if(a&&!c)o("major",`Removed parameter \`${a.name}\` from ${e}`);else if(!a&&c)o(s(c)?"minor":"major",`Added ${s(c)?"optional":"required"} parameter \`${c.name}\` to ${e}`);else if(a&&c){let l=`parameter \`${c.name}\` of ${e}`;s(a)&&!s(c)?o("major",`Made ${l} required`):!s(a)&&s(c)&&o("minor",`Made ${l} optional`);let u=er(l,a.type?.text,c.type?.text);u&&r.push(u)}}return r}function Es(e){let t=new Map;for(let n of e.members??[])tr(n)&&t.set(Yu(n),n);return t}function Ss(e,t){let n=new Map;for(let r of e.attributes??[]){let o=r.fieldName?t.get(r.fieldName):void 0;!tr(r)||r.internal||o&&!$e(o)||n.set(r.name.toLowerCase(),r)}return n}function em(e,t,n){let r=[],o=`\`<${e}>\``;for(let[s,i]of t){if(!$e(i))continue;let a=n.get(s),c=Qn(i);if(!a){r.push({bump:"major",source:"manifest",message:`Removed ${c} \`${i.name}\` from ${o}`});continue}if(!$e(a)){r.push({bump:"major",source:"manifest",message:`Made ${c} \`${i.name}\` on ${o} ${a.privacy}`});continue}if(a.kind!==i.kind){r.push({bump:"major",source:"manifest",message:`Changed \`${i.name}\` on ${o} from a ${c} to a ${Qn(a)}`});continue}let l=`${c} \`${i.name}\` on ${o}`;if(r.push(...nr(l,i,a)),i.kind==="method"&&r.push(...Qu(l,i.parameters,a.parameters)),i.kind==="field"){i.reflects&&!a.reflects&&r.push({bump:"major",source:"manifest",message:`Attribute \`${i.attribute??i.name}\` on ${o} no longer reflects`});for(let u of[er(l,i.type?.text,a.type?.text),xs(l,i.default,a.default)])u&&r.push(u)}}for(let[s,i]of n){if(!$e(i))continue;let a=t.get(s),c=Qn(i);a?$e(a)||r.push({bump:"minor",source:"manifest",message:`Made ${a.privacy} ${c} \`${i.name}\` on ${o} public`}):r.push({bump:"minor",source:"manifest",message:`Added ${c} \`${i.name}\` to ${o}`})}return r}function tm(e,t,n,r,o){let s=[],i=`\`<${e}>\``,a=Ss(t,r),c=Ss(n,o),l=p=>new Set((p.attributes??[]).filter(tr).map(f=>f.name.toLowerCase())),u=l(n),m=l(t),d=(p,f)=>{let h=p.fieldName?f.get(p.fieldName):void 0;return h!==void 0&&$e(h)};for(let[p,f]of a){let{name:h}=f,g=c.get(p);if(!g){s.push({bump:"major",source:"manifest",message:u.has(p)?`Made attribute \`${h}\` on ${i} private`:`Removed attribute \`${h}\` from ${i}`});continue}if(d(f,r)||d(g,o))continue;let y=`attribute \`${h}\` on ${i}`;for(let k of[er(y,f.type?.text,g.type?.text),xs(y,f.default,g.default)])k&&s.push(k);s.push(...nr(y,f,g))}for(let[p,{name:f}]of c)a.has(p)||s.push({bump:"minor",source:"manifest",message:m.has(p)?`Made private attribute \`${f}\` on ${i} public`:`Added attribute \`${f}\` to ${i}`});return s}function Mt(e,t,n,r){let o=u=>t==="slot"&&u===""?"default slot":`${t} \`${u}\``,s=`\`<${e}>\``,i=u=>new Set((u??[]).map(m=>m.name).filter(m=>typeof m=="string")),a=i(n),c=i(r),l=[];for(let u of a)c.has(u)||l.push({bump:"major",source:"manifest",message:`Removed ${o(u)} from ${s}`});for(let u of c)a.has(u)||l.push({bump:"minor",source:"manifest",message:`Added ${o(u)} to ${s}`});return l}var nm=[{key:"slots",describe:(e,t)=>e===""?`default slot of \`<${t}>\``:`slot \`${e}\` on \`<${t}>\``},{key:"cssParts",describe:(e,t)=>`CSS part \`${e}\` on \`<${t}>\``},{key:"cssProperties",describe:(e,t)=>`CSS custom property \`${e}\` on \`<${t}>\``}];function rm(e,t,n){return nm.flatMap(({key:r,describe:o})=>{let s=new Map((n[r]??[]).map(i=>[i.name,i]));return(t[r]??[]).flatMap(i=>{let a=s.get(i.name);return typeof i.name!="string"||!a?[]:nr(o(i.name,e),i,a)})})}function om(e,t,n){let r=Es(t),o=Es(n);return[...rm(e,t,n),...tm(e,t,n,r,o),...em(e,r,o),...Mt(e,"event",t.events,n.events),...Mt(e,"slot",t.slots,n.slots),...Mt(e,"CSS part",t.cssParts,n.cssParts),...Mt(e,"CSS custom property",t.cssProperties,n.cssProperties)]}function rr(e,t){let n=ks(e),r=ks(t),o=[],s=new Map;for(let[a,c]of n){if(r.has(a))continue;let l=[...r.values()].find(u=>u.className===c.className&&!n.has(u.tagName));l&&s.set(a,l.tagName)}let i=new Set(s.values());for(let[a,c]of n){let l=r.get(a);if(l){o.push(...om(a,c.declaration,l.declaration));continue}let u=s.get(a);o.push({bump:"major",source:"manifest",message:u?`Renamed element \`<${a}>\` to \`<${u}>\``:`Removed element \`<${a}>\``})}for(let a of r.keys())!n.has(a)&&!i.has(a)&&o.push({bump:"minor",source:"manifest",message:`Added element \`<${a}>\``});return o}import Ot from"semver";function As(e){if(e==null)return new Set;if(typeof e=="object"&&!Array.isArray(e)){let t=Object.keys(e);if(t.every(n=>n.startsWith(".")))return new Set(t)}return new Set(["."])}function sm(e,t){let n=e;if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let s=e;Object.keys(s).every(i=>i.startsWith("."))&&(n=s[t])}let r=[],o=s=>{typeof s=="string"?r.push(s):Array.isArray(s)?s.forEach(o):s&&typeof s=="object"&&Object.values(s).forEach(o)};return o(n),r}var im=/^(package-lock\.json|\.npmrc|node_modules\/|\.git\/)/u,am=/^(package\.json|readme(\.[^/]*)?|licen[cs]e(\.[^/]*)?)$/iu;function Cs(e){let t=e.indexOf("*");return t===-1?e:e.slice(0,t)}function cm(e,t){let n=e.replace(/^\.\//u,"");if(im.test(n))return!1;if(!t||am.test(n))return!0;let r=Cs(n);return t.some(o=>{let s=o.replace(/^\.\//u,"").replace(/\/$/u,"");return s.includes("*")?r.startsWith(Cs(s)):n===s||n.startsWith(`${s}/`)})}function Ts(e,t){return sm(e.exports,t).some(n=>cm(n,e.files))}function Rs(e){try{let t=Ot.minVersion(e);return t?t.major>0?`${t.major}`:`0.${t.minor}`:null}catch{return null}}function Ds(e,t={},n={}){let r=[];for(let[o,s]of Object.entries(n)){let i=t[o];if(i===void 0)continue;let a=Rs(i),c=Rs(s);a!==null&&c!==null&&a!==c&&r.push({bump:"major",source:"package",message:`Bumped ${e} \`${o}\` from \`${i}\` to \`${s}\``})}return r}function lm(e={},t={}){let n=[];for(let[r,o]of Object.entries(t)){let s=e[r],i=`engine \`${r}\``;if(s===void 0){n.push({bump:"major",source:"package",message:`Added ${i} requirement \`${o}\``});continue}let a=null,c=null;try{a=Ot.minVersion(s),c=Ot.minVersion(o)}catch{continue}a&&c&&Ot.gt(c,a)&&n.push({bump:"major",source:"package",message:`Tightened ${i} from \`${s}\` to \`${o}\``})}return n}function Ps(e,t){let n=[],r=As(e.exports),o=As(t.exports),s=e.exports===void 0&&t.exports!==void 0;s&&n.push({bump:"major",source:"package",message:"Added `exports`, which blocks imports of unlisted paths"});for(let a of r)o.has(a)||n.push(Ts(e,a)?{bump:"major",source:"package",message:`Removed export \`${a}\``}:{bump:"patch",source:"package",message:`Removed export \`${a}\`, which never resolved: its target isn't in the published package`});for(let a of o)!s&&!r.has(a)&&n.push(Ts(t,a)?{bump:"minor",source:"package",message:`Added export \`${a}\``}:{bump:"patch",source:"package",message:`Added export \`${a}\`, which won't resolve: its target isn't in the published package`});for(let a of["main","types","typings"])e[a]!==void 0&&t[a]===void 0&&n.push({bump:"major",source:"package",message:`Removed \`${a}\` (\`${e[a]}\`)`});let i=new Set(t.files??[]);for(let a of e.files??[])i.has(a)||n.push({bump:"major",source:"package",message:`Removed \`files\` entry \`${a}\``});return n.push(...Ds("peer dependency",e.peerDependencies,t.peerDependencies),...Ds("dependency",e.dependencies,t.dependencies),...lm(e.engines,t.engines)),n}var um=["test/","tests/",".github/","docs/"];function or(e){return um.some(t=>e.startsWith(t))}function mm(e){return or(e)?!1:/(^|\/)(src|demo)\//u.test(e)||/(^|\/)README\.md$/u.test(e)}function Ms(e){let t=e.filter(mm);if(t.length===0)return[];let n=t.slice(0,5).map(o=>`\`${o}\``),r=t.length>n.length?` and ${t.length-n.length} more`:"";return[{bump:"patch",source:"files",message:`Changed published files: ${n.join(", ")}${r}`}]}var It={install:"npm ci --no-audit --no-fund",build:"npm run build",pin:"npm install --no-save --no-audit --no-fund"},dm="custom-elements.json";function sr(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function pm(e){return e.charAt(0).toLowerCase()+e.slice(1)}function fm(e,t,n,r){let o="Commits declare no release.";if(e!=="none"){let c=[...new Set(r.filter(u=>u.bump===e).map(u=>u.type??"breaking change"))];o=`Commits declare ${c.length?c.map(u=>`\`${u}\``).join(", "):"a release"} (${e}).`}if(t==="none")return`${o} Code requires no release.`;let s=n.filter(c=>c.bump===t).map(c=>pm(c.message)),i=s.slice(0,3).join("; "),a=s.length>3?`; and ${s.length-3} more`:"";return`${o} Code requires ${t}: ${i}${a}.`}async function gm(e,t,n){let{baseSha:r,headSha:o,manifestPath:s,rebuild:i,commands:a}=t,c=async p=>sr(await Rt(e,p,s)),l={manifests:null,baseWithHeadGenerator:null,generators:null};if(!i){let p=await c(o),f=await c(r);return!p||!f?(n.push(`No ${s} at the ${p?"base":"head"} ref, so the public API wasn't compared.`),l):{...l,manifests:{base:f,head:p}}}let u;try{u=await Pt(e,o,s,a)}catch(p){throw new Error(`Could not build ${s} at the head ref: ${p.message}`)}let m=null;try{m=await Pt(e,r,s,a)}catch(p){let f=await c(r);if(n.push(f?`The base ref didn't build, so its committed ${s} was used: ${p.message.split(`
|
|
255
|
+
`)[0]}`:`The base ref didn't build and has no committed ${s}, so the public API wasn't compared.`),!f)return{...l,generators:{base:null,head:u.generator}};m={manifest:f,generator:null}}let d=null;if(u.generator&&m.generator&&ws(m.generator,u.generator))try{d=(await Pt(e,r,s,a,u.generator)).manifest}catch(p){n.push(`The base didn't build with the head's generator, so changes couldn't be split between the code and the generator upgrade: ${p.message.split(`
|
|
256
|
+
`)[0]}`)}return{manifests:{base:m.manifest,head:u.manifest},baseWithHeadGenerator:d,generators:{base:m.generator,head:u.generator}}}function Ns(e){return e?e.auroCli?`auro-cli ${e.auroCli}`:`analyzer ${e.analyzer}`:"unknown"}async function Os(e,t="HEAD",n={}){let r=n.cwd??process.cwd(),o=n.rebuild??!0,s={...It,...n.commands},i=[],a=await Xn(r,e),c=await Xn(r,t),l=await ps(r,a,c),u=await fs(r,l,c),m=sr(await Rt(r,l,"package.json"))??{},d=sr(await Rt(r,c,"package.json"))??{},p=n.manifest??d.customElements??dm,f=[],h=null,g=0;if(u.some(w=>!or(w))){let w=n.manifests?{manifests:n.manifests,baseWithHeadGenerator:null,generators:null}:await gm(r,{baseSha:l,headSha:c,manifestPath:p,rebuild:o,commands:s},i);if(h=w.generators,w.manifests){let oe=rr(w.manifests.base,w.manifests.head);if(w.baseWithHeadGenerator){let se=new Set(rr(w.baseWithHeadGenerator,w.manifests.head).map(ye=>ye.message));for(let ye of oe)ye.cause=se.has(ye.message)?"code":"generator";g=oe.filter(ye=>ye.cause==="generator").length}f.push(...oe)}}f.push(...Ps(m,d),...Ms(u));let y=ss(f),k=rs(y.map(w=>w.bump)),$=ls(r),C=await gs(r,l,c),v=await us(C,$,r);C.length>0&&$.source==="default"&&i.push("The repo's release config couldn't be resolved, so commits were read with the shared auro-config rules, which may differ from how the repo releases.");let b=fm(v.bump,k,y,v.commits);return g>0&&h&&(b+=` ${g} of the manifest changes come from upgrading ${Ns(h.base)} to ${Ns(h.head)}, not from the component's code; they still change the published manifest.`),{required:k,reasons:y.map(w=>w.message),declared:v.bump,outcome:os(v.bump,k),summary:b,base:a,head:c,mergeBase:l,changes:y,commits:v.commits,releaseConfig:$.source,generators:h,warnings:i}}var bm={pass:"\u2714",warn:"\u26A0",fail:"\u2716"};async function wm(e,t,n={}){let r=n.json?null:ym(`Comparing ${e}...${t??"HEAD"}...`).start(),o;try{o=await Os(e,t,{rebuild:n.rebuild,manifest:n.manifest,commands:{install:n.installCommand,build:n.buildCommand}})}catch(i){let a=`api-diff failed: ${i.message}`;r?r.fail(a):console.error(a),ir.exit(2)}let s=!!n.enforce&&o.outcome==="fail";if(n.json)ir.stdout.write(`${JSON.stringify(o,null,2)}
|
|
257
|
+
`);else{if(r?.stop(),console.error(`${bm[o.outcome]} ${o.summary}`),o.changes.length>0){console.error(`
|
|
258
|
+
Changes:`);for(let i of o.changes){let a=i.cause==="generator"?" (generator upgrade)":"";console.error(` [${i.bump}] ${i.message}${a}`)}}if(o.commits.length>0){console.error(`
|
|
259
|
+
Commits:`);for(let i of o.commits)console.error(` [${i.bump}] ${i.hash.slice(0,7)} ${i.subject}`)}for(let i of o.warnings)console.error(`
|
|
260
|
+
\u26A0 ${i}`)}s&&ir.exit(1)}var Qb=hm.command("api-diff <baseRef> [headRef]").description("Work out the smallest version bump the changes from baseRef to headRef (default HEAD) require, and check the commits declare at least that much.").option("--json","Output the result as JSON on stdout",!1).option("--enforce","Exit 1 when the commits declare a smaller bump than the code requires",!1).option("--no-rebuild","Compare the committed custom-elements.json files instead of rebuilding them").option("--manifest <path>","Manifest path relative to the repo root (default: package.json customElements, else custom-elements.json)").option("--install-command <cmd>","Command that installs dependencies in each rebuilt checkout",It.install).option("--build-command <cmd>","Command that writes the manifest in each rebuilt checkout",It.build).action(wm);import Cm from"node:fs/promises";import Tm from"node:path";import{program as Rm}from"commander";import dr from"ora";var km='# Auro Design System \u2014 AI Assistant Context\nAlaska Airlines open-source design system | https://auro.alaskaair.com\n\n## What is Auro?\nAuro is Alaska Airlines\' design system built on Web Components (Custom Elements v1) using the Lit library.\n- npm scope: `@aurodesignsystem/` (current), `@alaskaairux/` (legacy)\n- Framework-agnostic: works with React, Angular, Vue, Svelte, or plain HTML\n- Each component is a separate npm package\n- All components use the `<auro-*>` custom element tag\n\n## Rules for Writing Auro Code\n\n1. **Use `<auro-*>` custom element tags \u2014 never plain HTML equivalents**\n - \u2717 `<button>` \u2192 \u2713 `<auro-button>`\n - \u2717 `<a href="...">` \u2192 \u2713 `<auro-hyperlink href="...">`\n - \u2717 `<input>` \u2192 \u2713 `<auro-input>` (from auro-formkit)\n\n2. **Install and register each component before use**\n ```bash\n npm install @aurodesignsystem/auro-button\n ```\n ```js\n import "@aurodesignsystem/auro-button"; // registers <auro-button> globally\n ```\n\n3. **Props are HTML attributes in templates; camelCase properties in JS**\n ```html\n <auro-button disabled loading>Save</auro-button>\n ```\n ```js\n document.querySelector(\'auro-button\').loading = true;\n ```\n\n4. **Content goes in named slots, not innerHTML**\n ```html\n <auro-dialog>\n <span slot="header">Title</span>\n <div slot="content">Body content here</div>\n </auro-dialog>\n ```\n\n5. **Design tokens are CSS custom properties**\n ```bash\n npm install @aurodesignsystem/design-tokens\n ```\n ```css\n @import "@aurodesignsystem/design-tokens/dist/themes/CSSCustomProperties--bundled.css";\n ```\n Token naming: `--ds-basic-*` and `--ds-advanced-*` (e.g. `--ds-advanced-color-*`, `--ds-basic-color-*`)\n\n## Component Reference\n\n',vm=`| Element Tag | Package | Description |
|
|
261
|
+
|---|---|---|`,ar=[{tag:"auro-accordion",pkg:"@aurodesignsystem/auro-accordion",description:"Expandable content sections"},{tag:"auro-alert",pkg:"@aurodesignsystem/auro-alert",description:"Inline status messages: error, warning, success, information"},{tag:"auro-avatar",pkg:"@aurodesignsystem/auro-avatar",description:"User or entity avatar"},{tag:"auro-background",pkg:"@aurodesignsystem/auro-background",description:"Themed background wrapper"},{tag:"auro-backtotop",pkg:"@aurodesignsystem/auro-backtotop",description:"Scroll-to-top button"},{tag:"auro-badge",pkg:"@aurodesignsystem/auro-badge",description:"Status or count badge"},{tag:"auro-banner",pkg:"@aurodesignsystem/auro-banner",description:"Full-width promotional banner"},{tag:"auro-button",pkg:"@aurodesignsystem/auro-button",description:"Interactive button; supports `loading`, `disabled`, `shape`"},{tag:"auro-card",pkg:"@aurodesignsystem/auro-card",description:"Content card container"},{tag:"auro-carousel",pkg:"@aurodesignsystem/auro-carousel",description:"Horizontally scrollable carousel"},{tag:"auro-datetime",pkg:"@aurodesignsystem/auro-datetime",description:"Localized date and time formatting"},{tag:"auro-dialog",pkg:"@aurodesignsystem/auro-dialog",description:"Modal dialog; slots: header, content, footer"},{tag:"auro-drawer",pkg:"@aurodesignsystem/auro-drawer",description:"Slide-in panel; slots: header, content, footer"},{tag:"auro-flight",pkg:"@aurodesignsystem/auro-flight",description:"Flight segment display (origin, destination, stops)"},{tag:"auro-flightline",pkg:"@aurodesignsystem/auro-flightline",description:"Visual flight path/stop indicator"},{tag:"auro-input",pkg:"@aurodesignsystem/auro-formkit",description:"Text input field"},{tag:"auro-select",pkg:"@aurodesignsystem/auro-formkit",description:"Select/dropdown"},{tag:"auro-datepicker",pkg:"@aurodesignsystem/auro-formkit",description:"Date picker input"},{tag:"auro-combobox",pkg:"@aurodesignsystem/auro-formkit",description:"Combobox with search"},{tag:"auro-checkbox",pkg:"@aurodesignsystem/auro-formkit",description:"Checkbox input"},{tag:"auro-radio",pkg:"@aurodesignsystem/auro-formkit",description:"Radio button input"},{tag:"auro-header",pkg:"@aurodesignsystem/auro-header",description:"Page/section heading"},{tag:"auro-hyperlink",pkg:"@aurodesignsystem/auro-hyperlink",description:"Accessible anchor link"},{tag:"auro-icon",pkg:"@aurodesignsystem/auro-icon",description:"Alaska Airlines icon: `category` + `name` attributes"},{tag:"auro-loader",pkg:"@aurodesignsystem/auro-loader",description:"Loading spinner"},{tag:"auro-lockup",pkg:"@aurodesignsystem/auro-lockup",description:"Image + text layout lockup"},{tag:"auro-nav",pkg:"@aurodesignsystem/auro-nav",description:"Secondary navigation aid (relation to higher-level pages)"},{tag:"auro-pane",pkg:"@aurodesignsystem/auro-pane",description:"Selectable shoulder dates with associated prices"},{tag:"auro-popover",pkg:"@aurodesignsystem/auro-popover",description:"Tooltip-style popover"},{tag:"auro-sidenav",pkg:"@aurodesignsystem/auro-sidenav",description:"Vertical side navigation"},{tag:"auro-skeleton",pkg:"@aurodesignsystem/auro-skeleton",description:"Loading placeholder skeleton"},{tag:"auro-slideshow",pkg:"@aurodesignsystem/auro-slideshow",description:"Image/content slideshow"},{tag:"auro-table",pkg:"@aurodesignsystem/auro-table",description:"Accessible data table"},{tag:"auro-tabs",pkg:"@aurodesignsystem/auro-tabs",description:"Tabbed content panels"},{tag:"auro-tail",pkg:"@aurodesignsystem/auro-tail",description:"Alaska, Hawaiian, and partner airline tail graphics"},{tag:"auro-toast",pkg:"@aurodesignsystem/auro-toast",description:"Transient notification toast"},{tag:"auro-tokenlist",pkg:"@aurodesignsystem/auro-tokenlist",description:"Design token display utilities"}];function cr(e){return e.map(t=>`| \`<${t.tag}>\` | \`${t.pkg}\` | ${t.description.replace(/\|/gu,"\\|")} |`).join(`
|
|
262
|
+
`)}var $m=cr(ar),Em=`## Common Patterns
|
|
263
263
|
|
|
264
264
|
### Button (default, secondary, tertiary)
|
|
265
265
|
\`\`\`html
|
|
@@ -337,14 +337,14 @@ document.querySelector('#confirmDialog').show();
|
|
|
337
337
|
- Design tokens: https://auro.alaskaair.com/getting-started/developers/token-usage
|
|
338
338
|
- Contributing: https://auro.alaskaair.com/getting-started/developers/contributing
|
|
339
339
|
- GitHub: https://github.com/AlaskaAirlines
|
|
340
|
-
`;function
|
|
340
|
+
`;function lr(e){return`${km}${vm}
|
|
341
341
|
${e}
|
|
342
342
|
|
|
343
|
-
${
|
|
344
|
-
`)}async function
|
|
345
|
-
Paste this file into your AI coding tool (Claude, Cursor, Copilot, etc.) to prime it on Auro components.`)}catch(l){let u=l instanceof Error?l.message:String(l);c.fail(`Failed to write context: ${u}`),process.exit(1)}}else process.stdout.write(a);t&&
|
|
343
|
+
${Em}`}var tw=lr($m);function x(e){return(e??"").replace(/\s+/gu," ").trim()}import R from"chalk";var G="@aurodesignsystem/auro-formkit",ur=["@aurodesignsystem/auro-input","@aurodesignsystem/auro-select","@aurodesignsystem/auro-combobox","@aurodesignsystem/auro-menu","@aurodesignsystem/auro-checkbox","@aurodesignsystem/auro-radio","@aurodesignsystem/auro-datepicker","@aurodesignsystem/auro-dropdown","@aurodesignsystem/auro-form"],Sm=new Set(ur);function Z(e){return Sm.has(e)}function mr(e){return e.slice(18)}function Ee(e){return`${G}/${mr(e)}`}var xm=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/u;function Is(e){let t=xm.exec(e.trim());return t?{main:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]?t[4].split("."):[]}:null}function Am(e,t){let n=Is(e),r=Is(t);if(!n||!r)return null;for(let s=0;s<3;s+=1)if(n.main[s]!==r.main[s])return n.main[s]<r.main[s]?-1:1;if(n.pre.length===0&&r.pre.length===0)return 0;if(n.pre.length===0)return 1;if(r.pre.length===0)return-1;let o=Math.max(n.pre.length,r.pre.length);for(let s=0;s<o;s+=1){let i=n.pre[s],a=r.pre[s];if(i===void 0)return-1;if(a===void 0)return 1;let c=/^\d+$/u.test(i),l=/^\d+$/u.test(a);if(c&&l){let u=Number(i)-Number(a);if(u!==0)return u<0?-1:1}else{if(c!==l)return c?-1:1;if(i!==a)return i<a?-1:1}}return 0}async function Se(e){let t=[...e.entries()],n=await Promise.all(t.map(([o])=>Oo(o))),r=[];return t.forEach(([o,s],i)=>{let a=n[i];if(!a)return;let c=Am(s,a);c!==null&&c<0&&r.push({pkg:o,installed:s,latest:a})}),r}var js=" \u21E2 auro-formkit";function xe(e){if(e.length===0)return"";let t=e.filter(d=>Z(d.pkg)),n=e.filter(d=>!Z(d.pkg)),r=`\u26A0 ${e.length} Auro component(s) are NOT on the latest release`,o=Math.max(...e.map(d=>d.pkg.length)),s=Math.max(...e.map(d=>d.installed.length)),i=d=>Z(d.pkg),a=e.map(d=>{let p=` ${R.bold(d.pkg.padEnd(o))} ${R.dim(d.installed.padStart(s))} ${R.dim("\u2192")} ${R.green.bold(d.latest)}`;return i(d)?`${p}${R.yellow(js)}`:p}),c=[];if(n.length>0){let d=`npm install ${n.map(p=>`${p.pkg}@latest`).join(" ")}`;c.push("",R.dim(" Update to latest with:"),` ${R.cyan(d)}`)}if(t.length>0){c.push("",R.dim(" Migrate to auro-formkit (run `auro init`):"));for(let d of t)c.push(` ${R.dim(d.pkg)} ${R.dim("\u2192")} ${R.cyan(Ee(d.pkg))}`)}let l=[r.length+1,...e.map(d=>{let p=2+o+2+s+3+d.latest.length;return i(d)?p+js.length:p})],u=Math.min(Math.max(...l),78),m="\u2500".repeat(u);return["",R.yellow.bold(`\u250C${m}\u2510`),R.yellow.bold(r),R.yellow.bold(`\u2514${m}\u2518`),...a,...c,""].join(`
|
|
344
|
+
`)}async function Dm(e){let t=new Map;for(let i of ar)t.set(i.tag,{...i});let n=await Promise.all(j.map(i=>_(i,{allowNetwork:e}))),r=new Map(_n(n).map(i=>[i.pkg,i.version])),o=0,s=0;for(let i of n){if(!i.manifest)continue;o+=1;let a=(i.manifest.modules??[]).flatMap(c=>c.declarations??[]).filter(c=>c.customElement&&c.tagName);for(let c of a){let l=c.tagName,u=x(c.summary||c.description),m=t.get(l);t.set(l,{tag:l,pkg:i.target,description:u||m?.description||""}),u&&(s+=1)}}return{rows:cr([...t.values()]),resolved:o,enriched:s,local:r}}async function Pm(e){let t=dr("Checking for newer component releases...").start(),n=await Se(e);if(n.length===0){t.succeed("All installed Auro components are on the latest release.");return}t.stop(),console.error(xe(n))}async function Mm(e){let t=!e.offline,n=dr(t?"Resolving component manifests...":"Reading installed component manifests...").start(),{rows:r,resolved:o,enriched:s,local:i}=await Dm(t),a=lr(r);if(t?s>0?n.succeed(i.size>0?`Enriched ${s} component description(s); ${i.size} package(s) resolved from local node_modules.`:`Enriched ${s} component description(s) from unpkg.`):o>0?n.succeed(`Resolved ${o} component manifest(s); none documented a description, using the built-in table.`):n.warn("No manifests available; using the built-in component table."):i.size>0?n.succeed(s>0?`Read ${i.size} installed component manifest(s) from local node_modules; enriched ${s} description(s).`:`Read ${i.size} installed component manifest(s) from local node_modules; none documented a description, using the built-in table.`):n.warn("No installed component manifests found; using the built-in component table."),e.output){let c=dr(`Writing context to ${e.output}...`).start();try{let l=Tm.resolve(process.cwd(),e.output);await Cm.writeFile(l,a,"utf-8"),c.succeed(`Auro context written to ${e.output}`),console.error(`
|
|
345
|
+
Paste this file into your AI coding tool (Claude, Cursor, Copilot, etc.) to prime it on Auro components.`)}catch(l){let u=l instanceof Error?l.message:String(l);c.fail(`Failed to write context: ${u}`),process.exit(1)}}else process.stdout.write(a);t&&i.size>0&&await Pm(i)}var ww=Rm.command("context").description("Generate an AI assistant context document for the Auro Design System").option("-o, --output <path>","Write context to a file instead of stdout (e.g. AURO_CONTEXT.md)").option("--offline","Skip network fetches; use locally installed manifests and the built-in table",!1).action(Mm);import jd from"node:fs/promises";import _d from"node:path";import te from"node:process";import{program as Fd}from"commander";import ne from"inquirer";import Ve from"ora";var N="auro.config.json";import{existsSync as _s,readFileSync as Fs,statSync as Nm}from"node:fs";import jt from"node:path";import{parse as Ls}from"jsonc-parser";var Bs=["vscode","jsx","svelte","cssSnippets"];function Gs(e,t){try{return Nm(jt.join(e,t)).isDirectory()}catch{return!1}}function Ws(e){try{let t=Fs(jt.join(e,"package.json"),"utf-8"),n=Ls(t,[],{allowTrailingComma:!0});return typeof n!="object"||n===null?new Set:new Set([...Object.keys(n.dependencies??{}),...Object.keys(n.devDependencies??{})])}catch{return new Set}}function Om(e){return Gs(e,T)}function Im(e){return Gs(e,T)}function jm(e){let t=jt.join(e,"tsconfig.json");if(_s(t))try{let n=Fs(t,"utf-8"),r=Ls(n,[],{allowTrailingComma:!0});if(typeof r=="object"&&r!==null&&r.compilerOptions?.jsx!==void 0)return!0}catch{}return Ws(e).has("react")}function _m(e){return Ws(e).has("svelte")?!0:["js","ts","mjs","cjs"].some(t=>_s(jt.join(e,`svelte.config.${t}`)))}function Us(e){return{vscode:Om(e),jsx:jm(e),svelte:_m(e),cssSnippets:Im(e)}}import{existsSync as pr,readFileSync as Fm}from"node:fs";import Hs from"node:path";import{parse as Js}from"jsonc-parser";function _t(e,t){return Hs.join(e,...t.split("/"))}function Vs(e){try{return Fm(e,"utf-8")}catch{return null}}function Lm(e){let t=Vs(_t(e,`${T}/${ue}`));if(t===null)return!1;let r=Js(t,[],{allowTrailingComma:!0})?.[P];return typeof r=="string"?r===J:Array.isArray(r)?r.includes(J):!1}function Bm(e){for(let t of["tsconfig.json","jsconfig.json"]){let n=Vs(Hs.join(e,t));if(n===null)continue;let r=Js(n,[],{allowTrailingComma:!0}),o=r?.[M];return Array.isArray(o)?o.includes(V):!(o!==void 0||"files"in(r??{}))}return!0}function fr(e,t){let n=[];return t.vscode&&(pr(_t(e,me))||n.push(`${me} is missing \u2014 VS Code markup completions will not work.`),Lm(e)||n.push(`${T}/${ue} does not register "${J}" under "${P}".`)),t.svelte&&!pr(_t(e,pe))&&n.push(`${pe} is missing.`),t.jsx&&!pr(_t(e,de))&&n.push(`${de} is missing.`),(t.svelte||t.jsx)&&!Bm(e)&&n.push(`${V} is not on the TypeScript program (missing from "${M}").`),{inconsistencies:n,markupDisabled:!t.vscode}}import Ae from"node:fs/promises";import Bt from"node:path";var Gm="css,scss,less";function Wm(e){return!/[,|}]/u.test(e)}function Um(e){return(e.declaration.cssParts??[]).map(t=>t.name).filter(t=>typeof t=="string"&&t!=="").filter(Wm)}function Hm(e,t){let n=`\${1|${t.join(",")}|}`;return{scope:Gm,prefix:`${e}::part`,body:[`${e}::part(${n}) {`," $0","}"],description:`Style a shadow part of <${e}> (${t.join(", ")})`}}function zs(e,t){let n={};for(let r of e){let o=Um(r);if(o.length===0)continue;let s=jn(r,t);n[`Auro <${s}> ::part`]=Hm(s,o)}return Object.keys(n).length===0?null:{filename:wt,contents:X(JSON.stringify(n,null,2))}}import{getVsCodeHtmlCustomData as Jm}from"custom-element-vs-code-integration";function Ks(e,t){let n=be(e,t),r=Y(o=>Jm(n,{outdir:o,htmlFileName:"auro.html-custom-data.json",hideLogs:!0}));return{filename:me,contents:X(r)}}import{applyEdits as qs,modify as Ys,parse as Vm,parseTree as zm}from"jsonc-parser";var Xs={tabSize:2,insertSpaces:!0};function Km(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ft(e,t){if(e.trim()==="")return{data:{}};let n=[],r=Vm(e,n,{allowTrailingComma:!0});return n.length>0?{warning:`${t} is not valid JSON \u2014 leaving it untouched.`}:Km(r)?{data:r}:{warning:`${t} is not a JSON object \u2014 leaving it untouched.`}}function Je(e,t,n){let r=e.trim()===""?"{}":e,o=Ys(r,t,n,{formattingOptions:Xs});return qs(r,o)}function qm(e,t){let n=zm(e);if(!n||n.type!=="object"||n.children?.length!==1)return null;let r=n.children[0];if(r.children?.[0]?.value!==t)return null;let o=r.offset+r.length;for(;o<e.length&&e[o]===",";)o++;return e.slice(0,r.offset)+e.slice(o)}function gr(e,t){if(t.length===1){let r=qm(e,t[0]);if(r!==null)return r}let n=Ys(e,t,void 0,{formattingOptions:Xs});return qs(e,n)}function Zs(e,t=J){let n=Ft(e,".vscode/settings.json");if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let r=n.data[P],o;if(r===void 0)o=[t];else if(typeof r=="string"){if(r===t)return{contents:e,changed:!1};o=[r,t]}else if(Array.isArray(r)){if(r.includes(t))return{contents:e,changed:!1};o=[...r,t]}else return{contents:e,changed:!1,warning:`.vscode/settings.json "${P}" is not a string or array \u2014 leaving it untouched.`};return{contents:Je(e,[P],o),changed:!0}}function Qs(e,t=V,n="tsconfig.json"){let r=Ft(e,n);if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let{data:o}=r,s=o[M];return Array.isArray(s)?s.includes(t)?{contents:e,changed:!1}:{contents:Je(e,[M],[...s,t]),changed:!0}:s!==void 0?{contents:e,changed:!1,warning:`${n} "${M}" is not an array \u2014 leaving it untouched.`}:"files"in o?{contents:Je(e,[M],[t]),changed:!0}:{contents:e,changed:!1}}function ei(e,t=J){let n=Ft(e,".vscode/settings.json");if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let r=n.data[P];if(typeof r=="string")return r!==t?{contents:e,changed:!1}:{contents:gr(e,[P]),changed:!0};if(Array.isArray(r)){if(!r.includes(t))return{contents:e,changed:!1};let o=r.filter(i=>i!==t);return{contents:o.length===0?gr(e,[P]):Je(e,[P],o),changed:!0}}return{contents:e,changed:!1}}function ti(e,t=V,n="tsconfig.json"){let r=Ft(e,n);if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let o=r.data[M];if(!Array.isArray(o)||!o.includes(t))return{contents:e,changed:!1};let s=o.filter(a=>a!==t);return{contents:s.length===0?gr(e,[M]):Je(e,[M],s),changed:!0}}function ri(e,t){return Bt.join(e,...t.split("/"))}async function Lt(e,t){let n=ri(e,t.filename);return await Ae.mkdir(Bt.dirname(n),{recursive:!0}),await Ae.writeFile(n,t.contents,"utf-8"),t.filename}async function ni(e){try{return await Ae.readFile(e,"utf-8")}catch(t){if(t.code==="ENOENT")return"";throw t}}async function hr(e,t,n,r){let o=[],s=[];if(r.vscode){o.push(await Lt(e,Ks(t,n)));let i=`${T}/${ue}`,a=ri(e,i),c=Zs(await ni(a));c.warning?s.push(`${c.warning} Add "${J}" to "${P}" in ${i} by hand.`):c.changed&&(await Ae.mkdir(Bt.dirname(a),{recursive:!0}),await Ae.writeFile(a,c.contents,"utf-8"),o.push(i))}if(r.jsx&&o.push(await Lt(e,vt(t,n))),r.svelte&&o.push(await Lt(e,$t(t,n))),r.cssSnippets){let i=zs(t,n);i&&o.push(await Lt(e,i))}if(r.jsx||r.svelte)for(let i of["tsconfig.json","jsconfig.json"]){let a=Bt.join(e,i),c=await ni(a);if(c==="")continue;let l=Qs(c,V,i);l.warning?s.push(`${l.warning} Add "${V}" to "${M}" in ${i} by hand.`):l.changed&&(await Ae.writeFile(a,l.contents,"utf-8"),o.push(i));break}return{written:o,warnings:s}}var Q="AGENTS.md",ge="CLAUDE.md";var Gt="Generated by `auro init`",oi=`# Auro Design System \u2014 AI Assistant Grounding
|
|
346
346
|
|
|
347
|
-
<!-- ${
|
|
347
|
+
<!-- ${Gt}. Do not edit by hand \u2014 re-run \`auro init\` to
|
|
348
348
|
regenerate. Custom element tags are governed by \`auro.config.json\`. -->
|
|
349
349
|
|
|
350
350
|
Alaska Airlines open-source design system | https://auro.alaskaair.com
|
|
@@ -361,9 +361,9 @@ v1) using the Lit library.
|
|
|
361
361
|
- npm scope: \`@aurodesignsystem/\` (current), \`@alaskaairux/\` (legacy)
|
|
362
362
|
- Framework-agnostic: works with React, Angular, Vue, Svelte, or plain HTML
|
|
363
363
|
- Each component is a separate npm package and registers a custom element tag
|
|
364
|
-
`,
|
|
365
|
-
|---|---|---|---|`,
|
|
366
|
-
`;var
|
|
364
|
+
`,si=`| Tag | Package | Version | Import |
|
|
365
|
+
|---|---|---|---|`,ii="## Regeneration\n\nThis file is generated by `auro init`. Re-run it after adding or removing an Auro\ndependency to update the component list and APIs. Custom element tags are governed\nby `auro.config.json` (committed by default) \u2014 change prefixes there, not in this\nfile, then re-run `auro init`.\n",Wt=`@${Q}
|
|
366
|
+
`;var ai=`## Auro Coding Rules
|
|
367
367
|
|
|
368
368
|
These rules apply to every Auro component in this project. Use the exact
|
|
369
369
|
registered tags listed under **Installed Components** below: this project uses
|
|
@@ -404,35 +404,35 @@ name.
|
|
|
404
404
|
6. **Accessibility is built in \u2014 don't override it.** Auro components ship WCAG
|
|
405
405
|
2.1 AA behavior (focus management, ARIA, error messaging). Prefer the provided
|
|
406
406
|
slots and attributes over custom ARIA.
|
|
407
|
-
`;var
|
|
408
|
-
`)}function
|
|
409
|
-
`)}function
|
|
410
|
-
`)}function
|
|
407
|
+
`;var ci="@aurodesignsystem";function ui(e){let t=e.trim();if(t.startsWith("@"))return t;let n=t.toLowerCase();return n.startsWith("auro-")?`${ci}/${n}`:`${ci}/auro-${n}`}function Ym(e){return e.replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}function li(e){return e?typeof e=="string"?` [deprecated: ${x(e)}]`:" [deprecated]":""}function Ce(e){if(e.length===0)return" (none)";let t=Math.max(...e.map(([n])=>(n??"").length));return e.map(([n,r])=>` ${(n??"").padEnd(t)} ${r??""}`.trimEnd()).join(`
|
|
408
|
+
`)}function mi(e,t,n={}){let{installPkg:r=e,importSpecifier:o=e}=n,s=[];s.push(`${t.tagName} (${e})`);let i=t.summary||t.description;i&&s.push(x(i));let a=t.superclass?.name?`${t.name} extends ${t.superclass.name}`:t.name;return s.push(`Class: ${a}`),s.push(""),s.push("Install:"),s.push(` npm i ${r}`),s.push(` import "${o}";`),s.push(...yr(t)),s.join(`
|
|
409
|
+
`)}function yr(e){let t=[],n=e.attributes??[];t.push(""),t.push(`Attributes (${n.length}):`),t.push(Ce(n.map(l=>{let u=l.type?.text?` {${x(l.type.text)}}`:"",m=l.default?` = ${x(l.default)}`:"";return[l.name,`${x(l.description)}${u}${m}${li(l.deprecated)}`.trim()]})));let r=new Set(n.flatMap(l=>l.fieldName?[l.fieldName]:[l.name,Ym(l.name)])),o=(e.members??[]).filter(l=>l.name&&(l.privacy===void 0||l.privacy==="public")&&!l.static&&!(l.kind==="field"&&r.has(l.name)));t.push(""),t.push(`Properties & Methods (${o.length}):`),t.push(Ce(o.map(l=>{let u=l.kind==="method",m=u?`${l.name}()`:l.name,d=u?l.return?.type?.text:l.type?.text,p=d?` {${x(d)}}`:"",f=!u&&l.default?` = ${x(l.default)}`:"";return[m,`${x(l.description)}${p}${f}${li(l.deprecated)}`.trim()]})));let s=e.slots??[];t.push(""),t.push(`Slots (${s.length}):`),t.push(Ce(s.map(l=>[l.name||"(default)",x(l.description)])));let i=e.events??[];t.push(""),t.push(`Events (${i.length}):`),t.push(Ce(i.map(l=>{let u=l.type?.text?` {${x(l.type.text)}}`:"";return[l.name,`${x(l.description)}${u}`.trim()]})));let a=e.cssParts??[];a.length>0&&(t.push(""),t.push(`CSS Parts (${a.length}):`),t.push(Ce(a.map(l=>[l.name,x(l.description)]))));let c=e.cssProperties??[];return c.length>0&&(t.push(""),t.push(`CSS Custom Properties (${c.length}):`),t.push(Ce(c.map(l=>[l.name,x(l.description)])))),t}function di(e,t){return t.get(e.tagName)??e.tagName}function Xm(e,t){let{pkg:n,importPath:r,declaration:o}=e,s=[`${t} (${n})`],i=o.summary||o.description;i&&s.push(x(i));let a=o.superclass?.name?`${o.name} extends ${o.superclass.name}`:o.name;return s.push(`Class: ${a}`),s.push(""),s.push("Install:"),s.push(` npm i ${n}`),s.push(` import "${r}";`),s.push(` ${o.name}.register('${t}');`),s.push(...yr(o)),s.join(`
|
|
410
|
+
`)}function Zm(e,t=new Map){let n=e.map(i=>`| \`<${di(i,t)}>\` | \`${i.pkg}\` | ${i.version} | \`${i.importPath}\` |`),r=e.map(i=>{let a=di(i,t);return`### \`<${a}>\`
|
|
411
411
|
|
|
412
412
|
\`\`\`
|
|
413
|
-
${
|
|
414
|
-
\`\`\``}),o=["## Installed Components","",
|
|
413
|
+
${Xm(i,a)}
|
|
414
|
+
\`\`\``}),o=["## Installed Components","",si,...n];r.length>0&&o.push("",r.join(`
|
|
415
415
|
|
|
416
|
-
`));let
|
|
417
|
-
`);return`${[
|
|
416
|
+
`));let s=o.join(`
|
|
417
|
+
`);return`${[oi.trimEnd(),ai.trimEnd(),s,ii.trimEnd()].join(`
|
|
418
418
|
|
|
419
419
|
`)}
|
|
420
|
-
`}function
|
|
420
|
+
`}function Qm(){return Wt}function pi(e,t=new Map){return[{filename:Q,contents:Zm(e,t)},{filename:ge,contents:Qm()}]}import{appendFileSync as ed,readFileSync as hi}from"node:fs";import Ht from"node:path";import{simpleGit as td}from"simple-git";var nd="# Added by auro init \u2014 keep generated grounding/IntelliSense files tracked";function fi(e){return e.split(Ht.sep).join("/")}async function Ut(e,t){if(t.length===0)return[];try{return(await td({baseDir:e}).checkIgnore(t.map(fi))).map(fi)}catch{return[]}}function rd(e){let t=Ht.posix.dirname(e);return t==="."?"":t}function od(e){try{let t=hi(Ht.join(e,".gitignore"),"utf-8");return new Set(t.split(/\r?\n/).map(n=>n.trim()))}catch{return new Set}}function gi(e,t,n=!0){let r=Ht.join(e,".gitignore"),o="";try{o=hi(r,"utf-8")}catch{}let s=new Set(o.split(/\r?\n/).map(c=>c.trim())),i=n?t.filter(c=>!s.has(c.trim())):t;if(i.length===0)return;let a=o===""||o.endsWith(`
|
|
421
421
|
`)?"":`
|
|
422
|
-
`;try{
|
|
422
|
+
`;try{ed(r,`${a}${i.join(`
|
|
423
423
|
`)}
|
|
424
|
-
`,"utf-8")}catch{}}async function
|
|
425
|
-
`,"utf-8")}function
|
|
426
|
-
`,"utf-8")}let
|
|
427
|
-
`)}function Ce(e){return!Q.stdin.isTTY||!!Q.env.CI||!!e.nonInteractive||!!e.yes}async function vp(e){if(e.suggestedDefault){let{accept:n}=await ee.prompt([{type:"confirm",name:"accept",message:e.mixedPrefixes?`Existing registrations use more than one prefix. Use the most common, '${e.suggestedDefault}', as the default for the remaining components?`:`Use the detected prefix '${e.suggestedDefault}' as the default for the remaining components?`,default:!0}]);if(n)return e.suggestedDefault}let{prefix:t}=await ee.prompt([{type:"input",name:"prefix",message:"Prefix for Auro custom-element tags (e.g. myapp-; blank keeps the bare auro-* tags):",default:e.suggestedDefault??""}]);return String(t).trim()}function kp(e){let t=e.trim();return/^[a-z][a-z0-9-]*$/.test(t)?t.includes("-")?!0:"A custom-element tag must contain a hyphen (e.g. nav-menu).":"Use a lowercase tag starting with a letter (letters, digits, and hyphens only)."}async function $p(e,t){let{customize:n}=await ee.prompt([{type:"confirm",name:"customize",message:"Define a custom tag name for any installed component? (you'll be prompted per component; Enter keeps the calculated name)",default:!1}]);if(!n)return{};let r={};for(let o of e){let i=o.tagName,s=t.get(i)??i,{tag:a}=await ee.prompt([{type:"input",name:"tag",message:`Tag for ${o.declaration.name} (<${i}>):`,default:s,validate:kp}]),c=String(a).trim();c!==s&&(r[i]=c)}return r}function Ep(e,t){let n=e??ui();return{...n,init:{...n.init,prefix:{default:n.init.prefix.default,overrides:{...n.init.prefix.overrides,...t}}}}}var Sp={vscode:{label:"VS Code HTML custom-data",artifact:".vscode/auro.html-custom-data.json"},jsx:{label:"JSX/React type declarations",artifact:"auro-types/auro-jsx.d.ts"},svelte:{label:"Svelte type declarations",artifact:"auro-types/auro-svelte.d.ts"},cssSnippets:{label:"CSS ::part() snippets",artifact:".vscode/auro.code-snippets"}};async function Cp(e,t,n){let r=n?.init.editors,o=Ns(e),i=!Ce(t),s={vscode:!1,jsx:!1,svelte:!1,cssSnippets:!1},a=[];for(let c of Ps){let l=t[c];if(l!==void 0){s[c]=l;continue}let u=r?.[c];if(u!==void 0){s[c]=u;continue}if(i){let{label:m,artifact:p}=Sp[c];a.push({type:"confirm",name:c,message:`Generate ${m} (${p})?`,default:o[c]})}else s[c]=o[c]}if(a.length>0){let c=await ee.prompt(a);for(let{name:l}of a)s[l]=!!c[l]}return s}async function Ap(e,t){let n;try{n=yi(e)}catch(a){let c=a instanceof Error?a.message:String(a);return console.error(`\u26A0 Skipping formkit migration check: ${c}`),!1}if(n.length===0)return!1;let r=n.map(a=>a.pkg).join(", ");if(Ce(t))return console.error(`\u26A0 ${n.length} legacy standalone package(s) can be migrated to @aurodesignsystem/auro-formkit: ${r}. Run \`auro init\` interactively to apply the migration.`),!1;let{migrate:o}=await ee.prompt([{type:"confirm",name:"migrate",message:`${n.length} legacy standalone package(s) now live in auro-formkit (${r}). Migrate to auro-formkit now? This edits package.json and rewrites import specifiers.`,default:!1}]);if(!o)return!1;let i=Ue("Migrating to auro-formkit...").start(),s=bi(e,n);i.succeed(`Migrated ${s.packagesMigrated.length} package(s) to auro-formkit; rewrote ${s.rewriteCount} import(s) across ${s.filesChanged.length} file(s).`);for(let{file:a,specifier:c}of s.deepImports)console.error(`\u26A0 ${a}: left deep import '${c}' unchanged \u2014 update it to an @aurodesignsystem/auro-formkit subpath by hand.`);return console.error("Next: run `npm install`, then re-run `auro init` to regenerate grounding for auro-formkit."),!0}async function xp(e){let t=new Map(e.map(o=>[o.pkg,o.version])),n=Ue("Checking for newer component releases...").start(),r=await ke(t);if(r.length===0){n.succeed("All installed Auro components are on the latest release.");return}n.stop(),console.error($e(r))}async function Tp(e){let t=Q.cwd();if(e.reset){await Dp(t,e);return}let n=Ue("Detecting installed Auro components...").start(),{components:r,duplicates:o}=await Do();if(r.length===0){n.warn("No installed Auro components found; nothing to ground. Install an Auro component package and re-run `auro init`.");return}if(n.succeed(`Detected ${r.length} installed component(s) to ground.`),await Ap(t,e))return;let i;try{i=Ut(t)}catch(g){let y=g instanceof B||g instanceof Error?g.message:String(g);console.error(`Cannot read ${M}: ${y}`),Q.exit(1)}let s=pi(t),a=Ht(r,{config:i,scan:s,prefix:e.prefix}),l=!(e.prefix!==void 0||i?.init.prefix.default!==void 0)&&(a.needsDefaultPrefix||a.mixedPrefixes),u=e.prefix;if(l){if(Ce(e)){let g=a.needsDefaultPrefix?`${a.needingDefault.length} component(s) have no resolvable tag and no default prefix`:"existing registrations use inconsistent prefixes";console.error(`Cannot resolve component tags non-interactively: ${g}. Re-run with --prefix <prefix> (e.g. --prefix myapp-).`),Q.exit(1)}u=await vp(a),a=Ht(r,{config:i,scan:s,prefix:u})}if(a.needsDefaultPrefix&&(console.error("Unable to resolve a default prefix for every component. Re-run with --prefix <prefix>."),Q.exit(1)),!Ce(e)){let g=await $p(r,a.resolvedTags);Object.keys(g).length>0&&(a=Ht(r,{config:Ep(i,g),scan:s,prefix:u}))}let m=await Cp(t,e,i);a.config.init.editors=m;let p=Ue("Writing generated files...").start(),d={written:[],warnings:[]};try{for(let y of ri(r,a.resolvedTags))await yp.writeFile(bp.join(t,y.filename),y.contents,"utf-8");d=await ar(t,r,a.resolvedTags,m),mi(t,a.config);let g=d.written.length>0?` Editor IntelliSense: ${d.written.join(", ")}.`:"";p.succeed(`Wrote ${X}, ${pe}, and ${M} for ${r.length} component(s).${g}`)}catch(g){let y=g instanceof Error?g.message:String(g);p.fail(`Failed to write generated files: ${y}`),Q.exit(1)}for(let g of d.warnings)console.error(`\u26A0 ${g}`);for(let g of a.warnings)console.error(`\u26A0 ${g}`);for(let g of o)console.error(`\u26A0 Tag <${g.tagName}> is registered by multiple installed packages: ${g.packages.join(", ")}. Grounded once \u2014 verify which package you intend to use.`);a.reconciliationWarnings.length>0&&console.error(de(`\u26A0 ${a.reconciliationWarnings.length} component tag(s) may not match your app's registered tags`,a.reconciliationWarnings,"red")),a.noPrefixWarnings.length>0&&console.error(de(`\u26A0 ${a.noPrefixWarnings.length} component(s) grounded under bare 'auro-*' tags \u2014 pass a prefix to avoid collisions`,a.noPrefixWarnings,"yellow"));let f=sr(t,m);if(f.inconsistencies.length>0)try{let g=await ar(t,r,a.resolvedTags,m),y=new Set(d.warnings);for(let v of g.warnings)y.has(v)||console.error(`\u26A0 ${v}`);f=sr(t,m)}catch(g){let y=g instanceof Error?g.message:String(g);console.error(`\u26A0 Could not re-write editor artifacts to self-heal wiring: ${y}`)}f.inconsistencies.length>0&&console.error(de("\u26A0 Editor IntelliSense wiring is incomplete after writing",f.inconsistencies,"red")),f.markupDisabled&&console.error(de("\u26A0 VS Code markup IntelliSense is off \u2014 no <auro-*> completions or hover docs",["Type-checking may still work, but tag/attribute completions will not.","Re-run `auro init --vscode` to generate them."],"yellow"));let h=[...new Set([X,pe,M,...d.written])];await Rp(t,h,e),e.offline||await xp(r)}async function Rp(e,t,n){let r=await Ft(e,t);if(r.length===0)return;if(console.error(de(`\u26A0 ${r.length} file(s) auro init wrote are git-ignored and won't be committed`,[...r,"These are meant to be committed so your team and CI share the same grounding/IntelliSense."],"red")),Ce(n)&&!n.yes){console.error("\u26A0 Un-ignore them in .gitignore (or re-run with --yes) so they get committed.");return}if(!n.yes){let{fix:s}=await ee.prompt([{type:"confirm",name:"fix",message:"Add entries to .gitignore so these files stay tracked (committed)?",default:!0}]);if(!s)return}let{fixed:o,unfixable:i}=await ai(e,r);o.length>0&&console.error(`\u2714 Un-ignored ${o.length} file(s) in .gitignore so they will be committed.`),i.length>0&&console.error(de(`\u26A0 ${i.length} file(s) are still git-ignored \u2014 un-ignore them by hand`,[...i,"A parent directory is ignored by a rule auro init won't rewrite; edit .gitignore to re-include these paths."],"red"))}function Pp(e){return e.filesToRemove.length===0&&e.unmerges.length===0}async function Dp(e,t){let n=vi(e);if(Pp(n)){console.log("Nothing to reset \u2014 no `auro init` output found.");for(let c of n.filesToSkip)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);return}console.log("`auro init --reset` will:");for(let c of n.filesToRemove)console.log(` \u2022 remove ${c}`);for(let c of n.unmerges)console.log(` \u2022 remove the Auro entry from ${c.path}`);for(let c of n.dirsToPrune)console.log(` \u2022 remove ${c}/ if it is left empty`);for(let c of n.filesToSkip)console.log(` \u2022 keep ${c.path} (${c.reason})`);if(!Ce(t)){let{confirm:c}=await ee.prompt([{type:"confirm",name:"confirm",message:"Remove these files and config entries?",default:!1}]);if(!c){console.log("Reset aborted \u2014 nothing was changed.");return}}let r=Ue("Removing `auro init` output...").start(),o;try{o=ki(e,n)}catch(c){let l=c instanceof Error?c.message:String(c);r.fail(`Failed to reset: ${l}`),Q.exit(1)}let i=o.removed.length>0?`Removed ${o.removed.length} file(s)`:"Removed no files",s=o.unmerged.length>0?`, un-merged ${o.unmerged.join(", ")}`:"",a=o.prunedDirs.length>0?`, pruned ${o.prunedDirs.map(c=>`${c}/`).join(", ")}`:"";r.succeed(`${i}${s}${a}.`);for(let c of o.warnings)console.error(`\u26A0 ${c}`);for(let c of o.skipped)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);console.error("\u2139 Reset does not undo an `auro-formkit` migration. If you migrated a legacy standalone form package, revert those package.json and import changes with git.")}var mv=wp.command("init").description("Generate AI grounding files (AGENTS.md + CLAUDE.md) for the installed Auro components").option("--prefix <prefix>","Default custom-element tag prefix (e.g. myapp-) for components without an existing registration").option("--non-interactive","Never prompt; take the prefix from --prefix or fail cleanly (implied by a non-TTY stdin or CI)",!1).option("--yes","Alias for --non-interactive",!1).option("--offline","Skip the network check for newer component releases",!1).option("--vscode","Generate VS Code HTML custom-data IntelliSense (use --no-vscode to skip; default: auto-detect)").option("--no-vscode","Skip the VS Code HTML custom-data artifact").option("--jsx","Generate JSX/React type declarations (use --no-jsx to skip; default: auto-detect)").option("--no-jsx","Skip the JSX/React type declarations").option("--svelte","Generate Svelte type declarations (use --no-svelte to skip; default: auto-detect)").option("--no-svelte","Skip the Svelte type declarations").option("--css-snippets","Generate VS Code CSS ::part() snippets (use --no-css-snippets to skip; default: auto-detect)").option("--no-css-snippets","Skip the VS Code CSS ::part() snippets").option("--reset","Remove every file and config entry a previous `auro init` run created (does not undo an auro-formkit migration)",!1).action(Tp);import zt from"node:process";import{Logger as Mp}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Np}from"commander";import Ci from"ora";async function Ip(e,t){let n=r=>({headerPkg:e,installPkg:e,importSpecifier:e,redirectedToFormkit:!1,result:r});if(t.tag)return n(await O(`${e}@${t.tag}`));if(Y(e)){let r=await O(e,{allowNetwork:!1});return r.manifest?n(r):{headerPkg:G,installPkg:G,importSpecifier:ve(e),tagFilter:nr(e),redirectedToFormkit:!0,result:await O(G)}}return n(await O(e))}async function Op(e,t){let n=ei(e),r=Ci(`Fetching ${n}...`).start(),o=await Ip(n,t),{result:i}=o,s=i.target;i.manifest||(r.fail(i.transient?`Failed to fetch ${s}: ${i.reason}.`:`No custom-elements.json published for ${s}. It may not exist or may not publish a manifest yet.`),zt.exit(1));let c=(i.manifest.modules??[]).flatMap(m=>m.declarations??[]).filter(m=>m.customElement&&m.tagName).filter(m=>!o.tagFilter||m.tagName===o.tagFilter);c.length===0&&(r.fail(o.tagFilter?`No <${o.tagFilter}> element found in ${s}.`:`No registered custom elements found for ${s}.`),zt.exit(1));let l=i.source==="local"?` (local${i.version?` v${i.version}`:""})`:" (unpkg)";r.succeed(`${s} \u2014 ${c.length} custom element${c.length===1?"":"s"}${l}`),o.redirectedToFormkit&&console.error(`\u2139 ${o.tagFilter} now ships in ${G} \u2014 showing the monorepo version (the legacy standalone isn't installed).`);let u=null;if(i.source==="local"&&i.version){let m=Ci("Checking for a newer release...").start(),p=await ke(new Map([[o.headerPkg,i.version]]));m.stop(),p.length>0&&(u=$e(p))}if(t.json){zt.stdout.write(`${JSON.stringify(c,null,2)}
|
|
428
|
-
`),u&&console.error(u);return}
|
|
429
|
-
${c.map(m=>
|
|
424
|
+
`,"utf-8")}catch{}}async function yi(e,t){if(t.length===0)return{fixed:[],unfixable:[]};gi(e,[nd,...t.map(o=>`!${o}`)]);let n=await Ut(e,t);if(n.length>0){let o=od(e),s=[],i=new Set;for(let a of n){let c=rd(a);(c===""||o.has(`${c}/*`))&&o.has(`!${a}`)||(c!==""&&!i.has(c)&&!o.has(`${c}/*`)&&(i.add(c),s.push(`!${c}/`,`${c}/*`)),s.push(`!${a}`))}s.length>0&&(gi(e,s,!1),n=await Ut(e,t))}let r=new Set(n);return{fixed:t.filter(o=>!r.has(o)),unfixable:[...r]}}import{readFileSync as xi,writeFileSync as Si}from"node:fs";import Yt from"node:path";import{globSync as hd}from"glob";import{readFileSync as wi,writeFileSync as sd}from"node:fs";import zt from"node:path";import{globSync as id}from"glob";import D from"typescript";var Vt="auro-",wr="**/*.{js,jsx,ts,tsx,mjs,cjs,svelte}",kr=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**"],W=class extends Error{constructor(t){super(t),this.name="RegistryError"}};function ki(e=""){return{version:1,init:{prefix:{default:e,overrides:{}}}}}function ad(e,t){let n=e;if(!n||typeof n!="object")throw new W(`${t}: not a JSON object.`);if(n.version!==1)throw new W(`${t}: unsupported config version ${String(n.version)} (expected ${1}). Upgrade the CLI or remove the file.`);let r=n.init?.prefix;if(!r||typeof r.default!="string"||typeof r.overrides!="object"||r.overrides===null)throw new W(`${t}: malformed init.prefix block.`);return n}function Kt(e){let t=zt.join(e,N),n;try{n=wi(t,"utf-8")}catch(o){if(o.code==="ENOENT")return null;throw o}let r;try{r=JSON.parse(n)}catch{throw new W(`${N}: invalid JSON.`)}return ad(r,N)}function vi(e,t){let n=zt.join(e,N);sd(n,`${JSON.stringify(t,null,2)}
|
|
425
|
+
`,"utf-8")}function cd(e){switch(zt.extname(e).toLowerCase()){case".tsx":return D.ScriptKind.TSX;case".jsx":return D.ScriptKind.JSX;case".ts":case".mts":case".cts":return D.ScriptKind.TS;default:return D.ScriptKind.JS}}function ld(e){return e&&(D.isStringLiteral(e)||D.isNoSubstitutionTemplateLiteral(e))?e.text:null}function bi(e,t,n=cd(e)){let r=[],o=[],s=[],i;try{i=D.createSourceFile(e,t,D.ScriptTarget.ES2022,!0,n)}catch{return{matches:r,defaultRegistrations:o,warnings:[`${e}: could not be parsed; skipped.`]}}let a=c=>{if(D.isCallExpression(c)&&D.isPropertyAccessExpression(c.expression)&&c.expression.name.text==="register"){let l=c.expression.expression,u=D.isIdentifier(l)?l.text:void 0;if(c.arguments.length===0)u&&o.push(u);else{let m=ld(c.arguments[0]);m===null?s.push(`${e}: register() with a non-literal tag could not be resolved; skipped.`):r.push({className:u,tag:m})}}D.forEachChild(c,a)};return a(i),{matches:r,defaultRegistrations:o,warnings:s}}var br=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,ud=/\blang\s*=\s*["']?(?:ts|typescript)["']?/i;function md(e){let t=[];br.lastIndex=0;let n=br.exec(e);for(;n!==null;){let[,r,o]=n;t.push({content:o,scriptKind:ud.test(r)?D.ScriptKind.TS:D.ScriptKind.JS}),n=br.exec(e)}return t}function $i(e){let t=id(wr,{cwd:e,absolute:!0,nodir:!0,ignore:kr}),n=[],r=[],o=[],s=i=>{n.push(...i.matches),r.push(...i.defaultRegistrations??[]),o.push(...i.warnings)};for(let i of t){let a;try{a=wi(i,"utf-8")}catch{o.push(`${i}: could not be read; skipped.`);continue}if(zt.extname(i).toLowerCase()===".svelte")for(let{content:c,scriptKind:l}of md(a))s(bi(i,c,l));else s(bi(i,a))}return{matches:n,defaultRegistrations:r,warnings:o}}function Ei(e){return e.startsWith(Vt)?e.slice(Vt.length):e}function dd(e,t){let n=Ei(e);return t.endsWith(n)?t.slice(0,t.length-n.length):null}function pd(e){let t=new Map;for(let o of e)!o||o===Vt||t.set(o,(t.get(o)??0)+1);if(t.size===0)return{mixed:!1};let n,r=-1;for(let[o,s]of t)s>r&&(r=s,n=o);return{suggestion:n,mixed:t.size>1}}function fd(e,t,n=[]){let r=new Map;for(let a of e)r.set(a.declaration.name,a.tagName);let o=new Map,s=[];for(let a of t){let c=a.className?r.get(a.className):void 0;if(!c){s.push(`Found register('${a.tag}')${a.className?` on ${a.className}`:""} but could not tie it to an installed Auro component; ignored.`);continue}o.set(c,a.tag)}let i=new Map;for(let a of n){let c=r.get(a);c&&i.set(c,a)}return{overrides:o,defaultRegistered:i,warnings:s}}function gd(e,t){return!e||e===Vt?t:e+Ei(t)}function qt(e,t={}){let{config:n,scan:r,prefix:o}=t,s=n?.init.prefix.overrides??{},i=fd(e,r?.matches??[],r?.defaultRegistrations??[]),a=n?.init.prefix.default,c=o??a,l=new Map,u={...s},m=[],d=[...r?.warnings??[],...i.warnings],p=[],f=[];for(let v of e){let b=v.tagName,w=s[b];if(w!==void 0){l.set(b,w);continue}let oe=i.overrides.get(b);if(oe!==void 0){l.set(b,oe),u[b]=oe;continue}if(c===void 0){m.push(b);continue}let se=gd(c,b);l.set(b,se),se===b?f.push(`${b}: no custom prefix \u2014 grounding it under its bare 'auro-*' tag. Pass a prefix to avoid registration collisions.`):i.defaultRegistered.has(b)||p.push(`${b}: grounded as '<${se}>' from the '${c}' prefix, but no register('${se}') was found in your source. If ${v.declaration.name} is registered under a different tag (e.g. the default '<${b}>' from a side-effect import), IntelliSense will not match your markup \u2014 call ${v.declaration.name}.register('${se}') so your app matches the generated tags.`)}for(let[v,b]of i.defaultRegistered){let w=l.get(v);w!==void 0&&w!==v&&p.push(`${b}.register() uses the default '<${v}>' tag, but this project grounds it as '<${w}>'. Update the register() call to '${w}' so your app matches AGENTS.md.`)}let h=[...Object.entries(s),...i.overrides].map(([v,b])=>dd(v,b)),{suggestion:g,mixed:y}=pd(h),k=m.length>0&&c===void 0;return{resolvedTags:l,config:{version:1,init:{prefix:{default:c??g??"",overrides:u}}},needingDefault:m,needsDefaultPrefix:k,suggestedDefault:g,mixedPrefixes:y,warnings:d,reconciliationWarnings:p,noPrefixWarnings:f}}var vr="package.json";function yd(e){let t=e.match(/\n([ \t]+)\S/u);return t?t[1]:2}function Ai(e){let t;try{t=xi(Yt.join(e,vr),"utf-8")}catch(n){if(n.code==="ENOENT")return null;throw n}try{return{pkgJson:JSON.parse(t),indent:yd(t)}}catch{throw new Error(`${vr}: invalid JSON.`)}}function Ci(e){let t=Ai(e);if(!t)return[];let{pkgJson:n}=t,r=[],o=["dependencies","devDependencies"];for(let s of ur)for(let i of o){let a=n[i]?.[s];if(typeof a=="string"){r.push({pkg:s,version:a,field:i});break}}return r}function bd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wd(e){return e.split(Yt.sep).join("/")}function kd(e,t){let n=e,r=0,o=[];for(let s of t){let i=bd(s),a=new RegExp(`(['"\`])${i}\\1`,"g");n=n.replace(a,(u,m)=>(r+=1,`${m}${Ee(s)}${m}`));let c=new RegExp(`(['"\`])(${i}/[^'"\`]*)\\1`,"g"),l=c.exec(n);for(;l!==null;)o.push(l[2]),l=c.exec(n)}return{next:n,rewrites:r,deep:o}}function Ti(e,t){let n=[...new Set(t.map(i=>i.pkg).filter(Z))],r={packagesMigrated:[],formkit:"present",filesChanged:[],rewriteCount:0,deepImports:[]};if(n.length===0)return r;let o=Ai(e);if(o){let{pkgJson:i,indent:a}=o;for(let l of["dependencies","devDependencies"]){let u=i[l];if(u)for(let m of n)m in u&&(delete u[m],r.packagesMigrated.includes(m)||r.packagesMigrated.push(m))}!!i.dependencies?.[G]||!!i.devDependencies?.[G]?r.formkit="present":(i.dependencies??={},i.dependencies[G]="latest",r.formkit="added"),Si(Yt.join(e,vr),`${JSON.stringify(i,null,a)}
|
|
426
|
+
`,"utf-8")}let s=hd(wr,{cwd:e,absolute:!0,nodir:!0,ignore:kr});for(let i of s){let a;try{a=xi(i,"utf-8")}catch{continue}let{next:c,rewrites:l,deep:u}=kd(a,n),m=wd(Yt.relative(e,i));for(let d of u)r.deepImports.push({file:m,specifier:d});l>0&&c!==a&&(Si(i,c,"utf-8"),r.filesChanged.push(m),r.rewriteCount+=l)}return r}import{existsSync as Ri,readdirSync as vd,readFileSync as $d,rmdirSync as Ed,rmSync as Sd,writeFileSync as xd}from"node:fs";import Ad from"node:path";import{parse as Cd}from"jsonc-parser";function ee(e,t){return Ad.join(e,...t.split("/"))}function Td(e){let t=Cd(e,[],{allowTrailingComma:!0});return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length===0}function Rd(e){return e.includes("//")||e.includes("/*")}function $r(e){try{return $d(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}var Dd=[me,wt,de,pe];function Pd(e,t){return e===null?null:t==="agents"?e.includes(Gt)?"remove":`not recognized as an \`auro init\` file (missing the "${Gt}" marker)`:e.trim()===Wt.trim()?"remove":"contains content beyond the generated `@AGENTS.md` import"}function Di(e){let t=[],n=[],r=[];for(let[a,c]of[[Q,"agents"],[ge,"claude"]]){let l=Pd($r(ee(e,a)),c);l==="remove"?t.push(a):l!==null&&n.push({path:a,reason:l})}if(Ri(ee(e,N)))try{Kt(e)&&t.push(N)}catch(a){let c=a instanceof W?a.message:String(a);n.push({path:N,reason:c})}for(let a of Dd)Ri(ee(e,a))&&t.push(a);let o=[],s=`${T}/${ue}`,i=$r(ee(e,s));if(i!==null){let a=ei(i);a.warning?r.push(a.warning):a.changed&&(Td(a.contents)&&!Rd(a.contents)?t.push(s):o.push({path:s,result:a}))}for(let a of["tsconfig.json","jsconfig.json"]){let c=$r(ee(e,a));if(c===null)continue;let l=ti(c,void 0,a);l.warning?r.push(l.warning):l.changed&&o.push({path:a,result:l});break}return{filesToRemove:t,filesToSkip:n,unmerges:o,warnings:r,dirsToPrune:[Ue,T]}}function Md(e){try{return vd(e).length===0}catch{return!1}}function Pi(e,t){let n=[];for(let s of t.filesToRemove)Sd(ee(e,s),{force:!0}),n.push(s);let r=[];for(let{path:s,result:i}of t.unmerges)xd(ee(e,s),i.contents,"utf-8"),r.push(s);let o=[];for(let s of t.dirsToPrune){let i=ee(e,s);Md(i)&&(Ed(i),o.push(s))}return{removed:n,unmerged:r,prunedDirs:o,skipped:t.filesToSkip,warnings:t.warnings}}import Mi from"chalk";var Nd=78,Ni=74,Oi=" \u2022 ",Od=" ";function Id(e,t){let n=e.split(/\s+/u).filter(Boolean);if(n.length===0)return[""];let r=[],o=n[0];for(let s of n.slice(1))o.length+1+s.length<=t?o+=` ${s}`:(r.push(o),o=s);return r.push(o),r}function he(e,t,n="red"){if(t.length===0)return"";let r=Mi[n].bold,o=[];t.forEach((c,l)=>{Id(c,Ni-Oi.length).forEach((m,d)=>{let p=d===0?Oi:Od;o.push(Mi[n](p+m))}),l<t.length-1&&o.push("")});let s=e.length+(e.includes("\u26A0")?1:0),i=Math.min(Math.max(s,Ni),Nd),a="\u2500".repeat(i);return["",r(`\u250C${a}\u2510`),r(e),r(`\u2514${a}\u2518`),...o,""].join(`
|
|
427
|
+
`)}function Te(e){return!te.stdin.isTTY||!!te.env.CI||!!e.nonInteractive||!!e.yes}async function Ld(e){if(e.suggestedDefault){let{accept:n}=await ne.prompt([{type:"confirm",name:"accept",message:e.mixedPrefixes?`Existing registrations use more than one prefix. Use the most common, '${e.suggestedDefault}', as the default for the remaining components?`:`Use the detected prefix '${e.suggestedDefault}' as the default for the remaining components?`,default:!0}]);if(n)return e.suggestedDefault}let{prefix:t}=await ne.prompt([{type:"input",name:"prefix",message:"Prefix for Auro custom-element tags (e.g. myapp-; blank keeps the bare auro-* tags):",default:e.suggestedDefault??""}]);return String(t).trim()}function Bd(e){let t=e.trim();return/^[a-z][a-z0-9-]*$/.test(t)?t.includes("-")?!0:"A custom-element tag must contain a hyphen (e.g. nav-menu).":"Use a lowercase tag starting with a letter (letters, digits, and hyphens only)."}async function Gd(e,t){let{customize:n}=await ne.prompt([{type:"confirm",name:"customize",message:"Define a custom tag name for any installed component? (you'll be prompted per component; Enter keeps the calculated name)",default:!1}]);if(!n)return{};let r={};for(let o of e){let s=o.tagName,i=t.get(s)??s,{tag:a}=await ne.prompt([{type:"input",name:"tag",message:`Tag for ${o.declaration.name} (<${s}>):`,default:i,validate:Bd}]),c=String(a).trim();c!==i&&(r[s]=c)}return r}function Wd(e,t){let n=e??ki();return{...n,init:{...n.init,prefix:{default:n.init.prefix.default,overrides:{...n.init.prefix.overrides,...t}}}}}var Ud={vscode:{label:"VS Code HTML custom-data",artifact:".vscode/auro.html-custom-data.json"},jsx:{label:"JSX/React type declarations",artifact:"auro-types/auro-jsx.d.ts"},svelte:{label:"Svelte type declarations",artifact:"auro-types/auro-svelte.d.ts"},cssSnippets:{label:"CSS ::part() snippets",artifact:".vscode/auro.code-snippets"}};async function Hd(e,t,n){let r=n?.init.editors,o=Us(e),s=!Te(t),i={vscode:!1,jsx:!1,svelte:!1,cssSnippets:!1},a=[];for(let c of Bs){let l=t[c];if(l!==void 0){i[c]=l;continue}let u=r?.[c];if(u!==void 0){i[c]=u;continue}if(s){let{label:m,artifact:d}=Ud[c];a.push({type:"confirm",name:c,message:`Generate ${m} (${d})?`,default:o[c]})}else i[c]=o[c]}if(a.length>0){let c=await ne.prompt(a);for(let{name:l}of a)i[l]=!!c[l]}return i}async function Jd(e,t){let n;try{n=Ci(e)}catch(a){let c=a instanceof Error?a.message:String(a);return console.error(`\u26A0 Skipping formkit migration check: ${c}`),!1}if(n.length===0)return!1;let r=n.map(a=>a.pkg).join(", ");if(Te(t))return console.error(`\u26A0 ${n.length} legacy standalone package(s) can be migrated to @aurodesignsystem/auro-formkit: ${r}. Run \`auro init\` interactively to apply the migration.`),!1;let{migrate:o}=await ne.prompt([{type:"confirm",name:"migrate",message:`${n.length} legacy standalone package(s) now live in auro-formkit (${r}). Migrate to auro-formkit now? This edits package.json and rewrites import specifiers.`,default:!1}]);if(!o)return!1;let s=Ve("Migrating to auro-formkit...").start(),i=Ti(e,n);s.succeed(`Migrated ${i.packagesMigrated.length} package(s) to auro-formkit; rewrote ${i.rewriteCount} import(s) across ${i.filesChanged.length} file(s).`);for(let{file:a,specifier:c}of i.deepImports)console.error(`\u26A0 ${a}: left deep import '${c}' unchanged \u2014 update it to an @aurodesignsystem/auro-formkit subpath by hand.`);return console.error("Next: run `npm install`, then re-run `auro init` to regenerate grounding for auro-formkit."),!0}async function Vd(e){let t=new Map(e.map(o=>[o.pkg,o.version])),n=Ve("Checking for newer component releases...").start(),r=await Se(t);if(r.length===0){n.succeed("All installed Auro components are on the latest release.");return}n.stop(),console.error(xe(r))}async function zd(e){let t=te.cwd();if(e.reset){await Yd(t,e);return}let n=Ve("Detecting installed Auro components...").start(),{components:r,duplicates:o}=await Go();if(r.length===0){n.warn("No installed Auro components found; nothing to ground. Install an Auro component package and re-run `auro init`.");return}if(n.succeed(`Detected ${r.length} installed component(s) to ground.`),await Jd(t,e))return;let s;try{s=Kt(t)}catch(g){let y=g instanceof W||g instanceof Error?g.message:String(g);console.error(`Cannot read ${N}: ${y}`),te.exit(1)}let i=$i(t),a=qt(r,{config:s,scan:i,prefix:e.prefix}),l=!(e.prefix!==void 0||s?.init.prefix.default!==void 0)&&(a.needsDefaultPrefix||a.mixedPrefixes),u=e.prefix;if(l){if(Te(e)){let g=a.needsDefaultPrefix?`${a.needingDefault.length} component(s) have no resolvable tag and no default prefix`:"existing registrations use inconsistent prefixes";console.error(`Cannot resolve component tags non-interactively: ${g}. Re-run with --prefix <prefix> (e.g. --prefix myapp-).`),te.exit(1)}u=await Ld(a),a=qt(r,{config:s,scan:i,prefix:u})}if(a.needsDefaultPrefix&&(console.error("Unable to resolve a default prefix for every component. Re-run with --prefix <prefix>."),te.exit(1)),!Te(e)){let g=await Gd(r,a.resolvedTags);Object.keys(g).length>0&&(a=qt(r,{config:Wd(s,g),scan:i,prefix:u}))}let m=await Hd(t,e,s);a.config.init.editors=m;let d=Ve("Writing generated files...").start(),p={written:[],warnings:[]};try{for(let y of pi(r,a.resolvedTags))await jd.writeFile(_d.join(t,y.filename),y.contents,"utf-8");p=await hr(t,r,a.resolvedTags,m),vi(t,a.config);let g=p.written.length>0?` Editor IntelliSense: ${p.written.join(", ")}.`:"";d.succeed(`Wrote ${Q}, ${ge}, and ${N} for ${r.length} component(s).${g}`)}catch(g){let y=g instanceof Error?g.message:String(g);d.fail(`Failed to write generated files: ${y}`),te.exit(1)}for(let g of p.warnings)console.error(`\u26A0 ${g}`);for(let g of a.warnings)console.error(`\u26A0 ${g}`);for(let g of o)console.error(`\u26A0 Tag <${g.tagName}> is registered by multiple installed packages: ${g.packages.join(", ")}. Grounded once \u2014 verify which package you intend to use.`);a.reconciliationWarnings.length>0&&console.error(he(`\u26A0 ${a.reconciliationWarnings.length} component tag(s) may not match your app's registered tags`,a.reconciliationWarnings,"red")),a.noPrefixWarnings.length>0&&console.error(he(`\u26A0 ${a.noPrefixWarnings.length} component(s) grounded under bare 'auro-*' tags \u2014 pass a prefix to avoid collisions`,a.noPrefixWarnings,"yellow"));let f=fr(t,m);if(f.inconsistencies.length>0)try{let g=await hr(t,r,a.resolvedTags,m),y=new Set(p.warnings);for(let k of g.warnings)y.has(k)||console.error(`\u26A0 ${k}`);f=fr(t,m)}catch(g){let y=g instanceof Error?g.message:String(g);console.error(`\u26A0 Could not re-write editor artifacts to self-heal wiring: ${y}`)}f.inconsistencies.length>0&&console.error(he("\u26A0 Editor IntelliSense wiring is incomplete after writing",f.inconsistencies,"red")),f.markupDisabled&&console.error(he("\u26A0 VS Code markup IntelliSense is off \u2014 no <auro-*> completions or hover docs",["Type-checking may still work, but tag/attribute completions will not.","Re-run `auro init --vscode` to generate them."],"yellow"));let h=[...new Set([Q,ge,N,...p.written])];await Kd(t,h,e),e.offline||await Vd(r)}async function Kd(e,t,n){let r=await Ut(e,t);if(r.length===0)return;if(console.error(he(`\u26A0 ${r.length} file(s) auro init wrote are git-ignored and won't be committed`,[...r,"These are meant to be committed so your team and CI share the same grounding/IntelliSense."],"red")),Te(n)&&!n.yes){console.error("\u26A0 Un-ignore them in .gitignore (or re-run with --yes) so they get committed.");return}if(!n.yes){let{fix:i}=await ne.prompt([{type:"confirm",name:"fix",message:"Add entries to .gitignore so these files stay tracked (committed)?",default:!0}]);if(!i)return}let{fixed:o,unfixable:s}=await yi(e,r);o.length>0&&console.error(`\u2714 Un-ignored ${o.length} file(s) in .gitignore so they will be committed.`),s.length>0&&console.error(he(`\u26A0 ${s.length} file(s) are still git-ignored \u2014 un-ignore them by hand`,[...s,"A parent directory is ignored by a rule auro init won't rewrite; edit .gitignore to re-include these paths."],"red"))}function qd(e){return e.filesToRemove.length===0&&e.unmerges.length===0}async function Yd(e,t){let n=Di(e);if(qd(n)){console.log("Nothing to reset \u2014 no `auro init` output found.");for(let c of n.filesToSkip)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);return}console.log("`auro init --reset` will:");for(let c of n.filesToRemove)console.log(` \u2022 remove ${c}`);for(let c of n.unmerges)console.log(` \u2022 remove the Auro entry from ${c.path}`);for(let c of n.dirsToPrune)console.log(` \u2022 remove ${c}/ if it is left empty`);for(let c of n.filesToSkip)console.log(` \u2022 keep ${c.path} (${c.reason})`);if(!Te(t)){let{confirm:c}=await ne.prompt([{type:"confirm",name:"confirm",message:"Remove these files and config entries?",default:!1}]);if(!c){console.log("Reset aborted \u2014 nothing was changed.");return}}let r=Ve("Removing `auro init` output...").start(),o;try{o=Pi(e,n)}catch(c){let l=c instanceof Error?c.message:String(c);r.fail(`Failed to reset: ${l}`),te.exit(1)}let s=o.removed.length>0?`Removed ${o.removed.length} file(s)`:"Removed no files",i=o.unmerged.length>0?`, un-merged ${o.unmerged.join(", ")}`:"",a=o.prunedDirs.length>0?`, pruned ${o.prunedDirs.map(c=>`${c}/`).join(", ")}`:"";r.succeed(`${s}${i}${a}.`);for(let c of o.warnings)console.error(`\u26A0 ${c}`);for(let c of o.skipped)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);console.error("\u2139 Reset does not undo an `auro-formkit` migration. If you migrated a legacy standalone form package, revert those package.json and import changes with git.")}var Zk=Fd.command("init").description("Generate AI grounding files (AGENTS.md + CLAUDE.md) for the installed Auro components").option("--prefix <prefix>","Default custom-element tag prefix (e.g. myapp-) for components without an existing registration").option("--non-interactive","Never prompt; take the prefix from --prefix or fail cleanly (implied by a non-TTY stdin or CI)",!1).option("--yes","Alias for --non-interactive",!1).option("--offline","Skip the network check for newer component releases",!1).option("--vscode","Generate VS Code HTML custom-data IntelliSense (use --no-vscode to skip; default: auto-detect)").option("--no-vscode","Skip the VS Code HTML custom-data artifact").option("--jsx","Generate JSX/React type declarations (use --no-jsx to skip; default: auto-detect)").option("--no-jsx","Skip the JSX/React type declarations").option("--svelte","Generate Svelte type declarations (use --no-svelte to skip; default: auto-detect)").option("--no-svelte","Skip the Svelte type declarations").option("--css-snippets","Generate VS Code CSS ::part() snippets (use --no-css-snippets to skip; default: auto-detect)").option("--no-css-snippets","Skip the VS Code CSS ::part() snippets").option("--reset","Remove every file and config entry a previous `auro init` run created (does not undo an auro-formkit migration)",!1).action(zd);import Xt from"node:process";import{Logger as Xd}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Zd}from"commander";import Ii from"ora";async function Qd(e,t){let n=r=>({headerPkg:e,installPkg:e,importSpecifier:e,redirectedToFormkit:!1,result:r});if(t.tag)return n(await _(`${e}@${t.tag}`));if(Z(e)){let r=await _(e,{allowNetwork:!1});return r.manifest?n(r):{headerPkg:G,installPkg:G,importSpecifier:Ee(e),tagFilter:mr(e),redirectedToFormkit:!0,result:await _(G)}}return n(await _(e))}async function ep(e,t){let n=ui(e),r=Ii(`Fetching ${n}...`).start(),o=await Qd(n,t),{result:s}=o,i=s.target;s.manifest||(r.fail(s.transient?`Failed to fetch ${i}: ${s.reason}.`:`No custom-elements.json published for ${i}. It may not exist or may not publish a manifest yet.`),Xt.exit(1));let c=(s.manifest.modules??[]).flatMap(m=>m.declarations??[]).filter(m=>m.customElement&&m.tagName).filter(m=>!o.tagFilter||m.tagName===o.tagFilter);c.length===0&&(r.fail(o.tagFilter?`No <${o.tagFilter}> element found in ${i}.`:`No registered custom elements found for ${i}.`),Xt.exit(1));let l=s.source==="local"?` (local${s.version?` v${s.version}`:""})`:" (unpkg)";r.succeed(`${i} \u2014 ${c.length} custom element${c.length===1?"":"s"}${l}`),o.redirectedToFormkit&&console.error(`\u2139 ${o.tagFilter} now ships in ${G} \u2014 showing the monorepo version (the legacy standalone isn't installed).`);let u=null;if(s.source==="local"&&s.version){let m=Ii("Checking for a newer release...").start(),d=await Se(new Map([[o.headerPkg,s.version]]));m.stop(),d.length>0&&(u=xe(d))}if(t.json){Xt.stdout.write(`${JSON.stringify(c,null,2)}
|
|
428
|
+
`),u&&console.error(u);return}Xt.stdout.write(`
|
|
429
|
+
${c.map(m=>mi(o.headerPkg,m,{installPkg:o.installPkg,importSpecifier:o.importSpecifier})).join(`
|
|
430
430
|
|
|
431
431
|
---
|
|
432
432
|
|
|
433
433
|
`)}
|
|
434
|
-
`),
|
|
435
|
-
Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var
|
|
434
|
+
`),Xd.info(`
|
|
435
|
+
Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var cv=Zd.command("component <name>").description("Look up an Auro component's API (attributes, properties, slots, events, CSS parts) from its published Custom Elements Manifest").option("-t, --tag <version>","npm dist-tag or version to look up (default: latest); pins the standalone package for a legacy form component").option("--json","Output the raw manifest declaration(s) as JSON",!1).action(ep);import{program as tp}from"commander";import np from"ora";var Er=tp.command("docs").description("Generate API documentation").option("-c, --cem","Generate Custom Elements Manifest (CEM) file",!1).option("-a, --api","Creates api md file from CEM",!1).option("-w, --watch","Watch for changes and rebuild docs",!1).option("-r, --readme-template <url>","URL to the README template file").option("--skip-readme","Skip README.md processing",!1);Er=Xe(Er);var rp={cem:st,api:it,docs:Vr,serve:Kr,watchDocs:qr};async function op(e,t=rp){try{e.cem&&await t.cem(),e.api&&await t.api();try{await t.docs(e)}catch(n){if(!e.watch)throw n}e.serve&&await t.serve(e),e.watch&&await t.watchDocs(e)}catch(n){np().fail(`Docs failed: ${n instanceof Error?n.message:String(n)}`),process.exit(1)}}var fv=Er.action(e=>op(e));import{program as lp}from"commander";import{Octokit as Sr}from"@octokit/rest";import*as Qt from"azure-devops-node-api";import Zt from"ora";var sp=async e=>{let t=process.env.GH_TOKEN;if(!t)throw new Error("GH_TOKEN environment variable is required");let n=new Sr({auth:t}),r,o,s;if(e.includes("github.com")){let a=e.match(/github\.com\/([^\/]+)\/([^\/]+)\/issues\/(\d+)/);if(!a)throw new Error("Invalid GitHub issue URL format");[,r,o,s]=a}else if(e.includes("#")){let a=e.match(/([^\/]+)\/([^#]+)#(\d+)/);if(!a)throw new Error("Invalid GitHub issue reference format");[,r,o,s]=a}else throw new Error("Issue must be provided as full URL or in format 'owner/repo#number'");let i=Number.parseInt(s,10);try{let{data:a}=await n.rest.issues.get({owner:r,repo:o,issue_number:i});return{title:a.title,body:a.body??null,html_url:a.html_url,number:a.number,repository:{owner:{login:r},name:o}}}catch(a){throw new Error(`Failed to fetch GitHub issue: ${a}`)}},ip=async e=>{let t=process.env.GH_TOKEN;if(!t)return null;let n=new Sr({auth:t});try{let r=`
|
|
436
436
|
query($owner: String!, $repo: String!, $issueNumber: Int!) {
|
|
437
437
|
repository(owner: $owner, name: $repo) {
|
|
438
438
|
issue(number: $issueNumber) {
|
|
@@ -458,7 +458,7 @@ Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var kv=Np.command("c
|
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
`,o={owner:e.repository.owner.login,repo:e.repository.name,issueNumber:e.number},
|
|
461
|
+
`,o={owner:e.repository.owner.login,repo:e.repository.name,issueNumber:e.number},i=(await n.graphql(r,o)).repository.issue.projectItems.nodes.find(a=>a.project.number===19);if(i){let a=i.fieldValues.nodes.find(c=>c.field?.name?.toLowerCase()==="ado"&&c.text?.trim());if(a?.text?.trim())return a.text.trim()}return null}catch(r){return console.error(`Failed to check existing ADO link: ${r}`),null}},ap=async(e,t)=>{let n=process.env.GH_TOKEN;if(!n)throw new Error("GH_TOKEN environment variable is required");let r=new Sr({auth:n}),o=19;try{let s=`
|
|
462
462
|
query($org: String!, $projectNumber: Int!, $owner: String!, $repo: String!, $issueNumber: Int!) {
|
|
463
463
|
organization(login: $org) {
|
|
464
464
|
projectV2(number: $projectNumber) {
|
|
@@ -495,7 +495,7 @@ Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var kv=Np.command("c
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
`,
|
|
498
|
+
`,i={org:"AlaskaAirlines",projectNumber:o,owner:e.repository.owner.login,repo:e.repository.name,issueNumber:e.number},a=await r.graphql(s,i),c=a.organization.projectV2.id,l=a.repository.issue.id,u=a.organization.projectV2.fields.nodes.find(d=>d.name?.toLowerCase()==="ado"),m=a.repository.issue.projectItems.nodes.find(d=>d.project.number===o)?.id;if(m||(m=(await r.graphql(`
|
|
499
499
|
mutation($projectId: ID!, $contentId: ID!) {
|
|
500
500
|
addProjectV2ItemById(
|
|
501
501
|
input: {
|
|
@@ -525,12 +525,25 @@ Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var kv=Np.command("c
|
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
`,{projectId:c,itemId:m,fieldId:u.id,value:t});else if(!u)throw new Error("No 'ado' field found in GitHub project")}catch(
|
|
529
|
-
${r.body??""}`;for(let
|
|
530
|
-
${n.map(
|
|
531
|
-
`)}`),t}function
|
|
532
|
-
${e.map(
|
|
533
|
-
`)}`;for(let[o,
|
|
534
|
-
${
|
|
528
|
+
`,{projectId:c,itemId:m,fieldId:u.id,value:t});else if(!u)throw new Error("No 'ado' field found in GitHub project")}catch(s){console.error(`Failed to update GitHub project: ${s}`)}},cp=async e=>{let t=process.env.ADO_TOKEN;if(!t)throw new Error("ADO_TOKEN environment variable is required");let n="https://dev.azure.com/itsals",r="E_Retain_Content",o="E_Retain_Content\\Auro Design System",s=Qt.getPersonalAccessTokenHandler(t),a=await new Qt.WebApi(n,s).getWorkItemTrackingApi();try{let c=[{op:"add",path:"/fields/System.Title",value:e.title},{op:"add",path:"/fields/System.Description",value:`GitHub Issue: <a href="${e.html_url}">${e.html_url}</a>`},{op:"add",path:"/fields/System.AreaPath",value:o}];return await a.createWorkItem(null,c,r,"User Story")}catch(c){throw new Error(`Failed to create ADO work item: ${c}`)}},ji=async e=>{let t=Zt(`Processing GitHub issue: ${e}`).start();try{if(!process.env.GH_TOKEN)throw new Error("GH_TOKEN environment variable is required");if(!process.env.ADO_TOKEN)throw new Error("ADO_TOKEN environment variable is required");t.text="Fetching GitHub issue details...";let n=await sp(e);t.succeed(`Found issue: "${n.title}"`);let r=Zt("Checking for existing ADO work item...").start(),o=await ip(n);if(o){r.succeed("ADO work item already exists for this issue!"),console.log(`${o}`);return}r.succeed("No existing ADO work item found");let s=Zt("Creating new ADO work item...").start(),i=await cp(n);if(s.succeed(`Successfully created ADO work item #${i.id}`),console.log(`Work item: ${i._links?.html?.href||"N/A"}`),i._links?.html?.href){let a=Zt("Adding to GitHub project and updating ADO field...").start();await ap(n,i._links.html.href),a.succeed("Updated GitHub project with ADO link")}}catch(n){t.fail(`Error: ${n instanceof Error?n.message:n}`),process.exit(1)}};var vv=lp.command("ado").description("Generate ADO item from GitHub issue").option("-g, --gh-issue <issue>","What GitHub issue to use").action(async e=>{e.ghIssue&&await ji(e.ghIssue)});import{program as Ep}from"commander";import{Octokit as kp}from"@octokit/rest";import{simpleGit as vp}from"simple-git";import*as en from"azure-devops-node-api";import{WorkItemErrorPolicy as _i,WorkItemExpand as up}from"azure-devops-node-api/interfaces/WorkItemTrackingInterfaces.js";var Li="https://dev.azure.com/itsals",xr="E_Retain_Content",Bi="auro-rcs",mp=new Set(["closed","removed"]);function Gi(e){let t=new Set,n=/AB#(\d+)/gi;for(let r of e){let o=r.message??`${r.subject??""}
|
|
529
|
+
${r.body??""}`;for(let s of o.matchAll(n)){let i=Number.parseInt(s[1],10);Number.isNaN(i)||t.add(i)}}return[...t]}async function dp(){let e=process.env.ADO_TOKEN;if(!e)throw new Error("ADO_TOKEN environment variable is required to resolve the Release ticket.");let t=en.getPersonalAccessTokenHandler(e);return new en.WebApi(Li,t).getWorkItemTrackingApi()}function pp(e){if(!e)return null;let t=e.match(/\/workItems\/(\d+)(?:\/)?$/i);return t?Number.parseInt(t[1],10):null}function fp(e){let t=e.fields?.["System.Tags"];return typeof t!="string"?!1:t.split(";").map(n=>n.trim().toLowerCase()).includes(Bi)}function Fi(e){let t=e.fields?.["System.State"];return typeof t!="string"||!mp.has(t.toLowerCase())}function gp(e){let t=e.filter(Fi),n=e.filter(r=>!Fi(r));return n.length>0&&console.log(`Ignoring ${n.length} closed Release ticket(s):
|
|
530
|
+
${n.map(Ar).join(`
|
|
531
|
+
`)}`),t}function Cr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function hp(e){let t=Cr(e),n=t.replace(/^auro /,"");return[...new Set([t,n])].filter(Boolean)}function yp(e,t){let n=e.fields?.["System.AreaPath"];return typeof n!="string"?!1:n.split("\\").map(Cr).some(r=>t.includes(r))}function bp(e,t){let n=e.fields?.["System.Title"];if(typeof n!="string")return!1;let r=` ${Cr(n)} `;return t.some(o=>r.includes(` ${o} `))}function Ar(e){let t=e.fields?.["System.Title"]??"(no title)",n=e.fields?.["System.AreaPath"]??"(no area path)",r=e.fields?.["System.State"]??"(no state)";return`#${e.id} "${t}" [${n}] (${r})`}function wp(e,t){let n=hp(t),r=`
|
|
532
|
+
${e.map(Ar).join(`
|
|
533
|
+
`)}`;for(let[o,s]of[["Area Path",yp],["title",bp]]){let i=e.filter(a=>s(a,n));if(i.length===1)return console.log(`Found ${e.length} Release tickets; selected #${i[0].id} for "${t}" by ${o}.`),i[0];if(i.length>1)throw new Error(`Found ${i.length} Release tickets whose ${o} matches "${t}":
|
|
534
|
+
${i.map(Ar).join(`
|
|
535
535
|
`)}
|
|
536
|
-
Only one Release Candidate ticket per repo is supported.`)}throw new Error(`Found ${e.length} Release tickets but none could be matched to "${t}" by Area Path or title:${r}`)}async function Mi(e,t){if(e.length===0)return console.log("No ADO work item references (AB#<id>) found in the RC commits."),null;let n=await Vp(),r=await n.getWorkItems(e,void 0,void 0,Jp.Relations,xi.Omit,hr),o=new Set;for(let u of r??[])for(let m of u.relations??[]){let p=Kp(m.url);p!==null&&o.add(p)}if(o.size===0)return console.log(`None of the committed work items (${e.join(", ")}) link to another work item in ADO.`),null;let i=await n.getWorkItems([...o],["System.Title","System.Tags","System.AreaPath","System.State"],void 0,void 0,xi.Omit,hr),s=Yp((i??[]).filter(qp));if(s.length===0)return console.log(`No open Release ticket (tagged "${Pi}") is linked to the committed work items (${e.join(", ")}).`),null;let a=s.length===1?s[0]:ed(s,t);if(a.id===void 0)throw new Error("Failed to resolve the Release ticket details from ADO.");let c=typeof a.fields?.["System.Title"]=="string"?a.fields["System.Title"]:`Work item ${a.id}`,l=a._links?.html?.href??`${Ri}/${hr}/_workitems/edit/${a.id}`;return{id:a.id,url:l,title:c}}var He="dev",rd="main",Yt=class e{constructor(t,n,r){this.repoInfo={owner:t,repo:n},this.octokit=r}static async create(){let t=process.env.GITHUB_TOKEN;if(!t)throw new Error("GITHUB_TOKEN is required to run RC workflow.");if(!process.env.ADO_TOKEN)throw new Error("ADO_TOKEN is required to resolve the ADO Release ticket for the RC workflow.");let n=await V.getRepoOwnerAndName(),r=new td({auth:t});if(!n)throw new Error("Failed to retrieve repository information. Ensure you're in a valid git repository.");let o=await e.getTriggerBranchName();return o&&o!==He&&(console.log(`Switching from ${o} to ${He} branch...`),await nd().checkout(He)),new e(n.owner,n.repo,r)}get owner(){return this.repoInfo.owner}get repo(){return this.repoInfo.repo}get repoData(){return{...this.repoInfo}}async createReleaseCandidate(){let t=await this.resolveReleaseTicket();if(!t){console.log("No ADO Release ticket is linked to the new commits on `dev`. Skipping Release PR.");return}console.log(`Using ADO Release ticket #${t.id} (${t.title}) -> ${t.url}`);let n=await this.getLinkedPrByHead(t.id);if(n?.multipleOpen)throw new Error("Multiple open RC PRs found for the same rc/<ticketId> branch.");n?.state==="closed"&&(console.log("Linked RC PR is closed. Creating a new RC PR on the same branch."),n=null),await this.createOrUpdateRcBranch(t.id),n?await this.updateRcPr(t,n.number):n=await this.createRcPr(t)}async resolveReleaseTicket(){let t=await V.getCommitMessages(He),n=Di(t);return Mi(n,this.repoInfo.repo)}async createOrUpdateRcBranch(t){let n=`heads/rc/${t}`,r=`rc/${t}`,{data:o}=await this.octokit.rest.repos.getBranch({owner:this.repoInfo.owner,repo:this.repoInfo.repo,branch:He}),{data:i}=await this.octokit.rest.git.listMatchingRefs({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:n}),s=i.length>0;try{s?(console.log(`Updating existing RC branch: ${r}`),await this.octokit.rest.git.updateRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:n,sha:o.commit.sha,force:!0})):(console.log(`Creating new RC branch: ${r}`),await this.octokit.rest.git.createRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:`refs/${n}`,sha:o.commit.sha}))}catch(a){throw new Error(`Failed to create or update ${r} branch: ${a}`)}}async getLinkedPrByHead(t){let n=`${this.repoInfo.owner}:rc/${t}`,{data:r}=await this.octokit.rest.pulls.list({owner:this.repoInfo.owner,repo:this.repoInfo.repo,state:"all",head:n,per_page:30}),o=r.filter(s=>s.state==="open");if(o.length>1)return{state:"open",multipleOpen:!0};if(o.length===1)return{state:"open",html_url:o[0].html_url,number:o[0].number};let i=r.filter(s=>s.state==="closed");return i.length>0?{state:"closed",html_url:i[0].html_url,number:i[0].number}:null}rcReference(t){return`Release candidate pull request. Tracked by ADO Release ticket [AB#${t.id}](${t.url}) \u2014 ${t.title}.`}async buildPrBody(t){let n=this.rcReference(t);try{let{data:r}=await this.octokit.rest.repos.getContent({owner:this.repoInfo.owner,repo:this.repoInfo.repo,path:".github/PULL_REQUEST_TEMPLATE.md"});if("content"in r&&r.type==="file"){let o=Buffer.from(r.content,"base64").toString("utf-8");return o=o.replace("Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.",n),o=o.replace(/<details>/g,"<details open>"),o}}catch(r){r&&typeof r=="object"&&"status"in r&&r.status===404?console.log("No PR template found in repo, using default message."):console.warn("Failed to fetch PR template:",r)}return n}async createRcPr(t){try{let n=await this.buildPrBody(t),{data:r}=await this.octokit.request(`POST /repos/${this.repoInfo.owner}/${this.repoInfo.repo}/pulls`,{owner:this.repoInfo.owner,repo:this.repoInfo.repo,title:`RC #${t.id}`,body:n,head:`rc/${t.id}`,base:rd,headers:{"X-GitHub-Api-Version":"2022-11-28"}});return console.log(`Created Release Candidate pull request: #${r.number} (${r.html_url})`),{state:"open",html_url:r.html_url,number:r.number}}catch(n){throw console.error("Failed to create RC PR:",n),n}}async updateRcPr(t,n){try{let r=await this.buildPrBody(t);await this.octokit.rest.pulls.update({owner:this.repoInfo.owner,repo:this.repoInfo.repo,pull_number:n,body:r}),console.log(`Updated Release Candidate pull request: #${n}`)}catch(r){throw console.error("Failed to update RC PR:",r),r}}static async getTriggerBranchName(){return process.env.GITHUB_REF_NAME?process.env.GITHUB_REF_NAME:process.env.GITHUB_REF?.startsWith("refs/heads/")?process.env.GITHUB_REF.replace("refs/heads/",""):V.getCurrentBranchName()}};var Jv=od.command("rc-workflow").description("Generate RC issue and pull request").action(async()=>{await(await Yt.create()).createReleaseCandidate()});wr.name("auro").version(Xt()).description("A cli tool to support the Auro Design System");wr.addHelpText("beforeAll",vr());wr.parse();
|
|
536
|
+
Only one Release Candidate ticket per repo is supported.`)}throw new Error(`Found ${e.length} Release tickets but none could be matched to "${t}" by Area Path or title:${r}`)}async function Wi(e,t){if(e.length===0)return console.log("No ADO work item references (AB#<id>) found in the RC commits."),null;let n=await dp(),r=await n.getWorkItems(e,void 0,void 0,up.Relations,_i.Omit,xr),o=new Set;for(let u of r??[])for(let m of u.relations??[]){let d=pp(m.url);d!==null&&o.add(d)}if(o.size===0)return console.log(`None of the committed work items (${e.join(", ")}) link to another work item in ADO.`),null;let s=await n.getWorkItems([...o],["System.Title","System.Tags","System.AreaPath","System.State"],void 0,void 0,_i.Omit,xr),i=gp((s??[]).filter(fp));if(i.length===0)return console.log(`No open Release ticket (tagged "${Bi}") is linked to the committed work items (${e.join(", ")}).`),null;let a=i.length===1?i[0]:wp(i,t);if(a.id===void 0)throw new Error("Failed to resolve the Release ticket details from ADO.");let c=typeof a.fields?.["System.Title"]=="string"?a.fields["System.Title"]:`Work item ${a.id}`,l=a._links?.html?.href??`${Li}/${xr}/_workitems/edit/${a.id}`;return{id:a.id,url:l,title:c}}var ze="dev",$p="main",tn=class e{constructor(t,n,r){this.repoInfo={owner:t,repo:n},this.octokit=r}static async create(){let t=process.env.GITHUB_TOKEN;if(!t)throw new Error("GITHUB_TOKEN is required to run RC workflow.");if(!process.env.ADO_TOKEN)throw new Error("ADO_TOKEN is required to resolve the ADO Release ticket for the RC workflow.");let n=await q.getRepoOwnerAndName(),r=new kp({auth:t});if(!n)throw new Error("Failed to retrieve repository information. Ensure you're in a valid git repository.");let o=await e.getTriggerBranchName();return o&&o!==ze&&(console.log(`Switching from ${o} to ${ze} branch...`),await vp().checkout(ze)),new e(n.owner,n.repo,r)}get owner(){return this.repoInfo.owner}get repo(){return this.repoInfo.repo}get repoData(){return{...this.repoInfo}}async createReleaseCandidate(){let t=await this.resolveReleaseTicket();if(!t){console.log("No ADO Release ticket is linked to the new commits on `dev`. Skipping Release PR.");return}console.log(`Using ADO Release ticket #${t.id} (${t.title}) -> ${t.url}`);let n=await this.getLinkedPrByHead(t.id);if(n?.multipleOpen)throw new Error("Multiple open RC PRs found for the same rc/<ticketId> branch.");n?.state==="closed"&&(console.log("Linked RC PR is closed. Creating a new RC PR on the same branch."),n=null),await this.createOrUpdateRcBranch(t.id),n?await this.updateRcPr(t,n.number):n=await this.createRcPr(t)}async resolveReleaseTicket(){let t=await q.getCommitMessages(ze),n=Gi(t);return Wi(n,this.repoInfo.repo)}async createOrUpdateRcBranch(t){let n=`heads/rc/${t}`,r=`rc/${t}`,{data:o}=await this.octokit.rest.repos.getBranch({owner:this.repoInfo.owner,repo:this.repoInfo.repo,branch:ze}),{data:s}=await this.octokit.rest.git.listMatchingRefs({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:n}),i=s.length>0;try{i?(console.log(`Updating existing RC branch: ${r}`),await this.octokit.rest.git.updateRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:n,sha:o.commit.sha,force:!0})):(console.log(`Creating new RC branch: ${r}`),await this.octokit.rest.git.createRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:`refs/${n}`,sha:o.commit.sha}))}catch(a){throw new Error(`Failed to create or update ${r} branch: ${a}`)}}async getLinkedPrByHead(t){let n=`${this.repoInfo.owner}:rc/${t}`,{data:r}=await this.octokit.rest.pulls.list({owner:this.repoInfo.owner,repo:this.repoInfo.repo,state:"all",head:n,per_page:30}),o=r.filter(i=>i.state==="open");if(o.length>1)return{state:"open",multipleOpen:!0};if(o.length===1)return{state:"open",html_url:o[0].html_url,number:o[0].number};let s=r.filter(i=>i.state==="closed");return s.length>0?{state:"closed",html_url:s[0].html_url,number:s[0].number}:null}rcReference(t){return`Release candidate pull request. Tracked by ADO Release ticket [AB#${t.id}](${t.url}) \u2014 ${t.title}.`}async buildPrBody(t){let n=this.rcReference(t);try{let{data:r}=await this.octokit.rest.repos.getContent({owner:this.repoInfo.owner,repo:this.repoInfo.repo,path:".github/PULL_REQUEST_TEMPLATE.md"});if("content"in r&&r.type==="file"){let o=Buffer.from(r.content,"base64").toString("utf-8");return o=o.replace("Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.",n),o=o.replace(/<details>/g,"<details open>"),o}}catch(r){r&&typeof r=="object"&&"status"in r&&r.status===404?console.log("No PR template found in repo, using default message."):console.warn("Failed to fetch PR template:",r)}return n}async createRcPr(t){try{let n=await this.buildPrBody(t),{data:r}=await this.octokit.request(`POST /repos/${this.repoInfo.owner}/${this.repoInfo.repo}/pulls`,{owner:this.repoInfo.owner,repo:this.repoInfo.repo,title:`RC #${t.id}`,body:n,head:`rc/${t.id}`,base:$p,headers:{"X-GitHub-Api-Version":"2022-11-28"}});return console.log(`Created Release Candidate pull request: #${r.number} (${r.html_url})`),{state:"open",html_url:r.html_url,number:r.number}}catch(n){throw console.error("Failed to create RC PR:",n),n}}async updateRcPr(t,n){try{let r=await this.buildPrBody(t);await this.octokit.rest.pulls.update({owner:this.repoInfo.owner,repo:this.repoInfo.repo,pull_number:n,body:r}),console.log(`Updated Release Candidate pull request: #${n}`)}catch(r){throw console.error("Failed to update RC PR:",r),r}}static async getTriggerBranchName(){return process.env.GITHUB_REF_NAME?process.env.GITHUB_REF_NAME:process.env.GITHUB_REF?.startsWith("refs/heads/")?process.env.GITHUB_REF.replace("refs/heads/",""):q.getCurrentBranchName()}};var Mv=Ep.command("rc-workflow").description("Generate RC issue and pull request").action(async()=>{await(await tn.create()).createReleaseCandidate()});import{mkdir as Bp,writeFile as qi}from"node:fs/promises";import on from"node:path";import U from"node:process";import{Logger as sn}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Gp}from"commander";var Sp=1;function Ui(e,t=new Date().toISOString().slice(0,10)){let n={},r=s=>(n[s]??={bundles:[],bundledBy:[]},n[s]);for(let s of e){if(s.bundles.length===0&&!s.internal)continue;let i=r(s.package);i.repo=s.repo,i.bundles=s.bundles,s.internal&&(i.internal=s.internal);for(let a of s.bundles)r(a.package).bundledBy.push(s.package)}for(let s of e)n[s.package]&&!n[s.package].repo&&s.repo&&(n[s.package].repo=s.repo);let o={};for(let s of Object.keys(n).sort()){let i=n[s];i.bundledBy.sort(),o[s]={...i.repo?{repo:i.repo}:{},bundles:i.bundles,bundledBy:i.bundledBy,...i.internal?{internal:i.internal}:{}}}return{schemaVersion:Sp,generatedAt:t,packages:o,releaseOrder:xp(o),warnings:e.flatMap(s=>s.warnings)}}function xp(e){let t=Object.fromEntries(Object.entries(e).map(([n,r])=>[n,{dependsOn:r.bundles.map(o=>o.package),dependentPackages:[...r.bundledBy]}]));return gt(t).map(n=>n.sort())}function nn(e,t){let n=new Set,r=[...e.packages[t]?.bundledBy??[]];for(;r.length>0;){let o=r.shift();n.has(o)||(n.add(o),r.push(...e.packages[o]?.bundledBy??[]))}return e.releaseOrder.map(o=>o.filter(s=>n.has(s))).filter(o=>o.length>0)}import Ke from"node:fs/promises";import O from"node:path";var Hi=new Set(["@aurodesignsystem/auro-library","@aurodesignsystem/auro-cli","@aurodesignsystem/auro-config"]),Ap=new Set([".js",".mjs",".ts"]),Cp=/(?:from\s+|import\s*\(\s*|import\s+)["'](@aurodesignsystem\/auro-[a-z0-9-]+)(?:\/[^"']*)?["']/g,Tp=/writeDepVersionFile\(\s*["']([^"']+)["']\s*\)/g,Rp=/export\s+default\s+["']([^"']+)["']/;async function Ji(e){try{return JSON.parse(await Ke.readFile(e,"utf-8"))}catch{return}}async function Tr(e){try{return await Ke.readFile(e,"utf-8")}catch{return}}async function Vi(e){let t;try{t=await Ke.readdir(e,{withFileTypes:!0})}catch{return[]}let n=[];for(let r of t){let o=O.join(e,r.name);if(r.isDirectory()){if(r.name==="node_modules")continue;n.push(...await Vi(o))}else Ap.has(O.extname(r.name))&&n.push(o)}return n}function Dp(e){return(typeof e.repository=="string"?e.repository:e.repository?.url)?.match(/github\.com[/:]([^/]+\/[^/.]+)/)?.[1]}function Pp(e){return[...e.matchAll(Tp)].map(t=>t[1])}function Mp(e){let t=new Set;for(let n of e.matchAll(Cp))Hi.has(n[1])||t.add(n[1]);return[...t]}async function Np(e,t){let n=t.substring(t.indexOf("auro-")+5);return(await Tr(O.join(e,"src",`${n}Version.js`)))?.match(Rp)?.[1]}function Op(e,t){let n=f=>{let h=f.match(/^(\d+)\.(\d+)\.(\d+)$/);return h?h.slice(1).map(Number):void 0},r=t.trim();if(r==="*"||r==="")return!0;let o=n(e),s=r.match(/^[\^~]/)?.[0]??"",i=n(r.slice(s.length));if(!o||!i)return;let[a,c,l]=o,[u,m,d]=i;return a>u||a===u&&(c>m||c===m&&l>=d)?s===""?a===u&&c===m&&l===d:s==="~"?a===u&&c===m:u>0?a===u:m>0?a===0&&c===m:a===0&&c===0&&l===d:!1}function Ip(e,...t){for(let n of t){let r=n?.dependencies?.[e]??n?.peerDependencies?.[e]??n?.devDependencies?.[e];if(r)return r}}async function jp(e,t){let n=t.manifest.name??O.basename(t.dir),r=new Map;for(let i of await Vi(O.join(t.dir,"src"))){let a=await Tr(i);if(a)for(let c of Mp(a)){if(c===n)continue;let l=r.get(c)??[];l.push(O.relative(e,i)),r.set(c,l)}}let o=await Tr(O.join(t.dir,"scripts","version.mjs")),s=new Set(o?Pp(o):[]);return{name:n,imports:r,versioned:s}}async function _p(e){let t=O.join(e,"components"),n;try{n=await Ke.readdir(t,{withFileTypes:!0})}catch{return[]}let r=[];for(let o of n){if(!o.isDirectory())continue;let s=O.join(t,o.name),i=await Ji(O.join(s,"package.json"));i?.name&&r.push({dir:s,manifest:i})}return r.sort((o,s)=>o.manifest.name.localeCompare(s.manifest.name))}async function Fp(e){let t=await Ji(O.join(e,"package.json"));if(!t?.name)return;let n=await _p(e),r=n.length>0,o=r?n:[{dir:e,manifest:t}],s=new Set(n.map(l=>l.manifest.name)),i=new Map,a={},c=[];for(let l of o){let u=await jp(e,l),m=r?`${t.name} (${u.name})`:u.name;for(let p of u.versioned)u.imports.has(p)||c.push(`${m}: scripts/version.mjs writes a version for ${p}, but src/ never imports it.`);let d=[];for(let[p,f]of[...u.imports].sort(([h],[g])=>h.localeCompare(g))){if(s.has(p)){d.push(p);continue}let h=u.versioned.has(p)?"versioned-tag":"extends",g=Ip(p,l.manifest,t),y=await Np(l.dir,p),k=y!==void 0&&g!==void 0&&Op(y,g)===!1;if(k){let C=p.substring(p.indexOf("auro-")+5);c.push(`${m}: src/${C}Version.js pins ${p}@${y}, outside the declared range ${g}. Run \`npm run build:version\` and commit the result.`)}let $=i.get(p);if($){$.files.push(...f),h==="versioned-tag"&&($.kind=h),k?($.stale=!0,$.pinned=y):$.stale||($.pinned??=y),r&&$.via.push(u.name);continue}i.set(p,{package:p,kind:h,range:g,pinned:y,...k?{stale:!0}:{},...r?{via:[u.name]}:{},files:[...f]})}r&&d.length>0&&(a[u.name]=d)}for(let l of i.values())l.files.sort(),l.pinned===void 0&&delete l.pinned,l.range===void 0&&delete l.range;return{package:t.name,repo:Dp(t),bundles:[...i.values()].sort((l,u)=>l.package.localeCompare(u.package)),...r?{internal:a}:{},warnings:c}}async function zi(e){let t=await Ke.readdir(e,{withFileTypes:!0}),n=[];for(let r of t){if(!r.isDirectory()||r.name.startsWith("."))continue;let o=await Fp(O.join(e,r.name));o?.package.startsWith("@aurodesignsystem/")&&!Hi.has(o.package)&&n.push(o)}return n.sort((r,o)=>r.package.localeCompare(o.package))}function re(e){return e.replace(/^@[^/]+\//,"")}function Rr(e){return re(e).replace(/[^a-zA-Z0-9]/g,"_")}function Lp(e){let t=["graph LR"];for(let n of Object.keys(e.packages))t.push(` ${Rr(n)}["${re(n)}"]`);for(let[n,r]of Object.entries(e.packages))for(let o of r.bundles){let s=o.kind==="extends"?"-.->":"-->";t.push(` ${Rr(o.package)} ${s} ${Rr(n)}`)}return t.join(`
|
|
537
|
+
`)}function rn(e){return e.length>0?e.map(t=>`\`${re(t)}\``).join(", "):"\u2014"}function Ki(e){let t=Object.entries(e.packages).map(([o,s])=>{let i=s.bundles.map(c=>{let l=c.pinned?`@${c.pinned}`:"",u=c.kind==="extends"?" (extends)":"",m=c.stale?` \u26A0 stale (range ${c.range})`:"";return`\`${re(c.package)}${l}\`${u}${m}`}),a=nn(e,o).flat();return`| \`${o}\` | ${i.join(", ")||"\u2014"} | ${rn(s.bundledBy)} | ${rn(a)} |`}),n=Object.entries(e.packages).filter(([,o])=>o.internal).map(([o,s])=>{let i=Object.entries(s.internal).map(([a,c])=>`- \`${re(a)}\` \u2192 ${rn(c)}`);return`### \`${o}\` (internal, same release)
|
|
538
|
+
|
|
539
|
+
${i.join(`
|
|
540
|
+
`)}`}),r=e.releaseOrder.map((o,s)=>`${s+1}. ${rn(o)}`);return["# Auro component dependency map","",`> Generated by \`auro deps map\` on ${e.generatedAt} (schema v${e.schemaVersion}). Do not edit by hand \u2014 regenerate it.`,"","## How to read this","","Auro components **bundle** other Auro components into their own build. They register them under a version-suffixed tag via `AuroDependencyVersioning.generateTag`, or subclass them directly. The sub-component is compiled in, so its releases reach users only when each consumer bumps the devDependency, rebuilds (`npm run build:version` refreshes `src/<name>Version.js`), and cuts its own release.","","- **Bundles**: sub-components this package compiles in, with the version pinned at its last build. `(extends)` = class imported without a versioned tag. `\u26A0 stale` = the committed version file is outside the package.json range, so the tag name no longer matches the code compiled in.","- **Bundled by**: packages that directly bundle this one.","- **All downstream**: every package that must rebuild and release after this one releases, in release order.","- **Patch/minor** releases of a package should cascade into everything downstream. **Major** releases need a manual migration.","","## Diagram","","Arrows point the way a release flows (`auro-icon --> auro-dialog`: auro-dialog bundles auro-icon). Dotted arrows are `extends` edges.","","```mermaid",Lp(e),"```","","## Packages","","| Package | Bundles | Bundled by | All downstream |","| --- | --- | --- | --- |",...t,"",...n.length>0?["## Monorepo internals","",...n,""]:[],"## Release order","","Each batch bundles only packages from earlier batches. Release top to bottom.","",...r,"",...e.warnings.length>0?["## Warnings","",...e.warnings.map(o=>`- ${o}`),""]:[]].join(`
|
|
541
|
+
`)}var Wp="auro-dependency-map.json",Up="auro-dependency-map.md";async function Yi(e){let t=on.resolve(U.cwd(),e.local),n=await zi(t);return n.length===0&&(sn.error(`No @aurodesignsystem repos found under ${t}.`),U.exit(1)),Ui(n)}async function Hp(e){let t=await Yi(e),n=`${JSON.stringify(t,null,2)}
|
|
542
|
+
`,r=Ki(t);if(!e.out){U.stdout.write(e.format==="json"?n:r);return}let o=on.resolve(U.cwd(),e.out);await Bp(o,{recursive:!0}),e.format!=="md"&&await qi(on.join(o,Wp),n,"utf-8"),e.format!=="json"&&await qi(on.join(o,Up),r,"utf-8"),sn.success(`Mapped ${Object.keys(t.packages).length} packages in ${t.releaseOrder.length} release batches to ${o}`);for(let s of t.warnings)sn.warn(s)}async function Jp(e,t){let n=e.includes("/")?e:`@aurodesignsystem/${e}`,r=await Yi(t);r.packages[n]||(sn.error(`${n} neither bundles nor is bundled by another package.`),U.exit(1));let o=nn(r,n);if(t.json){U.stdout.write(`${JSON.stringify(o,null,2)}
|
|
543
|
+
`);return}if(o.length===0){U.stdout.write(`Nothing bundles ${re(n)}.
|
|
544
|
+
`);return}let s=o.map((i,a)=>`Batch ${a+1}
|
|
545
|
+
${i.map(c=>` - ${re(c)}`).join(`
|
|
546
|
+
`)}`).join(`
|
|
547
|
+
|
|
548
|
+
`);U.stdout.write(`${s}
|
|
549
|
+
`)}var Xi=Gp.command("deps").description("Map which Auro components bundle which, and who must release after a component releases");Xi.command("map").description("Generate the bundled-component dependency map from a folder of Auro repo checkouts").option("-l, --local <dir>","Folder containing Auro repo checkouts",U.cwd()).option("-o, --out <dir>","Write auro-dependency-map.{json,md} here instead of stdout").option("-f, --format <format>","json, md, or both","both").action(Hp);Xi.command("dependents <package>").description("List every package that must rebuild and release after <package> releases, in release order").option("-l, --local <dir>","Folder containing Auro repo checkouts",U.cwd()).option("--json","Print release batches as JSON").action(Jp);Dr.name("auro").version(an()).description("A cli tool to support the Auro Design System");Dr.addHelpText("beforeAll",Pr());Dr.parse();
|