@sugarcube-org/cli 0.0.0-alpha.17 → 0.0.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +4 -4
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Je=Object.defineProperty;var o=(e,t)=>Je(e,"name",{value:t,configurable:!0});import{Command as L}from"commander";import{relative as R,join as $,basename as x,resolve as Q,dirname as qe,normalize as ze}from"pathe";import c from"picocolors";import{existsSync as N,readFileSync as ye}from"node:fs";import Ze from"node-fetch";import{z as m}from"zod";import se,{mkdir as W,writeFile as X,readFile as Qe}from"node:fs/promises";import{execa as Xe}from"execa";import{loadAndResolveTokens as et,validateConfig as tt,configFileExists as v,loadInternalConfig as ee,loadUserConfig as nt,processAndConvertTokens as oe,generateCSSVariables as Te,writeCSSVariablesToDisk as Se,writeCSSUtilitiesToDisk as Ie,convertConfigToUnoRules as st,DEFAULT_STYLES_PATH as ot,DEFAULT_CONFIG as re,fillDefaults as rt}from"@sugarcube-org/core";import it from"is-unicode-supported";import ie,{resolve as at}from"node:path";import{select as ct,isCancel as ae,log as lt,multiselect as ut,confirm as ft,cancel as ke}from"@clack/prompts";import{getColumns as pt}from"@clack/core";import{wrapAnsi as dt}from"fast-wrap-ansi";import*as Ee from"node:readline";import be from"node:readline";import{createLogUpdate as Ce}from"log-update";import{detect as gt}from"@antfu/ni";import{getTsconfig as mt}from"get-tsconfig";import{createGenerator as ht}from"@unocss/core";import G from"fast-glob";var wt="0.0.0-alpha.
|
|
2
|
+
var Je=Object.defineProperty;var o=(e,t)=>Je(e,"name",{value:t,configurable:!0});import{Command as L}from"commander";import{relative as R,join as $,basename as x,resolve as Q,dirname as qe,normalize as ze}from"pathe";import c from"picocolors";import{existsSync as N,readFileSync as ye}from"node:fs";import Ze from"node-fetch";import{z as m}from"zod";import se,{mkdir as W,writeFile as X,readFile as Qe}from"node:fs/promises";import{execa as Xe}from"execa";import{loadAndResolveTokens as et,validateConfig as tt,configFileExists as v,loadInternalConfig as ee,loadUserConfig as nt,processAndConvertTokens as oe,generateCSSVariables as Te,writeCSSVariablesToDisk as Se,writeCSSUtilitiesToDisk as Ie,convertConfigToUnoRules as st,DEFAULT_STYLES_PATH as ot,DEFAULT_CONFIG as re,fillDefaults as rt}from"@sugarcube-org/core";import it from"is-unicode-supported";import ie,{resolve as at}from"node:path";import{select as ct,isCancel as ae,log as lt,multiselect as ut,confirm as ft,cancel as ke}from"@clack/prompts";import{getColumns as pt}from"@clack/core";import{wrapAnsi as dt}from"fast-wrap-ansi";import*as Ee from"node:readline";import be from"node:readline";import{createLogUpdate as Ce}from"log-update";import{detect as gt}from"@antfu/ni";import{getTsconfig as mt}from"get-tsconfig";import{createGenerator as ht}from"@unocss/core";import G from"fast-glob";var wt="0.0.0-alpha.18",yt={version:wt};const ce="fluid",$e="**/*.json",Re="@sugarcube-org/vite",Tt=["node_modules",".git",".next","dist","build"],St=5,A={INIT:"make-sugarcube init",COMPONENTS:"make-sugarcube components",GENERATE:"make-sugarcube generate",CUBE:"make-sugarcube cube"},It={INITIALIZATION:"https://sugarcube.sh/docs/getting-started/setup"},w={PROJECT_REQUIRED:`No sugarcube project detected. Please run ${c.cyan(A.INIT)} first.
|
|
3
3
|
|
|
4
4
|
For more information, visit: ${c.cyan(It.INITIALIZATION)}`,CONFIG_EXISTS:o(()=>`A sugarcube config file already exists in this projct.
|
|
5
5
|
|
|
@@ -128,10 +128,10 @@ ${e.map(r=>`${n} ${he(r,t+1)}`).join(`,
|
|
|
128
128
|
${n}]`;if(typeof e=="object"){const s=Object.entries(e);return s.length===0?"{}":`{
|
|
129
129
|
${s.map(([i,u])=>{const a=fn(i)?i:JSON.stringify(i);return`${n} ${a}: ${he(u,t+1)}`}).join(`,
|
|
130
130
|
`)}
|
|
131
|
-
${n}}`}return JSON.stringify(e)}o(he,"formatValue");function pn(e,t){const n=he(e,0);return`${t?`import type { UserConfig } from "@sugarcube-org/
|
|
131
|
+
${n}}`}return JSON.stringify(e)}o(he,"formatValue");function pn(e,t){const n=he(e,0);return`${t?`import type { UserConfig } from "@sugarcube-org/vite";
|
|
132
132
|
|
|
133
133
|
const config: UserConfig = `:`/**
|
|
134
|
-
* @type {import('@sugarcube-org/
|
|
134
|
+
* @type {import('@sugarcube-org/vite').UserConfig}
|
|
135
135
|
*/
|
|
136
136
|
const config = `}${n};
|
|
137
137
|
|
|
@@ -144,7 +144,7 @@ Please run ${c.cyan(A.INIT)} (or manually create a config file).
|
|
|
144
144
|
Stuck? ${c.cyan("https://sugarcube.sh")}`);const{config:t}=await ee(),{trees:n,resolved:s}=await B(t),r=await yn(n,s,t);if(!e.silent){const i=r.map(f=>f.path),l=[...new Set(i)].map(f=>R(process.cwd(),f)).map(f=>({pending:`Write ${f}`,start:`Writing ${f}`,end:`Wrote ${f}`,while:o(async()=>{},"while")}));await S.tasks(l,{spacing:1,minDurationMs:0,successPauseMs:100,successMessage:"\u{1F389} Files written!"}),S.space(1),ne(c.green("CSS generated successfully."))}}catch(t){H(t)}});function Sn(e){return{source:[$(R(process.cwd(),e.actualTokensDir),$e)]}}o(Sn,"createSingleTokenCollection");async function In(e){return Sn(e)}o(In,"buildTokensConfig");async function kn(e){const t=await In({actualTokensDir:e.actualTokensDir}),n=R(process.cwd(),e.actualStylesDir),s=e.isSrcDir?re.output.components:re.output.components.replace(/^src\//,"");return{tokens:t,output:{css:n,components:s,separate:re.output.separate}}}o(kn,"buildUserConfig");function Ve(e,t=0){if(typeof e!="object"||e===null||t>St)return!1;for(const[n,s]of Object.entries(e))if(!n.startsWith("$")&&typeof s=="object"&&s!==null&&("$value"in s||Ve(s,t+1)))return!0;return!1}o(Ve,"hasAnyToken");async function En(e){try{const t=await G($e,{cwd:e,absolute:!0});for(const n of t)try{const s=await se.readFile(n,"utf-8"),r=JSON.parse(s);if(Ve(r))return!0}catch{}return!1}catch{return!1}}o(En,"detectExistingTokens");const Ke=["**/node_modules/**",".next","public","dist","build",".astro",".nuxt",".output",".svelte-kit"];function bn(e){try{const t=ie.resolve(e,"package.json");if(!N(t))return null;const n=ye(t,"utf-8");return JSON.parse(n)}catch{return null}}o(bn,"getPackageJson");async function Cn(e){const[t,n,s]=await Promise.all([G.glob("**/{next,vite,astro,nuxt,svelte,remix,eleventy}.config.*|.eleventy.js",{cwd:e,deep:3,ignore:Ke}),N(ie.resolve(e,"src")),bn(e)]),r=n?"src/design-tokens":"design-tokens",i=n?"src/styles":"styles",u=n?"src/components":"components";let a="none";return t.find(l=>l.startsWith("next.config."))?.length?a=N(ie.resolve(e,`${n?"src/":""}app`))?"next-app":"next-pages":t.find(l=>l.startsWith("astro.config."))?.length?a="astro":t.find(l=>l.startsWith("nuxt.config."))?.length?a="nuxt":t.find(l=>l.startsWith("svelte.config."))?.length?a="sveltekit":Object.keys(s?.dependencies??{}).find(l=>l.startsWith("@remix-run/"))?a="remix":t.find(l=>l.startsWith("eleventy.config.")||l.startsWith(".eleventy."))?.length?a="eleventy":t.find(l=>l.startsWith("vite.config."))?.length&&(a="vite"),{framework:a,isSrcDir:n,tokensDir:r,stylesDir:i,componentDir:u}}o(Cn,"getProjectInfo");async function $n(e,t){return!!((await G.glob("vite.config.*",{cwd:e,deep:1,ignore:Ke})).length>0||["vite","astro","nuxt","sveltekit","remix"].includes(t))}o($n,"shouldInstallVitePlugin");const Rn=o(async e=>{S.space(2),await j(200);let t="Next steps";if(e.pluginToInstall===Re)t+=`
|
|
145
145
|
|
|
146
146
|
`,t+=`1. Import the generated CSS
|
|
147
|
-
`,t+=` ${c.cyan("import 'virtual:
|
|
147
|
+
`,t+=` ${c.cyan("import 'virtual:sugarcube.css'")}`;else{const n=`${e.stylesDir}/global/tokens.variables.gen.css`;t+=`
|
|
148
148
|
|
|
149
149
|
`,t+=`1. Import the generated CSS
|
|
150
150
|
`,t+=` ${c.cyan(`import './${n}'`)}`}t+=`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sugarcube-org/cli",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.18",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": false
|
|
@@ -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.
|
|
43
|
+
"@sugarcube-org/core": "0.0.1-alpha.8",
|
|
44
44
|
"@unocss/core": "66.5.2",
|
|
45
45
|
"commander": "12.1.0",
|
|
46
46
|
"execa": "9.5.2",
|