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