design-lazyyy-cli 0.1.2 → 0.2.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/README.md CHANGED
@@ -42,7 +42,7 @@ all through a single CLI connected to Figma Desktop via Chrome DevTools Protocol
42
42
  # Install globally via npm
43
43
  npm install -g design-lazyyy-cli
44
44
 
45
- # One-time setup: patch Figma & install figma-use
45
+ # One-time setup: patch Figma for CLI access
46
46
  design-lazyyy-cli init
47
47
 
48
48
  # Connect to Figma Desktop
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "design-lazyyy-cli",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "CLI for managing Figma design systems. Create variables, components, and more. No API key required.",
5
5
  "author": "plugin87",
6
6
  "license": "MIT",
@@ -24,6 +24,7 @@
24
24
  "dependencies": {
25
25
  "chalk": "^5.3.0",
26
26
  "commander": "^12.0.0",
27
+ "figma-use": "^0.13.1",
27
28
  "ora": "^8.0.0",
28
29
  "ws": "^8.16.0"
29
30
  }
@@ -2,7 +2,7 @@
2
2
  * FigJam CDP Client
3
3
  *
4
4
  * Connects directly to FigJam via Chrome DevTools Protocol,
5
- * bypassing figma-use which has compatibility issues with FigJam.
5
+ * using direct CDP connection for better FigJam compatibility.
6
6
  */
7
7
 
8
8
  import WebSocket from 'ws';
package/src/index.js CHANGED
@@ -6,7 +6,7 @@ import ora from 'ora';
6
6
  import { execSync, spawn } from 'child_process';
7
7
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
8
8
  import { fileURLToPath } from 'url';
9
- import { dirname, join } from 'path';
9
+ import { dirname, join, resolve } from 'path';
10
10
  import { createInterface } from 'readline';
11
11
  import { homedir, platform } from 'os';
12
12
  import { FigJamClient } from './figjam-client.js';
@@ -95,10 +95,15 @@ function saveConfig(config) {
95
95
  writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
96
96
  }
97
97
 
98
- // Helper: Run figma-use command
98
+ // Resolve engine binary path (local node_modules)
99
+ const __filename2 = fileURLToPath(import.meta.url);
100
+ const __pkgRoot = dirname(dirname(__filename2));
101
+ const ENGINE_BIN = resolve(__pkgRoot, 'node_modules', '.bin', 'figma-use');
102
+
103
+ // Helper: Run engine command
99
104
  function figmaUse(args, options = {}) {
100
105
  try {
101
- const result = execSync(`figma-use ${args}`, {
106
+ const result = execSync(`"${ENGINE_BIN}" ${args}`, {
102
107
  encoding: 'utf8',
103
108
  stdio: options.silent ? 'pipe' : 'inherit',
104
109
  ...options
@@ -122,16 +127,16 @@ function checkConnection() {
122
127
  return true;
123
128
  }
124
129
 
125
- // Helper: Check if figma-use is installed
130
+ // Helper: Check if engine is available
126
131
  function checkDependencies(silent = false) {
127
132
  try {
128
- execSync('which figma-use', { stdio: 'pipe' });
129
- return true;
130
- } catch {
133
+ if (existsSync(ENGINE_BIN)) return true;
131
134
  if (!silent) {
132
- console.log(chalk.yellow(' Installing figma-use...'));
133
- execSync('npm install -g figma-use', { stdio: 'inherit' });
135
+ console.log(chalk.yellow(' Installing dependencies...'));
136
+ execSync('npm install', { cwd: __pkgRoot, stdio: 'inherit' });
134
137
  }
138
+ return existsSync(ENGINE_BIN);
139
+ } catch {
135
140
  return false;
136
141
  }
137
142
  }
@@ -189,18 +194,18 @@ program.action(async () => {
189
194
  }
190
195
  console.log(chalk.green(` ✓ Node.js ${nodeVersion}`));
191
196
 
192
- // Step 2: Install figma-use
197
+ // Step 2: Install dependencies
193
198
  console.log(chalk.blue('\nStep 2/4: ') + 'Installing dependencies...');
194
199
  if (checkDependencies(true)) {
195
- console.log(chalk.green(' ✓ figma-use already installed'));
200
+ console.log(chalk.green(' ✓ Dependencies ready'));
196
201
  } else {
197
- const spinner = ora(' Installing figma-use...').start();
202
+ const spinner = ora(' Installing dependencies...').start();
198
203
  try {
199
- execSync('npm install -g figma-use', { stdio: 'pipe' });
200
- spinner.succeed('figma-use installed');
204
+ execSync('npm install', { cwd: __pkgRoot, stdio: 'pipe' });
205
+ spinner.succeed('Dependencies installed');
201
206
  } catch (error) {
202
- spinner.fail('Failed to install figma-use');
203
- console.log(chalk.gray(' Try manually: npm install -g figma-use'));
207
+ spinner.fail('Failed to install dependencies');
208
+ console.log(chalk.gray(' Try manually: npm install'));
204
209
  process.exit(1);
205
210
  }
206
211
  }
@@ -213,7 +218,7 @@ program.action(async () => {
213
218
  console.log(chalk.gray(' (This allows CLI to connect to Figma)'));
214
219
  const spinner = ora(' Patching...').start();
215
220
  try {
216
- execSync('figma-use patch', { stdio: 'pipe' });
221
+ execSync(`"${ENGINE_BIN}" patch`, { stdio: 'pipe' });
217
222
  config.patched = true;
218
223
  saveConfig(config);
219
224
  spinner.succeed('Figma patched');
@@ -224,7 +229,7 @@ program.action(async () => {
224
229
  spinner.succeed('Figma already patched');
225
230
  } else {
226
231
  spinner.fail('Patch failed');
227
- console.log(chalk.gray(' Try manually: figma-use patch'));
232
+ console.log(chalk.gray(' Try: design-lazyyy-cli init'));
228
233
  }
229
234
  }
230
235
  }
@@ -348,18 +353,18 @@ program
348
353
  }
349
354
  console.log(chalk.green(` ✓ Node.js ${nodeVersion}`));
350
355
 
351
- // Step 2: Install figma-use
356
+ // Step 2: Install dependencies
352
357
  console.log(chalk.blue('\nStep 2/4: ') + 'Installing dependencies...');
353
358
  if (checkDependencies(true)) {
354
- console.log(chalk.green(' ✓ figma-use already installed'));
359
+ console.log(chalk.green(' ✓ Dependencies ready'));
355
360
  } else {
356
- const spinner = ora(' Installing figma-use...').start();
361
+ const spinner = ora(' Installing dependencies...').start();
357
362
  try {
358
- execSync('npm install -g figma-use', { stdio: 'pipe' });
359
- spinner.succeed('figma-use installed');
363
+ execSync('npm install', { cwd: __pkgRoot, stdio: 'pipe' });
364
+ spinner.succeed('Dependencies installed');
360
365
  } catch (error) {
361
- spinner.fail('Failed to install figma-use');
362
- console.log(chalk.gray(' Try manually: npm install -g figma-use'));
366
+ spinner.fail('Failed to install dependencies');
367
+ console.log(chalk.gray(' Try manually: npm install'));
363
368
  process.exit(1);
364
369
  }
365
370
  }
@@ -373,7 +378,7 @@ program
373
378
  console.log(chalk.gray(' (This allows CLI to connect to Figma)'));
374
379
  const spinner = ora(' Patching...').start();
375
380
  try {
376
- execSync('figma-use patch', { stdio: 'pipe' });
381
+ execSync(`"${ENGINE_BIN}" patch`, { stdio: 'pipe' });
377
382
  config.patched = true;
378
383
  saveConfig(config);
379
384
  spinner.succeed('Figma patched');
@@ -384,7 +389,7 @@ program
384
389
  spinner.succeed('Figma already patched');
385
390
  } else {
386
391
  spinner.fail('Patch failed');
387
- console.log(chalk.gray(' Try manually: figma-use patch'));
392
+ console.log(chalk.gray(' Try: design-lazyyy-cli init'));
388
393
  }
389
394
  }
390
395
  }
@@ -1104,7 +1109,7 @@ removed
1104
1109
 
1105
1110
  try {
1106
1111
  for (const { jsx } of jsxComponents) {
1107
- execSync(`echo '${jsx}' | figma-use render --stdin`, { stdio: 'pipe' });
1112
+ execSync(`echo '${jsx}' | "${ENGINE_BIN}" render --stdin`, { stdio: 'pipe' });
1108
1113
  }
1109
1114
  spinner.succeed('9 frames created');
1110
1115
  } catch (e) { spinner.fail('Frame creation failed'); }
@@ -2179,7 +2184,7 @@ program
2179
2184
  .description('Render JSX to Figma')
2180
2185
  .action((jsx) => {
2181
2186
  checkConnection();
2182
- execSync(`echo '${jsx}' | figma-use render --stdin`, { stdio: 'inherit' });
2187
+ execSync(`echo '${jsx}' | "${ENGINE_BIN}" render --stdin`, { stdio: 'inherit' });
2183
2188
  });
2184
2189
 
2185
2190
  // ============ EXPORT ============
@@ -2257,7 +2262,7 @@ program
2257
2262
 
2258
2263
  program
2259
2264
  .command('raw <command...>')
2260
- .description('Run raw figma-use command')
2265
+ .description('Run raw engine command')
2261
2266
  .action((command) => {
2262
2267
  checkConnection();
2263
2268
  figmaUse(command.join(' '));