crm-summit/app/Commands/SyncFigmaData.php
mahdahar 329e4e6725 feat(figma): add local sync dashboard, API, and CLI tooling
Add Figma persistence and sync flow for one file source.

- create figma_files, figma_file_versions, and figma_comments tables with supporting migrations
- add FigmaSyncService for full and incremental sync, API fetch, pagination, dedupe, and upserts
- add CLI commands and shell wrappers for full and incremental sync runs
- expose Figma dashboard plus API endpoints for summary, snapshots, comments, and admin sync trigger
- wire route and sidebar entry for dashboard access
- trim legacy file_url and thumbnail_url fields, add version label/description support
2026-04-27 16:55:43 +07:00

43 lines
1.1 KiB
PHP

<?php
namespace App\Commands;
use App\Libraries\FigmaSyncService;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
class SyncFigmaData extends BaseCommand
{
protected $group = 'Figma';
protected $name = 'figma:sync';
protected $description = 'Full sync single Figma file snapshots and comments into local database.';
public function run(array $params)
{
CLI::write('Starting Figma full sync...', 'yellow');
$service = new FigmaSyncService();
$result = $service->syncAll();
if (!($result['success'] ?? false)) {
CLI::error('Sync failed: ' . ($result['message'] ?? 'Unknown error'));
return;
}
$stats = $result['stats'] ?? [];
CLI::write('Sync done.', 'green');
CLI::write('Files: ' . ($stats['files_synced'] ?? 0));
CLI::write('Snapshots: ' . ($stats['versions_synced'] ?? 0));
CLI::write('Comments: ' . ($stats['comments_synced'] ?? 0));
$errors = $stats['errors'] ?? [];
if (!empty($errors)) {
CLI::newLine();
CLI::write('Warnings / Errors:', 'yellow');
foreach ($errors as $error) {
CLI::write('- ' . $error, 'light_red');
}
}
}
}