@fragments-sdk/cli 0.4.0 → 0.4.1

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 (55) hide show
  1. package/dist/bin.js +11 -11
  2. package/dist/{chunk-OZQ7Z6C3.js → chunk-5CKYLCJH.js} +28 -1
  3. package/dist/{chunk-OZQ7Z6C3.js.map → chunk-5CKYLCJH.js.map} +1 -1
  4. package/dist/{chunk-5JNME72P.js → chunk-5ZYEOHYK.js} +11 -9
  5. package/dist/chunk-5ZYEOHYK.js.map +1 -0
  6. package/dist/{chunk-FYIYMXGA.js → chunk-G3M3MPQ6.js} +13 -2
  7. package/dist/chunk-G3M3MPQ6.js.map +1 -0
  8. package/dist/{chunk-LDKNZ55O.js → chunk-J4SI5RIH.js} +3 -3
  9. package/dist/{chunk-ODXQAQQX.js → chunk-ZFKGX3QK.js} +4 -4
  10. package/dist/{core-F3VT277E.js → core-LNXDLXDP.js} +2 -2
  11. package/dist/{generate-PNIUR75D.js → generate-OIXXHOWR.js} +3 -3
  12. package/dist/index.js +4 -4
  13. package/dist/{init-ON6WYG66.js → init-EVPXIDW4.js} +3 -3
  14. package/dist/mcp-bin.js +2 -2
  15. package/dist/mcp-bin.js.map +1 -1
  16. package/dist/scan-YVYD64GD.js +12 -0
  17. package/dist/{service-U7AR2PC2.js → service-K52ORLCJ.js} +3 -3
  18. package/dist/{static-viewer-QL2SCWYB.js → static-viewer-JNQIHA4B.js} +2 -2
  19. package/dist/{test-PBPKJ4WJ.js → test-USARUEFW.js} +8 -4
  20. package/dist/test-USARUEFW.js.map +1 -0
  21. package/dist/{tokens-4J4PRIGT.js → tokens-C6YHBOQE.js} +4 -4
  22. package/dist/{viewer-6VCZMA3T.js → viewer-H7TVFT4E.js} +14 -14
  23. package/dist/{viewer-6VCZMA3T.js.map → viewer-H7TVFT4E.js.map} +1 -1
  24. package/package.json +2 -1
  25. package/src/core/parser.ts +48 -0
  26. package/src/core/storyAdapter.ts +1 -1
  27. package/src/core/storybook-csf.ts +11 -0
  28. package/src/core/types.ts +1 -1
  29. package/src/mcp/server.ts +1 -1
  30. package/src/service/enhance/doc-extractor.ts +2 -2
  31. package/src/service/enhance/props-extractor.ts +1 -1
  32. package/src/service/enhance/storybook-parser.ts +1 -1
  33. package/src/service/figma.ts +2 -2
  34. package/src/service/metrics-store.ts +2 -1
  35. package/src/service/patch-generator.ts +2 -1
  36. package/src/test/reporters/junit.ts +7 -3
  37. package/src/test/runner.ts +4 -4
  38. package/src/test/watch.ts +2 -2
  39. package/src/viewer/components/CodePanel.tsx +1 -1
  40. package/src/viewer/components/FigmaEmbed.tsx +1 -1
  41. package/src/viewer/jsx-parser.ts +2 -1
  42. package/src/viewer/utils/colorSchemes.ts +3 -3
  43. package/dist/chunk-5JNME72P.js.map +0 -1
  44. package/dist/chunk-FYIYMXGA.js.map +0 -1
  45. package/dist/scan-E6U644RS.js +0 -12
  46. package/dist/test-PBPKJ4WJ.js.map +0 -1
  47. /package/dist/{chunk-LDKNZ55O.js.map → chunk-J4SI5RIH.js.map} +0 -0
  48. /package/dist/{chunk-ODXQAQQX.js.map → chunk-ZFKGX3QK.js.map} +0 -0
  49. /package/dist/{core-F3VT277E.js.map → core-LNXDLXDP.js.map} +0 -0
  50. /package/dist/{generate-PNIUR75D.js.map → generate-OIXXHOWR.js.map} +0 -0
  51. /package/dist/{init-ON6WYG66.js.map → init-EVPXIDW4.js.map} +0 -0
  52. /package/dist/{scan-E6U644RS.js.map → scan-YVYD64GD.js.map} +0 -0
  53. /package/dist/{service-U7AR2PC2.js.map → service-K52ORLCJ.js.map} +0 -0
  54. /package/dist/{static-viewer-QL2SCWYB.js.map → static-viewer-JNQIHA4B.js.map} +0 -0
  55. /package/dist/{tokens-4J4PRIGT.js.map → tokens-C6YHBOQE.js.map} +0 -0
package/dist/bin.js CHANGED
@@ -9,10 +9,10 @@ import {
9
9
  validateAll,
10
10
  validateCoverage,
11
11
  validateSchema
12
- } from "./chunk-ODXQAQQX.js";
12
+ } from "./chunk-ZFKGX3QK.js";
13
13
  import {
14
14
  scan
15
- } from "./chunk-LDKNZ55O.js";
15
+ } from "./chunk-J4SI5RIH.js";
16
16
  import {
17
17
  FigmaClient,
18
18
  StorageManager,
@@ -28,15 +28,15 @@ import {
28
28
  renderAllComponentVariants,
29
29
  scanCodebase,
30
30
  shutdownSharedPool
31
- } from "./chunk-5JNME72P.js";
31
+ } from "./chunk-5ZYEOHYK.js";
32
32
  import {
33
33
  discoverSegmentFiles,
34
34
  loadConfig,
35
35
  loadSegmentFile
36
- } from "./chunk-OZQ7Z6C3.js";
36
+ } from "./chunk-5CKYLCJH.js";
37
37
  import {
38
38
  generateContext
39
- } from "./chunk-FYIYMXGA.js";
39
+ } from "./chunk-G3M3MPQ6.js";
40
40
  import {
41
41
  BRAND
42
42
  } from "./chunk-AW7MWOUH.js";
@@ -1771,7 +1771,7 @@ ${BRAND.name} Dev Server
1771
1771
  }
1772
1772
  }
1773
1773
  }
1774
- const { createDevServer } = await import("./viewer-6VCZMA3T.js");
1774
+ const { createDevServer } = await import("./viewer-H7TVFT4E.js");
1775
1775
  console.log(pc7.dim("\nStarting dev server..."));
1776
1776
  const parsedPort = typeof port === "string" ? parseInt(port, 10) : port;
1777
1777
  try {
@@ -4641,7 +4641,7 @@ Make sure the dev server is running: ${BRAND.cliCommand} dev`));
4641
4641
  });
4642
4642
  program.command("view").description(`Generate a static HTML viewer for ${BRAND.outFile}`).option("-i, --input <path>", `Path to ${BRAND.outFile}`, BRAND.outFile).option("-o, --output <path>", "Output HTML file path", BRAND.viewerHtmlFile).option("--open", "Open in browser after generation").action(async (options) => {
4643
4643
  try {
4644
- const { generateViewerFromJson } = await import("./static-viewer-QL2SCWYB.js");
4644
+ const { generateViewerFromJson } = await import("./static-viewer-JNQIHA4B.js");
4645
4645
  const fs = await import("fs/promises");
4646
4646
  const path = await import("path");
4647
4647
  const inputPath = path.resolve(process.cwd(), options.input);
@@ -4689,7 +4689,7 @@ program.command("add").argument("[name]", 'Component name (e.g., "Button", "Text
4689
4689
  });
4690
4690
  program.command("init").description("Initialize fragments in a project (interactive by default)").option("--force", "Overwrite existing config").option("-y, --yes", "Non-interactive mode - auto-detect and use defaults").action(async (options) => {
4691
4691
  try {
4692
- const { init } = await import("./init-ON6WYG66.js");
4692
+ const { init } = await import("./init-EVPXIDW4.js");
4693
4693
  const result = await init({
4694
4694
  projectRoot: process.cwd(),
4695
4695
  force: options.force,
@@ -4709,7 +4709,7 @@ program.command("init").description("Initialize fragments in a project (interact
4709
4709
  });
4710
4710
  program.command("tokens").description("Discover and list design tokens from CSS/SCSS files").option("-c, --config <path>", "Path to config file").option("--json", "Output as JSON").option("--categories", "Group tokens by category").option("--theme <theme>", "Filter by theme name").option("--category <category>", "Filter by category (color, spacing, typography, etc.)").option("--verbose", "Show all tokens (no truncation)").action(async (options) => {
4711
4711
  try {
4712
- const { tokens } = await import("./tokens-4J4PRIGT.js");
4712
+ const { tokens } = await import("./tokens-C6YHBOQE.js");
4713
4713
  const result = await tokens({
4714
4714
  config: options.config,
4715
4715
  json: options.json,
@@ -4728,7 +4728,7 @@ program.command("tokens").description("Discover and list design tokens from CSS/
4728
4728
  });
4729
4729
  program.command("generate").description("Generate fragment files from component source code").argument("[component]", "Specific component name to generate (optional)").option("--force", "Overwrite existing fragment files").option("--pattern <glob>", "Pattern for component files", "src/components/**/*.tsx").action(async (component, options) => {
4730
4730
  try {
4731
- const { generate } = await import("./generate-PNIUR75D.js");
4731
+ const { generate } = await import("./generate-OIXXHOWR.js");
4732
4732
  const result = await generate({
4733
4733
  projectRoot: process.cwd(),
4734
4734
  component,
@@ -4747,7 +4747,7 @@ program.command("generate").description("Generate fragment files from component
4747
4747
  program.command("test").description("Run interaction tests for fragments with play functions").option("-c, --config <path>", "Path to config file").option("--component <name>", "Filter by component name").option("--tags <tags>", "Filter by tags (comma-separated)").option("--grep <pattern>", "Filter by variant name pattern").option("--exclude <pattern>", "Exclude tests matching pattern").option("--parallel <count>", "Number of parallel browser contexts", parseInt, 4).option("--timeout <ms>", "Timeout per test in milliseconds", parseInt, 3e4).option("--retries <count>", "Number of retries for failed tests", parseInt, 0).option("--bail", "Stop on first failure").option("--browser <name>", "Browser to use (chromium, firefox, webkit)", "chromium").option("--headed", "Run in headed mode (show browser)").option("--a11y", "Run accessibility checks with axe-core").option("--visual", "Capture screenshots for visual regression").option("--update-snapshots", "Update visual snapshots").option("--watch", "Watch mode - re-run on file changes").option("--reporters <names>", "Reporters to use (console, junit, json)", "console").option("-o, --output <dir>", "Output directory for results", "./test-results").option("--server-url <url>", "URL of running dev server (skips starting server)").option("-p, --port <port>", "Port for dev server", parseInt, 6006).option("--ci", "CI mode - non-interactive, exit with code 1 on failure").option("--list", "List available tests without running them").action(async (options) => {
4748
4748
  try {
4749
4749
  const { config, configDir } = await loadConfig(options.config);
4750
- const { runTestCommand, listTests } = await import("./test-PBPKJ4WJ.js");
4750
+ const { runTestCommand, listTests } = await import("./test-USARUEFW.js");
4751
4751
  if (options.list) {
4752
4752
  await listTests(config, configDir, {
4753
4753
  component: options.component,
@@ -1321,6 +1321,32 @@ function extractVariants(arg, sourceFile, warnings) {
1321
1321
  }
1322
1322
  return variants;
1323
1323
  }
1324
+ function dedent(str) {
1325
+ const lines = str.split("\n");
1326
+ if (lines.length <= 1) {
1327
+ return str;
1328
+ }
1329
+ const firstLineIndent = lines[0].match(/^(\s*)/)?.[1].length ?? 0;
1330
+ const startIndex = firstLineIndent === 0 ? 1 : 0;
1331
+ let minIndent = Infinity;
1332
+ for (let i = startIndex; i < lines.length; i++) {
1333
+ const line = lines[i];
1334
+ if (line.trim() === "") continue;
1335
+ const match = line.match(/^(\s*)/);
1336
+ if (match) {
1337
+ minIndent = Math.min(minIndent, match[1].length);
1338
+ }
1339
+ }
1340
+ if (minIndent === Infinity || minIndent === 0) {
1341
+ return str;
1342
+ }
1343
+ return lines.map((line, index) => {
1344
+ if (index === 0 && firstLineIndent === 0) {
1345
+ return line;
1346
+ }
1347
+ return line.slice(minIndent);
1348
+ }).join("\n");
1349
+ }
1324
1350
  function extractRenderCode(renderProp, sourceFile) {
1325
1351
  if (ts2.isArrowFunction(renderProp)) {
1326
1352
  const body = renderProp.body;
@@ -1330,6 +1356,7 @@ function extractRenderCode(renderProp, sourceFile) {
1330
1356
  if (code.startsWith("(") && code.endsWith(")")) {
1331
1357
  code = code.slice(1, -1).trim();
1332
1358
  }
1359
+ code = dedent(code);
1333
1360
  return code;
1334
1361
  }
1335
1362
  return void 0;
@@ -1541,4 +1568,4 @@ export {
1541
1568
  generateRegistry,
1542
1569
  generateContextMd
1543
1570
  };
1544
- //# sourceMappingURL=chunk-OZQ7Z6C3.js.map
1571
+ //# sourceMappingURL=chunk-5CKYLCJH.js.map