rafters 0.0.35 → 0.0.37

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 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12829,6 +12829,7 @@ function frameworkToTarget(framework) {
12829
12829
  if (framework === "astro") return "astro";
12830
12830
  return "react";
12831
12831
  }
12832
+ var COMPONENT_EXTENSIONS = [".tsx", ".astro", ".vue", ".svelte"];
12832
12833
  function targetToExtension(target) {
12833
12834
  const map2 = {
12834
12835
  react: ".tsx",
@@ -12838,6 +12839,11 @@ function targetToExtension(target) {
12838
12839
  };
12839
12840
  return map2[target];
12840
12841
  }
12842
+ function resolveComponentTarget(config3) {
12843
+ if (config3?.componentTarget) return config3.componentTarget;
12844
+ if (config3?.framework) return frameworkToTarget(config3.framework);
12845
+ return "react";
12846
+ }
12841
12847
  async function hasAstroReact(cwd) {
12842
12848
  try {
12843
12849
  const content = await readFile(join(cwd, "package.json"), "utf-8");
@@ -12969,11 +12975,11 @@ function log(event) {
12969
12975
  console.log(` CSS already configured: ${event.cssPath}`);
12970
12976
  break;
12971
12977
  case "init:regenerate":
12978
+ context.spinner?.stop();
12972
12979
  context.spinner = ora("Regenerating from existing config...").start();
12973
12980
  break;
12974
12981
  case "init:loaded":
12975
12982
  context.spinner?.succeed(`Loaded ${event.tokenCount} tokens`);
12976
- context.spinner = ora("Generating outputs...").start();
12977
12983
  break;
12978
12984
  case "init:existing_design_detected":
12979
12985
  context.spinner?.info("Existing design system detected");
@@ -13005,6 +13011,7 @@ function log(event) {
13005
13011
  break;
13006
13012
  case "init:complete": {
13007
13013
  context.spinner?.succeed("Done!");
13014
+ context.spinner = null;
13008
13015
  console.log(`
13009
13016
  Output: ${event.path}`);
13010
13017
  const outputs = event.outputs;
@@ -13012,6 +13019,7 @@ function log(event) {
13012
13019
  console.log(` - ${file2}`);
13013
13020
  }
13014
13021
  console.log("");
13022
+ if (process.stdin.unref) process.stdin.unref();
13015
13023
  break;
13016
13024
  }
13017
13025
  // Add events
@@ -13348,9 +13356,7 @@ function getInstalledNames(config3) {
13348
13356
  return [...names2].sort();
13349
13357
  }
13350
13358
  function getComponentTarget(config3) {
13351
- if (config3?.componentTarget) return config3.componentTarget;
13352
- if (config3?.framework) return frameworkToTarget(config3.framework);
13353
- return "react";
13359
+ return resolveComponentTarget(config3);
13354
13360
  }
13355
13361
  var SHARED_EXTENSIONS = /* @__PURE__ */ new Set([".classes.ts", ".types.ts", ".constants.ts"]);
13356
13362
  function isSharedFile(path2) {
@@ -60599,12 +60605,32 @@ var RaftersToolHandler = class _RaftersToolHandler {
60599
60605
  return join10(this.projectRoot, "packages/ui/src/components/ui");
60600
60606
  }
60601
60607
  /**
60602
- * Load component metadata from source file
60608
+ * Find the actual component file on disk for a given name.
60609
+ * Checks the config's componentTarget extension first, then falls back
60610
+ * to all known extensions so Astro projects with React islands also work.
60611
+ */
60612
+ async resolveComponentFile(componentsPath, name2) {
60613
+ const config3 = await this.loadConfig();
60614
+ const preferredExt = targetToExtension(resolveComponentTarget(config3));
60615
+ const preferred = join10(componentsPath, `${name2}${preferredExt}`);
60616
+ if (existsSync4(preferred)) return preferred;
60617
+ for (const ext2 of COMPONENT_EXTENSIONS) {
60618
+ if (ext2 === preferredExt) continue;
60619
+ const candidate = join10(componentsPath, `${name2}${ext2}`);
60620
+ if (existsSync4(candidate)) return candidate;
60621
+ }
60622
+ return null;
60623
+ }
60624
+ /**
60625
+ * Load component metadata from source file.
60626
+ * Resolves the actual file extension from the config's componentTarget
60627
+ * and merges variant/size data from .classes.ts companions when present.
60603
60628
  */
60604
60629
  async loadComponentMetadata(name2) {
60605
60630
  const componentsPath = await this.getComponentsPath();
60606
60631
  if (!componentsPath) return null;
60607
- const filePath = join10(componentsPath, `${name2}.tsx`);
60632
+ const filePath = await this.resolveComponentFile(componentsPath, name2);
60633
+ if (!filePath) return null;
60608
60634
  try {
60609
60635
  const source = await readFile6(filePath, "utf-8");
60610
60636
  const intelligence = parseJSDocIntelligence(source);
@@ -60614,16 +60640,28 @@ var RaftersToolHandler = class _RaftersToolHandler {
60614
60640
  jsDocDeps = extractJSDocDependencies(source);
60615
60641
  } catch {
60616
60642
  }
60643
+ let variants = extractVariants(source);
60644
+ let sizes = extractSizes(source);
60645
+ try {
60646
+ const classesSource = await readFile6(join10(componentsPath, `${name2}.classes.ts`), "utf-8");
60647
+ if (!variants || variants.length === 0) {
60648
+ variants = extractVariants(classesSource);
60649
+ }
60650
+ if (!sizes || sizes.length === 0) {
60651
+ sizes = extractSizes(classesSource);
60652
+ }
60653
+ } catch {
60654
+ }
60617
60655
  const metadata = {
60618
60656
  name: name2,
60619
60657
  displayName: toDisplayName(name2),
60620
60658
  category: this.inferCategory(name2),
60621
- variants: extractVariants(source),
60622
- sizes: extractSizes(source),
60659
+ variants,
60660
+ sizes,
60623
60661
  dependencies: extractDependencies(source),
60624
60662
  primitives: extractPrimitiveDependencies(source),
60625
60663
  // projectRoot is guaranteed non-null here: handleToolCall guards it
60626
- filePath: relative2(this.projectRoot, join10(componentsPath, `${name2}.tsx`))
60664
+ filePath: relative2(this.projectRoot, filePath)
60627
60665
  };
60628
60666
  if (hasAnyDeps(jsDocDeps)) {
60629
60667
  metadata.jsDocDependencies = jsDocDeps;
@@ -60720,7 +60758,12 @@ var RaftersToolHandler = class _RaftersToolHandler {
60720
60758
  if (componentsPath) {
60721
60759
  try {
60722
60760
  const files = await readdir3(componentsPath);
60723
- available = files.filter((f) => f.endsWith(".tsx")).map((f) => basename(f, ".tsx")).filter((n2) => n2.includes(name2) || name2.includes(n2)).slice(0, 5);
60761
+ available = files.filter(
60762
+ (f) => COMPONENT_EXTENSIONS.some((ext2) => f.endsWith(ext2)) && !f.includes(".classes.")
60763
+ ).map((f) => {
60764
+ const ext2 = COMPONENT_EXTENSIONS.find((e) => f.endsWith(e));
60765
+ return ext2 ? basename(f, ext2) : basename(f);
60766
+ }).filter((n2) => n2.includes(name2) || name2.includes(n2)).slice(0, 5);
60724
60767
  } catch {
60725
60768
  }
60726
60769
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafters",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "CLI for Rafters design system - scaffold tokens and add components",
5
5
  "license": "MIT",
6
6
  "type": "module",