@kinetixui/cli 0.16.0 → 0.16.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.
Files changed (2) hide show
  1. package/dist/index.js +34 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -91,6 +91,14 @@ function assertComponentName(name) {
91
91
  }
92
92
  return name;
93
93
  }
94
+ function assertThemeName(name) {
95
+ if (typeof name !== "string" || !/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(name)) {
96
+ throw new Error(
97
+ `Invalid theme name ${JSON.stringify(name)} \u2014 expected letters, digits and dashes.`
98
+ );
99
+ }
100
+ return name;
101
+ }
94
102
  function assertRegistryUrl(url) {
95
103
  let parsed;
96
104
  try {
@@ -248,6 +256,13 @@ async function doctor() {
248
256
  levels.push(report("warn", `"${alias}" alias points to ${path5.relative(cwd, dir) || "."}, which doesn't exist yet.`));
249
257
  }
250
258
  }
259
+ const utilsBase = resolveAliasDir(cwd, config, "utils");
260
+ const utilsFile = [".ts", ".tsx", ".js", ".jsx"].map((ext) => `${utilsBase}${ext}`).find((f) => existsSync5(f));
261
+ if (utilsFile) {
262
+ levels.push(report("pass", `"utils" alias resolves to ${path5.relative(cwd, utilsFile)}`));
263
+ } else {
264
+ levels.push(report("warn", `"utils" alias points to ${path5.relative(cwd, utilsBase)}, which doesn't exist yet.`));
265
+ }
251
266
  const cssPath2 = path5.join(cwd, config.srcDir ? "src" : "", config.tailwind.css);
252
267
  if (existsSync5(cssPath2)) {
253
268
  levels.push(report("pass", `Tailwind CSS file found at ${path5.relative(cwd, cssPath2)}`));
@@ -381,7 +396,12 @@ async function inspect(name, options) {
381
396
  console.log();
382
397
  console.log(`${pc4.dim("Type")} ${item.type}`);
383
398
  const cwd = process.cwd();
384
- const config = await readConfig(cwd);
399
+ let config = null;
400
+ try {
401
+ config = await readConfig(cwd);
402
+ } catch {
403
+ console.log(`${pc4.dim("Installed")} ${pc4.yellow("? (kinetixui.json exists but isn't valid JSON)")}`);
404
+ }
385
405
  if (config) {
386
406
  const uiDir = resolveAliasDir(cwd, config, "ui");
387
407
  const installed = item.files.some(
@@ -447,7 +467,7 @@ var COLOR_PATTERNS = [
447
467
  // style={{ color: "#1a2b3c" }} / a plain CSS declaration `color: #1a2b3c;`
448
468
  new RegExp(`:\\s*["']?#${HEX}["']?`, "g")
449
469
  ];
450
- var SPACING_UTILITY_PATTERN = "-?(?:p|m)[trblxy]?|gap(?:-[xy])?|space-[xy]|inset(?:-[xy])?|top|right|bottom|left";
470
+ var SPACING_UTILITY_PATTERN = "-?(?:(?:p|m)[trblxy]?|gap(?:-[xy])?|space-[xy]|inset(?:-[xy])?|top|right|bottom|left)";
451
471
  var SPACING_VALUE = "-?[\\d.]+(?:px|rem|em|%)?";
452
472
  var SPACING_PATTERNS = [
453
473
  new RegExp(`\\b(?:${SPACING_UTILITY_PATTERN})-\\[${SPACING_VALUE}\\]`, "g")
@@ -494,6 +514,14 @@ var SUGGESTION = {
494
514
  color: "consider a semantic token utility instead (e.g. bg-primary, text-foreground)",
495
515
  spacing: "consider a token-backed spacing utility instead (e.g. p-4, gap-2)"
496
516
  };
517
+ function dedupeNestedDirs(dirs) {
518
+ const sorted = [...new Set(dirs)].sort((a, b) => a.length - b.length);
519
+ const kept = [];
520
+ for (const dir of sorted) {
521
+ if (!kept.some((k) => dir === k || dir.startsWith(k + path8.sep))) kept.push(dir);
522
+ }
523
+ return kept;
524
+ }
497
525
  async function collectFiles(dir) {
498
526
  if (!existsSync8(dir)) return [];
499
527
  const files = [];
@@ -523,7 +551,7 @@ async function lint(targetArg, options) {
523
551
  }
524
552
  const config = await readConfig(cwd);
525
553
  if (!config) throw new Error(`${CONFIG_FILE} exists but isn't valid JSON.`);
526
- dirs = [resolveAliasDir(cwd, config, "components"), resolveAliasDir(cwd, config, "ui")];
554
+ dirs = dedupeNestedDirs([resolveAliasDir(cwd, config, "components"), resolveAliasDir(cwd, config, "ui")]);
527
555
  }
528
556
  const seenFiles = /* @__PURE__ */ new Set();
529
557
  const files = [];
@@ -817,6 +845,7 @@ function cssPath(cwd, name) {
817
845
  return path9.join(cwd, THEME_DIR, `${name}.css`);
818
846
  }
819
847
  async function themeCreate(name, options) {
848
+ assertThemeName(name);
820
849
  const cwd = process.cwd();
821
850
  const file = csvPath(cwd, name);
822
851
  if (existsSync9(file) && !options.force) {
@@ -829,6 +858,7 @@ async function themeCreate(name, options) {
829
858
  console.log(pc8.dim(` kinetixui theme build ${name}`));
830
859
  }
831
860
  async function themeBuild(name, options) {
861
+ assertThemeName(name);
832
862
  const cwd = process.cwd();
833
863
  const src = csvPath(cwd, name);
834
864
  if (!existsSync9(src)) {
@@ -870,7 +900,7 @@ async function themeBuild(name, options) {
870
900
  // package.json
871
901
  var package_default = {
872
902
  name: "@kinetixui/cli",
873
- version: "0.16.0",
903
+ version: "0.16.1",
874
904
  description: "Add KinetixUI components and tokens to your project.",
875
905
  type: "module",
876
906
  license: "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kinetixui/cli",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Add KinetixUI components and tokens to your project.",
5
5
  "type": "module",
6
6
  "license": "MIT",