@kinetixui/cli 0.16.0 → 0.17.0

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 +53 -8
  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(
@@ -402,10 +422,25 @@ async function inspect(name, options) {
402
422
  }
403
423
  const spec = await fetchComponentSpec(options.registry, name);
404
424
  if (spec) {
405
- console.log();
406
- console.log(pc4.dim("Variants:"));
407
- for (const [axis, options_] of Object.entries(spec.variants)) {
408
- console.log(` ${pc4.dim(axis)} ${options_.join(", ")}`);
425
+ if (spec.since || spec.status) {
426
+ console.log();
427
+ console.log(`${pc4.dim("Since:")} ${spec.since ?? "\u2014"} ${pc4.dim(spec.status ? `(${spec.status})` : "")}`);
428
+ }
429
+ const axes = Object.entries(spec.variants ?? {});
430
+ if (axes.length) {
431
+ console.log();
432
+ console.log(pc4.dim("Variants:"));
433
+ for (const [axis, options_] of axes) {
434
+ console.log(` ${pc4.dim(axis)} ${options_.join(", ")}`);
435
+ }
436
+ }
437
+ if (spec.components?.length) {
438
+ console.log();
439
+ console.log(pc4.dim("Parts:"));
440
+ for (const part of spec.components) {
441
+ const own = part.props.map((p) => p.required ? p.name : `${p.name}?`);
442
+ console.log(` ${part.name}${own.length ? ` ${pc4.dim(own.join(", "))}` : ""}`);
443
+ }
409
444
  }
410
445
  }
411
446
  console.log();
@@ -447,7 +482,7 @@ var COLOR_PATTERNS = [
447
482
  // style={{ color: "#1a2b3c" }} / a plain CSS declaration `color: #1a2b3c;`
448
483
  new RegExp(`:\\s*["']?#${HEX}["']?`, "g")
449
484
  ];
450
- var SPACING_UTILITY_PATTERN = "-?(?:p|m)[trblxy]?|gap(?:-[xy])?|space-[xy]|inset(?:-[xy])?|top|right|bottom|left";
485
+ var SPACING_UTILITY_PATTERN = "-?(?:(?:p|m)[trblxy]?|gap(?:-[xy])?|space-[xy]|inset(?:-[xy])?|top|right|bottom|left)";
451
486
  var SPACING_VALUE = "-?[\\d.]+(?:px|rem|em|%)?";
452
487
  var SPACING_PATTERNS = [
453
488
  new RegExp(`\\b(?:${SPACING_UTILITY_PATTERN})-\\[${SPACING_VALUE}\\]`, "g")
@@ -494,6 +529,14 @@ var SUGGESTION = {
494
529
  color: "consider a semantic token utility instead (e.g. bg-primary, text-foreground)",
495
530
  spacing: "consider a token-backed spacing utility instead (e.g. p-4, gap-2)"
496
531
  };
532
+ function dedupeNestedDirs(dirs) {
533
+ const sorted = [...new Set(dirs)].sort((a, b) => a.length - b.length);
534
+ const kept = [];
535
+ for (const dir of sorted) {
536
+ if (!kept.some((k) => dir === k || dir.startsWith(k + path8.sep))) kept.push(dir);
537
+ }
538
+ return kept;
539
+ }
497
540
  async function collectFiles(dir) {
498
541
  if (!existsSync8(dir)) return [];
499
542
  const files = [];
@@ -523,7 +566,7 @@ async function lint(targetArg, options) {
523
566
  }
524
567
  const config = await readConfig(cwd);
525
568
  if (!config) throw new Error(`${CONFIG_FILE} exists but isn't valid JSON.`);
526
- dirs = [resolveAliasDir(cwd, config, "components"), resolveAliasDir(cwd, config, "ui")];
569
+ dirs = dedupeNestedDirs([resolveAliasDir(cwd, config, "components"), resolveAliasDir(cwd, config, "ui")]);
527
570
  }
528
571
  const seenFiles = /* @__PURE__ */ new Set();
529
572
  const files = [];
@@ -817,6 +860,7 @@ function cssPath(cwd, name) {
817
860
  return path9.join(cwd, THEME_DIR, `${name}.css`);
818
861
  }
819
862
  async function themeCreate(name, options) {
863
+ assertThemeName(name);
820
864
  const cwd = process.cwd();
821
865
  const file = csvPath(cwd, name);
822
866
  if (existsSync9(file) && !options.force) {
@@ -829,6 +873,7 @@ async function themeCreate(name, options) {
829
873
  console.log(pc8.dim(` kinetixui theme build ${name}`));
830
874
  }
831
875
  async function themeBuild(name, options) {
876
+ assertThemeName(name);
832
877
  const cwd = process.cwd();
833
878
  const src = csvPath(cwd, name);
834
879
  if (!existsSync9(src)) {
@@ -870,7 +915,7 @@ async function themeBuild(name, options) {
870
915
  // package.json
871
916
  var package_default = {
872
917
  name: "@kinetixui/cli",
873
- version: "0.16.0",
918
+ version: "0.17.0",
874
919
  description: "Add KinetixUI components and tokens to your project.",
875
920
  type: "module",
876
921
  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.17.0",
4
4
  "description": "Add KinetixUI components and tokens to your project.",
5
5
  "type": "module",
6
6
  "license": "MIT",