@supernovaio/cli 2.0.41 → 2.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-analyzer/analyzers/component-usage.js.map +1 -1
- package/dist/code-analyzer/analyzers/helpers.js.map +1 -1
- package/dist/code-analyzer/analyzers/index.js.map +1 -1
- package/dist/code-analyzer/analyzers/jsdoc.js.map +1 -1
- package/dist/code-analyzer/analyzers/static-components.js.map +1 -1
- package/dist/code-analyzer/analyzers/storybook-docs.js.map +1 -1
- package/dist/code-analyzer/analyzers/storybook-stories.js.map +1 -1
- package/dist/code-analyzer/analyzers/types.js.map +1 -1
- package/dist/code-analyzer/analyzers/typescript-api.js.map +1 -1
- package/dist/code-analyzer/components/analyze.js.map +1 -1
- package/dist/code-analyzer/components/mappers/component.js.map +1 -1
- package/dist/code-analyzer/components/mappers/property.js.map +1 -1
- package/dist/code-analyzer/components/parser/index.js.map +1 -1
- package/dist/code-analyzer/components/parser/module-parser.js.map +1 -1
- package/dist/code-analyzer/components/parser/parser.js.map +1 -1
- package/dist/code-analyzer/components/parser/types.js.map +1 -1
- package/dist/code-analyzer/components/parser/utils/build-filter.js.map +1 -1
- package/dist/code-analyzer/components/parser/utils/filter-duplicates.js.map +1 -1
- package/dist/code-analyzer/components/parser/utils/is-react-component.js.map +1 -1
- package/dist/code-analyzer/components/parser/utils/trim-file-name.js.map +1 -1
- package/dist/code-analyzer/components/types.js.map +1 -1
- package/dist/code-analyzer/components/utils/get-module-exports-path.js.map +1 -1
- package/dist/code-analyzer/index.js.map +1 -1
- package/dist/code-analyzer/orchestrator/index.js.map +1 -1
- package/dist/code-analyzer/orchestrator/run-analysis.js.map +1 -1
- package/dist/code-analyzer/snapshot/index.js.map +1 -1
- package/dist/code-analyzer/snapshot/write-snapshot.js.map +1 -1
- package/dist/commands/analyze/adoption.js.map +1 -1
- package/dist/commands/analyze/components.js.map +1 -1
- package/dist/commands/analyze/status.js.map +1 -1
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/components-import.js.map +1 -1
- package/dist/commands/describe-design-system.js.map +1 -1
- package/dist/commands/describe-workspaces.js.map +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/publish-documentation.js.map +1 -1
- package/dist/commands/run-local-exporter.js.map +1 -1
- package/dist/commands/storybook-import.js.map +1 -1
- package/dist/commands/sync-tokens.js.map +1 -1
- package/dist/commands/template-upload.d.ts +4 -1
- package/dist/commands/template-upload.d.ts.map +1 -1
- package/dist/commands/template-upload.js +83 -48
- package/dist/commands/template-upload.js.map +1 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/hooks/postrun/save-config.js.map +1 -1
- package/dist/hooks/prerun/load-config.js.map +1 -1
- package/dist/hooks/prerun/sentry.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/user.service.d.ts.map +1 -1
- package/dist/services/user.service.js.map +1 -1
- package/dist/services/vault.service.js.map +1 -1
- package/dist/types/base-command.js.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/types/environment.js.map +1 -1
- package/dist/types/flags.js.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/login.js.map +1 -1
- package/dist/types/not-authorized.error.js.map +1 -1
- package/dist/types/sentry-command.js.map +1 -1
- package/dist/types/types.js.map +1 -1
- package/dist/utils/analyze-command.js.map +1 -1
- package/dist/utils/analyze-status.js.map +1 -1
- package/dist/utils/api-client.js.map +1 -1
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.service.js.map +1 -1
- package/dist/utils/discover.d.ts +1 -1
- package/dist/utils/discover.d.ts.map +1 -1
- package/dist/utils/discover.js +5 -5
- package/dist/utils/discover.js.map +1 -1
- package/dist/utils/figma-tokens-data-loader.js.map +1 -1
- package/dist/utils/http-client.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/run-exporter/exporter-utils.js.map +1 -1
- package/dist/utils/sdk.js.map +1 -1
- package/dist/utils/validate-templates.js.map +1 -1
- package/oclif.manifest.json +24 -7
- package/package.json +10 -10
- package/dist/docker-scripts/extract-private-packages.js +0 -74
package/dist/utils/discover.js
CHANGED
|
@@ -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]="
|
|
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]="3641e013-6aae-5262-897b-e2c830289d87")}catch(e){}}();
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
export function folderNameToDisplayName(folderName) {
|
|
@@ -31,7 +31,7 @@ function parseDescriptionFromReadme(readmeFilePath) {
|
|
|
31
31
|
if (!match)
|
|
32
32
|
return "";
|
|
33
33
|
let description = match[1].trim();
|
|
34
|
-
description = description.replaceAll(
|
|
34
|
+
description = description.replaceAll("**", "").replaceAll("*", "");
|
|
35
35
|
description = description.charAt(0).toUpperCase() + description.slice(1);
|
|
36
36
|
if (!description.endsWith(".") && !description.endsWith("!") && !description.endsWith("?")) {
|
|
37
37
|
description += ".";
|
|
@@ -66,7 +66,7 @@ function parseImportsFromTSFile(filePath, baseDir) {
|
|
|
66
66
|
const actualPath = possiblePaths.find(p => fs.existsSync(p));
|
|
67
67
|
if (actualPath) {
|
|
68
68
|
const containerRoot = path.resolve(baseDir, "../../..");
|
|
69
|
-
const relativePath = path.relative(containerRoot, actualPath).replaceAll(
|
|
69
|
+
const relativePath = path.relative(containerRoot, actualPath).replaceAll("\\", "/");
|
|
70
70
|
if (relativePath.startsWith("supernova/")) {
|
|
71
71
|
dependencies.push(relativePath);
|
|
72
72
|
}
|
|
@@ -183,7 +183,7 @@ function discoverItems(basePath, subdirectory) {
|
|
|
183
183
|
const thumbnail = findThumbnail(itemDir);
|
|
184
184
|
const files = getAllFilesInDirectory(itemDir, itemDir);
|
|
185
185
|
const containerRoot = path.resolve(itemDir, "../../..");
|
|
186
|
-
const itemRelativePath = path.relative(containerRoot, itemDir).replaceAll(
|
|
186
|
+
const itemRelativePath = path.relative(containerRoot, itemDir).replaceAll("\\", "/");
|
|
187
187
|
const fullPathFiles = files.map(file => `${itemRelativePath}/${file}`);
|
|
188
188
|
const importDependencies = parseImportsFromDirectory(itemDir);
|
|
189
189
|
const allDependencies = [...new Set(importDependencies)];
|
|
@@ -304,4 +304,4 @@ export async function discoverAndUpdatePackageJson(basePath) {
|
|
|
304
304
|
return result;
|
|
305
305
|
}
|
|
306
306
|
//# sourceMappingURL=discover.js.map
|
|
307
|
-
//# debugId=
|
|
307
|
+
//# debugId=3641e013-6aae-5262-897b-e2c830289d87
|
|
@@ -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 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,O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CAAA;AACf,CAAC","debug_id":"8d01cf90-bafa-5c36-82b4-70b7a809ff77"}
|
|
1
|
+
{"version":3,"file":"discover.js","sources":["../../src/utils/discover.ts"],"sourceRoot":"","sourcesContent":["import fs from \"node:fs\"\nimport path from \"node:path\"\n\nexport interface 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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AA4B,CAAC,QAAQ,CAAC,CAAA;IAC3D,MAAM,gBAAgB,GAAG,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;IAGlD,MAAM,WAAW,GAAG,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","debugId":"3641e013-6aae-5262-897b-e2c830289d87"}
|
|
@@ -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 \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: `preciseCopy` must be of boolean or string type\")\n }\n }\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,GAAG,MAAM,kBAAkB,CAAA;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAE7B,MAAM,OAAO,qBAAqB;IAChC,kBAAkB,CAAC,UAAkB;QAInC,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAuC,CAAA;YACtG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;YAC1C,OAAO,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,KAAK,CAAC,CAAA;QAClE,CAAC;IACH,CAAC;IAED,sBAAsB,CAAC,UAAkB;QACvC,IAAI,CAAC;YACH,IAAI,CAAC,CAA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AAM,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC9F,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;YAClF,CAAC;YAED,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBAChG,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;YACnF,CAAC;YAED,IACE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC;gBAC9C,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,KAAK,SAAS;gBACjD,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,KAAK,QAAQ,EAChD,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAA;YACjG,CAAC;QACH,CAAC;IACH,CAAC;CACF","debug_id":"a5ca7936-f853-5cd2-8d62-a5367c6f068f"}
|
|
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(\"Unable to load mapping file: `preciseCopy` must be of boolean or string type\")\n }\n }\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,GAAG,MAAM,kBAAkB,CAAA;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAE7B,MAAM,OAAO,qBAAqB;IAChC,kBAAkB,CAAC,UAAkB;QAInC,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAuC,CAAA;YACtG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;YAC1C,OAAO,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,KAAK,CAAC,CAAA;QAClE,CAAC;IACH,CAAC;IAED,sBAAsB,CAAC,UAAkB;QACvC,IAAI,CAAC;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,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC9F,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;YAClF,CAAC;YAED,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBAChG,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;YACnF,CAAC;YAED,IACE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC;gBAC9C,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,KAAK,SAAS;gBACjD,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,KAAK,QAAQ,EAChD,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAA;YACjG,CAAC;QACH,CAAC;IACH,CAAC;CACF","debugId":"a5ca7936-f853-5cd2-8d62-a5367c6f068f"}
|
|
@@ -1 +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","
|
|
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","debugId":"a966c97b-b882-521a-91df-7d00928cf26e"}
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourceRoot":"","sourcesContent":["export * from \"./api-client.js\"\n"],"names":[],"mappings":";;AAAA,cAAc,iBAAiB,CAAA","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourceRoot":"","sourcesContent":["export * from \"./api-client.js\"\n"],"names":[],"mappings":";;AAAA,cAAc,iBAAiB,CAAA","debugId":"13f23c5e-738b-519d-9c69-b830cda985ca"}
|
|
@@ -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 \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","
|
|
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","debugId":"5fd4a873-80bf-5785-95a6-bf82a8d511af"}
|
package/dist/utils/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/utils/sdk.ts"],"sourceRoot":"","sourcesContent":["import * as sdkTypes from \"@supernovaio/sdk\"\nimport { createRequire } from \"node:module\"\nimport { HttpsProxyAgent } from \"https-proxy-agent\"\n\nimport { apiUrlForEnvironment, getTargetEnv } from \"../types/environment.js\"\n\nconst require = createRequire(import.meta.url)\nconst sdkProvider = require(\"@supernovaio/sdk\") as typeof sdkTypes\n\nexport interface DefaultDesignSystemFlags {\n apiKey: string\n apiUrl?: string\n brandId?: string\n designSystemId: string\n proxyUrl?: string\n themeId?: string\n}\n\nexport async function getWritableVersion(flags: DefaultDesignSystemFlags): Promise<{\n brand: null | sdkTypes.Brand\n designSystem: sdkTypes.DesignSystem\n id: sdkTypes.RemoteWorkspaceVersionIdentifier\n instance: sdkTypes.Supernova\n theme: null | sdkTypes.TokenTheme\n version: sdkTypes.DesignSystemVersion\n}> {\n if (!flags.apiKey || flags.apiKey.length === 0) {\n throw new Error(`API key must not be empty`)\n }\n\n if (!flags.designSystemId || flags.designSystemId.length === 0) {\n throw new Error(`Design System ID must not be empty`)\n }\n\n // Create instance for prod / dev\n const apiUrl = flags.apiUrl && flags.apiUrl.length > 0 ? flags.apiUrl : apiUrlForEnvironment(getTargetEnv())\n const instance = new sdkProvider.Supernova(flags.apiKey, {\n apiUrl,\n customProxyLib: flags.proxyUrl ? new HttpsProxyAgent(flags.proxyUrl) : null,\n })\n\n const designSystem = await instance.designSystems.designSystem(flags.designSystemId)\n if (!designSystem) {\n throw new Error(`Design system ${flags.designSystemId} not found or not available under provided API key`)\n }\n\n const version = await instance.versions.getActiveVersion(flags.designSystemId)\n if (!version) {\n throw new Error(\n `Design system ${flags.designSystemId} writable version not found or not available under provided API key`,\n )\n }\n\n const id: sdkTypes.RemoteWorkspaceVersionIdentifier = {\n designSystemId: flags.designSystemId,\n versionId: version.id,\n workspaceId: designSystem.workspaceId,\n }\n\n let brand: null | sdkTypes.Brand = null\n if (flags.brandId) {\n const brands = await instance.brands.getBrands(id)\n brand = brands.find(brand => brand.id === flags.brandId || brand.idInVersion === flags.brandId) ?? null\n if (!brand) {\n throw new Error(`Brand ${flags.brandId} not found in specified design system`)\n }\n }\n\n let theme: null | sdkTypes.TokenTheme = null\n if (flags.themeId) {\n const themes = await instance.tokens.getTokenThemes(id)\n theme = themes.find(theme => theme.id === flags.themeId || theme.idInVersion === flags.themeId) ?? null\n if (!theme) {\n throw new Error(`Theme ${flags.themeId} not found in specified brand`)\n }\n }\n\n return { brand, designSystem, id, instance, theme, version }\n}\n"],"names":[],"mappings":";;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,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,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;QACxE,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC9D,CAAC","
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../src/utils/sdk.ts"],"sourceRoot":"","sourcesContent":["import * as sdkTypes from \"@supernovaio/sdk\"\nimport { createRequire } from \"node:module\"\nimport { HttpsProxyAgent } from \"https-proxy-agent\"\n\nimport { apiUrlForEnvironment, getTargetEnv } from \"../types/environment.js\"\n\nconst require = createRequire(import.meta.url)\nconst sdkProvider = require(\"@supernovaio/sdk\") as typeof sdkTypes\n\nexport interface DefaultDesignSystemFlags {\n apiKey: string\n apiUrl?: string\n brandId?: string\n designSystemId: string\n proxyUrl?: string\n themeId?: string\n}\n\nexport async function getWritableVersion(flags: DefaultDesignSystemFlags): Promise<{\n brand: null | sdkTypes.Brand\n designSystem: sdkTypes.DesignSystem\n id: sdkTypes.RemoteWorkspaceVersionIdentifier\n instance: sdkTypes.Supernova\n theme: null | sdkTypes.TokenTheme\n version: sdkTypes.DesignSystemVersion\n}> {\n if (!flags.apiKey || flags.apiKey.length === 0) {\n throw new Error(`API key must not be empty`)\n }\n\n if (!flags.designSystemId || flags.designSystemId.length === 0) {\n throw new Error(`Design System ID must not be empty`)\n }\n\n // Create instance for prod / dev\n const apiUrl = flags.apiUrl && flags.apiUrl.length > 0 ? flags.apiUrl : apiUrlForEnvironment(getTargetEnv())\n const instance = new sdkProvider.Supernova(flags.apiKey, {\n apiUrl,\n customProxyLib: flags.proxyUrl ? new HttpsProxyAgent(flags.proxyUrl) : null,\n })\n\n const designSystem = await instance.designSystems.designSystem(flags.designSystemId)\n if (!designSystem) {\n throw new Error(`Design system ${flags.designSystemId} not found or not available under provided API key`)\n }\n\n const version = await instance.versions.getActiveVersion(flags.designSystemId)\n if (!version) {\n throw new Error(\n `Design system ${flags.designSystemId} writable version not found or not available under provided API key`,\n )\n }\n\n const id: sdkTypes.RemoteWorkspaceVersionIdentifier = {\n designSystemId: flags.designSystemId,\n versionId: version.id,\n workspaceId: designSystem.workspaceId,\n }\n\n let brand: null | sdkTypes.Brand = null\n if (flags.brandId) {\n const brands = await instance.brands.getBrands(id)\n brand = brands.find(brand => brand.id === flags.brandId || brand.idInVersion === flags.brandId) ?? null\n if (!brand) {\n throw new Error(`Brand ${flags.brandId} not found in specified design system`)\n }\n }\n\n let theme: null | sdkTypes.TokenTheme = null\n if (flags.themeId) {\n const themes = await instance.tokens.getTokenThemes(id)\n theme = themes.find(theme => theme.id === flags.themeId || theme.idInVersion === flags.themeId) ?? null\n if (!theme) {\n throw new Error(`Theme ${flags.themeId} not found in specified brand`)\n }\n }\n\n return { brand, designSystem, id, instance, theme, version }\n}\n"],"names":[],"mappings":";;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE5E,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAoB,CAAA;AAWlE,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAA+B;IAQtE,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,oCAAoC,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CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;QACvG,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,OAAO,uCAAuC,CAAC,CAAA;QAChF,CAAC;IACH,CAAC;IAED,IAAI,KAAK,GAA+B,IAAI,CAAA;IAC5C,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QACvD,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;QACvG,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;QACxE,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC9D,CAAC","debugId":"2e4ad83e-2d39-52ed-98f7-417ef8624e3b"}
|
|
@@ -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 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,WAAW,GAAG,CAAC,CAAA;QAGpD,IAAI,CAAC,Q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C,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,UAAU,CACvC,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":"ce63cd84-8d0f-5d20-89d4-cc6de4a4ba89"}
|
|
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,WAAW,GAAG,CAAC,CAAA;QAGpD,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,KAA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AC,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,UAAU,CACvC,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","debugId":"ce63cd84-8d0f-5d20-89d4-cc6de4a4ba89"}
|
package/oclif.manifest.json
CHANGED
|
@@ -604,7 +604,7 @@
|
|
|
604
604
|
"type": "boolean"
|
|
605
605
|
},
|
|
606
606
|
"npmToken": {
|
|
607
|
-
"description": "Allows passing NPM token as a Docker secret. The token will be available as
|
|
607
|
+
"description": "Allows passing NPM token as a Docker secret. The token will be available as NPM_TOKEN env variable",
|
|
608
608
|
"name": "npmToken",
|
|
609
609
|
"required": false,
|
|
610
610
|
"hasDynamicHelp": false,
|
|
@@ -618,12 +618,29 @@
|
|
|
618
618
|
"allowNo": false,
|
|
619
619
|
"type": "boolean"
|
|
620
620
|
},
|
|
621
|
-
"
|
|
622
|
-
"description": "
|
|
623
|
-
"name": "
|
|
621
|
+
"dockerImageUri": {
|
|
622
|
+
"description": "Set this flag to upload image to a custom Docker registry, omit to use Supernova Docker registry. The registry needs to be accessible by Supernova, and authentication must be provided using 'dockerUser' and 'dockerPassword' flags",
|
|
623
|
+
"name": "dockerImageUri",
|
|
624
624
|
"required": false,
|
|
625
|
-
"
|
|
626
|
-
"
|
|
625
|
+
"hasDynamicHelp": false,
|
|
626
|
+
"multiple": false,
|
|
627
|
+
"type": "option"
|
|
628
|
+
},
|
|
629
|
+
"dockerUser": {
|
|
630
|
+
"description": "Username for accessing custom Docker registry, to be used in combination with 'dockerImageUri'. Supernova will pass it to 'docker login'.",
|
|
631
|
+
"name": "dockerUser",
|
|
632
|
+
"required": false,
|
|
633
|
+
"hasDynamicHelp": false,
|
|
634
|
+
"multiple": false,
|
|
635
|
+
"type": "option"
|
|
636
|
+
},
|
|
637
|
+
"dockerPassword": {
|
|
638
|
+
"description": "Password for accessing custom Docker registry, to be used in combination with 'dockerImageUri'. Supernova will pass it to 'docker login'. Set this to '-' to accept password from stdin.",
|
|
639
|
+
"name": "dockerPassword",
|
|
640
|
+
"required": false,
|
|
641
|
+
"hasDynamicHelp": false,
|
|
642
|
+
"multiple": false,
|
|
643
|
+
"type": "option"
|
|
627
644
|
},
|
|
628
645
|
"debug": {
|
|
629
646
|
"description": "Preserve shell directory and App.tsx on template build failures for debugging",
|
|
@@ -827,5 +844,5 @@
|
|
|
827
844
|
]
|
|
828
845
|
}
|
|
829
846
|
},
|
|
830
|
-
"version": "2.0.
|
|
847
|
+
"version": "2.0.43"
|
|
831
848
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supernovaio/cli",
|
|
3
3
|
"description": "Supernova.io Command Line Interface",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.43",
|
|
5
5
|
"author": "Supernova.io",
|
|
6
6
|
"bin": {
|
|
7
7
|
"supernova": "./bin/run"
|
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
"@oclif/core": "^4",
|
|
13
13
|
"@oclif/plugin-help": "^6",
|
|
14
14
|
"@oclif/plugin-plugins": "^5",
|
|
15
|
-
"@sentry/nestjs": "
|
|
16
|
-
"@sentry/node": "
|
|
17
|
-
"@sentry/profiling-node": "
|
|
15
|
+
"@sentry/nestjs": "10.43.0",
|
|
16
|
+
"@sentry/node": "10.43.0",
|
|
17
|
+
"@sentry/profiling-node": "10.43.0",
|
|
18
18
|
"@sindresorhus/slugify": "^2.2.1",
|
|
19
|
-
"@supernova-studio/client": "1.
|
|
20
|
-
"@supernova-studio/model": "1.
|
|
21
|
-
"@supernova-studio/pulsar-core": "2.7.
|
|
22
|
-
"@supernova-studio/pulsar-language": "2.7.
|
|
19
|
+
"@supernova-studio/client": "1.87.8",
|
|
20
|
+
"@supernova-studio/model": "1.87.8",
|
|
21
|
+
"@supernova-studio/pulsar-core": "2.7.13",
|
|
22
|
+
"@supernova-studio/pulsar-language": "2.7.13",
|
|
23
23
|
"@supernova-studio/simple-parse-github-url": "1.0.0",
|
|
24
24
|
"@supernovaio/sdk": "2.2.54",
|
|
25
25
|
"@types/fs-extra": "^11.0.4",
|
|
26
26
|
"adm-zip": "^0.5.16",
|
|
27
|
-
"axios": "^1.13.
|
|
27
|
+
"axios": "^1.13.6",
|
|
28
28
|
"cli-progress": "^3.12.0",
|
|
29
29
|
"colors": "^1.4.0",
|
|
30
30
|
"dotenv": "^16.4.7",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@mui/material": "^6.4.4",
|
|
56
56
|
"@oclif/prettier-config": "^0.2.1",
|
|
57
57
|
"@oclif/test": "^4",
|
|
58
|
-
"@sentry/cli": "
|
|
58
|
+
"@sentry/cli": "3.3.3",
|
|
59
59
|
"@supernovaio/export-helpers": "^1.0.30",
|
|
60
60
|
"@supernovaio/sdk-exporters": "^2.0.36",
|
|
61
61
|
"@types/adm-zip": "^0.5.7",
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process"
|
|
2
|
-
import fs from "node:fs"
|
|
3
|
-
import path from "node:path"
|
|
4
|
-
|
|
5
|
-
const PRIVATE_DEPS_DIR_NAME = "private-deps"
|
|
6
|
-
|
|
7
|
-
;(() => {
|
|
8
|
-
const packageJsonPath = path.join(process.cwd(), "package.json")
|
|
9
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString())
|
|
10
|
-
|
|
11
|
-
const privateDependencies = packageJson.supernova?.privateDependencies
|
|
12
|
-
if (!privateDependencies) return
|
|
13
|
-
if (!Array.isArray(privateDependencies)) {
|
|
14
|
-
throw new TypeError(
|
|
15
|
-
`supernova.privateDependencies must be an array, example: "privateDependencies": ["@example/package"]`,
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (privateDependencies.length === 0) return
|
|
20
|
-
|
|
21
|
-
// Validate all private dependencies
|
|
22
|
-
for (const [i, d] of privateDependencies.entries()) {
|
|
23
|
-
if (typeof d !== "string") {
|
|
24
|
-
throw new TypeError(`Invalid value at supernova.privateDependencies[${i}]: '${d}'`)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (!packageJson.dependencies[d]) {
|
|
28
|
-
throw new Error(`Private dependency ${d} must be present in package.json dependencies`)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (!fs.existsSync(getDependencySourceFullPath(d))) {
|
|
32
|
-
throw new Error(`Private dependency ${d} must be present in node_modules`)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
for (const dependency of privateDependencies) {
|
|
37
|
-
// Move the dependency
|
|
38
|
-
const src = getDependencySourceFullPath(dependency)
|
|
39
|
-
const target = getDependencyTargetFullPath(dependency)
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
// Make sure the target directory exists
|
|
43
|
-
fs.mkdirSync(target, { recursive: true })
|
|
44
|
-
|
|
45
|
-
// Copy folder to private-deps
|
|
46
|
-
execSync(`cp -R ${src}/ ${path.dirname(target)}`)
|
|
47
|
-
|
|
48
|
-
// Remove from source
|
|
49
|
-
fs.rmSync(src, { recursive: true })
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.error(`Couldn't move dependency ${dependency} from ${src} to ${target}`)
|
|
52
|
-
throw error
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Switch dependency from version to file directive
|
|
56
|
-
packageJson.dependencies[dependency] = `file:${getDependencyTargetRelativePath(dependency)}`
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
fs.writeFileSync(packageJsonPath, Buffer.from(JSON.stringify(packageJson, null, 2) + "\n"))
|
|
60
|
-
})()
|
|
61
|
-
|
|
62
|
-
function getDependencySourceFullPath(name) {
|
|
63
|
-
return path.join(process.cwd(), "node_modules", name)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function getDependencyTargetFullPath(name) {
|
|
67
|
-
return path.join(process.cwd(), PRIVATE_DEPS_DIR_NAME, name)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function getDependencyTargetRelativePath(name) {
|
|
71
|
-
return path.join(".", PRIVATE_DEPS_DIR_NAME, name)
|
|
72
|
-
}
|
|
73
|
-
!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]="c8431c5b-b015-5d9d-bdef-9202f73e7f49")}catch(e){}}();
|
|
74
|
-
//# debugId=c8431c5b-b015-5d9d-bdef-9202f73e7f49
|