@salty-css/core 0.0.1-alpha.32 → 0.0.1-alpha.33

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 +5 -5
  2. package/bin/main.js +111 -108
  3. package/package.json +1 -1
package/bin/main.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("commander"),a=require("fs/promises"),e=require("path"),L=require("ejs"),R=require("../compiler/index.cjs"),z=require("../pascal-case-iWoaJWwT.cjs"),k=require("winston"),W=require("fs"),H=require("child_process"),M=require("ora");var U=typeof document<"u"?document.currentScript:null;const t=k.createLogger({level:"debug",format:k.format.combine(k.format.colorize(),k.format.cli()),transports:[new k.transports.Console({})]}),v=i=>{t.error(i)},E=i=>new Promise((g,h)=>{H.exec(i,w=>{if(w)return h(w);g()})}),b=async(...i)=>{const g=i.map(x=>x.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),h=M(`Installing packages: ${g}`).start(),w=i.join(" ");await E(`npm install ${w}`),h.succeed(`Installed packages: ${g}`)},B=()=>W.existsSync(e.join(process.cwd(),"node_modules",".bin","prettier"));async function D(i){try{if(!B())return;await E(`./node_modules/.bin/prettier --write "${i}"`),t.info(`Formatted ${i} with Prettier`)}catch(g){t.error(`Error formatting ${i} with Prettier:`,g)}}async function G(){const i=new T.Command;i.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"))},h=async(o,r)=>{const{default:d}=await g[o],u=L.render(d,r);return{fileName:o,content:u}},w=async()=>{const o=e.join(process.cwd(),".saltyrc");return await a.readFile(o,"utf-8").then(JSON.parse).catch(()=>({}))},x=async o=>{const r=await a.readFile(o,"utf-8").then(JSON.parse).catch(()=>{});if(!r)throw"Could not read package.json file!";return r},O=async()=>{const o=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:U&&U.tagName.toUpperCase()==="SCRIPT"&&U.src||new URL("bin/main.cjs",document.baseURI).href);return x(o)},J=await(async()=>(await w()).defaultProject)(),C=await O(),I={core:`@salty-css/core@${C.version}`,react:`@salty-css/react@${C.version}`,eslintPluginCore:`@salty-css/eslint-plugin-core@${C.version}`,vite:`@salty-css/vite@${C.version}`};i.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(o){t.info("Initializing a new Salty-CSS project!");const{dir:r=o,cssFile:d,skipInstall:u}=this.opts();if(!r)return v("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");u||(await b(I.core,I.react),await b(`-D ${I.eslintPluginCore}`));const f=process.cwd(),p=e.join(f,r),S=await Promise.all([h("salty.config.ts"),h("saltygen/index.css")]);await a.mkdir(p,{recursive:!0});const j=S.map(async({fileName:n,content:l})=>{const m=e.join(p,n);if(await a.readFile(m,"utf-8").catch(()=>{})!==void 0){t.debug("File already exists: "+m);return}const N=n.split("/").slice(0,-1).join("/");N&&await a.mkdir(e.join(p,N),{recursive:!0}),t.info("Writing file: "+m),await a.writeFile(m,l),await D(m)});await Promise.all(j);const c=e.relative(f,p),s=e.join(f,".saltyrc"),y=await a.readFile(s,"utf-8").catch(()=>{});if(y===void 0){t.info("Creating file: "+s);const l=JSON.stringify({defaultProject:c,projects:[c]},null,2);await a.writeFile(s,l)}else{t.info("Edit file: "+s);const n=JSON.parse(y),l=new Set((n==null?void 0:n.projects)||[]);l.add(c),n.projects=[...l];const m=JSON.stringify(n,null,2);await a.writeFile(s,m)}const $=e.join(f,".gitignore"),F=await a.readFile($,"utf-8").catch(()=>{});if(F!==void 0&&(F.includes("saltygen")||(t.info("Edit file: "+$),await a.writeFile($,F+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("commander"),a=require("fs/promises"),o=require("path"),R=require("ejs"),z=require("../compiler/index.cjs"),W=require("../pascal-case-iWoaJWwT.cjs"),k=require("winston"),H=require("fs"),M=require("child_process"),B=require("ora");var E=typeof document<"u"?document.currentScript:null;const t=k.createLogger({level:"debug",format:k.format.combine(k.format.colorize(),k.format.cli()),transports:[new k.transports.Console({})]}),v=i=>{t.error(i)},O=i=>new Promise((f,h)=>{M.exec(i,w=>{if(w)return h(w);f()})}),b=async(...i)=>{const f=i.map(x=>x.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),h=B(`Installing packages: ${f}`).start(),w=i.join(" ");await O(`npm install ${w}`),h.succeed(`Installed packages: ${f}`)},G=()=>H.existsSync(o.join(process.cwd(),"node_modules",".bin","prettier"));async function q(i){try{if(!G())return;await O(`./node_modules/.bin/prettier --write "${i}"`),t.info(`Formatted ${i} with Prettier`)}catch(f){t.error(`Error formatting ${i} with Prettier:`,f)}}async function V(){const i=new L.Command;i.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"))},h=async(e,r)=>{const{default:c}=await f[e],p=R.render(c,r);return{fileName:e,content:p}},w=async()=>{const e=o.join(process.cwd(),".saltyrc");return await a.readFile(e,"utf-8").then(JSON.parse).catch(()=>({}))},x=async e=>{const r=await a.readFile(e,"utf-8").then(JSON.parse).catch(()=>{});if(!r)throw"Could not read package.json file!";return r},A=async()=>{const e=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:E&&E.tagName.toUpperCase()==="SCRIPT"&&E.src||new URL("bin/main.cjs",document.baseURI).href);return x(e)},J=await(async()=>(await w()).defaultProject)(),C=await A(),I={core:`@salty-css/core@${C.version}`,react:`@salty-css/react@${C.version}`,eslintPluginCore:`@salty-css/eslint-plugin-core@${C.version}`,vite:`@salty-css/vite@${C.version}`},N=e=>{const r=e==="."?"":e,c=process.cwd();return o.join(c,r)};i.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(e="."){t.info("Initializing a new Salty-CSS project!");const{dir:r=e,cssFile:c,skipInstall:p}=this.opts();if(!r)return v("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||(await b(I.core,I.react),await b(`-D ${I.eslintPluginCore}`));const g=process.cwd(),u=N(r),S=await Promise.all([h("salty.config.ts"),h("saltygen/index.css")]);await a.mkdir(u,{recursive:!0});const j=S.map(async({fileName:n,content:d})=>{const m=o.join(u,n);if(await a.readFile(m,"utf-8").catch(()=>{})!==void 0){t.debug("File already exists: "+m);return}const U=n.split("/").slice(0,-1).join("/");U&&await a.mkdir(o.join(u,U),{recursive:!0}),t.info("Writing file: "+m),await a.writeFile(m,d),await q(m)});await Promise.all(j);const l=o.relative(g,u)||".",s=o.join(g,".saltyrc"),y=await a.readFile(s,"utf-8").catch(()=>{});if(y===void 0){t.info("Creating file: "+s);const d=JSON.stringify({defaultProject:l,projects:[l]},null,2);await a.writeFile(s,d)}else{t.info("Edit file: "+s);const n=JSON.parse(y),d=new Set((n==null?void 0:n.projects)||[]);d.add(l),n.projects=[...d];const m=JSON.stringify(n,null,2);await a.writeFile(s,m)}const $=o.join(g,".gitignore"),F=await a.readFile($,"utf-8").catch(()=>{});if(F!==void 0&&(F.includes("saltygen")||(t.info("Edit file: "+$),await a.writeFile($,F+`
2
2
 
3
3
  # Salty-CSS
4
4
  saltygen
5
- `))),d){const n=e.join(p,d),l=await a.readFile(n,"utf-8").catch(()=>{});if(l!==void 0&&!l.includes("saltygen")){const q=e.join(n,".."),A=`@import '${e.relative(q,e.join(p,"saltygen/index.css"))}';`;t.info("Edit file: "+n),await a.writeFile(n,A+`
6
- `+l),await D(n)}}const P=e.join(p,"vite.config.ts"),_=await a.readFile(P,"utf-8").catch(()=>{});if(_!==void 0&&!_.includes("saltyPlugin")){t.info("Edit file: "+P);const l=`import { saltyPlugin } from '@salty-css/vite';
7
- `,q=_.replace(/(plugins: \[)/,`$1
8
- saltyPlugin(__dirname),`);t.info("Installing @salty-css/vite"),u||await b(`-D ${I.vite}`),t.info("Adding Salty-CSS plugin to Vite config..."),await a.writeFile(P,l+q),await D(P)}}),i.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(o=J){t.info("Building the Salty-CSS project...");const{dir:r=o}=this.opts();if(!r)return v("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const d=e.join(process.cwd(),r);await R.generateCss(d)}),i.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.").action(async function(o,r=J){const{file:d=o,dir:u=r,tag:f,name:p,className:S}=this.opts();if(!d)return v("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!u)return v("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const j=e.join(process.cwd(),u),c=e.join(j,d),s=e.parse(c);s.ext||(s.ext=".ts"),s.name.endsWith(".css")||(s.name=s.name+".css"),s.base=s.name+s.ext;const y=e.format(s);if(await a.readFile(y,"utf-8").catch(()=>{})!==void 0){t.error("File already exists:",y);return}t.info("Generating a new file: "+y);const F=z.pascalCase(p||s.base.replace(/\.css\.\w+$/,"")),{content:P}=await h("react/react-styled-file.ts",{tag:f,name:F,className:S});await a.writeFile(y,P),await D(y)}),i.command("update").alias("up").description("Update Salty-CSS packages to the latest version.").option("--legacy-peer-deps <legacyPeerDeps>","Use legacy peer dependencies (not recommended).",!1).action(async function(o,r=J){const{legacyPeerDeps:d}=this.opts(),u=e.join(process.cwd(),"package.json"),f=await x(u).catch(c=>v(c));if(!f)return;const p={...f.dependencies,...f.devDependencies},S=Object.keys(p).filter(c=>c==="salty-css"||c.startsWith("@salty-css/"));if(!S.length)return v("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 j=S.map(c=>`${c}@${C.version}`);d?(t.warn("Using legacy peer dependencies to update packages."),await b(...j,"--legacy-peer-deps")):await b(...j),t.info("Salty-CSS packages updated successfully!")}),i.parseAsync(process.argv)}exports.main=G;
5
+ `))),c){const n=o.join(u,c),d=await a.readFile(n,"utf-8").catch(()=>{});if(d!==void 0&&!d.includes("saltygen")){const D=o.join(n,".."),T=`@import '${o.relative(D,o.join(u,"saltygen/index.css"))}';`;t.info("Edit file: "+n),await a.writeFile(n,T+`
6
+ `+d),await q(n)}}const P=o.join(u,"vite.config.ts"),_=await a.readFile(P,"utf-8").catch(()=>{});if(_!==void 0&&!_.includes("saltyPlugin")){t.info("Edit file: "+P);const d=`import { saltyPlugin } from '@salty-css/vite';
7
+ `,D=_.replace(/(plugins: \[)/,`$1
8
+ saltyPlugin(__dirname),`);t.info("Installing @salty-css/vite"),p||await b(`-D ${I.vite}`),t.info("Adding Salty-CSS plugin to Vite config..."),await a.writeFile(P,d+D),await q(P)}}),i.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(e=J){t.info("Building the Salty-CSS project...");const{dir:r=e}=this.opts();if(!r)return v("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const c=N(r);await z.generateCss(c)}),i.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.").action(async function(e,r=J){const{file:c=e,dir:p=r,tag:g,name:u,className:S}=this.opts();if(!c)return v("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!p)return v("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const j=N(p),l=o.join(j,c),s=o.parse(l);s.ext||(s.ext=".ts"),s.name.endsWith(".css")||(s.name=s.name+".css"),s.base=s.name+s.ext;const y=o.format(s);if(await a.readFile(y,"utf-8").catch(()=>{})!==void 0){t.error("File already exists:",y);return}t.info("Generating a new file: "+y);const F=W.pascalCase(u||s.base.replace(/\.css\.\w+$/,"")),{content:P}=await h("react/react-styled-file.ts",{tag:g,name:F,className:S});await a.writeFile(y,P),await q(y)}),i.command("update").alias("up").description("Update Salty-CSS packages to the latest version.").option("--legacy-peer-deps <legacyPeerDeps>","Use legacy peer dependencies (not recommended).",!1).action(async function(e,r=J){const{legacyPeerDeps:c}=this.opts(),p=o.join(process.cwd(),"package.json"),g=await x(p).catch(l=>v(l));if(!g)return;const u={...g.dependencies,...g.devDependencies},S=Object.keys(u).filter(l=>l==="salty-css"||l.startsWith("@salty-css/"));if(!S.length)return v("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+p);const j=S.map(l=>`${l}@${C.version}`);c?(t.warn("Using legacy peer dependencies to update packages."),await b(...j,"--legacy-peer-deps")):await b(...j),t.info("Salty-CSS packages updated successfully!")}),i.parseAsync(process.argv)}exports.main=V;
package/bin/main.js CHANGED
@@ -1,156 +1,159 @@
1
- import { Command as W } from "commander";
2
- import { mkdir as _, readFile as y, writeFile as w } from "fs/promises";
3
- import { join as o, relative as U, parse as H, format as B } from "path";
4
- import { render as G } from "ejs";
5
- import { generateCss as M } from "../compiler/index.js";
6
- import { p as R } from "../pascal-case-BQpR5PdN.js";
7
- import { createLogger as V, format as O, transports as q } from "winston";
8
- import { existsSync as K } from "fs";
9
- import { exec as Q } from "child_process";
10
- import X from "ora";
11
- const t = V({
1
+ import { Command as H } from "commander";
2
+ import { mkdir as U, readFile as y, writeFile as w } from "fs/promises";
3
+ import { join as r, relative as z, parse as B, format as G } from "path";
4
+ import { render as M } from "ejs";
5
+ import { generateCss as R } from "../compiler/index.js";
6
+ import { p as V } from "../pascal-case-BQpR5PdN.js";
7
+ import { createLogger as q, format as _, transports as K } from "winston";
8
+ import { existsSync as Q } from "fs";
9
+ import { exec as X } from "child_process";
10
+ import Y from "ora";
11
+ const e = q({
12
12
  level: "debug",
13
- format: O.combine(O.colorize(), O.cli()),
14
- transports: [new q.Console({})]
15
- }), j = (e) => {
16
- t.error(e);
17
- }, z = (e) => new Promise((g, h) => {
18
- Q(e, (S) => {
13
+ format: _.combine(_.colorize(), _.cli()),
14
+ transports: [new K.Console({})]
15
+ }), C = (n) => {
16
+ e.error(n);
17
+ }, L = (n) => new Promise((f, h) => {
18
+ X(n, (S) => {
19
19
  if (S) return h(S);
20
- g();
20
+ f();
21
21
  });
22
- }), x = async (...e) => {
23
- const g = e.map((F) => F.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), h = X(`Installing packages: ${g}`).start(), S = e.join(" ");
24
- await z(`npm install ${S}`), h.succeed(`Installed packages: ${g}`);
25
- }, Y = () => K(o(process.cwd(), "node_modules", ".bin", "prettier"));
26
- async function J(e) {
22
+ }), x = async (...n) => {
23
+ const f = n.map((F) => F.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), h = Y(`Installing packages: ${f}`).start(), S = n.join(" ");
24
+ await L(`npm install ${S}`), h.succeed(`Installed packages: ${f}`);
25
+ }, Z = () => Q(r(process.cwd(), "node_modules", ".bin", "prettier"));
26
+ async function J(n) {
27
27
  try {
28
- if (!Y()) return;
29
- await z(`./node_modules/.bin/prettier --write "${e}"`), t.info(`Formatted ${e} with Prettier`);
30
- } catch (g) {
31
- t.error(`Error formatting ${e} with Prettier:`, g);
28
+ if (!Z()) return;
29
+ await L(`./node_modules/.bin/prettier --write "${n}"`), e.info(`Formatted ${n} with Prettier`);
30
+ } catch (f) {
31
+ e.error(`Error formatting ${n} with Prettier:`, f);
32
32
  }
33
33
  }
34
- async function dt() {
35
- const e = new W();
36
- e.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
37
- const g = {
34
+ async function pt() {
35
+ const n = new H();
36
+ n.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
37
+ const f = {
38
38
  // Core files
39
39
  "salty.config.ts": import("../salty.config-D9ANEDiH.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
- }, h = async (i, s) => {
44
- const { default: l } = await g[i], p = G(l, s);
45
- return { fileName: i, content: p };
43
+ }, h = async (t, a) => {
44
+ const { default: s } = await f[t], d = M(s, a);
45
+ return { fileName: t, content: d };
46
46
  }, S = async () => {
47
- const i = o(process.cwd(), ".saltyrc");
48
- return await y(i, "utf-8").then(JSON.parse).catch(() => ({}));
49
- }, F = async (i) => {
50
- const s = await y(i, "utf-8").then(JSON.parse).catch(() => {
47
+ const t = r(process.cwd(), ".saltyrc");
48
+ return await y(t, "utf-8").then(JSON.parse).catch(() => ({}));
49
+ }, F = async (t) => {
50
+ const a = await y(t, "utf-8").then(JSON.parse).catch(() => {
51
51
  });
52
- if (!s) throw "Could not read package.json file!";
53
- return s;
54
- }, L = async () => {
55
- const i = new URL("../package.json", import.meta.url);
56
- return F(i);
57
- }, N = await (async () => (await S()).defaultProject)(), k = await L(), b = {
52
+ if (!a) throw "Could not read package.json file!";
53
+ return a;
54
+ }, T = async () => {
55
+ const t = new URL("../package.json", import.meta.url);
56
+ return F(t);
57
+ }, N = await (async () => (await S()).defaultProject)(), k = await T(), b = {
58
58
  core: `@salty-css/core@${k.version}`,
59
59
  react: `@salty-css/react@${k.version}`,
60
60
  eslintPluginCore: `@salty-css/eslint-plugin-core@${k.version}`,
61
61
  vite: `@salty-css/vite@${k.version}`
62
+ }, E = (t) => {
63
+ const a = t === "." ? "" : t, s = process.cwd();
64
+ return r(s, a);
62
65
  };
63
- 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.").option("--skip-install", "Skip installing dependencies.").action(async function(i) {
64
- t.info("Initializing a new Salty-CSS project!");
65
- const { dir: s = i, cssFile: l, skipInstall: p } = this.opts();
66
- if (!s) return j("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
67
- p || (await x(b.core, b.react), await x(`-D ${b.eslintPluginCore}`));
68
- const f = process.cwd(), d = o(f, s), P = await Promise.all([h("salty.config.ts"), h("saltygen/index.css")]);
69
- await _(d, { recursive: !0 });
70
- const v = P.map(async ({ fileName: n, content: c }) => {
71
- const m = o(d, n);
66
+ 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.").option("--skip-install", "Skip installing dependencies.").action(async function(t = ".") {
67
+ e.info("Initializing a new Salty-CSS project!");
68
+ const { dir: a = t, cssFile: s, skipInstall: d } = this.opts();
69
+ if (!a) return C("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
70
+ d || (await x(b.core, b.react), await x(`-D ${b.eslintPluginCore}`));
71
+ const g = process.cwd(), p = E(a), P = await Promise.all([h("salty.config.ts"), h("saltygen/index.css")]);
72
+ await U(p, { recursive: !0 });
73
+ const v = P.map(async ({ fileName: i, content: l }) => {
74
+ const m = r(p, i);
72
75
  if (await y(m, "utf-8").catch(() => {
73
76
  }) !== void 0) {
74
- t.debug("File already exists: " + m);
77
+ e.debug("File already exists: " + m);
75
78
  return;
76
79
  }
77
- const A = n.split("/").slice(0, -1).join("/");
78
- A && await _(o(d, A), { recursive: !0 }), t.info("Writing file: " + m), await w(m, c), await J(m);
80
+ const O = i.split("/").slice(0, -1).join("/");
81
+ O && await U(r(p, O), { recursive: !0 }), e.info("Writing file: " + m), await w(m, l), await J(m);
79
82
  });
80
83
  await Promise.all(v);
81
- const r = U(f, d), a = o(f, ".saltyrc"), u = await y(a, "utf-8").catch(() => {
84
+ const c = z(g, p) || ".", o = r(g, ".saltyrc"), u = await y(o, "utf-8").catch(() => {
82
85
  });
83
86
  if (u === void 0) {
84
- t.info("Creating file: " + a);
85
- const c = JSON.stringify({
86
- defaultProject: r,
87
- projects: [r]
87
+ e.info("Creating file: " + o);
88
+ const l = JSON.stringify({
89
+ defaultProject: c,
90
+ projects: [c]
88
91
  }, null, 2);
89
- await w(a, c);
92
+ await w(o, l);
90
93
  } else {
91
- t.info("Edit file: " + a);
92
- const n = JSON.parse(u), c = new Set((n == null ? void 0 : n.projects) || []);
93
- c.add(r), n.projects = [...c];
94
- const m = JSON.stringify(n, null, 2);
95
- await w(a, m);
94
+ e.info("Edit file: " + o);
95
+ const i = JSON.parse(u), l = new Set((i == null ? void 0 : i.projects) || []);
96
+ l.add(c), i.projects = [...l];
97
+ const m = JSON.stringify(i, null, 2);
98
+ await w(o, m);
96
99
  }
97
- const I = o(f, ".gitignore"), $ = await y(I, "utf-8").catch(() => {
100
+ const D = r(g, ".gitignore"), $ = await y(D, "utf-8").catch(() => {
98
101
  });
99
- if ($ !== void 0 && ($.includes("saltygen") || (t.info("Edit file: " + I), await w(I, $ + `
102
+ if ($ !== void 0 && ($.includes("saltygen") || (e.info("Edit file: " + D), await w(D, $ + `
100
103
 
101
104
  # Salty-CSS
102
105
  saltygen
103
- `))), l) {
104
- const n = o(d, l), c = await y(n, "utf-8").catch(() => {
106
+ `))), s) {
107
+ const i = r(p, s), l = await y(i, "utf-8").catch(() => {
105
108
  });
106
- if (c !== void 0 && !c.includes("saltygen")) {
107
- const D = o(n, ".."), T = `@import '${U(D, o(d, "saltygen/index.css"))}';`;
108
- t.info("Edit file: " + n), await w(n, T + `
109
- ` + c), await J(n);
109
+ if (l !== void 0 && !l.includes("saltygen")) {
110
+ const I = r(i, ".."), W = `@import '${z(I, r(p, "saltygen/index.css"))}';`;
111
+ e.info("Edit file: " + i), await w(i, W + `
112
+ ` + l), await J(i);
110
113
  }
111
114
  }
112
- const C = o(d, "vite.config.ts"), E = await y(C, "utf-8").catch(() => {
115
+ const j = r(p, "vite.config.ts"), A = await y(j, "utf-8").catch(() => {
113
116
  });
114
- if (E !== void 0 && !E.includes("saltyPlugin")) {
115
- t.info("Edit file: " + C);
116
- const c = `import { saltyPlugin } from '@salty-css/vite';
117
- `, D = E.replace(/(plugins: \[)/, `$1
117
+ if (A !== void 0 && !A.includes("saltyPlugin")) {
118
+ e.info("Edit file: " + j);
119
+ const l = `import { saltyPlugin } from '@salty-css/vite';
120
+ `, I = A.replace(/(plugins: \[)/, `$1
118
121
  saltyPlugin(__dirname),`);
119
- t.info("Installing @salty-css/vite"), p || await x(`-D ${b.vite}`), t.info("Adding Salty-CSS plugin to Vite config..."), await w(C, c + D), await J(C);
122
+ e.info("Installing @salty-css/vite"), d || await x(`-D ${b.vite}`), e.info("Adding Salty-CSS plugin to Vite config..."), await w(j, l + I), await J(j);
120
123
  }
121
- }), 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(i = N) {
122
- t.info("Building the Salty-CSS project...");
123
- const { dir: s = i } = this.opts();
124
- if (!s) return j("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
125
- const l = o(process.cwd(), s);
126
- await M(l);
127
- }), e.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.").action(async function(i, s = N) {
128
- const { file: l = i, dir: p = s, tag: f, name: d, className: P } = this.opts();
129
- if (!l) return j("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
130
- if (!p) return j("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
131
- const v = o(process.cwd(), p), r = o(v, l), a = H(r);
132
- a.ext || (a.ext = ".ts"), a.name.endsWith(".css") || (a.name = a.name + ".css"), a.base = a.name + a.ext;
133
- const u = B(a);
124
+ }), 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(t = N) {
125
+ e.info("Building the Salty-CSS project...");
126
+ const { dir: a = t } = this.opts();
127
+ if (!a) return C("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
128
+ const s = E(a);
129
+ await R(s);
130
+ }), n.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.").action(async function(t, a = N) {
131
+ const { file: s = t, dir: d = a, tag: g, name: p, className: P } = this.opts();
132
+ if (!s) return C("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
133
+ if (!d) return C("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
134
+ const v = E(d), c = r(v, s), o = B(c);
135
+ o.ext || (o.ext = ".ts"), o.name.endsWith(".css") || (o.name = o.name + ".css"), o.base = o.name + o.ext;
136
+ const u = G(o);
134
137
  if (await y(u, "utf-8").catch(() => {
135
138
  }) !== void 0) {
136
- t.error("File already exists:", u);
139
+ e.error("File already exists:", u);
137
140
  return;
138
141
  }
139
- t.info("Generating a new file: " + u);
140
- const $ = R(d || a.base.replace(/\.css\.\w+$/, "")), { content: C } = await h("react/react-styled-file.ts", { tag: f, name: $, className: P });
141
- await w(u, C), await J(u);
142
- }), e.command("update").alias("up").description("Update Salty-CSS packages to the latest version.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", !1).action(async function(i, s = N) {
143
- const { legacyPeerDeps: l } = this.opts(), p = o(process.cwd(), "package.json"), f = await F(p).catch((r) => j(r));
144
- if (!f) return;
145
- const d = { ...f.dependencies, ...f.devDependencies }, P = Object.keys(d).filter((r) => r === "salty-css" || r.startsWith("@salty-css/"));
142
+ e.info("Generating a new file: " + u);
143
+ const $ = V(p || o.base.replace(/\.css\.\w+$/, "")), { content: j } = await h("react/react-styled-file.ts", { tag: g, name: $, className: P });
144
+ await w(u, j), await J(u);
145
+ }), n.command("update").alias("up").description("Update Salty-CSS packages to the latest version.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", !1).action(async function(t, a = N) {
146
+ const { legacyPeerDeps: s } = this.opts(), d = r(process.cwd(), "package.json"), g = await F(d).catch((c) => C(c));
147
+ if (!g) return;
148
+ const p = { ...g.dependencies, ...g.devDependencies }, P = Object.keys(p).filter((c) => c === "salty-css" || c.startsWith("@salty-css/"));
146
149
  if (!P.length)
147
- return j(
148
- "No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + p
150
+ return C(
151
+ "No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + d
149
152
  );
150
- const v = P.map((r) => `${r}@${k.version}`);
151
- l ? (t.warn("Using legacy peer dependencies to update packages."), await x(...v, "--legacy-peer-deps")) : await x(...v), t.info("Salty-CSS packages updated successfully!");
152
- }), e.parseAsync(process.argv);
153
+ const v = P.map((c) => `${c}@${k.version}`);
154
+ s ? (e.warn("Using legacy peer dependencies to update packages."), await x(...v, "--legacy-peer-deps")) : await x(...v), e.info("Salty-CSS packages updated successfully!");
155
+ }), n.parseAsync(process.argv);
153
156
  }
154
157
  export {
155
- dt as main
158
+ pt as main
156
159
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.32",
3
+ "version": "0.0.1-alpha.33",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",