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