@sugarcube-org/cli 0.0.0-alpha.27 → 0.0.0-alpha.29

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/LICENSE.md CHANGED
@@ -1,31 +1,9 @@
1
- # Sugarcube Private Alpha License
1
+ MIT License
2
2
 
3
- Copyright © 2025 Mark Tomlinson. All rights reserved.
3
+ Copyright (c) Mark Tomlinson
4
4
 
5
- **Version 1.0 December 2025**
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
7
- This software is provided under a temporary, non-exclusive, non-transferable
8
- license for private evaluation and internal use as part of the Sugarcube
9
- Private Alpha Program.
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
8
 
11
- ## Permitted
12
-
13
- - Use in internal and client projects for the purpose of evaluating Sugarcube
14
- - Reporting bugs, performance issues, and usability feedback
15
-
16
- ## Not Permitted
17
-
18
- - Redistribution of the software or any derivative works
19
- - Public hosting of the source code
20
- - Sublicensing, resale, or commercial distribution of Sugarcube itself
21
- - Reverse engineering for the purpose of creating a competing product
22
-
23
- ## Disclaimer
24
-
25
- This software is provided "as is", without warranty of any kind, express or
26
- implied. The author assumes no liability for damages arising from its use.
27
-
28
- ## Future Licensing
29
-
30
- This license will be replaced by an open-source license at public beta or
31
- general availability.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # @sugarcube-org/cli
2
2
 
3
- > ⚠️ **Private Alpha** — This package is under active development and not yet ready for public use.
3
+ <p>
4
+ <a href="https://www.npmjs.com/package/@sugarcube-org/cli"><img src="https://img.shields.io/npm/v/@sugarcube-org/cli.svg" alt="Latest Release"></a>
5
+ <a href="https://www.npmjs.com/package/@sugarcube-org/cli"><img src="https://img.shields.io/npm/dt/@sugarcube-org/cli.svg" alt="Total Downloads"></a>
6
+ <a href="https://github.com/sugarcube-org/sugarcube/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/license-see%20LICENSE-blue" alt="License"></a>
7
+ </p>
8
+
9
+ > **Alpha** — This project is in early development.
10
+
11
+ CLI for [sugarcube](https://sugarcube.sh).
12
+
13
+ ---
14
+
15
+ ## Documentation
16
+
17
+ For full documentation, visit [sugarcube.sh](https://sugarcube.sh).
4
18
 
5
19
  ## License
6
20
 
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- var Xe=Object.defineProperty;var o=(e,t)=>Xe(e,"name",{value:t,configurable:!0});import{Command as U}from"commander";import{relative as R,join as C,basename as Te,resolve as L,dirname as et,normalize as tt}from"pathe";import c from"picocolors";import{existsSync as A,readFileSync as Se}from"node:fs";import nt from"node-fetch";import{z as w}from"zod";import oe,{mkdir as V,writeFile as Q,readFile as Ie}from"node:fs/promises";import{execa as st}from"execa";import X from"fast-glob";import{loadAndResolveTokens as ot,loadInternalConfig as ee,configFileExists as O,loadUserConfig as rt,processAndConvertTokens as re,generateCSSVariables as Ee,writeCSSVariablesToDisk as ke,writeCSSUtilitiesToDisk as $e,convertConfigToUnoRules as it,DEFAULT_STYLES_PATH as at,DEFAULT_CONFIG as te,fillDefaults as ct}from"@sugarcube-org/core";import ie,{resolve as lt}from"node:path";import{select as ut,isCancel as ae,log as ft,multiselect as pt,confirm as dt,cancel as _e}from"@clack/prompts";import{getColumns as gt}from"@clack/core";import{wrapAnsi as mt}from"fast-wrap-ansi";import ht from"is-unicode-supported";import*as Re from"node:readline";import Ce from"node:readline";import{createLogUpdate as be}from"log-update";import{detect as wt}from"@antfu/ni";import{getTsconfig as yt}from"get-tsconfig";import{createGenerator as Tt}from"@unocss/core";var St="0.0.0-alpha.27",It={version:St};const ce="fluid",Et="**/*.json",le="@sugarcube-org/vite",kt=["node_modules",".git",".next","dist","build"],$t=5,b={INIT:"make-sugarcube init",COMPONENTS:"make-sugarcube components",GENERATE:"make-sugarcube generate",CUBE:"make-sugarcube cube"},ve={INITIALIZATION:"https://sugarcube.sh/docs/setup",CONFIGURATION:"https://sugarcube.sh/docs/configuration"},m={PROJECT_REQUIRED:`No sugarcube project detected. Please run ${c.cyan(b.INIT)} first.
2
+ var Xe=Object.defineProperty;var o=(e,t)=>Xe(e,"name",{value:t,configurable:!0});import{Command as U}from"commander";import{relative as _,join as R,basename as Te,resolve as L,dirname as et,isAbsolute as tt,normalize as nt}from"pathe";import c from"picocolors";import{existsSync as A,readFileSync as Se}from"node:fs";import{z as w}from"zod";import oe,{mkdir as V,writeFile as Q,readFile as Ie}from"node:fs/promises";import{execa as st}from"execa";import X from"fast-glob";import{loadAndResolveTokens as ot,loadInternalConfig as ee,configFileExists as O,loadSugarcubeConfig as rt,processAndConvertTokens as re,generateCSSVariables as Ee,writeCSSVariablesToDisk as ke,writeCSSUtilitiesToDisk as $e,convertConfigToUnoRules as it,DEFAULT_STYLES_PATH as at,DEFAULT_CONFIG as te,fillDefaults as ct}from"@sugarcube-org/core";import{select as lt,isCancel as ie,log as ut,multiselect as ft,confirm as dt,cancel as be}from"@clack/prompts";import{getColumns as pt}from"@clack/core";import{wrapAnsi as gt}from"fast-wrap-ansi";import mt from"is-unicode-supported";import*as _e from"node:readline";import Re from"node:readline";import{createLogUpdate as Ce}from"log-update";import ae,{resolve as ht}from"node:path";import{detect as wt}from"@antfu/ni";import{getTsconfig as yt}from"get-tsconfig";import{createGenerator as Tt}from"@unocss/core";var St="0.0.0-alpha.29",It={version:St};const ce="fluid",Et="**/*.json",le="@sugarcube-org/vite",kt=["node_modules",".git",".next","dist","build"],$t=5,C={INIT:"make-sugarcube init",COMPONENTS:"make-sugarcube components",GENERATE:"make-sugarcube generate",CUBE:"make-sugarcube cube"},ve={INITIALIZATION:"https://sugarcube.sh/docs/setup",CONFIGURATION:"https://sugarcube.sh/docs/configuration"},m={PROJECT_REQUIRED:`No sugarcube project detected. Please run ${c.cyan(C.INIT)} first.
3
3
 
4
- For more information, visit: ${c.cyan(ve.INITIALIZATION)}`,CONFIG_EXISTS:o(()=>`A sugarcube config file already exists in this projct.
4
+ For more information, visit: ${c.cyan(ve.INITIALIZATION)}`,CONFIG_EXISTS:o(()=>`A sugarcube config file already exists in this project.
5
5
 
6
- To start over, remove it and run ${c.cyan(b.INIT)} again.`,"CONFIG_EXISTS"),PLUGIN_INSTALL_FAILED:o(e=>{const t=e.packageManager==="npm"?"install":"add";return`Failed to install ${e.pluginToInstall} plugin.
6
+ To start over, remove it and run ${c.cyan(C.INIT)} again.`,"CONFIG_EXISTS"),PLUGIN_INSTALL_FAILED:o(e=>{const t=e.packageManager==="npm"?"install":"add";return`Failed to install ${e.pluginToInstall} plugin.
7
7
 
8
8
  This is usually a temporary issue. Try these steps:
9
9
 
@@ -77,8 +77,8 @@ The 'generate' command is for manual generation without plugins. Since you have
77
77
 
78
78
  npm run dev # or your framework's dev command
79
79
 
80
- The plugin will automatically generate CSS with hot module replacement.`,"PLUGIN_DETECTED")};class d extends Error{static{o(this,"CLIError")}constructor(t,n){super(t),this.name="CLIError",this.cause=n}}const ue=w.enum(["react","web-components","css-only"]),De=w.object({path:w.string(),type:w.string()}),_t=De.extend({framework:ue}),Rt=w.object({name:w.string(),type:w.string(),description:w.string().optional(),frameworks:w.array(w.string()).optional(),files:w.array(w.union([_t,De])),tokens:w.record(w.object({type:w.string(),mapping:w.string()})).optional(),dependencies:w.record(ue,w.array(w.string())).optional(),registryDependencies:w.record(ue,w.array(w.string())).optional(),tokenDependencies:w.array(w.string()).optional()}),Ct=w.array(Rt),bt=w.object({content:w.string()}),Ne=process.env.REGISTRY_URL??"https://sugarcube.sh/r";async function Ae(e){try{const t=await nt(e);if(!t.ok){if(t.status===401)throw new d(m.REGISTRY_AUTH_REQUIRED(e));if(t.status===403)throw new d(m.REGISTRY_AUTH_INVALID(e));if(t.status===404)throw new d(m.REGISTRY_NOT_FOUND(e));const n=await t.json().catch(()=>null),s=n&&typeof n=="object"&&"error"in n?String(n.error):t.statusText;throw new d(m.REGISTRY_REQUEST_FAILED(s,e))}return t.json()}catch(t){throw t instanceof d?t:new d(m.REGISTRY_NETWORK_ERROR(e))}}o(Ae,"fetchRegistry");async function j(){const e=`${Ne}/index.json`,t=await Ae(e);try{return Ct.parse(t)}catch{throw new d(m.REGISTRY_INVALID_DATA(e))}}o(j,"getRegistryIndex");async function fe({type:e,name:t,framework:n}){const s=await j(),r=s.find(l=>l.type===e&&l.name===t);if(!r){const l=s.filter(p=>p.type===e).map(p=>p.name);throw new d(m.REGISTRY_ITEM_NOT_FOUND(e,t,l))}let i=r.files;e==="component"&&n&&(i=r.files.filter(l=>"framework"in l&&l.framework===n));const a=await Promise.all(i.map(async l=>{const p=`${Ne}/${l.path}.json`,f=await Ae(p);try{const u=bt.parse(f);return{path:l.path,type:l.type,framework:"framework"in l?l.framework:void 0,content:u.content}}catch{throw new d(m.REGISTRY_FILE_INVALID(l.path))}}));return{item:r,files:a}}o(fe,"getRegistryFiles");async function vt(e){const t=await fe({type:"tokens",name:e});if(!t.files[0])throw new d(m.STARTER_KIT_UNAVAILABLE(e));return t}o(vt,"fetchStarterKit");async function pe(e,t,n){const s=[],r=new Set;async function i(a){if(r.has(a))return;r.add(a);const l=e.find(f=>f.name===a);if(!l){const f=e.filter(u=>u.type==="component").map(u=>u.name).join(", ");throw new d(`Component '${a}' not found in registry
81
- Available components: ${f}`)}const p=l.registryDependencies?.[n]||[];for(const f of p)await i(f);s.push(l)}o(i,"resolveComponent");for(const a of t)await i(a);return s}o(pe,"resolveTree");async function Dt({selectedComponents:e,componentType:t,componentsOutputDirectory:n}){const s={variableCSS:[],utilityCSS:[],componentFiles:[],componentCSS:[],cubeCSS:[],indexFiles:[]},r=await j(),a=(await pe(r,e,t)).map(u=>u.name),l=r.filter(u=>u.type==="component").filter(u=>a.includes(u.name)),p=l.flatMap(u=>u.files.filter(g=>(g.type==="tsx"||g.type==="astro"||g.type==="njk")&&"framework"in g&&g.framework===t).map(g=>R(process.cwd(),C(n,u.name,`${u.name}.${g.type}`))));s.componentFiles=p.filter(u=>A(C(process.cwd(),u)));const f=l.map(u=>{const g=u.name;return R(process.cwd(),C(n,u.name,`${g}.css`))});return s.componentCSS=f.filter(u=>A(C(process.cwd(),u))),s}o(Dt,"collectComponentOverwriteWarnings");async function Nt({cubeDirectory:e}){const t={variableCSS:[],utilityCSS:[],componentFiles:[],componentCSS:[],cubeCSS:[],indexFiles:[]},s=(await j()).filter(r=>r.type==="cube").flatMap(r=>r.files).map(r=>{const i=r.path.replace(/^styles\//,"");return R(process.cwd(),C(e,i))});return t.cubeCSS=s.filter(r=>A(C(process.cwd(),r))),t}o(Nt,"collectCubeOverwriteWarnings");function Oe(e){const t=[];if(e.variableCSS.length>0&&t.push(`CSS variables files:
80
+ The plugin will automatically generate CSS with hot module replacement.`,"PLUGIN_DETECTED")};class p extends Error{static{o(this,"CLIError")}constructor(t,n){super(t),this.name="CLIError",this.cause=n}}const ue=w.enum(["react","web-components","css-only"]),De=w.object({path:w.string(),type:w.string()}),bt=De.extend({framework:ue}),_t=w.object({name:w.string(),type:w.string(),description:w.string().optional(),frameworks:w.array(w.string()).optional(),files:w.array(w.union([bt,De])),tokens:w.record(w.object({type:w.string(),mapping:w.string()})).optional(),dependencies:w.record(ue,w.array(w.string())).optional(),registryDependencies:w.record(ue,w.array(w.string())).optional(),tokenDependencies:w.array(w.string()).optional()}),Rt=w.array(_t),Ct=w.object({content:w.string()}),Ne=process.env.REGISTRY_URL??"https://sugarcube.sh/r";async function Ae(e){try{const t=await fetch(e);if(!t.ok){if(t.status===401)throw new p(m.REGISTRY_AUTH_REQUIRED(e));if(t.status===403)throw new p(m.REGISTRY_AUTH_INVALID(e));if(t.status===404)throw new p(m.REGISTRY_NOT_FOUND(e));const n=await t.json().catch(()=>null),s=n&&typeof n=="object"&&"error"in n?String(n.error):t.statusText;throw new p(m.REGISTRY_REQUEST_FAILED(s,e))}return t.json()}catch(t){throw t instanceof p?t:new p(m.REGISTRY_NETWORK_ERROR(e))}}o(Ae,"fetchRegistry");async function j(){const e=`${Ne}/index.json`,t=await Ae(e);try{return Rt.parse(t)}catch{throw new p(m.REGISTRY_INVALID_DATA(e))}}o(j,"getRegistryIndex");async function fe({type:e,name:t,framework:n}){const s=await j(),r=s.find(l=>l.type===e&&l.name===t);if(!r){const l=s.filter(d=>d.type===e).map(d=>d.name);throw new p(m.REGISTRY_ITEM_NOT_FOUND(e,t,l))}let i=r.files;e==="component"&&n&&(i=r.files.filter(l=>"framework"in l&&l.framework===n));const a=await Promise.all(i.map(async l=>{const d=`${Ne}/${l.path}.json`,f=await Ae(d);try{const u=Ct.parse(f);return{path:l.path,type:l.type,framework:"framework"in l?l.framework:void 0,content:u.content}}catch{throw new p(m.REGISTRY_FILE_INVALID(l.path))}}));return{item:r,files:a}}o(fe,"getRegistryFiles");async function vt(e){const t=await fe({type:"tokens",name:e});if(!t.files[0])throw new p(m.STARTER_KIT_UNAVAILABLE(e));return t}o(vt,"fetchStarterKit");async function de(e,t,n){const s=[],r=new Set;async function i(a){if(r.has(a))return;r.add(a);const l=e.find(f=>f.name===a);if(!l){const f=e.filter(u=>u.type==="component").map(u=>u.name).join(", ");throw new p(`Component '${a}' not found in registry
81
+ Available components: ${f}`)}const d=l.registryDependencies?.[n]||[];for(const f of d)await i(f);s.push(l)}o(i,"resolveComponent");for(const a of t)await i(a);return s}o(de,"resolveTree");async function Dt({selectedComponents:e,componentType:t,componentsOutputDirectory:n}){const s={variableCSS:[],utilityCSS:[],componentFiles:[],componentCSS:[],cubeCSS:[],indexFiles:[]},r=await j(),a=(await de(r,e,t)).map(u=>u.name),l=r.filter(u=>u.type==="component").filter(u=>a.includes(u.name)),d=l.flatMap(u=>u.files.filter(g=>(g.type==="tsx"||g.type==="astro"||g.type==="njk")&&"framework"in g&&g.framework===t).map(g=>_(process.cwd(),R(n,u.name,`${u.name}.${g.type}`))));s.componentFiles=d.filter(u=>A(R(process.cwd(),u)));const f=l.map(u=>{const g=u.name;return _(process.cwd(),R(n,u.name,`${g}.css`))});return s.componentCSS=f.filter(u=>A(R(process.cwd(),u))),s}o(Dt,"collectComponentOverwriteWarnings");async function Nt({cubeDirectory:e}){const t={variableCSS:[],utilityCSS:[],componentFiles:[],componentCSS:[],cubeCSS:[],indexFiles:[]},s=(await j()).filter(r=>r.type==="cube").flatMap(r=>r.files).map(r=>{const i=r.path.replace(/^styles\//,"");return _(process.cwd(),R(e,i))});return t.cubeCSS=s.filter(r=>A(R(process.cwd(),r))),t}o(Nt,"collectCubeOverwriteWarnings");function Oe(e){const t=[];if(e.variableCSS.length>0&&t.push(`CSS variables files:
82
82
  ${e.variableCSS.map(s=>` - ${s}`).join(`
83
83
  `)}`),e.utilityCSS.length>0&&t.push(`CSS utility files:
84
84
  ${e.utilityCSS.map(s=>` - ${s}`).join(`
@@ -92,76 +92,76 @@ ${e.indexFiles.map(s=>` - ${s}`).join(`
92
92
 
93
93
  ${t.join(`
94
94
 
95
- `)}`}o(Oe,"formatOverwriteWarnings");async function de(e,t,n,s={}){if(e.length===0)return;const{devDependency:r=!1}=s,i=n==="npm"?"install":"add",a=(()=>{if(!r)return[];switch(n){case"npm":return["--save-dev"];case"pnpm":return["-D"];case"yarn":return["-D"];case"bun":return["-d"]}})();try{await st(n,[i,...a,...e],{cwd:t})}catch{throw new d(m.DEPENDENCY_INSTALL_FAILED(n))}}o(de,"installDependencies");async function At(e,t,n){const s=C(n,t.name);if(await V(s,{recursive:!0}),e.path.endsWith(".css")){const i=C(s,`${t.name}.css`);return await Q(i,e.content),i}const r=C(s,Te(e.path));return await Q(r,e.content),r}o(At,"writeComponentFile");async function Ot({registryIndex:e,selectedComponents:t,componentType:n,componentsOutputDirectory:s,packageManager:r}){const i=[],a=new Set;await V(s,{recursive:!0});const l=await pe(e,t,n);for(const p of l){const f=await fe({type:"component",name:p.name,framework:n});for(const g of f.files)if(g)try{const h=await At(g,p,s);h&&i.push(h)}catch(h){const k=h instanceof Error?`: ${h.message}`:"";throw new d(`Failed to write component file for "${p.name}"${k}`)}const u=p.dependencies?.[n]||[];for(const g of u)a.add(g)}if(a.size>0)try{await de(Array.from(a),process.cwd(),r)}catch(p){const f=p instanceof Error?`: ${p.message}`:"";throw new d(`Failed to install component dependencies${f}`)}return{createdFiles:i,npmDependencies:a}}o(Ot,"installComponents");function Ft(e,t){const n=L(e),s=L(t);return n.startsWith(`${s}/`)||n===s}o(Ft,"isWithinDirectory");async function Pt(e){const t=[],n=L(process.cwd(),e);await V(n,{recursive:!0});const r=(await j()).filter(i=>i.type==="cube").map(i=>i.name);for(const i of r){const a=await fe({type:"cube",name:i});for(const l of a.files){if(!l)continue;const p=l.path.replace(/^styles\//,""),f=L(n,p);if(!Ft(f,n))throw new d(`Invalid file path detected in CUBE module "${i}": path escapes target directory`);const u=et(f);try{await V(u,{recursive:!0}),await Q(f,l.content),t.push(f)}catch(g){const h=g instanceof Error?`: ${g.message}`:"";throw new d(`Failed to write CUBE module "${i}"${h}`)}}}return t}o(Pt,"installCUBE");async function Fe(e){const t=C(e,"*.resolver.json"),n=await X(t,{onlyFiles:!0});if(n.length===0)return{found:"none"};const[s]=n;return n.length===1&&s?{found:"one",path:R(process.cwd(),s)}:{found:"multiple",paths:n.map(r=>R(process.cwd(),r))}}o(Fe,"findResolverDocument");async function Lt(e,t){await oe.mkdir(t,{recursive:!0});const n=[];for(const s of e)await oe.writeFile(s.path,s.content),n.push(s.path);return n}o(Lt,"writeTokenFiles");async function W(e,t){let n;if(t)n={type:"memory",data:t,config:e};else{if(!e.resolver)throw new d(m.RESOLVER_NOT_CONFIGURED());n={type:"resolver",resolverPath:e.resolver,config:e}}const{trees:s,resolved:r,modifiers:i,errors:a}=await ot(n);if(a.load.length>0){const l=a.load.map(p=>{const f=p.file.split("/").pop()||"unknown file";let u=`File ${f}: `;return p.message.includes("Unexpected token")?u=m.TOKEN_FILE_INVALID_JSON(f):p.message.includes("Unexpected end")?u=m.TOKEN_FILE_INCOMPLETE_JSON(f):u=m.TOKEN_FILE_GENERIC_ERROR(f,p.message),u});throw new d(m.TOKEN_LOAD_FAILED(l))}if(a.validation.length>0||a.flatten.length>0||a.resolution.length>0){const l=[...a.flatten,...a.validation,...a.resolution],p=new Map;for(const f of l)if(f.source?.sourcePath){const u=p.get(f.source.sourcePath)||[];u.push(f.message),p.set(f.source.sourcePath,u)}throw new d(m.TOKEN_VALIDATION_FAILED(p))}return{trees:s,resolved:r,modifiers:i}}o(W,"loadAndResolveTokensForCLI");const Mt=o(async(e,t,n)=>{const s=await vt(e),r=L(process.cwd(),t),i=s.files.map(a=>({path:C(r,Te(a.path)),content:a.content}));return{config:n,tokenFiles:i,tokensDir:r,createdTokenPaths:i.map(a=>R(process.cwd(),a.path))}},"prepareStarterKitForInstall");async function Ut(e){const t=await Mt(e.starterKit??"",e.tokensDir,e.config),n=await Lt(t.tokenFiles,e.tokensDir),s=await Fe(e.tokensDir);if(s.found==="none")throw new d(m.RESOLVER_NOT_FOUND(e.tokensDir));if(s.found==="multiple")throw new d(m.RESOLVER_MULTIPLE_FOUND(s.paths));const r={...e.config,resolver:s.path},{trees:i,resolved:a}=await W(r);e.setupResult={config:r,createdTokenPaths:t.createdTokenPaths,trees:i,resolved:a,tokenFiles:t.tokenFiles,tokensDir:t.tokensDir},e.createdFiles.push(...n),e.config=r,e.userConfig={...e.userConfig,resolver:s.path}}o(Ut,"installFromStarterKit");async function Pe(e=!0){const t=[{label:"React",value:"react",hint:".tsx"},{label:"CSS Only",value:"css-only",hint:".css"},{label:c.dim("Web components"),value:"web-components",hint:"Coming soon!"}];e&&t.push({label:"Skip",value:"skip",hint:"continue without components"});const n=await ut({message:"Build with",options:t});return ae(n)&&process.exit(0),n==="web-components"?(ft.info(c.blue("Web components are coming soon! Please choose React or CSS Only for now.")),Pe(e)):n}o(Pe,"promptComponentFramework");async function jt(e,t){const n=e.filter(r=>r.type==="component"&&r.frameworks?.includes(t)),s=await pt({message:"Select components to add",options:n.map(r=>({label:r.name,value:r.name,hint:r.description})),required:!0});return ae(s)&&process.exit(0),s}o(jt,"promptComponentSelectionFiltered");async function Le(e,t=!1){const n=await dt({message:e,initialValue:t});return(!n||ae(n))&&(_e(),process.exit(0)),!0}o(Le,"confirmOverwrite");const{hidden:ds}=c,Gt=ht(),E=o((e,t)=>Gt?e:t,"unicodeOr"),xt=E("\u25C7","o"),Me=E("\u250C","T"),F=E("\u2502","|"),ge=E("\u2514","\u2014"),Bt=E("\u2510","T"),Vt=E("\u2518","\u2014"),ne=E("\u2500","-"),Wt=E("\u256E","+"),Yt=E("\u256F","+"),Kt=E("\u2570","+"),Ht=E("\u256D","+"),zt=E("\u25CF","\u2022"),Jt=E("\u25C6","*"),qt=E("\u25B2","!"),Zt=E("\u25A0","x"),Y=o((e,t=c.bgGreen,n=c.black)=>t(` ${n(e)} `),"label"),K=o(e=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),n=new RegExp(t,"g");return typeof e=="string"?e.replace(n,""):e},"strip"),H=o((e="",t)=>{process.stdout.write(`
96
-
97
- ${c.gray(Me)}${c.gray(ne)} ${e}
98
- `)},"intro"),se=o((e="",t)=>{process.stdout.write(`${c.gray(F)}
99
- ${c.gray(ge)}${c.gray(ne)} ${e}
100
-
101
- `)},"outro");function G(e){return new Promise(t=>setTimeout(t,e))}o(G,"sleep");const Qt=[Ht,Wt,Kt,Yt],Xt=[Me,Bt,ge,Vt];function Ue(e,t,n,s){let r=n,i=n;return s==="center"?r=Math.floor((t-e)/2):s==="right"&&(r=t-e-n),i=t-r-e,[r,i]}o(Ue,"getPaddingForLine");const en=o(e=>e,"defaultFormatBorder"),me=o((e="",t="",n)=>{const s=n?.output??process.stdout,r=gt(s),a=1*2,l=n?.titlePadding??1,p=n?.contentPadding??2,f=n?.width===void 0||n.width==="auto"?1:Math.min(1,n.width),u=n?.includePrefix?`${F} `:"",g=n?.formatBorder??en,h=(n?.rounded?Qt:Xt).map(g),k=g(ne),$=g(F),T=r-u.length;let _=Math.floor(r*f)-u.length;if(n?.width==="auto"){const q=e.split(`
102
- `);let B=K(t).length+l*2;for(const Qe of q){const ye=K(Qe).length+p*2;ye>B&&(B=ye)}const Z=B+a;Z<_&&(_=Z)}_%2!==0&&(_<T?_++:_--);const I=_-a,N=I-l*2,y=K(t).length>N?`${t.slice(0,N-3)}...`:t,[v,D]=Ue(K(y).length,I,l,n?.titleAlign),P=mt(e,I-p*2,{hard:!0,trim:!1});s.write(`${u}${h[0]}${k.repeat(v)}${y}${k.repeat(D)}${h[1]}
103
- `);const J=P.split(`
104
- `);for(const q of J){const[B,Z]=Ue(K(q).length,I,p,n?.contentAlign);s.write(`${u}${$}${" ".repeat(B)}${q}${" ".repeat(Z)}${$}
105
- `)}s.write(`${u}${h[2]}${k.repeat(I)}${h[3]}
106
- `)},"box");function he(e,t={}){const n=`
107
- ${e}`;me(n,c.black(c.bgRed(" ERROR ")),{width:"auto",titlePadding:2,formatBorder:c.red,...t})}o(he,"errorBoxWithBadge");function je(e,t={}){const n=`
108
- ${e}`;me(n,c.black(c.bgYellow(" WARNING ")),{width:"auto",titlePadding:2,formatBorder:c.yellow,...t})}o(je,"warningBoxWithBadge");function tn(e,t={}){const n=`
109
- ${e}`;me(n,c.black(c.bgCyan(" INFO ")),{width:"auto",titlePadding:2,formatBorder:c.cyan,...t})}o(tn,"infoBoxWithBadge");const nn=o((e,t)=>{if(!(e.meta&&e.name!=="escape")){if(e.ctrl){if(e.name==="a")return"first";if(e.name==="c"||e.name==="d")return"abort";if(e.name==="e")return"last";if(e.name==="g")return"reset"}return e.name==="return"||e.name==="enter"?"submit":e.name==="backspace"?"delete":e.name==="delete"?"deleteForward":e.name==="abort"?"abort":e.name==="escape"?"exit":e.name==="tab"?"next":e.name==="pagedown"?"nextPage":e.name==="pageup"?"prevPage":e.name==="home"?"home":e.name==="end"?"end":e.name==="up"?"up":e.name==="down"?"down":e.name==="right"?"right":e.name==="left"?"left":!1}},"action"),sn=o(async(e,t={})=>{const{sidebarSymbol:n=c.gray("\u2502"),clear:s=!1,stdin:r=process.stdin,stdout:i=process.stdout}=t,a=Ce.createInterface({input:r,escapeCodeTimeout:50}),l=be(i,{showCursor:!1});Ce.emitKeypressEvents(r,a);let p=0,f=!1;const u=o(async()=>{r.off("keypress",g),r.isTTY&&r.setRawMode(!1),a.close(),f=!0,p<e.length-1||s?l.clear():l.done()},"done"),g=o((h,k)=>{r.isTTY&&r.setRawMode(!0);const $=nn(k);if($==="abort")return u(),process.exit(0);["up","down","left","right"].includes($)||u()},"handleKeyPress");r.isTTY&&r.setRawMode(!0),r.on("keypress",g);for(const h of e){const k=Array.isArray(h)?h:h.split(" "),$=[];for(const I of[""].concat(k)){I&&$.push(I);const N=$.join(" ").replace(/sugarcube/g,c.cyan("sugarcube")),y=`${n} ${N}`;l(y),f||await new Promise(v=>setTimeout(v,Math.floor(Math.random()*126)+75))}f||await new Promise(I=>setTimeout(I,100));const _=(await Promise.all(k).then(I=>I.join(" "))).replace(/sugarcube/g,c.cyan("sugarcube"));l(`${n} ${_}`),f||await new Promise(I=>setTimeout(I,Math.floor(Math.random()*201)+1200)),p++}r.off("keypress",g),await new Promise(h=>setTimeout(h,100)),u(),r.isTTY&&r.setRawMode(!1),r.removeAllListeners("keypress")},"sayAnimatedInSidebar");function on(){return Math.floor(Math.random()*551)+200}o(on,"getRandomTaskDuration");async function rn(e,{sidebarSymbol:t="\u2502",spacing:n=1,stdin:s=process.stdin,stdout:r=process.stdout,initialDelayMs:i=200,minDurationMs:a,successPauseMs:l=300,successMessage:p,successAsOutro:f=!1}={}){const u=o((y,v)=>{let D="";switch(v){case"start":D=`${c.cyan(`\u25B6 ${y.start}`)}`;break;case"pending":D=`${c.dim(`\u25A1 ${y.pending}`)}`;break;case"success":D=`${c.green(`\u2714 ${y.end}`)}`;break;case"end":D=`${c.dim(`\u25A0 ${y.end}`)}`;break}return`${t} ${D}`},"formatWithSidebar"),g=Array.from({length:e.length},()=>"");e.forEach((y,v)=>{g[v]=u(y,"pending")});const h=be(r),k=Re.createInterface({input:s,escapeCodeTimeout:50});Re.emitKeypressEvents(s,k);const $=o(y=>{y===""&&(h.clear(),k.close(),s.isTTY&&s.setRawMode(!1),process.exit(0)),s.isTTY&&s.setRawMode(!0)},"keypress");s.isTTY&&s.setRawMode(!0),s.on("keypress",$);const T=Array.from({length:Math.max(n,0)},()=>`${t}`),_=o(()=>[...T,...g].join(`
110
- `),"renderContent");h(_()),await G(i);let I=0;for(const y of e){g[I]=u(y,"start"),h(_());const v=Date.now(),D=y.while();try{await D;const P=Date.now()-v,J=typeof a=="number"?a:on();P<J&&await G(J-P),g[I]=u(y,"success"),h(_()),await G(l)}catch(P){throw g[I]=`${t} ${c.red(`\u2717 ${y.end} (failed)`)}`,h(_()),y.onError?.(P),s.removeListener("keypress",$),k.close(),s.isTTY&&s.setRawMode(!1),P}I++}const N=e.map(y=>u(y,"end"));if(p)if(f){const y=`${c.gray(ge)}${c.gray(ne)} ${c.green(p)}`;h([...T,...N,`${t}`,y].join(`
111
- `))}else{const y=`${t} ${c.green(p)}`;h([...T,...N,`${t}`,y].join(`
112
- `))}else h([...T,...N].join(`
113
- `));await G(1e3),s.removeListener("keypress",$),s.isTTY&&s.setRawMode(!1),k.close(),h.done()}o(rn,"executeTasksInSidebar");const an=o(e=>process.stdout.write(`${e}
114
- `),"rawLog"),S={message:o((e=[],{symbol:t=c.gray(F),secondarySymbol:n=c.gray(F),output:s=process.stdout,spacing:r=1}={})=>{const i=[];for(let l=0;l<r;l++)i.push(`${n}`);const a=Array.isArray(e)?e:e.split(`
115
- `);if(a.length>0){const[l,...p]=a;l&&l.length>0?i.push(`${t} ${l}`):i.push(t);for(const f of p)f.length>0?i.push(`${n} ${f}`):i.push(n)}s.write(`${i.join(`
116
- `)}
117
- `)},"message"),info:o((e,t)=>{S.message(e,{...t,symbol:c.blue(zt)})},"info"),success:o((e,t)=>{S.message(e,{...t,symbol:c.green(Jt)})},"success"),step:o((e,t)=>{S.message(e,{...t,symbol:c.green(xt)})},"step"),warn:o((e,t)=>{S.message(e,{...t,symbol:c.yellow(qt)})},"warn"),error:o((e,t)=>{S.message(e,{...t,symbol:c.red(Zt)})},"error"),animated:o(async(e,{secondarySymbol:t=c.gray(F),output:n=process.stdout,clear:s=!1,...r}={})=>sn(e,{sidebarSymbol:t,stdout:n,clear:s,...r}),"animated"),tasks:o(async(e,{spacing:t=1,secondarySymbol:n=c.gray(F),output:s=process.stdout,...r}={})=>rn(e,{sidebarSymbol:n,spacing:t,stdout:s,...r}),"tasks"),space:o((e=1)=>{for(let t=0;t<e;t++)process.stdout.write(`${c.gray(F)}
118
- `)},"space"),break:o((e=1)=>{for(let t=0;t<e;t++)process.stdout.write(`
119
- `)},"break")};function z(e){if(e instanceof d)S.space(1),he(e.message,{});else{const t=`An unexpected error occurred: ${e instanceof Error?e.message:String(e)}
120
-
121
- If this issue persists, please report it: ${c.cyan("https://github.com/sugarcube-org/sugarcube/issues")}`;S.space(1),he(t,{})}process.exit(0)}o(z,"handleError");function Ge(e){return{absolute:L(process.cwd(),e)}}o(Ge,"resolveDirectoryFromFlag");async function xe(e){const{config:t}=await ee(),n=cn(t,e);if(typeof n=="string")return L(process.cwd(),n)}o(xe,"resolveDirectoryFromConfig");function cn(e,t){const n=t.split(".");let s=e;for(const r of n){if(s==null||typeof s!="object")return;s=s[r]}return s}o(cn,"getNestedValue");async function ln(e){if(e){const{absolute:t}=Ge(e);return{directory:t,fromConfig:!1}}if(O())try{const t=await xe("output.css");if(t)return{directory:t,fromConfig:!0}}catch(t){const n=t instanceof Error?t.message:typeof t=="string"?t:JSON.stringify(t),s=t instanceof Error&&t.stack?`
95
+ `)}`}o(Oe,"formatOverwriteWarnings");async function pe(e,t,n,s={}){if(e.length===0)return;const{devDependency:r=!1}=s,i=n==="npm"?"install":"add",a=(()=>{if(!r)return[];switch(n){case"npm":return["--save-dev"];case"pnpm":return["-D"];case"yarn":return["-D"];case"bun":return["-d"]}})();try{await st(n,[i,...a,...e],{cwd:t})}catch{throw new p(m.DEPENDENCY_INSTALL_FAILED(n))}}o(pe,"installDependencies");async function At(e,t,n){const s=R(n,t.name);if(await V(s,{recursive:!0}),e.path.endsWith(".css")){const i=R(s,`${t.name}.css`);return await Q(i,e.content),i}const r=R(s,Te(e.path));return await Q(r,e.content),r}o(At,"writeComponentFile");async function Ot({registryIndex:e,selectedComponents:t,componentType:n,componentsOutputDirectory:s,packageManager:r}){const i=[],a=new Set;await V(s,{recursive:!0});const l=await de(e,t,n);for(const d of l){const f=await fe({type:"component",name:d.name,framework:n});for(const g of f.files)if(g)try{const h=await At(g,d,s);h&&i.push(h)}catch(h){const k=h instanceof Error?`: ${h.message}`:"";throw new p(`Failed to write component file for "${d.name}"${k}`)}const u=d.dependencies?.[n]||[];for(const g of u)a.add(g)}if(a.size>0)try{await pe(Array.from(a),process.cwd(),r)}catch(d){const f=d instanceof Error?`: ${d.message}`:"";throw new p(`Failed to install component dependencies${f}`)}return{createdFiles:i,npmDependencies:a}}o(Ot,"installComponents");function Ft(e,t){const n=L(e),s=L(t),r=_(s,n);return!r.startsWith("..")&&!tt(r)}o(Ft,"isWithinDirectory");async function Pt(e){const t=[],n=L(process.cwd(),e);await V(n,{recursive:!0});const r=(await j()).filter(i=>i.type==="cube").map(i=>i.name);for(const i of r){const a=await fe({type:"cube",name:i});for(const l of a.files){if(!l)continue;const d=l.path.replace(/^styles\//,""),f=L(n,d);if(!Ft(f,n))throw new p(`Invalid file path detected in CUBE module "${i}": path escapes target directory`);const u=et(f);try{await V(u,{recursive:!0}),await Q(f,l.content),t.push(f)}catch(g){const h=g instanceof Error?`: ${g.message}`:"";throw new p(`Failed to write CUBE module "${i}"${h}`)}}}return t}o(Pt,"installCUBE");async function Fe(e){const t=R(e,"*.resolver.json"),n=await X(t,{onlyFiles:!0});if(n.length===0)return{found:"none"};const[s]=n;return n.length===1&&s?{found:"one",path:_(process.cwd(),s)}:{found:"multiple",paths:n.map(r=>_(process.cwd(),r))}}o(Fe,"findResolverDocument");async function Lt(e,t){await oe.mkdir(t,{recursive:!0});const n=[];for(const s of e)await oe.writeFile(s.path,s.content),n.push(s.path);return n}o(Lt,"writeTokenFiles");async function W(e,t){let n;if(t)n={type:"memory",data:t,config:e};else{if(!e.resolver)throw new p(m.RESOLVER_NOT_CONFIGURED());n={type:"resolver",resolverPath:e.resolver,config:e}}const{trees:s,resolved:r,modifiers:i,errors:a}=await ot(n);if(a.load.length>0){const l=a.load.map(d=>{const f=d.file.split("/").pop()||"unknown file";let u=`File ${f}: `;return d.message.includes("Unexpected token")?u=m.TOKEN_FILE_INVALID_JSON(f):d.message.includes("Unexpected end")?u=m.TOKEN_FILE_INCOMPLETE_JSON(f):u=m.TOKEN_FILE_GENERIC_ERROR(f,d.message),u});throw new p(m.TOKEN_LOAD_FAILED(l))}if(a.validation.length>0||a.flatten.length>0||a.resolution.length>0){const l=[...a.flatten,...a.validation,...a.resolution],d=new Map;for(const f of l)if(f.source?.sourcePath){const u=d.get(f.source.sourcePath)||[];u.push(f.message),d.set(f.source.sourcePath,u)}throw new p(m.TOKEN_VALIDATION_FAILED(d))}return{trees:s,resolved:r,modifiers:i}}o(W,"loadAndResolveTokensForCLI");const Mt=o(async(e,t,n)=>{const s=await vt(e),r=L(process.cwd(),t),i=s.files.map(a=>({path:R(r,Te(a.path)),content:a.content}));return{config:n,tokenFiles:i,tokensDir:r,createdTokenPaths:i.map(a=>_(process.cwd(),a.path))}},"prepareStarterKitForInstall");async function Ut(e){const t=await Mt(e.starterKit??"",e.tokensDir,e.config),n=await Lt(t.tokenFiles,e.tokensDir),s=await Fe(e.tokensDir);if(s.found==="none")throw new p(m.RESOLVER_NOT_FOUND(e.tokensDir));if(s.found==="multiple")throw new p(m.RESOLVER_MULTIPLE_FOUND(s.paths));const r={...e.config,resolver:s.path},{trees:i,resolved:a}=await W(r);e.setupResult={config:r,createdTokenPaths:t.createdTokenPaths,trees:i,resolved:a,tokenFiles:t.tokenFiles,tokensDir:t.tokensDir},e.createdFiles.push(...n),e.config=r,e.sugarcubeConfig={...e.sugarcubeConfig,resolver:s.path}}o(Ut,"installFromStarterKit");async function Pe(e=!0){const t=[{label:"React",value:"react",hint:".tsx"},{label:"CSS Only",value:"css-only",hint:".css"},{label:c.dim("Web components"),value:"web-components",hint:"Coming soon!"}];e&&t.push({label:"Skip",value:"skip",hint:"continue without components"});const n=await lt({message:"Build with",options:t});return ie(n)&&process.exit(0),n==="web-components"?(ut.info(c.blue("Web components are coming soon! Please choose React or CSS Only for now.")),Pe(e)):n}o(Pe,"promptComponentFramework");async function jt(e,t){const n=e.filter(r=>r.type==="component"&&r.frameworks?.includes(t)),s=await ft({message:"Select components to add",options:n.map(r=>({label:r.name,value:r.name,hint:r.description})),required:!0});return ie(s)&&process.exit(0),s}o(jt,"promptComponentSelectionFiltered");async function Le(e,t=!1){const n=await dt({message:e,initialValue:t});return(!n||ie(n))&&(be(),process.exit(0)),!0}o(Le,"confirmOverwrite");function Me(e){return{absolute:L(process.cwd(),e)}}o(Me,"resolveDirectoryFromFlag");async function Ue(e){const{config:t}=await ee(),n=Gt(t,e);if(typeof n=="string")return L(process.cwd(),n)}o(Ue,"resolveDirectoryFromConfig");function Gt(e,t){const n=t.split(".");let s=e;for(const r of n){if(s==null||typeof s!="object")return;s=s[r]}return s}o(Gt,"getNestedValue");async function xt(e){if(e){const{absolute:t}=Me(e);return{directory:t,fromConfig:!1}}if(O())try{const t=await Ue("output.css");if(t)return{directory:t,fromConfig:!0}}catch(t){const n=t instanceof Error?t.message:typeof t=="string"?t:JSON.stringify(t),s=t instanceof Error&&t.stack?`
122
96
 
123
97
  Stack trace:
124
- ${t.stack}`:"";throw new d(`Found a sugarcube config file but couldn't load it: ${n}${s}`)}throw new d(`A sugarcube config file was not found.
98
+ ${t.stack}`:"";throw new p(`Found a sugarcube config file but couldn't load it: ${n}${s}`)}throw new p(`A sugarcube config file was not found.
125
99
 
126
100
  Either a config file or --styles-dir is required to run this command.
127
101
 
128
102
  To use the cube command without a config file:
129
- e.g. ${c.cyan(`${b.CUBE} --styles-dir src/styles`)}
103
+ e.g. ${c.cyan(`${C.CUBE} --styles-dir src/styles`)}
130
104
 
131
105
  To create a config file:
132
- ${c.cyan(b.INIT)}
106
+ ${c.cyan(C.INIT)}
133
107
 
134
- Stuck? ${c.cyan("https://sugarcube.sh")}`)}o(ln,"getCssDir");async function un(e){if(e){const{absolute:t}=Ge(e);return{directory:t,fromConfig:!1}}if(O())try{const t=await xe("output.components");if(t)return{directory:t,fromConfig:!0}}catch{}throw new d(`A sugarcube config file was not found.
108
+ Stuck? ${c.cyan("https://sugarcube.sh")}`)}o(xt,"getCssDir");async function Bt(e){if(e){const{absolute:t}=Me(e);return{directory:t,fromConfig:!1}}if(O())try{const t=await Ue("output.components");if(t)return{directory:t,fromConfig:!0}}catch{}throw new p(`A sugarcube config file was not found.
135
109
 
136
110
  Either a config file or --components-dir is required to run this command.
137
111
 
138
112
  To use the components command without a config file:
139
- e.g. ${c.cyan(`${b.COMPONENTS} --components-dir src/components/ui`)}
113
+ e.g. ${c.cyan(`${C.COMPONENTS} --components-dir src/components/ui`)}
140
114
 
141
115
  To create a config file:
142
- ${c.cyan(b.INIT)}
116
+ ${c.cyan(C.INIT)}
117
+
118
+ Stuck? ${c.cyan("https://sugarcube.sh")}`)}o(Bt,"getComponentsDir");const{hidden:ds}=c,Vt=mt(),E=o((e,t)=>Vt?e:t,"unicodeOr"),Wt=E("\u25C7","o"),je=E("\u250C","T"),F=E("\u2502","|"),ge=E("\u2514","\u2014"),Yt=E("\u2510","T"),Kt=E("\u2518","\u2014"),ne=E("\u2500","-"),Ht=E("\u256E","+"),zt=E("\u256F","+"),Jt=E("\u2570","+"),qt=E("\u256D","+"),Zt=E("\u25CF","\u2022"),Qt=E("\u25C6","*"),Xt=E("\u25B2","!"),en=E("\u25A0","x"),Y=o((e,t=c.bgGreen,n=c.black)=>t(` ${n(e)} `),"label"),K=o(e=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),n=new RegExp(t,"g");return typeof e=="string"?e.replace(n,""):e},"strip"),H=o((e="",t)=>{process.stdout.write(`
119
+
120
+ ${c.gray(je)}${c.gray(ne)} ${e}
121
+ `)},"intro"),se=o((e="",t)=>{process.stdout.write(`${c.gray(F)}
122
+ ${c.gray(ge)}${c.gray(ne)} ${e}
123
+
124
+ `)},"outro");function G(e){return new Promise(t=>setTimeout(t,e))}o(G,"sleep");const tn=[qt,Ht,Jt,zt],nn=[je,Yt,ge,Kt];function Ge(e,t,n,s){let r=n,i=n;return s==="center"?r=Math.floor((t-e)/2):s==="right"&&(r=t-e-n),i=t-r-e,[r,i]}o(Ge,"getPaddingForLine");const sn=o(e=>e,"defaultFormatBorder"),me=o((e="",t="",n)=>{const s=n?.output??process.stdout,r=pt(s),a=1*2,l=n?.titlePadding??1,d=n?.contentPadding??2,f=n?.width===void 0||n.width==="auto"?1:Math.min(1,n.width),u=n?.includePrefix?`${F} `:"",g=n?.formatBorder??sn,h=(n?.rounded?tn:nn).map(g),k=g(ne),$=g(F),T=r-u.length;let b=Math.floor(r*f)-u.length;if(n?.width==="auto"){const q=e.split(`
125
+ `);let B=K(t).length+l*2;for(const Qe of q){const ye=K(Qe).length+d*2;ye>B&&(B=ye)}const Z=B+a;Z<b&&(b=Z)}b%2!==0&&(b<T?b++:b--);const I=b-a,N=I-l*2,y=K(t).length>N?`${t.slice(0,N-3)}...`:t,[v,D]=Ge(K(y).length,I,l,n?.titleAlign),P=gt(e,I-d*2,{hard:!0,trim:!1});s.write(`${u}${h[0]}${k.repeat(v)}${y}${k.repeat(D)}${h[1]}
126
+ `);const J=P.split(`
127
+ `);for(const q of J){const[B,Z]=Ge(K(q).length,I,d,n?.contentAlign);s.write(`${u}${$}${" ".repeat(B)}${q}${" ".repeat(Z)}${$}
128
+ `)}s.write(`${u}${h[2]}${k.repeat(I)}${h[3]}
129
+ `)},"box");function he(e,t={}){const n=`
130
+ ${e}`;me(n,c.black(c.bgRed(" ERROR ")),{width:"auto",titlePadding:2,formatBorder:c.red,...t})}o(he,"errorBoxWithBadge");function xe(e,t={}){const n=`
131
+ ${e}`;me(n,c.black(c.bgYellow(" WARNING ")),{width:"auto",titlePadding:2,formatBorder:c.yellow,...t})}o(xe,"warningBoxWithBadge");function on(e,t={}){const n=`
132
+ ${e}`;me(n,c.black(c.bgCyan(" INFO ")),{width:"auto",titlePadding:2,formatBorder:c.cyan,...t})}o(on,"infoBoxWithBadge");const rn=o((e,t)=>{if(!(e.meta&&e.name!=="escape")){if(e.ctrl){if(e.name==="a")return"first";if(e.name==="c"||e.name==="d")return"abort";if(e.name==="e")return"last";if(e.name==="g")return"reset"}return e.name==="return"||e.name==="enter"?"submit":e.name==="backspace"?"delete":e.name==="delete"?"deleteForward":e.name==="abort"?"abort":e.name==="escape"?"exit":e.name==="tab"?"next":e.name==="pagedown"?"nextPage":e.name==="pageup"?"prevPage":e.name==="home"?"home":e.name==="end"?"end":e.name==="up"?"up":e.name==="down"?"down":e.name==="right"?"right":e.name==="left"?"left":!1}},"action"),an=o(async(e,t={})=>{const{sidebarSymbol:n=c.gray("\u2502"),clear:s=!1,stdin:r=process.stdin,stdout:i=process.stdout}=t,a=Re.createInterface({input:r,escapeCodeTimeout:50}),l=Ce(i,{showCursor:!1});Re.emitKeypressEvents(r,a);let d=0,f=!1;const u=o(async()=>{r.off("keypress",g),r.isTTY&&r.setRawMode(!1),a.close(),f=!0,d<e.length-1||s?l.clear():l.done()},"done"),g=o((h,k)=>{r.isTTY&&r.setRawMode(!0);const $=rn(k);if($==="abort")return u(),process.exit(0);["up","down","left","right"].includes($)||u()},"handleKeyPress");r.isTTY&&r.setRawMode(!0),r.on("keypress",g);for(const h of e){const k=Array.isArray(h)?h:h.split(" "),$=[];for(const I of[""].concat(k)){I&&$.push(I);const N=$.join(" ").replace(/sugarcube/g,c.cyan("sugarcube")),y=`${n} ${N}`;l(y),f||await new Promise(v=>setTimeout(v,Math.floor(Math.random()*126)+75))}f||await new Promise(I=>setTimeout(I,100));const b=(await Promise.all(k).then(I=>I.join(" "))).replace(/sugarcube/g,c.cyan("sugarcube"));l(`${n} ${b}`),f||await new Promise(I=>setTimeout(I,Math.floor(Math.random()*201)+1200)),d++}r.off("keypress",g),await new Promise(h=>setTimeout(h,100)),u(),r.isTTY&&r.setRawMode(!1),r.removeAllListeners("keypress")},"sayAnimatedInSidebar");function cn(){return Math.floor(Math.random()*551)+200}o(cn,"getRandomTaskDuration");async function ln(e,{sidebarSymbol:t="\u2502",spacing:n=1,stdin:s=process.stdin,stdout:r=process.stdout,initialDelayMs:i=200,minDurationMs:a,successPauseMs:l=300,successMessage:d,successAsOutro:f=!1}={}){const u=o((y,v)=>{let D="";switch(v){case"start":D=`${c.cyan(`\u25B6 ${y.start}`)}`;break;case"pending":D=`${c.dim(`\u25A1 ${y.pending}`)}`;break;case"success":D=`${c.green(`\u2714 ${y.end}`)}`;break;case"end":D=`${c.dim(`\u25A0 ${y.end}`)}`;break}return`${t} ${D}`},"formatWithSidebar"),g=Array.from({length:e.length},()=>"");e.forEach((y,v)=>{g[v]=u(y,"pending")});const h=Ce(r),k=_e.createInterface({input:s,escapeCodeTimeout:50});_e.emitKeypressEvents(s,k);const $=o(y=>{y===""&&(h.clear(),k.close(),s.isTTY&&s.setRawMode(!1),process.exit(0)),s.isTTY&&s.setRawMode(!0)},"keypress");s.isTTY&&s.setRawMode(!0),s.on("keypress",$);const T=Array.from({length:Math.max(n,0)},()=>`${t}`),b=o(()=>[...T,...g].join(`
133
+ `),"renderContent");h(b()),await G(i);let I=0;for(const y of e){g[I]=u(y,"start"),h(b());const v=Date.now(),D=y.while();try{await D;const P=Date.now()-v,J=typeof a=="number"?a:cn();P<J&&await G(J-P),g[I]=u(y,"success"),h(b()),await G(l)}catch(P){throw g[I]=`${t} ${c.red(`\u2717 ${y.end} (failed)`)}`,h(b()),y.onError?.(P),s.removeListener("keypress",$),k.close(),s.isTTY&&s.setRawMode(!1),P}I++}const N=e.map(y=>u(y,"end"));if(d)if(f){const y=`${c.gray(ge)}${c.gray(ne)} ${c.green(d)}`;h([...T,...N,`${t}`,y].join(`
134
+ `))}else{const y=`${t} ${c.green(d)}`;h([...T,...N,`${t}`,y].join(`
135
+ `))}else h([...T,...N].join(`
136
+ `));await G(1e3),s.removeListener("keypress",$),s.isTTY&&s.setRawMode(!1),k.close(),h.done()}o(ln,"executeTasksInSidebar");const un=o(e=>process.stdout.write(`${e}
137
+ `),"rawLog"),S={message:o((e=[],{symbol:t=c.gray(F),secondarySymbol:n=c.gray(F),output:s=process.stdout,spacing:r=1}={})=>{const i=[];for(let l=0;l<r;l++)i.push(`${n}`);const a=Array.isArray(e)?e:e.split(`
138
+ `);if(a.length>0){const[l,...d]=a;l&&l.length>0?i.push(`${t} ${l}`):i.push(t);for(const f of d)f.length>0?i.push(`${n} ${f}`):i.push(n)}s.write(`${i.join(`
139
+ `)}
140
+ `)},"message"),info:o((e,t)=>{S.message(e,{...t,symbol:c.blue(Zt)})},"info"),success:o((e,t)=>{S.message(e,{...t,symbol:c.green(Qt)})},"success"),step:o((e,t)=>{S.message(e,{...t,symbol:c.green(Wt)})},"step"),warn:o((e,t)=>{S.message(e,{...t,symbol:c.yellow(Xt)})},"warn"),error:o((e,t)=>{S.message(e,{...t,symbol:c.red(en)})},"error"),animated:o(async(e,{secondarySymbol:t=c.gray(F),output:n=process.stdout,clear:s=!1,...r}={})=>an(e,{sidebarSymbol:t,stdout:n,clear:s,...r}),"animated"),tasks:o(async(e,{spacing:t=1,secondarySymbol:n=c.gray(F),output:s=process.stdout,...r}={})=>ln(e,{sidebarSymbol:n,spacing:t,stdout:s,...r}),"tasks"),space:o((e=1)=>{for(let t=0;t<e;t++)process.stdout.write(`${c.gray(F)}
141
+ `)},"space"),break:o((e=1)=>{for(let t=0;t<e;t++)process.stdout.write(`
142
+ `)},"break")};function z(e){if(e instanceof p)S.space(1),he(e.message,{});else{const t=`An unexpected error occurred: ${e instanceof Error?e.message:String(e)}
143
143
 
144
- Stuck? ${c.cyan("https://sugarcube.sh")}`)}o(un,"getComponentsDir");function x(e,t=process.cwd()){try{const n=lt(t,"package.json");if(!A(n))return!1;const s=Se(n,"utf-8"),r=JSON.parse(s),i={...r.dependencies,...r.devDependencies,...r.peerDependencies};return e in i}catch{return!1}}o(x,"isPackageInstalled");async function Be(e,{withFallback:t=!1}={}){const n=await wt({programmatic:!0,cwd:e});if(n?.includes("yarn"))return"yarn";if(n?.includes("pnpm"))return"pnpm";if(n?.includes("bun"))return"bun";if(n?.includes("npm"))return"npm";if(t){const s=process.env.npm_config_user_agent||"";if(s.includes("yarn"))return"yarn";if(s.includes("pnpm"))return"pnpm";if(s.includes("bun"))return"bun"}return"npm"}o(Be,"getPackageManager");function fn(e=process.cwd()){return yt(e)!==null}o(fn,"isTypeScriptProject");async function Ve(e=process.cwd()){return fn(e)?"sugarcube.config.ts":"sugarcube.config.js"}o(Ve,"getConfigFileName");function pn(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}o(pn,"isValidIdentifier");function we(e,t=0){const n=" ".repeat(t);if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length===0?"[]":`[
144
+ If this issue persists, please report it: ${c.cyan("https://github.com/sugarcube-org/sugarcube/issues")}`;S.space(1),he(t,{})}process.exit(1)}o(z,"handleError");function x(e,t=process.cwd()){try{const n=ht(t,"package.json");if(!A(n))return!1;const s=Se(n,"utf-8"),r=JSON.parse(s),i={...r.dependencies,...r.devDependencies,...r.peerDependencies};return e in i}catch{return!1}}o(x,"isPackageInstalled");async function Be(e,{withFallback:t=!1}={}){const n=await wt({programmatic:!0,cwd:e});if(n?.includes("yarn"))return"yarn";if(n?.includes("pnpm"))return"pnpm";if(n?.includes("bun"))return"bun";if(n?.includes("npm"))return"npm";if(t){const s=process.env.npm_config_user_agent||"";if(s.includes("yarn"))return"yarn";if(s.includes("pnpm"))return"pnpm";if(s.includes("bun"))return"bun"}return"npm"}o(Be,"getPackageManager");function fn(e=process.cwd()){return yt(e)!==null}o(fn,"isTypeScriptProject");async function Ve(e=process.cwd()){return fn(e)?"sugarcube.config.ts":"sugarcube.config.js"}o(Ve,"getConfigFileName");function dn(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}o(dn,"isValidIdentifier");function we(e,t=0){const n=" ".repeat(t);if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length===0?"[]":`[
145
145
  ${e.map(r=>`${n} ${we(r,t+1)}`).join(`,
146
146
  `)}
147
147
  ${n}]`;if(typeof e=="object"){const s=Object.entries(e);return s.length===0?"{}":`{
148
- ${s.map(([i,a])=>{const l=pn(i)?i:JSON.stringify(i);return`${n} ${l}: ${we(a,t+1)}`}).join(`,
148
+ ${s.map(([i,a])=>{const l=dn(i)?i:JSON.stringify(i);return`${n} ${l}: ${we(a,t+1)}`}).join(`,
149
149
  `)}
150
- ${n}}`}return JSON.stringify(e)}o(we,"formatValue");function dn(e,t,n){const s=we(e,0);let r;return n?r=t?`import type { UserConfig } from "@sugarcube-org/vite";
150
+ ${n}}`}return JSON.stringify(e)}o(we,"formatValue");function pn(e,t,n){const s=we(e,0);let r;return n?r=t?`import type { SugarcubeConfig } from "@sugarcube-org/vite";
151
151
 
152
- const config: UserConfig = `:`/**
153
- * @type {import('@sugarcube-org/vite').UserConfig}
152
+ const config: SugarcubeConfig = `:`/**
153
+ * @type {import('@sugarcube-org/vite').SugarcubeConfig}
154
154
  */
155
155
  const config = `:r=`// Configuration reference: ${ve.CONFIGURATION}
156
156
  const config = `,`${r}${s};
157
157
 
158
158
  export default config;
159
- `}o(dn,"formatConfigAsCode");async function We(e,t){try{const n=await Ve(),s=n.endsWith(".ts"),r=dn(e,s,t);await Q(n,r,"utf-8")}catch(n){const s=n instanceof Error?`: ${n.message}`:"";throw new d(`Failed to write config file${s}`)}}o(We,"writeUserConfig");function gn(e,t){return{...e,...t,output:{...e.output??{},...t.output??{}},transforms:{...e.transforms??{},...t.transforms??{}}}}o(gn,"mergeUserConfig");async function Ye(e){const{config:t}=await rt(),n=gn(t,e),s=x(le);await We(n,s)}o(Ye,"mergeConfigIntoFile");const mn=new U().name("components").description("Add components to your project").argument("[components...]","Components to add (e.g., button card)").option("-f, --framework <type>","Framework to use (react, css-only)").option("--components-dir <dir>","Components output directory (e.g., 'src/components')").option("-s, --silent","Suppress logs and prompts").option("-o, --overwrite","Overwrite existing files").action(async(e,t)=>{try{t.silent||H(Y(c.bgGreen(c.black("Components"))));const{directory:n,fromConfig:s}=await un(t.componentsDir);let r=[],i;if(e.length>0||t.framework){if(!t.framework)throw new d(m.COMPONENTS_FRAMEWORK_REQUIRED());if(!["react","css-only"].includes(t.framework))throw new d(m.COMPONENTS_INVALID_FRAMEWORK());i=t.framework,r=e}else{i=await Pe(!1);const T=await j();T||(_e("Failed to fetch component list"),process.exit(1)),r=await jt(T,i)}const a=await Be(process.cwd(),{withFallback:!0}),l=await j(),p=await pe(l,r,i),f=await Dt({selectedComponents:r,componentType:i,componentsOutputDirectory:n}),u=Oe(f);if(u&&!t.force&&!t.silent){const T=je(u,{});S.space(1),await Le("Continue?",!1)}const g=[],h=[],k=new Set;for(const T of p){const _=T.dependencies?.[i]||[];for(const I of _)k.add(I)}const $=Array.from(k).filter(T=>!x(T,process.cwd()));$.length>0&&g.push({pending:`Install ${$.length} dependencies`,start:`Installing ${$.join(", ")}...`,end:`Installed ${$.join(", ")}`,while:o(async()=>{await de($,process.cwd(),a)},"while")});for(const T of p)g.push({pending:`Write component files for ${T.name}`,start:`Writing component files for ${T.name}...`,end:`Wrote component files for ${T.name}`,while:o(async()=>{const _=await Ot({registryIndex:l,selectedComponents:[T.name],componentType:i,componentsOutputDirectory:n,overwrite:t.overwrite||!1,packageManager:a});h.push(..._.createdFiles)},"while")});if(await S.tasks(g,{successMessage:"Components added successfully! \u{1F389} ",minDurationMs:0,successAsOutro:!0}),an(""),!s&&O()){const T=R(process.cwd(),n);await Ye({output:{components:T}})}}catch(n){z(n)}}),hn=new U().name("cube").description("Add CUBE CSS to your project").option("-s, --silent","Suppress logs and prompts").option("-f, --force","Skip overwrite confirmation").option("--styles-dir <dir>","CSS output directory (e.g., 'src/styles')").action(async e=>{try{e.silent||H(Y("CUBE CSS"));const{directory:t,fromConfig:n}=await ln(e.stylesDir);try{await V(t,{recursive:!0})}catch(a){const l=a instanceof Error?`: ${a.message}`:"";throw new d(`Failed to create output directory${l}`)}const s=await Nt({cubeDirectory:t}),r=Oe(s);if(r&&!e.force&&!e.silent){S.space(1);const a=je(r,{});await Le("Continue?",!1)}const i=await Pt(t);if(!e.silent){S.space(1);const a=i,f=[...new Set(a)].map(u=>R(process.cwd(),u)).map(u=>({pending:`Write ${u}`,start:`Writing ${u}`,end:`Wrote ${u}`,while:o(async()=>{},"while")}));await S.tasks(f,{spacing:0,minDurationMs:0,successPauseMs:100,successMessage:"\u{1F389} Files written!"}),se(c.green("CUBE added successfully."))}if(!n&&O()){const a=R(process.cwd(),t);await Ye({output:{css:a}})}}catch(t){z(t)}}),wn="**/*.{html,htm,js,ts,jsx,tsx,vue,svelte,astro,php,njk,liquid,pug,hbs,handlebars,twig,erb,ejs}",yn=["**/node_modules/**","**/dist/**","**/build/**","**/.next/**","**/.nuxt/**","**/.astro/**","**/.git/**","**/coverage/**","**/.pnpm/**","**/.pnpm-store/**","**/.npm/**","**/.cache/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**","**/out/**","**/__snapshots__/**","**/*.config.{js,ts,mjs}","**/*.min.js","**/*.bundle.js","**/*.d.ts"],Ke=1e4,He=100;async function ze(e,t){const n={name:"sugarcube",rules:it(t.utilities??{},e),preflights:[]},s=await Tt({presets:[n]}),r=await X(wn,{ignore:yn,dot:!1,onlyFiles:!0,absolute:!1});if(r.length===0)return[];if(r.length>Ke)throw new d(`Found ${r.length} files to scan (limit: ${Ke}). Are you running this from a monorepo root or a directory containing multiple projects? Run the command from within a single project directory instead.`);const i=[];let a=0;const l=He*1024*1024;for(const u of r){const g=await Ie(u,"utf8");if(a+=g.length,a>l)throw new d(`Total source size exceeds ${He}MB. Are you running this from a monorepo root or a directory containing multiple projects? Run the command from within a single project directory instead.`);i.push(g)}const p=i.join(`
160
- `),{css:f}=await s.generate(p,{preflights:!1});return f?.trim()?[{path:`${t.output?.css||at}/utilities/utilities.gen.css`,css:f}]:[]}o(ze,"generateSugarcubeUtilities");async function Tn(e,t,n,s){const r=[],i=await re(e,t,n),a=await Ee(i,n,s);await ke(a),r.push(...a);const l=await ze(i,n);return await $e(l),r.push(...l),r}o(Tn,"generateAllCSS");const Sn=new U().name("generate").description("Generate CSS from your design tokens").option("--force","Skip overwrite confirmation").option("-s, --silent","Suppress logs and prompts").action(async e=>{try{if(e.silent||H(Y("Generate CSS")),x("@sugarcube-org/vite"))throw new d("Sugarcube vite plugin detected. When using the plugin, CSS is generated automatically during your build process. Remove the plugin to use CLI generation instead.");if(!O())throw new d(`A sugarcube config file was not found. This command requires one.
159
+ `}o(pn,"formatConfigAsCode");async function We(e,t){try{const n=await Ve(),s=n.endsWith(".ts"),r=pn(e,s,t);await Q(n,r,"utf-8")}catch(n){const s=n instanceof Error?`: ${n.message}`:"";throw new p(`Failed to write config file${s}`)}}o(We,"writeSugarcubeConfig");function gn(e,t){return{...e,...t,output:{...e.output??{},...t.output??{}},transforms:{...e.transforms??{},...t.transforms??{}}}}o(gn,"mergeSugarcubeConfig");async function Ye(e){const{config:t}=await rt(),n=gn(t,e),s=x(le);await We(n,s)}o(Ye,"mergeConfigIntoFile");const mn=new U().name("components").description("Add components to your project").argument("[components...]","Components to add (e.g., button card)").option("-f, --framework <type>","Framework to use (react, css-only)").option("--components-dir <dir>","Components output directory (e.g., 'src/components')").option("-s, --silent","Suppress logs and prompts").option("-o, --overwrite","Overwrite existing files").action(async(e,t)=>{try{t.silent||H(Y(c.bgGreen(c.black("Components"))));const{directory:n,fromConfig:s}=await Bt(t.componentsDir);let r=[],i;if(e.length>0||t.framework){if(!t.framework)throw new p(m.COMPONENTS_FRAMEWORK_REQUIRED());if(!["react","css-only"].includes(t.framework))throw new p(m.COMPONENTS_INVALID_FRAMEWORK());i=t.framework,r=e}else{i=await Pe(!1);const T=await j();T||(be("Failed to fetch component list"),process.exit(1)),r=await jt(T,i)}const a=await Be(process.cwd(),{withFallback:!0}),l=await j(),d=await de(l,r,i),f=await Dt({selectedComponents:r,componentType:i,componentsOutputDirectory:n}),u=Oe(f);if(u&&!t.force&&!t.silent){const T=xe(u,{});S.space(1),await Le("Continue?",!1)}const g=[],h=[],k=new Set;for(const T of d){const b=T.dependencies?.[i]||[];for(const I of b)k.add(I)}const $=Array.from(k).filter(T=>!x(T,process.cwd()));$.length>0&&g.push({pending:`Install ${$.length} dependencies`,start:`Installing ${$.join(", ")}...`,end:`Installed ${$.join(", ")}`,while:o(async()=>{await pe($,process.cwd(),a)},"while")});for(const T of d)g.push({pending:`Write component files for ${T.name}`,start:`Writing component files for ${T.name}...`,end:`Wrote component files for ${T.name}`,while:o(async()=>{const b=await Ot({registryIndex:l,selectedComponents:[T.name],componentType:i,componentsOutputDirectory:n,overwrite:t.overwrite||!1,packageManager:a});h.push(...b.createdFiles)},"while")});if(await S.tasks(g,{successMessage:"Components added successfully! \u{1F389} ",minDurationMs:0,successAsOutro:!0}),un(""),!s&&O()){const T=_(process.cwd(),n);await Ye({output:{components:T}})}}catch(n){z(n)}}),hn=new U().name("cube").description("Add CUBE CSS to your project").option("-s, --silent","Suppress logs and prompts").option("-f, --force","Skip overwrite confirmation").option("--styles-dir <dir>","CSS output directory (e.g., 'src/styles')").action(async e=>{try{e.silent||H(Y("CUBE CSS"));const{directory:t,fromConfig:n}=await xt(e.stylesDir);try{await V(t,{recursive:!0})}catch(a){const l=a instanceof Error?`: ${a.message}`:"";throw new p(`Failed to create output directory${l}`)}const s=await Nt({cubeDirectory:t}),r=Oe(s);if(r&&!e.force&&!e.silent){S.space(1);const a=xe(r,{});await Le("Continue?",!1)}const i=await Pt(t);if(!e.silent){S.space(1);const a=i,f=[...new Set(a)].map(u=>_(process.cwd(),u)).map(u=>({pending:`Write ${u}`,start:`Writing ${u}`,end:`Wrote ${u}`,while:o(async()=>{},"while")}));await S.tasks(f,{spacing:0,minDurationMs:0,successPauseMs:100,successMessage:"\u{1F389} Files written!"}),se(c.green("CUBE added successfully."))}if(!n&&O()){const a=_(process.cwd(),t);await Ye({output:{css:a}})}}catch(t){z(t)}}),wn="**/*.{html,htm,js,ts,jsx,tsx,vue,svelte,astro,php,njk,liquid,pug,hbs,handlebars,twig,erb,ejs}",yn=["**/node_modules/**","**/dist/**","**/build/**","**/.next/**","**/.nuxt/**","**/.astro/**","**/.git/**","**/coverage/**","**/.pnpm/**","**/.pnpm-store/**","**/.npm/**","**/.cache/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**","**/out/**","**/__snapshots__/**","**/*.config.{js,ts,mjs}","**/*.min.js","**/*.bundle.js","**/*.d.ts"],Ke=1e4,He=100;async function ze(e,t){const n={name:"sugarcube",rules:it(t.utilities??{},e),preflights:[]},s=await Tt({presets:[n]}),r=await X(wn,{ignore:yn,dot:!1,onlyFiles:!0,absolute:!1});if(r.length===0)return[];if(r.length>Ke)throw new p(`Found ${r.length} files to scan (limit: ${Ke}). Are you running this from a monorepo root or a directory containing multiple projects? Run the command from within a single project directory instead.`);const i=[];let a=0;const l=He*1024*1024;for(const u of r){const g=await Ie(u,"utf8");if(a+=g.length,a>l)throw new p(`Total source size exceeds ${He}MB. Are you running this from a monorepo root or a directory containing multiple projects? Run the command from within a single project directory instead.`);i.push(g)}const d=i.join(`
160
+ `),{css:f}=await s.generate(d,{preflights:!1});return f?.trim()?[{path:`${t.output?.css||at}/utilities/utilities.gen.css`,css:f}]:[]}o(ze,"generateSugarcubeUtilities");async function Tn(e,t,n,s){const r=[],i=await re(e,t,n),a=await Ee(i,n,s);await ke(a),r.push(...a);const l=await ze(i,n);return await $e(l),r.push(...l),r}o(Tn,"generateAllCSS");const Sn=new U().name("generate").description("Generate CSS from your design tokens").option("--force","Skip overwrite confirmation").option("-s, --silent","Suppress logs and prompts").action(async e=>{try{if(e.silent||H(Y("Generate CSS")),x("@sugarcube-org/vite"))throw new p("Sugarcube vite plugin detected. When using the plugin, CSS is generated automatically during your build process. Remove the plugin to use CLI generation instead.");if(!O())throw new p(`A sugarcube config file was not found. This command requires one.
161
161
 
162
- Please run ${c.cyan(b.INIT)} (or manually create a config file).
162
+ Please run ${c.cyan(C.INIT)} (or manually create a config file).
163
163
 
164
- Stuck? ${c.cyan("https://sugarcube.sh")}`);const{config:t}=await ee(),{trees:n,resolved:s,modifiers:r}=await W(t),i=await Tn(n,s,t,r);if(!e.silent){const a=i.map(u=>u.path),f=[...new Set(a)].map(u=>R(process.cwd(),u)).map(u=>({pending:`Write ${u}`,start:`Writing ${u}`,end:`Wrote ${u}`,while:o(async()=>{},"while")}));await S.tasks(f,{spacing:1,minDurationMs:0,successPauseMs:100,successMessage:"\u{1F389} Files written!"}),S.space(1),se(c.green("CSS generated successfully."))}}catch(t){z(t)}});async function In(e){const t=R(process.cwd(),e.actualStylesDir),n=e.isSrcDir?te.output.components:te.output.components.replace(/^src\//,"");return{resolver:e.resolverPath,output:{css:t,components:n}}}o(In,"buildUserConfig");function Je(e,t=0){if(typeof e!="object"||e===null||t>$t)return!1;for(const[n,s]of Object.entries(e))if(!n.startsWith("$")&&typeof s=="object"&&s!==null&&("$value"in s||Je(s,t+1)))return!0;return!1}o(Je,"hasAnyToken");async function En(e){try{const t=await X(Et,{cwd:e,absolute:!0});for(const n of t)try{const s=await oe.readFile(n,"utf-8"),r=JSON.parse(s);if(Je(r))return!0}catch{}return!1}catch{return!1}}o(En,"detectExistingTokens");function qe(e){try{const t=ie.resolve(e,"package.json");if(!A(t))return null;const n=Se(t,"utf-8");return JSON.parse(n)}catch{return null}}o(qe,"getPackageJson");function M(e,t){if(!e)return!1;const n=e.dependencies,s=e.devDependencies;return!!(n?.[t]||s?.[t])}o(M,"hasDependency");function kn(e,t){if(!e)return!1;const n=e.dependencies,s=e.devDependencies,r={...n,...s};return Object.keys(r).some(i=>i.startsWith(t))}o(kn,"hasDependencyStartingWith");function $n(e){const t=A(ie.resolve(e,"src")),n=qe(e),s=t?"src/design-tokens":"design-tokens",r=t?"src/styles":"styles",i=t?"src/components":"components";let a="none";return M(n,"next")?a=A(ie.resolve(e,`${t?"src/":""}app`))?"next-app":"next-pages":M(n,"astro")?a="astro":M(n,"nuxt")?a="nuxt":M(n,"@sveltejs/kit")?a="sveltekit":kn(n,"@remix-run/")?a="remix":M(n,"@11ty/eleventy")?a="eleventy":M(n,"vite")&&(a="vite"),{framework:a,isSrcDir:t,tokensDir:s,stylesDir:r,componentDir:i}}o($n,"getProjectInfo");function _n(e,t){if(["vite","astro","nuxt","sveltekit","remix"].includes(e))return!0;if(e==="eleventy"){const s=qe(t);return M(s,"vite")}return!1}o(_n,"shouldInstallVitePlugin");const Rn=o(async e=>{S.space(2),await G(200);let t="Next steps";if(e.pluginToInstall===le)t+=`
164
+ Stuck? ${c.cyan("https://sugarcube.sh")}`);const{config:t}=await ee(),{trees:n,resolved:s,modifiers:r}=await W(t),i=await Tn(n,s,t,r);if(!e.silent){const a=i.map(u=>u.path),f=[...new Set(a)].map(u=>_(process.cwd(),u)).map(u=>({pending:`Write ${u}`,start:`Writing ${u}`,end:`Wrote ${u}`,while:o(async()=>{},"while")}));await S.tasks(f,{spacing:1,minDurationMs:0,successPauseMs:100,successMessage:"\u{1F389} Files written!"}),S.space(1),se(c.green("CSS generated successfully."))}}catch(t){z(t)}});async function In(e){const t=_(process.cwd(),e.actualStylesDir),n=e.isSrcDir?te.output.components:te.output.components.replace(/^src\//,"");return{resolver:e.resolverPath,output:{css:t,components:n}}}o(In,"buildSugarcubeConfig");function Je(e){try{const t=ae.resolve(e,"package.json");if(!A(t))return null;const n=Se(t,"utf-8");return JSON.parse(n)}catch{return null}}o(Je,"getPackageJson");function M(e,t){if(!e)return!1;const n=e.dependencies,s=e.devDependencies;return!!(n?.[t]||s?.[t])}o(M,"hasDependency");function En(e,t){if(!e)return!1;const n=e.dependencies,s=e.devDependencies,r={...n,...s};return Object.keys(r).some(i=>i.startsWith(t))}o(En,"hasDependencyStartingWith");function kn(e){const t=A(ae.resolve(e,"src")),n=Je(e),s=t?"src/design-tokens":"design-tokens",r=t?"src/styles":"styles",i=t?"src/components":"components";let a="none";return M(n,"next")?a=A(ae.resolve(e,`${t?"src/":""}app`))?"next-app":"next-pages":M(n,"astro")?a="astro":M(n,"nuxt")?a="nuxt":M(n,"@sveltejs/kit")?a="sveltekit":En(n,"@remix-run/")?a="remix":M(n,"@11ty/eleventy")?a="eleventy":M(n,"vite")&&(a="vite"),{framework:a,isSrcDir:t,tokensDir:s,stylesDir:r,componentDir:i}}o(kn,"getProjectInfo");function $n(e,t){if(["vite","astro","nuxt","sveltekit","remix"].includes(e))return!0;if(e==="eleventy"){const s=Je(t);return M(s,"vite")}return!1}o($n,"shouldInstallVitePlugin");function qe(e,t=0){if(typeof e!="object"||e===null||t>$t)return!1;for(const[n,s]of Object.entries(e))if(!n.startsWith("$")&&typeof s=="object"&&s!==null&&("$value"in s||qe(s,t+1)))return!0;return!1}o(qe,"hasAnyToken");async function bn(e){try{const t=await X(Et,{cwd:e,absolute:!0});for(const n of t)try{const s=await oe.readFile(n,"utf-8"),r=JSON.parse(s);if(qe(r))return!0}catch{}return!1}catch{return!1}}o(bn,"detectExistingTokens");const _n=o(async e=>{S.space(2),await G(200);let t="Next steps";if(e.pluginToInstall===le)t+=`
165
165
 
166
166
  `,t+=`1. Configure the plugin
167
167
  `,t+=` Add the plugin to your build configuration:
@@ -173,18 +173,18 @@ Stuck? ${c.cyan("https://sugarcube.sh")}`);const{config:t}=await ee(),{trees:n,r
173
173
  `,t+=`
174
174
 
175
175
  `,t+=`3. (Optional) Add CUBE CSS
176
- `,t+=` ${c.cyan(b.CUBE)}`,t+=`
176
+ `,t+=` ${c.cyan(C.CUBE)}`,t+=`
177
177
 
178
178
  `,t+=`4. (Optional) Add components
179
- `,t+=` ${c.cyan(b.COMPONENTS)}`;else{const n=`${e.stylesDir}/global/tokens.variables.gen.css`;t+=`
179
+ `,t+=` ${c.cyan(C.COMPONENTS)}`;else{const n=`${e.stylesDir}/global/tokens.variables.gen.css`;t+=`
180
180
 
181
181
  `,t+=`1. Import the generated CSS
182
182
  `;const s=e.isSrcDir?`"${n}"`:`"./${n}"`;t+=` ${c.cyan(`import ${s}`)}`,t+=`
183
183
 
184
184
  `,t+=`2. (Optional) Add CUBE CSS
185
- `,t+=` ${c.cyan(b.CUBE)}`,t+=`
185
+ `,t+=` ${c.cyan(C.CUBE)}`,t+=`
186
186
 
187
187
  `,t+=`3. (Optional) Add components
188
- `,t+=` ${c.cyan(b.COMPONENTS)}`}t+=`
188
+ `,t+=` ${c.cyan(C.COMPONENTS)}`}t+=`
189
189
 
190
- `,t+=`Docs: ${c.cyan("https://sugarcube.sh")}`,tn(t,{width:.75}),await G(200),S.break(1)},"nextSteps");async function Cn(e){await Rn(e)}o(Cn,"next");const bn=o(async()=>{const e=["Welcome to sugarcube \u2014 the toolkit for seriously sweet frontends!"];S.space(1),await S.animated(e,{clear:!1})},"welcome");function Ze(e,t){if(!e||e.trim()==="")throw new d(m.DIRECTORY_PATH_EMPTY(t));const s=tt(e).split("/")[0];if(s&&kt.includes(s))throw new d(m.DIRECTORY_PATH_RESERVED(t,e))}o(Ze,"validateDirectoryPath");function vn(e){e.tokensDir&&Ze(e.tokensDir,"tokens-dir"),e.stylesDir&&Ze(e.stylesDir,"styles-dir")}o(vn,"validateOptions");async function Dn(){O()&&(he(m.CONFIG_EXISTS(),{}),process.exit(0))}o(Dn,"preflightInit");async function Nn(e){const t=$n(process.cwd()),n=e.tokensDir||t.tokensDir,s=e.stylesDir||t.stylesDir,r=await En(n);let i=null;if(r){const a=await Fe(n);if(a.found==="none")throw new d(m.RESOLVER_NOT_FOUND(n));if(a.found==="multiple")throw new d(m.RESOLVER_MULTIPLE_FOUND(a.paths));i=a.path}return{tokensDir:n,stylesDir:s,isSrcDir:t.isSrcDir,hasExistingTokens:r,resolverPath:i,framework:t.framework}}o(Nn,"initializeProjectContext");function An(e,t,n){const s=t?null:e.kit||ce;if((e.skip||[]).includes("plugin"))return{starterKit:s,pluginToInstall:null};const i=On(n,process.cwd());return{starterKit:s,pluginToInstall:i}}o(An,"determineInstallationTargets");function On(e,t){return _n(e,t)?le:null}o(On,"determinePlugin");async function Fn(e,t,n,s,r){const i=await Be(process.cwd(),{withFallback:!0});return{options:e,...t,isSrcDir:t.isSrcDir,config:n,userConfig:s,...r,packageManager:i,createdFiles:[],createdDirectories:[],installedDependencies:[],tasks:[]}}o(Fn,"buildInitContext");async function Pn(e){const{trees:t,resolved:n}=await W(e.config);e.setupResult={config:e.config,createdTokenPaths:[],trees:t,resolved:n,tokenFiles:[],tokensDir:e.tokensDir}}o(Pn,"processExistingTokens");async function Ln(e){!e.hasExistingTokens&&e.starterKit?await Ut(e):await Pn(e)}o(Ln,"setupDesignTokens");async function Mn(e){if(!e.setupResult)throw new d(m.INITIALIZATION_INCOMPLETE());const{trees:t,resolved:n}=e.setupResult,s=await re(t,n,e.config),r=await Ee(s,e.config);await ke(r)}o(Mn,"writeCSSVariables");async function Un(e){if(!e.setupResult)throw new d(m.INITIALIZATION_INCOMPLETE());const{trees:t,resolved:n}=e.setupResult,s=await re(t,n,e.config),r=await ze(s,e.config);r.length&&await $e(r)}o(Un,"writeCSSUtilities");async function jn(e){if(e.pluginToInstall&&!x(e.pluginToInstall))try{await de([e.pluginToInstall],process.cwd(),e.packageManager,{devDependency:!0}),e.installedDependencies.push(e.pluginToInstall)}catch{throw new d(m.PLUGIN_INSTALL_FAILED({pluginToInstall:e.pluginToInstall,packageManager:e.packageManager}))}}o(jn,"installPlugins");async function Gn(e){try{const t=!!e.pluginToInstall;await We(e.userConfig,t);const n=await Ve();e.createdFiles.push(n)}catch{throw new d(m.CONFIG_WRITE_FAILED())}}o(Gn,"finalize");function xn(e){const t=[];if(e.hasExistingTokens?t.push({pending:"Looking for existing tokens",start:"Looking for existing tokens...",end:`Existing tokens found at ${e.tokensDir} ${E("\u2192","->")} using them`,while:o(async()=>{},"while")}):e.starterKit&&t.push({pending:"Looking for existing tokens",start:"Looking for existing tokens...",end:`No existing tokens detected ${E("\u2192","->")} adding starter kit`,while:o(async()=>{},"while")}),e.pluginToInstall){const n="Vite";x(e.pluginToInstall)?t.push({pending:`Checking for ${n} compatibility`,start:`Checking for ${n} compatibility...`,end:`${n} plugin already installed ${E("\u2192","->")} skipping plugin installation`,while:o(async()=>{},"while")}):t.push({pending:"Checking for Vite compatibility",start:"Checking for Vite compatibility...",end:`Vite detected ${E("\u2192","->")} plugin will be installed`,while:o(async()=>{},"while")})}else{const n=e.options.skip?.includes("plugin");t.push({pending:"Checking for Vite compatibility",start:"Checking for Vite compatibility...",end:n?`Plugin skipped ${E("\u2192","->")} CSS will be generated as file(s)`:`No Vite detected ${E("\u2192","->")} CSS will be generated as file(s)`,while:o(async()=>{},"while")})}return t}o(xn,"buildDetectionTasks");async function Bn(e){if(e.tasks.push({pending:e.hasExistingTokens?"Process existing design tokens":"Add design tokens",start:e.hasExistingTokens?"Processing existing design tokens...":"Adding design tokens...",end:e.hasExistingTokens?"Design tokens processed":"Design tokens added",while:o(async()=>{await Ln(e)},"while")}),!e.pluginToInstall)e.tasks.push({pending:"Generate CSS variables",start:"Generating CSS variables...",end:"CSS variables generated",while:o(async()=>{await Mn(e)},"while")}),e.tasks.push({pending:"Generate CSS utilities",start:"Generating CSS utilities...",end:"CSS utilities generated",while:o(async()=>{await Un(e)},"while")});else if(e.pluginToInstall&&!x(e.pluginToInstall)){const t="Vite";e.tasks.push({pending:`Install ${t} plugin`,start:`Installing ${t} plugin...`,end:`${t} plugin installed`,while:o(async()=>{await jn(e)},"while")})}e.tasks.push({pending:"Write configuration file",start:"Writing configuration file...",end:"Configuration file written",while:o(async()=>{await Gn(e)},"while")})}o(Bn,"buildExecutionTasks");const Vn=new U().name("init").description("Initialize a new sugarcube project").option("--kit <kit>",`Starter kit to use (default: ${ce})`,ce).option("--tokens-dir <dir>","Design tokens directory (e.g., 'src/design-tokens')").option("--styles-dir <dir>","Styles output directory (e.g., 'src/styles')").option("--with <items...>","Install optional items").option("--skip <items...>","Skip installation of specific items (e.g., plugin)").action(async e=>{let t;try{vn(e),await Dn();const n=await Nn(e),s=n.resolverPath??"",r=await In({resolverPath:s,actualStylesDir:n.stylesDir,isSrcDir:n.isSrcDir}),i=ct(r),a=An(e,n.hasExistingTokens,n.framework);t=await Fn(e,n,i,r,a),H(Y("sugarcube")),await bn();const l=xn(t);l.length>0&&(S.message("Detecting project\u2026"),await S.tasks(l,{minDurationMs:1e3})),t.tasks=[],await Bn(t),t.tasks.length>0&&(S.message("Setting things up\u2026"),await S.tasks(t.tasks,{successMessage:"\u{1F389} Tasks completed successfully!"})),await Cn(t)}catch(n){z(n)}}),Wn=new U().name("validate").description("Validate design token files").argument("[paths...]","Token files or directories to validate (e.g., src/design-tokens)").action(async e=>{try{if(H(Y("Validate")),O()&&!e.length){const{config:i}=await ee();await W(i),se(c.greenBright("All tokens valid \u2728"));return}if(!e.length)throw new d(m.VALIDATE_NO_PATH_SPECIFIED());for(const i of e)if(!A(i))throw new d(m.VALIDATE_PATH_NOT_FOUND(i));const n=(await X(e.map(i=>i.endsWith(".json")?i:C(i,"**/*.json")))).filter(i=>!i.endsWith(".resolver.json"));if(n.length===0)throw new d(m.VALIDATE_NO_TOKEN_FILES());const s={};for(const i of n){const a=await Ie(i,"utf-8"),l=R(process.cwd(),i);s[l]={content:a}}const r=O()?(await ee()).config:{output:te.output,transforms:te.transforms};await W(r,s),se(c.greenBright("All tokens valid \u2728"))}catch(t){z(t)}});process.on("SIGINT",()=>process.exit(0)),process.on("SIGTERM",()=>process.exit(0));async function Yn(){const e=new U().name("sugarcube").description("CLI for scaffolding sugarcube projects").version(It.version,"-v, --version","display the version number");e.addCommand(Vn).addCommand(Sn).addCommand(Wn).addCommand(mn).addCommand(hn),e.parse()}o(Yn,"main"),Yn();
190
+ `,t+=`Docs: ${c.cyan("https://sugarcube.sh")}`,on(t,{width:.75}),await G(200),S.break(1)},"nextSteps");async function Rn(e){await _n(e)}o(Rn,"next");const Cn=o(async()=>{const e=["Welcome to sugarcube \u2014 the toolkit for seriously sweet frontends!"];S.space(1),await S.animated(e,{clear:!1})},"welcome");function Ze(e,t){if(!e||e.trim()==="")throw new p(m.DIRECTORY_PATH_EMPTY(t));const s=nt(e).split("/")[0];if(s&&kt.includes(s))throw new p(m.DIRECTORY_PATH_RESERVED(t,e))}o(Ze,"validateDirectoryPath");function vn(e){e.tokensDir&&Ze(e.tokensDir,"tokens-dir"),e.stylesDir&&Ze(e.stylesDir,"styles-dir")}o(vn,"validateOptions");async function Dn(){O()&&(he(m.CONFIG_EXISTS(),{}),process.exit(1))}o(Dn,"preflightInit");async function Nn(e){const t=kn(process.cwd()),n=e.tokensDir||t.tokensDir,s=e.stylesDir||t.stylesDir,r=await bn(n);let i=null;if(r){const a=await Fe(n);if(a.found==="none")throw new p(m.RESOLVER_NOT_FOUND(n));if(a.found==="multiple")throw new p(m.RESOLVER_MULTIPLE_FOUND(a.paths));i=a.path}return{tokensDir:n,stylesDir:s,isSrcDir:t.isSrcDir,hasExistingTokens:r,resolverPath:i,framework:t.framework}}o(Nn,"initializeProjectContext");function An(e,t,n){const s=t?null:e.kit||ce;if((e.skip||[]).includes("plugin"))return{starterKit:s,pluginToInstall:null};const i=On(n,process.cwd());return{starterKit:s,pluginToInstall:i}}o(An,"determineInstallationTargets");function On(e,t){return $n(e,t)?le:null}o(On,"determinePlugin");async function Fn(e,t,n,s,r){const i=await Be(process.cwd(),{withFallback:!0});return{options:e,...t,isSrcDir:t.isSrcDir,config:n,sugarcubeConfig:s,...r,packageManager:i,createdFiles:[],createdDirectories:[],installedDependencies:[],tasks:[]}}o(Fn,"buildInitContext");async function Pn(e){const{trees:t,resolved:n}=await W(e.config);e.setupResult={config:e.config,createdTokenPaths:[],trees:t,resolved:n,tokenFiles:[],tokensDir:e.tokensDir}}o(Pn,"processExistingTokens");async function Ln(e){!e.hasExistingTokens&&e.starterKit?await Ut(e):await Pn(e)}o(Ln,"setupDesignTokens");async function Mn(e){if(!e.setupResult)throw new p(m.INITIALIZATION_INCOMPLETE());const{trees:t,resolved:n}=e.setupResult,s=await re(t,n,e.config),r=await Ee(s,e.config);await ke(r)}o(Mn,"writeCSSVariables");async function Un(e){if(!e.setupResult)throw new p(m.INITIALIZATION_INCOMPLETE());const{trees:t,resolved:n}=e.setupResult,s=await re(t,n,e.config),r=await ze(s,e.config);r.length&&await $e(r)}o(Un,"writeCSSUtilities");async function jn(e){if(e.pluginToInstall&&!x(e.pluginToInstall))try{await pe([e.pluginToInstall],process.cwd(),e.packageManager,{devDependency:!0}),e.installedDependencies.push(e.pluginToInstall)}catch{throw new p(m.PLUGIN_INSTALL_FAILED({pluginToInstall:e.pluginToInstall,packageManager:e.packageManager}))}}o(jn,"installPlugins");async function Gn(e){try{const t=!!e.pluginToInstall;await We(e.sugarcubeConfig,t);const n=await Ve();e.createdFiles.push(n)}catch{throw new p(m.CONFIG_WRITE_FAILED())}}o(Gn,"finalize");function xn(e){const t=[];if(e.hasExistingTokens?t.push({pending:"Looking for existing tokens",start:"Looking for existing tokens...",end:`Existing tokens found at ${e.tokensDir} ${E("\u2192","->")} using them`,while:o(async()=>{},"while")}):e.starterKit&&t.push({pending:"Looking for existing tokens",start:"Looking for existing tokens...",end:`No existing tokens detected ${E("\u2192","->")} adding starter kit`,while:o(async()=>{},"while")}),e.pluginToInstall){const n="Vite";x(e.pluginToInstall)?t.push({pending:`Checking for ${n} compatibility`,start:`Checking for ${n} compatibility...`,end:`${n} plugin already installed ${E("\u2192","->")} skipping plugin installation`,while:o(async()=>{},"while")}):t.push({pending:"Checking for Vite compatibility",start:"Checking for Vite compatibility...",end:`Vite detected ${E("\u2192","->")} plugin will be installed`,while:o(async()=>{},"while")})}else{const n=e.options.skip?.includes("plugin");t.push({pending:"Checking for Vite compatibility",start:"Checking for Vite compatibility...",end:n?`Plugin skipped ${E("\u2192","->")} CSS will be generated as file(s)`:`No Vite detected ${E("\u2192","->")} CSS will be generated as file(s)`,while:o(async()=>{},"while")})}return t}o(xn,"buildDetectionTasks");async function Bn(e){if(e.tasks.push({pending:e.hasExistingTokens?"Process existing design tokens":"Add design tokens",start:e.hasExistingTokens?"Processing existing design tokens...":"Adding design tokens...",end:e.hasExistingTokens?"Design tokens processed":"Design tokens added",while:o(async()=>{await Ln(e)},"while")}),!e.pluginToInstall)e.tasks.push({pending:"Generate CSS variables",start:"Generating CSS variables...",end:"CSS variables generated",while:o(async()=>{await Mn(e)},"while")}),e.tasks.push({pending:"Generate CSS utilities",start:"Generating CSS utilities...",end:"CSS utilities generated",while:o(async()=>{await Un(e)},"while")});else if(e.pluginToInstall&&!x(e.pluginToInstall)){const t="Vite";e.tasks.push({pending:`Install ${t} plugin`,start:`Installing ${t} plugin...`,end:`${t} plugin installed`,while:o(async()=>{await jn(e)},"while")})}e.tasks.push({pending:"Write configuration file",start:"Writing configuration file...",end:"Configuration file written",while:o(async()=>{await Gn(e)},"while")})}o(Bn,"buildExecutionTasks");const Vn=new U().name("init").description("Initialize a new sugarcube project").option("--kit <kit>",`Starter kit to use (default: ${ce})`,ce).option("--tokens-dir <dir>","Design tokens directory (e.g., 'src/design-tokens')").option("--styles-dir <dir>","Styles output directory (e.g., 'src/styles')").option("--with <items...>","Install optional items").option("--skip <items...>","Skip installation of specific items (e.g., plugin)").action(async e=>{let t;try{vn(e),await Dn();const n=await Nn(e),s=n.resolverPath??"",r=await In({resolverPath:s,actualStylesDir:n.stylesDir,isSrcDir:n.isSrcDir}),i=ct(r),a=An(e,n.hasExistingTokens,n.framework);t=await Fn(e,n,i,r,a),H(Y("sugarcube")),await Cn();const l=xn(t);l.length>0&&(S.message("Detecting project\u2026"),await S.tasks(l,{minDurationMs:1e3})),t.tasks=[],await Bn(t),t.tasks.length>0&&(S.message("Setting things up\u2026"),await S.tasks(t.tasks,{successMessage:"\u{1F389} Tasks completed successfully!"})),await Rn(t)}catch(n){z(n)}}),Wn=new U().name("validate").description("Validate design token files").argument("[paths...]","Token files or directories to validate (e.g., src/design-tokens)").action(async e=>{try{if(H(Y("Validate")),O()&&!e.length){const{config:i}=await ee();await W(i),se(c.greenBright("All tokens valid \u2728"));return}if(!e.length)throw new p(m.VALIDATE_NO_PATH_SPECIFIED());for(const i of e)if(!A(i))throw new p(m.VALIDATE_PATH_NOT_FOUND(i));const n=(await X(e.map(i=>i.endsWith(".json")?i:R(i,"**/*.json")))).filter(i=>!i.endsWith(".resolver.json"));if(n.length===0)throw new p(m.VALIDATE_NO_TOKEN_FILES());const s={};for(const i of n){const a=await Ie(i,"utf-8"),l=_(process.cwd(),i);s[l]={content:a}}const r=O()?(await ee()).config:{output:te.output,transforms:te.transforms};await W(r,s),se(c.greenBright("All tokens valid \u2728"))}catch(t){z(t)}});process.on("SIGINT",()=>process.exit(0)),process.on("SIGTERM",()=>process.exit(0));async function Yn(){const e=new U().name("sugarcube").description("CLI for sugarcube").version(It.version,"-v, --version","display the version number");e.addCommand(Vn).addCommand(Sn).addCommand(Wn).addCommand(mn).addCommand(hn),e.parse()}o(Yn,"main"),Yn();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sugarcube-org/cli",
3
- "version": "0.0.0-alpha.27",
3
+ "version": "0.0.0-alpha.29",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false
7
7
  },
8
8
  "description": "A CLI for scaffolding sugarcube applications",
9
- "license": "SEE LICENSE IN LICENSE.md",
9
+ "license": "MIT",
10
10
  "author": "Mark Tomlinson",
11
11
  "repository": {
12
12
  "type": "git",
@@ -40,7 +40,7 @@
40
40
  "@antfu/ni": "23.3.0",
41
41
  "@clack/core": "1.0.0-alpha.3",
42
42
  "@clack/prompts": "1.0.0-alpha.3",
43
- "@sugarcube-org/core": "0.0.1-alpha.12",
43
+ "@sugarcube-org/core": "0.0.1-alpha.14",
44
44
  "@unocss/core": "66.5.2",
45
45
  "commander": "12.1.0",
46
46
  "execa": "9.5.2",
@@ -49,7 +49,6 @@
49
49
  "get-tsconfig": "4.7.2",
50
50
  "is-unicode-supported": "2.1.0",
51
51
  "log-update": "6.1.0",
52
- "node-fetch": "3.3.0",
53
52
  "pathe": "2.0.3",
54
53
  "picocolors": "1.1.1",
55
54
  "zod": "3.21.4"