@salty-css/core 0.0.1-alpha.19 → 0.0.1-alpha.20

Sign up to get free protection for your applications and to get access to all the features.
package/bin/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- "use strict";const S=require("commander"),c=require("fs/promises"),g=require("path"),Q=require("ejs"),j=require("../compiler/index.cjs"),z=require("../pascal-case-iWoaJWwT.cjs"),W=require("winston"),k=require("fs"),L=require("child_process");var H=typeof document<"u"?document.currentScript:null;const l=W.createLogger({level:"debug",format:W.format.combine(W.format.colorize(),W.format.cli()),transports:[new W.transports.Console({})]}),v=n=>new Promise((e,A)=>{L.exec(n,p=>{if(p)return A(p);e()})}),X=async(...n)=>{const e=n.join(" ");await v(`npm install ${e}`)},U=()=>k.existsSync(g.join(process.cwd(),"node_modules",".bin","prettier"));async function Y(n){try{if(!U())return;await v(`./node_modules/.bin/prettier --write "${n}"`),l.info(`Formatted ${n} with Prettier`)}catch(e){l.error(`Error formatting ${n} with Prettier:`,e)}}const V=new URL("data:video/mp2t;base64,IyEvdXNyL2Jpbi9lbnYgbm9kZQppbXBvcnQgeyBDb21tYW5kIH0gZnJvbSAnY29tbWFuZGVyJzsKaW1wb3J0IHsgcmVhZEZpbGUsIHdyaXRlRmlsZSwgbWtkaXIgfSBmcm9tICdmcy9wcm9taXNlcyc7CmltcG9ydCB7IGpvaW4sIHJlbGF0aXZlLCBwYXJzZSBhcyBwYXJzZVBhdGgsIGZvcm1hdCBhcyBmb3JtYXRQYXRoIH0gZnJvbSAncGF0aCc7CmltcG9ydCB7IHJlbmRlciB9IGZyb20gJ2Vqcyc7CmltcG9ydCB7IGdlbmVyYXRlQ3NzIH0gZnJvbSAnLi4vY29tcGlsZXInOwppbXBvcnQgeyBwYXNjYWxDYXNlIH0gZnJvbSAnLi4vdXRpbCc7CmltcG9ydCB7IGxvZ2dlciB9IGZyb20gJy4vbG9nZ2VyJzsKaW1wb3J0IHsgZm9ybWF0V2l0aFByZXR0aWVyIH0gZnJvbSAnLi9wcmV0d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ZSwgY29udGVudCB9OwogIH07CgogIGludGVyZmFjZSBSQ0ZpbGUgewogICAgZGVmYXVsdFByb2plY3Q6IHN0cmluZzsKICAgIHByb2plY3RzOiBzdHJpbmdbXTsKICB9CgogIGNvbnN0IHJlYWRSQ0ZpbGUgPSBhc3luYyAoKSA9PiB7CiAgICBjb25zdCByY1BhdGggPSBqb2luKHByb2Nlc3MuY3dkKCksICcuc2FsdHlyYycpOwogICAgY29uc3QgcmNDb250ZW50ID0gYXdhaXQgcmVhZEZpbGUocmNQYXRoLCAndXRmLTgnKQogICAgICAudGhlbihKU09OLnBhcnNlKQogICAgICAuY2F0Y2goKCkgPT4gKHt9KSk7CgogICAgcmV0dXJuIHJjQ29udGVudCBhcyBSQ0ZpbGU7CiAgfTsKCiAgY29uc3QgcmVhZFRoaXNQYWNrYWdlSnNvbiA9IGFzeW5jICgpID0+IHsKICAgIGNvbnN0IHBhY2thZ2VKc29uUGF0aCA9IGpvaW4oX19kaXJuYW1lLCAnLi4vcGFja2FnZS5qc29uJyk7CiAgICBjb25zb2xlLmxvZyh7IF9fZGlybmFtZSwgcGFja2FnZUpzb25QYXRoIH0pOwogICAgY29uc3QgcGFja2FnZUpzb25Db250ZW50ID0gYXdhaXQgcmVhZEZpbGUocGFja2FnZUpzb25QYXRoLCAndXRmLTgnKQogICAgICAudGhlbihKU09OLnBhcnNlKQogICAgICAuY2F0Y2goKCkgPT4gKHt9KSk7CgogICAgcmV0dXJuIHBhY2thZ2VKc29uQ29udGVudDsKICB9OwoKICBjb25zdCByZWFkUGFja2FnZUpzb24gPSBhc3luYyAocHJvamVjdERpcjogc3RyaW5nKSA9PiB7CiAgICBjb25zdCBwYWNrYWdlSnNvblBhdGggPSBqb2luKHByb2plY3REaXIsICdwYWNrYWdlLmpzb24nKTsKICAgIGNvbnN0IHBhY2thZ2VKc29uQ29udGVudCA9IGF3YWl0IHJlYWRGaWxlKHBhY2thZ2VKc29uUGF0aCwgJ3V0Zi04JykKICAgICAgLnRoZW4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YWxyZWFkeUV4aXN0cyA9IGF3YWl0IHJlYWRGaWxlKGZvcm1hdHRlZEZpbGVQYXRoLCAndXRmLTgnKS5jYXRjaCgoKSA9PiB1bmRlZmluZWQpOwogICAgICBpZiAoYWxyZWFkeUV4aXN0cyAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgbG9nZ2VyLmVycm9yKCdGaWxlIGFscmVhZHkgZXhpc3RzOicsIGZvcm1hdHRlZEZpbGVQYXRoKTsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgbG9nZ2VyLmluZm8oJ0dlbmVyYXRpbmcgYSBuZXcgZmlsZTogJyArIGZvcm1hdHRlZEZpbGVQYXRoKTsKCiAgICAgIGNvbnN0IF9uYW1lID0gcGFzY2FsQ2FzZShuYW1lIHx8IHBhcnNlZEZpbGVQYXRoLmJhc2UucmVwbGFjZSgvXC5jc3NcLlx3KyQvLCAnJykpOwogICAgICBjb25zdCB7IGNvbnRlbnQgfSA9IGF3YWl0IHJlYWRUZW1wbGF0ZSgncmVhY3QvcmVhY3Qtc3R5bGVkLWZpbGUudHMnLCB7IHRhZywgbmFtZTogX25hbWUsIGNsYXNzTmFtZSB9KTsKICAgICAgYXdhaXQgd3JpdGVGaWxlKGZvcm1hdHRlZEZpbGVQYXRoLCBjb250ZW50KTsKCiAgICAgIGF3YWl0IGZvcm1hdFdpdGhQcmV0dGllcihmb3JtYXR0ZWRGaWxlUGF0aCk7CiAgICB9KTsKCiAgcHJvZ3JhbS5wYXJzZUFzeW5jKHByb2Nlc3MuYXJndik7Cn0KCm1haW4oKS5jYXRjaCgoZSkgPT4gY29uc29sZS5lcnJvcihlKSk7Cg==",typeof document>"u"?require("url").pathToFileURL(__filename).href:H&&H.tagName.toUpperCase()==="SCRIPT"&&H.src||new URL("bin/index.cjs",document.baseURI).href).pathname;async function x(){const n=new S.Command;n.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const e={"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"))},A=async(a,d)=>{const{default:s}=await e[a],t=Q.render(s,d);return{fileName:a,content:t}},p=async()=>{const a=g.join(process.cwd(),".saltyrc");return await c.readFile(a,"utf-8").then(JSON.parse).catch(()=>({}))},J=async()=>{const a=g.join(V,"../package.json");return console.log({__dirname:V,packageJsonPath:a}),await c.readFile(a,"utf-8").then(JSON.parse).catch(()=>({}))},F=await(async()=>(await p()).defaultProject)(),B=await J(),r={core:`@salty-css/core@${B.version}`,react:`@salty-css/react@${B.version}`,eslintPluginCore:`@salty-css/eslint-plugin-core@${B.version}`,vite:`@salty-css/vite@${B.version}`};n.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(){l.info("Installing salty-css packages core, eslint-plugin and react"),await X(r.core,r.react),await X(`-D ${r.eslintPluginCore}`),l.info("Initializing a new Salty-CSS project...");const{dir:a,cssFile:d}=this.opts(),s=process.cwd(),t=g.join(s,a),R=await Promise.all([A("salty.config.ts"),A("saltygen/index.css")]);await c.mkdir(t,{recursive:!0});const h=R.map(async({fileName:C,content:i})=>{const o=g.join(t,C);if(await c.readFile(o,"utf-8").catch(()=>{})!==void 0){l.debug("File already exists: "+o);return}const N=C.split("/").slice(0,-1).join("/");N&&await c.mkdir(g.join(t,N),{recursive:!0}),l.info("Writing file: "+o),await c.writeFile(o,i),await Y(o)});await Promise.all(h);const G=g.relative(s,t),I=g.join(s,".saltyrc"),Z=await c.readFile(I,"utf-8").catch(()=>{});if(Z===void 0){l.info("Creating file: "+I);const i=JSON.stringify({defaultProject:G,projects:[G]},null,2);await c.writeFile(I,i)}else{l.info("Edit file: "+I);const C=JSON.parse(Z),i=new Set((C==null?void 0:C.projects)||[]);i.add(G),C.projects=[...i];const o=JSON.stringify(C,null,2);await c.writeFile(I,o)}const y=g.join(s,".gitignore"),m=await c.readFile(y,"utf-8").catch(()=>{});if(m!==void 0&&(m.includes("saltygen")||(l.info("Edit file: "+y),await c.writeFile(y,m+`
2
+ "use strict";const D=require("commander"),n=require("fs/promises"),t=require("path"),L=require("ejs"),O=require("../compiler/index.cjs"),R=require("../pascal-case-iWoaJWwT.cjs"),h=require("winston"),T=require("fs"),U=require("child_process");var $=typeof document<"u"?document.currentScript:null;const o=h.createLogger({level:"debug",format:h.format.combine(h.format.colorize(),h.format.cli()),transports:[new h.transports.Console({})]}),_=a=>new Promise((f,m)=>{U.exec(a,S=>{if(S)return m(S);f()})}),k=async(...a)=>{const f=a.join(" ");await _(`npm install ${f}`)},z=()=>T.existsSync(t.join(process.cwd(),"node_modules",".bin","prettier"));async function F(a){try{if(!z())return;await _(`./node_modules/.bin/prettier --write "${a}"`),o.info(`Formatted ${a} with Prettier`)}catch(f){o.error(`Error formatting ${a} with Prettier:`,f)}}async function A(){const a=new D.Command;a.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const f={"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"))},m=async(s,l)=>{const{default:p}=await f[s],c=L.render(p,l);return{fileName:s,content:c}},S=async()=>{const s=t.join(process.cwd(),".saltyrc");return await n.readFile(s,"utf-8").then(JSON.parse).catch(()=>({}))},E=async()=>{const s=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:$&&$.tagName.toUpperCase()==="SCRIPT"&&$.src||new URL("bin/index.cjs",document.baseURI).href);return console.log({packageJsonPath:s}),await n.readFile(s,"utf-8").then(JSON.parse).catch(()=>({}))},J=await(async()=>(await S()).defaultProject)(),j=await E(),P={core:`@salty-css/core@${j.version}`,react:`@salty-css/react@${j.version}`,eslintPluginCore:`@salty-css/eslint-plugin-core@${j.version}`,vite:`@salty-css/vite@${j.version}`};a.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(){o.info("Installing salty-css packages core, eslint-plugin and react"),await k(P.core,P.react),await k(`-D ${P.eslintPluginCore}`),o.info("Initializing a new Salty-CSS project...");const{dir:s,cssFile:l}=this.opts(),p=process.cwd(),c=t.join(p,s),x=await Promise.all([m("salty.config.ts"),m("saltygen/index.css")]);await n.mkdir(c,{recursive:!0});const I=x.map(async({fileName:e,content:r})=>{const d=t.join(c,e);if(await n.readFile(d,"utf-8").catch(()=>{})!==void 0){o.debug("File already exists: "+d);return}const q=e.split("/").slice(0,-1).join("/");q&&await n.mkdir(t.join(c,q),{recursive:!0}),o.info("Writing file: "+d),await n.writeFile(d,r),await F(d)});await Promise.all(I);const y=t.relative(p,c),i=t.join(p,".saltyrc"),u=await n.readFile(i,"utf-8").catch(()=>{});if(u===void 0){o.info("Creating file: "+i);const r=JSON.stringify({defaultProject:y,projects:[y]},null,2);await n.writeFile(i,r)}else{o.info("Edit file: "+i);const e=JSON.parse(u),r=new Set((e==null?void 0:e.projects)||[]);r.add(y),e.projects=[...r];const d=JSON.stringify(e,null,2);await n.writeFile(i,d)}const v=t.join(p,".gitignore"),w=await n.readFile(v,"utf-8").catch(()=>{});if(w!==void 0&&(w.includes("saltygen")||(o.info("Edit file: "+v),await n.writeFile(v,w+`
3
3
 
4
4
  # Salty-CSS
5
5
  saltygen
6
- `))),d){const C=g.join(t,d),i=await c.readFile(C,"utf-8").catch(()=>{});if(i!==void 0&&!i.includes("saltygen")){const u=g.join(C,".."),w=`@import '${g.relative(u,g.join(t,"saltygen/index.css"))}';`;l.info("Edit file: "+C),await c.writeFile(C,w+`
7
- `+i),await Y(C)}}const b=g.join(t,"vite.config.ts"),K=await c.readFile(b,"utf-8").catch(()=>{});if(K!==void 0&&!K.includes("saltyPlugin")){l.info("Edit file: "+b);const i=`import { saltyPlugin } from '@salty-css/vite';
8
- `,u=K.replace(/(plugins: \[)/,`$1
9
- saltyPlugin(__dirname),`);l.info("Installing @salty-css/vite"),await X(r.vite),l.info("Adding Salty-CSS plugin to Vite config..."),await c.writeFile(b,i+u),await Y(b)}}),n.command("build").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>","Project directory to build the project in.",F).action(async function(){l.info("Building the Salty-CSS project...");const{dir:a}=this.opts(),d=g.join(process.cwd(),a);await j.generateCss(d)}),n.command("generate <file>").alias("g").description("Generate a new component file.").option("-d, --dir <dir>","Project directory to generate the file in.",F).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.").action(async function(a){const{dir:d,tag:s,name:t,className:R}=this.opts(),h=g.join(process.cwd(),d),G=g.join(h,a),I=g.parse(G);I.ext||(I.ext=".ts"),I.name.endsWith(".css")||(I.name=I.name+".css"),I.base=I.name+I.ext;const Z=g.format(I);if(await c.readFile(Z,"utf-8").catch(()=>{})!==void 0){l.error("File already exists:",Z);return}l.info("Generating a new file: "+Z);const m=z.pascalCase(t||I.base.replace(/\.css\.\w+$/,"")),{content:b}=await A("react/react-styled-file.ts",{tag:s,name:m,className:R});await c.writeFile(Z,b),await Y(Z)}),n.parseAsync(process.argv)}x().catch(n=>console.error(n));
6
+ `))),l){const e=t.join(c,l),r=await n.readFile(e,"utf-8").catch(()=>{});if(r!==void 0&&!r.includes("saltygen")){const C=t.join(e,".."),N=`@import '${t.relative(C,t.join(c,"saltygen/index.css"))}';`;o.info("Edit file: "+e),await n.writeFile(e,N+`
7
+ `+r),await F(e)}}const g=t.join(c,"vite.config.ts"),b=await n.readFile(g,"utf-8").catch(()=>{});if(b!==void 0&&!b.includes("saltyPlugin")){o.info("Edit file: "+g);const r=`import { saltyPlugin } from '@salty-css/vite';
8
+ `,C=b.replace(/(plugins: \[)/,`$1
9
+ saltyPlugin(__dirname),`);o.info("Installing @salty-css/vite"),await k(P.vite),o.info("Adding Salty-CSS plugin to Vite config..."),await n.writeFile(g,r+C),await F(g)}}),a.command("build").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>","Project directory to build the project in.",J).action(async function(){o.info("Building the Salty-CSS project...");const{dir:s}=this.opts(),l=t.join(process.cwd(),s);await O.generateCss(l)}),a.command("generate <file>").alias("g").description("Generate a new component file.").option("-d, --dir <dir>","Project directory to generate the file in.",J).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.").action(async function(s){const{dir:l,tag:p,name:c,className:x}=this.opts(),I=t.join(process.cwd(),l),y=t.join(I,s),i=t.parse(y);i.ext||(i.ext=".ts"),i.name.endsWith(".css")||(i.name=i.name+".css"),i.base=i.name+i.ext;const u=t.format(i);if(await n.readFile(u,"utf-8").catch(()=>{})!==void 0){o.error("File already exists:",u);return}o.info("Generating a new file: "+u);const w=R.pascalCase(c||i.base.replace(/\.css\.\w+$/,"")),{content:g}=await m("react/react-styled-file.ts",{tag:p,name:w,className:x});await n.writeFile(u,g),await F(u)}),a.parseAsync(process.argv)}A().catch(a=>console.error(a));
package/bin/index.js CHANGED
@@ -1,130 +1,129 @@
1
1
  #!/usr/bin/env node
2
- import { Command as j } from "commander";
3
- import { mkdir as F, readFile as b, writeFile as A } from "fs/promises";
4
- import { join as l, relative as J, parse as z, format as k } from "path";
5
- import { render as L } from "ejs";
6
- import { generateCss as U } from "../compiler/index.js";
7
- import { p as x } from "../pascal-case-BQpR5PdN.js";
8
- import { createLogger as f, format as H, transports as T } from "winston";
9
- import { existsSync as P } from "fs";
10
- import { exec as O } from "child_process";
11
- const I = f({
2
+ import { Command as L } from "commander";
3
+ import { mkdir as D, readFile as g, writeFile as m } from "fs/promises";
4
+ import { join as a, relative as N, parse as A, format as H } from "path";
5
+ import { render as T } from "ejs";
6
+ import { generateCss as W } from "../compiler/index.js";
7
+ import { p as B } from "../pascal-case-BQpR5PdN.js";
8
+ import { createLogger as G, format as k, transports as R } from "winston";
9
+ import { existsSync as q } from "fs";
10
+ import { exec as M } from "child_process";
11
+ const n = G({
12
12
  level: "debug",
13
- format: H.combine(H.colorize(), H.cli()),
14
- transports: [new T.Console({})]
15
- }), S = (c) => new Promise((o, m) => {
16
- O(c, (p) => {
17
- if (p) return m(p);
18
- o();
13
+ format: k.combine(k.colorize(), k.cli()),
14
+ transports: [new R.Console({})]
15
+ }), O = (i) => new Promise((d, u) => {
16
+ M(i, (S) => {
17
+ if (S) return u(S);
18
+ d();
19
19
  });
20
- }), X = async (...c) => {
21
- const o = c.join(" ");
22
- await S(`npm install ${o}`);
23
- }, E = () => P(l(process.cwd(), "node_modules", ".bin", "prettier"));
24
- async function r(c) {
20
+ }), J = async (...i) => {
21
+ const d = i.join(" ");
22
+ await O(`npm install ${d}`);
23
+ }, U = () => q(a(process.cwd(), "node_modules", ".bin", "prettier"));
24
+ async function x(i) {
25
25
  try {
26
- if (!E()) return;
27
- await S(`./node_modules/.bin/prettier --write "${c}"`), I.info(`Formatted ${c} with Prettier`);
28
- } catch (o) {
29
- I.error(`Error formatting ${c} with Prettier:`, o);
26
+ if (!U()) return;
27
+ await O(`./node_modules/.bin/prettier --write "${i}"`), n.info(`Formatted ${i} with Prettier`);
28
+ } catch (d) {
29
+ n.error(`Error formatting ${i} with Prettier:`, d);
30
30
  }
31
31
  }
32
- const v = new URL("data:video/mp2t;base64,IyEvdXNyL2Jpbi9lbnYgbm9kZQppbXBvcnQgeyBDb21tYW5kIH0gZnJvbSAnY29tbWFuZGVyJzsKaW1wb3J0IHsgcmVhZEZpbGUsIHdyaXRlRmlsZSwgbWtkaXIgfSBmcm9tICdmcy9wcm9taXNlcyc7CmltcG9ydCB7IGpvaW4sIHJlbGF0aXZlLCBwYXJzZSBhcyBwYXJzZVBhdGgsIGZvcm1hdCBhcyBmb3JtYXRQYXRoIH0gZnJvbS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zZUFzeW5jKHByb2Nlc3MuYXJndik7Cn0KCm1haW4oKS5jYXRjaCgoZSkgPT4gY29uc29sZS5lcnJvcihlKSk7Cg==", import.meta.url).pathname;
33
- async function D() {
34
- const c = new j();
35
- c.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
36
- const o = {
32
+ async function V() {
33
+ const i = new L();
34
+ i.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
35
+ const d = {
37
36
  // Core files
38
37
  "salty.config.ts": import("../salty.config-D9ANEDiH.js"),
39
38
  "saltygen/index.css": import("../index-D_732b92.js"),
40
39
  // React
41
40
  "react/react-styled-file.ts": import("../react-styled-file-CGVf5n1B.js")
42
- }, m = async (n, i) => {
43
- const { default: Z } = await o[n], t = L(Z, i);
44
- return { fileName: n, content: t };
45
- }, p = async () => {
46
- const n = l(process.cwd(), ".saltyrc");
47
- return await b(n, "utf-8").then(JSON.parse).catch(() => ({}));
48
- }, w = async () => {
49
- const n = l(v, "../package.json");
50
- return console.log({ __dirname: v, packageJsonPath: n }), await b(n, "utf-8").then(JSON.parse).catch(() => ({}));
51
- }, V = await (async () => (await p()).defaultProject)(), B = await w(), y = {
52
- core: `@salty-css/core@${B.version}`,
53
- react: `@salty-css/react@${B.version}`,
54
- eslintPluginCore: `@salty-css/eslint-plugin-core@${B.version}`,
55
- vite: `@salty-css/vite@${B.version}`
41
+ }, u = async (o, c) => {
42
+ const { default: f } = await d[o], r = T(f, c);
43
+ return { fileName: o, content: r };
44
+ }, S = async () => {
45
+ const o = a(process.cwd(), ".saltyrc");
46
+ return await g(o, "utf-8").then(JSON.parse).catch(() => ({}));
47
+ }, _ = async () => {
48
+ const o = new URL("../package.json", import.meta.url);
49
+ return console.log({ packageJsonPath: o }), await g(o, "utf-8").then(JSON.parse).catch(() => ({}));
50
+ }, E = await (async () => (await S()).defaultProject)(), P = await _(), v = {
51
+ core: `@salty-css/core@${P.version}`,
52
+ react: `@salty-css/react@${P.version}`,
53
+ eslintPluginCore: `@salty-css/eslint-plugin-core@${P.version}`,
54
+ vite: `@salty-css/vite@${P.version}`
56
55
  };
57
- c.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() {
58
- I.info("Installing salty-css packages core, eslint-plugin and react"), await X(y.core, y.react), await X(`-D ${y.eslintPluginCore}`), I.info("Initializing a new Salty-CSS project...");
59
- const { dir: n, cssFile: i } = this.opts(), Z = process.cwd(), t = l(Z, n), R = await Promise.all([m("salty.config.ts"), m("saltygen/index.css")]);
60
- await F(t, { recursive: !0 });
61
- const h = R.map(async ({ fileName: g, content: a }) => {
62
- const d = l(t, g);
63
- if (await b(d, "utf-8").catch(() => {
56
+ 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() {
57
+ n.info("Installing salty-css packages core, eslint-plugin and react"), await J(v.core, v.react), await J(`-D ${v.eslintPluginCore}`), n.info("Initializing a new Salty-CSS project...");
58
+ const { dir: o, cssFile: c } = this.opts(), f = process.cwd(), r = a(f, o), F = await Promise.all([u("salty.config.ts"), u("saltygen/index.css")]);
59
+ await D(r, { recursive: !0 });
60
+ const I = F.map(async ({ fileName: t, content: s }) => {
61
+ const l = a(r, t);
62
+ if (await g(l, "utf-8").catch(() => {
64
63
  }) !== void 0) {
65
- I.debug("File already exists: " + d);
64
+ n.debug("File already exists: " + l);
66
65
  return;
67
66
  }
68
- const N = g.split("/").slice(0, -1).join("/");
69
- N && await F(l(t, N), { recursive: !0 }), I.info("Writing file: " + d), await A(d, a), await r(d);
67
+ const b = t.split("/").slice(0, -1).join("/");
68
+ b && await D(a(r, b), { recursive: !0 }), n.info("Writing file: " + l), await m(l, s), await x(l);
70
69
  });
71
- await Promise.all(h);
72
- const e = J(Z, t), C = l(Z, ".saltyrc"), s = await b(C, "utf-8").catch(() => {
70
+ await Promise.all(I);
71
+ const w = N(f, r), e = a(f, ".saltyrc"), p = await g(e, "utf-8").catch(() => {
73
72
  });
74
- if (s === void 0) {
75
- I.info("Creating file: " + C);
76
- const a = JSON.stringify({
77
- defaultProject: e,
78
- projects: [e]
73
+ if (p === void 0) {
74
+ n.info("Creating file: " + e);
75
+ const s = JSON.stringify({
76
+ defaultProject: w,
77
+ projects: [w]
79
78
  }, null, 2);
80
- await A(C, a);
79
+ await m(e, s);
81
80
  } else {
82
- I.info("Edit file: " + C);
83
- const g = JSON.parse(s), a = new Set((g == null ? void 0 : g.projects) || []);
84
- a.add(e), g.projects = [...a];
85
- const d = JSON.stringify(g, null, 2);
86
- await A(C, d);
81
+ n.info("Edit file: " + e);
82
+ const t = JSON.parse(p), s = new Set((t == null ? void 0 : t.projects) || []);
83
+ s.add(w), t.projects = [...s];
84
+ const l = JSON.stringify(t, null, 2);
85
+ await m(e, l);
87
86
  }
88
- const Y = l(Z, ".gitignore"), W = await b(Y, "utf-8").catch(() => {
87
+ const C = a(f, ".gitignore"), h = await g(C, "utf-8").catch(() => {
89
88
  });
90
- if (W !== void 0 && (W.includes("saltygen") || (I.info("Edit file: " + Y), await A(Y, W + `
89
+ if (h !== void 0 && (h.includes("saltygen") || (n.info("Edit file: " + C), await m(C, h + `
91
90
 
92
91
  # Salty-CSS
93
92
  saltygen
94
- `))), i) {
95
- const g = l(t, i), a = await b(g, "utf-8").catch(() => {
93
+ `))), c) {
94
+ const t = a(r, c), s = await g(t, "utf-8").catch(() => {
96
95
  });
97
- if (a !== void 0 && !a.includes("saltygen")) {
98
- const u = l(g, ".."), Q = `@import '${J(u, l(t, "saltygen/index.css"))}';`;
99
- I.info("Edit file: " + g), await A(g, Q + `
100
- ` + a), await r(g);
96
+ if (s !== void 0 && !s.includes("saltygen")) {
97
+ const j = a(t, ".."), z = `@import '${N(j, a(r, "saltygen/index.css"))}';`;
98
+ n.info("Edit file: " + t), await m(t, z + `
99
+ ` + s), await x(t);
101
100
  }
102
101
  }
103
- const G = l(t, "vite.config.ts"), K = await b(G, "utf-8").catch(() => {
102
+ const y = a(r, "vite.config.ts"), $ = await g(y, "utf-8").catch(() => {
104
103
  });
105
- if (K !== void 0 && !K.includes("saltyPlugin")) {
106
- I.info("Edit file: " + G);
107
- const a = `import { saltyPlugin } from '@salty-css/vite';
108
- `, u = K.replace(/(plugins: \[)/, `$1
104
+ if ($ !== void 0 && !$.includes("saltyPlugin")) {
105
+ n.info("Edit file: " + y);
106
+ const s = `import { saltyPlugin } from '@salty-css/vite';
107
+ `, j = $.replace(/(plugins: \[)/, `$1
109
108
  saltyPlugin(__dirname),`);
110
- I.info("Installing @salty-css/vite"), await X(y.vite), I.info("Adding Salty-CSS plugin to Vite config..."), await A(G, a + u), await r(G);
109
+ n.info("Installing @salty-css/vite"), await J(v.vite), n.info("Adding Salty-CSS plugin to Vite config..."), await m(y, s + j), await x(y);
111
110
  }
112
- }), c.command("build").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.", V).action(async function() {
113
- I.info("Building the Salty-CSS project...");
114
- const { dir: n } = this.opts(), i = l(process.cwd(), n);
115
- await U(i);
116
- }), c.command("generate <file>").alias("g").description("Generate a new component file.").option("-d, --dir <dir>", "Project directory to generate the file in.", V).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.").action(async function(n) {
117
- const { dir: i, tag: Z, name: t, className: R } = this.opts(), h = l(process.cwd(), i), e = l(h, n), C = z(e);
118
- C.ext || (C.ext = ".ts"), C.name.endsWith(".css") || (C.name = C.name + ".css"), C.base = C.name + C.ext;
119
- const s = k(C);
120
- if (await b(s, "utf-8").catch(() => {
111
+ }), i.command("build").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.", E).action(async function() {
112
+ n.info("Building the Salty-CSS project...");
113
+ const { dir: o } = this.opts(), c = a(process.cwd(), o);
114
+ await W(c);
115
+ }), i.command("generate <file>").alias("g").description("Generate a new component file.").option("-d, --dir <dir>", "Project directory to generate the file in.", E).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.").action(async function(o) {
116
+ const { dir: c, tag: f, name: r, className: F } = this.opts(), I = a(process.cwd(), c), w = a(I, o), e = A(w);
117
+ e.ext || (e.ext = ".ts"), e.name.endsWith(".css") || (e.name = e.name + ".css"), e.base = e.name + e.ext;
118
+ const p = H(e);
119
+ if (await g(p, "utf-8").catch(() => {
121
120
  }) !== void 0) {
122
- I.error("File already exists:", s);
121
+ n.error("File already exists:", p);
123
122
  return;
124
123
  }
125
- I.info("Generating a new file: " + s);
126
- const W = x(t || C.base.replace(/\.css\.\w+$/, "")), { content: G } = await m("react/react-styled-file.ts", { tag: Z, name: W, className: R });
127
- await A(s, G), await r(s);
128
- }), c.parseAsync(process.argv);
124
+ n.info("Generating a new file: " + p);
125
+ const h = B(r || e.base.replace(/\.css\.\w+$/, "")), { content: y } = await u("react/react-styled-file.ts", { tag: f, name: h, className: F });
126
+ await m(p, y), await x(p);
127
+ }), i.parseAsync(process.argv);
129
128
  }
130
- D().catch((c) => console.error(c));
129
+ V().catch((i) => console.error(i));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.19",
3
+ "version": "0.0.1-alpha.20",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",