@salty-css/core 0.0.1-alpha.16 → 0.0.1-alpha.18

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