@salty-css/core 0.0.1-alpha.22 → 0.0.1-alpha.24

Sign up to get free protection for your applications and to get access to all the features.
package/bin/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";const E=require("commander"),n=require("fs/promises"),t=require("path"),L=require("ejs"),O=require("../compiler/index.cjs"),R=require("../pascal-case-iWoaJWwT.cjs"),j=require("winston"),T=require("fs"),U=require("child_process"),z=require("ora");var k=typeof document<"u"?document.currentScript:null;const a=j.createLogger({level:"debug",format:j.format.combine(j.format.colorize(),j.format.cli()),transports:[new j.transports.Console({})]}),N=i=>new Promise((d,g)=>{U.exec(i,m=>{if(m)return g(m);d()})}),J=async(...i)=>{const d=i.map(x=>x.replace("-D","").split("@").slice(0,-1).join("@").trim()),g=z(`Installing packages: ${d.join(",")}`).start(),m=i.join(" ");await N(`npm install ${m}`),g.succeed(`Installed packages: ${d.join(",")}`)},A=()=>T.existsSync(t.join(process.cwd(),"node_modules",".bin","prettier"));async function F(i){try{if(!A())return;await N(`./node_modules/.bin/prettier --write "${i}"`),a.info(`Formatted ${i} with Prettier`)}catch(d){a.error(`Error formatting ${i} with Prettier:`,d)}}async function H(){const i=new E.Command;i.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const d={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-BupieCfE.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"))},g=async(s,l)=>{const{default:f}=await d[s],c=L.render(f,l);return{fileName:s,content:c}},m=async()=>{const s=t.join(process.cwd(),".saltyrc");return await n.readFile(s,"utf-8").then(JSON.parse).catch(()=>({}))},x=async()=>{const s=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:k&&k.tagName.toUpperCase()==="SCRIPT"&&k.src||new URL("bin/index.cjs",document.baseURI).href);return await n.readFile(s,"utf-8").then(JSON.parse).catch(()=>({}))},_=await(async()=>(await m()).defaultProject)(),S=await x(),P={core:`@salty-css/core@${S.version}`,react:`@salty-css/react@${S.version}`,eslintPluginCore:`@salty-css/eslint-plugin-core@${S.version}`,vite:`@salty-css/vite@${S.version}`};i.command("init").description("Initialize a new Salty-CSS project.").requiredOption("-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.").action(async function(){await J(P.core,P.react),await J(`-D ${P.eslintPluginCore}`),a.info("Initializing a new Salty-CSS project...");const{dir:s,cssFile:l}=this.opts(),f=process.cwd(),c=t.join(f,s),I=await Promise.all([g("salty.config.ts"),g("saltygen/index.css")]);await n.mkdir(c,{recursive:!0});const q=I.map(async({fileName:e,content:r})=>{const p=t.join(c,e);if(await n.readFile(p,"utf-8").catch(()=>{})!==void 0){a.debug("File already exists: "+p);return}const b=e.split("/").slice(0,-1).join("/");b&&await n.mkdir(t.join(c,b),{recursive:!0}),a.info("Writing file: "+p),await n.writeFile(p,r),await F(p)});await Promise.all(q);const w=t.relative(f,c),o=t.join(f,".saltyrc"),u=await n.readFile(o,"utf-8").catch(()=>{});if(u===void 0){a.info("Creating file: "+o);const r=JSON.stringify({defaultProject:w,projects:[w]},null,2);await n.writeFile(o,r)}else{a.info("Edit file: "+o);const e=JSON.parse(u),r=new Set((e==null?void 0:e.projects)||[]);r.add(w),e.projects=[...r];const p=JSON.stringify(e,null,2);await n.writeFile(o,p)}const v=t.join(f,".gitignore"),h=await n.readFile(v,"utf-8").catch(()=>{});if(h!==void 0&&(h.includes("saltygen")||(a.info("Edit file: "+v),await n.writeFile(v,h+`
2
+ "use strict";const E=require("commander"),n=require("fs/promises"),t=require("path"),L=require("ejs"),O=require("../compiler/index.cjs"),R=require("../pascal-case-iWoaJWwT.cjs"),j=require("winston"),T=require("fs"),U=require("child_process"),z=require("ora");var k=typeof document<"u"?document.currentScript:null;const a=j.createLogger({level:"debug",format:j.format.combine(j.format.colorize(),j.format.cli()),transports:[new j.transports.Console({})]}),N=i=>new Promise((d,g)=>{U.exec(i,m=>{if(m)return g(m);d()})}),J=async(...i)=>{const d=i.map(x=>x.replace("-D","").split("@").slice(0,-1).join("@").trim()),g=z(`Installing packages: ${d.join(", ")}`).start(),m=i.join(" ");await N(`npm install ${m}`),g.succeed(`Installed packages: ${d.join(",")}`)},A=()=>T.existsSync(t.join(process.cwd(),"node_modules",".bin","prettier"));async function F(i){try{if(!A())return;await N(`./node_modules/.bin/prettier --write "${i}"`),a.info(`Formatted ${i} with Prettier`)}catch(d){a.error(`Error formatting ${i} with Prettier:`,d)}}async function H(){const i=new E.Command;i.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const d={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-BupieCfE.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"))},g=async(s,l)=>{const{default:f}=await d[s],c=L.render(f,l);return{fileName:s,content:c}},m=async()=>{const s=t.join(process.cwd(),".saltyrc");return await n.readFile(s,"utf-8").then(JSON.parse).catch(()=>({}))},x=async()=>{const s=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:k&&k.tagName.toUpperCase()==="SCRIPT"&&k.src||new URL("bin/index.cjs",document.baseURI).href);return await n.readFile(s,"utf-8").then(JSON.parse).catch(()=>({}))},_=await(async()=>(await m()).defaultProject)(),S=await x(),P={core:`@salty-css/core@${S.version}`,react:`@salty-css/react@${S.version}`,eslintPluginCore:`@salty-css/eslint-plugin-core@${S.version}`,vite:`@salty-css/vite@${S.version}`};i.command("init").description("Initialize a new Salty-CSS project.").requiredOption("-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.").action(async function(){await J(P.core,P.react),await J(`-D ${P.eslintPluginCore}`),a.info("Initializing a new Salty-CSS project...");const{dir:s,cssFile:l}=this.opts(),f=process.cwd(),c=t.join(f,s),I=await Promise.all([g("salty.config.ts"),g("saltygen/index.css")]);await n.mkdir(c,{recursive:!0});const q=I.map(async({fileName:e,content:r})=>{const p=t.join(c,e);if(await n.readFile(p,"utf-8").catch(()=>{})!==void 0){a.debug("File already exists: "+p);return}const b=e.split("/").slice(0,-1).join("/");b&&await n.mkdir(t.join(c,b),{recursive:!0}),a.info("Writing file: "+p),await n.writeFile(p,r),await F(p)});await Promise.all(q);const w=t.relative(f,c),o=t.join(f,".saltyrc"),u=await n.readFile(o,"utf-8").catch(()=>{});if(u===void 0){a.info("Creating file: "+o);const r=JSON.stringify({defaultProject:w,projects:[w]},null,2);await n.writeFile(o,r)}else{a.info("Edit file: "+o);const e=JSON.parse(u),r=new Set((e==null?void 0:e.projects)||[]);r.add(w),e.projects=[...r];const p=JSON.stringify(e,null,2);await n.writeFile(o,p)}const v=t.join(f,".gitignore"),h=await n.readFile(v,"utf-8").catch(()=>{});if(h!==void 0&&(h.includes("saltygen")||(a.info("Edit file: "+v),await n.writeFile(v,h+`
3
3
 
4
4
  # Salty-CSS
5
5
  saltygen
package/bin/index.js CHANGED
@@ -19,7 +19,7 @@ const i = G({
19
19
  l();
20
20
  });
21
21
  }), D = async (...e) => {
22
- const l = e.map((F) => F.replace("-D", "").split("@").slice(0, -1).join("@").trim()), m = U(`Installing packages: ${l.join(",")}`).start(), u = e.join(" ");
22
+ const l = e.map((F) => F.replace("-D", "").split("@").slice(0, -1).join("@").trim()), m = U(`Installing packages: ${l.join(", ")}`).start(), u = e.join(" ");
23
23
  await _(`npm install ${u}`), m.succeed(`Installed packages: ${l.join(",")}`);
24
24
  }, V = () => q(o(process.cwd(), "node_modules", ".bin", "prettier"));
25
25
  async function x(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.22",
3
+ "version": "0.0.1-alpha.24",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -26,6 +26,7 @@
26
26
  "commander": ">=12.x",
27
27
  "ejs": ">=3.x",
28
28
  "esbuild": ">=0.21.x",
29
+ "ora": ">=8.x",
29
30
  "react": ">=18.x || >=19.x",
30
31
  "winston": ">=3.x"
31
32
  },