@salty-css/core 0.0.1-alpha.30 → 0.0.1-alpha.300
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/.saltyrc.schema.json +48 -0
- package/README.md +469 -26
- package/bin/main.cjs +8 -5
- package/bin/main.js +230 -108
- package/cache/resolve-dynamic-config-cache.cjs +1 -0
- package/cache/resolve-dynamic-config-cache.d.ts +1 -0
- package/cache/resolve-dynamic-config-cache.js +11 -0
- package/compiler/get-files.d.ts +3 -0
- package/compiler/get-function-range.d.ts +1 -0
- package/compiler/helpers.d.ts +2 -0
- package/compiler/index.cjs +1 -11
- package/compiler/index.d.ts +19 -11
- package/compiler/index.js +20 -172
- package/config/define-config.d.ts +1 -1
- package/config/index.cjs +1 -1
- package/config/index.d.ts +2 -1
- package/config/index.js +12 -2
- package/css/index.cjs +1 -1
- package/css/index.d.ts +4 -1
- package/css/index.js +10 -2
- package/css/keyframes.cjs +1 -0
- package/css/keyframes.d.ts +22 -0
- package/css/keyframes.js +39 -0
- package/css/media.cjs +1 -0
- package/css/media.d.ts +87 -0
- package/css/media.js +88 -0
- package/css/merge.cjs +1 -0
- package/css/merge.d.ts +7 -0
- package/css/merge.js +5 -0
- package/css/token.cjs +1 -0
- package/css/token.d.ts +1 -0
- package/css/token.js +4 -0
- package/{dash-case-DKzpenwY.cjs → dash-case-BJEkFEGQ.cjs} +1 -1
- package/{dash-case-DMQMcCO6.js → dash-case-DBThphLm.js} +2 -2
- package/define-templates-4A2yHcMF.js +52 -0
- package/define-templates-Cunsb_Tr.cjs +1 -0
- package/factories/define-global-styles.d.ts +7 -0
- package/factories/define-media-query.d.ts +8 -0
- package/factories/define-templates.d.ts +27 -0
- package/factories/define-variables.d.ts +12 -0
- package/factories/index.cjs +1 -0
- package/factories/index.d.ts +4 -0
- package/factories/index.js +30 -0
- package/generators/class-name-generator.d.ts +6 -0
- package/generators/index.cjs +1 -0
- package/generators/index.d.ts +2 -0
- package/generators/index.js +88 -0
- package/generators/styled-generator.d.ts +20 -0
- package/generators/styles-generator.d.ts +22 -0
- package/helpers/color.d.ts +18 -0
- package/helpers/index.cjs +1 -0
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +1183 -0
- package/helpers/viewport-clamp.d.ts +9 -0
- package/helpers-CC5pFyba.cjs +1 -0
- package/helpers-nHqH4L9L.js +11 -0
- package/index-CituHO0U.js +524 -0
- package/index-ol1Q_xul.cjs +41 -0
- package/package.json +54 -6
- package/parse-styles-B1E0JeC7.cjs +5 -0
- package/parse-styles-y_-drahL.js +161 -0
- package/parsers/index.cjs +2 -0
- package/parsers/index.d.ts +5 -0
- package/parsers/index.js +33 -0
- package/parsers/parse-modifiers.d.ts +3 -0
- package/parsers/parse-styles.d.ts +13 -0
- package/parsers/parse-templates.d.ts +4 -0
- package/parsers/parse-tokens.d.ts +3 -0
- package/parsers/parser-types.d.ts +8 -0
- package/parsers/property-name-check.d.ts +1 -0
- package/parsers/unit-check.d.ts +7 -0
- package/react-vanilla-file-CCXbsjIb.js +18 -0
- package/react-vanilla-file-CG_WJLam.cjs +15 -0
- package/{salty.config-D9ANEDiH.js → salty.config-BhBY_oOk.js} +1 -0
- package/{salty.config-BupieCfE.cjs → salty.config-Dk6ZcCxI.cjs} +3 -2
- package/server/index.cjs +1 -0
- package/server/index.d.ts +1 -0
- package/server/index.js +4 -0
- package/server/should-restart.d.ts +1 -0
- package/should-restart-C6VJ-qaY.js +12 -0
- package/should-restart-DAhvRrtu.cjs +1 -0
- package/templates/salty-reset.d.ts +2 -0
- package/types/cli-types.d.ts +10 -0
- package/types/config-types.d.ts +85 -0
- package/types/index.d.ts +57 -23
- package/util/dot-case.d.ts +1 -0
- package/util/index.cjs +1 -1
- package/util/index.js +1 -1
- package/util/module-type.d.ts +1 -0
- package/viewport-clamp-CaYwREKc.js +7 -0
- package/viewport-clamp-mq_DFtRR.cjs +1 -0
- package/config/config-types.d.ts +0 -59
- package/generator/index.cjs +0 -1
- package/generator/index.d.ts +0 -1
- package/generator/index.js +0 -61
- package/generator/parse-modifiers.d.ts +0 -3
- package/generator/parse-styles.d.ts +0 -2
- package/generator/parse-templates.d.ts +0 -2
- package/generator/parse-tokens.d.ts +0 -2
- package/generator/parser-types.d.ts +0 -4
- package/generator/style-generator.d.ts +0 -28
- package/parse-templates-D4p3pgQR.js +0 -92
- package/parse-templates-W0YfTmOT.cjs +0 -8
package/bin/main.js
CHANGED
@@ -1,141 +1,263 @@
|
|
1
|
-
import { Command as
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import
|
10
|
-
import
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
}), $ = (e) => {
|
16
|
-
n.error(e);
|
17
|
-
}, L = (e) => new Promise((c, g) => {
|
18
|
-
K(e, (w) => {
|
19
|
-
if (w) return g(w);
|
20
|
-
c();
|
1
|
+
import { Command as ot } from "commander";
|
2
|
+
import { existsSync as Q, watch as rt } from "fs";
|
3
|
+
import { mkdir as q, readFile as S, writeFile as C } from "fs/promises";
|
4
|
+
import { join as a, relative as z, parse as ct, format as et } from "path";
|
5
|
+
import { render as lt } from "ejs";
|
6
|
+
import { l as e, a as h, g as K, i as dt, b as ft } from "../index-CituHO0U.js";
|
7
|
+
import { p as pt } from "../pascal-case-BQpR5PdN.js";
|
8
|
+
import { exec as gt } from "child_process";
|
9
|
+
import ut from "ora";
|
10
|
+
import { c as yt } from "../should-restart-C6VJ-qaY.js";
|
11
|
+
const st = (u) => new Promise((v, k) => {
|
12
|
+
gt(u, ($) => {
|
13
|
+
if ($) return k($);
|
14
|
+
v();
|
21
15
|
});
|
22
|
-
}),
|
23
|
-
const
|
24
|
-
await
|
25
|
-
},
|
26
|
-
async function
|
16
|
+
}), E = async (...u) => {
|
17
|
+
const v = u.map((J) => J.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), k = ut(`Installing packages: ${v}`).start(), $ = u.join(" ");
|
18
|
+
await st(`npm install ${$}`), k.succeed(`Installed packages: ${v}`);
|
19
|
+
}, mt = () => Q(a(process.cwd(), "node_modules", ".bin", "prettier"));
|
20
|
+
async function j(u) {
|
27
21
|
try {
|
28
|
-
if (!
|
29
|
-
await
|
30
|
-
} catch (
|
31
|
-
|
22
|
+
if (!mt()) return;
|
23
|
+
await st(`./node_modules/.bin/prettier --write "${u}"`), e.info(`Formatted ${u} with Prettier`);
|
24
|
+
} catch (v) {
|
25
|
+
e.error(`Error formatting ${u} with Prettier:`, v);
|
32
26
|
}
|
33
27
|
}
|
34
|
-
async function
|
35
|
-
const
|
36
|
-
|
37
|
-
const
|
28
|
+
async function Jt() {
|
29
|
+
const u = new ot();
|
30
|
+
u.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
|
31
|
+
const v = {
|
38
32
|
// Core files
|
39
|
-
"salty.config.ts": import("../salty.config-
|
33
|
+
"salty.config.ts": import("../salty.config-BhBY_oOk.js"),
|
40
34
|
"saltygen/index.css": import("../index-D_732b92.js"),
|
41
35
|
// React
|
42
|
-
"react/react-styled-file.ts": import("../react-styled-file-CGVf5n1B.js")
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
36
|
+
"react/react-styled-file.ts": import("../react-styled-file-CGVf5n1B.js"),
|
37
|
+
"react/react-vanilla-file.ts": import("../react-vanilla-file-CCXbsjIb.js")
|
38
|
+
}, k = async (s, i) => {
|
39
|
+
const { default: d } = await v[s], l = lt(d, i);
|
40
|
+
return { fileName: s, content: l };
|
41
|
+
}, $ = async () => {
|
42
|
+
const s = a(process.cwd(), ".saltyrc.json");
|
43
|
+
return await S(s, "utf-8").then(JSON.parse).catch(() => ({}));
|
44
|
+
}, J = a(process.cwd(), "package.json"), O = async (s = J) => {
|
45
|
+
const i = await S(s, "utf-8").then(JSON.parse).catch(() => {
|
46
|
+
});
|
47
|
+
if (!i) throw "Could not read package.json file!";
|
48
|
+
return i;
|
49
|
+
}, nt = async (s, i = J) => {
|
50
|
+
typeof s == "object" && (s = JSON.stringify(s, null, 2)), await C(i, s);
|
51
|
+
}, X = async () => {
|
52
|
+
const s = new URL("../package.json", import.meta.url);
|
53
|
+
return O(s);
|
54
|
+
}, Y = await (async () => (await $()).defaultProject)(), N = await X(), A = {
|
55
|
+
core: `@salty-css/core@${N.version}`,
|
56
|
+
react: `@salty-css/react@${N.version}`,
|
57
|
+
eslintConfigCore: `@salty-css/eslint-config-core@${N.version}`,
|
58
|
+
vite: `@salty-css/vite@${N.version}`,
|
59
|
+
next: `@salty-css/next@${N.version}`
|
60
|
+
}, G = (s) => {
|
61
|
+
const i = s === "." ? "" : s, d = process.cwd();
|
62
|
+
return a(d, i);
|
57
63
|
};
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
await
|
65
|
-
const
|
66
|
-
|
67
|
-
|
64
|
+
u.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(s = ".") {
|
65
|
+
if (!await O().catch(() => {
|
66
|
+
})) return h("Salty CSS project must be initialized in a directory with a package.json file.");
|
67
|
+
e.info("Initializing a new Salty-CSS project!");
|
68
|
+
const { dir: d = s, cssFile: l, skipInstall: p } = this.opts();
|
69
|
+
if (!d) return h("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
|
70
|
+
p || await E(A.core, A.react);
|
71
|
+
const r = process.cwd(), o = G(d), T = await Promise.all([k("salty.config.ts"), k("saltygen/index.css")]);
|
72
|
+
await q(o, { recursive: !0 });
|
73
|
+
const y = T.map(async ({ fileName: t, content: g }) => {
|
74
|
+
const c = a(o, t);
|
75
|
+
if (await S(c, "utf-8").catch(() => {
|
68
76
|
}) !== void 0) {
|
69
|
-
|
77
|
+
e.debug("File already exists: " + c);
|
70
78
|
return;
|
71
79
|
}
|
72
|
-
const
|
73
|
-
|
80
|
+
const b = t.split("/").slice(0, -1).join("/");
|
81
|
+
b && await q(a(o, b), { recursive: !0 }), e.info("Creating file: " + c), await C(c, g), await j(c);
|
74
82
|
});
|
75
|
-
await Promise.all(
|
76
|
-
const
|
83
|
+
await Promise.all(y);
|
84
|
+
const w = z(r, o) || ".", m = a(r, ".saltyrc.json"), f = await S(m, "utf-8").catch(() => {
|
77
85
|
});
|
78
86
|
if (f === void 0) {
|
79
|
-
|
80
|
-
const
|
81
|
-
|
82
|
-
|
87
|
+
e.info("Creating file: " + m);
|
88
|
+
const g = JSON.stringify({
|
89
|
+
$schema: "./node_modules/@salty-css/core/.saltyrc.schema.json",
|
90
|
+
info: "This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.",
|
91
|
+
defaultProject: w,
|
92
|
+
projects: [
|
93
|
+
{
|
94
|
+
dir: w,
|
95
|
+
framework: "react"
|
96
|
+
}
|
97
|
+
]
|
83
98
|
}, null, 2);
|
84
|
-
await
|
99
|
+
await C(m, g), await j(m);
|
85
100
|
} else {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
101
|
+
const t = JSON.parse(f), g = (t == null ? void 0 : t.projects) || [];
|
102
|
+
if (g.findIndex((n) => n.dir === w) === -1) {
|
103
|
+
g.push({ dir: w, framework: "react" }), t.projects = [...g];
|
104
|
+
const n = JSON.stringify(t, null, 2);
|
105
|
+
n !== f && (e.info("Edit file: " + m), await C(m, n), await j(m));
|
106
|
+
}
|
91
107
|
}
|
92
|
-
const
|
108
|
+
const P = a(r, ".gitignore"), H = await S(P, "utf-8").catch(() => {
|
93
109
|
});
|
94
|
-
|
110
|
+
H !== void 0 && (H.includes("saltygen") || (e.info("Edit file: " + P), await C(P, H + `
|
95
111
|
|
96
112
|
# Salty-CSS
|
97
113
|
saltygen
|
98
|
-
`)))
|
99
|
-
|
114
|
+
`)));
|
115
|
+
const F = ["src", "public", "assets", "styles", "css", "app"], M = ["styles", "css", "app", "pages"], B = ["index", "styles", "main", "app", "global", "globals"], U = [".css", ".scss", ".sass"], D = await (async () => {
|
116
|
+
if (l) return l;
|
117
|
+
for (const t of F)
|
118
|
+
for (const g of B)
|
119
|
+
for (const c of U) {
|
120
|
+
const n = a(o, t, g + c);
|
121
|
+
if (await S(n, "utf-8").catch(() => {
|
122
|
+
}) !== void 0) return z(o, n);
|
123
|
+
for (const L of M) {
|
124
|
+
const R = a(o, t, L, g + c);
|
125
|
+
if (await S(R, "utf-8").catch(() => {
|
126
|
+
}) !== void 0) return z(o, R);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
})();
|
130
|
+
if (D) {
|
131
|
+
const t = a(o, D), g = await S(t, "utf-8").catch(() => {
|
100
132
|
});
|
101
|
-
if (
|
102
|
-
const
|
103
|
-
|
104
|
-
` +
|
133
|
+
if (g !== void 0 && !g.includes("saltygen")) {
|
134
|
+
const n = a(t, ".."), L = `@import '${z(n, a(o, "saltygen/index.css"))}';`;
|
135
|
+
e.info("Adding global import statement to CSS file: " + t), await C(t, L + `
|
136
|
+
` + g), await j(t);
|
105
137
|
}
|
138
|
+
} else
|
139
|
+
e.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");
|
140
|
+
const at = {
|
141
|
+
projectJs: a(o, "eslint.config.js"),
|
142
|
+
rootJs: a(r, "eslint.config.js"),
|
143
|
+
projectMjs: a(o, "eslint.config.mjs"),
|
144
|
+
rootMjs: a(r, "eslint.config.mjs"),
|
145
|
+
projectJson: a(o, ".eslintrc.json"),
|
146
|
+
rootJson: a(r, ".eslintrc.json")
|
147
|
+
}, x = Object.values(at).find((t) => Q(t));
|
148
|
+
if (x) {
|
149
|
+
p || await E(A.eslintConfigCore);
|
150
|
+
const t = await S(x, "utf-8").catch(() => {
|
151
|
+
});
|
152
|
+
if (!t) return h("Could not read ESLint config file.");
|
153
|
+
if (!t.includes("salty-css"))
|
154
|
+
if (e.info("Edit file: " + x), x.endsWith("js")) {
|
155
|
+
let n = `import saltyCss from "@salty-css/eslint-config-core/flat";
|
156
|
+
${t}`;
|
157
|
+
t.includes("typescript-eslint") ? n.includes(".config(") ? n = n.replace(".config(", ".config(saltyCss,") : e.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.") : n.includes("export default [") ? n = n.replace("export default [", "export default [ saltyCss,") : n.includes("eslintConfig = [") ? n = n.replace("eslintConfig = [", "eslintConfig = [ saltyCss,") : e.warn("Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."), await C(x, n), await j(x);
|
158
|
+
} else {
|
159
|
+
const c = JSON.parse(t);
|
160
|
+
c.extends || (c.extends = []), c.extends.push("@salty-css/core");
|
161
|
+
const n = JSON.stringify(c, null, 2);
|
162
|
+
await C(x, n), await j(x);
|
163
|
+
}
|
106
164
|
}
|
107
|
-
const
|
165
|
+
const W = a(o, "vite.config.ts"), V = await S(W, "utf-8").catch(() => {
|
108
166
|
});
|
109
|
-
if (
|
110
|
-
|
111
|
-
const
|
112
|
-
`,
|
167
|
+
if (V !== void 0 && !V.includes("saltyPlugin")) {
|
168
|
+
e.info("Edit file: " + W);
|
169
|
+
const g = `import { saltyPlugin } from '@salty-css/vite';
|
170
|
+
`, n = V.replace(/(plugins: \[)/, `$1
|
113
171
|
saltyPlugin(__dirname),`);
|
114
|
-
|
172
|
+
p || await E(`-D ${A.vite}`), e.info("Adding Salty-CSS plugin to Vite config..."), await C(W, g + n), await j(W);
|
173
|
+
}
|
174
|
+
const _ = ["next.config.js", "next.config.cjs", "next.config.ts", "next.config.mjs"].map((t) => a(o, t)).find((t) => Q(t));
|
175
|
+
if (_) {
|
176
|
+
let t = await S(_, "utf-8").catch(() => {
|
177
|
+
});
|
178
|
+
if (t !== void 0 && !t.includes("withSaltyCss")) {
|
179
|
+
let c = !1;
|
180
|
+
/\splugins([^=]*)=[^[]\[/.test(t) && !c && (t = t.replace(/\splugins([^=]*)=[^[]\[/, (R, I) => ` plugins${I}= [withSaltyCss,`), c = !0);
|
181
|
+
const b = t.includes("module.exports"), L = b ? `const { withSaltyCss } = require('@salty-css/next');
|
182
|
+
` : `import { withSaltyCss } from '@salty-css/next';
|
183
|
+
`;
|
184
|
+
b && !c ? (t = t.replace(/module.exports = ([^;]+)/, (R, I) => `module.exports = withSaltyCss(${I})`), c = !0) : c || (t = t.replace(/export default ([^;]+)/, (R, I) => `export default withSaltyCss(${I})`)), p || await E(`-D ${A.next}`), e.info("Adding Salty-CSS plugin to Next.js config..."), await C(_, L + t), await j(_);
|
185
|
+
}
|
115
186
|
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
const
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
if (
|
187
|
+
const it = await O().catch(() => h("Could not read package.json file.")).then((t) => (t.scripts || (t.scripts = {}), t.scripts.prepare ? t.scripts.prepare.includes("salty-css") || (e.info("Edit file: " + J), t.scripts.prepare = t.scripts.prepare + " && npx salty-css build") : (e.info("Edit file: " + J), t.scripts.prepare = "npx salty-css build"), t));
|
188
|
+
await nt(it), e.info("Running the build to generate initial CSS..."), await K(o), e.info("🎉 Salty CSS project initialized successfully!"), e.info("Next steps:"), e.info("1. Configure variables and templates in `salty.config.ts`"), e.info("2. Create a new component with `npx salty-css generate [component-name]`"), e.info("3. Run `npx salty-css build` to generate the CSS"), e.info("4. Read about the features in the documentation: https://salty-css.dev"), e.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐");
|
189
|
+
}), u.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").option("--watch", "Watch for changes and rebuild the project.").action(async function(s = Y) {
|
190
|
+
e.info("Building the Salty-CSS project...");
|
191
|
+
const { dir: i = s, watch: d } = this.opts();
|
192
|
+
if (!i) return h("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
|
193
|
+
const l = G(i);
|
194
|
+
await K(l), d && (e.info("Watching for changes in the project directory..."), rt(l, { recursive: !0 }, async (p, r) => {
|
195
|
+
await yt(r) ? await K(l, !1, !1) : dt(r) && await ft(l, r);
|
196
|
+
}));
|
197
|
+
}), u.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.").option("-r, --reactComponent", "Generate a React component as well.").action(async function(s, i = Y) {
|
198
|
+
const { file: d = s, dir: l = i, tag: p, name: r, className: o, reactComponent: T = !1 } = this.opts();
|
199
|
+
if (!d) return h("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
|
200
|
+
if (!l) return h("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
|
201
|
+
const y = G(l), w = d.split("/").slice(0, -1).join("/");
|
202
|
+
w && await q(a(y, w), { recursive: !0 });
|
203
|
+
const m = a(y, d), f = ct(m);
|
204
|
+
f.ext || (f.ext = ".ts"), f.name.endsWith(".css") || (f.name = f.name + ".css"), f.base = f.name + f.ext;
|
205
|
+
const P = et(f);
|
206
|
+
if (await S(P, "utf-8").catch(() => {
|
130
207
|
}) !== void 0) {
|
131
|
-
|
208
|
+
e.error("File already exists:", P);
|
132
209
|
return;
|
133
210
|
}
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
211
|
+
let F = pt(r || f.base.replace(/\.css\.\w+$/, ""));
|
212
|
+
if (T) {
|
213
|
+
const B = F + "Component";
|
214
|
+
F = F + "Wrapper";
|
215
|
+
const U = f.base.replace(/\.css\.\w+$/, ""), { content: tt } = await k("react/react-vanilla-file.ts", { tag: p, componentName: B, styledComponentName: F, className: o, fileName: U });
|
216
|
+
f.name = U.replace(/\.css$/, ""), f.ext = ".tsx", f.base = f.name + f.ext;
|
217
|
+
const D = et(f);
|
218
|
+
e.info("Generating a new file: " + D), await C(D, tt), await j(D);
|
219
|
+
}
|
220
|
+
const { content: M } = await k("react/react-styled-file.ts", { tag: p, name: F, className: o });
|
221
|
+
e.info("Generating a new file: " + P), await C(P, M), await j(P);
|
222
|
+
});
|
223
|
+
const Z = async () => {
|
224
|
+
const s = a(process.cwd(), "package.json"), i = await O(s).catch((p) => h(p));
|
225
|
+
if (!i) return h("Could not read package.json file.");
|
226
|
+
const d = { ...i.dependencies, ...i.devDependencies }, l = Object.entries(d).filter(([p]) => p === "salty-css" || p.startsWith("@salty-css/"));
|
227
|
+
return l.length ? l : h(
|
228
|
+
"No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + s
|
229
|
+
);
|
230
|
+
};
|
231
|
+
u.command("update [version]").alias("up").description("Update Salty-CSS packages to the latest or specified version.").option("-v, --version <version>", "Version to update to.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", !1).action(async function(s = "latest") {
|
232
|
+
const { legacyPeerDeps: i, version: d = s } = this.opts(), l = await Z();
|
233
|
+
if (!l) return h("Could not update Salty-CSS packages as any were found in package.json.");
|
234
|
+
const p = l.map(([y]) => d === "@" ? `${y}@${N.version}` : `${y}@${d.replace(/^@/, "")}`);
|
235
|
+
i ? (e.warn("Using legacy peer dependencies to update packages."), await E(...p, "--legacy-peer-deps")) : await E(...p);
|
236
|
+
const r = await Z();
|
237
|
+
if (!r) return h("Something went wrong while reading the updated packages.");
|
238
|
+
const o = r.reduce((y, [w, m]) => (y[m] || (y[m] = []), y[m].push(w), y), {});
|
239
|
+
if (Object.keys(o).length === 1) {
|
240
|
+
const w = Object.keys(o)[0].replace(/^\^/, "");
|
241
|
+
e.info(`Updated to all Salty CSS packages successfully to ${w}`);
|
242
|
+
} else
|
243
|
+
for (const [y, w] of Object.entries(o)) {
|
244
|
+
const m = y.replace(/^\^/, "");
|
245
|
+
e.info(`Updated to ${m}: ${w.join(", ")}`);
|
246
|
+
}
|
247
|
+
}), u.option("-v, --version", "Show the current version of Salty-CSS.").action(async function() {
|
248
|
+
const s = await X();
|
249
|
+
e.info("CLI is running: " + s.version);
|
250
|
+
const i = a(process.cwd(), "package.json"), d = await O(i).catch((r) => h(r));
|
251
|
+
if (!d) return;
|
252
|
+
const l = { ...d.dependencies, ...d.devDependencies }, p = Object.keys(l).filter((r) => r === "salty-css" || r.startsWith("@salty-css/"));
|
253
|
+
if (!p.length)
|
254
|
+
return h(
|
255
|
+
"No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + i
|
256
|
+
);
|
257
|
+
for (const r of p)
|
258
|
+
e.info(`${r}: ${l[r]}`);
|
259
|
+
}), u.parseAsync(process.argv);
|
138
260
|
}
|
139
261
|
export {
|
140
|
-
|
262
|
+
Jt as main
|
141
263
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("fs/promises"),r=require("path"),t=require("../helpers-CC5pFyba.cjs"),i=async()=>{const o=t.getCorePackageRoot(),c=r.join(o,"cache/config-cache.json"),e=await n.readFile(c,"utf8");if(!e)throw new Error("Could not find config cache file");return JSON.parse(e)};exports.resolveDynamicConfigCache=i;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const resolveDynamicConfigCache: () => Promise<any>;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { readFile as r } from "fs/promises";
|
2
|
+
import { join as t } from "path";
|
3
|
+
import { g as n } from "../helpers-nHqH4L9L.js";
|
4
|
+
const s = async () => {
|
5
|
+
const e = n(), c = t(e, "cache/config-cache.json"), o = await r(c, "utf8");
|
6
|
+
if (!o) throw new Error("Could not find config cache file");
|
7
|
+
return JSON.parse(o);
|
8
|
+
};
|
9
|
+
export {
|
10
|
+
s as resolveDynamicConfigCache
|
11
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getFunctionRange: (contents: string, name: string) => Promise<[number, number]>;
|
package/compiler/index.cjs
CHANGED
@@ -1,11 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
2
|
-
`),v=P.toHash(i,6),d=o.join(s,`css/${v}.css`);r.writeFileSync(d,F)}}await S(t,s);const l=e.map(i=>`@import url('./css/${i}');`).join(`
|
3
|
-
`);let f=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
4
|
-
|
5
|
-
${["@import url('./css/variables.css');","@import url('./css/global.css');","@import url('./css/templates.css');"].join(`
|
6
|
-
`)}
|
7
|
-
${l}`;if(j.importStrategy!=="component"){const i=n.flat().map(g=>`@import url('./css/${g}');`).join(`
|
8
|
-
`);f+=i}r.writeFileSync(a,f)}catch(e){console.error(e)}},L=async(t,e)=>{try{const n=[],s=o.join(t,"./saltygen"),a=o.join(s,"index.css");if(O(e)){const j=await E(t),S=await T(e,s);Object.entries(S).forEach(([g,$])=>{if(!$.generator)return;const m=$.generator._withBuildContext({name:g,config:j}),u=`${m.hash}-${m.priority}.css`,h=`css/${u}`,F=o.join(s,h);n.push(u),r.writeFileSync(F,m.css)});const l=r.readFileSync(a,"utf8").split(`
|
9
|
-
`),b=n.map(g=>`@import url('../saltygen/css/${g}');`),i=[...new Set([...l,...b])].join(`
|
10
|
-
`);r.writeFileSync(a,i)}}catch(n){console.error(n)}},U=async(t,e)=>{try{const n=o.join(t,"./saltygen");if(O(e)){const a=r.readFileSync(e,"utf8");a.replace(/^(?!export\s)const\s.*/gm,f=>`export ${f}`)!==a&&await K.writeFile(e,a);const j=await E(t),S=await T(e,n);let l=a;Object.entries(S).forEach(([f,i])=>{var F;if(i.isKeyframes){console.log("value",i);return}if(!i.generator)return;const g=i.generator._withBuildContext({name:f,config:j}),$=new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!$)return console.error("Could not find the original declaration");const m=(F=$.at(1))==null?void 0:F.trim(),u=`${f} = styled(${m}, "${g.classNames}", "${g._callerName}", ${JSON.stringify(g.props)});`,h=new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`,"g");l=l.replace(h,u)});const b=P.toHash(e,6);return j.importStrategy==="component"&&(l=`import '../../saltygen/css/${b}.css';
|
11
|
-
${l}`),l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error(n)}};exports.compileSaltyFile=T;exports.generateConfigStyles=M;exports.generateCss=A;exports.generateFile=L;exports.isSaltyFile=O;exports.minimizeFile=U;exports.saltyFileExtensions=_;exports.saltyFileRegExp=q;
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-styles-B1E0JeC7.cjs");require("../parsers/index.cjs");const e=require("../index-ol1Q_xul.cjs");require("../css/merge.cjs");require("../define-templates-Cunsb_Tr.cjs");require("../helpers-CC5pFyba.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
|
package/compiler/index.d.ts
CHANGED
@@ -1,16 +1,24 @@
|
|
1
|
-
import { StyleComponentGenerator } from '../generator/style-generator';
|
2
1
|
export declare const saltyFileExtensions: string[];
|
3
2
|
export declare const saltyFileRegExp: (additional?: string[]) => RegExp;
|
4
3
|
export declare const isSaltyFile: (file: string, additional?: string[]) => boolean;
|
5
|
-
export declare const generateConfigStyles: (dirname: string) => Promise<void>;
|
6
|
-
export declare const compileSaltyFile: (sourceFilePath: string, outputDirectory: string) => Promise<{
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
export declare const generateConfigStyles: (dirname: string, configFiles: Set<string>) => Promise<void>;
|
5
|
+
export declare const compileSaltyFile: (dirname: string, sourceFilePath: string, outputDirectory: string) => Promise<{
|
6
|
+
contents: {
|
7
|
+
[key: string]: {
|
8
|
+
generator: any;
|
9
|
+
isClassName?: boolean;
|
10
|
+
isMedia?: boolean;
|
11
|
+
isGlobalDefine?: boolean;
|
12
|
+
isDefineVariables?: boolean;
|
13
|
+
isDefineTemplates?: boolean;
|
14
|
+
isKeyframes?: boolean;
|
15
|
+
animationName?: string;
|
16
|
+
css?: Promise<string>;
|
17
|
+
styles?: any;
|
18
|
+
};
|
12
19
|
};
|
20
|
+
outputFilePath: string;
|
13
21
|
}>;
|
14
|
-
export declare const generateCss: (dirname: string) => Promise<void>;
|
15
|
-
export declare const generateFile: (dirname: string, file: string) => Promise<void>;
|
16
|
-
export declare const minimizeFile: (dirname: string, file: string) => Promise<string | undefined>;
|
22
|
+
export declare const generateCss: (dirname: string, prod?: boolean, clean?: boolean) => Promise<void>;
|
23
|
+
export declare const generateFile: (dirname: string, file: string, prod?: boolean) => Promise<void>;
|
24
|
+
export declare const minimizeFile: (dirname: string, file: string, prod?: boolean) => Promise<string | undefined>;
|