rafters 0.0.52 → 0.0.53

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 +75 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -241,6 +241,18 @@ var registryClient = new RegistryClient();
241
241
  import { existsSync } from "fs";
242
242
  import { readFile } from "fs/promises";
243
243
  import { join } from "path";
244
+ var SELECTABLE_FRAMEWORKS = [
245
+ "next",
246
+ "vite",
247
+ "remix",
248
+ "react-router",
249
+ "astro",
250
+ "wc",
251
+ "vanilla"
252
+ ];
253
+ function isSelectableFramework(value2) {
254
+ return SELECTABLE_FRAMEWORKS.includes(value2);
255
+ }
244
256
  var CONFIG_FILE_FRAMEWORKS = [
245
257
  { files: ["astro.config.mjs", "astro.config.ts", "astro.config.js"], framework: "astro" },
246
258
  { files: ["next.config.mjs", "next.config.ts", "next.config.js"], framework: "next" },
@@ -313,6 +325,7 @@ async function detectShadcn(cwd) {
313
325
  }
314
326
  function frameworkToTarget(framework) {
315
327
  if (framework === "astro") return "astro";
328
+ if (framework === "wc") return "wc";
316
329
  return "react";
317
330
  }
318
331
  function targetToExtension(target) {
@@ -320,7 +333,8 @@ function targetToExtension(target) {
320
333
  react: ".tsx",
321
334
  astro: ".astro",
322
335
  vue: ".vue",
323
- svelte: ".svelte"
336
+ svelte: ".svelte",
337
+ wc: ".element.ts"
324
338
  };
325
339
  return map[target];
326
340
  }
@@ -46273,6 +46287,8 @@ var CSS_LOCATIONS = {
46273
46287
  vite: ["src/index.css", "src/main.css", "src/styles.css", "src/app.css"],
46274
46288
  remix: ["app/styles/global.css", "app/globals.css", "app/root.css"],
46275
46289
  "react-router": ["app/app.css", "app/root.css", "app/styles.css", "app/globals.css"],
46290
+ wc: ["src/index.css", "src/main.css", "src/styles.css", "styles/global.css"],
46291
+ vanilla: ["src/index.css", "src/main.css", "src/styles.css", "styles/global.css"],
46276
46292
  unknown: ["src/styles/global.css", "src/index.css", "styles/globals.css"]
46277
46293
  };
46278
46294
  var COMPONENT_PATHS = {
@@ -46297,8 +46313,27 @@ var COMPONENT_PATHS = {
46297
46313
  primitives: "app/lib/primitives",
46298
46314
  composites: "app/composites"
46299
46315
  },
46316
+ wc: {
46317
+ components: "src/components/ui",
46318
+ primitives: "src/lib/primitives",
46319
+ composites: "src/composites"
46320
+ },
46321
+ vanilla: {
46322
+ components: "src/components/ui",
46323
+ primitives: "src/lib/primitives",
46324
+ composites: "src/composites"
46325
+ },
46300
46326
  unknown: { components: "components/ui", primitives: "lib/primitives", composites: "composites" }
46301
46327
  };
46328
+ var FRAMEWORK_PROMPT_LABELS = {
46329
+ next: "Next.js",
46330
+ vite: "Vite",
46331
+ remix: "Remix",
46332
+ "react-router": "React Router v7",
46333
+ astro: "Astro",
46334
+ wc: "Web Components (custom elements, shadow DOM)",
46335
+ vanilla: "Vanilla (plain HTML/TS, no framework)"
46336
+ };
46302
46337
  async function findMainCssFile(cwd, framework) {
46303
46338
  const locations = CSS_LOCATIONS[framework] || CSS_LOCATIONS.unknown;
46304
46339
  for (const location of locations) {
@@ -46340,6 +46375,26 @@ ${cssContent}`;
46340
46375
  function isInteractive() {
46341
46376
  return Boolean(process.stdin.isTTY && process.stdout.isTTY);
46342
46377
  }
46378
+ async function resolveFramework(detected, flag, agentMode) {
46379
+ if (flag) {
46380
+ if (!isSelectableFramework(flag)) {
46381
+ throw new Error(
46382
+ `Unknown --framework "${flag}". Valid values: ${SELECTABLE_FRAMEWORKS.join(", ")}.`
46383
+ );
46384
+ }
46385
+ return flag;
46386
+ }
46387
+ if (detected !== "unknown") return detected;
46388
+ if (agentMode || !isInteractive()) return "unknown";
46389
+ const picked = await select({
46390
+ message: "Couldn't auto-detect your framework. Which one is this?",
46391
+ choices: SELECTABLE_FRAMEWORKS.map((value2) => ({
46392
+ name: FRAMEWORK_PROMPT_LABELS[value2],
46393
+ value: value2
46394
+ }))
46395
+ });
46396
+ return picked;
46397
+ }
46343
46398
  async function promptExportFormats(existingConfig) {
46344
46399
  if (!isInteractive()) {
46345
46400
  return existingConfig ?? DEFAULT_EXPORTS;
@@ -46677,13 +46732,26 @@ async function init(options) {
46677
46732
  const cwd = process.cwd();
46678
46733
  const paths = getRaftersPaths(cwd);
46679
46734
  log({ event: "init:start", cwd });
46680
- const { framework, shadcn, tailwindVersion } = await detectProject(cwd);
46735
+ const { framework: detectedFramework, shadcn, tailwindVersion } = await detectProject(cwd);
46681
46736
  log({
46682
46737
  event: "init:detected",
46683
- framework,
46738
+ framework: detectedFramework,
46684
46739
  tailwindVersion,
46685
46740
  hasShadcn: !!shadcn
46686
46741
  });
46742
+ const framework = await resolveFramework(
46743
+ detectedFramework,
46744
+ options.framework,
46745
+ isAgentMode2
46746
+ );
46747
+ if (framework !== detectedFramework) {
46748
+ log({
46749
+ event: "init:framework_resolved",
46750
+ detected: detectedFramework,
46751
+ resolved: framework,
46752
+ source: options.framework ? "flag" : "prompt"
46753
+ });
46754
+ }
46687
46755
  if (isTailwindV3(tailwindVersion)) {
46688
46756
  throw new Error("Tailwind v3 detected. Rafters requires Tailwind v4.");
46689
46757
  }
@@ -48213,7 +48281,10 @@ async function studio() {
48213
48281
  // src/index.ts
48214
48282
  var program = new Command();
48215
48283
  program.name("rafters").description("Design system CLI - scaffold tokens and serve MCP").version("0.0.1");
48216
- program.command("init").description("Initialize .rafters/ with default tokens and config").option("-r, --rebuild", "Regenerate output files from existing tokens").option("--reset", "Re-run generators fresh, replacing persisted tokens").option("--agent", "Output JSON for machine consumption").action(withErrorHandler(init));
48284
+ program.command("init").description("Initialize .rafters/ with default tokens and config").option("-r, --rebuild", "Regenerate output files from existing tokens").option("--reset", "Re-run generators fresh, replacing persisted tokens").option(
48285
+ "--framework <name>",
48286
+ "Override framework detection (next|vite|remix|react-router|astro|wc|vanilla)"
48287
+ ).option("--agent", "Output JSON for machine consumption").action(withErrorHandler(init));
48217
48288
  program.command("import").description("Import existing design tokens (Tailwind v4, shadcn, generic CSS)").option("--force", "Overwrite existing .rafters/import-pending.json").option("--importer <id>", "Force a specific importer (tailwind-v4, shadcn, generic-css)").option("--agent", "Output JSON for machine consumption").action(withErrorHandler(importCommand));
48218
48289
  program.command("add").description("Add rafters components to the project").argument("[components...]", "Component names to add").option("--list", "List available components").option("--overwrite", "Overwrite existing component files").option("--update", "Re-fetch named components from registry").option("--update-all", "Re-fetch all installed components from registry").option("--registry-url <url>", "Custom registry URL").option("--agent", "Output JSON for machine consumption").action(withErrorHandler(add));
48219
48290
  program.command("mcp").description("Start MCP server for AI agent access (stdio)").option("--project-root <path>", "Explicit project root (skips .rafters/ discovery)").action(mcp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafters",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "description": "CLI for Rafters design system - scaffold tokens and add components",
5
5
  "license": "MIT",
6
6
  "type": "module",