rafters 0.0.58 → 0.0.60

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 +50 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13389,6 +13389,7 @@ async function installWithPackageManager(packageManager, dependencies, options)
13389
13389
  }
13390
13390
 
13391
13391
  // src/utils/install-registry-deps.ts
13392
+ var REACT_RUNTIME_PACKAGES = /* @__PURE__ */ new Set(["react", "react-dom", "@types/react", "@types/react-dom"]);
13392
13393
  function parseDependency(dep) {
13393
13394
  const trimmed = dep.trim();
13394
13395
  if (!trimmed) {
@@ -13439,8 +13440,12 @@ async function installRegistryDependencies(items, targetDir, options = {}) {
13439
13440
  return result;
13440
13441
  }
13441
13442
  const externalDeps = [];
13443
+ const dropForTarget = options.target && options.target !== "react";
13442
13444
  for (const dep of allDeps) {
13443
- if (parseDependency(dep).name.startsWith("@rafters/")) {
13445
+ const { name } = parseDependency(dep);
13446
+ if (name.startsWith("@rafters/")) {
13447
+ result.skipped.push(dep);
13448
+ } else if (dropForTarget && REACT_RUNTIME_PACKAGES.has(name)) {
13444
13449
  result.skipped.push(dep);
13445
13450
  } else {
13446
13451
  externalDeps.push(dep);
@@ -13630,6 +13635,26 @@ function selectFilesForFramework(files, target) {
13630
13635
  return { files, fallback: false };
13631
13636
  }
13632
13637
  var FOLDER_NAMES = /* @__PURE__ */ new Set(["composites"]);
13638
+ var COMPOSITES_RUNTIME_CONTENT = `export { Composite, createComposites, toJsx, toMdx } from '@rafters/composites/client';
13639
+ export type { CompositeProps, ToJsxOptions } from '@rafters/composites/client';
13640
+ `;
13641
+ function buildCompositesRuntimeItem() {
13642
+ return {
13643
+ name: "composites",
13644
+ type: "composite",
13645
+ primitives: [],
13646
+ rules: [],
13647
+ composites: [],
13648
+ files: [
13649
+ {
13650
+ path: "composites/index.ts",
13651
+ content: COMPOSITES_RUNTIME_CONTENT,
13652
+ dependencies: ["@rafters/composites"],
13653
+ devDependencies: []
13654
+ }
13655
+ ]
13656
+ };
13657
+ }
13633
13658
  function isAlreadyInstalled(config2, item) {
13634
13659
  if (!config2?.installed) return false;
13635
13660
  if (item.type === "ui") {
@@ -13640,6 +13665,14 @@ function isAlreadyInstalled(config2, item) {
13640
13665
  }
13641
13666
  return config2.installed.primitives.includes(item.name);
13642
13667
  }
13668
+ function isInstalledOnDisk(config2, item, cwd) {
13669
+ if (!isAlreadyInstalled(config2, item)) return false;
13670
+ const filesToCheck = item.type === "ui" ? selectFilesForFramework(item.files, getComponentTarget(config2)).files : item.files;
13671
+ for (const file2 of filesToCheck) {
13672
+ if (fileExists(cwd, transformPath(file2.path, config2, cwd))) return true;
13673
+ }
13674
+ return false;
13675
+ }
13643
13676
  function trackInstalled(config2, items) {
13644
13677
  if (!config2.installed) {
13645
13678
  config2.installed = { components: [], primitives: [], composites: [], rules: [] };
@@ -13814,6 +13847,9 @@ async function add(componentArgs, options) {
13814
13847
  }
13815
13848
  components = installedNames;
13816
13849
  }
13850
+ if (folder === "composites" && components.length === 0) {
13851
+ components = ["__composites_runtime__"];
13852
+ }
13817
13853
  if (components.length === 0) {
13818
13854
  error46("No components specified. Usage: rafters add <component...>");
13819
13855
  process.exitCode = 1;
@@ -13831,7 +13867,7 @@ async function add(componentArgs, options) {
13831
13867
  try {
13832
13868
  if (folder === "composites") {
13833
13869
  if (!seen.has(itemName)) {
13834
- const item = await client.fetchComposite(itemName);
13870
+ const item = itemName === "__composites_runtime__" ? buildCompositesRuntimeItem() : await client.fetchComposite(itemName);
13835
13871
  seen.add(itemName);
13836
13872
  allItems.push(item);
13837
13873
  }
@@ -13856,13 +13892,20 @@ async function add(componentArgs, options) {
13856
13892
  const target = getComponentTarget(config2);
13857
13893
  for (const item of allItems) {
13858
13894
  if (!options.overwrite && isAlreadyInstalled(config2, item)) {
13895
+ if (isInstalledOnDisk(config2, item, cwd)) {
13896
+ log({
13897
+ event: "add:skip",
13898
+ component: item.name,
13899
+ reason: "already installed"
13900
+ });
13901
+ skipped.push(item.name);
13902
+ continue;
13903
+ }
13859
13904
  log({
13860
- event: "add:skip",
13905
+ event: "add:warning",
13861
13906
  component: item.name,
13862
- reason: "already installed"
13907
+ message: "Config tracks this as installed but no files found on disk -- reinstalling."
13863
13908
  });
13864
- skipped.push(item.name);
13865
- continue;
13866
13909
  }
13867
13910
  try {
13868
13911
  const result = await installItem(cwd, item, options, config2);
@@ -13903,7 +13946,7 @@ async function add(componentArgs, options) {
13903
13946
  };
13904
13947
  let depsResult = emptyDeps;
13905
13948
  try {
13906
- depsResult = await installRegistryDependencies(filteredItems, cwd);
13949
+ depsResult = await installRegistryDependencies(filteredItems, cwd, { target });
13907
13950
  } catch (err) {
13908
13951
  const message = err instanceof Error ? err.message : String(err);
13909
13952
  log({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafters",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "description": "Design Intelligence CLI. Scaffold tokens, import existing shadcn/Tailwind v4 sources, add components, and serve an MCP server so AI agents read decisions instead of guessing.",
5
5
  "homepage": "https://rafters.studio",
6
6
  "license": "MIT",