@figtools/cli 0.2.0 → 0.2.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.
package/dist/cli.js CHANGED
@@ -55,8 +55,28 @@ function slugifyWithCollisions(names) {
55
55
  function isFigmaPage(result) {
56
56
  return "nodes" in result;
57
57
  }
58
+ function formatPaint(paint) {
59
+ const { r, g, b, a } = paint.color;
60
+ const color = `rgba(${r}, ${g}, ${b}, ${a})`;
61
+ return paint.styleName ? `${paint.styleName} (${color})` : color;
62
+ }
63
+ function metadataLines(node) {
64
+ const lines = [
65
+ `type: ${node.type}`
66
+ ];
67
+ if (null !== node.position.x && null !== node.position.y) lines.push(`position: x=${node.position.x}, y=${node.position.y}`);
68
+ if (null !== node.size.width && null !== node.size.height) lines.push(`size: width=${node.size.width}, height=${node.size.height}`);
69
+ const { typography, fills, strokes, ...rest } = node.styles;
70
+ for (const [key, value] of Object.entries(rest))if (void 0 !== value) lines.push(`${key}: ${value}`);
71
+ if (fills && fills.length > 0) lines.push(`fills: ${fills.map(formatPaint).join(", ")}`);
72
+ if (strokes && strokes.length > 0) lines.push(`strokes: ${strokes.map(formatPaint).join(", ")}`);
73
+ if (typography) {
74
+ for (const [key, value] of Object.entries(typography))if (null != value) lines.push(`typography.${key}: ${value}`);
75
+ }
76
+ return lines;
77
+ }
58
78
  function leafContent(node) {
59
- return `# ${node.name}\n\ntype: ${node.type}\n`;
79
+ return `# ${node.name}\n\n${metadataLines(node).join("\n")}\n`;
60
80
  }
61
81
  function containerContent(name, children, childSlugs) {
62
82
  const links = children.map((child, i)=>{
@@ -98,7 +118,7 @@ async function writeAsMarkdownTree(fileKey, result, options) {
98
118
  await writeFile(join(fileKeyDir, "index.md"), containerContent(result.name, result.children, childSlugs), "utf8");
99
119
  for(let i = 0; i < result.children.length; i++)await writeChildNode(result.children[i], fileKeyDir, childSlugs[i]);
100
120
  }
101
- var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"0.2.0","h_":"Resolves one or more Figma URLs from the command line and writes the result as JSON or as a navigable markdown tree meant to be used as a data source by an LLM."}');
121
+ var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"0.2.1","h_":"Resolves one or more Figma URLs from the command line and writes the result as JSON or as a navigable markdown tree meant to be used as a data source by an LLM."}');
102
122
  function createProgram() {
103
123
  let output = "";
104
124
  let parsed;
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-writer.d.ts","sourceRoot":"","sources":["../../src/output/markdown-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAwB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAG9E,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;CACnB;AAoCD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAgCf"}
1
+ {"version":3,"file":"markdown-writer.d.ts","sourceRoot":"","sources":["../../src/output/markdown-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAG1F,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;CACnB;AAyED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAgCf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@figtools/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Resolves one or more Figma URLs from the command line and writes the result as JSON or as a navigable markdown tree meant to be used as a data source by an LLM.",
5
5
  "keywords": [
6
6
  "figma",