@supernovaio/cli 2.0.40 → 2.0.42
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.d.ts +0 -1
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +25 -5
- 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.map +1 -1
- package/dist/commands/template-upload.js +41 -9
- package/dist/commands/template-upload.js.map +1 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/docker-scripts/extract-private-packages-tarball.js +282 -0
- 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.d.ts.map +1 -1
- package/dist/utils/analyze-command.js +29 -2
- 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 +6 -5
- package/package.json +11 -11
- package/dist/docker-scripts/extract-private-packages.js +0 -74
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storybook-import.js","sources":["../../src/commands/storybook-import.ts"],"sourceRoot":"","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { action } from \"@oclif/core/ux\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport slugify from \"@sindresorhus/slugify\"\nimport { DesignSystemSourcesEndpoint, DTODataSourceStorybook, SupernovaApiClient } from \"@supernova-studio/client\"\nimport AdmZip from \"adm-zip\"\nimport axios from \"axios\"\nimport cliProgress from \"cli-progress\"\nimport inquirer from \"inquirer\"\nimport * as fs from \"node:fs\"\nimport path from \"node:path\"\nimport terminalLink from \"terminal-link\"\nimport { z, ZodType } from \"zod\"\n\nimport { SupernovaConfigStorybook } from \"../types/config.js\"\nimport { commonFlags, SentryCommand, storybookUrlForEnvironment, TargetEnv } from \"../types/index.js\"\nimport { sleep } from \"../utils/common.js\"\n\n// Maximum allowed size for storybook zip file (500MB)\nconst MAX_ZIP_SIZE_BYTES = 500 * 1024 * 1024\n\nconst bytesToKB = (bytes: number) => (bytes / 1024).toFixed(2)\nconst bytesToMB = (bytes: number) => (bytes / (1024 * 1024)).toFixed(2)\n\nconst ImportStorybookConfig = z.object({\n brandId: z.string().optional(),\n designSystemId: z.string().optional(),\n from: z.string().optional(),\n name: z.string().optional(),\n sourceId: z.string().optional(),\n publicAccess: z.boolean().optional(),\n})\n\ntype ImportStorybookConfig = z.infer<typeof ImportStorybookConfig>\n\nconst storybookEndpoint = (\n environment: TargetEnv,\n designSystemId: string,\n name: string,\n format: \"html\" | \"json\" = \"html\",\n): string => {\n const host = storybookUrlForEnvironment(environment)\n return `${host}/design-systems/${designSystemId}/alias/${name}/index.${format}`\n}\n\nexport default class ImportStorybook extends SentryCommand<ImportStorybookConfig> {\n static override args = {}\n static override description = \"Import storybook static export to Supernova\"\n static override examples = [\"<%= config.bin %> <%= command.id %> import-storybook \"]\n static override flags = {\n ...commonFlags,\n brandId: Flags.string({ char: \"b\", description: \"Import storybooks to brand of\" }),\n designSystemId: Flags.string({ char: \"d\", description: \"Import storybooks to design system of\" }),\n from: Flags.string({\n char: \"f\",\n description: \"Directory with storybook static export to import.\",\n }),\n name: Flags.string({ char: \"n\", description: \"Import storybooks with name of\" }),\n sourceId: Flags.string({ char: \"s\", description: \"Import storybooks to source of\" }),\n publicAccess: Flags.boolean({\n required: false,\n description:\n \"Allow public access to the published Storybook website. \" +\n \"Can be used in combination with public documentation.\",\n }),\n }\n\n get commandId(): string {\n return ImportStorybook.id\n }\n\n get configSchema(): ZodType<ImportStorybookConfig> {\n return ImportStorybookConfig\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const { flags } = await this.parse()\n const config = this.configService.get()\n const storybookConfig = config?.storybook ?? {}\n\n const { sourceId } = { ...storybookConfig, ...flags }\n\n const storybookDirectory = this.getStorybookDirectory(flags, storybookConfig)\n const storybookName = await this.getStorybookName(flags, storybookConfig)\n const designSystemId = await this.getDesignSystemId(flags, storybookConfig)\n const brandPersistentId = await this.getBrandId(flags, storybookConfig, designSystemId)\n const isPublic = this.getIsPublic(flags, storybookConfig)\n\n const apiClient = await this.apiClient()\n\n const { designSystems, storybookSites } = apiClient\n\n await this.validateDatasource(designSystems.sources, sourceId, designSystemId)\n\n this.log(`Preparing Storybook files from ${storybookDirectory}...`)\n const { sizeBytes, zipPath } = await this.createZipFromDirectory(storybookDirectory)\n\n const sizeValidation = this.validateZipSize(zipPath, sizeBytes)\n if (!sizeValidation.isValid) {\n this.error(sizeValidation.error!)\n }\n\n const { storybookSiteVersion, uploadUrl } = await storybookSites.uploadInit({\n designSystemId,\n isPublic,\n name: storybookName,\n })\n\n await this.uploadArchiveToSignedUrl({ uploadUrl, zipPath })\n this.log(\"✅ Upload complete.\")\n\n const accessType = isPublic ? \"Public\" : \"Private\"\n await runAsAction({\n start: \"Deploying Storybook to private Supernova hosting service\",\n done: \"\\n✅ \" + accessType + \" Storybook deployed successfully!\",\n fn: () => this.publishRemoteSite({ apiClient, storybookSiteVersionId: storybookSiteVersion.id }),\n })\n\n const { sourceId: finalSourceId } = await runAsAction({\n start: \"Updating Storybook stories\",\n done: \"\\n✅ Storybook stories have been updated!\",\n fn: () =>\n this.importStorybookStories({\n apiClient,\n designSystemId,\n brandPersistentId,\n sourceId,\n storybookDirectory,\n storybookName,\n }),\n })\n\n this.configService.update({\n storybook: {\n designSystemId,\n from: storybookDirectory,\n name: storybookName,\n brandId: brandPersistentId,\n sourceId: finalSourceId,\n publicAccess: isPublic,\n },\n })\n }\n\n //\n // Argument parsing\n //\n\n private async getStorybookName(flags: ImportStorybookConfig, config: SupernovaConfigStorybook) {\n let result = flags.name ?? config.name\n\n if (!result) {\n const choice = await inquirer.prompt([\n {\n message: \"Enter name of your storybook instance (it will be part of the URL)\",\n name: \"name\",\n type: \"input\",\n },\n ])\n\n if (typeof choice.name === \"string\") {\n result = choice.name\n }\n }\n\n if (!result) {\n this.error(\"Parameter `name` is required\")\n }\n\n return slugify(result, { lowercase: true })\n }\n\n private async getDesignSystemId(flags: ImportStorybookConfig, config: SupernovaConfigStorybook) {\n let designSystemId = flags.designSystemId ?? config.designSystemId\n\n if (!designSystemId) {\n designSystemId = await this.promptDesignSystemId()\n }\n\n if (!designSystemId) this.error(\"Parameter `designSystemId` is required\")\n\n return designSystemId\n }\n\n private async getBrandId(flags: ImportStorybookConfig, config: SupernovaConfigStorybook, designSystemId: string) {\n let brandId = flags.brandId ?? config.brandId\n\n if (!brandId) {\n brandId = await this.promptBrandId(designSystemId)\n }\n\n if (!brandId) this.error(\"Parameter `brandId` is required\")\n\n return brandId\n }\n\n private getStorybookDirectory(flags: ImportStorybookConfig, config: SupernovaConfigStorybook) {\n const from = flags.from ?? config.from\n if (!from) this.error(\"Parameter `from` is required\")\n\n const directoryValidation = this.validateStorybookDirectory(from)\n if (!directoryValidation.isValid) {\n this.error(directoryValidation.error)\n }\n\n return from\n }\n\n private getIsPublic(flags: ImportStorybookConfig, config: SupernovaConfigStorybook): boolean {\n return flags.publicAccess ?? config.publicAccess ?? false\n }\n\n //\n // Upload to hosting\n //\n\n /**\n * Creates a zip archive from a directory\n * @param directoryPath Path to the directory to zip\n * @returns Path to the created zip file and its size\n */\n private async createZipFromDirectory(directoryPath: string): Promise<{ sizeBytes: number; zipPath: string }> {\n const zip = new AdmZip()\n\n let totalFiles = 0\n let processedFiles = 0\n\n const countFiles = (currentPath: string) => {\n const files = fs.readdirSync(currentPath)\n\n for (const file of files) {\n const filePath = path.join(currentPath, file)\n const stat = fs.statSync(filePath)\n\n if (stat.isDirectory()) {\n countFiles(filePath)\n } else {\n totalFiles++\n }\n }\n }\n\n countFiles(directoryPath)\n\n const progressBar = new cliProgress.SingleBar(\n {\n barCompleteChar: \"\\u2588\",\n barIncompleteChar: \"\\u2591\",\n format: \"Creating zip [{bar}] {percentage}% | {value}/{total} files | Current: {filename}\",\n hideCursor: true,\n },\n cliProgress.Presets.shades_classic,\n )\n\n progressBar.start(totalFiles, 0, {\n filename: \"Initializing...\",\n })\n\n const addFilesToZip = (currentPath: string, relativePath = \"\") => {\n const files = fs.readdirSync(currentPath)\n\n for (const file of files) {\n const filePath = path.join(currentPath, file)\n const stat = fs.statSync(filePath)\n const displayPath = path.join(relativePath, file)\n\n if (stat.isDirectory()) {\n addFilesToZip(filePath, displayPath)\n } else {\n // Update the progress bar with the current file\n processedFiles++\n progressBar.update(processedFiles, {\n filename:\n displayPath.length > 40 ? \"...\" + displayPath.slice(Math.max(0, displayPath.length - 37)) : displayPath,\n })\n\n zip.addLocalFile(filePath, relativePath)\n }\n }\n }\n\n try {\n addFilesToZip(directoryPath)\n } finally {\n progressBar.stop()\n }\n\n const zipPath = `${directoryPath}.zip`\n await zip.writeZipPromise(zipPath)\n\n const sizeBytes = fs.statSync(zipPath).size\n\n return { sizeBytes, zipPath }\n }\n\n private getIndexJson(directoryPath: string) {\n const indexJsonPath = path.join(directoryPath, \"index.json\")\n if (fs.existsSync(indexJsonPath)) {\n return JSON.parse(fs.readFileSync(indexJsonPath, \"utf8\"))\n }\n\n const storiesJsonPath = path.join(directoryPath, \"stories.json\")\n if (fs.existsSync(storiesJsonPath)) {\n return JSON.parse(fs.readFileSync(storiesJsonPath, \"utf8\"))\n }\n\n throw new Error(`Can't open \"index.json\" or \"stories.json\" in path ${directoryPath}`)\n }\n\n /**\n * Uploads the zip archive to the provided signed URL\n */\n private async uploadArchiveToSignedUrl(input: { uploadUrl: string; zipPath: string }): Promise<void> {\n const { uploadUrl, zipPath } = input\n this.log(`Securely uploading ${zipPath} to Supernova...`)\n\n const fileBuffer = fs.readFileSync(zipPath)\n const fileSize = fileBuffer.byteLength\n const fileSizeKB = Number.parseFloat(bytesToKB(fileSize))\n\n // Create a new progress bar\n const progressBar = new cliProgress.SingleBar(\n {\n barCompleteChar: \"\\u2588\",\n barIncompleteChar: \"\\u2591\",\n format: \"Uploading |{bar}| {percentage}% || {value}/{total} kB\",\n hideCursor: true,\n },\n cliProgress.Presets.shades_classic,\n )\n\n // Start the progress bar\n progressBar.start(fileSizeKB, 0)\n\n try {\n await axios.put(uploadUrl, fileBuffer, {\n headers: {\n \"Content-Length\": fileSize,\n \"Content-Type\": \"application/zip\",\n },\n onUploadProgress(progressEvent) {\n const loaded = progressEvent.loaded || 0\n const loadedKB = Number.parseFloat(bytesToKB(loaded))\n progressBar.update(loadedKB)\n },\n })\n\n // Complete the progress bar\n progressBar.update(fileSizeKB)\n progressBar.stop()\n } catch (error) {\n // Make sure to stop the progress bar if there's an error\n progressBar.stop()\n throw error\n }\n }\n\n private async publishRemoteSite(input: {\n apiClient: SupernovaApiClient\n storybookSiteVersionId: string\n }): Promise<void> {\n const { apiClient, storybookSiteVersionId } = input\n\n const getStatus = async () => {\n const { storybookSiteVersion } = await apiClient.storybookSites.getVersion(storybookSiteVersionId)\n return storybookSiteVersion.uploadStatus\n }\n\n const { storybookSiteVersion: finalizedVersion } =\n await apiClient.storybookSites.uploadFinailize(storybookSiteVersionId)\n\n let lastStatus = finalizedVersion.uploadStatus\n\n // Wait for publishing to complete\n // Do 15 * 60 tries roughly correspond to at least 15 minutes\n for (let i = 0; i < 60; i++) {\n lastStatus = await getStatus()\n\n // Unknown status means the upload hasn't been picked up yet, we tolerate it for very limited amount of time\n if (lastStatus !== \"InProgress\" && lastStatus !== \"PendingUpload\") break\n\n await sleep(1000)\n }\n\n // React to publishing status\n switch (lastStatus) {\n case \"PendingUpload\":\n return this.error(\"Storybook deployment initialization failed\")\n case \"Timeout\":\n return this.error(\"Storybook deployment initialization has timed out\")\n case \"Failed\":\n return this.error(\"Storybook deployment has failed\")\n case \"InProgress\":\n return this.error(\"Storybook deployment has timed out\")\n }\n }\n\n private async importStorybookStories(input: {\n apiClient: SupernovaApiClient\n brandPersistentId: string\n designSystemId: string\n sourceId: string | undefined\n storybookDirectory: string\n storybookName: string\n }): Promise<{ sourceId: string }> {\n const { apiClient, brandPersistentId, designSystemId, storybookDirectory, storybookName } = input\n let { sourceId } = input\n\n const sourcesEndpoint = apiClient.designSystems.sources\n const storybookUrl = storybookEndpoint(this.env, designSystemId, storybookName)\n\n let storiesCount = 0\n if (sourceId) {\n const sourceUpdateResult = await sourcesEndpoint.updateStorybookImport(designSystemId, \"head\", {\n payload: this.getIndexJson(storybookDirectory),\n sourceId,\n })\n storiesCount = sourceUpdateResult.storiesCount\n } else {\n const { source } = await sourcesEndpoint.create(designSystemId, {\n brandPersistentId,\n description: \"CLI\",\n indexUrl: storybookEndpoint(this.env, designSystemId, storybookName, \"json\"),\n payload: this.getIndexJson(storybookDirectory),\n type: \"Storybook\",\n userUrl: storybookUrl,\n fileName: storybookName,\n })\n\n storiesCount = (source as unknown as DTODataSourceStorybook).storybook.storiesCount\n sourceId = source.id\n }\n\n this.log(`✅ Imported ${storiesCount} component stories into Supernova!`)\n const link = terminalLink(\"here\", storybookUrl, { fallback: (_, url) => url })\n this.log(`🔒 Access your Storybook ${link}`)\n\n return { sourceId }\n }\n\n /**\n * Validates if a directory is a valid storybook static export\n * @param directoryPath Path to the storybook directory\n * @returns An object indicating if the directory is valid and an error message if not\n */\n private validateStorybookDirectory(directoryPath: string): { error: string; isValid: false } | { isValid: true } {\n if (!fs.existsSync(directoryPath)) {\n return { error: `Directory not found: ${directoryPath}`, isValid: false }\n }\n\n if (!fs.statSync(directoryPath).isDirectory()) {\n return { error: `Not a directory: ${directoryPath}`, isValid: false }\n }\n\n // Check for essential storybook files\n const requiredFiles = [\"index.html\", \"iframe.html\"]\n const missingFiles = requiredFiles.filter(file => !fs.existsSync(path.join(directoryPath, file)))\n\n if (missingFiles.length > 0) {\n return {\n error: `Directory does not appear to be a valid Storybook export. Missing files: ${missingFiles.join(\", \")}`,\n isValid: false,\n }\n }\n\n // Check for Stories index file\n const requiredAtLeastOneFile = [\"index.json\", \"stories.json\"]\n if (!requiredAtLeastOneFile.some(file => fs.existsSync(path.join(directoryPath, file)))) {\n return {\n error:\n `Storybook directory is missing \"index.json\" or \"stories.json\".\\n` +\n `Tip: if running Storybook 6 or lower, you might need to enable \"buildStoriesJson: true\" in your Storybook config.`,\n isValid: false,\n }\n }\n\n return { isValid: true }\n }\n\n /**\n * Validates if a zip file size is within the allowed limits\n * @param zipPath Path to the zip file\n * @param sizeBytes Size of the zip file in bytes\n * @returns An object indicating if the zip is valid and an error message if not\n */\n private validateZipSize(zipPath: string, sizeBytes: number): { error?: string; isValid: boolean } {\n if (sizeBytes > MAX_ZIP_SIZE_BYTES) {\n // Delete the zip file if it's too large\n try {\n fs.unlinkSync(zipPath)\n } catch {\n // Ignore errors during cleanup\n }\n\n return {\n error: `Zip file is too large: ${bytesToMB(sizeBytes)}MB. Maximum allowed size is ${bytesToMB(MAX_ZIP_SIZE_BYTES)}MB`,\n isValid: false,\n }\n }\n\n return { isValid: true }\n }\n\n private async validateDatasource(\n sourcesEndpoint: DesignSystemSourcesEndpoint,\n sourceId: string | undefined,\n designSystemId: string,\n ) {\n if (sourceId) {\n const storybookDatasource = await sourcesEndpoint.get(designSystemId, sourceId).catch(() => null)\n if (!storybookDatasource) {\n this.error(\n \"This data source was deleted. Remove supernova.config.json and try again to create a new data source.\",\n )\n }\n }\n }\n}\n\nasync function runAsAction<T>(args: { start: string; done: string; fn: () => Promise<T> }): Promise<T> {\n action.start(args.start)\n try {\n const result = await args.fn()\n action.stop(args.done)\n return result\n } catch (error) {\n action.stop()\n throw error\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,OAAO,MAAM,uBAAuB,CAAA;AAE3C,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,WAAW,MAAM,cAAc,CAAA;AACtC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAGhC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,0BAA0B,EAAa,MAAM,mBAAmB,CAAA;AACrG,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAG1C,MAAM,kBAAkB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAA;AAE5C,MAAM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C,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;YACjG,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBACzB,IAAI,CAAC,KAAK,CACR,uGAAuG,CACxG,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;;AAzbY;IADZ,YAAY,EAAE;;;;0CAoEd;AAyXH,KAAK,UAAU,WAAW,CAAI,IAA2D;IACvF,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACxB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,EAAE,CAAA;QAC9B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,EAAE,CAAA;QACb,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC","debug_id":"37a8467d-951c-52b9-b28f-b48f19426407"}
|
|
1
|
+
{"version":3,"file":"storybook-import.js","sources":["../../src/commands/storybook-import.ts"],"sourceRoot":"","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { action } from \"@oclif/core/ux\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport slugify from \"@sindresorhus/slugify\"\nimport { DesignSystemSourcesEndpoint, DTODataSourceStorybook, SupernovaApiClient } from \"@supernova-studio/client\"\nimport AdmZip from \"adm-zip\"\nimport axios from \"axios\"\nimport cliProgress from \"cli-progress\"\nimport inquirer from \"inquirer\"\nimport * as fs from \"node:fs\"\nimport path from \"node:path\"\nimport terminalLink from \"terminal-link\"\nimport { z, ZodType } from \"zod\"\n\nimport { SupernovaConfigStorybook } from \"../types/config.js\"\nimport { commonFlags, SentryCommand, storybookUrlForEnvironment, TargetEnv } from \"../types/index.js\"\nimport { sleep } from \"../utils/common.js\"\n\n// Maximum allowed size for storybook zip file (500MB)\nconst MAX_ZIP_SIZE_BYTES = 500 * 1024 * 1024\n\nconst bytesToKB = (bytes: number) => (bytes / 1024).toFixed(2)\nconst bytesToMB = (bytes: number) => (bytes / (1024 * 1024)).toFixed(2)\n\nconst ImportStorybookConfig = z.object({\n brandId: z.string().optional(),\n designSystemId: z.string().optional(),\n from: z.string().optional(),\n name: z.string().optional(),\n sourceId: z.string().optional(),\n publicAccess: z.boolean().optional(),\n})\n\ntype ImportStorybookConfig = z.infer<typeof ImportStorybookConfig>\n\nconst storybookEndpoint = (\n environment: TargetEnv,\n designSystemId: string,\n name: string,\n format: \"html\" | \"json\" = \"html\",\n): string => {\n const host = storybookUrlForEnvironment(environment)\n return `${host}/design-systems/${designSystemId}/alias/${name}/index.${format}`\n}\n\nexport default class ImportStorybook extends SentryCommand<ImportStorybookConfig> {\n static override args = {}\n static override description = \"Import storybook static export to Supernova\"\n static override examples = [\"<%= config.bin %> <%= command.id %> import-storybook \"]\n static override flags = {\n ...commonFlags,\n brandId: Flags.string({ char: \"b\", description: \"Import storybooks to brand of\" }),\n designSystemId: Flags.string({ char: \"d\", description: \"Import storybooks to design system of\" }),\n from: Flags.string({\n char: \"f\",\n description: \"Directory with storybook static export to import.\",\n }),\n name: Flags.string({ char: \"n\", description: \"Import storybooks with name of\" }),\n sourceId: Flags.string({ char: \"s\", description: \"Import storybooks to source of\" }),\n publicAccess: Flags.boolean({\n required: false,\n description:\n \"Allow public access to the published Storybook website. \" +\n \"Can be used in combination with public documentation.\",\n }),\n }\n\n get commandId(): string {\n return ImportStorybook.id\n }\n\n get configSchema(): ZodType<ImportStorybookConfig> {\n return ImportStorybookConfig\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const { flags } = await this.parse()\n const config = this.configService.get()\n const storybookConfig = config?.storybook ?? {}\n\n const { sourceId } = { ...storybookConfig, ...flags }\n\n const storybookDirectory = this.getStorybookDirectory(flags, storybookConfig)\n const storybookName = await this.getStorybookName(flags, storybookConfig)\n const designSystemId = await this.getDesignSystemId(flags, storybookConfig)\n const brandPersistentId = await this.getBrandId(flags, storybookConfig, designSystemId)\n const isPublic = this.getIsPublic(flags, storybookConfig)\n\n const apiClient = await this.apiClient()\n\n const { designSystems, storybookSites } = apiClient\n\n await this.validateDatasource(designSystems.sources, sourceId, designSystemId)\n\n this.log(`Preparing Storybook files from ${storybookDirectory}...`)\n const { sizeBytes, zipPath } = await this.createZipFromDirectory(storybookDirectory)\n\n const sizeValidation = this.validateZipSize(zipPath, sizeBytes)\n if (!sizeValidation.isValid) {\n this.error(sizeValidation.error!)\n }\n\n const { storybookSiteVersion, uploadUrl } = await storybookSites.uploadInit({\n designSystemId,\n isPublic,\n name: storybookName,\n })\n\n await this.uploadArchiveToSignedUrl({ uploadUrl, zipPath })\n this.log(\"✅ Upload complete.\")\n\n const accessType = isPublic ? \"Public\" : \"Private\"\n await runAsAction({\n start: \"Deploying Storybook to private Supernova hosting service\",\n done: \"\\n✅ \" + accessType + \" Storybook deployed successfully!\",\n fn: () => this.publishRemoteSite({ apiClient, storybookSiteVersionId: storybookSiteVersion.id }),\n })\n\n const { sourceId: finalSourceId } = await runAsAction({\n start: \"Updating Storybook stories\",\n done: \"\\n✅ Storybook stories have been updated!\",\n fn: () =>\n this.importStorybookStories({\n apiClient,\n designSystemId,\n brandPersistentId,\n sourceId,\n storybookDirectory,\n storybookName,\n }),\n })\n\n this.configService.update({\n storybook: {\n designSystemId,\n from: storybookDirectory,\n name: storybookName,\n brandId: brandPersistentId,\n sourceId: finalSourceId,\n publicAccess: isPublic,\n },\n })\n }\n\n //\n // Argument parsing\n //\n\n private async getStorybookName(flags: ImportStorybookConfig, config: SupernovaConfigStorybook) {\n let result = flags.name ?? config.name\n\n if (!result) {\n const choice = await inquirer.prompt([\n {\n message: \"Enter name of your storybook instance (it will be part of the URL)\",\n name: \"name\",\n type: \"input\",\n },\n ])\n\n if (typeof choice.name === \"string\") {\n result = choice.name\n }\n }\n\n if (!result) {\n this.error(\"Parameter `name` is required\")\n }\n\n return slugify(result, { lowercase: true })\n }\n\n private async getDesignSystemId(flags: ImportStorybookConfig, config: SupernovaConfigStorybook) {\n let designSystemId = flags.designSystemId ?? config.designSystemId\n\n if (!designSystemId) {\n designSystemId = await this.promptDesignSystemId()\n }\n\n if (!designSystemId) this.error(\"Parameter `designSystemId` is required\")\n\n return designSystemId\n }\n\n private async getBrandId(flags: ImportStorybookConfig, config: SupernovaConfigStorybook, designSystemId: string) {\n let brandId = flags.brandId ?? config.brandId\n\n if (!brandId) {\n brandId = await this.promptBrandId(designSystemId)\n }\n\n if (!brandId) this.error(\"Parameter `brandId` is required\")\n\n return brandId\n }\n\n private getStorybookDirectory(flags: ImportStorybookConfig, config: SupernovaConfigStorybook) {\n const from = flags.from ?? config.from\n if (!from) this.error(\"Parameter `from` is required\")\n\n const directoryValidation = this.validateStorybookDirectory(from)\n if (!directoryValidation.isValid) {\n this.error(directoryValidation.error)\n }\n\n return from\n }\n\n private getIsPublic(flags: ImportStorybookConfig, config: SupernovaConfigStorybook): boolean {\n return flags.publicAccess ?? config.publicAccess ?? false\n }\n\n //\n // Upload to hosting\n //\n\n /**\n * Creates a zip archive from a directory\n * @param directoryPath Path to the directory to zip\n * @returns Path to the created zip file and its size\n */\n private async createZipFromDirectory(directoryPath: string): Promise<{ sizeBytes: number; zipPath: string }> {\n const zip = new AdmZip()\n\n let totalFiles = 0\n let processedFiles = 0\n\n const countFiles = (currentPath: string) => {\n const files = fs.readdirSync(currentPath)\n\n for (const file of files) {\n const filePath = path.join(currentPath, file)\n const stat = fs.statSync(filePath)\n\n if (stat.isDirectory()) {\n countFiles(filePath)\n } else {\n totalFiles++\n }\n }\n }\n\n countFiles(directoryPath)\n\n const progressBar = new cliProgress.SingleBar(\n {\n barCompleteChar: \"\\u2588\",\n barIncompleteChar: \"\\u2591\",\n format: \"Creating zip [{bar}] {percentage}% | {value}/{total} files | Current: {filename}\",\n hideCursor: true,\n },\n cliProgress.Presets.shades_classic,\n )\n\n progressBar.start(totalFiles, 0, {\n filename: \"Initializing...\",\n })\n\n const addFilesToZip = (currentPath: string, relativePath = \"\") => {\n const files = fs.readdirSync(currentPath)\n\n for (const file of files) {\n const filePath = path.join(currentPath, file)\n const stat = fs.statSync(filePath)\n const displayPath = path.join(relativePath, file)\n\n if (stat.isDirectory()) {\n addFilesToZip(filePath, displayPath)\n } else {\n // Update the progress bar with the current file\n processedFiles++\n progressBar.update(processedFiles, {\n filename:\n displayPath.length > 40 ? \"...\" + displayPath.slice(Math.max(0, displayPath.length - 37)) : displayPath,\n })\n\n zip.addLocalFile(filePath, relativePath)\n }\n }\n }\n\n try {\n addFilesToZip(directoryPath)\n } finally {\n progressBar.stop()\n }\n\n const zipPath = `${directoryPath}.zip`\n await zip.writeZipPromise(zipPath)\n\n const sizeBytes = fs.statSync(zipPath).size\n\n return { sizeBytes, zipPath }\n }\n\n private getIndexJson(directoryPath: string) {\n const indexJsonPath = path.join(directoryPath, \"index.json\")\n if (fs.existsSync(indexJsonPath)) {\n return JSON.parse(fs.readFileSync(indexJsonPath, \"utf8\"))\n }\n\n const storiesJsonPath = path.join(directoryPath, \"stories.json\")\n if (fs.existsSync(storiesJsonPath)) {\n return JSON.parse(fs.readFileSync(storiesJsonPath, \"utf8\"))\n }\n\n throw new Error(`Can't open \"index.json\" or \"stories.json\" in path ${directoryPath}`)\n }\n\n /**\n * Uploads the zip archive to the provided signed URL\n */\n private async uploadArchiveToSignedUrl(input: { uploadUrl: string; zipPath: string }): Promise<void> {\n const { uploadUrl, zipPath } = input\n this.log(`Securely uploading ${zipPath} to Supernova...`)\n\n const fileBuffer = fs.readFileSync(zipPath)\n const fileSize = fileBuffer.byteLength\n const fileSizeKB = Number.parseFloat(bytesToKB(fileSize))\n\n // Create a new progress bar\n const progressBar = new cliProgress.SingleBar(\n {\n barCompleteChar: \"\\u2588\",\n barIncompleteChar: \"\\u2591\",\n format: \"Uploading |{bar}| {percentage}% || {value}/{total} kB\",\n hideCursor: true,\n },\n cliProgress.Presets.shades_classic,\n )\n\n // Start the progress bar\n progressBar.start(fileSizeKB, 0)\n\n try {\n await axios.put(uploadUrl, fileBuffer, {\n headers: {\n \"Content-Length\": fileSize,\n \"Content-Type\": \"application/zip\",\n },\n onUploadProgress(progressEvent) {\n const loaded = progressEvent.loaded || 0\n const loadedKB = Number.parseFloat(bytesToKB(loaded))\n progressBar.update(loadedKB)\n },\n })\n\n // Complete the progress bar\n progressBar.update(fileSizeKB)\n progressBar.stop()\n } catch (error) {\n // Make sure to stop the progress bar if there's an error\n progressBar.stop()\n throw error\n }\n }\n\n private async publishRemoteSite(input: {\n apiClient: SupernovaApiClient\n storybookSiteVersionId: string\n }): Promise<void> {\n const { apiClient, storybookSiteVersionId } = input\n\n const getStatus = async () => {\n const { storybookSiteVersion } = await apiClient.storybookSites.getVersion(storybookSiteVersionId)\n return storybookSiteVersion.uploadStatus\n }\n\n const { storybookSiteVersion: finalizedVersion } =\n await apiClient.storybookSites.uploadFinailize(storybookSiteVersionId)\n\n let lastStatus = finalizedVersion.uploadStatus\n\n // Wait for publishing to complete\n // Do 15 * 60 tries roughly correspond to at least 15 minutes\n for (let i = 0; i < 60; i++) {\n lastStatus = await getStatus()\n\n // Unknown status means the upload hasn't been picked up yet, we tolerate it for very limited amount of time\n if (lastStatus !== \"InProgress\" && lastStatus !== \"PendingUpload\") break\n\n await sleep(1000)\n }\n\n // React to publishing status\n switch (lastStatus) {\n case \"PendingUpload\":\n return this.error(\"Storybook deployment initialization failed\")\n case \"Timeout\":\n return this.error(\"Storybook deployment initialization has timed out\")\n case \"Failed\":\n return this.error(\"Storybook deployment has failed\")\n case \"InProgress\":\n return this.error(\"Storybook deployment has timed out\")\n }\n }\n\n private async importStorybookStories(input: {\n apiClient: SupernovaApiClient\n brandPersistentId: string\n designSystemId: string\n sourceId: string | undefined\n storybookDirectory: string\n storybookName: string\n }): Promise<{ sourceId: string }> {\n const { apiClient, brandPersistentId, designSystemId, storybookDirectory, storybookName } = input\n let { sourceId } = input\n\n const sourcesEndpoint = apiClient.designSystems.sources\n const storybookUrl = storybookEndpoint(this.env, designSystemId, storybookName)\n\n let storiesCount = 0\n if (sourceId) {\n const sourceUpdateResult = await sourcesEndpoint.updateStorybookImport(designSystemId, \"head\", {\n payload: this.getIndexJson(storybookDirectory),\n sourceId,\n })\n storiesCount = sourceUpdateResult.storiesCount\n } else {\n const { source } = await sourcesEndpoint.create(designSystemId, {\n brandPersistentId,\n description: \"CLI\",\n indexUrl: storybookEndpoint(this.env, designSystemId, storybookName, \"json\"),\n payload: this.getIndexJson(storybookDirectory),\n type: \"Storybook\",\n userUrl: storybookUrl,\n fileName: storybookName,\n })\n\n storiesCount = (source as unknown as DTODataSourceStorybook).storybook.storiesCount\n sourceId = source.id\n }\n\n this.log(`✅ Imported ${storiesCount} component stories into Supernova!`)\n const link = terminalLink(\"here\", storybookUrl, { fallback: (_, url) => url })\n this.log(`🔒 Access your Storybook ${link}`)\n\n return { sourceId }\n }\n\n /**\n * Validates if a directory is a valid storybook static export\n * @param directoryPath Path to the storybook directory\n * @returns An object indicating if the directory is valid and an error message if not\n */\n private validateStorybookDirectory(directoryPath: string): { error: string; isValid: false } | { isValid: true } {\n if (!fs.existsSync(directoryPath)) {\n return { error: `Directory not found: ${directoryPath}`, isValid: false }\n }\n\n if (!fs.statSync(directoryPath).isDirectory()) {\n return { error: `Not a directory: ${directoryPath}`, isValid: false }\n }\n\n // Check for essential storybook files\n const requiredFiles = [\"index.html\", \"iframe.html\"]\n const missingFiles = requiredFiles.filter(file => !fs.existsSync(path.join(directoryPath, file)))\n\n if (missingFiles.length > 0) {\n return {\n error: `Directory does not appear to be a valid Storybook export. Missing files: ${missingFiles.join(\", \")}`,\n isValid: false,\n }\n }\n\n // Check for Stories index file\n const requiredAtLeastOneFile = [\"index.json\", \"stories.json\"]\n if (!requiredAtLeastOneFile.some(file => fs.existsSync(path.join(directoryPath, file)))) {\n return {\n error:\n `Storybook directory is missing \"index.json\" or \"stories.json\".\\n` +\n `Tip: if running Storybook 6 or lower, you might need to enable \"buildStoriesJson: true\" in your Storybook config.`,\n isValid: false,\n }\n }\n\n return { isValid: true }\n }\n\n /**\n * Validates if a zip file size is within the allowed limits\n * @param zipPath Path to the zip file\n * @param sizeBytes Size of the zip file in bytes\n * @returns An object indicating if the zip is valid and an error message if not\n */\n private validateZipSize(zipPath: string, sizeBytes: number): { error?: string; isValid: boolean } {\n if (sizeBytes > MAX_ZIP_SIZE_BYTES) {\n // Delete the zip file if it's too large\n try {\n fs.unlinkSync(zipPath)\n } catch {\n // Ignore errors during cleanup\n }\n\n return {\n error: `Zip file is too large: ${bytesToMB(sizeBytes)}MB. Maximum allowed size is ${bytesToMB(MAX_ZIP_SIZE_BYTES)}MB`,\n isValid: false,\n }\n }\n\n return { isValid: true }\n }\n\n private async validateDatasource(\n sourcesEndpoint: DesignSystemSourcesEndpoint,\n sourceId: string | undefined,\n designSystemId: string,\n ) {\n if (sourceId) {\n const storybookDatasource = await sourcesEndpoint.get(designSystemId, sourceId).catch(() => null)\n if (!storybookDatasource) {\n this.error(\n \"This data source was deleted. Remove supernova.config.json and try again to create a new data source.\",\n )\n }\n }\n }\n}\n\nasync function runAsAction<T>(args: { start: string; done: string; fn: () => Promise<T> }): Promise<T> {\n action.start(args.start)\n try {\n const result = await args.fn()\n action.stop(args.done)\n return result\n } catch (error) {\n action.stop()\n throw error\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,OAAO,MAAM,uBAAuB,CAAA;AAE3C,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,WAAW,MAAM,cAAc,CAAA;AACtC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAA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,CAAC;YAED,OAAO;gBACL,KAAK,EAAE,0BAA0B,SAAS,CAAC,SAAS,CAAC,+BAA+B,SAAS,CAAC,kBAAkB,CAAC,IAAI;gBACrH,OAAO,EAAE,KAAK;aACf,CAAA;QACH,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAC9B,eAA4C,EAC5C,QAA4B,EAC5B,cAAsB;QAEtB,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,mBAAmB,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;YACjG,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBACzB,IAAI,CAAC,KAAK,CACR,uGAAuG,CACxG,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;;AAzbY;IADZ,YAAY,EAAE;;;;0CAoEd;AAyXH,KAAK,UAAU,WAAW,CAAI,IAA2D;IACvF,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACxB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,EAAE,CAAA;QAC9B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,EAAE,CAAA;QACb,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC","debugId":"37a8467d-951c-52b9-b28f-b48f19426407"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-tokens.js","sources":["../../src/commands/sync-tokens.ts"],"sourceRoot":"","sourcesContent":["//\n// sync-tokens.ts\n// Supernova CLI\n//\n// Created by Jiri Trecak.\n// Copyright © Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\nimport { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport { z, ZodType } from \"zod\"\n\nimport { SentryCommand } from \"../types/index.js\"\n\nimport { FigmaTokensDataLoader } from \"../utils/figma-tokens-data-loader.js\"\nimport { getWritableVersion } from \"../utils/sdk.js\"\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Definition\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Configuration\n\nconst SyncDesignTokensConfigSchema = z.object({\n apiKey: z.string(),\n apiUrl: z.string().url().optional(),\n configFilePath: z.string(),\n designSystemId: z.string(),\n proxyUrl: z.string().url().optional(),\n tokenDirPath: z.string().optional(),\n tokenFilePath: z.string().optional(),\n})\n\ntype SyncDesignTokensConfig = z.infer<typeof SyncDesignTokensConfigSchema>\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Tool implementation\n\n/** Command that handles synchronization with design tokens plugin */\nexport class SyncDesignTokens extends SentryCommand<SyncDesignTokensConfig> {\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command configuration\n\n // How this command can be run\n static aliases = [\"sync-tokens\"]\n // Command help description\n static description = \"Synchronize tokens from Figma Tokens plugin to Supernova workspaces\"\n // Examples how to use the command\n static examples = [\n `$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenFilePath \"/path/to/tokens.json\" --configFilePath \"/path/to/config.json\"`,\n `$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenDirPath \"/path/to/tokens/\" --configFilePath \"/path/to/config.json\"`,\n ]\n // Static flags to enable / disable features\n static flags = {\n apiKey: Flags.string({ description: \"API key to use for accessing Supernova instance\", required: true }),\n apiUrl: Flags.string({\n description: \"API url to use for accessing Supernova instance, would ignore defaults\",\n hidden: true,\n }),\n configFilePath: Flags.string({ description: \"Path to configuration JSON file\", exclusive: [], required: true }),\n designSystemId: Flags.string({ description: \"Design System to synchronize contents with\", required: true }),\n proxyUrl: Flags.string({\n description: \"When set, CLI will use provided proxy URL for all requests\",\n hidden: true,\n required: false,\n }),\n tokenDirPath: Flags.string({\n description: \"Path to directory of JSON files containing token definitions\",\n exactlyOne: [\"tokenDirPath\", \"tokenFilePath\"],\n }),\n tokenFilePath: Flags.string({\n description: \"Path to JSON file containing token definitions\",\n exactlyOne: [\"tokenDirPath\", \"tokenFilePath\"],\n }),\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command runtime\n\n get commandId(): string {\n return SyncDesignTokens.id\n }\n\n get configSchema(): ZodType<SyncDesignTokensConfig> {\n return SyncDesignTokensConfigSchema\n }\n\n @SentryTraced()\n async run(): Promise<void> {\n const { flags } = await this.parse(SyncDesignTokens)\n\n // Get workspace -> design system –> version\n const { id, instance } = await getWritableVersion(flags)\n const dataLoader = new FigmaTokensDataLoader()\n const configDefinition = dataLoader.loadConfigFromPath(flags.configFilePath)\n const { settings } = configDefinition\n if (flags.dry) {\n settings.dryRun = true\n }\n\n const buildData = (payload: unknown) => ({\n connection: { name: \"CLI\" },\n ...dataLoader.loadConfigFromPathAsIs(flags.configFilePath),\n payload,\n })\n\n if (!flags.tokenFilePath && !flags.tokenDirPath) {\n throw new Error(`Either tokenFilePath or tokenDirPath must be provided`)\n }\n\n const tokenDefinition = flags.tokenDirPath\n ? await dataLoader.loadTokensFromDirectory(flags.tokenDirPath, flags.configFilePath)\n : await dataLoader.loadTokensFromPath(flags.tokenFilePath!)\n const response = (await instance.versions.writeTokenStudioData(id, buildData(tokenDefinition))) as {\n result: { logs: string[] }\n }\n if (response?.result?.logs && response.result.logs.length > 0) {\n for (const log of response.result.logs) {\n this.log(log)\n }\n }\n\n this.log(`\\nTokens synchronized`)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAQpD,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACnC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACrC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAA;AAQF,MAAM,OAAO,gBAAiB,SAAQ,aAAqC;IAKzE,MAAM,CAAC,OAAO,GAAG,CAAC,aAAa,CAAC,CAAA;IAEhC,MAAM,CAAC,WAAW,GAAG,qEAAqE,CAAA;IAE1F,MAAM,CAAC,QAAQ,GAAG;QAChB,gKAAgK;QAChK,2JAA2J;KAC5J,CAAA;IAED,MAAM,CAAC,KAAK,GAAG;QACb,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EA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;;2CAoCd","
|
|
1
|
+
{"version":3,"file":"sync-tokens.js","sources":["../../src/commands/sync-tokens.ts"],"sourceRoot":"","sourcesContent":["//\n// sync-tokens.ts\n// Supernova CLI\n//\n// Created by Jiri Trecak.\n// Copyright © Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\nimport { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport { z, ZodType } from \"zod\"\n\nimport { SentryCommand } from \"../types/index.js\"\n\nimport { FigmaTokensDataLoader } from \"../utils/figma-tokens-data-loader.js\"\nimport { getWritableVersion } from \"../utils/sdk.js\"\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Definition\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Configuration\n\nconst SyncDesignTokensConfigSchema = z.object({\n apiKey: z.string(),\n apiUrl: z.string().url().optional(),\n configFilePath: z.string(),\n designSystemId: z.string(),\n proxyUrl: z.string().url().optional(),\n tokenDirPath: z.string().optional(),\n tokenFilePath: z.string().optional(),\n})\n\ntype SyncDesignTokensConfig = z.infer<typeof SyncDesignTokensConfigSchema>\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Tool implementation\n\n/** Command that handles synchronization with design tokens plugin */\nexport class SyncDesignTokens extends SentryCommand<SyncDesignTokensConfig> {\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command configuration\n\n // How this command can be run\n static aliases = [\"sync-tokens\"]\n // Command help description\n static description = \"Synchronize tokens from Figma Tokens plugin to Supernova workspaces\"\n // Examples how to use the command\n static examples = [\n `$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenFilePath \"/path/to/tokens.json\" --configFilePath \"/path/to/config.json\"`,\n `$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenDirPath \"/path/to/tokens/\" --configFilePath \"/path/to/config.json\"`,\n ]\n // Static flags to enable / disable features\n static flags = {\n apiKey: Flags.string({ description: \"API key to use for accessing Supernova instance\", required: true }),\n apiUrl: Flags.string({\n description: \"API url to use for accessing Supernova instance, would ignore defaults\",\n hidden: true,\n }),\n configFilePath: Flags.string({ description: \"Path to configuration JSON file\", exclusive: [], required: true }),\n designSystemId: Flags.string({ description: \"Design System to synchronize contents with\", required: true }),\n proxyUrl: Flags.string({\n description: \"When set, CLI will use provided proxy URL for all requests\",\n hidden: true,\n required: false,\n }),\n tokenDirPath: Flags.string({\n description: \"Path to directory of JSON files containing token definitions\",\n exactlyOne: [\"tokenDirPath\", \"tokenFilePath\"],\n }),\n tokenFilePath: Flags.string({\n description: \"Path to JSON file containing token definitions\",\n exactlyOne: [\"tokenDirPath\", \"tokenFilePath\"],\n }),\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command runtime\n\n get commandId(): string {\n return SyncDesignTokens.id\n }\n\n get configSchema(): ZodType<SyncDesignTokensConfig> {\n return SyncDesignTokensConfigSchema\n }\n\n @SentryTraced()\n async run(): Promise<void> {\n const { flags } = await this.parse(SyncDesignTokens)\n\n // Get workspace -> design system –> version\n const { id, instance } = await getWritableVersion(flags)\n const dataLoader = new FigmaTokensDataLoader()\n const configDefinition = dataLoader.loadConfigFromPath(flags.configFilePath)\n const { settings } = configDefinition\n if (flags.dry) {\n settings.dryRun = true\n }\n\n const buildData = (payload: unknown) => ({\n connection: { name: \"CLI\" },\n ...dataLoader.loadConfigFromPathAsIs(flags.configFilePath),\n payload,\n })\n\n if (!flags.tokenFilePath && !flags.tokenDirPath) {\n throw new Error(`Either tokenFilePath or tokenDirPath must be provided`)\n }\n\n const tokenDefinition = flags.tokenDirPath\n ? await dataLoader.loadTokensFromDirectory(flags.tokenDirPath, flags.configFilePath)\n : await dataLoader.loadTokensFromPath(flags.tokenFilePath!)\n const response = (await instance.versions.writeTokenStudioData(id, buildData(tokenDefinition))) as {\n result: { logs: string[] }\n }\n if (response?.result?.logs && response.result.logs.length > 0) {\n for (const log of response.result.logs) {\n this.log(log)\n }\n }\n\n this.log(`\\nTokens synchronized`)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAQpD,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACnC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACrC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAA;AAQF,MAAM,OAAO,gBAAiB,SAAQ,aAAqC;IAKzE,MAAM,CAAC,OAAO,GAAG,CAAC,aAAa,CAAC,CAAA;IA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,MAAM,CAAC,IAAI,EAAE,CAAC;gBACvC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACf,CAAC;QACH,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;IACnC,CAAC;;AAnCK;IADL,YAAY,EAAE;;;;2CAoCd","debugId":"00776725-3ce8-5b09-99b1-8e3e148ce98e"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-upload.d.ts","sourceRoot":"","sources":["../../src/commands/template-upload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"template-upload.d.ts","sourceRoot":"","sources":["../../src/commands/template-upload.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAIhC,OAAO,EAAe,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAc9D,QAAA,MAAM,oBAAoB,gDAAe,CAAA;AAEzC,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAchE,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,aAAa,CAAC,oBAAoB,CAAC;IAC7E,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAAqD;IAChF,OAAgB,QAAQ,WAA0D;IAClF,OAAgB,MAAM,EAAE,OAAO,CAAQ;IACvC,OAAgB,KAAK;;;;;;;MA4BpB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAEhD;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAyGnB,oBAAoB;IAMlC,OAAO,CAAC,cAAc;YAIR,cAAc;YAId,kBAAkB;YAclB,gBAAgB;YAyBhB,eAAe;YAkBf,mBAAmB;YA0BnB,iCAAiC;CA4FhD"}
|
|
@@ -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]="42e67c9d-d6ea-592f-b5da-dc15f72b683c")}catch(e){}}();
|
|
3
3
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
4
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
5
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -17,6 +17,7 @@ import { exec as execCallback } from "node:child_process";
|
|
|
17
17
|
import * as fs from "node:fs/promises";
|
|
18
18
|
import path from "node:path";
|
|
19
19
|
import { promisify } from "node:util";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
20
21
|
import { z } from "zod";
|
|
21
22
|
import fsx from "fs-extra";
|
|
22
23
|
import crypto from "node:crypto";
|
|
@@ -27,7 +28,7 @@ import { discoverAndUpdatePackageJson, discoverFilesForTemplates } from "../util
|
|
|
27
28
|
import { fileExists, validateTemplates } from "../utils/validate-templates.js";
|
|
28
29
|
const exec = promisify(execCallback);
|
|
29
30
|
const TemplateUploadConfig = z.object({});
|
|
30
|
-
const
|
|
31
|
+
const dockerfileTemplateTarball = `
|
|
31
32
|
FROM node:22-slim
|
|
32
33
|
|
|
33
34
|
RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
@@ -35,8 +36,9 @@ RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/li
|
|
|
35
36
|
WORKDIR /home/user
|
|
36
37
|
|
|
37
38
|
COPY . .
|
|
38
|
-
RUN {{ npmTokenSecretMount }} npm i
|
|
39
|
-
RUN node docker-scripts/extract-private-packages.js
|
|
39
|
+
RUN {{ npmTokenSecretMount }} npm i
|
|
40
|
+
RUN node docker-scripts/extract-private-packages-tarball.js
|
|
41
|
+
RUN if [ -f .npmrc ]; then truncate -s 0 .npmrc; fi && if [ -f .supernova-private-deps-rewritten ]; then npm i; fi
|
|
40
42
|
`;
|
|
41
43
|
export default class TemplateUpload extends SentryCommand {
|
|
42
44
|
static args = {};
|
|
@@ -116,6 +118,13 @@ export default class TemplateUpload extends SentryCommand {
|
|
|
116
118
|
}
|
|
117
119
|
if (pkg.supernova?.privateDependencies) {
|
|
118
120
|
this.log(`Following packages will be linked as private dependencies: ${pkg.supernova.privateDependencies}`);
|
|
121
|
+
for (const dependency of pkg.supernova.privateDependencies) {
|
|
122
|
+
if (dependency.endsWith("/*"))
|
|
123
|
+
continue;
|
|
124
|
+
if (!pkg.dependencies[dependency]) {
|
|
125
|
+
this.error(`Private dependency ${dependency} is not listed in 'dependencies'`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
119
128
|
if (!(await fileExists(path.join(process.cwd(), ".npmrc")))) {
|
|
120
129
|
this.error(`CLI needs private NPM registry access to be able to bundle private dependencies.\n` +
|
|
121
130
|
`Please provide .npmrc file in the root directory and include neccessary access tokens.`);
|
|
@@ -131,6 +140,7 @@ export default class TemplateUpload extends SentryCommand {
|
|
|
131
140
|
await validateTemplates(templates, this, flags.debug);
|
|
132
141
|
templatesWithThumbnailUrls = await this.uploadThumbnailsAndBuildTemplates(apiClient, flags.workspaceId, templates);
|
|
133
142
|
}
|
|
143
|
+
const hasDesignModePlugin = await detectDesignModePlugin();
|
|
134
144
|
const buildData = await apiClient.sandboxes.builds.start({
|
|
135
145
|
workspaceId: flags.workspaceId,
|
|
136
146
|
designSystemId: flags.designSystemId,
|
|
@@ -138,6 +148,7 @@ export default class TemplateUpload extends SentryCommand {
|
|
|
138
148
|
version: pkg.version,
|
|
139
149
|
isExistingVersionUpdateAllowed: flags.force ?? false,
|
|
140
150
|
templates: templatesWithThumbnailUrls,
|
|
151
|
+
hasDesignModePlugin,
|
|
141
152
|
});
|
|
142
153
|
const url = imageUrl(buildData);
|
|
143
154
|
await this.validateDockerDaemon();
|
|
@@ -170,7 +181,7 @@ export default class TemplateUpload extends SentryCommand {
|
|
|
170
181
|
return !src.includes("node_modules/") && !src.includes(".git/") && !src.includes(".out/");
|
|
171
182
|
},
|
|
172
183
|
});
|
|
173
|
-
const cliSrcPath = path.resolve(path.dirname(
|
|
184
|
+
const cliSrcPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
174
185
|
await fsx.copy(path.join(cliSrcPath, "docker-scripts"), path.join(buildDir, "docker-scripts"));
|
|
175
186
|
}
|
|
176
187
|
async buildDockerImage(buildDir, imageUrl, npmToken) {
|
|
@@ -179,7 +190,7 @@ export default class TemplateUpload extends SentryCommand {
|
|
|
179
190
|
if (npmToken)
|
|
180
191
|
cmd += ` --secret id=NPM_TOKEN`;
|
|
181
192
|
cmd += " -f - .";
|
|
182
|
-
const dockerfile =
|
|
193
|
+
const dockerfile = dockerfileTemplateTarball.replace("{{ npmTokenSecretMount }}", npmToken ? `--mount=type=secret,id=NPM_TOKEN NPM_TOKEN="$(cat /run/secrets/NPM_TOKEN)"` : "");
|
|
183
194
|
const subprocess = exec(cmd, {
|
|
184
195
|
env: npmToken ? { ...process.env, NPM_TOKEN: npmToken } : process.env,
|
|
185
196
|
cwd: buildDir,
|
|
@@ -311,13 +322,22 @@ async function readPackageJson() {
|
|
|
311
322
|
if (typeof d !== "string") {
|
|
312
323
|
throw new TypeError(`supernova.privateDependencies[${i}] must be a string`);
|
|
313
324
|
}
|
|
314
|
-
if (!
|
|
315
|
-
throw new
|
|
325
|
+
if (!isValidPrivateDependencyEntry(d)) {
|
|
326
|
+
throw new TypeError(`supernova.privateDependencies[${i}] must be a package name or scope wildcard like "@example/*"`);
|
|
316
327
|
}
|
|
317
328
|
}
|
|
318
329
|
}
|
|
319
330
|
return pkg;
|
|
320
331
|
}
|
|
332
|
+
function isValidPrivateDependencyEntry(entry) {
|
|
333
|
+
if (!entry || entry.includes(" "))
|
|
334
|
+
return false;
|
|
335
|
+
if (entry.endsWith("/*")) {
|
|
336
|
+
const scope = entry.slice(0, -2);
|
|
337
|
+
return scope.startsWith("@") && !scope.includes("/");
|
|
338
|
+
}
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
321
341
|
function imageUrl(build) {
|
|
322
342
|
return `${build.dockerRegistryDomain}${build.build.dockerImagePath}`;
|
|
323
343
|
}
|
|
@@ -378,5 +398,17 @@ async function getFileSize(filePath) {
|
|
|
378
398
|
const stats = await fs.stat(filePath);
|
|
379
399
|
return stats.size;
|
|
380
400
|
}
|
|
401
|
+
async function detectDesignModePlugin() {
|
|
402
|
+
const viteConfigPath = path.join(process.cwd(), "vite.config.ts");
|
|
403
|
+
try {
|
|
404
|
+
const content = await fs.readFile(viteConfigPath, "utf8");
|
|
405
|
+
if (content.includes("supernovaDesignPlugin")) {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
catch {
|
|
410
|
+
}
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
381
413
|
//# sourceMappingURL=template-upload.js.map
|
|
382
|
-
//# debugId=
|
|
414
|
+
//# debugId=42e67c9d-d6ea-592f-b5da-dc15f72b683c
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-upload.js","sources":["../../src/commands/template-upload.ts"],"sourceRoot":"","sourcesContent":["import fetch from \"node-fetch\"\nimport { Flags } from \"@oclif/core\"\nimport { action } from \"@oclif/core/ux\"\nimport { SentryTraced } from \"@sentry/nestjs\"\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\"\nimport { z, ZodType } from \"zod\"\nimport fsx from \"fs-extra\"\nimport crypto from \"node:crypto\"\n\nimport { commonFlags, SentryCommand } from \"../types/index.js\"\n\nimport {\n DTOSandboxTemplateBuildCreateInput,\n DTOSandboxTemplateBuildCreateResponse,\n SupernovaApiClient,\n} from \"@supernova-studio/client\"\nimport { sleep } from \"../utils/common.js\"\nimport { tmpdir } from \"node:os\"\nimport { discoverAndUpdatePackageJson, discoverFilesForTemplates } from \"../utils/discover.js\"\nimport { fileExists, TemplatePreset, validateTemplates } from \"../utils/validate-templates.js\"\n\nconst exec = promisify(execCallback)\n\nconst TemplateUploadConfig = z.object({})\n\ntype TemplateUploadConfig = z.infer<typeof TemplateUploadConfig>\n\nconst dockerfileTemplate = `\nFROM node:22-slim\n\nRUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*\n\nWORKDIR /home/user\n\nCOPY . .\nRUN {{ npmTokenSecretMount }} npm i && truncate -s 0 .npmrc\nRUN node docker-scripts/extract-private-packages.js\n`\nexport default class TemplateUpload extends SentryCommand<TemplateUploadConfig> {\n static override args = {}\n static override description = \"Upload component container template to Supernova\"\n static override examples = [\"<%= config.bin %> <%= command.id %> TemplateUpload \"]\n static override hidden: boolean = false\n static override flags = {\n ...commonFlags,\n workspaceId: Flags.string({ char: \"w\", description: \"Workspace ID to upload the template to\", required: false }),\n designSystemId: Flags.string({\n char: \"d\",\n description: \"Design system ID to upload the template to\",\n required: false,\n }),\n force: Flags.boolean({\n char: \"f\",\n description:\n \"Allows overwriting already published version of this template if it exists. This flag has no effect on new versions.\",\n required: false,\n }),\n npmToken: Flags.string({\n description:\n \"Allows passing NPM token as a Docker secret. The token will be available as a NPM_TOKEN env variable\",\n required: false,\n }),\n discover: Flags.boolean({\n description: \"Run template and pattern discovery before upload to update package.json\",\n required: false,\n }),\n debug: Flags.boolean({\n description: \"Preserve shell directory and App.tsx on template build failures for debugging\",\n required: false,\n hidden: true,\n }),\n }\n\n get commandId(): string {\n return TemplateUpload.id\n }\n\n get configSchema(): ZodType<TemplateUploadConfig> {\n return TemplateUploadConfig\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const apiClient = await this.apiClient()\n const { flags } = await this.parse()\n\n // Update package.json with discovered names/descriptions if requested\n if (flags.discover) {\n action.start(\"🔍 Running template and pattern discovery\")\n try {\n const { templates, patterns } = await discoverAndUpdatePackageJson(process.cwd())\n action.stop(`found ${Object.keys(templates).length} templates, ${Object.keys(patterns).length} patterns`)\n } catch (error) {\n action.stop(\"failed\")\n if (error instanceof Error) this.error(`Discovery failed: ${error.message}`)\n else throw error\n }\n }\n\n // Check if this is discover-only mode\n const isDiscoverOnly = flags.discover && !flags.workspaceId && !flags.designSystemId\n\n if (isDiscoverOnly) {\n this.log(\"✅ Discovery completed. Use --workspaceId and --designSystemId to upload templates.\")\n return\n }\n\n // Validate required flags for upload\n if (!flags.workspaceId) {\n this.error(\"Missing required flag workspaceId\")\n }\n\n if (!flags.designSystemId) {\n this.error(\"Missing required flag designSystemId\")\n }\n\n // Read package json\n let pkg\n try {\n pkg = await readPackageJson()\n } catch (error) {\n if (error instanceof Error) this.error(`Failed to read or parse package.json: ${error.message}`)\n else throw error\n }\n\n if (pkg.supernova?.privateDependencies) {\n this.log(`Following packages will be linked as private dependencies: ${pkg.supernova.privateDependencies}`)\n\n if (!(await fileExists(path.join(process.cwd(), \".npmrc\")))) {\n this.error(\n `CLI needs private NPM registry access to be able to bundle private dependencies.\\n` +\n `Please provide .npmrc file in the root directory and include neccessary access tokens.`,\n )\n }\n } else {\n this.warn(`package.json doesn't contain 'supernova.privateDependencies' declaration.`)\n this.warn(`Dependencies coming from private registries will fail`)\n }\n\n let templatesWithThumbnailUrls: DTOSandboxTemplateBuildCreateInput[\"templates\"] | undefined\n\n if (pkg.supernova?.templates) {\n // Always enrich templates from package.json with discovered files/thumbnails info on the fly\n const templates = await discoverFilesForTemplates(pkg.supernova.templates, process.cwd())\n\n await validateTemplates(templates, this, flags.debug)\n templatesWithThumbnailUrls = await this.uploadThumbnailsAndBuildTemplates(apiClient, flags.workspaceId, templates)\n }\n\n // Request build\n const buildData = await apiClient.sandboxes.builds.start({\n workspaceId: flags.workspaceId,\n designSystemId: flags.designSystemId,\n name: pkg.name,\n version: pkg.version,\n isExistingVersionUpdateAllowed: flags.force ?? false,\n templates: templatesWithThumbnailUrls,\n })\n\n // Build image\n const url = imageUrl(buildData)\n\n await this.validateDockerDaemon()\n const buildDir = await this.createBuildDir()\n\n try {\n await this.prepareBuildFolder(buildDir)\n await this.buildDockerImage(buildDir, url, flags.npmToken)\n await this.pushDockerImage(buildDir, buildData.dockerRegistryDomain, url)\n await this.remoteTemplateBuild(apiClient, buildData.build.id)\n\n this.log(`✅ Template has been successfully uploaded`)\n } finally {\n await this.deleteBuildDir(buildDir)\n }\n }\n\n private async validateDockerDaemon() {\n await exec(\"docker info\").catch(() => {\n this.error(`Docker is not available, please start docker daemon and try again`)\n })\n }\n\n private createBuildDir(): Promise<string> {\n return fs.mkdtemp(path.join(tmpdir(), \"supernova-template-bundle-\"))\n }\n\n private async deleteBuildDir(buildDir: string) {\n await fs.rm(buildDir, { recursive: true, force: true })\n }\n\n private async prepareBuildFolder(buildDir: string) {\n // Move working directory to temp folder from where it will be built\n await fsx.copy(process.cwd(), buildDir, {\n filter(src) {\n return !src.includes(\"node_modules/\") && !src.includes(\".git/\") && !src.includes(\".out/\")\n },\n })\n\n // Inject Supernova scripts\n const cliSrcPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), \"..\")\n\n await fsx.copy(path.join(cliSrcPath, \"docker-scripts\"), path.join(buildDir, \"docker-scripts\"))\n }\n\n private async buildDockerImage(buildDir: string, imageUrl: string, npmToken: string | undefined) {\n action.start(\"🔨 Building docker image\")\n\n let cmd = `docker build -t ${imageUrl} --pull --platform linux/amd64`\n if (npmToken) cmd += ` --secret id=NPM_TOKEN`\n cmd += \" -f - .\"\n\n const dockerfile = dockerfileTemplate.replace(\n \"{{ npmTokenSecretMount }}\",\n npmToken ? `--mount=type=secret,id=NPM_TOKEN NPM_TOKEN=\"$(cat /run/secrets/NPM_TOKEN)\"` : \"\",\n )\n\n const subprocess = exec(cmd, {\n env: npmToken ? { ...process.env, NPM_TOKEN: npmToken } : process.env,\n cwd: buildDir,\n })\n\n subprocess.child.stdin!.write(dockerfile)\n subprocess.child.stdin!.end()\n\n await subprocess\n\n action.stop(\"done\")\n }\n\n private async pushDockerImage(buildDir: string, dockerHost: string, imageUrl: string) {\n const response = await fetch(`https://${dockerHost}/v2/`)\n if (response.status === 401) {\n // Requires auth\n const { accessToken } = (await this.apiClient()).config\n const loginProcess = exec(`docker login ${dockerHost} -u cli --password-stdin`)\n loginProcess.child.stdin!.write(accessToken)\n loginProcess.child.stdin!.end()\n await loginProcess\n }\n\n action.start(\"⬆️ Uploading docker image to Supernova\")\n await exec(`docker push ${imageUrl}`, {\n cwd: buildDir,\n })\n action.stop(\"done\")\n }\n\n private async remoteTemplateBuild(client: SupernovaApiClient, buildId: string) {\n action.start(\"📦 Creating template with the image\")\n\n // Trigger remote build phase\n await client.sandboxes.builds.finalize(buildId)\n\n // Poll every 2 seconds for roughly 5 minutes\n const pollIntervalMs = 2000\n const timeoutMs = 5 * 60 * 1000\n\n const startTime = Date.now()\n\n let build\n do {\n await sleep(pollIntervalMs)\n build = (await client.sandboxes.builds.get(buildId)).build\n } while (build.state === \"Building\" && Date.now() - startTime < timeoutMs)\n\n // Verify build state\n if (build.state !== \"Success\") {\n this.error(`Template creation failed`)\n }\n\n action.stop(\"done\")\n }\n\n private async uploadThumbnailsAndBuildTemplates(\n apiClient: SupernovaApiClient,\n workspaceId: string,\n templates: { [key: string]: TemplatePreset },\n ): Promise<DTOSandboxTemplateBuildCreateInput[\"templates\"]> {\n // Validate template names are unique\n const templateNames = Object.values(templates).map(t => t.name)\n const duplicateNames = templateNames.filter((name, index) => templateNames.indexOf(name) !== index)\n if (duplicateNames.length > 0) {\n throw new Error(\n `Duplicate template names found: ${[...new Set(duplicateNames)].join(\", \")}. Each template must have a unique name.`,\n )\n }\n\n const templateCount = Object.keys(templates).length\n action.start(`📸 Processing ${templateCount} template(s)`)\n\n const thumbnailFiles: Array<{\n name: string\n size: number\n checksum: string\n originalPath: string\n templateId: string\n }> = []\n\n // Validate thumbnail files\n for (const [templateId, template] of Object.entries(templates)) {\n if (!template.thumbnail) continue\n\n const validation = await validateThumbnailFile(templateId, template.thumbnail, this)\n if (!validation) continue\n\n try {\n const checksum = await calculateFileChecksum(validation.fullPath)\n thumbnailFiles.push({\n name: validation.name,\n size: validation.size,\n checksum,\n originalPath: validation.fullPath,\n templateId,\n })\n } catch (error) {\n this.warn(\n `Failed to calculate checksum for ${validation.fullPath}: ${error instanceof Error ? error.message : String(error)}`,\n )\n continue\n }\n }\n\n let thumbnailUrlMap: { [templateId: string]: string } = {}\n\n if (thumbnailFiles.length > 0) {\n try {\n // Request upload URLs from API\n const uploadResponse = await apiClient.files.upload({\n ownerType: \"Workspace\",\n workspaceId,\n files: thumbnailFiles.map(({ name, size, checksum }) => ({ name, size, checksum })),\n })\n\n // Upload files to signed URLs\n await uploadFilesToUrls(uploadResponse.uploadUrls, uploadResponse.files, thumbnailFiles)\n\n await apiClient.files.finalizeUpload({\n ownerType: \"Workspace\",\n workspaceId,\n fileIds: uploadResponse.uploadUrls.map(f => f.fileId),\n })\n\n // Map template IDs to their uploaded thumbnail URLs\n thumbnailUrlMap = buildTemplateUrlMap(thumbnailFiles, uploadResponse.files)\n } catch (error) {\n this.warn(`Failed to upload thumbnails: ${error instanceof Error ? error.message : String(error)}`)\n this.warn(\"Continuing without uploaded thumbnails...\")\n // Don't error out completely, just continue without uploaded thumbnails\n }\n }\n\n const message =\n thumbnailFiles.length > 0 ? `uploaded ${thumbnailFiles.length} thumbnail(s)` : \"no thumbnails to upload\"\n action.stop(message)\n\n const templatesWithUrls = Object.entries(templates).map(([id, template]) => ({\n id,\n name: template.name,\n description: template.description,\n thumbnailUrl: thumbnailUrlMap[id],\n files: template.files,\n }))\n\n return templatesWithUrls\n }\n}\n\ntype PackageJson = {\n name: string\n version: string\n dependencies: Record<string, string>\n supernova:\n | {\n privateDependencies: string[] | undefined\n templates?: {\n [key: string]: TemplatePreset\n }\n }\n | undefined\n}\n\nasync function readPackageJson(): Promise<PackageJson> {\n const pkgPath = path.join(process.cwd(), \"package.json\")\n\n if (!(await fileExists(pkgPath))) throw new Error(`package.json file was not found in the current directory`)\n\n const raw = await fs.readFile(pkgPath, \"utf8\")\n const pkg = JSON.parse(raw)\n\n if (typeof pkg !== \"object\" || pkg === null) throw new Error(`Error parsing package.json: not a json`)\n\n if (typeof pkg.name !== \"string\") throw new Error(`Error parsing package.json: 'name' must be defined`)\n if (typeof pkg.version !== \"string\") throw new Error(`Error parsing package.json: 'version' must be defined`)\n if (typeof pkg.dependencies !== \"object\" || pkg.dependencies === null)\n throw new Error(`Error parsing package.json: 'dependencies' must be defined`)\n\n if (pkg.supernova?.privateDependencies) {\n const privateDependencies = pkg.supernova?.privateDependencies\n if (!Array.isArray(privateDependencies)) throw new TypeError(`supernova.privateDependencies must be an array`)\n\n for (const [i, d] of privateDependencies.entries()) {\n if (typeof d !== \"string\") {\n throw new TypeError(`supernova.privateDependencies[${i}] must be a string`)\n }\n\n if (!pkg.dependencies[d]) {\n throw new Error(`Private dependency ${d} is not listed in 'dependencies'`)\n }\n }\n }\n\n return pkg\n}\n\nfunction imageUrl(build: DTOSandboxTemplateBuildCreateResponse) {\n return `${build.dockerRegistryDomain}${build.build.dockerImagePath}`\n}\n\nasync function validateThumbnailFile(\n templateId: string,\n thumbnailPath: string,\n logger: { warn: (msg: string) => void },\n): Promise<{ name: string; size: number; fullPath: string } | undefined> {\n const allowedExtensions = [\".png\", \".jpg\", \".jpeg\", \".svg\", \".webp\"]\n const maxFileSize = 10 * 1024 * 1024 // 10 MB in bytes\n\n const fullPath = path.resolve(thumbnailPath)\n const name = path.basename(thumbnailPath)\n\n if (!(await fileExists(fullPath))) {\n logger.warn(`Thumbnail file not found for template ${templateId}: ${thumbnailPath}`)\n return undefined\n }\n\n const extension = path.extname(thumbnailPath).toLowerCase()\n if (!allowedExtensions.includes(extension)) {\n logger.warn(\n `Thumbnail file ${name} for template ${templateId} has unsupported format. Allowed formats: ${allowedExtensions.join(\", \")}`,\n )\n return undefined\n }\n\n const size = await getFileSize(fullPath)\n if (size > maxFileSize) {\n logger.warn(\n `Thumbnail file ${name} for template ${templateId} is too large (${(size / 1024 / 1024).toFixed(2)}MB). Maximum size is 10MB.`,\n )\n return undefined\n }\n\n return { name, size, fullPath }\n}\n\nasync function uploadFilesToUrls(\n uploadUrls: Array<{ fileId: string; uploadUrl: string }>,\n fileResponses: Array<{ id: string; name: string; size: number }>,\n thumbnailFiles: Array<{ name: string; size: number; originalPath: string; templateId: string }>,\n): Promise<void> {\n const uploadTasks = uploadUrls.map(async uploadUrl => {\n const fileResponse = fileResponses.find(f => f.id === uploadUrl.fileId)\n const thumbnailFile = thumbnailFiles.find(f => f.name === fileResponse?.name && f.size === fileResponse?.size)\n\n if (thumbnailFile) {\n const fileBuffer = await fs.readFile(thumbnailFile.originalPath)\n await fetch(uploadUrl.uploadUrl, {\n method: \"PUT\",\n body: fileBuffer,\n headers: {\n \"Content-Type\": \"application/octet-stream\",\n },\n })\n }\n })\n\n await Promise.all(uploadTasks)\n}\n\nfunction buildTemplateUrlMap(\n thumbnailFiles: Array<{ templateId: string; checksum: string }>,\n fileResponses: Array<{ url: string; deduplicationKey: string }>,\n): { [templateId: string]: string } {\n const thumbnailUrlMap: { [templateId: string]: string } = {}\n\n for (const thumbnailFile of thumbnailFiles) {\n const fileResponse = fileResponses.find(f => f.deduplicationKey === thumbnailFile.checksum)\n if (fileResponse) {\n thumbnailUrlMap[thumbnailFile.templateId] = fileResponse.url\n }\n }\n\n return thumbnailUrlMap\n}\n\nasync function calculateFileChecksum(filePath: string): Promise<string> {\n const fileBuffer = await fs.readFile(filePath)\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", fileBuffer)\n return Buffer.from(hashBuffer).toString(\"hex\")\n}\n\nasync function getFileSize(fileP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A;AAChC,CAAC;AAED,SAAS,mBAAmB,CAC1B,cAA+D,EAC/D,aAA+D;IAE/D,MAAM,eAAe,GAAqC,EAAE,CAAA;IAE5D,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;QAC3C,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,KAAK,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC3F,IAAI,YAAY,EAAE,CAAC;YACjB,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,YAAY,CAAC,GAAG,CAAA;QAC9D,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAA;AACxB,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,QAAgB;IACnD,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC9C,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IACpE,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAChD,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,QAAgB;IACzC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACrC,OAAO,KAAK,CAAC,IAAI,CAAA;AACnB,CAAC","debug_id":"5532f0d2-8d38-51ea-b865-7958893e3079"}
|
|
1
|
+
{"version":3,"file":"template-upload.js","sources":["../../src/commands/template-upload.ts"],"sourceRoot":"","sourcesContent":["import fetch from \"node-fetch\"\nimport { Flags } from \"@oclif/core\"\nimport { action } from \"@oclif/core/ux\"\nimport { SentryTraced } from \"@sentry/nestjs\"\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\"\nimport { fileURLToPath } from \"node:url\"\nimport { z, ZodType } from \"zod\"\nimport fsx from \"fs-extra\"\nimport crypto from \"node:crypto\"\n\nimport { commonFlags, SentryCommand } from \"../types/index.js\"\n\nimport {\n DTOSandboxTemplateBuildCreateInput,\n DTOSandboxTemplateBuildCreateResponse,\n SupernovaApiClient,\n} from \"@supernova-studio/client\"\nimport { sleep } from \"../utils/common.js\"\nimport { tmpdir } from \"node:os\"\nimport { discoverAndUpdatePackageJson, discoverFilesForTemplates, TemplateInfo } from \"../utils/discover.js\"\nimport { fileExists, TemplatePreset, validateTemplates } from \"../utils/validate-templates.js\"\n\nconst exec = promisify(execCallback)\n\nconst TemplateUploadConfig = z.object({})\n\ntype TemplateUploadConfig = z.infer<typeof TemplateUploadConfig>\n\nconst dockerfileTemplateTarball = `\nFROM node:22-slim\n\nRUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*\n\nWORKDIR /home/user\n\nCOPY . .\nRUN {{ npmTokenSecretMount }} npm i\nRUN node docker-scripts/extract-private-packages-tarball.js\nRUN if [ -f .npmrc ]; then truncate -s 0 .npmrc; fi && if [ -f .supernova-private-deps-rewritten ]; then npm i; fi\n`\nexport default class TemplateUpload extends SentryCommand<TemplateUploadConfig> {\n static override args = {}\n static override description = \"Upload component container template to Supernova\"\n static override examples = [\"<%= config.bin %> <%= command.id %> TemplateUpload \"]\n static override hidden: boolean = false\n static override flags = {\n ...commonFlags,\n workspaceId: Flags.string({ char: \"w\", description: \"Workspace ID to upload the template to\", required: false }),\n designSystemId: Flags.string({\n char: \"d\",\n description: \"Design system ID to upload the template to\",\n required: false,\n }),\n force: Flags.boolean({\n char: \"f\",\n description:\n \"Allows overwriting already published version of this template if it exists. This flag has no effect on new versions.\",\n required: false,\n }),\n npmToken: Flags.string({\n description:\n \"Allows passing NPM token as a Docker secret. The token will be available as a NPM_TOKEN env variable\",\n required: false,\n }),\n discover: Flags.boolean({\n description: \"Run template and pattern discovery before upload to update package.json\",\n required: false,\n }),\n debug: Flags.boolean({\n description: \"Preserve shell directory and App.tsx on template build failures for debugging\",\n required: false,\n hidden: true,\n }),\n }\n\n get commandId(): string {\n return TemplateUpload.id\n }\n\n get configSchema(): ZodType<TemplateUploadConfig> {\n return TemplateUploadConfig\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const apiClient = await this.apiClient()\n const { flags } = await this.parse()\n\n // Update package.json with discovered names/descriptions if requested\n if (flags.discover) {\n action.start(\"🔍 Running template and pattern discovery\")\n try {\n const { templates, patterns } = await discoverAndUpdatePackageJson(process.cwd())\n action.stop(`found ${Object.keys(templates).length} templates, ${Object.keys(patterns).length} patterns`)\n } catch (error) {\n action.stop(\"failed\")\n if (error instanceof Error) this.error(`Discovery failed: ${error.message}`)\n else throw error\n }\n }\n\n // Check if this is discover-only mode\n const isDiscoverOnly = flags.discover && !flags.workspaceId && !flags.designSystemId\n\n if (isDiscoverOnly) {\n this.log(\"✅ Discovery completed. Use --workspaceId and --designSystemId to upload templates.\")\n return\n }\n\n // Validate required flags for upload\n if (!flags.workspaceId) {\n this.error(\"Missing required flag workspaceId\")\n }\n\n if (!flags.designSystemId) {\n this.error(\"Missing required flag designSystemId\")\n }\n\n // Read package json\n let pkg\n try {\n pkg = await readPackageJson()\n } catch (error) {\n if (error instanceof Error) this.error(`Failed to read or parse package.json: ${error.message}`)\n else throw error\n }\n\n if (pkg.supernova?.privateDependencies) {\n this.log(`Following packages will be linked as private dependencies: ${pkg.supernova.privateDependencies}`)\n\n for (const dependency of pkg.supernova.privateDependencies) {\n if (dependency.endsWith(\"/*\")) continue\n if (!pkg.dependencies[dependency]) {\n this.error(`Private dependency ${dependency} is not listed in 'dependencies'`)\n }\n }\n\n if (!(await fileExists(path.join(process.cwd(), \".npmrc\")))) {\n this.error(\n `CLI needs private NPM registry access to be able to bundle private dependencies.\\n` +\n `Please provide .npmrc file in the root directory and include neccessary access tokens.`,\n )\n }\n } else {\n this.warn(`package.json doesn't contain 'supernova.privateDependencies' declaration.`)\n this.warn(`Dependencies coming from private registries will fail`)\n }\n\n let templatesWithThumbnailUrls: DTOSandboxTemplateBuildCreateInput[\"templates\"] | undefined\n\n if (pkg.supernova?.templates) {\n // Always enrich templates from package.json with discovered files/thumbnails info on the fly\n const templates = await discoverFilesForTemplates(pkg.supernova.templates, process.cwd())\n\n await validateTemplates(templates, this, flags.debug)\n templatesWithThumbnailUrls = await this.uploadThumbnailsAndBuildTemplates(apiClient, flags.workspaceId, templates)\n }\n\n const hasDesignModePlugin = await detectDesignModePlugin()\n\n // Request build\n const buildData = await apiClient.sandboxes.builds.start({\n workspaceId: flags.workspaceId,\n designSystemId: flags.designSystemId,\n name: pkg.name,\n version: pkg.version,\n isExistingVersionUpdateAllowed: flags.force ?? false,\n templates: templatesWithThumbnailUrls,\n hasDesignModePlugin,\n })\n\n // Build image\n const url = imageUrl(buildData)\n\n await this.validateDockerDaemon()\n const buildDir = await this.createBuildDir()\n\n try {\n await this.prepareBuildFolder(buildDir)\n await this.buildDockerImage(buildDir, url, flags.npmToken)\n await this.pushDockerImage(buildDir, buildData.dockerRegistryDomain, url)\n await this.remoteTemplateBuild(apiClient, buildData.build.id)\n\n this.log(`✅ Template has been successfully uploaded`)\n } finally {\n await this.deleteBuildDir(buildDir)\n }\n }\n\n private async validateDockerDaemon() {\n await exec(\"docker info\").catch(() => {\n this.error(`Docker is not available, please start docker daemon and try again`)\n })\n }\n\n private createBuildDir(): Promise<string> {\n return fs.mkdtemp(path.join(tmpdir(), \"supernova-template-bundle-\"))\n }\n\n private async deleteBuildDir(buildDir: string) {\n await fs.rm(buildDir, { recursive: true, force: true })\n }\n\n private async prepareBuildFolder(buildDir: string) {\n // Move working directory to temp folder from where it will be built\n await fsx.copy(process.cwd(), buildDir, {\n filter(src) {\n return !src.includes(\"node_modules/\") && !src.includes(\".git/\") && !src.includes(\".out/\")\n },\n })\n\n // Inject Supernova scripts\n const cliSrcPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"..\")\n\n await fsx.copy(path.join(cliSrcPath, \"docker-scripts\"), path.join(buildDir, \"docker-scripts\"))\n }\n\n private async buildDockerImage(buildDir: string, imageUrl: string, npmToken: string | undefined) {\n action.start(\"🔨 Building docker image\")\n\n let cmd = `docker build -t ${imageUrl} --pull --platform linux/amd64`\n if (npmToken) cmd += ` --secret id=NPM_TOKEN`\n cmd += \" -f - .\"\n\n const dockerfile = dockerfileTemplateTarball.replace(\n \"{{ npmTokenSecretMount }}\",\n npmToken ? `--mount=type=secret,id=NPM_TOKEN NPM_TOKEN=\"$(cat /run/secrets/NPM_TOKEN)\"` : \"\",\n )\n\n const subprocess = exec(cmd, {\n env: npmToken ? { ...process.env, NPM_TOKEN: npmToken } : process.env,\n cwd: buildDir,\n })\n\n subprocess.child.stdin!.write(dockerfile)\n subprocess.child.stdin!.end()\n\n await subprocess\n\n action.stop(\"done\")\n }\n\n private async pushDockerImage(buildDir: string, dockerHost: string, imageUrl: string) {\n const response = await fetch(`https://${dockerHost}/v2/`)\n if (response.status === 401) {\n // Requires auth\n const { accessToken } = (await this.apiClient()).config\n const loginProcess = exec(`docker login ${dockerHost} -u cli --password-stdin`)\n loginProcess.child.stdin!.write(accessToken)\n loginProcess.child.stdin!.end()\n await loginProcess\n }\n\n action.start(\"⬆️ Uploading docker image to Supernova\")\n await exec(`docker push ${imageUrl}`, {\n cwd: buildDir,\n })\n action.stop(\"done\")\n }\n\n private async remoteTemplateBuild(client: SupernovaApiClient, buildId: string) {\n action.start(\"📦 Creating template with the image\")\n\n // Trigger remote build phase\n await client.sandboxes.builds.finalize(buildId)\n\n // Poll every 2 seconds for roughly 5 minutes\n const pollIntervalMs = 2000\n const timeoutMs = 5 * 60 * 1000\n\n const startTime = Date.now()\n\n let build\n do {\n await sleep(pollIntervalMs)\n build = (await client.sandboxes.builds.get(buildId)).build\n } while (build.state === \"Building\" && Date.now() - startTime < timeoutMs)\n\n // Verify build state\n if (build.state !== \"Success\") {\n this.error(`Template creation failed`)\n }\n\n action.stop(\"done\")\n }\n\n private async uploadThumbnailsAndBuildTemplates(\n apiClient: SupernovaApiClient,\n workspaceId: string,\n templates: { [key: string]: TemplateInfo },\n ): Promise<DTOSandboxTemplateBuildCreateInput[\"templates\"]> {\n // Validate template names are unique\n const templateNames = Object.values(templates).map(t => t.name)\n const duplicateNames = templateNames.filter((name, index) => templateNames.indexOf(name) !== index)\n if (duplicateNames.length > 0) {\n throw new Error(\n `Duplicate template names found: ${[...new Set(duplicateNames)].join(\", \")}. Each template must have a unique name.`,\n )\n }\n\n const templateCount = Object.keys(templates).length\n action.start(`📸 Processing ${templateCount} template(s)`)\n\n const thumbnailFiles: Array<{\n name: string\n size: number\n checksum: string\n originalPath: string\n templateId: string\n }> = []\n\n // Validate thumbnail files\n for (const [templateId, template] of Object.entries(templates)) {\n if (!template.thumbnail) continue\n\n const validation = await validateThumbnailFile(templateId, template.thumbnail, this)\n if (!validation) continue\n\n try {\n const checksum = await calculateFileChecksum(validation.fullPath)\n thumbnailFiles.push({\n name: validation.name,\n size: validation.size,\n checksum,\n originalPath: validation.fullPath,\n templateId,\n })\n } catch (error) {\n this.warn(\n `Failed to calculate checksum for ${validation.fullPath}: ${error instanceof Error ? error.message : String(error)}`,\n )\n continue\n }\n }\n\n let thumbnailUrlMap: { [templateId: string]: string } = {}\n\n if (thumbnailFiles.length > 0) {\n try {\n // Request upload URLs from API\n const uploadResponse = await apiClient.files.upload({\n ownerType: \"Workspace\",\n workspaceId,\n files: thumbnailFiles.map(({ name, size, checksum }) => ({ name, size, checksum })),\n })\n\n // Upload files to signed URLs\n await uploadFilesToUrls(uploadResponse.uploadUrls, uploadResponse.files, thumbnailFiles)\n\n await apiClient.files.finalizeUpload({\n ownerType: \"Workspace\",\n workspaceId,\n fileIds: uploadResponse.uploadUrls.map(f => f.fileId),\n })\n\n // Map template IDs to their uploaded thumbnail URLs\n thumbnailUrlMap = buildTemplateUrlMap(thumbnailFiles, uploadResponse.files)\n } catch (error) {\n this.warn(`Failed to upload thumbnails: ${error instanceof Error ? error.message : String(error)}`)\n this.warn(\"Continuing without uploaded thumbnails...\")\n // Don't error out completely, just continue without uploaded thumbnails\n }\n }\n\n const message =\n thumbnailFiles.length > 0 ? `uploaded ${thumbnailFiles.length} thumbnail(s)` : \"no thumbnails to upload\"\n action.stop(message)\n\n const templatesWithUrls = Object.entries(templates).map(([id, template]) => ({\n id,\n name: template.name,\n description: template.description,\n thumbnailUrl: thumbnailUrlMap[id],\n files: template.files,\n }))\n\n return templatesWithUrls\n }\n}\n\ntype PackageJson = {\n name: string\n version: string\n dependencies: Record<string, string>\n supernova:\n | {\n privateDependencies: string[] | undefined\n templates?: {\n [key: string]: TemplatePreset\n }\n }\n | undefined\n}\n\nasync function readPackageJson(): Promise<PackageJson> {\n const pkgPath = path.join(process.cwd(), \"package.json\")\n\n if (!(await fileExists(pkgPath))) throw new Error(`package.json file was not found in the current directory`)\n\n const raw = await fs.readFile(pkgPath, \"utf8\")\n const pkg = JSON.parse(raw)\n\n if (typeof pkg !== \"object\" || pkg === null) throw new Error(`Error parsing package.json: not a json`)\n\n if (typeof pkg.name !== \"string\") throw new Error(`Error parsing package.json: 'name' must be defined`)\n if (typeof pkg.version !== \"string\") throw new Error(`Error parsing package.json: 'version' must be defined`)\n if (typeof pkg.dependencies !== \"object\" || pkg.dependencies === null)\n throw new Error(`Error parsing package.json: 'dependencies' must be defined`)\n\n if (pkg.supernova?.privateDependencies) {\n const privateDependencies = pkg.supernova?.privateDependencies\n if (!Array.isArray(privateDependencies)) throw new TypeError(`supernova.privateDependencies must be an array`)\n\n for (const [i, d] of privateDependencies.entries()) {\n if (typeof d !== \"string\") {\n throw new TypeError(`supernova.privateDependencies[${i}] must be a string`)\n }\n\n if (!isValidPrivateDependencyEntry(d)) {\n throw new TypeError(\n `supernova.privateDependencies[${i}] must be a package name or scope wildcard like \"@example/*\"`,\n )\n }\n }\n }\n\n return pkg\n}\n\nfunction isValidPrivateDependencyEntry(entry: string): boolean {\n if (!entry || entry.includes(\" \")) return false\n if (entry.endsWith(\"/*\")) {\n const scope = entry.slice(0, -2)\n return scope.startsWith(\"@\") && !scope.includes(\"/\")\n }\n\n return true\n}\n\nfunction imageUrl(build: DTOSandboxTemplateBuildCreateResponse) {\n return `${build.dockerRegistryDomain}${build.build.dockerImagePath}`\n}\n\nasync function validateThumbnailFile(\n templateId: string,\n thumbnailPath: string,\n logger: { warn: (msg: string) => void },\n): Promise<{ name: string; size: number; fullPath: string } | undefined> {\n const allowedExtensions = [\".png\", \".jpg\", \".jpeg\", \".svg\", \".webp\"]\n const maxFileSize = 10 * 1024 * 1024 // 10 MB in bytes\n\n const fullPath = path.resolve(thumbnailPath)\n const name = path.basename(thumbnailPath)\n\n if (!(await fileExists(fullPath))) {\n logger.warn(`Thumbnail file not found for template ${templateId}: ${thumbnailPath}`)\n return undefined\n }\n\n const extension = path.extname(thumbnailPath).toLowerCase()\n if (!allowedExtensions.includes(extension)) {\n logger.warn(\n `Thumbnail file ${name} for template ${templateId} has unsupported format. Allowed formats: ${allowedExtensions.join(\", \")}`,\n )\n return undefined\n }\n\n const size = await getFileSize(fullPath)\n if (size > maxFileSize) {\n logger.warn(\n `Thumbnail file ${name} for template ${templateId} is too large (${(size / 1024 / 1024).toFixed(2)}MB). Maximum size is 10MB.`,\n )\n return undefined\n }\n\n return { name, size, fullPath }\n}\n\nasync function uploadFilesToUrls(\n uploadUrls: Array<{ fileId: string; uploadUrl: string }>,\n fileResponses: Array<{ id: string; name: string; size: number }>,\n thumbnailFiles: Array<{ name: string; size: number; originalPath: string; templateId: string }>,\n): Promise<void> {\n const uploadTasks = uploadUrls.map(async uploadUrl => {\n const fileResponse = fileResponses.find(f => f.id === uploadUrl.fileId)\n const thumbnailFile = thumbnailFiles.find(f => f.name === fileResponse?.name && f.size === fileResponse?.size)\n\n if (thumbnailFile) {\n const fileBuffer = await fs.readFile(thumbnailFile.originalPath)\n await fetch(uploadUrl.uploadUrl, {\n method: \"PUT\",\n body: fileBuffer,\n headers: {\n \"Content-Type\": \"application/octet-stream\",\n },\n })\n }\n })\n\n await Promise.all(uploadTasks)\n}\n\nfunction buildTemplateUrlMap(\n thumbnailFiles: Array<{ templateId: string; checksum: string }>,\n fileResponses: Array<{ url: string; deduplicationKey: string }>,\n): { [templateId: string]: string } {\n const thumbnailUrlMap: { [templateId: string]: string } = {}\n\n for (const thumbnailFile of thumbnailFiles) {\n const fileResponse = fileResponses.find(f => f.deduplicationKey === thumbnailFile.checksum)\n if (fileResponse) {\n thumbnailUrlMap[thumbnailFile.templateId] = fileResponse.url\n }\n }\n\n return thumbnailUrlMap\n}\n\nasync function calculateFileChecksum(filePath: string): Promise<string> {\n const fileBuffer = await fs.readFile(filePath)\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", fileBuffer)\n return Buffer.from(hashBuffer).toString(\"hex\")\n}\n\nasync function getFileSize(filePath: string): Promise<number> {\n const stats = await fs.stat(filePath)\n return stats.size\n}\n\nasync function detectDesignModePlugin(): Promise<true | undefined> {\n const viteConfigPath = path.join(process.cwd(), \"vite.config.ts\")\n\n try {\n const content = await fs.readFile(viteConfigPath, \"utf8\")\n // Simple string check — supernovaDesignPlugin won't appear in vite.config.ts by accident\n if (content.includes(\"supernovaDesignPlugin\")) {\n return true\n }\n } catch {\n // vite.config.ts not found or unreadable — ignore\n }\n\n return undefined\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,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;AACrC,OAAO,EAA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CAAC;AAED,KAAK,UAAU,sBAAsB;IACnC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAA;IAEjE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;QAEzD,IAAI,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;YAC9C,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC","debugId":"42e67c9d-d6ea-592f-b5da-dc15f72b683c"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sources":["../../src/commands/whoami.ts"],"sourceRoot":"","sourcesContent":["import { SentryTraced } from \"@sentry/nestjs\"\nimport { RequestExecutorError, SupernovaApiClient } from \"@supernova-studio/client\"\nimport { z } from \"zod\"\n\nimport { VaultService } from \"../services/vault.service.js\"\nimport { apiHostForEnvironment, commonFlags, getTargetEnv, SentryCommand, TargetEnv } from \"../types/index.js\"\n\nexport default class WhoAmICommand extends SentryCommand<object> {\n static override args = {}\n static override description = \"Print information about currently logged in user\"\n static override examples = [\"<%= config.bin %> <%= command.id %>\"]\n static override flags = commonFlags\n\n get commandId(): string {\n return WhoAmICommand.id\n }\n\n get configSchema() {\n return z.object({})\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const env = getTargetEnv()\n\n const accessToken = await this.getAccessTokenOrExit(env)\n const user = await this.getUserOrExit(env, accessToken)\n\n this.log(`Logged in as ${user.email}`)\n }\n\n private async getAccessTokenOrExit(env: TargetEnv): Promise<string> {\n const vaultService = new VaultService()\n const tokens = await vaultService.tryGetTokensFromVault(env)\n if (!tokens) {\n this.error(\n \"No active user session found. To log in try one of the following:\\n\" +\n \" - run `supernova login` to authenticate in browser\\n\" +\n \" - provide SUPERNOVA_TOKEN variable with a personal access token (can be generated in user profile settings)\",\n )\n }\n\n return tokens.accessToken\n }\n\n private async getUserOrExit(env: TargetEnv, accessToken: string) {\n const apiClient = new SupernovaApiClient({ accessToken, host: apiHostForEnvironment(env) })\n\n try {\n const { user } = await apiClient.users.getMe()\n return user\n } catch (error) {\n // TODO Artem: Add status\n if (error instanceof RequestExecutorError && error.type === \"ServerError\") {\n this.error(\n \"Current session has expired or has been revoked. To start a new session try one of the following:\\n\" +\n \" - run `supernova login` to authenticate in browser\\n\" +\n \" - provide SUPERNOVA_TOKEN variable with a personal access token (can be generated in user profile settings)\",\n )\n }\n\n throw error\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAE9G,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,aAAqB;IAC9D,MAAM,CAAU,IAAI,GAAG,EAAE,CAAA;IACzB,MAAM,CAAU,WAAW,GAAG,kDAAkD,CAAA;IAChF,MAAM,CAAU,QAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAA;IAClE,MAAM,CAAU,KAAK,GAAG,WAAW,CAAA;IAEnC,IAAI,SAAS;QACX,OAAO,aAAa,CAAC,EAAE,CAAA;IACzB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACrB,CAAC;IAGY,AAAN,KAAK,CAAC,GAAG;QACd,MAAM,GAAG,GAAG,YAAY,EAAE,CAAA;QAE1B,MAAM,WAAW,GAA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ent":["import { SentryTraced } from \"@sentry/nestjs\"\nimport { RequestExecutorError, SupernovaApiClient } from \"@supernova-studio/client\"\nimport { z } from \"zod\"\n\nimport { VaultService } from \"../services/vault.service.js\"\nimport { apiHostForEnvironment, commonFlags, getTargetEnv, SentryCommand, TargetEnv } from \"../types/index.js\"\n\nexport default class WhoAmICommand extends SentryCommand<object> {\n static override args = {}\n static override description = \"Print information about currently logged in user\"\n static override examples = [\"<%= config.bin %> <%= command.id %>\"]\n static override flags = commonFlags\n\n get commandId(): string {\n return WhoAmICommand.id\n }\n\n get configSchema() {\n return z.object({})\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const env = getTargetEnv()\n\n const accessToken = await this.getAccessTokenOrExit(env)\n const user = await this.getUserOrExit(env, accessToken)\n\n this.log(`Logged in as ${user.email}`)\n }\n\n private async getAccessTokenOrExit(env: TargetEnv): Promise<string> {\n const vaultService = new VaultService()\n const tokens = await vaultService.tryGetTokensFromVault(env)\n if (!tokens) {\n this.error(\n \"No active user session found. To log in try one of the following:\\n\" +\n \" - run `supernova login` to authenticate in browser\\n\" +\n \" - provide SUPERNOVA_TOKEN variable with a personal access token (can be generated in user profile settings)\",\n )\n }\n\n return tokens.accessToken\n }\n\n private async getUserOrExit(env: TargetEnv, accessToken: string) {\n const apiClient = new SupernovaApiClient({ accessToken, host: apiHostForEnvironment(env) })\n\n try {\n const { user } = await apiClient.users.getMe()\n return user\n } catch (error) {\n // TODO Artem: Add status\n if (error instanceof RequestExecutorError && error.type === \"ServerError\") {\n this.error(\n \"Current session has expired or has been revoked. To start a new session try one of the following:\\n\" +\n \" - run `supernova login` to authenticate in browser\\n\" +\n \" - provide SUPERNOVA_TOKEN variable with a personal access token (can be generated in user profile settings)\",\n )\n }\n\n throw error\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM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