@aurodesignsystem-dev/auro-cli 0.0.0-pr319.9 → 0.0.0-pr321.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/README.md +0 -79
- package/dist/auro-cli.js +50 -407
- package/dist/auro-cli.js.map +4 -4
- package/dist/migrations/docs-head-content-update/multi-gitter.yml +1 -1
- package/dist/migrations/github-config-and-gitignore-changes/multi-gitter.yml +1 -1
- package/dist/migrations/package-json-update-oidc/multi-gitter.yml +2 -2
- package/dist/migrations/package-update-dropdown-v3-2-2/multi-gitter.yml +1 -1
- package/dist/migrations/package-update-reusable/multi-gitter.yml +1 -1
- package/dist/migrations/token-formatting/multi-gitter.yml +1 -1
- package/package.json +3 -8
package/dist/auro-cli.js
CHANGED
|
@@ -1,425 +1,68 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{program as
|
|
2
|
+
import{program as ze}from"commander";import Wt from"figlet";import{mind as zt}from"gradient-string";var qe=()=>zt(Wt.textSync("Auro CLI"));import Ve from"node:fs";import Je from"node:path";import{fileURLToPath as qt}from"node:url";function Y(r){process.env.DEBUG&&console.log(`[DEBUG] ${r}`)}function ye(){try{let r=qt(import.meta.url),t=Je.dirname(r);Y(`Current module path: ${t}`);let e=Je.resolve(t,"..","package.json");return Y(`Checking package.json at: ${e}`),Ve.existsSync(e)?(Y(`Found package.json at: ${e}`),JSON.parse(Ve.readFileSync(e,"utf8")).version):(Y("Could not find package.json in the standard installed module location, using default version"),"0.0.0")}catch(r){return console.error("Error retrieving package version:",r),"0.0.0"}}import{program as Wr}from"commander";import bt from"ora";function X(r){return r.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 Z(r){return r.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 Gr from"@rollup/plugin-terser";import{watch as Lr}from"rollup";import{existsSync as mt,readFileSync as Sr,rmSync as Dr,writeFileSync as Pr}from"node:fs";import{basename as xr,dirname as Or,join as L,resolve as ae}from"node:path";import{pathToFileURL as dt}from"node:url";import{glob as Nr}from"glob";import Se from"ora";import{rollup as Re}from"rollup";import*as pt from"sass";import B from"ora";import{spawn as Vt}from"node:child_process";import Jt from"ora";var A=(r,t)=>{let e=`${r} ${t?t.join(" "):""}`,n=Jt(),o=r,s=t||[];if(!t&&typeof r=="string"){let m=r.split(" ");o=m[0],s=m.slice(1)}let i=e.includes("--watch")||e.includes(" -w"),l=Vt(o,s,{stdio:i?"inherit":["inherit","pipe","pipe"],shell:!0});if(!i){let m=[];l.stdout?.on("data",u=>{let c=u.toString();m.push(c),process.stdout.write(c)}),l.stderr?.on("data",u=>{let c=u.toString();m.push(c),process.stderr.write(c)})}return new Promise((m,u)=>{l.on("close",c=>{c!==0?i?(n.info(`Watch mode terminated with code ${c}`),m()):(n.fail(`${e} failed (code ${c})`),u(new Error(`Command failed with exit code ${c}`))):(n.succeed(`${e} completed successfully`),m())})})};import Q from"node:fs";import Kt from"node:path";import{markdownTable as Ke}from"markdown-table";var N=class r{static{this.manifest={schemaVersion:"1.0.0",readme:"",modules:[]}}static generate(t={}){let{outDir:e="./docs",outFile:n="api.md",manifestPath:o="./custom-elements.json"}=t,{getElements:s,renderAllElements:i}=r;if(o)try{let c=Q.readFileSync(o,"utf8");r.manifest=JSON.parse(c)}catch(c){throw console.error(`Error reading manifest file at ${o}:`,c),c}let a=s(),l=e;Q.existsSync(l)||Q.mkdirSync(l,{recursive:!0});let m=i(a),u=Kt.join(l,n);Q.writeFileSync(u,m),console.log(`Generated combined API documentation at ${u}`)}static getElements(){let t=r.manifest.modules.filter(r.isWcaModule);return r.manifest.modules.reduce((e,n)=>e.concat(n.declarations?.filter(o=>"customElement"in o&&o.customElement===!0&&"tagName"in o&&(t.length>0?r.isWcaModule(n):!0))??[]),[])}static isWcaModule(t){let{path:e}=t;return e?e.startsWith("scripts/wca/auro-")&&e.endsWith(".js"):!1}static renderAllElements(t){return`${t.sort((e,n)=>(e.tagName||"").localeCompare(n.tagName||"")).map(e=>r.renderElement(e,!0)).join(`
|
|
3
3
|
|
|
4
|
-
`)}`}static renderElement(t,
|
|
4
|
+
`)}`}static renderElement(t,e=!0){let n=[],{renderTable:o,renderPropertiesAttributesTable:s,renderParameters:i,getType:a}=r;n.push(e?`# ${t.tagName}`:""),t.description&&n.push(t.description);let l=s(t);l&&n.push(l.trim());let m=o("Methods",["name","parameters","return","description"],(t.members||[]).filter(p=>p.kind==="method"&&("privacy"in p?p.privacy!=="private":!0)&&p.name[0]!=="_").map(p=>({...p,parameters:i("parameters"in p?p.parameters:void 0),return:"return"in p&&p.return?a(p.return):""})));m&&n.push(m.trim());let u=o("Events",["name","description"],t.events);u&&n.push(u.trim());let c=o("Slots",[["name","(default)"],"description"],t.slots);c&&n.push(c.trim());let d=o("CSS Shadow Parts",["name","description"],t.cssParts);d&&n.push(d.trim());let f=o("CSS Custom Properties",["name","description"],t.cssProperties);return f&&n.push(f.trim()),n.join(`
|
|
5
5
|
|
|
6
|
-
`)}static renderPropertiesAttributesTable(t){let{getType:
|
|
6
|
+
`)}static renderPropertiesAttributesTable(t){let{getType:e,escapeMarkdown:n}=r,o=t.members?.filter(c=>c.kind==="field"&&("privacy"in c?c.privacy!=="private":!0)&&c.name[0]!=="_")||[],s=t.attributes||[],i=[],a=new Set;if(o.forEach(c=>{if(c.description?.trim()){let d=e(c)||"",p=("return"in c&&c.return?e(c.return):"")||d;i.push({name:c.name,properties:c.name,attributes:("attribute"in c?c.attribute:"")||"",modifiers:"readonly"in c&&c.readonly?"readonly":"",type:p,default:("default"in c?c.default:"")||"",description:c.description||""})}a.add(c.name),"attribute"in c&&c.attribute&&a.add(c.attribute)}),s.forEach(c=>{!a.has(c.name)&&c.description?.trim()&&i.push({name:c.name,properties:"",attributes:c.name,modifiers:"",type:e(c)||"",default:c.default||"",description:c.description||""})}),i.length===0)return"";let l=["Properties","Attributes","Modifiers","Type","Default","Description"],m=i.map(c=>{let g=(c.default||"").trim().replace(/^'([^']+)'$/,"$1").replace(/^"([^"]+)"$/,"$1"),b=g?g.startsWith("`")&&g.endsWith("`")?g:`\`${g}\``:"";return[n(c.properties),n(c.attributes),n(c.modifiers),n(c.type),n(b),n(c.description)]});return`### Properties & Attributes
|
|
7
7
|
|
|
8
|
-
${
|
|
9
|
-
`}static renderParameters(t){let{escapeMarkdown:
|
|
8
|
+
${Ke([l,...m])}
|
|
9
|
+
`}static renderParameters(t){let{escapeMarkdown:e,getType:n}=r;return!t||t.length===0?"None":t.map(o=>{let s=n(o)||"any",i=o.description?` - ${o.description}`:"";return`\`${o.name}\` (${e(s)})${e(i)}`}).join("<br>")}static renderTable(t,e,n){let{escapeMarkdown:o,get:s,capitalize:i}=r;if(n===void 0||n.length===0)return"";let a=n.filter(c=>{let{description:d}=c;return typeof d=="string"&&d.trim()});if(a.length===0)return"";let l=e.map(c=>i((Array.isArray(c)?c[0]:c).split(".")[0])),m=a.map(c=>e.map(d=>{let f=s(c,d);return o(String(f||""))})),u=Ke([l,...m]);return`### ${t}
|
|
10
10
|
|
|
11
|
-
${
|
|
12
|
-
`}static escapeMarkdown(t){return t.replace(/\\/g,"\\\\").replace(/\n/g,"<br>").replace(/\|/g,"\\|")}static getType(t){if(!t||!t.type)return"";let{type:
|
|
13
|
-
<!-- The below content is automatically added from ${
|
|
11
|
+
${u}
|
|
12
|
+
`}static escapeMarkdown(t){return t.replace(/\\/g,"\\\\").replace(/\n/g,"<br>").replace(/\|/g,"\\|")}static getType(t){if(!t||!t.type)return"";let{type:e}=t,n=s=>s.replace(/\s*\|\s*/g," | ").replace(/'([^']+)'/g,"`$1`");if(typeof e=="string")return n(e);if(e.text)return n(e.text);if(Array.isArray(e))return e.map(s=>typeof s=="string"?s:s.text?s.text:s.name?s.name:String(s)).join(" \\| ");if(e.name)return n(e.name);if(e.references&&Array.isArray(e.references))return e.references.map(s=>s.name||String(s)).join(" \\| ");let o=String(e);return n(o)}static get(t,e){let n="",o=e;Array.isArray(e)&&([o,n]=e);let s=o.split("."),i=t;for(;i&&s.length;)i=i[s.shift()];return i==null||i===""?n:String(i)}static capitalize(t){return t.replace(/([A-Z])/g," $1").replace(/^./,e=>e.toUpperCase()).trim()}};import Yt from"node:fs";import Xt from"node:os";import ee from"node:path";import we from"node:process";function Zt(){let r=Xt.homedir()||we.env.HOME||we.env.USERPROFILE;if(!r)throw new Error("Unable to determine user home directory");return ee.join(r,".auro")}function be(...r){return ee.join(Zt(),...r)}function ke(...r){let t=Yt.realpathSync(we.argv[1]),e=ee.dirname(t);return ee.resolve(e,...r)}var Ye=r=>ke("configs",r);import{copyFileSync as Qt,existsSync as Xe,mkdirSync as er}from"node:fs";import{join as tr,resolve as $e}from"node:path";function j(){let r=process.cwd(),t=$e(r,"README.md"),e=tr($e(r,"demo"),"readme.md");if(!Xe(t))return;let n=$e(r,"demo");Xe(n)||er(n,{recursive:!0}),Qt(t,e)}import rr from"ora";var Qe=[];function _(r){Qe.push(r)}var Ze=!1;function te(){Ze||(Ze=!0,process.on("SIGINT",()=>{let r=rr("Wrapping up...").start();for(let t of Qe)t.close();r.succeed("All done! See you next time. \u2728"),process.exit(0)}))}import{Logger as nr}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{generateReadmeUrl as or,processContentForFile as sr,templateFiller as Ae}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";import T from"node:fs";import{readFileSync as ve,existsSync as Ee}from"node:fs";import C from"node:path";var ir="/docs/pages",tt={overwriteLocalCopies:!0,remoteReadmeVersion:"master",remoteReadmeVariant:"_updated_paths",monorepoName:void 0,extraVars:{}};function E(r){return`${process.cwd()}/${r}`}function ar(r=process.cwd()){let t=r;for(;;){let e=C.join(t,"package.json");if(Ee(e))try{if(JSON.parse(ve(e,"utf8")).workspaces)return t}catch{}let n=C.dirname(t);if(n===t)break;t=n}return r}async function cr(r,t=!1){let e=[];if(!t){let o=r.localReadmePath?r.localReadmePath:{remoteUrl:r.remoteReadmeUrl||or(r.remoteReadmeVersion,r.remoteReadmeVariant),fileName:E("/docTemplates/README.md"),overwrite:r.overwriteLocalCopies};e.push({identifier:"README.md",input:o,output:E("/README.md")})}et("/docs/partials/index.md")&&e.push({identifier:"index.md",input:E("/docs/partials/index.md"),output:E("/demo/index.md"),mdMagicConfig:{output:{directory:E("/demo")}}}),et("/docs/partials/api.md")&&e.push({identifier:"api.md",input:E("/docs/partials/api.md"),output:E("/demo/api.md"),preProcessors:[Ae.formatApiTable]});let n=E(ir);if(T.existsSync(n)){let s=(await T.promises.readdir(n)).map(i=>({identifier:i,input:C.join(n,i),output:E(`/demo/${i}`)}));e.push(...s)}return e}async function lr(r=tt,t=!1){await Ae.extractNames();let e=await cr(r,t),n=r.monorepoName;if(!n)try{let s=C.join(ar(),"package.json");n=JSON.parse(ve(s,"utf8")).name?.replace(/^@[^/]+\//,"")}catch{}let o={...n?{monorepoName:n}:{},...r.extraVars||{}};for(let s of e)try{await sr({...s,extraVars:o}),s.output.endsWith(".md")&&await ur(s.output,o)}catch(i){nr.error(`Error processing ${s.identifier}: ${i.message}`)}}async function ur(r,t={}){let e=C.dirname(r),n=await T.promises.readFile(r,"utf8"),o=/^[ \t]*<!-- AURO-GENERATED-CONTENT:START \((FILE|CODE):src=([^)]+)\) -->\n[ \t]*<!-- AURO-GENERATED-CONTENT:END -->/gm,s,i=!1,a=E("demo");for(;(s=o.exec(n))!==null;){let[d,f,p]=s,g=C.resolve(e,p),b=C.resolve(a,p),x=Ee(g)?g:Ee(b)?b:null;if(x){let O=ve(x,"utf8"),k;if(f==="FILE")k=`<!-- AURO-GENERATED-CONTENT:START (FILE:src=${p}) -->
|
|
13
|
+
<!-- The below content is automatically added from ${p} -->
|
|
14
14
|
${O.trimEnd()}
|
|
15
|
-
<!-- AURO-GENERATED-CONTENT:END -->`;else{let
|
|
16
|
-
<!-- The below code snippet is automatically added from ${
|
|
17
|
-
<pre class="language-${
|
|
15
|
+
<!-- AURO-GENERATED-CONTENT:END -->`;else{let $=C.extname(p).slice(1)||"html",K=O.trimEnd().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");k=`<!-- AURO-GENERATED-CONTENT:START (CODE:src=${p}) -->
|
|
16
|
+
<!-- The below code snippet is automatically added from ${p} -->
|
|
17
|
+
<pre class="language-${$}"><code class="language-${$}">${K}
|
|
18
18
|
</code></pre>
|
|
19
|
-
<!-- AURO-GENERATED-CONTENT:END -->`}n=n.replace(
|
|
20
|
-
</code></pre>`});
|
|
21
|
-
`),
|
|
22
|
-
`)+
|
|
23
|
-
`),
|
|
24
|
-
`))}async function
|
|
25
|
-
`).start();try{let r={port:Number(e.port)||void 0,open:e.open?"/":void 0,watch:e.watch??xe.watch,nodeResolve:e.nodeResolve??xe.nodeResolve,basePath:e.basePath??xe.basePath,rootDir:e.rootDir??xe.rootDir,middleware:[function(s,i){return!s.url.endsWith("/")&&!s.url.includes(".")&&(s.url+=".html"),i()}],plugins:[_s(),Fs(),Ns({include:e.hmrInclude??xe.hmrInclude})]},n=await Ds({config:r,readCliArgs:!1,readFileConfig:!1});return t.stop(),n}catch(r){throw t.fail("Server snag! Couldn't start dev server."),console.error("Error starting development server:",r),new Error(`Development server failed to start: ${r.message}`)}}async function ze(){let e=Ce("Generating Custom Elements Manifest...").start();try{await _(`npx --package=@custom-elements-manifest/analyzer -y -- cem analyze --config '${Ur("custom-elements-manifest.config.mjs")}'`),e.succeed("Custom Elements Manifest generated successfully!")}catch(t){let r=t instanceof Error?t.message:String(t);e.warn("CEM analyzer completed with warnings: "+r)}}async function Ke(){let e=Ce("Generating API md file...").start();try{await ve.generate(),e.succeed("API md file generated successfully!")}catch(t){let r=t instanceof Error?t.message:String(t);throw e.fail("Failed to generate API md file: "+r),t}}async function Yr(e={}){let t=Ce("Compiling documentation...").start();try{await Se(e),t.succeed("Documentation compiled successfully!")}catch(r){let n=r instanceof Error?r.message:String(r);throw t.fail("Failed to compile MD documentation: "+n),r}Ee(),await V(),await Gt(e)}async function Xr(e={}){await Je(e)}async function Zr(e={}){let t=await import("chokidar"),r=["./src/**/*","./docs/**/*","./docTemplates/**/*","./apiExamples/**/*","./demo/**/*.scss"],n=["**/demo/*.min.js","**/demo/*.min.css","**/demo/*.md","**/demo/readme.md","**/docs/api.md","**/custom-elements.json","**/node_modules/**","**/dist/**","**/.git/**"],o=t.watch(r,{ignoreInitial:!0,ignored:n,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100}}),s=Ce("Waiting for changes...");s.spinner="bouncingBar",s.color="green",s.start();let i=null,a=!1,c=!1;async function l(m){if(a){c=!0;return}a=!0,o.unwatch(r);let u=Ce(`Change detected: ${m}`).start();try{await Se(e),Ee(),await V(),await Gt(e),u.succeed("Docs rebuilt!")}catch(p){let d=p instanceof Error?p.message:String(p);u.fail("Rebuild failed: "+d)}finally{setTimeout(()=>{o.add(r),a=!1,c&&(c=!1,l("queued changes"))},1e3)}}o.on("all",(m,u)=>{a||(i&&clearTimeout(i),i=setTimeout(()=>{l(u)},1e3))}),ke(o),We()}async function qe(){await ze(),await Ke()}import{basename as Bs,join as en,resolve as Us}from"node:path";import Hs from"@rollup/plugin-commonjs";import{nodeResolve as Ws}from"@rollup/plugin-node-resolve";import{glob as Vs}from"glob";import{litScss as Js}from"rollup-plugin-scss-lit";import Ls from"node:path";import{glob as Gs}from"glob";function Qr(e){return{name:"watch-globs",buildStart(){let t=Array.isArray(e)?e:[e];for(let r of t)try{for(let n of Gs.sync(Ls.resolve(r)))this.addWatchFile(n)}catch(n){this.error(`Error watching glob pattern "${r}": ${n.message}`)}}}}var Bt={moduleDirectories:["node_modules"],modulePaths:["../../node_modules","../node_modules","node_modules"],watchPatterns:["./apiExamples/**/*","./docs/**/*"]};function tn(e=[],t={}){let{watchPatterns:r=Bt.watchPatterns,dedupe:n=["lit","lit-element","lit-html"],dev:o=!1}=t,s=[...Bt.modulePaths,...e],i=process.cwd(),a=W.map(c=>Us(i,c));return[Ws({dedupe:n,preferBuiltins:!1,moduleDirectories:Bt.moduleDirectories,modulePaths:a}),Hs(),Js({minify:o?!1:{fast:!0},options:{loadPaths:[...s,en(process.cwd(),"src","styles"),en(process.cwd(),"src")]}}),Qr(r)]}function Ut(e={}){let{modulePaths:t=[],watch:r=!1,input:n=["./src/index.js","./src/registered.js"],outputDir:o="./dist",format:s="esm",dev:i=!1}=e;return{name:"Main",config:{input:n,output:{format:s,dir:o,entryFileNames:a=>i||["index","registered"].includes(a.name)?"[name].js":"[name]-[hash].js",chunkFileNames:i?"[name].js":"[name]-[hash].js",assetFileNames:i?"[name][extname]":"[name]-[hash][extname]"},external:zs(),plugins:tn(t,{dev:i}),watch:rn(r)}}}function Te(e={}){let{modulePaths:t=[],watch:r=!1,globPattern:n="./demo/*.js",ignorePattern:o=["./demo/*.min.js"],outputDir:s="./demo",dev:i=!1}=e,a=Vs.sync(n,{ignore:o}),c=tn(t,{dev:i}),l=rn(r);return{name:"Demo",configs:a.map(u=>({input:{[Bs(u,".js")]:u},output:{format:"esm",dir:s,entryFileNames:"[name].min.js",chunkFileNames:"[name].min.js",assetFileNames:i?"[name][extname]":"[name]-[hash][extname]",inlineDynamicImports:!0},plugins:c,onwarn(d,f){if(d.code==="UNRESOLVED_IMPORT")throw new Error(`Unresolved import "${d.exporter??d.source}" in ${d.id??u}. Make sure workspace dependencies are built before bundling demos.`);f(d)},watch:l}))}}function rn(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 zs(e=[]){return[...[/node_modules\/lit/,/node_modules\/lit-element/,/node_modules\/lit-html/,/node_modules\/@lit/],...e]}function an(){let e=$e("./dist"),t=Wt("Cleaning dist folder...").start();try{return qs(e,{recursive:!0,force:!0}),t.succeed("All clean! Dist folder wiped."),!0}catch(r){return t.fail(`Oops! Couldn't clean dist/ folder: ${r.message}`),console.error(r),!1}}async function Xe(e,t,r,n){let o=Wt(e).start();try{let s=await t();return o.succeed(r),s}catch(s){throw o.fail(n),console.error(`Error: ${s.message}`),s}}async function cn(e,t){return Xe(`Bundling ${e.name||"main"} and demo...`,async()=>{let r=await Ht(e);await r.write(e.output),await r.close();for(let n of t){let o=await Ht(n);await o.write(n.output),await o.close()}},`Bundles ready! ${e.name||"Main"} and demo built.`,"Bundle hiccup! Build failed.")}async function Ze(e){let{wcaInput:t,wcaOutput:r,skipDocs:n}=e;if(n){let o=Wt("Skipping docs generation...").start();setTimeout(()=>{o.succeed("Docs generation skipped.")},0);return}return Xe("Analyzing components and making docs...",async()=>{await qe(t,r),await Se(e),Ee()},"Docs ready! Looking good.","Doc troubles!")}function ei(){let e=process.cwd();function t(o){return[o,`${o}.scss`,`${o}.css`,$e(Zs(o),`_${Xs(o)}.scss`),$e(o,"_index.scss"),$e(o,"index.scss")].find(i=>nn(i))}function r(o){for(let i of W){let a=t(Ye(e,i,o));if(a)return a}let s=n(o);return s||null}function n(o){let s,i;if(o.startsWith("@")){let a=o.split("/");if(a.length<3)return null;s=`${a[0]}/${a[1]}`,i=`./${a.slice(2).join("/")}`}else{let a=o.indexOf("/");if(a===-1)return null;s=o.slice(0,a),i=`./${o.slice(a+1)}`}for(let a of W){let c=Ye(e,a,s,"package.json");if(nn(c))try{let m=JSON.parse(Ks(c,"utf-8")).exports;if(!m||typeof m!="object")continue;let u=m[i];if(!u)continue;let p=typeof u=="string"?u:u.default||u.import;if(!p)continue;let d=t(Ye(e,a,s,p));if(d)return d}catch{continue}}return null}return{findFileUrl(o){if(o.includes("/node_modules/")){let s=o.lastIndexOf("/node_modules/"),i=o.slice(s+14),a=r(i);if(a)return on(a)}if(!o.startsWith(".")&&!o.startsWith("/")&&!o.startsWith("file:")){let s=r(o);if(s)return on(s)}return null}}}async function V(e="./demo"){return Xe("Compiling demo SCSS...",async()=>{let t=Qs.sync($e(e,"**/*.scss")),r=ei(),n=process.cwd(),o=W.map(s=>Ye(n,s));for(let s of t){let i=sn.compile(s,{importers:[r],loadPaths:o,silenceDeprecations:["import"],style:"compressed"}),a=s.replace(/\.scss$/,".min.css");Ys(a,i.css)}return t.length},"Demo SCSS compiled.","SCSS compilation failed.")}async function Gt(e={}){let{configs:t}=Te(e);return Xe("Bundling demo JS...",async()=>{for(let r of t){let n=await Ht(r);await n.write(r.output),await n.close()}},"Demo JS bundled.","Demo JS bundling failed.")}import ln from"node:path";import te from"ora";import"rollup";var Ae=!1,ti={analyze:{active:!1,lastTime:0},docs:{active:!1,lastTime:0},scss:{active:!1,lastTime:0}},ri=5e3,Qe=new Set,ni=["/dist/index.d.ts","/custom-elements.json","/demo/api.md","/docs/api.md","/demo/index.min.js"];function oi(e){if(!e||typeof e!="string")return!1;try{let t=ln.normalize(e);return ni.some(r=>t.endsWith(r))||t.includes("/dist/")||t.endsWith(".min.js")||t.endsWith(".min.css")||t.endsWith(".d.ts")}catch(t){return console.error(`Error checking path (${typeof e}):`,t.message),!1}}async function Vt(e,t){let r=ti[e];if(r.active||Date.now()-r.lastTime<ri)return!1;try{return r.active=!0,r.lastTime=Date.now(),await t()}catch(n){return console.error(`Error in ${e} task:`,n),!1}finally{r.active=!1}}async function un(e,t,r){let n=!0,o={analyze:!1,docs:!1,scss:!1},s=null,i,a=te("Activating watch mode...").start(),c={analyze:async()=>{let{wcaInput:u,wcaOutput:p,skipDocs:d}=t;if(d){let h=te("Skipping component analysis...").start();return setTimeout(()=>{h.succeed("Component analysis skipped.")},0),!0}let f=te("Detective work: analyzing components...").start();try{return await qe(u,p),f.succeed("Component analysis complete! API generated."),!0}catch(h){return f.fail("Analysis hiccup! Something went wrong."),console.error("Component analysis error:",h),!1}},docs:async()=>{if(Ae)return!1;if(t.skipDocs){let p=te("Skipping docs generation...").start();return setTimeout(()=>{p.succeed("Docs generation skipped.")},0),!0}let u=te("Refreshing docs...").start();try{return await Ze(t),u.succeed("Documentation refreshed!"),!0}catch(p){u.fail("Docs stumble! Couldn't refresh."),console.error("Documentation rebuild error:",p)}},scss:async()=>{if(Ae)return!1;try{return await V(),!0}catch(u){return console.error("Demo SCSS compilation error:",u),!1}}},l=()=>{n&&o.analyze&&o.docs&&o.scss&&typeof r=="function"&&(n=!1,r())};function m(u=1e3){s&&clearTimeout(s),s=setTimeout(async()=>{setTimeout(async()=>{o.analyze=await Vt("analyze",c.analyze),setTimeout(async()=>{o.docs=await Vt("docs",c.docs),setTimeout(async()=>{o.scss=await Vt("scss",c.scss),l()},500)},1e3)},1e3)},u)}e.on("event",async u=>{switch(u.code){case"START":a.succeed("Watch mode active! Eyes peeled.");break;case"BUNDLE_START":if(Qe.clear(),u.input)try{let p=Array.isArray(u.input)?u.input:typeof u.input=="string"?[u.input]:typeof u.input=="object"&&u.input!==null?Object.values(u.input):[];for(let d of p)typeof d=="string"&&!oi(d)&&Qe.add(ln.normalize(d))}catch(p){console.error("Error processing input paths:",p)}i=te("Weaving bundles...").start(),Ae=!0;break;case"BUNDLE_END":i&&i.succeed(`Bundle ${Array.isArray(u.input)?`of ${u.input.join("& ")} `:""}done in ${u.duration}ms! \u{1F680}`),Ae=!1,Qe.size>0&&m();break;case"END":break;case"ERROR":Ae=!1,i?i.fail(`Oops! Bundle hit a snag: ${u.error.message}`):te().fail(`Watch mode hiccup: ${u.error.message}`),Qe.clear();break}})}function mn(e,t){return ke(e),t&&ke(t),We(),e}async function ai(e){let t=Ut(e),r=Te(e);e.dev||t.config.plugins.push(si()),await Ze(e),await V(),await cn(t.config,r.configs)}async function ci(e){let{dev:t}=e,r=Ut({...e,watch:!0}),n=Te({...e,watch:!0}),o=ii([r.config,...n.configs]);un(o,e,t?async()=>Je(e):void 0);let s=await import("chokidar"),i=!1,a=!1,c=null,l=s.watch("./demo/**/*.scss",{ignoreInitial:!0,ignored:["**/demo/**/*.min.css"],awaitWriteFinish:{stabilityThreshold:500,pollInterval:100}});return l.on("all",()=>{c&&clearTimeout(c),c=setTimeout(async()=>{if(i){a=!0;return}i=!0;try{await V()}catch(m){console.error("Demo SCSS watch compilation error:",m)}finally{i=!1,a&&(a=!1,l.emit("all"))}},500)}),mn(o,l),o}async function et(e={}){try{let{watch:t}=e;return an(),t?await ci(e):await ai(e)}catch(t){throw new Error(`Build failed: ${t.message}`)}}var Re=li.command("dev").description("Runs development server for auro components");Re=Ge(Re);Re=Be(Re);var Wm=Re.action(async e=>{try{let t=pn("Initializing...");e.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=e.docs===!1?"Building component (docs disabled)":"Building component",t.start(),e.watch||t.succeed("Build completed!"),await et({...e,dev:!0,watch:e.watch})}catch(t){pn().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{program as ui}from"commander";import dn from"ora";var Jt=ui.command("build").description("Builds auro components");Jt=Ge(Jt);var Ym=Jt.action(async e=>{try{let t=dn("Initializing...");e.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=e.docs===!1?"Building component (docs disabled)":"Building component",t.start(),await et(e),e.watch||t.succeed("Build completed!")}catch(t){dn().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{exec as mi}from"node:child_process";import fn from"node:path";import pi from"node:process";import{fileURLToPath as di}from"node:url";import fi from"node:util";import{program as gi}from"commander";import hi from"inquirer";var ip=gi.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=di(import.meta.url),r=fn.dirname(t),n=fn.resolve(r,"migrations",e.id);if(e.multiGitter){let o=fi.promisify(mi);try{await o("command -v multi-gitter")}catch{console.error("multi-gitter is not installed."),pi.exit(1)}(await hi.prompt([{type:"confirm",name:"dryRun",message:"Run migration in dry-run mode? (no changes will be committed)",default:!0}])).dryRun?_(`multi-gitter run ${n}/script.sh --config "${n}/multi-gitter.yml" --dry-run`):_(`multi-gitter run ${n}/script.sh --config "${n}/multi-gitter.yml"`)}else _(`${n}/script.sh`)});import wn from"node:process";import{program as Ei}from"commander";import{readFile as ki,writeFile as Si}from"node:fs/promises";import{Logger as Pe}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import zt from"node:fs/promises";import Kt from"node:path";import{Octokit as yi}from"@octokit/rest";import j from"ora";import{processContentForFile as bi,templateFiller as wi}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";async function gn(e,t){let r=new yi({auth:process.env.GITHUB_TOKEN||""});try{let o=(await r.request("GET /repos/{owner}/{repo}/contents/{path}",{ref:t,owner:"AlaskaAirlines",repo:"auro-templates",path:e,headers:{"X-GitHub-Api-Version":"2022-11-28"}})).data;if(typeof o!="object"||!Array.isArray(o)){let s=`Unexpected response format: ${JSON.stringify(o)}`;throw j().start().fail(s),new Error("Failed to retrieve folder items")}return o}catch(n){let o=j().start();throw n.status===404?o.fail(`Template '${e.split("/")[1]}' not found`):o.fail(`Error accessing template: ${n.message}`),n}}async function hn({folderItems:e,templatePathToReplace:t,rootDir:r,ref:n}){let o=[];for(let s of e){if(s.type=="dir"){let l=j(`Processing directory: ${s.path}`).start(),m=await gn(s.path,n);l.succeed(`Found ${m.length} additional items in ${s.path}`);let u=await hn({folderItems:m,templatePathToReplace:t,rootDir:r,ref:n});o.push(...u);continue}let i=s.path.replace(`${t}/`,""),a=`${r}/.github/${i}`,c={identifier:s.name,input:{remoteUrl:s.download_url||"",fileName:a,overwrite:!0},output:a};o.push(c)}return o}async function vi(e){try{await zt.rm(e,{recursive:!0,force:!0}),j().start().succeed(`Successfully removed directory: ${e}`)}catch(t){throw j().start().fail(`Error removing directory ${e}: ${t.message}`),t}}async function yn(e,t="",r=!0){try{let n=await zt.stat(e),o=Kt.basename(e);if(!n.isDirectory())return`${t}${r?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}
|
|
26
|
-
`;let s=`${t}${
|
|
27
|
-
`;try{let a=(await
|
|
28
|
-
`}return s}catch(n){return`${t}${
|
|
29
|
-
`}}async function
|
|
19
|
+
<!-- AURO-GENERATED-CONTENT:END -->`}n=n.replace(d,k),o.lastIndex=0,i=!0}}i&&(n=Ae.replaceTemplateValues(n,t),await T.promises.writeFile(r,n)),n=await T.promises.readFile(r,"utf8");let l=/^[ \t]*```(\w*)\n([\s\S]*?)^[ \t]*```[ \t]*$/gm,m=n.replace(l,(d,f,p)=>{let g=f||"html",b=p.trimEnd().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return`<pre class="language-${g}"><code class="language-${g}">${b}
|
|
20
|
+
</code></pre>`});m!==n&&await T.promises.writeFile(r,m),n=await T.promises.readFile(r,"utf8"),n=n.replace(/(<pre[^>]*><code[^>]*>)([\s\S]*?)(<\/code><\/pre>)/g,(d,f,p,g)=>{let b=p.split(`
|
|
21
|
+
`),x=b.filter($=>$.trim().length>0);if(x.length===0)return d;let O=Math.min(...x.map($=>{let K=$.match(/^[ \t]*/);return K?K[0].length:0})),k=b.map($=>$===""||$.trim().length===0?"\u200B":O>0?$.substring(O):$);for(;k.length>0&&(k[k.length-1]==="\u200B"||k[k.length-1]==="");)k.pop();return f+k.join(`
|
|
22
|
+
`)+g});let u=n.split(`
|
|
23
|
+
`),c=!1;for(let d=0;d<u.length;d++)/<pre[\s>]/i.test(u[d])&&(c=!0),c||(u[d]=u[d].replace(/^[ \t]+(?=<)/,"")),/<\/pre>/i.test(u[d])&&(c=!1);await T.promises.writeFile(r,u.join(`
|
|
24
|
+
`))}async function F(r={}){let t=r.readmeTemplate,e=t&&!t.startsWith("http");await lr({...tt,...e?{localReadmePath:C.resolve(process.cwd(),t)}:{remoteReadmeUrl:t||"https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/README.md"}},r.skipReadme)}function et(r){return T.existsSync(E(r))}import{existsSync as rt,readFileSync as mr}from"node:fs";import{builtinModules as dr}from"node:module";import{resolve as re}from"node:path";import{startDevServer as pr}from"@web/dev-server";import{hmrPlugin as fr}from"@web/dev-server-hmr";import*as nt from"esbuild";import gr from"ora";var I=["node_modules","../node_modules","../../node_modules","../../../node_modules"];var hr=/^\/__wds-outside-root__\/(\d+)\/(.+)$/;function yr(){return{name:"node-modules-css",serve(r){if(!r.path.endsWith(".css")||!r.path.startsWith("/@")&&!/^\/[a-z]/i.test(r.path))return;let t=r.path.slice(1),e=process.cwd();for(let n of I){let o=re(e,n,t);if(rt(o))return{body:mr(o,"utf-8"),type:"css"}}}}}function wr(r,t){let e=r.match(hr);return e?re(t,"../".repeat(Number.parseInt(e[1],10)),e[2]):re(t,`.${r}`)}function br(){let r=/\b(require\s*\(|module\.exports\b|exports\.\w)/,t=new Map,e;return{name:"cjs-to-esm",async serverStart({config:n}){e=re(n.rootDir)},async transform(n){if(!n.path.includes("node_modules")||!n.path.endsWith(".js")&&!n.path.endsWith(".cjs")||typeof n.body!="string"||!r.test(n.body))return;let o=wr(n.path,e);if(t.has(o))return t.get(o);if(rt(o))try{let i={body:(await nt.build({entryPoints:[o],bundle:!0,format:"esm",platform:"browser",write:!1,logLevel:"silent",external:dr})).outputFiles[0].text};return t.set(o,i),i}catch(s){console.error(`CJS-to-ESM bundling failed for ${n.path}:`,s.message)}}}}var M={watch:!0,nodeResolve:!0,basePath:"/",rootDir:"./demo",hmrInclude:["src/**/*","demo/**/*","apiExamples/**/*","docs/**/*"]};async function ne(r={}){if(!r.serve)return;let t=gr(`Firing up dev server...
|
|
25
|
+
`).start();try{let e={port:Number(r.port)||void 0,open:r.open?"/":void 0,watch:r.watch??M.watch,nodeResolve:r.nodeResolve??M.nodeResolve,basePath:r.basePath??M.basePath,rootDir:r.rootDir??M.rootDir,middleware:[function(s,i){return!s.url.endsWith("/")&&!s.url.includes(".")&&(s.url+=".html"),i()}],plugins:[yr(),br(),fr({include:r.hmrInclude??M.hmrInclude})]},n=await pr({config:e,readCliArgs:!1,readFileConfig:!1});return t.stop(),n}catch(e){throw t.fail("Server snag! Couldn't start dev server."),console.error("Error starting development server:",e),new Error(`Development server failed to start: ${e.message}`)}}async function oe(){let r=B("Generating Custom Elements Manifest...").start();try{await A(`npx --package=@custom-elements-manifest/analyzer -y -- cem analyze --config '${Ye("custom-elements-manifest.config.mjs")}'`),r.succeed("Custom Elements Manifest generated successfully!")}catch(t){let e=t instanceof Error?t.message:String(t);r.warn("CEM analyzer completed with warnings: "+e)}}async function se(){let r=B("Generating API md file...").start();try{await N.generate(),r.succeed("API md file generated successfully!")}catch(t){let e=t instanceof Error?t.message:String(t);throw r.fail("Failed to generate API md file: "+e),t}}async function ot(r={}){let t=B("Compiling documentation...").start();try{await F(r),t.succeed("Documentation compiled successfully!")}catch(e){let n=e instanceof Error?e.message:String(e);throw t.fail("Failed to compile MD documentation: "+n),e}j(),await R(),await Te(r)}async function st(r={}){await ne(r)}async function it(r={}){let t=await import("chokidar"),e=["./src/**/*","./docs/**/*","./docTemplates/**/*","./apiExamples/**/*","./demo/**/*.scss"],n=["**/demo/*.min.js","**/demo/*.min.css","**/demo/*.md","**/demo/readme.md","**/docs/api.md","**/custom-elements.json","**/node_modules/**","**/dist/**","**/.git/**"],o=t.watch(e,{ignoreInitial:!0,ignored:n,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100}}),s=B("Waiting for changes...");s.spinner="bouncingBar",s.color="green",s.start();let i=null,a=!1,l=!1;async function m(u){if(a){l=!0;return}a=!0,o.unwatch(e);let c=B(`Change detected: ${u}`).start();try{await F(r),j(),await R(),await Te(r),c.succeed("Docs rebuilt!")}catch(d){let f=d instanceof Error?d.message:String(d);c.fail("Rebuild failed: "+f)}finally{setTimeout(()=>{o.add(e),a=!1,l&&(l=!1,m("queued changes"))},1e3)}}o.on("all",(u,c)=>{a||(i&&clearTimeout(i),i=setTimeout(()=>{m(c)},1e3))}),_(o),te()}async function ie(){await oe(),await se()}import{basename as Er,join as ct,resolve as Ar}from"node:path";import vr from"@rollup/plugin-commonjs";import{nodeResolve as Tr}from"@rollup/plugin-node-resolve";import{glob as Cr}from"glob";import{litScss as Ir}from"rollup-plugin-scss-lit";import kr from"node:path";import{glob as $r}from"glob";function at(r){return{name:"watch-globs",buildStart(){let t=Array.isArray(r)?r:[r];for(let e of t)try{for(let n of $r.sync(kr.resolve(e)))this.addWatchFile(n)}catch(n){this.error(`Error watching glob pattern "${e}": ${n.message}`)}}}}var Ce={moduleDirectories:["node_modules"],modulePaths:["../../node_modules","../node_modules","node_modules"],watchPatterns:["./apiExamples/**/*","./docs/**/*"]};function lt(r=[],t={}){let{watchPatterns:e=Ce.watchPatterns,dedupe:n=["lit","lit-element","lit-html"],dev:o=!1}=t,s=[...Ce.modulePaths,...r],i=process.cwd(),a=I.map(l=>Ar(i,l));return[Tr({dedupe:n,preferBuiltins:!1,moduleDirectories:Ce.moduleDirectories,modulePaths:a}),vr(),Ir({minify:o?!1:{fast:!0},options:{loadPaths:[...s,ct(process.cwd(),"src","styles"),ct(process.cwd(),"src")]}}),at(e)]}function Ie(r={}){let{modulePaths:t=[],watch:e=!1,input:n=["./src/index.js","./src/registered.js"],outputDir:o="./dist",format:s="esm",dev:i=!1}=r;return{name:"Main",config:{input:n,output:{format:s,dir:o,entryFileNames:a=>i||["index","registered"].includes(a.name)?"[name].js":"[name]-[hash].js",chunkFileNames:i?"[name].js":"[name]-[hash].js",assetFileNames:i?"[name][extname]":"[name]-[hash][extname]"},external:Rr(),plugins:lt(t,{dev:i}),watch:ut(e)}}}function G(r={}){let{modulePaths:t=[],watch:e=!1,globPattern:n="./demo/*.js",ignorePattern:o=["./demo/*.min.js"],outputDir:s="./demo",dev:i=!1}=r,a=Cr.sync(n,{ignore:o}),l=lt(t,{dev:i}),m=ut(e);return{name:"Demo",configs:a.map(c=>({input:{[Er(c,".js")]:c},output:{format:"esm",dir:s,entryFileNames:"[name].min.js",chunkFileNames:"[name].min.js",assetFileNames:i?"[name][extname]":"[name]-[hash][extname]",inlineDynamicImports:!0},plugins:l,onwarn(f,p){if(f.code==="UNRESOLVED_IMPORT")throw new Error(`Unresolved import "${f.exporter??f.source}" in ${f.id??c}. Make sure workspace dependencies are built before bundling demos.`);p(f)},watch:m}))}}function ut(r){if(!r)return!1;let t=typeof r=="object"?r:{};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 Rr(r=[]){return[...[/node_modules\/lit/,/node_modules\/lit-element/,/node_modules\/lit-html/,/node_modules\/@lit/],...r]}function ft(){let r=L("./dist"),t=Se("Cleaning dist folder...").start();try{return Dr(r,{recursive:!0,force:!0}),t.succeed("All clean! Dist folder wiped."),!0}catch(e){return t.fail(`Oops! Couldn't clean dist/ folder: ${e.message}`),console.error(e),!1}}async function ce(r,t,e,n){let o=Se(r).start();try{let s=await t();return o.succeed(e),s}catch(s){throw o.fail(n),console.error(`Error: ${s.message}`),s}}async function gt(r,t){return ce(`Bundling ${r.name||"main"} and demo...`,async()=>{let e=await Re(r);await e.write(r.output),await e.close();for(let n of t){let o=await Re(n);await o.write(n.output),await o.close()}},`Bundles ready! ${r.name||"Main"} and demo built.`,"Bundle hiccup! Build failed.")}async function le(r){let{wcaInput:t,wcaOutput:e,skipDocs:n}=r;if(n){let o=Se("Skipping docs generation...").start();setTimeout(()=>{o.succeed("Docs generation skipped.")},0);return}return ce("Analyzing components and making docs...",async()=>{await ie(t,e),await F(r),j()},"Docs ready! Looking good.","Doc troubles!")}function jr(){let r=process.cwd();function t(o){return[o,`${o}.scss`,`${o}.css`,L(Or(o),`_${xr(o)}.scss`),L(o,"_index.scss"),L(o,"index.scss")].find(i=>mt(i))}function e(o){for(let i of I){let a=t(ae(r,i,o));if(a)return a}let s=n(o);return s||null}function n(o){let s,i;if(o.startsWith("@")){let a=o.split("/");if(a.length<3)return null;s=`${a[0]}/${a[1]}`,i=`./${a.slice(2).join("/")}`}else{let a=o.indexOf("/");if(a===-1)return null;s=o.slice(0,a),i=`./${o.slice(a+1)}`}for(let a of I){let l=ae(r,a,s,"package.json");if(mt(l))try{let u=JSON.parse(Sr(l,"utf-8")).exports;if(!u||typeof u!="object")continue;let c=u[i];if(!c)continue;let d=typeof c=="string"?c:c.default||c.import;if(!d)continue;let f=t(ae(r,a,s,d));if(f)return f}catch{continue}}return null}return{findFileUrl(o){if(o.includes("/node_modules/")){let s=o.lastIndexOf("/node_modules/"),i=o.slice(s+14),a=e(i);if(a)return dt(a)}if(!o.startsWith(".")&&!o.startsWith("/")&&!o.startsWith("file:")){let s=e(o);if(s)return dt(s)}return null}}}async function R(r="./demo"){return ce("Compiling demo SCSS...",async()=>{let t=Nr.sync(L(r,"**/*.scss")),e=jr(),n=process.cwd(),o=I.map(s=>ae(n,s));for(let s of t){let i=pt.compile(s,{importers:[e],loadPaths:o,silenceDeprecations:["import"],style:"compressed"}),a=s.replace(/\.scss$/,".min.css");Pr(a,i.css)}return t.length},"Demo SCSS compiled.","SCSS compilation failed.")}async function Te(r={}){let{configs:t}=G(r);return ce("Bundling demo JS...",async()=>{for(let e of t){let n=await Re(e);await n.write(e.output),await n.close()}},"Demo JS bundled.","Demo JS bundling failed.")}import ht from"node:path";import D from"ora";import"rollup";var U=!1,_r={analyze:{active:!1,lastTime:0},docs:{active:!1,lastTime:0},scss:{active:!1,lastTime:0}},Fr=5e3,ue=new Set,Mr=["/dist/index.d.ts","/custom-elements.json","/demo/api.md","/docs/api.md","/demo/index.min.js"];function Br(r){if(!r||typeof r!="string")return!1;try{let t=ht.normalize(r);return Mr.some(e=>t.endsWith(e))||t.includes("/dist/")||t.endsWith(".min.js")||t.endsWith(".min.css")||t.endsWith(".d.ts")}catch(t){return console.error(`Error checking path (${typeof r}):`,t.message),!1}}async function De(r,t){let e=_r[r];if(e.active||Date.now()-e.lastTime<Fr)return!1;try{return e.active=!0,e.lastTime=Date.now(),await t()}catch(n){return console.error(`Error in ${r} task:`,n),!1}finally{e.active=!1}}async function yt(r,t,e){let n=!0,o={analyze:!1,docs:!1,scss:!1},s=null,i,a=D("Activating watch mode...").start(),l={analyze:async()=>{let{wcaInput:c,wcaOutput:d,skipDocs:f}=t;if(f){let g=D("Skipping component analysis...").start();return setTimeout(()=>{g.succeed("Component analysis skipped.")},0),!0}let p=D("Detective work: analyzing components...").start();try{return await ie(c,d),p.succeed("Component analysis complete! API generated."),!0}catch(g){return p.fail("Analysis hiccup! Something went wrong."),console.error("Component analysis error:",g),!1}},docs:async()=>{if(U)return!1;if(t.skipDocs){let d=D("Skipping docs generation...").start();return setTimeout(()=>{d.succeed("Docs generation skipped.")},0),!0}let c=D("Refreshing docs...").start();try{return await le(t),c.succeed("Documentation refreshed!"),!0}catch(d){c.fail("Docs stumble! Couldn't refresh."),console.error("Documentation rebuild error:",d)}},scss:async()=>{if(U)return!1;try{return await R(),!0}catch(c){return console.error("Demo SCSS compilation error:",c),!1}}},m=()=>{n&&o.analyze&&o.docs&&o.scss&&typeof e=="function"&&(n=!1,e())};function u(c=1e3){s&&clearTimeout(s),s=setTimeout(async()=>{setTimeout(async()=>{o.analyze=await De("analyze",l.analyze),setTimeout(async()=>{o.docs=await De("docs",l.docs),setTimeout(async()=>{o.scss=await De("scss",l.scss),m()},500)},1e3)},1e3)},c)}r.on("event",async c=>{switch(c.code){case"START":a.succeed("Watch mode active! Eyes peeled.");break;case"BUNDLE_START":if(ue.clear(),c.input)try{let d=Array.isArray(c.input)?c.input:typeof c.input=="string"?[c.input]:typeof c.input=="object"&&c.input!==null?Object.values(c.input):[];for(let f of d)typeof f=="string"&&!Br(f)&&ue.add(ht.normalize(f))}catch(d){console.error("Error processing input paths:",d)}i=D("Weaving bundles...").start(),U=!0;break;case"BUNDLE_END":i&&i.succeed(`Bundle ${Array.isArray(c.input)?`of ${c.input.join("& ")} `:""}done in ${c.duration}ms! \u{1F680}`),U=!1,ue.size>0&&u();break;case"END":break;case"ERROR":U=!1,i?i.fail(`Oops! Bundle hit a snag: ${c.error.message}`):D().fail(`Watch mode hiccup: ${c.error.message}`),ue.clear();break}})}function wt(r,t){return _(r),t&&_(t),te(),r}async function Ur(r){let t=Ie(r),e=G(r);r.dev||t.config.plugins.push(Gr()),await le(r),await R(),await gt(t.config,e.configs)}async function Hr(r){let{dev:t}=r,e=Ie({...r,watch:!0}),n=G({...r,watch:!0}),o=Lr([e.config,...n.configs]);yt(o,r,t?async()=>ne(r):void 0);let s=await import("chokidar"),i=!1,a=!1,l=null,m=s.watch("./demo/**/*.scss",{ignoreInitial:!0,ignored:["**/demo/**/*.min.css"],awaitWriteFinish:{stabilityThreshold:500,pollInterval:100}});return m.on("all",()=>{l&&clearTimeout(l),l=setTimeout(async()=>{if(i){a=!0;return}i=!0;try{await R()}catch(u){console.error("Demo SCSS watch compilation error:",u)}finally{i=!1,a&&(a=!1,m.emit("all"))}},500)}),wt(o,m),o}async function me(r={}){try{let{watch:t}=r;return ft(),t?await Hr(r):await Ur(r)}catch(t){throw new Error(`Build failed: ${t.message}`)}}var H=Wr.command("dev").description("Runs development server for auro components");H=X(H);H=Z(H);var js=H.action(async r=>{try{let t=bt("Initializing...");r.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=r.docs===!1?"Building component (docs disabled)":"Building component",t.start(),r.watch||t.succeed("Build completed!"),await me({...r,dev:!0,watch:r.watch})}catch(t){bt().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{program as zr}from"commander";import kt from"ora";var Pe=zr.command("build").description("Builds auro components");Pe=X(Pe);var Ls=Pe.action(async r=>{try{let t=kt("Initializing...");r.watch?(t.text="Waiting for changes...",t.spinner="bouncingBar",t.color="green"):t.text=r.docs===!1?"Building component (docs disabled)":"Building component",t.start(),await me(r),r.watch||t.succeed("Build completed!")}catch(t){kt().fail(`Build failed: ${t.message}`),console.error(t),process.exit(1)}});import{exec as qr}from"node:child_process";import $t from"node:path";import Vr from"node:process";import{fileURLToPath as Jr}from"node:url";import Kr from"node:util";import{program as Yr}from"commander";import Xr from"inquirer";var Xs=Yr.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 r=>{let t=Jr(import.meta.url),e=$t.dirname(t),n=$t.resolve(e,"migrations",r.id);if(r.multiGitter){let o=Kr.promisify(qr);try{await o("command -v multi-gitter")}catch{console.error("multi-gitter is not installed."),Vr.exit(1)}(await Xr.prompt([{type:"confirm",name:"dryRun",message:"Run migration in dry-run mode? (no changes will be committed)",default:!0}])).dryRun?A(`multi-gitter run ${n}/script.sh --config "${n}/multi-gitter.yml" --dry-run`):A(`multi-gitter run ${n}/script.sh --config "${n}/multi-gitter.yml"`)}else A(`${n}/script.sh`)});import Ct from"node:process";import{program as rn}from"commander";import{readFile as nn,writeFile as on}from"node:fs/promises";import{Logger as W}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import xe from"node:fs/promises";import Oe from"node:path";import{Octokit as Zr}from"@octokit/rest";import v from"ora";import{processContentForFile as Qr,templateFiller as en}from"@aurodesignsystem/auro-library/scripts/utils/sharedFileProcessorUtils.mjs";async function Et(r,t){let e=new Zr({auth:process.env.GITHUB_TOKEN||""});try{let o=(await e.request("GET /repos/{owner}/{repo}/contents/{path}",{ref:t,owner:"AlaskaAirlines",repo:"auro-templates",path:r,headers:{"X-GitHub-Api-Version":"2022-11-28"}})).data;if(typeof o!="object"||!Array.isArray(o)){let s=`Unexpected response format: ${JSON.stringify(o)}`;throw v().start().fail(s),new Error("Failed to retrieve folder items")}return o}catch(n){let o=v().start();throw n.status===404?o.fail(`Template '${r.split("/")[1]}' not found`):o.fail(`Error accessing template: ${n.message}`),n}}async function At({folderItems:r,templatePathToReplace:t,rootDir:e,ref:n}){let o=[];for(let s of r){if(s.type=="dir"){let m=v(`Processing directory: ${s.path}`).start(),u=await Et(s.path,n);m.succeed(`Found ${u.length} additional items in ${s.path}`);let c=await At({folderItems:u,templatePathToReplace:t,rootDir:e,ref:n});o.push(...c);continue}let i=s.path.replace(`${t}/`,""),a=`${e}/.github/${i}`,l={identifier:s.name,input:{remoteUrl:s.download_url||"",fileName:a,overwrite:!0},output:a};o.push(l)}return o}async function tn(r){try{await xe.rm(r,{recursive:!0,force:!0}),v().start().succeed(`Successfully removed directory: ${r}`)}catch(t){throw v().start().fail(`Error removing directory ${r}: ${t.message}`),t}}async function vt(r,t="",e=!0){try{let n=await xe.stat(r),o=Oe.basename(r);if(!n.isDirectory())return`${t}${e?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}
|
|
26
|
+
`;let s=`${t}${e?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${o}/
|
|
27
|
+
`;try{let a=(await xe.readdir(r)).sort();for(let l=0;l<a.length;l++){let m=a[l],u=Oe.join(r,m),c=l===a.length-1,d=t+(e?" ":"\u2502 ");s+=await vt(u,d,c)}}catch{s+=`${t}${e?" ":"\u2502 "}\u2514\u2500\u2500 [Permission denied or error reading directory]
|
|
28
|
+
`}return s}catch(n){return`${t}${e?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}[Error: ${n}]
|
|
29
|
+
`}}async function Tt(r,t="main",e="default"){if(!r)throw v().start().fail("Root directory must be specified"),new Error("Root directory must be specified");if(await en.extractNames(),!process.env.GITHUB_TOKEN)throw v().start().fail("GITHUB_TOKEN environment variable is not set."),new Error("GITHUB_TOKEN environment variable is not set");let n=`templates/${e}/.github`,o=await Et(n,t),s=".github",i=v("Removing existing .github directory...").start();try{await tn(s),i.succeed(".github directory removed successfully")}catch(m){throw i.fail(`Error removing .github directory: ${m.message}`),new Error(`Failed to remove .github directory: ${m.message}`)}let a=await At({folderItems:o,templatePathToReplace:n,rootDir:r,ref:t}),l=v("Processing all files...").start();try{await Promise.all(a.map(u=>Qr(u))),l.succeed("All files processed.");let m=v("Generating directory tree...").start();try{let u=Oe.join(r,".github"),c=await vt(u);m.succeed("Synced .github directory structure:"),console.log(c)}catch(u){m.fail(`Error generating directory tree: ${u.message}`)}}catch(m){throw l.fail(`Error processing files: ${m.message}`),new Error(`Failed to process files: ${m.message}`)}}var ui=rn.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 r=>{W.info("Synchronizing repository configuration files..."),W.warn("Note: sync does not create a new git branch. Changes are added to the current branch.");let t=Ct.cwd();try{await Tt(t,r.ref,r.template);try{let e=`${t}/.github/CODEOWNERS`,o=(await nn(e,{encoding:"utf-8"})).replace(/\r\n/gu,`
|
|
30
30
|
`).replace(/\n\n/gu,`
|
|
31
|
-
`);await
|
|
31
|
+
`);await on(e,o,{encoding:"utf-8"}),(o.includes("\r")||o.includes(`
|
|
32
32
|
|
|
33
|
-
`))&&
|
|
33
|
+
`))&&W.error("CODEOWNERS file still has Windows line endings.")}catch(e){throw W.error(`Error processing CODEOWNERS file: ${e.message}`),e}}catch(e){W.error(`Sync operation failed: ${e.message}`),Ct.exit(1)}});import de from"node:fs";import z from"node:path";import{Logger as Rt}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as sn}from"commander";import{glob as an}from"glob";var It=(r,t)=>{let e=(r.match(/static register\(name \= (.+)\)/)||r.match(/customElements.get\((.+?)\)/))[1],n=r.match(/export class (.+) extends/)?.[1],o=r.match(/\/\*\*((.|\n)*?)(\*\n|\*\/|[@])/)?.[1]||"";return!e||!n?r:`
|
|
34
34
|
import { ${n} } from '${t}';
|
|
35
35
|
|
|
36
36
|
/**${o}*/
|
|
37
37
|
class ${n}WCA extends ${n} {}
|
|
38
38
|
|
|
39
|
-
if (!customElements.get(${
|
|
40
|
-
customElements.define(${
|
|
39
|
+
if (!customElements.get(${e})) {
|
|
40
|
+
customElements.define(${e}, ${n}WCA);
|
|
41
41
|
}
|
|
42
|
-
`};var
|
|
42
|
+
`};var pe=z.resolve(process.cwd(),"./scripts/wca");async function cn(r){try{return(await Promise.all(r.map(e=>an(e)))).flat()}catch(t){throw console.error("Error processing glob patterns:",t),t}}async function ln(r){de.existsSync(pe)||await de.promises.mkdir(pe,{recursive:!0});for(let t of r){let e=z.resolve(process.cwd(),t),n=await de.promises.readFile(e,"utf-8"),o=z.resolve(pe,`${z.basename(t)}`),s=It(n,z.relative(pe,t));await de.promises.writeFile(o,s)}}async function un(){let r=await cn(["./src/auro-*.js"]);await ln(r)}var bi=sn.command("wca-setup").description("Set up WCA (Web Component Analyzer) for the project").action(()=>{un().then(()=>{Rt.success("WCA setup completed successfully.")}).catch(r=>{Rt.error(`WCA setup failed: ${r.message}`)})});import{program as wn}from"commander";import xt from"chalk";import Ot from"ora";import{appendFile as mn,readFile as dn}from"node:fs/promises";import{Logger as h}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{simpleGit as pn}from"simple-git";var y;try{y=pn({baseDir:process.cwd(),binary:"git",maxConcurrentProcesses:1})}catch(r){h.error(`Failed to initialize git: ${r}`),y={}}var S=class r{static async checkGitignore(t){if(t==="")return!1;try{return(await dn(".gitignore","utf-8")).includes(t)}catch(e){return h.error(`Error reading file: ${e}`),!1}}static async getCommitMessages(t=""){try{let e=t;e||(e=(await y.branchLocal()).current);let n="main",o="";if(!!process.env.GITHUB_ACTIONS){n=process.env.GITHUB_BASE_REF||"main";try{if(await y.fetch("origin",n),e!=="HEAD")try{await y.raw(["rev-parse","--verify",`origin/${e}`])}catch{await y.fetch("origin",e)}let i=e==="HEAD"?"HEAD":`origin/${e}`;o=`${(await y.raw(["merge-base",`origin/${n}`,i])).trim()}..${i}`}catch(i){h.warn(`Error setting up commit range in CI: ${i}`);let a=e==="HEAD"?"HEAD":`origin/${e}`;o=`origin/${n}..${a}`}}else try{try{await y.raw(["rev-parse","--verify",`origin/${n}`])}catch{h.info(`Fetching ${n} from origin`),await y.fetch("origin",n)}if(e!=="HEAD")try{await y.raw(["rev-parse","--verify",e])}catch{await y.fetch("origin",e)}o=`${(await y.raw(["merge-base",`origin/${n}`,e])).trim()}..${e}`}catch(i){h.warn(`Error determining commits locally: ${i}`),o=`${e}~10..${e}`}return await r.getFormattedCommits(o)}catch(e){return h.error(`Error getting commit messages: ${e}`),[]}}static async getRepoOwnerAndName(){try{let t=await y.getRemotes(!0);if(t.length===0)return h.warn("No remotes found"),null;let e=t.find(o=>o.name==="origin")||t[0],n=e.refs.fetch||e.refs.push;return r.parseGitUrl(n)}catch(t){return h.error(`Error getting repo owner and name: ${t}`),null}}static async getCurrentBranchName(){try{return(await y.branchLocal()).current||null}catch(t){return h.error(`Error getting current branch name: ${t}`),null}}static parseGitUrl(t){let e;return t.includes("@")&&t.includes(":")&&(e=t.match(/@([^:]+):([^/]+)\/(.+?)(?:\.git)?$/),e)?{owner:e[2],repo:e[3]}:(e=t.match(/https?:\/\/(?:[^@]+@)?[^/]+\/([^/]+)\/(.+?)(?:\.git)?$/),e?{owner:e[1],repo:e[2]}:(h.warn(`Could not parse git URL: ${t}`),null))}static async getFormattedCommits(t){let n=(await y.raw(["log","--pretty=format:COMMIT_START%n%H%n%ad%n%an%n%s%n%b%nCOMMIT_END","--date=short",t])).split(`COMMIT_START
|
|
43
43
|
`).filter(s=>s.trim()!==""),o=[];for(let s of n){let i=s.split(`
|
|
44
|
-
`);if(i.length>=4){let a=i[0],
|
|
45
|
-
|
|
46
|
-
${
|
|
47
|
-
${t}`),
|
|
48
|
-
`,o=""),o=`${o}${s} `;return o.length>0&&(n+=o.trim()),n}function
|
|
49
|
-
`)}import*as
|
|
50
|
-
`;for(let n of
|
|
51
|
-
`,n.body?.trim()){let s=n.body.trim().split(/\n+/).map(i=>i.trim()).filter(i=>i.length>0);for(let i of s){let a=i;a=a.replace(/([^\s])(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)/g,"$1 $2"),a=a.replace(/(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)([^\s])/g,"$1 $2"),
|
|
52
|
-
`),n}async function
|
|
53
|
-
`).start();try{let o=await
|
|
44
|
+
`);if(i.length>=4){let a=i[0],l=i[1],m=i[2],u=i[3],c=i.slice(4).filter(b=>b!=="COMMIT_END"),d=c.length>0?c.join(""):"",f=a.substring(0,7),p=u.match(/^(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?:/),g=p?p[1]:"unknown";d.includes("BREAKING CHANGE")&&(g="breaking"),o.push({type:g,hash:f,date:l,subject:u,body:d,message:`${u}${d?`
|
|
45
|
+
|
|
46
|
+
${d}`:""}`,author_name:m})}}return o}static async addToGitignore(t,e=!0){await r.checkGitignore(t).then(async n=>{if(n)h.warn(`${t} already exists`);else try{await mn(".gitignore",`
|
|
47
|
+
${t}`),e&&h.success(`${t} added to .gitignore`)}catch(o){h.error(o)}})}static async removeFromGitCache(t){try{await y.rmKeepLocal(t),h.success(`${t.join(", ")} are removed from git cache`)}catch(e){h.error(e)}}static async createBranch(t){try{await y.checkoutLocalBranch(t),h.success(`Created and switched to ${t} branch`)}catch(e){h.error(e)}}static async commitStagedFiles(t){try{await y.add("."),await y.commit(t),h.success(`Committed with message: ${t}`)}catch(e){h.error(e)}}};import w from"chalk";var fn=60,gn=100;function q(r){switch(r){case"breaking":return w.bold.red(r);case"feat":return w.bold.green(r);case"fix":return w.bold.green(r);case"perf":return w.bold.green(r);case"docs":return w.bold.cyan(r);case"style":return w.bold.cyan(r);case"refactor":return w.bold.cyan(r);case"test":return w.bold.cyan(r);case"build":return w.bold.cyan(r);case"ci":return w.bold.cyan(r);case"chore":return w.bold.cyan(r);default:return w.bold.white(r)}}function St(r,t){if(!r)return"";if(r.length<=t)return r;let e=r.split(" "),n="",o="";for(let s of e)(o+s).length>t&&o.length>0&&(n+=`${o.trim()}
|
|
48
|
+
`,o=""),o=`${o}${s} `;return o.length>0&&(n+=o.trim()),n}function Dt(r){for(let t of r){console.log("\u2500".repeat(60));let e=St(t.subject,fn),n=St(t.body,gn);console.log(w.bold(`${q(t.type)}`)),console.log(w.dim(`${t.hash} | ${t.date} | ${t.author_name}`)),console.log(w.bold(`${w.white(e)}`)),t.body&&console.log(w.dim(n))}console.log("\u2500".repeat(60)),console.log(`
|
|
49
|
+
`)}import*as V from"@actions/github";async function Ne(){try{let r=process.env.GITHUB_TOKEN;if(!r)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=V.getOctokit(r),{context:e}=V;if(!e.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[n,o]=process.env.GITHUB_REPOSITORY.split("/"),s=e.payload.pull_request.number,{data:i}=await t.rest.issues.listLabelsOnIssue({owner:n,repo:o,issue_number:s});return i.map(a=>a.name)}catch(r){throw r instanceof Error?new Error(`Failed to get existing labels: ${r.message}`):r}}async function Pt(r){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 e=V.getOctokit(t),{context:n}=V;if(!n.payload.pull_request)throw new Error("No pull request found in the GitHub context");let[o,s]=process.env.GITHUB_REPOSITORY.split("/"),i=n.payload.pull_request.number,a=`semantic-status: ${r}`,l=await Ne();if(l.includes(a))return;let m=l.filter(u=>u.startsWith("semantic-status:")&&u!==a);for(let u of m)await e.rest.issues.removeLabel({owner:o,repo:s,issue_number:i,name:u});await e.rest.issues.addLabels({owner:o,repo:s,issue_number:i,labels:[a]});return}catch(t){throw t instanceof Error?new Error(`Failed to apply label: ${t.message}`):t}}var hn=["feat","fix","breaking","perf"];function je(r,t=!0){let e=`### In this release
|
|
50
|
+
`;for(let n of r)if(e+=`- ${n.hash} ${n.subject}
|
|
51
|
+
`,n.body?.trim()){let s=n.body.trim().split(/\n+/).map(i=>i.trim()).filter(i=>i.length>0);for(let i of s){let a=i;a=a.replace(/([^\s])(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)/g,"$1 $2"),a=a.replace(/(AlaskaAirlines\/[a-zA-Z0-9-]+#\d+)([^\s])/g,"$1 $2"),e+=` - ${a}`}}return r.length===0?"":(t&&console.log(xt.green(`\u2713 Generating release notes for ${r.length} commits`)),e)}function _e(r,t=!0){let e=r.filter(o=>hn.includes(o.type)),n;return t?n=e.length>0?e:r:n=e,n.length===0&&console.log(`No commits found to include in release notes.
|
|
52
|
+
`),n}async function Nt(r=!1,t=!1,e=!1){let n=Ot(`Checking commits...
|
|
53
|
+
`).start();try{let o=await S.getCommitMessages();if(e){n.succeed(`Total commits analyzed: ${o.length}`);let s=_e(o);console.log(je(s));return}if(r&&Dt(o),n.succeed(`Total commits analyzed: ${o.length}`),o.length!==0){let s=o.map(l=>l.type),a=Array.from(new Set(s)).map(l=>q(l)).join(", ");n.succeed(`Found commit types: ${a}`)}else n.info(`The list of commits is created by comparing the current branch
|
|
54
54
|
with the main branch. If you are on a new branch, please
|
|
55
|
-
make sure to commit some changes before running this command.`);t&&await
|
|
56
|
-
`,"utf8"),n.succeed(`Package.json updated to use ${
|
|
57
|
-
- ${
|
|
58
|
-
- `)}`:typeof
|
|
59
|
-
${Object.entries(
|
|
60
|
-
`)}`:`${t}: ${
|
|
61
|
-
`)}async function
|
|
62
|
-
${i.map(
|
|
55
|
+
make sure to commit some changes before running this command.`);t&&await yn(o,n)}catch(o){n.fail("Error getting commit messages"),console.error(o)}}async function yn(r,t){let e=["breaking","feat","fix","perf","docs","style","refactor","test","build","ci","chore"],n=r.map(i=>i.type).filter(i=>e.includes(i)),o=null,s=Number.POSITIVE_INFINITY;for(let i of n){let a=e.indexOf(i);a<s&&(s=a,o=i)}if(o){let i=Ot("Checking existing labels on pull request...").start();try{if((await Ne()).includes(`semantic-status: ${o}`)){i.info(`Label "semantic-status: ${q(o)}" already exists on the pull request.`);return}i.text="Applying label to pull request...",await Pt(o),i.succeed(`Label "semantic-status: ${q(o)}" applied to the pull request.`)}catch(a){let l=a instanceof Error?a.message:String(a);i.fail(l)}}else t.warn(xt.yellow("No semantic commit type found to apply as label."))}var _i=wn.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 r=>{await Nt(r.debug,r.setLabel,r.releaseNotes)});import jt from"node:fs";import{get as _t}from"node:https";import P from"chalk";import{program as bn}from"commander";import kn from"ora";var Hi=bn.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 r=>{await $n(r)}),$n=async r=>{let{namespace:t,prNumber:e}=r,n=kn("Updating package.json").start();try{let o="package.json",s=JSON.parse(jt.readFileSync(o,"utf8"));n.text="Checking npm registry for version information...";let i=`0.0.0-pr${e}`,a=s.name.split("/")[1],l=`${t}/${a}`,m=await En(i,l,n),u=`${i}.${m}`;s.name=l,s.version=u,n.text="Writing updated package.json...",jt.writeFileSync(o,`${JSON.stringify(s,null,2)}
|
|
56
|
+
`,"utf8"),n.succeed(`Package.json updated to use ${P.green(u)} and ${P.green(l)}`),process.exit(0)}catch(o){n.fail(`Failed to update package.json: ${o}`),process.exit(1)}},En=(r,t,e)=>new Promise(n=>{try{let a=function(l){if(l.statusCode!==200){e.info(`Package not found. Status code: ${P.red(l.statusCode)}, defaulting to version 0`),n(0);return}e.text="Processing version information...";let m="";l.on("data",u=>{m+=u}),l.on("end",()=>{try{let u=JSON.parse(m),c=u.versions?Object.keys(u.versions):[];e.text="Calculating next version number...";let d=-1,f=new RegExp(`^${r}\\.(\\d+)$`);for(let p of c){let g=p.match(f);if(g){let b=Number.parseInt(g[1],10);d=Math.max(d,b)}}d>=0?e.info(`Found existing version ${P.green(`${r}.${d}`)}. Incrementing to ${P.green(`${r}.${d+1}`)}`):e.info(`No existing version found for ${P.green(r)}. Starting with ${P.green(`${r}.0`)}`),n(d+1)}catch(u){e.warn(`Failed to parse NPM registry response: ${u instanceof Error?u.message:"Unknown error"}, defaulting to version 0`),n(0)}})};var o=a;let s=`https://registry.npmjs.org/${t}`,i=_t(s,{headers:{Accept:"application/json"}},l=>{if((l.statusCode===301||l.statusCode===302)&&l.headers.location){e.info(`Following redirect to ${l.headers.location}...`);try{_t(l.headers.location,{headers:{Accept:"application/json"}},a).on("error",m=>{e.warn(`Error following redirect: ${m.message}, defaulting to version 0`),n(0)}).end()}catch(m){e.warn(`Redirect request failed: ${m instanceof Error?m.message:"Unknown error"}, defaulting to version 0`),n(0)}return}a(l)});i.on("error",l=>{e.warn(`Request error: ${l.message}, defaulting to version 0`),n(0)}),i.end()}catch{e.warn("Error checking version in npm registry, defaulting to version 0"),n(0)}});import Fe from"node:path";import{fileURLToPath as An}from"node:url";import{program as vn}from"commander";import Tn from"open";var Cn=An(import.meta.url),In=Fe.resolve(Fe.dirname(Cn),".."),Yi=vn.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 r=>{let e=`npx wtr --config "${Fe.join(In,"dist","configs","web-test-runner.config.mjs")}"`,n=`${process.cwd()}/coverage/index.html`;if(r.coverageReport&&(e+=" --coverage"),r.watch&&(e+=" --watch"),r.files){let o=Array.isArray(r.files)?r.files.join(" "):r.files;e+=` --files "${o}"`}A(e),r.open&&await Tn(n)});import Le from"node:fs/promises";import Gt from"node:path";import{program as Nn}from"commander";import jn from"inquirer";import Ue from"ora";import Rn from"node:fs/promises";import Sn from"node:path";import Dn from"ora";var Pn={"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 xn(r){return Object.entries(r).map(([t,e])=>Array.isArray(e)?`${t}:
|
|
57
|
+
- ${e.join(`
|
|
58
|
+
- `)}`:typeof e=="object"&&e!==null?`${t}:
|
|
59
|
+
${Object.entries(e).map(([n,o])=>` ${n}: ${o}`).join(`
|
|
60
|
+
`)}`:`${t}: ${e}`).join(`
|
|
61
|
+
`)}async function Ft(r){let t=Dn("Writing multi-gitter configuration...").start(),e=xn(Pn),n=Sn.join(r,"multi-gitter_DEPENDENCY_TREE.yml");try{await Rn.writeFile(n,e,"utf8"),t.succeed(`Multi-gitter configuration written to ${n}`)}catch(o){t.fail("Error writing multi-gitter configuration:"),console.error(o)}}import Me from"node:fs";function Mt(r){let t={},e=[],n=[],o=[];for(let s in r)t[s]=r[s].dependsOn.length;for(let s in t)t[s]===0&&o.push(s);for(;o.length>0;){n=[];let s=o.length;for(let i=0;i<s;i++){let a=o.shift();n.push(a);for(let l of r[a].dependentPackages)t[l]--,t[l]===0&&o.push(l)}e.push(n)}if(e.flat().length!==Object.keys(r).length)throw new Error("Circular dependency detected!");return e}function On(r){return Me.readdirSync(r).filter(t=>t.endsWith(".json"))}async function Bt(r,t=[]){console.log(t);let e={},n=On(r);for(let o of n){if(o==="dependencyTree.json")continue;let s=Me.readFileSync(`${r}/${o}`,"utf-8"),i=JSON.parse(s),a=i.name,l=Object.keys(i.peerDependencies),m=Object.keys(i.devDependencies),u=Object.keys(i.dependencies);e[a]||(e[a]={dependsOn:[],dependentPackages:[]});let c=[...l,...m,...u];e[a].dependsOn=[...new Set(c)];for(let d of c)e[d]||(e[d]={dependsOn:[],dependentPackages:[]}),e[d].dependentPackages.includes(a)||e[d].dependentPackages.push(a)}if(t.length){let o=new Set;for(let[i,a]of Object.entries(e))a.dependsOn.some(l=>t.includes(l))&&o.add(i);for(let i of t)e[i]&&o.add(i);let s={};for(let i of o)s[i]={dependsOn:e[i].dependsOn.filter(a=>o.has(a)),dependentPackages:e[i].dependentPackages.filter(a=>o.has(a))};e=s}else console.log("No target dependencies provided - using all packages.");return Me.writeFileSync(`${r}/dependencyTree.json`,JSON.stringify(e,null,2)),e}var Be=be("run-migrations","config"),Ge=be("run-migrations","outputs");var Lt=["@aurodesignsystem/auro-accordion","@aurodesignsystem/auro-alert","@aurodesignsystem/auro-avatar","@aurodesignsystem/auro-background","@aurodesignsystem/auro-backtotop","@aurodesignsystem/auro-button","@aurodesignsystem/auro-badge","@aurodesignsystem/auro-banner","@aurodesignsystem/auro-card","@aurodesignsystem/auro-carousel","@aurodesignsystem/auro-datetime","@aurodesignsystem/auro-dialog","@aurodesignsystem/auro-drawer","@aurodesignsystem/auro-formkit","@aurodesignsystem/auro-flight","@aurodesignsystem/auro-flightline","@aurodesignsystem/auro-header","@aurodesignsystem/auro-hyperlink","@aurodesignsystem/auro-icon","@aurodesignsystem/auro-loader","@aurodesignsystem/auro-lockup","@aurodesignsystem/auro-nav","@aurodesignsystem/auro-pane","@aurodesignsystem/auro-popover","@aurodesignsystem/auro-sidenav","@aurodesignsystem/auro-skeleton","@aurodesignsystem/auro-slideshow","@aurodesignsystem/auro-table","@aurodesignsystem/auro-tabs","@aurodesignsystem/auro-toast"],pa=[...Lt,"@aurodesignsystem/auro-library","@aurodesignsystem/WebCoreStyleSheets","@aurodesignsystem/AuroDesignTokens","@aurodesignsystem/auro-cli","@alaskaairux/icons"];async function _n(r){try{await Le.mkdir(Ge,{recursive:!0}),await Le.mkdir(Be,{recursive:!0})}catch(o){console.error("Failed to create output or config directories:",o),process.exit(1)}let t=Ue("Creating dependency tree...").start();t.text="Creating multi-gitter dependency tree configuration...",await Ft(Be),t.text="Scraping dependencies from Auro packages...";let n=`multi-gitter run "node ${ke("static","getAuroDeps.js")}" --config ${Gt.join(Be,"multi-gitter_DEPENDENCY_TREE.yml")}`;try{await A(n)}catch(o){t.fail("Failed to generate dependency tree:"),console.error(o),process.exit(1)}return t.text="Generating dependency tree JSON file using packages...",await Bt(Ge,r),t.succeed("Dependency tree generated successfully."),Gt.join(Ge,"dependencyTree.json")}var Fn=async r=>{let t=Ue("Loading dependency tree...").start(),e=JSON.parse(await Le.readFile(r,"utf-8"));t.text="Processing dependency tree...";let n=Mt(e);return t.succeed("Dependency batches created successfully."),n},fa=Nn.command("agent").action(async r=>{let t=await jn.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:e=>e.agentAction==="run-migration",validate:e=>e.trim()!==""||"Migration id cannot be empty."},{type:"confirm",name:"useExisting",message:"Would you like to specify starting packages?",default:!0,transformer:e=>e?"Yes = Packages related to selections":"No = All packages",when:e=>e.agentAction==="run-migration"},{type:"checkbox",name:"startWithComponents",message:"Enter the components to start with (comma-separated, blank for all):",choices:Lt.map(e=>({name:e.replace("@aurodesignsystem/",""),value:e})),when:e=>e.agentAction==="run-migration"&&e.useExisting}]);switch(t.agentAction){case"run-migration":{let e=Ue("Running migration...").start(),n=await _n(t.startWithComponents);e.text="Getting dependency batches from tree...";let s=(await Fn(n)).map((i,a)=>`Batch ${a+1}
|
|
62
|
+
${i.map(l=>` - ${l.replace("@aurodesignsystem","AlaskaAirlines").replace("@alaskaairux/icons","AlaskaAirlines/Icons")}`).join(`
|
|
63
63
|
`)}`).join(`
|
|
64
64
|
|
|
65
|
-
`);console.log(s),
|
|
66
|
-
`,"utf-8")}catch(a){let c=a instanceof Error?a.message:String(a);t.fail(`Failed to write ${e.output}: ${c}`),nt.exit(1)}t.succeed(`Aggregated ${n.length}/${N.length} component manifests (${r.modules?.length??0} modules) to ${e.output}`);for(let a of o)a.transient||Gn.info(`Skipped ${a.target}: ${a.reason}`);s.length>0&&(Gn.error(`${s.length} component(s) failed to fetch transiently; the aggregate may be incomplete. Re-run to retry.`),nt.exit(1))}var Wd=ua.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(pa);import{readFileSync as no}from"node:fs";import{dirname as sc,join as ic,resolve as oo}from"node:path";import mt from"node:process";import{program as ac}from"commander";import cc from"ora";import{mkdtempSync as da,rmSync as fa}from"node:fs";import{tmpdir as ga}from"node:os";import{join as ha}from"node:path";function ar(e){return e.replace(/(['"`])(?:\\.|(?!\1)[\s\S])*\1/gu," ")}function cr(e){let t={")":"(","]":"[","}":"{",">":"<"},r=[],n="";for(let o of ar(e)){if(o===">"&&n==="="){n=o;continue}if(o==="("||o==="["||o==="{"||o==="<")r.push(o);else if((o===")"||o==="]"||o==="}"||o===">")&&r.pop()!==t[o])return!1;n=o}return r.length===0}function ir(e){let t=e.type?.text;if(typeof t=="string"&&t!==""&&!cr(t)){let{type:r,...n}=e;return n}return e}function lr(e,t){let{fieldName:r,description:n}=e;if(typeof r!="string"||r===""||typeof n=="string"&&n!=="")return!1;if(!t.has(r))return!0;let o=t.get(r);return o==="private"||o==="protected"}function ya(e){let t=o=>typeof o.name=="string",r=e.members?.filter(t).map(ir),n=new Map((r??[]).map(o=>[o.name,o.privacy]));return{...e,...r&&{members:r},...e.attributes&&{attributes:e.attributes.filter(t).filter(o=>!lr(o,n)).map(ir)},...e.slots&&{slots:e.slots.filter(t)},...e.events&&{events:e.events.filter(t).map(ir)},...e.cssParts&&{cssParts:e.cssParts.filter(t)},...e.cssProperties&&{cssProperties:e.cssProperties.filter(t)}}}function ur(e,t){return t.get(e.tagName)??e.tagName}function Un(e){return new Map(e.map(t=>[t.declaration.name,t.importPath]))}function ue(e,t){return{schemaVersion:"1.0.0",modules:e.map(r=>{let n=ya({...r.declaration,tagName:t?ur(r,t):r.tagName});return{kind:"javascript-module",path:r.importPath,declarations:[n],exports:[{kind:"js",name:n.name,declaration:{name:n.name,module:r.importPath}}]}})}}function z(e){let t=da(ha(ga(),"auro-editors-"));try{return e(t)}finally{try{fa(t,{recursive:!0,force:!0,maxRetries:10,retryDelay:100})}catch{}}}function K(e){return e.endsWith(`
|
|
67
|
-
`)?e:`${e}
|
|
68
|
-
`}var ba=` /** Identifies the currently active descendant of a composite widget. */
|
|
69
|
-
"aria-activedescendant"?: string;
|
|
70
|
-
/** Whether assistive technologies present all, or only parts of, changed regions. */
|
|
71
|
-
"aria-atomic"?: boolean | "true" | "false";
|
|
72
|
-
/** Whether inputting text triggers display of one or more predictions. */
|
|
73
|
-
"aria-autocomplete"?: "none" | "inline" | "list" | "both";
|
|
74
|
-
/** Defines a string value that labels the current element (braille). */
|
|
75
|
-
"aria-braillelabel"?: string;
|
|
76
|
-
/** Defines a human-readable, author-localized abbreviated role description (braille). */
|
|
77
|
-
"aria-brailleroledescription"?: string;
|
|
78
|
-
/** Whether an element is being modified and assistive technologies may wait. */
|
|
79
|
-
"aria-busy"?: boolean | "true" | "false";
|
|
80
|
-
/** The current "checked" state of checkboxes, radio buttons, and other widgets. */
|
|
81
|
-
"aria-checked"?: boolean | "false" | "mixed" | "true";
|
|
82
|
-
/** Defines the total number of columns in a table, grid, or treegrid. */
|
|
83
|
-
"aria-colcount"?: number;
|
|
84
|
-
/** Defines an element's column index or position within a table, grid, or treegrid. */
|
|
85
|
-
"aria-colindex"?: number;
|
|
86
|
-
/** A human-readable text alternative of aria-colindex. */
|
|
87
|
-
"aria-colindextext"?: string;
|
|
88
|
-
/** Defines the number of columns spanned by a cell or gridcell. */
|
|
89
|
-
"aria-colspan"?: number;
|
|
90
|
-
/** Identifies the element(s) whose contents or presence are controlled by this element. */
|
|
91
|
-
"aria-controls"?: string;
|
|
92
|
-
/** The element that represents the current item within a container or set. */
|
|
93
|
-
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time";
|
|
94
|
-
/** Identifies the element(s) that describes the object. */
|
|
95
|
-
"aria-describedby"?: string;
|
|
96
|
-
/** Defines a string value that describes or annotates the current element. */
|
|
97
|
-
"aria-description"?: string;
|
|
98
|
-
/** Identifies the element that provides a detailed, extended description. */
|
|
99
|
-
"aria-details"?: string;
|
|
100
|
-
/** Whether the element is perceivable but disabled, so not editable or operable. */
|
|
101
|
-
"aria-disabled"?: boolean | "true" | "false";
|
|
102
|
-
/** What functions can be performed when a dragged object is released. */
|
|
103
|
-
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup";
|
|
104
|
-
/** Identifies the element that provides an error message for the object. */
|
|
105
|
-
"aria-errormessage"?: string;
|
|
106
|
-
/** Whether the element, or another grouping element it controls, is expanded. */
|
|
107
|
-
"aria-expanded"?: boolean | "true" | "false";
|
|
108
|
-
/** The next element(s) in an alternate reading order of content. */
|
|
109
|
-
"aria-flowto"?: string;
|
|
110
|
-
/** Whether an element is in a "grabbed" state in a drag-and-drop operation. */
|
|
111
|
-
"aria-grabbed"?: boolean | "true" | "false";
|
|
112
|
-
/** Indicates the availability and type of an interactive popup element. */
|
|
113
|
-
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog";
|
|
114
|
-
/** Whether the element is exposed to an accessibility API. */
|
|
115
|
-
"aria-hidden"?: boolean | "true" | "false";
|
|
116
|
-
/** Whether the entered value does not conform to the expected format. */
|
|
117
|
-
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling";
|
|
118
|
-
/** Keyboard shortcuts an author has implemented to activate or focus an element. */
|
|
119
|
-
"aria-keyshortcuts"?: string;
|
|
120
|
-
/** A string value that labels the current element. */
|
|
121
|
-
"aria-label"?: string;
|
|
122
|
-
/** Identifies the element(s) that labels the current element. */
|
|
123
|
-
"aria-labelledby"?: string;
|
|
124
|
-
/** Defines the hierarchical level of an element within a structure. */
|
|
125
|
-
"aria-level"?: number;
|
|
126
|
-
/** Indicates that an element will be updated, and how live updates are described. */
|
|
127
|
-
"aria-live"?: "off" | "assertive" | "polite";
|
|
128
|
-
/** Whether an element is modal when displayed. */
|
|
129
|
-
"aria-modal"?: boolean | "true" | "false";
|
|
130
|
-
/** Whether a text box accepts multiple lines of input or only a single line. */
|
|
131
|
-
"aria-multiline"?: boolean | "true" | "false";
|
|
132
|
-
/** Whether the user may select more than one item from the current selectable descendants. */
|
|
133
|
-
"aria-multiselectable"?: boolean | "true" | "false";
|
|
134
|
-
/** Whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */
|
|
135
|
-
"aria-orientation"?: "horizontal" | "vertical";
|
|
136
|
-
/** Identifies an element in order to define a visual, functional, or contextual relationship. */
|
|
137
|
-
"aria-owns"?: string;
|
|
138
|
-
/** A short hint intended to aid the user with data entry when the control has no value. */
|
|
139
|
-
"aria-placeholder"?: string;
|
|
140
|
-
/** The number or position of an item in the current set of listitems or treeitems. */
|
|
141
|
-
"aria-posinset"?: number;
|
|
142
|
-
/** The current "pressed" state of toggle buttons. */
|
|
143
|
-
"aria-pressed"?: boolean | "false" | "mixed" | "true";
|
|
144
|
-
/** Whether the element is not editable but is otherwise operable. */
|
|
145
|
-
"aria-readonly"?: boolean | "true" | "false";
|
|
146
|
-
/** What notifications the user agent triggers when the accessibility tree is modified. */
|
|
147
|
-
"aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals";
|
|
148
|
-
/** Whether user input is required on the element before a form may be submitted. */
|
|
149
|
-
"aria-required"?: boolean | "true" | "false";
|
|
150
|
-
/** A human-readable, author-localized description for the role of an element. */
|
|
151
|
-
"aria-roledescription"?: string;
|
|
152
|
-
/** Defines the total number of rows in a table, grid, or treegrid. */
|
|
153
|
-
"aria-rowcount"?: number;
|
|
154
|
-
/** Defines an element's row index or position within a table, grid, or treegrid. */
|
|
155
|
-
"aria-rowindex"?: number;
|
|
156
|
-
/** A human-readable text alternative of aria-rowindex. */
|
|
157
|
-
"aria-rowindextext"?: string;
|
|
158
|
-
/** Defines the number of rows spanned by a cell or gridcell. */
|
|
159
|
-
"aria-rowspan"?: number;
|
|
160
|
-
/** The current "selected" state of various widgets. */
|
|
161
|
-
"aria-selected"?: boolean | "true" | "false";
|
|
162
|
-
/** Defines the number of items in the current set of listitems or treeitems. */
|
|
163
|
-
"aria-setsize"?: number;
|
|
164
|
-
/** Indicates if items in a table or grid are sorted in ascending or descending order. */
|
|
165
|
-
"aria-sort"?: "none" | "ascending" | "descending" | "other";
|
|
166
|
-
/** Defines the maximum allowed value for a range widget. */
|
|
167
|
-
"aria-valuemax"?: number;
|
|
168
|
-
/** Defines the minimum allowed value for a range widget. */
|
|
169
|
-
"aria-valuemin"?: number;
|
|
170
|
-
/** Defines the current value for a range widget. */
|
|
171
|
-
"aria-valuenow"?: number;
|
|
172
|
-
/** Defines the human-readable text alternative of aria-valuenow. */
|
|
173
|
-
"aria-valuetext"?: string;
|
|
174
|
-
/** Custom data-* attributes for the element. */
|
|
175
|
-
[key: \`data-\${string}\`]: string | number | boolean | null | undefined;
|
|
176
|
-
`,Bn=/(type BaseProps(?:<[^>]*>)? = \{\n)/,wa=` /** Defines the element's semantic role for accessibility APIs. */
|
|
177
|
-
role?: string;
|
|
178
|
-
/** The position of the element in the sequential keyboard navigation order. */
|
|
179
|
-
tabindex?: number;
|
|
180
|
-
`;function ot(e,{svelteGlobals:t}){if(!Bn.test(e))throw new Error("the JSX/Svelte generator no longer emits a recognizable `type BaseProps = {` block; the global-attribute injection in manifest.ts must be updated to match.");let r=`${t?wa:""}${ba}`;return e.replace(Bn,`$1${r}`)}function mr(e){let t=[];for(let r of e)r.source==="local"&&r.manifest&&r.version&&t.push({pkg:r.target,version:r.version,manifest:r.manifest});return t}async function Hn(e=N){let t=await Promise.all(e.map(r=>M(r,{allowNetwork:!1})));return mr(t)}function pr(e){return(e.modules??[]).flatMap(t=>t.declarations??[]).filter(t=>t.customElement&&t.tagName)}function dr(e){let t=[],r=new Map,n=new Set;for(let{pkg:s,version:i,manifest:a}of e){let c=pr(a),l=c.length>1;for(let m of c){let u=m.tagName,p=r.get(u);p?p.includes(s)||p.push(s):r.set(u,[s]),!n.has(u)&&(n.add(u),t.push({pkg:s,version:i,tagName:u,declaration:m,importPath:l?`${s}/${u}`:s,isMonorepo:l}))}}let o=[];for(let[s,i]of r)i.length>1&&o.push({tagName:s,packages:i});return{components:t,duplicates:o}}async function Wn(e){let t=await Hn(e);return dr(t)}var va=new Set(["variant","shape","size","type","appearance"]),Ea=new Set(["string","String","any"]),ka=new Map([["array","use `unknown[]`, `T[]`, or `Array<T>`"],["function","use `Function` or an explicit call signature `(\u2026) => \u2026`"]]),Sa=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>"]]),xa=new Set(["object","Object"]),Ca=[...ka].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*:)`,"u")})),Ta=[...Sa].map(([e,t])=>({token:e,fix:t,re:new RegExp(`\\b${e}\\b(?!\\s*[<:])`,"u")}));function Vn(e,t){return e===t?`\`type.text\` is \`${t}\``:`\`type.text\` (${JSON.stringify(e)}) uses \`${t}\``}var $a=[/^[\s>*_~([-]*@?deprecated\b/iu,/[([]\s*deprecated\b/iu,/\*\*\s*deprecated\b/iu,/@deprecated\b/iu];function qn(...e){return e.some(t=>typeof t=="string"&&$a.some(r=>r.test(t.trim())))}function Yn(e){return e===!0||Me(e)}function Jn(e,t,r,n){!Yn(n.deprecated)&&qn(n.description,n.summary)&&e.push({rule:"deprecated-prose-unflagged",severity:"warn",element:t,path:r,message:"described as deprecated but missing the `deprecated` field \u2014 add an `@deprecated` JSDoc tag so the generated JSX/Svelte types surface it with a strikethrough. (VS Code HTML custom-data has no deprecation field, so vanilla-HTML editors won't show it.)"})}function zn(e,t,r,n,o){!Yn(o.deprecated)&&qn(o.description,o.summary)&&e.push({rule:"deprecated-prose-unsupported",severity:"warn",element:t,path:n,message:`this ${r} reads as deprecated in prose, but the analyzer (v0.11.0) does not emit a \`deprecated\` field for inline \`@${r}\` tags \u2014 editors cannot surface it. Track upstream or a mapping plugin; suppress this warning if the prose is intentional.`})}function st(e,t,r,n){n.deprecated===!0&&e.push({rule:"deprecated-no-detail",severity:"warn",element:t,path:r,message:"`deprecated` is set but carries no message \u2014 editors show a strikethrough with no migration target. Prefer `@deprecated <what to use instead>`."})}function Me(e){return typeof e=="string"&&e!==""}function me(e,t,r,n){n?.forEach((o,s)=>{typeof o.name!="string"&&e.push({rule:"name-required",severity:"error",element:t,path:`${r}[${s}].name`,message:`${r}[${s}] has no string \`name\` \u2014 community generators call \`.name.startsWith(\u2026)\` and throw mid-generation.`})})}function fr(e,t,r,n){let o=n.type?.text;typeof o=="string"&&o!==""&&!cr(o)&&e.push({rule:"type-parseable",severity:"error",element:t,path:`${r}.type.text`,message:`\`type.text\` has unbalanced delimiters: ${JSON.stringify(o)} \u2014 the generated \`.d.ts\` would not parse.`})}function gr(e,t,r,n){let o=n.type?.text;if(typeof o!="string")return;let s=o.trim();if(s==="")return;let i=ar(s);for(let{token:a,re:c,fix:l}of Ca)if(c.test(i)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${r}.type.text`,message:`${Vn(s,a)}, which is not a TypeScript type \u2014 ${l}. The generated \`.d.ts\` would not compile.`});return}for(let{token:a,re:c,fix:l}of Ta)if(c.test(i)){e.push({rule:"type-not-typescript",severity:"error",element:t,path:`${r}.type.text`,message:`${Vn(s,a)}, a generic that requires a type argument \u2014 write \`${l}\`. The generated \`.d.ts\` would not compile.`});return}xa.has(s)&&e.push({rule:"type-imprecise",severity:"warn",element:t,path:`${r}.type.text`,message:`\`type.text\` is \`${s}\` \u2014 a valid type, but it exposes no properties so nothing completes. Prefer an explicit shape (e.g. \`{ id: string }\`).`})}function Aa(e,t){let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n--)r++;return r%2===1}function Ra(e){let t=[],r=0,n=null,o=0;for(let s=0;s<e.length;s++){let i=e[s];n!==null?i===n&&!Aa(e,s)&&(n=null):i==='"'||i==="'"||i==="`"?n=i:i==="("||i==="["||i==="{"||i==="<"?r++:i===")"||i==="]"||i==="}"?r--:i===">"?s>0&&e[s-1]!=="="&&r--:i==="|"&&r===0&&(t.push(e.slice(o,s).trim()),o=s+1)}return t.push(e.slice(o).trim()),t.filter(s=>s!=="")}function Pa(e){return/^(['"`]).*\1$/u.test(e)}function Ia(e,t,r,n){let o=n.type?.text?.trim();if(typeof o!="string"||!o.includes("|"))return;let s=Ra(o),i=s.some(Pa),a=s.some(c=>c==="string"||c==="String");i&&a&&e.push({rule:"union-widened-by-string",severity:"warn",element:t,path:`${r}.type.text`,message:`\`type.text\` (${JSON.stringify(o)}) unions string literals with a bare \`string\`, which widens the whole type back to \`string\` \u2014 drop the \`string\` member so the literals validate and complete.`})}function Kn(e){return typeof e!="string"||e.trim()===""}function hr(e,t,r,n,o){Kn(o.description)&&Kn(o.summary)&&e.push({rule:"missing-description",severity:"warn",element:t,...n===void 0?{}:{path:n},message:`${r} has no description or summary \u2014 editors show no hover documentation for it. Add a JSDoc description.`})}function Da(e,t){let r=Me(t.tagName)?t.tagName:"<unknown>";typeof t.name!="string"&&e.push({rule:"name-required",severity:"error",element:r,path:"name",message:"registered element has no string `name` \u2014 its generated import/export identity is undefined."}),hr(e,r,"this component",void 0,t);let n=t.members??[],o=t.attributes??[],s=t.events??[],i=t.slots??[];me(e,r,"members",n),me(e,r,"attributes",o),me(e,r,"slots",t.slots),me(e,r,"events",s),me(e,r,"cssParts",t.cssParts),me(e,r,"cssProperties",t.cssProperties),n.forEach((c,l)=>{fr(e,r,`members[${l}]`,c),gr(e,r,`members[${l}]`,c),Jn(e,r,`members[${l}]`,c),st(e,r,`members[${l}]`,c)}),o.forEach((c,l)=>{fr(e,r,`attributes[${l}]`,c),gr(e,r,`attributes[${l}]`,c),Ia(e,r,`attributes[${l}]`,c),hr(e,r,"attribute",`attributes[${l}]`,c),Jn(e,r,`attributes[${l}]`,c),st(e,r,`attributes[${l}]`,c)}),s.forEach((c,l)=>{fr(e,r,`events[${l}]`,c),gr(e,r,`events[${l}]`,c),hr(e,r,"event",`events[${l}]`,c),zn(e,r,"event",`events[${l}]`,c),st(e,r,`events[${l}]`,c)}),i.forEach((c,l)=>{zn(e,r,"slot",`slots[${l}]`,c),st(e,r,`slots[${l}]`,c)});let a=new Map(n.filter(c=>typeof c.name=="string").map(c=>[c.name,c.privacy]));o.forEach((c,l)=>{Me(c.name)&&/[A-Z]/u.test(c.name)&&e.push({rule:"attribute-name-not-lowercase",severity:"warn",element:r,path:`attributes[${l}].name`,message:`attribute \`${c.name}\` has uppercase letters \u2014 HTML lowercases attribute names, so it never binds as written. Use \`${c.name.toLowerCase()}\` (the camelCase property name belongs in \`fieldName\`).`}),Me(c.name)&&va.has(c.name)&&Ea.has(c.type?.text?.trim()??"")&&e.push({rule:"enumerated-union",severity:"warn",element:r,path:`attributes[${l}].type.text`,message:`\`${c.name}\` is typed as bare \`${JSON.stringify(c.type?.text??"")}\` \u2014 an enumerated attribute should carry a string-literal union (e.g. \`"primary" | "secondary"\`) so values validate and complete.`}),lr(c,a)&&e.push({rule:"private-reflection",severity:"warn",element:r,path:`attributes[${l}]`,message:`\`${c.name??"<unnamed>"}\` reflects a private/omitted member and has no description \u2014 it leaks into editor autocomplete as a settable attribute (add a description if it is genuinely public).`})})}function Xn(e){let t=[];Me(e.schemaVersion)||t.push({rule:"schema-version",severity:"warn",message:"manifest has no `schemaVersion` \u2014 declare the CEM schema version it targets."});for(let r of pr(e))Da(t,r);return t}import{execFileSync as qa}from"node:child_process";import{mkdirSync as br,writeFileSync as ut}from"node:fs";import{createRequire as Ya}from"node:module";import{dirname as Xa,join as pe}from"node:path";import Za from"node:process";import{generateJsxTypes as Ma}from"@wc-toolkit/jsx-types";var x=".vscode",oe="settings.json",Zn="auro.html-custom-data.json",$="html.customData",U=`./${x}/${Zn}`,se=`${x}/${Zn}`,Na="auro.code-snippets",it=`${x}/${Na}`,Oe="auro-types",yr="auro-jsx.d.ts",at="auro-svelte.d.ts",ie=`${Oe}/${yr}`,ae=`${Oe}/${at}`,A="include",H=Oe;function ct(e,t){let r=ue(e),n=Un(e),o=z(s=>Ma(r,{outdir:s,fileName:yr,tagFormatter:i=>t.get(i)??i,componentTypePath:i=>n.get(i)??i,useCemTypes:!0,includeDefaultDOMEvents:!0}));if(typeof o!="string")throw new Error("JSX type generation returned no output for the resolved components.");return{filename:ie,contents:K(ot(o,{svelteGlobals:!1}))}}import{readFileSync as Oa}from"node:fs";import{join as _a}from"node:path";import{generateSvelteTypes as ja}from"custom-element-svelte-integration";var Qn=`declare namespace svelteHTML {
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
182
|
-
interface IntrinsicElements extends CustomElements {}
|
|
183
|
-
}`,Fa=`declare global {
|
|
184
|
-
namespace svelteHTML {
|
|
185
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
186
|
-
interface IntrinsicElements extends CustomElements {}
|
|
187
|
-
}
|
|
188
|
-
}`,La=`
|
|
189
|
-
// Mouse events
|
|
190
|
-
"on:click"?: (e: MouseEvent) => void;
|
|
191
|
-
"on:contextmenu"?: (e: MouseEvent) => void;
|
|
192
|
-
"on:dblclick"?: (e: MouseEvent) => void;
|
|
193
|
-
"on:mousedown"?: (e: MouseEvent) => void;
|
|
194
|
-
"on:mouseenter"?: (e: MouseEvent) => void;
|
|
195
|
-
"on:mouseleave"?: (e: MouseEvent) => void;
|
|
196
|
-
"on:mousemove"?: (e: MouseEvent) => void;
|
|
197
|
-
"on:mouseout"?: (e: MouseEvent) => void;
|
|
198
|
-
"on:mouseover"?: (e: MouseEvent) => void;
|
|
199
|
-
"on:mouseup"?: (e: MouseEvent) => void;
|
|
200
|
-
// Drag events
|
|
201
|
-
"on:drag"?: (e: DragEvent) => void;
|
|
202
|
-
"on:dragend"?: (e: DragEvent) => void;
|
|
203
|
-
"on:dragenter"?: (e: DragEvent) => void;
|
|
204
|
-
"on:dragexit"?: (e: DragEvent) => void;
|
|
205
|
-
"on:dragleave"?: (e: DragEvent) => void;
|
|
206
|
-
"on:dragover"?: (e: DragEvent) => void;
|
|
207
|
-
"on:dragstart"?: (e: DragEvent) => void;
|
|
208
|
-
"on:drop"?: (e: DragEvent) => void;
|
|
209
|
-
// Keyboard events
|
|
210
|
-
"on:keydown"?: (e: KeyboardEvent) => void;
|
|
211
|
-
"on:keyup"?: (e: KeyboardEvent) => void;
|
|
212
|
-
"on:keypress"?: (e: KeyboardEvent) => void;
|
|
213
|
-
// Focus events
|
|
214
|
-
"on:focus"?: (e: FocusEvent) => void;
|
|
215
|
-
"on:blur"?: (e: FocusEvent) => void;
|
|
216
|
-
// Form events
|
|
217
|
-
"on:change"?: (e: Event) => void;
|
|
218
|
-
"on:input"?: (e: Event) => void;
|
|
219
|
-
"on:submit"?: (e: Event) => void;
|
|
220
|
-
"on:reset"?: (e: Event) => void;
|
|
221
|
-
// Scroll / wheel events
|
|
222
|
-
"on:scroll"?: (e: UIEvent) => void;
|
|
223
|
-
"on:wheel"?: (e: WheelEvent) => void;
|
|
224
|
-
// Animation / transition events
|
|
225
|
-
"on:animationstart"?: (e: AnimationEvent) => void;
|
|
226
|
-
"on:animationend"?: (e: AnimationEvent) => void;
|
|
227
|
-
"on:animationiteration"?: (e: AnimationEvent) => void;
|
|
228
|
-
"on:transitionend"?: (e: TransitionEvent) => void;
|
|
229
|
-
// Resource events
|
|
230
|
-
"on:load"?: (e: Event) => void;
|
|
231
|
-
"on:error"?: (e: Event) => void;
|
|
232
|
-
// Clipboard events
|
|
233
|
-
"on:copy"?: (e: ClipboardEvent) => void;
|
|
234
|
-
"on:cut"?: (e: ClipboardEvent) => void;
|
|
235
|
-
"on:paste"?: (e: ClipboardEvent) => void;
|
|
236
|
-
`,Ga=/^([ \t]*)"on:([^"]+)"(\?:.*=> void;)$/gmu;function Ba(e){return e.replace(Ga,(t,r,n,o)=>`${r}"on:${n}"${o}
|
|
237
|
-
${r}"on${n}"${o}`)}var Ua=/^(\s*"[^"]+": Partial<)(\w+)Props & BaseProps & BaseEvents(>;)$/gm;function Ha(e){let t=!1,r=e.replace(Ua,(n,o,s,i)=>(t=!0,`${o}Omit<${s}Props, keyof BaseProps> & BaseProps & Omit<BaseEvents, keyof ${s}Props>${i}`));if(!t)throw new Error("custom-element-svelte-integration no longer emits the expected `Partial<<Name>Props & BaseProps & BaseEvents>` element mapping; the base-member collision rewrite in svelteTypes.ts must be updated to match the new output.");return r}var Wa=/^type (\w+)Props = \{\n([\s\S]*?)\n\};$/gm,Va=/\/\*\* /g;function Ja(e,t){return e.replace(Wa,(r,n,o)=>{let s=t.get(n);if(s===void 0)return r;let i=o.replace(Va,`/** \u3010${s}\u3011 `);return`type ${n}Props = {
|
|
238
|
-
${i}
|
|
239
|
-
};`})}function za(e,t){return new Map(e.map(r=>{let n=r.tagName,o=t.get(n)??n,s=o===n?r.declaration.name:o;return[r.declaration.name,s]}))}function Ka(e){if(!e.includes(Qn))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(Qn,Fa)}function lt(e,t){let r=ue(e,t),n=za(e,t),o=z(s=>(ja(r,{outdir:s,fileName:at,hideLogs:!0,globalEvents:La}),Oa(_a(s,at),"utf-8")));return{filename:ae,contents:K(Ka(Ha(ot(Ba(Ja(o,n)),{svelteGlobals:!0}))))}}var Qa=Ya(import.meta.url),ec=Qa.resolve("typescript/bin/tsc"),tc=`declare namespace JSX {
|
|
240
|
-
type Element = unknown;
|
|
241
|
-
interface CSSProperties {}
|
|
242
|
-
}
|
|
243
|
-
`;function rc(e){return`${e.replace(/[^a-zA-Z0-9]+/gu,"_")}.d.ts`}function nc(e){let t=new Map,r=/^[ \t]*import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/gmu;for(let n of e.matchAll(r)){let o=n[1].split(",").map(i=>i.trim().split(/\s+as\s+/u)[0].trim()).filter(Boolean);if(o.length===0)continue;let s=t.get(n[2])??new Set;for(let i of o)s.add(i);t.set(n[2],s)}return t}function eo(e,t,r){ut(pe(e,"tsconfig.json"),JSON.stringify({compilerOptions:{noEmit:!0,skipLibCheck:!1,strict:!1,strictFunctionTypes:!0,target:"ES2020",module:"ESNext",moduleResolution:"bundler",...r&&{baseUrl:".",paths:r},lib:["ES2020","DOM"],types:[]},include:t},null,2),"utf-8")}function oc(e,t){let r=pe(e,t.filename);br(Xa(r),{recursive:!0}),ut(r,t.contents,"utf-8")}function to(e,t,r){return z(n=>{oc(n,t),r(n);try{return qa(Za.execPath,[ec,"-p","tsconfig.json"],{cwd:n,stdio:"pipe"}),null}catch(o){let s=o,i=`${s.stdout?.toString()??""}${s.stderr?.toString()??""}`;return{rule:"generation-smoke",severity:"error",element:e,message:`the generated ${e} \`.d.ts\` does not type-check \u2014 this CEM breaks the editor tooling:
|
|
244
|
-
${i.trim()}`}}})}function ro(e){if(e.length===0)return[];let t=new Map(e.map(n=>[n.tagName,n.tagName])),r=[];try{let n=ct(e,t),o=nc(n.contents),s=to("JSX",n,i=>{br(pe(i,"stubs"),{recursive:!0});let a={},c=[n.filename];for(let[l,m]of o){let u=rc(l);ut(pe(i,"stubs",u),`${[...m].map(p=>`export declare class ${p} extends HTMLElement {}`).join(`
|
|
245
|
-
`)}
|
|
246
|
-
`,"utf-8"),a[l]=[`./stubs/${u}`],c.push(`stubs/${u}`)}eo(i,c,a)});s&&r.push(s)}catch(n){r.push({rule:"generation-build",severity:"error",element:"JSX",message:`JSX type generation threw for this CEM: ${n.message}`})}try{let n=lt(e,t),o=to("Svelte",n,s=>{br(pe(s,"stubs"),{recursive:!0}),ut(pe(s,"stubs","jsx-shim.d.ts"),tc,"utf-8"),eo(s,[n.filename,"stubs/jsx-shim.d.ts"])});o&&r.push(o)}catch(n){r.push({rule:"generation-build",severity:"error",element:"Svelte",message:`Svelte type generation threw for this CEM: ${n.message}`})}return r}function lc(e){try{let t=no(ic(sc(oo(e)),"package.json"),"utf-8"),r=JSON.parse(t);return{pkg:typeof r.name=="string"?r.name:"cem-check-subject",version:typeof r.version=="string"?r.version:"0.0.0"}}catch{return{pkg:"cem-check-subject",version:"0.0.0"}}}function uc(e){let t=e.severity==="error"?"\u2716":"\u26A0",r=[e.element,e.path].filter(Boolean).join(" "),n=r?` ${r}`:"";return`${t} [${e.rule}]${n}: ${e.message}`}var mc="custom-elements.json";async function pc(e=mc,t={}){let r=t.json?null:cc(`Checking ${e} against the CEM contract...`).start(),n=h=>{r?r.fail(h):console.error(h),mt.exit(1)},o;try{o=JSON.parse(no(oo(e),"utf-8"))}catch(h){n(`Could not read or parse ${e}: ${h.message}`)}(typeof o!="object"||o===null||Array.isArray(o))&&n(`Could not read or parse ${e}: not a CEM object.`);let s=o,{pkg:i,version:a}=lc(e),c=[{pkg:i,version:a,manifest:s}],{components:l}=dr(c),m=[...Xn(s),...ro(l)],u=m.filter(h=>h.severity==="error"),p=m.filter(h=>h.severity==="warn"),d=u.length>0||!!t.strict&&p.length>0;if(t.json){mt.stdout.write(`${JSON.stringify(m,null,2)}
|
|
247
|
-
`),d&&mt.exit(1);return}let f=`${u.length} error${u.length===1?"":"s"}, ${p.length} warning${p.length===1?"":"s"}`;d?r?.fail(`CEM contract failed \u2014 ${f}.`):p.length>0?r?.warn(`CEM contract passed with warnings \u2014 ${f}.`):r?.succeed("CEM contract clean \u2014 no violations.");for(let h of[...u,...p])console.error(uc(h));d&&mt.exit(1)}var Nf=ac.command("cem-check [path]").description("Validate a custom-elements.json against the CEM contract (structural + parseability rules and an end-to-end generation smoke). Defaults to ./custom-elements.json.").option("--json","Output the findings as a JSON array on stdout",!1).option("--strict","Treat warnings as errors (any finding fails)",!1).action(pc);import vc from"node:fs/promises";import Ec from"node:path";import{program as kc}from"commander";import xr from"ora";var dc='# 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',fc=`| Element Tag | Package | Description |
|
|
248
|
-
|---|---|---|`,wr=[{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 vr(e){return e.map(t=>`| \`<${t.tag}>\` | \`${t.pkg}\` | ${t.description.replace(/\|/gu,"\\|")} |`).join(`
|
|
249
|
-
`)}var gc=vr(wr),hc=`## Common Patterns
|
|
250
|
-
|
|
251
|
-
### Button (default, secondary, tertiary)
|
|
252
|
-
\`\`\`html
|
|
253
|
-
<auro-button>Primary</auro-button>
|
|
254
|
-
<auro-button variant="secondary">Secondary</auro-button>
|
|
255
|
-
<auro-button variant="tertiary">Tertiary</auro-button>
|
|
256
|
-
<auro-button loading>Saving...</auro-button>
|
|
257
|
-
\`\`\`
|
|
258
|
-
|
|
259
|
-
### Alert
|
|
260
|
-
\`\`\`html
|
|
261
|
-
<auro-alert type="success">Changes saved.</auro-alert>
|
|
262
|
-
<auro-alert type="error">Something went wrong.</auro-alert>
|
|
263
|
-
<auro-alert type="warning">Please review before continuing.</auro-alert>
|
|
264
|
-
<auro-alert type="information">Your flight departs at 9am.</auro-alert>
|
|
265
|
-
\`\`\`
|
|
266
|
-
|
|
267
|
-
### Form inputs (auro-formkit)
|
|
268
|
-
auro-formkit has no root export \u2014 always import the specific sub-component.
|
|
269
|
-
The field label is a **slot**, not an attribute.
|
|
270
|
-
\`\`\`js
|
|
271
|
-
import "@aurodesignsystem/auro-formkit/auro-input";
|
|
272
|
-
import "@aurodesignsystem/auro-formkit/auro-select";
|
|
273
|
-
\`\`\`
|
|
274
|
-
\`\`\`html
|
|
275
|
-
<auro-input required>
|
|
276
|
-
<span slot="label">First name</span>
|
|
277
|
-
</auro-input>
|
|
278
|
-
<auro-select>
|
|
279
|
-
<span slot="label">Seat preference</span>
|
|
280
|
-
<auro-menu>
|
|
281
|
-
<auro-menuoption value="window">Window</auro-menuoption>
|
|
282
|
-
<auro-menuoption value="aisle">Aisle</auro-menuoption>
|
|
283
|
-
</auro-menu>
|
|
284
|
-
</auro-select>
|
|
285
|
-
\`\`\`
|
|
286
|
-
|
|
287
|
-
### Icon
|
|
288
|
-
Set \`category\` and \`name\`. Icon names are exact \u2014 check the icon library for the correct name.
|
|
289
|
-
\`\`\`html
|
|
290
|
-
<auro-icon category="interface" name="arrow-right"></auro-icon>
|
|
291
|
-
<auro-icon category="terminal" name="plane-side-fill"></auro-icon>
|
|
292
|
-
\`\`\`
|
|
293
|
-
|
|
294
|
-
### Hyperlink
|
|
295
|
-
\`\`\`html
|
|
296
|
-
<auro-hyperlink href="/flights">View flights</auro-hyperlink>
|
|
297
|
-
<auro-hyperlink href="https://example.com" target="_blank">External link</auro-hyperlink>
|
|
298
|
-
\`\`\`
|
|
299
|
-
|
|
300
|
-
### Dialog (modal)
|
|
301
|
-
\`\`\`js
|
|
302
|
-
document.querySelector('#confirmDialog').show();
|
|
303
|
-
\`\`\`
|
|
304
|
-
\`\`\`html
|
|
305
|
-
<auro-dialog id="confirmDialog">
|
|
306
|
-
<span slot="header">Confirm booking</span>
|
|
307
|
-
<div slot="content">Are you sure you want to book this flight?</div>
|
|
308
|
-
<div slot="footer">
|
|
309
|
-
<auro-button>Confirm</auro-button>
|
|
310
|
-
<auro-button variant="secondary">Cancel</auro-button>
|
|
311
|
-
</div>
|
|
312
|
-
</auro-dialog>
|
|
313
|
-
\`\`\`
|
|
314
|
-
|
|
315
|
-
## Accessibility Notes
|
|
316
|
-
- Use the \`ariaLabel\` slot on \`<auro-button>\` for icon-only buttons
|
|
317
|
-
- \`<auro-hyperlink>\` adds rel="noopener noreferrer" automatically for external links
|
|
318
|
-
- All \`auro-formkit\` components handle aria-invalid and error messaging built-in
|
|
319
|
-
- All components meet WCAG 2.1 AA
|
|
320
|
-
|
|
321
|
-
## Documentation
|
|
322
|
-
- Component docs: https://auro.alaskaair.com
|
|
323
|
-
- Component status: https://auro.alaskaair.com/component-status
|
|
324
|
-
- Design tokens: https://auro.alaskaair.com/getting-started/developers/token-usage
|
|
325
|
-
- Contributing: https://auro.alaskaair.com/getting-started/developers/contributing
|
|
326
|
-
- GitHub: https://github.com/AlaskaAirlines
|
|
327
|
-
`;function Er(e){return`${dc}${fc}
|
|
328
|
-
${e}
|
|
329
|
-
|
|
330
|
-
${hc}`}var Of=Er(gc);function v(e){return(e??"").replace(/\s+/gu," ").trim()}import C from"chalk";var F="@aurodesignsystem/auro-formkit",kr=["@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"],yc=new Set(kr);function q(e){return yc.has(e)}function Sr(e){return e.slice(18)}function de(e){return`${F}/${Sr(e)}`}var bc=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/u;function so(e){let t=bc.exec(e.trim());return t?{main:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]?t[4].split("."):[]}:null}function wc(e,t){let r=so(e),n=so(t);if(!r||!n)return null;for(let s=0;s<3;s+=1)if(r.main[s]!==n.main[s])return r.main[s]<n.main[s]?-1:1;if(r.pre.length===0&&n.pre.length===0)return 0;if(r.pre.length===0)return 1;if(n.pre.length===0)return-1;let o=Math.max(r.pre.length,n.pre.length);for(let s=0;s<o;s+=1){let i=r.pre[s],a=n.pre[s];if(i===void 0)return-1;if(a===void 0)return 1;let c=/^\d+$/u.test(i),l=/^\d+$/u.test(a);if(c&&l){let m=Number(i)-Number(a);if(m!==0)return m<0?-1:1}else{if(c!==l)return c?-1:1;if(i!==a)return i<a?-1:1}}return 0}async function fe(e){let t=[...e.entries()],r=await Promise.all(t.map(([o])=>jn(o))),n=[];return t.forEach(([o,s],i)=>{let a=r[i];if(!a)return;let c=wc(s,a);c!==null&&c<0&&n.push({pkg:o,installed:s,latest:a})}),n}var io=" \u21E2 auro-formkit";function ge(e){if(e.length===0)return"";let t=e.filter(p=>q(p.pkg)),r=e.filter(p=>!q(p.pkg)),n=`\u26A0 ${e.length} Auro component(s) are NOT on the latest release`,o=Math.max(...e.map(p=>p.pkg.length)),s=Math.max(...e.map(p=>p.installed.length)),i=p=>q(p.pkg),a=e.map(p=>{let d=` ${C.bold(p.pkg.padEnd(o))} ${C.dim(p.installed.padStart(s))} ${C.dim("\u2192")} ${C.green.bold(p.latest)}`;return i(p)?`${d}${C.yellow(io)}`:d}),c=[];if(r.length>0){let p=`npm install ${r.map(d=>`${d.pkg}@latest`).join(" ")}`;c.push("",C.dim(" Update to latest with:"),` ${C.cyan(p)}`)}if(t.length>0){c.push("",C.dim(" Migrate to auro-formkit (run `auro init`):"));for(let p of t)c.push(` ${C.dim(p.pkg)} ${C.dim("\u2192")} ${C.cyan(de(p.pkg))}`)}let l=[n.length+1,...e.map(p=>{let d=2+o+2+s+3+p.latest.length;return i(p)?d+io.length:d})],m=Math.min(Math.max(...l),78),u="\u2500".repeat(m);return["",C.yellow.bold(`\u250C${u}\u2510`),C.yellow.bold(n),C.yellow.bold(`\u2514${u}\u2518`),...a,...c,""].join(`
|
|
331
|
-
`)}async function Sc(e){let t=new Map;for(let i of wr)t.set(i.tag,{...i});let r=await Promise.all(N.map(i=>M(i,{allowNetwork:e}))),n=new Map(mr(r).map(i=>[i.pkg,i.version])),o=0,s=0;for(let i of r){if(!i.manifest)continue;o+=1;let a=(i.manifest.modules??[]).flatMap(c=>c.declarations??[]).filter(c=>c.customElement&&c.tagName);for(let c of a){let l=c.tagName,m=v(c.summary||c.description),u=t.get(l);t.set(l,{tag:l,pkg:i.target,description:m||u?.description||""}),m&&(s+=1)}}return{rows:vr([...t.values()]),resolved:o,enriched:s,local:n}}async function xc(e){let t=xr("Checking for newer component releases...").start(),r=await fe(e);if(r.length===0){t.succeed("All installed Auro components are on the latest release.");return}t.stop(),console.error(ge(r))}async function Cc(e){let t=!e.offline,r=xr(t?"Resolving component manifests...":"Reading installed component manifests...").start(),{rows:n,resolved:o,enriched:s,local:i}=await Sc(t),a=Er(n);if(t?s>0?r.succeed(i.size>0?`Enriched ${s} component description(s); ${i.size} package(s) resolved from local node_modules.`:`Enriched ${s} component description(s) from unpkg.`):o>0?r.succeed(`Resolved ${o} component manifest(s); none documented a description, using the built-in table.`):r.warn("No manifests available; using the built-in component table."):i.size>0?r.succeed(s>0?`Read ${i.size} installed component manifest(s) from local node_modules; enriched ${s} description(s).`:`Read ${i.size} installed component manifest(s) from local node_modules; none documented a description, using the built-in table.`):r.warn("No installed component manifests found; using the built-in component table."),e.output){let c=xr(`Writing context to ${e.output}...`).start();try{let l=Ec.resolve(process.cwd(),e.output);await vc.writeFile(l,a,"utf-8"),c.succeed(`Auro context written to ${e.output}`),console.error(`
|
|
332
|
-
Paste this file into your AI coding tool (Claude, Cursor, Copilot, etc.) to prime it on Auro components.`)}catch(l){let m=l instanceof Error?l.message:String(l);c.fail(`Failed to write context: ${m}`),process.exit(1)}}else process.stdout.write(a);t&&i.size>0&&await xc(i)}var Qf=kc.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(Cc);import Rl from"node:fs/promises";import Pl from"node:path";import Z from"node:process";import{program as Il}from"commander";import Q from"inquirer";import je from"ora";var R="auro.config.json";import{existsSync as ao,readFileSync as co,statSync as Tc}from"node:fs";import pt from"node:path";import{parse as lo}from"jsonc-parser";var uo=["vscode","jsx","svelte","cssSnippets"];function mo(e,t){try{return Tc(pt.join(e,t)).isDirectory()}catch{return!1}}function po(e){try{let t=co(pt.join(e,"package.json"),"utf-8"),r=lo(t,[],{allowTrailingComma:!0});return typeof r!="object"||r===null?new Set:new Set([...Object.keys(r.dependencies??{}),...Object.keys(r.devDependencies??{})])}catch{return new Set}}function $c(e){return mo(e,x)}function Ac(e){return mo(e,x)}function Rc(e){let t=pt.join(e,"tsconfig.json");if(ao(t))try{let r=co(t,"utf-8"),n=lo(r,[],{allowTrailingComma:!0});if(typeof n=="object"&&n!==null&&n.compilerOptions?.jsx!==void 0)return!0}catch{}return po(e).has("react")}function Pc(e){return po(e).has("svelte")?!0:["js","ts","mjs","cjs"].some(t=>ao(pt.join(e,`svelte.config.${t}`)))}function fo(e){return{vscode:$c(e),jsx:Rc(e),svelte:Pc(e),cssSnippets:Ac(e)}}import{existsSync as Cr,readFileSync as Ic}from"node:fs";import go from"node:path";import{parse as ho}from"jsonc-parser";function dt(e,t){return go.join(e,...t.split("/"))}function yo(e){try{return Ic(e,"utf-8")}catch{return null}}function Dc(e){let t=yo(dt(e,`${x}/${oe}`));if(t===null)return!1;let n=ho(t,[],{allowTrailingComma:!0})?.[$];return typeof n=="string"?n===U:Array.isArray(n)?n.includes(U):!1}function Nc(e){for(let t of["tsconfig.json","jsconfig.json"]){let r=yo(go.join(e,t));if(r===null)continue;let n=ho(r,[],{allowTrailingComma:!0}),o=n?.[A];return Array.isArray(o)?o.includes(H):!(o!==void 0||"files"in(n??{}))}return!0}function Tr(e,t){let r=[];return t.vscode&&(Cr(dt(e,se))||r.push(`${se} is missing \u2014 VS Code markup completions will not work.`),Dc(e)||r.push(`${x}/${oe} does not register "${U}" under "${$}".`)),t.svelte&&!Cr(dt(e,ae))&&r.push(`${ae} is missing.`),t.jsx&&!Cr(dt(e,ie))&&r.push(`${ie} is missing.`),(t.svelte||t.jsx)&&!Nc(e)&&r.push(`${H} is not on the TypeScript program (missing from "${A}").`),{inconsistencies:r,markupDisabled:!t.vscode}}import he from"node:fs/promises";import ht from"node:path";var Mc="css,scss,less";function Oc(e){return!/[,|}]/u.test(e)}function _c(e){return(e.declaration.cssParts??[]).map(t=>t.name).filter(t=>typeof t=="string"&&t!=="").filter(Oc)}function jc(e,t){let r=`\${1|${t.join(",")}|}`;return{scope:Mc,prefix:`${e}::part`,body:[`${e}::part(${r}) {`," $0","}"],description:`Style a shadow part of <${e}> (${t.join(", ")})`}}function bo(e,t){let r={};for(let n of e){let o=_c(n);if(o.length===0)continue;let s=ur(n,t);r[`Auro <${s}> ::part`]=jc(s,o)}return Object.keys(r).length===0?null:{filename:it,contents:K(JSON.stringify(r,null,2))}}import{getVsCodeHtmlCustomData as Fc}from"custom-element-vs-code-integration";function wo(e,t){let r=ue(e,t),n=z(o=>Fc(r,{outdir:o,htmlFileName:"auro.html-custom-data.json",hideLogs:!0}));return{filename:se,contents:K(n)}}import{applyEdits as vo,modify as Eo,parse as Lc,parseTree as Gc}from"jsonc-parser";var ko={tabSize:2,insertSpaces:!0};function Bc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ft(e,t){if(e.trim()==="")return{data:{}};let r=[],n=Lc(e,r,{allowTrailingComma:!0});return r.length>0?{warning:`${t} is not valid JSON \u2014 leaving it untouched.`}:Bc(n)?{data:n}:{warning:`${t} is not a JSON object \u2014 leaving it untouched.`}}function _e(e,t,r){let n=e.trim()===""?"{}":e,o=Eo(n,t,r,{formattingOptions:ko});return vo(n,o)}function Uc(e,t){let r=Gc(e);if(!r||r.type!=="object"||r.children?.length!==1)return null;let n=r.children[0];if(n.children?.[0]?.value!==t)return null;let o=n.offset+n.length;for(;o<e.length&&e[o]===",";)o++;return e.slice(0,n.offset)+e.slice(o)}function $r(e,t){if(t.length===1){let n=Uc(e,t[0]);if(n!==null)return n}let r=Eo(e,t,void 0,{formattingOptions:ko});return vo(e,r)}function So(e,t=U){let r=ft(e,".vscode/settings.json");if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let n=r.data[$],o;if(n===void 0)o=[t];else if(typeof n=="string"){if(n===t)return{contents:e,changed:!1};o=[n,t]}else if(Array.isArray(n)){if(n.includes(t))return{contents:e,changed:!1};o=[...n,t]}else return{contents:e,changed:!1,warning:`.vscode/settings.json "${$}" is not a string or array \u2014 leaving it untouched.`};return{contents:_e(e,[$],o),changed:!0}}function xo(e,t=H,r="tsconfig.json"){let n=ft(e,r);if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let{data:o}=n,s=o[A];return Array.isArray(s)?s.includes(t)?{contents:e,changed:!1}:{contents:_e(e,[A],[...s,t]),changed:!0}:s!==void 0?{contents:e,changed:!1,warning:`${r} "${A}" is not an array \u2014 leaving it untouched.`}:"files"in o?{contents:_e(e,[A],[t]),changed:!0}:{contents:e,changed:!1}}function Co(e,t=U){let r=ft(e,".vscode/settings.json");if("warning"in r)return{contents:e,changed:!1,warning:r.warning};let n=r.data[$];if(typeof n=="string")return n!==t?{contents:e,changed:!1}:{contents:$r(e,[$]),changed:!0};if(Array.isArray(n)){if(!n.includes(t))return{contents:e,changed:!1};let o=n.filter(i=>i!==t);return{contents:o.length===0?$r(e,[$]):_e(e,[$],o),changed:!0}}return{contents:e,changed:!1}}function To(e,t=H,r="tsconfig.json"){let n=ft(e,r);if("warning"in n)return{contents:e,changed:!1,warning:n.warning};let o=n.data[A];if(!Array.isArray(o)||!o.includes(t))return{contents:e,changed:!1};let s=o.filter(a=>a!==t);return{contents:s.length===0?$r(e,[A]):_e(e,[A],s),changed:!0}}function Ao(e,t){return ht.join(e,...t.split("/"))}async function gt(e,t){let r=Ao(e,t.filename);return await he.mkdir(ht.dirname(r),{recursive:!0}),await he.writeFile(r,t.contents,"utf-8"),t.filename}async function $o(e){try{return await he.readFile(e,"utf-8")}catch(t){if(t.code==="ENOENT")return"";throw t}}async function Ar(e,t,r,n){let o=[],s=[];if(n.vscode){o.push(await gt(e,wo(t,r)));let i=`${x}/${oe}`,a=Ao(e,i),c=So(await $o(a));c.warning?s.push(`${c.warning} Add "${U}" to "${$}" in ${i} by hand.`):c.changed&&(await he.mkdir(ht.dirname(a),{recursive:!0}),await he.writeFile(a,c.contents,"utf-8"),o.push(i))}if(n.jsx&&o.push(await gt(e,ct(t,r))),n.svelte&&o.push(await gt(e,lt(t,r))),n.cssSnippets){let i=bo(t,r);i&&o.push(await gt(e,i))}if(n.jsx||n.svelte)for(let i of["tsconfig.json","jsconfig.json"]){let a=ht.join(e,i),c=await $o(a);if(c==="")continue;let l=xo(c,H,i);l.warning?s.push(`${l.warning} Add "${H}" to "${A}" in ${i} by hand.`):l.changed&&(await he.writeFile(a,l.contents,"utf-8"),o.push(i));break}return{written:o,warnings:s}}var Y="AGENTS.md",ce="CLAUDE.md";var yt="Generated by `auro init`",Ro=`# Auro Design System \u2014 AI Assistant Grounding
|
|
333
|
-
|
|
334
|
-
<!-- ${yt}. Do not edit by hand \u2014 re-run \`auro init\` to
|
|
335
|
-
regenerate. Custom element tags are governed by \`auro.config.json\`. -->
|
|
336
|
-
|
|
337
|
-
Alaska Airlines open-source design system | https://auro.alaskaair.com
|
|
338
|
-
|
|
339
|
-
This file grounds AI assistants in the Auro components **installed in this
|
|
340
|
-
project**. It lists only installed packages, their exact registered tags, and the
|
|
341
|
-
full API for the installed version of each component. Treat it as authoritative
|
|
342
|
-
for this project.
|
|
343
|
-
|
|
344
|
-
## What is Auro?
|
|
345
|
-
|
|
346
|
-
Auro is Alaska Airlines' design system, built on Web Components (Custom Elements
|
|
347
|
-
v1) using the Lit library.
|
|
348
|
-
- npm scope: \`@aurodesignsystem/\` (current), \`@alaskaairux/\` (legacy)
|
|
349
|
-
- Framework-agnostic: works with React, Angular, Vue, Svelte, or plain HTML
|
|
350
|
-
- Each component is a separate npm package and registers a custom element tag
|
|
351
|
-
`,Po=`| Tag | Package | Version | Import |
|
|
352
|
-
|---|---|---|---|`,Io="## Regeneration\n\nThis file is generated by `auro init`. Re-run it after adding or removing an Auro\ndependency to update the component list and APIs. Custom element tags are governed\nby `auro.config.json` (committed by default) \u2014 change prefixes there, not in this\nfile, then re-run `auro init`.\n",bt=`@${Y}
|
|
353
|
-
`;var Do=`## Auro Coding Rules
|
|
354
|
-
|
|
355
|
-
These rules apply to every Auro component in this project. Use the exact
|
|
356
|
-
registered tags listed under **Installed Components** below: this project uses
|
|
357
|
-
custom registration, so a component's tag may differ from its default \`auro-*\`
|
|
358
|
-
name.
|
|
359
|
-
|
|
360
|
-
1. **Use Auro custom-element tags, never plain HTML equivalents.**
|
|
361
|
-
- \u2717 \`<button>\` \u2192 \u2713 the registered Auro button tag
|
|
362
|
-
- \u2717 \`<input>\` \u2192 \u2713 the registered Auro input tag (from \`auro-formkit\`)
|
|
363
|
-
|
|
364
|
-
Only use components listed under **Installed Components**. Do not invent tags
|
|
365
|
-
or reference components this project has not installed.
|
|
366
|
-
|
|
367
|
-
2. **Import and register each component before use.** Each component ships its
|
|
368
|
-
own import, and this project registers components under custom tags. The exact
|
|
369
|
-
\`import\` + \`register(...)\` snippet for each component is shown in its section
|
|
370
|
-
below. \`auro-formkit\` has no root export \u2014 always import the specific
|
|
371
|
-
sub-component via its subpath export (e.g.
|
|
372
|
-
\`@aurodesignsystem/auro-formkit/auro-input\`).
|
|
373
|
-
|
|
374
|
-
3. **Attributes in markup, camelCase properties in JS.** The same field is a
|
|
375
|
-
kebab-case attribute in HTML and a camelCase property in JavaScript.
|
|
376
|
-
\`\`\`html
|
|
377
|
-
<!-- attribute -->
|
|
378
|
-
<auro-button disabled>Save</auro-button>
|
|
379
|
-
\`\`\`
|
|
380
|
-
\`\`\`js
|
|
381
|
-
element.loading = true; // property
|
|
382
|
-
\`\`\`
|
|
383
|
-
|
|
384
|
-
4. **Put content in named slots, not \`innerHTML\`.** Each component's slot names
|
|
385
|
-
are listed in its API section below.
|
|
386
|
-
|
|
387
|
-
5. **Use design tokens for color, spacing, and type.** Install
|
|
388
|
-
\`@aurodesignsystem/design-tokens\` and use the \`--ds-basic-*\` /
|
|
389
|
-
\`--ds-advanced-*\` CSS custom properties rather than hard-coded values.
|
|
390
|
-
|
|
391
|
-
6. **Accessibility is built in \u2014 don't override it.** Auro components ship WCAG
|
|
392
|
-
2.1 AA behavior (focus management, ARIA, error messaging). Prefer the provided
|
|
393
|
-
slots and attributes over custom ARIA.
|
|
394
|
-
`;var No="@aurodesignsystem";function Oo(e){let t=e.trim();if(t.startsWith("@"))return t;let r=t.toLowerCase();return r.startsWith("auro-")?`${No}/${r}`:`${No}/auro-${r}`}function Hc(e){return e.replace(/-([a-z])/gu,(t,r)=>r.toUpperCase())}function Mo(e){return e?typeof e=="string"?` [deprecated: ${v(e)}]`:" [deprecated]":""}function ye(e){if(e.length===0)return" (none)";let t=Math.max(...e.map(([r])=>(r??"").length));return e.map(([r,n])=>` ${(r??"").padEnd(t)} ${n??""}`.trimEnd()).join(`
|
|
395
|
-
`)}function _o(e,t,r={}){let{installPkg:n=e,importSpecifier:o=e}=r,s=[];s.push(`${t.tagName} (${e})`);let i=t.summary||t.description;i&&s.push(v(i));let a=t.superclass?.name?`${t.name} extends ${t.superclass.name}`:t.name;return s.push(`Class: ${a}`),s.push(""),s.push("Install:"),s.push(` npm i ${n}`),s.push(` import "${o}";`),s.push(...Rr(t)),s.join(`
|
|
396
|
-
`)}function Rr(e){let t=[],r=e.attributes??[];t.push(""),t.push(`Attributes (${r.length}):`),t.push(ye(r.map(l=>{let m=l.type?.text?` {${v(l.type.text)}}`:"",u=l.default?` = ${v(l.default)}`:"";return[l.name,`${v(l.description)}${m}${u}${Mo(l.deprecated)}`.trim()]})));let n=new Set(r.flatMap(l=>l.fieldName?[l.fieldName]:[l.name,Hc(l.name)])),o=(e.members??[]).filter(l=>l.name&&(l.privacy===void 0||l.privacy==="public")&&!l.static&&!(l.kind==="field"&&n.has(l.name)));t.push(""),t.push(`Properties & Methods (${o.length}):`),t.push(ye(o.map(l=>{let m=l.kind==="method",u=m?`${l.name}()`:l.name,p=m?l.return?.type?.text:l.type?.text,d=p?` {${v(p)}}`:"",f=!m&&l.default?` = ${v(l.default)}`:"";return[u,`${v(l.description)}${d}${f}${Mo(l.deprecated)}`.trim()]})));let s=e.slots??[];t.push(""),t.push(`Slots (${s.length}):`),t.push(ye(s.map(l=>[l.name||"(default)",v(l.description)])));let i=e.events??[];t.push(""),t.push(`Events (${i.length}):`),t.push(ye(i.map(l=>{let m=l.type?.text?` {${v(l.type.text)}}`:"";return[l.name,`${v(l.description)}${m}`.trim()]})));let a=e.cssParts??[];a.length>0&&(t.push(""),t.push(`CSS Parts (${a.length}):`),t.push(ye(a.map(l=>[l.name,v(l.description)]))));let c=e.cssProperties??[];return c.length>0&&(t.push(""),t.push(`CSS Custom Properties (${c.length}):`),t.push(ye(c.map(l=>[l.name,v(l.description)])))),t}function jo(e,t){return t.get(e.tagName)??e.tagName}function Wc(e,t){let{pkg:r,importPath:n,declaration:o}=e,s=[`${t} (${r})`],i=o.summary||o.description;i&&s.push(v(i));let a=o.superclass?.name?`${o.name} extends ${o.superclass.name}`:o.name;return s.push(`Class: ${a}`),s.push(""),s.push("Install:"),s.push(` npm i ${r}`),s.push(` import "${n}";`),s.push(` ${o.name}.register('${t}');`),s.push(...Rr(o)),s.join(`
|
|
397
|
-
`)}function Vc(e,t=new Map){let r=e.map(i=>`| \`<${jo(i,t)}>\` | \`${i.pkg}\` | ${i.version} | \`${i.importPath}\` |`),n=e.map(i=>{let a=jo(i,t);return`### \`<${a}>\`
|
|
398
|
-
|
|
399
|
-
\`\`\`
|
|
400
|
-
${Wc(i,a)}
|
|
401
|
-
\`\`\``}),o=["## Installed Components","",Po,...r];n.length>0&&o.push("",n.join(`
|
|
402
|
-
|
|
403
|
-
`));let s=o.join(`
|
|
404
|
-
`);return`${[Ro.trimEnd(),Do.trimEnd(),s,Io.trimEnd()].join(`
|
|
405
|
-
|
|
406
|
-
`)}
|
|
407
|
-
`}function Jc(){return bt}function Fo(e,t=new Map){return[{filename:Y,contents:Vc(e,t)},{filename:ce,contents:Jc()}]}import{appendFileSync as zc,readFileSync as Bo}from"node:fs";import vt from"node:path";import{simpleGit as Kc}from"simple-git";var qc="# Added by auro init \u2014 keep generated grounding/IntelliSense files tracked";function Lo(e){return e.split(vt.sep).join("/")}async function wt(e,t){if(t.length===0)return[];try{return(await Kc({baseDir:e}).checkIgnore(t.map(Lo))).map(Lo)}catch{return[]}}function Yc(e){let t=vt.posix.dirname(e);return t==="."?"":t}function Xc(e){try{let t=Bo(vt.join(e,".gitignore"),"utf-8");return new Set(t.split(/\r?\n/).map(r=>r.trim()))}catch{return new Set}}function Go(e,t,r=!0){let n=vt.join(e,".gitignore"),o="";try{o=Bo(n,"utf-8")}catch{}let s=new Set(o.split(/\r?\n/).map(c=>c.trim())),i=r?t.filter(c=>!s.has(c.trim())):t;if(i.length===0)return;let a=o===""||o.endsWith(`
|
|
408
|
-
`)?"":`
|
|
409
|
-
`;try{zc(n,`${a}${i.join(`
|
|
410
|
-
`)}
|
|
411
|
-
`,"utf-8")}catch{}}async function Uo(e,t){if(t.length===0)return{fixed:[],unfixable:[]};Go(e,[qc,...t.map(o=>`!${o}`)]);let r=await wt(e,t);if(r.length>0){let o=Xc(e),s=[],i=new Set;for(let a of r){let c=Yc(a);(c===""||o.has(`${c}/*`))&&o.has(`!${a}`)||(c!==""&&!i.has(c)&&!o.has(`${c}/*`)&&(i.add(c),s.push(`!${c}/`,`${c}/*`)),s.push(`!${a}`))}s.length>0&&(Go(e,s,!1),r=await wt(e,t))}let n=new Set(r);return{fixed:t.filter(o=>!n.has(o)),unfixable:[...n]}}import{readFileSync as Yo,writeFileSync as qo}from"node:fs";import Tt from"node:path";import{globSync as ll}from"glob";import{readFileSync as Wo,writeFileSync as Zc}from"node:fs";import St from"node:path";import{globSync as Qc}from"glob";import T from"typescript";var kt="auro-",Ir="**/*.{js,jsx,ts,tsx,mjs,cjs,svelte}",Dr=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**"],L=class extends Error{constructor(t){super(t),this.name="RegistryError"}};function Vo(e=""){return{version:1,init:{prefix:{default:e,overrides:{}}}}}function el(e,t){let r=e;if(!r||typeof r!="object")throw new L(`${t}: not a JSON object.`);if(r.version!==1)throw new L(`${t}: unsupported config version ${String(r.version)} (expected ${1}). Upgrade the CLI or remove the file.`);let n=r.init?.prefix;if(!n||typeof n.default!="string"||typeof n.overrides!="object"||n.overrides===null)throw new L(`${t}: malformed init.prefix block.`);return r}function xt(e){let t=St.join(e,R),r;try{r=Wo(t,"utf-8")}catch(o){if(o.code==="ENOENT")return null;throw o}let n;try{n=JSON.parse(r)}catch{throw new L(`${R}: invalid JSON.`)}return el(n,R)}function Jo(e,t){let r=St.join(e,R);Zc(r,`${JSON.stringify(t,null,2)}
|
|
412
|
-
`,"utf-8")}function tl(e){switch(St.extname(e).toLowerCase()){case".tsx":return T.ScriptKind.TSX;case".jsx":return T.ScriptKind.JSX;case".ts":case".mts":case".cts":return T.ScriptKind.TS;default:return T.ScriptKind.JS}}function rl(e){return e&&(T.isStringLiteral(e)||T.isNoSubstitutionTemplateLiteral(e))?e.text:null}function Ho(e,t,r=tl(e)){let n=[],o=[],s=[],i;try{i=T.createSourceFile(e,t,T.ScriptTarget.ES2022,!0,r)}catch{return{matches:n,defaultRegistrations:o,warnings:[`${e}: could not be parsed; skipped.`]}}let a=c=>{if(T.isCallExpression(c)&&T.isPropertyAccessExpression(c.expression)&&c.expression.name.text==="register"){let l=c.expression.expression,m=T.isIdentifier(l)?l.text:void 0;if(c.arguments.length===0)m&&o.push(m);else{let u=rl(c.arguments[0]);u===null?s.push(`${e}: register() with a non-literal tag could not be resolved; skipped.`):n.push({className:m,tag:u})}}T.forEachChild(c,a)};return a(i),{matches:n,defaultRegistrations:o,warnings:s}}var Pr=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,nl=/\blang\s*=\s*["']?(?:ts|typescript)["']?/i;function ol(e){let t=[];Pr.lastIndex=0;let r=Pr.exec(e);for(;r!==null;){let[,n,o]=r;t.push({content:o,scriptKind:nl.test(n)?T.ScriptKind.TS:T.ScriptKind.JS}),r=Pr.exec(e)}return t}function zo(e){let t=Qc(Ir,{cwd:e,absolute:!0,nodir:!0,ignore:Dr}),r=[],n=[],o=[],s=i=>{r.push(...i.matches),n.push(...i.defaultRegistrations??[]),o.push(...i.warnings)};for(let i of t){let a;try{a=Wo(i,"utf-8")}catch{o.push(`${i}: could not be read; skipped.`);continue}if(St.extname(i).toLowerCase()===".svelte")for(let{content:c,scriptKind:l}of ol(a))s(Ho(i,c,l));else s(Ho(i,a))}return{matches:r,defaultRegistrations:n,warnings:o}}function Ko(e){return e.startsWith(kt)?e.slice(kt.length):e}function sl(e,t){let r=Ko(e);return t.endsWith(r)?t.slice(0,t.length-r.length):null}function il(e){let t=new Map;for(let o of e)!o||o===kt||t.set(o,(t.get(o)??0)+1);if(t.size===0)return{mixed:!1};let r,n=-1;for(let[o,s]of t)s>n&&(n=s,r=o);return{suggestion:r,mixed:t.size>1}}function al(e,t,r=[]){let n=new Map;for(let a of e)n.set(a.declaration.name,a.tagName);let o=new Map,s=[];for(let a of t){let c=a.className?n.get(a.className):void 0;if(!c){s.push(`Found register('${a.tag}')${a.className?` on ${a.className}`:""} but could not tie it to an installed Auro component; ignored.`);continue}o.set(c,a.tag)}let i=new Map;for(let a of r){let c=n.get(a);c&&i.set(c,a)}return{overrides:o,defaultRegistered:i,warnings:s}}function cl(e,t){return!e||e===kt?t:e+Ko(t)}function Ct(e,t={}){let{config:r,scan:n,prefix:o}=t,s=r?.init.prefix.overrides??{},i=al(e,n?.matches??[],n?.defaultRegistrations??[]),a=r?.init.prefix.default,c=o??a,l=new Map,m={...s},u=[],p=[...n?.warnings??[],...i.warnings],d=[],f=[];for(let S of e){let E=S.tagName,ee=s[E];if(ee!==void 0){l.set(E,ee);continue}let It=i.overrides.get(E);if(It!==void 0){l.set(E,It),m[E]=It;continue}if(c===void 0){u.push(E);continue}let we=cl(c,E);l.set(E,we),we===E?f.push(`${E}: no custom prefix \u2014 grounding it under its bare 'auro-*' tag. Pass a prefix to avoid registration collisions.`):i.defaultRegistered.has(E)||d.push(`${E}: grounded as '<${we}>' from the '${c}' prefix, but no register('${we}') was found in your source. If ${S.declaration.name} is registered under a different tag (e.g. the default '<${E}>' from a side-effect import), IntelliSense will not match your markup \u2014 call ${S.declaration.name}.register('${we}') so your app matches the generated tags.`)}for(let[S,E]of i.defaultRegistered){let ee=l.get(S);ee!==void 0&&ee!==S&&d.push(`${E}.register() uses the default '<${S}>' tag, but this project grounds it as '<${ee}>'. Update the register() call to '${ee}' so your app matches AGENTS.md.`)}let h=[...Object.entries(s),...i.overrides].map(([S,E])=>sl(S,E)),{suggestion:g,mixed:w}=il(h),O=u.length>0&&c===void 0;return{resolvedTags:l,config:{version:1,init:{prefix:{default:c??g??"",overrides:m}}},needingDefault:u,needsDefaultPrefix:O,suggestedDefault:g,mixedPrefixes:w,warnings:p,reconciliationWarnings:d,noPrefixWarnings:f}}var Nr="package.json";function ul(e){let t=e.match(/\n([ \t]+)\S/u);return t?t[1]:2}function Xo(e){let t;try{t=Yo(Tt.join(e,Nr),"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw r}try{return{pkgJson:JSON.parse(t),indent:ul(t)}}catch{throw new Error(`${Nr}: invalid JSON.`)}}function Zo(e){let t=Xo(e);if(!t)return[];let{pkgJson:r}=t,n=[],o=["dependencies","devDependencies"];for(let s of kr)for(let i of o){let a=r[i]?.[s];if(typeof a=="string"){n.push({pkg:s,version:a,field:i});break}}return n}function ml(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pl(e){return e.split(Tt.sep).join("/")}function dl(e,t){let r=e,n=0,o=[];for(let s of t){let i=ml(s),a=new RegExp(`(['"\`])${i}\\1`,"g");r=r.replace(a,(m,u)=>(n+=1,`${u}${de(s)}${u}`));let c=new RegExp(`(['"\`])(${i}/[^'"\`]*)\\1`,"g"),l=c.exec(r);for(;l!==null;)o.push(l[2]),l=c.exec(r)}return{next:r,rewrites:n,deep:o}}function Qo(e,t){let r=[...new Set(t.map(i=>i.pkg).filter(q))],n={packagesMigrated:[],formkit:"present",filesChanged:[],rewriteCount:0,deepImports:[]};if(r.length===0)return n;let o=Xo(e);if(o){let{pkgJson:i,indent:a}=o;for(let l of["dependencies","devDependencies"]){let m=i[l];if(m)for(let u of r)u in m&&(delete m[u],n.packagesMigrated.includes(u)||n.packagesMigrated.push(u))}!!i.dependencies?.[F]||!!i.devDependencies?.[F]?n.formkit="present":(i.dependencies??={},i.dependencies[F]="latest",n.formkit="added"),qo(Tt.join(e,Nr),`${JSON.stringify(i,null,a)}
|
|
413
|
-
`,"utf-8")}let s=ll(Ir,{cwd:e,absolute:!0,nodir:!0,ignore:Dr});for(let i of s){let a;try{a=Yo(i,"utf-8")}catch{continue}let{next:c,rewrites:l,deep:m}=dl(a,r),u=pl(Tt.relative(e,i));for(let p of m)n.deepImports.push({file:u,specifier:p});l>0&&c!==a&&(qo(i,c,"utf-8"),n.filesChanged.push(u),n.rewriteCount+=l)}return n}import{existsSync as es,readdirSync as fl,readFileSync as gl,rmdirSync as hl,rmSync as yl,writeFileSync as bl}from"node:fs";import wl from"node:path";import{parse as vl}from"jsonc-parser";function X(e,t){return wl.join(e,...t.split("/"))}function El(e){let t=vl(e,[],{allowTrailingComma:!0});return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length===0}function kl(e){return e.includes("//")||e.includes("/*")}function Mr(e){try{return gl(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}var Sl=[se,it,ie,ae];function xl(e,t){return e===null?null:t==="agents"?e.includes(yt)?"remove":`not recognized as an \`auro init\` file (missing the "${yt}" marker)`:e.trim()===bt.trim()?"remove":"contains content beyond the generated `@AGENTS.md` import"}function ts(e){let t=[],r=[],n=[];for(let[a,c]of[[Y,"agents"],[ce,"claude"]]){let l=xl(Mr(X(e,a)),c);l==="remove"?t.push(a):l!==null&&r.push({path:a,reason:l})}if(es(X(e,R)))try{xt(e)&&t.push(R)}catch(a){let c=a instanceof L?a.message:String(a);r.push({path:R,reason:c})}for(let a of Sl)es(X(e,a))&&t.push(a);let o=[],s=`${x}/${oe}`,i=Mr(X(e,s));if(i!==null){let a=Co(i);a.warning?n.push(a.warning):a.changed&&(El(a.contents)&&!kl(a.contents)?t.push(s):o.push({path:s,result:a}))}for(let a of["tsconfig.json","jsconfig.json"]){let c=Mr(X(e,a));if(c===null)continue;let l=To(c,void 0,a);l.warning?n.push(l.warning):l.changed&&o.push({path:a,result:l});break}return{filesToRemove:t,filesToSkip:r,unmerges:o,warnings:n,dirsToPrune:[Oe,x]}}function Cl(e){try{return fl(e).length===0}catch{return!1}}function rs(e,t){let r=[];for(let s of t.filesToRemove)yl(X(e,s),{force:!0}),r.push(s);let n=[];for(let{path:s,result:i}of t.unmerges)bl(X(e,s),i.contents,"utf-8"),n.push(s);let o=[];for(let s of t.dirsToPrune){let i=X(e,s);Cl(i)&&(hl(i),o.push(s))}return{removed:r,unmerged:n,prunedDirs:o,skipped:t.filesToSkip,warnings:t.warnings}}import ns from"chalk";var Tl=78,os=74,ss=" \u2022 ",$l=" ";function Al(e,t){let r=e.split(/\s+/u).filter(Boolean);if(r.length===0)return[""];let n=[],o=r[0];for(let s of r.slice(1))o.length+1+s.length<=t?o+=` ${s}`:(n.push(o),o=s);return n.push(o),n}function le(e,t,r="red"){if(t.length===0)return"";let n=ns[r].bold,o=[];t.forEach((c,l)=>{Al(c,os-ss.length).forEach((u,p)=>{let d=p===0?ss:$l;o.push(ns[r](d+u))}),l<t.length-1&&o.push("")});let s=e.length+(e.includes("\u26A0")?1:0),i=Math.min(Math.max(s,os),Tl),a="\u2500".repeat(i);return["",n(`\u250C${a}\u2510`),n(e),n(`\u2514${a}\u2518`),...o,""].join(`
|
|
414
|
-
`)}function be(e){return!Z.stdin.isTTY||!!Z.env.CI||!!e.nonInteractive||!!e.yes}async function Dl(e){if(e.suggestedDefault){let{accept:r}=await Q.prompt([{type:"confirm",name:"accept",message:e.mixedPrefixes?`Existing registrations use more than one prefix. Use the most common, '${e.suggestedDefault}', as the default for the remaining components?`:`Use the detected prefix '${e.suggestedDefault}' as the default for the remaining components?`,default:!0}]);if(r)return e.suggestedDefault}let{prefix:t}=await Q.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 Nl(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 Ml(e,t){let{customize:r}=await Q.prompt([{type:"confirm",name:"customize",message:"Define a custom tag name for any installed component? (you'll be prompted per component; Enter keeps the calculated name)",default:!1}]);if(!r)return{};let n={};for(let o of e){let s=o.tagName,i=t.get(s)??s,{tag:a}=await Q.prompt([{type:"input",name:"tag",message:`Tag for ${o.declaration.name} (<${s}>):`,default:i,validate:Nl}]),c=String(a).trim();c!==i&&(n[s]=c)}return n}function Ol(e,t){let r=e??Vo();return{...r,init:{...r.init,prefix:{default:r.init.prefix.default,overrides:{...r.init.prefix.overrides,...t}}}}}var _l={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 jl(e,t,r){let n=r?.init.editors,o=fo(e),s=!be(t),i={vscode:!1,jsx:!1,svelte:!1,cssSnippets:!1},a=[];for(let c of uo){let l=t[c];if(l!==void 0){i[c]=l;continue}let m=n?.[c];if(m!==void 0){i[c]=m;continue}if(s){let{label:u,artifact:p}=_l[c];a.push({type:"confirm",name:c,message:`Generate ${u} (${p})?`,default:o[c]})}else i[c]=o[c]}if(a.length>0){let c=await Q.prompt(a);for(let{name:l}of a)i[l]=!!c[l]}return i}async function Fl(e,t){let r;try{r=Zo(e)}catch(a){let c=a instanceof Error?a.message:String(a);return console.error(`\u26A0 Skipping formkit migration check: ${c}`),!1}if(r.length===0)return!1;let n=r.map(a=>a.pkg).join(", ");if(be(t))return console.error(`\u26A0 ${r.length} legacy standalone package(s) can be migrated to @aurodesignsystem/auro-formkit: ${n}. Run \`auro init\` interactively to apply the migration.`),!1;let{migrate:o}=await Q.prompt([{type:"confirm",name:"migrate",message:`${r.length} legacy standalone package(s) now live in auro-formkit (${n}). Migrate to auro-formkit now? This edits package.json and rewrites import specifiers.`,default:!1}]);if(!o)return!1;let s=je("Migrating to auro-formkit...").start(),i=Qo(e,r);s.succeed(`Migrated ${i.packagesMigrated.length} package(s) to auro-formkit; rewrote ${i.rewriteCount} import(s) across ${i.filesChanged.length} file(s).`);for(let{file:a,specifier:c}of i.deepImports)console.error(`\u26A0 ${a}: left deep import '${c}' unchanged \u2014 update it to an @aurodesignsystem/auro-formkit subpath by hand.`);return console.error("Next: run `npm install`, then re-run `auro init` to regenerate grounding for auro-formkit."),!0}async function Ll(e){let t=new Map(e.map(o=>[o.pkg,o.version])),r=je("Checking for newer component releases...").start(),n=await fe(t);if(n.length===0){r.succeed("All installed Auro components are on the latest release.");return}r.stop(),console.error(ge(n))}async function Gl(e){let t=Z.cwd();if(e.reset){await Hl(t,e);return}let r=je("Detecting installed Auro components...").start(),{components:n,duplicates:o}=await Wn();if(n.length===0){r.warn("No installed Auro components found; nothing to ground. Install an Auro component package and re-run `auro init`.");return}if(r.succeed(`Detected ${n.length} installed component(s) to ground.`),await Fl(t,e))return;let s;try{s=xt(t)}catch(g){let w=g instanceof L||g instanceof Error?g.message:String(g);console.error(`Cannot read ${R}: ${w}`),Z.exit(1)}let i=zo(t),a=Ct(n,{config:s,scan:i,prefix:e.prefix}),l=!(e.prefix!==void 0||s?.init.prefix.default!==void 0)&&(a.needsDefaultPrefix||a.mixedPrefixes),m=e.prefix;if(l){if(be(e)){let g=a.needsDefaultPrefix?`${a.needingDefault.length} component(s) have no resolvable tag and no default prefix`:"existing registrations use inconsistent prefixes";console.error(`Cannot resolve component tags non-interactively: ${g}. Re-run with --prefix <prefix> (e.g. --prefix myapp-).`),Z.exit(1)}m=await Dl(a),a=Ct(n,{config:s,scan:i,prefix:m})}if(a.needsDefaultPrefix&&(console.error("Unable to resolve a default prefix for every component. Re-run with --prefix <prefix>."),Z.exit(1)),!be(e)){let g=await Ml(n,a.resolvedTags);Object.keys(g).length>0&&(a=Ct(n,{config:Ol(s,g),scan:i,prefix:m}))}let u=await jl(t,e,s);a.config.init.editors=u;let p=je("Writing generated files...").start(),d={written:[],warnings:[]};try{for(let w of Fo(n,a.resolvedTags))await Rl.writeFile(Pl.join(t,w.filename),w.contents,"utf-8");d=await Ar(t,n,a.resolvedTags,u),Jo(t,a.config);let g=d.written.length>0?` Editor IntelliSense: ${d.written.join(", ")}.`:"";p.succeed(`Wrote ${Y}, ${ce}, and ${R} for ${n.length} component(s).${g}`)}catch(g){let w=g instanceof Error?g.message:String(g);p.fail(`Failed to write generated files: ${w}`),Z.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(le(`\u26A0 ${a.reconciliationWarnings.length} component tag(s) may not match your app's registered tags`,a.reconciliationWarnings,"red")),a.noPrefixWarnings.length>0&&console.error(le(`\u26A0 ${a.noPrefixWarnings.length} component(s) grounded under bare 'auro-*' tags \u2014 pass a prefix to avoid collisions`,a.noPrefixWarnings,"yellow"));let f=Tr(t,u);if(f.inconsistencies.length>0)try{let g=await Ar(t,n,a.resolvedTags,u),w=new Set(d.warnings);for(let O of g.warnings)w.has(O)||console.error(`\u26A0 ${O}`);f=Tr(t,u)}catch(g){let w=g instanceof Error?g.message:String(g);console.error(`\u26A0 Could not re-write editor artifacts to self-heal wiring: ${w}`)}f.inconsistencies.length>0&&console.error(le("\u26A0 Editor IntelliSense wiring is incomplete after writing",f.inconsistencies,"red")),f.markupDisabled&&console.error(le("\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([Y,ce,R,...d.written])];await Bl(t,h,e),e.offline||await Ll(n)}async function Bl(e,t,r){let n=await wt(e,t);if(n.length===0)return;if(console.error(le(`\u26A0 ${n.length} file(s) auro init wrote are git-ignored and won't be committed`,[...n,"These are meant to be committed so your team and CI share the same grounding/IntelliSense."],"red")),be(r)&&!r.yes){console.error("\u26A0 Un-ignore them in .gitignore (or re-run with --yes) so they get committed.");return}if(!r.yes){let{fix:i}=await Q.prompt([{type:"confirm",name:"fix",message:"Add entries to .gitignore so these files stay tracked (committed)?",default:!0}]);if(!i)return}let{fixed:o,unfixable:s}=await Uo(e,n);o.length>0&&console.error(`\u2714 Un-ignored ${o.length} file(s) in .gitignore so they will be committed.`),s.length>0&&console.error(le(`\u26A0 ${s.length} file(s) are still git-ignored \u2014 un-ignore them by hand`,[...s,"A parent directory is ignored by a rule auro init won't rewrite; edit .gitignore to re-include these paths."],"red"))}function Ul(e){return e.filesToRemove.length===0&&e.unmerges.length===0}async function Hl(e,t){let r=ts(e);if(Ul(r)){console.log("Nothing to reset \u2014 no `auro init` output found.");for(let c of r.filesToSkip)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);return}console.log("`auro init --reset` will:");for(let c of r.filesToRemove)console.log(` \u2022 remove ${c}`);for(let c of r.unmerges)console.log(` \u2022 remove the Auro entry from ${c.path}`);for(let c of r.dirsToPrune)console.log(` \u2022 remove ${c}/ if it is left empty`);for(let c of r.filesToSkip)console.log(` \u2022 keep ${c.path} (${c.reason})`);if(!be(t)){let{confirm:c}=await Q.prompt([{type:"confirm",name:"confirm",message:"Remove these files and config entries?",default:!1}]);if(!c){console.log("Reset aborted \u2014 nothing was changed.");return}}let n=je("Removing `auro init` output...").start(),o;try{o=rs(e,r)}catch(c){let l=c instanceof Error?c.message:String(c);n.fail(`Failed to reset: ${l}`),Z.exit(1)}let s=o.removed.length>0?`Removed ${o.removed.length} file(s)`:"Removed no files",i=o.unmerged.length>0?`, un-merged ${o.unmerged.join(", ")}`:"",a=o.prunedDirs.length>0?`, pruned ${o.prunedDirs.map(c=>`${c}/`).join(", ")}`:"";n.succeed(`${s}${i}${a}.`);for(let c of o.warnings)console.error(`\u26A0 ${c}`);for(let c of o.skipped)console.error(`\u26A0 Left ${c.path} in place: ${c.reason}.`);console.error("\u2139 Reset does not undo an `auro-formkit` migration. If you migrated a legacy standalone form package, revert those package.json and import changes with git.")}var Dh=Il.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(Gl);import $t from"node:process";import{Logger as Wl}from"@aurodesignsystem/auro-library/scripts/utils/logger.mjs";import{program as Vl}from"commander";import is from"ora";async function Jl(e,t){let r=n=>({headerPkg:e,installPkg:e,importSpecifier:e,redirectedToFormkit:!1,result:n});if(t.tag)return r(await M(`${e}@${t.tag}`));if(q(e)){let n=await M(e,{allowNetwork:!1});return n.manifest?r(n):{headerPkg:F,installPkg:F,importSpecifier:de(e),tagFilter:Sr(e),redirectedToFormkit:!0,result:await M(F)}}return r(await M(e))}async function zl(e,t){let r=Oo(e),n=is(`Fetching ${r}...`).start(),o=await Jl(r,t),{result:s}=o,i=s.target;s.manifest||(n.fail(s.transient?`Failed to fetch ${i}: ${s.reason}.`:`No custom-elements.json published for ${i}. It may not exist or may not publish a manifest yet.`),$t.exit(1));let c=(s.manifest.modules??[]).flatMap(u=>u.declarations??[]).filter(u=>u.customElement&&u.tagName).filter(u=>!o.tagFilter||u.tagName===o.tagFilter);c.length===0&&(n.fail(o.tagFilter?`No <${o.tagFilter}> element found in ${i}.`:`No registered custom elements found for ${i}.`),$t.exit(1));let l=s.source==="local"?` (local${s.version?` v${s.version}`:""})`:" (unpkg)";n.succeed(`${i} \u2014 ${c.length} custom element${c.length===1?"":"s"}${l}`),o.redirectedToFormkit&&console.error(`\u2139 ${o.tagFilter} now ships in ${F} \u2014 showing the monorepo version (the legacy standalone isn't installed).`);let m=null;if(s.source==="local"&&s.version){let u=is("Checking for a newer release...").start(),p=await fe(new Map([[o.headerPkg,s.version]]));u.stop(),p.length>0&&(m=ge(p))}if(t.json){$t.stdout.write(`${JSON.stringify(c,null,2)}
|
|
415
|
-
`),m&&console.error(m);return}$t.stdout.write(`
|
|
416
|
-
${c.map(u=>_o(o.headerPkg,u,{installPkg:o.installPkg,importSpecifier:o.importSpecifier})).join(`
|
|
417
|
-
|
|
418
|
-
---
|
|
419
|
-
|
|
420
|
-
`)}
|
|
421
|
-
`),Wl.info(`
|
|
422
|
-
Full docs: https://auro.alaskaair.com`),m&&console.error(m)}var Uh=Vl.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(zl);import{program as Kl}from"commander";var Or=Kl.command("docs").description("Generate API documentation").option("-c, --cem","Generate Custom Elements Manifest (CEM) file",!1).option("-a, --api","Creates api md file from CEM",!1).option("-w, --watch","Watch for changes and rebuild docs",!1).option("-r, --readme-template <url>","URL to the README template file").option("--skip-readme","Skip README.md processing",!1);Or=Be(Or);var zh=Or.action(async e=>{e.cem&&await ze(),e.api&&await Ke(),await Yr(e),e.serve&&await Xr(e),e.watch&&await Zr(e)});import{program as Ql}from"commander";import{Octokit as _r}from"@octokit/rest";import*as Rt from"azure-devops-node-api";import At from"ora";var ql=async e=>{let t=process.env.GH_TOKEN;if(!t)throw new Error("GH_TOKEN environment variable is required");let r=new _r({auth:t}),n,o,s;if(e.includes("github.com")){let a=e.match(/github\.com\/([^\/]+)\/([^\/]+)\/issues\/(\d+)/);if(!a)throw new Error("Invalid GitHub issue URL format");[,n,o,s]=a}else if(e.includes("#")){let a=e.match(/([^\/]+)\/([^#]+)#(\d+)/);if(!a)throw new Error("Invalid GitHub issue reference format");[,n,o,s]=a}else throw new Error("Issue must be provided as full URL or in format 'owner/repo#number'");let i=Number.parseInt(s,10);try{let{data:a}=await r.rest.issues.get({owner:n,repo:o,issue_number:i});return{title:a.title,body:a.body??null,html_url:a.html_url,number:a.number,repository:{owner:{login:n},name:o}}}catch(a){throw new Error(`Failed to fetch GitHub issue: ${a}`)}},Yl=async e=>{let t=process.env.GH_TOKEN;if(!t)return null;let r=new _r({auth:t});try{let n=`
|
|
65
|
+
`);console.log(s),e.text="Running migrations on dependency batches...",new Promise(i=>setTimeout(i,2e3)),e.succeed("Migration process completed successfully.");break}default:console.error("Unknown action selected.")}});import{program as Mn}from"commander";var He=Mn.command("docs").description("Generate API documentation").option("-c, --cem","Generate Custom Elements Manifest (CEM) file",!1).option("-a, --api","Creates api md file from CEM",!1).option("-w, --watch","Watch for changes and rebuild docs",!1).option("-r, --readme-template <url>","URL to the README template file").option("--skip-readme","Skip README.md processing",!1);He=Z(He);var ba=He.action(async r=>{r.cem&&await oe(),r.api&&await se(),await ot(r),r.serve&&await st(r),r.watch&&await it(r)});import{program as Hn}from"commander";import{Octokit as We}from"@octokit/rest";import*as ge from"azure-devops-node-api";import fe from"ora";var Bn=async r=>{let t=process.env.GH_TOKEN;if(!t)throw new Error("GH_TOKEN environment variable is required");let e=new We({auth:t}),n,o,s;if(r.includes("github.com")){let a=r.match(/github\.com\/([^\/]+)\/([^\/]+)\/issues\/(\d+)/);if(!a)throw new Error("Invalid GitHub issue URL format");[,n,o,s]=a}else if(r.includes("#")){let a=r.match(/([^\/]+)\/([^#]+)#(\d+)/);if(!a)throw new Error("Invalid GitHub issue reference format");[,n,o,s]=a}else throw new Error("Issue must be provided as full URL or in format 'owner/repo#number'");let i=Number.parseInt(s,10);try{let{data:a}=await e.rest.issues.get({owner:n,repo:o,issue_number:i});return{title:a.title,body:a.body??null,html_url:a.html_url,number:a.number,repository:{owner:{login:n},name:o}}}catch(a){throw new Error(`Failed to fetch GitHub issue: ${a}`)}},Gn=async r=>{let t=process.env.GH_TOKEN;if(!t)return null;let e=new We({auth:t});try{let n=`
|
|
423
66
|
query($owner: String!, $repo: String!, $issueNumber: Int!) {
|
|
424
67
|
repository(owner: $owner, name: $repo) {
|
|
425
68
|
issue(number: $issueNumber) {
|
|
@@ -445,7 +88,7 @@ Full docs: https://auro.alaskaair.com`),m&&console.error(m)}var Uh=Vl.command("c
|
|
|
445
88
|
}
|
|
446
89
|
}
|
|
447
90
|
}
|
|
448
|
-
`,o={owner:
|
|
91
|
+
`,o={owner:r.repository.owner.login,repo:r.repository.name,issueNumber:r.number},i=(await e.graphql(n,o)).repository.issue.projectItems.nodes.find(a=>a.project.number===19);if(i){let a=i.fieldValues.nodes.find(l=>l.field?.name?.toLowerCase()==="ado"&&l.text?.trim());if(a?.text?.trim())return a.text.trim()}return null}catch(n){return console.error(`Failed to check existing ADO link: ${n}`),null}},Ln=async(r,t)=>{let e=process.env.GH_TOKEN;if(!e)throw new Error("GH_TOKEN environment variable is required");let n=new We({auth:e}),o=19;try{let s=`
|
|
449
92
|
query($org: String!, $projectNumber: Int!, $owner: String!, $repo: String!, $issueNumber: Int!) {
|
|
450
93
|
organization(login: $org) {
|
|
451
94
|
projectV2(number: $projectNumber) {
|
|
@@ -482,7 +125,7 @@ Full docs: https://auro.alaskaair.com`),m&&console.error(m)}var Uh=Vl.command("c
|
|
|
482
125
|
}
|
|
483
126
|
}
|
|
484
127
|
}
|
|
485
|
-
`,i={org:"AlaskaAirlines",projectNumber:o,owner:
|
|
128
|
+
`,i={org:"AlaskaAirlines",projectNumber:o,owner:r.repository.owner.login,repo:r.repository.name,issueNumber:r.number},a=await n.graphql(s,i),l=a.organization.projectV2.id,m=a.repository.issue.id,u=a.organization.projectV2.fields.nodes.find(d=>d.name?.toLowerCase()==="ado"),c=a.repository.issue.projectItems.nodes.find(d=>d.project.number===o)?.id;if(c||(c=(await n.graphql(`
|
|
486
129
|
mutation($projectId: ID!, $contentId: ID!) {
|
|
487
130
|
addProjectV2ItemById(
|
|
488
131
|
input: {
|
|
@@ -495,7 +138,7 @@ Full docs: https://auro.alaskaair.com`),m&&console.error(m)}var Uh=Vl.command("c
|
|
|
495
138
|
}
|
|
496
139
|
}
|
|
497
140
|
}
|
|
498
|
-
`,{projectId:
|
|
141
|
+
`,{projectId:l,contentId:m})).addProjectV2ItemById.item.id),u&&c)await n.graphql(`
|
|
499
142
|
mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) {
|
|
500
143
|
updateProjectV2ItemFieldValue(
|
|
501
144
|
input: {
|
|
@@ -512,4 +155,4 @@ Full docs: https://auro.alaskaair.com`),m&&console.error(m)}var Uh=Vl.command("c
|
|
|
512
155
|
}
|
|
513
156
|
}
|
|
514
157
|
}
|
|
515
|
-
`,{projectId:
|
|
158
|
+
`,{projectId:l,itemId:c,fieldId:u.id,value:t});else if(!u)throw new Error("No 'ado' field found in GitHub project")}catch(s){console.error(`Failed to update GitHub project: ${s}`)}},Un=async r=>{let t=process.env.ADO_TOKEN;if(!t)throw new Error("ADO_TOKEN environment variable is required");let e="https://dev.azure.com/itsals",n="E_Retain_Content",o="E_Retain_Content\\Auro Design System",s=ge.getPersonalAccessTokenHandler(t),a=await new ge.WebApi(e,s).getWorkItemTrackingApi();try{let l=[{op:"add",path:"/fields/System.Title",value:r.title},{op:"add",path:"/fields/System.Description",value:`GitHub Issue: <a href="${r.html_url}">${r.html_url}</a>`},{op:"add",path:"/fields/System.AreaPath",value:o}];return await a.createWorkItem(null,l,n,"User Story")}catch(l){throw new Error(`Failed to create ADO work item: ${l}`)}},Ut=async r=>{let t=fe(`Processing GitHub issue: ${r}`).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 e=await Bn(r);t.succeed(`Found issue: "${e.title}"`);let n=fe("Checking for existing ADO work item...").start(),o=await Gn(e);if(o){n.succeed("ADO work item already exists for this issue!"),console.log(`${o}`);return}n.succeed("No existing ADO work item found");let s=fe("Creating new ADO work item...").start(),i=await Un(e);if(s.succeed(`Successfully created ADO work item #${i.id}`),console.log(`Work item: ${i._links?.html?.href||"N/A"}`),i._links?.html?.href){let a=fe("Adding to GitHub project and updating ADO field...").start();await Ln(e,i._links.html.href),a.succeed("Updated GitHub project with ADO link")}}catch(e){t.fail(`Error: ${e instanceof Error?e.message:e}`),process.exit(1)}};var Ca=Hn.command("ado").description("Generate ADO item from GitHub issue").option("-g, --gh-issue <issue>","What GitHub issue to use").action(async r=>{r.ghIssue&&await Ut(r.ghIssue)});import{program as Vn}from"commander";import{Octokit as Wn}from"@octokit/rest";import{simpleGit as zn}from"simple-git";var Ht="Release Candidate",J="dev",qn="main",he=class r{constructor(t,e,n){this.filteredCommits=null;this.repoInfo={owner:t,repo:e},this.octokit=n}static async create(){let t=process.env.GITHUB_TOKEN;if(!t)throw new Error("GITHUB_TOKEN is required to run RC workflow.");let e=await S.getRepoOwnerAndName(),n=new Wn({auth:t});if(!e)throw new Error("Failed to retrieve repository information. Ensure you're in a valid git repository.");let o=await r.getTriggerBranchName();return o&&o!==J&&(console.log(`Switching from ${o} to ${J} branch...`),await zn().checkout(J)),new r(e.owner,e.repo,n)}get owner(){return this.repoInfo.owner}get repo(){return this.repoInfo.repo}get repoData(){return{...this.repoInfo}}async createReleaseCandidate(){await this.hasCommitsReadyInDev()||console.log("No filtered commits found. Continuing to update RC issue/branch/PR.");let e=await this.getLatestOpenRcIssue(),n=e?await this.getLinkedPrByHead(e.number):null;if(n?.multipleOpen)throw new Error("Multiple open RC PRs found for the same rc/<issueNumber> branch.");if(n?.state==="closed"&&(console.log("Linked RC PR is closed. Creating a new RC issue and PR."),e=await this.createRcIssue(),n=null),e?await this.updateRcIssue(e.number):e=await this.createRcIssue(),!e)throw new Error("Failed to resolve RC issue.");await this.createOrUpdateRcBranch(e.number),n?await this.updateRcPr(e.number,n.number):n=await this.createRcPr(e.number)}async getFilteredCommits(){if(this.filteredCommits===null){let t=await S.getCommitMessages(J);this.filteredCommits=_e(t)}return this.filteredCommits}async hasCommitsReadyInDev(){return(await this.getFilteredCommits()).length>0}async getLatestOpenRcIssue(){let{data:t}=await this.octokit.rest.issues.listForRepo({owner:this.repoInfo.owner,repo:this.repoInfo.repo,labels:Ht,state:"open",sort:"updated",direction:"desc",per_page:30}),e=t.filter(o=>!o.pull_request);if(e.length===0)return console.log(`No open Release Candidate issues found in ${this.repoInfo.repo}`),null;let n=e[0];return console.log(`Using latest open Release Candidate issue: #${n.number}`),{number:n.number,title:n.title||""}}async updateRcIssue(t){let e=await this.getReleaseNotes(),n=`RC ${this.getCurrentDate()}`;await this.octokit.rest.issues.update({owner:this.repoInfo.owner,repo:this.repoInfo.repo,issue_number:t,title:n,body:e})}async createRcIssue(){let t=await this.getReleaseNotes(),{data:e}=await this.octokit.rest.issues.create({owner:this.repoInfo.owner,repo:this.repoInfo.repo,title:`RC ${this.getCurrentDate()}`,labels:[Ht],body:t});return console.log(`Created Release Candidate issue: #${e.number} (${e.html_url})`),{number:e.number,html_url:e.html_url}}async createOrUpdateRcBranch(t){let e=`heads/rc/${t}`,n=`rc/${t}`,{data:o}=await this.octokit.rest.repos.getBranch({owner:this.repoInfo.owner,repo:this.repoInfo.repo,branch:J}),{data:s}=await this.octokit.rest.git.listMatchingRefs({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:e}),i=s.length>0;try{i?(console.log(`Updating existing RC branch: ${n}`),await this.octokit.rest.git.updateRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:e,sha:o.commit.sha,force:!0})):(console.log(`Creating new RC branch: ${n}`),await this.octokit.rest.git.createRef({owner:this.repoInfo.owner,repo:this.repoInfo.repo,ref:`refs/${e}`,sha:o.commit.sha}))}catch(a){throw new Error(`Failed to create or update ${n} branch: ${a}`)}}async getLinkedPrByHead(t){let e=`${this.repoInfo.owner}:rc/${t}`,{data:n}=await this.octokit.rest.pulls.list({owner:this.repoInfo.owner,repo:this.repoInfo.repo,state:"all",head:e,per_page:30}),o=n.filter(i=>i.state==="open");if(o.length>1)return{state:"open",multipleOpen:!0};if(o.length===1)return{state:"open",html_url:o[0].html_url,number:o[0].number};let s=n.filter(i=>i.state==="closed");return s.length>0?{state:"closed",html_url:s[0].html_url,number:s[0].number}:null}async fetchPrTemplate(t){try{let{data:e}=await this.octokit.rest.repos.getContent({owner:this.repoInfo.owner,repo:this.repoInfo.repo,path:".github/PULL_REQUEST_TEMPLATE.md"});if("content"in e&&e.type==="file"){let n=Buffer.from(e.content,"base64").toString("utf-8");return n=n.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.",`Release candidate pull request. See issue #${t} for details.`),n=n.replace(/<details>/g,"<details open>"),n}}catch(e){e&&typeof e=="object"&&"status"in e&&e.status===404?console.log("No PR template found in repo, using default message."):console.warn("Failed to fetch PR template:",e)}return`Release candidate pull request. See issue #${t} for details.`}async createRcPr(t){try{let e=await this.fetchPrTemplate(t),{data:n}=await this.octokit.request(`POST /repos/${this.repoInfo.owner}/${this.repoInfo.repo}/pulls`,{owner:this.repoInfo.owner,repo:this.repoInfo.repo,title:`RC #${t}`,body:e,head:`rc/${t}`,base:qn,headers:{"X-GitHub-Api-Version":"2022-11-28"}});return console.log(`Created Release Candidate pull request: #${n.number} (${n.html_url})`),{state:"open",html_url:n.html_url,number:n.number}}catch(e){throw console.error("Failed to create RC PR:",e),e}}async updateRcPr(t,e){try{let n=await this.fetchPrTemplate(t);await this.octokit.rest.pulls.update({owner:this.repoInfo.owner,repo:this.repoInfo.repo,pull_number:e,body:n}),console.log(`Updated Release Candidate pull request: #${e}`)}catch(n){throw console.error("Failed to update RC PR:",n),n}}async getReleaseNotes(){let t=await this.getFilteredCommits();return je(t,!1)}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/",""):S.getCurrentBranchName()}getCurrentDate(){return new Date().toISOString().split("T")[0]}};var ja=Vn.command("rc-workflow").description("Generate RC issue and pull request").action(async()=>{await(await he.create()).createReleaseCandidate()});ze.name("auro").version(ye()).description("A cli tool to support the Auro Design System");ze.addHelpText("beforeAll",qe());ze.parse();
|