@salty-css/core 0.2.1 → 0.2.2-refactor-vite-8.5

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 (304) hide show
  1. package/dist/astro-component-Ov1RH0CO.js +4 -0
  2. package/dist/astro-component-r0qEcF1p.cjs +14 -0
  3. package/{bin → dist/bin}/bin-util.d.ts +1 -0
  4. package/dist/bin/bin-util.d.ts.map +1 -0
  5. package/{bin → dist/bin}/commands/build.d.ts +1 -0
  6. package/dist/bin/commands/build.d.ts.map +1 -0
  7. package/{bin → dist/bin}/commands/generate.d.ts +1 -0
  8. package/dist/bin/commands/generate.d.ts.map +1 -0
  9. package/{bin → dist/bin}/commands/init.d.ts +1 -0
  10. package/dist/bin/commands/init.d.ts.map +1 -0
  11. package/{bin → dist/bin}/commands/update.d.ts +1 -0
  12. package/dist/bin/commands/update.d.ts.map +1 -0
  13. package/{bin → dist/bin}/commands/version.d.ts +1 -0
  14. package/dist/bin/commands/version.d.ts.map +1 -0
  15. package/{bin → dist/bin}/confirm-install.d.ts +1 -0
  16. package/dist/bin/confirm-install.d.ts.map +1 -0
  17. package/{bin → dist/bin}/context.d.ts +1 -0
  18. package/dist/bin/context.d.ts.map +1 -0
  19. package/{bin → dist/bin}/detection/css-file.d.ts +1 -0
  20. package/dist/bin/detection/css-file.d.ts.map +1 -0
  21. package/{bin → dist/bin}/frameworks/astro.d.ts +1 -0
  22. package/dist/bin/frameworks/astro.d.ts.map +1 -0
  23. package/{bin → dist/bin}/frameworks/index.d.ts +1 -0
  24. package/dist/bin/frameworks/index.d.ts.map +1 -0
  25. package/{bin → dist/bin}/frameworks/react.d.ts +1 -0
  26. package/dist/bin/frameworks/react.d.ts.map +1 -0
  27. package/{bin → dist/bin}/frameworks/types.d.ts +1 -0
  28. package/dist/bin/frameworks/types.d.ts.map +1 -0
  29. package/dist/bin/index.cjs +2 -0
  30. package/dist/bin/index.d.ts +3 -0
  31. package/dist/bin/index.d.ts.map +1 -0
  32. package/dist/bin/index.js +5 -0
  33. package/{bin → dist/bin}/integrations/astro.d.ts +1 -0
  34. package/dist/bin/integrations/astro.d.ts.map +1 -0
  35. package/{bin → dist/bin}/integrations/eslint.d.ts +1 -0
  36. package/dist/bin/integrations/eslint.d.ts.map +1 -0
  37. package/{bin → dist/bin}/integrations/index.d.ts +1 -0
  38. package/dist/bin/integrations/index.d.ts.map +1 -0
  39. package/{bin → dist/bin}/integrations/next.d.ts +1 -0
  40. package/dist/bin/integrations/next.d.ts.map +1 -0
  41. package/{bin → dist/bin}/integrations/types.d.ts +1 -0
  42. package/dist/bin/integrations/types.d.ts.map +1 -0
  43. package/{bin → dist/bin}/integrations/vite.d.ts +1 -0
  44. package/dist/bin/integrations/vite.d.ts.map +1 -0
  45. package/{bin → dist/bin}/logger.d.ts +1 -0
  46. package/dist/bin/logger.d.ts.map +1 -0
  47. package/dist/bin/main.cjs +1 -0
  48. package/{bin → dist/bin}/main.d.ts +1 -0
  49. package/dist/bin/main.d.ts.map +1 -0
  50. package/dist/bin/main.js +2 -0
  51. package/{bin → dist/bin}/package-json.d.ts +1 -0
  52. package/dist/bin/package-json.d.ts.map +1 -0
  53. package/{bin → dist/bin}/path-defaults.d.ts +1 -0
  54. package/dist/bin/path-defaults.d.ts.map +1 -0
  55. package/{bin → dist/bin}/prettier.d.ts +1 -0
  56. package/dist/bin/prettier.d.ts.map +1 -0
  57. package/{bin → dist/bin}/saltyrc.d.ts +1 -0
  58. package/dist/bin/saltyrc.d.ts.map +1 -0
  59. package/dist/bin/templates.d.ts +15 -0
  60. package/dist/bin/templates.d.ts.map +1 -0
  61. package/dist/chunk-CMqjfN_6.cjs +1 -0
  62. package/dist/compiler/get-files.cjs +1 -0
  63. package/{compiler → dist/compiler}/get-files.d.ts +1 -0
  64. package/dist/compiler/get-files.d.ts.map +1 -0
  65. package/dist/compiler/get-files.js +15 -0
  66. package/dist/compiler/get-function-range.cjs +1 -0
  67. package/{compiler → dist/compiler}/get-function-range.d.ts +1 -0
  68. package/dist/compiler/get-function-range.d.ts.map +1 -0
  69. package/dist/compiler/get-function-range.js +17 -0
  70. package/dist/compiler/helpers.cjs +1 -0
  71. package/{compiler → dist/compiler}/helpers.d.ts +1 -0
  72. package/dist/compiler/helpers.d.ts.map +1 -0
  73. package/dist/compiler/helpers.js +24 -0
  74. package/{compiler → dist/compiler}/resolve-import.d.ts +1 -0
  75. package/dist/compiler/resolve-import.d.ts.map +1 -0
  76. package/dist/compiler/salty-compiler.cjs +1 -0
  77. package/{compiler → dist/compiler}/salty-compiler.d.ts +1 -0
  78. package/dist/compiler/salty-compiler.d.ts.map +1 -0
  79. package/dist/compiler/salty-compiler.js +2 -0
  80. package/{config → dist/config}/define-config.d.ts +1 -0
  81. package/dist/config/define-config.d.ts.map +1 -0
  82. package/dist/config/index.cjs +1 -0
  83. package/{config → dist/config}/index.d.ts +1 -0
  84. package/dist/config/index.d.ts.map +1 -0
  85. package/dist/config/index.js +5 -0
  86. package/dist/css/index.cjs +1 -0
  87. package/{css → dist/css}/index.d.ts +1 -0
  88. package/dist/css/index.d.ts.map +1 -0
  89. package/dist/css/index.js +5 -0
  90. package/dist/css/keyframes.cjs +1 -0
  91. package/{css → dist/css}/keyframes.d.ts +1 -0
  92. package/dist/css/keyframes.d.ts.map +1 -0
  93. package/dist/css/keyframes.js +30 -0
  94. package/dist/css/media.cjs +1 -0
  95. package/{css → dist/css}/media.d.ts +1 -0
  96. package/dist/css/media.d.ts.map +1 -0
  97. package/dist/css/media.js +84 -0
  98. package/dist/css/merge.cjs +1 -0
  99. package/{css → dist/css}/merge.d.ts +1 -0
  100. package/dist/css/merge.d.ts.map +1 -0
  101. package/dist/css/merge.js +20 -0
  102. package/dist/css/token.cjs +1 -0
  103. package/{css → dist/css}/token.d.ts +1 -0
  104. package/dist/css/token.d.ts.map +1 -0
  105. package/dist/css/token.js +4 -0
  106. package/{factories → dist/factories}/define-font.d.ts +1 -0
  107. package/dist/factories/define-font.d.ts.map +1 -0
  108. package/{factories → dist/factories}/define-global-styles.d.ts +1 -0
  109. package/dist/factories/define-global-styles.d.ts.map +1 -0
  110. package/{factories → dist/factories}/define-import.d.ts +1 -0
  111. package/dist/factories/define-import.d.ts.map +1 -0
  112. package/{factories → dist/factories}/define-media-query.d.ts +1 -0
  113. package/dist/factories/define-media-query.d.ts.map +1 -0
  114. package/{factories → dist/factories}/define-templates.d.ts +1 -0
  115. package/dist/factories/define-templates.d.ts.map +1 -0
  116. package/{factories → dist/factories}/define-variables.d.ts +1 -0
  117. package/dist/factories/define-variables.d.ts.map +1 -0
  118. package/dist/factories/index.cjs +1 -0
  119. package/{factories → dist/factories}/index.d.ts +1 -0
  120. package/dist/factories/index.d.ts.map +1 -0
  121. package/dist/factories/index.js +149 -0
  122. package/{generators → dist/generators}/class-name-generator.d.ts +1 -0
  123. package/dist/generators/class-name-generator.d.ts.map +1 -0
  124. package/dist/generators/index.cjs +1 -0
  125. package/{generators → dist/generators}/index.d.ts +1 -0
  126. package/dist/generators/index.d.ts.map +1 -0
  127. package/dist/generators/index.js +2 -0
  128. package/{generators → dist/generators}/styled-generator.d.ts +1 -0
  129. package/dist/generators/styled-generator.d.ts.map +1 -0
  130. package/{generators → dist/generators}/styles-generator.d.ts +1 -0
  131. package/dist/generators/styles-generator.d.ts.map +1 -0
  132. package/dist/generators-CrK45F8i.js +112 -0
  133. package/dist/generators-eEKEtyAm.cjs +1 -0
  134. package/{helpers → dist/helpers}/color.d.ts +1 -0
  135. package/dist/helpers/color.d.ts.map +1 -0
  136. package/dist/helpers/index.cjs +1 -0
  137. package/{helpers → dist/helpers}/index.d.ts +1 -0
  138. package/dist/helpers/index.d.ts.map +1 -0
  139. package/dist/helpers/index.js +33 -0
  140. package/{helpers → dist/helpers}/viewport-clamp.d.ts +1 -0
  141. package/dist/helpers/viewport-clamp.d.ts.map +1 -0
  142. package/dist/instances/classname-instance.cjs +1 -0
  143. package/{instances → dist/instances}/classname-instance.d.ts +1 -0
  144. package/dist/instances/classname-instance.d.ts.map +1 -0
  145. package/dist/instances/classname-instance.js +18 -0
  146. package/dist/main-DGpSu6zK.js +545 -0
  147. package/dist/main-LnoqOq21.cjs +11 -0
  148. package/dist/maybe.d.ts +2 -0
  149. package/dist/maybe.d.ts.map +1 -0
  150. package/dist/parse-styles-2rwbF9j_.cjs +3 -0
  151. package/dist/parse-styles-Bz0otiZ-.js +336 -0
  152. package/dist/parsers/index.cjs +3 -0
  153. package/{parsers → dist/parsers}/index.d.ts +1 -0
  154. package/dist/parsers/index.d.ts.map +1 -0
  155. package/dist/parsers/index.js +79 -0
  156. package/{parsers → dist/parsers}/parse-modifiers.d.ts +1 -0
  157. package/dist/parsers/parse-modifiers.d.ts.map +1 -0
  158. package/{parsers → dist/parsers}/parse-styles.d.ts +1 -0
  159. package/dist/parsers/parse-styles.d.ts.map +1 -0
  160. package/{parsers → dist/parsers}/parse-templates.d.ts +1 -0
  161. package/dist/parsers/parse-templates.d.ts.map +1 -0
  162. package/{parsers → dist/parsers}/parse-tokens.d.ts +1 -0
  163. package/dist/parsers/parse-tokens.d.ts.map +1 -0
  164. package/{parsers → dist/parsers}/parser-regexes.d.ts +1 -0
  165. package/dist/parsers/parser-regexes.d.ts.map +1 -0
  166. package/{parsers → dist/parsers}/parser-types.d.ts +1 -0
  167. package/dist/parsers/parser-types.d.ts.map +1 -0
  168. package/{parsers → dist/parsers}/property-name-check.d.ts +1 -0
  169. package/dist/parsers/property-name-check.d.ts.map +1 -0
  170. package/{parsers → dist/parsers}/resolve-template-variants.d.ts +1 -0
  171. package/dist/parsers/resolve-template-variants.d.ts.map +1 -0
  172. package/{parsers → dist/parsers}/strict.d.ts +1 -0
  173. package/dist/parsers/strict.d.ts.map +1 -0
  174. package/{parsers → dist/parsers}/unit-check.d.ts +1 -0
  175. package/dist/parsers/unit-check.d.ts.map +1 -0
  176. package/dist/runtime/index.cjs +2 -0
  177. package/{runtime → dist/runtime}/index.d.ts +1 -0
  178. package/dist/runtime/index.d.ts.map +1 -0
  179. package/dist/runtime/index.js +20 -0
  180. package/dist/salty-compiler-Bvd0OKHz.cjs +33 -0
  181. package/dist/salty-compiler-CvQ-rsex.js +484 -0
  182. package/dist/salty.config-B0ZiRpHR.cjs +7 -0
  183. package/dist/salty.config-DWF4i7K0.js +4 -0
  184. package/dist/server/index.cjs +1 -0
  185. package/dist/server/index.d.ts +2 -0
  186. package/dist/server/index.d.ts.map +1 -0
  187. package/dist/server/index.js +12 -0
  188. package/{server → dist/server}/should-restart.d.ts +1 -0
  189. package/dist/server/should-restart.d.ts.map +1 -0
  190. package/{styled-file-Cda3EeR6.js → dist/styled-file-BCbAEzBB.cjs} +2 -5
  191. package/dist/styled-file-C_4eLAdV.js +4 -0
  192. package/dist/styled-file-DQHLzmuL.js +4 -0
  193. package/{styled-file-DLcgYmGN.js → dist/styled-file-DorArlCk.cjs} +2 -5
  194. package/{templates → dist/templates}/salty-reset.d.ts +1 -0
  195. package/dist/templates/salty-reset.d.ts.map +1 -0
  196. package/dist/templates-BGHLaAOm.cjs +1 -0
  197. package/dist/templates-DWWLjEiU.js +4 -0
  198. package/{types → dist/types}/cli-types.d.ts +1 -0
  199. package/dist/types/cli-types.d.ts.map +1 -0
  200. package/{types → dist/types}/config-types.d.ts +1 -0
  201. package/dist/types/config-types.d.ts.map +1 -0
  202. package/{types → dist/types}/font-types.d.ts +1 -0
  203. package/dist/types/font-types.d.ts.map +1 -0
  204. package/dist/types/index.cjs +0 -0
  205. package/{types → dist/types}/index.d.ts +1 -0
  206. package/dist/types/index.d.ts.map +1 -0
  207. package/dist/types/index.js +0 -0
  208. package/{types → dist/types}/util-types.d.ts +1 -0
  209. package/dist/types/util-types.d.ts.map +1 -0
  210. package/{util → dist/util}/camel-case.d.ts +1 -0
  211. package/dist/util/camel-case.d.ts.map +1 -0
  212. package/{util → dist/util}/dash-case.d.ts +1 -0
  213. package/dist/util/dash-case.d.ts.map +1 -0
  214. package/{util → dist/util}/dot-case.d.ts +1 -0
  215. package/dist/util/dot-case.d.ts.map +1 -0
  216. package/{util → dist/util}/glob-match.d.ts +1 -0
  217. package/dist/util/glob-match.d.ts.map +1 -0
  218. package/dist/util/index.cjs +1 -0
  219. package/{util → dist/util}/index.d.ts +1 -0
  220. package/dist/util/index.d.ts.map +1 -0
  221. package/dist/util/index.js +72 -0
  222. package/{util → dist/util}/module-type.d.ts +1 -0
  223. package/dist/util/module-type.d.ts.map +1 -0
  224. package/{util → dist/util}/pascal-case.d.ts +1 -0
  225. package/dist/util/pascal-case.d.ts.map +1 -0
  226. package/{util → dist/util}/to-hash.d.ts +1 -0
  227. package/dist/util/to-hash.d.ts.map +1 -0
  228. package/dist/vanilla-file-BEqMIe-6.js +4 -0
  229. package/{vanilla-file-1kOqbCIM.js → dist/vanilla-file-Z3VsOa_U.cjs} +2 -5
  230. package/dist/viewport-clamp-CHOyzt37.cjs +1 -0
  231. package/dist/viewport-clamp-CRtzRvJ3.js +7 -0
  232. package/package.json +67 -64
  233. package/README.md +0 -535
  234. package/astro-component-5hrNTCJ5.js +0 -4
  235. package/astro-component-Dj3enX6K.cjs +0 -4
  236. package/bin/index.cjs +0 -4
  237. package/bin/index.d.ts +0 -2
  238. package/bin/index.js +0 -3
  239. package/bin/main.cjs +0 -783
  240. package/bin/main.js +0 -782
  241. package/bin/templates.d.ts +0 -14
  242. package/class-name-generator-BcbeZdcV.cjs +0 -88
  243. package/class-name-generator-DJ27JHW_.js +0 -89
  244. package/compiler/get-files.cjs +0 -25
  245. package/compiler/get-files.js +0 -25
  246. package/compiler/get-function-range.cjs +0 -22
  247. package/compiler/get-function-range.js +0 -22
  248. package/compiler/helpers.cjs +0 -34
  249. package/compiler/helpers.js +0 -33
  250. package/compiler/salty-compiler.cjs +0 -845
  251. package/compiler/salty-compiler.js +0 -827
  252. package/config/index.cjs +0 -20
  253. package/config/index.js +0 -20
  254. package/css/index.cjs +0 -12
  255. package/css/index.js +0 -12
  256. package/css/keyframes.cjs +0 -49
  257. package/css/keyframes.js +0 -49
  258. package/css/media.cjs +0 -93
  259. package/css/media.js +0 -93
  260. package/css/merge.cjs +0 -20
  261. package/css/merge.js +0 -20
  262. package/css/token.cjs +0 -4
  263. package/css/token.js +0 -4
  264. package/define-templates-CVhhgPnd.js +0 -60
  265. package/define-templates-Deq1aCbN.cjs +0 -59
  266. package/factories/index.cjs +0 -177
  267. package/factories/index.js +0 -177
  268. package/generators/index.cjs +0 -58
  269. package/generators/index.js +0 -59
  270. package/glob-match-C28iYp1A.js +0 -74
  271. package/glob-match-CT1uFlp-.cjs +0 -73
  272. package/helpers/index.cjs +0 -53
  273. package/helpers/index.js +0 -53
  274. package/index-ByR0nfaf.cjs +0 -4
  275. package/index-DKz1QXqs.js +0 -4
  276. package/instances/classname-instance.cjs +0 -31
  277. package/instances/classname-instance.js +0 -31
  278. package/parse-styles-BlUpavVg.js +0 -521
  279. package/parse-styles-DWT4tDyS.cjs +0 -520
  280. package/parsers/index.cjs +0 -147
  281. package/parsers/index.js +0 -148
  282. package/pascal-case-By_l58S-.cjs +0 -7
  283. package/pascal-case-F3Usi5Wf.js +0 -8
  284. package/runtime/index.cjs +0 -24
  285. package/runtime/index.js +0 -24
  286. package/salty.config-DogY_sSQ.cjs +0 -4
  287. package/salty.config-GV37Q-D2.js +0 -4
  288. package/server/index.cjs +0 -4
  289. package/server/index.d.ts +0 -1
  290. package/server/index.js +0 -4
  291. package/should-restart-CQsyHls3.cjs +0 -17
  292. package/should-restart-CXIO0jxY.js +0 -18
  293. package/styled-file-BzmB9_Ez.cjs +0 -12
  294. package/styled-file-CPd_rTW2.cjs +0 -11
  295. package/to-hash-DSoCPs8D.js +0 -33
  296. package/to-hash-DT2ImSPA.cjs +0 -32
  297. package/types/index.cjs +0 -1
  298. package/types/index.js +0 -1
  299. package/util/index.cjs +0 -18
  300. package/util/index.js +0 -18
  301. package/vanilla-file-r0fp2q_m.cjs +0 -18
  302. package/viewport-clamp-CEmzmcSj.cjs +0 -10
  303. package/viewport-clamp-K553uXu3.js +0 -11
  304. /package/{.saltyrc.schema.json → dist/.saltyrc.schema.json} +0 -0
@@ -0,0 +1,545 @@
1
+ import { n as e, r as t, t as n } from "./salty-compiler-CvQ-rsex.js";
2
+ import { isSaltyFile as r } from "./compiler/helpers.js";
3
+ import { pascalCase as i } from "./util/index.js";
4
+ import { checkShouldRestart as a } from "./server/index.js";
5
+ import { Command as o } from "commander";
6
+ import { existsSync as s, watch as c } from "fs";
7
+ import { format as l, join as u, parse as d, relative as f } from "path";
8
+ import { mkdir as p, readFile as m, writeFile as h } from "fs/promises";
9
+ import { exec as g } from "child_process";
10
+ import _ from "ora";
11
+ import v from "ejs";
12
+ import { createInterface as y } from "readline/promises";
13
+ //#region src/bin/package-json.ts
14
+ var b = u(process.cwd(), "package.json"), x = async (e = b) => {
15
+ let t = await m(e, "utf-8").then(JSON.parse).catch(() => void 0);
16
+ if (!t) throw "Could not read package.json file!";
17
+ return t;
18
+ }, S = async (e, t = b) => {
19
+ typeof e == "object" && (e = JSON.stringify(e, null, 2)), await h(t, e);
20
+ }, C = async () => x(new URL("../package.json", "" + import.meta.url)), w = {
21
+ core: (e) => `@salty-css/core@${e}`,
22
+ eslintConfigCore: (e) => `@salty-css/eslint-config-core@${e}`
23
+ }, T = (e) => {
24
+ e.scripts ||= {};
25
+ let t = e.scripts.prepare;
26
+ if (t) {
27
+ if (t.includes("salty-css")) return {
28
+ changed: !1,
29
+ pkg: e
30
+ };
31
+ e.scripts.prepare = t + " && npx salty-css build";
32
+ } else e.scripts.prepare = "npx salty-css build";
33
+ return {
34
+ changed: !0,
35
+ pkg: e
36
+ };
37
+ }, E = (e) => new Promise((t, n) => {
38
+ g(e, (e) => {
39
+ if (e) return n(e);
40
+ t();
41
+ });
42
+ }), D = async (...e) => {
43
+ let t = e.map((e) => e.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), n = _(`Installing packages: ${t}`).start();
44
+ await E(`npm install ${e.join(" ")}`), n.succeed(`Installed packages: ${t}`);
45
+ }, ee = () => s(u(process.cwd(), "node_modules", ".bin", "prettier"));
46
+ async function O(e) {
47
+ try {
48
+ if (!ee()) return;
49
+ await E(`./node_modules/.bin/prettier --write "${e}"`), t.info(`Formatted ${e} with Prettier`);
50
+ } catch (n) {
51
+ t.error(`Error formatting ${e} with Prettier:`, n);
52
+ }
53
+ }
54
+ var k = (e = process.cwd()) => u(e, ".saltyrc.json"), A = async (e = process.cwd()) => await m(k(e), "utf-8").then(JSON.parse).catch(() => ({})), j = async (e = process.cwd()) => m(k(e), "utf-8").catch(() => void 0), M = async (e = process.cwd()) => (await A(e)).defaultProject, N = (e, t, n, r = {}) => {
55
+ let i = u(t, n.srcDirectory), a = {
56
+ dir: i,
57
+ framework: n.name,
58
+ ...r
59
+ };
60
+ if (e === void 0) return {
61
+ content: JSON.stringify({
62
+ $schema: "./node_modules/@salty-css/core/.saltyrc.schema.json",
63
+ 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.",
64
+ defaultProject: i,
65
+ projects: [a]
66
+ }, null, 2),
67
+ changed: !0,
68
+ created: !0
69
+ };
70
+ let o = JSON.parse(e), s = o.projects || [];
71
+ if (s.some((e) => e.dir === i)) return {
72
+ content: e,
73
+ changed: !1,
74
+ created: !1
75
+ };
76
+ s.push(a), o.projects = [...s];
77
+ let c = JSON.stringify(o, null, 2);
78
+ return {
79
+ content: c,
80
+ changed: c !== e,
81
+ created: !1
82
+ };
83
+ }, P = async (e, n, r, i = {}) => {
84
+ let a = k(e), { content: o, changed: s, created: c } = N(await j(e), n, r, i);
85
+ return s ? (c ? t.info("Creating file: " + a) : t.info("Edit file: " + a), await h(a, o), await O(a), !0) : !1;
86
+ }, F = (e, t) => (e.projects || []).find((e) => e.dir === t)?.framework, I = (e, t = process.cwd()) => u(t, e === "." ? "" : e), L = async (e) => {
87
+ let t = process.cwd(), n = I(e.dir, t), r = f(t, n) || ".", i = await x().catch(() => void 0);
88
+ if (e.requirePackageJson !== !1 && !i) throw Error("Salty CSS project must be initialized in a directory with a package.json file.");
89
+ return {
90
+ cwd: t,
91
+ projectDir: n,
92
+ relativeProjectPath: r,
93
+ packageJson: i,
94
+ rcFile: await A(t),
95
+ cliVersion: (await C()).version || "0.0.0",
96
+ skipInstall: !!e.skipInstall,
97
+ yes: !!e.yes
98
+ };
99
+ }, te = (i, o) => {
100
+ i.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.").option("--mode <mode>", "Build mode: \"production\" or \"development\". Defaults to NODE_ENV-based detection.").action(async function(i = o) {
101
+ t.info("Building the Salty-CSS project...");
102
+ let { dir: s = i, watch: l, mode: u } = this.opts();
103
+ if (u !== void 0 && u !== "production" && u !== "development") return e(`Invalid --mode "${u}". Expected "production" or "development".`);
104
+ let d = s ?? await M();
105
+ if (!d) return e("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
106
+ let f = I(d), p = new n(f, { mode: u });
107
+ await p.generateCss(), l && (t.info("Watching for changes in the project directory..."), c(f, { recursive: !0 }, async (e, t) => {
108
+ if (!t) return console.warn("File path not provided for change event");
109
+ await a(t) ? await p.generateCss(!1) : r(t) && await p.generateFile(t);
110
+ }));
111
+ });
112
+ }, ne = [
113
+ "astro.config.mjs",
114
+ "astro.config.ts",
115
+ "astro.config.js",
116
+ "astro.config.cjs"
117
+ ], R = (e) => {
118
+ for (let t of ne) {
119
+ let n = u(e, t);
120
+ if (s(n)) return n;
121
+ }
122
+ return null;
123
+ }, z = (e) => {
124
+ let t = e.packageJson;
125
+ if (!t) return !1;
126
+ let n = {
127
+ ...t.dependencies,
128
+ ...t.devDependencies
129
+ };
130
+ return Object.prototype.hasOwnProperty.call(n, "astro");
131
+ }, B = {
132
+ name: "astro",
133
+ srcDirectory: "src",
134
+ detect: (e) => !!R(e.projectDir) || z(e),
135
+ runtimePackage: (e) => `@salty-css/astro@${e}`,
136
+ templates: {
137
+ styled: "astro/styled-file.ts",
138
+ component: {
139
+ styled: "astro/styled-file.ts",
140
+ wrapper: "astro/component.astro",
141
+ wrapperExt: ".astro"
142
+ }
143
+ }
144
+ }, V = {
145
+ name: "react",
146
+ srcDirectory: "",
147
+ detect: () => !0,
148
+ runtimePackage: (e) => `@salty-css/react@${e}`,
149
+ templates: {
150
+ styled: "react/styled-file.ts",
151
+ component: {
152
+ styled: "react/styled-file.ts",
153
+ wrapper: "react/vanilla-file.ts",
154
+ wrapperExt: ".tsx"
155
+ }
156
+ }
157
+ }, H = [B, V], U = {
158
+ astro: B,
159
+ react: V
160
+ }, W = async (e) => {
161
+ for (let t of H) if (await t.detect(e)) return t;
162
+ return V;
163
+ }, G = (e) => {
164
+ if (e) return U[e];
165
+ }, K = {
166
+ "salty.config.ts": () => import("./salty.config-DWF4i7K0.js"),
167
+ "saltygen/index.css": () => import("./templates-DWWLjEiU.js"),
168
+ "react/styled-file.ts": () => import("./styled-file-C_4eLAdV.js"),
169
+ "react/vanilla-file.ts": () => import("./vanilla-file-BEqMIe-6.js"),
170
+ "astro/styled-file.ts": () => import("./styled-file-DQHLzmuL.js"),
171
+ "astro/component.astro": () => import("./astro-component-Ov1RH0CO.js")
172
+ }, q = async (e, t) => {
173
+ let { default: n } = await K[e]();
174
+ return {
175
+ fileName: e,
176
+ content: v.render(n, t)
177
+ };
178
+ }, J = (n, r) => {
179
+ 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.").option("-r, --reactComponent", "Generate a wrapper component file alongside the styled definition.").action(async function(n, a = r) {
180
+ let { file: o = n, dir: s = a, tag: c, name: f, className: g, reactComponent: _ = !1 } = this.opts();
181
+ if (!o) return e("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
182
+ if (!s) return e("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
183
+ let v;
184
+ try {
185
+ v = await L({
186
+ dir: s,
187
+ requirePackageJson: !1
188
+ });
189
+ } catch (t) {
190
+ return e(t instanceof Error ? t.message : String(t));
191
+ }
192
+ let y = G(F(v.rcFile, v.relativeProjectPath)) ?? await W(v), b = o.split("/").slice(0, -1).join("/");
193
+ b && await p(u(v.projectDir, b), { recursive: !0 });
194
+ let x = d(u(v.projectDir, o));
195
+ x.ext ||= ".ts", x.name.endsWith(".css") || (x.name += ".css"), x.base = x.name + x.ext;
196
+ let S = l(x);
197
+ if (await m(S, "utf-8").catch(() => void 0) !== void 0) {
198
+ t.error("File already exists: " + S);
199
+ return;
200
+ }
201
+ let C = i(f || x.base.replace(/\.css\.\w+$/, ""));
202
+ if (_) {
203
+ if (!y.templates.component) return e(`--reactComponent is not supported for the ${y.name} framework.`);
204
+ let n = C + "Component";
205
+ C += "Wrapper";
206
+ let r = x.base.replace(/\.css\.\w+$/, ""), { content: i } = await q(y.templates.component.wrapper, {
207
+ tag: c,
208
+ componentName: n,
209
+ styledComponentName: C,
210
+ className: g,
211
+ fileName: r
212
+ });
213
+ x.name = r.replace(/\.css$/, ""), x.ext = y.templates.component.wrapperExt, x.base = x.name + x.ext;
214
+ let a = l(x);
215
+ t.info("Generating a new file: " + a), await h(a, i), await O(a);
216
+ }
217
+ let { content: w } = await q(_ && y.templates.component ? y.templates.component.styled : y.templates.styled, {
218
+ tag: c,
219
+ name: C,
220
+ className: g
221
+ });
222
+ t.info("Generating a new file: " + S), await h(S, w), await O(S);
223
+ });
224
+ }, Y = (e) => {
225
+ let t = e.trim();
226
+ return t.startsWith("-D ") ? `${t.slice(3).trim()} (dev)` : t;
227
+ }, X = (e) => e.map((e) => ` + ${Y(e)}`).join("\n"), Z = async (e, t, n = {}) => {
228
+ if (t || e.length === 0) return;
229
+ let r = n.input ?? process.stdin, i = n.output ?? process.stdout;
230
+ if (!(n.isTTY ?? process.stdin.isTTY ?? !1)) throw Error("Cannot prompt for install confirmation: stdin is not a TTY. Re-run with --yes to install the listed packages without prompting.");
231
+ i.write(`The following packages will be installed:\n${X(e)}\n`);
232
+ let a = y({
233
+ input: r,
234
+ output: i,
235
+ terminal: !1
236
+ });
237
+ try {
238
+ let e = (await a.question("Proceed? (y/N) ")).trim().toLowerCase();
239
+ if (e !== "y" && e !== "yes") throw Error("Install cancelled by user.");
240
+ } finally {
241
+ a.close();
242
+ }
243
+ }, re = async (e, t = {}) => {
244
+ if (t.yes) return !0;
245
+ let n = t.input ?? process.stdin, r = t.output ?? process.stdout;
246
+ if (!(t.isTTY ?? process.stdin.isTTY ?? !1)) return !1;
247
+ let i = t.defaultYes ? "(Y/n)" : "(y/N)", a = y({
248
+ input: n,
249
+ output: r,
250
+ terminal: !1
251
+ });
252
+ try {
253
+ let n = (await a.question(`${e} ${i} `)).trim().toLowerCase();
254
+ return n === "" ? !!t.defaultYes : n === "y" || n === "yes";
255
+ } finally {
256
+ a.close();
257
+ }
258
+ }, ie = [
259
+ "src",
260
+ "public",
261
+ "assets",
262
+ "styles",
263
+ "css",
264
+ "app"
265
+ ], ae = [
266
+ "styles",
267
+ "css",
268
+ "app",
269
+ "pages"
270
+ ], oe = [
271
+ "index",
272
+ "styles",
273
+ "main",
274
+ "app",
275
+ "global",
276
+ "globals"
277
+ ], se = [
278
+ ".css",
279
+ ".scss",
280
+ ".sass"
281
+ ], ce = async (e) => {
282
+ for (let t of ie) for (let n of oe) for (let r of se) {
283
+ let i = u(e, t, n + r);
284
+ if (await m(i, "utf-8").catch(() => void 0) !== void 0) return f(e, i);
285
+ for (let i of ae) {
286
+ let a = u(e, t, i, n + r);
287
+ if (await m(a, "utf-8").catch(() => void 0) !== void 0) return f(e, a);
288
+ }
289
+ }
290
+ }, le = (e) => `@salty-css/astro@${e}`, ue = "import saltyIntegration from '@salty-css/astro/integration';\n", de = (e) => {
291
+ if (e.includes("@salty-css/astro")) return { content: null };
292
+ let t = e, n = !1;
293
+ return /integrations\s*:\s*\[/.test(t) ? (t = t.replace(/integrations\s*:\s*\[/, (e) => `${e}saltyIntegration(),`), n = !0) : /defineConfig\s*\(\s*\{/.test(t) && (t = t.replace(/defineConfig\s*\(\s*\{/, (e) => `${e}\n integrations: [saltyIntegration()],`), n = !0), n ? { content: ue + t } : {
294
+ content: null,
295
+ warning: "Could not find a place to add saltyIntegration() in the Astro config. Please add it manually."
296
+ };
297
+ }, fe = {
298
+ name: "astro",
299
+ detect: (e) => R(e.projectDir),
300
+ plan: async (e, n) => {
301
+ let r = await m(n, "utf-8").catch(() => void 0);
302
+ if (r === void 0) return null;
303
+ let i = de(r);
304
+ if (i.warning && t.warn(i.warning), i.content === null) return null;
305
+ let a = i.content;
306
+ return {
307
+ packages: [`-D ${le(e.cliVersion)}`],
308
+ execute: async () => (t.info("Adding Salty-CSS integration to Astro config: " + n), await h(n, a), await O(n), { changed: !0 })
309
+ };
310
+ }
311
+ }, pe = [
312
+ ["projectJs", "eslint.config.js"],
313
+ ["rootJs", "eslint.config.js"],
314
+ ["projectMjs", "eslint.config.mjs"],
315
+ ["rootMjs", "eslint.config.mjs"],
316
+ ["projectJson", ".eslintrc.json"],
317
+ ["rootJson", ".eslintrc.json"]
318
+ ], me = (e, t) => pe.map(([n, r]) => u(n.startsWith("root") ? t : e, r)), he = (e, t) => {
319
+ if (e.includes("salty-css")) return { content: null };
320
+ if (t) {
321
+ let t = `import saltyCss from "@salty-css/eslint-config-core/flat";\n${e}`;
322
+ if (e.includes("typescript-eslint")) if (t.includes(".config(")) t = t.replace(".config(", ".config(saltyCss,");
323
+ else return {
324
+ content: null,
325
+ warning: "Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."
326
+ };
327
+ else if (t.includes("export default [")) t = t.replace("export default [", "export default [ saltyCss,");
328
+ else if (t.includes("eslintConfig = [")) t = t.replace("eslintConfig = [", "eslintConfig = [ saltyCss,");
329
+ else return {
330
+ content: null,
331
+ warning: "Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually."
332
+ };
333
+ return { content: t };
334
+ }
335
+ let n = JSON.parse(e);
336
+ return n.extends ||= [], n.extends.includes("@salty-css/core") || n.extends.push("@salty-css/core"), { content: JSON.stringify(n, null, 2) };
337
+ }, ge = {
338
+ name: "eslint",
339
+ detect: (e) => me(e.projectDir, e.cwd).find((e) => s(e)) ?? null,
340
+ plan: async (e, n) => {
341
+ let r = await m(n, "utf-8").catch(() => void 0);
342
+ if (r === void 0) return t.error("Could not read ESLint config file."), null;
343
+ let i = he(r, n.endsWith("js"));
344
+ if (i.warning && t.warn(i.warning), i.content === null) return null;
345
+ let a = i.content;
346
+ return {
347
+ packages: [w.eslintConfigCore(e.cliVersion)],
348
+ execute: async () => (t.info("Edit file: " + n), await h(n, a), await O(n), { changed: !0 })
349
+ };
350
+ }
351
+ }, _e = [
352
+ "next.config.js",
353
+ "next.config.cjs",
354
+ "next.config.ts",
355
+ "next.config.mjs"
356
+ ], ve = (e) => `@salty-css/next@${e}`, ye = (e) => {
357
+ if (e.includes("withSaltyCss")) return { content: null };
358
+ let t = e, n = !1;
359
+ /\splugins([^=]*)=[^[]\[/.test(t) && (t = t.replace(/\splugins([^=]*)=[^[]\[/, (e, t) => ` plugins${t}= [withSaltyCss,`), n = !0);
360
+ let r = t.includes("module.exports"), i = r ? "const { withSaltyCss } = require('@salty-css/next');\n" : "import { withSaltyCss } from '@salty-css/next';\n";
361
+ return r && !n ? (t = t.replace(/module.exports = ([^;]+)/, (e, t) => `module.exports = withSaltyCss(${t})`), n = !0) : n || (t = t.replace(/export default ([^;]+)/, (e, t) => `export default withSaltyCss(${t})`)), { content: i + t };
362
+ }, be = {
363
+ name: "next",
364
+ detect: (e) => _e.map((t) => u(e.projectDir, t)).find((e) => s(e)) ?? null,
365
+ plan: async (e, n) => {
366
+ let r = await m(n, "utf-8").catch(() => void 0);
367
+ if (r === void 0) return null;
368
+ let { content: i } = ye(r);
369
+ return i === null ? null : {
370
+ packages: [`-D ${ve(e.cliVersion)}`],
371
+ execute: async () => (t.info("Adding Salty-CSS plugin to Next.js config..."), await h(n, i), await O(n), { changed: !0 })
372
+ };
373
+ }
374
+ }, xe = (e) => `@salty-css/vite@${e}`, Se = (e) => e.includes("saltyPlugin") ? { content: null } : { content: "import { saltyPlugin } from '@salty-css/vite';\n" + e.replace(/(plugins: \[)/, "$1\n saltyPlugin(__dirname),") }, Ce = [
375
+ ge,
376
+ {
377
+ name: "vite",
378
+ detect: (e) => {
379
+ let t = u(e.projectDir, "vite.config.ts");
380
+ return s(t) ? t : null;
381
+ },
382
+ plan: async (e, n) => {
383
+ let r = await m(n, "utf-8").catch(() => void 0);
384
+ if (r === void 0) return null;
385
+ let { content: i } = Se(r);
386
+ return i === null ? null : {
387
+ packages: [`-D ${xe(e.cliVersion)}`],
388
+ execute: async () => (t.info("Edit file: " + n), t.info("Adding Salty-CSS plugin to Vite config..."), await h(n, i), await O(n), { changed: !0 })
389
+ };
390
+ }
391
+ },
392
+ be,
393
+ fe
394
+ ], we = async (e) => {
395
+ let t = [];
396
+ for (let n of Ce) {
397
+ let r = await n.detect(e);
398
+ if (!r) continue;
399
+ let i = await n.plan(e, r);
400
+ i && t.push({
401
+ name: n.name,
402
+ configPath: r,
403
+ plan: i
404
+ });
405
+ }
406
+ return t;
407
+ }, Te = async (e) => {
408
+ let t = [];
409
+ for (let { name: n, configPath: r, plan: i } of e) {
410
+ let e = await i.execute();
411
+ t.push({
412
+ name: n,
413
+ configPath: r,
414
+ changed: e.changed
415
+ });
416
+ }
417
+ return t;
418
+ }, Ee = {
419
+ vite: ["dist/**"],
420
+ next: [".next/**", "out/**"]
421
+ }, De = ({ framework: e, integrations: t, hasSrcDir: n }) => {
422
+ if (e === "astro") return {};
423
+ let r = [...new Set(t.flatMap((e) => Ee[e] ?? []))], i = {};
424
+ return n && (i.include = ["src/**"]), r.length && (i.exclude = r), i;
425
+ }, Oe = async (e, n, r) => {
426
+ let i = u(e, n);
427
+ if (s(i)) {
428
+ t.debug("File already exists: " + i);
429
+ return;
430
+ }
431
+ let a = n.split("/").slice(0, -1).join("/");
432
+ a && await p(u(e, a), { recursive: !0 }), t.info("Creating file: " + i), await h(i, r), await O(i);
433
+ }, Q = async (e) => {
434
+ let n = u(e, ".gitignore"), r = await m(n, "utf-8").catch(() => void 0);
435
+ r !== void 0 && (r.includes("saltygen") || (t.info("Edit file: " + n), await h(n, r + "\n\n# Salty-CSS\nsaltygen\n")));
436
+ }, ke = async (e, n) => {
437
+ let r = n ?? await ce(e);
438
+ if (!r) {
439
+ t.warn("Could not find a CSS file to import the generated CSS. Please add it manually.");
440
+ return;
441
+ }
442
+ let i = u(e, r), a = await m(i, "utf-8").catch(() => void 0);
443
+ if (a === void 0 || a.includes("saltygen")) return;
444
+ let o = f(u(i, ".."), u(e, "saltygen/index.css"));
445
+ t.info("Adding global import statement to CSS file: " + i), await h(i, `@import '${o}';\n` + a), await O(i);
446
+ }, Ae = async () => {
447
+ let t = await x().catch(() => {
448
+ e("Could not read package.json file.");
449
+ });
450
+ if (!t) return;
451
+ let { pkg: n } = T(t);
452
+ await S(n);
453
+ }, je = (r) => {
454
+ r.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.").option("-y, --yes", "Skip the install confirmation prompt.").action(async function(r = ".") {
455
+ try {
456
+ let i = this.opts(), a = i.dir ?? r;
457
+ if (!a) return e("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
458
+ let o = await L({
459
+ dir: a,
460
+ skipInstall: i.skipInstall,
461
+ yes: i.yes
462
+ });
463
+ t.info("Initializing a new Salty-CSS project!");
464
+ let c = await W(o);
465
+ t.info(`Detected framework: ${c.name}`);
466
+ let l = await we(o);
467
+ if (!o.skipInstall) {
468
+ let e = [
469
+ w.core(o.cliVersion),
470
+ c.runtimePackage(o.cliVersion),
471
+ ...l.flatMap((e) => e.plan.packages)
472
+ ];
473
+ await Z(e, o.yes), await D(...e);
474
+ }
475
+ let d = await Promise.all([q("salty.config.ts"), q("saltygen/index.css")]);
476
+ await p(o.projectDir, { recursive: !0 }), await Promise.all(d.map(({ fileName: e, content: t }) => Oe(o.projectDir, e, t)));
477
+ let f = De({
478
+ framework: c.name,
479
+ integrations: l.map((e) => e.name),
480
+ hasSrcDir: s(u(o.projectDir, "src"))
481
+ });
482
+ await P(o.cwd, o.relativeProjectPath, c, f), await Q(o.cwd), await ke(o.projectDir, i.cssFile), await Te(l), await Ae(), t.info("Running the build to generate initial CSS..."), await new n(o.projectDir).generateCss(), t.info("🎉 Salty CSS project initialized successfully!"), t.info("Next steps:"), t.info("1. Configure variables and templates in `salty.config.ts`"), t.info("2. Create a new component with `npx salty-css generate [component-name]`"), t.info("3. Run `npx salty-css build` to generate the CSS"), t.info("4. Read about the features in the documentation: https://salty-css.dev"), t.info("5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐");
483
+ } catch (t) {
484
+ return e(t instanceof Error ? t.message : String(t));
485
+ }
486
+ });
487
+ }, $ = async () => {
488
+ let t = u(process.cwd(), "package.json"), n = await x(t).catch((t) => e(t));
489
+ if (!n) return e("Could not read package.json file.");
490
+ let r = {
491
+ ...n.dependencies,
492
+ ...n.devDependencies
493
+ }, i = Object.entries(r).filter(([e]) => e === "salty-css" || e.startsWith("@salty-css/"));
494
+ return i.length ? i : e("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + t);
495
+ }, Me = (r) => {
496
+ r.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).option("-y, --yes", "Skip confirmation prompts (install and rebuild).").option("-d, --dir <dir>", "Project directory to rebuild after updating.").action(async function(r = "latest") {
497
+ let { legacyPeerDeps: i, version: a = r, yes: o = !1, dir: s } = this.opts(), c = await $();
498
+ if (!c) return e("Could not update Salty-CSS packages as any were found in package.json.");
499
+ let l = await C(), u = c.map(([e]) => a === "@" ? `${e}@${l.version}` : `${e}@${a.replace(/^@/, "")}`);
500
+ try {
501
+ await Z(u, o);
502
+ } catch (t) {
503
+ return e(t instanceof Error ? t.message : String(t));
504
+ }
505
+ i ? (t.warn("Using legacy peer dependencies to update packages."), await D(...u, "--legacy-peer-deps")) : await D(...u);
506
+ let d = await $();
507
+ if (!d) return e("Something went wrong while reading the updated packages.");
508
+ let f = d.reduce((e, [t, n]) => (e[n] || (e[n] = []), e[n].push(t), e), {});
509
+ if (Object.keys(f).length === 1) {
510
+ let e = Object.keys(f)[0];
511
+ t.info(`Updated to all Salty CSS packages successfully to ${e.replace(/^\^/, "")}`);
512
+ } else for (let [e, n] of Object.entries(f)) t.info(`Updated to ${e.replace(/^\^/, "")}: ${n.join(", ")}`);
513
+ let p = s ?? await M();
514
+ if (!p) {
515
+ t.warn("Skipping rebuild: no project directory configured. Run `salty-css build [dir]` manually.");
516
+ return;
517
+ }
518
+ if (!await re("Rebuild Salty CSS now?", { yes: o })) return;
519
+ let m = I(p);
520
+ t.info("Rebuilding Salty-CSS project..."), await new n(m).generateCss(), t.info("Rebuild complete.");
521
+ });
522
+ }, Ne = (n) => {
523
+ n.option("-v, --version", "Show the current version of Salty-CSS.").action(async function() {
524
+ let n = await C();
525
+ t.info("CLI is running: " + n.version);
526
+ let r = u(process.cwd(), "package.json"), i = await x(r).catch((t) => e(t));
527
+ if (!i) return;
528
+ let a = {
529
+ ...i.dependencies,
530
+ ...i.devDependencies
531
+ }, o = Object.keys(a).filter((e) => e === "salty-css" || e.startsWith("@salty-css/"));
532
+ if (!o.length) return e("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + r);
533
+ for (let e of o) t.info(`${e}: ${a[e]}`);
534
+ });
535
+ };
536
+ //#endregion
537
+ //#region src/bin/main.ts
538
+ async function Pe() {
539
+ let e = new o();
540
+ e.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
541
+ let t = await M();
542
+ je(e), Me(e), Ne(e), te(e, t), J(e, t), e.parseAsync(process.argv);
543
+ }
544
+ //#endregion
545
+ export { Pe as t };
@@ -0,0 +1,11 @@
1
+ const e=require("./chunk-CMqjfN_6.cjs"),t=require("./salty-compiler-Bvd0OKHz.cjs"),n=require("./compiler/helpers.cjs"),r=require("./util/index.cjs"),i=require("./server/index.cjs");let a=require("commander"),o=require("fs"),s=require("path"),c=require("fs/promises"),l=require("child_process"),u=require("ora");u=e.t(u,1);let d=require("ejs");d=e.t(d,1);let f=require("readline/promises");var p=(0,s.join)(process.cwd(),`package.json`),m=async(e=p)=>{let t=await(0,c.readFile)(e,`utf-8`).then(JSON.parse).catch(()=>void 0);if(!t)throw`Could not read package.json file!`;return t},h=async(e,t=p)=>{typeof e==`object`&&(e=JSON.stringify(e,null,2)),await(0,c.writeFile)(t,e)},g=async()=>m(new URL(`../package.json`,``+{}.url)),_={core:e=>`@salty-css/core@${e}`,eslintConfigCore:e=>`@salty-css/eslint-config-core@${e}`},v=e=>{e.scripts||={};let t=e.scripts.prepare;if(t){if(t.includes(`salty-css`))return{changed:!1,pkg:e};e.scripts.prepare=t+` && npx salty-css build`}else e.scripts.prepare=`npx salty-css build`;return{changed:!0,pkg:e}},y=e=>new Promise((t,n)=>{(0,l.exec)(e,e=>{if(e)return n(e);t()})}),b=async(...e)=>{let t=e.map(e=>e.replace(`-D`,``).split(`@`).slice(0,-1).join(`@`).trim()).join(`, `),n=(0,u.default)(`Installing packages: ${t}`).start();await y(`npm install ${e.join(` `)}`),n.succeed(`Installed packages: ${t}`)},x=()=>(0,o.existsSync)((0,s.join)(process.cwd(),`node_modules`,`.bin`,`prettier`));async function S(e){try{if(!x())return;await y(`./node_modules/.bin/prettier --write "${e}"`),t.r.info(`Formatted ${e} with Prettier`)}catch(n){t.r.error(`Error formatting ${e} with Prettier:`,n)}}var C=(e=process.cwd())=>(0,s.join)(e,`.saltyrc.json`),w=async(e=process.cwd())=>await(0,c.readFile)(C(e),`utf-8`).then(JSON.parse).catch(()=>({})),T=async(e=process.cwd())=>(0,c.readFile)(C(e),`utf-8`).catch(()=>void 0),E=async(e=process.cwd())=>(await w(e)).defaultProject,D=(e,t,n,r={})=>{let i=(0,s.join)(t,n.srcDirectory),a={dir:i,framework:n.name,...r};if(e===void 0)return{content:JSON.stringify({$schema:`./node_modules/@salty-css/core/.saltyrc.schema.json`,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.`,defaultProject:i,projects:[a]},null,2),changed:!0,created:!0};let o=JSON.parse(e),c=o.projects||[];if(c.some(e=>e.dir===i))return{content:e,changed:!1,created:!1};c.push(a),o.projects=[...c];let l=JSON.stringify(o,null,2);return{content:l,changed:l!==e,created:!1}},O=async(e,n,r,i={})=>{let a=C(e),{content:o,changed:s,created:l}=D(await T(e),n,r,i);return s?(l?t.r.info(`Creating file: `+a):t.r.info(`Edit file: `+a),await(0,c.writeFile)(a,o),await S(a),!0):!1},ee=(e,t)=>(e.projects||[]).find(e=>e.dir===t)?.framework,k=(e,t=process.cwd())=>(0,s.join)(t,e===`.`?``:e),A=async e=>{let t=process.cwd(),n=k(e.dir,t),r=(0,s.relative)(t,n)||`.`,i=await m().catch(()=>void 0);if(e.requirePackageJson!==!1&&!i)throw Error(`Salty CSS project must be initialized in a directory with a package.json file.`);return{cwd:t,projectDir:n,relativeProjectPath:r,packageJson:i,rcFile:await w(t),cliVersion:(await g()).version||`0.0.0`,skipInstall:!!e.skipInstall,yes:!!e.yes}},j=(e,r)=>{e.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.`).option(`--mode <mode>`,`Build mode: "production" or "development". Defaults to NODE_ENV-based detection.`).action(async function(e=r){t.r.info(`Building the Salty-CSS project...`);let{dir:a=e,watch:s,mode:c}=this.opts();if(c!==void 0&&c!==`production`&&c!==`development`)return t.n(`Invalid --mode "${c}". Expected "production" or "development".`);let l=a??await E();if(!l)return t.n(`Project directory must be provided. Add it as the first argument after build command or use the --dir option.`);let u=k(l),d=new t.t(u,{mode:c});await d.generateCss(),s&&(t.r.info(`Watching for changes in the project directory...`),(0,o.watch)(u,{recursive:!0},async(e,t)=>{if(!t)return console.warn(`File path not provided for change event`);await i.checkShouldRestart(t)?await d.generateCss(!1):n.isSaltyFile(t)&&await d.generateFile(t)}))})},M=[`astro.config.mjs`,`astro.config.ts`,`astro.config.js`,`astro.config.cjs`],N=e=>{for(let t of M){let n=(0,s.join)(e,t);if((0,o.existsSync)(n))return n}return null},te=e=>{let t=e.packageJson;if(!t)return!1;let n={...t.dependencies,...t.devDependencies};return Object.prototype.hasOwnProperty.call(n,`astro`)},P={name:`astro`,srcDirectory:`src`,detect:e=>!!N(e.projectDir)||te(e),runtimePackage:e=>`@salty-css/astro@${e}`,templates:{styled:`astro/styled-file.ts`,component:{styled:`astro/styled-file.ts`,wrapper:`astro/component.astro`,wrapperExt:`.astro`}}},F={name:`react`,srcDirectory:``,detect:()=>!0,runtimePackage:e=>`@salty-css/react@${e}`,templates:{styled:`react/styled-file.ts`,component:{styled:`react/styled-file.ts`,wrapper:`react/vanilla-file.ts`,wrapperExt:`.tsx`}}},I=[P,F],L={astro:P,react:F},R=async e=>{for(let t of I)if(await t.detect(e))return t;return F},z=e=>{if(e)return L[e]},B={"salty.config.ts":()=>Promise.resolve().then(()=>require("./salty.config-B0ZiRpHR.cjs")),"saltygen/index.css":()=>Promise.resolve().then(()=>require("./templates-BGHLaAOm.cjs")),"react/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-BCbAEzBB.cjs")),"react/vanilla-file.ts":()=>Promise.resolve().then(()=>require("./vanilla-file-Z3VsOa_U.cjs")),"astro/styled-file.ts":()=>Promise.resolve().then(()=>require("./styled-file-DorArlCk.cjs")),"astro/component.astro":()=>Promise.resolve().then(()=>require("./astro-component-r0qEcF1p.cjs"))},V=async(e,t)=>{let{default:n}=await B[e]();return{fileName:e,content:d.default.render(n,t)}},H=(e,n)=>{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.`).option(`-r, --reactComponent`,`Generate a wrapper component file alongside the styled definition.`).action(async function(e,i=n){let{file:a=e,dir:o=i,tag:l,name:u,className:d,reactComponent:f=!1}=this.opts();if(!a)return t.n(`File to generate must be provided. Add it as the first argument after generate command or use the --file option.`);if(!o)return t.n(`Project directory must be provided. Add it as the second argument after generate command or use the --dir option.`);let p;try{p=await A({dir:o,requirePackageJson:!1})}catch(e){return t.n(e instanceof Error?e.message:String(e))}let m=z(ee(p.rcFile,p.relativeProjectPath))??await R(p),h=a.split(`/`).slice(0,-1).join(`/`);h&&await(0,c.mkdir)((0,s.join)(p.projectDir,h),{recursive:!0});let g=(0,s.parse)((0,s.join)(p.projectDir,a));g.ext||=`.ts`,g.name.endsWith(`.css`)||(g.name+=`.css`),g.base=g.name+g.ext;let _=(0,s.format)(g);if(await(0,c.readFile)(_,`utf-8`).catch(()=>void 0)!==void 0){t.r.error(`File already exists: `+_);return}let v=r.pascalCase(u||g.base.replace(/\.css\.\w+$/,``));if(f){if(!m.templates.component)return t.n(`--reactComponent is not supported for the ${m.name} framework.`);let e=v+`Component`;v+=`Wrapper`;let n=g.base.replace(/\.css\.\w+$/,``),{content:r}=await V(m.templates.component.wrapper,{tag:l,componentName:e,styledComponentName:v,className:d,fileName:n});g.name=n.replace(/\.css$/,``),g.ext=m.templates.component.wrapperExt,g.base=g.name+g.ext;let i=(0,s.format)(g);t.r.info(`Generating a new file: `+i),await(0,c.writeFile)(i,r),await S(i)}let{content:y}=await V(f&&m.templates.component?m.templates.component.styled:m.templates.styled,{tag:l,name:v,className:d});t.r.info(`Generating a new file: `+_),await(0,c.writeFile)(_,y),await S(_)})},U=e=>{let t=e.trim();return t.startsWith(`-D `)?`${t.slice(3).trim()} (dev)`:t},W=e=>e.map(e=>` + ${U(e)}`).join(`
2
+ `),G=async(e,t,n={})=>{if(t||e.length===0)return;let r=n.input??process.stdin,i=n.output??process.stdout;if(!(n.isTTY??process.stdin.isTTY??!1))throw Error(`Cannot prompt for install confirmation: stdin is not a TTY. Re-run with --yes to install the listed packages without prompting.`);i.write(`The following packages will be installed:\n${W(e)}\n`);let a=(0,f.createInterface)({input:r,output:i,terminal:!1});try{let e=(await a.question(`Proceed? (y/N) `)).trim().toLowerCase();if(e!==`y`&&e!==`yes`)throw Error(`Install cancelled by user.`)}finally{a.close()}},K=async(e,t={})=>{if(t.yes)return!0;let n=t.input??process.stdin,r=t.output??process.stdout;if(!(t.isTTY??process.stdin.isTTY??!1))return!1;let i=t.defaultYes?`(Y/n)`:`(y/N)`,a=(0,f.createInterface)({input:n,output:r,terminal:!1});try{let n=(await a.question(`${e} ${i} `)).trim().toLowerCase();return n===``?!!t.defaultYes:n===`y`||n===`yes`}finally{a.close()}},q=[`src`,`public`,`assets`,`styles`,`css`,`app`],J=[`styles`,`css`,`app`,`pages`],Y=[`index`,`styles`,`main`,`app`,`global`,`globals`],X=[`.css`,`.scss`,`.sass`],Z=async e=>{for(let t of q)for(let n of Y)for(let r of X){let i=(0,s.join)(e,t,n+r);if(await(0,c.readFile)(i,`utf-8`).catch(()=>void 0)!==void 0)return(0,s.relative)(e,i);for(let i of J){let a=(0,s.join)(e,t,i,n+r);if(await(0,c.readFile)(a,`utf-8`).catch(()=>void 0)!==void 0)return(0,s.relative)(e,a)}}},Q=e=>`@salty-css/astro@${e}`,ne=`import saltyIntegration from '@salty-css/astro/integration';
3
+ `,re=e=>{if(e.includes(`@salty-css/astro`))return{content:null};let t=e,n=!1;return/integrations\s*:\s*\[/.test(t)?(t=t.replace(/integrations\s*:\s*\[/,e=>`${e}saltyIntegration(),`),n=!0):/defineConfig\s*\(\s*\{/.test(t)&&(t=t.replace(/defineConfig\s*\(\s*\{/,e=>`${e}\n integrations: [saltyIntegration()],`),n=!0),n?{content:ne+t}:{content:null,warning:`Could not find a place to add saltyIntegration() in the Astro config. Please add it manually.`}},ie={name:`astro`,detect:e=>N(e.projectDir),plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return null;let i=re(r);if(i.warning&&t.r.warn(i.warning),i.content===null)return null;let a=i.content;return{packages:[`-D ${Q(e.cliVersion)}`],execute:async()=>(t.r.info(`Adding Salty-CSS integration to Astro config: `+n),await(0,c.writeFile)(n,a),await S(n),{changed:!0})}}},ae=[[`projectJs`,`eslint.config.js`],[`rootJs`,`eslint.config.js`],[`projectMjs`,`eslint.config.mjs`],[`rootMjs`,`eslint.config.mjs`],[`projectJson`,`.eslintrc.json`],[`rootJson`,`.eslintrc.json`]],oe=(e,t)=>ae.map(([n,r])=>(0,s.join)(n.startsWith(`root`)?t:e,r)),se=(e,t)=>{if(e.includes(`salty-css`))return{content:null};if(t){let t=`import saltyCss from "@salty-css/eslint-config-core/flat";\n${e}`;if(e.includes(`typescript-eslint`))if(t.includes(`.config(`))t=t.replace(`.config(`,`.config(saltyCss,`);else return{content:null,warning:`Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.`};else if(t.includes(`export default [`))t=t.replace(`export default [`,`export default [ saltyCss,`);else if(t.includes(`eslintConfig = [`))t=t.replace(`eslintConfig = [`,`eslintConfig = [ saltyCss,`);else return{content:null,warning:`Could not find the correct place to add the Salty-CSS config for ESLint. Please add it manually.`};return{content:t}}let n=JSON.parse(e);return n.extends||=[],n.extends.includes(`@salty-css/core`)||n.extends.push(`@salty-css/core`),{content:JSON.stringify(n,null,2)}},ce={name:`eslint`,detect:e=>oe(e.projectDir,e.cwd).find(e=>(0,o.existsSync)(e))??null,plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return t.r.error(`Could not read ESLint config file.`),null;let i=se(r,n.endsWith(`js`));if(i.warning&&t.r.warn(i.warning),i.content===null)return null;let a=i.content;return{packages:[_.eslintConfigCore(e.cliVersion)],execute:async()=>(t.r.info(`Edit file: `+n),await(0,c.writeFile)(n,a),await S(n),{changed:!0})}}},le=[`next.config.js`,`next.config.cjs`,`next.config.ts`,`next.config.mjs`],ue=e=>`@salty-css/next@${e}`,de=e=>{if(e.includes(`withSaltyCss`))return{content:null};let t=e,n=!1;/\splugins([^=]*)=[^[]\[/.test(t)&&(t=t.replace(/\splugins([^=]*)=[^[]\[/,(e,t)=>` plugins${t}= [withSaltyCss,`),n=!0);let r=t.includes(`module.exports`),i=r?`const { withSaltyCss } = require('@salty-css/next');
4
+ `:`import { withSaltyCss } from '@salty-css/next';
5
+ `;return r&&!n?(t=t.replace(/module.exports = ([^;]+)/,(e,t)=>`module.exports = withSaltyCss(${t})`),n=!0):n||(t=t.replace(/export default ([^;]+)/,(e,t)=>`export default withSaltyCss(${t})`)),{content:i+t}},fe={name:`next`,detect:e=>le.map(t=>(0,s.join)(e.projectDir,t)).find(e=>(0,o.existsSync)(e))??null,plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return null;let{content:i}=de(r);return i===null?null:{packages:[`-D ${ue(e.cliVersion)}`],execute:async()=>(t.r.info(`Adding Salty-CSS plugin to Next.js config...`),await(0,c.writeFile)(n,i),await S(n),{changed:!0})}}},pe=e=>`@salty-css/vite@${e}`,me=e=>e.includes(`saltyPlugin`)?{content:null}:{content:`import { saltyPlugin } from '@salty-css/vite';
6
+ `+e.replace(/(plugins: \[)/,`$1
7
+ saltyPlugin(__dirname),`)},he=[ce,{name:`vite`,detect:e=>{let t=(0,s.join)(e.projectDir,`vite.config.ts`);return(0,o.existsSync)(t)?t:null},plan:async(e,n)=>{let r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);if(r===void 0)return null;let{content:i}=me(r);return i===null?null:{packages:[`-D ${pe(e.cliVersion)}`],execute:async()=>(t.r.info(`Edit file: `+n),t.r.info(`Adding Salty-CSS plugin to Vite config...`),await(0,c.writeFile)(n,i),await S(n),{changed:!0})}}},fe,ie],ge=async e=>{let t=[];for(let n of he){let r=await n.detect(e);if(!r)continue;let i=await n.plan(e,r);i&&t.push({name:n.name,configPath:r,plan:i})}return t},_e=async e=>{let t=[];for(let{name:n,configPath:r,plan:i}of e){let e=await i.execute();t.push({name:n,configPath:r,changed:e.changed})}return t},ve={vite:[`dist/**`],next:[`.next/**`,`out/**`]},ye=({framework:e,integrations:t,hasSrcDir:n})=>{if(e===`astro`)return{};let r=[...new Set(t.flatMap(e=>ve[e]??[]))],i={};return n&&(i.include=[`src/**`]),r.length&&(i.exclude=r),i},be=async(e,n,r)=>{let i=(0,s.join)(e,n);if((0,o.existsSync)(i)){t.r.debug(`File already exists: `+i);return}let a=n.split(`/`).slice(0,-1).join(`/`);a&&await(0,c.mkdir)((0,s.join)(e,a),{recursive:!0}),t.r.info(`Creating file: `+i),await(0,c.writeFile)(i,r),await S(i)},xe=async e=>{let n=(0,s.join)(e,`.gitignore`),r=await(0,c.readFile)(n,`utf-8`).catch(()=>void 0);r!==void 0&&(r.includes(`saltygen`)||(t.r.info(`Edit file: `+n),await(0,c.writeFile)(n,r+`
8
+
9
+ # Salty-CSS
10
+ saltygen
11
+ `)))},Se=async(e,n)=>{let r=n??await Z(e);if(!r){t.r.warn(`Could not find a CSS file to import the generated CSS. Please add it manually.`);return}let i=(0,s.join)(e,r),a=await(0,c.readFile)(i,`utf-8`).catch(()=>void 0);if(a===void 0||a.includes(`saltygen`))return;let o=(0,s.relative)((0,s.join)(i,`..`),(0,s.join)(e,`saltygen/index.css`));t.r.info(`Adding global import statement to CSS file: `+i),await(0,c.writeFile)(i,`@import '${o}';\n`+a),await S(i)},Ce=async()=>{let e=await m().catch(()=>{t.n(`Could not read package.json file.`)});if(!e)return;let{pkg:n}=v(e);await h(n)},we=e=>{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.`).option(`-y, --yes`,`Skip the install confirmation prompt.`).action(async function(e=`.`){try{let n=this.opts(),r=n.dir??e;if(!r)return t.n(`Project directory must be provided. Add it as the first argument after init command or use the --dir option.`);let i=await A({dir:r,skipInstall:n.skipInstall,yes:n.yes});t.r.info(`Initializing a new Salty-CSS project!`);let a=await R(i);t.r.info(`Detected framework: ${a.name}`);let l=await ge(i);if(!i.skipInstall){let e=[_.core(i.cliVersion),a.runtimePackage(i.cliVersion),...l.flatMap(e=>e.plan.packages)];await G(e,i.yes),await b(...e)}let u=await Promise.all([V(`salty.config.ts`),V(`saltygen/index.css`)]);await(0,c.mkdir)(i.projectDir,{recursive:!0}),await Promise.all(u.map(({fileName:e,content:t})=>be(i.projectDir,e,t)));let d=ye({framework:a.name,integrations:l.map(e=>e.name),hasSrcDir:(0,o.existsSync)((0,s.join)(i.projectDir,`src`))});await O(i.cwd,i.relativeProjectPath,a,d),await xe(i.cwd),await Se(i.projectDir,n.cssFile),await _e(l),await Ce(),t.r.info(`Running the build to generate initial CSS...`),await new t.t(i.projectDir).generateCss(),t.r.info(`🎉 Salty CSS project initialized successfully!`),t.r.info(`Next steps:`),t.r.info("1. Configure variables and templates in `salty.config.ts`"),t.r.info("2. Create a new component with `npx salty-css generate [component-name]`"),t.r.info("3. Run `npx salty-css build` to generate the CSS"),t.r.info(`4. Read about the features in the documentation: https://salty-css.dev`),t.r.info(`5. Star the project on GitHub: https://github.com/margarita-form/salty-css ⭐`)}catch(e){return t.n(e instanceof Error?e.message:String(e))}})},$=async()=>{let e=(0,s.join)(process.cwd(),`package.json`),n=await m(e).catch(e=>t.n(e));if(!n)return t.n(`Could not read package.json file.`);let r={...n.dependencies,...n.devDependencies},i=Object.entries(r).filter(([e])=>e===`salty-css`||e.startsWith(`@salty-css/`));return i.length?i:t.n(`No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: `+e)},Te=e=>{e.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).option(`-y, --yes`,`Skip confirmation prompts (install and rebuild).`).option(`-d, --dir <dir>`,`Project directory to rebuild after updating.`).action(async function(e=`latest`){let{legacyPeerDeps:n,version:r=e,yes:i=!1,dir:a}=this.opts(),o=await $();if(!o)return t.n(`Could not update Salty-CSS packages as any were found in package.json.`);let s=await g(),c=o.map(([e])=>r===`@`?`${e}@${s.version}`:`${e}@${r.replace(/^@/,``)}`);try{await G(c,i)}catch(e){return t.n(e instanceof Error?e.message:String(e))}n?(t.r.warn(`Using legacy peer dependencies to update packages.`),await b(...c,`--legacy-peer-deps`)):await b(...c);let l=await $();if(!l)return t.n(`Something went wrong while reading the updated packages.`);let u=l.reduce((e,[t,n])=>(e[n]||(e[n]=[]),e[n].push(t),e),{});if(Object.keys(u).length===1){let e=Object.keys(u)[0];t.r.info(`Updated to all Salty CSS packages successfully to ${e.replace(/^\^/,``)}`)}else for(let[e,n]of Object.entries(u))t.r.info(`Updated to ${e.replace(/^\^/,``)}: ${n.join(`, `)}`);let d=a??await E();if(!d){t.r.warn("Skipping rebuild: no project directory configured. Run `salty-css build [dir]` manually.");return}if(!await K(`Rebuild Salty CSS now?`,{yes:i}))return;let f=k(d);t.r.info(`Rebuilding Salty-CSS project...`),await new t.t(f).generateCss(),t.r.info(`Rebuild complete.`)})},Ee=e=>{e.option(`-v, --version`,`Show the current version of Salty-CSS.`).action(async function(){let e=await g();t.r.info(`CLI is running: `+e.version);let n=(0,s.join)(process.cwd(),`package.json`),r=await m(n).catch(e=>t.n(e));if(!r)return;let i={...r.dependencies,...r.devDependencies},a=Object.keys(i).filter(e=>e===`salty-css`||e.startsWith(`@salty-css/`));if(!a.length)return t.n(`No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: `+n);for(let e of a)t.r.info(`${e}: ${i[e]}`)})};async function De(){let e=new a.Command;e.name(`salty-css`).description(`Salty-CSS CLI tool to help with annoying configuration tasks.`);let t=await E();we(e),Te(e),Ee(e),j(e,t),H(e,t),e.parseAsync(process.argv)}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return De}});
@@ -0,0 +1,2 @@
1
+ export declare const originalMessage = "Hello from";
2
+ //# sourceMappingURL=maybe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maybe.d.ts","sourceRoot":"","sources":["../src/maybe.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ const e=require("./util/index.cjs"),t=require("./viewport-clamp-CHOyzt37.cjs");var n=e=>t=>{if(typeof t!=`string`||!e)return;let n=t,r=[];return Object.values(e).forEach(e=>{let{pattern:t,transform:i}=e;n=n.replace(t,e=>{let{value:t,css:n}=i(e);return n&&r.push(n),t})}),{transformed:n,additionalCss:r}},r=t=>n=>{if(typeof n==`string`&&/\{[^{}]+\}/g.test(n))return{transformed:n.replace(/\{([^{}]+)\}/g,(...n)=>{let r=e.dashCase(n[1].trim().replaceAll(`.`,`-`));return t&&!t.includes(r)&&console.warn(`Token ${r} might not exist`),r.startsWith(`-`)?`-${r}`:`var(--${r})`})}},i=r(),a=[`top`,`right`,`bottom`,`left`,`min-width`,/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],o=(e,n,r)=>{if(a.some(t=>typeof t==`string`?t===e:t.test(e))){let e=r?.defaultUnit||`px`;if(e.startsWith(`viewport-clamp:`))try{let r=e.split(`:`)[1];return t.t({screenSize:parseInt(r)})(Number(n))}catch(t){throw console.error(t),Error(`Invalid viewport-clamp value: ${e}`)}return`${n}${e}`}return`${n}`},s=[`Webkit`,`Moz`,`ms`,`O`],c=e=>s.some(t=>{if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n>=`A`&&n<=`Z`}),l=t=>t.startsWith(`-`)?t:c(t)?`-${e.dashCase(t)}`:e.dashCase(t),u=(e,t)=>{if(e===!0)throw Error(`[salty-css] ${t}`);e===`warn`&&console.warn(`[salty-css] ${t}`)},d=/^&(hover|focus(-(visible|within))?|active|visited|checked|disabled|enabled|empty|target|first-child|last-child|first-of-type|last-of-type|placeholder|placeholder-shown|root)\b/,f=/\$\{[^}]+\}/,p=/^@(media|supports|container|layer)\s*$/,m=/^@(?:-(?:webkit|moz|o|ms)-)?keyframes\b/,h=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.keys(e);return t.includes(`base`)||t.includes(`variants`)},g=e=>{if(typeof e==`string`){let[t,n]=e.split(`@`,2),r=t.split(`.`).filter(Boolean);if(!r.length)return;let i={};if(n)for(let e of n.split(`&`)){if(!e)continue;let t=e.indexOf(`=`);if(t===-1)i[e.trim()]=!0;else{let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();if(!n)continue;r===`true`?i[n]=!0:r===`false`?i[n]=!1:i[n]=r}}return{path:r,variants:i}}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e,n=t.name;if(typeof n!=`string`)return;let r=n.split(`.`).filter(Boolean);if(!r.length)return;let i={};for(let[e,n]of Object.entries(t))e!==`name`&&(typeof n==`string`||typeof n==`boolean`)&&(i[e]=n);return{path:r,variants:i}}},_=e=>{if(e!==void 0)return typeof e==`boolean`?String(e):e},v=(e,t)=>{let n=[{node:e,isRich:h(e)}],r=e;for(let e of t){if(typeof r!=`object`||!r)return;let t=r[e];if(t===void 0)return;n.push({node:t,isRich:h(t)}),r=t}return n},y=(e,t)=>{let n=v(e,t);return n?n.some(e=>e.isRich):!1},b=(e,t)=>{for(let[n,r]of Object.entries(e))if(n!==`css`&&t[n]!==_(r))return!1;return!0},x=(e,t)=>{let n=!1;for(let[r,i]of Object.entries(e))if(r!==`css`&&(n=!0,t[r]===_(i)))return!0;return!n},S=(e,t,n,r)=>{let i=v(e,t);if(!i)return;let a=i.map(e=>e.isRich?e.node:e.node&&typeof e.node==`object`&&!Array.isArray(e.node)?Object.keys(e.node).every(t=>e.node[t]&&typeof e.node[t]==`object`&&!h(e.node[t]))?{}:{base:e.node}:{}),o=new Set;for(let e of a)if(e.variants)for(let t of Object.keys(e.variants))o.add(t);for(let e of a)if(e.defaultVariants)for(let t of Object.keys(e.defaultVariants))o.add(t);let s={};for(let e of o){if(e in n){s[e]=_(n[e]);continue}for(let t=a.length-1;t>=0;t--){let n=a[t].defaultVariants?.[e];if(n!==void 0){s[e]=_(n);break}}}for(let[e,i]of Object.entries(n)){if(!o.has(e)){console.warn(`Template "${r}" path "${t.join(`.`)}" has no variant axis "${e}"; ignored.`);continue}let n=_(i),s=!1;for(let t of a)if(t.variants?.[e]&&n!==void 0&&n in t.variants[e]){s=!0;break}!s&&n!==void 0&&a.some(t=>t.variants&&e in t.variants)&&console.warn(`Template "${r}" axis "${e}" has no value "${n}" on path "${t.join(`.`)}"; ignored.`)}let c={};for(let e of a)e.base&&Object.assign(c,e.base);for(let e of Object.keys(s)){let t=s[e];if(t!==void 0)for(let n=a.length-1;n>=0;n--){let r=a[n].variants?.[e]?.[t];if(r){Object.assign(c,r);break}}}for(let e of a){if(e.compoundVariants)for(let t of e.compoundVariants)b(t,s)&&t.css&&Object.assign(c,t.css);if(e.anyOfVariants)for(let t of e.anyOfVariants)x(t,s)&&t.css&&Object.assign(c,t.css)}return c},C=async(e,t=``,i,a=!1)=>{if(!e)throw Error(`No styles provided to parseStyles function!`);let s=new Set,c=Object.entries(e),h=i?.strict,_=async([e,n])=>{let r=e.trim().replace(/^\?+/g,``),c=l(r),v=(e,t=`;`)=>`${c}:${e}${t}`,b={scope:t,config:i};if(typeof n==`function`)try{return await _([e,n(b)])}catch(e){u(h,`Function value for "${r}" threw: ${e?.message??e}`);return}if(n instanceof Promise)return _([e,await n]);if(i?.templates&&i.templatePaths?.[r])try{let[e,t]=i.templatePaths[r].split(`;;`),a=await import(t),o=t.includes(`salty.config`),s=o?a[e].templates:a[e],c=o?s[r]:s.params[r];if(s&&typeof c==`function`){let[e]=await C(await c(n),``);return e}}catch(e){console.error(`Error loading template "${r}" from path "${i.templatePaths[r]}"`,e);return}if(i?.templates&&i.templates[r]){if(a)return;let e=i.templates[r],t=g(n);if(t){let{path:n,variants:i}=t;if(Object.keys(i).length>0||y(e,n)){let t=S(e,n,i,r);if(t){let[e]=await C(t,``);return e}console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`);return}let a=n.reduce((e,t)=>e?.[t],e);if(a){let[e]=await C(a,``);return e}console.warn(`Template "${r}" with path of "${n.join(`.`)}" was not found in config!`);return}console.warn(`Template "${r}" received an unsupported call-site value.`);return}if(!(r===`compoundVariants`||r===`anyOfVariants`)&&Array.isArray(n))return n.length===0?void 0:_([e,n.join(`, `)]);if(typeof n==`object`){if(!n)return;if(n.isColor||n.isDefineFont)return v(n.toString());if(r===`defaultVariants`)return;if(r===`variants`){let e=Object.entries(n);for(let[n,r]of e){if(!r)continue;let e=Object.entries(r);for(let[r,a]of e)a&&(await C(a,`${t}.${n}-${r}`,i)).forEach(e=>s.add(e))}return}if(r===`compoundVariants`){for(let e of n){let{css:n,...r}=e;(await C(n,Object.entries(r).reduce((e,[t,n])=>`${e}.${t}-${n}`,t),i)).forEach(e=>s.add(e))}return}if(r===`anyOfVariants`){for(let e of n){let{css:n,...r}=e;(await C(n,`${t}:where(${Object.entries(r).map(([e,t])=>`.${e}-${t}`).join(`, `)})`,i)).forEach(e=>s.add(e))}return}if(r===`global`){(await C(n,``,i)).forEach(e=>s.add(e));return}if(r.startsWith(`@`)){p.test(r)&&u(h,`At-rule "${r}" is missing its condition (e.g. "@media (min-width: 600px)").`);let e=m.test(r)?``:t,a=`${i?.mediaQueries?.[r]||r} { ${await w(n,e,i)} }`;s.add(a);return}if(Object.keys(n).length===0)return;d.test(r)&&u(h,`Selector "${r}" looks like a missing-colon typo (did you mean "&:${r.slice(1)}"?).`);let e=D(t,r);(await C(n,e,i)).forEach(e=>s.add(e));return}if(r.startsWith(`$`)){u(h,`Property key "${r}" looks like a SCSS variable — Salty does not support those.`);return}if(r.includes(`:`)){u(h,`Property key "${r}" contains a colon — did you accidentally paste a whole declaration as a key?`);return}if(n==null){u(h,`Property "${r}" has a ${n===void 0?`undefined`:`null`} value — skipping.`);return}if(typeof n==`boolean`){u(h,`Property "${r}" has a boolean value (${n}) — skipping.`);return}if(n!==``){if(typeof n==`number`){if(!Number.isFinite(n)){u(h,`Property "${r}" has a non-finite numeric value (${n}) — skipping.`);return}return v(o(c,n,i))}if(typeof n!=`string`)if(n&&typeof n==`object`&&`toString`in n)n=n.toString();else{u(h,`Property "${r}" has an unsupported value type (${typeof n}) — skipping.`);return}return typeof n==`string`&&f.test(n)&&u(h,`Property "${r}" value "${n}" contains an unresolved \`\${...}\` — did you forget to interpolate?`),v(n)}},v=c.map(_),{modifiers:b}=i||{},x=[r(),n(b)],T=(await Promise.all(v).then(e=>Promise.all(e.map(e=>x.reduce(async(e,t)=>{let n=await e;if(!n)return n;let r=await t(n);if(!r)return n;let{transformed:i,additionalCss:a}=r,o=``;if(a)for(let e of a)o+=await w(e,``);return`${o}${i}`},Promise.resolve(e)))))).filter(e=>e!==void 0).join(`
2
+ `);if(!T.trim())return Array.from(s);let E=t?`${t} {\n\t${T}\n}`:T;return s.has(E)?Array.from(s):[E,...s]},w=async(e,t,n,r=!1)=>(await C(e,t,n,r)).join(`
3
+ `),T=e=>{let t=[],n=0,r=``;for(let i of e)if(i===`(`||i===`[`?n++:(i===`)`||i===`]`)&&(n=Math.max(0,n-1)),i===`,`&&n===0){let e=r.trim();e&&t.push(e),r=``}else r+=i;let i=r.trim();return i&&t.push(i),t},E=(e,t)=>t.includes(`&`)?t.replaceAll(`&`,e):t.startsWith(`:`)?`${e}${t}`:`${e} ${t}`,D=(e,t)=>{if(!e)return t;let n=T(e),r=T(t);if(!r.length)return e;if(n.length<=1&&r.length<=1)return E(n[0]??e,r[0]);let i=[];for(let e of n)for(let t of r)i.push(E(e,t));return i.join(`, `)};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}});