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