@aurodesignsystem-dev/auro-cli 0.0.0-pr359.1 → 0.0.0-pr362.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auro-cli.js +81 -81
- package/dist/auro-cli.js.map +3 -3
- package/package.json +1 -1
package/dist/auro-cli.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{program as
|
|
2
|
+
import{program as vr}from"commander";import Ii from"figlet";import{mind as Oi}from"gradient-string";var kr=()=>Oi(Ii.textSync("Auro CLI"));import $r from"node:fs";import Er from"node:path";import{fileURLToPath as ji}from"node:url";function Ve(e){process.env.DEBUG&&console.log(`[DEBUG] ${e}`)}function Zt(){try{let e=ji(import.meta.url),t=Er.dirname(e);Ve(`Current module path: ${t}`);let n=Er.resolve(t,"..","package.json");return Ve(`Checking package.json at: ${n}`),$r.existsSync(n)?(Ve(`Found package.json at: ${n}`),JSON.parse($r.readFileSync(n,"utf8")).version):(Ve("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 La}from"commander";import Qr from"ora";function Ke(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 qe(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 Oa from"@rollup/plugin-terser";import{watch as ja}from"rollup";import{existsSync as Jr,readFileSync as Sa,rmSync as Ca,writeFileSync as Aa}from"node:fs";import{basename as xa,dirname as Ta,join as Ie,resolve as st}from"node:path";import{pathToFileURL as zr}from"node:url";import{glob as Ra}from"glob";import un from"ora";import{rollup as ln}from"rollup";import*as Vr from"sass";import Me from"ora";import{spawn as _i}from"node:child_process";import Fi from"ora";var F=(e,t)=>{let n=`${e} ${t?t.join(" "):""}`,r=Fi(),o=e,i=t||[];if(!t&&typeof e=="string"){let l=e.split(" ");o=l[0],i=l.slice(1)}let s=n.includes("--watch")||n.includes(" -w"),c=_i(o,i,{stdio:s?"inherit":["inherit","pipe","pipe"],shell:!0});if(!s){let l=[];c.stdout?.on("data",u=>{let p=u.toString();l.push(p),process.stdout.write(p)}),c.stderr?.on("data",u=>{let p=u.toString();l.push(p),process.stderr.write(p)})}return new Promise((l,u)=>{c.on("close",p=>{p!==0?s?(r.info(`Watch mode terminated with code ${p}`),l()):(r.fail(`${n} failed (code ${p})`),u(new Error(`Command failed with exit code ${p}`))):(r.succeed(`${n} completed successfully`),l())})})};import he from"node:fs";import N from"node:path";import{markdownTable as Sr}from"markdown-table";var Ye=e=>typeof e=="number"&&Number.isFinite(e),Li=[{header:"Category",render:({category:e})=>typeof e=="string"?e:""},{header:"Required",render:({requiredWhen:e})=>typeof e!="string"||!e?"":e==="always"?"Yes":`\`${e}\``},{header:"Relevant when",render:({relevantWhen:e})=>typeof e=="string"&&e?`\`${e}\``:""},{header:"Range",render:({minimum:e,maximum:t})=>Ye(e)&&Ye(t)?`${e}\u2013${t}`:Ye(e)?`\u2265 ${e}`:Ye(t)?`\u2264 ${t}`:""}],Te=class e{static{this.manifest={schemaVersion:"1.0.0",readme:"",modules:[]}}static generate(t={}){let{outDir:n="./docs",outFile:r="api.md",manifestPath:o="./custom-elements.json"}=t,{getElements:i,renderAllElements:s}=e;if(o)try{let d=he.readFileSync(o,"utf8");e.manifest=JSON.parse(d)}catch(d){throw console.error(`Error reading manifest file at ${o}:`,d),d}let a=process.cwd(),c=e.isSharedManifest(o,a);c&&(e.manifest=e.scopeManifest(e.manifest,o,a));let l=i();if(c&&l.length===0)throw new Error(`${o} has no custom elements under ${a}. Check the path, and that the manifest was generated after this package's source changed.`);let u=n;he.existsSync(u)||he.mkdirSync(u,{recursive:!0});let p=s(l),m=N.join(u,r);he.writeFileSync(m,p),console.log(`Generated combined API documentation at ${m}`)}static isSharedManifest(t,n){return N.dirname(N.resolve(n,t))!==N.resolve(n)}static scopeManifest(t,n,r){let o=N.dirname(N.resolve(r,n)),i=N.relative(o,N.resolve(r));if(i==="")return t;if(i.startsWith("..")||N.isAbsolute(i))throw new Error(`${n} isn't in ${r} or one of its parent folders, so it can't describe this package.`);let s=`${i.split(N.sep).join("/")}/`,a=e.wcaTagNames(r),c=u=>a.size===0||!("customElement"in u&&u.customElement===!0)||"tagName"in u&&typeof u.tagName=="string"&&a.has(u.tagName),l=t.modules.filter(u=>(u.path??"").replace(/^\.\//u,"").startsWith(s)).map(u=>({...u,declarations:u.declarations?.filter(c)}));return{...t,modules:l}}static wcaTagNames(t){let n=N.join(t,"scripts","wca");return he.existsSync(n)?new Set(he.readdirSync(n).filter(r=>/^auro-.+\.js$/u.test(r)).map(r=>r.slice(0,-3))):new Set}static getElements(){let t=e.manifest.modules.filter(e.isWcaModule);return e.manifest.modules.reduce((n,r)=>n.concat(r.declarations?.filter(o=>"customElement"in o&&o.customElement===!0&&"tagName"in o&&(t.length>0?e.isWcaModule(r):!0))??[]),[])}static isWcaModule(t){let{path:n}=t;return n?n.startsWith("scripts/wca/auro-")&&n.endsWith(".js"):!1}static renderAllElements(t){return`${t.sort((n,r)=>(n.tagName||"").localeCompare(r.tagName||"")).map(n=>e.renderElement(n,!0)).join(`
|
|
3
3
|
|
|
4
|
-
`)}`}static renderElement(t,n=!0){let r=[],{renderTable:o,renderPropertiesAttributesTable:i,renderParameters:s,getType:a}=e;r.push(n?`# ${t.tagName}`:""),t.description&&r.push(t.description);let c=i(t);c&&r.push(c.trim());let l=o("Methods",["name","parameters","return","description"],(t.members||[]).filter(f=>f.kind==="method"&&("privacy"in f?f.privacy!=="private":!0)&&f.name[0]!=="_").map(f=>({...f,parameters:s("parameters"in f?f.parameters:void 0),return:"return"in f&&f.return?a(f.return):""})));l&&r.push(l.trim());let u=o("Events",["name","description"],t.events);u&&r.push(u.trim());let
|
|
4
|
+
`)}`}static renderElement(t,n=!0){let r=[],{renderTable:o,renderPropertiesAttributesTable:i,renderParameters:s,getType:a}=e;r.push(n?`# ${t.tagName}`:""),t.description&&r.push(t.description);let c=i(t);c&&r.push(c.trim());let l=o("Methods",["name","parameters","return","description"],(t.members||[]).filter(f=>f.kind==="method"&&("privacy"in f?f.privacy!=="private":!0)&&f.name[0]!=="_").map(f=>({...f,parameters:s("parameters"in f?f.parameters:void 0),return:"return"in f&&f.return?a(f.return):""})));l&&r.push(l.trim());let u=o("Events",["name","description"],t.events);u&&r.push(u.trim());let p=o("Slots",[["name","(default)"],"description"],t.slots,!0);p&&r.push(p.trim());let m=o("CSS shadow parts",["name","description"],t.cssParts,!0);m&&r.push(m.trim());let d=o("CSS custom properties",["name","description"],t.cssProperties,!0);return d&&r.push(d.trim()),r.join(`
|
|
5
5
|
|
|
6
|
-
`)}static renderPropertiesAttributesTable(t){let{getType:n,escapeMarkdown:r,addTagColumns:o}=e,i=t.members?.filter(
|
|
6
|
+
`)}static renderPropertiesAttributesTable(t){let{getType:n,escapeMarkdown:r,addTagColumns:o}=e,i=t.members?.filter(m=>m.kind==="field"&&("privacy"in m?m.privacy!=="private":!0)&&m.name[0]!=="_")||[],s=t.attributes||[],a=[],c=new Set;if(i.forEach(m=>{if(m.description?.trim()){let d=n(m)||"",h=("return"in m&&m.return?n(m.return):"")||d,g=s.find(y=>y.fieldName===m.name||"attribute"in m&&y.name===m.attribute);a.push({name:m.name,properties:m.name,attributes:("attribute"in m?m.attribute:"")||"",modifiers:"readonly"in m&&m.readonly?"readonly":"",type:h,default:("default"in m?m.default:"")||"",description:m.description||"",tags:{...g,...m}})}c.add(m.name),"attribute"in m&&m.attribute&&c.add(m.attribute)}),s.forEach(m=>{!c.has(m.name)&&m.description?.trim()&&a.push({name:m.name,properties:"",attributes:m.name,modifiers:"",type:n(m)||"",default:m.default||"",description:m.description||"",tags:m})}),a.length===0)return"";let l=["Properties","Attributes","Modifiers","Type","Default","Description"],u=a.map(m=>{let g=(m.default||"").trim().replace(/^'([^']+)'$/,"$1").replace(/^"([^"]+)"$/,"$1"),y=g?g.startsWith("`")&&g.endsWith("`")?g:`\`${g}\``:"";return[r(m.properties),r(m.attributes),r(m.modifiers),r(m.type),r(y),r(m.description)]});return`### Properties and attributes
|
|
7
7
|
|
|
8
|
-
${
|
|
9
|
-
`}static renderParameters(t){let{escapeMarkdown:n,getType:r}=e;return!t||t.length===0?"None":t.map(o=>{let i=r(o)||"any",s=o.description?` - ${o.description}`:"";return`\`${o.name}\` (${n(i)})${n(s)}`}).join("<br>")}static renderTable(t,n,r,o=!1){let{escapeMarkdown:i,get:s,capitalize:a,addTagColumns:c}=e;if(r===void 0||r.length===0)return"";let l=r.filter(d=>{let{description:f}=d;return typeof f=="string"&&f.trim()});if(l.length===0)return"";let u=n.map(d=>a((Array.isArray(d)?d[0]:d).split(".")[0])),
|
|
8
|
+
${Sr(o(l,u,a.map(m=>m.tags)))}
|
|
9
|
+
`}static renderParameters(t){let{escapeMarkdown:n,getType:r}=e;return!t||t.length===0?"None":t.map(o=>{let i=r(o)||"any",s=o.description?` - ${o.description}`:"";return`\`${o.name}\` (${n(i)})${n(s)}`}).join("<br>")}static renderTable(t,n,r,o=!1){let{escapeMarkdown:i,get:s,capitalize:a,addTagColumns:c}=e;if(r===void 0||r.length===0)return"";let l=r.filter(d=>{let{description:f}=d;return typeof f=="string"&&f.trim()});if(l.length===0)return"";let u=n.map(d=>a((Array.isArray(d)?d[0]:d).split(".")[0])),p=l.map(d=>n.map(f=>{let h=s(d,f);return i(String(h||""))})),m=Sr(o?c(u,p,l):[u,...p]);return`### ${t}
|
|
10
10
|
|
|
11
|
-
${
|
|
12
|
-
`}static addTagColumns(t,n,r){let o=Li.map(({header:
|
|
11
|
+
${m}
|
|
12
|
+
`}static addTagColumns(t,n,r){let o=Li.map(({header:p,render:m})=>({header:p,cells:r.map(d=>e.escapeMarkdown(m(d)))})).filter(({cells:p})=>p.some(Boolean)),i=t.length-1,s=(p,m)=>[...p.slice(0,i),...m,...p.slice(i)],a=r.map(({category:p})=>typeof p=="string"&&p?p:void 0),c=[...new Set(a.filter(Boolean))],l=p=>{let m=a[p];return m===void 0?c.length:c.indexOf(m)},u=n.map((p,m)=>({row:s(p,o.map(({cells:d})=>d[m]??"")),rank:l(m)})).sort((p,m)=>p.rank-m.rank).map(({row:p})=>p);return[s(t,o.map(({header:p})=>p)),...u]}static escapeMarkdown(t){return t.replace(/\\/g,"\\\\").replace(/\n/g,"<br>").replace(/\|/g,"\\|")}static getType(t){if(!t||!t.type)return"";let{type:n}=t,r=i=>i.replace(/\s*\|\s*/g," | ").replace(/'([^']+)'/g,"`$1`");if(typeof n=="string")return r(n);if(n.text)return r(n.text);if(Array.isArray(n))return n.map(i=>typeof i=="string"?i:i.text?i.text:i.name?i.name:String(i)).join(" \\| ");if(n.name)return r(n.name);if(n.references&&Array.isArray(n.references))return n.references.map(i=>i.name||String(i)).join(" \\| ");let o=String(n);return r(o)}static get(t,n){let r="",o=n;Array.isArray(n)&&([o,r]=n);let i=o.split("."),s=t;for(;s&&i.length;)s=s[i.shift()];return s==null||s===""?r:String(s)}static capitalize(t){return t.replace(/([A-Z])/g," $1").replace(/^./,n=>n.toUpperCase()).trim()}};import Gi from"node:fs";import Bi from"node:os";import Xe from"node:path";import Qt from"node:process";function Wi(){let e=Bi.homedir()||Qt.env.HOME||Qt.env.USERPROFILE;if(!e)throw new Error("Unable to determine user home directory");return Xe.join(e,".auro")}function en(...e){return Xe.join(Wi(),...e)}function tn(...e){let t=Gi.realpathSync(Qt.argv[1]),n=Xe.dirname(t);return Xe.resolve(n,...e)}var Cr=e=>tn("configs",e);import{copyFileSync as Ui,existsSync as Ar,mkdirSync as Hi}from"node:fs";import{join as Ji,resolve as nn}from"node:path";function Ze(){let e=process.cwd(),t=nn(e,"README.md"),n=Ji(nn(e,"demo"),"readme.md");if(!Ar(t))return;let r=nn(e,"demo");Ar(r)||Hi(r,{recursive:!0}),Ui(t,n)}import zi from"ora";var Tr=[];function Re(e){Tr.push(e)}var xr=!1;function Qe(){xr||(xr=!0,process.on("SIGINT",()=>{let e=zi("Wrapping up...").start();for(let t of Tr)t.close();e.succeed("All done! See you next time. \u2728"),process.exit(0)}))}import{Logger as Vi}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{generateReadmeUrl as Ki,processContentForFile as qi,templateFiller as on}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";import L from"node:fs";import{readFileSync as sn,existsSync as rn}from"node:fs";import U from"node:path";var Yi="/docs/pages",Dr={overwriteLocalCopies:!0,remoteReadmeVersion:"master",remoteReadmeVariant:"_updated_paths",monorepoName:void 0,extraVars:{}};function I(e){return`${process.cwd()}/${e}`}function Xi(e=process.cwd()){let t=e;for(;;){let n=U.join(t,"package.json");if(rn(n))try{if(JSON.parse(sn(n,"utf8")).workspaces)return t}catch{}let r=U.dirname(t);if(r===t)break;t=r}return e}async function Zi(e,t=!1){let n=[];if(!t){let o=e.localReadmePath?e.localReadmePath:{remoteUrl:e.remoteReadmeUrl||Ki(e.remoteReadmeVersion,e.remoteReadmeVariant),fileName:I("/docTemplates/README.md"),overwrite:e.overwriteLocalCopies};n.push({identifier:"README.md",input:o,output:I("/README.md")})}Pr("/docs/partials/index.md")&&n.push({identifier:"index.md",input:I("/docs/partials/index.md"),output:I("/demo/index.md"),mdMagicConfig:{output:{directory:I("/demo")}}}),Pr("/docs/partials/api.md")&&n.push({identifier:"api.md",input:I("/docs/partials/api.md"),output:I("/demo/api.md"),preProcessors:[on.formatApiTable]});let r=I(Yi);if(L.existsSync(r)){let i=(await L.promises.readdir(r)).map(s=>({identifier:s,input:U.join(r,s),output:I(`/demo/${s}`)}));n.push(...i)}return n}async function Qi(e=Dr,t=!1){await on.extractNames();let n=await Zi(e,t),r=e.monorepoName;if(!r)try{let s=U.join(Xi(),"package.json");r=JSON.parse(sn(s,"utf8")).name?.replace(/^@[^/]+\//,"")}catch{}let o={...r?{monorepoName:r}:{},...e.extraVars||{}},i=[];for(let s of n)try{if(await qi({...s,extraVars:o,preProcessors:[...s.preProcessors??[],a=>Nr(a,o)]}),s.output.endsWith(".md")){await sa(s.output,o);let a=oa(await L.promises.readFile(s.output,"utf8"));if(a.length>0)throw new Error(`Unreplaced template placeholders: ${a.join(", ")}`)}}catch(a){Vi.error(`Error processing ${s.identifier}: ${a.message}`),i.push(`${s.identifier}: ${a.message}`)}if(i.length>0)throw new Error(`Failed to generate ${i.length} docs file(s):
|
|
13
13
|
${i.map(s=>` - ${s}`).join(`
|
|
14
|
-
`)}`)}var ea=["name","Name","namespace","Namespace","Version","dtVersion","wcssVersion","monorepoName"],ta=["capitalize","withAuroNamespace","packageName"],na=/^~?(?:[#/^!>&{*]|\s*else\b)/,
|
|
14
|
+
`)}`)}var ea=["name","Name","namespace","Namespace","Version","dtVersion","wcssVersion","monorepoName"],ta=["capitalize","withAuroNamespace","packageName"],na=/^~?(?:[#/^!>&{*]|\s*else\b)/,Mr=/<pre\b[\s\S]*?<\/pre>|<code\b[\s\S]*?<\/code>|^[ \t]*(`{3,}|~{3,})[^\n]*\n[\s\S]*?^[ \t]*\1[ \t]*$|`[^`\n]*`/gim;function ra(e,t,n){if(na.test(e))return!n;let[r,...o]=e.replace(/^~?\s*|\s*~?$/g,"").split(/\s+/);return ta.includes(r)?o.every(i=>t.has(i)||/^(["']).*\1$/.test(i)):o.length===0&&t.has(r)}function Nr(e,t={}){let n=new Set([...ea,...Object.keys(t)]),r=(s,a)=>s.replace(/(?<![\\{])\{\{([\s\S]*?)\}\}/g,(c,l)=>ra(l,n,a)?c:`\\${c}`),o="",i=0;for(let s of e.matchAll(Mr))o+=r(e.slice(i,s.index),!1)+r(s[0],!0),i=s.index+s[0].length;return o+r(e.slice(i),!1)}function Rr(e,t){return on.replaceTemplateValues(Nr(e,t),t)}function oa(e){return e.replace(Mr,"").match(/\{\{[\s\S]*?\}\}/g)??[]}async function sa(e,t={}){let n=U.dirname(e),r=await L.promises.readFile(e,"utf8"),o=/^[ \t]*<!-- AURO-GENERATED-CONTENT:START \((FILE|CODE):src=([^)]+)\) -->\n[ \t]*<!-- AURO-GENERATED-CONTENT:END -->/gm,i,s=!1,a=I("demo"),c=[];for(;(i=o.exec(r))!==null;){let[d,f,h]=i,g=U.resolve(n,h),y=U.resolve(a,h),v=rn(g)?g:rn(y)?y:null;if(v){let _=sn(v,"utf8"),A;if(f==="FILE")A=`<!-- AURO-GENERATED-CONTENT:START (FILE:src=${h}) -->
|
|
15
15
|
<!-- The below content is automatically added from ${h} -->
|
|
16
|
-
${
|
|
17
|
-
<!-- AURO-GENERATED-CONTENT:END -->`;else{let k=
|
|
16
|
+
${Rr(_,t).trimEnd()}
|
|
17
|
+
<!-- AURO-GENERATED-CONTENT:END -->`;else{let k=U.extname(h).slice(1)||"html",b=_.trimEnd().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),w=Rr(`<pre class="language-${k}"><code class="language-${k}">${b}
|
|
18
18
|
</code></pre>`,t);A=`<!-- AURO-GENERATED-CONTENT:START (CODE:src=${h}) -->
|
|
19
19
|
<!-- The below code snippet is automatically added from ${h} -->
|
|
20
20
|
${w}
|
|
21
|
-
<!-- AURO-GENERATED-CONTENT:END -->`}r=r.replace(d,()=>A),o.lastIndex=0,s=!0}else c.includes(h)||c.push(h)}if(c.length>0)throw new Error(`Included file(s) not found: ${c.join(", ")}`);s&&await
|
|
22
|
-
</code></pre>`});u!==r&&await
|
|
23
|
-
`}`).join("");return f+k+g});let
|
|
24
|
-
`),
|
|
25
|
-
`))}async function
|
|
26
|
-
`).start();try{let n={port:Number(e.port)||void 0,open:e.open?"/":void 0,watch:e.watch??Re.watch,nodeResolve:e.nodeResolve??Re.nodeResolve,basePath:e.basePath??Re.basePath,rootDir:e.rootDir??Re.rootDir,middleware:[function(i,s){return!i.url.endsWith("/")&&!i.url.includes(".")&&(i.url+=".html"),s()}],plugins:[pa(),fa(),la({include:e.hmrInclude??Re.hmrInclude})]},r=await ca({config:n,readCliArgs:!1,readFileConfig:!1});return t.stop(),r}catch(n){throw t.fail("Server snag! Couldn't start dev server."),console.error("Error starting development server:",n),new Error(`Development server failed to start: ${n.message}`)}}async function tt(){let e=Pe("Generating Custom Elements Manifest...").start();try{await _(`npx --package=@custom-elements-manifest/analyzer -y -- cem analyze --config '${Sr("custom-elements-manifest.config.mjs")}'`),e.succeed("Custom Elements Manifest generated successfully!")}catch(t){let n=t instanceof Error?t.message:String(t);e.warn("CEM analyzer completed with warnings: "+n)}}async function nt(){let e=Pe("Generating API md file...").start();try{await Ae.generate(),e.succeed("API md file generated successfully!")}catch(t){let n=t instanceof Error?t.message:String(t);throw e.fail("Failed to generate API md file: "+n),t}}async function Or(e={},{build:t=Te,demo:n=jr}={}){let r=Pe("Compiling documentation...").start(),o;try{await t(e),r.succeed("Documentation compiled successfully!")}catch(i){let s=i instanceof Error?i.message:String(i);r.fail("Failed to compile MD documentation: "+s),o=i}if(await n(e),o)throw o}async function jr(e={}){Xe(),await re(),await Lr(e)}async function _r(e={}){await et(e)}async function Fr(e={}){let t=await import("chokidar"),n=["./src/**/*","./docs/**/*","./docTemplates/**/*","./apiExamples/**/*","./demo/**/*.scss"],r=["**/demo/*.min.js","**/demo/*.min.css","**/demo/*.md","**/demo/readme.md","**/docs/api.md","**/custom-elements.json","**/node_modules/**","**/dist/**","**/.git/**"],o=t.watch(n,{ignoreInitial:!0,ignored:r,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100}}),i=Pe("Waiting for changes...");i.spinner="bouncingBar",i.color="green",i.start();let s=null,a=!1,c=!1;async function l(u){if(a){c=!0;return}a=!0,o.unwatch(n);let m=Pe(`Change detected: ${u}`).start();try{let p;try{await Te(e)}catch(d){p=d}if(await jr(e),p)throw p;m.succeed("Docs rebuilt!")}catch(p){let d=p instanceof Error?p.message:String(p);m.fail("Rebuild failed: "+d)}finally{setTimeout(()=>{o.add(n),a=!1,c&&(c=!1,l("queued changes"))},1e3)}}o.on("all",(u,m)=>{a||(s&&clearTimeout(s),s=setTimeout(()=>{l(m)},1e3))}),xe(o),Ze()}async function rt(){await tt(),await nt()}import{basename as ya,join as Br,resolve as ba}from"node:path";import wa from"@rollup/plugin-commonjs";import{nodeResolve as va}from"@rollup/plugin-node-resolve";import{glob as ka}from"glob";import{litScss as $a}from"rollup-plugin-scss-lit";import ga from"node:path";import{glob as ha}from"glob";function Gr(e){return{name:"watch-globs",buildStart(){let t=Array.isArray(e)?e:[e];for(let n of t)try{for(let r of ha.sync(ga.resolve(n)))this.addWatchFile(r)}catch(r){this.error(`Error watching glob pattern "${n}": ${r.message}`)}}}}var sn={moduleDirectories:["node_modules"],modulePaths:["../../node_modules","../node_modules","node_modules"],watchPatterns:["./apiExamples/**/*","./docs/**/*"]};function Wr(e=[],t={}){let{watchPatterns:n=sn.watchPatterns,dedupe:r=["lit","lit-element","lit-html"],dev:o=!1}=t,i=[...sn.modulePaths,...e],s=process.cwd(),a=z.map(c=>ba(s,c));return[va({dedupe:r,preferBuiltins:!1,moduleDirectories:sn.moduleDirectories,modulePaths:a}),wa(),$a({minify:o?!1:{fast:!0},options:{loadPaths:[...i,Br(process.cwd(),"src","styles"),Br(process.cwd(),"src")]}}),Gr(n)]}function an(e={}){let{modulePaths:t=[],watch:n=!1,input:r=["./src/index.js","./src/registered.js"],outputDir:o="./dist",format:i="esm",dev:s=!1}=e;return{name:"Main",config:{input:r,output:{format:i,dir:o,entryFileNames:a=>s||["index","registered"].includes(a.name)?"[name].js":"[name]-[hash].js",chunkFileNames:s?"[name].js":"[name]-[hash].js",assetFileNames:s?"[name][extname]":"[name]-[hash][extname]"},external:Ea(),plugins:Wr(t,{dev:s}),watch:Ur(n)}}}function De(e={}){let{modulePaths:t=[],watch:n=!1,globPattern:r="./demo/*.js",ignorePattern:o=["./demo/*.min.js"],outputDir:i="./demo",dev:s=!1}=e,a=ka.sync(r,{ignore:o}),c=Wr(t,{dev:s}),l=Ur(n);return{name:"Demo",configs:a.map(m=>({input:{[ya(m,".js")]:m},output:{format:"esm",dir:i,entryFileNames:"[name].min.js",chunkFileNames:"[name].min.js",assetFileNames:s?"[name][extname]":"[name]-[hash][extname]",inlineDynamicImports:!0},plugins:c,onwarn(d,f){if(d.code==="UNRESOLVED_IMPORT")throw new Error(`Unresolved import "${d.exporter??d.source}" in ${d.id??m}. Make sure workspace dependencies are built before bundling demos.`);f(d)},watch:l}))}}function Ur(e){if(!e)return!1;let t=typeof e=="object"?e:{};return{clearScreen:t.clearScreen??!0,buildDelay:t.buildDelay??500,chokidar:{ignoreInitial:!0,ignored:t.ignored??["**/dist/**/*.d.ts","**/custom-elements.json","**/demo/*.md","**/demo/**/*.min.js","**/demo/**/*.min.css","**/docs/api.md","**/node_modules/**","**/.git/**"],awaitWriteFinish:t.awaitWriteFinish??{stabilityThreshold:1e3,pollInterval:100}},include:t.include??["./src/**/*.scss","./src/**/*.js","./src/**/*.ts","./demo/**/*.js","./apiExamples/**/*","./docs/**/*.md"],exclude:t.exclude??["./dist/**/*","./node_modules/**/*"]}}function Ea(e=[]){return[...[/node_modules\/lit/,/node_modules\/lit-element/,/node_modules\/lit-html/,/node_modules\/@lit/],...e]}function Vr(){let e=Me("./dist"),t=ln("Cleaning dist folder...").start();try{return Ca(e,{recursive:!0,force:!0}),t.succeed("All clean! Dist folder wiped."),!0}catch(n){return t.fail(`Oops! Couldn't clean dist/ folder: ${n.message}`),console.error(n),!1}}async function st(e,t,n,r){let o=ln(e).start();try{let i=await t();return o.succeed(n),i}catch(i){throw o.fail(r),console.error(`Error: ${i.message}`),i}}async function Kr(e,t){return st(`Bundling ${e.name||"main"} and demo...`,async()=>{let n=await cn(e);await n.write(e.output),await n.close();for(let r of t){let o=await cn(r);await o.write(r.output),await o.close()}},`Bundles ready! ${e.name||"Main"} and demo built.`,"Bundle hiccup! Build failed.")}async function it(e){let{wcaInput:t,wcaOutput:n,skipDocs:r}=e;if(r){let o=ln("Skipping docs generation...").start();setTimeout(()=>{o.succeed("Docs generation skipped.")},0);return}return st("Analyzing components and making docs...",async()=>{await rt(t,n),await Te(e),Xe()},"Docs ready! Looking good.","Doc troubles!")}function Pa(){let e=process.cwd();function t(o){return[o,`${o}.scss`,`${o}.css`,Me(Ta(o),`_${xa(o)}.scss`),Me(o,"_index.scss"),Me(o,"index.scss")].find(s=>Hr(s))}function n(o){for(let s of z){let a=t(ot(e,s,o));if(a)return a}let i=r(o);return i||null}function r(o){let i,s;if(o.startsWith("@")){let a=o.split("/");if(a.length<3)return null;i=`${a[0]}/${a[1]}`,s=`./${a.slice(2).join("/")}`}else{let a=o.indexOf("/");if(a===-1)return null;i=o.slice(0,a),s=`./${o.slice(a+1)}`}for(let a of z){let c=ot(e,a,i,"package.json");if(Hr(c))try{let u=JSON.parse(Sa(c,"utf-8")).exports;if(!u||typeof u!="object")continue;let m=u[s];if(!m)continue;let p=typeof m=="string"?m:m.default||m.import;if(!p)continue;let d=t(ot(e,a,i,p));if(d)return d}catch{continue}}return null}return{findFileUrl(o){if(o.includes("/node_modules/")){let i=o.lastIndexOf("/node_modules/"),s=o.slice(i+14),a=n(s);if(a)return Jr(a)}if(!o.startsWith(".")&&!o.startsWith("/")&&!o.startsWith("file:")){let i=n(o);if(i)return Jr(i)}return null}}}async function re(e="./demo"){return st("Compiling demo SCSS...",async()=>{let t=Ra.sync(Me(e,"**/*.scss")),n=Pa(),r=process.cwd(),o=z.map(i=>ot(r,i));for(let i of t){let s=zr.compile(i,{importers:[n],loadPaths:o,silenceDeprecations:["import"],style:"compressed"}),a=i.replace(/\.scss$/,".min.css");Aa(a,s.css)}return t.length},"Demo SCSS compiled.","SCSS compilation failed.")}async function Lr(e={}){let{configs:t}=De(e);return st("Bundling demo JS...",async()=>{for(let n of t){let r=await cn(n);await r.write(n.output),await r.close()}},"Demo JS bundled.","Demo JS bundling failed.")}import qr from"node:path";import oe from"ora";import"rollup";var Ne=!1,Da={analyze:{active:!1,lastTime:0},docs:{active:!1,lastTime:0},scss:{active:!1,lastTime:0}},Ma=5e3,at=new Set,Na=["/dist/index.d.ts","/custom-elements.json","/demo/api.md","/docs/api.md","/demo/index.min.js"];function Ia(e){if(!e||typeof e!="string")return!1;try{let t=qr.normalize(e);return Na.some(n=>t.endsWith(n))||t.includes("/dist/")||t.endsWith(".min.js")||t.endsWith(".min.css")||t.endsWith(".d.ts")}catch(t){return console.error(`Error checking path (${typeof e}):`,t.message),!1}}async function un(e,t){let n=Da[e];if(n.active||Date.now()-n.lastTime<Ma)return!1;try{return n.active=!0,n.lastTime=Date.now(),await t()}catch(r){return console.error(`Error in ${e} task:`,r),!1}finally{n.active=!1}}async function Yr(e,t,n,{analyze:r=rt,docs:o=it,scss:i=re}={}){let s=!0,a={analyze:!1,docs:!1,scss:!1},c=null,l,u=oe("Activating watch mode...").start(),m={analyze:async()=>{let{wcaInput:f,wcaOutput:h,skipDocs:g}=t;if(g){let v=oe("Skipping component analysis...").start();return setTimeout(()=>{v.succeed("Component analysis skipped.")},0),!0}let y=oe("Detective work: analyzing components...").start();try{return await r(f,h),y.succeed("Component analysis complete! API generated."),!0}catch(v){return y.fail("Analysis hiccup! Something went wrong."),console.error("Component analysis error:",v),!1}},docs:async()=>{if(Ne)return!1;if(t.skipDocs){let h=oe("Skipping docs generation...").start();return setTimeout(()=>{h.succeed("Docs generation skipped.")},0),!0}let f=oe("Refreshing docs...").start();try{await o(t),f.succeed("Documentation refreshed!")}catch(h){f.fail("Docs stumble! Couldn't refresh."),console.error("Documentation rebuild error:",h)}return!0},scss:async()=>{if(Ne)return!1;try{return await i(),!0}catch(f){return console.error("Demo SCSS compilation error:",f),!1}}},p=()=>{s&&a.analyze&&a.docs&&a.scss&&typeof n=="function"&&(s=!1,n())};function d(f=1e3){c&&clearTimeout(c),c=setTimeout(async()=>{setTimeout(async()=>{a.analyze=await un("analyze",m.analyze),setTimeout(async()=>{a.docs=await un("docs",m.docs),setTimeout(async()=>{a.scss=await un("scss",m.scss),p()},500)},1e3)},1e3)},f)}e.on("event",async f=>{switch(f.code){case"START":u.succeed("Watch mode active! Eyes peeled.");break;case"BUNDLE_START":if(at.clear(),f.input)try{let h=Array.isArray(f.input)?f.input:typeof f.input=="string"?[f.input]:typeof f.input=="object"&&f.input!==null?Object.values(f.input):[];for(let g of h)typeof g=="string"&&!Ia(g)&&at.add(qr.normalize(g))}catch(h){console.error("Error processing input paths:",h)}l=oe("Weaving bundles...").start(),Ne=!0;break;case"BUNDLE_END":l&&l.succeed(`Bundle ${Array.isArray(f.input)?`of ${f.input.join("& ")} `:""}done in ${f.duration}ms! \u{1F680}`),Ne=!1,at.size>0&&d();break;case"END":break;case"ERROR":Ne=!1,l?l.fail(`Oops! Bundle hit a snag: ${f.error.message}`):oe().fail(`Watch mode hiccup: ${f.error.message}`),at.clear();break}})}function Xr(e,t){return xe(e),t&&xe(t),Ze(),e}async function _a(e){let t=an(e),n=De(e);e.dev||t.config.plugins.push(Oa()),await it(e),await re(),await Kr(t.config,n.configs)}async function Fa(e){let{dev:t}=e,n=an({...e,watch:!0}),r=De({...e,watch:!0}),o=ja([n.config,...r.configs]);Yr(o,e,t?async()=>et(e):void 0);let i=await import("chokidar"),s=!1,a=!1,c=null,l=i.watch("./demo/**/*.scss",{ignoreInitial:!0,ignored:["**/demo/**/*.min.css"],awaitWriteFinish:{stabilityThreshold:500,pollInterval:100}});return l.on("all",()=>{c&&clearTimeout(c),c=setTimeout(async()=>{if(s){a=!0;return}s=!0;try{await re()}catch(u){console.error("Demo SCSS watch compilation error:",u)}finally{s=!1,a&&(a=!1,l.emit("all"))}},500)}),Xr(o,l),o}async function ct(e={}){try{let{watch:t}=e;return Vr(),t?await Fa(e):await _a(e)}catch(t){throw new Error(`Build failed: ${t.message}`)}}var Ie=La.command("dev").description("Runs development server for auro components");Ie=ze(Ie);Ie=Ve(Ie);var zf=Ie.action(async e=>{try{let t=Zr("Initializing...");e.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=e.docs===!1?"Building component (docs disabled)":"Building component",t.start(),e.watch||t.succeed("Build completed!"),await ct({...e,dev:!0,watch:e.watch})}catch(t){Zr().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{program as Ga}from"commander";import Qr from"ora";var mn=Ga.command("build").description("Builds auro components");mn=ze(mn);var Zf=mn.action(async e=>{try{let t=Qr("Initializing...");e.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=e.docs===!1?"Building component (docs disabled)":"Building component",t.start(),await ct(e),e.watch||t.succeed("Build completed!")}catch(t){Qr().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{exec as Ba}from"node:child_process";import eo from"node:path";import Wa from"node:process";import{fileURLToPath as Ua}from"node:url";import Ha from"node:util";import{program as Ja}from"commander";import za from"inquirer";var cg=Ja.command("migrate").description("Script runner to perform repetitive code change tasks").requiredOption("-i, --id <string>","Select the migration you would like to run by id").option("-m, --multi-gitter","Run the migration on all repositories in the multi-gitter config").action(async e=>{let t=Ua(import.meta.url),n=eo.dirname(t),r=eo.resolve(n,"migrations",e.id);if(e.multiGitter){let o=Ha.promisify(Ba);try{await o("command -v multi-gitter")}catch{console.error("multi-gitter is not installed."),Wa.exit(1)}(await za.prompt([{type:"confirm",name:"dryRun",message:"Run migration in dry-run mode? (no changes will be committed)",default:!0}])).dryRun?_(`multi-gitter run ${r}/script.sh --config "${r}/multi-gitter.yml" --dry-run`):_(`multi-gitter run ${r}/script.sh --config "${r}/multi-gitter.yml"`)}else _(`${r}/script.sh`)});import so from"node:process";import{program as Xa}from"commander";import{readFile as Za,writeFile as Qa}from"node:fs/promises";import{Logger as Oe}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import pn from"node:fs/promises";import dn from"node:path";import{Octokit as Va}from"@octokit/rest";import L from"ora";import{processContentForFile as Ka,templateFiller as qa}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";async function to(e,t){let n=new Va({auth:process.env.GITHUB_TOKEN||""});try{let o=(await n.request("GET /repos/{owner}/{repo}/contents/{path}",{ref:t,owner:"AlaskaAirlines",repo:"auro-templates",path:e,headers:{"X-GitHub-Api-Version":"2022-11-28"}})).data;if(typeof o!="object"||!Array.isArray(o)){let i=`Unexpected response format: ${JSON.stringify(o)}`;throw L().start().fail(i),new Error("Failed to retrieve folder items")}return o}catch(r){let o=L().start();throw r.status===404?o.fail(`Template '${e.split("/")[1]}' not found`):o.fail(`Error accessing template: ${r.message}`),r}}async function no({folderItems:e,templatePathToReplace:t,rootDir:n,ref:r}){let o=[];for(let i of e){if(i.type=="dir"){let l=L(`Processing directory: ${i.path}`).start(),u=await to(i.path,r);l.succeed(`Found ${u.length} additional items in ${i.path}`);let m=await no({folderItems:u,templatePathToReplace:t,rootDir:n,ref:r});o.push(...m);continue}let s=i.path.replace(`${t}/`,""),a=`${n}/.github/${s}`,c={identifier:i.name,input:{remoteUrl:i.download_url||"",fileName:a,overwrite:!0},output:a};o.push(c)}return o}async function Ya(e){try{await pn.rm(e,{recursive:!0,force:!0}),L().start().succeed(`Successfully removed directory: ${e}`)}catch(t){throw L().start().fail(`Error removing directory ${e}: ${t.message}`),t}}async function ro(e,t="",n=!0){try{let r=await pn.stat(e),o=dn.basename(e);if(!r.isDirectory())return`${t}${n?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}
|
|
21
|
+
<!-- AURO-GENERATED-CONTENT:END -->`}r=r.replace(d,()=>A),o.lastIndex=0,s=!0}else c.includes(h)||c.push(h)}if(c.length>0)throw new Error(`Included file(s) not found: ${c.join(", ")}`);s&&await L.promises.writeFile(e,r),r=await L.promises.readFile(e,"utf8");let l=/^[ \t]*```(\w*)\n([\s\S]*?)^[ \t]*```[ \t]*$/gm,u=r.replace(l,(d,f,h)=>{let g=f||"html",y=h.trimEnd().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return`<pre class="language-${g}"><code class="language-${g}">${y}
|
|
22
|
+
</code></pre>`});u!==r&&await L.promises.writeFile(e,u),r=await L.promises.readFile(e,"utf8"),r=r.replace(/(<pre[^>]*><code[^>]*>)([\s\S]*?)(<\/code><\/pre>)/g,(d,f,h,g)=>{let y=h.split(/\r?\n/),v=y.filter(b=>b.trim().length>0);if(v.length===0)return d;let _=Math.min(...v.map(b=>{let w=b.match(/^[ \t]*/);return w?w[0].length:0})),A=y.map(b=>_>0?b.substring(_):b);for(;A.length>0&&A[A.length-1].trim()==="";)A.pop();let k=A.map((b,w)=>w===A.length-1?b:`${b}${b.trim()===""?" ":`
|
|
23
|
+
`}`).join("");return f+k+g});let p=r.split(`
|
|
24
|
+
`),m=!1;for(let d=0;d<p.length;d++)/<pre[\s>]/i.test(p[d])&&(m=!0),m||(p[d]=p[d].replace(/^[ \t]+(?=<)/,"")),/<\/pre>/i.test(p[d])&&(m=!1);await L.promises.writeFile(e,p.join(`
|
|
25
|
+
`))}async function Pe(e={}){let t=e.readmeTemplate,n=t&&!t.startsWith("http");await Qi({...Dr,...n?{localReadmePath:U.resolve(process.cwd(),t)}:{remoteReadmeUrl:t||"https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/README.md"}},e.skipReadme)}function Pr(e){return L.existsSync(I(e))}import{existsSync as Ir,readFileSync as ia}from"node:fs";import{builtinModules as aa}from"node:module";import{resolve as et}from"node:path";import{startDevServer as ca}from"@web/dev-server";import{hmrPlugin as la}from"@web/dev-server-hmr";import*as Or from"esbuild";import ua from"ora";var V=["node_modules","../node_modules","../../node_modules","../../../node_modules"];var ma=/^\/__wds-outside-root__\/(\d+)\/(.+)$/;function pa(){return{name:"node-modules-css",serve(e){if(!e.path.endsWith(".css")||!e.path.startsWith("/@")&&!/^\/[a-z]/i.test(e.path))return;let t=e.path.slice(1),n=process.cwd();for(let r of V){let o=et(n,r,t);if(Ir(o))return{body:ia(o,"utf-8"),type:"css"}}}}}function da(e,t){let n=e.match(ma);return n?et(t,"../".repeat(Number.parseInt(n[1],10)),n[2]):et(t,`.${e}`)}function fa(){let e=/\b(require\s*\(|module\.exports\b|exports\.\w)/,t=new Map,n;return{name:"cjs-to-esm",async serverStart({config:r}){n=et(r.rootDir)},async transform(r){if(!r.path.includes("node_modules")||!r.path.endsWith(".js")&&!r.path.endsWith(".cjs")||typeof r.body!="string"||!e.test(r.body))return;let o=da(r.path,n);if(t.has(o))return t.get(o);if(Ir(o))try{let s={body:(await Or.build({entryPoints:[o],bundle:!0,format:"esm",platform:"browser",write:!1,logLevel:"silent",external:aa})).outputFiles[0].text};return t.set(o,s),s}catch(i){console.error(`CJS-to-ESM bundling failed for ${r.path}:`,i.message)}}}}var De={watch:!0,nodeResolve:!0,basePath:"/",rootDir:"./demo",hmrInclude:["src/**/*","demo/**/*","apiExamples/**/*","docs/**/*"]};async function tt(e={}){if(!e.serve)return;let t=ua(`Firing up dev server...
|
|
26
|
+
`).start();try{let n={port:Number(e.port)||void 0,open:e.open?"/":void 0,watch:e.watch??De.watch,nodeResolve:e.nodeResolve??De.nodeResolve,basePath:e.basePath??De.basePath,rootDir:e.rootDir??De.rootDir,middleware:[function(i,s){return!i.url.endsWith("/")&&!i.url.includes(".")&&(i.url+=".html"),s()}],plugins:[pa(),fa(),la({include:e.hmrInclude??De.hmrInclude})]},r=await ca({config:n,readCliArgs:!1,readFileConfig:!1});return t.stop(),r}catch(n){throw t.fail("Server snag! Couldn't start dev server."),console.error("Error starting development server:",n),new Error(`Development server failed to start: ${n.message}`)}}async function nt(){let e=Me("Generating Custom Elements Manifest...").start();try{await F(`npx --package=@custom-elements-manifest/analyzer -y -- cem analyze --config '${Cr("custom-elements-manifest.config.mjs")}'`),e.succeed("Custom Elements Manifest generated successfully!")}catch(t){let n=t instanceof Error?t.message:String(t);e.warn("CEM analyzer completed with warnings: "+n)}}async function rt({manifestPath:e}={}){let t=Me("Generating API md file...").start();try{await Te.generate(e?{manifestPath:e}:{}),t.succeed("API md file generated successfully!")}catch(n){let r=n instanceof Error?n.message:String(n);throw t.fail("Failed to generate API md file: "+r),n}}async function jr(e={},{build:t=Pe,demo:n=_r}={}){let r=Me("Compiling documentation...").start(),o;try{await t(e),r.succeed("Documentation compiled successfully!")}catch(i){let s=i instanceof Error?i.message:String(i);r.fail("Failed to compile MD documentation: "+s),o=i}if(await n(e),o)throw o}async function _r(e={}){Ze(),await oe(),await Gr(e)}async function Fr(e={}){await tt(e)}async function Lr(e={}){let t=await import("chokidar"),n=["./src/**/*","./docs/**/*","./docTemplates/**/*","./apiExamples/**/*","./demo/**/*.scss"],r=["**/demo/*.min.js","**/demo/*.min.css","**/demo/*.md","**/demo/readme.md","**/docs/api.md","**/custom-elements.json","**/node_modules/**","**/dist/**","**/.git/**"],o=t.watch(n,{ignoreInitial:!0,ignored:r,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100}}),i=Me("Waiting for changes...");i.spinner="bouncingBar",i.color="green",i.start();let s=null,a=!1,c=!1;async function l(u){if(a){c=!0;return}a=!0,o.unwatch(n);let p=Me(`Change detected: ${u}`).start();try{let m;try{await Pe(e)}catch(d){m=d}if(await _r(e),m)throw m;p.succeed("Docs rebuilt!")}catch(m){let d=m instanceof Error?m.message:String(m);p.fail("Rebuild failed: "+d)}finally{setTimeout(()=>{o.add(n),a=!1,c&&(c=!1,l("queued changes"))},1e3)}}o.on("all",(u,p)=>{a||(s&&clearTimeout(s),s=setTimeout(()=>{l(p)},1e3))}),Re(o),Qe()}async function ot(){await nt(),await rt()}import{basename as ya,join as Wr,resolve as ba}from"node:path";import wa from"@rollup/plugin-commonjs";import{nodeResolve as va}from"@rollup/plugin-node-resolve";import{glob as ka}from"glob";import{litScss as $a}from"rollup-plugin-scss-lit";import ga from"node:path";import{glob as ha}from"glob";function Br(e){return{name:"watch-globs",buildStart(){let t=Array.isArray(e)?e:[e];for(let n of t)try{for(let r of ha.sync(ga.resolve(n)))this.addWatchFile(r)}catch(r){this.error(`Error watching glob pattern "${n}": ${r.message}`)}}}}var an={moduleDirectories:["node_modules"],modulePaths:["../../node_modules","../node_modules","node_modules"],watchPatterns:["./apiExamples/**/*","./docs/**/*"]};function Ur(e=[],t={}){let{watchPatterns:n=an.watchPatterns,dedupe:r=["lit","lit-element","lit-html"],dev:o=!1}=t,i=[...an.modulePaths,...e],s=process.cwd(),a=V.map(c=>ba(s,c));return[va({dedupe:r,preferBuiltins:!1,moduleDirectories:an.moduleDirectories,modulePaths:a}),wa(),$a({minify:o?!1:{fast:!0},options:{loadPaths:[...i,Wr(process.cwd(),"src","styles"),Wr(process.cwd(),"src")]}}),Br(n)]}function cn(e={}){let{modulePaths:t=[],watch:n=!1,input:r=["./src/index.js","./src/registered.js"],outputDir:o="./dist",format:i="esm",dev:s=!1}=e;return{name:"Main",config:{input:r,output:{format:i,dir:o,entryFileNames:a=>s||["index","registered"].includes(a.name)?"[name].js":"[name]-[hash].js",chunkFileNames:s?"[name].js":"[name]-[hash].js",assetFileNames:s?"[name][extname]":"[name]-[hash][extname]"},external:Ea(),plugins:Ur(t,{dev:s}),watch:Hr(n)}}}function Ne(e={}){let{modulePaths:t=[],watch:n=!1,globPattern:r="./demo/*.js",ignorePattern:o=["./demo/*.min.js"],outputDir:i="./demo",dev:s=!1}=e,a=ka.sync(r,{ignore:o}),c=Ur(t,{dev:s}),l=Hr(n);return{name:"Demo",configs:a.map(p=>({input:{[ya(p,".js")]:p},output:{format:"esm",dir:i,entryFileNames:"[name].min.js",chunkFileNames:"[name].min.js",assetFileNames:s?"[name][extname]":"[name]-[hash][extname]",inlineDynamicImports:!0},plugins:c,onwarn(d,f){if(d.code==="UNRESOLVED_IMPORT")throw new Error(`Unresolved import "${d.exporter??d.source}" in ${d.id??p}. Make sure workspace dependencies are built before bundling demos.`);f(d)},watch:l}))}}function Hr(e){if(!e)return!1;let t=typeof e=="object"?e:{};return{clearScreen:t.clearScreen??!0,buildDelay:t.buildDelay??500,chokidar:{ignoreInitial:!0,ignored:t.ignored??["**/dist/**/*.d.ts","**/custom-elements.json","**/demo/*.md","**/demo/**/*.min.js","**/demo/**/*.min.css","**/docs/api.md","**/node_modules/**","**/.git/**"],awaitWriteFinish:t.awaitWriteFinish??{stabilityThreshold:1e3,pollInterval:100}},include:t.include??["./src/**/*.scss","./src/**/*.js","./src/**/*.ts","./demo/**/*.js","./apiExamples/**/*","./docs/**/*.md"],exclude:t.exclude??["./dist/**/*","./node_modules/**/*"]}}function Ea(e=[]){return[...[/node_modules\/lit/,/node_modules\/lit-element/,/node_modules\/lit-html/,/node_modules\/@lit/],...e]}function Kr(){let e=Ie("./dist"),t=un("Cleaning dist folder...").start();try{return Ca(e,{recursive:!0,force:!0}),t.succeed("All clean! Dist folder wiped."),!0}catch(n){return t.fail(`Oops! Couldn't clean dist/ folder: ${n.message}`),console.error(n),!1}}async function it(e,t,n,r){let o=un(e).start();try{let i=await t();return o.succeed(n),i}catch(i){throw o.fail(r),console.error(`Error: ${i.message}`),i}}async function qr(e,t){return it(`Bundling ${e.name||"main"} and demo...`,async()=>{let n=await ln(e);await n.write(e.output),await n.close();for(let r of t){let o=await ln(r);await o.write(r.output),await o.close()}},`Bundles ready! ${e.name||"Main"} and demo built.`,"Bundle hiccup! Build failed.")}async function at(e){let{wcaInput:t,wcaOutput:n,skipDocs:r}=e;if(r){let o=un("Skipping docs generation...").start();setTimeout(()=>{o.succeed("Docs generation skipped.")},0);return}return it("Analyzing components and making docs...",async()=>{await ot(t,n),await Pe(e),Ze()},"Docs ready! Looking good.","Doc troubles!")}function Pa(){let e=process.cwd();function t(o){return[o,`${o}.scss`,`${o}.css`,Ie(Ta(o),`_${xa(o)}.scss`),Ie(o,"_index.scss"),Ie(o,"index.scss")].find(s=>Jr(s))}function n(o){for(let s of V){let a=t(st(e,s,o));if(a)return a}let i=r(o);return i||null}function r(o){let i,s;if(o.startsWith("@")){let a=o.split("/");if(a.length<3)return null;i=`${a[0]}/${a[1]}`,s=`./${a.slice(2).join("/")}`}else{let a=o.indexOf("/");if(a===-1)return null;i=o.slice(0,a),s=`./${o.slice(a+1)}`}for(let a of V){let c=st(e,a,i,"package.json");if(Jr(c))try{let u=JSON.parse(Sa(c,"utf-8")).exports;if(!u||typeof u!="object")continue;let p=u[s];if(!p)continue;let m=typeof p=="string"?p:p.default||p.import;if(!m)continue;let d=t(st(e,a,i,m));if(d)return d}catch{continue}}return null}return{findFileUrl(o){if(o.includes("/node_modules/")){let i=o.lastIndexOf("/node_modules/"),s=o.slice(i+14),a=n(s);if(a)return zr(a)}if(!o.startsWith(".")&&!o.startsWith("/")&&!o.startsWith("file:")){let i=n(o);if(i)return zr(i)}return null}}}async function oe(e="./demo"){return it("Compiling demo SCSS...",async()=>{let t=Ra.sync(Ie(e,"**/*.scss")),n=Pa(),r=process.cwd(),o=V.map(i=>st(r,i));for(let i of t){let s=Vr.compile(i,{importers:[n],loadPaths:o,silenceDeprecations:["import"],style:"compressed"}),a=i.replace(/\.scss$/,".min.css");Aa(a,s.css)}return t.length},"Demo SCSS compiled.","SCSS compilation failed.")}async function Gr(e={}){let{configs:t}=Ne(e);return it("Bundling demo JS...",async()=>{for(let n of t){let r=await ln(n);await r.write(n.output),await r.close()}},"Demo JS bundled.","Demo JS bundling failed.")}import Yr from"node:path";import se from"ora";import"rollup";var Oe=!1,Da={analyze:{active:!1,lastTime:0},docs:{active:!1,lastTime:0},scss:{active:!1,lastTime:0}},Ma=5e3,ct=new Set,Na=["/dist/index.d.ts","/custom-elements.json","/demo/api.md","/docs/api.md","/demo/index.min.js"];function Ia(e){if(!e||typeof e!="string")return!1;try{let t=Yr.normalize(e);return Na.some(n=>t.endsWith(n))||t.includes("/dist/")||t.endsWith(".min.js")||t.endsWith(".min.css")||t.endsWith(".d.ts")}catch(t){return console.error(`Error checking path (${typeof e}):`,t.message),!1}}async function mn(e,t){let n=Da[e];if(n.active||Date.now()-n.lastTime<Ma)return!1;try{return n.active=!0,n.lastTime=Date.now(),await t()}catch(r){return console.error(`Error in ${e} task:`,r),!1}finally{n.active=!1}}async function Xr(e,t,n,{analyze:r=ot,docs:o=at,scss:i=oe}={}){let s=!0,a={analyze:!1,docs:!1,scss:!1},c=null,l,u=se("Activating watch mode...").start(),p={analyze:async()=>{let{wcaInput:f,wcaOutput:h,skipDocs:g}=t;if(g){let v=se("Skipping component analysis...").start();return setTimeout(()=>{v.succeed("Component analysis skipped.")},0),!0}let y=se("Detective work: analyzing components...").start();try{return await r(f,h),y.succeed("Component analysis complete! API generated."),!0}catch(v){return y.fail("Analysis hiccup! Something went wrong."),console.error("Component analysis error:",v),!1}},docs:async()=>{if(Oe)return!1;if(t.skipDocs){let h=se("Skipping docs generation...").start();return setTimeout(()=>{h.succeed("Docs generation skipped.")},0),!0}let f=se("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(Oe)return!1;try{return await i(),!0}catch(f){return console.error("Demo SCSS compilation error:",f),!1}}},m=()=>{s&&a.analyze&&a.docs&&a.scss&&typeof n=="function"&&(s=!1,n())};function d(f=1e3){c&&clearTimeout(c),c=setTimeout(async()=>{setTimeout(async()=>{a.analyze=await mn("analyze",p.analyze),setTimeout(async()=>{a.docs=await mn("docs",p.docs),setTimeout(async()=>{a.scss=await mn("scss",p.scss),m()},500)},1e3)},1e3)},f)}e.on("event",async f=>{switch(f.code){case"START":u.succeed("Watch mode active! Eyes peeled.");break;case"BUNDLE_START":if(ct.clear(),f.input)try{let h=Array.isArray(f.input)?f.input:typeof f.input=="string"?[f.input]:typeof f.input=="object"&&f.input!==null?Object.values(f.input):[];for(let g of h)typeof g=="string"&&!Ia(g)&&ct.add(Yr.normalize(g))}catch(h){console.error("Error processing input paths:",h)}l=se("Weaving bundles...").start(),Oe=!0;break;case"BUNDLE_END":l&&l.succeed(`Bundle ${Array.isArray(f.input)?`of ${f.input.join("& ")} `:""}done in ${f.duration}ms! \u{1F680}`),Oe=!1,ct.size>0&&d();break;case"END":break;case"ERROR":Oe=!1,l?l.fail(`Oops! Bundle hit a snag: ${f.error.message}`):se().fail(`Watch mode hiccup: ${f.error.message}`),ct.clear();break}})}function Zr(e,t){return Re(e),t&&Re(t),Qe(),e}async function _a(e){let t=cn(e),n=Ne(e);e.dev||t.config.plugins.push(Oa()),await at(e),await oe(),await qr(t.config,n.configs)}async function Fa(e){let{dev:t}=e,n=cn({...e,watch:!0}),r=Ne({...e,watch:!0}),o=ja([n.config,...r.configs]);Xr(o,e,t?async()=>tt(e):void 0);let i=await import("chokidar"),s=!1,a=!1,c=null,l=i.watch("./demo/**/*.scss",{ignoreInitial:!0,ignored:["**/demo/**/*.min.css"],awaitWriteFinish:{stabilityThreshold:500,pollInterval:100}});return l.on("all",()=>{c&&clearTimeout(c),c=setTimeout(async()=>{if(s){a=!0;return}s=!0;try{await oe()}catch(u){console.error("Demo SCSS watch compilation error:",u)}finally{s=!1,a&&(a=!1,l.emit("all"))}},500)}),Zr(o,l),o}async function lt(e={}){try{let{watch:t}=e;return Kr(),t?await Fa(e):await _a(e)}catch(t){throw new Error(`Build failed: ${t.message}`)}}var je=La.command("dev").description("Runs development server for auro components");je=Ke(je);je=qe(je);var zf=je.action(async e=>{try{let t=Qr("Initializing...");e.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=e.docs===!1?"Building component (docs disabled)":"Building component",t.start(),e.watch||t.succeed("Build completed!"),await lt({...e,dev:!0,watch:e.watch})}catch(t){Qr().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{program as Ga}from"commander";import eo from"ora";var pn=Ga.command("build").description("Builds auro components");pn=Ke(pn);var Zf=pn.action(async e=>{try{let t=eo("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 lt(e),e.watch||t.succeed("Build completed!")}catch(t){eo().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{exec as Ba}from"node:child_process";import to from"node:path";import Wa from"node:process";import{fileURLToPath as Ua}from"node:url";import Ha from"node:util";import{program as Ja}from"commander";import za from"inquirer";var cg=Ja.command("migrate").description("Script runner to perform repetitive code change tasks").requiredOption("-i, --id <string>","Select the migration you would like to run by id").option("-m, --multi-gitter","Run the migration on all repositories in the multi-gitter config").action(async e=>{let t=Ua(import.meta.url),n=to.dirname(t),r=to.resolve(n,"migrations",e.id);if(e.multiGitter){let o=Ha.promisify(Ba);try{await o("command -v multi-gitter")}catch{console.error("multi-gitter is not installed."),Wa.exit(1)}(await za.prompt([{type:"confirm",name:"dryRun",message:"Run migration in dry-run mode? (no changes will be committed)",default:!0}])).dryRun?F(`multi-gitter run ${r}/script.sh --config "${r}/multi-gitter.yml" --dry-run`):F(`multi-gitter run ${r}/script.sh --config "${r}/multi-gitter.yml"`)}else F(`${r}/script.sh`)});import io from"node:process";import{program as Xa}from"commander";import{readFile as Za,writeFile as Qa}from"node:fs/promises";import{Logger as _e}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import dn from"node:fs/promises";import fn from"node:path";import{Octokit as Va}from"@octokit/rest";import G from"ora";import{processContentForFile as Ka,templateFiller as qa}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";async function no(e,t){let n=new Va({auth:process.env.GITHUB_TOKEN||""});try{let o=(await n.request("GET /repos/{owner}/{repo}/contents/{path}",{ref:t,owner:"AlaskaAirlines",repo:"auro-templates",path:e,headers:{"X-GitHub-Api-Version":"2022-11-28"}})).data;if(typeof o!="object"||!Array.isArray(o)){let i=`Unexpected response format: ${JSON.stringify(o)}`;throw G().start().fail(i),new Error("Failed to retrieve folder items")}return o}catch(r){let o=G().start();throw r.status===404?o.fail(`Template '${e.split("/")[1]}' not found`):o.fail(`Error accessing template: ${r.message}`),r}}async function ro({folderItems:e,templatePathToReplace:t,rootDir:n,ref:r}){let o=[];for(let i of e){if(i.type=="dir"){let l=G(`Processing directory: ${i.path}`).start(),u=await no(i.path,r);l.succeed(`Found ${u.length} additional items in ${i.path}`);let p=await ro({folderItems:u,templatePathToReplace:t,rootDir:n,ref:r});o.push(...p);continue}let s=i.path.replace(`${t}/`,""),a=`${n}/.github/${s}`,c={identifier:i.name,input:{remoteUrl:i.download_url||"",fileName:a,overwrite:!0},output:a};o.push(c)}return o}async function Ya(e){try{await dn.rm(e,{recursive:!0,force:!0}),G().start().succeed(`Successfully removed directory: ${e}`)}catch(t){throw G().start().fail(`Error removing directory ${e}: ${t.message}`),t}}async function oo(e,t="",n=!0){try{let r=await dn.stat(e),o=fn.basename(e);if(!r.isDirectory())return`${t}${n?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}
|
|
27
27
|
`;let i=`${t}${n?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}/
|
|
28
|
-
`;try{let a=(await
|
|
28
|
+
`;try{let a=(await dn.readdir(e)).sort();for(let c=0;c<a.length;c++){let l=a[c],u=fn.join(e,l),p=c===a.length-1,m=t+(n?" ":"\u2502 ");i+=await oo(u,m,p)}}catch{i+=`${t}${n?" ":"\u2502 "}\u2514\u2500\u2500 [Permission denied or error reading directory]
|
|
29
29
|
`}return i}catch(r){return`${t}${n?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}[Error: ${r}]
|
|
30
|
-
`}}async function
|
|
30
|
+
`}}async function so(e,t="main",n="default"){if(!e)throw G().start().fail("Root directory must be specified"),new Error("Root directory must be specified");if(await qa.extractNames(),!process.env.GITHUB_TOKEN)throw G().start().fail("GITHUB_TOKEN environment variable is not set."),new Error("GITHUB_TOKEN environment variable is not set");let r=`templates/${n}/.github`,o=await no(r,t),i=".github",s=G("Removing existing .github directory...").start();try{await Ya(i),s.succeed(".github directory removed successfully")}catch(l){throw s.fail(`Error removing .github directory: ${l.message}`),new Error(`Failed to remove .github directory: ${l.message}`)}let a=await ro({folderItems:o,templatePathToReplace:r,rootDir:e,ref:t}),c=G("Processing all files...").start();try{await Promise.all(a.map(u=>Ka(u))),c.succeed("All files processed.");let l=G("Generating directory tree...").start();try{let u=fn.join(e,".github"),p=await oo(u);l.succeed("Synced .github directory structure:"),console.log(p)}catch(u){l.fail(`Error generating directory tree: ${u.message}`)}}catch(l){throw c.fail(`Error processing files: ${l.message}`),new Error(`Failed to process files: ${l.message}`)}}var kg=Xa.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=>{_e.info("Synchronizing repository configuration files..."),_e.warn("Note: sync does not create a new git branch. Changes are added to the current branch.");let t=io.cwd();try{await so(t,e.ref,e.template);try{let n=`${t}/.github/CODEOWNERS`,o=(await Za(n,{encoding:"utf-8"})).replace(/\r\n/gu,`
|
|
31
31
|
`).replace(/\n\n/gu,`
|
|
32
32
|
`);await Qa(n,o,{encoding:"utf-8"}),(o.includes("\r")||o.includes(`
|
|
33
33
|
|
|
34
|
-
`))&&
|
|
34
|
+
`))&&_e.error("CODEOWNERS file still has Windows line endings.")}catch(n){throw _e.error(`Error processing CODEOWNERS file: ${n.message}`),n}}catch(n){_e.error(`Sync operation failed: ${n.message}`),io.exit(1)}});import ut from"node:fs";import Fe from"node:path";import{Logger as co}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as ec}from"commander";import{glob as tc}from"glob";var ao=(e,t)=>{let n=(e.match(/static register\(name \= (.+)\)/)||e.match(/customElements.get\((.+?)\)/))[1],r=e.match(/export class (.+) extends/)?.[1],o=e.match(/\/\*\*((.|\n)*?)(\*\n|\*\/|[@])/)?.[1]||"";return!n||!r?e:`
|
|
35
35
|
import { ${r} } from '${t}';
|
|
36
36
|
|
|
37
37
|
/**${o}*/
|
|
@@ -40,31 +40,31 @@ class ${r}WCA extends ${r} {}
|
|
|
40
40
|
if (!customElements.get(${n})) {
|
|
41
41
|
customElements.define(${n}, ${r}WCA);
|
|
42
42
|
}
|
|
43
|
-
`};var
|
|
43
|
+
`};var mt=Fe.resolve(process.cwd(),"./scripts/wca");async function nc(e){try{return(await Promise.all(e.map(n=>tc(n)))).flat()}catch(t){throw console.error("Error processing glob patterns:",t),t}}async function rc(e){ut.existsSync(mt)||await ut.promises.mkdir(mt,{recursive:!0});for(let t of e){let n=Fe.resolve(process.cwd(),t),r=await ut.promises.readFile(n,"utf-8"),o=Fe.resolve(mt,`${Fe.basename(t)}`),i=ao(r,Fe.relative(mt,t));await ut.promises.writeFile(o,i)}}async function oc(){let e=await nc(["./src/auro-*.js"]);await rc(e)}var Pg=ec.command("wca-setup").description("Set up WCA (Web Component Analyzer) for the project").action(()=>{oc().then(()=>{co.success("WCA setup completed successfully.")}).catch(e=>{co.error(`WCA setup failed: ${e.message}`)})});import{program as fc}from"commander";import po from"chalk";import fo from"ora";import{appendFile as sc,readFile as ic}from"node:fs/promises";import{Logger as $}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{simpleGit as ac}from"simple-git";var E;try{E=ac({baseDir:process.cwd(),binary:"git",maxConcurrentProcesses:1})}catch(e){$.error(`Failed to initialize git: ${e}`),E={}}var K=class e{static async checkGitignore(t){if(t==="")return!1;try{return(await ic(".gitignore","utf-8")).includes(t)}catch(n){return $.error(`Error reading file: ${n}`),!1}}static async getCommitMessages(t=""){try{let n=t;n||(n=(await E.branchLocal()).current);let r="main",o="";if(!!process.env.GITHUB_ACTIONS){r=process.env.GITHUB_BASE_REF||"main";try{if(await E.fetch("origin",r),n!=="HEAD")try{await E.raw(["rev-parse","--verify",`origin/${n}`])}catch{await E.fetch("origin",n)}let s=n==="HEAD"?"HEAD":`origin/${n}`;o=`${(await E.raw(["merge-base",`origin/${r}`,s])).trim()}..${s}`}catch(s){$.warn(`Error setting up commit range in CI: ${s}`);let a=n==="HEAD"?"HEAD":`origin/${n}`;o=`origin/${r}..${a}`}}else try{try{await E.raw(["rev-parse","--verify",`origin/${r}`])}catch{$.info(`Fetching ${r} from origin`),await E.fetch("origin",r)}if(n!=="HEAD")try{await E.raw(["rev-parse","--verify",n])}catch{await E.fetch("origin",n)}o=`${(await E.raw(["merge-base",`origin/${r}`,n])).trim()}..${n}`}catch(s){$.warn(`Error determining commits locally: ${s}`),o=`${n}~10..${n}`}return await e.getFormattedCommits(o)}catch(n){return $.error(`Error getting commit messages: ${n}`),[]}}static async getRepoOwnerAndName(){try{let t=await E.getRemotes(!0);if(t.length===0)return $.warn("No remotes found"),null;let n=t.find(o=>o.name==="origin")||t[0],r=n.refs.fetch||n.refs.push;return e.parseGitUrl(r)}catch(t){return $.error(`Error getting repo owner and name: ${t}`),null}}static async getCurrentBranchName(){try{return(await E.branchLocal()).current||null}catch(t){return $.error(`Error getting current branch name: ${t}`),null}}static parseGitUrl(t){let n;return t.includes("@")&&t.includes(":")&&(n=t.match(/@([^:]+):([^/]+)\/(.+?)(?:\.git)?$/),n)?{owner:n[2],repo:n[3]}:(n=t.match(/https?:\/\/(?:[^@]+@)?[^/]+\/([^/]+)\/(.+?)(?:\.git)?$/),n?{owner:n[1],repo:n[2]}:($.warn(`Could not parse git URL: ${t}`),null))}static async getFormattedCommits(t){let r=(await E.raw(["log","--pretty=format:COMMIT_START%n%H%n%ad%n%an%n%s%n%b%nCOMMIT_END","--date=short",t])).split(`COMMIT_START
|
|
44
44
|
`).filter(i=>i.trim()!==""),o=[];for(let i of r){let s=i.split(`
|
|
45
|
-
`);if(s.length>=4){let a=s[0],c=s[1],l=s[2],u=s[3],
|
|
45
|
+
`);if(s.length>=4){let a=s[0],c=s[1],l=s[2],u=s[3],p=s.slice(4).filter(g=>g!=="COMMIT_END"),m=p.length>0?p.join(""):"",d=a.substring(0,7),f=u.match(/^(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?:/),h=f?f[1]:"unknown";m.includes("BREAKING CHANGE")&&(h="breaking"),o.push({type:h,hash:d,date:c,subject:u,body:m,message:`${u}${m?`
|
|
46
46
|
|
|
47
|
-
${
|
|
48
|
-
${t}`),n&&$.success(`${t} added to .gitignore`)}catch(o){$.error(o)}})}static async removeFromGitCache(t){try{await E.rmKeepLocal(t),$.success(`${t.join(", ")} are removed from git cache`)}catch(n){$.error(n)}}static async createBranch(t){try{await E.checkoutLocalBranch(t),$.success(`Created and switched to ${t} branch`)}catch(n){$.error(n)}}static async commitStagedFiles(t){try{await E.add("."),await E.commit(t),$.success(`Committed with message: ${t}`)}catch(n){$.error(n)}}};import C from"chalk";var cc=60,lc=100;function
|
|
49
|
-
`,o=""),o=`${o}${i} `;return o.length>0&&(r+=o.trim()),r}function
|
|
50
|
-
`)}import*as
|
|
47
|
+
${m}`:""}`,author_name:l})}}return o}static async addToGitignore(t,n=!0){await e.checkGitignore(t).then(async r=>{if(r)$.warn(`${t} already exists`);else try{await sc(".gitignore",`
|
|
48
|
+
${t}`),n&&$.success(`${t} added to .gitignore`)}catch(o){$.error(o)}})}static async removeFromGitCache(t){try{await E.rmKeepLocal(t),$.success(`${t.join(", ")} are removed from git cache`)}catch(n){$.error(n)}}static async createBranch(t){try{await E.checkoutLocalBranch(t),$.success(`Created and switched to ${t} branch`)}catch(n){$.error(n)}}static async commitStagedFiles(t){try{await E.add("."),await E.commit(t),$.success(`Committed with message: ${t}`)}catch(n){$.error(n)}}};import C from"chalk";var cc=60,lc=100;function Le(e){switch(e){case"breaking":return C.bold.red(e);case"feat":return C.bold.green(e);case"fix":return C.bold.green(e);case"perf":return C.bold.green(e);case"docs":return C.bold.cyan(e);case"style":return C.bold.cyan(e);case"refactor":return C.bold.cyan(e);case"test":return C.bold.cyan(e);case"build":return C.bold.cyan(e);case"ci":return C.bold.cyan(e);case"chore":return C.bold.cyan(e);default:return C.bold.white(e)}}function lo(e,t){if(!e)return"";if(e.length<=t)return e;let n=e.split(" "),r="",o="";for(let i of n)(o+i).length>t&&o.length>0&&(r+=`${o.trim()}
|
|
49
|
+
`,o=""),o=`${o}${i} `;return o.length>0&&(r+=o.trim()),r}function uo(e){for(let t of e){console.log("\u2500".repeat(60));let n=lo(t.subject,cc),r=lo(t.body,lc);console.log(C.bold(`${Le(t.type)}`)),console.log(C.dim(`${t.hash} | ${t.date} | ${t.author_name}`)),console.log(C.bold(`${C.white(n)}`)),t.body&&console.log(C.dim(r))}console.log("\u2500".repeat(60)),console.log(`
|
|
50
|
+
`)}import*as Ge from"@actions/github";async function gn(){try{let e=process.env.GITHUB_TOKEN;if(!e)throw new Error("GITHUB_TOKEN environment variable is not set");if(!process.env.GITHUB_REPOSITORY||!process.env.GITHUB_EVENT_PATH)throw new Error("This function can only be used in a GitHub Actions environment");let t=Ge.getOctokit(e),{context:n}=Ge;if(!n.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[r,o]=process.env.GITHUB_REPOSITORY.split("/"),i=n.payload.pull_request.number,{data:s}=await t.rest.issues.listLabelsOnIssue({owner:r,repo:o,issue_number:i});return s.map(a=>a.name)}catch(e){throw e instanceof Error?new Error(`Failed to get existing labels: ${e.message}`):e}}async function mo(e){try{let t=process.env.GITHUB_TOKEN;if(!t)throw new Error("GITHUB_TOKEN environment variable is not set");if(!process.env.GITHUB_REPOSITORY||!process.env.GITHUB_EVENT_PATH)throw new Error("This function can only be used in a GitHub Actions environment");let n=Ge.getOctokit(t),{context:r}=Ge;if(!r.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[o,i]=process.env.GITHUB_REPOSITORY.split("/"),s=r.payload.pull_request.number,a=`semantic-status: ${e}`,c=await gn();if(c.includes(a))return;let l=c.filter(u=>u.startsWith("semantic-status:")&&u!==a);for(let u of l)await n.rest.issues.removeLabel({owner:o,repo:i,issue_number:s,name:u});await n.rest.issues.addLabels({owner:o,repo:i,issue_number:s,labels:[a]});return}catch(t){throw t instanceof Error?new Error(`Failed to apply label: ${t.message}`):t}}var uc=["feat","fix","breaking","perf"];function mc(e,t=!0){let n=`### In this release
|
|
51
51
|
`;for(let r of e)if(n+=`- ${r.hash} ${r.subject}
|
|
52
|
-
`,r.body?.trim()){let i=r.body.trim().split(/\n+/).map(s=>s.trim()).filter(s=>s.length>0);for(let s of i){let a=s;a=a.replace(/([^\s])(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)/g,"$1 $2"),a=a.replace(/(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)([^\s])/g,"$1 $2"),n+=` - ${a}`}}return e.length===0?"":(t&&console.log(
|
|
53
|
-
`),r}async function
|
|
54
|
-
`).start();try{let o=await
|
|
52
|
+
`,r.body?.trim()){let i=r.body.trim().split(/\n+/).map(s=>s.trim()).filter(s=>s.length>0);for(let s of i){let a=s;a=a.replace(/([^\s])(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)/g,"$1 $2"),a=a.replace(/(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)([^\s])/g,"$1 $2"),n+=` - ${a}`}}return e.length===0?"":(t&&console.log(po.green(`\u2713 Generating release notes for ${e.length} commits`)),n)}function pc(e,t=!0){let n=e.filter(o=>uc.includes(o.type)),r;return t?r=n.length>0?n:e:r=n,r.length===0&&console.log(`No commits found to include in release notes.
|
|
53
|
+
`),r}async function go(e=!1,t=!1,n=!1){let r=fo(`Checking commits...
|
|
54
|
+
`).start();try{let o=await K.getCommitMessages();if(n){r.succeed(`Total commits analyzed: ${o.length}`);let i=pc(o);console.log(mc(i));return}if(e&&uo(o),r.succeed(`Total commits analyzed: ${o.length}`),o.length!==0){let i=o.map(c=>c.type),a=Array.from(new Set(i)).map(c=>Le(c)).join(", ");r.succeed(`Found commit types: ${a}`)}else r.info(`The list of commits is created by comparing the current branch
|
|
55
55
|
with the main branch. If you are on a new branch, please
|
|
56
|
-
make sure to commit some changes before running this command.`);t&&await dc(o,r)}catch(o){r.fail("Error getting commit messages"),console.error(o)}}async function dc(e,t){let n=["breaking","feat","fix","perf","docs","style","refactor","test","build","ci","chore"],r=e.map(s=>s.type).filter(s=>n.includes(s)),o=null,i=Number.POSITIVE_INFINITY;for(let s of r){let a=n.indexOf(s);a<i&&(i=a,o=s)}if(o){let s=
|
|
57
|
-
`,"utf8"),r.succeed(`Package.json updated to use ${
|
|
56
|
+
make sure to commit some changes before running this command.`);t&&await dc(o,r)}catch(o){r.fail("Error getting commit messages"),console.error(o)}}async function dc(e,t){let n=["breaking","feat","fix","perf","docs","style","refactor","test","build","ci","chore"],r=e.map(s=>s.type).filter(s=>n.includes(s)),o=null,i=Number.POSITIVE_INFINITY;for(let s of r){let a=n.indexOf(s);a<i&&(i=a,o=s)}if(o){let s=fo("Checking existing labels on pull request...").start();try{if((await gn()).includes(`semantic-status: ${o}`)){s.info(`Label "semantic-status: ${Le(o)}" already exists on the pull request.`);return}s.text="Applying label to pull request...",await mo(o),s.succeed(`Label "semantic-status: ${Le(o)}" applied to the pull request.`)}catch(a){let c=a instanceof Error?a.message:String(a);s.fail(c)}}else t.warn(po.yellow("No semantic commit type found to apply as label."))}var Vg=fc.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 go(e.debug,e.setLabel,e.releaseNotes)});import ho from"node:fs";import{get as yo}from"node:https";import ie from"chalk";import{program as gc}from"commander";import hc from"ora";var eh=gc.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 yc(e)}),yc=async e=>{let{namespace:t,prNumber:n}=e,r=hc("Updating package.json").start();try{let o="package.json",i=JSON.parse(ho.readFileSync(o,"utf8"));r.text="Checking npm registry for version information...";let s=`0.0.0-pr${n}`,a=i.name.split("/")[1],c=`${t}/${a}`,l=await bc(s,c,r),u=`${s}.${l}`;i.name=c,i.version=u,r.text="Writing updated package.json...",ho.writeFileSync(o,`${JSON.stringify(i,null,2)}
|
|
57
|
+
`,"utf8"),r.succeed(`Package.json updated to use ${ie.green(u)} and ${ie.green(c)}`),process.exit(0)}catch(o){r.fail(`Failed to update package.json: ${o}`),process.exit(1)}},bc=(e,t,n)=>new Promise(r=>{try{let a=function(c){if(c.statusCode!==200){n.info(`Package not found. Status code: ${ie.red(c.statusCode)}, defaulting to version 0`),r(0);return}n.text="Processing version information...";let l="";c.on("data",u=>{l+=u}),c.on("end",()=>{try{let u=JSON.parse(l),p=u.versions?Object.keys(u.versions):[];n.text="Calculating next version number...";let m=-1,d=new RegExp(`^${e}\\.(\\d+)$`);for(let f of p){let h=f.match(d);if(h){let g=Number.parseInt(h[1],10);m=Math.max(m,g)}}m>=0?n.info(`Found existing version ${ie.green(`${e}.${m}`)}. Incrementing to ${ie.green(`${e}.${m+1}`)}`):n.info(`No existing version found for ${ie.green(e)}. Starting with ${ie.green(`${e}.0`)}`),r(m+1)}catch(u){n.warn(`Failed to parse NPM registry response: ${u instanceof Error?u.message:"Unknown error"}, defaulting to version 0`),r(0)}})};var o=a;let i=`https://registry.npmjs.org/${t}`,s=yo(i,{headers:{Accept:"application/json"}},c=>{if((c.statusCode===301||c.statusCode===302)&&c.headers.location){n.info(`Following redirect to ${c.headers.location}...`);try{yo(c.headers.location,{headers:{Accept:"application/json"}},a).on("error",l=>{n.warn(`Error following redirect: ${l.message}, defaulting to version 0`),r(0)}).end()}catch(l){n.warn(`Redirect request failed: ${l instanceof Error?l.message:"Unknown error"}, defaulting to version 0`),r(0)}return}a(c)});s.on("error",c=>{n.warn(`Request error: ${c.message}, defaulting to version 0`),r(0)}),s.end()}catch{n.warn("Error checking version in npm registry, defaulting to version 0"),r(0)}});import hn from"node:path";import{fileURLToPath as wc}from"node:url";import{program as vc}from"commander";import kc from"open";var $c=wc(import.meta.url),Ec=hn.resolve(hn.dirname($c),".."),ah=vc.command("test").option("-w, --watch","Set watch number for the test").option("-c, --coverage-report","Generate coverage report").option("-o, --open","Open the coverage report in the browser").option("-f, --files <String|String[]>","Test files glob pattern").description("Run the web test runner to test the component library").action(async e=>{let n=`npx wtr --config "${hn.join(Ec,"dist","configs","web-test-runner.config.mjs")}"`,r=`${process.cwd()}/coverage/index.html`;if(e.coverageReport&&(n+=" --coverage"),e.watch&&(n+=" --watch"),e.files){let o=Array.isArray(e.files)?e.files.join(" "):e.files;n+=` --files "${o}"`}F(n),e.open&&await kc(r)});import vn from"node:fs/promises";import ko from"node:path";import{program as Pc}from"commander";import Dc from"inquirer";import kn from"ora";import Sc from"node:fs/promises";import Cc from"node:path";import Ac from"ora";var xc={"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 Tc(e){return Object.entries(e).map(([t,n])=>Array.isArray(n)?`${t}:
|
|
58
58
|
- ${n.join(`
|
|
59
59
|
- `)}`:typeof n=="object"&&n!==null?`${t}:
|
|
60
60
|
${Object.entries(n).map(([r,o])=>` ${r}: ${o}`).join(`
|
|
61
61
|
`)}`:`${t}: ${n}`).join(`
|
|
62
|
-
`)}async function
|
|
62
|
+
`)}async function bo(e){let t=Ac("Writing multi-gitter configuration...").start(),n=Tc(xc),r=Cc.join(e,"multi-gitter_DEPENDENCY_TREE.yml");try{await Sc.writeFile(r,n,"utf8"),t.succeed(`Multi-gitter configuration written to ${r}`)}catch(o){t.fail("Error writing multi-gitter configuration:"),console.error(o)}}import yn from"node:fs";function wo(e){let t={},n=[],r=[],o=[];for(let i in e)t[i]=e[i].dependsOn.length;for(let i in t)t[i]===0&&o.push(i);for(;o.length>0;){r=[];let i=o.length;for(let s=0;s<i;s++){let a=o.shift();r.push(a);for(let c of e[a].dependentPackages)t[c]--,t[c]===0&&o.push(c)}n.push(r)}if(n.flat().length!==Object.keys(e).length)throw new Error("Circular dependency detected!");return n}function Rc(e){return yn.readdirSync(e).filter(t=>t.endsWith(".json"))}async function vo(e,t=[]){console.log(t);let n={},r=Rc(e);for(let o of r){if(o==="dependencyTree.json")continue;let i=yn.readFileSync(`${e}/${o}`,"utf-8"),s=JSON.parse(i),a=s.name,c=Object.keys(s.peerDependencies),l=Object.keys(s.devDependencies),u=Object.keys(s.dependencies);n[a]||(n[a]={dependsOn:[],dependentPackages:[]});let p=[...c,...l,...u];n[a].dependsOn=[...new Set(p)];for(let m of p)n[m]||(n[m]={dependsOn:[],dependentPackages:[]}),n[m].dependentPackages.includes(a)||n[m].dependentPackages.push(a)}if(t.length){let o=new Set;for(let[s,a]of Object.entries(n))a.dependsOn.some(c=>t.includes(c))&&o.add(s);for(let s of t)n[s]&&o.add(s);let i={};for(let s of o)i[s]={dependsOn:n[s].dependsOn.filter(a=>o.has(a)),dependentPackages:n[s].dependentPackages.filter(a=>o.has(a))};n=i}else console.log("No target dependencies provided - using all packages.");return yn.writeFileSync(`${e}/dependencyTree.json`,JSON.stringify(n,null,2)),n}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 bn=en("run-migrations","config"),wn=en("run-migrations","outputs");var Ah=[...O,"@aurodesignsystem/auro-library","@aurodesignsystem/WebCoreStyleSheets","@aurodesignsystem/AuroDesignTokens","@aurodesignsystem/auro-cli","@alaskaairux/icons"];async function Mc(e){try{await vn.mkdir(wn,{recursive:!0}),await vn.mkdir(bn,{recursive:!0})}catch(o){console.error("Failed to create output or config directories:",o),process.exit(1)}let t=kn("Creating dependency tree...").start();t.text="Creating multi-gitter dependency tree configuration...",await bo(bn),t.text="Scraping dependencies from Auro packages...";let r=`multi-gitter run "node ${tn("static","getAuroDeps.js")}" --config ${ko.join(bn,"multi-gitter_DEPENDENCY_TREE.yml")}`;try{await F(r)}catch(o){t.fail("Failed to generate dependency tree:"),console.error(o),process.exit(1)}return t.text="Generating dependency tree JSON file using packages...",await vo(wn,e),t.succeed("Dependency tree generated successfully."),ko.join(wn,"dependencyTree.json")}var Nc=async e=>{let t=kn("Loading dependency tree...").start(),n=JSON.parse(await vn.readFile(e,"utf-8"));t.text="Processing dependency tree...";let r=wo(n);return t.succeed("Dependency batches created successfully."),r},xh=Pc.command("agent").action(async e=>{let t=await Dc.prompt([{type:"select",name:"agentAction",message:"What agent action do you want to perform?",choices:[{name:"Run a migration on auro components",value:"run-migration"}],default:["run-migration"]},{type:"input",name:"migrationId",message:"What migration id do you want to run?",when:n=>n.agentAction==="run-migration",validate:n=>n.trim()!==""||"Migration id cannot be empty."},{type:"confirm",name:"useExisting",message:"Would you like to specify starting packages?",default:!0,transformer:n=>n?"Yes = Packages related to selections":"No = All packages",when:n=>n.agentAction==="run-migration"},{type:"checkbox",name:"startWithComponents",message:"Enter the components to start with (comma-separated, blank for all):",choices:O.map(n=>({name:n.replace("@aurodesignsystem/",""),value:n})),when:n=>n.agentAction==="run-migration"&&n.useExisting}]);switch(t.agentAction){case"run-migration":{let n=kn("Running migration...").start(),r=await Mc(t.startWithComponents);n.text="Getting dependency batches from tree...";let i=(await Nc(r)).map((s,a)=>`Batch ${a+1}
|
|
63
63
|
${s.map(c=>` - ${c.replace("@aurodesignsystem","AlaskaAirlines").replace("@alaskaairux/icons","AlaskaAirlines/Icons")}`).join(`
|
|
64
64
|
`)}`).join(`
|
|
65
65
|
|
|
66
|
-
`);console.log(i),n.text="Running migrations on dependency batches...",new Promise(s=>setTimeout(s,2e3)),n.succeed("Migration process completed successfully.");break}default:console.error("Unknown action selected.")}});import{writeFile as Gc}from"node:fs/promises";import Bc from"node:path";import
|
|
67
|
-
`,"utf-8")}catch(a){let c=a instanceof Error?a.message:String(a);t.fail(`Failed to write ${e.output}: ${c}`),
|
|
66
|
+
`);console.log(i),n.text="Running migrations on dependency batches...",new Promise(s=>setTimeout(s,2e3)),n.succeed("Migration process completed successfully.");break}default:console.error("Unknown action selected.")}});import{writeFile as Gc}from"node:fs/promises";import Bc from"node:path";import pt from"node:process";import{Logger as To}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Wc}from"commander";import Uc from"ora";import{readFile as $o}from"node:fs/promises";import ae from"node:path";import Ic from"node:process";var Oc="https://unpkg.com",jc="https://registry.npmjs.org",$n=1e4;function _c(e){let t=e.lastIndexOf("@");return t>0?{pkg:e.slice(0,t),ref:e.slice(t+1)}:{pkg:e}}function Eo(e,t){let n=ae.relative(e,t);return n===""||!n.startsWith("..")&&!ae.isAbsolute(n)}async function Fc(e){let t=ae.join(Ic.cwd(),"node_modules"),n=ae.join(t,...e.split("/"));if(!Eo(t,n))return null;let r,o="custom-elements.json";try{let i=JSON.parse(await $o(ae.join(n,"package.json"),"utf-8"));typeof i.version=="string"&&(r=i.version),typeof i.customElements=="string"&&Eo(n,ae.resolve(n,i.customElements))&&(o=i.customElements)}catch{return null}try{let i=JSON.parse(await $o(ae.join(n,o),"utf-8"));return{target:e,manifest:i,source:"local",version:r}}catch{return null}}async function j(e,t={}){let{preferLocal:n=!0,allowNetwork:r=!0}=t,{ref:o}=_c(e);if(n&&!o){let a=await Fc(e);if(a)return{...a,target:e}}if(!r)return{target:e,manifest:null,reason:"not installed locally and network fetching is disabled"};let i=`${Oc}/${e}/custom-elements.json`,s;try{s=await fetch(i,{signal:AbortSignal.timeout($n)})}catch(a){let l=a instanceof DOMException&&a.name==="TimeoutError"?`timed out after ${$n/1e3}s`:a instanceof Error?a.message:String(a);return{target:e,manifest:null,reason:`request failed (${l})`,transient:!0}}if(s.status===404)return{target:e,manifest:null,reason:"no custom-elements.json published"};if(!s.ok)return{target:e,manifest:null,reason:`HTTP ${s.status}`,transient:!0};try{return{target:e,manifest:await s.json(),source:"unpkg"}}catch{return{target:e,manifest:null,reason:"custom-elements.json is not valid JSON",transient:!0}}}function So(e){let t=e.filter(n=>!n.manifest);return{skipped:t,transientFailures:t.filter(n=>n.transient)}}async function Co(e){try{let t=await fetch(`${jc}/${e}/latest`,{signal:AbortSignal.timeout($n)});if(!t.ok)return null;let n=await t.json();return typeof n.version=="string"?n.version:null}catch{return null}}import{Logger as Lc}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";function En(e,t){if(Array.isArray(e))return e.map(n=>En(n,t));if(e&&typeof e=="object"){let n=e,r={};for(let[o,i]of Object.entries(n))o==="module"&&typeof i=="string"&&n.package==null?r[o]=`${t}/${i}`:r[o]=En(i,t);return r}return e}function Ao(e,t=Lc.warn){let n=[];for(let{pkg:o,manifest:i}of e)for(let s of i.modules??[]){let a=En(s,o);typeof s.path=="string"&&(a.path=`${o}/${s.path}`),n.push(a)}let r=new Set(e.map(o=>o.manifest.schemaVersion).filter(Boolean));return r.size>1&&t(`Merging mixed CEM schema versions: ${[...r].join(", ")}`),{schemaVersion:e[0]?.manifest.schemaVersion??"1.0.0",modules:n}}async function xo(e,t={}){let n=await Promise.all(e.map(s=>j(s,t))),r=[];for(let s of n)s.manifest&&r.push({pkg:s.target,manifest:s.manifest});let{skipped:o,transientFailures:i}=So(n);return{manifest:Ao(r),sources:r,skipped:o,transientFailures:i}}async function Hc(e){let t=Uc(`Fetching manifests for ${O.length} components...`).start(),{manifest:n,sources:r,skipped:o,transientFailures:i}=await xo(O,{preferLocal:!1});r.length===0&&(t.fail("No component manifests could be fetched."),pt.exit(1));let s=Bc.resolve(pt.cwd(),e.output);try{await Gc(s,`${JSON.stringify(n,null,2)}
|
|
67
|
+
`,"utf-8")}catch(a){let c=a instanceof Error?a.message:String(a);t.fail(`Failed to write ${e.output}: ${c}`),pt.exit(1)}t.succeed(`Aggregated ${r.length}/${O.length} component manifests (${n.modules?.length??0} modules) to ${e.output}`);for(let a of o)a.transient||To.info(`Skipped ${a.target}: ${a.reason}`);i.length>0&&(To.error(`${i.length} component(s) failed to fetch transiently; the aggregate may be incomplete. Re-run to retry.`),pt.exit(1))}var zh=Wc.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(Hc);import{readFileSync as zo}from"node:fs";import{dirname as Vo,join as nu,resolve as _n}from"node:path";import kt from"node:process";import{program as ru}from"commander";import ou from"ora";import{mkdtempSync as Jc,rmSync as zc}from"node:fs";import{tmpdir as Vc}from"node:os";import{join as Kc}from"node:path";function Cn(e){return e.replace(/(['"`])(?:\\.|(?!\1)[\s\S])*\1/gu," ")}function An(e){let t={")":"(","]":"[","}":"{",">":"<"},n=[],r="";for(let o of Cn(e)){if(o===">"&&r==="="){r=o;continue}if(o==="("||o==="["||o==="{"||o==="<")n.push(o);else if((o===")"||o==="]"||o==="}"||o===">")&&n.pop()!==t[o])return!1;r=o}return n.length===0}function Sn(e){let t=e.type?.text;if(typeof t=="string"&&t!==""&&!An(t)){let{type:n,...r}=e;return r}return e}function xn(e,t){let{fieldName:n,description:r}=e;if(typeof n!="string"||n===""||typeof r=="string"&&r!=="")return!1;if(!t.has(n))return!0;let o=t.get(n);return o==="private"||o==="protected"}function qc(e){let t=o=>typeof o.name=="string",n=e.members?.filter(t).map(Sn),r=new Map((n??[]).map(o=>[o.name,o.privacy]));return{...e,...n&&{members:n},...e.attributes&&{attributes:e.attributes.filter(t).filter(o=>!xn(o,r)).map(Sn)},...e.slots&&{slots:e.slots.filter(t)},...e.events&&{events:e.events.filter(t).map(Sn)},...e.cssParts&&{cssParts:e.cssParts.filter(t)},...e.cssProperties&&{cssProperties:e.cssProperties.filter(t)}}}function Tn(e,t){return t.get(e.tagName)??e.tagName}function Po(e){return new Map(e.map(t=>[t.declaration.name,t.importPath]))}function ye(e,t){return{schemaVersion:"1.0.0",modules:e.map(n=>{let r=qc({...n.declaration,tagName:t?Tn(n,t):n.tagName});return{kind:"javascript-module",path:n.importPath,declarations:[r],exports:[{kind:"js",name:r.name,declaration:{name:r.name,module:n.importPath}}]}})}}function q(e){let t=Jc(Kc(Vc(),"auro-editors-"));try{return e(t)}finally{try{zc(t,{recursive:!0,force:!0,maxRetries:10,retryDelay:100})}catch{}}}function Y(e){return e.endsWith(`
|
|
68
68
|
`)?e:`${e}
|
|
69
69
|
`}var Yc=` /** Identifies the currently active descendant of a composite widget. */
|
|
70
70
|
"aria-activedescendant"?: string;
|
|
@@ -174,11 +174,11 @@ ${s.map(c=>` - ${c.replace("@aurodesignsystem","AlaskaAirlines").replace("@alas
|
|
|
174
174
|
"aria-valuetext"?: string;
|
|
175
175
|
/** Custom data-* attributes for the element. */
|
|
176
176
|
[key: \`data-\${string}\`]: string | number | boolean | null | undefined;
|
|
177
|
-
`,
|
|
177
|
+
`,Ro=/(type BaseProps(?:<[^>]*>)? = \{\n)/,Xc=` /** Defines the element's semantic role for accessibility APIs. */
|
|
178
178
|
role?: string;
|
|
179
179
|
/** The position of the element in the sequential keyboard navigation order. */
|
|
180
180
|
tabindex?: number;
|
|
181
|
-
`;function
|
|
181
|
+
`;function dt(e,{svelteGlobals:t}){if(!Ro.test(e))throw new Error("the JSX/Svelte generator no longer emits a recognizable `type BaseProps = {` block; the global-attribute injection in manifest.ts must be updated to match.");let n=`${t?Xc:""}${Yc}`;return e.replace(Ro,`$1${n}`)}function Rn(e){let t=[];for(let n of e)n.source==="local"&&n.manifest&&n.version&&t.push({pkg:n.target,version:n.version,manifest:n.manifest});return t}async function Do(e=O){let t=await Promise.all(e.map(n=>j(n,{allowNetwork:!1})));return Rn(t)}function Pn(e){return(e.modules??[]).flatMap(t=>t.declarations??[]).filter(t=>t.customElement&&t.tagName)}function Dn(e){let t=[],n=new Map,r=new Set;for(let{pkg:i,version:s,manifest:a}of e){let c=Pn(a),l=c.length>1;for(let u of c){let p=u.tagName,m=n.get(p);m?m.includes(i)||m.push(i):n.set(p,[i]),!r.has(p)&&(r.add(p),t.push({pkg:i,version:s,tagName:p,declaration:u,importPath:l?`${i}/${p}`:i,isMonorepo:l}))}}let o=[];for(let[i,s]of n)s.length>1&&o.push({tagName:i,packages:s});return{components:t,duplicates:o}}async function Mo(e){let t=await Do(e);return Dn(t)}var Zc=new Set(["variant","shape","size","type","appearance"]),Qc=new Set(["string","String","any"]),el=new Map([["array","use `unknown[]`, `T[]`, or `Array<T>`"],["function","use `Function` or an explicit call signature `(\u2026) => \u2026`"]]),tl=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>"]]),nl=new Set(["object","Object"]),rl=[...el].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*:)`,"u")})),ol=[...tl].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*[<:])`,"u")}));function No(e,t){return e===t?`\`type.text\` is \`${t}\``:`\`type.text\` (${JSON.stringify(e)}) uses \`${t}\``}var sl=[/^[\s>*_~([-]*@?deprecated\b/iu,/[([]\s*deprecated\b/iu,/\*\*\s*deprecated\b/iu,/@deprecated\b/iu];function _o(...e){return e.some(t=>typeof t=="string"&&sl.some(n=>n.test(t.trim())))}function Fo(e){return e===!0||Be(e)}function Io(e,t,n,r){!Fo(r.deprecated)&&_o(r.description,r.summary)&&e.push({rule:"deprecated-prose-unflagged",severity:"warn",element:t,path:n,message:"described as deprecated but missing the `deprecated` field \u2014 add an `@deprecated` JSDoc tag so the generated JSX/Svelte types surface it with a strikethrough. (VS Code HTML custom-data has no deprecation field, so vanilla-HTML editors won't show it.)"})}function Oo(e,t,n,r,o){!Fo(o.deprecated)&&_o(o.description,o.summary)&&e.push({rule:"deprecated-prose-unsupported",severity:"warn",element:t,path:r,message:`this ${n} reads as deprecated in prose, but the analyzer (v0.11.0) does not emit a \`deprecated\` field for inline \`@${n}\` tags \u2014 editors cannot surface it. Track upstream or a mapping plugin; suppress this warning if the prose is intentional.`})}function ft(e,t,n,r){r.deprecated===!0&&e.push({rule:"deprecated-no-detail",severity:"warn",element:t,path:n,message:"`deprecated` is set but carries no message \u2014 editors show a strikethrough with no migration target. Prefer `@deprecated <what to use instead>`."})}function Be(e){return typeof e=="string"&&e!==""}function be(e,t,n,r){r?.forEach((o,i)=>{typeof o.name!="string"&&e.push({rule:"name-required",severity:"error",element:t,path:`${n}[${i}].name`,message:`${n}[${i}] has no string \`name\` \u2014 community generators call \`.name.startsWith(\u2026)\` and throw mid-generation.`})})}function Mn(e,t,n,r){let o=r.type?.text;typeof o=="string"&&o!==""&&!An(o)&&e.push({rule:"type-parseable",severity:"error",element:t,path:`${n}.type.text`,message:`\`type.text\` has unbalanced delimiters: ${JSON.stringify(o)} \u2014 the generated \`.d.ts\` would not parse.`})}function Nn(e,t,n,r){let o=r.type?.text;if(typeof o!="string")return;let i=o.trim();if(i==="")return;let s=Cn(i);for(let{token:a,re:c,fix:l}of rl)if(c.test(s)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${n}.type.text`,message:`${No(i,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 ol)if(c.test(s)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${n}.type.text`,message:`${No(i,a)}, a generic that requires a type argument \u2014 write \`${l}\`. The generated \`.d.ts\` would not compile.`});return}nl.has(i)&&e.push({rule:"type-imprecise",severity:"warn",element:t,path:`${n}.type.text`,message:`\`type.text\` is \`${i}\` \u2014 a valid type, but it exposes no properties so nothing completes. Prefer an explicit shape (e.g. \`{ id: string }\`).`})}function il(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r--)n++;return n%2===1}function al(e){let t=[],n=0,r=null,o=0;for(let i=0;i<e.length;i++){let s=e[i];r!==null?s===r&&!il(e,i)&&(r=null):s==='"'||s==="'"||s==="`"?r=s:s==="("||s==="["||s==="{"||s==="<"?n++:s===")"||s==="]"||s==="}"?n--:s===">"?i>0&&e[i-1]!=="="&&n--:s==="|"&&n===0&&(t.push(e.slice(o,i).trim()),o=i+1)}return t.push(e.slice(o).trim()),t.filter(i=>i!=="")}function cl(e){return/^(['"`]).*\1$/u.test(e)}function ll(e,t,n,r){let o=r.type?.text?.trim();if(typeof o!="string"||!o.includes("|"))return;let i=al(o),s=i.some(cl),a=i.some(c=>c==="string"||c==="String");s&&a&&e.push({rule:"union-widened-by-string",severity:"warn",element:t,path:`${n}.type.text`,message:`\`type.text\` (${JSON.stringify(o)}) unions string literals with a bare \`string\`, which widens the whole type back to \`string\` \u2014 drop the \`string\` member so the literals validate and complete.`})}function jo(e){return typeof e!="string"||e.trim()===""}function In(e,t,n,r,o){jo(o.description)&&jo(o.summary)&&e.push({rule:"missing-description",severity:"warn",element:t,...r===void 0?{}:{path:r},message:`${n} has no description or summary \u2014 editors show no hover documentation for it. Add a JSDoc description.`})}function ul(e,t){let n=Be(t.tagName)?t.tagName:"<unknown>";typeof t.name!="string"&&e.push({rule:"name-required",severity:"error",element:n,path:"name",message:"registered element has no string `name` \u2014 its generated import/export identity is undefined."}),In(e,n,"this component",void 0,t);let r=t.members??[],o=t.attributes??[],i=t.events??[],s=t.slots??[];be(e,n,"members",r),be(e,n,"attributes",o),be(e,n,"slots",t.slots),be(e,n,"events",i),be(e,n,"cssParts",t.cssParts),be(e,n,"cssProperties",t.cssProperties),r.forEach((c,l)=>{Mn(e,n,`members[${l}]`,c),Nn(e,n,`members[${l}]`,c),Io(e,n,`members[${l}]`,c),ft(e,n,`members[${l}]`,c)}),o.forEach((c,l)=>{Mn(e,n,`attributes[${l}]`,c),Nn(e,n,`attributes[${l}]`,c),ll(e,n,`attributes[${l}]`,c),In(e,n,"attribute",`attributes[${l}]`,c),Io(e,n,`attributes[${l}]`,c),ft(e,n,`attributes[${l}]`,c)}),i.forEach((c,l)=>{Mn(e,n,`events[${l}]`,c),Nn(e,n,`events[${l}]`,c),In(e,n,"event",`events[${l}]`,c),Oo(e,n,"event",`events[${l}]`,c),ft(e,n,`events[${l}]`,c)}),s.forEach((c,l)=>{Oo(e,n,"slot",`slots[${l}]`,c),ft(e,n,`slots[${l}]`,c)});let a=new Map(r.filter(c=>typeof c.name=="string").map(c=>[c.name,c.privacy]));o.forEach((c,l)=>{Be(c.name)&&/[A-Z]/u.test(c.name)&&e.push({rule:"attribute-name-not-lowercase",severity:"warn",element:n,path:`attributes[${l}].name`,message:`attribute \`${c.name}\` has uppercase letters \u2014 HTML lowercases attribute names, so it never binds as written. Use \`${c.name.toLowerCase()}\` (the camelCase property name belongs in \`fieldName\`).`}),Be(c.name)&&Zc.has(c.name)&&Qc.has(c.type?.text?.trim()??"")&&e.push({rule:"enumerated-union",severity:"warn",element:n,path:`attributes[${l}].type.text`,message:`\`${c.name}\` is typed as bare \`${JSON.stringify(c.type?.text??"")}\` \u2014 an enumerated attribute should carry a string-literal union (e.g. \`"primary" | "secondary"\`) so values validate and complete.`}),xn(c,a)&&e.push({rule:"private-reflection",severity:"warn",element:n,path:`attributes[${l}]`,message:`\`${c.name??"<unnamed>"}\` reflects a private/omitted member and has no description \u2014 it leaks into editor autocomplete as a settable attribute (add a description if it is genuinely public).`})})}function Lo(e){let t=[];Be(e.schemaVersion)||t.push({rule:"schema-version",severity:"warn",message:"manifest has no `schemaVersion` \u2014 declare the CEM schema version it targets."});for(let n of Pn(e))ul(t,n);return t}import{execFileSync as xl}from"node:child_process";import{mkdirSync as jn,writeFileSync as wt}from"node:fs";import{createRequire as Tl}from"node:module";import{dirname as Rl,join as we}from"node:path";import Pl from"node:process";import{generateJsxTypes as pl}from"@wc-toolkit/jsx-types";var x=".vscode",ce="settings.json",Go="auro.html-custom-data.json",P="html.customData",H=`./${x}/${Go}`,le=`${x}/${Go}`,ml="auro.code-snippets",gt=`${x}/${ml}`,We="auro-types",On="auro-jsx.d.ts",ht="auro-svelte.d.ts",ue=`${We}/${On}`,me=`${We}/${ht}`,D="include",J=We;function yt(e,t){let n=ye(e),r=Po(e),o=q(i=>pl(n,{outdir:i,fileName:On,tagFormatter:s=>t.get(s)??s,componentTypePath:s=>r.get(s)??s,useCemTypes:!0,includeDefaultDOMEvents:!0}));if(typeof o!="string")throw new Error("JSX type generation returned no output for the resolved components.");return{filename:ue,contents:Y(dt(o,{svelteGlobals:!1}))}}import{readFileSync as dl}from"node:fs";import{join as fl}from"node:path";import{generateSvelteTypes as gl}from"custom-element-svelte-integration";var Bo=`declare namespace svelteHTML {
|
|
182
182
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
183
183
|
interface IntrinsicElements extends CustomElements {}
|
|
184
184
|
}`,hl=`declare global {
|
|
@@ -237,29 +237,29 @@ ${s.map(c=>` - ${c.replace("@aurodesignsystem","AlaskaAirlines").replace("@alas
|
|
|
237
237
|
`,bl=/^([ \t]*)"on:([^"]+)"(\?:.*=> void;)$/gmu;function wl(e){return e.replace(bl,(t,n,r,o)=>`${n}"on:${r}"${o}
|
|
238
238
|
${n}"on${r}"${o}`)}var vl=/^(\s*"[^"]+": Partial<)(\w+)Props & BaseProps & BaseEvents(>;)$/gm;function kl(e){let t=!1,n=e.replace(vl,(r,o,i,s)=>(t=!0,`${o}Omit<${i}Props, keyof BaseProps> & BaseProps & Omit<BaseEvents, keyof ${i}Props>${s}`));if(!t)throw new Error("custom-element-svelte-integration no longer emits the expected `Partial<<Name>Props & BaseProps & BaseEvents>` element mapping; the base-member collision rewrite in svelteTypes.ts must be updated to match the new output.");return n}var $l=/^type (\w+)Props = \{\n([\s\S]*?)\n\};$/gm,El=/\/\*\* /g;function Sl(e,t){return e.replace($l,(n,r,o)=>{let i=t.get(r);if(i===void 0)return n;let s=o.replace(El,`/** \u3010${i}\u3011 `);return`type ${r}Props = {
|
|
239
239
|
${s}
|
|
240
|
-
};`})}function Cl(e,t){return new Map(e.map(n=>{let r=n.tagName,o=t.get(r)??r,i=o===r?n.declaration.name:o;return[n.declaration.name,i]}))}function Al(e){if(!e.includes(
|
|
240
|
+
};`})}function Cl(e,t){return new Map(e.map(n=>{let r=n.tagName,o=t.get(r)??r,i=o===r?n.declaration.name:o;return[n.declaration.name,i]}))}function Al(e){if(!e.includes(Bo))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(Bo,hl)}function bt(e,t){let n=ye(e,t),r=Cl(e,t),o=q(i=>(gl(n,{outdir:i,fileName:ht,hideLogs:!0,globalEvents:yl}),dl(fl(i,ht),"utf-8")));return{filename:me,contents:Y(Al(kl(dt(wl(Sl(o,r)),{svelteGlobals:!0}))))}}var Dl=Tl(import.meta.url),Ml=Dl.resolve("typescript/bin/tsc"),Nl=`declare namespace JSX {
|
|
241
241
|
type Element = unknown;
|
|
242
242
|
interface CSSProperties {}
|
|
243
243
|
}
|
|
244
|
-
`;function Il(e){return`${e.replace(/[^a-zA-Z0-9]+/gu,"_")}.d.ts`}function Ol(e){let t=new Map,n=/^[ \t]*import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/gmu;for(let r of e.matchAll(n)){let o=r[1].split(",").map(s=>s.trim().split(/\s+as\s+/u)[0].trim()).filter(Boolean);if(o.length===0)continue;let i=t.get(r[2])??new Set;for(let s of o)i.add(s);t.set(r[2],i)}return t}function
|
|
245
|
-
${s.trim()}`}}})}function
|
|
244
|
+
`;function Il(e){return`${e.replace(/[^a-zA-Z0-9]+/gu,"_")}.d.ts`}function Ol(e){let t=new Map,n=/^[ \t]*import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/gmu;for(let r of e.matchAll(n)){let o=r[1].split(",").map(s=>s.trim().split(/\s+as\s+/u)[0].trim()).filter(Boolean);if(o.length===0)continue;let i=t.get(r[2])??new Set;for(let s of o)i.add(s);t.set(r[2],i)}return t}function Wo(e,t,n){wt(we(e,"tsconfig.json"),JSON.stringify({compilerOptions:{noEmit:!0,skipLibCheck:!1,strict:!1,strictFunctionTypes:!0,target:"ES2020",module:"ESNext",moduleResolution:"bundler",...n&&{baseUrl:".",paths:n},lib:["ES2020","DOM"],types:[]},include:t},null,2),"utf-8")}function jl(e,t){let n=we(e,t.filename);jn(Rl(n),{recursive:!0}),wt(n,t.contents,"utf-8")}function Uo(e,t,n){return q(r=>{jl(r,t),n(r);try{return xl(Pl.execPath,[Ml,"-p","tsconfig.json"],{cwd:r,stdio:"pipe"}),null}catch(o){let i=o,s=`${i.stdout?.toString()??""}${i.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
|
+
${s.trim()}`}}})}function Ho(e){if(e.length===0)return[];let t=new Map(e.map(r=>[r.tagName,r.tagName])),n=[];try{let r=yt(e,t),o=Ol(r.contents),i=Uo("JSX",r,s=>{jn(we(s,"stubs"),{recursive:!0});let a={},c=[r.filename];for(let[l,u]of o){let p=Il(l);wt(we(s,"stubs",p),`${[...u].map(m=>`export declare class ${m} extends HTMLElement {}`).join(`
|
|
246
246
|
`)}
|
|
247
|
-
`,"utf-8"),a[l]=[`./stubs/${
|
|
248
|
-
`).map(a=>a.replace(/^\s*\*?\s?/u,"").trimEnd()),following:e.slice(i,Math.min(s,i+Bl))}})}var Hl=/^@default\s+false$/u,Jl=/^@type\s+\{\s*boolean\s*\}/iu,zl=[/^\s*[\w$]+\s*:\s*\{[^}]*?\btype\s*:\s*Boolean\b/u,/^\s*@property\(\s*\{[^}]*?\btype\s*:\s*Boolean\b/u];function Vl(e){return e.lines.some(t=>Jl.test(t))||zl.some(t=>t.test(e.following))}function Kl(e,t,n){let r=n.lines.findIndex(o=>Hl.test(o.trim()));r===-1||!Vl(n)||e.push({rule:"redundant-boolean-default",severity:"warn",path:`${t}:${n.line+r}`,message:"`@default false` on a boolean property is redundant \u2014 a boolean that isn't set is already off, and the manifest picks up a constructor's `false` on its own. Remove the tag (content guidelines \u203A Defaults)."})}var ql=new Set(["category","customElement","default","forcePrivate","internal","maximum","minimum","private","relevantWhen","requiredWhen","see","type"]),Yl=[/`[^`]*`/gu,/\bhttps?:\/\/\S+/gu,/\{@[^}]*\}/gu];function Xl(e){let t=[],n=!1,r=!1;return e.lines.forEach((o,i)=>{let s=o.trim();if(s.startsWith("```")){r=!r;return}let a=/^@(\w+)/u.exec(s)?.[1];a!==void 0&&(n=a==="example",n||ql.has(a))||r||n||s===""||t.push({index:i,text:Yl.reduce((c,l)=>c.replace(l," "),s)})}),t}function
|
|
249
|
-
`),d&&
|
|
250
|
-
`)[0].trim();s.push({hash:a.hash,subject:c,type:fu(c),bump:
|
|
251
|
-
`):[]}var Cu=/^Merge (pull request|branch|remote-tracking branch) /u;async function
|
|
247
|
+
`,"utf-8"),a[l]=[`./stubs/${p}`],c.push(`stubs/${p}`)}Wo(s,c,a)});i&&n.push(i)}catch(r){n.push({rule:"generation-build",severity:"error",element:"JSX",message:`JSX type generation threw for this CEM: ${r.message}`})}try{let r=bt(e,t),o=Uo("Svelte",r,i=>{jn(we(i,"stubs"),{recursive:!0}),wt(we(i,"stubs","jsx-shim.d.ts"),Nl,"utf-8"),Wo(i,[r.filename,"stubs/jsx-shim.d.ts"])});o&&n.push(o)}catch(r){n.push({rule:"generation-build",severity:"error",element:"Svelte",message:`Svelte type generation threw for this CEM: ${r.message}`})}return n}import{readFileSync as _l}from"node:fs";import{resolve as Fl}from"node:path";var Ll=/\/\*\*(?!\/)([\s\S]*?)\*\//gu,Gl=/\.[cm]?[jt]s$/u,Bl=400;function Wl(e,t){let n=1;for(let r=0;r<t;r++)e.charCodeAt(r)===10&&n++;return n}function Ul(e){let t=[...e.matchAll(Ll)];return t.map((n,r)=>{let o=n.index??0,i=o+n[0].length,s=t[r+1]?.index??e.length;return{line:Wl(e,o),lines:(n[1]??"").split(`
|
|
248
|
+
`).map(a=>a.replace(/^\s*\*?\s?/u,"").trimEnd()),following:e.slice(i,Math.min(s,i+Bl))}})}var Hl=/^@default\s+false$/u,Jl=/^@type\s+\{\s*boolean\s*\}/iu,zl=[/^\s*[\w$]+\s*:\s*\{[^}]*?\btype\s*:\s*Boolean\b/u,/^\s*@property\(\s*\{[^}]*?\btype\s*:\s*Boolean\b/u];function Vl(e){return e.lines.some(t=>Jl.test(t))||zl.some(t=>t.test(e.following))}function Kl(e,t,n){let r=n.lines.findIndex(o=>Hl.test(o.trim()));r===-1||!Vl(n)||e.push({rule:"redundant-boolean-default",severity:"warn",path:`${t}:${n.line+r}`,message:"`@default false` on a boolean property is redundant \u2014 a boolean that isn't set is already off, and the manifest picks up a constructor's `false` on its own. Remove the tag (content guidelines \u203A Defaults)."})}var ql=new Set(["category","customElement","default","forcePrivate","internal","maximum","minimum","private","relevantWhen","requiredWhen","see","type"]),Yl=[/`[^`]*`/gu,/\bhttps?:\/\/\S+/gu,/\{@[^}]*\}/gu];function Xl(e){let t=[],n=!1,r=!1;return e.lines.forEach((o,i)=>{let s=o.trim();if(s.startsWith("```")){r=!r;return}let a=/^@(\w+)/u.exec(s)?.[1];a!==void 0&&(n=a==="example",n||ql.has(a))||r||n||s===""||t.push({index:i,text:Yl.reduce((c,l)=>c.replace(l," "),s)})}),t}function vt(e,t,n,r,o,i){e.push({rule:o,severity:"warn",path:`${t}:${n.line+r.index}`,message:i})}var Zl=[{pattern:/\be\.g\./iu,message:'uses "e.g." \u2014 write "for example" or "such as". Some tools also end the summary at its first period (content guidelines \u203A Word choices).'},{pattern:/\bi\.e\./iu,message:'uses "i.e." \u2014 write "that is". Some tools also end the summary at its first period (content guidelines \u203A Word choices).'},{pattern:/\bHTML5\b/u,message:'uses "HTML5" \u2014 name the element instead, such as "the inner `<button>` element" (content guidelines \u203A Word choices).'},{pattern:/\ba11y\b/iu,message:'uses "a11y" \u2014 write "accessibility", or name the people affected, such as "screen reader users" (content guidelines \u203A Word choices).'}],Ql=/^(?:This (?:property|attribute|Boolean|boolean)\b|Used to\b)/u;function eu(e){return e.flatMap((t,n)=>{if(t.text.startsWith("@")){let r=t.text.indexOf(" - ");return r===-1?[]:[{index:t.index,text:t.text.slice(r+3).trim()}]}return n===0?[t]:[]})}function tu(e,t,n){let r=Xl(n);for(let o of r){for(let{pattern:i,message:s}of Zl)i.test(o.text)&&vt(e,t,n,o,"word-choice",s);o.text.includes(" \u2014 ")&&vt(e,t,n,o,"spaced-em-dash",'has a spaced em dash (" \u2014 ") \u2014 use a colon or a new sentence, or an em dash with no spaces (content guidelines \u203A Formatting \u203A Dashes).'),/\bDEPRECATED\b/u.test(o.text)&&vt(e,t,n,o,"deprecated-casing",'writes "DEPRECATED" in capitals \u2014 use "Deprecated:" in sentence case, followed by what to use instead (content guidelines \u203A Deprecations).')}for(let o of eu(r))Ql.test(o.text)&&vt(e,t,n,o,"filler-opener",'starts with filler ("This property \u2026" or "Used to \u2026") \u2014 start with a verb that says what it does, such as "Sets the \u2026" (content guidelines \u203A Structure \u203A No filler openers).')}function Jo(e,t){let n=[],r=new Set;for(let o of e.modules??[]){let i=o.path;if(typeof i!="string"||!Gl.test(i)||r.has(i))continue;r.add(i);let s;try{s=_l(Fl(t,i),"utf-8")}catch{continue}for(let a of Ul(s))Kl(n,i,a),tu(n,i,a)}return n}function su(e){try{let t=zo(nu(Vo(_n(e)),"package.json"),"utf-8"),n=JSON.parse(t);return{pkg:typeof n.name=="string"?n.name:"cem-check-subject",version:typeof n.version=="string"?n.version:"0.0.0"}}catch{return{pkg:"cem-check-subject",version:"0.0.0"}}}function iu(e){let t=e.severity==="error"?"\u2716":"\u26A0",n=[e.element,e.path].filter(Boolean).join(" "),r=n?` ${n}`:"";return`${t} [${e.rule}]${r}: ${e.message}`}var au="custom-elements.json";async function cu(e=au,t={}){let n=t.json?null:ou(`Checking ${e} against the CEM contract...`).start(),r=h=>{n?n.fail(h):console.error(h),kt.exit(1)},o;try{o=JSON.parse(zo(_n(e),"utf-8"))}catch(h){r(`Could not read or parse ${e}: ${h.message}`)}(typeof o!="object"||o===null||Array.isArray(o))&&r(`Could not read or parse ${e}: not a CEM object.`);let i=o,{pkg:s,version:a}=su(e),c=[{pkg:s,version:a,manifest:i}],{components:l}=Dn(c),u=[...Lo(i),...Ho(l),...Jo(i,Vo(_n(e)))],p=u.filter(h=>h.severity==="error"),m=u.filter(h=>h.severity==="warn"),d=p.length>0||!!t.strict&&m.length>0;if(t.json){kt.stdout.write(`${JSON.stringify(u,null,2)}
|
|
249
|
+
`),d&&kt.exit(1);return}let f=`${p.length} error${p.length===1?"":"s"}, ${m.length} warning${m.length===1?"":"s"}`;d?n?.fail(`CEM contract failed \u2014 ${f}.`):m.length>0?n?.warn(`CEM contract passed with warnings \u2014 ${f}.`):n?.succeed("CEM contract clean \u2014 no violations.");for(let h of[...p,...m])console.error(iu(h));d&&kt.exit(1)}var Fy=ru.command("cem-check [path]").description("Validate a custom-elements.json against the CEM contract (structural + parseability rules, an end-to-end generation smoke, and documentation rules on the JSDoc in the source files it lists). Defaults to ./custom-elements.json.").option("--json","Output the findings as a JSON array on stdout",!1).option("--strict","Treat warnings as errors (any finding fails)",!1).action(cu);import Zn from"node:process";import{program as Xu}from"commander";import Zu from"ora";var ve={none:0,patch:1,minor:2,major:3};function Ko(e){let t="none";for(let n of e)ve[n]>ve[t]&&(t=n);return t}function qo(e,t){return ve[e]<ve[t]?"fail":t==="none"&&e!=="none"?"warn":"pass"}function Yo(e){let t=new Set;return e.map((n,r)=>({change:n,index:r})).sort((n,r)=>ve[r.change.bump]-ve[n.change.bump]||n.index-r.index).map(({change:n})=>n).filter(n=>t.has(n.message)?!1:(t.add(n.message),!0))}import{existsSync as lu,readFileSync as Ln}from"node:fs";import{createRequire as Qo}from"node:module";import{join as $t}from"node:path";import{pathToFileURL as uu}from"node:url";var Et="@semantic-release/commit-analyzer",Fn={preset:"conventionalcommits",releaseRules:[{type:"docs",scope:"README",release:"patch"},{type:"refactor",release:"patch"},{type:"style",release:"patch"}]};function mu(e){for(let t of[".releaserc",".releaserc.json"]){let n=$t(e,t);if(lu(n))try{return{config:JSON.parse(Ln(n,"utf-8")),file:t}}catch{}}try{let t=JSON.parse(Ln($t(e,"package.json"),"utf-8"));if(t.release&&typeof t.release=="object")return{config:t.release,file:"package.json#release"}}catch{}return null}function Xo(e){for(let t of e??[]){if(t===Et)return{};if(Array.isArray(t)&&t[0]===Et)return t[1]??{}}return null}function es(e){let t=mu(e);if(!t)return{options:Fn,source:"default"};let n=Xo(t.config.plugins);if(n)return{options:n,source:t.file};if(t.config.plugins)return{options:Fn,source:"default"};let r=Qo($t(e,"package.json")),o=[t.config.extends??[]].flat().reverse();for(let i of o)try{let s=r.resolve(i),a=JSON.parse(Ln(s,"utf-8")),c=Xo(a.plugins);if(c)return{options:c,source:i}}catch{}return{options:Fn,source:"default"}}async function pu(e){let t;try{t=Qo($t(e,"package.json")).resolve(Et)}catch{throw new Error(`${Et} isn't installed in ${e}. The declared bump is read with the repo's own analyzer, so the check matches the release; run \`npm ci\` first.`)}return(await import(uu(t).href)).analyzeCommits}var du={log:()=>{}};function Zo(e){return e==="major"||e==="minor"||e==="patch"?e:"none"}function fu(e){let t=/^(\w+)(?:\([^)]*\))?(!?):/u.exec(e);return t?`${t[1]}${t[2]}`:null}async function ts(e,t,n){if(e.length===0)return{bump:"none",commits:[]};let r=await pu(n),o={cwd:n,logger:du},i=Zo(await r(t.options,{...o,commits:e})),s=[];for(let a of[...e].reverse()){let c=a.message.split(`
|
|
250
|
+
`)[0].trim();s.push({hash:a.hash,subject:c,type:fu(c),bump:Zo(await r(t.options,{...o,commits:[a]}))})}return{bump:i,commits:s}}import{execFile as gu,execFileSync as hu,spawn as yu}from"node:child_process";import{existsSync as rs,rmSync as bu}from"node:fs";import{mkdtemp as wu,readFile as Wn,rm as vu}from"node:fs/promises";import{constants as ku,tmpdir as $u}from"node:os";import{join as z}from"node:path";import{promisify as Eu}from"node:util";var Su=Eu(gu);async function pe(e,t){let{stdout:n}=await Su("git",t,{cwd:e,maxBuffer:67108864});return n.trim()}function Un(e,t){return pe(e,["rev-parse","--verify",`${t}^{commit}`])}function os(e,t,n){return pe(e,["merge-base",t,n])}async function Ct(e,t,n){try{return await pe(e,["show",`${t}:${n}`])}catch{return null}}async function ss(e,t,n){let r=await pe(e,["diff","--name-only","--no-renames",t,n]);return r?r.split(`
|
|
251
|
+
`):[]}var Cu=/^Merge (pull request|branch|remote-tracking branch) /u;async function is(e,t,n){return(await pe(e,["log","--no-merges","--format=%H%x1f%B%x1e",`${t}..${n}`])).split("").map(o=>o.trim()).filter(Boolean).map(o=>{let[i,s=""]=o.split("");return{hash:i.trim(),message:s.trim()}}).filter(o=>!Cu.test(o.message))}var Ue=new Map,St=new Set,as=["SIGINT","SIGTERM"];function cs(e){for(let t of St)Au(t);for(let[t,n]of Ue){try{hu("git",["worktree","remove","--force",t],{cwd:n,stdio:"ignore"})}catch{}bu(t,{recursive:!0,force:!0})}process.exit(128+(ku.signals[e]??0))}var ls=process.platform!=="win32";function Au(e){try{ls&&e.pid?process.kill(-e.pid,"SIGKILL"):e.kill("SIGKILL")}catch{}}function xu(e,t){if(Ue.size===0)for(let n of as)process.on(n,cs);Ue.set(e,t)}function Tu(e){if(Ue.delete(e),Ue.size===0)for(let t of as)process.off(t,cs)}function Gn(e,t){return new Promise((n,r)=>{let o=yu(e,{cwd:t,shell:!0,detached:ls,stdio:["ignore","pipe","pipe"],env:{...process.env,HUSKY:"0"}});St.add(o);let i=[];o.stdout?.on("data",s=>i.push(String(s))),o.stderr?.on("data",s=>i.push(String(s))),o.on("error",s=>{St.delete(o),r(s)}),o.on("close",s=>{if(St.delete(o),s===0){n();return}let a=i.join("").trim().split(`
|
|
252
252
|
`).slice(-20).join(`
|
|
253
253
|
`);r(new Error(`\`${e}\` exited with ${s}
|
|
254
|
-
${a}`))})})}var Ct="@aurodesignsystem/auro-cli",Un="@custom-elements-manifest/analyzer";function Gn(e,t){for(let n of[J(e,"node_modules",t),J(e,"node_modules",Ct,"node_modules",t)])if(ns(J(n,"package.json")))return n;return null}async function ts(e,t){let n=Gn(e,t);if(n)return JSON.parse(await Bn(J(n,"package.json"),"utf-8")).version}function ls(e,t){return e.auroCli!==t.auroCli||e.analyzer!==t.analyzer}async function Ru(e){let t=await ts(e,Ct),n=await ts(e,Un);return t||n?{auroCli:t,analyzer:n}:null}async function Pu(e){if(JSON.parse(await Bn(J(e,"package.json"),"utf-8")).scripts?.analyze)return"npm run analyze";let n=Gn(e,Ct),r=Gn(e,Un),o=n?J(n,"dist","configs","custom-elements-manifest.config.mjs"):null;return!o||!ns(o)||!r?null:`node "${J(r,"cem.js")}" analyze --config "${o}"`}async function At(e,t,n,r,o){let i=await wu(J($u(),"auro-api-diff-"));xu(i,e);try{if(await me(e,["worktree","add","--detach","--force",i,t]),await Ln(r.install,i),o){let c=[o.auroCli&&`${Ct}@${o.auroCli}`,o.analyzer&&`${Un}@${o.analyzer}`].filter(Boolean);await Ln(`${r.pin} ${c.join(" ")}`,i)}let s=await Ru(i),a=o?await Pu(i):null;return await Ln(a??r.build,i),{manifest:JSON.parse(await Bn(J(i,n),"utf-8")),generator:s}}finally{await me(e,["worktree","remove","--force",i]).catch(()=>{}),await vu(i,{recursive:!0,force:!0}).catch(()=>{}),Tu(i)}}function us(e){let t=new Map;for(let n of e.modules??[])for(let r of n.declarations??[]){let{tagName:o}=r;o&&!t.has(o)&&t.set(o,{tagName:o,className:r.name,declaration:r})}return t}function we(e){return e.privacy===void 0||e.privacy==="public"}function Du(e){return e.static?`static ${e.name}`:e.name}function Hn(e){let t=e.kind==="field"?"property":e.kind;return e.static?`static ${t}`:t}function Tt(e){return e.replace(/['`]/gu,'"').replace(/\s+/gu," ").trim()}function Mu(e){let t=Tt(e),n=/^\{\s*("[^"]*"|-?\d+(?:\.\d+)?|true|false|null|undefined)\s*\}$/u.exec(t);return n?n[1]:t}function ms(e){let t=[],n=0,r=null,o="";for(let s of e){if(r)s===r&&(r=null);else if(s==='"'||s==="'"||s==="`")r=s;else if("([{<".includes(s))n++;else if(")]}>".includes(s)&&!(s===">"&&o.endsWith("=")))n--;else if((s==="|"||s===",")&&n===0){t.push(o),o="";continue}o+=s}t.push(o);let i={String:"string",Number:"number",Boolean:"boolean"};return t.map(Tt).filter(s=>s.length>0).map(s=>i[s]??s)}function Nu(e){return/^".*"$/u.test(e)?"string":/^-?\d+(?:\.\d+)?$/u.test(e)?"number":e==="true"||e==="false"?"boolean":null}function ps(e,t){let n=Nu(t);return e.includes(t)||n!==null&&e.includes(n)}function Jn(e,t,n){if(t===void 0||n===void 0)return null;let r=ms(t),o=ms(n),i=r.filter(c=>!ps(o,c)),s=o.filter(c=>!ps(r,c));if(i.length===0&&s.length===0)return null;let a=c=>c.map(l=>`\`${l}\``).join(", ");return i.length>0&&s.length>0?{bump:"major",source:"manifest",message:`Changed type of ${e} from \`${Tt(t)}\` to \`${Tt(n)}\``}:i.length>0?{bump:"major",source:"manifest",message:`Narrowed type of ${e} (removed ${a(i)})`}:{bump:"minor",source:"manifest",message:`Widened type of ${e} (added ${a(s)})`}}function gs(e,t,n){let r=s=>{let a=s===void 0?void 0:Mu(s);return a==="undefined"?void 0:a},o=r(t),i=r(n);return o===i?null:o===void 0?{bump:"minor",source:"manifest",message:`Added default \`${i}\` to ${e}`}:i===void 0?{bump:"minor",source:"manifest",message:`Removed default \`${o}\` from ${e}`}:{bump:"major",source:"manifest",message:`Changed default of ${e} from \`${o}\` to \`${i}\``}}function zn(e){return typeof e.name=="string"&&e.name!==""}function Vn(e,t,n){let r=[],o=(c,l)=>r.push({bump:c,source:"manifest",message:l}),i=t.requiredWhen,s=n.requiredWhen;i!==s&&(i===void 0?o("major",`Made ${e} required when \`${s}\``):s===void 0?o("minor",`Made ${e} no longer required`):i==="always"?o("minor",`Made ${e} required only when \`${s}\``):o("major",`Changed when ${e} is required from \`${i}\` to \`${s}\``));let a=(c,l)=>{let u=t[c],m=n[c];if(u===m)return;let p=c==="minimum"?"minimum":"maximum";u===void 0?o("major",`Added ${p} \`${m}\` to ${e}`):m===void 0?o("minor",`Removed ${p} \`${u}\` from ${e}`):l(m,u)?o("major",`Tightened ${p} of ${e} from \`${u}\` to \`${m}\``):o("minor",`Loosened ${p} of ${e} from \`${u}\` to \`${m}\``)};a("minimum",(c,l)=>c>l),a("maximum",(c,l)=>c<l),!t.readonly&&n.readonly?o("major",`Made ${e} read-only`):t.readonly&&!n.readonly&&o("minor",`Made ${e} writable`),!t.deprecated&&n.deprecated?o("minor",`Deprecated ${e}`):t.deprecated&&!n.deprecated&&o("minor",`Removed the deprecation of ${e}`);for(let c of["relevantWhen","category"]){let l=t[c],u=n[c];l!==u&&(l===void 0?o("minor",`Added \`${c}\` \`${u}\` to ${e}`):u===void 0?o("minor",`Removed \`${c}\` \`${l}\` from ${e}`):o("minor",`Changed \`${c}\` of ${e} from \`${l}\` to \`${u}\``))}return r}function Iu(e,t=[],n=[]){let r=[],o=(s,a)=>r.push({bump:s,source:"manifest",message:a}),i=s=>!!(s.optional||s.rest);for(let s=0;s<Math.max(t.length,n.length);s++){let a=t[s],c=n[s];if(a&&!c)o("major",`Removed parameter \`${a.name}\` from ${e}`);else if(!a&&c)o(i(c)?"minor":"major",`Added ${i(c)?"optional":"required"} parameter \`${c.name}\` to ${e}`);else if(a&&c){let l=`parameter \`${c.name}\` of ${e}`;i(a)&&!i(c)?o("major",`Made ${l} required`):!i(a)&&i(c)&&o("minor",`Made ${l} optional`);let u=Jn(l,a.type?.text,c.type?.text);u&&r.push(u)}}return r}function ds(e){let t=new Map;for(let n of e.members??[])zn(n)&&t.set(Du(n),n);return t}function fs(e,t){let n=new Map;for(let r of e.attributes??[]){let o=r.fieldName?t.get(r.fieldName):void 0;!zn(r)||r.internal||o&&!we(o)||n.set(r.name.toLowerCase(),r)}return n}function Ou(e,t,n){let r=[],o=`\`<${e}>\``;for(let[i,s]of t){if(!we(s))continue;let a=n.get(i),c=Hn(s);if(!a){r.push({bump:"major",source:"manifest",message:`Removed ${c} \`${s.name}\` from ${o}`});continue}if(!we(a)){r.push({bump:"major",source:"manifest",message:`Made ${c} \`${s.name}\` on ${o} ${a.privacy}`});continue}if(a.kind!==s.kind){r.push({bump:"major",source:"manifest",message:`Changed \`${s.name}\` on ${o} from a ${c} to a ${Hn(a)}`});continue}let l=`${c} \`${s.name}\` on ${o}`;if(r.push(...Vn(l,s,a)),s.kind==="method"&&r.push(...Iu(l,s.parameters,a.parameters)),s.kind==="field"){s.reflects&&!a.reflects&&r.push({bump:"major",source:"manifest",message:`Attribute \`${s.attribute??s.name}\` on ${o} no longer reflects`});for(let u of[Jn(l,s.type?.text,a.type?.text),gs(l,s.default,a.default)])u&&r.push(u)}}for(let[i,s]of n){if(!we(s))continue;let a=t.get(i),c=Hn(s);a?we(a)||r.push({bump:"minor",source:"manifest",message:`Made ${a.privacy} ${c} \`${s.name}\` on ${o} public`}):r.push({bump:"minor",source:"manifest",message:`Added ${c} \`${s.name}\` to ${o}`})}return r}function ju(e,t,n,r,o){let i=[],s=`\`<${e}>\``,a=fs(t,r),c=fs(n,o),l=d=>new Set((d.attributes??[]).filter(zn).map(f=>f.name.toLowerCase())),u=l(n),m=l(t),p=(d,f)=>{let h=d.fieldName?f.get(d.fieldName):void 0;return h!==void 0&&we(h)};for(let[d,f]of a){let{name:h}=f,g=c.get(d);if(!g){i.push({bump:"major",source:"manifest",message:u.has(d)?`Made attribute \`${h}\` on ${s} private`:`Removed attribute \`${h}\` from ${s}`});continue}if(p(f,r)||p(g,o))continue;let y=`attribute \`${h}\` on ${s}`;for(let v of[Jn(y,f.type?.text,g.type?.text),gs(y,f.default,g.default)])v&&i.push(v);i.push(...Vn(y,f,g))}for(let[d,{name:f}]of c)a.has(d)||i.push({bump:"minor",source:"manifest",message:m.has(d)?`Made private attribute \`${f}\` on ${s} public`:`Added attribute \`${f}\` to ${s}`});return i}function xt(e,t,n,r){let o=u=>t==="slot"&&u===""?"default slot":`${t} \`${u}\``,i=`\`<${e}>\``,s=u=>new Set((u??[]).map(m=>m.name).filter(m=>typeof m=="string")),a=s(n),c=s(r),l=[];for(let u of a)c.has(u)||l.push({bump:"major",source:"manifest",message:`Removed ${o(u)} from ${i}`});for(let u of c)a.has(u)||l.push({bump:"minor",source:"manifest",message:`Added ${o(u)} to ${i}`});return l}var _u=[{key:"slots",describe:(e,t)=>e===""?`default slot of \`<${t}>\``:`slot \`${e}\` on \`<${t}>\``},{key:"cssParts",describe:(e,t)=>`CSS part \`${e}\` on \`<${t}>\``},{key:"cssProperties",describe:(e,t)=>`CSS custom property \`${e}\` on \`<${t}>\``}];function Fu(e,t,n){return _u.flatMap(({key:r,describe:o})=>{let i=new Map((n[r]??[]).map(s=>[s.name,s]));return(t[r]??[]).flatMap(s=>{let a=i.get(s.name);return typeof s.name!="string"||!a?[]:Vn(o(s.name,e),s,a)})})}function Lu(e,t,n){let r=ds(t),o=ds(n);return[...Fu(e,t,n),...ju(e,t,n,r,o),...Ou(e,r,o),...xt(e,"event",t.events,n.events),...xt(e,"slot",t.slots,n.slots),...xt(e,"CSS part",t.cssParts,n.cssParts),...xt(e,"CSS custom property",t.cssProperties,n.cssProperties)]}function Kn(e,t){let n=us(e),r=us(t),o=[],i=new Map;for(let[a,c]of n){if(r.has(a))continue;let l=[...r.values()].find(u=>u.className===c.className&&!n.has(u.tagName));l&&i.set(a,l.tagName)}let s=new Set(i.values());for(let[a,c]of n){let l=r.get(a);if(l){o.push(...Lu(a,c.declaration,l.declaration));continue}let u=i.get(a);o.push({bump:"major",source:"manifest",message:u?`Renamed element \`<${a}>\` to \`<${u}>\``:`Removed element \`<${a}>\``})}for(let a of r.keys())!n.has(a)&&!s.has(a)&&o.push({bump:"minor",source:"manifest",message:`Added element \`<${a}>\``});return o}import Rt from"semver";function hs(e){if(e==null)return new Set;if(typeof e=="object"&&!Array.isArray(e)){let t=Object.keys(e);if(t.every(n=>n.startsWith(".")))return new Set(t)}return new Set(["."])}function Gu(e,t){let n=e;if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let i=e;Object.keys(i).every(s=>s.startsWith("."))&&(n=i[t])}let r=[],o=i=>{typeof i=="string"?r.push(i):Array.isArray(i)?i.forEach(o):i&&typeof i=="object"&&Object.values(i).forEach(o)};return o(n),r}var Bu=/^(package-lock\.json|\.npmrc|node_modules\/|\.git\/)/u,Wu=/^(package\.json|readme(\.[^/]*)?|licen[cs]e(\.[^/]*)?)$/iu;function ys(e){let t=e.indexOf("*");return t===-1?e:e.slice(0,t)}function Uu(e,t){let n=e.replace(/^\.\//u,"");if(Bu.test(n))return!1;if(!t||Wu.test(n))return!0;let r=ys(n);return t.some(o=>{let i=o.replace(/^\.\//u,"").replace(/\/$/u,"");return i.includes("*")?r.startsWith(ys(i)):n===i||n.startsWith(`${i}/`)})}function bs(e,t){return Gu(e.exports,t).some(n=>Uu(n,e.files))}function ws(e){try{let t=Rt.minVersion(e);return t?t.major>0?`${t.major}`:`0.${t.minor}`:null}catch{return null}}function vs(e,t={},n={}){let r=[];for(let[o,i]of Object.entries(n)){let s=t[o];if(s===void 0)continue;let a=ws(s),c=ws(i);a!==null&&c!==null&&a!==c&&r.push({bump:"major",source:"package",message:`Bumped ${e} \`${o}\` from \`${s}\` to \`${i}\``})}return r}function Hu(e={},t={}){let n=[];for(let[r,o]of Object.entries(t)){let i=e[r],s=`engine \`${r}\``;if(i===void 0){n.push({bump:"major",source:"package",message:`Added ${s} requirement \`${o}\``});continue}let a=null,c=null;try{a=Rt.minVersion(i),c=Rt.minVersion(o)}catch{continue}a&&c&&Rt.gt(c,a)&&n.push({bump:"major",source:"package",message:`Tightened ${s} from \`${i}\` to \`${o}\``})}return n}function ks(e,t){let n=[],r=hs(e.exports),o=hs(t.exports),i=e.exports===void 0&&t.exports!==void 0;i&&n.push({bump:"major",source:"package",message:"Added `exports`, which blocks imports of unlisted paths"});for(let a of r)o.has(a)||n.push(bs(e,a)?{bump:"major",source:"package",message:`Removed export \`${a}\``}:{bump:"patch",source:"package",message:`Removed export \`${a}\`, which never resolved: its target isn't in the published package`});for(let a of o)!i&&!r.has(a)&&n.push(bs(t,a)?{bump:"minor",source:"package",message:`Added export \`${a}\``}:{bump:"patch",source:"package",message:`Added export \`${a}\`, which won't resolve: its target isn't in the published package`});for(let a of["main","types","typings"])e[a]!==void 0&&t[a]===void 0&&n.push({bump:"major",source:"package",message:`Removed \`${a}\` (\`${e[a]}\`)`});let s=new Set(t.files??[]);for(let a of e.files??[])s.has(a)||n.push({bump:"major",source:"package",message:`Removed \`files\` entry \`${a}\``});return n.push(...vs("peer dependency",e.peerDependencies,t.peerDependencies),...vs("dependency",e.dependencies,t.dependencies),...Hu(e.engines,t.engines)),n}var Ju=["test/","tests/",".github/","docs/"];function qn(e){return Ju.some(t=>e.startsWith(t))}function zu(e){return qn(e)?!1:/(^|\/)(src|demo)\//u.test(e)||/(^|\/)README\.md$/u.test(e)}function $s(e){let t=e.filter(zu);if(t.length===0)return[];let n=t.slice(0,5).map(o=>`\`${o}\``),r=t.length>n.length?` and ${t.length-n.length} more`:"";return[{bump:"patch",source:"files",message:`Changed published files: ${n.join(", ")}${r}`}]}var Pt={install:"npm ci --no-audit --no-fund",build:"npm run build",pin:"npm install --no-save --no-audit --no-fund"},Vu="custom-elements.json";function Yn(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function Ku(e){return e.charAt(0).toLowerCase()+e.slice(1)}function qu(e,t,n,r){let o="Commits declare no release.";if(e!=="none"){let c=[...new Set(r.filter(u=>u.bump===e).map(u=>u.type??"breaking change"))];o=`Commits declare ${c.length?c.map(u=>`\`${u}\``).join(", "):"a release"} (${e}).`}if(t==="none")return`${o} Code requires no release.`;let i=n.filter(c=>c.bump===t).map(c=>Ku(c.message)),s=i.slice(0,3).join("; "),a=i.length>3?`; and ${i.length-3} more`:"";return`${o} Code requires ${t}: ${s}${a}.`}async function Yu(e,t,n){let{baseSha:r,headSha:o,manifestPath:i,rebuild:s,commands:a}=t,c=async d=>Yn(await St(e,d,i)),l={manifests:null,baseWithHeadGenerator:null,generators:null};if(!s){let d=await c(o),f=await c(r);return!d||!f?(n.push(`No ${i} at the ${d?"base":"head"} ref, so the public API wasn't compared.`),l):{...l,manifests:{base:f,head:d}}}let u;try{u=await At(e,o,i,a)}catch(d){throw new Error(`Could not build ${i} at the head ref: ${d.message}`)}let m=null;try{m=await At(e,r,i,a)}catch(d){let f=await c(r);if(n.push(f?`The base ref didn't build, so its committed ${i} was used: ${d.message.split(`
|
|
255
|
-
`)[0]}`:`The base ref didn't build and has no committed ${i}, so the public API wasn't compared.`),!f)return{...l,generators:{base:null,head:u.generator}};
|
|
256
|
-
`)[0]}`)}return{manifests:{base:
|
|
254
|
+
${a}`))})})}var At="@aurodesignsystem/auro-cli",Hn="@custom-elements-manifest/analyzer";function Bn(e,t){for(let n of[z(e,"node_modules",t),z(e,"node_modules",At,"node_modules",t)])if(rs(z(n,"package.json")))return n;return null}async function ns(e,t){let n=Bn(e,t);if(n)return JSON.parse(await Wn(z(n,"package.json"),"utf-8")).version}function us(e,t){return e.auroCli!==t.auroCli||e.analyzer!==t.analyzer}async function Ru(e){let t=await ns(e,At),n=await ns(e,Hn);return t||n?{auroCli:t,analyzer:n}:null}async function Pu(e){if(JSON.parse(await Wn(z(e,"package.json"),"utf-8")).scripts?.analyze)return"npm run analyze";let n=Bn(e,At),r=Bn(e,Hn),o=n?z(n,"dist","configs","custom-elements-manifest.config.mjs"):null;return!o||!rs(o)||!r?null:`node "${z(r,"cem.js")}" analyze --config "${o}"`}async function xt(e,t,n,r,o){let i=await wu(z($u(),"auro-api-diff-"));xu(i,e);try{if(await pe(e,["worktree","add","--detach","--force",i,t]),await Gn(r.install,i),o){let c=[o.auroCli&&`${At}@${o.auroCli}`,o.analyzer&&`${Hn}@${o.analyzer}`].filter(Boolean);await Gn(`${r.pin} ${c.join(" ")}`,i)}let s=await Ru(i),a=o?await Pu(i):null;return await Gn(a??r.build,i),{manifest:JSON.parse(await Wn(z(i,n),"utf-8")),generator:s}}finally{await pe(e,["worktree","remove","--force",i]).catch(()=>{}),await vu(i,{recursive:!0,force:!0}).catch(()=>{}),Tu(i)}}function ms(e){let t=new Map;for(let n of e.modules??[])for(let r of n.declarations??[]){let{tagName:o}=r;o&&!t.has(o)&&t.set(o,{tagName:o,className:r.name,declaration:r})}return t}function ke(e){return e.privacy===void 0||e.privacy==="public"}function Du(e){return e.static?`static ${e.name}`:e.name}function Jn(e){let t=e.kind==="field"?"property":e.kind;return e.static?`static ${t}`:t}function Rt(e){return e.replace(/['`]/gu,'"').replace(/\s+/gu," ").trim()}function Mu(e){let t=Rt(e),n=/^\{\s*("[^"]*"|-?\d+(?:\.\d+)?|true|false|null|undefined)\s*\}$/u.exec(t);return n?n[1]:t}function ps(e){let t=[],n=0,r=null,o="";for(let s of e){if(r)s===r&&(r=null);else if(s==='"'||s==="'"||s==="`")r=s;else if("([{<".includes(s))n++;else if(")]}>".includes(s)&&!(s===">"&&o.endsWith("=")))n--;else if((s==="|"||s===",")&&n===0){t.push(o),o="";continue}o+=s}t.push(o);let i={String:"string",Number:"number",Boolean:"boolean"};return t.map(Rt).filter(s=>s.length>0).map(s=>i[s]??s)}function Nu(e){return/^".*"$/u.test(e)?"string":/^-?\d+(?:\.\d+)?$/u.test(e)?"number":e==="true"||e==="false"?"boolean":null}function ds(e,t){let n=Nu(t);return e.includes(t)||n!==null&&e.includes(n)}function zn(e,t,n){if(t===void 0||n===void 0)return null;let r=ps(t),o=ps(n),i=r.filter(c=>!ds(o,c)),s=o.filter(c=>!ds(r,c));if(i.length===0&&s.length===0)return null;let a=c=>c.map(l=>`\`${l}\``).join(", ");return i.length>0&&s.length>0?{bump:"major",source:"manifest",message:`Changed type of ${e} from \`${Rt(t)}\` to \`${Rt(n)}\``}:i.length>0?{bump:"major",source:"manifest",message:`Narrowed type of ${e} (removed ${a(i)})`}:{bump:"minor",source:"manifest",message:`Widened type of ${e} (added ${a(s)})`}}function hs(e,t,n){let r=s=>{let a=s===void 0?void 0:Mu(s);return a==="undefined"?void 0:a},o=r(t),i=r(n);return o===i?null:o===void 0?{bump:"minor",source:"manifest",message:`Added default \`${i}\` to ${e}`}:i===void 0?{bump:"minor",source:"manifest",message:`Removed default \`${o}\` from ${e}`}:{bump:"major",source:"manifest",message:`Changed default of ${e} from \`${o}\` to \`${i}\``}}function Vn(e){return typeof e.name=="string"&&e.name!==""}function Kn(e,t,n){let r=[],o=(c,l)=>r.push({bump:c,source:"manifest",message:l}),i=t.requiredWhen,s=n.requiredWhen;i!==s&&(i===void 0?o("major",`Made ${e} required when \`${s}\``):s===void 0?o("minor",`Made ${e} no longer required`):i==="always"?o("minor",`Made ${e} required only when \`${s}\``):o("major",`Changed when ${e} is required from \`${i}\` to \`${s}\``));let a=(c,l)=>{let u=t[c],p=n[c];if(u===p)return;let m=c==="minimum"?"minimum":"maximum";u===void 0?o("major",`Added ${m} \`${p}\` to ${e}`):p===void 0?o("minor",`Removed ${m} \`${u}\` from ${e}`):l(p,u)?o("major",`Tightened ${m} of ${e} from \`${u}\` to \`${p}\``):o("minor",`Loosened ${m} of ${e} from \`${u}\` to \`${p}\``)};a("minimum",(c,l)=>c>l),a("maximum",(c,l)=>c<l),!t.readonly&&n.readonly?o("major",`Made ${e} read-only`):t.readonly&&!n.readonly&&o("minor",`Made ${e} writable`),!t.deprecated&&n.deprecated?o("minor",`Deprecated ${e}`):t.deprecated&&!n.deprecated&&o("minor",`Removed the deprecation of ${e}`);for(let c of["relevantWhen","category"]){let l=t[c],u=n[c];l!==u&&(l===void 0?o("minor",`Added \`${c}\` \`${u}\` to ${e}`):u===void 0?o("minor",`Removed \`${c}\` \`${l}\` from ${e}`):o("minor",`Changed \`${c}\` of ${e} from \`${l}\` to \`${u}\``))}return r}function Iu(e,t=[],n=[]){let r=[],o=(s,a)=>r.push({bump:s,source:"manifest",message:a}),i=s=>!!(s.optional||s.rest);for(let s=0;s<Math.max(t.length,n.length);s++){let a=t[s],c=n[s];if(a&&!c)o("major",`Removed parameter \`${a.name}\` from ${e}`);else if(!a&&c)o(i(c)?"minor":"major",`Added ${i(c)?"optional":"required"} parameter \`${c.name}\` to ${e}`);else if(a&&c){let l=`parameter \`${c.name}\` of ${e}`;i(a)&&!i(c)?o("major",`Made ${l} required`):!i(a)&&i(c)&&o("minor",`Made ${l} optional`);let u=zn(l,a.type?.text,c.type?.text);u&&r.push(u)}}return r}function fs(e){let t=new Map;for(let n of e.members??[])Vn(n)&&t.set(Du(n),n);return t}function gs(e,t){let n=new Map;for(let r of e.attributes??[]){let o=r.fieldName?t.get(r.fieldName):void 0;!Vn(r)||r.internal||o&&!ke(o)||n.set(r.name.toLowerCase(),r)}return n}function Ou(e,t,n){let r=[],o=`\`<${e}>\``;for(let[i,s]of t){if(!ke(s))continue;let a=n.get(i),c=Jn(s);if(!a){r.push({bump:"major",source:"manifest",message:`Removed ${c} \`${s.name}\` from ${o}`});continue}if(!ke(a)){r.push({bump:"major",source:"manifest",message:`Made ${c} \`${s.name}\` on ${o} ${a.privacy}`});continue}if(a.kind!==s.kind){r.push({bump:"major",source:"manifest",message:`Changed \`${s.name}\` on ${o} from a ${c} to a ${Jn(a)}`});continue}let l=`${c} \`${s.name}\` on ${o}`;if(r.push(...Kn(l,s,a)),s.kind==="method"&&r.push(...Iu(l,s.parameters,a.parameters)),s.kind==="field"){s.reflects&&!a.reflects&&r.push({bump:"major",source:"manifest",message:`Attribute \`${s.attribute??s.name}\` on ${o} no longer reflects`});for(let u of[zn(l,s.type?.text,a.type?.text),hs(l,s.default,a.default)])u&&r.push(u)}}for(let[i,s]of n){if(!ke(s))continue;let a=t.get(i),c=Jn(s);a?ke(a)||r.push({bump:"minor",source:"manifest",message:`Made ${a.privacy} ${c} \`${s.name}\` on ${o} public`}):r.push({bump:"minor",source:"manifest",message:`Added ${c} \`${s.name}\` to ${o}`})}return r}function ju(e,t,n,r,o){let i=[],s=`\`<${e}>\``,a=gs(t,r),c=gs(n,o),l=d=>new Set((d.attributes??[]).filter(Vn).map(f=>f.name.toLowerCase())),u=l(n),p=l(t),m=(d,f)=>{let h=d.fieldName?f.get(d.fieldName):void 0;return h!==void 0&&ke(h)};for(let[d,f]of a){let{name:h}=f,g=c.get(d);if(!g){i.push({bump:"major",source:"manifest",message:u.has(d)?`Made attribute \`${h}\` on ${s} private`:`Removed attribute \`${h}\` from ${s}`});continue}if(m(f,r)||m(g,o))continue;let y=`attribute \`${h}\` on ${s}`;for(let v of[zn(y,f.type?.text,g.type?.text),hs(y,f.default,g.default)])v&&i.push(v);i.push(...Kn(y,f,g))}for(let[d,{name:f}]of c)a.has(d)||i.push({bump:"minor",source:"manifest",message:p.has(d)?`Made private attribute \`${f}\` on ${s} public`:`Added attribute \`${f}\` to ${s}`});return i}function Tt(e,t,n,r){let o=u=>t==="slot"&&u===""?"default slot":`${t} \`${u}\``,i=`\`<${e}>\``,s=u=>new Set((u??[]).map(p=>p.name).filter(p=>typeof p=="string")),a=s(n),c=s(r),l=[];for(let u of a)c.has(u)||l.push({bump:"major",source:"manifest",message:`Removed ${o(u)} from ${i}`});for(let u of c)a.has(u)||l.push({bump:"minor",source:"manifest",message:`Added ${o(u)} to ${i}`});return l}var _u=[{key:"slots",describe:(e,t)=>e===""?`default slot of \`<${t}>\``:`slot \`${e}\` on \`<${t}>\``},{key:"cssParts",describe:(e,t)=>`CSS part \`${e}\` on \`<${t}>\``},{key:"cssProperties",describe:(e,t)=>`CSS custom property \`${e}\` on \`<${t}>\``}];function Fu(e,t,n){return _u.flatMap(({key:r,describe:o})=>{let i=new Map((n[r]??[]).map(s=>[s.name,s]));return(t[r]??[]).flatMap(s=>{let a=i.get(s.name);return typeof s.name!="string"||!a?[]:Kn(o(s.name,e),s,a)})})}function Lu(e,t,n){let r=fs(t),o=fs(n);return[...Fu(e,t,n),...ju(e,t,n,r,o),...Ou(e,r,o),...Tt(e,"event",t.events,n.events),...Tt(e,"slot",t.slots,n.slots),...Tt(e,"CSS part",t.cssParts,n.cssParts),...Tt(e,"CSS custom property",t.cssProperties,n.cssProperties)]}function qn(e,t){let n=ms(e),r=ms(t),o=[],i=new Map;for(let[a,c]of n){if(r.has(a))continue;let l=[...r.values()].find(u=>u.className===c.className&&!n.has(u.tagName));l&&i.set(a,l.tagName)}let s=new Set(i.values());for(let[a,c]of n){let l=r.get(a);if(l){o.push(...Lu(a,c.declaration,l.declaration));continue}let u=i.get(a);o.push({bump:"major",source:"manifest",message:u?`Renamed element \`<${a}>\` to \`<${u}>\``:`Removed element \`<${a}>\``})}for(let a of r.keys())!n.has(a)&&!s.has(a)&&o.push({bump:"minor",source:"manifest",message:`Added element \`<${a}>\``});return o}import Pt from"semver";function ys(e){if(e==null)return new Set;if(typeof e=="object"&&!Array.isArray(e)){let t=Object.keys(e);if(t.every(n=>n.startsWith(".")))return new Set(t)}return new Set(["."])}function Gu(e,t){let n=e;if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let i=e;Object.keys(i).every(s=>s.startsWith("."))&&(n=i[t])}let r=[],o=i=>{typeof i=="string"?r.push(i):Array.isArray(i)?i.forEach(o):i&&typeof i=="object"&&Object.values(i).forEach(o)};return o(n),r}var Bu=/^(package-lock\.json|\.npmrc|node_modules\/|\.git\/)/u,Wu=/^(package\.json|readme(\.[^/]*)?|licen[cs]e(\.[^/]*)?)$/iu;function bs(e){let t=e.indexOf("*");return t===-1?e:e.slice(0,t)}function Uu(e,t){let n=e.replace(/^\.\//u,"");if(Bu.test(n))return!1;if(!t||Wu.test(n))return!0;let r=bs(n);return t.some(o=>{let i=o.replace(/^\.\//u,"").replace(/\/$/u,"");return i.includes("*")?r.startsWith(bs(i)):n===i||n.startsWith(`${i}/`)})}function ws(e,t){return Gu(e.exports,t).some(n=>Uu(n,e.files))}function vs(e){try{let t=Pt.minVersion(e);return t?t.major>0?`${t.major}`:`0.${t.minor}`:null}catch{return null}}function ks(e,t={},n={}){let r=[];for(let[o,i]of Object.entries(n)){let s=t[o];if(s===void 0)continue;let a=vs(s),c=vs(i);a!==null&&c!==null&&a!==c&&r.push({bump:"major",source:"package",message:`Bumped ${e} \`${o}\` from \`${s}\` to \`${i}\``})}return r}function Hu(e={},t={}){let n=[];for(let[r,o]of Object.entries(t)){let i=e[r],s=`engine \`${r}\``;if(i===void 0){n.push({bump:"major",source:"package",message:`Added ${s} requirement \`${o}\``});continue}let a=null,c=null;try{a=Pt.minVersion(i),c=Pt.minVersion(o)}catch{continue}a&&c&&Pt.gt(c,a)&&n.push({bump:"major",source:"package",message:`Tightened ${s} from \`${i}\` to \`${o}\``})}return n}function $s(e,t){let n=[],r=ys(e.exports),o=ys(t.exports),i=e.exports===void 0&&t.exports!==void 0;i&&n.push({bump:"major",source:"package",message:"Added `exports`, which blocks imports of unlisted paths"});for(let a of r)o.has(a)||n.push(ws(e,a)?{bump:"major",source:"package",message:`Removed export \`${a}\``}:{bump:"patch",source:"package",message:`Removed export \`${a}\`, which never resolved: its target isn't in the published package`});for(let a of o)!i&&!r.has(a)&&n.push(ws(t,a)?{bump:"minor",source:"package",message:`Added export \`${a}\``}:{bump:"patch",source:"package",message:`Added export \`${a}\`, which won't resolve: its target isn't in the published package`});for(let a of["main","types","typings"])e[a]!==void 0&&t[a]===void 0&&n.push({bump:"major",source:"package",message:`Removed \`${a}\` (\`${e[a]}\`)`});let s=new Set(t.files??[]);for(let a of e.files??[])s.has(a)||n.push({bump:"major",source:"package",message:`Removed \`files\` entry \`${a}\``});return n.push(...ks("peer dependency",e.peerDependencies,t.peerDependencies),...ks("dependency",e.dependencies,t.dependencies),...Hu(e.engines,t.engines)),n}var Ju=["test/","tests/",".github/","docs/"];function Yn(e){return Ju.some(t=>e.startsWith(t))}function zu(e){return Yn(e)?!1:/(^|\/)(src|demo)\//u.test(e)||/(^|\/)README\.md$/u.test(e)}function Es(e){let t=e.filter(zu);if(t.length===0)return[];let n=t.slice(0,5).map(o=>`\`${o}\``),r=t.length>n.length?` and ${t.length-n.length} more`:"";return[{bump:"patch",source:"files",message:`Changed published files: ${n.join(", ")}${r}`}]}var Dt={install:"npm ci --no-audit --no-fund",build:"npm run build",pin:"npm install --no-save --no-audit --no-fund"},Vu="custom-elements.json";function Xn(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function Ku(e){return e.charAt(0).toLowerCase()+e.slice(1)}function qu(e,t,n,r){let o="Commits declare no release.";if(e!=="none"){let c=[...new Set(r.filter(u=>u.bump===e).map(u=>u.type??"breaking change"))];o=`Commits declare ${c.length?c.map(u=>`\`${u}\``).join(", "):"a release"} (${e}).`}if(t==="none")return`${o} Code requires no release.`;let i=n.filter(c=>c.bump===t).map(c=>Ku(c.message)),s=i.slice(0,3).join("; "),a=i.length>3?`; and ${i.length-3} more`:"";return`${o} Code requires ${t}: ${s}${a}.`}async function Yu(e,t,n){let{baseSha:r,headSha:o,manifestPath:i,rebuild:s,commands:a}=t,c=async d=>Xn(await Ct(e,d,i)),l={manifests:null,baseWithHeadGenerator:null,generators:null};if(!s){let d=await c(o),f=await c(r);return!d||!f?(n.push(`No ${i} at the ${d?"base":"head"} ref, so the public API wasn't compared.`),l):{...l,manifests:{base:f,head:d}}}let u;try{u=await xt(e,o,i,a)}catch(d){throw new Error(`Could not build ${i} at the head ref: ${d.message}`)}let p=null;try{p=await xt(e,r,i,a)}catch(d){let f=await c(r);if(n.push(f?`The base ref didn't build, so its committed ${i} was used: ${d.message.split(`
|
|
255
|
+
`)[0]}`:`The base ref didn't build and has no committed ${i}, so the public API wasn't compared.`),!f)return{...l,generators:{base:null,head:u.generator}};p={manifest:f,generator:null}}let m=null;if(u.generator&&p.generator&&us(p.generator,u.generator))try{m=(await xt(e,r,i,a,u.generator)).manifest}catch(d){n.push(`The base didn't build with the head's generator, so changes couldn't be split between the code and the generator upgrade: ${d.message.split(`
|
|
256
|
+
`)[0]}`)}return{manifests:{base:p.manifest,head:u.manifest},baseWithHeadGenerator:m,generators:{base:p.generator,head:u.generator}}}function Ss(e){return e?e.auroCli?`auro-cli ${e.auroCli}`:`analyzer ${e.analyzer}`:"unknown"}async function Cs(e,t="HEAD",n={}){let r=n.cwd??process.cwd(),o=n.rebuild??!0,i={...Dt,...n.commands},s=[],a=await Un(r,e),c=await Un(r,t),l=await os(r,a,c),u=await ss(r,l,c),p=Xn(await Ct(r,l,"package.json"))??{},m=Xn(await Ct(r,c,"package.json"))??{},d=n.manifest??m.customElements??Vu,f=[],h=null,g=0;if(u.some(w=>!Yn(w))){let w=n.manifests?{manifests:n.manifests,baseWithHeadGenerator:null,generators:null}:await Yu(r,{baseSha:l,headSha:c,manifestPath:d,rebuild:o,commands:i},s);if(h=w.generators,w.manifests){let ne=qn(w.manifests.base,w.manifests.head);if(w.baseWithHeadGenerator){let re=new Set(qn(w.baseWithHeadGenerator,w.manifests.head).map(ge=>ge.message));for(let ge of ne)ge.cause=re.has(ge.message)?"code":"generator";g=ne.filter(ge=>ge.cause==="generator").length}f.push(...ne)}}f.push(...$s(p,m),...Es(u));let y=Yo(f),v=Ko(y.map(w=>w.bump)),_=es(r),A=await is(r,l,c),k=await ts(A,_,r);A.length>0&&_.source==="default"&&s.push("The repo's release config couldn't be resolved, so commits were read with the shared auro-config rules, which may differ from how the repo releases.");let b=qu(k.bump,v,y,k.commits);return g>0&&h&&(b+=` ${g} of the manifest changes come from upgrading ${Ss(h.base)} to ${Ss(h.head)}, not from the component's code; they still change the published manifest.`),{required:v,reasons:y.map(w=>w.message),declared:k.bump,outcome:qo(k.bump,v),summary:b,base:a,head:c,mergeBase:l,changes:y,commits:k.commits,releaseConfig:_.source,generators:h,warnings:s}}var Qu={pass:"\u2714",warn:"\u26A0",fail:"\u2716"};async function em(e,t,n={}){let r=n.json?null:Zu(`Comparing ${e}...${t??"HEAD"}...`).start(),o;try{o=await Cs(e,t,{rebuild:n.rebuild,manifest:n.manifest,commands:{install:n.installCommand,build:n.buildCommand}})}catch(s){let a=`api-diff failed: ${s.message}`;r?r.fail(a):console.error(a),Zn.exit(2)}let i=!!n.enforce&&o.outcome==="fail";if(n.json)Zn.stdout.write(`${JSON.stringify(o,null,2)}
|
|
257
257
|
`);else{if(r?.stop(),console.error(`${Qu[o.outcome]} ${o.summary}`),o.changes.length>0){console.error(`
|
|
258
258
|
Changes:`);for(let s of o.changes){let a=s.cause==="generator"?" (generator upgrade)":"";console.error(` [${s.bump}] ${s.message}${a}`)}}if(o.commits.length>0){console.error(`
|
|
259
259
|
Commits:`);for(let s of o.commits)console.error(` [${s.bump}] ${s.hash.slice(0,7)} ${s.subject}`)}for(let s of o.warnings)console.error(`
|
|
260
|
-
\u26A0 ${s}`)}i&&
|
|
261
|
-
|---|---|---|`,
|
|
262
|
-
`)}var rm=Qn
|
|
260
|
+
\u26A0 ${s}`)}i&&Zn.exit(1)}var pb=Xu.command("api-diff <baseRef> [headRef]").description("Work out the smallest version bump the changes from baseRef to headRef (default HEAD) require, and check the commits declare at least that much.").option("--json","Output the result as JSON on stdout",!1).option("--enforce","Exit 1 when the commits declare a smaller bump than the code requires",!1).option("--no-rebuild","Compare the committed custom-elements.json files instead of rebuilding them").option("--manifest <path>","Manifest path relative to the repo root (default: package.json customElements, else custom-elements.json)").option("--install-command <cmd>","Command that installs dependencies in each rebuilt checkout",Dt.install).option("--build-command <cmd>","Command that writes the manifest in each rebuilt checkout",Dt.build).action(em);import cm from"node:fs/promises";import lm from"node:path";import{program as um}from"commander";import or from"ora";var tm='# 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',nm=`| Element Tag | Package | Description |
|
|
261
|
+
|---|---|---|`,Qn=[{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 er(e){return e.map(t=>`| \`<${t.tag}>\` | \`${t.pkg}\` | ${t.description.replace(/\|/gu,"\\|")} |`).join(`
|
|
262
|
+
`)}var rm=er(Qn),om=`## Common Patterns
|
|
263
263
|
|
|
264
264
|
### Button (default, secondary, tertiary)
|
|
265
265
|
\`\`\`html
|
|
@@ -337,14 +337,14 @@ document.querySelector('#confirmDialog').show();
|
|
|
337
337
|
- Design tokens: https://auro.alaskaair.com/getting-started/developers/token-usage
|
|
338
338
|
- Contributing: https://auro.alaskaair.com/getting-started/developers/contributing
|
|
339
339
|
- GitHub: https://github.com/AlaskaAirlines
|
|
340
|
-
`;function
|
|
340
|
+
`;function tr(e){return`${tm}${nm}
|
|
341
341
|
${e}
|
|
342
342
|
|
|
343
|
-
${om}`}var fb=
|
|
344
|
-
`)}async function mm(e){let t=new Map;for(let s of
|
|
345
|
-
Paste this file into your AI coding tool (Claude, Cursor, Copilot, etc.) to prime it on Auro components.`)}catch(l){let u=l instanceof Error?l.message:String(l);c.fail(`Failed to write context: ${u}`),process.exit(1)}}else process.stdout.write(a);t&&s.size>0&&await pm(s)}var Mb=um.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(dm);import yp from"node:fs/promises";import bp from"node:path";import
|
|
343
|
+
${om}`}var fb=tr(rm);function S(e){return(e??"").replace(/\s+/gu," ").trim()}import T from"chalk";var B="@aurodesignsystem/auro-formkit",nr=["@aurodesignsystem/auro-input","@aurodesignsystem/auro-select","@aurodesignsystem/auro-combobox","@aurodesignsystem/auro-menu","@aurodesignsystem/auro-checkbox","@aurodesignsystem/auro-radio","@aurodesignsystem/auro-datepicker","@aurodesignsystem/auro-dropdown","@aurodesignsystem/auro-form"],sm=new Set(nr);function X(e){return sm.has(e)}function rr(e){return e.slice(18)}function $e(e){return`${B}/${rr(e)}`}var im=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/u;function As(e){let t=im.exec(e.trim());return t?{main:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]?t[4].split("."):[]}:null}function am(e,t){let n=As(e),r=As(t);if(!n||!r)return null;for(let i=0;i<3;i+=1)if(n.main[i]!==r.main[i])return n.main[i]<r.main[i]?-1:1;if(n.pre.length===0&&r.pre.length===0)return 0;if(n.pre.length===0)return 1;if(r.pre.length===0)return-1;let o=Math.max(n.pre.length,r.pre.length);for(let i=0;i<o;i+=1){let s=n.pre[i],a=r.pre[i];if(s===void 0)return-1;if(a===void 0)return 1;let c=/^\d+$/u.test(s),l=/^\d+$/u.test(a);if(c&&l){let u=Number(s)-Number(a);if(u!==0)return u<0?-1:1}else{if(c!==l)return c?-1:1;if(s!==a)return s<a?-1:1}}return 0}async function Ee(e){let t=[...e.entries()],n=await Promise.all(t.map(([o])=>Co(o))),r=[];return t.forEach(([o,i],s)=>{let a=n[s];if(!a)return;let c=am(i,a);c!==null&&c<0&&r.push({pkg:o,installed:i,latest:a})}),r}var xs=" \u21E2 auro-formkit";function Se(e){if(e.length===0)return"";let t=e.filter(m=>X(m.pkg)),n=e.filter(m=>!X(m.pkg)),r=`\u26A0 ${e.length} Auro component(s) are NOT on the latest release`,o=Math.max(...e.map(m=>m.pkg.length)),i=Math.max(...e.map(m=>m.installed.length)),s=m=>X(m.pkg),a=e.map(m=>{let d=` ${T.bold(m.pkg.padEnd(o))} ${T.dim(m.installed.padStart(i))} ${T.dim("\u2192")} ${T.green.bold(m.latest)}`;return s(m)?`${d}${T.yellow(xs)}`:d}),c=[];if(n.length>0){let m=`npm install ${n.map(d=>`${d.pkg}@latest`).join(" ")}`;c.push("",T.dim(" Update to latest with:"),` ${T.cyan(m)}`)}if(t.length>0){c.push("",T.dim(" Migrate to auro-formkit (run `auro init`):"));for(let m of t)c.push(` ${T.dim(m.pkg)} ${T.dim("\u2192")} ${T.cyan($e(m.pkg))}`)}let l=[r.length+1,...e.map(m=>{let d=2+o+2+i+3+m.latest.length;return s(m)?d+xs.length:d})],u=Math.min(Math.max(...l),78),p="\u2500".repeat(u);return["",T.yellow.bold(`\u250C${p}\u2510`),T.yellow.bold(r),T.yellow.bold(`\u2514${p}\u2518`),...a,...c,""].join(`
|
|
344
|
+
`)}async function mm(e){let t=new Map;for(let s of Qn)t.set(s.tag,{...s});let n=await Promise.all(O.map(s=>j(s,{allowNetwork:e}))),r=new Map(Rn(n).map(s=>[s.pkg,s.version])),o=0,i=0;for(let s of n){if(!s.manifest)continue;o+=1;let a=(s.manifest.modules??[]).flatMap(c=>c.declarations??[]).filter(c=>c.customElement&&c.tagName);for(let c of a){let l=c.tagName,u=S(c.summary||c.description),p=t.get(l);t.set(l,{tag:l,pkg:s.target,description:u||p?.description||""}),u&&(i+=1)}}return{rows:er([...t.values()]),resolved:o,enriched:i,local:r}}async function pm(e){let t=or("Checking for newer component releases...").start(),n=await Ee(e);if(n.length===0){t.succeed("All installed Auro components are on the latest release.");return}t.stop(),console.error(Se(n))}async function dm(e){let t=!e.offline,n=or(t?"Resolving component manifests...":"Reading installed component manifests...").start(),{rows:r,resolved:o,enriched:i,local:s}=await mm(t),a=tr(r);if(t?i>0?n.succeed(s.size>0?`Enriched ${i} component description(s); ${s.size} package(s) resolved from local node_modules.`:`Enriched ${i} component description(s) from unpkg.`):o>0?n.succeed(`Resolved ${o} component manifest(s); none documented a description, using the built-in table.`):n.warn("No manifests available; using the built-in component table."):s.size>0?n.succeed(i>0?`Read ${s.size} installed component manifest(s) from local node_modules; enriched ${i} description(s).`:`Read ${s.size} installed component manifest(s) from local node_modules; none documented a description, using the built-in table.`):n.warn("No installed component manifests found; using the built-in component table."),e.output){let c=or(`Writing context to ${e.output}...`).start();try{let l=lm.resolve(process.cwd(),e.output);await cm.writeFile(l,a,"utf-8"),c.succeed(`Auro context written to ${e.output}`),console.error(`
|
|
345
|
+
Paste this file into your AI coding tool (Claude, Cursor, Copilot, etc.) to prime it on Auro components.`)}catch(l){let u=l instanceof Error?l.message:String(l);c.fail(`Failed to write context: ${u}`),process.exit(1)}}else process.stdout.write(a);t&&s.size>0&&await pm(s)}var Mb=um.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(dm);import yp from"node:fs/promises";import bp from"node:path";import ee from"node:process";import{program as wp}from"commander";import te from"inquirer";import Je from"ora";var M="auro.config.json";import{existsSync as Ts,readFileSync as Rs,statSync as fm}from"node:fs";import Mt from"node:path";import{parse as Ps}from"jsonc-parser";var Ds=["vscode","jsx","svelte","cssSnippets"];function Ms(e,t){try{return fm(Mt.join(e,t)).isDirectory()}catch{return!1}}function Ns(e){try{let t=Rs(Mt.join(e,"package.json"),"utf-8"),n=Ps(t,[],{allowTrailingComma:!0});return typeof n!="object"||n===null?new Set:new Set([...Object.keys(n.dependencies??{}),...Object.keys(n.devDependencies??{})])}catch{return new Set}}function gm(e){return Ms(e,x)}function hm(e){return Ms(e,x)}function ym(e){let t=Mt.join(e,"tsconfig.json");if(Ts(t))try{let n=Rs(t,"utf-8"),r=Ps(n,[],{allowTrailingComma:!0});if(typeof r=="object"&&r!==null&&r.compilerOptions?.jsx!==void 0)return!0}catch{}return Ns(e).has("react")}function bm(e){return Ns(e).has("svelte")?!0:["js","ts","mjs","cjs"].some(t=>Ts(Mt.join(e,`svelte.config.${t}`)))}function Is(e){return{vscode:gm(e),jsx:ym(e),svelte:bm(e),cssSnippets:hm(e)}}import{existsSync as sr,readFileSync as wm}from"node:fs";import Os from"node:path";import{parse as js}from"jsonc-parser";function Nt(e,t){return Os.join(e,...t.split("/"))}function _s(e){try{return wm(e,"utf-8")}catch{return null}}function vm(e){let t=_s(Nt(e,`${x}/${ce}`));if(t===null)return!1;let r=js(t,[],{allowTrailingComma:!0})?.[P];return typeof r=="string"?r===H:Array.isArray(r)?r.includes(H):!1}function km(e){for(let t of["tsconfig.json","jsconfig.json"]){let n=_s(Os.join(e,t));if(n===null)continue;let r=js(n,[],{allowTrailingComma:!0}),o=r?.[D];return Array.isArray(o)?o.includes(J):!(o!==void 0||"files"in(r??{}))}return!0}function ir(e,t){let n=[];return t.vscode&&(sr(Nt(e,le))||n.push(`${le} is missing \u2014 VS Code markup completions will not work.`),vm(e)||n.push(`${x}/${ce} does not register "${H}" under "${P}".`)),t.svelte&&!sr(Nt(e,me))&&n.push(`${me} is missing.`),t.jsx&&!sr(Nt(e,ue))&&n.push(`${ue} is missing.`),(t.svelte||t.jsx)&&!km(e)&&n.push(`${J} is not on the TypeScript program (missing from "${D}").`),{inconsistencies:n,markupDisabled:!t.vscode}}import Ce from"node:fs/promises";import jt from"node:path";var $m="css,scss,less";function Em(e){return!/[,|}]/u.test(e)}function Sm(e){return(e.declaration.cssParts??[]).map(t=>t.name).filter(t=>typeof t=="string"&&t!=="").filter(Em)}function Cm(e,t){let n=`\${1|${t.join(",")}|}`;return{scope:$m,prefix:`${e}::part`,body:[`${e}::part(${n}) {`," $0","}"],description:`Style a shadow part of <${e}> (${t.join(", ")})`}}function Fs(e,t){let n={};for(let r of e){let o=Sm(r);if(o.length===0)continue;let i=Tn(r,t);n[`Auro <${i}> ::part`]=Cm(i,o)}return Object.keys(n).length===0?null:{filename:gt,contents:Y(JSON.stringify(n,null,2))}}import{getVsCodeHtmlCustomData as Am}from"custom-element-vs-code-integration";function Ls(e,t){let n=ye(e,t),r=q(o=>Am(n,{outdir:o,htmlFileName:"auro.html-custom-data.json",hideLogs:!0}));return{filename:le,contents:Y(r)}}import{applyEdits as Gs,modify as Bs,parse as xm,parseTree as Tm}from"jsonc-parser";var Ws={tabSize:2,insertSpaces:!0};function Rm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function It(e,t){if(e.trim()==="")return{data:{}};let n=[],r=xm(e,n,{allowTrailingComma:!0});return n.length>0?{warning:`${t} is not valid JSON \u2014 leaving it untouched.`}:Rm(r)?{data:r}:{warning:`${t} is not a JSON object \u2014 leaving it untouched.`}}function He(e,t,n){let r=e.trim()===""?"{}":e,o=Bs(r,t,n,{formattingOptions:Ws});return Gs(r,o)}function Pm(e,t){let n=Tm(e);if(!n||n.type!=="object"||n.children?.length!==1)return null;let r=n.children[0];if(r.children?.[0]?.value!==t)return null;let o=r.offset+r.length;for(;o<e.length&&e[o]===",";)o++;return e.slice(0,r.offset)+e.slice(o)}function ar(e,t){if(t.length===1){let r=Pm(e,t[0]);if(r!==null)return r}let n=Bs(e,t,void 0,{formattingOptions:Ws});return Gs(e,n)}function Us(e,t=H){let n=It(e,".vscode/settings.json");if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let r=n.data[P],o;if(r===void 0)o=[t];else if(typeof r=="string"){if(r===t)return{contents:e,changed:!1};o=[r,t]}else if(Array.isArray(r)){if(r.includes(t))return{contents:e,changed:!1};o=[...r,t]}else return{contents:e,changed:!1,warning:`.vscode/settings.json "${P}" is not a string or array \u2014 leaving it untouched.`};return{contents:He(e,[P],o),changed:!0}}function Hs(e,t=J,n="tsconfig.json"){let r=It(e,n);if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let{data:o}=r,i=o[D];return Array.isArray(i)?i.includes(t)?{contents:e,changed:!1}:{contents:He(e,[D],[...i,t]),changed:!0}:i!==void 0?{contents:e,changed:!1,warning:`${n} "${D}" is not an array \u2014 leaving it untouched.`}:"files"in o?{contents:He(e,[D],[t]),changed:!0}:{contents:e,changed:!1}}function Js(e,t=H){let n=It(e,".vscode/settings.json");if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let r=n.data[P];if(typeof r=="string")return r!==t?{contents:e,changed:!1}:{contents:ar(e,[P]),changed:!0};if(Array.isArray(r)){if(!r.includes(t))return{contents:e,changed:!1};let o=r.filter(s=>s!==t);return{contents:o.length===0?ar(e,[P]):He(e,[P],o),changed:!0}}return{contents:e,changed:!1}}function zs(e,t=J,n="tsconfig.json"){let r=It(e,n);if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let o=r.data[D];if(!Array.isArray(o)||!o.includes(t))return{contents:e,changed:!1};let i=o.filter(a=>a!==t);return{contents:i.length===0?ar(e,[D]):He(e,[D],i),changed:!0}}function Ks(e,t){return jt.join(e,...t.split("/"))}async function Ot(e,t){let n=Ks(e,t.filename);return await Ce.mkdir(jt.dirname(n),{recursive:!0}),await Ce.writeFile(n,t.contents,"utf-8"),t.filename}async function Vs(e){try{return await Ce.readFile(e,"utf-8")}catch(t){if(t.code==="ENOENT")return"";throw t}}async function cr(e,t,n,r){let o=[],i=[];if(r.vscode){o.push(await Ot(e,Ls(t,n)));let s=`${x}/${ce}`,a=Ks(e,s),c=Us(await Vs(a));c.warning?i.push(`${c.warning} Add "${H}" to "${P}" in ${s} by hand.`):c.changed&&(await Ce.mkdir(jt.dirname(a),{recursive:!0}),await Ce.writeFile(a,c.contents,"utf-8"),o.push(s))}if(r.jsx&&o.push(await Ot(e,yt(t,n))),r.svelte&&o.push(await Ot(e,bt(t,n))),r.cssSnippets){let s=Fs(t,n);s&&o.push(await Ot(e,s))}if(r.jsx||r.svelte)for(let s of["tsconfig.json","jsconfig.json"]){let a=jt.join(e,s),c=await Vs(a);if(c==="")continue;let l=Hs(c,J,s);l.warning?i.push(`${l.warning} Add "${J}" to "${D}" in ${s} by hand.`):l.changed&&(await Ce.writeFile(a,l.contents,"utf-8"),o.push(s));break}return{written:o,warnings:i}}var Z="AGENTS.md",de="CLAUDE.md";var _t="Generated by `auro init`",qs=`# Auro Design System \u2014 AI Assistant Grounding
|
|
346
346
|
|
|
347
|
-
<!-- ${
|
|
347
|
+
<!-- ${_t}. Do not edit by hand \u2014 re-run \`auro init\` to
|
|
348
348
|
regenerate. Custom element tags are governed by \`auro.config.json\`. -->
|
|
349
349
|
|
|
350
350
|
Alaska Airlines open-source design system | https://auro.alaskaair.com
|
|
@@ -361,9 +361,9 @@ v1) using the Lit library.
|
|
|
361
361
|
- npm scope: \`@aurodesignsystem/\` (current), \`@alaskaairux/\` (legacy)
|
|
362
362
|
- Framework-agnostic: works with React, Angular, Vue, Svelte, or plain HTML
|
|
363
363
|
- Each component is a separate npm package and registers a custom element tag
|
|
364
|
-
`,
|
|
365
|
-
|---|---|---|---|`,
|
|
366
|
-
`;var
|
|
364
|
+
`,Ys=`| Tag | Package | Version | Import |
|
|
365
|
+
|---|---|---|---|`,Xs="## 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",Ft=`@${Z}
|
|
366
|
+
`;var Zs=`## Auro Coding Rules
|
|
367
367
|
|
|
368
368
|
These rules apply to every Auro component in this project. Use the exact
|
|
369
369
|
registered tags listed under **Installed Components** below: this project uses
|
|
@@ -404,35 +404,35 @@ name.
|
|
|
404
404
|
6. **Accessibility is built in \u2014 don't override it.** Auro components ship WCAG
|
|
405
405
|
2.1 AA behavior (focus management, ARIA, error messaging). Prefer the provided
|
|
406
406
|
slots and attributes over custom ARIA.
|
|
407
|
-
`;var
|
|
408
|
-
`)}function
|
|
409
|
-
`)}function
|
|
410
|
-
`)}function Nm(e,t=new Map){let n=e.map(s=>`| \`<${
|
|
407
|
+
`;var Qs="@aurodesignsystem";function ti(e){let t=e.trim();if(t.startsWith("@"))return t;let n=t.toLowerCase();return n.startsWith("auro-")?`${Qs}/${n}`:`${Qs}/auro-${n}`}function Dm(e){return e.replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}function ei(e){return e?typeof e=="string"?` [deprecated: ${S(e)}]`:" [deprecated]":""}function Ae(e){if(e.length===0)return" (none)";let t=Math.max(...e.map(([n])=>(n??"").length));return e.map(([n,r])=>` ${(n??"").padEnd(t)} ${r??""}`.trimEnd()).join(`
|
|
408
|
+
`)}function ni(e,t,n={}){let{installPkg:r=e,importSpecifier:o=e}=n,i=[];i.push(`${t.tagName} (${e})`);let s=t.summary||t.description;s&&i.push(S(s));let a=t.superclass?.name?`${t.name} extends ${t.superclass.name}`:t.name;return i.push(`Class: ${a}`),i.push(""),i.push("Install:"),i.push(` npm i ${r}`),i.push(` import "${o}";`),i.push(...lr(t)),i.join(`
|
|
409
|
+
`)}function lr(e){let t=[],n=e.attributes??[];t.push(""),t.push(`Attributes (${n.length}):`),t.push(Ae(n.map(l=>{let u=l.type?.text?` {${S(l.type.text)}}`:"",p=l.default?` = ${S(l.default)}`:"";return[l.name,`${S(l.description)}${u}${p}${ei(l.deprecated)}`.trim()]})));let r=new Set(n.flatMap(l=>l.fieldName?[l.fieldName]:[l.name,Dm(l.name)])),o=(e.members??[]).filter(l=>l.name&&(l.privacy===void 0||l.privacy==="public")&&!l.static&&!(l.kind==="field"&&r.has(l.name)));t.push(""),t.push(`Properties & Methods (${o.length}):`),t.push(Ae(o.map(l=>{let u=l.kind==="method",p=u?`${l.name}()`:l.name,m=u?l.return?.type?.text:l.type?.text,d=m?` {${S(m)}}`:"",f=!u&&l.default?` = ${S(l.default)}`:"";return[p,`${S(l.description)}${d}${f}${ei(l.deprecated)}`.trim()]})));let i=e.slots??[];t.push(""),t.push(`Slots (${i.length}):`),t.push(Ae(i.map(l=>[l.name||"(default)",S(l.description)])));let s=e.events??[];t.push(""),t.push(`Events (${s.length}):`),t.push(Ae(s.map(l=>{let u=l.type?.text?` {${S(l.type.text)}}`:"";return[l.name,`${S(l.description)}${u}`.trim()]})));let a=e.cssParts??[];a.length>0&&(t.push(""),t.push(`CSS Parts (${a.length}):`),t.push(Ae(a.map(l=>[l.name,S(l.description)]))));let c=e.cssProperties??[];return c.length>0&&(t.push(""),t.push(`CSS Custom Properties (${c.length}):`),t.push(Ae(c.map(l=>[l.name,S(l.description)])))),t}function ri(e,t){return t.get(e.tagName)??e.tagName}function Mm(e,t){let{pkg:n,importPath:r,declaration:o}=e,i=[`${t} (${n})`],s=o.summary||o.description;s&&i.push(S(s));let a=o.superclass?.name?`${o.name} extends ${o.superclass.name}`:o.name;return i.push(`Class: ${a}`),i.push(""),i.push("Install:"),i.push(` npm i ${n}`),i.push(` import "${r}";`),i.push(` ${o.name}.register('${t}');`),i.push(...lr(o)),i.join(`
|
|
410
|
+
`)}function Nm(e,t=new Map){let n=e.map(s=>`| \`<${ri(s,t)}>\` | \`${s.pkg}\` | ${s.version} | \`${s.importPath}\` |`),r=e.map(s=>{let a=ri(s,t);return`### \`<${a}>\`
|
|
411
411
|
|
|
412
412
|
\`\`\`
|
|
413
413
|
${Mm(s,a)}
|
|
414
|
-
\`\`\``}),o=["## Installed Components","",
|
|
414
|
+
\`\`\``}),o=["## Installed Components","",Ys,...n];r.length>0&&o.push("",r.join(`
|
|
415
415
|
|
|
416
416
|
`));let i=o.join(`
|
|
417
|
-
`);return`${[
|
|
417
|
+
`);return`${[qs.trimEnd(),Zs.trimEnd(),i,Xs.trimEnd()].join(`
|
|
418
418
|
|
|
419
419
|
`)}
|
|
420
|
-
`}function Im(){return
|
|
420
|
+
`}function Im(){return Ft}function oi(e,t=new Map){return[{filename:Z,contents:Nm(e,t)},{filename:de,contents:Im()}]}import{appendFileSync as Om,readFileSync as ai}from"node:fs";import Gt from"node:path";import{simpleGit as jm}from"simple-git";var _m="# Added by auro init \u2014 keep generated grounding/IntelliSense files tracked";function si(e){return e.split(Gt.sep).join("/")}async function Lt(e,t){if(t.length===0)return[];try{return(await jm({baseDir:e}).checkIgnore(t.map(si))).map(si)}catch{return[]}}function Fm(e){let t=Gt.posix.dirname(e);return t==="."?"":t}function Lm(e){try{let t=ai(Gt.join(e,".gitignore"),"utf-8");return new Set(t.split(/\r?\n/).map(n=>n.trim()))}catch{return new Set}}function ii(e,t,n=!0){let r=Gt.join(e,".gitignore"),o="";try{o=ai(r,"utf-8")}catch{}let i=new Set(o.split(/\r?\n/).map(c=>c.trim())),s=n?t.filter(c=>!i.has(c.trim())):t;if(s.length===0)return;let a=o===""||o.endsWith(`
|
|
421
421
|
`)?"":`
|
|
422
422
|
`;try{Om(r,`${a}${s.join(`
|
|
423
423
|
`)}
|
|
424
|
-
`,"utf-8")}catch{}}async function
|
|
425
|
-
`,"utf-8")}function Um(e){switch(
|
|
426
|
-
`,"utf-8")}let i=Xm(
|
|
427
|
-
`)}function Ce(e){return!Q.stdin.isTTY||!!Q.env.CI||!!e.nonInteractive||!!e.yes}async function vp(e){if(e.suggestedDefault){let{accept:n}=await ee.prompt([{type:"confirm",name:"accept",message:e.mixedPrefixes?`Existing registrations use more than one prefix. Use the most common, '${e.suggestedDefault}', as the default for the remaining components?`:`Use the detected prefix '${e.suggestedDefault}' as the default for the remaining components?`,default:!0}]);if(n)return e.suggestedDefault}let{prefix:t}=await ee.prompt([{type:"input",name:"prefix",message:"Prefix for Auro custom-element tags (e.g. myapp-; blank keeps the bare auro-* tags):",default:e.suggestedDefault??""}]);return String(t).trim()}function kp(e){let t=e.trim();return/^[a-z][a-z0-9-]*$/.test(t)?t.includes("-")?!0:"A custom-element tag must contain a hyphen (e.g. nav-menu).":"Use a lowercase tag starting with a letter (letters, digits, and hyphens only)."}async function $p(e,t){let{customize:n}=await ee.prompt([{type:"confirm",name:"customize",message:"Define a custom tag name for any installed component? (you'll be prompted per component; Enter keeps the calculated name)",default:!1}]);if(!n)return{};let r={};for(let o of e){let i=o.tagName,s=t.get(i)??i,{tag:a}=await ee.prompt([{type:"input",name:"tag",message:`Tag for ${o.declaration.name} (<${i}>):`,default:s,validate:kp}]),c=String(a).trim();c!==s&&(r[i]=c)}return r}function Ep(e,t){let n=e??ui();return{...n,init:{...n.init,prefix:{default:n.init.prefix.default,overrides:{...n.init.prefix.overrides,...t}}}}}var Sp={vscode:{label:"VS Code HTML custom-data",artifact:".vscode/auro.html-custom-data.json"},jsx:{label:"JSX/React type declarations",artifact:"auro-types/auro-jsx.d.ts"},svelte:{label:"Svelte type declarations",artifact:"auro-types/auro-svelte.d.ts"},cssSnippets:{label:"CSS ::part() snippets",artifact:".vscode/auro.code-snippets"}};async function Cp(e,t,n){let r=n?.init.editors,o=Ns(e),i=!Ce(t),s={vscode:!1,jsx:!1,svelte:!1,cssSnippets:!1},a=[];for(let c of Ps){let l=t[c];if(l!==void 0){s[c]=l;continue}let u=r?.[c];if(u!==void 0){s[c]=u;continue}if(i){let{label:m,artifact:p}=Sp[c];a.push({type:"confirm",name:c,message:`Generate ${m} (${p})?`,default:o[c]})}else s[c]=o[c]}if(a.length>0){let c=await ee.prompt(a);for(let{name:l}of a)s[l]=!!c[l]}return s}async function Ap(e,t){let n;try{n=yi(e)}catch(a){let c=a instanceof Error?a.message:String(a);return console.error(`\u26A0 Skipping formkit migration check: ${c}`),!1}if(n.length===0)return!1;let r=n.map(a=>a.pkg).join(", ");if(Ce(t))return console.error(`\u26A0 ${n.length} legacy standalone package(s) can be migrated to @aurodesignsystem/auro-formkit: ${r}. Run \`auro init\` interactively to apply the migration.`),!1;let{migrate:o}=await ee.prompt([{type:"confirm",name:"migrate",message:`${n.length} legacy standalone package(s) now live in auro-formkit (${r}). Migrate to auro-formkit now? This edits package.json and rewrites import specifiers.`,default:!1}]);if(!o)return!1;let i=Ue("Migrating to auro-formkit...").start(),s=bi(e,n);i.succeed(`Migrated ${s.packagesMigrated.length} package(s) to auro-formkit; rewrote ${s.rewriteCount} import(s) across ${s.filesChanged.length} file(s).`);for(let{file:a,specifier:c}of s.deepImports)console.error(`\u26A0 ${a}: left deep import '${c}' unchanged \u2014 update it to an @aurodesignsystem/auro-formkit subpath by hand.`);return console.error("Next: run `npm install`, then re-run `auro init` to regenerate grounding for auro-formkit."),!0}async function xp(e){let t=new Map(e.map(o=>[o.pkg,o.version])),n=Ue("Checking for newer component releases...").start(),r=await ke(t);if(r.length===0){n.succeed("All installed Auro components are on the latest release.");return}n.stop(),console.error($e(r))}async function Tp(e){let t=Q.cwd();if(e.reset){await Dp(t,e);return}let n=Ue("Detecting installed Auro components...").start(),{components:r,duplicates:o}=await Do();if(r.length===0){n.warn("No installed Auro components found; nothing to ground. Install an Auro component package and re-run `auro init`.");return}if(n.succeed(`Detected ${r.length} installed component(s) to ground.`),await Ap(t,e))return;let i;try{i=Ut(t)}catch(g){let y=g instanceof B||g instanceof Error?g.message:String(g);console.error(`Cannot read ${M}: ${y}`),Q.exit(1)}let s=pi(t),a=Ht(r,{config:i,scan:s,prefix:e.prefix}),l=!(e.prefix!==void 0||i?.init.prefix.default!==void 0)&&(a.needsDefaultPrefix||a.mixedPrefixes),u=e.prefix;if(l){if(Ce(e)){let g=a.needsDefaultPrefix?`${a.needingDefault.length} component(s) have no resolvable tag and no default prefix`:"existing registrations use inconsistent prefixes";console.error(`Cannot resolve component tags non-interactively: ${g}. Re-run with --prefix <prefix> (e.g. --prefix myapp-).`),Q.exit(1)}u=await vp(a),a=Ht(r,{config:i,scan:s,prefix:u})}if(a.needsDefaultPrefix&&(console.error("Unable to resolve a default prefix for every component. Re-run with --prefix <prefix>."),Q.exit(1)),!Ce(e)){let g=await $p(r,a.resolvedTags);Object.keys(g).length>0&&(a=Ht(r,{config:Ep(i,g),scan:s,prefix:u}))}let m=await Cp(t,e,i);a.config.init.editors=m;let p=Ue("Writing generated files...").start(),d={written:[],warnings:[]};try{for(let y of ri(r,a.resolvedTags))await yp.writeFile(bp.join(t,y.filename),y.contents,"utf-8");d=await ar(t,r,a.resolvedTags,m),mi(t,a.config);let g=d.written.length>0?` Editor IntelliSense: ${d.written.join(", ")}.`:"";p.succeed(`Wrote ${X}, ${pe}, and ${M} for ${r.length} component(s).${g}`)}catch(g){let y=g instanceof Error?g.message:String(g);p.fail(`Failed to write generated files: ${y}`),Q.exit(1)}for(let g of d.warnings)console.error(`\u26A0 ${g}`);for(let g of a.warnings)console.error(`\u26A0 ${g}`);for(let g of o)console.error(`\u26A0 Tag <${g.tagName}> is registered by multiple installed packages: ${g.packages.join(", ")}. Grounded once \u2014 verify which package you intend to use.`);a.reconciliationWarnings.length>0&&console.error(de(`\u26A0 ${a.reconciliationWarnings.length} component tag(s) may not match your app's registered tags`,a.reconciliationWarnings,"red")),a.noPrefixWarnings.length>0&&console.error(de(`\u26A0 ${a.noPrefixWarnings.length} component(s) grounded under bare 'auro-*' tags \u2014 pass a prefix to avoid collisions`,a.noPrefixWarnings,"yellow"));let f=sr(t,m);if(f.inconsistencies.length>0)try{let g=await ar(t,r,a.resolvedTags,m),y=new Set(d.warnings);for(let v of g.warnings)y.has(v)||console.error(`\u26A0 ${v}`);f=sr(t,m)}catch(g){let y=g instanceof Error?g.message:String(g);console.error(`\u26A0 Could not re-write editor artifacts to self-heal wiring: ${y}`)}f.inconsistencies.length>0&&console.error(de("\u26A0 Editor IntelliSense wiring is incomplete after writing",f.inconsistencies,"red")),f.markupDisabled&&console.error(de("\u26A0 VS Code markup IntelliSense is off \u2014 no <auro-*> completions or hover docs",["Type-checking may still work, but tag/attribute completions will not.","Re-run `auro init --vscode` to generate them."],"yellow"));let h=[...new Set([X,pe,M,...d.written])];await Rp(t,h,e),e.offline||await xp(r)}async function Rp(e,t,n){let r=await Ft(e,t);if(r.length===0)return;if(console.error(de(`\u26A0 ${r.length} file(s) auro init wrote are git-ignored and won't be committed`,[...r,"These are meant to be committed so your team and CI share the same grounding/IntelliSense."],"red")),Ce(n)&&!n.yes){console.error("\u26A0 Un-ignore them in .gitignore (or re-run with --yes) so they get committed.");return}if(!n.yes){let{fix:s}=await ee.prompt([{type:"confirm",name:"fix",message:"Add entries to .gitignore so these files stay tracked (committed)?",default:!0}]);if(!s)return}let{fixed:o,unfixable:i}=await ai(e,r);o.length>0&&console.error(`\u2714 Un-ignored ${o.length} file(s) in .gitignore so they will be committed.`),i.length>0&&console.error(de(`\u26A0 ${i.length} file(s) are still git-ignored \u2014 un-ignore them by hand`,[...i,"A parent directory is ignored by a rule auro init won't rewrite; edit .gitignore to re-include these paths."],"red"))}function Pp(e){return e.filesToRemove.length===0&&e.unmerges.length===0}async function Dp(e,t){let n=vi(e);if(Pp(n)){console.log("Nothing to reset \u2014 no `auro init` output found.");for(let c of n.filesToSkip)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);return}console.log("`auro init --reset` will:");for(let c of n.filesToRemove)console.log(` \u2022 remove ${c}`);for(let c of n.unmerges)console.log(` \u2022 remove the Auro entry from ${c.path}`);for(let c of n.dirsToPrune)console.log(` \u2022 remove ${c}/ if it is left empty`);for(let c of n.filesToSkip)console.log(` \u2022 keep ${c.path} (${c.reason})`);if(!Ce(t)){let{confirm:c}=await ee.prompt([{type:"confirm",name:"confirm",message:"Remove these files and config entries?",default:!1}]);if(!c){console.log("Reset aborted \u2014 nothing was changed.");return}}let r=Ue("Removing `auro init` output...").start(),o;try{o=ki(e,n)}catch(c){let l=c instanceof Error?c.message:String(c);r.fail(`Failed to reset: ${l}`),Q.exit(1)}let i=o.removed.length>0?`Removed ${o.removed.length} file(s)`:"Removed no files",s=o.unmerged.length>0?`, un-merged ${o.unmerged.join(", ")}`:"",a=o.prunedDirs.length>0?`, pruned ${o.prunedDirs.map(c=>`${c}/`).join(", ")}`:"";r.succeed(`${i}${s}${a}.`);for(let c of o.warnings)console.error(`\u26A0 ${c}`);for(let c of o.skipped)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);console.error("\u2139 Reset does not undo an `auro-formkit` migration. If you migrated a legacy standalone form package, revert those package.json and import changes with git.")}var mv=wp.command("init").description("Generate AI grounding files (AGENTS.md + CLAUDE.md) for the installed Auro components").option("--prefix <prefix>","Default custom-element tag prefix (e.g. myapp-) for components without an existing registration").option("--non-interactive","Never prompt; take the prefix from --prefix or fail cleanly (implied by a non-TTY stdin or CI)",!1).option("--yes","Alias for --non-interactive",!1).option("--offline","Skip the network check for newer component releases",!1).option("--vscode","Generate VS Code HTML custom-data IntelliSense (use --no-vscode to skip; default: auto-detect)").option("--no-vscode","Skip the VS Code HTML custom-data artifact").option("--jsx","Generate JSX/React type declarations (use --no-jsx to skip; default: auto-detect)").option("--no-jsx","Skip the JSX/React type declarations").option("--svelte","Generate Svelte type declarations (use --no-svelte to skip; default: auto-detect)").option("--no-svelte","Skip the Svelte type declarations").option("--css-snippets","Generate VS Code CSS ::part() snippets (use --no-css-snippets to skip; default: auto-detect)").option("--no-css-snippets","Skip the VS Code CSS ::part() snippets").option("--reset","Remove every file and config entry a previous `auro init` run created (does not undo an auro-formkit migration)",!1).action(Tp);import zt from"node:process";import{Logger as Mp}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Np}from"commander";import Ci from"ora";async function Ip(e,t){let n=r=>({headerPkg:e,installPkg:e,importSpecifier:e,redirectedToFormkit:!1,result:r});if(t.tag)return n(await O(`${e}@${t.tag}`));if(Y(e)){let r=await O(e,{allowNetwork:!1});return r.manifest?n(r):{headerPkg:G,installPkg:G,importSpecifier:ve(e),tagFilter:nr(e),redirectedToFormkit:!0,result:await O(G)}}return n(await O(e))}async function Op(e,t){let n=ei(e),r=Ci(`Fetching ${n}...`).start(),o=await Ip(n,t),{result:i}=o,s=i.target;i.manifest||(r.fail(i.transient?`Failed to fetch ${s}: ${i.reason}.`:`No custom-elements.json published for ${s}. It may not exist or may not publish a manifest yet.`),zt.exit(1));let c=(i.manifest.modules??[]).flatMap(m=>m.declarations??[]).filter(m=>m.customElement&&m.tagName).filter(m=>!o.tagFilter||m.tagName===o.tagFilter);c.length===0&&(r.fail(o.tagFilter?`No <${o.tagFilter}> element found in ${s}.`:`No registered custom elements found for ${s}.`),zt.exit(1));let l=i.source==="local"?` (local${i.version?` v${i.version}`:""})`:" (unpkg)";r.succeed(`${s} \u2014 ${c.length} custom element${c.length===1?"":"s"}${l}`),o.redirectedToFormkit&&console.error(`\u2139 ${o.tagFilter} now ships in ${G} \u2014 showing the monorepo version (the legacy standalone isn't installed).`);let u=null;if(i.source==="local"&&i.version){let m=Ci("Checking for a newer release...").start(),p=await ke(new Map([[o.headerPkg,i.version]]));m.stop(),p.length>0&&(u=$e(p))}if(t.json){zt.stdout.write(`${JSON.stringify(c,null,2)}
|
|
428
|
-
`),u&&console.error(u);return}
|
|
429
|
-
${c.map(
|
|
424
|
+
`,"utf-8")}catch{}}async function ci(e,t){if(t.length===0)return{fixed:[],unfixable:[]};ii(e,[_m,...t.map(o=>`!${o}`)]);let n=await Lt(e,t);if(n.length>0){let o=Lm(e),i=[],s=new Set;for(let a of n){let c=Fm(a);(c===""||o.has(`${c}/*`))&&o.has(`!${a}`)||(c!==""&&!s.has(c)&&!o.has(`${c}/*`)&&(s.add(c),i.push(`!${c}/`,`${c}/*`)),i.push(`!${a}`))}i.length>0&&(ii(e,i,!1),n=await Lt(e,t))}let r=new Set(n);return{fixed:t.filter(o=>!r.has(o)),unfixable:[...r]}}import{readFileSync as hi,writeFileSync as gi}from"node:fs";import zt from"node:path";import{globSync as Xm}from"glob";import{readFileSync as ui,writeFileSync as Gm}from"node:fs";import Ut from"node:path";import{globSync as Bm}from"glob";import R from"typescript";var Wt="auro-",mr="**/*.{js,jsx,ts,tsx,mjs,cjs,svelte}",pr=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**"],W=class extends Error{constructor(t){super(t),this.name="RegistryError"}};function mi(e=""){return{version:1,init:{prefix:{default:e,overrides:{}}}}}function Wm(e,t){let n=e;if(!n||typeof n!="object")throw new W(`${t}: not a JSON object.`);if(n.version!==1)throw new W(`${t}: unsupported config version ${String(n.version)} (expected ${1}). Upgrade the CLI or remove the file.`);let r=n.init?.prefix;if(!r||typeof r.default!="string"||typeof r.overrides!="object"||r.overrides===null)throw new W(`${t}: malformed init.prefix block.`);return n}function Ht(e){let t=Ut.join(e,M),n;try{n=ui(t,"utf-8")}catch(o){if(o.code==="ENOENT")return null;throw o}let r;try{r=JSON.parse(n)}catch{throw new W(`${M}: invalid JSON.`)}return Wm(r,M)}function pi(e,t){let n=Ut.join(e,M);Gm(n,`${JSON.stringify(t,null,2)}
|
|
425
|
+
`,"utf-8")}function Um(e){switch(Ut.extname(e).toLowerCase()){case".tsx":return R.ScriptKind.TSX;case".jsx":return R.ScriptKind.JSX;case".ts":case".mts":case".cts":return R.ScriptKind.TS;default:return R.ScriptKind.JS}}function Hm(e){return e&&(R.isStringLiteral(e)||R.isNoSubstitutionTemplateLiteral(e))?e.text:null}function li(e,t,n=Um(e)){let r=[],o=[],i=[],s;try{s=R.createSourceFile(e,t,R.ScriptTarget.ES2022,!0,n)}catch{return{matches:r,defaultRegistrations:o,warnings:[`${e}: could not be parsed; skipped.`]}}let a=c=>{if(R.isCallExpression(c)&&R.isPropertyAccessExpression(c.expression)&&c.expression.name.text==="register"){let l=c.expression.expression,u=R.isIdentifier(l)?l.text:void 0;if(c.arguments.length===0)u&&o.push(u);else{let p=Hm(c.arguments[0]);p===null?i.push(`${e}: register() with a non-literal tag could not be resolved; skipped.`):r.push({className:u,tag:p})}}R.forEachChild(c,a)};return a(s),{matches:r,defaultRegistrations:o,warnings:i}}var ur=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Jm=/\blang\s*=\s*["']?(?:ts|typescript)["']?/i;function zm(e){let t=[];ur.lastIndex=0;let n=ur.exec(e);for(;n!==null;){let[,r,o]=n;t.push({content:o,scriptKind:Jm.test(r)?R.ScriptKind.TS:R.ScriptKind.JS}),n=ur.exec(e)}return t}function di(e){let t=Bm(mr,{cwd:e,absolute:!0,nodir:!0,ignore:pr}),n=[],r=[],o=[],i=s=>{n.push(...s.matches),r.push(...s.defaultRegistrations??[]),o.push(...s.warnings)};for(let s of t){let a;try{a=ui(s,"utf-8")}catch{o.push(`${s}: could not be read; skipped.`);continue}if(Ut.extname(s).toLowerCase()===".svelte")for(let{content:c,scriptKind:l}of zm(a))i(li(s,c,l));else i(li(s,a))}return{matches:n,defaultRegistrations:r,warnings:o}}function fi(e){return e.startsWith(Wt)?e.slice(Wt.length):e}function Vm(e,t){let n=fi(e);return t.endsWith(n)?t.slice(0,t.length-n.length):null}function Km(e){let t=new Map;for(let o of e)!o||o===Wt||t.set(o,(t.get(o)??0)+1);if(t.size===0)return{mixed:!1};let n,r=-1;for(let[o,i]of t)i>r&&(r=i,n=o);return{suggestion:n,mixed:t.size>1}}function qm(e,t,n=[]){let r=new Map;for(let a of e)r.set(a.declaration.name,a.tagName);let o=new Map,i=[];for(let a of t){let c=a.className?r.get(a.className):void 0;if(!c){i.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 s=new Map;for(let a of n){let c=r.get(a);c&&s.set(c,a)}return{overrides:o,defaultRegistered:s,warnings:i}}function Ym(e,t){return!e||e===Wt?t:e+fi(t)}function Jt(e,t={}){let{config:n,scan:r,prefix:o}=t,i=n?.init.prefix.overrides??{},s=qm(e,r?.matches??[],r?.defaultRegistrations??[]),a=n?.init.prefix.default,c=o??a,l=new Map,u={...i},p=[],m=[...r?.warnings??[],...s.warnings],d=[],f=[];for(let k of e){let b=k.tagName,w=i[b];if(w!==void 0){l.set(b,w);continue}let ne=s.overrides.get(b);if(ne!==void 0){l.set(b,ne),u[b]=ne;continue}if(c===void 0){p.push(b);continue}let re=Ym(c,b);l.set(b,re),re===b?f.push(`${b}: no custom prefix \u2014 grounding it under its bare 'auro-*' tag. Pass a prefix to avoid registration collisions.`):s.defaultRegistered.has(b)||d.push(`${b}: grounded as '<${re}>' from the '${c}' prefix, but no register('${re}') was found in your source. If ${k.declaration.name} is registered under a different tag (e.g. the default '<${b}>' from a side-effect import), IntelliSense will not match your markup \u2014 call ${k.declaration.name}.register('${re}') so your app matches the generated tags.`)}for(let[k,b]of s.defaultRegistered){let w=l.get(k);w!==void 0&&w!==k&&d.push(`${b}.register() uses the default '<${k}>' tag, but this project grounds it as '<${w}>'. Update the register() call to '${w}' so your app matches AGENTS.md.`)}let h=[...Object.entries(i),...s.overrides].map(([k,b])=>Vm(k,b)),{suggestion:g,mixed:y}=Km(h),v=p.length>0&&c===void 0;return{resolvedTags:l,config:{version:1,init:{prefix:{default:c??g??"",overrides:u}}},needingDefault:p,needsDefaultPrefix:v,suggestedDefault:g,mixedPrefixes:y,warnings:m,reconciliationWarnings:d,noPrefixWarnings:f}}var dr="package.json";function Zm(e){let t=e.match(/\n([ \t]+)\S/u);return t?t[1]:2}function yi(e){let t;try{t=hi(zt.join(e,dr),"utf-8")}catch(n){if(n.code==="ENOENT")return null;throw n}try{return{pkgJson:JSON.parse(t),indent:Zm(t)}}catch{throw new Error(`${dr}: invalid JSON.`)}}function bi(e){let t=yi(e);if(!t)return[];let{pkgJson:n}=t,r=[],o=["dependencies","devDependencies"];for(let i of nr)for(let s of o){let a=n[s]?.[i];if(typeof a=="string"){r.push({pkg:i,version:a,field:s});break}}return r}function Qm(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ep(e){return e.split(zt.sep).join("/")}function tp(e,t){let n=e,r=0,o=[];for(let i of t){let s=Qm(i),a=new RegExp(`(['"\`])${s}\\1`,"g");n=n.replace(a,(u,p)=>(r+=1,`${p}${$e(i)}${p}`));let c=new RegExp(`(['"\`])(${s}/[^'"\`]*)\\1`,"g"),l=c.exec(n);for(;l!==null;)o.push(l[2]),l=c.exec(n)}return{next:n,rewrites:r,deep:o}}function wi(e,t){let n=[...new Set(t.map(s=>s.pkg).filter(X))],r={packagesMigrated:[],formkit:"present",filesChanged:[],rewriteCount:0,deepImports:[]};if(n.length===0)return r;let o=yi(e);if(o){let{pkgJson:s,indent:a}=o;for(let l of["dependencies","devDependencies"]){let u=s[l];if(u)for(let p of n)p in u&&(delete u[p],r.packagesMigrated.includes(p)||r.packagesMigrated.push(p))}!!s.dependencies?.[B]||!!s.devDependencies?.[B]?r.formkit="present":(s.dependencies??={},s.dependencies[B]="latest",r.formkit="added"),gi(zt.join(e,dr),`${JSON.stringify(s,null,a)}
|
|
426
|
+
`,"utf-8")}let i=Xm(mr,{cwd:e,absolute:!0,nodir:!0,ignore:pr});for(let s of i){let a;try{a=hi(s,"utf-8")}catch{continue}let{next:c,rewrites:l,deep:u}=tp(a,n),p=ep(zt.relative(e,s));for(let m of u)r.deepImports.push({file:p,specifier:m});l>0&&c!==a&&(gi(s,c,"utf-8"),r.filesChanged.push(p),r.rewriteCount+=l)}return r}import{existsSync as vi,readdirSync as np,readFileSync as rp,rmdirSync as op,rmSync as sp,writeFileSync as ip}from"node:fs";import ap from"node:path";import{parse as cp}from"jsonc-parser";function Q(e,t){return ap.join(e,...t.split("/"))}function lp(e){let t=cp(e,[],{allowTrailingComma:!0});return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length===0}function up(e){return e.includes("//")||e.includes("/*")}function fr(e){try{return rp(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}var mp=[le,gt,ue,me];function pp(e,t){return e===null?null:t==="agents"?e.includes(_t)?"remove":`not recognized as an \`auro init\` file (missing the "${_t}" marker)`:e.trim()===Ft.trim()?"remove":"contains content beyond the generated `@AGENTS.md` import"}function ki(e){let t=[],n=[],r=[];for(let[a,c]of[[Z,"agents"],[de,"claude"]]){let l=pp(fr(Q(e,a)),c);l==="remove"?t.push(a):l!==null&&n.push({path:a,reason:l})}if(vi(Q(e,M)))try{Ht(e)&&t.push(M)}catch(a){let c=a instanceof W?a.message:String(a);n.push({path:M,reason:c})}for(let a of mp)vi(Q(e,a))&&t.push(a);let o=[],i=`${x}/${ce}`,s=fr(Q(e,i));if(s!==null){let a=Js(s);a.warning?r.push(a.warning):a.changed&&(lp(a.contents)&&!up(a.contents)?t.push(i):o.push({path:i,result:a}))}for(let a of["tsconfig.json","jsconfig.json"]){let c=fr(Q(e,a));if(c===null)continue;let l=zs(c,void 0,a);l.warning?r.push(l.warning):l.changed&&o.push({path:a,result:l});break}return{filesToRemove:t,filesToSkip:n,unmerges:o,warnings:r,dirsToPrune:[We,x]}}function dp(e){try{return np(e).length===0}catch{return!1}}function $i(e,t){let n=[];for(let i of t.filesToRemove)sp(Q(e,i),{force:!0}),n.push(i);let r=[];for(let{path:i,result:s}of t.unmerges)ip(Q(e,i),s.contents,"utf-8"),r.push(i);let o=[];for(let i of t.dirsToPrune){let s=Q(e,i);dp(s)&&(op(s),o.push(i))}return{removed:n,unmerged:r,prunedDirs:o,skipped:t.filesToSkip,warnings:t.warnings}}import Ei from"chalk";var fp=78,Si=74,Ci=" \u2022 ",gp=" ";function hp(e,t){let n=e.split(/\s+/u).filter(Boolean);if(n.length===0)return[""];let r=[],o=n[0];for(let i of n.slice(1))o.length+1+i.length<=t?o+=` ${i}`:(r.push(o),o=i);return r.push(o),r}function fe(e,t,n="red"){if(t.length===0)return"";let r=Ei[n].bold,o=[];t.forEach((c,l)=>{hp(c,Si-Ci.length).forEach((p,m)=>{let d=m===0?Ci:gp;o.push(Ei[n](d+p))}),l<t.length-1&&o.push("")});let i=e.length+(e.includes("\u26A0")?1:0),s=Math.min(Math.max(i,Si),fp),a="\u2500".repeat(s);return["",r(`\u250C${a}\u2510`),r(e),r(`\u2514${a}\u2518`),...o,""].join(`
|
|
427
|
+
`)}function xe(e){return!ee.stdin.isTTY||!!ee.env.CI||!!e.nonInteractive||!!e.yes}async function vp(e){if(e.suggestedDefault){let{accept:n}=await te.prompt([{type:"confirm",name:"accept",message:e.mixedPrefixes?`Existing registrations use more than one prefix. Use the most common, '${e.suggestedDefault}', as the default for the remaining components?`:`Use the detected prefix '${e.suggestedDefault}' as the default for the remaining components?`,default:!0}]);if(n)return e.suggestedDefault}let{prefix:t}=await te.prompt([{type:"input",name:"prefix",message:"Prefix for Auro custom-element tags (e.g. myapp-; blank keeps the bare auro-* tags):",default:e.suggestedDefault??""}]);return String(t).trim()}function kp(e){let t=e.trim();return/^[a-z][a-z0-9-]*$/.test(t)?t.includes("-")?!0:"A custom-element tag must contain a hyphen (e.g. nav-menu).":"Use a lowercase tag starting with a letter (letters, digits, and hyphens only)."}async function $p(e,t){let{customize:n}=await te.prompt([{type:"confirm",name:"customize",message:"Define a custom tag name for any installed component? (you'll be prompted per component; Enter keeps the calculated name)",default:!1}]);if(!n)return{};let r={};for(let o of e){let i=o.tagName,s=t.get(i)??i,{tag:a}=await te.prompt([{type:"input",name:"tag",message:`Tag for ${o.declaration.name} (<${i}>):`,default:s,validate:kp}]),c=String(a).trim();c!==s&&(r[i]=c)}return r}function Ep(e,t){let n=e??mi();return{...n,init:{...n.init,prefix:{default:n.init.prefix.default,overrides:{...n.init.prefix.overrides,...t}}}}}var Sp={vscode:{label:"VS Code HTML custom-data",artifact:".vscode/auro.html-custom-data.json"},jsx:{label:"JSX/React type declarations",artifact:"auro-types/auro-jsx.d.ts"},svelte:{label:"Svelte type declarations",artifact:"auro-types/auro-svelte.d.ts"},cssSnippets:{label:"CSS ::part() snippets",artifact:".vscode/auro.code-snippets"}};async function Cp(e,t,n){let r=n?.init.editors,o=Is(e),i=!xe(t),s={vscode:!1,jsx:!1,svelte:!1,cssSnippets:!1},a=[];for(let c of Ds){let l=t[c];if(l!==void 0){s[c]=l;continue}let u=r?.[c];if(u!==void 0){s[c]=u;continue}if(i){let{label:p,artifact:m}=Sp[c];a.push({type:"confirm",name:c,message:`Generate ${p} (${m})?`,default:o[c]})}else s[c]=o[c]}if(a.length>0){let c=await te.prompt(a);for(let{name:l}of a)s[l]=!!c[l]}return s}async function Ap(e,t){let n;try{n=bi(e)}catch(a){let c=a instanceof Error?a.message:String(a);return console.error(`\u26A0 Skipping formkit migration check: ${c}`),!1}if(n.length===0)return!1;let r=n.map(a=>a.pkg).join(", ");if(xe(t))return console.error(`\u26A0 ${n.length} legacy standalone package(s) can be migrated to @aurodesignsystem/auro-formkit: ${r}. Run \`auro init\` interactively to apply the migration.`),!1;let{migrate:o}=await te.prompt([{type:"confirm",name:"migrate",message:`${n.length} legacy standalone package(s) now live in auro-formkit (${r}). Migrate to auro-formkit now? This edits package.json and rewrites import specifiers.`,default:!1}]);if(!o)return!1;let i=Je("Migrating to auro-formkit...").start(),s=wi(e,n);i.succeed(`Migrated ${s.packagesMigrated.length} package(s) to auro-formkit; rewrote ${s.rewriteCount} import(s) across ${s.filesChanged.length} file(s).`);for(let{file:a,specifier:c}of s.deepImports)console.error(`\u26A0 ${a}: left deep import '${c}' unchanged \u2014 update it to an @aurodesignsystem/auro-formkit subpath by hand.`);return console.error("Next: run `npm install`, then re-run `auro init` to regenerate grounding for auro-formkit."),!0}async function xp(e){let t=new Map(e.map(o=>[o.pkg,o.version])),n=Je("Checking for newer component releases...").start(),r=await Ee(t);if(r.length===0){n.succeed("All installed Auro components are on the latest release.");return}n.stop(),console.error(Se(r))}async function Tp(e){let t=ee.cwd();if(e.reset){await Dp(t,e);return}let n=Je("Detecting installed Auro components...").start(),{components:r,duplicates:o}=await Mo();if(r.length===0){n.warn("No installed Auro components found; nothing to ground. Install an Auro component package and re-run `auro init`.");return}if(n.succeed(`Detected ${r.length} installed component(s) to ground.`),await Ap(t,e))return;let i;try{i=Ht(t)}catch(g){let y=g instanceof W||g instanceof Error?g.message:String(g);console.error(`Cannot read ${M}: ${y}`),ee.exit(1)}let s=di(t),a=Jt(r,{config:i,scan:s,prefix:e.prefix}),l=!(e.prefix!==void 0||i?.init.prefix.default!==void 0)&&(a.needsDefaultPrefix||a.mixedPrefixes),u=e.prefix;if(l){if(xe(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-).`),ee.exit(1)}u=await vp(a),a=Jt(r,{config:i,scan:s,prefix:u})}if(a.needsDefaultPrefix&&(console.error("Unable to resolve a default prefix for every component. Re-run with --prefix <prefix>."),ee.exit(1)),!xe(e)){let g=await $p(r,a.resolvedTags);Object.keys(g).length>0&&(a=Jt(r,{config:Ep(i,g),scan:s,prefix:u}))}let p=await Cp(t,e,i);a.config.init.editors=p;let m=Je("Writing generated files...").start(),d={written:[],warnings:[]};try{for(let y of oi(r,a.resolvedTags))await yp.writeFile(bp.join(t,y.filename),y.contents,"utf-8");d=await cr(t,r,a.resolvedTags,p),pi(t,a.config);let g=d.written.length>0?` Editor IntelliSense: ${d.written.join(", ")}.`:"";m.succeed(`Wrote ${Z}, ${de}, and ${M} for ${r.length} component(s).${g}`)}catch(g){let y=g instanceof Error?g.message:String(g);m.fail(`Failed to write generated files: ${y}`),ee.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(fe(`\u26A0 ${a.reconciliationWarnings.length} component tag(s) may not match your app's registered tags`,a.reconciliationWarnings,"red")),a.noPrefixWarnings.length>0&&console.error(fe(`\u26A0 ${a.noPrefixWarnings.length} component(s) grounded under bare 'auro-*' tags \u2014 pass a prefix to avoid collisions`,a.noPrefixWarnings,"yellow"));let f=ir(t,p);if(f.inconsistencies.length>0)try{let g=await cr(t,r,a.resolvedTags,p),y=new Set(d.warnings);for(let v of g.warnings)y.has(v)||console.error(`\u26A0 ${v}`);f=ir(t,p)}catch(g){let y=g instanceof Error?g.message:String(g);console.error(`\u26A0 Could not re-write editor artifacts to self-heal wiring: ${y}`)}f.inconsistencies.length>0&&console.error(fe("\u26A0 Editor IntelliSense wiring is incomplete after writing",f.inconsistencies,"red")),f.markupDisabled&&console.error(fe("\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([Z,de,M,...d.written])];await Rp(t,h,e),e.offline||await xp(r)}async function Rp(e,t,n){let r=await Lt(e,t);if(r.length===0)return;if(console.error(fe(`\u26A0 ${r.length} file(s) auro init wrote are git-ignored and won't be committed`,[...r,"These are meant to be committed so your team and CI share the same grounding/IntelliSense."],"red")),xe(n)&&!n.yes){console.error("\u26A0 Un-ignore them in .gitignore (or re-run with --yes) so they get committed.");return}if(!n.yes){let{fix:s}=await te.prompt([{type:"confirm",name:"fix",message:"Add entries to .gitignore so these files stay tracked (committed)?",default:!0}]);if(!s)return}let{fixed:o,unfixable:i}=await ci(e,r);o.length>0&&console.error(`\u2714 Un-ignored ${o.length} file(s) in .gitignore so they will be committed.`),i.length>0&&console.error(fe(`\u26A0 ${i.length} file(s) are still git-ignored \u2014 un-ignore them by hand`,[...i,"A parent directory is ignored by a rule auro init won't rewrite; edit .gitignore to re-include these paths."],"red"))}function Pp(e){return e.filesToRemove.length===0&&e.unmerges.length===0}async function Dp(e,t){let n=ki(e);if(Pp(n)){console.log("Nothing to reset \u2014 no `auro init` output found.");for(let c of n.filesToSkip)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);return}console.log("`auro init --reset` will:");for(let c of n.filesToRemove)console.log(` \u2022 remove ${c}`);for(let c of n.unmerges)console.log(` \u2022 remove the Auro entry from ${c.path}`);for(let c of n.dirsToPrune)console.log(` \u2022 remove ${c}/ if it is left empty`);for(let c of n.filesToSkip)console.log(` \u2022 keep ${c.path} (${c.reason})`);if(!xe(t)){let{confirm:c}=await te.prompt([{type:"confirm",name:"confirm",message:"Remove these files and config entries?",default:!1}]);if(!c){console.log("Reset aborted \u2014 nothing was changed.");return}}let r=Je("Removing `auro init` output...").start(),o;try{o=$i(e,n)}catch(c){let l=c instanceof Error?c.message:String(c);r.fail(`Failed to reset: ${l}`),ee.exit(1)}let i=o.removed.length>0?`Removed ${o.removed.length} file(s)`:"Removed no files",s=o.unmerged.length>0?`, un-merged ${o.unmerged.join(", ")}`:"",a=o.prunedDirs.length>0?`, pruned ${o.prunedDirs.map(c=>`${c}/`).join(", ")}`:"";r.succeed(`${i}${s}${a}.`);for(let c of o.warnings)console.error(`\u26A0 ${c}`);for(let c of o.skipped)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);console.error("\u2139 Reset does not undo an `auro-formkit` migration. If you migrated a legacy standalone form package, revert those package.json and import changes with git.")}var mv=wp.command("init").description("Generate AI grounding files (AGENTS.md + CLAUDE.md) for the installed Auro components").option("--prefix <prefix>","Default custom-element tag prefix (e.g. myapp-) for components without an existing registration").option("--non-interactive","Never prompt; take the prefix from --prefix or fail cleanly (implied by a non-TTY stdin or CI)",!1).option("--yes","Alias for --non-interactive",!1).option("--offline","Skip the network check for newer component releases",!1).option("--vscode","Generate VS Code HTML custom-data IntelliSense (use --no-vscode to skip; default: auto-detect)").option("--no-vscode","Skip the VS Code HTML custom-data artifact").option("--jsx","Generate JSX/React type declarations (use --no-jsx to skip; default: auto-detect)").option("--no-jsx","Skip the JSX/React type declarations").option("--svelte","Generate Svelte type declarations (use --no-svelte to skip; default: auto-detect)").option("--no-svelte","Skip the Svelte type declarations").option("--css-snippets","Generate VS Code CSS ::part() snippets (use --no-css-snippets to skip; default: auto-detect)").option("--no-css-snippets","Skip the VS Code CSS ::part() snippets").option("--reset","Remove every file and config entry a previous `auro init` run created (does not undo an auro-formkit migration)",!1).action(Tp);import Vt from"node:process";import{Logger as Mp}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Np}from"commander";import Ai from"ora";async function Ip(e,t){let n=r=>({headerPkg:e,installPkg:e,importSpecifier:e,redirectedToFormkit:!1,result:r});if(t.tag)return n(await j(`${e}@${t.tag}`));if(X(e)){let r=await j(e,{allowNetwork:!1});return r.manifest?n(r):{headerPkg:B,installPkg:B,importSpecifier:$e(e),tagFilter:rr(e),redirectedToFormkit:!0,result:await j(B)}}return n(await j(e))}async function Op(e,t){let n=ti(e),r=Ai(`Fetching ${n}...`).start(),o=await Ip(n,t),{result:i}=o,s=i.target;i.manifest||(r.fail(i.transient?`Failed to fetch ${s}: ${i.reason}.`:`No custom-elements.json published for ${s}. It may not exist or may not publish a manifest yet.`),Vt.exit(1));let c=(i.manifest.modules??[]).flatMap(p=>p.declarations??[]).filter(p=>p.customElement&&p.tagName).filter(p=>!o.tagFilter||p.tagName===o.tagFilter);c.length===0&&(r.fail(o.tagFilter?`No <${o.tagFilter}> element found in ${s}.`:`No registered custom elements found for ${s}.`),Vt.exit(1));let l=i.source==="local"?` (local${i.version?` v${i.version}`:""})`:" (unpkg)";r.succeed(`${s} \u2014 ${c.length} custom element${c.length===1?"":"s"}${l}`),o.redirectedToFormkit&&console.error(`\u2139 ${o.tagFilter} now ships in ${B} \u2014 showing the monorepo version (the legacy standalone isn't installed).`);let u=null;if(i.source==="local"&&i.version){let p=Ai("Checking for a newer release...").start(),m=await Ee(new Map([[o.headerPkg,i.version]]));p.stop(),m.length>0&&(u=Se(m))}if(t.json){Vt.stdout.write(`${JSON.stringify(c,null,2)}
|
|
428
|
+
`),u&&console.error(u);return}Vt.stdout.write(`
|
|
429
|
+
${c.map(p=>ni(o.headerPkg,p,{installPkg:o.installPkg,importSpecifier:o.importSpecifier})).join(`
|
|
430
430
|
|
|
431
431
|
---
|
|
432
432
|
|
|
433
433
|
`)}
|
|
434
434
|
`),Mp.info(`
|
|
435
|
-
Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var kv=Np.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(Op);import{program as jp}from"commander";import _p from"ora";var
|
|
435
|
+
Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var kv=Np.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(Op);import{program as jp}from"commander";import _p from"ora";var gr=jp.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("--manifest <path>","Path to the custom-elements.json that --api reads (default: ./custom-elements.json). In a monorepo, point it at the root manifest; only this package's elements are documented").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);gr=qe(gr);var Fp={cem:nt,api:rt,docs:jr,serve:Fr,watchDocs:Lr};async function Lp(e,t=Fp){try{e.cem&&await t.cem(),e.api&&await t.api({manifestPath:e.manifest});try{await t.docs(e)}catch(n){if(!e.watch)throw n}e.serve&&await t.serve(e),e.watch&&await t.watchDocs(e)}catch(n){_p().fail(`Docs failed: ${n instanceof Error?n.message:String(n)}`),process.exit(1)}}var xv=gr.action(e=>Lp(e));import{program as Hp}from"commander";import{Octokit as hr}from"@octokit/rest";import*as qt from"azure-devops-node-api";import Kt from"ora";var Gp=async e=>{let t=process.env.GH_TOKEN;if(!t)throw new Error("GH_TOKEN environment variable is required");let n=new hr({auth:t}),r,o,i;if(e.includes("github.com")){let a=e.match(/github\.com\/([^\/]+)\/([^\/]+)\/issues\/(\d+)/);if(!a)throw new Error("Invalid GitHub issue URL format");[,r,o,i]=a}else if(e.includes("#")){let a=e.match(/([^\/]+)\/([^#]+)#(\d+)/);if(!a)throw new Error("Invalid GitHub issue reference format");[,r,o,i]=a}else throw new Error("Issue must be provided as full URL or in format 'owner/repo#number'");let s=Number.parseInt(i,10);try{let{data:a}=await n.rest.issues.get({owner:r,repo:o,issue_number:s});return{title:a.title,body:a.body??null,html_url:a.html_url,number:a.number,repository:{owner:{login:r},name:o}}}catch(a){throw new Error(`Failed to fetch GitHub issue: ${a}`)}},Bp=async e=>{let t=process.env.GH_TOKEN;if(!t)return null;let n=new hr({auth:t});try{let r=`
|
|
436
436
|
query($owner: String!, $repo: String!, $issueNumber: Int!) {
|
|
437
437
|
repository(owner: $owner, name: $repo) {
|
|
438
438
|
issue(number: $issueNumber) {
|
|
@@ -458,7 +458,7 @@ Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var kv=Np.command("c
|
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
`,o={owner:e.repository.owner.login,repo:e.repository.name,issueNumber:e.number},s=(await n.graphql(r,o)).repository.issue.projectItems.nodes.find(a=>a.project.number===19);if(s){let a=s.fieldValues.nodes.find(c=>c.field?.name?.toLowerCase()==="ado"&&c.text?.trim());if(a?.text?.trim())return a.text.trim()}return null}catch(r){return console.error(`Failed to check existing ADO link: ${r}`),null}},Wp=async(e,t)=>{let n=process.env.GH_TOKEN;if(!n)throw new Error("GH_TOKEN environment variable is required");let r=new
|
|
461
|
+
`,o={owner:e.repository.owner.login,repo:e.repository.name,issueNumber:e.number},s=(await n.graphql(r,o)).repository.issue.projectItems.nodes.find(a=>a.project.number===19);if(s){let a=s.fieldValues.nodes.find(c=>c.field?.name?.toLowerCase()==="ado"&&c.text?.trim());if(a?.text?.trim())return a.text.trim()}return null}catch(r){return console.error(`Failed to check existing ADO link: ${r}`),null}},Wp=async(e,t)=>{let n=process.env.GH_TOKEN;if(!n)throw new Error("GH_TOKEN environment variable is required");let r=new hr({auth:n}),o=19;try{let i=`
|
|
462
462
|
query($org: String!, $projectNumber: Int!, $owner: String!, $repo: String!, $issueNumber: Int!) {
|
|
463
463
|
organization(login: $org) {
|
|
464
464
|
projectV2(number: $projectNumber) {
|
|
@@ -495,7 +495,7 @@ Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var kv=Np.command("c
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
`,s={org:"AlaskaAirlines",projectNumber:o,owner:e.repository.owner.login,repo:e.repository.name,issueNumber:e.number},a=await r.graphql(i,s),c=a.organization.projectV2.id,l=a.repository.issue.id,u=a.organization.projectV2.fields.nodes.find(
|
|
498
|
+
`,s={org:"AlaskaAirlines",projectNumber:o,owner:e.repository.owner.login,repo:e.repository.name,issueNumber:e.number},a=await r.graphql(i,s),c=a.organization.projectV2.id,l=a.repository.issue.id,u=a.organization.projectV2.fields.nodes.find(m=>m.name?.toLowerCase()==="ado"),p=a.repository.issue.projectItems.nodes.find(m=>m.project.number===o)?.id;if(p||(p=(await r.graphql(`
|
|
499
499
|
mutation($projectId: ID!, $contentId: ID!) {
|
|
500
500
|
addProjectV2ItemById(
|
|
501
501
|
input: {
|
|
@@ -508,7 +508,7 @@ Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var kv=Np.command("c
|
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
`,{projectId:c,contentId:l})).addProjectV2ItemById.item.id),u&&
|
|
511
|
+
`,{projectId:c,contentId:l})).addProjectV2ItemById.item.id),u&&p)await r.graphql(`
|
|
512
512
|
mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) {
|
|
513
513
|
updateProjectV2ItemFieldValue(
|
|
514
514
|
input: {
|
|
@@ -525,12 +525,12 @@ Full docs: https://auro.alaskaair.com`),u&&console.error(u)}var kv=Np.command("c
|
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
`,{projectId:c,itemId:
|
|
529
|
-
${r.body??""}`;for(let i of o.matchAll(n)){let s=Number.parseInt(i[1],10);Number.isNaN(s)||t.add(s)}}return[...t]}async function Vp(){let e=process.env.ADO_TOKEN;if(!e)throw new Error("ADO_TOKEN environment variable is required to resolve the Release ticket.");let t=
|
|
530
|
-
${n.map(
|
|
531
|
-
`)}`),t}function
|
|
532
|
-
${e.map(
|
|
528
|
+
`,{projectId:c,itemId:p,fieldId:u.id,value:t});else if(!u)throw new Error("No 'ado' field found in GitHub project")}catch(i){console.error(`Failed to update GitHub project: ${i}`)}},Up=async e=>{let t=process.env.ADO_TOKEN;if(!t)throw new Error("ADO_TOKEN environment variable is required");let n="https://dev.azure.com/itsals",r="E_Retain_Content",o="E_Retain_Content\\Auro Design System",i=qt.getPersonalAccessTokenHandler(t),a=await new qt.WebApi(n,i).getWorkItemTrackingApi();try{let c=[{op:"add",path:"/fields/System.Title",value:e.title},{op:"add",path:"/fields/System.Description",value:`GitHub Issue: <a href="${e.html_url}">${e.html_url}</a>`},{op:"add",path:"/fields/System.AreaPath",value:o}];return await a.createWorkItem(null,c,r,"User Story")}catch(c){throw new Error(`Failed to create ADO work item: ${c}`)}},xi=async e=>{let t=Kt(`Processing GitHub issue: ${e}`).start();try{if(!process.env.GH_TOKEN)throw new Error("GH_TOKEN environment variable is required");if(!process.env.ADO_TOKEN)throw new Error("ADO_TOKEN environment variable is required");t.text="Fetching GitHub issue details...";let n=await Gp(e);t.succeed(`Found issue: "${n.title}"`);let r=Kt("Checking for existing ADO work item...").start(),o=await Bp(n);if(o){r.succeed("ADO work item already exists for this issue!"),console.log(`${o}`);return}r.succeed("No existing ADO work item found");let i=Kt("Creating new ADO work item...").start(),s=await Up(n);if(i.succeed(`Successfully created ADO work item #${s.id}`),console.log(`Work item: ${s._links?.html?.href||"N/A"}`),s._links?.html?.href){let a=Kt("Adding to GitHub project and updating ADO field...").start();await Wp(n,s._links.html.href),a.succeed("Updated GitHub project with ADO link")}}catch(n){t.fail(`Error: ${n instanceof Error?n.message:n}`),process.exit(1)}};var Iv=Hp.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 xi(e.ghIssue)});import{program as od}from"commander";import{Octokit as td}from"@octokit/rest";import{simpleGit as nd}from"simple-git";import*as Yt from"azure-devops-node-api";import{WorkItemErrorPolicy as Ti,WorkItemExpand as Jp}from"azure-devops-node-api/interfaces/WorkItemTrackingInterfaces.js";var Pi="https://dev.azure.com/itsals",yr="E_Retain_Content",Di="auro-rcs",zp=new Set(["closed","removed"]);function Mi(e){let t=new Set,n=/AB#(\d+)/gi;for(let r of e){let o=r.message??`${r.subject??""}
|
|
529
|
+
${r.body??""}`;for(let i of o.matchAll(n)){let s=Number.parseInt(i[1],10);Number.isNaN(s)||t.add(s)}}return[...t]}async function Vp(){let e=process.env.ADO_TOKEN;if(!e)throw new Error("ADO_TOKEN environment variable is required to resolve the Release ticket.");let t=Yt.getPersonalAccessTokenHandler(e);return new Yt.WebApi(Pi,t).getWorkItemTrackingApi()}function Kp(e){if(!e)return null;let t=e.match(/\/workItems\/(\d+)(?:\/)?$/i);return t?Number.parseInt(t[1],10):null}function qp(e){let t=e.fields?.["System.Tags"];return typeof t!="string"?!1:t.split(";").map(n=>n.trim().toLowerCase()).includes(Di)}function Ri(e){let t=e.fields?.["System.State"];return typeof t!="string"||!zp.has(t.toLowerCase())}function Yp(e){let t=e.filter(Ri),n=e.filter(r=>!Ri(r));return n.length>0&&console.log(`Ignoring ${n.length} closed Release ticket(s):
|
|
530
|
+
${n.map(br).join(`
|
|
531
|
+
`)}`),t}function wr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function Xp(e){let t=wr(e),n=t.replace(/^auro /,"");return[...new Set([t,n])].filter(Boolean)}function Zp(e,t){let n=e.fields?.["System.AreaPath"];return typeof n!="string"?!1:n.split("\\").map(wr).some(r=>t.includes(r))}function Qp(e,t){let n=e.fields?.["System.Title"];if(typeof n!="string")return!1;let r=` ${wr(n)} `;return t.some(o=>r.includes(` ${o} `))}function br(e){let t=e.fields?.["System.Title"]??"(no title)",n=e.fields?.["System.AreaPath"]??"(no area path)",r=e.fields?.["System.State"]??"(no state)";return`#${e.id} "${t}" [${n}] (${r})`}function ed(e,t){let n=Xp(t),r=`
|
|
532
|
+
${e.map(br).join(`
|
|
533
533
|
`)}`;for(let[o,i]of[["Area Path",Zp],["title",Qp]]){let s=e.filter(a=>i(a,n));if(s.length===1)return console.log(`Found ${e.length} Release tickets; selected #${s[0].id} for "${t}" by ${o}.`),s[0];if(s.length>1)throw new Error(`Found ${s.length} Release tickets whose ${o} matches "${t}":
|
|
534
|
-
${s.map(
|
|
534
|
+
${s.map(br).join(`
|
|
535
535
|
`)}
|
|
536
|
-
Only one Release Candidate ticket per repo is supported.`)}throw new Error(`Found ${e.length} Release tickets but none could be matched to "${t}" by Area Path or title:${r}`)}async function
|
|
536
|
+
Only one Release Candidate ticket per repo is supported.`)}throw new Error(`Found ${e.length} Release tickets but none could be matched to "${t}" by Area Path or title:${r}`)}async function Ni(e,t){if(e.length===0)return console.log("No ADO work item references (AB#<id>) found in the RC commits."),null;let n=await Vp(),r=await n.getWorkItems(e,void 0,void 0,Jp.Relations,Ti.Omit,yr),o=new Set;for(let u of r??[])for(let p of u.relations??[]){let m=Kp(p.url);m!==null&&o.add(m)}if(o.size===0)return console.log(`None of the committed work items (${e.join(", ")}) link to another work item in ADO.`),null;let i=await n.getWorkItems([...o],["System.Title","System.Tags","System.AreaPath","System.State"],void 0,void 0,Ti.Omit,yr),s=Yp((i??[]).filter(qp));if(s.length===0)return console.log(`No open Release ticket (tagged "${Di}") is linked to the committed work items (${e.join(", ")}).`),null;let a=s.length===1?s[0]:ed(s,t);if(a.id===void 0)throw new Error("Failed to resolve the Release ticket details from ADO.");let c=typeof a.fields?.["System.Title"]=="string"?a.fields["System.Title"]:`Work item ${a.id}`,l=a._links?.html?.href??`${Pi}/${yr}/_workitems/edit/${a.id}`;return{id:a.id,url:l,title:c}}var ze="dev",rd="main",Xt=class e{constructor(t,n,r){this.repoInfo={owner:t,repo:n},this.octokit=r}static async create(){let t=process.env.GITHUB_TOKEN;if(!t)throw new Error("GITHUB_TOKEN is required to run RC workflow.");if(!process.env.ADO_TOKEN)throw new Error("ADO_TOKEN is required to resolve the ADO Release ticket for the RC workflow.");let n=await K.getRepoOwnerAndName(),r=new td({auth:t});if(!n)throw new Error("Failed to retrieve repository information. Ensure you're in a valid git repository.");let o=await e.getTriggerBranchName();return o&&o!==ze&&(console.log(`Switching from ${o} to ${ze} branch...`),await nd().checkout(ze)),new e(n.owner,n.repo,r)}get owner(){return this.repoInfo.owner}get repo(){return this.repoInfo.repo}get repoData(){return{...this.repoInfo}}async createReleaseCandidate(){let t=await this.resolveReleaseTicket();if(!t){console.log("No ADO Release ticket is linked to the new commits on `dev`. Skipping Release PR.");return}console.log(`Using ADO Release ticket #${t.id} (${t.title}) -> ${t.url}`);let n=await this.getLinkedPrByHead(t.id);if(n?.multipleOpen)throw new Error("Multiple open RC PRs found for the same rc/<ticketId> branch.");n?.state==="closed"&&(console.log("Linked RC PR is closed. Creating a new RC PR on the same branch."),n=null),await this.createOrUpdateRcBranch(t.id),n?await this.updateRcPr(t,n.number):n=await this.createRcPr(t)}async resolveReleaseTicket(){let t=await K.getCommitMessages(ze),n=Mi(t);return Ni(n,this.repoInfo.repo)}async createOrUpdateRcBranch(t){let n=`heads/rc/${t}`,r=`rc/${t}`,{data:o}=await this.octokit.rest.repos.getBranch({owner:this.repoInfo.owner,repo:this.repoInfo.repo,branch:ze}),{data:i}=await this.octokit.rest.git.listMatchingRefs({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:n}),s=i.length>0;try{s?(console.log(`Updating existing RC branch: ${r}`),await this.octokit.rest.git.updateRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:n,sha:o.commit.sha,force:!0})):(console.log(`Creating new RC branch: ${r}`),await this.octokit.rest.git.createRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:`refs/${n}`,sha:o.commit.sha}))}catch(a){throw new Error(`Failed to create or update ${r} branch: ${a}`)}}async getLinkedPrByHead(t){let n=`${this.repoInfo.owner}:rc/${t}`,{data:r}=await this.octokit.rest.pulls.list({owner:this.repoInfo.owner,repo:this.repoInfo.repo,state:"all",head:n,per_page:30}),o=r.filter(s=>s.state==="open");if(o.length>1)return{state:"open",multipleOpen:!0};if(o.length===1)return{state:"open",html_url:o[0].html_url,number:o[0].number};let i=r.filter(s=>s.state==="closed");return i.length>0?{state:"closed",html_url:i[0].html_url,number:i[0].number}:null}rcReference(t){return`Release candidate pull request. Tracked by ADO Release ticket [AB#${t.id}](${t.url}) \u2014 ${t.title}.`}async buildPrBody(t){let n=this.rcReference(t);try{let{data:r}=await this.octokit.rest.repos.getContent({owner:this.repoInfo.owner,repo:this.repoInfo.repo,path:".github/PULL_REQUEST_TEMPLATE.md"});if("content"in r&&r.type==="file"){let o=Buffer.from(r.content,"base64").toString("utf-8");return o=o.replace("Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.",n),o=o.replace(/<details>/g,"<details open>"),o}}catch(r){r&&typeof r=="object"&&"status"in r&&r.status===404?console.log("No PR template found in repo, using default message."):console.warn("Failed to fetch PR template:",r)}return n}async createRcPr(t){try{let n=await this.buildPrBody(t),{data:r}=await this.octokit.request(`POST /repos/${this.repoInfo.owner}/${this.repoInfo.repo}/pulls`,{owner:this.repoInfo.owner,repo:this.repoInfo.repo,title:`RC #${t.id}`,body:n,head:`rc/${t.id}`,base:rd,headers:{"X-GitHub-Api-Version":"2022-11-28"}});return console.log(`Created Release Candidate pull request: #${r.number} (${r.html_url})`),{state:"open",html_url:r.html_url,number:r.number}}catch(n){throw console.error("Failed to create RC PR:",n),n}}async updateRcPr(t,n){try{let r=await this.buildPrBody(t);await this.octokit.rest.pulls.update({owner:this.repoInfo.owner,repo:this.repoInfo.repo,pull_number:n,body:r}),console.log(`Updated Release Candidate pull request: #${n}`)}catch(r){throw console.error("Failed to update RC PR:",r),r}}static async getTriggerBranchName(){return process.env.GITHUB_REF_NAME?process.env.GITHUB_REF_NAME:process.env.GITHUB_REF?.startsWith("refs/heads/")?process.env.GITHUB_REF.replace("refs/heads/",""):K.getCurrentBranchName()}};var Jv=od.command("rc-workflow").description("Generate RC issue and pull request").action(async()=>{await(await Xt.create()).createReleaseCandidate()});vr.name("auro").version(Zt()).description("A cli tool to support the Auro Design System");vr.addHelpText("beforeAll",kr());vr.parse();
|