@salty-css/core 0.0.1-alpha.23 → 0.0.1-alpha.25

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