@mstrathman/figma 0.1.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2025-01-17
9
+
10
+ ### Added
11
+
12
+ - Initial release of @mstrathman/figma
13
+ - Authentication via OAuth and personal access tokens
14
+ - File operations: get file info, list nodes, export images
15
+ - Component operations: list and get component details
16
+ - Style operations: list and get style details
17
+ - Variable operations: list and export variables
18
+ - Export capabilities: design tokens, icons, theme files
19
+ - Project operations: list projects and files
20
+ - Support for JSON and table output formats
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mstrathman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # figma
2
+
3
+ A command-line interface for the Figma API, inspired by GitHub's `gh` CLI. Built for design-to-code workflows.
4
+
5
+ > **Note:** This is an unofficial tool and is not affiliated with or endorsed by Figma, Inc.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g @mstrathman/figma
11
+ ```
12
+
13
+ ### From source
14
+
15
+ ```bash
16
+ git clone https://github.com/mstrathman/figma.git
17
+ cd figma
18
+ npm install
19
+ npm run build
20
+ npm link
21
+ ```
22
+
23
+ ## Authentication
24
+
25
+ ### Personal Access Token (Recommended)
26
+
27
+ Get a token from [Figma Developer Settings](https://www.figma.com/developers/api#access-tokens).
28
+
29
+ ```bash
30
+ # Interactive login
31
+ figma auth login
32
+
33
+ # Or with token directly
34
+ figma auth login --token <your-token>
35
+
36
+ # Or use environment variable
37
+ export FIGMA_TOKEN=<your-token>
38
+ ```
39
+
40
+ ### OAuth (Browser Login)
41
+
42
+ For OAuth, you need to [create a Figma app](https://www.figma.com/developers/apps) first.
43
+
44
+ ```bash
45
+ # Set credentials
46
+ export FIGMA_CLIENT_ID=<your-client-id>
47
+ export FIGMA_CLIENT_SECRET=<your-client-secret>
48
+
49
+ # Login via browser
50
+ figma auth login --web
51
+ ```
52
+
53
+ ### Check Status
54
+
55
+ ```bash
56
+ figma auth status
57
+ ```
58
+
59
+ ## Commands
60
+
61
+ ### Files
62
+
63
+ ```bash
64
+ # Get file structure
65
+ figma file get <file-key>
66
+
67
+ # Get specific nodes
68
+ figma file nodes <file-key> --ids "1:2,1:3"
69
+
70
+ # Export images
71
+ figma file images <file-key> --ids "1:2" --format svg --output ./icons
72
+ ```
73
+
74
+ ### Projects
75
+
76
+ ```bash
77
+ # List team projects
78
+ figma project list --team <team-id>
79
+
80
+ # List files in a project
81
+ figma project files <project-id>
82
+ ```
83
+
84
+ ### Components
85
+
86
+ ```bash
87
+ # List components in a file
88
+ figma component list --file <file-key>
89
+
90
+ # List team components
91
+ figma component list --team <team-id>
92
+
93
+ # Get component details
94
+ figma component get <component-key>
95
+ ```
96
+
97
+ ### Styles
98
+
99
+ ```bash
100
+ # List styles in a file
101
+ figma style list --file <file-key>
102
+
103
+ # List team styles
104
+ figma style list --team <team-id>
105
+
106
+ # Get style details
107
+ figma style get <style-key>
108
+ ```
109
+
110
+ ### Variables (Enterprise)
111
+
112
+ ```bash
113
+ # List variables
114
+ figma variable list <file-key>
115
+
116
+ # Export as design tokens
117
+ figma variable export <file-key> --format css --output tokens.css
118
+ figma variable export <file-key> --format style-dictionary --output tokens.json
119
+ ```
120
+
121
+ ### Export (Design-to-Code)
122
+
123
+ ```bash
124
+ # Export design tokens
125
+ figma export tokens <file-key> --format css
126
+ figma export tokens <file-key> --format scss
127
+ figma export tokens <file-key> --format tailwind
128
+ figma export tokens <file-key> --format style-dictionary
129
+
130
+ # Export icons
131
+ figma export icons <file-key> --frame "Icons" --format svg --output ./icons
132
+
133
+ # Export complete theme package
134
+ figma export theme <file-key> --formats "css,json,tailwind" --output ./theme
135
+ ```
136
+
137
+ ### Raw API Access
138
+
139
+ ```bash
140
+ # GET request
141
+ figma api /v1/me
142
+
143
+ # With query parameters
144
+ figma api /v1/files/<key>/images -q "ids=1:2,format=svg"
145
+
146
+ # POST request
147
+ figma api /v1/files/<key>/comments -X POST -d '{"message":"Hello"}'
148
+ ```
149
+
150
+ ## Output Formats
151
+
152
+ Most commands support `--format` for output:
153
+
154
+ - `json` (default) - JSON output, great for piping to `jq`
155
+ - `table` - Human-readable table format
156
+
157
+ ```bash
158
+ figma component list --file <key> --format table
159
+ ```
160
+
161
+ ## Configuration
162
+
163
+ Configuration is loaded in this priority order:
164
+
165
+ 1. Environment variables (`FIGMA_TOKEN`, `FIGMA_TEAM_ID`)
166
+ 2. Command-line flags (`--token`)
167
+ 3. Local config (`.figmarc` in current directory)
168
+ 4. User config (`~/.config/figma/config.json`)
169
+
170
+ ## File Keys
171
+
172
+ File keys can be found in Figma URLs:
173
+
174
+ ```
175
+ https://www.figma.com/file/ABC123xyz/My-Design
176
+ ^^^^^^^^^
177
+ This is the file key
178
+ ```
179
+
180
+ ## Examples
181
+
182
+ ### Export a design system
183
+
184
+ ```bash
185
+ # Export tokens as CSS variables
186
+ figma export tokens ABC123xyz --format css --output ./src/styles/tokens.css
187
+
188
+ # Export all icons as SVGs
189
+ figma export icons ABC123xyz --frame "Icons" --output ./src/assets/icons
190
+
191
+ # Export complete theme
192
+ figma export theme ABC123xyz --output ./src/theme
193
+ ```
194
+
195
+ ### Automate with scripts
196
+
197
+ ```bash
198
+ # Get all components and process with jq
199
+ figma component list --file ABC123xyz | jq '.meta.components[].name'
200
+
201
+ # Export specific nodes as PNGs
202
+ figma file images ABC123xyz --ids "1:2,1:3,1:4" --format png --scale 2 --output ./exports
203
+ ```
204
+
205
+ ## Tech Stack
206
+
207
+ - TypeScript
208
+ - Commander.js (CLI framework)
209
+ - `@figma/rest-api-spec` (official Figma API types)
210
+ - keytar (secure credential storage)
211
+
212
+ ## License
213
+
214
+ MIT
package/dist/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }