@supernovaio/cli-next 2.0.18 → 2.0.20
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.
|
@@ -103,7 +103,7 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
103
103
|
const { signedUrl, storybookUploadId } = await storybookHosting.getSignedUploadUrl(designSystemId, { name });
|
|
104
104
|
try {
|
|
105
105
|
await this.uploadArchiveToSignedUrl({ designSystemId, name, signedUrl, storybookUploadId, zipPath });
|
|
106
|
-
this.log("✅ Upload complete."
|
|
106
|
+
this.log("✅ Upload complete.");
|
|
107
107
|
this.log("Processing Storybook files...");
|
|
108
108
|
let status;
|
|
109
109
|
action.start("Deploying Storybook to private Supernova hosting service...");
|
|
@@ -122,16 +122,16 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
122
122
|
unknownStatusCount = 0;
|
|
123
123
|
}
|
|
124
124
|
if (unknownStatusCount >= 5) {
|
|
125
|
-
this.error("Failed to deploy Storybook: Internal server error"
|
|
125
|
+
this.error("Failed to deploy Storybook: Internal server error");
|
|
126
126
|
}
|
|
127
127
|
} while (status.status !== "Completed" || (status.timestamp && status.timestamp < startTime));
|
|
128
128
|
if (status.status === "Failed") {
|
|
129
|
-
action.stop("\nFailed to deploy Storybook: Internal server error"
|
|
129
|
+
action.stop("\nFailed to deploy Storybook: Internal server error");
|
|
130
130
|
}
|
|
131
131
|
else {
|
|
132
132
|
const { accessToken } = await storybookHosting.getAccessToken(designSystemId, name);
|
|
133
133
|
const storybookUrl = storybookEndpoint(env, designSystemId, name, accessToken);
|
|
134
|
-
action.stop("\n✅ Private Storybook deployed successfully!"
|
|
134
|
+
action.stop("\n✅ Private Storybook deployed successfully!");
|
|
135
135
|
try {
|
|
136
136
|
this.log(`Connecting Storybook as a data source in Supernova...`);
|
|
137
137
|
let storiesCount = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-storybook.js","sourceRoot":"","sources":["../../src/commands/import-stor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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;;AA5VY;IAFZ,YAAY,EAAE;;;;0CAqId","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { action } from \"@oclif/core/ux\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport slugify from \"@sindresorhus/slugify\"\nimport { DTODataSourceStorybook } 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 { z, ZodType } from \"zod\"\n\nimport { commonFlags, getTargetEnv, SentryCommand, storybookUrlForEnvironment, TargetEnv } from \"../types/index.js\"\nimport { sleep } from \"../utils/common.js\"\nimport { getApiClient } from \"../utils/index.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 ImportStorybookConfigSchema = z\n .object({\n brandId: z.string().optional(),\n designSystemId: z.string().optional(),\n dir: z.string().optional(),\n name: z.string().optional(),\n sourceId: z.string().optional(),\n versionId: z.string().optional(),\n })\n .transform(data => ({\n ...data,\n }))\n\ntype ImportStorybookConfig = z.infer<typeof ImportStorybookConfigSchema>\n\nconst storybookEndpoint = (\n environment: TargetEnv,\n designSystemId: string,\n name: string,\n accessToken: string,\n): string => {\n const host = storybookUrlForEnvironment(environment)\n const encodedAccessToken = encodeURIComponent(accessToken)\n return `${host}/design-systems/${designSystemId}/alias/${name}/index.html?storybook_jwt=${encodedAccessToken}`\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 = [\n \"<%= config.bin %> <%= command.id %> import-storybook --designSystemId=123 --dir ./storybook-static.zip\",\n ]\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 dir: Flags.string({\n char: \"d\",\n default: \"./storybook-static\",\n description: \"Directory with storybook static export to import.\",\n }),\n name: Flags.string({ char: \"a\", description: \"Import storybooks with name of\" }),\n sourceId: Flags.string({ char: \"s\", description: \"Import storybooks to source of\" }),\n }\n\n get commandId(): string {\n return ImportStorybook.id\n }\n\n get configSchema(): ZodType<ImportStorybookConfig> {\n return ImportStorybookConfigSchema\n }\n\n @SentryTraced()\n // eslint-disable-next-line complexity\n public async run(): Promise<void> {\n const startTime = Date.now()\n const { flags } = await this.parse(ImportStorybook)\n\n const env = getTargetEnv()\n const { brandId: bId, designSystemId: dsId, dir, name: nameInput, sourceId } = flags\n const name = slugify(await this.askName(nameInput), { lowercase: true })\n let designSystemId = dsId\n let brandId = bId\n\n const apiClient = await getApiClient(env)\n const { designSystems } = apiClient\n const { sources, storybookHosting } = designSystems\n\n if (!designSystemId) {\n designSystemId = await this.getDesignSystemId(env, designSystemId)\n\n if (!designSystemId) {\n this.error(\"Design system ID is required\")\n }\n\n this.saveConfig({ designSystemId })\n }\n\n if (!brandId) {\n brandId = await this.getBrandId(env, designSystemId, \"head\")\n\n if (!brandId) {\n this.error(\"Brand ID is required\")\n }\n\n this.saveConfig({ brandId })\n }\n\n const directoryValidation = this.validateStorybookDirectory(dir)\n if (!directoryValidation.isValid) {\n this.error(directoryValidation.error!)\n }\n\n this.log(`Preparing Storybook files from ${dir}...`)\n const { sizeBytes, zipPath } = this.createZipFromDirectory(dir)\n\n const sizeValidation = this.validateZipSize(zipPath, sizeBytes)\n if (!sizeValidation.isValid) {\n this.error(sizeValidation.error!)\n }\n\n const { signedUrl, storybookUploadId } = await storybookHosting.getSignedUploadUrl(designSystemId, { name })\n\n try {\n await this.uploadArchiveToSignedUrl({ designSystemId, name, signedUrl, storybookUploadId, zipPath })\n this.log(\"✅ Upload complete.\".green)\n this.log(\"Processing Storybook files...\")\n\n let status\n action.start(\"Deploying Storybook to private Supernova hosting service...\")\n\n let unknownStatusCount = 0\n try {\n do {\n // eslint-disable-next-line no-await-in-loop\n await sleep(1000)\n\n // eslint-disable-next-line no-await-in-loop\n status = await storybookHosting.getUploadStatus(designSystemId, storybookUploadId)\n\n if (status.status === \"Failed\") {\n break\n }\n\n if (status.status === \"Unknown\") {\n unknownStatusCount++\n } else {\n unknownStatusCount = 0\n }\n\n if (unknownStatusCount >= 5) {\n this.error(\"Failed to deploy Storybook: Internal server error\".red)\n }\n } while (status.status !== \"Completed\" || (status.timestamp && status.timestamp < startTime))\n\n if (status.status === \"Failed\") {\n action.stop(\"\\nFailed to deploy Storybook: Internal server error\".red)\n } else {\n const { accessToken } = await storybookHosting.getAccessToken(designSystemId, name)\n const storybookUrl = storybookEndpoint(env, designSystemId, name, accessToken)\n\n action.stop(\"\\n✅ Private Storybook deployed successfully!\".green)\n\n try {\n this.log(`Connecting Storybook as a data source in Supernova...`)\n let storiesCount = 0\n // eslint-disable-next-line max-depth\n if (sourceId) {\n const { storiesCount: updatedStoriesCount } = await sources.updateStorybookImport(\n designSystemId,\n \"head\",\n {\n payload: this.getIndexJson(dir),\n sourceId,\n },\n )\n storiesCount = updatedStoriesCount\n } else {\n const { source } = await sources.create(designSystemId, {\n brandPersistentId: brandId,\n description: \"CLI\",\n indexUrl: storybookUrl,\n payload: this.getIndexJson(dir),\n type: \"Storybook\",\n userUrl: storybookUrl,\n })\n storiesCount = (source as unknown as DTODataSourceStorybook).storybook.storiesCount\n this.saveConfig({ sourceId: source.id })\n }\n\n this.log(`✅ Imported ${storiesCount} component stories into Supernova!`.green)\n this.log(`🔒 Access your Storybook at: ${storybookUrl}`.green)\n } catch (error) {\n this.error(\n `Failed to connect Storybook as data source: ${error instanceof Error ? error.message : String(error)}`\n .red,\n )\n }\n }\n } catch (error) {\n action.stop(`\\nFailed to deploy Storybook: ${error instanceof Error ? error.message : String(error)}`.red)\n }\n } catch (error) {\n this.error(`Failed to upload Storybook files: ${error instanceof Error ? error.message : String(error)}`)\n }\n }\n\n private async askName(inputedName?: string) {\n if (inputedName) return inputedName\n const choice = await inquirer.prompt([\n {\n message: \"What's storybook name\",\n name: \"name\",\n type: \"input\",\n },\n ])\n if (choice.name === \"exit\") {\n this.log(\"Exiting...\")\n this.exit(0)\n }\n\n const name = choice.name as string\n this.saveConfig({ name })\n return name\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 createZipFromDirectory(directoryPath: string): { 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 zip.writeZip(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 \"{}\"\n }\n\n return JSON.parse(fs.readFileSync(indexJsonPath, \"utf8\"))\n }\n\n /**\n * Uploads the zip archive to the provided signed URL\n */\n private async uploadArchiveToSignedUrl(input: {\n designSystemId: string\n name?: string\n signedUrl: string\n storybookUploadId: string\n zipPath: string\n }): Promise<void> {\n const { designSystemId, name, signedUrl, storybookUploadId, zipPath } = input\n this.log(`Securely uploading ${zipPath} to Supernova...`)\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 const fileStream = fs.createReadStream(zipPath)\n const stats = fs.statSync(zipPath)\n const fileSize = stats.size\n const fileSizeKB = Number.parseFloat(bytesToKB(fileSize))\n\n // Start the progress bar\n progressBar.start(fileSizeKB, 0)\n\n try {\n await axios.put(signedUrl, fileStream, {\n headers: {\n \"Content-Length\": fileSize,\n \"Content-Type\": \"application/zip\",\n designSystemId,\n storybookUploadId,\n ...(name && { name }),\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 /**\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: boolean } {\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 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"]}
|
|
1
|
+
{"version":3,"file":"import-storybook.js","sourceRoot":"","sources":["../../src/commands/import-storybook.ts"],"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,W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C,QAAQ,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAC9C,OAAO,EAAE,KAAK,EAAE,oBAAoB,aAAa,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;QACvE,CAAC;QAGD,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,aAAa,CAAC,CAAA;QACnD,MAAM,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;QAEjG,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO;gBACL,KAAK,EAAE,4EAA4E,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC5G,OAAO,EAAE,KAAK;aACf,CAAA;QACH,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC;IAQO,eAAe,CAAC,OAAe,EAAE,SAAiB;QACxD,IAAI,SAAS,GAAG,kBAAkB,EAAE,CAAC;YAEnC,IAAI,CAAC;gBACH,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;YACxB,CAAC;YAAC,MAAM,CAAC;YAET,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;;AA5VY;IAFZ,YAAY,EAAE;;;;0CAqId","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { action } from \"@oclif/core/ux\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport slugify from \"@sindresorhus/slugify\"\nimport { DTODataSourceStorybook } 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 { z, ZodType } from \"zod\"\n\nimport { commonFlags, getTargetEnv, SentryCommand, storybookUrlForEnvironment, TargetEnv } from \"../types/index.js\"\nimport { sleep } from \"../utils/common.js\"\nimport { getApiClient } from \"../utils/index.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 ImportStorybookConfigSchema = z\n .object({\n brandId: z.string().optional(),\n designSystemId: z.string().optional(),\n dir: z.string().optional(),\n name: z.string().optional(),\n sourceId: z.string().optional(),\n versionId: z.string().optional(),\n })\n .transform(data => ({\n ...data,\n }))\n\ntype ImportStorybookConfig = z.infer<typeof ImportStorybookConfigSchema>\n\nconst storybookEndpoint = (\n environment: TargetEnv,\n designSystemId: string,\n name: string,\n accessToken: string,\n): string => {\n const host = storybookUrlForEnvironment(environment)\n const encodedAccessToken = encodeURIComponent(accessToken)\n return `${host}/design-systems/${designSystemId}/alias/${name}/index.html?storybook_jwt=${encodedAccessToken}`\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 = [\n \"<%= config.bin %> <%= command.id %> import-storybook --designSystemId=123 --dir ./storybook-static.zip\",\n ]\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 dir: Flags.string({\n char: \"d\",\n default: \"./storybook-static\",\n description: \"Directory with storybook static export to import.\",\n }),\n name: Flags.string({ char: \"a\", description: \"Import storybooks with name of\" }),\n sourceId: Flags.string({ char: \"s\", description: \"Import storybooks to source of\" }),\n }\n\n get commandId(): string {\n return ImportStorybook.id\n }\n\n get configSchema(): ZodType<ImportStorybookConfig> {\n return ImportStorybookConfigSchema\n }\n\n @SentryTraced()\n // eslint-disable-next-line complexity\n public async run(): Promise<void> {\n const startTime = Date.now()\n const { flags } = await this.parse(ImportStorybook)\n\n const env = getTargetEnv()\n const { brandId: bId, designSystemId: dsId, dir, name: nameInput, sourceId } = flags\n const name = slugify(await this.askName(nameInput), { lowercase: true })\n let designSystemId = dsId\n let brandId = bId\n\n const apiClient = await getApiClient(env)\n const { designSystems } = apiClient\n const { sources, storybookHosting } = designSystems\n\n if (!designSystemId) {\n designSystemId = await this.getDesignSystemId(env, designSystemId)\n\n if (!designSystemId) {\n this.error(\"Design system ID is required\")\n }\n\n this.saveConfig({ designSystemId })\n }\n\n if (!brandId) {\n brandId = await this.getBrandId(env, designSystemId, \"head\")\n\n if (!brandId) {\n this.error(\"Brand ID is required\")\n }\n\n this.saveConfig({ brandId })\n }\n\n const directoryValidation = this.validateStorybookDirectory(dir)\n if (!directoryValidation.isValid) {\n this.error(directoryValidation.error!)\n }\n\n this.log(`Preparing Storybook files from ${dir}...`)\n const { sizeBytes, zipPath } = this.createZipFromDirectory(dir)\n\n const sizeValidation = this.validateZipSize(zipPath, sizeBytes)\n if (!sizeValidation.isValid) {\n this.error(sizeValidation.error!)\n }\n\n const { signedUrl, storybookUploadId } = await storybookHosting.getSignedUploadUrl(designSystemId, { name })\n\n try {\n await this.uploadArchiveToSignedUrl({ designSystemId, name, signedUrl, storybookUploadId, zipPath })\n this.log(\"✅ Upload complete.\")\n this.log(\"Processing Storybook files...\")\n\n let status\n action.start(\"Deploying Storybook to private Supernova hosting service...\")\n\n let unknownStatusCount = 0\n try {\n do {\n // eslint-disable-next-line no-await-in-loop\n await sleep(1000)\n\n // eslint-disable-next-line no-await-in-loop\n status = await storybookHosting.getUploadStatus(designSystemId, storybookUploadId)\n\n if (status.status === \"Failed\") {\n break\n }\n\n if (status.status === \"Unknown\") {\n unknownStatusCount++\n } else {\n unknownStatusCount = 0\n }\n\n if (unknownStatusCount >= 5) {\n this.error(\"Failed to deploy Storybook: Internal server error\")\n }\n } while (status.status !== \"Completed\" || (status.timestamp && status.timestamp < startTime))\n\n if (status.status === \"Failed\") {\n action.stop(\"\\nFailed to deploy Storybook: Internal server error\")\n } else {\n const { accessToken } = await storybookHosting.getAccessToken(designSystemId, name)\n const storybookUrl = storybookEndpoint(env, designSystemId, name, accessToken)\n\n action.stop(\"\\n✅ Private Storybook deployed successfully!\")\n\n try {\n this.log(`Connecting Storybook as a data source in Supernova...`)\n let storiesCount = 0\n // eslint-disable-next-line max-depth\n if (sourceId) {\n const { storiesCount: updatedStoriesCount } = await sources.updateStorybookImport(\n designSystemId,\n \"head\",\n {\n payload: this.getIndexJson(dir),\n sourceId,\n },\n )\n storiesCount = updatedStoriesCount\n } else {\n const { source } = await sources.create(designSystemId, {\n brandPersistentId: brandId,\n description: \"CLI\",\n indexUrl: storybookUrl,\n payload: this.getIndexJson(dir),\n type: \"Storybook\",\n userUrl: storybookUrl,\n })\n storiesCount = (source as unknown as DTODataSourceStorybook).storybook.storiesCount\n this.saveConfig({ sourceId: source.id })\n }\n\n this.log(`✅ Imported ${storiesCount} component stories into Supernova!`.green)\n this.log(`🔒 Access your Storybook at: ${storybookUrl}`.green)\n } catch (error) {\n this.error(\n `Failed to connect Storybook as data source: ${error instanceof Error ? error.message : String(error)}`\n .red,\n )\n }\n }\n } catch (error) {\n action.stop(`\\nFailed to deploy Storybook: ${error instanceof Error ? error.message : String(error)}`.red)\n }\n } catch (error) {\n this.error(`Failed to upload Storybook files: ${error instanceof Error ? error.message : String(error)}`)\n }\n }\n\n private async askName(inputedName?: string) {\n if (inputedName) return inputedName\n const choice = await inquirer.prompt([\n {\n message: \"What's storybook name\",\n name: \"name\",\n type: \"input\",\n },\n ])\n if (choice.name === \"exit\") {\n this.log(\"Exiting...\")\n this.exit(0)\n }\n\n const name = choice.name as string\n this.saveConfig({ name })\n return name\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 createZipFromDirectory(directoryPath: string): { 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 zip.writeZip(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 \"{}\"\n }\n\n return JSON.parse(fs.readFileSync(indexJsonPath, \"utf8\"))\n }\n\n /**\n * Uploads the zip archive to the provided signed URL\n */\n private async uploadArchiveToSignedUrl(input: {\n designSystemId: string\n name?: string\n signedUrl: string\n storybookUploadId: string\n zipPath: string\n }): Promise<void> {\n const { designSystemId, name, signedUrl, storybookUploadId, zipPath } = input\n this.log(`Securely uploading ${zipPath} to Supernova...`)\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 const fileStream = fs.createReadStream(zipPath)\n const stats = fs.statSync(zipPath)\n const fileSize = stats.size\n const fileSizeKB = Number.parseFloat(bytesToKB(fileSize))\n\n // Start the progress bar\n progressBar.start(fileSizeKB, 0)\n\n try {\n await axios.put(signedUrl, fileStream, {\n headers: {\n \"Content-Length\": fileSize,\n \"Content-Type\": \"application/zip\",\n designSystemId,\n storybookUploadId,\n ...(name && { name }),\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 /**\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: boolean } {\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 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"]}
|
package/dist/commands/whoami.js
CHANGED
|
@@ -27,7 +27,7 @@ export default class WhoAmICommand extends SentryCommand {
|
|
|
27
27
|
const env = getTargetEnv();
|
|
28
28
|
const accessToken = await this.getAccessTokenOrExit(env);
|
|
29
29
|
const user = await this.getUserOrExit(env, accessToken);
|
|
30
|
-
this.log(`Logged in as ${user.email}
|
|
30
|
+
this.log(`Logged in as ${user.email}`);
|
|
31
31
|
}
|
|
32
32
|
async getAccessTokenOrExit(env) {
|
|
33
33
|
const vaultService = new VaultService();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"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,mBAAm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K,EAAE,CAAC;YAEf,IAAI,KAAK,YAAY,oBAAoB,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;gBAC1E,IAAI,CAAC,KAAK,CACR,qGAAqG;oBACnG,wDAAwD;oBACxD,+GAA+G,CAClH,CAAA;YACH,CAAC;YAED,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;;AAzCY;IADZ,YAAY,EAAE;;;;wCAQd","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"]}
|
package/oclif.manifest.json
CHANGED