@salty-css/core 0.0.1-alpha.78 → 0.0.1-alpha.79

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.
Files changed (3) hide show
  1. package/bin/main.cjs +6 -6
  2. package/bin/main.js +169 -156
  3. package/package.json +1 -1
package/bin/main.cjs CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ee=require("commander"),Q=require("fs"),s=require("fs/promises"),i=require("path"),te=require("ejs"),ne=require("../compiler/index.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),L=require("winston"),se=require("child_process"),ae=require("ora");var M=typeof document<"u"?document.currentScript:null;const t=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]}),m=c=>{t.error(c)},X=c=>new Promise((h,S)=>{se.exec(c,F=>{if(F)return S(F);h()})}),N=async(...c)=>{const h=c.map(k=>k.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),S=ae(`Installing packages: ${h}`).start(),F=c.join(" ");await X(`npm install ${F}`),S.succeed(`Installed packages: ${h}`)},oe=()=>Q.existsSync(i.join(process.cwd(),"node_modules",".bin","prettier"));async function I(c){try{if(!oe())return;await X(`./node_modules/.bin/prettier --write "${c}"`),t.info(`Formatted ${c} with Prettier`)}catch(h){t.error(`Error formatting ${c} with Prettier:`,h)}}async function re(){const c=new ee.Command;c.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const h={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},S=async(n,a)=>{const{default:r}=await h[n],u=te.render(r,a);return{fileName:n,content:u}},F=async()=>{const n=i.join(process.cwd(),".saltyrc");return await s.readFile(n,"utf-8").then(JSON.parse).catch(()=>({}))},k=i.join(process.cwd(),"package.json"),q=async(n=k)=>{const a=await s.readFile(n,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(n,a=k)=>{typeof n=="object"&&(n=JSON.stringify(n,null,2)),await s.writeFile(a,n)},B=async()=>{const n=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:M&&M.tagName.toUpperCase()==="SCRIPT"&&M.src||new URL("bin/main.cjs",document.baseURI).href);return q(n)},V=await(async()=>(await F()).defaultProject)(),x=await B(),A={core:`@salty-css/core@${x.version}`,react:`@salty-css/react@${x.version}`,eslintPluginCore:`@salty-css/eslint-plugin-core@${x.version}`,vite:`@salty-css/vite@${x.version}`,next:`@salty-css/next@${x.version}`},H=n=>{const a=n==="."?"":n,r=process.cwd();return i.join(r,a)};c.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(n="."){if(!await q().catch(()=>{}))return m("Salty CSS project must be initialized in a directory with a package.json file.");t.info("Initializing a new Salty-CSS project!");const{dir:r=n,cssFile:u,skipInstall:g}=this.opts();if(!r)return m("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");g||(await N(A.core,A.react),await N(`-D ${A.eslintPluginCore}`));const f=process.cwd(),l=H(r),b=await Promise.all([S("salty.config.ts"),S("saltygen/index.css")]);await s.mkdir(l,{recursive:!0});const y=b.map(async({fileName:e,content:p})=>{const d=i.join(l,e);if(await s.readFile(d,"utf-8").catch(()=>{})!==void 0){t.debug("File already exists: "+d);return}const P=e.split("/").slice(0,-1).join("/");P&&await s.mkdir(i.join(l,P),{recursive:!0}),t.info("Creating file: "+d),await s.writeFile(d,p),await I(d)});await Promise.all(y);const $=i.relative(f,l)||".",j=i.join(f,".saltyrc"),o=await s.readFile(j,"utf-8").catch(()=>{});if(o===void 0){t.info("Creating file: "+j);const p=JSON.stringify({defaultProject:$,projects:[$]},null,2);await s.writeFile(j,p)}else{t.info("Edit file: "+j);const e=JSON.parse(o),p=new Set((e==null?void 0:e.projects)||[]);p.add($),e.projects=[...p];const d=JSON.stringify(e,null,2);await s.writeFile(j,d)}const w=i.join(f,".gitignore"),O=await s.readFile(w,"utf-8").catch(()=>{});O!==void 0&&(O.includes("saltygen")||(t.info("Edit file: "+w),await s.writeFile(w,O+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("commander"),H=require("fs"),s=require("fs/promises"),n=require("path"),ae=require("ejs"),oe=require("../compiler/index.cjs"),re=require("../pascal-case-iWoaJWwT.cjs"),L=require("winston"),ce=require("child_process"),le=require("ora");var B=typeof document<"u"?document.currentScript:null;const t=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]}),h=p=>{t.error(p)},ee=p=>new Promise((w,j)=>{ce.exec(p,F=>{if(F)return j(F);w()})}),D=async(...p)=>{const w=p.map(k=>k.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),j=le(`Installing packages: ${w}`).start(),F=p.join(" ");await ee(`npm install ${F}`),j.succeed(`Installed packages: ${w}`)},de=()=>H.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function x(p){try{if(!de())return;await ee(`./node_modules/.bin/prettier --write "${p}"`),t.info(`Formatted ${p} with Prettier`)}catch(w){t.error(`Error formatting ${p} with Prettier:`,w)}}async function pe(){const p=new se.Command;p.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const w={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},j=async(i,o)=>{const{default:c}=await w[i],u=ae.render(c,o);return{fileName:i,content:u}},F=async()=>{const i=n.join(process.cwd(),".saltyrc");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},k=n.join(process.cwd(),"package.json"),I=async(i=k)=>{const o=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!o)throw"Could not read package.json file!";return o},te=async(i,o=k)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(o,i)},V=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:B&&B.tagName.toUpperCase()==="SCRIPT"&&B.src||new URL("bin/main.cjs",document.baseURI).href);return I(i)},K=await(async()=>(await F()).defaultProject)(),b=await V(),q={core:`@salty-css/core@${b.version}`,react:`@salty-css/react@${b.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${b.version}`,vite:`@salty-css/vite@${b.version}`,next:`@salty-css/next@${b.version}`},z=i=>{const o=i==="."?"":i,c=process.cwd();return n.join(c,o)};p.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await I().catch(()=>{}))return h("Salty CSS project must be initialized in a directory with a package.json file.");t.info("Initializing a new Salty-CSS project!");const{dir:c=i,cssFile:u,skipInstall:g}=this.opts();if(!c)return h("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");g||await D(q.core,q.react);const f=process.cwd(),l=z(c),$=await Promise.all([j("salty.config.ts"),j("saltygen/index.css")]);await s.mkdir(l,{recursive:!0});const m=$.map(async({fileName:e,content:a})=>{const d=n.join(l,e);if(await s.readFile(d,"utf-8").catch(()=>{})!==void 0){t.debug("File already exists: "+d);return}const C=e.split("/").slice(0,-1).join("/");C&&await s.mkdir(n.join(l,C),{recursive:!0}),t.info("Creating file: "+d),await s.writeFile(d,a),await x(d)});await Promise.all(m);const J=n.relative(f,l)||".",v=n.join(f,".saltyrc"),r=await s.readFile(v,"utf-8").catch(()=>{});if(r===void 0){t.info("Creating file: "+v);const a=JSON.stringify({defaultProject:J,projects:[J]},null,2);await s.writeFile(v,a)}else{t.info("Edit file: "+v);const e=JSON.parse(r),a=new Set((e==null?void 0:e.projects)||[]);a.add(J),e.projects=[...a];const d=JSON.stringify(e,null,2);await s.writeFile(v,d)}const S=n.join(f,".gitignore"),T=await s.readFile(S,"utf-8").catch(()=>{});T!==void 0&&(T.includes("saltygen")||(t.info("Edit file: "+S),await s.writeFile(S,T+`
2
2
 
3
3
  # Salty-CSS
4
4
  saltygen
5
- `)));const v=["src","public","assets","styles","css","app"],z=["styles","css","app","pages"],G=["index","styles","main","global","globals"],R=[".css",".scss",".sass"],J=await(async()=>{if(u)return u;for(const e of v)for(const p of G)for(const d of R){const C=i.join(l,e,p+d);if(await s.readFile(C,"utf-8").catch(()=>{})!==void 0)return i.relative(l,C);for(const _ of z){const E=i.join(l,e,_,p+d);if(await s.readFile(E,"utf-8").catch(()=>{})!==void 0)return i.relative(l,E)}}})();if(J){const e=i.join(l,J),p=await s.readFile(e,"utf-8").catch(()=>{});if(p!==void 0&&!p.includes("saltygen")){const C=i.join(e,".."),_=`@import '${i.relative(C,i.join(l,"saltygen/index.css"))}';`;t.info("Adding global import statement to CSS file: "+e),await s.writeFile(e,_+`
6
- `+p),await I(e)}}else t.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");const T=i.join(l,"vite.config.ts"),W=await s.readFile(T,"utf-8").catch(()=>{});if(W!==void 0&&!W.includes("saltyPlugin")){t.info("Edit file: "+T);const p=`import { saltyPlugin } from '@salty-css/vite';
7
- `,C=W.replace(/(plugins: \[)/,`$1
8
- saltyPlugin(__dirname),`);g||await N(`-D ${A.vite}`),t.info("Adding Salty-CSS plugin to Vite config..."),await s.writeFile(T,p+C),await I(T)}const U=["next.config.js","next.config.cjs","next.config.ts","next.config.mjs"].map(e=>i.join(l,e)).find(e=>Q.existsSync(e));if(U){let e=await s.readFile(U,"utf-8").catch(()=>{});if(e!==void 0&&!e.includes("withSaltyCss")){let d=!1;/\splugins([^=]*)=[^[]\[/.test(e)&&!d&&(e=e.replace(/\splugins([^=]*)=[^[]\[/,(E,D)=>` plugins${D}= [withSaltyCss,`),d=!0);const P=e.includes("module.exports"),_=P?`const { withSaltyCss } = require('@salty-css/next');
5
+ `)));const P=["src","public","assets","styles","css","app"],G=["styles","css","app","pages"],W=["index","styles","main","global","globals"],U=[".css",".scss",".sass"],N=await(async()=>{if(u)return u;for(const e of P)for(const a of W)for(const d of U){const y=n.join(l,e,a+d);if(await s.readFile(y,"utf-8").catch(()=>{})!==void 0)return n.relative(l,y);for(const O of G){const A=n.join(l,e,O,a+d);if(await s.readFile(A,"utf-8").catch(()=>{})!==void 0)return n.relative(l,A)}}})();if(N){const e=n.join(l,N),a=await s.readFile(e,"utf-8").catch(()=>{});if(a!==void 0&&!a.includes("saltygen")){const y=n.join(e,".."),O=`@import '${n.relative(y,n.join(l,"saltygen/index.css"))}';`;t.info("Adding global import statement to CSS file: "+e),await s.writeFile(e,O+`
6
+ `+a),await x(e)}}else t.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");const X=n.join(f,".eslintrc.js"),ne=H.existsSync(X),Y=n.join(l,".eslintrc.js"),Z=H.existsSync(Y);if(ne||Z){g||await D(q.eslintConfigCore);const e=Z?Y:X,a=await s.readFile(e,"utf-8").catch(()=>{});if(!a)return h("Could not read ESLint config file.");if(!a.includes("salty-css")){const y=JSON.parse(a);t.info("Edit file: "+e),y.extends||(y.extends=[]),y.extends.push("@salty-css/core");const C=JSON.stringify(y,null,2);await s.writeFile(e,C),await x(e)}}const _=n.join(l,"vite.config.ts"),M=await s.readFile(_,"utf-8").catch(()=>{});if(M!==void 0&&!M.includes("saltyPlugin")){t.info("Edit file: "+_);const a=`import { saltyPlugin } from '@salty-css/vite';
7
+ `,y=M.replace(/(plugins: \[)/,`$1
8
+ saltyPlugin(__dirname),`);g||await D(`-D ${q.vite}`),t.info("Adding Salty-CSS plugin to Vite config..."),await s.writeFile(_,a+y),await x(_)}const R=["next.config.js","next.config.cjs","next.config.ts","next.config.mjs"].map(e=>n.join(l,e)).find(e=>H.existsSync(e));if(R){let e=await s.readFile(R,"utf-8").catch(()=>{});if(e!==void 0&&!e.includes("withSaltyCss")){let d=!1;/\splugins([^=]*)=[^[]\[/.test(e)&&!d&&(e=e.replace(/\splugins([^=]*)=[^[]\[/,(A,E)=>` plugins${E}= [withSaltyCss,`),d=!0);const C=e.includes("module.exports"),O=C?`const { withSaltyCss } = require('@salty-css/next');
9
9
  `:`import { withSaltyCss } from '@salty-css/next';
10
- `;P&&!d?(e=e.replace(/module.exports = ([^;]+)/,(E,D)=>`module.exports = withSaltyCss(${D})`),d=!0):d||(e=e.replace(/export default ([^;]+)/,(E,D)=>`export default withSaltyCss(${D})`)),g||await N(`-D ${A.next}`),t.info("Adding Salty-CSS plugin to Next.js config..."),await s.writeFile(U,_+e),await I(U)}}const Z=await q().catch(()=>m("Could not read package.json file.")).then(e=>(e.scripts||(e.scripts={}),e.scripts.prepare?e.scripts.prepare.includes("salty-css")||(t.info("Edit file: "+k),e.scripts.prepare=e.scripts.prepare+" && npx salty-css build"):(t.info("Edit file: "+k),e.scripts.prepare="npx salty-css build"),e));await Y(Z),t.info("🎉 Salty CSS project initialized successfully!"),t.info("Next steps:"),t.info("1. Configure variables and templates in `salty.config.ts`"),t.info("2. Create a new component with `npx salty-css generate [component-name]`"),t.info("3. Run `npx salty-css build` to generate the CSS"),t.info("4. Read about the features in the documentation: https://salty-css.dev"),t.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐")}),c.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>","Project directory to build the project in.").action(async function(n=V){t.info("Building the Salty-CSS project...");const{dir:a=n}=this.opts();if(!a)return m("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const r=H(a);await ne.generateCss(r)}),c.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>","File to generate.").option("-d, --dir <dir>","Project directory to generate the file in.").option("-t, --tag <tag>","HTML tag of the component.","div").option("-n, --name <name>","Name of the component.").option("-c, --className <className>","CSS class of the component.").option("-rc, --reactComponent <rc>","Generate a React component as well.").action(async function(n,a=V){const{file:r=n,dir:u=a,tag:g,name:f,className:l,reactComponent:b=!1}=this.opts();if(!r)return m("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!u)return m("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const y=H(u),$=r.split("/").slice(0,-1).join("/");$&&await s.mkdir(i.join(y,$),{recursive:!0});const j=i.join(y,r),o=i.parse(j);o.ext||(o.ext=".ts"),o.name.endsWith(".css")||(o.name=o.name+".css"),o.base=o.name+o.ext;const w=i.format(o);if(await s.readFile(w,"utf-8").catch(()=>{})!==void 0){t.error("File already exists:",w);return}let v=ie.pascalCase(f||o.base.replace(/\.css\.\w+$/,""));if(b){const G=v+"Component";v=v+"Wrapper";const R=o.base.replace(/\.css\.\w+$/,""),{content:K}=await S("react/react-vanilla-file.ts",{tag:g,componentName:G,styledComponentName:v,className:l,fileName:R});o.name=R.replace(/\.css$/,""),o.ext=".tsx",o.base=o.name+o.ext;const J=i.format(o);t.info("Generating a new file: "+J),await s.writeFile(J,K),await I(J)}const{content:z}=await S("react/react-styled-file.ts",{tag:g,name:v,className:l});t.info("Generating a new file: "+w),await s.writeFile(w,z),await I(w)}),c.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>","Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>","Use legacy peer dependencies (not recommended).",!1).action(async function(n="latest"){const{legacyPeerDeps:a,version:r=n}=this.opts(),u=i.join(process.cwd(),"package.json"),g=await q(u).catch(y=>m(y));if(!g)return;const f={...g.dependencies,...g.devDependencies},l=Object.keys(f).filter(y=>y==="salty-css"||y.startsWith("@salty-css/"));if(!l.length)return m("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+u);const b=l.map(y=>r==="@"?`${y}@${x.version}`:`${y}@${r.replace(/^@/,"")}`);a?(t.warn("Using legacy peer dependencies to update packages."),await N(...b,"--legacy-peer-deps")):await N(...b),t.info("Salty-CSS packages updated successfully!")}),c.option("-v, --version","Show the current version of Salty-CSS.").action(async function(){const n=await B();t.info("CLI is running: "+n.version);const a=i.join(process.cwd(),"package.json"),r=await q(a).catch(f=>m(f));if(!r)return;const u={...r.dependencies,...r.devDependencies},g=Object.keys(u).filter(f=>f==="salty-css"||f.startsWith("@salty-css/"));if(!g.length)return m("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+a);for(const f of g)t.info(`${f}: ${u[f]}`)}),c.parseAsync(process.argv)}exports.main=re;
10
+ `;C&&!d?(e=e.replace(/module.exports = ([^;]+)/,(A,E)=>`module.exports = withSaltyCss(${E})`),d=!0):d||(e=e.replace(/export default ([^;]+)/,(A,E)=>`export default withSaltyCss(${E})`)),g||await D(`-D ${q.next}`),t.info("Adding Salty-CSS plugin to Next.js config..."),await s.writeFile(R,O+e),await x(R)}}const ie=await I().catch(()=>h("Could not read package.json file.")).then(e=>(e.scripts||(e.scripts={}),e.scripts.prepare?e.scripts.prepare.includes("salty-css")||(t.info("Edit file: "+k),e.scripts.prepare=e.scripts.prepare+" && npx salty-css build"):(t.info("Edit file: "+k),e.scripts.prepare="npx salty-css build"),e));await te(ie),t.info("🎉 Salty CSS project initialized successfully!"),t.info("Next steps:"),t.info("1. Configure variables and templates in `salty.config.ts`"),t.info("2. Create a new component with `npx salty-css generate [component-name]`"),t.info("3. Run `npx salty-css build` to generate the CSS"),t.info("4. Read about the features in the documentation: https://salty-css.dev"),t.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐")}),p.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>","Project directory to build the project in.").action(async function(i=K){t.info("Building the Salty-CSS project...");const{dir:o=i}=this.opts();if(!o)return h("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const c=z(o);await oe.generateCss(c)}),p.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>","File to generate.").option("-d, --dir <dir>","Project directory to generate the file in.").option("-t, --tag <tag>","HTML tag of the component.","div").option("-n, --name <name>","Name of the component.").option("-c, --className <className>","CSS class of the component.").option("-rc, --reactComponent <rc>","Generate a React component as well.").action(async function(i,o=K){const{file:c=i,dir:u=o,tag:g,name:f,className:l,reactComponent:$=!1}=this.opts();if(!c)return h("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!u)return h("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const m=z(u),J=c.split("/").slice(0,-1).join("/");J&&await s.mkdir(n.join(m,J),{recursive:!0});const v=n.join(m,c),r=n.parse(v);r.ext||(r.ext=".ts"),r.name.endsWith(".css")||(r.name=r.name+".css"),r.base=r.name+r.ext;const S=n.format(r);if(await s.readFile(S,"utf-8").catch(()=>{})!==void 0){t.error("File already exists:",S);return}let P=re.pascalCase(f||r.base.replace(/\.css\.\w+$/,""));if($){const W=P+"Component";P=P+"Wrapper";const U=r.base.replace(/\.css\.\w+$/,""),{content:Q}=await j("react/react-vanilla-file.ts",{tag:g,componentName:W,styledComponentName:P,className:l,fileName:U});r.name=U.replace(/\.css$/,""),r.ext=".tsx",r.base=r.name+r.ext;const N=n.format(r);t.info("Generating a new file: "+N),await s.writeFile(N,Q),await x(N)}const{content:G}=await j("react/react-styled-file.ts",{tag:g,name:P,className:l});t.info("Generating a new file: "+S),await s.writeFile(S,G),await x(S)}),p.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>","Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>","Use legacy peer dependencies (not recommended).",!1).action(async function(i="latest"){const{legacyPeerDeps:o,version:c=i}=this.opts(),u=n.join(process.cwd(),"package.json"),g=await I(u).catch(m=>h(m));if(!g)return;const f={...g.dependencies,...g.devDependencies},l=Object.keys(f).filter(m=>m==="salty-css"||m.startsWith("@salty-css/"));if(!l.length)return h("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+u);const $=l.map(m=>c==="@"?`${m}@${b.version}`:`${m}@${c.replace(/^@/,"")}`);o?(t.warn("Using legacy peer dependencies to update packages."),await D(...$,"--legacy-peer-deps")):await D(...$),t.info("Salty-CSS packages updated successfully!")}),p.option("-v, --version","Show the current version of Salty-CSS.").action(async function(){const i=await V();t.info("CLI is running: "+i.version);const o=n.join(process.cwd(),"package.json"),c=await I(o).catch(f=>h(f));if(!c)return;const u={...c.dependencies,...c.devDependencies},g=Object.keys(u).filter(f=>f==="salty-css"||f.startsWith("@salty-css/"));if(!g.length)return h("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+o);for(const f of g)t.info(`${f}: ${u[f]}`)}),p.parseAsync(process.argv)}exports.main=pe;
package/bin/main.js CHANGED
@@ -1,219 +1,232 @@
1
- import { Command as at } from "commander";
2
- import { existsSync as Z } from "fs";
3
- import { mkdir as B, readFile as m, writeFile as y } from "fs/promises";
4
- import { join as o, relative as z, parse as nt, format as Y } from "path";
5
- import { render as it } from "ejs";
6
- import { generateCss as ot } from "../compiler/index.js";
7
- import { p as rt } from "../pascal-case-BQpR5PdN.js";
8
- import { createLogger as ct, format as V, transports as lt } from "winston";
9
- import { exec as pt } from "child_process";
10
- import dt from "ora";
11
- const e = ct({
1
+ import { Command as rt } from "commander";
2
+ import { existsSync as G } from "fs";
3
+ import { mkdir as V, readFile as y, writeFile as h } from "fs/promises";
4
+ import { join as a, relative as z, parse as ct, format as nt } from "path";
5
+ import { render as lt } from "ejs";
6
+ import { generateCss as dt } from "../compiler/index.js";
7
+ import { p as pt } from "../pascal-case-BQpR5PdN.js";
8
+ import { createLogger as ft, format as K, transports as gt } from "winston";
9
+ import { exec as ut } from "child_process";
10
+ import mt from "ora";
11
+ const e = ft({
12
12
  level: "debug",
13
- format: V.combine(V.colorize(), V.cli()),
14
- transports: [new lt.Console({})]
15
- }), h = (r) => {
16
- e.error(r);
17
- }, tt = (r) => new Promise((w, C) => {
18
- pt(r, (x) => {
19
- if (x) return C(x);
20
- w();
13
+ format: K.combine(K.colorize(), K.cli()),
14
+ transports: [new gt.Console({})]
15
+ }), w = (d) => {
16
+ e.error(d);
17
+ }, st = (d) => new Promise((C, P) => {
18
+ ut(d, (b) => {
19
+ if (b) return P(b);
20
+ C();
21
21
  });
22
- }), I = async (...r) => {
23
- const w = r.map((b) => b.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), C = dt(`Installing packages: ${w}`).start(), x = r.join(" ");
24
- await tt(`npm install ${x}`), C.succeed(`Installed packages: ${w}`);
25
- }, ft = () => Z(o(process.cwd(), "node_modules", ".bin", "prettier"));
26
- async function A(r) {
22
+ }), I = async (...d) => {
23
+ const C = d.map((F) => F.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), P = mt(`Installing packages: ${C}`).start(), b = d.join(" ");
24
+ await st(`npm install ${b}`), P.succeed(`Installed packages: ${C}`);
25
+ }, yt = () => G(a(process.cwd(), "node_modules", ".bin", "prettier"));
26
+ async function k(d) {
27
27
  try {
28
- if (!ft()) return;
29
- await tt(`./node_modules/.bin/prettier --write "${r}"`), e.info(`Formatted ${r} with Prettier`);
30
- } catch (w) {
31
- e.error(`Error formatting ${r} with Prettier:`, w);
28
+ if (!yt()) return;
29
+ await st(`./node_modules/.bin/prettier --write "${d}"`), e.info(`Formatted ${d} with Prettier`);
30
+ } catch (C) {
31
+ e.error(`Error formatting ${d} with Prettier:`, C);
32
32
  }
33
33
  }
34
- async function xt() {
35
- const r = new at();
36
- r.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
37
- const w = {
34
+ async function Jt() {
35
+ const d = new rt();
36
+ d.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
37
+ const C = {
38
38
  // Core files
39
39
  "salty.config.ts": import("../salty.config-BhBY_oOk.js"),
40
40
  "saltygen/index.css": import("../index-D_732b92.js"),
41
41
  // React
42
42
  "react/react-styled-file.ts": import("../react-styled-file-CGVf5n1B.js"),
43
43
  "react/react-vanilla-file.ts": import("../react-vanilla-file-CCXbsjIb.js")
44
- }, C = async (s, a) => {
45
- const { default: i } = await w[s], f = it(i, a);
46
- return { fileName: s, content: f };
47
- }, x = async () => {
48
- const s = o(process.cwd(), ".saltyrc");
49
- return await m(s, "utf-8").then(JSON.parse).catch(() => ({}));
50
- }, b = o(process.cwd(), "package.json"), E = async (s = b) => {
51
- const a = await m(s, "utf-8").then(JSON.parse).catch(() => {
44
+ }, P = async (n, i) => {
45
+ const { default: r } = await C[n], f = lt(r, i);
46
+ return { fileName: n, content: f };
47
+ }, b = async () => {
48
+ const n = a(process.cwd(), ".saltyrc");
49
+ return await y(n, "utf-8").then(JSON.parse).catch(() => ({}));
50
+ }, F = a(process.cwd(), "package.json"), A = async (n = F) => {
51
+ const i = await y(n, "utf-8").then(JSON.parse).catch(() => {
52
52
  });
53
- if (!a) throw "Could not read package.json file!";
54
- return a;
55
- }, et = async (s, a = b) => {
56
- typeof s == "object" && (s = JSON.stringify(s, null, 2)), await y(a, s);
57
- }, K = async () => {
58
- const s = new URL("../package.json", import.meta.url);
59
- return E(s);
60
- }, Q = await (async () => (await x()).defaultProject)(), F = await K(), O = {
61
- core: `@salty-css/core@${F.version}`,
62
- react: `@salty-css/react@${F.version}`,
63
- eslintPluginCore: `@salty-css/eslint-plugin-core@${F.version}`,
64
- vite: `@salty-css/vite@${F.version}`,
65
- next: `@salty-css/next@${F.version}`
66
- }, G = (s) => {
67
- const a = s === "." ? "" : s, i = process.cwd();
68
- return o(i, a);
53
+ if (!i) throw "Could not read package.json file!";
54
+ return i;
55
+ }, at = async (n, i = F) => {
56
+ typeof n == "object" && (n = JSON.stringify(n, null, 2)), await h(i, n);
57
+ }, Q = async () => {
58
+ const n = new URL("../package.json", import.meta.url);
59
+ return A(n);
60
+ }, X = await (async () => (await b()).defaultProject)(), $ = await Q(), O = {
61
+ core: `@salty-css/core@${$.version}`,
62
+ react: `@salty-css/react@${$.version}`,
63
+ eslintConfigCore: `@salty-css/eslint-config-core@${$.version}`,
64
+ vite: `@salty-css/vite@${$.version}`,
65
+ next: `@salty-css/next@${$.version}`
66
+ }, W = (n) => {
67
+ const i = n === "." ? "" : n, r = process.cwd();
68
+ return a(r, i);
69
69
  };
70
- r.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>", "Project directory to initialize the project in.").option("--css-file <css-file>", "Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install", "Skip installing dependencies.").action(async function(s = ".") {
71
- if (!await E().catch(() => {
72
- })) return h("Salty CSS project must be initialized in a directory with a package.json file.");
70
+ d.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>", "Project directory to initialize the project in.").option("--css-file <css-file>", "Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install", "Skip installing dependencies.").action(async function(n = ".") {
71
+ if (!await A().catch(() => {
72
+ })) return w("Salty CSS project must be initialized in a directory with a package.json file.");
73
73
  e.info("Initializing a new Salty-CSS project!");
74
- const { dir: i = s, cssFile: f, skipInstall: g } = this.opts();
75
- if (!i) return h("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
76
- g || (await I(O.core, O.react), await I(`-D ${O.eslintPluginCore}`));
77
- const d = process.cwd(), c = G(i), $ = await Promise.all([C("salty.config.ts"), C("saltygen/index.css")]);
78
- await B(c, { recursive: !0 });
79
- const u = $.map(async ({ fileName: t, content: p }) => {
80
- const l = o(c, t);
81
- if (await m(l, "utf-8").catch(() => {
74
+ const { dir: r = n, cssFile: f, skipInstall: g } = this.opts();
75
+ if (!r) return w("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
76
+ g || await I(O.core, O.react);
77
+ const p = process.cwd(), c = W(r), J = await Promise.all([P("salty.config.ts"), P("saltygen/index.css")]);
78
+ await V(c, { recursive: !0 });
79
+ const m = J.map(async ({ fileName: t, content: s }) => {
80
+ const l = a(c, t);
81
+ if (await y(l, "utf-8").catch(() => {
82
82
  }) !== void 0) {
83
83
  e.debug("File already exists: " + l);
84
84
  return;
85
85
  }
86
- const k = t.split("/").slice(0, -1).join("/");
87
- k && await B(o(c, k), { recursive: !0 }), e.info("Creating file: " + l), await y(l, p), await A(l);
86
+ const v = t.split("/").slice(0, -1).join("/");
87
+ v && await V(a(c, v), { recursive: !0 }), e.info("Creating file: " + l), await h(l, s), await k(l);
88
88
  });
89
- await Promise.all(u);
90
- const J = z(d, c) || ".", P = o(d, ".saltyrc"), n = await m(P, "utf-8").catch(() => {
89
+ await Promise.all(m);
90
+ const N = z(p, c) || ".", j = a(p, ".saltyrc"), o = await y(j, "utf-8").catch(() => {
91
91
  });
92
- if (n === void 0) {
93
- e.info("Creating file: " + P);
94
- const p = JSON.stringify({
95
- defaultProject: J,
96
- projects: [J]
92
+ if (o === void 0) {
93
+ e.info("Creating file: " + j);
94
+ const s = JSON.stringify({
95
+ defaultProject: N,
96
+ projects: [N]
97
97
  }, null, 2);
98
- await y(P, p);
98
+ await h(j, s);
99
99
  } else {
100
- e.info("Edit file: " + P);
101
- const t = JSON.parse(n), p = new Set((t == null ? void 0 : t.projects) || []);
102
- p.add(J), t.projects = [...p];
100
+ e.info("Edit file: " + j);
101
+ const t = JSON.parse(o), s = new Set((t == null ? void 0 : t.projects) || []);
102
+ s.add(N), t.projects = [...s];
103
103
  const l = JSON.stringify(t, null, 2);
104
- await y(P, l);
104
+ await h(j, l);
105
105
  }
106
- const S = o(d, ".gitignore"), T = await m(S, "utf-8").catch(() => {
106
+ const S = a(p, ".gitignore"), T = await y(S, "utf-8").catch(() => {
107
107
  });
108
- T !== void 0 && (T.includes("saltygen") || (e.info("Edit file: " + S), await y(S, T + `
108
+ T !== void 0 && (T.includes("saltygen") || (e.info("Edit file: " + S), await h(S, T + `
109
109
 
110
110
  # Salty-CSS
111
111
  saltygen
112
112
  `)));
113
- const j = ["src", "public", "assets", "styles", "css", "app"], W = ["styles", "css", "app", "pages"], M = ["index", "styles", "main", "global", "globals"], R = [".css", ".scss", ".sass"], D = await (async () => {
113
+ const x = ["src", "public", "assets", "styles", "css", "app"], M = ["styles", "css", "app", "pages"], q = ["index", "styles", "main", "global", "globals"], U = [".css", ".scss", ".sass"], E = await (async () => {
114
114
  if (f) return f;
115
- for (const t of j)
116
- for (const p of M)
117
- for (const l of R) {
118
- const v = o(c, t, p + l);
119
- if (await m(v, "utf-8").catch(() => {
120
- }) !== void 0) return z(c, v);
121
- for (const L of W) {
122
- const H = o(c, t, L, p + l);
123
- if (await m(H, "utf-8").catch(() => {
124
- }) !== void 0) return z(c, H);
115
+ for (const t of x)
116
+ for (const s of q)
117
+ for (const l of U) {
118
+ const u = a(c, t, s + l);
119
+ if (await y(u, "utf-8").catch(() => {
120
+ }) !== void 0) return z(c, u);
121
+ for (const H of M) {
122
+ const L = a(c, t, H, s + l);
123
+ if (await y(L, "utf-8").catch(() => {
124
+ }) !== void 0) return z(c, L);
125
125
  }
126
126
  }
127
127
  })();
128
- if (D) {
129
- const t = o(c, D), p = await m(t, "utf-8").catch(() => {
128
+ if (E) {
129
+ const t = a(c, E), s = await y(t, "utf-8").catch(() => {
130
130
  });
131
- if (p !== void 0 && !p.includes("saltygen")) {
132
- const v = o(t, ".."), L = `@import '${z(v, o(c, "saltygen/index.css"))}';`;
133
- e.info("Adding global import statement to CSS file: " + t), await y(t, L + `
134
- ` + p), await A(t);
131
+ if (s !== void 0 && !s.includes("saltygen")) {
132
+ const u = a(t, ".."), H = `@import '${z(u, a(c, "saltygen/index.css"))}';`;
133
+ e.info("Adding global import statement to CSS file: " + t), await h(t, H + `
134
+ ` + s), await k(t);
135
135
  }
136
136
  } else
137
137
  e.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");
138
- const U = o(c, "vite.config.ts"), q = await m(U, "utf-8").catch(() => {
138
+ const Z = a(p, ".eslintrc.js"), it = G(Z), tt = a(c, ".eslintrc.js"), et = G(tt);
139
+ if (it || et) {
140
+ g || await I(O.eslintConfigCore);
141
+ const t = et ? tt : Z, s = await y(t, "utf-8").catch(() => {
142
+ });
143
+ if (!s) return w("Could not read ESLint config file.");
144
+ if (!s.includes("salty-css")) {
145
+ const u = JSON.parse(s);
146
+ e.info("Edit file: " + t), u.extends || (u.extends = []), u.extends.push("@salty-css/core");
147
+ const v = JSON.stringify(u, null, 2);
148
+ await h(t, v), await k(t);
149
+ }
150
+ }
151
+ const R = a(c, "vite.config.ts"), B = await y(R, "utf-8").catch(() => {
139
152
  });
140
- if (q !== void 0 && !q.includes("saltyPlugin")) {
141
- e.info("Edit file: " + U);
142
- const p = `import { saltyPlugin } from '@salty-css/vite';
143
- `, v = q.replace(/(plugins: \[)/, `$1
153
+ if (B !== void 0 && !B.includes("saltyPlugin")) {
154
+ e.info("Edit file: " + R);
155
+ const s = `import { saltyPlugin } from '@salty-css/vite';
156
+ `, u = B.replace(/(plugins: \[)/, `$1
144
157
  saltyPlugin(__dirname),`);
145
- g || await I(`-D ${O.vite}`), e.info("Adding Salty-CSS plugin to Vite config..."), await y(U, p + v), await A(U);
158
+ g || await I(`-D ${O.vite}`), e.info("Adding Salty-CSS plugin to Vite config..."), await h(R, s + u), await k(R);
146
159
  }
147
- const _ = ["next.config.js", "next.config.cjs", "next.config.ts", "next.config.mjs"].map((t) => o(c, t)).find((t) => Z(t));
160
+ const _ = ["next.config.js", "next.config.cjs", "next.config.ts", "next.config.mjs"].map((t) => a(c, t)).find((t) => G(t));
148
161
  if (_) {
149
- let t = await m(_, "utf-8").catch(() => {
162
+ let t = await y(_, "utf-8").catch(() => {
150
163
  });
151
164
  if (t !== void 0 && !t.includes("withSaltyCss")) {
152
165
  let l = !1;
153
- /\splugins([^=]*)=[^[]\[/.test(t) && !l && (t = t.replace(/\splugins([^=]*)=[^[]\[/, (H, N) => ` plugins${N}= [withSaltyCss,`), l = !0);
154
- const k = t.includes("module.exports"), L = k ? `const { withSaltyCss } = require('@salty-css/next');
166
+ /\splugins([^=]*)=[^[]\[/.test(t) && !l && (t = t.replace(/\splugins([^=]*)=[^[]\[/, (L, D) => ` plugins${D}= [withSaltyCss,`), l = !0);
167
+ const v = t.includes("module.exports"), H = v ? `const { withSaltyCss } = require('@salty-css/next');
155
168
  ` : `import { withSaltyCss } from '@salty-css/next';
156
169
  `;
157
- k && !l ? (t = t.replace(/module.exports = ([^;]+)/, (H, N) => `module.exports = withSaltyCss(${N})`), l = !0) : l || (t = t.replace(/export default ([^;]+)/, (H, N) => `export default withSaltyCss(${N})`)), g || await I(`-D ${O.next}`), e.info("Adding Salty-CSS plugin to Next.js config..."), await y(_, L + t), await A(_);
170
+ v && !l ? (t = t.replace(/module.exports = ([^;]+)/, (L, D) => `module.exports = withSaltyCss(${D})`), l = !0) : l || (t = t.replace(/export default ([^;]+)/, (L, D) => `export default withSaltyCss(${D})`)), g || await I(`-D ${O.next}`), e.info("Adding Salty-CSS plugin to Next.js config..."), await h(_, H + t), await k(_);
158
171
  }
159
172
  }
160
- const st = await E().catch(() => h("Could not read package.json file.")).then((t) => (t.scripts || (t.scripts = {}), t.scripts.prepare ? t.scripts.prepare.includes("salty-css") || (e.info("Edit file: " + b), t.scripts.prepare = t.scripts.prepare + " && npx salty-css build") : (e.info("Edit file: " + b), t.scripts.prepare = "npx salty-css build"), t));
161
- await et(st), e.info("🎉 Salty CSS project initialized successfully!"), e.info("Next steps:"), e.info("1. Configure variables and templates in `salty.config.ts`"), e.info("2. Create a new component with `npx salty-css generate [component-name]`"), e.info("3. Run `npx salty-css build` to generate the CSS"), e.info("4. Read about the features in the documentation: https://salty-css.dev"), e.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐");
162
- }), r.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").action(async function(s = Q) {
173
+ const ot = await A().catch(() => w("Could not read package.json file.")).then((t) => (t.scripts || (t.scripts = {}), t.scripts.prepare ? t.scripts.prepare.includes("salty-css") || (e.info("Edit file: " + F), t.scripts.prepare = t.scripts.prepare + " && npx salty-css build") : (e.info("Edit file: " + F), t.scripts.prepare = "npx salty-css build"), t));
174
+ await at(ot), e.info("🎉 Salty CSS project initialized successfully!"), e.info("Next steps:"), e.info("1. Configure variables and templates in `salty.config.ts`"), e.info("2. Create a new component with `npx salty-css generate [component-name]`"), e.info("3. Run `npx salty-css build` to generate the CSS"), e.info("4. Read about the features in the documentation: https://salty-css.dev"), e.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐");
175
+ }), d.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").action(async function(n = X) {
163
176
  e.info("Building the Salty-CSS project...");
164
- const { dir: a = s } = this.opts();
165
- if (!a) return h("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
166
- const i = G(a);
167
- await ot(i);
168
- }), r.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>", "File to generate.").option("-d, --dir <dir>", "Project directory to generate the file in.").option("-t, --tag <tag>", "HTML tag of the component.", "div").option("-n, --name <name>", "Name of the component.").option("-c, --className <className>", "CSS class of the component.").option("-rc, --reactComponent <rc>", "Generate a React component as well.").action(async function(s, a = Q) {
169
- const { file: i = s, dir: f = a, tag: g, name: d, className: c, reactComponent: $ = !1 } = this.opts();
170
- if (!i) return h("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
171
- if (!f) return h("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
172
- const u = G(f), J = i.split("/").slice(0, -1).join("/");
173
- J && await B(o(u, J), { recursive: !0 });
174
- const P = o(u, i), n = nt(P);
175
- n.ext || (n.ext = ".ts"), n.name.endsWith(".css") || (n.name = n.name + ".css"), n.base = n.name + n.ext;
176
- const S = Y(n);
177
- if (await m(S, "utf-8").catch(() => {
177
+ const { dir: i = n } = this.opts();
178
+ if (!i) return w("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
179
+ const r = W(i);
180
+ await dt(r);
181
+ }), d.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>", "File to generate.").option("-d, --dir <dir>", "Project directory to generate the file in.").option("-t, --tag <tag>", "HTML tag of the component.", "div").option("-n, --name <name>", "Name of the component.").option("-c, --className <className>", "CSS class of the component.").option("-rc, --reactComponent <rc>", "Generate a React component as well.").action(async function(n, i = X) {
182
+ const { file: r = n, dir: f = i, tag: g, name: p, className: c, reactComponent: J = !1 } = this.opts();
183
+ if (!r) return w("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
184
+ if (!f) return w("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
185
+ const m = W(f), N = r.split("/").slice(0, -1).join("/");
186
+ N && await V(a(m, N), { recursive: !0 });
187
+ const j = a(m, r), o = ct(j);
188
+ o.ext || (o.ext = ".ts"), o.name.endsWith(".css") || (o.name = o.name + ".css"), o.base = o.name + o.ext;
189
+ const S = nt(o);
190
+ if (await y(S, "utf-8").catch(() => {
178
191
  }) !== void 0) {
179
192
  e.error("File already exists:", S);
180
193
  return;
181
194
  }
182
- let j = rt(d || n.base.replace(/\.css\.\w+$/, ""));
183
- if ($) {
184
- const M = j + "Component";
185
- j = j + "Wrapper";
186
- const R = n.base.replace(/\.css\.\w+$/, ""), { content: X } = await C("react/react-vanilla-file.ts", { tag: g, componentName: M, styledComponentName: j, className: c, fileName: R });
187
- n.name = R.replace(/\.css$/, ""), n.ext = ".tsx", n.base = n.name + n.ext;
188
- const D = Y(n);
189
- e.info("Generating a new file: " + D), await y(D, X), await A(D);
195
+ let x = pt(p || o.base.replace(/\.css\.\w+$/, ""));
196
+ if (J) {
197
+ const q = x + "Component";
198
+ x = x + "Wrapper";
199
+ const U = o.base.replace(/\.css\.\w+$/, ""), { content: Y } = await P("react/react-vanilla-file.ts", { tag: g, componentName: q, styledComponentName: x, className: c, fileName: U });
200
+ o.name = U.replace(/\.css$/, ""), o.ext = ".tsx", o.base = o.name + o.ext;
201
+ const E = nt(o);
202
+ e.info("Generating a new file: " + E), await h(E, Y), await k(E);
190
203
  }
191
- const { content: W } = await C("react/react-styled-file.ts", { tag: g, name: j, className: c });
192
- e.info("Generating a new file: " + S), await y(S, W), await A(S);
193
- }), r.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>", "Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", !1).action(async function(s = "latest") {
194
- const { legacyPeerDeps: a, version: i = s } = this.opts(), f = o(process.cwd(), "package.json"), g = await E(f).catch((u) => h(u));
204
+ const { content: M } = await P("react/react-styled-file.ts", { tag: g, name: x, className: c });
205
+ e.info("Generating a new file: " + S), await h(S, M), await k(S);
206
+ }), d.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>", "Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", !1).action(async function(n = "latest") {
207
+ const { legacyPeerDeps: i, version: r = n } = this.opts(), f = a(process.cwd(), "package.json"), g = await A(f).catch((m) => w(m));
195
208
  if (!g) return;
196
- const d = { ...g.dependencies, ...g.devDependencies }, c = Object.keys(d).filter((u) => u === "salty-css" || u.startsWith("@salty-css/"));
209
+ const p = { ...g.dependencies, ...g.devDependencies }, c = Object.keys(p).filter((m) => m === "salty-css" || m.startsWith("@salty-css/"));
197
210
  if (!c.length)
198
- return h(
211
+ return w(
199
212
  "No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + f
200
213
  );
201
- const $ = c.map((u) => i === "@" ? `${u}@${F.version}` : `${u}@${i.replace(/^@/, "")}`);
202
- a ? (e.warn("Using legacy peer dependencies to update packages."), await I(...$, "--legacy-peer-deps")) : await I(...$), e.info("Salty-CSS packages updated successfully!");
203
- }), r.option("-v, --version", "Show the current version of Salty-CSS.").action(async function() {
204
- const s = await K();
205
- e.info("CLI is running: " + s.version);
206
- const a = o(process.cwd(), "package.json"), i = await E(a).catch((d) => h(d));
207
- if (!i) return;
208
- const f = { ...i.dependencies, ...i.devDependencies }, g = Object.keys(f).filter((d) => d === "salty-css" || d.startsWith("@salty-css/"));
214
+ const J = c.map((m) => r === "@" ? `${m}@${$.version}` : `${m}@${r.replace(/^@/, "")}`);
215
+ i ? (e.warn("Using legacy peer dependencies to update packages."), await I(...J, "--legacy-peer-deps")) : await I(...J), e.info("Salty-CSS packages updated successfully!");
216
+ }), d.option("-v, --version", "Show the current version of Salty-CSS.").action(async function() {
217
+ const n = await Q();
218
+ e.info("CLI is running: " + n.version);
219
+ const i = a(process.cwd(), "package.json"), r = await A(i).catch((p) => w(p));
220
+ if (!r) return;
221
+ const f = { ...r.dependencies, ...r.devDependencies }, g = Object.keys(f).filter((p) => p === "salty-css" || p.startsWith("@salty-css/"));
209
222
  if (!g.length)
210
- return h(
211
- "No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + a
223
+ return w(
224
+ "No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + i
212
225
  );
213
- for (const d of g)
214
- e.info(`${d}: ${f[d]}`);
215
- }), r.parseAsync(process.argv);
226
+ for (const p of g)
227
+ e.info(`${p}: ${f[p]}`);
228
+ }), d.parseAsync(process.argv);
216
229
  }
217
230
  export {
218
- xt as main
231
+ Jt as main
219
232
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.78",
3
+ "version": "0.0.1-alpha.79",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",