figma-mcp-cli 1.0.6 → 1.0.7

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 (43) hide show
  1. package/askCopilot.js +51 -0
  2. package/index.js +10 -3
  3. package/my-new-project/.env +1 -1
  4. package/my-new-project/.vscode/settings.json +1 -1
  5. package/my-new-project/my-app/.env +1 -0
  6. package/my-new-project/my-app/README.md +73 -0
  7. package/my-new-project/my-app/eslint.config.js +23 -0
  8. package/my-new-project/my-app/index.html +13 -0
  9. package/my-new-project/my-app/package-lock.json +3212 -0
  10. package/my-new-project/my-app/package.json +30 -0
  11. package/my-new-project/my-app/public/vite.svg +1 -0
  12. package/my-new-project/my-app/src/App.css +42 -0
  13. package/my-new-project/my-app/src/App.tsx +28 -0
  14. package/my-new-project/my-app/src/FigmaSidebarComponent.css +99 -0
  15. package/my-new-project/my-app/src/FigmaSidebarComponent.tsx +111 -0
  16. package/my-new-project/my-app/src/React19AllFeaturesDemo.jsx +111 -0
  17. package/my-new-project/my-app/src/RenderRightSidebar.css +32 -0
  18. package/my-new-project/my-app/src/RenderRightSidebar.tsx +73 -0
  19. package/my-new-project/my-app/src/assets/react.svg +1 -0
  20. package/my-new-project/my-app/src/components/AccordionSection.tsx +33 -0
  21. package/my-new-project/my-app/src/components/ChevronIcon.tsx +24 -0
  22. package/my-new-project/my-app/src/components/EnvironmentScenePanel.tsx +57 -0
  23. package/my-new-project/my-app/src/components/LightingPanel.tsx +57 -0
  24. package/my-new-project/my-app/src/components/RenderScalePanel.tsx +34 -0
  25. package/my-new-project/my-app/src/components/ResolutionPanel.tsx +27 -0
  26. package/my-new-project/my-app/src/components/SaturationPanel.tsx +27 -0
  27. package/my-new-project/my-app/src/components/SidebarButton.tsx +27 -0
  28. package/my-new-project/my-app/src/components/SidebarPreview.tsx +77 -0
  29. package/my-new-project/my-app/src/index.css +68 -0
  30. package/my-new-project/my-app/src/main.tsx +10 -0
  31. package/my-new-project/my-app/src/styles/AccordionSection.css +70 -0
  32. package/my-new-project/my-app/src/styles/EnvironmentScenePanel.css +104 -0
  33. package/my-new-project/my-app/src/styles/LightingPanel.css +111 -0
  34. package/my-new-project/my-app/src/styles/RenderScalePanel.css +67 -0
  35. package/my-new-project/my-app/src/styles/ResolutionPanel.css +60 -0
  36. package/my-new-project/my-app/src/styles/SaturationPanel.css +56 -0
  37. package/my-new-project/my-app/src/styles/SidebarButton.css +81 -0
  38. package/my-new-project/my-app/src/styles/SidebarPreview.css +92 -0
  39. package/my-new-project/my-app/tsconfig.app.json +28 -0
  40. package/my-new-project/my-app/tsconfig.json +7 -0
  41. package/my-new-project/my-app/tsconfig.node.json +26 -0
  42. package/my-new-project/my-app/vite.config.ts +7 -0
  43. package/package.json +2 -1
package/askCopilot.js ADDED
@@ -0,0 +1,51 @@
1
+ // 注意:这段代码需要在VS Code扩展环境中运行
2
+ // const vscode = require("vscode");
3
+ import vscode from "vscode";
4
+
5
+ async function askCopilot(prompt) {
6
+ // 获取可用的语言模型(通常是Copilot)
7
+ const lm = await vscode.lm.selectChatModels({
8
+ vendor: "github",
9
+ family: "copilot",
10
+ });
11
+ if (lm.length === 0) {
12
+ vscode.window.showErrorMessage("未找到可用的Copilot模型。");
13
+ return;
14
+ }
15
+ const chatModel = lm[0];
16
+
17
+ // 创建对话消息
18
+ const messages = [vscode.LanguageModelChatMessage.User(prompt)];
19
+
20
+ try {
21
+ // 发起请求并获取响应流
22
+ const response = await chatModel.sendRequest(messages, {});
23
+ let fullResponse = "";
24
+ for await (const fragment of response.text) {
25
+ fullResponse += fragment;
26
+ }
27
+ return fullResponse;
28
+ } catch (error) {
29
+ vscode.window.showErrorMessage(`Copilot请求失败: ${error.message}`);
30
+ return null;
31
+ }
32
+ }
33
+
34
+ // 使用示例:将Figma文本发送给Copilot并请求生成代码
35
+ (async () => {
36
+ const figmaText = await getFigmaTextContent(
37
+ "YOUR_FILE_KEY",
38
+ "0:1,0:2",
39
+ "YOUR_ACCESS_TOKEN"
40
+ );
41
+ if (figmaText) {
42
+ const prompt = `请根据以下Figma设计稿中的文本信息,生成一个React组件的JSX代码,使用Tailwind CSS样式。设计稿信息如下:\n${figmaText}`;
43
+ const code = await askCopilot(prompt);
44
+ if (code) {
45
+ // 将生成的代码写入文件
46
+ const fs = require("fs");
47
+ fs.writeFileSync("./GeneratedComponent.jsx", code);
48
+ vscode.window.showInformationMessage("组件代码已生成!");
49
+ }
50
+ }
51
+ })();
package/index.js CHANGED
@@ -5,6 +5,7 @@ import inquirer from "inquirer";
5
5
  import fs from "fs";
6
6
  import path from "path";
7
7
  import dotenv from "dotenv";
8
+ import clipboardy from "clipboardy";
8
9
  import { fileURLToPath } from "url";
9
10
 
10
11
  dotenv.config();
@@ -104,15 +105,21 @@ program
104
105
  },
105
106
  ]);
106
107
 
108
+ await clipboardy.write(
109
+ `${answers.figmaUrl}, Convert this to a ${answers.framework} component, Componentization and style separation are required.`
110
+ );
107
111
  console.log("\n🔄 Please follow these steps:\n");
108
112
  console.log(
109
113
  `1. Ensure VS Code is running and Copilot (Agent mode) is open.`
110
114
  );
111
- console.log(`2. Paste the design link into the Copilot chat:`);
112
- console.log(` ${answers.figmaUrl}`);
115
+ // console.log(`2. Paste the design link into the Copilot chat:`);
113
116
  console.log(
114
- `3. Enter a prompt, for example: “Convert this to a ${answers.framework} component using Tailwind CSS.”`
117
+ "2. The chat content has been copied to the clipboard. Please paste it directly into Copilot chat."
115
118
  );
119
+ // console.log(` ${answers.figmaUrl}`);
120
+ // console.log(
121
+ // `3. Enter a prompt, for example: “Convert this to a ${answers.framework} component, Componentization and style separation are required.”`
122
+ // );
116
123
  });
117
124
 
118
125
  program.parse(process.argv);
@@ -1 +1 @@
1
- FIGMA_PERSONAL_ACCESS_TOKEN="1111"
1
+ FIGMA_PERSONAL_ACCESS_TOKEN="figd_ZHGLl3Jg-3fDzsfR-C-lOyJisGl4eAwpdUUaHs9H"
@@ -5,7 +5,7 @@
5
5
  "args": [
6
6
  "-y",
7
7
  "figma-developer-mcp",
8
- "--figma-api-key=1111",
8
+ "--figma-api-key=figd_ZHGLl3Jg-3fDzsfR-C-lOyJisGl4eAwpdUUaHs9H",
9
9
  "--stdio"
10
10
  ]
11
11
  }
@@ -0,0 +1 @@
1
+ FIGMA_PERSONAL_ACCESS_TOKEN="figd_ZHGLl3Jg-3fDzsfR-C-lOyJisGl4eAwpdUUaHs9H"
@@ -0,0 +1,73 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+ ```
45
+
46
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import reactX from 'eslint-plugin-react-x'
51
+ import reactDom from 'eslint-plugin-react-dom'
52
+
53
+ export default defineConfig([
54
+ globalIgnores(['dist']),
55
+ {
56
+ files: ['**/*.{ts,tsx}'],
57
+ extends: [
58
+ // Other configs...
59
+ // Enable lint rules for React
60
+ reactX.configs['recommended-typescript'],
61
+ // Enable lint rules for React DOM
62
+ reactDom.configs.recommended,
63
+ ],
64
+ languageOptions: {
65
+ parserOptions: {
66
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
+ tsconfigRootDir: import.meta.dirname,
68
+ },
69
+ // other options...
70
+ },
71
+ },
72
+ ])
73
+ ```
@@ -0,0 +1,23 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import tseslint from 'typescript-eslint'
6
+ import { defineConfig, globalIgnores } from 'eslint/config'
7
+
8
+ export default defineConfig([
9
+ globalIgnores(['dist']),
10
+ {
11
+ files: ['**/*.{ts,tsx}'],
12
+ extends: [
13
+ js.configs.recommended,
14
+ tseslint.configs.recommended,
15
+ reactHooks.configs.flat.recommended,
16
+ reactRefresh.configs.vite,
17
+ ],
18
+ languageOptions: {
19
+ ecmaVersion: 2020,
20
+ globals: globals.browser,
21
+ },
22
+ },
23
+ ])
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>my-app</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>