@supernovaio/cli 2.0.38 → 2.0.40

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.
Files changed (172) hide show
  1. package/README.md +1 -0
  2. package/dist/code-analyzer/analyzers/component-usage.d.ts +6 -0
  3. package/dist/code-analyzer/analyzers/component-usage.d.ts.map +1 -0
  4. package/dist/code-analyzer/analyzers/component-usage.js +344 -0
  5. package/dist/code-analyzer/analyzers/component-usage.js.map +1 -0
  6. package/dist/code-analyzer/analyzers/helpers.d.ts +11 -0
  7. package/dist/code-analyzer/analyzers/helpers.d.ts.map +1 -0
  8. package/dist/code-analyzer/analyzers/helpers.js +59 -0
  9. package/dist/code-analyzer/analyzers/helpers.js.map +1 -0
  10. package/dist/code-analyzer/analyzers/index.d.ts +8 -0
  11. package/dist/code-analyzer/analyzers/index.d.ts.map +1 -0
  12. package/dist/code-analyzer/analyzers/index.js +11 -0
  13. package/dist/code-analyzer/analyzers/index.js.map +1 -0
  14. package/dist/code-analyzer/analyzers/jsdoc.d.ts +3 -0
  15. package/dist/code-analyzer/analyzers/jsdoc.d.ts.map +1 -0
  16. package/dist/code-analyzer/analyzers/jsdoc.js +7 -0
  17. package/dist/code-analyzer/analyzers/jsdoc.js.map +1 -0
  18. package/dist/code-analyzer/analyzers/static-components.d.ts +3 -0
  19. package/dist/code-analyzer/analyzers/static-components.d.ts.map +1 -0
  20. package/dist/code-analyzer/analyzers/static-components.js +399 -0
  21. package/dist/code-analyzer/analyzers/static-components.js.map +1 -0
  22. package/dist/code-analyzer/analyzers/storybook-docs.d.ts +3 -0
  23. package/dist/code-analyzer/analyzers/storybook-docs.d.ts.map +1 -0
  24. package/dist/code-analyzer/analyzers/storybook-docs.js +163 -0
  25. package/dist/code-analyzer/analyzers/storybook-docs.js.map +1 -0
  26. package/dist/code-analyzer/analyzers/storybook-stories.d.ts +3 -0
  27. package/dist/code-analyzer/analyzers/storybook-stories.d.ts.map +1 -0
  28. package/dist/code-analyzer/analyzers/storybook-stories.js +91 -0
  29. package/dist/code-analyzer/analyzers/storybook-stories.js.map +1 -0
  30. package/dist/code-analyzer/analyzers/types.d.ts +88 -0
  31. package/dist/code-analyzer/analyzers/types.d.ts.map +1 -0
  32. package/dist/code-analyzer/analyzers/types.js +12 -0
  33. package/dist/code-analyzer/analyzers/types.js.map +1 -0
  34. package/dist/code-analyzer/analyzers/typescript-api.d.ts +3 -0
  35. package/dist/code-analyzer/analyzers/typescript-api.d.ts.map +1 -0
  36. package/dist/code-analyzer/analyzers/typescript-api.js +7 -0
  37. package/dist/code-analyzer/analyzers/typescript-api.js.map +1 -0
  38. package/dist/code-analyzer/components/analyze.d.ts +8 -0
  39. package/dist/code-analyzer/components/analyze.d.ts.map +1 -0
  40. package/dist/code-analyzer/components/analyze.js +38 -0
  41. package/dist/code-analyzer/components/analyze.js.map +1 -0
  42. package/dist/code-analyzer/components/mappers/component.d.ts +4 -0
  43. package/dist/code-analyzer/components/mappers/component.d.ts.map +1 -0
  44. package/dist/code-analyzer/components/mappers/component.js +20 -0
  45. package/dist/code-analyzer/components/mappers/component.js.map +1 -0
  46. package/dist/code-analyzer/components/mappers/property.d.ts +4 -0
  47. package/dist/code-analyzer/components/mappers/property.d.ts.map +1 -0
  48. package/dist/code-analyzer/components/mappers/property.js +19 -0
  49. package/dist/code-analyzer/components/mappers/property.js.map +1 -0
  50. package/dist/code-analyzer/components/parser/index.d.ts +6 -0
  51. package/dist/code-analyzer/components/parser/index.d.ts.map +1 -0
  52. package/dist/code-analyzer/components/parser/index.js +9 -0
  53. package/dist/code-analyzer/components/parser/index.js.map +1 -0
  54. package/dist/code-analyzer/components/parser/module-parser.d.ts +12 -0
  55. package/dist/code-analyzer/components/parser/module-parser.d.ts.map +1 -0
  56. package/dist/code-analyzer/components/parser/module-parser.js +116 -0
  57. package/dist/code-analyzer/components/parser/module-parser.js.map +1 -0
  58. package/dist/code-analyzer/components/parser/parser.d.ts +46 -0
  59. package/dist/code-analyzer/components/parser/parser.d.ts.map +1 -0
  60. package/dist/code-analyzer/components/parser/parser.js +904 -0
  61. package/dist/code-analyzer/components/parser/parser.js.map +1 -0
  62. package/dist/code-analyzer/components/parser/types.d.ts +123 -0
  63. package/dist/code-analyzer/components/parser/types.d.ts.map +1 -0
  64. package/dist/code-analyzer/components/parser/types.js +21 -0
  65. package/dist/code-analyzer/components/parser/types.js.map +1 -0
  66. package/dist/code-analyzer/components/parser/utils/build-filter.d.ts +3 -0
  67. package/dist/code-analyzer/components/parser/utils/build-filter.d.ts.map +1 -0
  68. package/dist/code-analyzer/components/parser/utils/build-filter.js +31 -0
  69. package/dist/code-analyzer/components/parser/utils/build-filter.js.map +1 -0
  70. package/dist/code-analyzer/components/parser/utils/filter-duplicates.d.ts +3 -0
  71. package/dist/code-analyzer/components/parser/utils/filter-duplicates.d.ts.map +1 -0
  72. package/dist/code-analyzer/components/parser/utils/filter-duplicates.js +17 -0
  73. package/dist/code-analyzer/components/parser/utils/filter-duplicates.js.map +1 -0
  74. package/dist/code-analyzer/components/parser/utils/is-react-component.d.ts +4 -0
  75. package/dist/code-analyzer/components/parser/utils/is-react-component.d.ts.map +1 -0
  76. package/dist/code-analyzer/components/parser/utils/is-react-component.js +43 -0
  77. package/dist/code-analyzer/components/parser/utils/is-react-component.js.map +1 -0
  78. package/dist/code-analyzer/components/parser/utils/trim-file-name.d.ts +2 -0
  79. package/dist/code-analyzer/components/parser/utils/trim-file-name.d.ts.map +1 -0
  80. package/dist/code-analyzer/components/parser/utils/trim-file-name.js +22 -0
  81. package/dist/code-analyzer/components/parser/utils/trim-file-name.js.map +1 -0
  82. package/dist/code-analyzer/components/types.d.ts +18 -0
  83. package/dist/code-analyzer/components/types.d.ts.map +1 -0
  84. package/dist/code-analyzer/components/types.js +5 -0
  85. package/dist/code-analyzer/components/types.js.map +1 -0
  86. package/dist/code-analyzer/components/utils/get-module-exports-path.d.ts +2 -0
  87. package/dist/code-analyzer/components/utils/get-module-exports-path.d.ts.map +1 -0
  88. package/dist/code-analyzer/components/utils/get-module-exports-path.js +60 -0
  89. package/dist/code-analyzer/components/utils/get-module-exports-path.js.map +1 -0
  90. package/dist/code-analyzer/index.d.ts +5 -0
  91. package/dist/code-analyzer/index.d.ts.map +1 -0
  92. package/dist/code-analyzer/index.js +8 -0
  93. package/dist/code-analyzer/index.js.map +1 -0
  94. package/dist/code-analyzer/orchestrator/index.d.ts +2 -0
  95. package/dist/code-analyzer/orchestrator/index.d.ts.map +1 -0
  96. package/dist/code-analyzer/orchestrator/index.js +5 -0
  97. package/dist/code-analyzer/orchestrator/index.js.map +1 -0
  98. package/dist/code-analyzer/orchestrator/run-analysis.d.ts +19 -0
  99. package/dist/code-analyzer/orchestrator/run-analysis.d.ts.map +1 -0
  100. package/dist/code-analyzer/orchestrator/run-analysis.js +109 -0
  101. package/dist/code-analyzer/orchestrator/run-analysis.js.map +1 -0
  102. package/dist/code-analyzer/snapshot/index.d.ts +2 -0
  103. package/dist/code-analyzer/snapshot/index.d.ts.map +1 -0
  104. package/dist/code-analyzer/snapshot/index.js +5 -0
  105. package/dist/code-analyzer/snapshot/index.js.map +1 -0
  106. package/dist/code-analyzer/snapshot/write-snapshot.d.ts +17 -0
  107. package/dist/code-analyzer/snapshot/write-snapshot.d.ts.map +1 -0
  108. package/dist/code-analyzer/snapshot/write-snapshot.js +60 -0
  109. package/dist/code-analyzer/snapshot/write-snapshot.js.map +1 -0
  110. package/dist/commands/analyze/adoption.d.ts +15 -0
  111. package/dist/commands/analyze/adoption.d.ts.map +1 -0
  112. package/dist/commands/analyze/adoption.js +34 -0
  113. package/dist/commands/analyze/adoption.js.map +1 -0
  114. package/dist/commands/analyze/components.d.ts +15 -0
  115. package/dist/commands/analyze/components.d.ts.map +1 -0
  116. package/dist/commands/analyze/components.js +34 -0
  117. package/dist/commands/analyze/components.js.map +1 -0
  118. package/dist/commands/analyze/status.d.ts +24 -0
  119. package/dist/commands/analyze/status.d.ts.map +1 -0
  120. package/dist/commands/analyze/status.js +54 -0
  121. package/dist/commands/analyze/status.js.map +1 -0
  122. package/dist/commands/analyze.d.ts +15 -0
  123. package/dist/commands/analyze.d.ts.map +1 -0
  124. package/dist/commands/analyze.js +34 -0
  125. package/dist/commands/analyze.js.map +1 -0
  126. package/dist/commands/components-import.d.ts +3 -3
  127. package/dist/commands/components-import.d.ts.map +1 -1
  128. package/dist/commands/components-import.js +9 -3
  129. package/dist/commands/components-import.js.map +1 -1
  130. package/dist/commands/publish-documentation.d.ts +2 -2
  131. package/dist/commands/run-local-exporter.js +2 -2
  132. package/dist/commands/run-local-exporter.js.map +1 -1
  133. package/dist/commands/storybook-import.d.ts +2 -2
  134. package/dist/commands/template-upload.d.ts.map +1 -1
  135. package/dist/commands/template-upload.js +10 -12
  136. package/dist/commands/template-upload.js.map +1 -1
  137. package/dist/types/config.d.ts +41 -5
  138. package/dist/types/config.d.ts.map +1 -1
  139. package/dist/types/config.js +9 -2
  140. package/dist/types/config.js.map +1 -1
  141. package/dist/types/types.js +2 -2
  142. package/dist/types/types.js.map +1 -1
  143. package/dist/utils/analyze-command.d.ts +42 -0
  144. package/dist/utils/analyze-command.d.ts.map +1 -0
  145. package/dist/utils/analyze-command.js +606 -0
  146. package/dist/utils/analyze-command.js.map +1 -0
  147. package/dist/utils/analyze-status.d.ts +7 -0
  148. package/dist/utils/analyze-status.d.ts.map +1 -0
  149. package/dist/utils/analyze-status.js +94 -0
  150. package/dist/utils/analyze-status.js.map +1 -0
  151. package/dist/utils/config.service.d.ts +1 -2
  152. package/dist/utils/config.service.d.ts.map +1 -1
  153. package/dist/utils/config.service.js +5 -7
  154. package/dist/utils/config.service.js.map +1 -1
  155. package/dist/utils/discover.d.ts +2 -2
  156. package/dist/utils/discover.d.ts.map +1 -1
  157. package/dist/utils/discover.js +25 -23
  158. package/dist/utils/discover.js.map +1 -1
  159. package/dist/utils/figma-tokens-data-loader.js +2 -2
  160. package/dist/utils/figma-tokens-data-loader.js.map +1 -1
  161. package/dist/utils/http-client.d.ts +4 -0
  162. package/dist/utils/http-client.d.ts.map +1 -0
  163. package/dist/utils/http-client.js +18 -0
  164. package/dist/utils/http-client.js.map +1 -0
  165. package/dist/utils/run-exporter/exporter-utils.js +2 -2
  166. package/dist/utils/run-exporter/exporter-utils.js.map +1 -1
  167. package/dist/utils/validate-templates.d.ts +1 -1
  168. package/dist/utils/validate-templates.d.ts.map +1 -1
  169. package/dist/utils/validate-templates.js +4 -4
  170. package/dist/utils/validate-templates.js.map +1 -1
  171. package/oclif.manifest.json +216 -1
  172. package/package.json +12 -4
@@ -1 +1 @@
1
- {"version":3,"file":"discover.js","sources":["../../src/utils/discover.ts"],"sourceRoot":"","sourcesContent":["import fs from \"node:fs\"\nimport path from \"node:path\"\n\ninterface TemplateInfo {\n name: string\n description: string\n thumbnail?: string\n files: string[]\n}\n\ninterface ItemsObject {\n [itemKey: string]: TemplateInfo\n}\n\n/**\n * Converts folder name to spaced title case\n * e.g., \"AppShell\" -> \"App Shell\", \"PortalFeatureDetail\" -> \"Portal Feature Detail\"\n */\nexport function folderNameToDisplayName(folderName: string): string {\n return folderName\n .replace(/[-_]/g, \" \") // kebab-case and snake_case → spaces\n .replace(/([A-Z])/g, \" $1\") // PascalCase/camelCase → spaces before uppercase\n .trim()\n .replace(/\\s+/g, \" \") // normalize multiple spaces\n .replace(/\\b\\w/g, c => c.toUpperCase()) // capitalize each word\n}\n\n/**\n * Recursively get all files in a directory relative to that directory\n */\nfunction getAllFilesInDirectory(dirPath: string, relativeTo: string): string[] {\n return fs\n .readdirSync(dirPath, { recursive: true, withFileTypes: true })\n .filter(entry => entry.isFile() && entry.name !== \"README.md\")\n .map(entry => path.relative(relativeTo, path.join(entry.parentPath || dirPath, entry.name)))\n .sort()\n}\n\n/**\n * Check for thumbnail files in a directory\n */\nfunction findThumbnail(templateDir: string): string | undefined {\n return [\".png\", \".svg\", \".jpg\", \".jpeg\"]\n .map(ext => `thumbnail${ext}`)\n .find(filename => fs.existsSync(path.join(templateDir, filename)))\n}\n\n/**\n * Parse description from a README.md file in any directory\n * Takes the first sentence after the first # heading\n *\n * @param readmeFilePath - Full path to README.md file\n * @returns string - The description or empty string if not found\n */\nfunction parseDescriptionFromReadme(readmeFilePath: string): string {\n if (!fs.existsSync(readmeFilePath)) return \"\"\n\n try {\n const content = fs.readFileSync(readmeFilePath, \"utf8\")\n\n // Find first paragraph after first # heading\n const match = content.match(/^#[^\\n]*\\n+([^\\n#]+)/m)\n if (!match) return \"\"\n\n let description = match[1].trim()\n\n // Clean up the description\n description = description.replace(/\\*\\*/g, \"\").replace(/\\*/g, \"\") // Remove markdown formatting\n description = description.charAt(0).toUpperCase() + description.slice(1) // Ensure capital letter\n\n // Ensure it ends with period if it doesn't already\n if (!description.endsWith(\".\") && !description.endsWith(\"!\") && !description.endsWith(\"?\")) {\n description += \".\"\n }\n\n return description\n } catch (error) {\n return \"\"\n }\n}\n\n/**\n * Parse TypeScript/TSX files for import statements and extract file dependencies\n * @param filePath - Path to .ts/.tsx file\n * @param baseDir - Base directory for resolving relative imports\n * @returns string[] - Array of imported file paths (resolved to project root)\n */\nfunction parseImportsFromTSFile(filePath: string, baseDir: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n try {\n const content = fs.readFileSync(filePath, \"utf8\")\n const dependencies: string[] = []\n\n // Regex to match import statements\n const importRegex = /import\\s+(?:[\\w*{}\\s,]+\\s+from\\s+)?['\"`]([^'\"`]+)['\"`]/g\n\n let match\n while ((match = importRegex.exec(content)) !== null) {\n const importPath = match[1]\n\n // Only process relative imports (starting with ./ or ../)\n if (importPath.startsWith(\"./\") || importPath.startsWith(\"../\")) {\n try {\n // Resolve relative to the file's directory\n const fileDir = path.dirname(filePath)\n const resolvedPath = path.resolve(fileDir, importPath)\n\n // Try common extensions if no extension provided\n const possiblePaths = [\n resolvedPath,\n resolvedPath + \".tsx\",\n resolvedPath + \".ts\",\n resolvedPath + \".json\",\n resolvedPath + \".js\",\n ]\n\n const actualPath = possiblePaths.find(p => fs.existsSync(p))\n\n if (actualPath) {\n // Convert to path relative to container root\n const containerRoot = path.resolve(baseDir, \"../../..\")\n const relativePath = path.relative(containerRoot, actualPath).replace(/\\\\/g, \"/\")\n\n // Only include files within the supernova directory\n if (relativePath.startsWith(\"supernova/\")) {\n dependencies.push(relativePath)\n }\n }\n } catch (error) {\n // Skip invalid import paths\n }\n }\n }\n\n return dependencies\n } catch (error) {\n return []\n }\n}\n\n/**\n * Parse all TypeScript/TSX files in a directory for import dependencies\n * @param itemDir - Directory containing the template/pattern\n * @returns string[] - Array of all imported file paths from all TS/TSX files\n */\nfunction parseImportsFromDirectory(itemDir: string): string[] {\n const dependencies = new Set<string>()\n\n try {\n const entries = fs.readdirSync(itemDir, { recursive: true, withFileTypes: true })\n\n for (const entry of entries) {\n if (entry.isFile()) {\n const ext = path.extname(entry.name).toLowerCase()\n if (ext === \".ts\" || ext === \".tsx\") {\n const fullPath = path.join(entry.parentPath || itemDir, entry.name)\n const fileDeps = parseImportsFromTSFile(fullPath, itemDir)\n fileDeps.forEach(dep => dependencies.add(dep))\n }\n }\n }\n } catch (error) {\n // Skip directories that can't be read\n }\n\n return Array.from(dependencies).sort()\n}\n\n/**\n * Parse main directory README.md for table-based descriptions\n * Extracts description from markdown table like:\n * | Pattern | Description |\n * | PromptEditor | Tiptap rich text editor |\n */\nfunction parseMainReadmeTable(mainReadmePath: string, itemKey: string): string | null {\n if (!fs.existsSync(mainReadmePath)) return null\n\n try {\n const content = fs.readFileSync(mainReadmePath, \"utf8\")\n\n // Find table that contains Pattern or Template header\n const tableMatch = content.match(/(\\|\\s*(?:Pattern|Template)\\s*\\|[^\\n]*)\\n\\|[-\\s|]*\\n((?:\\|[^\\n]*\\n)*)/i)\n if (!tableMatch) return null\n\n // Parse header to get column indices\n const headerCells = tableMatch[1]\n .split(\"|\")\n .map(cell => cell.trim())\n .filter(cell => cell)\n const nameIndex = headerCells.findIndex(cell => /^(Pattern|Template)$/i.test(cell))\n const descIndex = headerCells.findIndex(cell => /^Description$/i.test(cell))\n\n if (nameIndex === -1 || descIndex === -1) return null\n\n // Parse table rows\n const rows = tableMatch[2].split(\"\\n\").filter(row => row.trim())\n\n for (const row of rows) {\n const cells = row\n .split(\"|\")\n .map(cell => cell.trim())\n .filter(cell => cell)\n\n if (cells.length > Math.max(nameIndex, descIndex)) {\n const name = cells[nameIndex]?.replace(/\\[([^\\]]+)\\].*/, \"$1\") // Remove markdown link syntax\n const description = cells[descIndex]\n\n if (name === itemKey) {\n return description.endsWith(\".\") ? description : description + \".\"\n }\n }\n }\n } catch (error) {\n // If error reading file, return null\n }\n\n return null\n}\n\n/**\n * Extract description from README.md file\n * Priority: 1) Individual README, 2) Main directory table, 3) Fallback\n */\nfunction extractDescriptionFromReadme(\n itemDir: string,\n fallbackName: string,\n itemKey: string,\n subdirectory: \"templates\" | \"patterns\",\n): string {\n // Try individual README first (highest priority)\n const itemReadmePath = path.join(itemDir, \"README.md\")\n const individualDescription = parseDescriptionFromReadme(itemReadmePath)\n if (individualDescription) {\n return individualDescription\n }\n\n // Try main directory table second\n const containerRoot = path.resolve(itemDir, \"../../..\")\n const mainReadmePath = path.join(containerRoot, \"supernova\", subdirectory, \"README.md\")\n const tableDescription = parseMainReadmeTable(mainReadmePath, itemKey)\n if (tableDescription) {\n return tableDescription\n }\n\n // Fall back to default\n return `Use this to prototype similar to ${fallbackName}`\n}\n\n/**\n * Read package.json and return parsed content\n */\nfunction readPackageJson(basePath: string): any {\n const packageJsonPath = path.join(basePath, \"package.json\")\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(`package.json not found at ${packageJsonPath}`)\n }\n\n const content = fs.readFileSync(packageJsonPath, \"utf8\")\n return JSON.parse(content)\n}\n\n/**\n * Write package.json with proper formatting\n */\nfunction writePackageJson(basePath: string, packageData: any): void {\n const packageJsonPath = path.join(basePath, \"package.json\")\n const content = JSON.stringify(packageData, null, 2) + \"\\n\"\n fs.writeFileSync(packageJsonPath, content, \"utf8\")\n}\n\n/**\n * Discovers items in a supernova subdirectory and returns metadata object\n *\n * @param basePath - Base directory path (defaults to current working directory)\n * @param subdirectory - Subdirectory name ('templates' or 'patterns')\n * @returns ItemsObject - Object with item metadata\n */\nfunction discoverItems(basePath: string, subdirectory: \"templates\" | \"patterns\"): ItemsObject {\n const resolvedBasePath = basePath || process.cwd()\n const itemsDir = path.join(resolvedBasePath, \"supernova\", subdirectory)\n\n // Check if directory exists\n if (!fs.existsSync(itemsDir)) {\n throw new Error(`${subdirectory} directory not found at ${itemsDir}`)\n }\n\n const items: ItemsObject = {}\n\n // Read all entries in directory\n const entries = fs.readdirSync(itemsDir, { withFileTypes: true })\n\n for (const entry of entries) {\n // Skip non-directories and README files\n if (!entry.isDirectory() || entry.name === \"README.md\") {\n continue\n }\n\n const itemKey = entry.name\n const itemDir = path.join(itemsDir, itemKey)\n\n // Generate display name\n const displayName = folderNameToDisplayName(itemKey)\n\n // Extract description from README.md\n const description = extractDescriptionFromReadme(itemDir, displayName, itemKey, subdirectory)\n\n // Find thumbnail\n const thumbnail = findThumbnail(itemDir)\n\n // Get all files in item directory with full paths\n const files = getAllFilesInDirectory(itemDir, itemDir)\n const containerRoot = path.resolve(itemDir, \"../../..\") // This goes from supernova/templates/X to container root\n const itemRelativePath = path.relative(containerRoot, itemDir).replace(/\\\\/g, \"/\")\n const fullPathFiles = files.map(file => `${itemRelativePath}/${file}`)\n\n // Parse dependencies from TypeScript/TSX import statements\n const importDependencies = parseImportsFromDirectory(itemDir)\n\n // Combine both sources of dependencies\n const allDependencies = [...new Set([...importDependencies])]\n\n // Filter out dependencies that are within the same item directory\n const itemBasePath = itemRelativePath\n const externalDependencies = allDependencies.filter(dep => !dep.startsWith(itemBasePath + \"/\"))\n\n // Validate that external dependencies exist in the filesystem\n const validExternalDependencies = externalDependencies.filter(dep => {\n const fullPath = path.join(containerRoot, dep)\n const exists = fs.existsSync(fullPath)\n if (!exists) {\n console.warn(`Warning: Dependency not found: ${dep} (expected at ${fullPath})`)\n }\n return exists\n })\n\n // Combine files and valid dependencies, remove duplicates\n const allFiles = new Set([...fullPathFiles, ...validExternalDependencies])\n // Remove README.md files and thumbnail files from the combined list\n const filteredFiles = Array.from(allFiles).filter(\n file =>\n !file.endsWith(\"README.md\") &&\n ![\"/thumbnail.png\", \"/thumbnail.svg\", \"/thumbnail.jpg\", \"/thumbnail.jpeg\"].some(ext => file.endsWith(ext)),\n )\n\n // Validate that all files exist in the filesystem\n const existingFiles = filteredFiles\n .filter(file => {\n const fullPath = path.join(containerRoot, file)\n const exists = fs.existsSync(fullPath)\n if (!exists) {\n console.warn(`Warning: File not found: ${file} (expected at ${fullPath})`)\n }\n return exists\n })\n .sort()\n\n // Build item info object\n const itemInfo: TemplateInfo = {\n name: displayName,\n description,\n files: existingFiles,\n }\n\n // Only add thumbnail property if it exists (with full path)\n if (thumbnail) {\n itemInfo.thumbnail = `${itemRelativePath}/${thumbnail}`\n }\n\n items[itemKey] = itemInfo\n }\n\n return items\n}\n\n/**\n * Discovers templates in supernova/templates directory and returns metadata object\n *\n * @param basePath - Base directory path (defaults to current working directory)\n * @returns ItemsObject - Object with template metadata\n */\nfunction discoverTemplates(basePath?: string): ItemsObject {\n const resolvedBasePath = basePath || process.cwd()\n return discoverItems(resolvedBasePath, \"templates\")\n}\n\n/**\n * Discovers patterns in supernova/patterns directory and returns metadata object\n *\n * @param basePath - Base directory path (defaults to current working directory)\n * @returns ItemsObject - Object with pattern metadata\n */\nfunction discoverPatterns(basePath?: string): ItemsObject {\n const resolvedBasePath = basePath || process.cwd()\n return discoverItems(resolvedBasePath, \"patterns\")\n}\n\n/**\n * Resolve transitive dependencies for templates/patterns\n * If Template A imports Pattern B, and Pattern B imports Pattern C,\n * then Template A should include files from both Pattern B and Pattern C\n */\nfunction resolveTransitiveDependencies(items: ItemsObject, patterns: ItemsObject, basePath: string): ItemsObject {\n const resolvedItems: ItemsObject = {}\n\n for (const [itemKey, itemInfo] of Object.entries(items)) {\n const resolvedFiles = new Set([...itemInfo.files])\n\n // Find which patterns this item depends on\n const dependentPatterns = new Set<string>()\n\n // Check direct dependencies by looking at file paths\n for (const file of itemInfo.files) {\n const pathMatch = file.match(/^supernova\\/patterns\\/([^\\/]+)\\//)\n if (pathMatch) {\n dependentPatterns.add(pathMatch[1])\n }\n }\n\n // Recursively resolve transitive dependencies\n function addTransitiveDependencies(patternKey: string, visited = new Set<string>()) {\n if (visited.has(patternKey)) {\n return // Avoid circular dependencies\n }\n visited.add(patternKey)\n\n const pattern = patterns[patternKey]\n if (!pattern) {\n return\n }\n\n // Add all files from this pattern\n pattern.files.forEach(file => resolvedFiles.add(file))\n\n // Find what patterns this pattern depends on\n for (const file of pattern.files) {\n const pathMatch = file.match(/^supernova\\/patterns\\/([^\\/]+)\\//)\n if (pathMatch && pathMatch[1] !== patternKey) {\n // Recursively add transitive dependencies\n addTransitiveDependencies(pathMatch[1], new Set(visited))\n }\n }\n }\n\n // Resolve transitive dependencies for each direct dependency\n for (const patternKey of dependentPatterns) {\n addTransitiveDependencies(patternKey)\n }\n\n // Validate all resolved files exist\n const containerRoot = path.resolve(basePath)\n const validFiles = Array.from(resolvedFiles)\n .filter(file => {\n const fullPath = path.join(containerRoot, file)\n const exists = fs.existsSync(fullPath)\n if (!exists) {\n console.warn(`Warning: Transitive dependency not found: ${file} (expected at ${fullPath})`)\n }\n return exists\n })\n .sort()\n\n resolvedItems[itemKey] = {\n ...itemInfo,\n files: validFiles,\n }\n }\n\n return resolvedItems\n}\n\n/**\n * Discovers templates and patterns, then updates package.json with the results\n *\n * @param basePath - Base directory path (defaults to current working directory)\n * @returns Promise<{templates: ItemsObject, patterns: ItemsObject}> - Object with template and pattern metadata\n */\n\nexport async function discoverTemplatesAndPatterns(\n basePath?: string,\n): Promise<{ templates: ItemsObject; patterns: ItemsObject }> {\n const resolvedBasePath = basePath || process.cwd()\n\n // First discover templates and patterns independently\n const rawTemplates = discoverTemplates(resolvedBasePath)\n const rawPatterns = discoverPatterns(resolvedBasePath)\n\n // Resolve transitive dependencies for templates\n const templates = resolveTransitiveDependencies(rawTemplates, rawPatterns, resolvedBasePath)\n\n // Resolve transitive dependencies for patterns (in case patterns depend on other patterns)\n const patterns = resolveTransitiveDependencies(rawPatterns, rawPatterns, resolvedBasePath)\n\n return { templates, patterns }\n}\n\nexport async function discoverFilesForTemplates(\n pkgTemplates: Record<string, Pick<TemplateInfo, \"name\" | \"description\">>,\n basePath?: string,\n): Promise<ItemsObject> {\n const { templates } = await discoverTemplatesAndPatterns(basePath)\n return Object.fromEntries(\n Object.entries(pkgTemplates).map(([key, pkgTemplate]) => [key, { ...templates[key], ...pkgTemplate }]),\n )\n}\n\nexport async function discoverAndUpdatePackageJson(\n basePath?: string,\n): Promise<{ templates: ItemsObject; patterns: ItemsObject }> {\n const result = await discoverTemplatesAndPatterns(basePath)\n const resolvedBasePath = basePath || process.cwd()\n\n // Read current package.json\n const packageData = readPackageJson(resolvedBasePath)\n\n // Ensure supernova object exists\n if (!packageData.supernova) {\n packageData.supernova = {}\n }\n\n // Only persist name and description — files and thumbnail are always re-discovered at upload time\n packageData.supernova.templates = Object.fromEntries(\n Object.entries(result.templates).map(([key, { name, description }]) => [key, { name, description }]),\n )\n\n // Write back to package.json\n writePackageJson(resolvedBasePath, packageData)\n\n return result\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAiB5B,MAAM,UAAU,uBAAuB,CAAC,UAAkB;IACxD,OAAO,UAAU;SACd,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,IAAI,EAAE;SACN,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AAC3C,CAAC;AAKD,SAAS,sBAAsB,CAAC,OAAe,EAAE,UAAkB;IACjE,OAAO,EAAE;S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ts"],"sourceRoot":"","sourcesContent":["import fs from \"node:fs\"\nimport path from \"node:path\"\n\ninterface TemplateInfo {\n description: string\n files: string[]\n name: string\n thumbnail?: string\n}\n\ninterface ItemsObject {\n [itemKey: string]: TemplateInfo\n}\n\n/**\n * Converts folder name to spaced title case\n * e.g., \"AppShell\" -> \"App Shell\", \"PortalFeatureDetail\" -> \"Portal Feature Detail\"\n */\nexport function folderNameToDisplayName(folderName: string): string {\n return folderName\n .replaceAll(/[-_]/g, \" \") // kebab-case and snake_case → spaces\n .replaceAll(/([A-Z])/g, \" $1\") // PascalCase/camelCase → spaces before uppercase\n .trim()\n .replaceAll(/\\s+/g, \" \") // normalize multiple spaces\n .replaceAll(/\\b\\w/g, c => c.toUpperCase()) // capitalize each word\n}\n\n/**\n * Recursively get all files in a directory relative to that directory\n */\nfunction getAllFilesInDirectory(dirPath: string, relativeTo: string): string[] {\n return fs\n .readdirSync(dirPath, { recursive: true, withFileTypes: true })\n .filter(entry => entry.isFile() && entry.name !== \"README.md\")\n .map(entry => path.relative(relativeTo, path.join(entry.parentPath || dirPath, entry.name)))\n .sort()\n}\n\n/**\n * Check for thumbnail files in a directory\n */\nfunction findThumbnail(templateDir: string): string | undefined {\n return [\".png\", \".svg\", \".jpg\", \".jpeg\"]\n .map(ext => `thumbnail${ext}`)\n .find(filename => fs.existsSync(path.join(templateDir, filename)))\n}\n\n/**\n * Parse description from a README.md file in any directory\n * Takes the first sentence after the first # heading\n *\n * @param readmeFilePath - Full path to README.md file\n * @returns string - The description or empty string if not found\n */\nfunction parseDescriptionFromReadme(readmeFilePath: string): string {\n if (!fs.existsSync(readmeFilePath)) return \"\"\n\n try {\n const content = fs.readFileSync(readmeFilePath, \"utf8\")\n\n // Find first paragraph after first # heading\n const match = content.match(/^#[^\\n]*\\n+([^\\n#]+)/m)\n if (!match) return \"\"\n\n let description = match[1].trim()\n\n // Clean up the description\n description = description.replaceAll('**', \"\").replaceAll('*', \"\") // Remove markdown formatting\n description = description.charAt(0).toUpperCase() + description.slice(1) // Ensure capital letter\n\n // Ensure it ends with period if it doesn't already\n if (!description.endsWith(\".\") && !description.endsWith(\"!\") && !description.endsWith(\"?\")) {\n description += \".\"\n }\n\n return description\n } catch {\n return \"\"\n }\n}\n\n/**\n * Parse TypeScript/TSX files for import statements and extract file dependencies\n * @param filePath - Path to .ts/.tsx file\n * @param baseDir - Base directory for resolving relative imports\n * @returns string[] - Array of imported file paths (resolved to project root)\n */\nfunction parseImportsFromTSFile(filePath: string, baseDir: string): string[] {\n if (!fs.existsSync(filePath)) return []\n\n try {\n const content = fs.readFileSync(filePath, \"utf8\")\n const dependencies: string[] = []\n\n // Regex to match import statements\n const importRegex = /import\\s+(?:[\\w*{}\\s,]+\\s+from\\s+)?['\"`]([^'\"`]+)['\"`]/g\n\n let match\n while ((match = importRegex.exec(content)) !== null) {\n const importPath = match[1]\n\n // Only process relative imports (starting with ./ or ../)\n if (importPath.startsWith(\"./\") || importPath.startsWith(\"../\")) {\n try {\n // Resolve relative to the file's directory\n const fileDir = path.dirname(filePath)\n const resolvedPath = path.resolve(fileDir, importPath)\n\n // Try common extensions if no extension provided\n const possiblePaths = [\n resolvedPath,\n resolvedPath + \".tsx\",\n resolvedPath + \".ts\",\n resolvedPath + \".json\",\n resolvedPath + \".js\",\n ]\n\n const actualPath = possiblePaths.find(p => fs.existsSync(p))\n\n if (actualPath) {\n // Convert to path relative to container root\n const containerRoot = path.resolve(baseDir, \"../../..\")\n const relativePath = path.relative(containerRoot, actualPath).replaceAll('\\\\', \"/\")\n\n // Only include files within the supernova directory\n if (relativePath.startsWith(\"supernova/\")) {\n dependencies.push(relativePath)\n }\n }\n } catch {\n // Skip invalid import paths\n }\n }\n }\n\n return dependencies\n } catch {\n return []\n }\n}\n\n/**\n * Parse all TypeScript/TSX files in a directory for import dependencies\n * @param itemDir - Directory containing the template/pattern\n * @returns string[] - Array of all imported file paths from all TS/TSX files\n */\nfunction parseImportsFromDirectory(itemDir: string): string[] {\n const dependencies = new Set<string>()\n\n try {\n const entries = fs.readdirSync(itemDir, { recursive: true, withFileTypes: true })\n\n for (const entry of entries) {\n if (entry.isFile()) {\n const ext = path.extname(entry.name).toLowerCase()\n if (ext === \".ts\" || ext === \".tsx\") {\n const fullPath = path.join(entry.parentPath || itemDir, entry.name)\n const fileDeps = parseImportsFromTSFile(fullPath, itemDir)\n for (const dep of fileDeps) dependencies.add(dep)\n }\n }\n }\n } catch {\n // Skip directories that can't be read\n }\n\n return [...dependencies].sort()\n}\n\n/**\n * Parse main directory README.md for table-based descriptions\n * Extracts description from markdown table like:\n * | Pattern | Description |\n * | PromptEditor | Tiptap rich text editor |\n */\nfunction parseMainReadmeTable(mainReadmePath: string, itemKey: string): string | null {\n if (!fs.existsSync(mainReadmePath)) return null\n\n try {\n const content = fs.readFileSync(mainReadmePath, \"utf8\")\n\n // Find table that contains Pattern or Template header\n const tableMatch = content.match(/(\\|\\s*(?:Pattern|Template)\\s*\\|[^\\n]*)\\n\\|[-\\s|]*\\n((?:\\|[^\\n]*\\n)*)/i)\n if (!tableMatch) return null\n\n // Parse header to get column indices\n const headerCells = tableMatch[1]\n .split(\"|\")\n .map(cell => cell.trim())\n .filter(Boolean)\n const nameIndex = headerCells.findIndex(cell => /^(Pattern|Template)$/i.test(cell))\n const descIndex = headerCells.findIndex(cell => /^Description$/i.test(cell))\n\n if (nameIndex === -1 || descIndex === -1) return null\n\n // Parse table rows\n const rows = tableMatch[2].split(\"\\n\").filter(row => row.trim())\n\n for (const row of rows) {\n const cells = row\n .split(\"|\")\n .map(cell => cell.trim())\n .filter(Boolean)\n\n if (cells.length > Math.max(nameIndex, descIndex)) {\n const name = cells[nameIndex]?.replace(/\\[([^\\]]+)\\].*/, \"$1\") // Remove markdown link syntax\n const description = cells[descIndex]\n\n if (name === itemKey) {\n return description.endsWith(\".\") ? description : description + \".\"\n }\n }\n }\n } catch {\n // If error reading file, return null\n }\n\n return null\n}\n\n/**\n * Extract description from README.md file\n * Priority: 1) Individual README, 2) Main directory table, 3) Fallback\n */\nfunction extractDescriptionFromReadme(\n itemDir: string,\n fallbackName: string,\n itemKey: string,\n subdirectory: \"templates\" | \"patterns\",\n): string {\n // Try individual README first (highest priority)\n const itemReadmePath = path.join(itemDir, \"README.md\")\n const individualDescription = parseDescriptionFromReadme(itemReadmePath)\n if (individualDescription) {\n return individualDescription\n }\n\n // Try main directory table second\n const containerRoot = path.resolve(itemDir, \"../../..\")\n const mainReadmePath = path.join(containerRoot, \"supernova\", subdirectory, \"README.md\")\n const tableDescription = parseMainReadmeTable(mainReadmePath, itemKey)\n if (tableDescription) {\n return tableDescription\n }\n\n // Fall back to default\n return `Use this to prototype similar to ${fallbackName}`\n}\n\n/**\n * Read package.json and return parsed content\n */\nfunction readPackageJson(basePath: string): any {\n const packageJsonPath = path.join(basePath, \"package.json\")\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(`package.json not found at ${packageJsonPath}`)\n }\n\n const content = fs.readFileSync(packageJsonPath, \"utf8\")\n return JSON.parse(content)\n}\n\n/**\n * Write package.json with proper formatting\n */\nfunction writePackageJson(basePath: string, packageData: any): void {\n const packageJsonPath = path.join(basePath, \"package.json\")\n const content = JSON.stringify(packageData, null, 2) + \"\\n\"\n fs.writeFileSync(packageJsonPath, content, \"utf8\")\n}\n\n/**\n * Discovers items in a supernova subdirectory and returns metadata object\n *\n * @param basePath - Base directory path (defaults to current working directory)\n * @param subdirectory - Subdirectory name ('templates' or 'patterns')\n * @returns ItemsObject - Object with item metadata\n */\nfunction discoverItems(basePath: string, subdirectory: \"templates\" | \"patterns\"): ItemsObject {\n const resolvedBasePath = basePath || process.cwd()\n const itemsDir = path.join(resolvedBasePath, \"supernova\", subdirectory)\n\n // Check if directory exists\n if (!fs.existsSync(itemsDir)) {\n throw new Error(`${subdirectory} directory not found at ${itemsDir}`)\n }\n\n const items: ItemsObject = {}\n\n // Read all entries in directory\n const entries = fs.readdirSync(itemsDir, { withFileTypes: true })\n\n for (const entry of entries) {\n // Skip non-directories and README files\n if (!entry.isDirectory() || entry.name === \"README.md\") {\n continue\n }\n\n const itemKey = entry.name\n const itemDir = path.join(itemsDir, itemKey)\n\n // Generate display name\n const displayName = folderNameToDisplayName(itemKey)\n\n // Extract description from README.md\n const description = extractDescriptionFromReadme(itemDir, displayName, itemKey, subdirectory)\n\n // Find thumbnail\n const thumbnail = findThumbnail(itemDir)\n\n // Get all files in item directory with full paths\n const files = getAllFilesInDirectory(itemDir, itemDir)\n const containerRoot = path.resolve(itemDir, \"../../..\") // This goes from supernova/templates/X to container root\n const itemRelativePath = path.relative(containerRoot, itemDir).replaceAll('\\\\', \"/\")\n const fullPathFiles = files.map(file => `${itemRelativePath}/${file}`)\n\n // Parse dependencies from TypeScript/TSX import statements\n const importDependencies = parseImportsFromDirectory(itemDir)\n\n // Combine both sources of dependencies\n const allDependencies = [...new Set(importDependencies)]\n\n // Filter out dependencies that are within the same item directory\n const itemBasePath = itemRelativePath\n const externalDependencies = allDependencies.filter(dep => !dep.startsWith(itemBasePath + \"/\"))\n\n // Validate that external dependencies exist in the filesystem\n const validExternalDependencies = externalDependencies.filter(dep => {\n const fullPath = path.join(containerRoot, dep)\n const exists = fs.existsSync(fullPath)\n if (!exists) {\n console.warn(`Warning: Dependency not found: ${dep} (expected at ${fullPath})`)\n }\n\n return exists\n })\n\n // Combine files and valid dependencies, remove duplicates\n const allFiles = new Set([...fullPathFiles, ...validExternalDependencies])\n // Remove README.md files and thumbnail files from the combined list\n const filteredFiles = [...allFiles].filter(\n file =>\n !file.endsWith(\"README.md\") &&\n ![\"/thumbnail.png\", \"/thumbnail.svg\", \"/thumbnail.jpg\", \"/thumbnail.jpeg\"].some(ext => file.endsWith(ext)),\n )\n\n // Validate that all files exist in the filesystem\n const existingFiles = filteredFiles\n .filter(file => {\n const fullPath = path.join(containerRoot, file)\n const exists = fs.existsSync(fullPath)\n if (!exists) {\n console.warn(`Warning: File not found: ${file} (expected at ${fullPath})`)\n }\n\n return exists\n })\n .sort()\n\n // Build item info object\n const itemInfo: TemplateInfo = {\n name: displayName,\n description,\n files: existingFiles,\n }\n\n // Only add thumbnail property if it exists (with full path)\n if (thumbnail) {\n itemInfo.thumbnail = `${itemRelativePath}/${thumbnail}`\n }\n\n items[itemKey] = itemInfo\n }\n\n return items\n}\n\n/**\n * Discovers templates in supernova/templates directory and returns metadata object\n *\n * @param basePath - Base directory path (defaults to current working directory)\n * @returns ItemsObject - Object with template metadata\n */\nfunction discoverTemplates(basePath?: string): ItemsObject {\n const resolvedBasePath = basePath || process.cwd()\n return discoverItems(resolvedBasePath, \"templates\")\n}\n\n/**\n * Discovers patterns in supernova/patterns directory and returns metadata object\n *\n * @param basePath - Base directory path (defaults to current working directory)\n * @returns ItemsObject - Object with pattern metadata\n */\nfunction discoverPatterns(basePath?: string): ItemsObject {\n const resolvedBasePath = basePath || process.cwd()\n return discoverItems(resolvedBasePath, \"patterns\")\n}\n\n/**\n * Resolve transitive dependencies for templates/patterns\n * If Template A imports Pattern B, and Pattern B imports Pattern C,\n * then Template A should include files from both Pattern B and Pattern C\n */\nfunction resolveTransitiveDependencies(items: ItemsObject, patterns: ItemsObject, basePath: string): ItemsObject {\n const resolvedItems: ItemsObject = {}\n\n for (const [itemKey, itemInfo] of Object.entries(items)) {\n const resolvedFiles = new Set(itemInfo.files)\n\n // Find which patterns this item depends on\n const dependentPatterns = new Set<string>()\n\n // Check direct dependencies by looking at file paths\n for (const file of itemInfo.files) {\n const pathMatch = file.match(/^supernova\\/patterns\\/([^\\/]+)\\//)\n if (pathMatch) {\n dependentPatterns.add(pathMatch[1])\n }\n }\n\n // Recursively resolve transitive dependencies\n function addTransitiveDependencies(patternKey: string, visited = new Set<string>()) {\n if (visited.has(patternKey)) {\n return // Avoid circular dependencies\n }\n\n visited.add(patternKey)\n\n const pattern = patterns[patternKey]\n if (!pattern) {\n return\n }\n\n // Add all files from this pattern\n for (const file of pattern.files) resolvedFiles.add(file)\n\n // Find what patterns this pattern depends on\n for (const file of pattern.files) {\n const pathMatch = file.match(/^supernova\\/patterns\\/([^\\/]+)\\//)\n if (pathMatch && pathMatch[1] !== patternKey) {\n // Recursively add transitive dependencies\n addTransitiveDependencies(pathMatch[1], new Set(visited))\n }\n }\n }\n\n // Resolve transitive dependencies for each direct dependency\n for (const patternKey of dependentPatterns) {\n addTransitiveDependencies(patternKey)\n }\n\n // Validate all resolved files exist\n const containerRoot = path.resolve(basePath)\n const validFiles = [...resolvedFiles]\n .filter(file => {\n const fullPath = path.join(containerRoot, file)\n const exists = fs.existsSync(fullPath)\n if (!exists) {\n console.warn(`Warning: Transitive dependency not found: ${file} (expected at ${fullPath})`)\n }\n\n return exists\n })\n .sort()\n\n resolvedItems[itemKey] = {\n ...itemInfo,\n files: validFiles,\n }\n }\n\n return resolvedItems\n}\n\n/**\n * Discovers templates and patterns, then updates package.json with the results\n *\n * @param basePath - Base directory path (defaults to current working directory)\n * @returns Promise<{templates: ItemsObject, patterns: ItemsObject}> - Object with template and pattern metadata\n */\n\nexport async function discoverTemplatesAndPatterns(\n basePath?: string,\n): Promise<{ templates: ItemsObject; patterns: ItemsObject }> {\n const resolvedBasePath = basePath || process.cwd()\n\n // First discover templates and patterns independently\n const rawTemplates = discoverTemplates(resolvedBasePath)\n const rawPatterns = discoverPatterns(resolvedBasePath)\n\n // Resolve transitive dependencies for templates\n const templates = resolveTransitiveDependencies(rawTemplates, rawPatterns, resolvedBasePath)\n\n // Resolve transitive dependencies for patterns (in case patterns depend on other patterns)\n const patterns = resolveTransitiveDependencies(rawPatterns, rawPatterns, resolvedBasePath)\n\n return { templates, patterns }\n}\n\nexport async function discoverFilesForTemplates(\n pkgTemplates: Record<string, Pick<TemplateInfo, \"name\" | \"description\">>,\n basePath?: string,\n): Promise<ItemsObject> {\n const { templates } = await discoverTemplatesAndPatterns(basePath)\n return Object.fromEntries(\n Object.entries(pkgTemplates).map(([key, pkgTemplate]) => [key, { ...templates[key], ...pkgTemplate }]),\n )\n}\n\nexport async function discoverAndUpdatePackageJson(\n basePath?: string,\n): Promise<{ templates: ItemsObject; patterns: ItemsObject }> {\n const result = await discoverTemplatesAndPatterns(basePath)\n const resolvedBasePath = basePath || process.cwd()\n\n // Read current package.json\n const packageData = readPackageJson(resolvedBasePath)\n\n // Ensure supernova object exists\n if (!packageData.supernova) {\n packageData.supernova = {}\n }\n\n // Only persist name and description — files and thumbnail are always re-discovered at upload time\n packageData.supernova.templates = Object.fromEntries(\n Object.entries(result.templates).map(([key, { name, description }]) => [key, { name, description }]),\n )\n\n // Write back to package.json\n writePackageJson(resolvedBasePath, packageData)\n\n return result\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAiB5B,MAAM,UAAU,uBAAuB,CAAC,UAAkB;IACxD,OAAO,UAAU;SACd,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;SACxB,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC;SAC7B,IAAI,EAAE;SACN,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC;SACvB,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AAC9C,CAAC;AAKD,SAAS,sBAAsB,CAAC,OAAe,EAAE,UAAkB;IACjE,OAAO,EAAE;SACN,WAAW,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;SAC9D,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;SAC7D,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3F,IAAI,EAAE,CAAA;AACX,CAAC;A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AAG,eAAe,CAAC,gBAAgB,CAAC,CAAA;IAGrD,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;QAC3B,WAAW,CAAC,SAAS,GAAG,EAAE,CAAA;IAC5B,CAAC;IAGD,WAAW,CAAC,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAClD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CACrG,CAAA;IAGD,gBAAgB,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;IAE/C,OAAO,MAAM,CAAA;AACf,CAAC","debug_id":"8d01cf90-bafa-5c36-82b4-70b7a809ff77"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c05237d5-38a4-5f7c-aba5-dedba82a2d2e")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a5ca7936-f853-5cd2-8d62-a5367c6f068f")}catch(e){}}();
3
3
  import sdk from "@supernovaio/sdk";
4
4
  import * as fs from "node:fs";
5
5
  export class FigmaTokensDataLoader {
@@ -193,4 +193,4 @@ export class FigmaTokensDataLoader {
193
193
  }
194
194
  }
195
195
  //# sourceMappingURL=figma-tokens-data-loader.js.map
196
- //# debugId=c05237d5-38a4-5f7c-aba5-dedba82a2d2e
196
+ //# debugId=a5ca7936-f853-5cd2-8d62-a5367c6f068f
@@ -1 +1 @@
1
- {"version":3,"file":"figma-tokens-data-loader.js","sources":["../../src/utils/figma-tokens-data-loader.ts"],"sourceRoot":"","sourcesContent":["import sdk from \"@supernovaio/sdk\"\nimport * as fs from \"node:fs\"\n\nexport class FigmaTokensDataLoader {\n loadConfigFromPath(pathToFile: string): {\n mapping: sdk.DTPluginToSupernovaMapPack\n settings: sdk.DTPluginToSupernovaSettings\n } {\n try {\n const parsedDefinition = this.loadConfigFromPathAsIs(pathToFile) as sdk.DTPluginToSupernovaMappingFile\n this.weakValidateMapping(parsedDefinition)\n return this.processFileToMapping(parsedDefinition)\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n loadConfigFromPathAsIs(pathToFile: string): sdk.DTPluginToSupernovaMappingFile {\n try {\n if (!(fs.existsSync(pathToFile) && fs.lstatSync(pathToFile).isFile())) {\n throw new Error(`Provided configuration file directory ${pathToFile} is not a file or doesn't exist`)\n }\n\n const definition = fs.readFileSync(pathToFile, \"utf8\")\n const parsedDefinition = this.parseDefinition(definition) as sdk.DTPluginToSupernovaMappingFile\n return parsedDefinition\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n async loadTokensFromDirectory(pathToDirectory: string, settingsPath: string): Promise<object> {\n try {\n const fullStructuredObject: Record<string, unknown> = {}\n\n if (!(fs.existsSync(pathToDirectory) && fs.lstatSync(pathToDirectory).isDirectory())) {\n throw new Error(`Provided data directory ${pathToDirectory} is not a directory or doesn't exist`)\n }\n\n const jsonPaths = this.getAllJSONFiles(pathToDirectory)\n for (const path of jsonPaths) {\n if (path.endsWith(\"json\") && path !== settingsPath && !path.includes(\"$\")) {\n // eslint-disable-next-line no-await-in-loop\n const result = await this.loadObjectFile(path)\n if (typeof result === \"object\") {\n // let name = this.getFileNameWithoutExtension(path)\n const name = this.getSetKey(path, pathToDirectory)\n fullStructuredObject[name] = result\n }\n }\n }\n\n // Try to load themes, if any\n // eslint-disable-next-line no-useless-concat\n const themePath = pathToDirectory + \"/\" + \"$themes.json\"\n if (fs.existsSync(themePath)) {\n const themes = await this.loadObjectFile(themePath)\n fullStructuredObject.$themes = themes\n }\n\n // Try to load metadata, if any\n // eslint-disable-next-line no-useless-concat\n const metadataPath = pathToDirectory + \"/\" + \"$metadata.json\"\n if (fs.existsSync(metadataPath)) {\n const metadata = await this.loadObjectFile(metadataPath)\n fullStructuredObject.$metadata = metadata\n }\n\n return fullStructuredObject\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n /** Load token definitions from path */\n async loadTokensFromPath(pathToFile: string): Promise<object> {\n try {\n if (!(fs.existsSync(pathToFile) && fs.lstatSync(pathToFile).isFile())) {\n throw new Error(`Provided token file directory ${pathToFile} is not a file or doesn't exist`)\n }\n\n const definition = fs.readFileSync(pathToFile, \"utf8\")\n const parsedDefinition = this.parseDefinition(definition)\n return parsedDefinition\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n private getAllJSONFiles(dir: string): string[] {\n const files = fs.readdirSync(dir)\n const jsonFiles = []\n\n for (const file of files) {\n const filePath = `${dir}/${file}`\n const fileStat = fs.statSync(filePath)\n\n if (fileStat.isDirectory()) {\n jsonFiles.push(...this.getAllJSONFiles(filePath))\n } else if (fileStat.isFile() && filePath.endsWith(\".json\")) {\n jsonFiles.push(filePath)\n }\n }\n\n return jsonFiles\n }\n\n private getSetKey(jsonFilePath: string, loadedDirectory: string): string {\n return jsonFilePath.slice(loadedDirectory.length + 1, -5)\n }\n\n private async loadObjectFile(pathToFile: string): Promise<object> {\n try {\n if (!(fs.existsSync(pathToFile) && fs.lstatSync(pathToFile).isFile())) {\n throw new Error(`Provided token file directory ${pathToFile} is not a file or doesn't exist`)\n }\n\n const definition = fs.readFileSync(pathToFile, \"utf8\")\n const parsedDefinition = this.parseDefinition(definition)\n return parsedDefinition\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n private parseDefinition(definition: string): object {\n try {\n const object = JSON.parse(definition)\n if (typeof object !== \"object\") {\n throw new TypeError(\"Invalid Supernova mapping definition JSON file - root level entity must be object\")\n }\n\n return object\n } catch {\n throw new Error(\"Invalid Supernova mapping definition JSON file - file structure invalid\")\n }\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - File Parser\n\n private processFileToMapping(mapping: sdk.DTPluginToSupernovaMappingFile): {\n mapping: sdk.DTPluginToSupernovaMapPack\n settings: sdk.DTPluginToSupernovaSettings\n } {\n const result: sdk.DTPluginToSupernovaMap[] = []\n for (const map of mapping.mapping) {\n result.push({\n bindToBrand: map.supernovaBrand,\n bindToTheme: map.supernovaTheme ?? null,\n nodes: null,\n pluginSets: map.tokenSets ?? null,\n pluginTheme: map.tokensTheme ?? null,\n processedGroups: null,\n processedNodes: null,\n type: map.tokenSets ? sdk.DTPluginToSupernovaMapType.set : sdk.DTPluginToSupernovaMapType.theme,\n })\n }\n\n const settings: sdk.DTPluginToSupernovaSettings = {\n ...mapping.settings,\n dryRun: mapping.settings?.dryRun ?? false,\n preciseCopy: sdk.toPreciseCopyStrategy(mapping.settings?.preciseCopy),\n themeOverridesStrategy:\n mapping.settings?.themeOverridesStrategy ?? (\"default\" as sdk.DTPluginThemeOverrideStrategy),\n verbose: mapping.settings?.verbose ?? false,\n }\n\n return {\n mapping: result,\n settings,\n }\n }\n\n private weakValidateMapping(mapping: sdk.DTPluginToSupernovaMappingFile) {\n if (\n !Object.hasOwn(mapping, \"mode\") ||\n typeof mapping.mode !== \"string\" ||\n (mapping.mode !== \"multi-file\" && mapping.mode !== \"single-file\")\n ) {\n throw new Error(\"Unable to load mapping file: `mode` must be provided [single-file or multi-file]`\")\n }\n\n if (!mapping.mapping || !Array.isArray(mapping.mapping)) {\n throw new Error(\"Unable to load mapping file: `mapping` key must be present and array.\")\n }\n\n const mapPack = mapping.mapping\n for (const map of mapPack) {\n if (typeof map !== \"object\") {\n throw new TypeError(\"Unable to load mapping file: `mapping` must contain objects only\")\n }\n\n if (!map.tokenSets && !map.tokensTheme) {\n throw new Error(\"Unable to load mapping file: `mapping` must contain either `tokensTheme` or `tokenSets`\")\n }\n\n if (map.tokenSets && map.tokensTheme) {\n throw new Error(\"Unable to load mapping file: `mapping` must not contain both `tokensTheme` or `tokenSets`\")\n }\n\n if (map.tokenSets && (!Array.isArray(map.tokenSets) || (map.tokenSets as Array<unknown>).length === 0)) {\n throw new Error(\"Unable to load mapping file: `mapping`.`tokenSets` must be an Array with at least one entry\")\n }\n\n if (\n map.tokensTheme &&\n ((typeof map.tokensTheme !== \"string\" && !Array.isArray(map.tokensTheme)) || map.tokensTheme.length === 0)\n ) {\n throw new Error(\n \"Unable to load mapping file: `mapping`.`tokensTheme` must be a non-empty string or non-empty array of strings\",\n )\n }\n\n if (!map.supernovaBrand || typeof map.supernovaBrand !== \"string\" || map.supernovaBrand.length === 0) {\n throw new Error(\"Unable to load mapping file: `supernovaBrand` must be a non-empty string\")\n }\n\n if (map.supernovaTheme && (typeof map.supernovaTheme !== \"string\" || map.supernovaTheme.length === 0)) {\n throw new Error(\n \"Unable to load mapping file: `supernovaTheme` may be empty but must be non-empty string if not\",\n )\n }\n }\n\n if (mapping.settings) {\n if (typeof mapping.settings !== \"object\") {\n throw new TypeError(\"Unable to load mapping file: `settings` must be an object\")\n }\n\n if (Object.hasOwn(mapping.settings, \"dryRun\") && typeof mapping.settings.dryRun !== \"boolean\") {\n throw new Error(\"Unable to load mapping file: `dryRun` must be of boolean type\")\n }\n\n if (Object.hasOwn(mapping.settings, \"verbose\") && typeof mapping.settings.verbose !== \"boolean\") {\n throw new Error(\"Unable to load mapping file: `verbose` must be of boolean type\")\n }\n\n if (\n Object.hasOwn(mapping.settings, \"preciseCopy\") &&\n typeof mapping.settings.preciseCopy !== \"boolean\" &&\n typeof mapping.settings.preciseCopy !== \"string\"\n ) {\n throw new Error(\"Unable to load mapping file: `preci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,CAAC;IACH,CAAC;CACF","debug_id":"c05237d5-38a4-5f7c-aba5-dedba82a2d2e"}
1
+ {"version":3,"file":"figma-tokens-data-loader.js","sources":["../../src/utils/figma-tokens-data-loader.ts"],"sourceRoot":"","sourcesContent":["import sdk from \"@supernovaio/sdk\"\nimport * as fs from \"node:fs\"\n\nexport class FigmaTokensDataLoader {\n loadConfigFromPath(pathToFile: string): {\n mapping: sdk.DTPluginToSupernovaMapPack\n settings: sdk.DTPluginToSupernovaSettings\n } {\n try {\n const parsedDefinition = this.loadConfigFromPathAsIs(pathToFile) as sdk.DTPluginToSupernovaMappingFile\n this.weakValidateMapping(parsedDefinition)\n return this.processFileToMapping(parsedDefinition)\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n loadConfigFromPathAsIs(pathToFile: string): sdk.DTPluginToSupernovaMappingFile {\n try {\n if (!(fs.existsSync(pathToFile) && fs.lstatSync(pathToFile).isFile())) {\n throw new Error(`Provided configuration file directory ${pathToFile} is not a file or doesn't exist`)\n }\n\n const definition = fs.readFileSync(pathToFile, \"utf8\")\n const parsedDefinition = this.parseDefinition(definition) as sdk.DTPluginToSupernovaMappingFile\n return parsedDefinition\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n async loadTokensFromDirectory(pathToDirectory: string, settingsPath: string): Promise<object> {\n try {\n const fullStructuredObject: Record<string, unknown> = {}\n\n if (!(fs.existsSync(pathToDirectory) && fs.lstatSync(pathToDirectory).isDirectory())) {\n throw new Error(`Provided data directory ${pathToDirectory} is not a directory or doesn't exist`)\n }\n\n const jsonPaths = this.getAllJSONFiles(pathToDirectory)\n for (const path of jsonPaths) {\n if (path.endsWith(\"json\") && path !== settingsPath && !path.includes(\"$\")) {\n \n const result = await this.loadObjectFile(path)\n if (typeof result === \"object\") {\n // let name = this.getFileNameWithoutExtension(path)\n const name = this.getSetKey(path, pathToDirectory)\n fullStructuredObject[name] = result\n }\n }\n }\n\n // Try to load themes, if any\n // eslint-disable-next-line no-useless-concat\n const themePath = pathToDirectory + \"/\" + \"$themes.json\"\n if (fs.existsSync(themePath)) {\n const themes = await this.loadObjectFile(themePath)\n fullStructuredObject.$themes = themes\n }\n\n // Try to load metadata, if any\n // eslint-disable-next-line no-useless-concat\n const metadataPath = pathToDirectory + \"/\" + \"$metadata.json\"\n if (fs.existsSync(metadataPath)) {\n const metadata = await this.loadObjectFile(metadataPath)\n fullStructuredObject.$metadata = metadata\n }\n\n return fullStructuredObject\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n /** Load token definitions from path */\n async loadTokensFromPath(pathToFile: string): Promise<object> {\n try {\n if (!(fs.existsSync(pathToFile) && fs.lstatSync(pathToFile).isFile())) {\n throw new Error(`Provided token file directory ${pathToFile} is not a file or doesn't exist`)\n }\n\n const definition = fs.readFileSync(pathToFile, \"utf8\")\n const parsedDefinition = this.parseDefinition(definition)\n return parsedDefinition\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n private getAllJSONFiles(dir: string): string[] {\n const files = fs.readdirSync(dir)\n const jsonFiles = []\n\n for (const file of files) {\n const filePath = `${dir}/${file}`\n const fileStat = fs.statSync(filePath)\n\n if (fileStat.isDirectory()) {\n jsonFiles.push(...this.getAllJSONFiles(filePath))\n } else if (fileStat.isFile() && filePath.endsWith(\".json\")) {\n jsonFiles.push(filePath)\n }\n }\n\n return jsonFiles\n }\n\n private getSetKey(jsonFilePath: string, loadedDirectory: string): string {\n return jsonFilePath.slice(loadedDirectory.length + 1, -5)\n }\n\n private async loadObjectFile(pathToFile: string): Promise<object> {\n try {\n if (!(fs.existsSync(pathToFile) && fs.lstatSync(pathToFile).isFile())) {\n throw new Error(`Provided token file directory ${pathToFile} is not a file or doesn't exist`)\n }\n\n const definition = fs.readFileSync(pathToFile, \"utf8\")\n const parsedDefinition = this.parseDefinition(definition)\n return parsedDefinition\n } catch (error) {\n throw new Error(\"Unable to load JSON definition file: \" + error)\n }\n }\n\n private parseDefinition(definition: string): object {\n try {\n const object = JSON.parse(definition)\n if (typeof object !== \"object\") {\n throw new TypeError(\"Invalid Supernova mapping definition JSON file - root level entity must be object\")\n }\n\n return object\n } catch {\n throw new Error(\"Invalid Supernova mapping definition JSON file - file structure invalid\")\n }\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - File Parser\n\n private processFileToMapping(mapping: sdk.DTPluginToSupernovaMappingFile): {\n mapping: sdk.DTPluginToSupernovaMapPack\n settings: sdk.DTPluginToSupernovaSettings\n } {\n const result: sdk.DTPluginToSupernovaMap[] = []\n for (const map of mapping.mapping) {\n result.push({\n bindToBrand: map.supernovaBrand,\n bindToTheme: map.supernovaTheme ?? null,\n nodes: null,\n pluginSets: map.tokenSets ?? null,\n pluginTheme: map.tokensTheme ?? null,\n processedGroups: null,\n processedNodes: null,\n type: map.tokenSets ? sdk.DTPluginToSupernovaMapType.set : sdk.DTPluginToSupernovaMapType.theme,\n })\n }\n\n const settings: sdk.DTPluginToSupernovaSettings = {\n ...mapping.settings,\n dryRun: mapping.settings?.dryRun ?? false,\n preciseCopy: sdk.toPreciseCopyStrategy(mapping.settings?.preciseCopy),\n themeOverridesStrategy:\n mapping.settings?.themeOverridesStrategy ?? (\"default\" as sdk.DTPluginThemeOverrideStrategy),\n verbose: mapping.settings?.verbose ?? false,\n }\n\n return {\n mapping: result,\n settings,\n }\n }\n\n private weakValidateMapping(mapping: sdk.DTPluginToSupernovaMappingFile) {\n if (\n !Object.hasOwn(mapping, \"mode\") ||\n typeof mapping.mode !== \"string\" ||\n (mapping.mode !== \"multi-file\" && mapping.mode !== \"single-file\")\n ) {\n throw new Error(\"Unable to load mapping file: `mode` must be provided [single-file or multi-file]`\")\n }\n\n if (!mapping.mapping || !Array.isArray(mapping.mapping)) {\n throw new Error(\"Unable to load mapping file: `mapping` key must be present and array.\")\n }\n\n const mapPack = mapping.mapping\n for (const map of mapPack) {\n if (typeof map !== \"object\") {\n throw new TypeError(\"Unable to load mapping file: `mapping` must contain objects only\")\n }\n\n if (!map.tokenSets && !map.tokensTheme) {\n throw new Error(\"Unable to load mapping file: `mapping` must contain either `tokensTheme` or `tokenSets`\")\n }\n\n if (map.tokenSets && map.tokensTheme) {\n throw new Error(\"Unable to load mapping file: `mapping` must not contain both `tokensTheme` or `tokenSets`\")\n }\n\n if (map.tokenSets && (!Array.isArray(map.tokenSets) || (map.tokenSets as Array<unknown>).length === 0)) {\n throw new Error(\"Unable to load mapping file: `mapping`.`tokenSets` must be an Array with at least one entry\")\n }\n\n if (\n map.tokensTheme &&\n ((typeof map.tokensTheme !== \"string\" && !Array.isArray(map.tokensTheme)) || map.tokensTheme.length === 0)\n ) {\n throw new Error(\n \"Unable to load mapping file: `mapping`.`tokensTheme` must be a non-empty string or non-empty array of strings\",\n )\n }\n\n if (!map.supernovaBrand || typeof map.supernovaBrand !== \"string\" || map.supernovaBrand.length === 0) {\n throw new Error(\"Unable to load mapping file: `supernovaBrand` must be a non-empty string\")\n }\n\n if (map.supernovaTheme && (typeof map.supernovaTheme !== \"string\" || map.supernovaTheme.length === 0)) {\n throw new Error(\n \"Unable to load mapping file: `supernovaTheme` may be empty but must be non-empty string if not\",\n )\n }\n }\n\n if (mapping.settings) {\n if (typeof mapping.settings !== \"object\") {\n throw new TypeError(\"Unable to load mapping file: `settings` must be an object\")\n }\n\n if (Object.hasOwn(mapping.settings, \"dryRun\") && typeof mapping.settings.dryRun !== \"boolean\") {\n throw new Error(\"Unable to load mapping file: `dryRun` must be of boolean type\")\n }\n\n if (Object.hasOwn(mapping.settings, \"verbose\") && typeof mapping.settings.verbose !== \"boolean\") {\n throw new Error(\"Unable to load mapping file: `verbose` must be of boolean type\")\n }\n\n if (\n Object.hasOwn(mapping.settings, \"preciseCopy\") &&\n typeof mapping.settings.preciseCopy !== \"boolean\" &&\n typeof mapping.settings.preciseCopy !== \"string\"\n ) {\n throw new Error(\"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ACjG,CAAC;QACH,CAAC;IACH,CAAC;CACF","debug_id":"a5ca7936-f853-5cd2-8d62-a5367c6f068f"}
@@ -0,0 +1,4 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { TargetEnv } from "../types/environment.js";
3
+ export declare function createApiClient(env: TargetEnv): Promise<AxiosInstance>;
4
+ //# sourceMappingURL=http-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/utils/http-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAG5C,OAAO,EAAwB,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEzE,wBAAsB,eAAe,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAW5E"}
@@ -0,0 +1,18 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a966c97b-b882-521a-91df-7d00928cf26e")}catch(e){}}();
3
+ import axios from "axios";
4
+ import { VaultService } from "../services/vault.service.js";
5
+ import { apiUrlForEnvironment } from "../types/environment.js";
6
+ export async function createApiClient(env) {
7
+ const token = await new VaultService().getTokensFromVault(env);
8
+ return axios.create({
9
+ baseURL: apiUrlForEnvironment(env),
10
+ headers: {
11
+ Authorization: `Bearer ${token.accessToken}`,
12
+ "Content-Type": "application/json",
13
+ },
14
+ timeout: 30_000,
15
+ });
16
+ }
17
+ //# sourceMappingURL=http-client.js.map
18
+ //# debugId=a966c97b-b882-521a-91df-7d00928cf26e
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.js","sources":["../../src/utils/http-client.ts"],"sourceRoot":"","sourcesContent":["import axios, { AxiosInstance } from \"axios\"\n\nimport { VaultService } from \"../services/vault.service.js\"\nimport { apiUrlForEnvironment, TargetEnv } from \"../types/environment.js\"\n\nexport async function createApiClient(env: TargetEnv): Promise<AxiosInstance> {\n const token = await new VaultService().getTokensFromVault(env)\n\n return axios.create({\n baseURL: apiUrlForEnvironment(env),\n headers: {\n Authorization: `Bearer ${token.accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n timeout: 30_000,\n })\n}\n"],"names":[],"mappings":";;AAAA,OAAO,KAAwB,MAAM,OAAO,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAa,MAAM,yBAAyB,CAAA;AAEzE,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAc;IAClD,MAAM,KAAK,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;IAE9D,OAAO,KAAK,CAAC,MAAM,CAAC;QAClB,OAAO,EAAE,oBAAoB,CAAC,GAAG,CAAC;QAClC,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,KAAK,CAAC,WAAW,EAAE;YAC5C,cAAc,EAAE,kBAAkB;SACnC;QACD,OAAO,EAAE,MAAM;KAChB,CAAC,CAAA;AACJ,CAAC","debug_id":"a966c97b-b882-521a-91df-7d00928cf26e"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9cea29ab-f6af-5e6a-81c9-fd44af720431")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5fd4a873-80bf-5785-95a6-bf82a8d511af")}catch(e){}}();
3
3
  import { apiUrlForEnvironment } from "../../types/index.js";
4
4
  export function exportConfiguration(setup) {
5
5
  return {
@@ -16,4 +16,4 @@ export function exportConfiguration(setup) {
16
16
  };
17
17
  }
18
18
  //# sourceMappingURL=exporter-utils.js.map
19
- //# debugId=9cea29ab-f6af-5e6a-81c9-fd44af720431
19
+ //# debugId=5fd4a873-80bf-5785-95a6-bf82a8d511af
@@ -1 +1 @@
1
- {"version":3,"file":"exporter-utils.js","sources":["../../../src/utils/run-exporter/exporter-utils.ts"],"sourceRoot":"","sourcesContent":["//\n// exporter-utils.ts\n// Supernova CLI\n//\n// Created by Jiri Trecak.\n// Copyright © Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\n// eslint-disable-next-line n/no-extraneous-import\nimport * as pulsar from \"@supernova-studio/pulsar-language\"\n\nimport { apiUrlForEnvironment, ExportConfiguration, TargetEnv } from \"../../types/index.js\"\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Utils\n\nexport function exportConfiguration(setup: {\n apiKey: string\n brandId?: string\n dsId: string\n environment: TargetEnv\n exportPath: string\n logger: pulsar.PLLogger\n proxyUrl?: string\n themeId?: string\n versionId: string\n}): ExportConfiguration {\n return {\n accessToken: setup.apiKey,\n apiUrl: `${apiUrlForEnvironment(setup.environment, undefined)}`,\n apiVersion: \"0.2\",\n brandId: setup.brandId,\n designSystemId: setup.dsId,\n designSystemVersionId: setup.versionId,\n exportPath: setup.exportPath,\n logger: setup.logger,\n proxyUrl: setup.proxyUrl,\n themeId: setup.themeId,\n }\n}\n"],"names":[],"mappings":";;AAcA,OAAO,EAAE,oBAAoB,EAAkC,MAAM,sBAAsB,CAAA;AAK3F,MAAM,UAAU,mBAAmB,CAAC,KAUnC;IACC,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,MAAM;QACzB,MAAM,EAAE,GAAG,oBAAoB,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE;QAC/D,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,cAAc,EAAE,KAAK,CAAC,IAAI;QAC1B,qBAAqB,EAAE,KAAK,CAAC,SAAS;QACtC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAA;AACH,CAAC","debug_id":"9cea29ab-f6af-5e6a-81c9-fd44af720431"}
1
+ {"version":3,"file":"exporter-utils.js","sources":["../../../src/utils/run-exporter/exporter-utils.ts"],"sourceRoot":"","sourcesContent":["//\n// exporter-utils.ts\n// Supernova CLI\n//\n// Created by Jiri Trecak.\n// Copyright © Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\n \nimport * as pulsar from \"@supernova-studio/pulsar-language\"\n\nimport { apiUrlForEnvironment, ExportConfiguration, TargetEnv } from \"../../types/index.js\"\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Utils\n\nexport function exportConfiguration(setup: {\n apiKey: string\n brandId?: string\n dsId: string\n environment: TargetEnv\n exportPath: string\n logger: pulsar.PLLogger\n proxyUrl?: string\n themeId?: string\n versionId: string\n}): ExportConfiguration {\n return {\n accessToken: setup.apiKey,\n apiUrl: `${apiUrlForEnvironment(setup.environment, undefined)}`,\n apiVersion: \"0.2\",\n brandId: setup.brandId,\n designSystemId: setup.dsId,\n designSystemVersionId: setup.versionId,\n exportPath: setup.exportPath,\n logger: setup.logger,\n proxyUrl: setup.proxyUrl,\n themeId: setup.themeId,\n }\n}\n"],"names":[],"mappings":";;AAcA,OAAO,EAAE,oBAAoB,EAAkC,MAAM,sBAAsB,CAAA;AAK3F,MAAM,UAAU,mBAAmB,CAAC,KAUnC;IACC,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,MAAM;QACzB,MAAM,EAAE,GAAG,oBAAoB,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE;QAC/D,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,cAAc,EAAE,KAAK,CAAC,IAAI;QAC1B,qBAAqB,EAAE,KAAK,CAAC,SAAS;QACtC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAA;AACH,CAAC","debug_id":"5fd4a873-80bf-5785-95a6-bf82a8d511af"}
@@ -5,9 +5,9 @@ export type TemplatePreset = {
5
5
  files?: string[];
6
6
  };
7
7
  export interface Logger {
8
- warn: (msg: string) => void;
9
8
  error: (msg: string) => never;
10
9
  log: (msg: string) => void;
10
+ warn: (msg: string) => void;
11
11
  }
12
12
  export declare function fileExists(p: string): Promise<boolean>;
13
13
  export declare function validateTemplates(templates: {
@@ -1 +1 @@
1
- {"version":3,"file":"validate-templates.d.ts","sourceRoot":"","sources":["../../src/utils/validate-templates.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAExG,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,CAAA;IAC7B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAC3B;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,MAAM,oBAOzC;AAED,wBAAsB,iBAAiB,CACrC,SAAS,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,EAC5C,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,CAwCf"}
1
+ {"version":3,"file":"validate-templates.d.ts","sourceRoot":"","sources":["../../src/utils/validate-templates.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAExG,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,CAAA;IAC7B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5B;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,MAAM,oBAOzC;AAED,wBAAsB,iBAAiB,CACrC,SAAS,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,EAC5C,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,CAwCf"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8648ca5c-4a11-592c-b7d6-b6ccc9afb0f6")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ce63cd84-8d0f-5d20-89d4-cc6de4a4ba89")}catch(e){}}();
3
3
  import { action } from "@oclif/core/ux";
4
4
  import { exec as execCallback } from "node:child_process";
5
5
  import * as fs from "node:fs/promises";
@@ -70,7 +70,7 @@ async function testTemplateBuild(templateKey, files, logger, debug) {
70
70
  }
71
71
  }
72
72
  async function checkNoDirsExist(dirs) {
73
- for (const dir of [...new Set(dirs)]) {
73
+ for (const dir of new Set(dirs)) {
74
74
  if (await fileExists(dir)) {
75
75
  throw new Error(`Component directory already exists: ${path.relative(process.cwd(), dir)}. Please remove or rename this directory before testing the template.`);
76
76
  }
@@ -131,10 +131,10 @@ async function cleanup(copiedFiles, appTsxPath, originalAppContent) {
131
131
  }
132
132
  async function updateImportsInFile(filePath) {
133
133
  const content = await fs.readFile(filePath, "utf8");
134
- const updatedContent = content.replace(/from\s+["']\.\.\/\.\.\/(patterns|templates)\/([^/"']+\/[^"']+)["']/g, 'from "../$2"');
134
+ const updatedContent = content.replaceAll(/from\s+["']\.\.\/\.\.\/(patterns|templates)\/([^/"']+\/[^"']+)["']/g, 'from "../$2"');
135
135
  if (content !== updatedContent) {
136
136
  await fs.writeFile(filePath, updatedContent);
137
137
  }
138
138
  }
139
139
  //# sourceMappingURL=validate-templates.js.map
140
- //# debugId=8648ca5c-4a11-592c-b7d6-b6ccc9afb0f6
140
+ //# debugId=ce63cd84-8d0f-5d20-89d4-cc6de4a4ba89
@@ -1 +1 @@
1
- {"version":3,"file":"validate-templates.js","sources":["../../src/utils/validate-templates.ts"],"sourceRoot":"","sourcesContent":["import { action } from \"@oclif/core/ux\"\nimport { exec as execCallback } from \"node:child_process\"\nimport * as fs from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { promisify } from \"node:util\"\n\nconst exec = promisify(execCallback)\n\nexport type TemplatePreset = { name: string; description: string; thumbnail?: string; files?: string[] }\n\nexport interface Logger {\n warn: (msg: string) => void\n error: (msg: string) => never\n log: (msg: string) => void\n}\n\nexport async function fileExists(p: string) {\n try {\n await fs.access(p)\n return true\n } catch {\n return false\n }\n}\n\nexport async function validateTemplates(\n templates: { [key: string]: TemplatePreset },\n logger: Logger,\n debug?: boolean,\n): Promise<void> {\n action.start(`🔍 Validating ${Object.keys(templates).length} template(s)`)\n\n for (const [templateKey, template] of Object.entries(templates)) {\n action.start(`Validating template '${templateKey}'`)\n\n // Check if template has files\n if (!template.files || template.files.length === 0) {\n action.stop(\"no files specified\")\n logger.error(`Template '${templateKey}': No files specified`)\n }\n\n // Validate main file exists\n const expectedMainFile = `supernova/templates/${templateKey}/${templateKey}.tsx`\n if (!template.files.includes(expectedMainFile)) {\n action.stop(\"main file missing\")\n logger.error(`Template '${templateKey}': Expected main file '${expectedMainFile}' not found in files array`)\n }\n\n // Validate all files exist on disk\n for (const filePath of template.files) {\n if (!(await fileExists(path.resolve(filePath)))) {\n action.stop(\"files missing\")\n logger.error(`Template '${templateKey}': File does not exist: ${filePath}`)\n }\n }\n\n // Actually test the template by copying and building\n try {\n await testTemplateBuild(templateKey, template.files, logger, debug)\n action.stop(\"build successful\")\n } catch (error) {\n action.stop(\"build failed\")\n logger.error(\n `Template '${templateKey}': Build test failed: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n action.stop(\"validation complete\")\n}\n\nasync function testTemplateBuild(templateKey: string, files: string[], logger: Logger, debug?: boolean): Promise<void> {\n const appTsxPath = path.resolve(\"src/App.tsx\")\n const componentsDir = path.resolve(\"src/components\")\n const toDestPath = (filePath: string) =>\n path.join(componentsDir, filePath.replace(/^supernova\\/(patterns|templates)\\//, \"\"))\n\n let originalAppContent = \"\"\n let copiedFiles: string[] = []\n let failed = false\n\n try {\n await checkNoDirsExist(files.map(f => path.dirname(toDestPath(f))))\n copiedFiles = await copyFiles(files, toDestPath)\n originalAppContent = await patchAppTsx(appTsxPath, templateKey)\n await runBuild(logger)\n } catch (error) {\n failed = true\n throw error\n } finally {\n const keepFilesForDebugging = debug && failed\n if (!keepFilesForDebugging) {\n await cleanup(copiedFiles, appTsxPath, originalAppContent)\n }\n }\n}\n\nasync function checkNoDirsExist(dirs: string[]): Promise<void> {\n for (const dir of [...new Set(dirs)]) {\n if (await fileExists(dir)) {\n throw new Error(\n `Component directory already exists: ${path.relative(process.cwd(), dir)}. Please remove or rename this directory before testing the template.`,\n )\n }\n }\n}\n\nasync function copyFiles(files: string[], toDestPath: (f: string) => string): Promise<string[]> {\n const copiedFiles: string[] = []\n for (const filePath of files) {\n const destPath = toDestPath(filePath)\n await fs.mkdir(path.dirname(destPath), { recursive: true })\n await fs.copyFile(path.resolve(filePath), destPath)\n copiedFiles.push(destPath)\n if (destPath.endsWith(\".tsx\") || destPath.endsWith(\".ts\")) {\n await updateImportsInFile(destPath)\n }\n }\n return copiedFiles\n}\n\nasync function patchAppTsx(appTsxPath: string, templateKey: string): Promise<string> {\n if (!(await fileExists(appTsxPath))) return \"\"\n const originalContent = await fs.readFile(appTsxPath, \"utf8\")\n await fs.writeFile(\n appTsxPath,\n `import { ${templateKey} } from \"./components/${templateKey}/${templateKey}\"\\n\\nexport default function App() {\\n return <${templateKey} />\\n}`,\n )\n return originalContent\n}\n\nasync function runBuild(logger: Logger): Promise<void> {\n try {\n const result = await exec(\"npm run build\", { cwd: process.cwd() })\n if (result.stderr) logger.log(`Build stderr: ${result.stderr}`)\n } catch (buildError: any) {\n logger.log(`Build failed with error: ${buildError.message}`)\n if (buildError.stdout) logger.log(`Build stdout: ${buildError.stdout}`)\n if (buildError.stderr) logger.log(`Build stderr: ${buildError.stderr}`)\n throw buildError\n }\n}\n\nasync function cleanup(copiedFiles: string[], appTsxPath: string, originalAppContent: string): Promise<void> {\n for (const filePath of copiedFiles) {\n if (await fileExists(filePath)) {\n await fs.rm(filePath, { force: true })\n }\n }\n\n const sortedDirs = [...new Set(copiedFiles.map(f => path.dirname(f)))].sort((a, b) => b.length - a.length)\n for (const dir of sortedDirs) {\n try {\n await fs.rm(dir, { recursive: true, force: true })\n } catch {\n // ignore\n }\n }\n\n if (originalAppContent && (await fileExists(appTsxPath))) {\n await fs.writeFile(appTsxPath, originalAppContent)\n }\n}\n\nasync function updateImportsInFile(filePath: string): Promise<void> {\n const content = await fs.readFile(filePath, \"utf8\")\n const updatedContent = content.replace(\n /from\\s+[\"']\\.\\.\\/\\.\\.\\/(patterns|templates)\\/([^/\"']+\\/[^\"']+)[\"']/g,\n 'from \"../$2\"',\n )\n if (content !== updatedContent) {\n await fs.writeFile(filePath, updatedContent)\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;AAUpC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,CAAS;IACxC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAA4C,EAC5C,MAAc,EACd,KAAe;IAEf,MAAM,CAAC,KAAK,CAAC,iBAAiB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,cAAc,CAAC,CAAA;IAE1E,KAAK,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAChE,M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CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAA;IAC1G,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACpD,CAAC;QAAC,MAAM,CAAC;QAET,CAAC;IACH,CAAC;IAED,IAAI,kBAAkB,IAAI,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QACzD,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAA;IACpD,CAAC;AACH,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACjD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACnD,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CACpC,qEAAqE,EACrE,cAAc,CACf,CAAA;IACD,IAAI,OAAO,KAAK,cAAc,EAAE,CAAC;QAC/B,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;IAC9C,CAAC;AACH,CAAC","debug_id":"8648ca5c-4a11-592c-b7d6-b6ccc9afb0f6"}
1
+ {"version":3,"file":"validate-templates.js","sources":["../../src/utils/validate-templates.ts"],"sourceRoot":"","sourcesContent":["import { action } from \"@oclif/core/ux\"\nimport { exec as execCallback } from \"node:child_process\"\nimport * as fs from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { promisify } from \"node:util\"\n\nconst exec = promisify(execCallback)\n\nexport type TemplatePreset = { name: string; description: string; thumbnail?: string; files?: string[] }\n\nexport interface Logger {\n error: (msg: string) => never\n log: (msg: string) => void\n warn: (msg: string) => void\n}\n\nexport async function fileExists(p: string) {\n try {\n await fs.access(p)\n return true\n } catch {\n return false\n }\n}\n\nexport async function validateTemplates(\n templates: { [key: string]: TemplatePreset },\n logger: Logger,\n debug?: boolean,\n): Promise<void> {\n action.start(`🔍 Validating ${Object.keys(templates).length} template(s)`)\n\n for (const [templateKey, template] of Object.entries(templates)) {\n action.start(`Validating template '${templateKey}'`)\n\n // Check if template has files\n if (!template.files || template.files.length === 0) {\n action.stop(\"no files specified\")\n logger.error(`Template '${templateKey}': No files specified`)\n }\n\n // Validate main file exists\n const expectedMainFile = `supernova/templates/${templateKey}/${templateKey}.tsx`\n if (!template.files.includes(expectedMainFile)) {\n action.stop(\"main file missing\")\n logger.error(`Template '${templateKey}': Expected main file '${expectedMainFile}' not found in files array`)\n }\n\n // Validate all files exist on disk\n for (const filePath of template.files) {\n if (!(await fileExists(path.resolve(filePath)))) {\n action.stop(\"files missing\")\n logger.error(`Template '${templateKey}': File does not exist: ${filePath}`)\n }\n }\n\n // Actually test the template by copying and building\n try {\n await testTemplateBuild(templateKey, template.files, logger, debug)\n action.stop(\"build successful\")\n } catch (error) {\n action.stop(\"build failed\")\n logger.error(\n `Template '${templateKey}': Build test failed: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n action.stop(\"validation complete\")\n}\n\nasync function testTemplateBuild(templateKey: string, files: string[], logger: Logger, debug?: boolean): Promise<void> {\n const appTsxPath = path.resolve(\"src/App.tsx\")\n const componentsDir = path.resolve(\"src/components\")\n const toDestPath = (filePath: string) =>\n path.join(componentsDir, filePath.replace(/^supernova\\/(patterns|templates)\\//, \"\"))\n\n let originalAppContent = \"\"\n let copiedFiles: string[] = []\n let failed = false\n\n try {\n await checkNoDirsExist(files.map(f => path.dirname(toDestPath(f))))\n copiedFiles = await copyFiles(files, toDestPath)\n originalAppContent = await patchAppTsx(appTsxPath, templateKey)\n await runBuild(logger)\n } catch (error) {\n failed = true\n throw error\n } finally {\n const keepFilesForDebugging = debug && failed\n if (!keepFilesForDebugging) {\n await cleanup(copiedFiles, appTsxPath, originalAppContent)\n }\n }\n}\n\nasync function checkNoDirsExist(dirs: string[]): Promise<void> {\n for (const dir of new Set(dirs)) {\n if (await fileExists(dir)) {\n throw new Error(\n `Component directory already exists: ${path.relative(process.cwd(), dir)}. Please remove or rename this directory before testing the template.`,\n )\n }\n }\n}\n\nasync function copyFiles(files: string[], toDestPath: (f: string) => string): Promise<string[]> {\n const copiedFiles: string[] = []\n for (const filePath of files) {\n const destPath = toDestPath(filePath)\n await fs.mkdir(path.dirname(destPath), { recursive: true })\n await fs.copyFile(path.resolve(filePath), destPath)\n copiedFiles.push(destPath)\n if (destPath.endsWith(\".tsx\") || destPath.endsWith(\".ts\")) {\n await updateImportsInFile(destPath)\n }\n }\n\n return copiedFiles\n}\n\nasync function patchAppTsx(appTsxPath: string, templateKey: string): Promise<string> {\n if (!(await fileExists(appTsxPath))) return \"\"\n const originalContent = await fs.readFile(appTsxPath, \"utf8\")\n await fs.writeFile(\n appTsxPath,\n `import { ${templateKey} } from \"./components/${templateKey}/${templateKey}\"\\n\\nexport default function App() {\\n return <${templateKey} />\\n}`,\n )\n return originalContent\n}\n\nasync function runBuild(logger: Logger): Promise<void> {\n try {\n const result = await exec(\"npm run build\", { cwd: process.cwd() })\n if (result.stderr) logger.log(`Build stderr: ${result.stderr}`)\n } catch (buildError: any) {\n logger.log(`Build failed with error: ${buildError.message}`)\n if (buildError.stdout) logger.log(`Build stdout: ${buildError.stdout}`)\n if (buildError.stderr) logger.log(`Build stderr: ${buildError.stderr}`)\n throw buildError\n }\n}\n\nasync function cleanup(copiedFiles: string[], appTsxPath: string, originalAppContent: string): Promise<void> {\n for (const filePath of copiedFiles) {\n if (await fileExists(filePath)) {\n await fs.rm(filePath, { force: true })\n }\n }\n\n const sortedDirs = [...new Set(copiedFiles.map(f => path.dirname(f)))].sort((a, b) => b.length - a.length)\n for (const dir of sortedDirs) {\n try {\n await fs.rm(dir, { recursive: true, force: true })\n } catch {\n // ignore\n }\n }\n\n if (originalAppContent && (await fileExists(appTsxPath))) {\n await fs.writeFile(appTsxPath, originalAppContent)\n }\n}\n\nasync function updateImportsInFile(filePath: string): Promise<void> {\n const content = await fs.readFile(filePath, \"utf8\")\n const updatedContent = content.replaceAll(\n /from\\s+[\"']\\.\\.\\/\\.\\.\\/(patterns|templates)\\/([^/\"']+\\/[^\"']+)[\"']/g,\n 'from \"../$2\"',\n )\n if (content !== updatedContent) {\n await fs.writeFile(filePath, updatedContent)\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;AAUpC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,CAAS;IACxC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAA4C,EAC5C,MAAc,EACd,KAAe;IAEf,MAAM,CAAC,KAAK,CAAC,iBAAiB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,cAAc,CAAC,CAAA;IAE1E,KAAK,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAChE,MAAM,CAAC,KAAK,CAAC,wBAAwB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