Skip to content

Commit 40385ad

Browse files
authored
Merge pull request #12 from dev-five-git/fix-coverage
Fix coverage
2 parents 95bd421 + 22205c8 commit 40385ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+6050
-2740
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: dev-five-git
2+
patreon: JeongMinOh

.github/workflows/CI.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '**/*.md'
9+
- LICENSE
10+
- '**/*.gitignore'
11+
- .editorconfig
12+
pull_request:
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
test:
21+
name: Test
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v5
25+
- uses: oven-sh/setup-bun@v2
26+
with:
27+
bun-version: latest
28+
- name: Install dependencies
29+
run: bun install
30+
- name: Lint
31+
run: bun run lint
32+
- name: Test
33+
run: bun test
34+
- name: Upload to codecov.io
35+
uses: codecov/codecov-action@v5
36+
with:
37+
token: ${{ secrets.CODECOV_TOKEN }}
38+
fail_ci_if_error: true
39+
files: coverage/lcov.info
40+
if: github.ref_name == 'main'

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
3+
bun run lint
4+
bun run test

README.md

Lines changed: 171 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,186 @@
1-
Below are the steps to get your plugin running. You can also find instructions at:
1+
# Devup Figma Plugin
2+
<p align="center">
3+
<a href="LICENSE">
4+
<img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License: Apache-2.0" />
5+
</a>
6+
<a href="https://github.com/dev-five-git/devup-figma-plugin/actions">
7+
<img src="https://img.shields.io/github/actions/workflow/status/dev-five-git/devup-figma-plugin/CI.yml?branch=main&label=CI" alt="Build Status" />
8+
</a>
9+
<a href="https://codecov.io/gh/dev-five-git/devup-figma-plugin">
10+
<img src="https://img.shields.io/codecov/c/github/dev-five-git/devup-figma-plugin" alt="Codecov Coverage" />
11+
</a>
12+
<a href="https://github.com/dev-five-git/devup-figma-plugin">
13+
<img src="https://img.shields.io/github/stars/dev-five-git/devup-figma-plugin.svg?style=social&label=Star" alt="GitHub stars" />
14+
</a>
15+
<a href="https://github.com/dev-five-git/devup-figma-plugin/fork">
16+
<img src="https://img.shields.io/github/forks/dev-five-git/devup-figma-plugin.svg?style=social&label=Fork" alt="GitHub forks" />
17+
</a>
18+
<a href="https://github.com/dev-five-git/devup-figma-plugin/issues">
19+
<img src="https://img.shields.io/github/issues/dev-five-git/devup-figma-plugin.svg" alt="GitHub issues" />
20+
</a>
21+
<a href="https://github.com/dev-five-git/devup-figma-plugin/pulls">
22+
<img src="https://img.shields.io/github/issues-pr/dev-five-git/devup-figma-plugin.svg" alt="GitHub pull requests" />
23+
</a>
24+
<a href="https://github.com/dev-five-git/devup-figma-plugin/commits/main">
25+
<img src="https://img.shields.io/github/last-commit/dev-five-git/devup-figma-plugin.svg" alt="GitHub last commit" />
26+
</a>
27+
</p>
228

3-
https://www.figma.com/plugin-docs/plugin-quickstart-guide/
29+
A powerful Figma plugin that generates React/TypeScript code from Figma designs and manages Devup design system configurations. This plugin enables seamless conversion of Figma components to production-ready React code and facilitates design system synchronization.
430

5-
This plugin template uses Typescript and NPM, two standard tools in creating JavaScript applications.
31+
## Features
632

7-
First, download Node.js which comes with NPM. This will allow you to install TypeScript and other
8-
libraries. You can find the download link here:
33+
### 🎨 Code Generation
34+
- **React Component Generation**: Automatically converts Figma designs to React/TypeScript components using the Devup-UI format
35+
- **Codegen Support**: Works with Figma's Dev Mode codegen feature for real-time code preview
36+
- **Component Extraction**: Extracts and generates code for nested components
37+
- **CLI Export**: Generates bash commands for easy file creation
938

10-
https://nodejs.org/en/download/
39+
### 📦 Design System Management
40+
- **Export Devup Config**: Export your design system (colors, typography, components) in JSON or Excel format
41+
- **Import Devup Config**: Import design system configurations back into Figma
42+
- **Treeshaking Support**: Optimize exports by removing unused design tokens
43+
- **Variable Support**: Handles Figma variables and color collections with multiple modes
1144

12-
Next, install TypeScript using the command:
45+
### 🚀 Component & Asset Export
46+
- **Component Export**: Export selected components as a ZIP file containing individual component files
47+
- **Asset Export**: Export design assets (currently in development)
1348

14-
npm install -g typescript
49+
## Installation
1550

16-
Finally, in the directory of your plugin, get the latest type definitions for the plugin API by running:
51+
### Prerequisites
52+
- [Bun](https://bun.sh/) (recommended) or Node.js
53+
- Figma Desktop App (for plugin development)
1754

18-
npm install --save-dev @figma/plugin-typings
55+
### Setup
1956

20-
If you are familiar with JavaScript, TypeScript will look very familiar. In fact, valid JavaScript code
21-
is already valid Typescript code.
57+
1. Clone the repository:
58+
```bash
59+
git clone <repository-url>
60+
cd devup-figma-plugin
61+
```
2262

23-
TypeScript adds type annotations to variables. This allows code editors such as Visual Studio Code
24-
to provide information about the Figma API while you are writing code, as well as help catch bugs
25-
you previously didn't notice.
63+
2. Install dependencies:
64+
```bash
65+
bun install
66+
```
2667

27-
For more information, visit https://www.typescriptlang.org/
68+
3. Build the plugin:
69+
```bash
70+
bun run build
71+
```
2872

29-
Using TypeScript requires a compiler to convert TypeScript (code.ts) into JavaScript (code.js)
30-
for the browser to run.
73+
4. Load the plugin in Figma:
74+
- Open Figma Desktop
75+
- Go to `Plugins``Development``Import plugin from manifest...`
76+
- Select the `manifest.json` file from this project
3177

32-
We recommend writing TypeScript code using Visual Studio code:
78+
## Development
3379

34-
1. Download Visual Studio Code if you haven't already: https://code.visualstudio.com/.
35-
2. Open this directory in Visual Studio Code.
36-
3. Compile TypeScript to JavaScript: Run the "Terminal > Run Build Task..." menu item,
37-
then select "npm: watch". You will have to do this again every time
38-
you reopen Visual Studio Code.
80+
### Available Scripts
3981

40-
That's it! Visual Studio Code will regenerate the JavaScript file every time you save.
82+
- `bun run dev` - Start development server with hot reload
83+
- `bun run build` - Build the plugin for production
84+
- `bun run watch` - Build the plugin in watch mode
85+
- `bun run test` - Run tests with coverage
86+
- `bun run lint` - Check code for linting errors
87+
- `bun run lint:fix` - Fix linting errors automatically
88+
89+
### Project Structure
90+
91+
```
92+
src/
93+
├── code.ts # Main plugin entry point
94+
├── codegen/ # Code generation logic
95+
│ ├── Codegen.ts # Main codegen class
96+
│ ├── props/ # Property generators (layout, colors, etc.)
97+
│ ├── render/ # Component rendering logic
98+
│ └── utils/ # Codegen utilities
99+
├── commands/ # Plugin commands
100+
│ ├── devup/ # Devup export/import functionality
101+
│ ├── exportAssets.ts # Asset export command
102+
│ └── exportComponents.ts # Component export command
103+
└── utils/ # Shared utilities
104+
```
105+
106+
## Usage
107+
108+
### Code Generation (Dev Mode)
109+
110+
1. Open Figma in Dev Mode
111+
2. Select a design element (frame, component, etc.)
112+
3. The plugin will automatically generate React/TypeScript code in the code panel
113+
4. You can copy the generated code or use the provided CLI commands
114+
115+
### Export Devup Configuration
116+
117+
1. Select elements in your Figma file
118+
2. Go to `Plugins``Devup``Export Devup` (or `Export Devup Excel`)
119+
3. Choose whether to use treeshaking (removes unused tokens)
120+
4. The configuration file will be downloaded
121+
122+
### Import Devup Configuration
123+
124+
1. Go to `Plugins``Devup``Import Devup` (or `Import Devup Excel`)
125+
2. Select your Devup configuration file
126+
3. The design system will be imported into Figma
127+
128+
### Export Components
129+
130+
1. Select the components you want to export
131+
2. Go to `Plugins``Devup``Export Components`
132+
3. A ZIP file containing all component files will be downloaded
133+
134+
## Technical Details
135+
136+
### Code Generation
137+
138+
The plugin converts Figma nodes to React components by:
139+
- Analyzing layout properties (auto-layout, padding, spacing)
140+
- Converting styles (colors, typography, effects)
141+
- Handling component variants and instances
142+
- Generating proper TypeScript types
143+
- Optimizing CSS properties
144+
145+
### Supported Figma Features
146+
147+
- ✅ Auto Layout
148+
- ✅ Components & Variants
149+
- ✅ Text Styles & Typography
150+
- ✅ Color Variables & Collections
151+
- ✅ Effects (shadows, blurs)
152+
- ✅ Borders & Strokes
153+
- ✅ Grid Layouts
154+
- ✅ Transform properties
155+
156+
### Build Configuration
157+
158+
- **Bundler**: Rspack
159+
- **Language**: TypeScript
160+
- **Linter**: Biome
161+
- **Test Runner**: Bun
162+
- **Package Manager**: Bun
163+
164+
## Testing
165+
166+
Run tests with coverage:
167+
```bash
168+
bun run test
169+
```
170+
171+
Test coverage reports are generated in the `coverage/` directory.
172+
173+
## Contributing
174+
175+
1. Follow the existing code style (enforced by Biome)
176+
2. Write tests for new features
177+
3. Ensure all tests pass and linting checks succeed
178+
4. Update documentation as needed
179+
180+
## License
181+
182+
[Add your license information here]
183+
184+
## Support
185+
186+
For issues, questions, or contributions, please [open an issue](link-to-issues) or contact the maintainers.

biome.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"includes": ["**", "!**/dist"]
10+
},
11+
"javascript": {
12+
"formatter": {
13+
"semicolons": "asNeeded",
14+
"quoteStyle": "single",
15+
"indentStyle": "space",
16+
"indentWidth": 2
17+
}
18+
},
19+
"json": {
20+
"formatter": {
21+
"indentStyle": "space",
22+
"indentWidth": 2
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)