@aurodesignsystem-dev/auro-cli 0.0.0-pr333.4 → 0.0.0-pr333.5

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{program as jr}from"commander";import ys from"figlet";import{mind as bs}from"gradient-string";var Fr=()=>bs(ys.textSync("Auro CLI"));import Lr from"node:fs";import Gr from"node:path";import{fileURLToPath as ws}from"node:url";function Fe(e){process.env.DEBUG&&console.log(`[DEBUG] ${e}`)}function Nt(){try{let e=ws(import.meta.url),t=Gr.dirname(e);Fe(`Current module path: ${t}`);let r=Gr.resolve(t,"..","package.json");return Fe(`Checking package.json at: ${r}`),Lr.existsSync(r)?(Fe(`Found package.json at: ${r}`),JSON.parse(Lr.readFileSync(r,"utf8")).version):(Fe("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 vi}from"commander";import gn from"ora";function Le(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 Ge(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 hi from"@rollup/plugin-terser";import{watch as yi}from"rollup";import{existsSync as an,readFileSync as si,rmSync as ii,writeFileSync as ai}from"node:fs";import{basename as ci,dirname as li,join as xe,resolve as Ye}from"node:path";import{pathToFileURL as cn}from"node:url";import{glob as ui}from"glob";import Ht from"ora";import{rollup as Wt}from"rollup";import*as ln from"sass";import Te from"ora";import{spawn as vs}from"node:child_process";import ks from"ora";var _=(e,t)=>{let r=`${e} ${t?t.join(" "):""}`,n=ks(),o=e,s=t||[];if(!t&&typeof e=="string"){let l=e.split(" ");o=l[0],s=l.slice(1)}let i=r.includes("--watch")||r.includes(" -w"),c=vs(o,s,{stdio:i?"inherit":["inherit","pipe","pipe"],shell:!0});if(!i){let l=[];c.stdout?.on("data",m=>{let u=m.toString();l.push(u),process.stdout.write(u)}),c.stderr?.on("data",m=>{let u=m.toString();l.push(u),process.stderr.write(u)})}return new Promise((l,m)=>{c.on("close",u=>{u!==0?i?(n.info(`Watch mode terminated with code ${u}`),l()):(n.fail(`${r} failed (code ${u})`),m(new Error(`Command failed with exit code ${u}`))):(n.succeed(`${r} completed successfully`),l())})})};import Be from"node:fs";import Es from"node:path";import{markdownTable as Br}from"markdown-table";var ve=class e{static{this.manifest={schemaVersion:"1.0.0",readme:"",modules:[]}}static generate(t={}){let{outDir:r="./docs",outFile:n="api.md",manifestPath:o="./custom-elements.json"}=t,{getElements:s,renderAllElements:i}=e;if(o)try{let u=Be.readFileSync(o,"utf8");e.manifest=JSON.parse(u)}catch(u){throw console.error(`Error reading manifest file at ${o}:`,u),u}let a=s(),c=r;Be.existsSync(c)||Be.mkdirSync(c,{recursive:!0});let l=i(a),m=Es.join(c,n);Be.writeFileSync(m,l),console.log(`Generated combined API documentation at ${m}`)}static getElements(){let t=e.manifest.modules.filter(e.isWcaModule);return e.manifest.modules.reduce((r,n)=>r.concat(n.declarations?.filter(o=>"customElement"in o&&o.customElement===!0&&"tagName"in o&&(t.length>0?e.isWcaModule(n):!0))??[]),[])}static isWcaModule(t){let{path:r}=t;return r?r.startsWith("scripts/wca/auro-")&&r.endsWith(".js"):!1}static renderAllElements(t){return`${t.sort((r,n)=>(r.tagName||"").localeCompare(n.tagName||"")).map(r=>e.renderElement(r,!0)).join(`
2
+ import{program as jr}from"commander";import bs from"figlet";import{mind as ws}from"gradient-string";var Fr=()=>ws(bs.textSync("Auro CLI"));import Lr from"node:fs";import Gr from"node:path";import{fileURLToPath as vs}from"node:url";function Fe(e){process.env.DEBUG&&console.log(`[DEBUG] ${e}`)}function Nt(){try{let e=vs(import.meta.url),t=Gr.dirname(e);Fe(`Current module path: ${t}`);let r=Gr.resolve(t,"..","package.json");return Fe(`Checking package.json at: ${r}`),Lr.existsSync(r)?(Fe(`Found package.json at: ${r}`),JSON.parse(Lr.readFileSync(r,"utf8")).version):(Fe("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 vi}from"commander";import hn from"ora";function Le(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 Ge(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 hi from"@rollup/plugin-terser";import{watch as yi}from"rollup";import{existsSync as cn,readFileSync as si,rmSync as ii,writeFileSync as ai}from"node:fs";import{basename as ci,dirname as li,join as xe,resolve as Ye}from"node:path";import{pathToFileURL as ln}from"node:url";import{glob as ui}from"glob";import Ht from"ora";import{rollup as Wt}from"rollup";import*as un from"sass";import Te from"ora";import{spawn as ks}from"node:child_process";import Es from"ora";var _=(e,t)=>{let r=`${e} ${t?t.join(" "):""}`,n=Es(),o=e,s=t||[];if(!t&&typeof e=="string"){let l=e.split(" ");o=l[0],s=l.slice(1)}let i=r.includes("--watch")||r.includes(" -w"),c=ks(o,s,{stdio:i?"inherit":["inherit","pipe","pipe"],shell:!0});if(!i){let l=[];c.stdout?.on("data",m=>{let u=m.toString();l.push(u),process.stdout.write(u)}),c.stderr?.on("data",m=>{let u=m.toString();l.push(u),process.stderr.write(u)})}return new Promise((l,m)=>{c.on("close",u=>{u!==0?i?(n.info(`Watch mode terminated with code ${u}`),l()):(n.fail(`${r} failed (code ${u})`),m(new Error(`Command failed with exit code ${u}`))):(n.succeed(`${r} completed successfully`),l())})})};import Be from"node:fs";import Ss from"node:path";import{markdownTable as Br}from"markdown-table";var ve=class e{static{this.manifest={schemaVersion:"1.0.0",readme:"",modules:[]}}static generate(t={}){let{outDir:r="./docs",outFile:n="api.md",manifestPath:o="./custom-elements.json"}=t,{getElements:s,renderAllElements:i}=e;if(o)try{let u=Be.readFileSync(o,"utf8");e.manifest=JSON.parse(u)}catch(u){throw console.error(`Error reading manifest file at ${o}:`,u),u}let a=s(),c=r;Be.existsSync(c)||Be.mkdirSync(c,{recursive:!0});let l=i(a),m=Ss.join(c,n);Be.writeFileSync(m,l),console.log(`Generated combined API documentation at ${m}`)}static getElements(){let t=e.manifest.modules.filter(e.isWcaModule);return e.manifest.modules.reduce((r,n)=>r.concat(n.declarations?.filter(o=>"customElement"in o&&o.customElement===!0&&"tagName"in o&&(t.length>0?e.isWcaModule(n):!0))??[]),[])}static isWcaModule(t){let{path:r}=t;return r?r.startsWith("scripts/wca/auro-")&&r.endsWith(".js"):!1}static renderAllElements(t){return`${t.sort((r,n)=>(r.tagName||"").localeCompare(n.tagName||"")).map(r=>e.renderElement(r,!0)).join(`
3
3
 
4
4
  `)}`}static renderElement(t,r=!0){let n=[],{renderTable:o,renderPropertiesAttributesTable:s,renderParameters:i,getType:a}=e;n.push(r?`# ${t.tagName}`:""),t.description&&n.push(t.description);let c=s(t);c&&n.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&&n.push(l.trim());let m=o("Events",["name","description"],t.events);m&&n.push(m.trim());let u=o("Slots",[["name","(default)"],"description"],t.slots);u&&n.push(u.trim());let p=o("CSS Shadow Parts",["name","description"],t.cssParts);p&&n.push(p.trim());let d=o("CSS Custom Properties",["name","description"],t.cssProperties);return d&&n.push(d.trim()),n.join(`
5
5
 
@@ -9,30 +9,29 @@ ${Br([c,...l])}
9
9
  `}static renderParameters(t){let{escapeMarkdown:r,getType:n}=e;return!t||t.length===0?"None":t.map(o=>{let s=n(o)||"any",i=o.description?` - ${o.description}`:"";return`\`${o.name}\` (${r(s)})${r(i)}`}).join("<br>")}static renderTable(t,r,n){let{escapeMarkdown:o,get:s,capitalize:i}=e;if(n===void 0||n.length===0)return"";let a=n.filter(u=>{let{description:p}=u;return typeof p=="string"&&p.trim()});if(a.length===0)return"";let c=r.map(u=>i((Array.isArray(u)?u[0]:u).split(".")[0])),l=a.map(u=>r.map(p=>{let d=s(u,p);return o(String(d||""))})),m=Br([c,...l]);return`### ${t}
10
10
 
11
11
  ${m}
12
- `}static escapeMarkdown(t){return t.replace(/\\/g,"\\\\").replace(/\n/g,"<br>").replace(/\|/g,"\\|")}static getType(t){if(!t||!t.type)return"";let{type:r}=t,n=s=>s.replace(/\s*\|\s*/g," | ").replace(/'([^']+)'/g,"`$1`");if(typeof r=="string")return n(r);if(r.text)return n(r.text);if(Array.isArray(r))return r.map(s=>typeof s=="string"?s:s.text?s.text:s.name?s.name:String(s)).join(" \\| ");if(r.name)return n(r.name);if(r.references&&Array.isArray(r.references))return r.references.map(s=>s.name||String(s)).join(" \\| ");let o=String(r);return n(o)}static get(t,r){let n="",o=r;Array.isArray(r)&&([o,n]=r);let s=o.split("."),i=t;for(;i&&s.length;)i=i[s.shift()];return i==null||i===""?n:String(i)}static capitalize(t){return t.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase()).trim()}};import Ss from"node:fs";import Ts from"node:os";import Ue from"node:path";import Ot from"node:process";function $s(){let e=Ts.homedir()||Ot.env.HOME||Ot.env.USERPROFILE;if(!e)throw new Error("Unable to determine user home directory");return Ue.join(e,".auro")}function Mt(...e){return Ue.join($s(),...e)}function _t(...e){let t=Ss.realpathSync(Ot.argv[1]),r=Ue.dirname(t);return Ue.resolve(r,...e)}var Ur=e=>_t("configs",e);import{copyFileSync as xs,existsSync as Wr,mkdirSync as As}from"node:fs";import{join as Cs,resolve as jt}from"node:path";function We(){let e=process.cwd(),t=jt(e,"README.md"),r=Cs(jt(e,"demo"),"readme.md");if(!Wr(t))return;let n=jt(e,"demo");Wr(n)||As(n,{recursive:!0}),xs(t,r)}import Rs from"ora";var Vr=[];function ke(e){Vr.push(e)}var Hr=!1;function He(){Hr||(Hr=!0,process.on("SIGINT",()=>{let e=Rs("Wrapping up...").start();for(let t of Vr)t.close();e.succeed("All done! See you next time. \u2728"),process.exit(0)}))}import{Logger as Ps}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{generateReadmeUrl as Ds,processContentForFile as Is,templateFiller as Lt}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";import j from"node:fs";import{readFileSync as Gt,existsSync as Ft}from"node:fs";import B from"node:path";var Ns="/docs/pages",zr={overwriteLocalCopies:!0,remoteReadmeVersion:"master",remoteReadmeVariant:"_updated_paths",monorepoName:void 0,extraVars:{}};function N(e){return`${process.cwd()}/${e}`}function Os(e=process.cwd()){let t=e;for(;;){let r=B.join(t,"package.json");if(Ft(r))try{if(JSON.parse(Gt(r,"utf8")).workspaces)return t}catch{}let n=B.dirname(t);if(n===t)break;t=n}return e}async function Ms(e,t=!1){let r=[];if(!t){let o=e.localReadmePath?e.localReadmePath:{remoteUrl:e.remoteReadmeUrl||Ds(e.remoteReadmeVersion,e.remoteReadmeVariant),fileName:N("/docTemplates/README.md"),overwrite:e.overwriteLocalCopies};r.push({identifier:"README.md",input:o,output:N("/README.md")})}Jr("/docs/partials/index.md")&&r.push({identifier:"index.md",input:N("/docs/partials/index.md"),output:N("/demo/index.md"),mdMagicConfig:{output:{directory:N("/demo")}}}),Jr("/docs/partials/api.md")&&r.push({identifier:"api.md",input:N("/docs/partials/api.md"),output:N("/demo/api.md"),preProcessors:[Lt.formatApiTable]});let n=N(Ns);if(j.existsSync(n)){let s=(await j.promises.readdir(n)).map(i=>({identifier:i,input:B.join(n,i),output:N(`/demo/${i}`)}));r.push(...s)}return r}async function _s(e=zr,t=!1){await Lt.extractNames();let r=await Ms(e,t),n=e.monorepoName;if(!n)try{let i=B.join(Os(),"package.json");n=JSON.parse(Gt(i,"utf8")).name?.replace(/^@[^/]+\//,"")}catch{}let o={...n?{monorepoName:n}:{},...e.extraVars||{}},s=[];for(let i of r)try{if(await Is({...i,extraVars:o,preProcessors:[...i.preProcessors??[],a=>Kr(a,o)]}),i.output.endsWith(".md")){await Gs(i.output,o);let a=Ls(await j.promises.readFile(i.output,"utf8"));if(a.length>0)throw new Error(`Unreplaced template placeholders: ${a.join(", ")}`)}}catch(a){Ps.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):
12
+ `}static escapeMarkdown(t){return t.replace(/\\/g,"\\\\").replace(/\n/g,"<br>").replace(/\|/g,"\\|")}static getType(t){if(!t||!t.type)return"";let{type:r}=t,n=s=>s.replace(/\s*\|\s*/g," | ").replace(/'([^']+)'/g,"`$1`");if(typeof r=="string")return n(r);if(r.text)return n(r.text);if(Array.isArray(r))return r.map(s=>typeof s=="string"?s:s.text?s.text:s.name?s.name:String(s)).join(" \\| ");if(r.name)return n(r.name);if(r.references&&Array.isArray(r.references))return r.references.map(s=>s.name||String(s)).join(" \\| ");let o=String(r);return n(o)}static get(t,r){let n="",o=r;Array.isArray(r)&&([o,n]=r);let s=o.split("."),i=t;for(;i&&s.length;)i=i[s.shift()];return i==null||i===""?n:String(i)}static capitalize(t){return t.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase()).trim()}};import Ts from"node:fs";import $s from"node:os";import Ue from"node:path";import Ot from"node:process";function xs(){let e=$s.homedir()||Ot.env.HOME||Ot.env.USERPROFILE;if(!e)throw new Error("Unable to determine user home directory");return Ue.join(e,".auro")}function Mt(...e){return Ue.join(xs(),...e)}function _t(...e){let t=Ts.realpathSync(Ot.argv[1]),r=Ue.dirname(t);return Ue.resolve(r,...e)}var Ur=e=>_t("configs",e);import{copyFileSync as As,existsSync as Wr,mkdirSync as Cs}from"node:fs";import{join as Rs,resolve as jt}from"node:path";function We(){let e=process.cwd(),t=jt(e,"README.md"),r=Rs(jt(e,"demo"),"readme.md");if(!Wr(t))return;let n=jt(e,"demo");Wr(n)||Cs(n,{recursive:!0}),As(t,r)}import Ps from"ora";var Vr=[];function ke(e){Vr.push(e)}var Hr=!1;function He(){Hr||(Hr=!0,process.on("SIGINT",()=>{let e=Ps("Wrapping up...").start();for(let t of Vr)t.close();e.succeed("All done! See you next time. \u2728"),process.exit(0)}))}import{Logger as Ds}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{generateReadmeUrl as Is,processContentForFile as Ns,templateFiller as Lt}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";import j from"node:fs";import{readFileSync as Gt,existsSync as Ft}from"node:fs";import B from"node:path";var Os="/docs/pages",Kr={overwriteLocalCopies:!0,remoteReadmeVersion:"master",remoteReadmeVariant:"_updated_paths",monorepoName:void 0,extraVars:{}};function N(e){return`${process.cwd()}/${e}`}function Ms(e=process.cwd()){let t=e;for(;;){let r=B.join(t,"package.json");if(Ft(r))try{if(JSON.parse(Gt(r,"utf8")).workspaces)return t}catch{}let n=B.dirname(t);if(n===t)break;t=n}return e}async function _s(e,t=!1){let r=[];if(!t){let o=e.localReadmePath?e.localReadmePath:{remoteUrl:e.remoteReadmeUrl||Is(e.remoteReadmeVersion,e.remoteReadmeVariant),fileName:N("/docTemplates/README.md"),overwrite:e.overwriteLocalCopies};r.push({identifier:"README.md",input:o,output:N("/README.md")})}zr("/docs/partials/index.md")&&r.push({identifier:"index.md",input:N("/docs/partials/index.md"),output:N("/demo/index.md"),mdMagicConfig:{output:{directory:N("/demo")}}}),zr("/docs/partials/api.md")&&r.push({identifier:"api.md",input:N("/docs/partials/api.md"),output:N("/demo/api.md"),preProcessors:[Lt.formatApiTable]});let n=N(Os);if(j.existsSync(n)){let s=(await j.promises.readdir(n)).map(i=>({identifier:i,input:B.join(n,i),output:N(`/demo/${i}`)}));r.push(...s)}return r}async function js(e=Kr,t=!1){await Lt.extractNames();let r=await _s(e,t),n=e.monorepoName;if(!n)try{let i=B.join(Ms(),"package.json");n=JSON.parse(Gt(i,"utf8")).name?.replace(/^@[^/]+\//,"")}catch{}let o={...n?{monorepoName:n}:{},...e.extraVars||{}},s=[];for(let i of r)try{if(await Ns({...i,extraVars:o,preProcessors:[...i.preProcessors??[],a=>qr(a,o)]}),i.output.endsWith(".md")){await Gs(i.output,o);let a=Ls(await j.promises.readFile(i.output,"utf8"));if(a.length>0)throw new Error(`Unreplaced template placeholders: ${a.join(", ")}`)}}catch(a){Ds.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
13
  ${s.map(i=>` - ${i}`).join(`
14
- `)}`)}var js=["name","Name","namespace","Namespace","Version","dtVersion","wcssVersion","monorepoName","capitalize","withAuroNamespace","packageName","if","unless","each","with","lookup","log","else","this","true","false","null","undefined"];function Kr(e,t={}){let r=new Set([...js,...Object.keys(t)]);return e.replace(/(?<![\\{])\{\{(?![{#/^!>&])((?:(?!\}\})[\s\S])*)\}\}/g,(n,o)=>{if(/^~[#/^!>&{]/.test(o))return n;let s=o.replace(/^~?\s*/,"").match(/^[A-Za-z_$][\w$-]*/);return s&&r.has(s[0])?n:`\\${n}`})}function Fs(e,t){return Lt.replaceTemplateValues(Kr(e,t),t)}function Ls(e){return e.replace(/<pre\b[\s\S]*?<\/pre>/gi,"").replace(/<code\b[\s\S]*?<\/code>/gi,"").replace(/^[ \t]*(`{3,}|~{3,})[^\n]*\n[\s\S]*?^[ \t]*\1[ \t]*$/gm,"").replace(/`[^`\n]*`/g,"").match(/\{\{[\s\S]*?\}\}/g)??[]}async function Gs(e,t={}){let r=B.dirname(e),n=await j.promises.readFile(e,"utf8"),o=/^[ \t]*<!-- AURO-GENERATED-CONTENT:START \((FILE|CODE):src=([^)]+)\) -->\n[ \t]*<!-- AURO-GENERATED-CONTENT:END -->/gm,s,i=!1,a=N("demo"),c=[];for(;(s=o.exec(n))!==null;){let[d,f,h]=s,g=B.resolve(r,h),b=B.resolve(a,h),S=Ft(g)?g:Ft(b)?b:null;if(S){let le=Fs(Gt(S,"utf8"),t),I;if(f==="FILE")I=`<!-- AURO-GENERATED-CONTENT:START (FILE:src=${h}) -->
14
+ `)}`)}var Fs=["name","Name","namespace","Namespace","Version","dtVersion","wcssVersion","monorepoName","capitalize","withAuroNamespace","packageName","if","unless","each","with","lookup","log","else","this","true","false","null","undefined"];function qr(e,t={}){let r=new Set([...Fs,...Object.keys(t)]);return e.replace(/(?<![\\{])\{\{(?![{#/^!>&])((?:(?!\}\})[\s\S])*)\}\}/g,(n,o)=>{if(/^~[#/^!>&{]/.test(o))return n;let s=o.replace(/^~?\s*/,"").match(/^[A-Za-z_$][\w$-]*/);return s&&r.has(s[0])?n:`\\${n}`})}function Jr(e,t){return Lt.replaceTemplateValues(qr(e,t),t)}function Ls(e){return e.replace(/<pre\b[\s\S]*?<\/pre>/gi,"").replace(/<code\b[\s\S]*?<\/code>/gi,"").replace(/^[ \t]*(`{3,}|~{3,})[^\n]*\n[\s\S]*?^[ \t]*\1[ \t]*$/gm,"").replace(/`[^`\n]*`/g,"").match(/\{\{[\s\S]*?\}\}/g)??[]}async function Gs(e,t={}){let r=B.dirname(e),n=await j.promises.readFile(e,"utf8"),o=/^[ \t]*<!-- AURO-GENERATED-CONTENT:START \((FILE|CODE):src=([^)]+)\) -->\n[ \t]*<!-- AURO-GENERATED-CONTENT:END -->/gm,s,i=!1,a=N("demo"),c=[];for(;(s=o.exec(n))!==null;){let[d,f,h]=s,g=B.resolve(r,h),b=B.resolve(a,h),S=Ft(g)?g:Ft(b)?b:null;if(S){let le=Gt(S,"utf8"),I;if(f==="FILE")I=`<!-- AURO-GENERATED-CONTENT:START (FILE:src=${h}) -->
15
15
  <!-- The below content is automatically added from ${h} -->
16
- ${le.trimEnd()}
17
- <!-- AURO-GENERATED-CONTENT:END -->`;else{let T=B.extname(h).slice(1)||"html",y=le.trimEnd().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");I=`<!-- AURO-GENERATED-CONTENT:START (CODE:src=${h}) -->
16
+ ${Jr(le,t).trimEnd()}
17
+ <!-- AURO-GENERATED-CONTENT:END -->`;else{let T=B.extname(h).slice(1)||"html",y=le.trimEnd().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),$=Jr(`<pre class="language-${T}"><code class="language-${T}">${y}
18
+ </code></pre>`,t);I=`<!-- AURO-GENERATED-CONTENT:START (CODE:src=${h}) -->
18
19
  <!-- The below code snippet is automatically added from ${h} -->
19
- <pre class="language-${T}"><code class="language-${T}">${y}
20
- </code></pre>
20
+ ${$}
21
21
  <!-- AURO-GENERATED-CONTENT:END -->`}n=n.replace(d,I),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 j.promises.writeFile(e,n),n=await j.promises.readFile(e,"utf8");let l=/^[ \t]*```(\w*)\n([\s\S]*?)^[ \t]*```[ \t]*$/gm,m=n.replace(l,(d,f,h)=>{let g=f||"html",b=h.trimEnd().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return`<pre class="language-${g}"><code class="language-${g}">${b}
22
- </code></pre>`});m!==n&&await j.promises.writeFile(e,m),n=await j.promises.readFile(e,"utf8"),n=n.replace(/(<pre[^>]*><code[^>]*>)([\s\S]*?)(<\/code><\/pre>)/g,(d,f,h,g)=>{let b=h.split(`
23
- `),S=b.filter(y=>y.trim().length>0);if(S.length===0)return d;let le=Math.min(...S.map(y=>{let D=y.match(/^[ \t]*/);return D?D[0].length:0})),I=b.map(y=>le>0?y.substring(le):y);for(;I.length>0&&I[I.length-1].trim()==="";)I.pop();let T=I.map((y,D)=>D===I.length-1?y:`${y}${y.trim()===""?"&#10;":`
22
+ </code></pre>`});m!==n&&await j.promises.writeFile(e,m),n=await j.promises.readFile(e,"utf8"),n=n.replace(/(<pre[^>]*><code[^>]*>)([\s\S]*?)(<\/code><\/pre>)/g,(d,f,h,g)=>{let b=h.split(/\r?\n/),S=b.filter(y=>y.trim().length>0);if(S.length===0)return d;let le=Math.min(...S.map(y=>{let $=y.match(/^[ \t]*/);return $?$[0].length:0})),I=b.map(y=>le>0?y.substring(le):y);for(;I.length>0&&I[I.length-1].trim()==="";)I.pop();let T=I.map((y,$)=>$===I.length-1?y:`${y}${y.trim()===""?"&#10;":`
24
23
  `}`).join("");return f+T+g});let u=n.split(`
25
24
  `),p=!1;for(let d=0;d<u.length;d++)/<pre[\s>]/i.test(u[d])&&(p=!0),p||(u[d]=u[d].replace(/^[ \t]+(?=<)/,"")),/<\/pre>/i.test(u[d])&&(p=!1);await j.promises.writeFile(e,u.join(`
26
- `))}async function Ee(e={}){let t=e.readmeTemplate,r=t&&!t.startsWith("http");await _s({...zr,...r?{localReadmePath:B.resolve(process.cwd(),t)}:{remoteReadmeUrl:t||"https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/README.md"}},e.skipReadme)}function Jr(e){return j.existsSync(N(e))}import{existsSync as qr,readFileSync as Bs}from"node:fs";import{builtinModules as Us}from"node:module";import{resolve as Ve}from"node:path";import{startDevServer as Ws}from"@web/dev-server";import{hmrPlugin as Hs}from"@web/dev-server-hmr";import*as Yr from"esbuild";import Vs from"ora";var H=["node_modules","../node_modules","../../node_modules","../../../node_modules"];var Js=/^\/__wds-outside-root__\/(\d+)\/(.+)$/;function zs(){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),r=process.cwd();for(let n of H){let o=Ve(r,n,t);if(qr(o))return{body:Bs(o,"utf-8"),type:"css"}}}}}function Ks(e,t){let r=e.match(Js);return r?Ve(t,"../".repeat(Number.parseInt(r[1],10)),r[2]):Ve(t,`.${e}`)}function qs(){let e=/\b(require\s*\(|module\.exports\b|exports\.\w)/,t=new Map,r;return{name:"cjs-to-esm",async serverStart({config:n}){r=Ve(n.rootDir)},async transform(n){if(!n.path.includes("node_modules")||!n.path.endsWith(".js")&&!n.path.endsWith(".cjs")||typeof n.body!="string"||!e.test(n.body))return;let o=Ks(n.path,r);if(t.has(o))return t.get(o);if(qr(o))try{let i={body:(await Yr.build({entryPoints:[o],bundle:!0,format:"esm",platform:"browser",write:!1,logLevel:"silent",external:Us})).outputFiles[0].text};return t.set(o,i),i}catch(s){console.error(`CJS-to-ESM bundling failed for ${n.path}:`,s.message)}}}}var Se={watch:!0,nodeResolve:!0,basePath:"/",rootDir:"./demo",hmrInclude:["src/**/*","demo/**/*","apiExamples/**/*","docs/**/*"]};async function Je(e={}){if(!e.serve)return;let t=Vs(`Firing up dev server...
27
- `).start();try{let r={port:Number(e.port)||void 0,open:e.open?"/":void 0,watch:e.watch??Se.watch,nodeResolve:e.nodeResolve??Se.nodeResolve,basePath:e.basePath??Se.basePath,rootDir:e.rootDir??Se.rootDir,middleware:[function(s,i){return!s.url.endsWith("/")&&!s.url.includes(".")&&(s.url+=".html"),i()}],plugins:[zs(),qs(),Hs({include:e.hmrInclude??Se.hmrInclude})]},n=await Ws({config:r,readCliArgs:!1,readFileConfig:!1});return t.stop(),n}catch(r){throw t.fail("Server snag! Couldn't start dev server."),console.error("Error starting development server:",r),new Error(`Development server failed to start: ${r.message}`)}}async function ze(){let e=Te("Generating Custom Elements Manifest...").start();try{await _(`npx --package=@custom-elements-manifest/analyzer -y -- cem analyze --config '${Ur("custom-elements-manifest.config.mjs")}'`),e.succeed("Custom Elements Manifest generated successfully!")}catch(t){let r=t instanceof Error?t.message:String(t);e.warn("CEM analyzer completed with warnings: "+r)}}async function Ke(){let e=Te("Generating API md file...").start();try{await ve.generate(),e.succeed("API md file generated successfully!")}catch(t){let r=t instanceof Error?t.message:String(t);throw e.fail("Failed to generate API md file: "+r),t}}async function Xr(e={},{build:t=Ee,demo:r=Zr}={}){let n=Te("Compiling documentation...").start(),o;try{await t(e),n.succeed("Documentation compiled successfully!")}catch(s){let i=s instanceof Error?s.message:String(s);n.fail("Failed to compile MD documentation: "+i),o=s}if(await r(e),o)throw o}async function Zr(e={}){We(),await Q(),await tn(e)}async function Qr(e={}){await Je(e)}async function en(e={}){let t=await import("chokidar"),r=["./src/**/*","./docs/**/*","./docTemplates/**/*","./apiExamples/**/*","./demo/**/*.scss"],n=["**/demo/*.min.js","**/demo/*.min.css","**/demo/*.md","**/demo/readme.md","**/docs/api.md","**/custom-elements.json","**/node_modules/**","**/dist/**","**/.git/**"],o=t.watch(r,{ignoreInitial:!0,ignored:n,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100}}),s=Te("Waiting for changes...");s.spinner="bouncingBar",s.color="green",s.start();let i=null,a=!1,c=!1;async function l(m){if(a){c=!0;return}a=!0,o.unwatch(r);let u=Te(`Change detected: ${m}`).start();try{let p;try{await Ee(e)}catch(d){p=d}if(await Zr(e),p)throw p;u.succeed("Docs rebuilt!")}catch(p){let d=p instanceof Error?p.message:String(p);u.fail("Rebuild failed: "+d)}finally{setTimeout(()=>{o.add(r),a=!1,c&&(c=!1,l("queued changes"))},1e3)}}o.on("all",(m,u)=>{a||(i&&clearTimeout(i),i=setTimeout(()=>{l(u)},1e3))}),ke(o),He()}async function qe(){await ze(),await Ke()}import{basename as Zs,join as nn,resolve as Qs}from"node:path";import ei from"@rollup/plugin-commonjs";import{nodeResolve as ti}from"@rollup/plugin-node-resolve";import{glob as ri}from"glob";import{litScss as ni}from"rollup-plugin-scss-lit";import Ys from"node:path";import{glob as Xs}from"glob";function rn(e){return{name:"watch-globs",buildStart(){let t=Array.isArray(e)?e:[e];for(let r of t)try{for(let n of Xs.sync(Ys.resolve(r)))this.addWatchFile(n)}catch(n){this.error(`Error watching glob pattern "${r}": ${n.message}`)}}}}var Bt={moduleDirectories:["node_modules"],modulePaths:["../../node_modules","../node_modules","node_modules"],watchPatterns:["./apiExamples/**/*","./docs/**/*"]};function on(e=[],t={}){let{watchPatterns:r=Bt.watchPatterns,dedupe:n=["lit","lit-element","lit-html"],dev:o=!1}=t,s=[...Bt.modulePaths,...e],i=process.cwd(),a=H.map(c=>Qs(i,c));return[ti({dedupe:n,preferBuiltins:!1,moduleDirectories:Bt.moduleDirectories,modulePaths:a}),ei(),ni({minify:o?!1:{fast:!0},options:{loadPaths:[...s,nn(process.cwd(),"src","styles"),nn(process.cwd(),"src")]}}),rn(r)]}function Ut(e={}){let{modulePaths:t=[],watch:r=!1,input:n=["./src/index.js","./src/registered.js"],outputDir:o="./dist",format:s="esm",dev:i=!1}=e;return{name:"Main",config:{input:n,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:oi(),plugins:on(t,{dev:i}),watch:sn(r)}}}function $e(e={}){let{modulePaths:t=[],watch:r=!1,globPattern:n="./demo/*.js",ignorePattern:o=["./demo/*.min.js"],outputDir:s="./demo",dev:i=!1}=e,a=ri.sync(n,{ignore:o}),c=on(t,{dev:i}),l=sn(r);return{name:"Demo",configs:a.map(u=>({input:{[Zs(u,".js")]:u},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(d,f){if(d.code==="UNRESOLVED_IMPORT")throw new Error(`Unresolved import "${d.exporter??d.source}" in ${d.id??u}. Make sure workspace dependencies are built before bundling demos.`);f(d)},watch:l}))}}function sn(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 oi(e=[]){return[...[/node_modules\/lit/,/node_modules\/lit-element/,/node_modules\/lit-html/,/node_modules\/@lit/],...e]}function un(){let e=xe("./dist"),t=Ht("Cleaning dist folder...").start();try{return ii(e,{recursive:!0,force:!0}),t.succeed("All clean! Dist folder wiped."),!0}catch(r){return t.fail(`Oops! Couldn't clean dist/ folder: ${r.message}`),console.error(r),!1}}async function Xe(e,t,r,n){let o=Ht(e).start();try{let s=await t();return o.succeed(r),s}catch(s){throw o.fail(n),console.error(`Error: ${s.message}`),s}}async function mn(e,t){return Xe(`Bundling ${e.name||"main"} and demo...`,async()=>{let r=await Wt(e);await r.write(e.output),await r.close();for(let n of t){let o=await Wt(n);await o.write(n.output),await o.close()}},`Bundles ready! ${e.name||"Main"} and demo built.`,"Bundle hiccup! Build failed.")}async function Ze(e){let{wcaInput:t,wcaOutput:r,skipDocs:n}=e;if(n){let o=Ht("Skipping docs generation...").start();setTimeout(()=>{o.succeed("Docs generation skipped.")},0);return}return Xe("Analyzing components and making docs...",async()=>{await qe(t,r),await Ee(e),We()},"Docs ready! Looking good.","Doc troubles!")}function mi(){let e=process.cwd();function t(o){return[o,`${o}.scss`,`${o}.css`,xe(li(o),`_${ci(o)}.scss`),xe(o,"_index.scss"),xe(o,"index.scss")].find(i=>an(i))}function r(o){for(let i of H){let a=t(Ye(e,i,o));if(a)return a}let s=n(o);return s||null}function n(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 H){let c=Ye(e,a,s,"package.json");if(an(c))try{let m=JSON.parse(si(c,"utf-8")).exports;if(!m||typeof m!="object")continue;let u=m[i];if(!u)continue;let p=typeof u=="string"?u:u.default||u.import;if(!p)continue;let d=t(Ye(e,a,s,p));if(d)return d}catch{continue}}return null}return{findFileUrl(o){if(o.includes("/node_modules/")){let s=o.lastIndexOf("/node_modules/"),i=o.slice(s+14),a=r(i);if(a)return cn(a)}if(!o.startsWith(".")&&!o.startsWith("/")&&!o.startsWith("file:")){let s=r(o);if(s)return cn(s)}return null}}}async function Q(e="./demo"){return Xe("Compiling demo SCSS...",async()=>{let t=ui.sync(xe(e,"**/*.scss")),r=mi(),n=process.cwd(),o=H.map(s=>Ye(n,s));for(let s of t){let i=ln.compile(s,{importers:[r],loadPaths:o,silenceDeprecations:["import"],style:"compressed"}),a=s.replace(/\.scss$/,".min.css");ai(a,i.css)}return t.length},"Demo SCSS compiled.","SCSS compilation failed.")}async function tn(e={}){let{configs:t}=$e(e);return Xe("Bundling demo JS...",async()=>{for(let r of t){let n=await Wt(r);await n.write(r.output),await n.close()}},"Demo JS bundled.","Demo JS bundling failed.")}import pn from"node:path";import ee from"ora";import"rollup";var Ae=!1,pi={analyze:{active:!1,lastTime:0},docs:{active:!1,lastTime:0},scss:{active:!1,lastTime:0}},di=5e3,Qe=new Set,fi=["/dist/index.d.ts","/custom-elements.json","/demo/api.md","/docs/api.md","/demo/index.min.js"];function gi(e){if(!e||typeof e!="string")return!1;try{let t=pn.normalize(e);return fi.some(r=>t.endsWith(r))||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 Vt(e,t){let r=pi[e];if(r.active||Date.now()-r.lastTime<di)return!1;try{return r.active=!0,r.lastTime=Date.now(),await t()}catch(n){return console.error(`Error in ${e} task:`,n),!1}finally{r.active=!1}}async function dn(e,t,r,{analyze:n=qe,docs:o=Ze,scss:s=Q}={}){let i=!0,a={analyze:!1,docs:!1,scss:!1},c=null,l,m=ee("Activating watch mode...").start(),u={analyze:async()=>{let{wcaInput:f,wcaOutput:h,skipDocs:g}=t;if(g){let S=ee("Skipping component analysis...").start();return setTimeout(()=>{S.succeed("Component analysis skipped.")},0),!0}let b=ee("Detective work: analyzing components...").start();try{return await n(f,h),b.succeed("Component analysis complete! API generated."),!0}catch(S){return b.fail("Analysis hiccup! Something went wrong."),console.error("Component analysis error:",S),!1}},docs:async()=>{if(Ae)return!1;if(t.skipDocs){let h=ee("Skipping docs generation...").start();return setTimeout(()=>{h.succeed("Docs generation skipped.")},0),!0}let f=ee("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(Ae)return!1;try{return await s(),!0}catch(f){return console.error("Demo SCSS compilation error:",f),!1}}},p=()=>{i&&a.analyze&&a.docs&&a.scss&&typeof r=="function"&&(i=!1,r())};function d(f=1e3){c&&clearTimeout(c),c=setTimeout(async()=>{setTimeout(async()=>{a.analyze=await Vt("analyze",u.analyze),setTimeout(async()=>{a.docs=await Vt("docs",u.docs),setTimeout(async()=>{a.scss=await Vt("scss",u.scss),p()},500)},1e3)},1e3)},f)}e.on("event",async f=>{switch(f.code){case"START":m.succeed("Watch mode active! Eyes peeled.");break;case"BUNDLE_START":if(Qe.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"&&!gi(g)&&Qe.add(pn.normalize(g))}catch(h){console.error("Error processing input paths:",h)}l=ee("Weaving bundles...").start(),Ae=!0;break;case"BUNDLE_END":l&&l.succeed(`Bundle ${Array.isArray(f.input)?`of ${f.input.join("& ")} `:""}done in ${f.duration}ms! \u{1F680}`),Ae=!1,Qe.size>0&&d();break;case"END":break;case"ERROR":Ae=!1,l?l.fail(`Oops! Bundle hit a snag: ${f.error.message}`):ee().fail(`Watch mode hiccup: ${f.error.message}`),Qe.clear();break}})}function fn(e,t){return ke(e),t&&ke(t),He(),e}async function bi(e){let t=Ut(e),r=$e(e);e.dev||t.config.plugins.push(hi()),await Ze(e),await Q(),await mn(t.config,r.configs)}async function wi(e){let{dev:t}=e,r=Ut({...e,watch:!0}),n=$e({...e,watch:!0}),o=yi([r.config,...n.configs]);dn(o,e,t?async()=>Je(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 Q()}catch(m){console.error("Demo SCSS watch compilation error:",m)}finally{i=!1,a&&(a=!1,l.emit("all"))}},500)}),fn(o,l),o}async function et(e={}){try{let{watch:t}=e;return un(),t?await wi(e):await bi(e)}catch(t){throw new Error(`Build failed: ${t.message}`)}}var Ce=vi.command("dev").description("Runs development server for auro components");Ce=Le(Ce);Ce=Ge(Ce);var fp=Ce.action(async e=>{try{let t=gn("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 et({...e,dev:!0,watch:e.watch})}catch(t){gn().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{program as ki}from"commander";import hn from"ora";var Jt=ki.command("build").description("Builds auro components");Jt=Le(Jt);var vp=Jt.action(async e=>{try{let t=hn("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 et(e),e.watch||t.succeed("Build completed!")}catch(t){hn().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{exec as Ei}from"node:child_process";import yn from"node:path";import Si from"node:process";import{fileURLToPath as Ti}from"node:url";import $i from"node:util";import{program as xi}from"commander";import Ai from"inquirer";var Pp=xi.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=Ti(import.meta.url),r=yn.dirname(t),n=yn.resolve(r,"migrations",e.id);if(e.multiGitter){let o=$i.promisify(Ei);try{await o("command -v multi-gitter")}catch{console.error("multi-gitter is not installed."),Si.exit(1)}(await Ai.prompt([{type:"confirm",name:"dryRun",message:"Run migration in dry-run mode? (no changes will be committed)",default:!0}])).dryRun?_(`multi-gitter run ${n}/script.sh --config "${n}/multi-gitter.yml" --dry-run`):_(`multi-gitter run ${n}/script.sh --config "${n}/multi-gitter.yml"`)}else _(`${n}/script.sh`)});import En from"node:process";import{program as Ii}from"commander";import{readFile as Ni,writeFile as Oi}from"node:fs/promises";import{Logger as Re}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import zt from"node:fs/promises";import Kt from"node:path";import{Octokit as Ci}from"@octokit/rest";import F from"ora";import{processContentForFile as Ri,templateFiller as Pi}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";async function bn(e,t){let r=new Ci({auth:process.env.GITHUB_TOKEN||""});try{let o=(await r.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 F().start().fail(s),new Error("Failed to retrieve folder items")}return o}catch(n){let o=F().start();throw n.status===404?o.fail(`Template '${e.split("/")[1]}' not found`):o.fail(`Error accessing template: ${n.message}`),n}}async function wn({folderItems:e,templatePathToReplace:t,rootDir:r,ref:n}){let o=[];for(let s of e){if(s.type=="dir"){let l=F(`Processing directory: ${s.path}`).start(),m=await bn(s.path,n);l.succeed(`Found ${m.length} additional items in ${s.path}`);let u=await wn({folderItems:m,templatePathToReplace:t,rootDir:r,ref:n});o.push(...u);continue}let i=s.path.replace(`${t}/`,""),a=`${r}/.github/${i}`,c={identifier:s.name,input:{remoteUrl:s.download_url||"",fileName:a,overwrite:!0},output:a};o.push(c)}return o}async function Di(e){try{await zt.rm(e,{recursive:!0,force:!0}),F().start().succeed(`Successfully removed directory: ${e}`)}catch(t){throw F().start().fail(`Error removing directory ${e}: ${t.message}`),t}}async function vn(e,t="",r=!0){try{let n=await zt.stat(e),o=Kt.basename(e);if(!n.isDirectory())return`${t}${r?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}
25
+ `))}async function Ee(e={}){let t=e.readmeTemplate,r=t&&!t.startsWith("http");await js({...Kr,...r?{localReadmePath:B.resolve(process.cwd(),t)}:{remoteReadmeUrl:t||"https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/README.md"}},e.skipReadme)}function zr(e){return j.existsSync(N(e))}import{existsSync as Yr,readFileSync as Bs}from"node:fs";import{builtinModules as Us}from"node:module";import{resolve as Ve}from"node:path";import{startDevServer as Ws}from"@web/dev-server";import{hmrPlugin as Hs}from"@web/dev-server-hmr";import*as Xr from"esbuild";import Vs from"ora";var H=["node_modules","../node_modules","../../node_modules","../../../node_modules"];var Js=/^\/__wds-outside-root__\/(\d+)\/(.+)$/;function zs(){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),r=process.cwd();for(let n of H){let o=Ve(r,n,t);if(Yr(o))return{body:Bs(o,"utf-8"),type:"css"}}}}}function Ks(e,t){let r=e.match(Js);return r?Ve(t,"../".repeat(Number.parseInt(r[1],10)),r[2]):Ve(t,`.${e}`)}function qs(){let e=/\b(require\s*\(|module\.exports\b|exports\.\w)/,t=new Map,r;return{name:"cjs-to-esm",async serverStart({config:n}){r=Ve(n.rootDir)},async transform(n){if(!n.path.includes("node_modules")||!n.path.endsWith(".js")&&!n.path.endsWith(".cjs")||typeof n.body!="string"||!e.test(n.body))return;let o=Ks(n.path,r);if(t.has(o))return t.get(o);if(Yr(o))try{let i={body:(await Xr.build({entryPoints:[o],bundle:!0,format:"esm",platform:"browser",write:!1,logLevel:"silent",external:Us})).outputFiles[0].text};return t.set(o,i),i}catch(s){console.error(`CJS-to-ESM bundling failed for ${n.path}:`,s.message)}}}}var Se={watch:!0,nodeResolve:!0,basePath:"/",rootDir:"./demo",hmrInclude:["src/**/*","demo/**/*","apiExamples/**/*","docs/**/*"]};async function Je(e={}){if(!e.serve)return;let t=Vs(`Firing up dev server...
26
+ `).start();try{let r={port:Number(e.port)||void 0,open:e.open?"/":void 0,watch:e.watch??Se.watch,nodeResolve:e.nodeResolve??Se.nodeResolve,basePath:e.basePath??Se.basePath,rootDir:e.rootDir??Se.rootDir,middleware:[function(s,i){return!s.url.endsWith("/")&&!s.url.includes(".")&&(s.url+=".html"),i()}],plugins:[zs(),qs(),Hs({include:e.hmrInclude??Se.hmrInclude})]},n=await Ws({config:r,readCliArgs:!1,readFileConfig:!1});return t.stop(),n}catch(r){throw t.fail("Server snag! Couldn't start dev server."),console.error("Error starting development server:",r),new Error(`Development server failed to start: ${r.message}`)}}async function ze(){let e=Te("Generating Custom Elements Manifest...").start();try{await _(`npx --package=@custom-elements-manifest/analyzer -y -- cem analyze --config '${Ur("custom-elements-manifest.config.mjs")}'`),e.succeed("Custom Elements Manifest generated successfully!")}catch(t){let r=t instanceof Error?t.message:String(t);e.warn("CEM analyzer completed with warnings: "+r)}}async function Ke(){let e=Te("Generating API md file...").start();try{await ve.generate(),e.succeed("API md file generated successfully!")}catch(t){let r=t instanceof Error?t.message:String(t);throw e.fail("Failed to generate API md file: "+r),t}}async function Zr(e={},{build:t=Ee,demo:r=Qr}={}){let n=Te("Compiling documentation...").start(),o;try{await t(e),n.succeed("Documentation compiled successfully!")}catch(s){let i=s instanceof Error?s.message:String(s);n.fail("Failed to compile MD documentation: "+i),o=s}if(await r(e),o)throw o}async function Qr(e={}){We(),await Q(),await rn(e)}async function en(e={}){await Je(e)}async function tn(e={}){let t=await import("chokidar"),r=["./src/**/*","./docs/**/*","./docTemplates/**/*","./apiExamples/**/*","./demo/**/*.scss"],n=["**/demo/*.min.js","**/demo/*.min.css","**/demo/*.md","**/demo/readme.md","**/docs/api.md","**/custom-elements.json","**/node_modules/**","**/dist/**","**/.git/**"],o=t.watch(r,{ignoreInitial:!0,ignored:n,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100}}),s=Te("Waiting for changes...");s.spinner="bouncingBar",s.color="green",s.start();let i=null,a=!1,c=!1;async function l(m){if(a){c=!0;return}a=!0,o.unwatch(r);let u=Te(`Change detected: ${m}`).start();try{let p;try{await Ee(e)}catch(d){p=d}if(await Qr(e),p)throw p;u.succeed("Docs rebuilt!")}catch(p){let d=p instanceof Error?p.message:String(p);u.fail("Rebuild failed: "+d)}finally{setTimeout(()=>{o.add(r),a=!1,c&&(c=!1,l("queued changes"))},1e3)}}o.on("all",(m,u)=>{a||(i&&clearTimeout(i),i=setTimeout(()=>{l(u)},1e3))}),ke(o),He()}async function qe(){await ze(),await Ke()}import{basename as Zs,join as on,resolve as Qs}from"node:path";import ei from"@rollup/plugin-commonjs";import{nodeResolve as ti}from"@rollup/plugin-node-resolve";import{glob as ri}from"glob";import{litScss as ni}from"rollup-plugin-scss-lit";import Ys from"node:path";import{glob as Xs}from"glob";function nn(e){return{name:"watch-globs",buildStart(){let t=Array.isArray(e)?e:[e];for(let r of t)try{for(let n of Xs.sync(Ys.resolve(r)))this.addWatchFile(n)}catch(n){this.error(`Error watching glob pattern "${r}": ${n.message}`)}}}}var Bt={moduleDirectories:["node_modules"],modulePaths:["../../node_modules","../node_modules","node_modules"],watchPatterns:["./apiExamples/**/*","./docs/**/*"]};function sn(e=[],t={}){let{watchPatterns:r=Bt.watchPatterns,dedupe:n=["lit","lit-element","lit-html"],dev:o=!1}=t,s=[...Bt.modulePaths,...e],i=process.cwd(),a=H.map(c=>Qs(i,c));return[ti({dedupe:n,preferBuiltins:!1,moduleDirectories:Bt.moduleDirectories,modulePaths:a}),ei(),ni({minify:o?!1:{fast:!0},options:{loadPaths:[...s,on(process.cwd(),"src","styles"),on(process.cwd(),"src")]}}),nn(r)]}function Ut(e={}){let{modulePaths:t=[],watch:r=!1,input:n=["./src/index.js","./src/registered.js"],outputDir:o="./dist",format:s="esm",dev:i=!1}=e;return{name:"Main",config:{input:n,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:oi(),plugins:sn(t,{dev:i}),watch:an(r)}}}function $e(e={}){let{modulePaths:t=[],watch:r=!1,globPattern:n="./demo/*.js",ignorePattern:o=["./demo/*.min.js"],outputDir:s="./demo",dev:i=!1}=e,a=ri.sync(n,{ignore:o}),c=sn(t,{dev:i}),l=an(r);return{name:"Demo",configs:a.map(u=>({input:{[Zs(u,".js")]:u},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(d,f){if(d.code==="UNRESOLVED_IMPORT")throw new Error(`Unresolved import "${d.exporter??d.source}" in ${d.id??u}. Make sure workspace dependencies are built before bundling demos.`);f(d)},watch:l}))}}function an(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 oi(e=[]){return[...[/node_modules\/lit/,/node_modules\/lit-element/,/node_modules\/lit-html/,/node_modules\/@lit/],...e]}function mn(){let e=xe("./dist"),t=Ht("Cleaning dist folder...").start();try{return ii(e,{recursive:!0,force:!0}),t.succeed("All clean! Dist folder wiped."),!0}catch(r){return t.fail(`Oops! Couldn't clean dist/ folder: ${r.message}`),console.error(r),!1}}async function Xe(e,t,r,n){let o=Ht(e).start();try{let s=await t();return o.succeed(r),s}catch(s){throw o.fail(n),console.error(`Error: ${s.message}`),s}}async function pn(e,t){return Xe(`Bundling ${e.name||"main"} and demo...`,async()=>{let r=await Wt(e);await r.write(e.output),await r.close();for(let n of t){let o=await Wt(n);await o.write(n.output),await o.close()}},`Bundles ready! ${e.name||"Main"} and demo built.`,"Bundle hiccup! Build failed.")}async function Ze(e){let{wcaInput:t,wcaOutput:r,skipDocs:n}=e;if(n){let o=Ht("Skipping docs generation...").start();setTimeout(()=>{o.succeed("Docs generation skipped.")},0);return}return Xe("Analyzing components and making docs...",async()=>{await qe(t,r),await Ee(e),We()},"Docs ready! Looking good.","Doc troubles!")}function mi(){let e=process.cwd();function t(o){return[o,`${o}.scss`,`${o}.css`,xe(li(o),`_${ci(o)}.scss`),xe(o,"_index.scss"),xe(o,"index.scss")].find(i=>cn(i))}function r(o){for(let i of H){let a=t(Ye(e,i,o));if(a)return a}let s=n(o);return s||null}function n(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 H){let c=Ye(e,a,s,"package.json");if(cn(c))try{let m=JSON.parse(si(c,"utf-8")).exports;if(!m||typeof m!="object")continue;let u=m[i];if(!u)continue;let p=typeof u=="string"?u:u.default||u.import;if(!p)continue;let d=t(Ye(e,a,s,p));if(d)return d}catch{continue}}return null}return{findFileUrl(o){if(o.includes("/node_modules/")){let s=o.lastIndexOf("/node_modules/"),i=o.slice(s+14),a=r(i);if(a)return ln(a)}if(!o.startsWith(".")&&!o.startsWith("/")&&!o.startsWith("file:")){let s=r(o);if(s)return ln(s)}return null}}}async function Q(e="./demo"){return Xe("Compiling demo SCSS...",async()=>{let t=ui.sync(xe(e,"**/*.scss")),r=mi(),n=process.cwd(),o=H.map(s=>Ye(n,s));for(let s of t){let i=un.compile(s,{importers:[r],loadPaths:o,silenceDeprecations:["import"],style:"compressed"}),a=s.replace(/\.scss$/,".min.css");ai(a,i.css)}return t.length},"Demo SCSS compiled.","SCSS compilation failed.")}async function rn(e={}){let{configs:t}=$e(e);return Xe("Bundling demo JS...",async()=>{for(let r of t){let n=await Wt(r);await n.write(r.output),await n.close()}},"Demo JS bundled.","Demo JS bundling failed.")}import dn from"node:path";import ee from"ora";import"rollup";var Ae=!1,pi={analyze:{active:!1,lastTime:0},docs:{active:!1,lastTime:0},scss:{active:!1,lastTime:0}},di=5e3,Qe=new Set,fi=["/dist/index.d.ts","/custom-elements.json","/demo/api.md","/docs/api.md","/demo/index.min.js"];function gi(e){if(!e||typeof e!="string")return!1;try{let t=dn.normalize(e);return fi.some(r=>t.endsWith(r))||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 Vt(e,t){let r=pi[e];if(r.active||Date.now()-r.lastTime<di)return!1;try{return r.active=!0,r.lastTime=Date.now(),await t()}catch(n){return console.error(`Error in ${e} task:`,n),!1}finally{r.active=!1}}async function fn(e,t,r,{analyze:n=qe,docs:o=Ze,scss:s=Q}={}){let i=!0,a={analyze:!1,docs:!1,scss:!1},c=null,l,m=ee("Activating watch mode...").start(),u={analyze:async()=>{let{wcaInput:f,wcaOutput:h,skipDocs:g}=t;if(g){let S=ee("Skipping component analysis...").start();return setTimeout(()=>{S.succeed("Component analysis skipped.")},0),!0}let b=ee("Detective work: analyzing components...").start();try{return await n(f,h),b.succeed("Component analysis complete! API generated."),!0}catch(S){return b.fail("Analysis hiccup! Something went wrong."),console.error("Component analysis error:",S),!1}},docs:async()=>{if(Ae)return!1;if(t.skipDocs){let h=ee("Skipping docs generation...").start();return setTimeout(()=>{h.succeed("Docs generation skipped.")},0),!0}let f=ee("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(Ae)return!1;try{return await s(),!0}catch(f){return console.error("Demo SCSS compilation error:",f),!1}}},p=()=>{i&&a.analyze&&a.docs&&a.scss&&typeof r=="function"&&(i=!1,r())};function d(f=1e3){c&&clearTimeout(c),c=setTimeout(async()=>{setTimeout(async()=>{a.analyze=await Vt("analyze",u.analyze),setTimeout(async()=>{a.docs=await Vt("docs",u.docs),setTimeout(async()=>{a.scss=await Vt("scss",u.scss),p()},500)},1e3)},1e3)},f)}e.on("event",async f=>{switch(f.code){case"START":m.succeed("Watch mode active! Eyes peeled.");break;case"BUNDLE_START":if(Qe.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"&&!gi(g)&&Qe.add(dn.normalize(g))}catch(h){console.error("Error processing input paths:",h)}l=ee("Weaving bundles...").start(),Ae=!0;break;case"BUNDLE_END":l&&l.succeed(`Bundle ${Array.isArray(f.input)?`of ${f.input.join("& ")} `:""}done in ${f.duration}ms! \u{1F680}`),Ae=!1,Qe.size>0&&d();break;case"END":break;case"ERROR":Ae=!1,l?l.fail(`Oops! Bundle hit a snag: ${f.error.message}`):ee().fail(`Watch mode hiccup: ${f.error.message}`),Qe.clear();break}})}function gn(e,t){return ke(e),t&&ke(t),He(),e}async function bi(e){let t=Ut(e),r=$e(e);e.dev||t.config.plugins.push(hi()),await Ze(e),await Q(),await pn(t.config,r.configs)}async function wi(e){let{dev:t}=e,r=Ut({...e,watch:!0}),n=$e({...e,watch:!0}),o=yi([r.config,...n.configs]);fn(o,e,t?async()=>Je(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 Q()}catch(m){console.error("Demo SCSS watch compilation error:",m)}finally{i=!1,a&&(a=!1,l.emit("all"))}},500)}),gn(o,l),o}async function et(e={}){try{let{watch:t}=e;return mn(),t?await wi(e):await bi(e)}catch(t){throw new Error(`Build failed: ${t.message}`)}}var Ce=vi.command("dev").description("Runs development server for auro components");Ce=Le(Ce);Ce=Ge(Ce);var fp=Ce.action(async e=>{try{let t=hn("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 et({...e,dev:!0,watch:e.watch})}catch(t){hn().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{program as ki}from"commander";import yn from"ora";var Jt=ki.command("build").description("Builds auro components");Jt=Le(Jt);var vp=Jt.action(async e=>{try{let t=yn("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 et(e),e.watch||t.succeed("Build completed!")}catch(t){yn().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{exec as Ei}from"node:child_process";import bn from"node:path";import Si from"node:process";import{fileURLToPath as Ti}from"node:url";import $i from"node:util";import{program as xi}from"commander";import Ai from"inquirer";var Pp=xi.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=Ti(import.meta.url),r=bn.dirname(t),n=bn.resolve(r,"migrations",e.id);if(e.multiGitter){let o=$i.promisify(Ei);try{await o("command -v multi-gitter")}catch{console.error("multi-gitter is not installed."),Si.exit(1)}(await Ai.prompt([{type:"confirm",name:"dryRun",message:"Run migration in dry-run mode? (no changes will be committed)",default:!0}])).dryRun?_(`multi-gitter run ${n}/script.sh --config "${n}/multi-gitter.yml" --dry-run`):_(`multi-gitter run ${n}/script.sh --config "${n}/multi-gitter.yml"`)}else _(`${n}/script.sh`)});import Sn from"node:process";import{program as Ii}from"commander";import{readFile as Ni,writeFile as Oi}from"node:fs/promises";import{Logger as Re}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import zt from"node:fs/promises";import Kt from"node:path";import{Octokit as Ci}from"@octokit/rest";import F from"ora";import{processContentForFile as Ri,templateFiller as Pi}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";async function wn(e,t){let r=new Ci({auth:process.env.GITHUB_TOKEN||""});try{let o=(await r.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 F().start().fail(s),new Error("Failed to retrieve folder items")}return o}catch(n){let o=F().start();throw n.status===404?o.fail(`Template '${e.split("/")[1]}' not found`):o.fail(`Error accessing template: ${n.message}`),n}}async function vn({folderItems:e,templatePathToReplace:t,rootDir:r,ref:n}){let o=[];for(let s of e){if(s.type=="dir"){let l=F(`Processing directory: ${s.path}`).start(),m=await wn(s.path,n);l.succeed(`Found ${m.length} additional items in ${s.path}`);let u=await vn({folderItems:m,templatePathToReplace:t,rootDir:r,ref:n});o.push(...u);continue}let i=s.path.replace(`${t}/`,""),a=`${r}/.github/${i}`,c={identifier:s.name,input:{remoteUrl:s.download_url||"",fileName:a,overwrite:!0},output:a};o.push(c)}return o}async function Di(e){try{await zt.rm(e,{recursive:!0,force:!0}),F().start().succeed(`Successfully removed directory: ${e}`)}catch(t){throw F().start().fail(`Error removing directory ${e}: ${t.message}`),t}}async function kn(e,t="",r=!0){try{let n=await zt.stat(e),o=Kt.basename(e);if(!n.isDirectory())return`${t}${r?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}
28
27
  `;let s=`${t}${r?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}/
29
- `;try{let a=(await zt.readdir(e)).sort();for(let c=0;c<a.length;c++){let l=a[c],m=Kt.join(e,l),u=c===a.length-1,p=t+(r?" ":"\u2502 ");s+=await vn(m,p,u)}}catch{s+=`${t}${r?" ":"\u2502 "}\u2514\u2500\u2500 [Permission denied or error reading directory]
28
+ `;try{let a=(await zt.readdir(e)).sort();for(let c=0;c<a.length;c++){let l=a[c],m=Kt.join(e,l),u=c===a.length-1,p=t+(r?" ":"\u2502 ");s+=await kn(m,p,u)}}catch{s+=`${t}${r?" ":"\u2502 "}\u2514\u2500\u2500 [Permission denied or error reading directory]
30
29
  `}return s}catch(n){return`${t}${r?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}[Error: ${n}]
31
- `}}async function kn(e,t="main",r="default"){if(!e)throw F().start().fail("Root directory must be specified"),new Error("Root directory must be specified");if(await Pi.extractNames(),!process.env.GITHUB_TOKEN)throw F().start().fail("GITHUB_TOKEN environment variable is not set."),new Error("GITHUB_TOKEN environment variable is not set");let n=`templates/${r}/.github`,o=await bn(n,t),s=".github",i=F("Removing existing .github directory...").start();try{await Di(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 wn({folderItems:o,templatePathToReplace:n,rootDir:e,ref:t}),c=F("Processing all files...").start();try{await Promise.all(a.map(m=>Ri(m))),c.succeed("All files processed.");let l=F("Generating directory tree...").start();try{let m=Kt.join(e,".github"),u=await vn(m);l.succeed("Synced .github directory structure:"),console.log(u)}catch(m){l.fail(`Error generating directory tree: ${m.message}`)}}catch(l){throw c.fail(`Error processing files: ${l.message}`),new Error(`Failed to process files: ${l.message}`)}}var Wp=Ii.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=>{Re.info("Synchronizing repository configuration files..."),Re.warn("Note: sync does not create a new git branch. Changes are added to the current branch.");let t=En.cwd();try{await kn(t,e.ref,e.template);try{let r=`${t}/.github/CODEOWNERS`,o=(await Ni(r,{encoding:"utf-8"})).replace(/\r\n/gu,`
30
+ `}}async function En(e,t="main",r="default"){if(!e)throw F().start().fail("Root directory must be specified"),new Error("Root directory must be specified");if(await Pi.extractNames(),!process.env.GITHUB_TOKEN)throw F().start().fail("GITHUB_TOKEN environment variable is not set."),new Error("GITHUB_TOKEN environment variable is not set");let n=`templates/${r}/.github`,o=await wn(n,t),s=".github",i=F("Removing existing .github directory...").start();try{await Di(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 vn({folderItems:o,templatePathToReplace:n,rootDir:e,ref:t}),c=F("Processing all files...").start();try{await Promise.all(a.map(m=>Ri(m))),c.succeed("All files processed.");let l=F("Generating directory tree...").start();try{let m=Kt.join(e,".github"),u=await kn(m);l.succeed("Synced .github directory structure:"),console.log(u)}catch(m){l.fail(`Error generating directory tree: ${m.message}`)}}catch(l){throw c.fail(`Error processing files: ${l.message}`),new Error(`Failed to process files: ${l.message}`)}}var Wp=Ii.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=>{Re.info("Synchronizing repository configuration files..."),Re.warn("Note: sync does not create a new git branch. Changes are added to the current branch.");let t=Sn.cwd();try{await En(t,e.ref,e.template);try{let r=`${t}/.github/CODEOWNERS`,o=(await Ni(r,{encoding:"utf-8"})).replace(/\r\n/gu,`
32
31
  `).replace(/\n\n/gu,`
33
32
  `);await Oi(r,o,{encoding:"utf-8"}),(o.includes("\r")||o.includes(`
34
33
 
35
- `))&&Re.error("CODEOWNERS file still has Windows line endings.")}catch(r){throw Re.error(`Error processing CODEOWNERS file: ${r.message}`),r}}catch(r){Re.error(`Sync operation failed: ${r.message}`),En.exit(1)}});import tt from"node:fs";import Pe from"node:path";import{Logger as Tn}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Mi}from"commander";import{glob as _i}from"glob";var Sn=(e,t)=>{let r=(e.match(/static register\(name \= (.+)\)/)||e.match(/customElements.get\((.+?)\)/))[1],n=e.match(/export class (.+) extends/)?.[1],o=e.match(/\/\*\*((.|\n)*?)(\*\n|\*\/|[@])/)?.[1]||"";return!r||!n?e:`
34
+ `))&&Re.error("CODEOWNERS file still has Windows line endings.")}catch(r){throw Re.error(`Error processing CODEOWNERS file: ${r.message}`),r}}catch(r){Re.error(`Sync operation failed: ${r.message}`),Sn.exit(1)}});import tt from"node:fs";import Pe from"node:path";import{Logger as $n}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Mi}from"commander";import{glob as _i}from"glob";var Tn=(e,t)=>{let r=(e.match(/static register\(name \= (.+)\)/)||e.match(/customElements.get\((.+?)\)/))[1],n=e.match(/export class (.+) extends/)?.[1],o=e.match(/\/\*\*((.|\n)*?)(\*\n|\*\/|[@])/)?.[1]||"";return!r||!n?e:`
36
35
  import { ${n} } from '${t}';
37
36
 
38
37
  /**${o}*/
@@ -41,31 +40,31 @@ class ${n}WCA extends ${n} {}
41
40
  if (!customElements.get(${r})) {
42
41
  customElements.define(${r}, ${n}WCA);
43
42
  }
44
- `};var rt=Pe.resolve(process.cwd(),"./scripts/wca");async function ji(e){try{return(await Promise.all(e.map(r=>_i(r)))).flat()}catch(t){throw console.error("Error processing glob patterns:",t),t}}async function Fi(e){tt.existsSync(rt)||await tt.promises.mkdir(rt,{recursive:!0});for(let t of e){let r=Pe.resolve(process.cwd(),t),n=await tt.promises.readFile(r,"utf-8"),o=Pe.resolve(rt,`${Pe.basename(t)}`),s=Sn(n,Pe.relative(rt,t));await tt.promises.writeFile(o,s)}}async function Li(){let e=await ji(["./src/auro-*.js"]);await Fi(e)}var Zp=Mi.command("wca-setup").description("Set up WCA (Web Component Analyzer) for the project").action(()=>{Li().then(()=>{Tn.success("WCA setup completed successfully.")}).catch(e=>{Tn.error(`WCA setup failed: ${e.message}`)})});import{program as qi}from"commander";import Cn from"chalk";import Rn from"ora";import{appendFile as Gi,readFile as Bi}from"node:fs/promises";import{Logger as w}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{simpleGit as Ui}from"simple-git";var v;try{v=Ui({baseDir:process.cwd(),binary:"git",maxConcurrentProcesses:1})}catch(e){w.error(`Failed to initialize git: ${e}`),v={}}var V=class e{static async checkGitignore(t){if(t==="")return!1;try{return(await Bi(".gitignore","utf-8")).includes(t)}catch(r){return w.error(`Error reading file: ${r}`),!1}}static async getCommitMessages(t=""){try{let r=t;r||(r=(await v.branchLocal()).current);let n="main",o="";if(!!process.env.GITHUB_ACTIONS){n=process.env.GITHUB_BASE_REF||"main";try{if(await v.fetch("origin",n),r!=="HEAD")try{await v.raw(["rev-parse","--verify",`origin/${r}`])}catch{await v.fetch("origin",r)}let i=r==="HEAD"?"HEAD":`origin/${r}`;o=`${(await v.raw(["merge-base",`origin/${n}`,i])).trim()}..${i}`}catch(i){w.warn(`Error setting up commit range in CI: ${i}`);let a=r==="HEAD"?"HEAD":`origin/${r}`;o=`origin/${n}..${a}`}}else try{try{await v.raw(["rev-parse","--verify",`origin/${n}`])}catch{w.info(`Fetching ${n} from origin`),await v.fetch("origin",n)}if(r!=="HEAD")try{await v.raw(["rev-parse","--verify",r])}catch{await v.fetch("origin",r)}o=`${(await v.raw(["merge-base",`origin/${n}`,r])).trim()}..${r}`}catch(i){w.warn(`Error determining commits locally: ${i}`),o=`${r}~10..${r}`}return await e.getFormattedCommits(o)}catch(r){return w.error(`Error getting commit messages: ${r}`),[]}}static async getRepoOwnerAndName(){try{let t=await v.getRemotes(!0);if(t.length===0)return w.warn("No remotes found"),null;let r=t.find(o=>o.name==="origin")||t[0],n=r.refs.fetch||r.refs.push;return e.parseGitUrl(n)}catch(t){return w.error(`Error getting repo owner and name: ${t}`),null}}static async getCurrentBranchName(){try{return(await v.branchLocal()).current||null}catch(t){return w.error(`Error getting current branch name: ${t}`),null}}static parseGitUrl(t){let r;return t.includes("@")&&t.includes(":")&&(r=t.match(/@([^:]+):([^/]+)\/(.+?)(?:\.git)?$/),r)?{owner:r[2],repo:r[3]}:(r=t.match(/https?:\/\/(?:[^@]+@)?[^/]+\/([^/]+)\/(.+?)(?:\.git)?$/),r?{owner:r[1],repo:r[2]}:(w.warn(`Could not parse git URL: ${t}`),null))}static async getFormattedCommits(t){let n=(await v.raw(["log","--pretty=format:COMMIT_START%n%H%n%ad%n%an%n%s%n%b%nCOMMIT_END","--date=short",t])).split(`COMMIT_START
43
+ `};var rt=Pe.resolve(process.cwd(),"./scripts/wca");async function ji(e){try{return(await Promise.all(e.map(r=>_i(r)))).flat()}catch(t){throw console.error("Error processing glob patterns:",t),t}}async function Fi(e){tt.existsSync(rt)||await tt.promises.mkdir(rt,{recursive:!0});for(let t of e){let r=Pe.resolve(process.cwd(),t),n=await tt.promises.readFile(r,"utf-8"),o=Pe.resolve(rt,`${Pe.basename(t)}`),s=Tn(n,Pe.relative(rt,t));await tt.promises.writeFile(o,s)}}async function Li(){let e=await ji(["./src/auro-*.js"]);await Fi(e)}var Zp=Mi.command("wca-setup").description("Set up WCA (Web Component Analyzer) for the project").action(()=>{Li().then(()=>{$n.success("WCA setup completed successfully.")}).catch(e=>{$n.error(`WCA setup failed: ${e.message}`)})});import{program as qi}from"commander";import Rn from"chalk";import Pn from"ora";import{appendFile as Gi,readFile as Bi}from"node:fs/promises";import{Logger as w}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{simpleGit as Ui}from"simple-git";var v;try{v=Ui({baseDir:process.cwd(),binary:"git",maxConcurrentProcesses:1})}catch(e){w.error(`Failed to initialize git: ${e}`),v={}}var V=class e{static async checkGitignore(t){if(t==="")return!1;try{return(await Bi(".gitignore","utf-8")).includes(t)}catch(r){return w.error(`Error reading file: ${r}`),!1}}static async getCommitMessages(t=""){try{let r=t;r||(r=(await v.branchLocal()).current);let n="main",o="";if(!!process.env.GITHUB_ACTIONS){n=process.env.GITHUB_BASE_REF||"main";try{if(await v.fetch("origin",n),r!=="HEAD")try{await v.raw(["rev-parse","--verify",`origin/${r}`])}catch{await v.fetch("origin",r)}let i=r==="HEAD"?"HEAD":`origin/${r}`;o=`${(await v.raw(["merge-base",`origin/${n}`,i])).trim()}..${i}`}catch(i){w.warn(`Error setting up commit range in CI: ${i}`);let a=r==="HEAD"?"HEAD":`origin/${r}`;o=`origin/${n}..${a}`}}else try{try{await v.raw(["rev-parse","--verify",`origin/${n}`])}catch{w.info(`Fetching ${n} from origin`),await v.fetch("origin",n)}if(r!=="HEAD")try{await v.raw(["rev-parse","--verify",r])}catch{await v.fetch("origin",r)}o=`${(await v.raw(["merge-base",`origin/${n}`,r])).trim()}..${r}`}catch(i){w.warn(`Error determining commits locally: ${i}`),o=`${r}~10..${r}`}return await e.getFormattedCommits(o)}catch(r){return w.error(`Error getting commit messages: ${r}`),[]}}static async getRepoOwnerAndName(){try{let t=await v.getRemotes(!0);if(t.length===0)return w.warn("No remotes found"),null;let r=t.find(o=>o.name==="origin")||t[0],n=r.refs.fetch||r.refs.push;return e.parseGitUrl(n)}catch(t){return w.error(`Error getting repo owner and name: ${t}`),null}}static async getCurrentBranchName(){try{return(await v.branchLocal()).current||null}catch(t){return w.error(`Error getting current branch name: ${t}`),null}}static parseGitUrl(t){let r;return t.includes("@")&&t.includes(":")&&(r=t.match(/@([^:]+):([^/]+)\/(.+?)(?:\.git)?$/),r)?{owner:r[2],repo:r[3]}:(r=t.match(/https?:\/\/(?:[^@]+@)?[^/]+\/([^/]+)\/(.+?)(?:\.git)?$/),r?{owner:r[1],repo:r[2]}:(w.warn(`Could not parse git URL: ${t}`),null))}static async getFormattedCommits(t){let n=(await v.raw(["log","--pretty=format:COMMIT_START%n%H%n%ad%n%an%n%s%n%b%nCOMMIT_END","--date=short",t])).split(`COMMIT_START
45
44
  `).filter(s=>s.trim()!==""),o=[];for(let s of n){let i=s.split(`
46
45
  `);if(i.length>=4){let a=i[0],c=i[1],l=i[2],m=i[3],u=i.slice(4).filter(g=>g!=="COMMIT_END"),p=u.length>0?u.join(""):"",d=a.substring(0,7),f=m.match(/^(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?:/),h=f?f[1]:"unknown";p.includes("BREAKING CHANGE")&&(h="breaking"),o.push({type:h,hash:d,date:c,subject:m,body:p,message:`${m}${p?`
47
46
 
48
47
  ${p}`:""}`,author_name:l})}}return o}static async addToGitignore(t,r=!0){await e.checkGitignore(t).then(async n=>{if(n)w.warn(`${t} already exists`);else try{await Gi(".gitignore",`
49
- ${t}`),r&&w.success(`${t} added to .gitignore`)}catch(o){w.error(o)}})}static async removeFromGitCache(t){try{await v.rmKeepLocal(t),w.success(`${t.join(", ")} are removed from git cache`)}catch(r){w.error(r)}}static async createBranch(t){try{await v.checkoutLocalBranch(t),w.success(`Created and switched to ${t} branch`)}catch(r){w.error(r)}}static async commitStagedFiles(t){try{await v.add("."),await v.commit(t),w.success(`Committed with message: ${t}`)}catch(r){w.error(r)}}};import E from"chalk";var Wi=60,Hi=100;function De(e){switch(e){case"breaking":return E.bold.red(e);case"feat":return E.bold.green(e);case"fix":return E.bold.green(e);case"perf":return E.bold.green(e);case"docs":return E.bold.cyan(e);case"style":return E.bold.cyan(e);case"refactor":return E.bold.cyan(e);case"test":return E.bold.cyan(e);case"build":return E.bold.cyan(e);case"ci":return E.bold.cyan(e);case"chore":return E.bold.cyan(e);default:return E.bold.white(e)}}function $n(e,t){if(!e)return"";if(e.length<=t)return e;let r=e.split(" "),n="",o="";for(let s of r)(o+s).length>t&&o.length>0&&(n+=`${o.trim()}
50
- `,o=""),o=`${o}${s} `;return o.length>0&&(n+=o.trim()),n}function xn(e){for(let t of e){console.log("\u2500".repeat(60));let r=$n(t.subject,Wi),n=$n(t.body,Hi);console.log(E.bold(`${De(t.type)}`)),console.log(E.dim(`${t.hash} | ${t.date} | ${t.author_name}`)),console.log(E.bold(`${E.white(r)}`)),t.body&&console.log(E.dim(n))}console.log("\u2500".repeat(60)),console.log(`
51
- `)}import*as Ie from"@actions/github";async function qt(){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=Ie.getOctokit(e),{context:r}=Ie;if(!r.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[n,o]=process.env.GITHUB_REPOSITORY.split("/"),s=r.payload.pull_request.number,{data:i}=await t.rest.issues.listLabelsOnIssue({owner:n,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 An(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 r=Ie.getOctokit(t),{context:n}=Ie;if(!n.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[o,s]=process.env.GITHUB_REPOSITORY.split("/"),i=n.payload.pull_request.number,a=`semantic-status: ${e}`,c=await qt();if(c.includes(a))return;let l=c.filter(m=>m.startsWith("semantic-status:")&&m!==a);for(let m of l)await r.rest.issues.removeLabel({owner:o,repo:s,issue_number:i,name:m});await r.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 Vi=["feat","fix","breaking","perf"];function Ji(e,t=!0){let r=`### In this release
48
+ ${t}`),r&&w.success(`${t} added to .gitignore`)}catch(o){w.error(o)}})}static async removeFromGitCache(t){try{await v.rmKeepLocal(t),w.success(`${t.join(", ")} are removed from git cache`)}catch(r){w.error(r)}}static async createBranch(t){try{await v.checkoutLocalBranch(t),w.success(`Created and switched to ${t} branch`)}catch(r){w.error(r)}}static async commitStagedFiles(t){try{await v.add("."),await v.commit(t),w.success(`Committed with message: ${t}`)}catch(r){w.error(r)}}};import E from"chalk";var Wi=60,Hi=100;function De(e){switch(e){case"breaking":return E.bold.red(e);case"feat":return E.bold.green(e);case"fix":return E.bold.green(e);case"perf":return E.bold.green(e);case"docs":return E.bold.cyan(e);case"style":return E.bold.cyan(e);case"refactor":return E.bold.cyan(e);case"test":return E.bold.cyan(e);case"build":return E.bold.cyan(e);case"ci":return E.bold.cyan(e);case"chore":return E.bold.cyan(e);default:return E.bold.white(e)}}function xn(e,t){if(!e)return"";if(e.length<=t)return e;let r=e.split(" "),n="",o="";for(let s of r)(o+s).length>t&&o.length>0&&(n+=`${o.trim()}
49
+ `,o=""),o=`${o}${s} `;return o.length>0&&(n+=o.trim()),n}function An(e){for(let t of e){console.log("\u2500".repeat(60));let r=xn(t.subject,Wi),n=xn(t.body,Hi);console.log(E.bold(`${De(t.type)}`)),console.log(E.dim(`${t.hash} | ${t.date} | ${t.author_name}`)),console.log(E.bold(`${E.white(r)}`)),t.body&&console.log(E.dim(n))}console.log("\u2500".repeat(60)),console.log(`
50
+ `)}import*as Ie from"@actions/github";async function qt(){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=Ie.getOctokit(e),{context:r}=Ie;if(!r.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[n,o]=process.env.GITHUB_REPOSITORY.split("/"),s=r.payload.pull_request.number,{data:i}=await t.rest.issues.listLabelsOnIssue({owner:n,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 Cn(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 r=Ie.getOctokit(t),{context:n}=Ie;if(!n.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[o,s]=process.env.GITHUB_REPOSITORY.split("/"),i=n.payload.pull_request.number,a=`semantic-status: ${e}`,c=await qt();if(c.includes(a))return;let l=c.filter(m=>m.startsWith("semantic-status:")&&m!==a);for(let m of l)await r.rest.issues.removeLabel({owner:o,repo:s,issue_number:i,name:m});await r.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 Vi=["feat","fix","breaking","perf"];function Ji(e,t=!0){let r=`### In this release
52
51
  `;for(let n of e)if(r+=`- ${n.hash} ${n.subject}
53
- `,n.body?.trim()){let s=n.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"),r+=` - ${a}`}}return e.length===0?"":(t&&console.log(Cn.green(`\u2713 Generating release notes for ${e.length} commits`)),r)}function zi(e,t=!0){let r=e.filter(o=>Vi.includes(o.type)),n;return t?n=r.length>0?r:e:n=r,n.length===0&&console.log(`No commits found to include in release notes.
54
- `),n}async function Pn(e=!1,t=!1,r=!1){let n=Rn(`Checking commits...
55
- `).start();try{let o=await V.getCommitMessages();if(r){n.succeed(`Total commits analyzed: ${o.length}`);let s=zi(o);console.log(Ji(s));return}if(e&&xn(o),n.succeed(`Total commits analyzed: ${o.length}`),o.length!==0){let s=o.map(c=>c.type),a=Array.from(new Set(s)).map(c=>De(c)).join(", ");n.succeed(`Found commit types: ${a}`)}else n.info(`The list of commits is created by comparing the current branch
52
+ `,n.body?.trim()){let s=n.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"),r+=` - ${a}`}}return e.length===0?"":(t&&console.log(Rn.green(`\u2713 Generating release notes for ${e.length} commits`)),r)}function zi(e,t=!0){let r=e.filter(o=>Vi.includes(o.type)),n;return t?n=r.length>0?r:e:n=r,n.length===0&&console.log(`No commits found to include in release notes.
53
+ `),n}async function Dn(e=!1,t=!1,r=!1){let n=Pn(`Checking commits...
54
+ `).start();try{let o=await V.getCommitMessages();if(r){n.succeed(`Total commits analyzed: ${o.length}`);let s=zi(o);console.log(Ji(s));return}if(e&&An(o),n.succeed(`Total commits analyzed: ${o.length}`),o.length!==0){let s=o.map(c=>c.type),a=Array.from(new Set(s)).map(c=>De(c)).join(", ");n.succeed(`Found commit types: ${a}`)}else n.info(`The list of commits is created by comparing the current branch
56
55
  with the main branch. If you are on a new branch, please
57
- make sure to commit some changes before running this command.`);t&&await Ki(o,n)}catch(o){n.fail("Error getting commit messages"),console.error(o)}}async function Ki(e,t){let r=["breaking","feat","fix","perf","docs","style","refactor","test","build","ci","chore"],n=e.map(i=>i.type).filter(i=>r.includes(i)),o=null,s=Number.POSITIVE_INFINITY;for(let i of n){let a=r.indexOf(i);a<s&&(s=a,o=i)}if(o){let i=Rn("Checking existing labels on pull request...").start();try{if((await qt()).includes(`semantic-status: ${o}`)){i.info(`Label "semantic-status: ${De(o)}" already exists on the pull request.`);return}i.text="Applying label to pull request...",await An(o),i.succeed(`Label "semantic-status: ${De(o)}" applied to the pull request.`)}catch(a){let c=a instanceof Error?a.message:String(a);i.fail(c)}}else t.warn(Cn.yellow("No semantic commit type found to apply as label."))}var gd=qi.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 Pn(e.debug,e.setLabel,e.releaseNotes)});import Dn from"node:fs";import{get as In}from"node:https";import te from"chalk";import{program as Yi}from"commander";import Xi from"ora";var Ed=Yi.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 Zi(e)}),Zi=async e=>{let{namespace:t,prNumber:r}=e,n=Xi("Updating package.json").start();try{let o="package.json",s=JSON.parse(Dn.readFileSync(o,"utf8"));n.text="Checking npm registry for version information...";let i=`0.0.0-pr${r}`,a=s.name.split("/")[1],c=`${t}/${a}`,l=await Qi(i,c,n),m=`${i}.${l}`;s.name=c,s.version=m,n.text="Writing updated package.json...",Dn.writeFileSync(o,`${JSON.stringify(s,null,2)}
58
- `,"utf8"),n.succeed(`Package.json updated to use ${te.green(m)} and ${te.green(c)}`),process.exit(0)}catch(o){n.fail(`Failed to update package.json: ${o}`),process.exit(1)}},Qi=(e,t,r)=>new Promise(n=>{try{let a=function(c){if(c.statusCode!==200){r.info(`Package not found. Status code: ${te.red(c.statusCode)}, defaulting to version 0`),n(0);return}r.text="Processing version information...";let l="";c.on("data",m=>{l+=m}),c.on("end",()=>{try{let m=JSON.parse(l),u=m.versions?Object.keys(m.versions):[];r.text="Calculating next version number...";let p=-1,d=new RegExp(`^${e}\\.(\\d+)$`);for(let f of u){let h=f.match(d);if(h){let g=Number.parseInt(h[1],10);p=Math.max(p,g)}}p>=0?r.info(`Found existing version ${te.green(`${e}.${p}`)}. Incrementing to ${te.green(`${e}.${p+1}`)}`):r.info(`No existing version found for ${te.green(e)}. Starting with ${te.green(`${e}.0`)}`),n(p+1)}catch(m){r.warn(`Failed to parse NPM registry response: ${m instanceof Error?m.message:"Unknown error"}, defaulting to version 0`),n(0)}})};var o=a;let s=`https://registry.npmjs.org/${t}`,i=In(s,{headers:{Accept:"application/json"}},c=>{if((c.statusCode===301||c.statusCode===302)&&c.headers.location){r.info(`Following redirect to ${c.headers.location}...`);try{In(c.headers.location,{headers:{Accept:"application/json"}},a).on("error",l=>{r.warn(`Error following redirect: ${l.message}, defaulting to version 0`),n(0)}).end()}catch(l){r.warn(`Redirect request failed: ${l instanceof Error?l.message:"Unknown error"}, defaulting to version 0`),n(0)}return}a(c)});i.on("error",c=>{r.warn(`Request error: ${c.message}, defaulting to version 0`),n(0)}),i.end()}catch{r.warn("Error checking version in npm registry, defaulting to version 0"),n(0)}});import Yt from"node:path";import{fileURLToPath as ea}from"node:url";import{program as ta}from"commander";import ra from"open";var na=ea(import.meta.url),oa=Yt.resolve(Yt.dirname(na),".."),Rd=ta.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 r=`npx wtr --config "${Yt.join(oa,"dist","configs","web-test-runner.config.mjs")}"`,n=`${process.cwd()}/coverage/index.html`;if(e.coverageReport&&(r+=" --coverage"),e.watch&&(r+=" --watch"),e.files){let o=Array.isArray(e.files)?e.files.join(" "):e.files;r+=` --files "${o}"`}_(r),e.open&&await ra(n)});import er from"node:fs/promises";import _n from"node:path";import{program as ma}from"commander";import pa from"inquirer";import tr from"ora";import sa from"node:fs/promises";import ia from"node:path";import aa from"ora";var ca={"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 la(e){return Object.entries(e).map(([t,r])=>Array.isArray(r)?`${t}:
56
+ make sure to commit some changes before running this command.`);t&&await Ki(o,n)}catch(o){n.fail("Error getting commit messages"),console.error(o)}}async function Ki(e,t){let r=["breaking","feat","fix","perf","docs","style","refactor","test","build","ci","chore"],n=e.map(i=>i.type).filter(i=>r.includes(i)),o=null,s=Number.POSITIVE_INFINITY;for(let i of n){let a=r.indexOf(i);a<s&&(s=a,o=i)}if(o){let i=Pn("Checking existing labels on pull request...").start();try{if((await qt()).includes(`semantic-status: ${o}`)){i.info(`Label "semantic-status: ${De(o)}" already exists on the pull request.`);return}i.text="Applying label to pull request...",await Cn(o),i.succeed(`Label "semantic-status: ${De(o)}" applied to the pull request.`)}catch(a){let c=a instanceof Error?a.message:String(a);i.fail(c)}}else t.warn(Rn.yellow("No semantic commit type found to apply as label."))}var gd=qi.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 Dn(e.debug,e.setLabel,e.releaseNotes)});import In from"node:fs";import{get as Nn}from"node:https";import te from"chalk";import{program as Yi}from"commander";import Xi from"ora";var Ed=Yi.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 Zi(e)}),Zi=async e=>{let{namespace:t,prNumber:r}=e,n=Xi("Updating package.json").start();try{let o="package.json",s=JSON.parse(In.readFileSync(o,"utf8"));n.text="Checking npm registry for version information...";let i=`0.0.0-pr${r}`,a=s.name.split("/")[1],c=`${t}/${a}`,l=await Qi(i,c,n),m=`${i}.${l}`;s.name=c,s.version=m,n.text="Writing updated package.json...",In.writeFileSync(o,`${JSON.stringify(s,null,2)}
57
+ `,"utf8"),n.succeed(`Package.json updated to use ${te.green(m)} and ${te.green(c)}`),process.exit(0)}catch(o){n.fail(`Failed to update package.json: ${o}`),process.exit(1)}},Qi=(e,t,r)=>new Promise(n=>{try{let a=function(c){if(c.statusCode!==200){r.info(`Package not found. Status code: ${te.red(c.statusCode)}, defaulting to version 0`),n(0);return}r.text="Processing version information...";let l="";c.on("data",m=>{l+=m}),c.on("end",()=>{try{let m=JSON.parse(l),u=m.versions?Object.keys(m.versions):[];r.text="Calculating next version number...";let p=-1,d=new RegExp(`^${e}\\.(\\d+)$`);for(let f of u){let h=f.match(d);if(h){let g=Number.parseInt(h[1],10);p=Math.max(p,g)}}p>=0?r.info(`Found existing version ${te.green(`${e}.${p}`)}. Incrementing to ${te.green(`${e}.${p+1}`)}`):r.info(`No existing version found for ${te.green(e)}. Starting with ${te.green(`${e}.0`)}`),n(p+1)}catch(m){r.warn(`Failed to parse NPM registry response: ${m instanceof Error?m.message:"Unknown error"}, defaulting to version 0`),n(0)}})};var o=a;let s=`https://registry.npmjs.org/${t}`,i=Nn(s,{headers:{Accept:"application/json"}},c=>{if((c.statusCode===301||c.statusCode===302)&&c.headers.location){r.info(`Following redirect to ${c.headers.location}...`);try{Nn(c.headers.location,{headers:{Accept:"application/json"}},a).on("error",l=>{r.warn(`Error following redirect: ${l.message}, defaulting to version 0`),n(0)}).end()}catch(l){r.warn(`Redirect request failed: ${l instanceof Error?l.message:"Unknown error"}, defaulting to version 0`),n(0)}return}a(c)});i.on("error",c=>{r.warn(`Request error: ${c.message}, defaulting to version 0`),n(0)}),i.end()}catch{r.warn("Error checking version in npm registry, defaulting to version 0"),n(0)}});import Yt from"node:path";import{fileURLToPath as ea}from"node:url";import{program as ta}from"commander";import ra from"open";var na=ea(import.meta.url),oa=Yt.resolve(Yt.dirname(na),".."),Rd=ta.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 r=`npx wtr --config "${Yt.join(oa,"dist","configs","web-test-runner.config.mjs")}"`,n=`${process.cwd()}/coverage/index.html`;if(e.coverageReport&&(r+=" --coverage"),e.watch&&(r+=" --watch"),e.files){let o=Array.isArray(e.files)?e.files.join(" "):e.files;r+=` --files "${o}"`}_(r),e.open&&await ra(n)});import er from"node:fs/promises";import jn from"node:path";import{program as ma}from"commander";import pa from"inquirer";import tr from"ora";import sa from"node:fs/promises";import ia from"node:path";import aa from"ora";var ca={"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 la(e){return Object.entries(e).map(([t,r])=>Array.isArray(r)?`${t}:
59
58
  - ${r.join(`
60
59
  - `)}`:typeof r=="object"&&r!==null?`${t}:
61
60
  ${Object.entries(r).map(([n,o])=>` ${n}: ${o}`).join(`
62
61
  `)}`:`${t}: ${r}`).join(`
63
- `)}async function Nn(e){let t=aa("Writing multi-gitter configuration...").start(),r=la(ca),n=ia.join(e,"multi-gitter_DEPENDENCY_TREE.yml");try{await sa.writeFile(n,r,"utf8"),t.succeed(`Multi-gitter configuration written to ${n}`)}catch(o){t.fail("Error writing multi-gitter configuration:"),console.error(o)}}import Xt from"node:fs";function On(e){let t={},r=[],n=[],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;){n=[];let s=o.length;for(let i=0;i<s;i++){let a=o.shift();n.push(a);for(let c of e[a].dependentPackages)t[c]--,t[c]===0&&o.push(c)}r.push(n)}if(r.flat().length!==Object.keys(e).length)throw new Error("Circular dependency detected!");return r}function ua(e){return Xt.readdirSync(e).filter(t=>t.endsWith(".json"))}async function Mn(e,t=[]){console.log(t);let r={},n=ua(e);for(let o of n){if(o==="dependencyTree.json")continue;let s=Xt.readFileSync(`${e}/${o}`,"utf-8"),i=JSON.parse(s),a=i.name,c=Object.keys(i.peerDependencies),l=Object.keys(i.devDependencies),m=Object.keys(i.dependencies);r[a]||(r[a]={dependsOn:[],dependentPackages:[]});let u=[...c,...l,...m];r[a].dependsOn=[...new Set(u)];for(let p of u)r[p]||(r[p]={dependsOn:[],dependentPackages:[]}),r[p].dependentPackages.includes(a)||r[p].dependentPackages.push(a)}if(t.length){let o=new Set;for(let[i,a]of Object.entries(r))a.dependsOn.some(c=>t.includes(c))&&o.add(i);for(let i of t)r[i]&&o.add(i);let s={};for(let i of o)s[i]={dependsOn:r[i].dependsOn.filter(a=>o.has(a)),dependentPackages:r[i].dependentPackages.filter(a=>o.has(a))};r=s}else console.log("No target dependencies provided - using all packages.");return Xt.writeFileSync(`${e}/dependencyTree.json`,JSON.stringify(r,null,2)),r}var O=["@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 Zt=Mt("run-migrations","config"),Qt=Mt("run-migrations","outputs");var Kd=[...O,"@aurodesignsystem/auro-library","@aurodesignsystem/WebCoreStyleSheets","@aurodesignsystem/AuroDesignTokens","@aurodesignsystem/auro-cli","@alaskaairux/icons"];async function da(e){try{await er.mkdir(Qt,{recursive:!0}),await er.mkdir(Zt,{recursive:!0})}catch(o){console.error("Failed to create output or config directories:",o),process.exit(1)}let t=tr("Creating dependency tree...").start();t.text="Creating multi-gitter dependency tree configuration...",await Nn(Zt),t.text="Scraping dependencies from Auro packages...";let n=`multi-gitter run "node ${_t("static","getAuroDeps.js")}" --config ${_n.join(Zt,"multi-gitter_DEPENDENCY_TREE.yml")}`;try{await _(n)}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 Mn(Qt,e),t.succeed("Dependency tree generated successfully."),_n.join(Qt,"dependencyTree.json")}var fa=async e=>{let t=tr("Loading dependency tree...").start(),r=JSON.parse(await er.readFile(e,"utf-8"));t.text="Processing dependency tree...";let n=On(r);return t.succeed("Dependency batches created successfully."),n},qd=ma.command("agent").action(async e=>{let t=await pa.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:r=>r.agentAction==="run-migration",validate:r=>r.trim()!==""||"Migration id cannot be empty."},{type:"confirm",name:"useExisting",message:"Would you like to specify starting packages?",default:!0,transformer:r=>r?"Yes = Packages related to selections":"No = All packages",when:r=>r.agentAction==="run-migration"},{type:"checkbox",name:"startWithComponents",message:"Enter the components to start with (comma-separated, blank for all):",choices:O.map(r=>({name:r.replace("@aurodesignsystem/",""),value:r})),when:r=>r.agentAction==="run-migration"&&r.useExisting}]);switch(t.agentAction){case"run-migration":{let r=tr("Running migration...").start(),n=await da(t.startWithComponents);r.text="Getting dependency batches from tree...";let s=(await fa(n)).map((i,a)=>`Batch ${a+1}
62
+ `)}async function On(e){let t=aa("Writing multi-gitter configuration...").start(),r=la(ca),n=ia.join(e,"multi-gitter_DEPENDENCY_TREE.yml");try{await sa.writeFile(n,r,"utf8"),t.succeed(`Multi-gitter configuration written to ${n}`)}catch(o){t.fail("Error writing multi-gitter configuration:"),console.error(o)}}import Xt from"node:fs";function Mn(e){let t={},r=[],n=[],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;){n=[];let s=o.length;for(let i=0;i<s;i++){let a=o.shift();n.push(a);for(let c of e[a].dependentPackages)t[c]--,t[c]===0&&o.push(c)}r.push(n)}if(r.flat().length!==Object.keys(e).length)throw new Error("Circular dependency detected!");return r}function ua(e){return Xt.readdirSync(e).filter(t=>t.endsWith(".json"))}async function _n(e,t=[]){console.log(t);let r={},n=ua(e);for(let o of n){if(o==="dependencyTree.json")continue;let s=Xt.readFileSync(`${e}/${o}`,"utf-8"),i=JSON.parse(s),a=i.name,c=Object.keys(i.peerDependencies),l=Object.keys(i.devDependencies),m=Object.keys(i.dependencies);r[a]||(r[a]={dependsOn:[],dependentPackages:[]});let u=[...c,...l,...m];r[a].dependsOn=[...new Set(u)];for(let p of u)r[p]||(r[p]={dependsOn:[],dependentPackages:[]}),r[p].dependentPackages.includes(a)||r[p].dependentPackages.push(a)}if(t.length){let o=new Set;for(let[i,a]of Object.entries(r))a.dependsOn.some(c=>t.includes(c))&&o.add(i);for(let i of t)r[i]&&o.add(i);let s={};for(let i of o)s[i]={dependsOn:r[i].dependsOn.filter(a=>o.has(a)),dependentPackages:r[i].dependentPackages.filter(a=>o.has(a))};r=s}else console.log("No target dependencies provided - using all packages.");return Xt.writeFileSync(`${e}/dependencyTree.json`,JSON.stringify(r,null,2)),r}var O=["@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 Zt=Mt("run-migrations","config"),Qt=Mt("run-migrations","outputs");var Kd=[...O,"@aurodesignsystem/auro-library","@aurodesignsystem/WebCoreStyleSheets","@aurodesignsystem/AuroDesignTokens","@aurodesignsystem/auro-cli","@alaskaairux/icons"];async function da(e){try{await er.mkdir(Qt,{recursive:!0}),await er.mkdir(Zt,{recursive:!0})}catch(o){console.error("Failed to create output or config directories:",o),process.exit(1)}let t=tr("Creating dependency tree...").start();t.text="Creating multi-gitter dependency tree configuration...",await On(Zt),t.text="Scraping dependencies from Auro packages...";let n=`multi-gitter run "node ${_t("static","getAuroDeps.js")}" --config ${jn.join(Zt,"multi-gitter_DEPENDENCY_TREE.yml")}`;try{await _(n)}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 _n(Qt,e),t.succeed("Dependency tree generated successfully."),jn.join(Qt,"dependencyTree.json")}var fa=async e=>{let t=tr("Loading dependency tree...").start(),r=JSON.parse(await er.readFile(e,"utf-8"));t.text="Processing dependency tree...";let n=Mn(r);return t.succeed("Dependency batches created successfully."),n},qd=ma.command("agent").action(async e=>{let t=await pa.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:r=>r.agentAction==="run-migration",validate:r=>r.trim()!==""||"Migration id cannot be empty."},{type:"confirm",name:"useExisting",message:"Would you like to specify starting packages?",default:!0,transformer:r=>r?"Yes = Packages related to selections":"No = All packages",when:r=>r.agentAction==="run-migration"},{type:"checkbox",name:"startWithComponents",message:"Enter the components to start with (comma-separated, blank for all):",choices:O.map(r=>({name:r.replace("@aurodesignsystem/",""),value:r})),when:r=>r.agentAction==="run-migration"&&r.useExisting}]);switch(t.agentAction){case"run-migration":{let r=tr("Running migration...").start(),n=await da(t.startWithComponents);r.text="Getting dependency batches from tree...";let s=(await fa(n)).map((i,a)=>`Batch ${a+1}
64
63
  ${i.map(c=>` - ${c.replace("@aurodesignsystem","AlaskaAirlines").replace("@alaskaairux/icons","AlaskaAirlines/Icons")}`).join(`
65
64
  `)}`).join(`
66
65
 
67
- `);console.log(s),r.text="Running migrations on dependency batches...",new Promise(i=>setTimeout(i,2e3)),r.succeed("Migration process completed successfully.");break}default:console.error("Unknown action selected.")}});import{writeFile as ka}from"node:fs/promises";import Ea from"node:path";import nt from"node:process";import{Logger as Wn}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Sa}from"commander";import Ta from"ora";import{readFile as jn}from"node:fs/promises";import re from"node:path";import ga from"node:process";var ha="https://unpkg.com",ya="https://registry.npmjs.org",rr=1e4;function ba(e){let t=e.lastIndexOf("@");return t>0?{pkg:e.slice(0,t),ref:e.slice(t+1)}:{pkg:e}}function Fn(e,t){let r=re.relative(e,t);return r===""||!r.startsWith("..")&&!re.isAbsolute(r)}async function wa(e){let t=re.join(ga.cwd(),"node_modules"),r=re.join(t,...e.split("/"));if(!Fn(t,r))return null;let n,o="custom-elements.json";try{let s=JSON.parse(await jn(re.join(r,"package.json"),"utf-8"));typeof s.version=="string"&&(n=s.version),typeof s.customElements=="string"&&Fn(r,re.resolve(r,s.customElements))&&(o=s.customElements)}catch{return null}try{let s=JSON.parse(await jn(re.join(r,o),"utf-8"));return{target:e,manifest:s,source:"local",version:n}}catch{return null}}async function M(e,t={}){let{preferLocal:r=!0,allowNetwork:n=!0}=t,{ref:o}=ba(e);if(r&&!o){let a=await wa(e);if(a)return{...a,target:e}}if(!n)return{target:e,manifest:null,reason:"not installed locally and network fetching is disabled"};let s=`${ha}/${e}/custom-elements.json`,i;try{i=await fetch(s,{signal:AbortSignal.timeout(rr)})}catch(a){let l=a instanceof DOMException&&a.name==="TimeoutError"?`timed out after ${rr/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 Ln(e){let t=e.filter(r=>!r.manifest);return{skipped:t,transientFailures:t.filter(r=>r.transient)}}async function Gn(e){try{let t=await fetch(`${ya}/${e}/latest`,{signal:AbortSignal.timeout(rr)});if(!t.ok)return null;let r=await t.json();return typeof r.version=="string"?r.version:null}catch{return null}}import{Logger as va}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";function nr(e,t){if(Array.isArray(e))return e.map(r=>nr(r,t));if(e&&typeof e=="object"){let r=e,n={};for(let[o,s]of Object.entries(r))o==="module"&&typeof s=="string"&&r.package==null?n[o]=`${t}/${s}`:n[o]=nr(s,t);return n}return e}function Bn(e,t=va.warn){let r=[];for(let{pkg:o,manifest:s}of e)for(let i of s.modules??[]){let a=nr(i,o);typeof i.path=="string"&&(a.path=`${o}/${i.path}`),r.push(a)}let n=new Set(e.map(o=>o.manifest.schemaVersion).filter(Boolean));return n.size>1&&t(`Merging mixed CEM schema versions: ${[...n].join(", ")}`),{schemaVersion:e[0]?.manifest.schemaVersion??"1.0.0",modules:r}}async function Un(e,t={}){let r=await Promise.all(e.map(i=>M(i,t))),n=[];for(let i of r)i.manifest&&n.push({pkg:i.target,manifest:i.manifest});let{skipped:o,transientFailures:s}=Ln(r);return{manifest:Bn(n),sources:n,skipped:o,transientFailures:s}}async function $a(e){let t=Ta(`Fetching manifests for ${O.length} components...`).start(),{manifest:r,sources:n,skipped:o,transientFailures:s}=await Un(O,{preferLocal:!1});n.length===0&&(t.fail("No component manifests could be fetched."),nt.exit(1));let i=Ea.resolve(nt.cwd(),e.output);try{await ka(i,`${JSON.stringify(r,null,2)}
68
- `,"utf-8")}catch(a){let c=a instanceof Error?a.message:String(a);t.fail(`Failed to write ${e.output}: ${c}`),nt.exit(1)}t.succeed(`Aggregated ${n.length}/${O.length} component manifests (${r.modules?.length??0} modules) to ${e.output}`);for(let a of o)a.transient||Wn.info(`Skipped ${a.target}: ${a.reason}`);s.length>0&&(Wn.error(`${s.length} component(s) failed to fetch transiently; the aggregate may be incomplete. Re-run to retry.`),nt.exit(1))}var gf=Sa.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($a);import{readFileSync as io}from"node:fs";import{dirname as bc,join as wc,resolve as ao}from"node:path";import mt from"node:process";import{program as vc}from"commander";import kc from"ora";import{mkdtempSync as xa,rmSync as Aa}from"node:fs";import{tmpdir as Ca}from"node:os";import{join as Ra}from"node:path";function sr(e){return e.replace(/(['"`])(?:\\.|(?!\1)[\s\S])*\1/gu," ")}function ir(e){let t={")":"(","]":"[","}":"{",">":"<"},r=[],n="";for(let o of sr(e)){if(o===">"&&n==="="){n=o;continue}if(o==="("||o==="["||o==="{"||o==="<")r.push(o);else if((o===")"||o==="]"||o==="}"||o===">")&&r.pop()!==t[o])return!1;n=o}return r.length===0}function or(e){let t=e.type?.text;if(typeof t=="string"&&t!==""&&!ir(t)){let{type:r,...n}=e;return n}return e}function ar(e,t){let{fieldName:r,description:n}=e;if(typeof r!="string"||r===""||typeof n=="string"&&n!=="")return!1;if(!t.has(r))return!0;let o=t.get(r);return o==="private"||o==="protected"}function Pa(e){let t=o=>typeof o.name=="string",r=e.members?.filter(t).map(or),n=new Map((r??[]).map(o=>[o.name,o.privacy]));return{...e,...r&&{members:r},...e.attributes&&{attributes:e.attributes.filter(t).filter(o=>!ar(o,n)).map(or)},...e.slots&&{slots:e.slots.filter(t)},...e.events&&{events:e.events.filter(t).map(or)},...e.cssParts&&{cssParts:e.cssParts.filter(t)},...e.cssProperties&&{cssProperties:e.cssProperties.filter(t)}}}function cr(e,t){return t.get(e.tagName)??e.tagName}function Vn(e){return new Map(e.map(t=>[t.declaration.name,t.importPath]))}function ue(e,t){return{schemaVersion:"1.0.0",modules:e.map(r=>{let n=Pa({...r.declaration,tagName:t?cr(r,t):r.tagName});return{kind:"javascript-module",path:r.importPath,declarations:[n],exports:[{kind:"js",name:n.name,declaration:{name:n.name,module:r.importPath}}]}})}}function J(e){let t=xa(Ra(Ca(),"auro-editors-"));try{return e(t)}finally{try{Aa(t,{recursive:!0,force:!0,maxRetries:10,retryDelay:100})}catch{}}}function z(e){return e.endsWith(`
66
+ `);console.log(s),r.text="Running migrations on dependency batches...",new Promise(i=>setTimeout(i,2e3)),r.succeed("Migration process completed successfully.");break}default:console.error("Unknown action selected.")}});import{writeFile as ka}from"node:fs/promises";import Ea from"node:path";import nt from"node:process";import{Logger as Hn}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Sa}from"commander";import Ta from"ora";import{readFile as Fn}from"node:fs/promises";import re from"node:path";import ga from"node:process";var ha="https://unpkg.com",ya="https://registry.npmjs.org",rr=1e4;function ba(e){let t=e.lastIndexOf("@");return t>0?{pkg:e.slice(0,t),ref:e.slice(t+1)}:{pkg:e}}function Ln(e,t){let r=re.relative(e,t);return r===""||!r.startsWith("..")&&!re.isAbsolute(r)}async function wa(e){let t=re.join(ga.cwd(),"node_modules"),r=re.join(t,...e.split("/"));if(!Ln(t,r))return null;let n,o="custom-elements.json";try{let s=JSON.parse(await Fn(re.join(r,"package.json"),"utf-8"));typeof s.version=="string"&&(n=s.version),typeof s.customElements=="string"&&Ln(r,re.resolve(r,s.customElements))&&(o=s.customElements)}catch{return null}try{let s=JSON.parse(await Fn(re.join(r,o),"utf-8"));return{target:e,manifest:s,source:"local",version:n}}catch{return null}}async function M(e,t={}){let{preferLocal:r=!0,allowNetwork:n=!0}=t,{ref:o}=ba(e);if(r&&!o){let a=await wa(e);if(a)return{...a,target:e}}if(!n)return{target:e,manifest:null,reason:"not installed locally and network fetching is disabled"};let s=`${ha}/${e}/custom-elements.json`,i;try{i=await fetch(s,{signal:AbortSignal.timeout(rr)})}catch(a){let l=a instanceof DOMException&&a.name==="TimeoutError"?`timed out after ${rr/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 Gn(e){let t=e.filter(r=>!r.manifest);return{skipped:t,transientFailures:t.filter(r=>r.transient)}}async function Bn(e){try{let t=await fetch(`${ya}/${e}/latest`,{signal:AbortSignal.timeout(rr)});if(!t.ok)return null;let r=await t.json();return typeof r.version=="string"?r.version:null}catch{return null}}import{Logger as va}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";function nr(e,t){if(Array.isArray(e))return e.map(r=>nr(r,t));if(e&&typeof e=="object"){let r=e,n={};for(let[o,s]of Object.entries(r))o==="module"&&typeof s=="string"&&r.package==null?n[o]=`${t}/${s}`:n[o]=nr(s,t);return n}return e}function Un(e,t=va.warn){let r=[];for(let{pkg:o,manifest:s}of e)for(let i of s.modules??[]){let a=nr(i,o);typeof i.path=="string"&&(a.path=`${o}/${i.path}`),r.push(a)}let n=new Set(e.map(o=>o.manifest.schemaVersion).filter(Boolean));return n.size>1&&t(`Merging mixed CEM schema versions: ${[...n].join(", ")}`),{schemaVersion:e[0]?.manifest.schemaVersion??"1.0.0",modules:r}}async function Wn(e,t={}){let r=await Promise.all(e.map(i=>M(i,t))),n=[];for(let i of r)i.manifest&&n.push({pkg:i.target,manifest:i.manifest});let{skipped:o,transientFailures:s}=Gn(r);return{manifest:Un(n),sources:n,skipped:o,transientFailures:s}}async function $a(e){let t=Ta(`Fetching manifests for ${O.length} components...`).start(),{manifest:r,sources:n,skipped:o,transientFailures:s}=await Wn(O,{preferLocal:!1});n.length===0&&(t.fail("No component manifests could be fetched."),nt.exit(1));let i=Ea.resolve(nt.cwd(),e.output);try{await ka(i,`${JSON.stringify(r,null,2)}
67
+ `,"utf-8")}catch(a){let c=a instanceof Error?a.message:String(a);t.fail(`Failed to write ${e.output}: ${c}`),nt.exit(1)}t.succeed(`Aggregated ${n.length}/${O.length} component manifests (${r.modules?.length??0} modules) to ${e.output}`);for(let a of o)a.transient||Hn.info(`Skipped ${a.target}: ${a.reason}`);s.length>0&&(Hn.error(`${s.length} component(s) failed to fetch transiently; the aggregate may be incomplete. Re-run to retry.`),nt.exit(1))}var gf=Sa.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($a);import{readFileSync as ao}from"node:fs";import{dirname as bc,join as wc,resolve as co}from"node:path";import mt from"node:process";import{program as vc}from"commander";import kc from"ora";import{mkdtempSync as xa,rmSync as Aa}from"node:fs";import{tmpdir as Ca}from"node:os";import{join as Ra}from"node:path";function sr(e){return e.replace(/(['"`])(?:\\.|(?!\1)[\s\S])*\1/gu," ")}function ir(e){let t={")":"(","]":"[","}":"{",">":"<"},r=[],n="";for(let o of sr(e)){if(o===">"&&n==="="){n=o;continue}if(o==="("||o==="["||o==="{"||o==="<")r.push(o);else if((o===")"||o==="]"||o==="}"||o===">")&&r.pop()!==t[o])return!1;n=o}return r.length===0}function or(e){let t=e.type?.text;if(typeof t=="string"&&t!==""&&!ir(t)){let{type:r,...n}=e;return n}return e}function ar(e,t){let{fieldName:r,description:n}=e;if(typeof r!="string"||r===""||typeof n=="string"&&n!=="")return!1;if(!t.has(r))return!0;let o=t.get(r);return o==="private"||o==="protected"}function Pa(e){let t=o=>typeof o.name=="string",r=e.members?.filter(t).map(or),n=new Map((r??[]).map(o=>[o.name,o.privacy]));return{...e,...r&&{members:r},...e.attributes&&{attributes:e.attributes.filter(t).filter(o=>!ar(o,n)).map(or)},...e.slots&&{slots:e.slots.filter(t)},...e.events&&{events:e.events.filter(t).map(or)},...e.cssParts&&{cssParts:e.cssParts.filter(t)},...e.cssProperties&&{cssProperties:e.cssProperties.filter(t)}}}function cr(e,t){return t.get(e.tagName)??e.tagName}function Jn(e){return new Map(e.map(t=>[t.declaration.name,t.importPath]))}function ue(e,t){return{schemaVersion:"1.0.0",modules:e.map(r=>{let n=Pa({...r.declaration,tagName:t?cr(r,t):r.tagName});return{kind:"javascript-module",path:r.importPath,declarations:[n],exports:[{kind:"js",name:n.name,declaration:{name:n.name,module:r.importPath}}]}})}}function J(e){let t=xa(Ra(Ca(),"auro-editors-"));try{return e(t)}finally{try{Aa(t,{recursive:!0,force:!0,maxRetries:10,retryDelay:100})}catch{}}}function z(e){return e.endsWith(`
69
68
  `)?e:`${e}
70
69
  `}var Da=` /** Identifies the currently active descendant of a composite widget. */
71
70
  "aria-activedescendant"?: string;
@@ -175,11 +174,11 @@ ${i.map(c=>` - ${c.replace("@aurodesignsystem","AlaskaAirlines").replace("@alas
175
174
  "aria-valuetext"?: string;
176
175
  /** Custom data-* attributes for the element. */
177
176
  [key: \`data-\${string}\`]: string | number | boolean | null | undefined;
178
- `,Hn=/(type BaseProps(?:<[^>]*>)? = \{\n)/,Ia=` /** Defines the element's semantic role for accessibility APIs. */
177
+ `,Vn=/(type BaseProps(?:<[^>]*>)? = \{\n)/,Ia=` /** Defines the element's semantic role for accessibility APIs. */
179
178
  role?: string;
180
179
  /** The position of the element in the sequential keyboard navigation order. */
181
180
  tabindex?: number;
182
- `;function ot(e,{svelteGlobals:t}){if(!Hn.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 r=`${t?Ia:""}${Da}`;return e.replace(Hn,`$1${r}`)}function lr(e){let t=[];for(let r of e)r.source==="local"&&r.manifest&&r.version&&t.push({pkg:r.target,version:r.version,manifest:r.manifest});return t}async function Jn(e=O){let t=await Promise.all(e.map(r=>M(r,{allowNetwork:!1})));return lr(t)}function ur(e){return(e.modules??[]).flatMap(t=>t.declarations??[]).filter(t=>t.customElement&&t.tagName)}function mr(e){let t=[],r=new Map,n=new Set;for(let{pkg:s,version:i,manifest:a}of e){let c=ur(a),l=c.length>1;for(let m of c){let u=m.tagName,p=r.get(u);p?p.includes(s)||p.push(s):r.set(u,[s]),!n.has(u)&&(n.add(u),t.push({pkg:s,version:i,tagName:u,declaration:m,importPath:l?`${s}/${u}`:s,isMonorepo:l}))}}let o=[];for(let[s,i]of r)i.length>1&&o.push({tagName:s,packages:i});return{components:t,duplicates:o}}async function zn(e){let t=await Jn(e);return mr(t)}var Na=new Set(["variant","shape","size","type","appearance"]),Oa=new Set(["string","String","any"]),Ma=new Map([["array","use `unknown[]`, `T[]`, or `Array<T>`"],["function","use `Function` or an explicit call signature `(\u2026) => \u2026`"]]),_a=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>"]]),ja=new Set(["object","Object"]),Fa=[...Ma].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*:)`,"u")})),La=[..._a].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*[<:])`,"u")}));function Kn(e,t){return e===t?`\`type.text\` is \`${t}\``:`\`type.text\` (${JSON.stringify(e)}) uses \`${t}\``}var Ga=[/^[\s>*_~([-]*@?deprecated\b/iu,/[([]\s*deprecated\b/iu,/\*\*\s*deprecated\b/iu,/@deprecated\b/iu];function Zn(...e){return e.some(t=>typeof t=="string"&&Ga.some(r=>r.test(t.trim())))}function Qn(e){return e===!0||Ne(e)}function qn(e,t,r,n){!Qn(n.deprecated)&&Zn(n.description,n.summary)&&e.push({rule:"deprecated-prose-unflagged",severity:"warn",element:t,path:r,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 Yn(e,t,r,n,o){!Qn(o.deprecated)&&Zn(o.description,o.summary)&&e.push({rule:"deprecated-prose-unsupported",severity:"warn",element:t,path:n,message:`this ${r} reads as deprecated in prose, but the analyzer (v0.11.0) does not emit a \`deprecated\` field for inline \`@${r}\` tags \u2014 editors cannot surface it. Track upstream or a mapping plugin; suppress this warning if the prose is intentional.`})}function st(e,t,r,n){n.deprecated===!0&&e.push({rule:"deprecated-no-detail",severity:"warn",element:t,path:r,message:"`deprecated` is set but carries no message \u2014 editors show a strikethrough with no migration target. Prefer `@deprecated <what to use instead>`."})}function Ne(e){return typeof e=="string"&&e!==""}function me(e,t,r,n){n?.forEach((o,s)=>{typeof o.name!="string"&&e.push({rule:"name-required",severity:"error",element:t,path:`${r}[${s}].name`,message:`${r}[${s}] has no string \`name\` \u2014 community generators call \`.name.startsWith(\u2026)\` and throw mid-generation.`})})}function pr(e,t,r,n){let o=n.type?.text;typeof o=="string"&&o!==""&&!ir(o)&&e.push({rule:"type-parseable",severity:"error",element:t,path:`${r}.type.text`,message:`\`type.text\` has unbalanced delimiters: ${JSON.stringify(o)} \u2014 the generated \`.d.ts\` would not parse.`})}function dr(e,t,r,n){let o=n.type?.text;if(typeof o!="string")return;let s=o.trim();if(s==="")return;let i=sr(s);for(let{token:a,re:c,fix:l}of Fa)if(c.test(i)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${r}.type.text`,message:`${Kn(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 La)if(c.test(i)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${r}.type.text`,message:`${Kn(s,a)}, a generic that requires a type argument \u2014 write \`${l}\`. The generated \`.d.ts\` would not compile.`});return}ja.has(s)&&e.push({rule:"type-imprecise",severity:"warn",element:t,path:`${r}.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 Ba(e,t){let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n--)r++;return r%2===1}function Ua(e){let t=[],r=0,n=null,o=0;for(let s=0;s<e.length;s++){let i=e[s];n!==null?i===n&&!Ba(e,s)&&(n=null):i==='"'||i==="'"||i==="`"?n=i:i==="("||i==="["||i==="{"||i==="<"?r++:i===")"||i==="]"||i==="}"?r--:i===">"?s>0&&e[s-1]!=="="&&r--:i==="|"&&r===0&&(t.push(e.slice(o,s).trim()),o=s+1)}return t.push(e.slice(o).trim()),t.filter(s=>s!=="")}function Wa(e){return/^(['"`]).*\1$/u.test(e)}function Ha(e,t,r,n){let o=n.type?.text?.trim();if(typeof o!="string"||!o.includes("|"))return;let s=Ua(o),i=s.some(Wa),a=s.some(c=>c==="string"||c==="String");i&&a&&e.push({rule:"union-widened-by-string",severity:"warn",element:t,path:`${r}.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 Xn(e){return typeof e!="string"||e.trim()===""}function fr(e,t,r,n,o){Xn(o.description)&&Xn(o.summary)&&e.push({rule:"missing-description",severity:"warn",element:t,...n===void 0?{}:{path:n},message:`${r} has no description or summary \u2014 editors show no hover documentation for it. Add a JSDoc description.`})}function Va(e,t){let r=Ne(t.tagName)?t.tagName:"<unknown>";typeof t.name!="string"&&e.push({rule:"name-required",severity:"error",element:r,path:"name",message:"registered element has no string `name` \u2014 its generated import/export identity is undefined."}),fr(e,r,"this component",void 0,t);let n=t.members??[],o=t.attributes??[],s=t.events??[],i=t.slots??[];me(e,r,"members",n),me(e,r,"attributes",o),me(e,r,"slots",t.slots),me(e,r,"events",s),me(e,r,"cssParts",t.cssParts),me(e,r,"cssProperties",t.cssProperties),n.forEach((c,l)=>{pr(e,r,`members[${l}]`,c),dr(e,r,`members[${l}]`,c),qn(e,r,`members[${l}]`,c),st(e,r,`members[${l}]`,c)}),o.forEach((c,l)=>{pr(e,r,`attributes[${l}]`,c),dr(e,r,`attributes[${l}]`,c),Ha(e,r,`attributes[${l}]`,c),fr(e,r,"attribute",`attributes[${l}]`,c),qn(e,r,`attributes[${l}]`,c),st(e,r,`attributes[${l}]`,c)}),s.forEach((c,l)=>{pr(e,r,`events[${l}]`,c),dr(e,r,`events[${l}]`,c),fr(e,r,"event",`events[${l}]`,c),Yn(e,r,"event",`events[${l}]`,c),st(e,r,`events[${l}]`,c)}),i.forEach((c,l)=>{Yn(e,r,"slot",`slots[${l}]`,c),st(e,r,`slots[${l}]`,c)});let a=new Map(n.filter(c=>typeof c.name=="string").map(c=>[c.name,c.privacy]));o.forEach((c,l)=>{Ne(c.name)&&/[A-Z]/u.test(c.name)&&e.push({rule:"attribute-name-not-lowercase",severity:"warn",element:r,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\`).`}),Ne(c.name)&&Na.has(c.name)&&Oa.has(c.type?.text?.trim()??"")&&e.push({rule:"enumerated-union",severity:"warn",element:r,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.`}),ar(c,a)&&e.push({rule:"private-reflection",severity:"warn",element:r,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 eo(e){let t=[];Ne(e.schemaVersion)||t.push({rule:"schema-version",severity:"warn",message:"manifest has no `schemaVersion` \u2014 declare the CEM schema version it targets."});for(let r of ur(e))Va(t,r);return t}import{execFileSync as cc}from"node:child_process";import{mkdirSync as hr,writeFileSync as ut}from"node:fs";import{createRequire as lc}from"node:module";import{dirname as uc,join as pe}from"node:path";import mc from"node:process";import{generateJsxTypes as za}from"@wc-toolkit/jsx-types";var $=".vscode",ne="settings.json",to="auro.html-custom-data.json",C="html.customData",U=`./${$}/${to}`,oe=`${$}/${to}`,Ja="auro.code-snippets",it=`${$}/${Ja}`,Oe="auro-types",gr="auro-jsx.d.ts",at="auro-svelte.d.ts",se=`${Oe}/${gr}`,ie=`${Oe}/${at}`,R="include",W=Oe;function ct(e,t){let r=ue(e),n=Vn(e),o=J(s=>za(r,{outdir:s,fileName:gr,tagFormatter:i=>t.get(i)??i,componentTypePath:i=>n.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:se,contents:z(ot(o,{svelteGlobals:!1}))}}import{readFileSync as Ka}from"node:fs";import{join as qa}from"node:path";import{generateSvelteTypes as Ya}from"custom-element-svelte-integration";var ro=`declare namespace svelteHTML {
181
+ `;function ot(e,{svelteGlobals:t}){if(!Vn.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 r=`${t?Ia:""}${Da}`;return e.replace(Vn,`$1${r}`)}function lr(e){let t=[];for(let r of e)r.source==="local"&&r.manifest&&r.version&&t.push({pkg:r.target,version:r.version,manifest:r.manifest});return t}async function zn(e=O){let t=await Promise.all(e.map(r=>M(r,{allowNetwork:!1})));return lr(t)}function ur(e){return(e.modules??[]).flatMap(t=>t.declarations??[]).filter(t=>t.customElement&&t.tagName)}function mr(e){let t=[],r=new Map,n=new Set;for(let{pkg:s,version:i,manifest:a}of e){let c=ur(a),l=c.length>1;for(let m of c){let u=m.tagName,p=r.get(u);p?p.includes(s)||p.push(s):r.set(u,[s]),!n.has(u)&&(n.add(u),t.push({pkg:s,version:i,tagName:u,declaration:m,importPath:l?`${s}/${u}`:s,isMonorepo:l}))}}let o=[];for(let[s,i]of r)i.length>1&&o.push({tagName:s,packages:i});return{components:t,duplicates:o}}async function Kn(e){let t=await zn(e);return mr(t)}var Na=new Set(["variant","shape","size","type","appearance"]),Oa=new Set(["string","String","any"]),Ma=new Map([["array","use `unknown[]`, `T[]`, or `Array<T>`"],["function","use `Function` or an explicit call signature `(\u2026) => \u2026`"]]),_a=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>"]]),ja=new Set(["object","Object"]),Fa=[...Ma].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*:)`,"u")})),La=[..._a].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*[<:])`,"u")}));function qn(e,t){return e===t?`\`type.text\` is \`${t}\``:`\`type.text\` (${JSON.stringify(e)}) uses \`${t}\``}var Ga=[/^[\s>*_~([-]*@?deprecated\b/iu,/[([]\s*deprecated\b/iu,/\*\*\s*deprecated\b/iu,/@deprecated\b/iu];function Qn(...e){return e.some(t=>typeof t=="string"&&Ga.some(r=>r.test(t.trim())))}function eo(e){return e===!0||Ne(e)}function Yn(e,t,r,n){!eo(n.deprecated)&&Qn(n.description,n.summary)&&e.push({rule:"deprecated-prose-unflagged",severity:"warn",element:t,path:r,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 Xn(e,t,r,n,o){!eo(o.deprecated)&&Qn(o.description,o.summary)&&e.push({rule:"deprecated-prose-unsupported",severity:"warn",element:t,path:n,message:`this ${r} reads as deprecated in prose, but the analyzer (v0.11.0) does not emit a \`deprecated\` field for inline \`@${r}\` tags \u2014 editors cannot surface it. Track upstream or a mapping plugin; suppress this warning if the prose is intentional.`})}function st(e,t,r,n){n.deprecated===!0&&e.push({rule:"deprecated-no-detail",severity:"warn",element:t,path:r,message:"`deprecated` is set but carries no message \u2014 editors show a strikethrough with no migration target. Prefer `@deprecated <what to use instead>`."})}function Ne(e){return typeof e=="string"&&e!==""}function me(e,t,r,n){n?.forEach((o,s)=>{typeof o.name!="string"&&e.push({rule:"name-required",severity:"error",element:t,path:`${r}[${s}].name`,message:`${r}[${s}] has no string \`name\` \u2014 community generators call \`.name.startsWith(\u2026)\` and throw mid-generation.`})})}function pr(e,t,r,n){let o=n.type?.text;typeof o=="string"&&o!==""&&!ir(o)&&e.push({rule:"type-parseable",severity:"error",element:t,path:`${r}.type.text`,message:`\`type.text\` has unbalanced delimiters: ${JSON.stringify(o)} \u2014 the generated \`.d.ts\` would not parse.`})}function dr(e,t,r,n){let o=n.type?.text;if(typeof o!="string")return;let s=o.trim();if(s==="")return;let i=sr(s);for(let{token:a,re:c,fix:l}of Fa)if(c.test(i)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${r}.type.text`,message:`${qn(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 La)if(c.test(i)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${r}.type.text`,message:`${qn(s,a)}, a generic that requires a type argument \u2014 write \`${l}\`. The generated \`.d.ts\` would not compile.`});return}ja.has(s)&&e.push({rule:"type-imprecise",severity:"warn",element:t,path:`${r}.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 Ba(e,t){let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n--)r++;return r%2===1}function Ua(e){let t=[],r=0,n=null,o=0;for(let s=0;s<e.length;s++){let i=e[s];n!==null?i===n&&!Ba(e,s)&&(n=null):i==='"'||i==="'"||i==="`"?n=i:i==="("||i==="["||i==="{"||i==="<"?r++:i===")"||i==="]"||i==="}"?r--:i===">"?s>0&&e[s-1]!=="="&&r--:i==="|"&&r===0&&(t.push(e.slice(o,s).trim()),o=s+1)}return t.push(e.slice(o).trim()),t.filter(s=>s!=="")}function Wa(e){return/^(['"`]).*\1$/u.test(e)}function Ha(e,t,r,n){let o=n.type?.text?.trim();if(typeof o!="string"||!o.includes("|"))return;let s=Ua(o),i=s.some(Wa),a=s.some(c=>c==="string"||c==="String");i&&a&&e.push({rule:"union-widened-by-string",severity:"warn",element:t,path:`${r}.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 Zn(e){return typeof e!="string"||e.trim()===""}function fr(e,t,r,n,o){Zn(o.description)&&Zn(o.summary)&&e.push({rule:"missing-description",severity:"warn",element:t,...n===void 0?{}:{path:n},message:`${r} has no description or summary \u2014 editors show no hover documentation for it. Add a JSDoc description.`})}function Va(e,t){let r=Ne(t.tagName)?t.tagName:"<unknown>";typeof t.name!="string"&&e.push({rule:"name-required",severity:"error",element:r,path:"name",message:"registered element has no string `name` \u2014 its generated import/export identity is undefined."}),fr(e,r,"this component",void 0,t);let n=t.members??[],o=t.attributes??[],s=t.events??[],i=t.slots??[];me(e,r,"members",n),me(e,r,"attributes",o),me(e,r,"slots",t.slots),me(e,r,"events",s),me(e,r,"cssParts",t.cssParts),me(e,r,"cssProperties",t.cssProperties),n.forEach((c,l)=>{pr(e,r,`members[${l}]`,c),dr(e,r,`members[${l}]`,c),Yn(e,r,`members[${l}]`,c),st(e,r,`members[${l}]`,c)}),o.forEach((c,l)=>{pr(e,r,`attributes[${l}]`,c),dr(e,r,`attributes[${l}]`,c),Ha(e,r,`attributes[${l}]`,c),fr(e,r,"attribute",`attributes[${l}]`,c),Yn(e,r,`attributes[${l}]`,c),st(e,r,`attributes[${l}]`,c)}),s.forEach((c,l)=>{pr(e,r,`events[${l}]`,c),dr(e,r,`events[${l}]`,c),fr(e,r,"event",`events[${l}]`,c),Xn(e,r,"event",`events[${l}]`,c),st(e,r,`events[${l}]`,c)}),i.forEach((c,l)=>{Xn(e,r,"slot",`slots[${l}]`,c),st(e,r,`slots[${l}]`,c)});let a=new Map(n.filter(c=>typeof c.name=="string").map(c=>[c.name,c.privacy]));o.forEach((c,l)=>{Ne(c.name)&&/[A-Z]/u.test(c.name)&&e.push({rule:"attribute-name-not-lowercase",severity:"warn",element:r,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\`).`}),Ne(c.name)&&Na.has(c.name)&&Oa.has(c.type?.text?.trim()??"")&&e.push({rule:"enumerated-union",severity:"warn",element:r,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.`}),ar(c,a)&&e.push({rule:"private-reflection",severity:"warn",element:r,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 to(e){let t=[];Ne(e.schemaVersion)||t.push({rule:"schema-version",severity:"warn",message:"manifest has no `schemaVersion` \u2014 declare the CEM schema version it targets."});for(let r of ur(e))Va(t,r);return t}import{execFileSync as cc}from"node:child_process";import{mkdirSync as hr,writeFileSync as ut}from"node:fs";import{createRequire as lc}from"node:module";import{dirname as uc,join as pe}from"node:path";import mc from"node:process";import{generateJsxTypes as za}from"@wc-toolkit/jsx-types";var x=".vscode",ne="settings.json",ro="auro.html-custom-data.json",R="html.customData",U=`./${x}/${ro}`,oe=`${x}/${ro}`,Ja="auro.code-snippets",it=`${x}/${Ja}`,Oe="auro-types",gr="auro-jsx.d.ts",at="auro-svelte.d.ts",se=`${Oe}/${gr}`,ie=`${Oe}/${at}`,P="include",W=Oe;function ct(e,t){let r=ue(e),n=Jn(e),o=J(s=>za(r,{outdir:s,fileName:gr,tagFormatter:i=>t.get(i)??i,componentTypePath:i=>n.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:se,contents:z(ot(o,{svelteGlobals:!1}))}}import{readFileSync as Ka}from"node:fs";import{join as qa}from"node:path";import{generateSvelteTypes as Ya}from"custom-element-svelte-integration";var no=`declare namespace svelteHTML {
183
182
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
184
183
  interface IntrinsicElements extends CustomElements {}
185
184
  }`,Xa=`declare global {
@@ -238,14 +237,14 @@ ${i.map(c=>` - ${c.replace("@aurodesignsystem","AlaskaAirlines").replace("@alas
238
237
  `,Qa=/^([ \t]*)"on:([^"]+)"(\?:.*=> void;)$/gmu;function ec(e){return e.replace(Qa,(t,r,n,o)=>`${r}"on:${n}"${o}
239
238
  ${r}"on${n}"${o}`)}var tc=/^(\s*"[^"]+": Partial<)(\w+)Props & BaseProps & BaseEvents(>;)$/gm;function rc(e){let t=!1,r=e.replace(tc,(n,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 r}var nc=/^type (\w+)Props = \{\n([\s\S]*?)\n\};$/gm,oc=/\/\*\* /g;function sc(e,t){return e.replace(nc,(r,n,o)=>{let s=t.get(n);if(s===void 0)return r;let i=o.replace(oc,`/** \u3010${s}\u3011 `);return`type ${n}Props = {
240
239
  ${i}
241
- };`})}function ic(e,t){return new Map(e.map(r=>{let n=r.tagName,o=t.get(n)??n,s=o===n?r.declaration.name:o;return[r.declaration.name,s]}))}function ac(e){if(!e.includes(ro))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(ro,Xa)}function lt(e,t){let r=ue(e,t),n=ic(e,t),o=J(s=>(Ya(r,{outdir:s,fileName:at,hideLogs:!0,globalEvents:Za}),Ka(qa(s,at),"utf-8")));return{filename:ie,contents:z(ac(rc(ot(ec(sc(o,n)),{svelteGlobals:!0}))))}}var pc=lc(import.meta.url),dc=pc.resolve("typescript/bin/tsc"),fc=`declare namespace JSX {
240
+ };`})}function ic(e,t){return new Map(e.map(r=>{let n=r.tagName,o=t.get(n)??n,s=o===n?r.declaration.name:o;return[r.declaration.name,s]}))}function ac(e){if(!e.includes(no))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(no,Xa)}function lt(e,t){let r=ue(e,t),n=ic(e,t),o=J(s=>(Ya(r,{outdir:s,fileName:at,hideLogs:!0,globalEvents:Za}),Ka(qa(s,at),"utf-8")));return{filename:ie,contents:z(ac(rc(ot(ec(sc(o,n)),{svelteGlobals:!0}))))}}var pc=lc(import.meta.url),dc=pc.resolve("typescript/bin/tsc"),fc=`declare namespace JSX {
242
241
  type Element = unknown;
243
242
  interface CSSProperties {}
244
243
  }
245
- `;function gc(e){return`${e.replace(/[^a-zA-Z0-9]+/gu,"_")}.d.ts`}function hc(e){let t=new Map,r=/^[ \t]*import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/gmu;for(let n of e.matchAll(r)){let o=n[1].split(",").map(i=>i.trim().split(/\s+as\s+/u)[0].trim()).filter(Boolean);if(o.length===0)continue;let s=t.get(n[2])??new Set;for(let i of o)s.add(i);t.set(n[2],s)}return t}function no(e,t,r){ut(pe(e,"tsconfig.json"),JSON.stringify({compilerOptions:{noEmit:!0,skipLibCheck:!1,strict:!1,strictFunctionTypes:!0,target:"ES2020",module:"ESNext",moduleResolution:"bundler",...r&&{baseUrl:".",paths:r},lib:["ES2020","DOM"],types:[]},include:t},null,2),"utf-8")}function yc(e,t){let r=pe(e,t.filename);hr(uc(r),{recursive:!0}),ut(r,t.contents,"utf-8")}function oo(e,t,r){return J(n=>{yc(n,t),r(n);try{return cc(mc.execPath,[dc,"-p","tsconfig.json"],{cwd:n,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:
246
- ${i.trim()}`}}})}function so(e){if(e.length===0)return[];let t=new Map(e.map(n=>[n.tagName,n.tagName])),r=[];try{let n=ct(e,t),o=hc(n.contents),s=oo("JSX",n,i=>{hr(pe(i,"stubs"),{recursive:!0});let a={},c=[n.filename];for(let[l,m]of o){let u=gc(l);ut(pe(i,"stubs",u),`${[...m].map(p=>`export declare class ${p} extends HTMLElement {}`).join(`
244
+ `;function gc(e){return`${e.replace(/[^a-zA-Z0-9]+/gu,"_")}.d.ts`}function hc(e){let t=new Map,r=/^[ \t]*import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/gmu;for(let n of e.matchAll(r)){let o=n[1].split(",").map(i=>i.trim().split(/\s+as\s+/u)[0].trim()).filter(Boolean);if(o.length===0)continue;let s=t.get(n[2])??new Set;for(let i of o)s.add(i);t.set(n[2],s)}return t}function oo(e,t,r){ut(pe(e,"tsconfig.json"),JSON.stringify({compilerOptions:{noEmit:!0,skipLibCheck:!1,strict:!1,strictFunctionTypes:!0,target:"ES2020",module:"ESNext",moduleResolution:"bundler",...r&&{baseUrl:".",paths:r},lib:["ES2020","DOM"],types:[]},include:t},null,2),"utf-8")}function yc(e,t){let r=pe(e,t.filename);hr(uc(r),{recursive:!0}),ut(r,t.contents,"utf-8")}function so(e,t,r){return J(n=>{yc(n,t),r(n);try{return cc(mc.execPath,[dc,"-p","tsconfig.json"],{cwd:n,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 io(e){if(e.length===0)return[];let t=new Map(e.map(n=>[n.tagName,n.tagName])),r=[];try{let n=ct(e,t),o=hc(n.contents),s=so("JSX",n,i=>{hr(pe(i,"stubs"),{recursive:!0});let a={},c=[n.filename];for(let[l,m]of o){let u=gc(l);ut(pe(i,"stubs",u),`${[...m].map(p=>`export declare class ${p} extends HTMLElement {}`).join(`
247
246
  `)}
248
- `,"utf-8"),a[l]=[`./stubs/${u}`],c.push(`stubs/${u}`)}no(i,c,a)});s&&r.push(s)}catch(n){r.push({rule:"generation-build",severity:"error",element:"JSX",message:`JSX type generation threw for this CEM: ${n.message}`})}try{let n=lt(e,t),o=oo("Svelte",n,s=>{hr(pe(s,"stubs"),{recursive:!0}),ut(pe(s,"stubs","jsx-shim.d.ts"),fc,"utf-8"),no(s,[n.filename,"stubs/jsx-shim.d.ts"])});o&&r.push(o)}catch(n){r.push({rule:"generation-build",severity:"error",element:"Svelte",message:`Svelte type generation threw for this CEM: ${n.message}`})}return r}function Ec(e){try{let t=io(wc(bc(ao(e)),"package.json"),"utf-8"),r=JSON.parse(t);return{pkg:typeof r.name=="string"?r.name:"cem-check-subject",version:typeof r.version=="string"?r.version:"0.0.0"}}catch{return{pkg:"cem-check-subject",version:"0.0.0"}}}function Sc(e){let t=e.severity==="error"?"\u2716":"\u26A0",r=[e.element,e.path].filter(Boolean).join(" "),n=r?` ${r}`:"";return`${t} [${e.rule}]${n}: ${e.message}`}var Tc="custom-elements.json";async function $c(e=Tc,t={}){let r=t.json?null:kc(`Checking ${e} against the CEM contract...`).start(),n=h=>{r?r.fail(h):console.error(h),mt.exit(1)},o;try{o=JSON.parse(io(ao(e),"utf-8"))}catch(h){n(`Could not read or parse ${e}: ${h.message}`)}(typeof o!="object"||o===null||Array.isArray(o))&&n(`Could not read or parse ${e}: not a CEM object.`);let s=o,{pkg:i,version:a}=Ec(e),c=[{pkg:i,version:a,manifest:s}],{components:l}=mr(c),m=[...eo(s),...so(l)],u=m.filter(h=>h.severity==="error"),p=m.filter(h=>h.severity==="warn"),d=u.length>0||!!t.strict&&p.length>0;if(t.json){mt.stdout.write(`${JSON.stringify(m,null,2)}
247
+ `,"utf-8"),a[l]=[`./stubs/${u}`],c.push(`stubs/${u}`)}oo(i,c,a)});s&&r.push(s)}catch(n){r.push({rule:"generation-build",severity:"error",element:"JSX",message:`JSX type generation threw for this CEM: ${n.message}`})}try{let n=lt(e,t),o=so("Svelte",n,s=>{hr(pe(s,"stubs"),{recursive:!0}),ut(pe(s,"stubs","jsx-shim.d.ts"),fc,"utf-8"),oo(s,[n.filename,"stubs/jsx-shim.d.ts"])});o&&r.push(o)}catch(n){r.push({rule:"generation-build",severity:"error",element:"Svelte",message:`Svelte type generation threw for this CEM: ${n.message}`})}return r}function Ec(e){try{let t=ao(wc(bc(co(e)),"package.json"),"utf-8"),r=JSON.parse(t);return{pkg:typeof r.name=="string"?r.name:"cem-check-subject",version:typeof r.version=="string"?r.version:"0.0.0"}}catch{return{pkg:"cem-check-subject",version:"0.0.0"}}}function Sc(e){let t=e.severity==="error"?"\u2716":"\u26A0",r=[e.element,e.path].filter(Boolean).join(" "),n=r?` ${r}`:"";return`${t} [${e.rule}]${n}: ${e.message}`}var Tc="custom-elements.json";async function $c(e=Tc,t={}){let r=t.json?null:kc(`Checking ${e} against the CEM contract...`).start(),n=h=>{r?r.fail(h):console.error(h),mt.exit(1)},o;try{o=JSON.parse(ao(co(e),"utf-8"))}catch(h){n(`Could not read or parse ${e}: ${h.message}`)}(typeof o!="object"||o===null||Array.isArray(o))&&n(`Could not read or parse ${e}: not a CEM object.`);let s=o,{pkg:i,version:a}=Ec(e),c=[{pkg:i,version:a,manifest:s}],{components:l}=mr(c),m=[...to(s),...io(l)],u=m.filter(h=>h.severity==="error"),p=m.filter(h=>h.severity==="warn"),d=u.length>0||!!t.strict&&p.length>0;if(t.json){mt.stdout.write(`${JSON.stringify(m,null,2)}
249
248
  `),d&&mt.exit(1);return}let f=`${u.length} error${u.length===1?"":"s"}, ${p.length} warning${p.length===1?"":"s"}`;d?r?.fail(`CEM contract failed \u2014 ${f}.`):p.length>0?r?.warn(`CEM contract passed with warnings \u2014 ${f}.`):r?.succeed("CEM contract clean \u2014 no violations.");for(let h of[...u,...p])console.error(Sc(h));d&&mt.exit(1)}var ng=vc.command("cem-check [path]").description("Validate a custom-elements.json against the CEM contract (structural + parseability rules and an end-to-end generation smoke). 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($c);import Nc from"node:fs/promises";import Oc from"node:path";import{program as Mc}from"commander";import Er from"ora";var xc='# 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',Ac=`| Element Tag | Package | Description |
250
249
  |---|---|---|`,yr=[{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 br(e){return e.map(t=>`| \`<${t.tag}>\` | \`${t.pkg}\` | ${t.description.replace(/\|/gu,"\\|")} |`).join(`
251
250
  `)}var Cc=br(yr),Rc=`## Common Patterns
@@ -329,9 +328,9 @@ document.querySelector('#confirmDialog').show();
329
328
  `;function wr(e){return`${xc}${Ac}
330
329
  ${e}
331
330
 
332
- ${Rc}`}var sg=wr(Cc);function k(e){return(e??"").replace(/\s+/gu," ").trim()}import x from"chalk";var L="@aurodesignsystem/auro-formkit",vr=["@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"],Pc=new Set(vr);function K(e){return Pc.has(e)}function kr(e){return e.slice(18)}function de(e){return`${L}/${kr(e)}`}var Dc=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/u;function co(e){let t=Dc.exec(e.trim());return t?{main:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]?t[4].split("."):[]}:null}function Ic(e,t){let r=co(e),n=co(t);if(!r||!n)return null;for(let s=0;s<3;s+=1)if(r.main[s]!==n.main[s])return r.main[s]<n.main[s]?-1:1;if(r.pre.length===0&&n.pre.length===0)return 0;if(r.pre.length===0)return 1;if(n.pre.length===0)return-1;let o=Math.max(r.pre.length,n.pre.length);for(let s=0;s<o;s+=1){let i=r.pre[s],a=n.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 m=Number(i)-Number(a);if(m!==0)return m<0?-1:1}else{if(c!==l)return c?-1:1;if(i!==a)return i<a?-1:1}}return 0}async function fe(e){let t=[...e.entries()],r=await Promise.all(t.map(([o])=>Gn(o))),n=[];return t.forEach(([o,s],i)=>{let a=r[i];if(!a)return;let c=Ic(s,a);c!==null&&c<0&&n.push({pkg:o,installed:s,latest:a})}),n}var lo=" \u21E2 auro-formkit";function ge(e){if(e.length===0)return"";let t=e.filter(p=>K(p.pkg)),r=e.filter(p=>!K(p.pkg)),n=`\u26A0 ${e.length} Auro component(s) are NOT on the latest release`,o=Math.max(...e.map(p=>p.pkg.length)),s=Math.max(...e.map(p=>p.installed.length)),i=p=>K(p.pkg),a=e.map(p=>{let d=` ${x.bold(p.pkg.padEnd(o))} ${x.dim(p.installed.padStart(s))} ${x.dim("\u2192")} ${x.green.bold(p.latest)}`;return i(p)?`${d}${x.yellow(lo)}`:d}),c=[];if(r.length>0){let p=`npm install ${r.map(d=>`${d.pkg}@latest`).join(" ")}`;c.push("",x.dim(" Update to latest with:"),` ${x.cyan(p)}`)}if(t.length>0){c.push("",x.dim(" Migrate to auro-formkit (run `auro init`):"));for(let p of t)c.push(` ${x.dim(p.pkg)} ${x.dim("\u2192")} ${x.cyan(de(p.pkg))}`)}let l=[n.length+1,...e.map(p=>{let d=2+o+2+s+3+p.latest.length;return i(p)?d+lo.length:d})],m=Math.min(Math.max(...l),78),u="\u2500".repeat(m);return["",x.yellow.bold(`\u250C${u}\u2510`),x.yellow.bold(n),x.yellow.bold(`\u2514${u}\u2518`),...a,...c,""].join(`
331
+ ${Rc}`}var sg=wr(Cc);function k(e){return(e??"").replace(/\s+/gu," ").trim()}import A from"chalk";var L="@aurodesignsystem/auro-formkit",vr=["@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"],Pc=new Set(vr);function K(e){return Pc.has(e)}function kr(e){return e.slice(18)}function de(e){return`${L}/${kr(e)}`}var Dc=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/u;function lo(e){let t=Dc.exec(e.trim());return t?{main:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]?t[4].split("."):[]}:null}function Ic(e,t){let r=lo(e),n=lo(t);if(!r||!n)return null;for(let s=0;s<3;s+=1)if(r.main[s]!==n.main[s])return r.main[s]<n.main[s]?-1:1;if(r.pre.length===0&&n.pre.length===0)return 0;if(r.pre.length===0)return 1;if(n.pre.length===0)return-1;let o=Math.max(r.pre.length,n.pre.length);for(let s=0;s<o;s+=1){let i=r.pre[s],a=n.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 m=Number(i)-Number(a);if(m!==0)return m<0?-1:1}else{if(c!==l)return c?-1:1;if(i!==a)return i<a?-1:1}}return 0}async function fe(e){let t=[...e.entries()],r=await Promise.all(t.map(([o])=>Bn(o))),n=[];return t.forEach(([o,s],i)=>{let a=r[i];if(!a)return;let c=Ic(s,a);c!==null&&c<0&&n.push({pkg:o,installed:s,latest:a})}),n}var uo=" \u21E2 auro-formkit";function ge(e){if(e.length===0)return"";let t=e.filter(p=>K(p.pkg)),r=e.filter(p=>!K(p.pkg)),n=`\u26A0 ${e.length} Auro component(s) are NOT on the latest release`,o=Math.max(...e.map(p=>p.pkg.length)),s=Math.max(...e.map(p=>p.installed.length)),i=p=>K(p.pkg),a=e.map(p=>{let d=` ${A.bold(p.pkg.padEnd(o))} ${A.dim(p.installed.padStart(s))} ${A.dim("\u2192")} ${A.green.bold(p.latest)}`;return i(p)?`${d}${A.yellow(uo)}`:d}),c=[];if(r.length>0){let p=`npm install ${r.map(d=>`${d.pkg}@latest`).join(" ")}`;c.push("",A.dim(" Update to latest with:"),` ${A.cyan(p)}`)}if(t.length>0){c.push("",A.dim(" Migrate to auro-formkit (run `auro init`):"));for(let p of t)c.push(` ${A.dim(p.pkg)} ${A.dim("\u2192")} ${A.cyan(de(p.pkg))}`)}let l=[n.length+1,...e.map(p=>{let d=2+o+2+s+3+p.latest.length;return i(p)?d+uo.length:d})],m=Math.min(Math.max(...l),78),u="\u2500".repeat(m);return["",A.yellow.bold(`\u250C${u}\u2510`),A.yellow.bold(n),A.yellow.bold(`\u2514${u}\u2518`),...a,...c,""].join(`
333
332
  `)}async function _c(e){let t=new Map;for(let i of yr)t.set(i.tag,{...i});let r=await Promise.all(O.map(i=>M(i,{allowNetwork:e}))),n=new Map(lr(r).map(i=>[i.pkg,i.version])),o=0,s=0;for(let i of r){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,m=k(c.summary||c.description),u=t.get(l);t.set(l,{tag:l,pkg:i.target,description:m||u?.description||""}),m&&(s+=1)}}return{rows:br([...t.values()]),resolved:o,enriched:s,local:n}}async function jc(e){let t=Er("Checking for newer component releases...").start(),r=await fe(e);if(r.length===0){t.succeed("All installed Auro components are on the latest release.");return}t.stop(),console.error(ge(r))}async function Fc(e){let t=!e.offline,r=Er(t?"Resolving component manifests...":"Reading installed component manifests...").start(),{rows:n,resolved:o,enriched:s,local:i}=await _c(t),a=wr(n);if(t?s>0?r.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?r.succeed(`Resolved ${o} component manifest(s); none documented a description, using the built-in table.`):r.warn("No manifests available; using the built-in component table."):i.size>0?r.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.`):r.warn("No installed component manifests found; using the built-in component table."),e.output){let c=Er(`Writing context to ${e.output}...`).start();try{let l=Oc.resolve(process.cwd(),e.output);await Nc.writeFile(l,a,"utf-8"),c.succeed(`Auro context written to ${e.output}`),console.error(`
334
- Paste this file into your AI coding tool (Claude, Cursor, Copilot, etc.) to prime it on Auro components.`)}catch(l){let m=l instanceof Error?l.message:String(l);c.fail(`Failed to write context: ${m}`),process.exit(1)}}else process.stdout.write(a);t&&i.size>0&&await jc(i)}var Sg=Mc.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(Fc);import Ul from"node:fs/promises";import Wl from"node:path";import X from"node:process";import{program as Hl}from"commander";import Z from"inquirer";import _e from"ora";var P="auro.config.json";import{existsSync as uo,readFileSync as mo,statSync as Lc}from"node:fs";import pt from"node:path";import{parse as po}from"jsonc-parser";var fo=["vscode","jsx","svelte","cssSnippets"];function go(e,t){try{return Lc(pt.join(e,t)).isDirectory()}catch{return!1}}function ho(e){try{let t=mo(pt.join(e,"package.json"),"utf-8"),r=po(t,[],{allowTrailingComma:!0});return typeof r!="object"||r===null?new Set:new Set([...Object.keys(r.dependencies??{}),...Object.keys(r.devDependencies??{})])}catch{return new Set}}function Gc(e){return go(e,$)}function Bc(e){return go(e,$)}function Uc(e){let t=pt.join(e,"tsconfig.json");if(uo(t))try{let r=mo(t,"utf-8"),n=po(r,[],{allowTrailingComma:!0});if(typeof n=="object"&&n!==null&&n.compilerOptions?.jsx!==void 0)return!0}catch{}return ho(e).has("react")}function Wc(e){return ho(e).has("svelte")?!0:["js","ts","mjs","cjs"].some(t=>uo(pt.join(e,`svelte.config.${t}`)))}function yo(e){return{vscode:Gc(e),jsx:Uc(e),svelte:Wc(e),cssSnippets:Bc(e)}}import{existsSync as Sr,readFileSync as Hc}from"node:fs";import bo from"node:path";import{parse as wo}from"jsonc-parser";function dt(e,t){return bo.join(e,...t.split("/"))}function vo(e){try{return Hc(e,"utf-8")}catch{return null}}function Vc(e){let t=vo(dt(e,`${$}/${ne}`));if(t===null)return!1;let n=wo(t,[],{allowTrailingComma:!0})?.[C];return typeof n=="string"?n===U:Array.isArray(n)?n.includes(U):!1}function Jc(e){for(let t of["tsconfig.json","jsconfig.json"]){let r=vo(bo.join(e,t));if(r===null)continue;let n=wo(r,[],{allowTrailingComma:!0}),o=n?.[R];return Array.isArray(o)?o.includes(W):!(o!==void 0||"files"in(n??{}))}return!0}function Tr(e,t){let r=[];return t.vscode&&(Sr(dt(e,oe))||r.push(`${oe} is missing \u2014 VS Code markup completions will not work.`),Vc(e)||r.push(`${$}/${ne} does not register "${U}" under "${C}".`)),t.svelte&&!Sr(dt(e,ie))&&r.push(`${ie} is missing.`),t.jsx&&!Sr(dt(e,se))&&r.push(`${se} is missing.`),(t.svelte||t.jsx)&&!Jc(e)&&r.push(`${W} is not on the TypeScript program (missing from "${R}").`),{inconsistencies:r,markupDisabled:!t.vscode}}import he from"node:fs/promises";import ht from"node:path";var zc="css,scss,less";function Kc(e){return!/[,|}]/u.test(e)}function qc(e){return(e.declaration.cssParts??[]).map(t=>t.name).filter(t=>typeof t=="string"&&t!=="").filter(Kc)}function Yc(e,t){let r=`\${1|${t.join(",")}|}`;return{scope:zc,prefix:`${e}::part`,body:[`${e}::part(${r}) {`," $0","}"],description:`Style a shadow part of <${e}> (${t.join(", ")})`}}function ko(e,t){let r={};for(let n of e){let o=qc(n);if(o.length===0)continue;let s=cr(n,t);r[`Auro <${s}> ::part`]=Yc(s,o)}return Object.keys(r).length===0?null:{filename:it,contents:z(JSON.stringify(r,null,2))}}import{getVsCodeHtmlCustomData as Xc}from"custom-element-vs-code-integration";function Eo(e,t){let r=ue(e,t),n=J(o=>Xc(r,{outdir:o,htmlFileName:"auro.html-custom-data.json",hideLogs:!0}));return{filename:oe,contents:z(n)}}import{applyEdits as So,modify as To,parse as Zc,parseTree as Qc}from"jsonc-parser";var $o={tabSize:2,insertSpaces:!0};function el(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ft(e,t){if(e.trim()==="")return{data:{}};let r=[],n=Zc(e,r,{allowTrailingComma:!0});return r.length>0?{warning:`${t} is not valid JSON \u2014 leaving it untouched.`}:el(n)?{data:n}:{warning:`${t} is not a JSON object \u2014 leaving it untouched.`}}function Me(e,t,r){let n=e.trim()===""?"{}":e,o=To(n,t,r,{formattingOptions:$o});return So(n,o)}function tl(e,t){let r=Qc(e);if(!r||r.type!=="object"||r.children?.length!==1)return null;let n=r.children[0];if(n.children?.[0]?.value!==t)return null;let o=n.offset+n.length;for(;o<e.length&&e[o]===",";)o++;return e.slice(0,n.offset)+e.slice(o)}function $r(e,t){if(t.length===1){let n=tl(e,t[0]);if(n!==null)return n}let r=To(e,t,void 0,{formattingOptions:$o});return So(e,r)}function xo(e,t=U){let r=ft(e,".vscode/settings.json");if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let n=r.data[C],o;if(n===void 0)o=[t];else if(typeof n=="string"){if(n===t)return{contents:e,changed:!1};o=[n,t]}else if(Array.isArray(n)){if(n.includes(t))return{contents:e,changed:!1};o=[...n,t]}else return{contents:e,changed:!1,warning:`.vscode/settings.json "${C}" is not a string or array \u2014 leaving it untouched.`};return{contents:Me(e,[C],o),changed:!0}}function Ao(e,t=W,r="tsconfig.json"){let n=ft(e,r);if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let{data:o}=n,s=o[R];return Array.isArray(s)?s.includes(t)?{contents:e,changed:!1}:{contents:Me(e,[R],[...s,t]),changed:!0}:s!==void 0?{contents:e,changed:!1,warning:`${r} "${R}" is not an array \u2014 leaving it untouched.`}:"files"in o?{contents:Me(e,[R],[t]),changed:!0}:{contents:e,changed:!1}}function Co(e,t=U){let r=ft(e,".vscode/settings.json");if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let n=r.data[C];if(typeof n=="string")return n!==t?{contents:e,changed:!1}:{contents:$r(e,[C]),changed:!0};if(Array.isArray(n)){if(!n.includes(t))return{contents:e,changed:!1};let o=n.filter(i=>i!==t);return{contents:o.length===0?$r(e,[C]):Me(e,[C],o),changed:!0}}return{contents:e,changed:!1}}function Ro(e,t=W,r="tsconfig.json"){let n=ft(e,r);if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let o=n.data[R];if(!Array.isArray(o)||!o.includes(t))return{contents:e,changed:!1};let s=o.filter(a=>a!==t);return{contents:s.length===0?$r(e,[R]):Me(e,[R],s),changed:!0}}function Do(e,t){return ht.join(e,...t.split("/"))}async function gt(e,t){let r=Do(e,t.filename);return await he.mkdir(ht.dirname(r),{recursive:!0}),await he.writeFile(r,t.contents,"utf-8"),t.filename}async function Po(e){try{return await he.readFile(e,"utf-8")}catch(t){if(t.code==="ENOENT")return"";throw t}}async function xr(e,t,r,n){let o=[],s=[];if(n.vscode){o.push(await gt(e,Eo(t,r)));let i=`${$}/${ne}`,a=Do(e,i),c=xo(await Po(a));c.warning?s.push(`${c.warning} Add "${U}" to "${C}" in ${i} by hand.`):c.changed&&(await he.mkdir(ht.dirname(a),{recursive:!0}),await he.writeFile(a,c.contents,"utf-8"),o.push(i))}if(n.jsx&&o.push(await gt(e,ct(t,r))),n.svelte&&o.push(await gt(e,lt(t,r))),n.cssSnippets){let i=ko(t,r);i&&o.push(await gt(e,i))}if(n.jsx||n.svelte)for(let i of["tsconfig.json","jsconfig.json"]){let a=ht.join(e,i),c=await Po(a);if(c==="")continue;let l=Ao(c,W,i);l.warning?s.push(`${l.warning} Add "${W}" to "${R}" in ${i} by hand.`):l.changed&&(await he.writeFile(a,l.contents,"utf-8"),o.push(i));break}return{written:o,warnings:s}}var q="AGENTS.md",ae="CLAUDE.md";var yt="Generated by `auro init`",Io=`# Auro Design System \u2014 AI Assistant Grounding
333
+ Paste this file into your AI coding tool (Claude, Cursor, Copilot, etc.) to prime it on Auro components.`)}catch(l){let m=l instanceof Error?l.message:String(l);c.fail(`Failed to write context: ${m}`),process.exit(1)}}else process.stdout.write(a);t&&i.size>0&&await jc(i)}var Sg=Mc.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(Fc);import Ul from"node:fs/promises";import Wl from"node:path";import X from"node:process";import{program as Hl}from"commander";import Z from"inquirer";import _e from"ora";var D="auro.config.json";import{existsSync as mo,readFileSync as po,statSync as Lc}from"node:fs";import pt from"node:path";import{parse as fo}from"jsonc-parser";var go=["vscode","jsx","svelte","cssSnippets"];function ho(e,t){try{return Lc(pt.join(e,t)).isDirectory()}catch{return!1}}function yo(e){try{let t=po(pt.join(e,"package.json"),"utf-8"),r=fo(t,[],{allowTrailingComma:!0});return typeof r!="object"||r===null?new Set:new Set([...Object.keys(r.dependencies??{}),...Object.keys(r.devDependencies??{})])}catch{return new Set}}function Gc(e){return ho(e,x)}function Bc(e){return ho(e,x)}function Uc(e){let t=pt.join(e,"tsconfig.json");if(mo(t))try{let r=po(t,"utf-8"),n=fo(r,[],{allowTrailingComma:!0});if(typeof n=="object"&&n!==null&&n.compilerOptions?.jsx!==void 0)return!0}catch{}return yo(e).has("react")}function Wc(e){return yo(e).has("svelte")?!0:["js","ts","mjs","cjs"].some(t=>mo(pt.join(e,`svelte.config.${t}`)))}function bo(e){return{vscode:Gc(e),jsx:Uc(e),svelte:Wc(e),cssSnippets:Bc(e)}}import{existsSync as Sr,readFileSync as Hc}from"node:fs";import wo from"node:path";import{parse as vo}from"jsonc-parser";function dt(e,t){return wo.join(e,...t.split("/"))}function ko(e){try{return Hc(e,"utf-8")}catch{return null}}function Vc(e){let t=ko(dt(e,`${x}/${ne}`));if(t===null)return!1;let n=vo(t,[],{allowTrailingComma:!0})?.[R];return typeof n=="string"?n===U:Array.isArray(n)?n.includes(U):!1}function Jc(e){for(let t of["tsconfig.json","jsconfig.json"]){let r=ko(wo.join(e,t));if(r===null)continue;let n=vo(r,[],{allowTrailingComma:!0}),o=n?.[P];return Array.isArray(o)?o.includes(W):!(o!==void 0||"files"in(n??{}))}return!0}function Tr(e,t){let r=[];return t.vscode&&(Sr(dt(e,oe))||r.push(`${oe} is missing \u2014 VS Code markup completions will not work.`),Vc(e)||r.push(`${x}/${ne} does not register "${U}" under "${R}".`)),t.svelte&&!Sr(dt(e,ie))&&r.push(`${ie} is missing.`),t.jsx&&!Sr(dt(e,se))&&r.push(`${se} is missing.`),(t.svelte||t.jsx)&&!Jc(e)&&r.push(`${W} is not on the TypeScript program (missing from "${P}").`),{inconsistencies:r,markupDisabled:!t.vscode}}import he from"node:fs/promises";import ht from"node:path";var zc="css,scss,less";function Kc(e){return!/[,|}]/u.test(e)}function qc(e){return(e.declaration.cssParts??[]).map(t=>t.name).filter(t=>typeof t=="string"&&t!=="").filter(Kc)}function Yc(e,t){let r=`\${1|${t.join(",")}|}`;return{scope:zc,prefix:`${e}::part`,body:[`${e}::part(${r}) {`," $0","}"],description:`Style a shadow part of <${e}> (${t.join(", ")})`}}function Eo(e,t){let r={};for(let n of e){let o=qc(n);if(o.length===0)continue;let s=cr(n,t);r[`Auro <${s}> ::part`]=Yc(s,o)}return Object.keys(r).length===0?null:{filename:it,contents:z(JSON.stringify(r,null,2))}}import{getVsCodeHtmlCustomData as Xc}from"custom-element-vs-code-integration";function So(e,t){let r=ue(e,t),n=J(o=>Xc(r,{outdir:o,htmlFileName:"auro.html-custom-data.json",hideLogs:!0}));return{filename:oe,contents:z(n)}}import{applyEdits as To,modify as $o,parse as Zc,parseTree as Qc}from"jsonc-parser";var xo={tabSize:2,insertSpaces:!0};function el(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ft(e,t){if(e.trim()==="")return{data:{}};let r=[],n=Zc(e,r,{allowTrailingComma:!0});return r.length>0?{warning:`${t} is not valid JSON \u2014 leaving it untouched.`}:el(n)?{data:n}:{warning:`${t} is not a JSON object \u2014 leaving it untouched.`}}function Me(e,t,r){let n=e.trim()===""?"{}":e,o=$o(n,t,r,{formattingOptions:xo});return To(n,o)}function tl(e,t){let r=Qc(e);if(!r||r.type!=="object"||r.children?.length!==1)return null;let n=r.children[0];if(n.children?.[0]?.value!==t)return null;let o=n.offset+n.length;for(;o<e.length&&e[o]===",";)o++;return e.slice(0,n.offset)+e.slice(o)}function $r(e,t){if(t.length===1){let n=tl(e,t[0]);if(n!==null)return n}let r=$o(e,t,void 0,{formattingOptions:xo});return To(e,r)}function Ao(e,t=U){let r=ft(e,".vscode/settings.json");if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let n=r.data[R],o;if(n===void 0)o=[t];else if(typeof n=="string"){if(n===t)return{contents:e,changed:!1};o=[n,t]}else if(Array.isArray(n)){if(n.includes(t))return{contents:e,changed:!1};o=[...n,t]}else return{contents:e,changed:!1,warning:`.vscode/settings.json "${R}" is not a string or array \u2014 leaving it untouched.`};return{contents:Me(e,[R],o),changed:!0}}function Co(e,t=W,r="tsconfig.json"){let n=ft(e,r);if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let{data:o}=n,s=o[P];return Array.isArray(s)?s.includes(t)?{contents:e,changed:!1}:{contents:Me(e,[P],[...s,t]),changed:!0}:s!==void 0?{contents:e,changed:!1,warning:`${r} "${P}" is not an array \u2014 leaving it untouched.`}:"files"in o?{contents:Me(e,[P],[t]),changed:!0}:{contents:e,changed:!1}}function Ro(e,t=U){let r=ft(e,".vscode/settings.json");if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let n=r.data[R];if(typeof n=="string")return n!==t?{contents:e,changed:!1}:{contents:$r(e,[R]),changed:!0};if(Array.isArray(n)){if(!n.includes(t))return{contents:e,changed:!1};let o=n.filter(i=>i!==t);return{contents:o.length===0?$r(e,[R]):Me(e,[R],o),changed:!0}}return{contents:e,changed:!1}}function Po(e,t=W,r="tsconfig.json"){let n=ft(e,r);if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let o=n.data[P];if(!Array.isArray(o)||!o.includes(t))return{contents:e,changed:!1};let s=o.filter(a=>a!==t);return{contents:s.length===0?$r(e,[P]):Me(e,[P],s),changed:!0}}function Io(e,t){return ht.join(e,...t.split("/"))}async function gt(e,t){let r=Io(e,t.filename);return await he.mkdir(ht.dirname(r),{recursive:!0}),await he.writeFile(r,t.contents,"utf-8"),t.filename}async function Do(e){try{return await he.readFile(e,"utf-8")}catch(t){if(t.code==="ENOENT")return"";throw t}}async function xr(e,t,r,n){let o=[],s=[];if(n.vscode){o.push(await gt(e,So(t,r)));let i=`${x}/${ne}`,a=Io(e,i),c=Ao(await Do(a));c.warning?s.push(`${c.warning} Add "${U}" to "${R}" in ${i} by hand.`):c.changed&&(await he.mkdir(ht.dirname(a),{recursive:!0}),await he.writeFile(a,c.contents,"utf-8"),o.push(i))}if(n.jsx&&o.push(await gt(e,ct(t,r))),n.svelte&&o.push(await gt(e,lt(t,r))),n.cssSnippets){let i=Eo(t,r);i&&o.push(await gt(e,i))}if(n.jsx||n.svelte)for(let i of["tsconfig.json","jsconfig.json"]){let a=ht.join(e,i),c=await Do(a);if(c==="")continue;let l=Co(c,W,i);l.warning?s.push(`${l.warning} Add "${W}" to "${P}" in ${i} by hand.`):l.changed&&(await he.writeFile(a,l.contents,"utf-8"),o.push(i));break}return{written:o,warnings:s}}var q="AGENTS.md",ae="CLAUDE.md";var yt="Generated by `auro init`",No=`# Auro Design System \u2014 AI Assistant Grounding
335
334
 
336
335
  <!-- ${yt}. Do not edit by hand \u2014 re-run \`auro init\` to
337
336
  regenerate. Custom element tags are governed by \`auro.config.json\`. -->
@@ -350,9 +349,9 @@ v1) using the Lit library.
350
349
  - npm scope: \`@aurodesignsystem/\` (current), \`@alaskaairux/\` (legacy)
351
350
  - Framework-agnostic: works with React, Angular, Vue, Svelte, or plain HTML
352
351
  - Each component is a separate npm package and registers a custom element tag
353
- `,No=`| Tag | Package | Version | Import |
354
- |---|---|---|---|`,Oo="## 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",bt=`@${q}
355
- `;var Mo=`## Auro Coding Rules
352
+ `,Oo=`| Tag | Package | Version | Import |
353
+ |---|---|---|---|`,Mo="## 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",bt=`@${q}
354
+ `;var _o=`## Auro Coding Rules
356
355
 
357
356
  These rules apply to every Auro component in this project. Use the exact
358
357
  registered tags listed under **Installed Components** below: this project uses
@@ -393,35 +392,35 @@ name.
393
392
  6. **Accessibility is built in \u2014 don't override it.** Auro components ship WCAG
394
393
  2.1 AA behavior (focus management, ARIA, error messaging). Prefer the provided
395
394
  slots and attributes over custom ARIA.
396
- `;var _o="@aurodesignsystem";function Fo(e){let t=e.trim();if(t.startsWith("@"))return t;let r=t.toLowerCase();return r.startsWith("auro-")?`${_o}/${r}`:`${_o}/auro-${r}`}function rl(e){return e.replace(/-([a-z])/gu,(t,r)=>r.toUpperCase())}function jo(e){return e?typeof e=="string"?` [deprecated: ${k(e)}]`:" [deprecated]":""}function ye(e){if(e.length===0)return" (none)";let t=Math.max(...e.map(([r])=>(r??"").length));return e.map(([r,n])=>` ${(r??"").padEnd(t)} ${n??""}`.trimEnd()).join(`
397
- `)}function Lo(e,t,r={}){let{installPkg:n=e,importSpecifier:o=e}=r,s=[];s.push(`${t.tagName} (${e})`);let i=t.summary||t.description;i&&s.push(k(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 ${n}`),s.push(` import "${o}";`),s.push(...Ar(t)),s.join(`
398
- `)}function Ar(e){let t=[],r=e.attributes??[];t.push(""),t.push(`Attributes (${r.length}):`),t.push(ye(r.map(l=>{let m=l.type?.text?` {${k(l.type.text)}}`:"",u=l.default?` = ${k(l.default)}`:"";return[l.name,`${k(l.description)}${m}${u}${jo(l.deprecated)}`.trim()]})));let n=new Set(r.flatMap(l=>l.fieldName?[l.fieldName]:[l.name,rl(l.name)])),o=(e.members??[]).filter(l=>l.name&&(l.privacy===void 0||l.privacy==="public")&&!l.static&&!(l.kind==="field"&&n.has(l.name)));t.push(""),t.push(`Properties & Methods (${o.length}):`),t.push(ye(o.map(l=>{let m=l.kind==="method",u=m?`${l.name}()`:l.name,p=m?l.return?.type?.text:l.type?.text,d=p?` {${k(p)}}`:"",f=!m&&l.default?` = ${k(l.default)}`:"";return[u,`${k(l.description)}${d}${f}${jo(l.deprecated)}`.trim()]})));let s=e.slots??[];t.push(""),t.push(`Slots (${s.length}):`),t.push(ye(s.map(l=>[l.name||"(default)",k(l.description)])));let i=e.events??[];t.push(""),t.push(`Events (${i.length}):`),t.push(ye(i.map(l=>{let m=l.type?.text?` {${k(l.type.text)}}`:"";return[l.name,`${k(l.description)}${m}`.trim()]})));let a=e.cssParts??[];a.length>0&&(t.push(""),t.push(`CSS Parts (${a.length}):`),t.push(ye(a.map(l=>[l.name,k(l.description)]))));let c=e.cssProperties??[];return c.length>0&&(t.push(""),t.push(`CSS Custom Properties (${c.length}):`),t.push(ye(c.map(l=>[l.name,k(l.description)])))),t}function Go(e,t){return t.get(e.tagName)??e.tagName}function nl(e,t){let{pkg:r,importPath:n,declaration:o}=e,s=[`${t} (${r})`],i=o.summary||o.description;i&&s.push(k(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 ${r}`),s.push(` import "${n}";`),s.push(` ${o.name}.register('${t}');`),s.push(...Ar(o)),s.join(`
399
- `)}function ol(e,t=new Map){let r=e.map(i=>`| \`<${Go(i,t)}>\` | \`${i.pkg}\` | ${i.version} | \`${i.importPath}\` |`),n=e.map(i=>{let a=Go(i,t);return`### \`<${a}>\`
395
+ `;var jo="@aurodesignsystem";function Lo(e){let t=e.trim();if(t.startsWith("@"))return t;let r=t.toLowerCase();return r.startsWith("auro-")?`${jo}/${r}`:`${jo}/auro-${r}`}function rl(e){return e.replace(/-([a-z])/gu,(t,r)=>r.toUpperCase())}function Fo(e){return e?typeof e=="string"?` [deprecated: ${k(e)}]`:" [deprecated]":""}function ye(e){if(e.length===0)return" (none)";let t=Math.max(...e.map(([r])=>(r??"").length));return e.map(([r,n])=>` ${(r??"").padEnd(t)} ${n??""}`.trimEnd()).join(`
396
+ `)}function Go(e,t,r={}){let{installPkg:n=e,importSpecifier:o=e}=r,s=[];s.push(`${t.tagName} (${e})`);let i=t.summary||t.description;i&&s.push(k(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 ${n}`),s.push(` import "${o}";`),s.push(...Ar(t)),s.join(`
397
+ `)}function Ar(e){let t=[],r=e.attributes??[];t.push(""),t.push(`Attributes (${r.length}):`),t.push(ye(r.map(l=>{let m=l.type?.text?` {${k(l.type.text)}}`:"",u=l.default?` = ${k(l.default)}`:"";return[l.name,`${k(l.description)}${m}${u}${Fo(l.deprecated)}`.trim()]})));let n=new Set(r.flatMap(l=>l.fieldName?[l.fieldName]:[l.name,rl(l.name)])),o=(e.members??[]).filter(l=>l.name&&(l.privacy===void 0||l.privacy==="public")&&!l.static&&!(l.kind==="field"&&n.has(l.name)));t.push(""),t.push(`Properties & Methods (${o.length}):`),t.push(ye(o.map(l=>{let m=l.kind==="method",u=m?`${l.name}()`:l.name,p=m?l.return?.type?.text:l.type?.text,d=p?` {${k(p)}}`:"",f=!m&&l.default?` = ${k(l.default)}`:"";return[u,`${k(l.description)}${d}${f}${Fo(l.deprecated)}`.trim()]})));let s=e.slots??[];t.push(""),t.push(`Slots (${s.length}):`),t.push(ye(s.map(l=>[l.name||"(default)",k(l.description)])));let i=e.events??[];t.push(""),t.push(`Events (${i.length}):`),t.push(ye(i.map(l=>{let m=l.type?.text?` {${k(l.type.text)}}`:"";return[l.name,`${k(l.description)}${m}`.trim()]})));let a=e.cssParts??[];a.length>0&&(t.push(""),t.push(`CSS Parts (${a.length}):`),t.push(ye(a.map(l=>[l.name,k(l.description)]))));let c=e.cssProperties??[];return c.length>0&&(t.push(""),t.push(`CSS Custom Properties (${c.length}):`),t.push(ye(c.map(l=>[l.name,k(l.description)])))),t}function Bo(e,t){return t.get(e.tagName)??e.tagName}function nl(e,t){let{pkg:r,importPath:n,declaration:o}=e,s=[`${t} (${r})`],i=o.summary||o.description;i&&s.push(k(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 ${r}`),s.push(` import "${n}";`),s.push(` ${o.name}.register('${t}');`),s.push(...Ar(o)),s.join(`
398
+ `)}function ol(e,t=new Map){let r=e.map(i=>`| \`<${Bo(i,t)}>\` | \`${i.pkg}\` | ${i.version} | \`${i.importPath}\` |`),n=e.map(i=>{let a=Bo(i,t);return`### \`<${a}>\`
400
399
 
401
400
  \`\`\`
402
401
  ${nl(i,a)}
403
- \`\`\``}),o=["## Installed Components","",No,...r];n.length>0&&o.push("",n.join(`
402
+ \`\`\``}),o=["## Installed Components","",Oo,...r];n.length>0&&o.push("",n.join(`
404
403
 
405
404
  `));let s=o.join(`
406
- `);return`${[Io.trimEnd(),Mo.trimEnd(),s,Oo.trimEnd()].join(`
405
+ `);return`${[No.trimEnd(),_o.trimEnd(),s,Mo.trimEnd()].join(`
407
406
 
408
407
  `)}
409
- `}function sl(){return bt}function Bo(e,t=new Map){return[{filename:q,contents:ol(e,t)},{filename:ae,contents:sl()}]}import{appendFileSync as il,readFileSync as Ho}from"node:fs";import vt from"node:path";import{simpleGit as al}from"simple-git";var cl="# Added by auro init \u2014 keep generated grounding/IntelliSense files tracked";function Uo(e){return e.split(vt.sep).join("/")}async function wt(e,t){if(t.length===0)return[];try{return(await al({baseDir:e}).checkIgnore(t.map(Uo))).map(Uo)}catch{return[]}}function ll(e){let t=vt.posix.dirname(e);return t==="."?"":t}function ul(e){try{let t=Ho(vt.join(e,".gitignore"),"utf-8");return new Set(t.split(/\r?\n/).map(r=>r.trim()))}catch{return new Set}}function Wo(e,t,r=!0){let n=vt.join(e,".gitignore"),o="";try{o=Ho(n,"utf-8")}catch{}let s=new Set(o.split(/\r?\n/).map(c=>c.trim())),i=r?t.filter(c=>!s.has(c.trim())):t;if(i.length===0)return;let a=o===""||o.endsWith(`
408
+ `}function sl(){return bt}function Uo(e,t=new Map){return[{filename:q,contents:ol(e,t)},{filename:ae,contents:sl()}]}import{appendFileSync as il,readFileSync as Vo}from"node:fs";import vt from"node:path";import{simpleGit as al}from"simple-git";var cl="# Added by auro init \u2014 keep generated grounding/IntelliSense files tracked";function Wo(e){return e.split(vt.sep).join("/")}async function wt(e,t){if(t.length===0)return[];try{return(await al({baseDir:e}).checkIgnore(t.map(Wo))).map(Wo)}catch{return[]}}function ll(e){let t=vt.posix.dirname(e);return t==="."?"":t}function ul(e){try{let t=Vo(vt.join(e,".gitignore"),"utf-8");return new Set(t.split(/\r?\n/).map(r=>r.trim()))}catch{return new Set}}function Ho(e,t,r=!0){let n=vt.join(e,".gitignore"),o="";try{o=Vo(n,"utf-8")}catch{}let s=new Set(o.split(/\r?\n/).map(c=>c.trim())),i=r?t.filter(c=>!s.has(c.trim())):t;if(i.length===0)return;let a=o===""||o.endsWith(`
410
409
  `)?"":`
411
410
  `;try{il(n,`${a}${i.join(`
412
411
  `)}
413
- `,"utf-8")}catch{}}async function Vo(e,t){if(t.length===0)return{fixed:[],unfixable:[]};Wo(e,[cl,...t.map(o=>`!${o}`)]);let r=await wt(e,t);if(r.length>0){let o=ul(e),s=[],i=new Set;for(let a of r){let c=ll(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&&(Wo(e,s,!1),r=await wt(e,t))}let n=new Set(r);return{fixed:t.filter(o=>!n.has(o)),unfixable:[...n]}}import{readFileSync as Qo,writeFileSync as Zo}from"node:fs";import xt from"node:path";import{globSync as El}from"glob";import{readFileSync as zo,writeFileSync as ml}from"node:fs";import St from"node:path";import{globSync as pl}from"glob";import A from"typescript";var Et="auro-",Rr="**/*.{js,jsx,ts,tsx,mjs,cjs,svelte}",Pr=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**"],G=class extends Error{constructor(t){super(t),this.name="RegistryError"}};function Ko(e=""){return{version:1,init:{prefix:{default:e,overrides:{}}}}}function dl(e,t){let r=e;if(!r||typeof r!="object")throw new G(`${t}: not a JSON object.`);if(r.version!==1)throw new G(`${t}: unsupported config version ${String(r.version)} (expected ${1}). Upgrade the CLI or remove the file.`);let n=r.init?.prefix;if(!n||typeof n.default!="string"||typeof n.overrides!="object"||n.overrides===null)throw new G(`${t}: malformed init.prefix block.`);return r}function Tt(e){let t=St.join(e,P),r;try{r=zo(t,"utf-8")}catch(o){if(o.code==="ENOENT")return null;throw o}let n;try{n=JSON.parse(r)}catch{throw new G(`${P}: invalid JSON.`)}return dl(n,P)}function qo(e,t){let r=St.join(e,P);ml(r,`${JSON.stringify(t,null,2)}
414
- `,"utf-8")}function fl(e){switch(St.extname(e).toLowerCase()){case".tsx":return A.ScriptKind.TSX;case".jsx":return A.ScriptKind.JSX;case".ts":case".mts":case".cts":return A.ScriptKind.TS;default:return A.ScriptKind.JS}}function gl(e){return e&&(A.isStringLiteral(e)||A.isNoSubstitutionTemplateLiteral(e))?e.text:null}function Jo(e,t,r=fl(e)){let n=[],o=[],s=[],i;try{i=A.createSourceFile(e,t,A.ScriptTarget.ES2022,!0,r)}catch{return{matches:n,defaultRegistrations:o,warnings:[`${e}: could not be parsed; skipped.`]}}let a=c=>{if(A.isCallExpression(c)&&A.isPropertyAccessExpression(c.expression)&&c.expression.name.text==="register"){let l=c.expression.expression,m=A.isIdentifier(l)?l.text:void 0;if(c.arguments.length===0)m&&o.push(m);else{let u=gl(c.arguments[0]);u===null?s.push(`${e}: register() with a non-literal tag could not be resolved; skipped.`):n.push({className:m,tag:u})}}A.forEachChild(c,a)};return a(i),{matches:n,defaultRegistrations:o,warnings:s}}var Cr=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,hl=/\blang\s*=\s*["']?(?:ts|typescript)["']?/i;function yl(e){let t=[];Cr.lastIndex=0;let r=Cr.exec(e);for(;r!==null;){let[,n,o]=r;t.push({content:o,scriptKind:hl.test(n)?A.ScriptKind.TS:A.ScriptKind.JS}),r=Cr.exec(e)}return t}function Yo(e){let t=pl(Rr,{cwd:e,absolute:!0,nodir:!0,ignore:Pr}),r=[],n=[],o=[],s=i=>{r.push(...i.matches),n.push(...i.defaultRegistrations??[]),o.push(...i.warnings)};for(let i of t){let a;try{a=zo(i,"utf-8")}catch{o.push(`${i}: could not be read; skipped.`);continue}if(St.extname(i).toLowerCase()===".svelte")for(let{content:c,scriptKind:l}of yl(a))s(Jo(i,c,l));else s(Jo(i,a))}return{matches:r,defaultRegistrations:n,warnings:o}}function Xo(e){return e.startsWith(Et)?e.slice(Et.length):e}function bl(e,t){let r=Xo(e);return t.endsWith(r)?t.slice(0,t.length-r.length):null}function wl(e){let t=new Map;for(let o of e)!o||o===Et||t.set(o,(t.get(o)??0)+1);if(t.size===0)return{mixed:!1};let r,n=-1;for(let[o,s]of t)s>n&&(n=s,r=o);return{suggestion:r,mixed:t.size>1}}function vl(e,t,r=[]){let n=new Map;for(let a of e)n.set(a.declaration.name,a.tagName);let o=new Map,s=[];for(let a of t){let c=a.className?n.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 r){let c=n.get(a);c&&i.set(c,a)}return{overrides:o,defaultRegistered:i,warnings:s}}function kl(e,t){return!e||e===Et?t:e+Xo(t)}function $t(e,t={}){let{config:r,scan:n,prefix:o}=t,s=r?.init.prefix.overrides??{},i=vl(e,n?.matches??[],n?.defaultRegistrations??[]),a=r?.init.prefix.default,c=o??a,l=new Map,m={...s},u=[],p=[...n?.warnings??[],...i.warnings],d=[],f=[];for(let T of e){let y=T.tagName,D=s[y];if(D!==void 0){l.set(y,D);continue}let It=i.overrides.get(y);if(It!==void 0){l.set(y,It),m[y]=It;continue}if(c===void 0){u.push(y);continue}let we=kl(c,y);l.set(y,we),we===y?f.push(`${y}: no custom prefix \u2014 grounding it under its bare 'auro-*' tag. Pass a prefix to avoid registration collisions.`):i.defaultRegistered.has(y)||d.push(`${y}: grounded as '<${we}>' from the '${c}' prefix, but no register('${we}') was found in your source. If ${T.declaration.name} is registered under a different tag (e.g. the default '<${y}>' from a side-effect import), IntelliSense will not match your markup \u2014 call ${T.declaration.name}.register('${we}') so your app matches the generated tags.`)}for(let[T,y]of i.defaultRegistered){let D=l.get(T);D!==void 0&&D!==T&&d.push(`${y}.register() uses the default '<${T}>' tag, but this project grounds it as '<${D}>'. Update the register() call to '${D}' so your app matches AGENTS.md.`)}let h=[...Object.entries(s),...i.overrides].map(([T,y])=>bl(T,y)),{suggestion:g,mixed:b}=wl(h),S=u.length>0&&c===void 0;return{resolvedTags:l,config:{version:1,init:{prefix:{default:c??g??"",overrides:m}}},needingDefault:u,needsDefaultPrefix:S,suggestedDefault:g,mixedPrefixes:b,warnings:p,reconciliationWarnings:d,noPrefixWarnings:f}}var Dr="package.json";function Sl(e){let t=e.match(/\n([ \t]+)\S/u);return t?t[1]:2}function es(e){let t;try{t=Qo(xt.join(e,Dr),"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw r}try{return{pkgJson:JSON.parse(t),indent:Sl(t)}}catch{throw new Error(`${Dr}: invalid JSON.`)}}function ts(e){let t=es(e);if(!t)return[];let{pkgJson:r}=t,n=[],o=["dependencies","devDependencies"];for(let s of vr)for(let i of o){let a=r[i]?.[s];if(typeof a=="string"){n.push({pkg:s,version:a,field:i});break}}return n}function Tl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $l(e){return e.split(xt.sep).join("/")}function xl(e,t){let r=e,n=0,o=[];for(let s of t){let i=Tl(s),a=new RegExp(`(['"\`])${i}\\1`,"g");r=r.replace(a,(m,u)=>(n+=1,`${u}${de(s)}${u}`));let c=new RegExp(`(['"\`])(${i}/[^'"\`]*)\\1`,"g"),l=c.exec(r);for(;l!==null;)o.push(l[2]),l=c.exec(r)}return{next:r,rewrites:n,deep:o}}function rs(e,t){let r=[...new Set(t.map(i=>i.pkg).filter(K))],n={packagesMigrated:[],formkit:"present",filesChanged:[],rewriteCount:0,deepImports:[]};if(r.length===0)return n;let o=es(e);if(o){let{pkgJson:i,indent:a}=o;for(let l of["dependencies","devDependencies"]){let m=i[l];if(m)for(let u of r)u in m&&(delete m[u],n.packagesMigrated.includes(u)||n.packagesMigrated.push(u))}!!i.dependencies?.[L]||!!i.devDependencies?.[L]?n.formkit="present":(i.dependencies??={},i.dependencies[L]="latest",n.formkit="added"),Zo(xt.join(e,Dr),`${JSON.stringify(i,null,a)}
415
- `,"utf-8")}let s=El(Rr,{cwd:e,absolute:!0,nodir:!0,ignore:Pr});for(let i of s){let a;try{a=Qo(i,"utf-8")}catch{continue}let{next:c,rewrites:l,deep:m}=xl(a,r),u=$l(xt.relative(e,i));for(let p of m)n.deepImports.push({file:u,specifier:p});l>0&&c!==a&&(Zo(i,c,"utf-8"),n.filesChanged.push(u),n.rewriteCount+=l)}return n}import{existsSync as ns,readdirSync as Al,readFileSync as Cl,rmdirSync as Rl,rmSync as Pl,writeFileSync as Dl}from"node:fs";import Il from"node:path";import{parse as Nl}from"jsonc-parser";function Y(e,t){return Il.join(e,...t.split("/"))}function Ol(e){let t=Nl(e,[],{allowTrailingComma:!0});return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length===0}function Ml(e){return e.includes("//")||e.includes("/*")}function Ir(e){try{return Cl(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}var _l=[oe,it,se,ie];function jl(e,t){return e===null?null:t==="agents"?e.includes(yt)?"remove":`not recognized as an \`auro init\` file (missing the "${yt}" marker)`:e.trim()===bt.trim()?"remove":"contains content beyond the generated `@AGENTS.md` import"}function os(e){let t=[],r=[],n=[];for(let[a,c]of[[q,"agents"],[ae,"claude"]]){let l=jl(Ir(Y(e,a)),c);l==="remove"?t.push(a):l!==null&&r.push({path:a,reason:l})}if(ns(Y(e,P)))try{Tt(e)&&t.push(P)}catch(a){let c=a instanceof G?a.message:String(a);r.push({path:P,reason:c})}for(let a of _l)ns(Y(e,a))&&t.push(a);let o=[],s=`${$}/${ne}`,i=Ir(Y(e,s));if(i!==null){let a=Co(i);a.warning?n.push(a.warning):a.changed&&(Ol(a.contents)&&!Ml(a.contents)?t.push(s):o.push({path:s,result:a}))}for(let a of["tsconfig.json","jsconfig.json"]){let c=Ir(Y(e,a));if(c===null)continue;let l=Ro(c,void 0,a);l.warning?n.push(l.warning):l.changed&&o.push({path:a,result:l});break}return{filesToRemove:t,filesToSkip:r,unmerges:o,warnings:n,dirsToPrune:[Oe,$]}}function Fl(e){try{return Al(e).length===0}catch{return!1}}function ss(e,t){let r=[];for(let s of t.filesToRemove)Pl(Y(e,s),{force:!0}),r.push(s);let n=[];for(let{path:s,result:i}of t.unmerges)Dl(Y(e,s),i.contents,"utf-8"),n.push(s);let o=[];for(let s of t.dirsToPrune){let i=Y(e,s);Fl(i)&&(Rl(i),o.push(s))}return{removed:r,unmerged:n,prunedDirs:o,skipped:t.filesToSkip,warnings:t.warnings}}import is from"chalk";var Ll=78,as=74,cs=" \u2022 ",Gl=" ";function Bl(e,t){let r=e.split(/\s+/u).filter(Boolean);if(r.length===0)return[""];let n=[],o=r[0];for(let s of r.slice(1))o.length+1+s.length<=t?o+=` ${s}`:(n.push(o),o=s);return n.push(o),n}function ce(e,t,r="red"){if(t.length===0)return"";let n=is[r].bold,o=[];t.forEach((c,l)=>{Bl(c,as-cs.length).forEach((u,p)=>{let d=p===0?cs:Gl;o.push(is[r](d+u))}),l<t.length-1&&o.push("")});let s=e.length+(e.includes("\u26A0")?1:0),i=Math.min(Math.max(s,as),Ll),a="\u2500".repeat(i);return["",n(`\u250C${a}\u2510`),n(e),n(`\u2514${a}\u2518`),...o,""].join(`
416
- `)}function be(e){return!X.stdin.isTTY||!!X.env.CI||!!e.nonInteractive||!!e.yes}async function Vl(e){if(e.suggestedDefault){let{accept:r}=await Z.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(r)return e.suggestedDefault}let{prefix:t}=await Z.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 Jl(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 zl(e,t){let{customize:r}=await Z.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(!r)return{};let n={};for(let o of e){let s=o.tagName,i=t.get(s)??s,{tag:a}=await Z.prompt([{type:"input",name:"tag",message:`Tag for ${o.declaration.name} (<${s}>):`,default:i,validate:Jl}]),c=String(a).trim();c!==i&&(n[s]=c)}return n}function Kl(e,t){let r=e??Ko();return{...r,init:{...r.init,prefix:{default:r.init.prefix.default,overrides:{...r.init.prefix.overrides,...t}}}}}var ql={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 Yl(e,t,r){let n=r?.init.editors,o=yo(e),s=!be(t),i={vscode:!1,jsx:!1,svelte:!1,cssSnippets:!1},a=[];for(let c of fo){let l=t[c];if(l!==void 0){i[c]=l;continue}let m=n?.[c];if(m!==void 0){i[c]=m;continue}if(s){let{label:u,artifact:p}=ql[c];a.push({type:"confirm",name:c,message:`Generate ${u} (${p})?`,default:o[c]})}else i[c]=o[c]}if(a.length>0){let c=await Z.prompt(a);for(let{name:l}of a)i[l]=!!c[l]}return i}async function Xl(e,t){let r;try{r=ts(e)}catch(a){let c=a instanceof Error?a.message:String(a);return console.error(`\u26A0 Skipping formkit migration check: ${c}`),!1}if(r.length===0)return!1;let n=r.map(a=>a.pkg).join(", ");if(be(t))return console.error(`\u26A0 ${r.length} legacy standalone package(s) can be migrated to @aurodesignsystem/auro-formkit: ${n}. Run \`auro init\` interactively to apply the migration.`),!1;let{migrate:o}=await Z.prompt([{type:"confirm",name:"migrate",message:`${r.length} legacy standalone package(s) now live in auro-formkit (${n}). Migrate to auro-formkit now? This edits package.json and rewrites import specifiers.`,default:!1}]);if(!o)return!1;let s=_e("Migrating to auro-formkit...").start(),i=rs(e,r);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 Zl(e){let t=new Map(e.map(o=>[o.pkg,o.version])),r=_e("Checking for newer component releases...").start(),n=await fe(t);if(n.length===0){r.succeed("All installed Auro components are on the latest release.");return}r.stop(),console.error(ge(n))}async function Ql(e){let t=X.cwd();if(e.reset){await ru(t,e);return}let r=_e("Detecting installed Auro components...").start(),{components:n,duplicates:o}=await zn();if(n.length===0){r.warn("No installed Auro components found; nothing to ground. Install an Auro component package and re-run `auro init`.");return}if(r.succeed(`Detected ${n.length} installed component(s) to ground.`),await Xl(t,e))return;let s;try{s=Tt(t)}catch(g){let b=g instanceof G||g instanceof Error?g.message:String(g);console.error(`Cannot read ${P}: ${b}`),X.exit(1)}let i=Yo(t),a=$t(n,{config:s,scan:i,prefix:e.prefix}),l=!(e.prefix!==void 0||s?.init.prefix.default!==void 0)&&(a.needsDefaultPrefix||a.mixedPrefixes),m=e.prefix;if(l){if(be(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-).`),X.exit(1)}m=await Vl(a),a=$t(n,{config:s,scan:i,prefix:m})}if(a.needsDefaultPrefix&&(console.error("Unable to resolve a default prefix for every component. Re-run with --prefix <prefix>."),X.exit(1)),!be(e)){let g=await zl(n,a.resolvedTags);Object.keys(g).length>0&&(a=$t(n,{config:Kl(s,g),scan:i,prefix:m}))}let u=await Yl(t,e,s);a.config.init.editors=u;let p=_e("Writing generated files...").start(),d={written:[],warnings:[]};try{for(let b of Bo(n,a.resolvedTags))await Ul.writeFile(Wl.join(t,b.filename),b.contents,"utf-8");d=await xr(t,n,a.resolvedTags,u),qo(t,a.config);let g=d.written.length>0?` Editor IntelliSense: ${d.written.join(", ")}.`:"";p.succeed(`Wrote ${q}, ${ae}, and ${P} for ${n.length} component(s).${g}`)}catch(g){let b=g instanceof Error?g.message:String(g);p.fail(`Failed to write generated files: ${b}`),X.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(ce(`\u26A0 ${a.reconciliationWarnings.length} component tag(s) may not match your app's registered tags`,a.reconciliationWarnings,"red")),a.noPrefixWarnings.length>0&&console.error(ce(`\u26A0 ${a.noPrefixWarnings.length} component(s) grounded under bare 'auro-*' tags \u2014 pass a prefix to avoid collisions`,a.noPrefixWarnings,"yellow"));let f=Tr(t,u);if(f.inconsistencies.length>0)try{let g=await xr(t,n,a.resolvedTags,u),b=new Set(d.warnings);for(let S of g.warnings)b.has(S)||console.error(`\u26A0 ${S}`);f=Tr(t,u)}catch(g){let b=g instanceof Error?g.message:String(g);console.error(`\u26A0 Could not re-write editor artifacts to self-heal wiring: ${b}`)}f.inconsistencies.length>0&&console.error(ce("\u26A0 Editor IntelliSense wiring is incomplete after writing",f.inconsistencies,"red")),f.markupDisabled&&console.error(ce("\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,ae,P,...d.written])];await eu(t,h,e),e.offline||await Zl(n)}async function eu(e,t,r){let n=await wt(e,t);if(n.length===0)return;if(console.error(ce(`\u26A0 ${n.length} file(s) auro init wrote are git-ignored and won't be committed`,[...n,"These are meant to be committed so your team and CI share the same grounding/IntelliSense."],"red")),be(r)&&!r.yes){console.error("\u26A0 Un-ignore them in .gitignore (or re-run with --yes) so they get committed.");return}if(!r.yes){let{fix:i}=await Z.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 Vo(e,n);o.length>0&&console.error(`\u2714 Un-ignored ${o.length} file(s) in .gitignore so they will be committed.`),s.length>0&&console.error(ce(`\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 tu(e){return e.filesToRemove.length===0&&e.unmerges.length===0}async function ru(e,t){let r=os(e);if(tu(r)){console.log("Nothing to reset \u2014 no `auro init` output found.");for(let c of r.filesToSkip)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);return}console.log("`auro init --reset` will:");for(let c of r.filesToRemove)console.log(` \u2022 remove ${c}`);for(let c of r.unmerges)console.log(` \u2022 remove the Auro entry from ${c.path}`);for(let c of r.dirsToPrune)console.log(` \u2022 remove ${c}/ if it is left empty`);for(let c of r.filesToSkip)console.log(` \u2022 keep ${c.path} (${c.reason})`);if(!be(t)){let{confirm:c}=await Z.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 n=_e("Removing `auro init` output...").start(),o;try{o=ss(e,r)}catch(c){let l=c instanceof Error?c.message:String(c);n.fail(`Failed to reset: ${l}`),X.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(", ")}`:"";n.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 ry=Hl.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(Ql);import At from"node:process";import{Logger as nu}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as ou}from"commander";import ls from"ora";async function su(e,t){let r=n=>({headerPkg:e,installPkg:e,importSpecifier:e,redirectedToFormkit:!1,result:n});if(t.tag)return r(await M(`${e}@${t.tag}`));if(K(e)){let n=await M(e,{allowNetwork:!1});return n.manifest?r(n):{headerPkg:L,installPkg:L,importSpecifier:de(e),tagFilter:kr(e),redirectedToFormkit:!0,result:await M(L)}}return r(await M(e))}async function iu(e,t){let r=Fo(e),n=ls(`Fetching ${r}...`).start(),o=await su(r,t),{result:s}=o,i=s.target;s.manifest||(n.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.`),At.exit(1));let c=(s.manifest.modules??[]).flatMap(u=>u.declarations??[]).filter(u=>u.customElement&&u.tagName).filter(u=>!o.tagFilter||u.tagName===o.tagFilter);c.length===0&&(n.fail(o.tagFilter?`No <${o.tagFilter}> element found in ${i}.`:`No registered custom elements found for ${i}.`),At.exit(1));let l=s.source==="local"?` (local${s.version?` v${s.version}`:""})`:" (unpkg)";n.succeed(`${i} \u2014 ${c.length} custom element${c.length===1?"":"s"}${l}`),o.redirectedToFormkit&&console.error(`\u2139 ${o.tagFilter} now ships in ${L} \u2014 showing the monorepo version (the legacy standalone isn't installed).`);let m=null;if(s.source==="local"&&s.version){let u=ls("Checking for a newer release...").start(),p=await fe(new Map([[o.headerPkg,s.version]]));u.stop(),p.length>0&&(m=ge(p))}if(t.json){At.stdout.write(`${JSON.stringify(c,null,2)}
412
+ `,"utf-8")}catch{}}async function Jo(e,t){if(t.length===0)return{fixed:[],unfixable:[]};Ho(e,[cl,...t.map(o=>`!${o}`)]);let r=await wt(e,t);if(r.length>0){let o=ul(e),s=[],i=new Set;for(let a of r){let c=ll(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&&(Ho(e,s,!1),r=await wt(e,t))}let n=new Set(r);return{fixed:t.filter(o=>!n.has(o)),unfixable:[...n]}}import{readFileSync as es,writeFileSync as Qo}from"node:fs";import xt from"node:path";import{globSync as El}from"glob";import{readFileSync as Ko,writeFileSync as ml}from"node:fs";import St from"node:path";import{globSync as pl}from"glob";import C from"typescript";var Et="auro-",Rr="**/*.{js,jsx,ts,tsx,mjs,cjs,svelte}",Pr=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**"],G=class extends Error{constructor(t){super(t),this.name="RegistryError"}};function qo(e=""){return{version:1,init:{prefix:{default:e,overrides:{}}}}}function dl(e,t){let r=e;if(!r||typeof r!="object")throw new G(`${t}: not a JSON object.`);if(r.version!==1)throw new G(`${t}: unsupported config version ${String(r.version)} (expected ${1}). Upgrade the CLI or remove the file.`);let n=r.init?.prefix;if(!n||typeof n.default!="string"||typeof n.overrides!="object"||n.overrides===null)throw new G(`${t}: malformed init.prefix block.`);return r}function Tt(e){let t=St.join(e,D),r;try{r=Ko(t,"utf-8")}catch(o){if(o.code==="ENOENT")return null;throw o}let n;try{n=JSON.parse(r)}catch{throw new G(`${D}: invalid JSON.`)}return dl(n,D)}function Yo(e,t){let r=St.join(e,D);ml(r,`${JSON.stringify(t,null,2)}
413
+ `,"utf-8")}function fl(e){switch(St.extname(e).toLowerCase()){case".tsx":return C.ScriptKind.TSX;case".jsx":return C.ScriptKind.JSX;case".ts":case".mts":case".cts":return C.ScriptKind.TS;default:return C.ScriptKind.JS}}function gl(e){return e&&(C.isStringLiteral(e)||C.isNoSubstitutionTemplateLiteral(e))?e.text:null}function zo(e,t,r=fl(e)){let n=[],o=[],s=[],i;try{i=C.createSourceFile(e,t,C.ScriptTarget.ES2022,!0,r)}catch{return{matches:n,defaultRegistrations:o,warnings:[`${e}: could not be parsed; skipped.`]}}let a=c=>{if(C.isCallExpression(c)&&C.isPropertyAccessExpression(c.expression)&&c.expression.name.text==="register"){let l=c.expression.expression,m=C.isIdentifier(l)?l.text:void 0;if(c.arguments.length===0)m&&o.push(m);else{let u=gl(c.arguments[0]);u===null?s.push(`${e}: register() with a non-literal tag could not be resolved; skipped.`):n.push({className:m,tag:u})}}C.forEachChild(c,a)};return a(i),{matches:n,defaultRegistrations:o,warnings:s}}var Cr=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,hl=/\blang\s*=\s*["']?(?:ts|typescript)["']?/i;function yl(e){let t=[];Cr.lastIndex=0;let r=Cr.exec(e);for(;r!==null;){let[,n,o]=r;t.push({content:o,scriptKind:hl.test(n)?C.ScriptKind.TS:C.ScriptKind.JS}),r=Cr.exec(e)}return t}function Xo(e){let t=pl(Rr,{cwd:e,absolute:!0,nodir:!0,ignore:Pr}),r=[],n=[],o=[],s=i=>{r.push(...i.matches),n.push(...i.defaultRegistrations??[]),o.push(...i.warnings)};for(let i of t){let a;try{a=Ko(i,"utf-8")}catch{o.push(`${i}: could not be read; skipped.`);continue}if(St.extname(i).toLowerCase()===".svelte")for(let{content:c,scriptKind:l}of yl(a))s(zo(i,c,l));else s(zo(i,a))}return{matches:r,defaultRegistrations:n,warnings:o}}function Zo(e){return e.startsWith(Et)?e.slice(Et.length):e}function bl(e,t){let r=Zo(e);return t.endsWith(r)?t.slice(0,t.length-r.length):null}function wl(e){let t=new Map;for(let o of e)!o||o===Et||t.set(o,(t.get(o)??0)+1);if(t.size===0)return{mixed:!1};let r,n=-1;for(let[o,s]of t)s>n&&(n=s,r=o);return{suggestion:r,mixed:t.size>1}}function vl(e,t,r=[]){let n=new Map;for(let a of e)n.set(a.declaration.name,a.tagName);let o=new Map,s=[];for(let a of t){let c=a.className?n.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 r){let c=n.get(a);c&&i.set(c,a)}return{overrides:o,defaultRegistered:i,warnings:s}}function kl(e,t){return!e||e===Et?t:e+Zo(t)}function $t(e,t={}){let{config:r,scan:n,prefix:o}=t,s=r?.init.prefix.overrides??{},i=vl(e,n?.matches??[],n?.defaultRegistrations??[]),a=r?.init.prefix.default,c=o??a,l=new Map,m={...s},u=[],p=[...n?.warnings??[],...i.warnings],d=[],f=[];for(let T of e){let y=T.tagName,$=s[y];if($!==void 0){l.set(y,$);continue}let It=i.overrides.get(y);if(It!==void 0){l.set(y,It),m[y]=It;continue}if(c===void 0){u.push(y);continue}let we=kl(c,y);l.set(y,we),we===y?f.push(`${y}: no custom prefix \u2014 grounding it under its bare 'auro-*' tag. Pass a prefix to avoid registration collisions.`):i.defaultRegistered.has(y)||d.push(`${y}: grounded as '<${we}>' from the '${c}' prefix, but no register('${we}') was found in your source. If ${T.declaration.name} is registered under a different tag (e.g. the default '<${y}>' from a side-effect import), IntelliSense will not match your markup \u2014 call ${T.declaration.name}.register('${we}') so your app matches the generated tags.`)}for(let[T,y]of i.defaultRegistered){let $=l.get(T);$!==void 0&&$!==T&&d.push(`${y}.register() uses the default '<${T}>' tag, but this project grounds it as '<${$}>'. Update the register() call to '${$}' so your app matches AGENTS.md.`)}let h=[...Object.entries(s),...i.overrides].map(([T,y])=>bl(T,y)),{suggestion:g,mixed:b}=wl(h),S=u.length>0&&c===void 0;return{resolvedTags:l,config:{version:1,init:{prefix:{default:c??g??"",overrides:m}}},needingDefault:u,needsDefaultPrefix:S,suggestedDefault:g,mixedPrefixes:b,warnings:p,reconciliationWarnings:d,noPrefixWarnings:f}}var Dr="package.json";function Sl(e){let t=e.match(/\n([ \t]+)\S/u);return t?t[1]:2}function ts(e){let t;try{t=es(xt.join(e,Dr),"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw r}try{return{pkgJson:JSON.parse(t),indent:Sl(t)}}catch{throw new Error(`${Dr}: invalid JSON.`)}}function rs(e){let t=ts(e);if(!t)return[];let{pkgJson:r}=t,n=[],o=["dependencies","devDependencies"];for(let s of vr)for(let i of o){let a=r[i]?.[s];if(typeof a=="string"){n.push({pkg:s,version:a,field:i});break}}return n}function Tl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $l(e){return e.split(xt.sep).join("/")}function xl(e,t){let r=e,n=0,o=[];for(let s of t){let i=Tl(s),a=new RegExp(`(['"\`])${i}\\1`,"g");r=r.replace(a,(m,u)=>(n+=1,`${u}${de(s)}${u}`));let c=new RegExp(`(['"\`])(${i}/[^'"\`]*)\\1`,"g"),l=c.exec(r);for(;l!==null;)o.push(l[2]),l=c.exec(r)}return{next:r,rewrites:n,deep:o}}function ns(e,t){let r=[...new Set(t.map(i=>i.pkg).filter(K))],n={packagesMigrated:[],formkit:"present",filesChanged:[],rewriteCount:0,deepImports:[]};if(r.length===0)return n;let o=ts(e);if(o){let{pkgJson:i,indent:a}=o;for(let l of["dependencies","devDependencies"]){let m=i[l];if(m)for(let u of r)u in m&&(delete m[u],n.packagesMigrated.includes(u)||n.packagesMigrated.push(u))}!!i.dependencies?.[L]||!!i.devDependencies?.[L]?n.formkit="present":(i.dependencies??={},i.dependencies[L]="latest",n.formkit="added"),Qo(xt.join(e,Dr),`${JSON.stringify(i,null,a)}
414
+ `,"utf-8")}let s=El(Rr,{cwd:e,absolute:!0,nodir:!0,ignore:Pr});for(let i of s){let a;try{a=es(i,"utf-8")}catch{continue}let{next:c,rewrites:l,deep:m}=xl(a,r),u=$l(xt.relative(e,i));for(let p of m)n.deepImports.push({file:u,specifier:p});l>0&&c!==a&&(Qo(i,c,"utf-8"),n.filesChanged.push(u),n.rewriteCount+=l)}return n}import{existsSync as os,readdirSync as Al,readFileSync as Cl,rmdirSync as Rl,rmSync as Pl,writeFileSync as Dl}from"node:fs";import Il from"node:path";import{parse as Nl}from"jsonc-parser";function Y(e,t){return Il.join(e,...t.split("/"))}function Ol(e){let t=Nl(e,[],{allowTrailingComma:!0});return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length===0}function Ml(e){return e.includes("//")||e.includes("/*")}function Ir(e){try{return Cl(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}var _l=[oe,it,se,ie];function jl(e,t){return e===null?null:t==="agents"?e.includes(yt)?"remove":`not recognized as an \`auro init\` file (missing the "${yt}" marker)`:e.trim()===bt.trim()?"remove":"contains content beyond the generated `@AGENTS.md` import"}function ss(e){let t=[],r=[],n=[];for(let[a,c]of[[q,"agents"],[ae,"claude"]]){let l=jl(Ir(Y(e,a)),c);l==="remove"?t.push(a):l!==null&&r.push({path:a,reason:l})}if(os(Y(e,D)))try{Tt(e)&&t.push(D)}catch(a){let c=a instanceof G?a.message:String(a);r.push({path:D,reason:c})}for(let a of _l)os(Y(e,a))&&t.push(a);let o=[],s=`${x}/${ne}`,i=Ir(Y(e,s));if(i!==null){let a=Ro(i);a.warning?n.push(a.warning):a.changed&&(Ol(a.contents)&&!Ml(a.contents)?t.push(s):o.push({path:s,result:a}))}for(let a of["tsconfig.json","jsconfig.json"]){let c=Ir(Y(e,a));if(c===null)continue;let l=Po(c,void 0,a);l.warning?n.push(l.warning):l.changed&&o.push({path:a,result:l});break}return{filesToRemove:t,filesToSkip:r,unmerges:o,warnings:n,dirsToPrune:[Oe,x]}}function Fl(e){try{return Al(e).length===0}catch{return!1}}function is(e,t){let r=[];for(let s of t.filesToRemove)Pl(Y(e,s),{force:!0}),r.push(s);let n=[];for(let{path:s,result:i}of t.unmerges)Dl(Y(e,s),i.contents,"utf-8"),n.push(s);let o=[];for(let s of t.dirsToPrune){let i=Y(e,s);Fl(i)&&(Rl(i),o.push(s))}return{removed:r,unmerged:n,prunedDirs:o,skipped:t.filesToSkip,warnings:t.warnings}}import as from"chalk";var Ll=78,cs=74,ls=" \u2022 ",Gl=" ";function Bl(e,t){let r=e.split(/\s+/u).filter(Boolean);if(r.length===0)return[""];let n=[],o=r[0];for(let s of r.slice(1))o.length+1+s.length<=t?o+=` ${s}`:(n.push(o),o=s);return n.push(o),n}function ce(e,t,r="red"){if(t.length===0)return"";let n=as[r].bold,o=[];t.forEach((c,l)=>{Bl(c,cs-ls.length).forEach((u,p)=>{let d=p===0?ls:Gl;o.push(as[r](d+u))}),l<t.length-1&&o.push("")});let s=e.length+(e.includes("\u26A0")?1:0),i=Math.min(Math.max(s,cs),Ll),a="\u2500".repeat(i);return["",n(`\u250C${a}\u2510`),n(e),n(`\u2514${a}\u2518`),...o,""].join(`
415
+ `)}function be(e){return!X.stdin.isTTY||!!X.env.CI||!!e.nonInteractive||!!e.yes}async function Vl(e){if(e.suggestedDefault){let{accept:r}=await Z.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(r)return e.suggestedDefault}let{prefix:t}=await Z.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 Jl(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 zl(e,t){let{customize:r}=await Z.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(!r)return{};let n={};for(let o of e){let s=o.tagName,i=t.get(s)??s,{tag:a}=await Z.prompt([{type:"input",name:"tag",message:`Tag for ${o.declaration.name} (<${s}>):`,default:i,validate:Jl}]),c=String(a).trim();c!==i&&(n[s]=c)}return n}function Kl(e,t){let r=e??qo();return{...r,init:{...r.init,prefix:{default:r.init.prefix.default,overrides:{...r.init.prefix.overrides,...t}}}}}var ql={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 Yl(e,t,r){let n=r?.init.editors,o=bo(e),s=!be(t),i={vscode:!1,jsx:!1,svelte:!1,cssSnippets:!1},a=[];for(let c of go){let l=t[c];if(l!==void 0){i[c]=l;continue}let m=n?.[c];if(m!==void 0){i[c]=m;continue}if(s){let{label:u,artifact:p}=ql[c];a.push({type:"confirm",name:c,message:`Generate ${u} (${p})?`,default:o[c]})}else i[c]=o[c]}if(a.length>0){let c=await Z.prompt(a);for(let{name:l}of a)i[l]=!!c[l]}return i}async function Xl(e,t){let r;try{r=rs(e)}catch(a){let c=a instanceof Error?a.message:String(a);return console.error(`\u26A0 Skipping formkit migration check: ${c}`),!1}if(r.length===0)return!1;let n=r.map(a=>a.pkg).join(", ");if(be(t))return console.error(`\u26A0 ${r.length} legacy standalone package(s) can be migrated to @aurodesignsystem/auro-formkit: ${n}. Run \`auro init\` interactively to apply the migration.`),!1;let{migrate:o}=await Z.prompt([{type:"confirm",name:"migrate",message:`${r.length} legacy standalone package(s) now live in auro-formkit (${n}). Migrate to auro-formkit now? This edits package.json and rewrites import specifiers.`,default:!1}]);if(!o)return!1;let s=_e("Migrating to auro-formkit...").start(),i=ns(e,r);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 Zl(e){let t=new Map(e.map(o=>[o.pkg,o.version])),r=_e("Checking for newer component releases...").start(),n=await fe(t);if(n.length===0){r.succeed("All installed Auro components are on the latest release.");return}r.stop(),console.error(ge(n))}async function Ql(e){let t=X.cwd();if(e.reset){await ru(t,e);return}let r=_e("Detecting installed Auro components...").start(),{components:n,duplicates:o}=await Kn();if(n.length===0){r.warn("No installed Auro components found; nothing to ground. Install an Auro component package and re-run `auro init`.");return}if(r.succeed(`Detected ${n.length} installed component(s) to ground.`),await Xl(t,e))return;let s;try{s=Tt(t)}catch(g){let b=g instanceof G||g instanceof Error?g.message:String(g);console.error(`Cannot read ${D}: ${b}`),X.exit(1)}let i=Xo(t),a=$t(n,{config:s,scan:i,prefix:e.prefix}),l=!(e.prefix!==void 0||s?.init.prefix.default!==void 0)&&(a.needsDefaultPrefix||a.mixedPrefixes),m=e.prefix;if(l){if(be(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-).`),X.exit(1)}m=await Vl(a),a=$t(n,{config:s,scan:i,prefix:m})}if(a.needsDefaultPrefix&&(console.error("Unable to resolve a default prefix for every component. Re-run with --prefix <prefix>."),X.exit(1)),!be(e)){let g=await zl(n,a.resolvedTags);Object.keys(g).length>0&&(a=$t(n,{config:Kl(s,g),scan:i,prefix:m}))}let u=await Yl(t,e,s);a.config.init.editors=u;let p=_e("Writing generated files...").start(),d={written:[],warnings:[]};try{for(let b of Uo(n,a.resolvedTags))await Ul.writeFile(Wl.join(t,b.filename),b.contents,"utf-8");d=await xr(t,n,a.resolvedTags,u),Yo(t,a.config);let g=d.written.length>0?` Editor IntelliSense: ${d.written.join(", ")}.`:"";p.succeed(`Wrote ${q}, ${ae}, and ${D} for ${n.length} component(s).${g}`)}catch(g){let b=g instanceof Error?g.message:String(g);p.fail(`Failed to write generated files: ${b}`),X.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(ce(`\u26A0 ${a.reconciliationWarnings.length} component tag(s) may not match your app's registered tags`,a.reconciliationWarnings,"red")),a.noPrefixWarnings.length>0&&console.error(ce(`\u26A0 ${a.noPrefixWarnings.length} component(s) grounded under bare 'auro-*' tags \u2014 pass a prefix to avoid collisions`,a.noPrefixWarnings,"yellow"));let f=Tr(t,u);if(f.inconsistencies.length>0)try{let g=await xr(t,n,a.resolvedTags,u),b=new Set(d.warnings);for(let S of g.warnings)b.has(S)||console.error(`\u26A0 ${S}`);f=Tr(t,u)}catch(g){let b=g instanceof Error?g.message:String(g);console.error(`\u26A0 Could not re-write editor artifacts to self-heal wiring: ${b}`)}f.inconsistencies.length>0&&console.error(ce("\u26A0 Editor IntelliSense wiring is incomplete after writing",f.inconsistencies,"red")),f.markupDisabled&&console.error(ce("\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,ae,D,...d.written])];await eu(t,h,e),e.offline||await Zl(n)}async function eu(e,t,r){let n=await wt(e,t);if(n.length===0)return;if(console.error(ce(`\u26A0 ${n.length} file(s) auro init wrote are git-ignored and won't be committed`,[...n,"These are meant to be committed so your team and CI share the same grounding/IntelliSense."],"red")),be(r)&&!r.yes){console.error("\u26A0 Un-ignore them in .gitignore (or re-run with --yes) so they get committed.");return}if(!r.yes){let{fix:i}=await Z.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 Jo(e,n);o.length>0&&console.error(`\u2714 Un-ignored ${o.length} file(s) in .gitignore so they will be committed.`),s.length>0&&console.error(ce(`\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 tu(e){return e.filesToRemove.length===0&&e.unmerges.length===0}async function ru(e,t){let r=ss(e);if(tu(r)){console.log("Nothing to reset \u2014 no `auro init` output found.");for(let c of r.filesToSkip)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);return}console.log("`auro init --reset` will:");for(let c of r.filesToRemove)console.log(` \u2022 remove ${c}`);for(let c of r.unmerges)console.log(` \u2022 remove the Auro entry from ${c.path}`);for(let c of r.dirsToPrune)console.log(` \u2022 remove ${c}/ if it is left empty`);for(let c of r.filesToSkip)console.log(` \u2022 keep ${c.path} (${c.reason})`);if(!be(t)){let{confirm:c}=await Z.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 n=_e("Removing `auro init` output...").start(),o;try{o=is(e,r)}catch(c){let l=c instanceof Error?c.message:String(c);n.fail(`Failed to reset: ${l}`),X.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(", ")}`:"";n.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 ry=Hl.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(Ql);import At from"node:process";import{Logger as nu}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as ou}from"commander";import us from"ora";async function su(e,t){let r=n=>({headerPkg:e,installPkg:e,importSpecifier:e,redirectedToFormkit:!1,result:n});if(t.tag)return r(await M(`${e}@${t.tag}`));if(K(e)){let n=await M(e,{allowNetwork:!1});return n.manifest?r(n):{headerPkg:L,installPkg:L,importSpecifier:de(e),tagFilter:kr(e),redirectedToFormkit:!0,result:await M(L)}}return r(await M(e))}async function iu(e,t){let r=Lo(e),n=us(`Fetching ${r}...`).start(),o=await su(r,t),{result:s}=o,i=s.target;s.manifest||(n.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.`),At.exit(1));let c=(s.manifest.modules??[]).flatMap(u=>u.declarations??[]).filter(u=>u.customElement&&u.tagName).filter(u=>!o.tagFilter||u.tagName===o.tagFilter);c.length===0&&(n.fail(o.tagFilter?`No <${o.tagFilter}> element found in ${i}.`:`No registered custom elements found for ${i}.`),At.exit(1));let l=s.source==="local"?` (local${s.version?` v${s.version}`:""})`:" (unpkg)";n.succeed(`${i} \u2014 ${c.length} custom element${c.length===1?"":"s"}${l}`),o.redirectedToFormkit&&console.error(`\u2139 ${o.tagFilter} now ships in ${L} \u2014 showing the monorepo version (the legacy standalone isn't installed).`);let m=null;if(s.source==="local"&&s.version){let u=us("Checking for a newer release...").start(),p=await fe(new Map([[o.headerPkg,s.version]]));u.stop(),p.length>0&&(m=ge(p))}if(t.json){At.stdout.write(`${JSON.stringify(c,null,2)}
417
416
  `),m&&console.error(m);return}At.stdout.write(`
418
- ${c.map(u=>Lo(o.headerPkg,u,{installPkg:o.installPkg,importSpecifier:o.importSpecifier})).join(`
417
+ ${c.map(u=>Go(o.headerPkg,u,{installPkg:o.installPkg,importSpecifier:o.importSpecifier})).join(`
419
418
 
420
419
  ---
421
420
 
422
421
  `)}
423
422
  `),nu.info(`
424
- Full docs: https://auro.alaskaair.com`),m&&console.error(m)}var py=ou.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(iu);import{program as au}from"commander";import cu from"ora";var Nr=au.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);Nr=Ge(Nr);var lu={cem:ze,api:Ke,docs:Xr,serve:Qr,watchDocs:en};async function uu(e,t=lu){try{e.cem&&await t.cem(),e.api&&await t.api();try{await t.docs(e)}catch(r){if(!e.watch)throw r}e.serve&&await t.serve(e),e.watch&&await t.watchDocs(e)}catch(r){cu().fail(`Docs failed: ${r instanceof Error?r.message:String(r)}`),process.exit(1)}}var by=Nr.action(e=>uu(e));import{program as gu}from"commander";import{Octokit as Or}from"@octokit/rest";import*as Rt from"azure-devops-node-api";import Ct from"ora";var mu=async e=>{let t=process.env.GH_TOKEN;if(!t)throw new Error("GH_TOKEN environment variable is required");let r=new Or({auth:t}),n,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");[,n,o,s]=a}else if(e.includes("#")){let a=e.match(/([^\/]+)\/([^#]+)#(\d+)/);if(!a)throw new Error("Invalid GitHub issue reference format");[,n,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 r.rest.issues.get({owner:n,repo:o,issue_number:i});return{title:a.title,body:a.body??null,html_url:a.html_url,number:a.number,repository:{owner:{login:n},name:o}}}catch(a){throw new Error(`Failed to fetch GitHub issue: ${a}`)}},pu=async e=>{let t=process.env.GH_TOKEN;if(!t)return null;let r=new Or({auth:t});try{let n=`
423
+ Full docs: https://auro.alaskaair.com`),m&&console.error(m)}var py=ou.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(iu);import{program as au}from"commander";import cu from"ora";var Nr=au.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);Nr=Ge(Nr);var lu={cem:ze,api:Ke,docs:Zr,serve:en,watchDocs:tn};async function uu(e,t=lu){try{e.cem&&await t.cem(),e.api&&await t.api();try{await t.docs(e)}catch(r){if(!e.watch)throw r}e.serve&&await t.serve(e),e.watch&&await t.watchDocs(e)}catch(r){cu().fail(`Docs failed: ${r instanceof Error?r.message:String(r)}`),process.exit(1)}}var by=Nr.action(e=>uu(e));import{program as gu}from"commander";import{Octokit as Or}from"@octokit/rest";import*as Rt from"azure-devops-node-api";import Ct from"ora";var mu=async e=>{let t=process.env.GH_TOKEN;if(!t)throw new Error("GH_TOKEN environment variable is required");let r=new Or({auth:t}),n,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");[,n,o,s]=a}else if(e.includes("#")){let a=e.match(/([^\/]+)\/([^#]+)#(\d+)/);if(!a)throw new Error("Invalid GitHub issue reference format");[,n,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 r.rest.issues.get({owner:n,repo:o,issue_number:i});return{title:a.title,body:a.body??null,html_url:a.html_url,number:a.number,repository:{owner:{login:n},name:o}}}catch(a){throw new Error(`Failed to fetch GitHub issue: ${a}`)}},pu=async e=>{let t=process.env.GH_TOKEN;if(!t)return null;let r=new Or({auth:t});try{let n=`
425
424
  query($owner: String!, $repo: String!, $issueNumber: Int!) {
426
425
  repository(owner: $owner, name: $repo) {
427
426
  issue(number: $issueNumber) {
@@ -514,10 +513,10 @@ Full docs: https://auro.alaskaair.com`),m&&console.error(m)}var py=ou.command("c
514
513
  }
515
514
  }
516
515
  }
517
- `,{projectId:c,itemId:u,fieldId:m.id,value:t});else if(!m)throw new Error("No 'ado' field found in GitHub project")}catch(s){console.error(`Failed to update GitHub project: ${s}`)}},fu=async e=>{let t=process.env.ADO_TOKEN;if(!t)throw new Error("ADO_TOKEN environment variable is required");let r="https://dev.azure.com/itsals",n="E_Retain_Content",o="E_Retain_Content\\Auro Design System",s=Rt.getPersonalAccessTokenHandler(t),a=await new Rt.WebApi(r,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,n,"User Story")}catch(c){throw new Error(`Failed to create ADO work item: ${c}`)}},us=async e=>{let t=Ct(`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 r=await mu(e);t.succeed(`Found issue: "${r.title}"`);let n=Ct("Checking for existing ADO work item...").start(),o=await pu(r);if(o){n.succeed("ADO work item already exists for this issue!"),console.log(`${o}`);return}n.succeed("No existing ADO work item found");let s=Ct("Creating new ADO work item...").start(),i=await fu(r);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=Ct("Adding to GitHub project and updating ADO field...").start();await du(r,i._links.html.href),a.succeed("Updated GitHub project with ADO link")}}catch(r){t.fail(`Error: ${r instanceof Error?r.message:r}`),process.exit(1)}};var $y=gu.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 us(e.ghIssue)});import{program as Au}from"commander";import{Octokit as Tu}from"@octokit/rest";import{simpleGit as $u}from"simple-git";import*as Pt from"azure-devops-node-api";import{WorkItemErrorPolicy as ms,WorkItemExpand as hu}from"azure-devops-node-api/interfaces/WorkItemTrackingInterfaces.js";var ds="https://dev.azure.com/itsals",Mr="E_Retain_Content",fs="auro-rcs";function gs(e){let t=new Set,r=/AB#(\d+)/gi;for(let n of e){let o=n.message??`${n.subject??""}
518
- ${n.body??""}`;for(let s of o.matchAll(r)){let i=Number.parseInt(s[1],10);Number.isNaN(i)||t.add(i)}}return[...t]}async function yu(){let e=process.env.ADO_TOKEN;if(!e)throw new Error("ADO_TOKEN environment variable is required to resolve the Release ticket.");let t=Pt.getPersonalAccessTokenHandler(e);return new Pt.WebApi(ds,t).getWorkItemTrackingApi()}function bu(e){if(!e)return null;let t=e.match(/\/workItems\/(\d+)(?:\/)?$/i);return t?Number.parseInt(t[1],10):null}function wu(e){let t=e.fields?.["System.Tags"];return typeof t!="string"?!1:t.split(";").map(r=>r.trim().toLowerCase()).includes(fs)}function _r(e){return e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function vu(e){let t=_r(e),r=t.replace(/^auro /,"");return[...new Set([t,r])].filter(Boolean)}function ku(e,t){let r=e.fields?.["System.AreaPath"];return typeof r!="string"?!1:r.split("\\").map(_r).some(n=>t.includes(n))}function Eu(e,t){let r=e.fields?.["System.Title"];if(typeof r!="string")return!1;let n=` ${_r(r)} `;return t.some(o=>n.includes(` ${o} `))}function ps(e){let t=e.fields?.["System.Title"]??"(no title)",r=e.fields?.["System.AreaPath"]??"(no area path)";return`#${e.id} "${t}" [${r}]`}function Su(e,t){let r=vu(t),n=`
519
- ${e.map(ps).join(`
516
+ `,{projectId:c,itemId:u,fieldId:m.id,value:t});else if(!m)throw new Error("No 'ado' field found in GitHub project")}catch(s){console.error(`Failed to update GitHub project: ${s}`)}},fu=async e=>{let t=process.env.ADO_TOKEN;if(!t)throw new Error("ADO_TOKEN environment variable is required");let r="https://dev.azure.com/itsals",n="E_Retain_Content",o="E_Retain_Content\\Auro Design System",s=Rt.getPersonalAccessTokenHandler(t),a=await new Rt.WebApi(r,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,n,"User Story")}catch(c){throw new Error(`Failed to create ADO work item: ${c}`)}},ms=async e=>{let t=Ct(`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 r=await mu(e);t.succeed(`Found issue: "${r.title}"`);let n=Ct("Checking for existing ADO work item...").start(),o=await pu(r);if(o){n.succeed("ADO work item already exists for this issue!"),console.log(`${o}`);return}n.succeed("No existing ADO work item found");let s=Ct("Creating new ADO work item...").start(),i=await fu(r);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=Ct("Adding to GitHub project and updating ADO field...").start();await du(r,i._links.html.href),a.succeed("Updated GitHub project with ADO link")}}catch(r){t.fail(`Error: ${r instanceof Error?r.message:r}`),process.exit(1)}};var $y=gu.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 ms(e.ghIssue)});import{program as Au}from"commander";import{Octokit as Tu}from"@octokit/rest";import{simpleGit as $u}from"simple-git";import*as Pt from"azure-devops-node-api";import{WorkItemErrorPolicy as ps,WorkItemExpand as hu}from"azure-devops-node-api/interfaces/WorkItemTrackingInterfaces.js";var fs="https://dev.azure.com/itsals",Mr="E_Retain_Content",gs="auro-rcs";function hs(e){let t=new Set,r=/AB#(\d+)/gi;for(let n of e){let o=n.message??`${n.subject??""}
517
+ ${n.body??""}`;for(let s of o.matchAll(r)){let i=Number.parseInt(s[1],10);Number.isNaN(i)||t.add(i)}}return[...t]}async function yu(){let e=process.env.ADO_TOKEN;if(!e)throw new Error("ADO_TOKEN environment variable is required to resolve the Release ticket.");let t=Pt.getPersonalAccessTokenHandler(e);return new Pt.WebApi(fs,t).getWorkItemTrackingApi()}function bu(e){if(!e)return null;let t=e.match(/\/workItems\/(\d+)(?:\/)?$/i);return t?Number.parseInt(t[1],10):null}function wu(e){let t=e.fields?.["System.Tags"];return typeof t!="string"?!1:t.split(";").map(r=>r.trim().toLowerCase()).includes(gs)}function _r(e){return e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function vu(e){let t=_r(e),r=t.replace(/^auro /,"");return[...new Set([t,r])].filter(Boolean)}function ku(e,t){let r=e.fields?.["System.AreaPath"];return typeof r!="string"?!1:r.split("\\").map(_r).some(n=>t.includes(n))}function Eu(e,t){let r=e.fields?.["System.Title"];if(typeof r!="string")return!1;let n=` ${_r(r)} `;return t.some(o=>n.includes(` ${o} `))}function ds(e){let t=e.fields?.["System.Title"]??"(no title)",r=e.fields?.["System.AreaPath"]??"(no area path)";return`#${e.id} "${t}" [${r}]`}function Su(e,t){let r=vu(t),n=`
518
+ ${e.map(ds).join(`
520
519
  `)}`;for(let[o,s]of[["Area Path",ku],["title",Eu]]){let i=e.filter(a=>s(a,r));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}":
521
- ${i.map(ps).join(`
520
+ ${i.map(ds).join(`
522
521
  `)}
523
- 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:${n}`)}async function hs(e,t){if(e.length===0)return console.log("No ADO work item references (AB#<id>) found in the RC commits."),null;let r=await yu(),n=await r.getWorkItems(e,void 0,void 0,hu.Relations,ms.Omit,Mr),o=new Set;for(let m of n??[])for(let u of m.relations??[]){let p=bu(u.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 r.getWorkItems([...o],["System.Title","System.Tags","System.AreaPath"],void 0,void 0,ms.Omit,Mr)??[]).filter(wu);if(i.length===0)return console.log(`No Release ticket (tagged "${fs}") is linked to the committed work items (${e.join(", ")}).`),null;let a=i.length===1?i[0]:Su(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??`${ds}/${Mr}/_workitems/edit/${a.id}`;return{id:a.id,url:l,title:c}}var je="dev",xu="main",Dt=class e{constructor(t,r,n){this.repoInfo={owner:t,repo:r},this.octokit=n}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 r=await V.getRepoOwnerAndName(),n=new Tu({auth:t});if(!r)throw new Error("Failed to retrieve repository information. Ensure you're in a valid git repository.");let o=await e.getTriggerBranchName();return o&&o!==je&&(console.log(`Switching from ${o} to ${je} branch...`),await $u().checkout(je)),new e(r.owner,r.repo,n)}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 r=await this.getLinkedPrByHead(t.id);if(r?.multipleOpen)throw new Error("Multiple open RC PRs found for the same rc/<ticketId> branch.");r?.state==="closed"&&(console.log("Linked RC PR is closed. Creating a new RC PR on the same branch."),r=null),await this.createOrUpdateRcBranch(t.id),r?await this.updateRcPr(t,r.number):r=await this.createRcPr(t)}async resolveReleaseTicket(){let t=await V.getCommitMessages(je),r=gs(t);return hs(r,this.repoInfo.repo)}async createOrUpdateRcBranch(t){let r=`heads/rc/${t}`,n=`rc/${t}`,{data:o}=await this.octokit.rest.repos.getBranch({owner:this.repoInfo.owner,repo:this.repoInfo.repo,branch:je}),{data:s}=await this.octokit.rest.git.listMatchingRefs({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:r}),i=s.length>0;try{i?(console.log(`Updating existing RC branch: ${n}`),await this.octokit.rest.git.updateRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:r,sha:o.commit.sha,force:!0})):(console.log(`Creating new RC branch: ${n}`),await this.octokit.rest.git.createRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:`refs/${r}`,sha:o.commit.sha}))}catch(a){throw new Error(`Failed to create or update ${n} branch: ${a}`)}}async getLinkedPrByHead(t){let r=`${this.repoInfo.owner}:rc/${t}`,{data:n}=await this.octokit.rest.pulls.list({owner:this.repoInfo.owner,repo:this.repoInfo.repo,state:"all",head:r,per_page:30}),o=n.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=n.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 r=this.rcReference(t);try{let{data:n}=await this.octokit.rest.repos.getContent({owner:this.repoInfo.owner,repo:this.repoInfo.repo,path:".github/PULL_REQUEST_TEMPLATE.md"});if("content"in n&&n.type==="file"){let o=Buffer.from(n.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.",r),o=o.replace(/<details>/g,"<details open>"),o}}catch(n){n&&typeof n=="object"&&"status"in n&&n.status===404?console.log("No PR template found in repo, using default message."):console.warn("Failed to fetch PR template:",n)}return r}async createRcPr(t){try{let r=await this.buildPrBody(t),{data:n}=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:r,head:`rc/${t.id}`,base:xu,headers:{"X-GitHub-Api-Version":"2022-11-28"}});return console.log(`Created Release Candidate pull request: #${n.number} (${n.html_url})`),{state:"open",html_url:n.html_url,number:n.number}}catch(r){throw console.error("Failed to create RC PR:",r),r}}async updateRcPr(t,r){try{let n=await this.buildPrBody(t);await this.octokit.rest.pulls.update({owner:this.repoInfo.owner,repo:this.repoInfo.repo,pull_number:r,body:n}),console.log(`Updated Release Candidate pull request: #${r}`)}catch(n){throw console.error("Failed to update RC PR:",n),n}}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 _y=Au.command("rc-workflow").description("Generate RC issue and pull request").action(async()=>{await(await Dt.create()).createReleaseCandidate()});jr.name("auro").version(Nt()).description("A cli tool to support the Auro Design System");jr.addHelpText("beforeAll",Fr());jr.parse();
522
+ 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:${n}`)}async function ys(e,t){if(e.length===0)return console.log("No ADO work item references (AB#<id>) found in the RC commits."),null;let r=await yu(),n=await r.getWorkItems(e,void 0,void 0,hu.Relations,ps.Omit,Mr),o=new Set;for(let m of n??[])for(let u of m.relations??[]){let p=bu(u.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 r.getWorkItems([...o],["System.Title","System.Tags","System.AreaPath"],void 0,void 0,ps.Omit,Mr)??[]).filter(wu);if(i.length===0)return console.log(`No Release ticket (tagged "${gs}") is linked to the committed work items (${e.join(", ")}).`),null;let a=i.length===1?i[0]:Su(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??`${fs}/${Mr}/_workitems/edit/${a.id}`;return{id:a.id,url:l,title:c}}var je="dev",xu="main",Dt=class e{constructor(t,r,n){this.repoInfo={owner:t,repo:r},this.octokit=n}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 r=await V.getRepoOwnerAndName(),n=new Tu({auth:t});if(!r)throw new Error("Failed to retrieve repository information. Ensure you're in a valid git repository.");let o=await e.getTriggerBranchName();return o&&o!==je&&(console.log(`Switching from ${o} to ${je} branch...`),await $u().checkout(je)),new e(r.owner,r.repo,n)}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 r=await this.getLinkedPrByHead(t.id);if(r?.multipleOpen)throw new Error("Multiple open RC PRs found for the same rc/<ticketId> branch.");r?.state==="closed"&&(console.log("Linked RC PR is closed. Creating a new RC PR on the same branch."),r=null),await this.createOrUpdateRcBranch(t.id),r?await this.updateRcPr(t,r.number):r=await this.createRcPr(t)}async resolveReleaseTicket(){let t=await V.getCommitMessages(je),r=hs(t);return ys(r,this.repoInfo.repo)}async createOrUpdateRcBranch(t){let r=`heads/rc/${t}`,n=`rc/${t}`,{data:o}=await this.octokit.rest.repos.getBranch({owner:this.repoInfo.owner,repo:this.repoInfo.repo,branch:je}),{data:s}=await this.octokit.rest.git.listMatchingRefs({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:r}),i=s.length>0;try{i?(console.log(`Updating existing RC branch: ${n}`),await this.octokit.rest.git.updateRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:r,sha:o.commit.sha,force:!0})):(console.log(`Creating new RC branch: ${n}`),await this.octokit.rest.git.createRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:`refs/${r}`,sha:o.commit.sha}))}catch(a){throw new Error(`Failed to create or update ${n} branch: ${a}`)}}async getLinkedPrByHead(t){let r=`${this.repoInfo.owner}:rc/${t}`,{data:n}=await this.octokit.rest.pulls.list({owner:this.repoInfo.owner,repo:this.repoInfo.repo,state:"all",head:r,per_page:30}),o=n.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=n.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 r=this.rcReference(t);try{let{data:n}=await this.octokit.rest.repos.getContent({owner:this.repoInfo.owner,repo:this.repoInfo.repo,path:".github/PULL_REQUEST_TEMPLATE.md"});if("content"in n&&n.type==="file"){let o=Buffer.from(n.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.",r),o=o.replace(/<details>/g,"<details open>"),o}}catch(n){n&&typeof n=="object"&&"status"in n&&n.status===404?console.log("No PR template found in repo, using default message."):console.warn("Failed to fetch PR template:",n)}return r}async createRcPr(t){try{let r=await this.buildPrBody(t),{data:n}=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:r,head:`rc/${t.id}`,base:xu,headers:{"X-GitHub-Api-Version":"2022-11-28"}});return console.log(`Created Release Candidate pull request: #${n.number} (${n.html_url})`),{state:"open",html_url:n.html_url,number:n.number}}catch(r){throw console.error("Failed to create RC PR:",r),r}}async updateRcPr(t,r){try{let n=await this.buildPrBody(t);await this.octokit.rest.pulls.update({owner:this.repoInfo.owner,repo:this.repoInfo.repo,pull_number:r,body:n}),console.log(`Updated Release Candidate pull request: #${r}`)}catch(n){throw console.error("Failed to update RC PR:",n),n}}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 _y=Au.command("rc-workflow").description("Generate RC issue and pull request").action(async()=>{await(await Dt.create()).createReleaseCandidate()});jr.name("auro").version(Nt()).description("A cli tool to support the Auro Design System");jr.addHelpText("beforeAll",Fr());jr.parse();