rafters 0.0.9 → 0.0.12
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/dist/index.js +207 -41
- package/dist/registry/types.d.ts +10 -6
- package/dist/registry/types.js +7 -7
- package/package.json +6 -1
package/dist/index.js
CHANGED
|
@@ -12563,23 +12563,23 @@ var RegistryFileSchema = external_exports.object({
|
|
|
12563
12563
|
devDependencies: external_exports.array(external_exports.string()).default([])
|
|
12564
12564
|
// e.g., ["vitest"] - from @devDependencies JSDoc
|
|
12565
12565
|
});
|
|
12566
|
-
var RegistryItemTypeSchema = external_exports.enum([
|
|
12567
|
-
"registry:ui",
|
|
12568
|
-
"registry:primitive",
|
|
12569
|
-
"registry:composite"
|
|
12570
|
-
]);
|
|
12566
|
+
var RegistryItemTypeSchema = external_exports.enum(["ui", "primitive", "composite"]);
|
|
12571
12567
|
var RegistryItemSchema = external_exports.object({
|
|
12572
12568
|
name: external_exports.string(),
|
|
12573
12569
|
type: RegistryItemTypeSchema,
|
|
12574
12570
|
description: external_exports.string().optional(),
|
|
12575
12571
|
primitives: external_exports.array(external_exports.string()),
|
|
12576
|
-
files: external_exports.array(RegistryFileSchema)
|
|
12572
|
+
files: external_exports.array(RegistryFileSchema),
|
|
12573
|
+
rules: external_exports.array(external_exports.string()).default([]),
|
|
12574
|
+
composites: external_exports.array(external_exports.string()).default([])
|
|
12577
12575
|
});
|
|
12578
12576
|
var RegistryIndexSchema = external_exports.object({
|
|
12579
12577
|
name: external_exports.string(),
|
|
12580
12578
|
homepage: external_exports.string(),
|
|
12581
12579
|
components: external_exports.array(external_exports.string()),
|
|
12582
|
-
primitives: external_exports.array(external_exports.string())
|
|
12580
|
+
primitives: external_exports.array(external_exports.string()),
|
|
12581
|
+
composites: external_exports.array(external_exports.string()).default([]),
|
|
12582
|
+
rules: external_exports.array(external_exports.string()).default([])
|
|
12583
12583
|
});
|
|
12584
12584
|
|
|
12585
12585
|
// src/registry/client.ts
|
|
@@ -12650,6 +12650,30 @@ var RegistryClient = class {
|
|
|
12650
12650
|
this.cache.set(cacheKey, item);
|
|
12651
12651
|
return item;
|
|
12652
12652
|
}
|
|
12653
|
+
/**
|
|
12654
|
+
* Fetch a composite by name
|
|
12655
|
+
*/
|
|
12656
|
+
async fetchComposite(name2) {
|
|
12657
|
+
const cacheKey = `composite:${name2}`;
|
|
12658
|
+
const cached2 = this.cache.get(cacheKey);
|
|
12659
|
+
if (cached2) {
|
|
12660
|
+
return cached2;
|
|
12661
|
+
}
|
|
12662
|
+
const url2 = `${this.baseUrl}/registry/composites/${name2}.json`;
|
|
12663
|
+
const response = await fetch(url2);
|
|
12664
|
+
if (response.status === 404) {
|
|
12665
|
+
throw new Error(`Composite "${name2}" not found`);
|
|
12666
|
+
}
|
|
12667
|
+
if (!response.ok) {
|
|
12668
|
+
throw new Error(
|
|
12669
|
+
`Failed to fetch composite "${name2}": ${response.status} ${response.statusText}`
|
|
12670
|
+
);
|
|
12671
|
+
}
|
|
12672
|
+
const data = await response.json();
|
|
12673
|
+
const item = RegistryItemSchema.parse(data);
|
|
12674
|
+
this.cache.set(cacheKey, item);
|
|
12675
|
+
return item;
|
|
12676
|
+
}
|
|
12653
12677
|
/**
|
|
12654
12678
|
* Fetch a registry item (component or primitive) by name
|
|
12655
12679
|
* Tries component first, then primitive
|
|
@@ -12675,6 +12699,13 @@ var RegistryClient = class {
|
|
|
12675
12699
|
const index = await this.fetchIndex();
|
|
12676
12700
|
return index.components.map((name2) => ({ name: name2 }));
|
|
12677
12701
|
}
|
|
12702
|
+
/**
|
|
12703
|
+
* List all available composites
|
|
12704
|
+
*/
|
|
12705
|
+
async listComposites() {
|
|
12706
|
+
const index = await this.fetchIndex();
|
|
12707
|
+
return index.composites.map((name2) => ({ name: name2 }));
|
|
12708
|
+
}
|
|
12678
12709
|
/**
|
|
12679
12710
|
* Check if a component exists in the registry
|
|
12680
12711
|
*/
|
|
@@ -13199,25 +13230,40 @@ async function saveConfig(cwd, config3) {
|
|
|
13199
13230
|
}
|
|
13200
13231
|
function getInstalledNames(config3) {
|
|
13201
13232
|
if (!config3?.installed) return [];
|
|
13202
|
-
const names2 = /* @__PURE__ */ new Set([
|
|
13233
|
+
const names2 = /* @__PURE__ */ new Set([
|
|
13234
|
+
...config3.installed.components,
|
|
13235
|
+
...config3.installed.primitives,
|
|
13236
|
+
...config3.installed.composites ?? []
|
|
13237
|
+
]);
|
|
13203
13238
|
return [...names2].sort();
|
|
13204
13239
|
}
|
|
13240
|
+
var FOLDER_NAMES = /* @__PURE__ */ new Set(["composites"]);
|
|
13205
13241
|
function isAlreadyInstalled(config3, item) {
|
|
13206
13242
|
if (!config3?.installed) return false;
|
|
13207
|
-
if (item.type === "
|
|
13243
|
+
if (item.type === "ui") {
|
|
13208
13244
|
return config3.installed.components.includes(item.name);
|
|
13209
13245
|
}
|
|
13246
|
+
if (item.type === "composite") {
|
|
13247
|
+
return (config3.installed.composites ?? []).includes(item.name);
|
|
13248
|
+
}
|
|
13210
13249
|
return config3.installed.primitives.includes(item.name);
|
|
13211
13250
|
}
|
|
13212
13251
|
function trackInstalled(config3, items) {
|
|
13213
13252
|
if (!config3.installed) {
|
|
13214
|
-
config3.installed = { components: [], primitives: [] };
|
|
13253
|
+
config3.installed = { components: [], primitives: [], composites: [] };
|
|
13254
|
+
}
|
|
13255
|
+
if (!config3.installed.composites) {
|
|
13256
|
+
config3.installed.composites = [];
|
|
13215
13257
|
}
|
|
13216
13258
|
for (const item of items) {
|
|
13217
|
-
if (item.type === "
|
|
13259
|
+
if (item.type === "ui") {
|
|
13218
13260
|
if (!config3.installed.components.includes(item.name)) {
|
|
13219
13261
|
config3.installed.components.push(item.name);
|
|
13220
13262
|
}
|
|
13263
|
+
} else if (item.type === "composite") {
|
|
13264
|
+
if (!config3.installed.composites.includes(item.name)) {
|
|
13265
|
+
config3.installed.composites.push(item.name);
|
|
13266
|
+
}
|
|
13221
13267
|
} else {
|
|
13222
13268
|
if (!config3.installed.primitives.includes(item.name)) {
|
|
13223
13269
|
config3.installed.primitives.push(item.name);
|
|
@@ -13226,6 +13272,7 @@ function trackInstalled(config3, items) {
|
|
|
13226
13272
|
}
|
|
13227
13273
|
config3.installed.components.sort();
|
|
13228
13274
|
config3.installed.primitives.sort();
|
|
13275
|
+
config3.installed.composites.sort();
|
|
13229
13276
|
}
|
|
13230
13277
|
function transformPath(registryPath, config3) {
|
|
13231
13278
|
if (!config3) return registryPath;
|
|
@@ -13235,6 +13282,9 @@ function transformPath(registryPath, config3) {
|
|
|
13235
13282
|
if (registryPath.startsWith("lib/primitives/")) {
|
|
13236
13283
|
return registryPath.replace("lib/primitives/", `${config3.primitivesPath}/`);
|
|
13237
13284
|
}
|
|
13285
|
+
if (registryPath.startsWith("composites/")) {
|
|
13286
|
+
return registryPath.replace("composites/", `${config3.compositesPath}/`);
|
|
13287
|
+
}
|
|
13238
13288
|
return registryPath;
|
|
13239
13289
|
}
|
|
13240
13290
|
function fileExists(cwd, relativePath) {
|
|
@@ -13306,15 +13356,32 @@ async function add(componentArgs, options) {
|
|
|
13306
13356
|
setAgentMode(options.agent ?? false);
|
|
13307
13357
|
let components = componentArgs;
|
|
13308
13358
|
const client = new RegistryClient(options.registryUrl);
|
|
13359
|
+
let folder;
|
|
13360
|
+
const firstArg = components[0];
|
|
13361
|
+
if (firstArg && FOLDER_NAMES.has(firstArg)) {
|
|
13362
|
+
folder = firstArg;
|
|
13363
|
+
components = components.slice(1);
|
|
13364
|
+
}
|
|
13309
13365
|
if (options.list) {
|
|
13310
13366
|
const availableComponents = await client.listComponents();
|
|
13367
|
+
const availableComposites = await client.listComposites();
|
|
13311
13368
|
if (options.agent) {
|
|
13312
|
-
log({
|
|
13369
|
+
log({
|
|
13370
|
+
event: "add:list",
|
|
13371
|
+
components: availableComponents,
|
|
13372
|
+
composites: availableComposites
|
|
13373
|
+
});
|
|
13313
13374
|
} else {
|
|
13314
13375
|
console.log("Available components:\n");
|
|
13315
13376
|
for (const comp of availableComponents) {
|
|
13316
13377
|
console.log(` ${comp.name} ${comp.description ?? ""}`);
|
|
13317
13378
|
}
|
|
13379
|
+
if (availableComposites.length > 0) {
|
|
13380
|
+
console.log("\nAvailable composites:\n");
|
|
13381
|
+
for (const comp of availableComposites) {
|
|
13382
|
+
console.log(` ${comp.name} ${comp.description ?? ""}`);
|
|
13383
|
+
}
|
|
13384
|
+
}
|
|
13318
13385
|
}
|
|
13319
13386
|
return;
|
|
13320
13387
|
}
|
|
@@ -13357,15 +13424,23 @@ async function add(componentArgs, options) {
|
|
|
13357
13424
|
});
|
|
13358
13425
|
const allItems = [];
|
|
13359
13426
|
const seen = /* @__PURE__ */ new Set();
|
|
13360
|
-
for (const
|
|
13427
|
+
for (const itemName of components) {
|
|
13361
13428
|
try {
|
|
13362
|
-
|
|
13363
|
-
|
|
13429
|
+
if (folder === "composites") {
|
|
13430
|
+
if (!seen.has(itemName)) {
|
|
13431
|
+
const item = await client.fetchComposite(itemName);
|
|
13432
|
+
seen.add(itemName);
|
|
13433
|
+
allItems.push(item);
|
|
13434
|
+
}
|
|
13435
|
+
} else {
|
|
13436
|
+
const items = await client.resolveDependencies(itemName, seen);
|
|
13437
|
+
allItems.push(...items);
|
|
13438
|
+
}
|
|
13364
13439
|
} catch (err) {
|
|
13365
13440
|
if (err instanceof Error) {
|
|
13366
13441
|
error46(err.message);
|
|
13367
13442
|
} else {
|
|
13368
|
-
error46(`Failed to fetch
|
|
13443
|
+
error46(`Failed to fetch "${itemName}"`);
|
|
13369
13444
|
}
|
|
13370
13445
|
process.exitCode = 1;
|
|
13371
13446
|
return;
|
|
@@ -13443,10 +13518,11 @@ async function add(componentArgs, options) {
|
|
|
13443
13518
|
framework: "unknown",
|
|
13444
13519
|
componentsPath: "components/ui",
|
|
13445
13520
|
primitivesPath: "lib/primitives",
|
|
13521
|
+
compositesPath: "composites",
|
|
13446
13522
|
cssPath: null,
|
|
13447
13523
|
shadcn: false,
|
|
13448
13524
|
exports: DEFAULT_EXPORTS,
|
|
13449
|
-
installed: { components: [], primitives: [] }
|
|
13525
|
+
installed: { components: [], primitives: [], composites: [] }
|
|
13450
13526
|
};
|
|
13451
13527
|
trackInstalled(newConfig, installedItems);
|
|
13452
13528
|
await saveConfig(cwd, newConfig);
|
|
@@ -13469,7 +13545,7 @@ async function add(componentArgs, options) {
|
|
|
13469
13545
|
}
|
|
13470
13546
|
|
|
13471
13547
|
// src/commands/init.ts
|
|
13472
|
-
import { existsSync as
|
|
13548
|
+
import { existsSync as existsSync3 } from "fs";
|
|
13473
13549
|
import { copyFile, mkdir as mkdir3, readFile as readFile5, rm, writeFile as writeFile3 } from "fs/promises";
|
|
13474
13550
|
import { createRequire } from "module";
|
|
13475
13551
|
import { join as join9, relative } from "path";
|
|
@@ -14397,6 +14473,42 @@ function buildExtensions(token) {
|
|
|
14397
14473
|
if (token.customPropertyOnly) {
|
|
14398
14474
|
extensions.customPropertyOnly = token.customPropertyOnly;
|
|
14399
14475
|
}
|
|
14476
|
+
if (token.userOverride) {
|
|
14477
|
+
extensions.userOverride = token.userOverride;
|
|
14478
|
+
}
|
|
14479
|
+
if (token.computedValue !== void 0) {
|
|
14480
|
+
extensions.computedValue = convertValue({ ...token, value: token.computedValue });
|
|
14481
|
+
}
|
|
14482
|
+
if (token.generationRule) {
|
|
14483
|
+
extensions.generationRule = token.generationRule;
|
|
14484
|
+
}
|
|
14485
|
+
if (token.pairedWith && token.pairedWith.length > 0) {
|
|
14486
|
+
extensions.pairedWith = token.pairedWith;
|
|
14487
|
+
}
|
|
14488
|
+
if (token.conflictsWith && token.conflictsWith.length > 0) {
|
|
14489
|
+
extensions.conflictsWith = token.conflictsWith;
|
|
14490
|
+
}
|
|
14491
|
+
if (token.applicableComponents && token.applicableComponents.length > 0) {
|
|
14492
|
+
extensions.applicableComponents = token.applicableComponents;
|
|
14493
|
+
}
|
|
14494
|
+
if (token.requiredForComponents && token.requiredForComponents.length > 0) {
|
|
14495
|
+
extensions.requiredForComponents = token.requiredForComponents;
|
|
14496
|
+
}
|
|
14497
|
+
if (token.trustLevel) {
|
|
14498
|
+
extensions.trustLevel = token.trustLevel;
|
|
14499
|
+
}
|
|
14500
|
+
if (token.cognitiveLoad !== void 0) {
|
|
14501
|
+
extensions.cognitiveLoad = token.cognitiveLoad;
|
|
14502
|
+
}
|
|
14503
|
+
if (token.consequence) {
|
|
14504
|
+
extensions.consequence = token.consequence;
|
|
14505
|
+
}
|
|
14506
|
+
if (token.accessibilityLevel) {
|
|
14507
|
+
extensions.accessibilityLevel = token.accessibilityLevel;
|
|
14508
|
+
}
|
|
14509
|
+
if (token.appliesWhen && token.appliesWhen.length > 0) {
|
|
14510
|
+
extensions.appliesWhen = token.appliesWhen;
|
|
14511
|
+
}
|
|
14400
14512
|
return Object.keys(extensions).length > 0 ? { rafters: extensions } : {};
|
|
14401
14513
|
}
|
|
14402
14514
|
function tokenToDTCG(token) {
|
|
@@ -47524,7 +47636,7 @@ function extractPrimitiveDependencies(source) {
|
|
|
47524
47636
|
const pkg = match2[1];
|
|
47525
47637
|
if (pkg && (pkg.includes("/primitives/") || pkg.includes("../primitives/"))) {
|
|
47526
47638
|
const primitiveName = pkg.split("/").pop()?.replace(/\.(ts|tsx)$/, "");
|
|
47527
|
-
if (primitiveName && !primitives.includes(primitiveName)
|
|
47639
|
+
if (primitiveName && !primitives.includes(primitiveName)) {
|
|
47528
47640
|
primitives.push(primitiveName);
|
|
47529
47641
|
}
|
|
47530
47642
|
}
|
|
@@ -47547,7 +47659,13 @@ function extractJSDocDependencies(source) {
|
|
|
47547
47659
|
if (!field) continue;
|
|
47548
47660
|
const value2 = getTagValue(tag).trim();
|
|
47549
47661
|
if (value2) {
|
|
47550
|
-
|
|
47662
|
+
const tokens = value2.split(/\s+/).filter(Boolean);
|
|
47663
|
+
const validTokens = [];
|
|
47664
|
+
for (const token of tokens) {
|
|
47665
|
+
if (token.startsWith("(")) break;
|
|
47666
|
+
validTokens.push(token);
|
|
47667
|
+
}
|
|
47668
|
+
result[field].push(...validTokens);
|
|
47551
47669
|
}
|
|
47552
47670
|
}
|
|
47553
47671
|
}
|
|
@@ -50782,8 +50900,15 @@ var RuleContextSchema = external_exports.object({
|
|
|
50782
50900
|
});
|
|
50783
50901
|
|
|
50784
50902
|
// src/utils/detect.ts
|
|
50903
|
+
import { existsSync as existsSync2 } from "fs";
|
|
50785
50904
|
import { readFile as readFile4 } from "fs/promises";
|
|
50786
50905
|
import { join as join8 } from "path";
|
|
50906
|
+
var CONFIG_FILE_FRAMEWORKS = [
|
|
50907
|
+
{ files: ["astro.config.mjs", "astro.config.ts", "astro.config.js"], framework: "astro" },
|
|
50908
|
+
{ files: ["next.config.mjs", "next.config.ts", "next.config.js"], framework: "next" },
|
|
50909
|
+
{ files: ["remix.config.js", "remix.config.ts"], framework: "remix" },
|
|
50910
|
+
{ files: ["vite.config.ts", "vite.config.js", "vite.config.mjs"], framework: "vite" }
|
|
50911
|
+
];
|
|
50787
50912
|
async function detectFramework(cwd) {
|
|
50788
50913
|
try {
|
|
50789
50914
|
const content = await readFile4(join8(cwd, "package.json"), "utf-8");
|
|
@@ -50805,10 +50930,19 @@ async function detectFramework(cwd) {
|
|
|
50805
50930
|
if (deps.vite) {
|
|
50806
50931
|
return "vite";
|
|
50807
50932
|
}
|
|
50808
|
-
return "unknown";
|
|
50809
50933
|
} catch {
|
|
50810
|
-
return "unknown";
|
|
50811
50934
|
}
|
|
50935
|
+
return detectFrameworkFromConfigFiles(cwd);
|
|
50936
|
+
}
|
|
50937
|
+
function detectFrameworkFromConfigFiles(cwd) {
|
|
50938
|
+
for (const { files, framework } of CONFIG_FILE_FRAMEWORKS) {
|
|
50939
|
+
for (const file2 of files) {
|
|
50940
|
+
if (existsSync2(join8(cwd, file2))) {
|
|
50941
|
+
return framework;
|
|
50942
|
+
}
|
|
50943
|
+
}
|
|
50944
|
+
}
|
|
50945
|
+
return "unknown";
|
|
50812
50946
|
}
|
|
50813
50947
|
async function detectTailwindVersion(cwd) {
|
|
50814
50948
|
try {
|
|
@@ -50910,18 +51044,34 @@ var CSS_LOCATIONS = {
|
|
|
50910
51044
|
unknown: ["src/styles/global.css", "src/index.css", "styles/globals.css"]
|
|
50911
51045
|
};
|
|
50912
51046
|
var COMPONENT_PATHS = {
|
|
50913
|
-
astro: {
|
|
50914
|
-
|
|
50915
|
-
|
|
50916
|
-
|
|
50917
|
-
|
|
50918
|
-
|
|
51047
|
+
astro: {
|
|
51048
|
+
components: "src/components/ui",
|
|
51049
|
+
primitives: "src/lib/primitives",
|
|
51050
|
+
composites: "src/composites"
|
|
51051
|
+
},
|
|
51052
|
+
next: { components: "components/ui", primitives: "lib/primitives", composites: "composites" },
|
|
51053
|
+
vite: {
|
|
51054
|
+
components: "src/components/ui",
|
|
51055
|
+
primitives: "src/lib/primitives",
|
|
51056
|
+
composites: "src/composites"
|
|
51057
|
+
},
|
|
51058
|
+
remix: {
|
|
51059
|
+
components: "app/components/ui",
|
|
51060
|
+
primitives: "app/lib/primitives",
|
|
51061
|
+
composites: "app/composites"
|
|
51062
|
+
},
|
|
51063
|
+
"react-router": {
|
|
51064
|
+
components: "app/components/ui",
|
|
51065
|
+
primitives: "app/lib/primitives",
|
|
51066
|
+
composites: "app/composites"
|
|
51067
|
+
},
|
|
51068
|
+
unknown: { components: "components/ui", primitives: "lib/primitives", composites: "composites" }
|
|
50919
51069
|
};
|
|
50920
51070
|
async function findMainCssFile(cwd, framework) {
|
|
50921
51071
|
const locations = CSS_LOCATIONS[framework] || CSS_LOCATIONS.unknown;
|
|
50922
51072
|
for (const location of locations) {
|
|
50923
51073
|
const fullPath = join9(cwd, location);
|
|
50924
|
-
if (
|
|
51074
|
+
if (existsSync3(fullPath)) {
|
|
50925
51075
|
return location;
|
|
50926
51076
|
}
|
|
50927
51077
|
}
|
|
@@ -51043,7 +51193,7 @@ async function generateOutputs(cwd, paths, registry2, exports, shadcn) {
|
|
|
51043
51193
|
}
|
|
51044
51194
|
return outputs;
|
|
51045
51195
|
}
|
|
51046
|
-
async function regenerateFromExisting(cwd, paths, shadcn, isAgentMode2) {
|
|
51196
|
+
async function regenerateFromExisting(cwd, paths, shadcn, isAgentMode2, framework) {
|
|
51047
51197
|
log({ event: "init:regenerate", cwd });
|
|
51048
51198
|
let existingConfig = null;
|
|
51049
51199
|
try {
|
|
@@ -51051,6 +51201,13 @@ async function regenerateFromExisting(cwd, paths, shadcn, isAgentMode2) {
|
|
|
51051
51201
|
existingConfig = JSON.parse(configContent);
|
|
51052
51202
|
} catch {
|
|
51053
51203
|
}
|
|
51204
|
+
if (framework !== "unknown" && existingConfig) {
|
|
51205
|
+
const frameworkPaths = COMPONENT_PATHS[framework] || COMPONENT_PATHS.unknown;
|
|
51206
|
+
existingConfig.framework = framework;
|
|
51207
|
+
existingConfig.componentsPath = frameworkPaths.components;
|
|
51208
|
+
existingConfig.primitivesPath = frameworkPaths.primitives;
|
|
51209
|
+
existingConfig.compositesPath = frameworkPaths.composites;
|
|
51210
|
+
}
|
|
51054
51211
|
const adapter = new NodePersistenceAdapter(cwd);
|
|
51055
51212
|
const allTokens = await adapter.load();
|
|
51056
51213
|
if (allTokens.length === 0) {
|
|
@@ -51086,7 +51243,7 @@ async function regenerateFromExisting(cwd, paths, shadcn, isAgentMode2) {
|
|
|
51086
51243
|
path: paths.output
|
|
51087
51244
|
});
|
|
51088
51245
|
}
|
|
51089
|
-
async function resetToDefaults(cwd, paths, shadcn, isAgentMode2) {
|
|
51246
|
+
async function resetToDefaults(cwd, paths, shadcn, isAgentMode2, framework) {
|
|
51090
51247
|
log({ event: "init:reset", cwd });
|
|
51091
51248
|
let existingConfig = null;
|
|
51092
51249
|
try {
|
|
@@ -51094,6 +51251,13 @@ async function resetToDefaults(cwd, paths, shadcn, isAgentMode2) {
|
|
|
51094
51251
|
existingConfig = JSON.parse(configContent);
|
|
51095
51252
|
} catch {
|
|
51096
51253
|
}
|
|
51254
|
+
if (framework !== "unknown" && existingConfig) {
|
|
51255
|
+
const frameworkPaths = COMPONENT_PATHS[framework] || COMPONENT_PATHS.unknown;
|
|
51256
|
+
existingConfig.framework = framework;
|
|
51257
|
+
existingConfig.componentsPath = frameworkPaths.components;
|
|
51258
|
+
existingConfig.primitivesPath = frameworkPaths.primitives;
|
|
51259
|
+
existingConfig.compositesPath = frameworkPaths.composites;
|
|
51260
|
+
}
|
|
51097
51261
|
const adapter = new NodePersistenceAdapter(cwd);
|
|
51098
51262
|
const existingTokens = await adapter.load();
|
|
51099
51263
|
const overriddenTokens = existingTokens.filter((t2) => t2.userOverride);
|
|
@@ -51179,12 +51343,12 @@ async function init(options) {
|
|
|
51179
51343
|
if (isTailwindV3(tailwindVersion)) {
|
|
51180
51344
|
throw new Error("Tailwind v3 detected. Rafters requires Tailwind v4.");
|
|
51181
51345
|
}
|
|
51182
|
-
const raftersExists =
|
|
51346
|
+
const raftersExists = existsSync3(paths.root);
|
|
51183
51347
|
if (options.reset && !raftersExists) {
|
|
51184
51348
|
throw new Error("Nothing to reset. No .rafters/ directory found.");
|
|
51185
51349
|
}
|
|
51186
51350
|
if (raftersExists && options.reset) {
|
|
51187
|
-
await resetToDefaults(cwd, paths, shadcn, isAgentMode2);
|
|
51351
|
+
await resetToDefaults(cwd, paths, shadcn, isAgentMode2, framework);
|
|
51188
51352
|
return;
|
|
51189
51353
|
}
|
|
51190
51354
|
if (raftersExists && !options.rebuild) {
|
|
@@ -51193,7 +51357,7 @@ async function init(options) {
|
|
|
51193
51357
|
);
|
|
51194
51358
|
}
|
|
51195
51359
|
if (raftersExists && options.rebuild) {
|
|
51196
|
-
await regenerateFromExisting(cwd, paths, shadcn, isAgentMode2);
|
|
51360
|
+
await regenerateFromExisting(cwd, paths, shadcn, isAgentMode2, framework);
|
|
51197
51361
|
return;
|
|
51198
51362
|
}
|
|
51199
51363
|
let existingColors = null;
|
|
@@ -51304,12 +51468,14 @@ async function init(options) {
|
|
|
51304
51468
|
framework,
|
|
51305
51469
|
componentsPath: frameworkPaths.components,
|
|
51306
51470
|
primitivesPath: frameworkPaths.primitives,
|
|
51471
|
+
compositesPath: frameworkPaths.composites,
|
|
51307
51472
|
cssPath: detectedCssPath,
|
|
51308
51473
|
shadcn: !!shadcn,
|
|
51309
51474
|
exports,
|
|
51310
51475
|
installed: {
|
|
51311
51476
|
components: [],
|
|
51312
|
-
primitives: []
|
|
51477
|
+
primitives: [],
|
|
51478
|
+
composites: []
|
|
51313
51479
|
}
|
|
51314
51480
|
};
|
|
51315
51481
|
await writeFile3(paths.config, JSON.stringify(config3, null, 2));
|
|
@@ -51326,7 +51492,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
51326
51492
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
51327
51493
|
|
|
51328
51494
|
// src/mcp/tools.ts
|
|
51329
|
-
import { existsSync as
|
|
51495
|
+
import { existsSync as existsSync4 } from "fs";
|
|
51330
51496
|
import { readdir as readdir3, readFile as readFile6 } from "fs/promises";
|
|
51331
51497
|
import { basename, join as join10 } from "path";
|
|
51332
51498
|
|
|
@@ -52753,7 +52919,7 @@ var RaftersToolHandler = class {
|
|
|
52753
52919
|
let installed = [];
|
|
52754
52920
|
try {
|
|
52755
52921
|
const paths = getRaftersPaths(this.projectRoot);
|
|
52756
|
-
if (
|
|
52922
|
+
if (existsSync4(paths.config)) {
|
|
52757
52923
|
const content = await readFile6(paths.config, "utf-8");
|
|
52758
52924
|
const config3 = JSON.parse(content);
|
|
52759
52925
|
installed = config3.installed?.components ?? [];
|
|
@@ -53291,7 +53457,7 @@ async function mcp() {
|
|
|
53291
53457
|
}
|
|
53292
53458
|
|
|
53293
53459
|
// src/commands/studio.ts
|
|
53294
|
-
import { existsSync as
|
|
53460
|
+
import { existsSync as existsSync5 } from "fs";
|
|
53295
53461
|
import { dirname as dirname3, join as join11 } from "path";
|
|
53296
53462
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
53297
53463
|
import { execa as execa2 } from "execa";
|
|
@@ -53299,14 +53465,14 @@ var __dirname2 = dirname3(fileURLToPath3(import.meta.url));
|
|
|
53299
53465
|
async function studio() {
|
|
53300
53466
|
const cwd = process.cwd();
|
|
53301
53467
|
const paths = getRaftersPaths(cwd);
|
|
53302
|
-
if (!
|
|
53468
|
+
if (!existsSync5(paths.root)) {
|
|
53303
53469
|
console.error('No .rafters/ directory found. Run "rafters init" first.');
|
|
53304
53470
|
process.exit(1);
|
|
53305
53471
|
}
|
|
53306
53472
|
const devStudioPath = join11(__dirname2, "..", "..", "..", "studio");
|
|
53307
53473
|
const prodStudioPath = join11(__dirname2, "..", "node_modules", "@rafters", "studio");
|
|
53308
|
-
const studioPath =
|
|
53309
|
-
if (!
|
|
53474
|
+
const studioPath = existsSync5(devStudioPath) ? devStudioPath : prodStudioPath;
|
|
53475
|
+
if (!existsSync5(studioPath)) {
|
|
53310
53476
|
console.error("Studio package not found. Please reinstall @rafters/cli.");
|
|
53311
53477
|
process.exit(1);
|
|
53312
53478
|
}
|
package/dist/registry/types.d.ts
CHANGED
|
@@ -22,9 +22,9 @@ type RegistryFile = z.infer<typeof RegistryFileSchema>;
|
|
|
22
22
|
* Item type in registry
|
|
23
23
|
*/
|
|
24
24
|
declare const RegistryItemTypeSchema: z.ZodEnum<{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
ui: "ui";
|
|
26
|
+
primitive: "primitive";
|
|
27
|
+
composite: "composite";
|
|
28
28
|
}>;
|
|
29
29
|
type RegistryItemType = z.infer<typeof RegistryItemTypeSchema>;
|
|
30
30
|
/**
|
|
@@ -33,9 +33,9 @@ type RegistryItemType = z.infer<typeof RegistryItemTypeSchema>;
|
|
|
33
33
|
declare const RegistryItemSchema: z.ZodObject<{
|
|
34
34
|
name: z.ZodString;
|
|
35
35
|
type: z.ZodEnum<{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
ui: "ui";
|
|
37
|
+
primitive: "primitive";
|
|
38
|
+
composite: "composite";
|
|
39
39
|
}>;
|
|
40
40
|
description: z.ZodOptional<z.ZodString>;
|
|
41
41
|
primitives: z.ZodArray<z.ZodString>;
|
|
@@ -45,6 +45,8 @@ declare const RegistryItemSchema: z.ZodObject<{
|
|
|
45
45
|
dependencies: z.ZodArray<z.ZodString>;
|
|
46
46
|
devDependencies: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
47
47
|
}, z.core.$strip>>;
|
|
48
|
+
rules: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
49
|
+
composites: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
48
50
|
}, z.core.$strip>;
|
|
49
51
|
type RegistryItem = z.infer<typeof RegistryItemSchema>;
|
|
50
52
|
/**
|
|
@@ -55,6 +57,8 @@ declare const RegistryIndexSchema: z.ZodObject<{
|
|
|
55
57
|
homepage: z.ZodString;
|
|
56
58
|
components: z.ZodArray<z.ZodString>;
|
|
57
59
|
primitives: z.ZodArray<z.ZodString>;
|
|
60
|
+
composites: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
61
|
+
rules: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
58
62
|
}, z.core.$strip>;
|
|
59
63
|
type RegistryIndex = z.infer<typeof RegistryIndexSchema>;
|
|
60
64
|
|
package/dist/registry/types.js
CHANGED
|
@@ -8,23 +8,23 @@ var RegistryFileSchema = z.object({
|
|
|
8
8
|
devDependencies: z.array(z.string()).default([])
|
|
9
9
|
// e.g., ["vitest"] - from @devDependencies JSDoc
|
|
10
10
|
});
|
|
11
|
-
var RegistryItemTypeSchema = z.enum([
|
|
12
|
-
"registry:ui",
|
|
13
|
-
"registry:primitive",
|
|
14
|
-
"registry:composite"
|
|
15
|
-
]);
|
|
11
|
+
var RegistryItemTypeSchema = z.enum(["ui", "primitive", "composite"]);
|
|
16
12
|
var RegistryItemSchema = z.object({
|
|
17
13
|
name: z.string(),
|
|
18
14
|
type: RegistryItemTypeSchema,
|
|
19
15
|
description: z.string().optional(),
|
|
20
16
|
primitives: z.array(z.string()),
|
|
21
|
-
files: z.array(RegistryFileSchema)
|
|
17
|
+
files: z.array(RegistryFileSchema),
|
|
18
|
+
rules: z.array(z.string()).default([]),
|
|
19
|
+
composites: z.array(z.string()).default([])
|
|
22
20
|
});
|
|
23
21
|
var RegistryIndexSchema = z.object({
|
|
24
22
|
name: z.string(),
|
|
25
23
|
homepage: z.string(),
|
|
26
24
|
components: z.array(z.string()),
|
|
27
|
-
primitives: z.array(z.string())
|
|
25
|
+
primitives: z.array(z.string()),
|
|
26
|
+
composites: z.array(z.string()).default([]),
|
|
27
|
+
rules: z.array(z.string()).default([])
|
|
28
28
|
});
|
|
29
29
|
export {
|
|
30
30
|
RegistryFileSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rafters",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "CLI for Rafters design system - scaffold tokens and add components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -48,6 +48,11 @@
|
|
|
48
48
|
"vitest": "catalog:",
|
|
49
49
|
"zocker": "catalog:"
|
|
50
50
|
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/ezmode-games/rafters.git",
|
|
54
|
+
"directory": "packages/cli"
|
|
55
|
+
},
|
|
51
56
|
"publishConfig": {
|
|
52
57
|
"access": "public"
|
|
53
58
|
}
|