desen-cli 1.0.0-draft.4 → 1.0.0-draft.6

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > desen-cli@1.0.0-draft.4 build /Users/selmanay/Desktop/desen/packages/cli
3
+ > desen-cli@1.0.0-draft.6 build /Users/selmanay/Desktop/desen/packages/cli
4
4
  > tsc
5
5
 
package/dist/index.js CHANGED
@@ -172,8 +172,9 @@ program
172
172
  <div class="card">
173
173
  <h1>šŸš€ DESEN Daemon Active</h1>
174
174
  <p>The Synchronization (Sync) server is waiting for incoming <strong>UI AST</strong> data from Figma. It can safely continue running in the background.</p>
175
- <p>To preview your design live as a standalone application using the <strong>desen</strong> render engine, open a new terminal in your project directory and run the following commands:</p>
176
- <div class="code">cd desen-workspace<br/>npm install<br/>npm run dev</div>
175
+ <p>When you press <strong>Sync to Localhost</strong> in Figma, the daemon will <strong>automatically</strong>:</p>
176
+ <div class="code">1. Validate &amp; save JSON files<br/>2. Install dependencies (if needed)<br/>3. Start dev server on port 3001<br/>4. Open your browser ✨</div>
177
+ <p style="margin-top:16px;color:#888;">Zero-touch. Just press Sync and watch the magic.</p>
177
178
  </div>
178
179
  </body>
179
180
  </html>
@@ -248,8 +249,8 @@ program
248
249
  "start": "next start"
249
250
  },
250
251
  dependencies: {
251
- "desen-core": "1.0.0-draft.4",
252
- "desen": "1.0.0-draft.4",
252
+ "desen-core": "1.0.0-draft.6",
253
+ "desen": "1.0.0-draft.6",
253
254
  "next": "14.2.3",
254
255
  "react": "18.3.1",
255
256
  "react-dom": "18.3.1"
@@ -551,6 +552,74 @@ export const registry: Record<string, React.FC<any>> = {
551
552
  }
552
553
  }
553
554
  } // End if(!package.json)
555
+ // ─────────────────────────────────────────────────────────
556
+ // AUTO-PILOT: npm install + npm run dev + browser open
557
+ // Zero-touch DX — developer never leaves Figma
558
+ // ─────────────────────────────────────────────────────────
559
+ const nodeModulesPath = path_1.default.join(workspaceDir, "node_modules");
560
+ const devServerPort = 3001;
561
+ const isPortInUse = (port) => {
562
+ return new Promise((resolve) => {
563
+ const net = require("net");
564
+ const tester = net.createServer()
565
+ .once("error", (err) => {
566
+ if (err.code === "EADDRINUSE")
567
+ resolve(true);
568
+ else
569
+ resolve(false);
570
+ })
571
+ .once("listening", () => {
572
+ tester.close(() => resolve(false));
573
+ })
574
+ .listen(port);
575
+ });
576
+ };
577
+ const runNpmInstallIfNeeded = async () => {
578
+ if (fs_1.default.existsSync(nodeModulesPath))
579
+ return;
580
+ console.log(chalk_1.default.blue(`\nšŸ“¦ Installing dependencies...`));
581
+ const { execSync } = require("child_process");
582
+ try {
583
+ execSync("npm install", { cwd: workspaceDir, stdio: "inherit" });
584
+ console.log(chalk_1.default.green(`āœ… Dependencies installed.`));
585
+ }
586
+ catch (e) {
587
+ console.error(chalk_1.default.red(`āŒ npm install failed: ${e.message}`));
588
+ }
589
+ };
590
+ const startDevServerIfNeeded = async () => {
591
+ const portBusy = await isPortInUse(devServerPort);
592
+ if (portBusy) {
593
+ console.log(chalk_1.default.gray(` Dev server already running on port ${devServerPort}.`));
594
+ return;
595
+ }
596
+ console.log(chalk_1.default.blue(`\nšŸš€ Starting dev server on port ${devServerPort}...`));
597
+ const { spawn } = require("child_process");
598
+ const child = spawn("npm", ["run", "dev"], {
599
+ cwd: workspaceDir,
600
+ detached: true,
601
+ stdio: "ignore"
602
+ });
603
+ child.unref();
604
+ console.log(chalk_1.default.green(`āœ… Dev server launched (PID: ${child.pid}).`));
605
+ // Wait a bit then open browser
606
+ setTimeout(() => {
607
+ const openCmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
608
+ const { exec } = require("child_process");
609
+ exec(`${openCmd} http://localhost:${devServerPort}`);
610
+ console.log(chalk_1.default.cyan(`🌐 Browser opened: http://localhost:${devServerPort}`));
611
+ }, 3000);
612
+ };
613
+ // Fire and forget — don't block the HTTP response
614
+ (async () => {
615
+ try {
616
+ await runNpmInstallIfNeeded();
617
+ await startDevServerIfNeeded();
618
+ }
619
+ catch (e) {
620
+ console.error(chalk_1.default.yellow(`āš ļø Auto-pilot warning: ${e.message}`));
621
+ }
622
+ })();
554
623
  res.status(200).json({ success: true, message: `Successfully saved ${savedCount} files.` });
555
624
  }
556
625
  catch (error) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "desen-cli",
3
- "version": "1.0.0-draft.4",
3
+ "version": "1.0.0-draft.6",
4
4
  "main": "dist/index.js",
5
5
  "dependencies": {
6
6
  "chalk": "^5.6.2",
7
7
  "commander": "^14.0.3",
8
8
  "express": "^4.19.2",
9
9
  "cors": "^2.8.5",
10
- "desen-core": "1.0.0-draft.4"
10
+ "desen-core": "1.0.0-draft.6"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/cors": "^2.8.19",
package/src/index.ts CHANGED
@@ -190,8 +190,9 @@ program
190
190
  <div class="card">
191
191
  <h1>šŸš€ DESEN Daemon Active</h1>
192
192
  <p>The Synchronization (Sync) server is waiting for incoming <strong>UI AST</strong> data from Figma. It can safely continue running in the background.</p>
193
- <p>To preview your design live as a standalone application using the <strong>desen</strong> render engine, open a new terminal in your project directory and run the following commands:</p>
194
- <div class="code">cd desen-workspace<br/>npm install<br/>npm run dev</div>
193
+ <p>When you press <strong>Sync to Localhost</strong> in Figma, the daemon will <strong>automatically</strong>:</p>
194
+ <div class="code">1. Validate &amp; save JSON files<br/>2. Install dependencies (if needed)<br/>3. Start dev server on port 3001<br/>4. Open your browser ✨</div>
195
+ <p style="margin-top:16px;color:#888;">Zero-touch. Just press Sync and watch the magic.</p>
195
196
  </div>
196
197
  </body>
197
198
  </html>
@@ -274,8 +275,8 @@ program
274
275
  "start": "next start"
275
276
  },
276
277
  dependencies: {
277
- "desen-core": "1.0.0-draft.4",
278
- "desen": "1.0.0-draft.4",
278
+ "desen-core": "1.0.0-draft.6",
279
+ "desen": "1.0.0-draft.6",
279
280
  "next": "14.2.3",
280
281
  "react": "18.3.1",
281
282
  "react-dom": "18.3.1"
@@ -589,6 +590,77 @@ export const registry: Record<string, React.FC<any>> = {
589
590
  }
590
591
  } // End if(!package.json)
591
592
 
593
+ // ─────────────────────────────────────────────────────────
594
+ // AUTO-PILOT: npm install + npm run dev + browser open
595
+ // Zero-touch DX — developer never leaves Figma
596
+ // ─────────────────────────────────────────────────────────
597
+ const nodeModulesPath = path.join(workspaceDir, "node_modules");
598
+ const devServerPort = 3001;
599
+
600
+ const isPortInUse = (port: number): Promise<boolean> => {
601
+ return new Promise((resolve) => {
602
+ const net = require("net");
603
+ const tester = net.createServer()
604
+ .once("error", (err: any) => {
605
+ if (err.code === "EADDRINUSE") resolve(true);
606
+ else resolve(false);
607
+ })
608
+ .once("listening", () => {
609
+ tester.close(() => resolve(false));
610
+ })
611
+ .listen(port);
612
+ });
613
+ };
614
+
615
+ const runNpmInstallIfNeeded = async () => {
616
+ if (fs.existsSync(nodeModulesPath)) return;
617
+
618
+ console.log(chalk.blue(`\nšŸ“¦ Installing dependencies...`));
619
+ const { execSync } = require("child_process");
620
+ try {
621
+ execSync("npm install", { cwd: workspaceDir, stdio: "inherit" });
622
+ console.log(chalk.green(`āœ… Dependencies installed.`));
623
+ } catch (e: any) {
624
+ console.error(chalk.red(`āŒ npm install failed: ${e.message}`));
625
+ }
626
+ };
627
+
628
+ const startDevServerIfNeeded = async () => {
629
+ const portBusy = await isPortInUse(devServerPort);
630
+ if (portBusy) {
631
+ console.log(chalk.gray(` Dev server already running on port ${devServerPort}.`));
632
+ return;
633
+ }
634
+
635
+ console.log(chalk.blue(`\nšŸš€ Starting dev server on port ${devServerPort}...`));
636
+ const { spawn } = require("child_process");
637
+ const child = spawn("npm", ["run", "dev"], {
638
+ cwd: workspaceDir,
639
+ detached: true,
640
+ stdio: "ignore"
641
+ });
642
+ child.unref();
643
+ console.log(chalk.green(`āœ… Dev server launched (PID: ${child.pid}).`));
644
+
645
+ // Wait a bit then open browser
646
+ setTimeout(() => {
647
+ const openCmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
648
+ const { exec } = require("child_process");
649
+ exec(`${openCmd} http://localhost:${devServerPort}`);
650
+ console.log(chalk.cyan(`🌐 Browser opened: http://localhost:${devServerPort}`));
651
+ }, 3000);
652
+ };
653
+
654
+ // Fire and forget — don't block the HTTP response
655
+ (async () => {
656
+ try {
657
+ await runNpmInstallIfNeeded();
658
+ await startDevServerIfNeeded();
659
+ } catch (e: any) {
660
+ console.error(chalk.yellow(`āš ļø Auto-pilot warning: ${e.message}`));
661
+ }
662
+ })();
663
+
592
664
  res.status(200).json({ success: true, message: `Successfully saved ${savedCount} files.` });
593
665
  } catch (error: any) {
594
666
  console.error(chalk.red("āŒ Sync Error:"), error);