css-typed-vars 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -122,6 +122,7 @@ npx css-typed-vars --input "src/**/*.css" --output src/cssVars.js # generates .
122
122
  | `--prefix` | Prefix for generated keys: `--prefix theme` → `themeColorPrimary` |
123
123
  | `--naming` | Key naming: `camelCase` (default), `snake`, `kebab` |
124
124
  | `--watch` | Watch for file changes and regenerate |
125
+ | `--version`, `-v` | Print the version number and exit |
125
126
 
126
127
  CLI flags override values from the config file.
127
128
 
@@ -10,6 +10,9 @@ import { writeFile, mkdir } from "fs/promises";
10
10
  import { dirname, resolve } from "path";
11
11
  async function generate(options) {
12
12
  const names = await scanVarNames(options.input, options.exclude);
13
+ if (names.length === 0) {
14
+ console.warn("css-typed-vars: no CSS custom properties found.");
15
+ }
13
16
  const outPath = resolve(options.output);
14
17
  await mkdir(dirname(outPath), { recursive: true });
15
18
  if (options.output.endsWith(".js")) {
package/dist/cli.cjs CHANGED
@@ -23,6 +23,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  mod
24
24
  ));
25
25
 
26
+ // node_modules/tsup/assets/cjs_shims.js
27
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
28
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
29
+
26
30
  // src/cli.ts
27
31
  var import_promises3 = require("fs/promises");
28
32
  var import_node_path2 = require("path");
@@ -131,6 +135,9 @@ function generateDeclaration(varNames, prefix, naming) {
131
135
  // src/index.ts
132
136
  async function generate(options) {
133
137
  const names = await scanVarNames(options.input, options.exclude);
138
+ if (names.length === 0) {
139
+ console.warn("css-typed-vars: no CSS custom properties found.");
140
+ }
134
141
  const outPath = (0, import_node_path.resolve)(options.output);
135
142
  await (0, import_promises2.mkdir)((0, import_node_path.dirname)(outPath), { recursive: true });
136
143
  if (options.output.endsWith(".js")) {
@@ -175,6 +182,11 @@ async function run(input, output, exclude, prefix, naming) {
175
182
  console.log(`Generated \u2192 ${output}`);
176
183
  }
177
184
  async function main() {
185
+ if (args.includes("--version") || args.includes("-v")) {
186
+ const pkg = JSON.parse(await (0, import_promises3.readFile)(new URL("../package.json", importMetaUrl), "utf8"));
187
+ console.log(pkg.version);
188
+ process.exit(0);
189
+ }
178
190
  const config = await loadConfig();
179
191
  const input = getArg("--input") ?? config.input;
180
192
  const output = getArg("--output") ?? config.output;
@@ -189,10 +201,11 @@ async function main() {
189
201
  await run(input, output, exclude, prefix, naming);
190
202
  if (watchMode) {
191
203
  const patterns = Array.isArray(input) ? input : [input];
192
- (0, import_chokidar.watch)(patterns).on("change", (file) => {
193
- console.log(`Changed: ${file}`);
204
+ const makeHandler = (label) => (file) => {
205
+ console.log(`${label}: ${file}`);
194
206
  run(input, output, exclude, prefix, naming).catch(console.error);
195
- });
207
+ };
208
+ (0, import_chokidar.watch)(patterns).on("change", makeHandler("Changed")).on("add", makeHandler("Added")).on("unlink", makeHandler("Removed"));
196
209
  console.log("Watching for changes...");
197
210
  }
198
211
  }
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  generate
4
- } from "./chunk-3XKCOLZL.js";
4
+ } from "./chunk-S2QNFCPF.js";
5
5
  import "./chunk-4VL6W5GO.js";
6
6
 
7
7
  // src/cli.ts
@@ -41,6 +41,11 @@ async function run(input, output, exclude, prefix, naming) {
41
41
  console.log(`Generated \u2192 ${output}`);
42
42
  }
43
43
  async function main() {
44
+ if (args.includes("--version") || args.includes("-v")) {
45
+ const pkg = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
46
+ console.log(pkg.version);
47
+ process.exit(0);
48
+ }
44
49
  const config = await loadConfig();
45
50
  const input = getArg("--input") ?? config.input;
46
51
  const output = getArg("--output") ?? config.output;
@@ -55,10 +60,11 @@ async function main() {
55
60
  await run(input, output, exclude, prefix, naming);
56
61
  if (watchMode) {
57
62
  const patterns = Array.isArray(input) ? input : [input];
58
- watch(patterns).on("change", (file) => {
59
- console.log(`Changed: ${file}`);
63
+ const makeHandler = (label) => (file) => {
64
+ console.log(`${label}: ${file}`);
60
65
  run(input, output, exclude, prefix, naming).catch(console.error);
61
- });
66
+ };
67
+ watch(patterns).on("change", makeHandler("Changed")).on("add", makeHandler("Added")).on("unlink", makeHandler("Removed"));
62
68
  console.log("Watching for changes...");
63
69
  }
64
70
  }
package/dist/index.cjs CHANGED
@@ -139,6 +139,9 @@ function generateDeclaration(varNames, prefix, naming) {
139
139
  // src/index.ts
140
140
  async function generate(options) {
141
141
  const names = await scanVarNames(options.input, options.exclude);
142
+ if (names.length === 0) {
143
+ console.warn("css-typed-vars: no CSS custom properties found.");
144
+ }
142
145
  const outPath = (0, import_node_path.resolve)(options.output);
143
146
  await (0, import_promises2.mkdir)((0, import_node_path.dirname)(outPath), { recursive: true });
144
147
  if (options.output.endsWith(".js")) {
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  generate
3
- } from "./chunk-3XKCOLZL.js";
3
+ } from "./chunk-S2QNFCPF.js";
4
4
  import {
5
5
  generateCode,
6
6
  generateDeclaration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-typed-vars",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Generate TypeScript typed constants from CSS custom properties",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",