figma-sprite-tool 0.1.0 → 0.1.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/README.md CHANGED
@@ -18,16 +18,76 @@ CLI tool to generate PNG/SVG sprite sheets, SCSS mixins, and JSON metadata from
18
18
 
19
19
  ## Installation
20
20
 
21
+ ### For End Users
22
+
23
+ #### Global Installation (Recommended)
24
+ ```bash
25
+ npm install -g figma-sprite-tool
26
+ ```
27
+
28
+ Verify installation:
29
+ ```bash
30
+ figma-sprite --version
31
+ ```
32
+
33
+ #### Use with npx (No Installation)
34
+ ```bash
35
+ npx figma-sprite-tool init
36
+ npx figma-sprite-tool generate
37
+ ```
38
+
39
+ #### Project-Local Installation
40
+ ```bash
41
+ npm install --save-dev figma-sprite-tool
42
+ ```
43
+
44
+ Add to package.json:
45
+ ```json
46
+ {
47
+ "scripts": {
48
+ "sprite": "figma-sprite generate"
49
+ }
50
+ }
51
+ ```
52
+
53
+ ## Environment Setup
54
+
55
+ ### Figma Token
56
+
57
+ Get your token from: https://www.figma.com/developers/api#access-tokens
58
+
59
+ #### Windows (Git Bash)
60
+ ```bash
61
+ export FIGMA_TOKEN="your-token-here"
62
+ ```
63
+
64
+ Make persistent:
21
65
  ```bash
22
- npm i -g figma-sprite-tool
66
+ echo 'export FIGMA_TOKEN="your-token-here"' >> ~/.bashrc
67
+ ```
68
+
69
+ #### Windows (CMD)
70
+ ```cmd
71
+ set FIGMA_TOKEN=your-token-here
72
+ ```
73
+
74
+ Make persistent:
75
+ ```cmd
76
+ setx FIGMA_TOKEN "your-token-here"
23
77
  ```
24
78
 
25
- Without global install:
79
+ #### macOS/Linux
80
+ ```bash
81
+ export FIGMA_TOKEN="your-token-here"
82
+ ```
26
83
 
84
+ Make persistent:
27
85
  ```bash
28
- npx figma-sprite --help
86
+ echo 'export FIGMA_TOKEN="your-token-here"' >> ~/.bashrc
29
87
  ```
30
88
 
89
+ ⚠️ **Never commit tokens to git!**
90
+
31
91
  ## Development
32
92
 
33
93
  ```bash
@@ -172,6 +232,43 @@ For detailed usage instructions on how to use generated sprite files:
172
232
  - 🇰🇷 [스프라이트 사용 가이드 (한국어)](./docs/SPRITE_USAGE_GUIDE.md)
173
233
  - 🇬🇧 [Sprite Usage Guide (English)](./docs/SPRITE_USAGE_GUIDE_EN.md)
174
234
 
235
+ ## Troubleshooting
236
+
237
+ ### Command not found: figma-sprite
238
+
239
+ **Problem**: Package not installed or not in PATH.
240
+
241
+ **Solutions**:
242
+ - Install globally: `npm install -g figma-sprite-tool`
243
+ - Use npx: `npx figma-sprite-tool [command]`
244
+ - Check PATH: `which figma-sprite` (should show path)
245
+
246
+ ### Figma token not found
247
+
248
+ **Problem**: FIGMA_TOKEN environment variable not set.
249
+
250
+ **Solutions**:
251
+ 1. Get token from: https://www.figma.com/developers/api#access-tokens
252
+ 2. Set environment variable (see [Environment Setup](#environment-setup))
253
+ 3. Or add to config: `{ "figma": { "personalAccessToken": "..." } }`
254
+
255
+ ### Configuration file not found
256
+
257
+ **Problem**: `figma.sprite.config.json` missing.
258
+
259
+ **Solutions**:
260
+ - Run: `figma-sprite init`
261
+ - Or create config manually (see [Manual Configuration (Advanced)](#manual-configuration-advanced))
262
+
263
+ ### Permission denied (Windows)
264
+
265
+ **Problem**: Execution policy blocks scripts.
266
+
267
+ **Solution** (PowerShell as Administrator):
268
+ ```powershell
269
+ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
270
+ ```
271
+
175
272
  ## Architecture
176
273
 
177
274
  - **CLI Layer**: Commander.js for command-line interface
package/dist/index.js CHANGED
@@ -394,14 +394,28 @@ function normalizeLegacyConfig(rawConfig) {
394
394
  async function loadConfig(options = {}) {
395
395
  const configPath = await resolveConfigPath(options);
396
396
  if (!configPath) {
397
- throw createConfigError(
398
- "E101" /* CONFIG_NOT_FOUND */,
399
- "Configuration file not found",
400
- {
401
- searchedPaths: DEFAULT_CONFIG_NAMES,
402
- cwd: options.cwd ?? process.cwd()
403
- }
404
- );
397
+ const cwd = options.cwd ?? process.cwd();
398
+ const errorMessage = [
399
+ "\u274C Configuration file not found",
400
+ "",
401
+ "\u{1F680} Quick Start:",
402
+ " Run: figma-sprite init",
403
+ " Then follow the interactive prompts",
404
+ "",
405
+ "\u{1F4DD} Manual Setup:",
406
+ ` Create ${DEFAULT_CONFIG_NAMES[0]} with:`,
407
+ " {",
408
+ ' "figma": { "fileKey": "...", "page": "..." },',
409
+ ' "output": { "dir": "./sprites", "name": "sprite" }',
410
+ " }",
411
+ "",
412
+ `\u{1F4C2} Searched in: ${cwd}`,
413
+ `\u{1F4C4} Tried: ${DEFAULT_CONFIG_NAMES.join(", ")}`
414
+ ].join("\n");
415
+ throw createConfigError("E101" /* CONFIG_NOT_FOUND */, errorMessage, {
416
+ searchedPaths: DEFAULT_CONFIG_NAMES,
417
+ cwd
418
+ });
405
419
  }
406
420
  return await loadConfigFromPath(configPath);
407
421
  }
@@ -2335,9 +2349,27 @@ function getFigmaToken(config) {
2335
2349
  }
2336
2350
  const token = process.env.FIGMA_TOKEN;
2337
2351
  if (!token) {
2338
- throw new Error(
2339
- "Figma token not found. Set FIGMA_TOKEN environment variable or add personalAccessToken to config."
2340
- );
2352
+ const errorMessage = [
2353
+ "\u274C Figma token not found",
2354
+ "",
2355
+ "\u{1F4DD} Setup Instructions:",
2356
+ " 1. Get your token: https://www.figma.com/developers/api#access-tokens",
2357
+ " 2. Set environment variable:",
2358
+ "",
2359
+ " Windows (Git Bash):",
2360
+ ' export FIGMA_TOKEN="your-token-here"',
2361
+ "",
2362
+ " Windows (CMD):",
2363
+ " set FIGMA_TOKEN=your-token-here",
2364
+ "",
2365
+ " macOS/Linux:",
2366
+ ' export FIGMA_TOKEN="your-token-here"',
2367
+ "",
2368
+ ' 3. Or add to config: { "figma": { "personalAccessToken": "your-token" } }',
2369
+ "",
2370
+ "\u26A0\uFE0F Never commit tokens to git!"
2371
+ ].join("\n");
2372
+ throw new Error(errorMessage);
2341
2373
  }
2342
2374
  return token;
2343
2375
  }