@supernovaio/cli 2.0.26 → 2.0.28
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/commands/storybook-import.d.ts +0 -1
- package/dist/commands/storybook-import.d.ts.map +1 -1
- package/dist/commands/storybook-import.js +7 -18
- package/dist/commands/storybook-import.js.map +1 -1
- package/dist/commands/template-upload.d.ts.map +1 -1
- package/dist/commands/template-upload.js +4 -4
- package/dist/commands/template-upload.js.map +1 -1
- package/dist/services/user.service.d.ts +1 -1
- package/dist/services/user.service.d.ts.map +1 -1
- package/dist/utils/sdk.d.ts.map +1 -1
- package/dist/utils/sdk.js +6 -4
- package/dist/utils/sdk.js.map +1 -1
- package/oclif.manifest.json +3 -9
- package/package.json +7 -6
|
@@ -30,7 +30,6 @@ export default class ImportStorybook extends SentryCommand<ImportStorybookConfig
|
|
|
30
30
|
from: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
31
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
32
|
sourceId: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
33
|
-
next: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
34
33
|
};
|
|
35
34
|
get commandId(): string;
|
|
36
35
|
get configSchema(): ZodType<ImportStorybookConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storybook-import.d.ts","sourceRoot":"","sources":["../../src/commands/storybook-import.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGhC,OAAO,EAAe,aAAa,EAAyC,MAAM,mBAAmB,CAAA;AASrG,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAMzB,CAAA;AAEF,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"storybook-import.d.ts","sourceRoot":"","sources":["../../src/commands/storybook-import.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGhC,OAAO,EAAe,aAAa,EAAyC,MAAM,mBAAmB,CAAA;AASrG,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAMzB,CAAA;AAEF,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAYlE,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,aAAa,CAAC,qBAAqB,CAAC;IAC/E,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAAgD;IAC3E,OAAgB,QAAQ,WAA4D;IACpF,OAAgB,KAAK;;;;;;MAUpB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAEjD;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAgEnB,gBAAgB;YAwBhB,iBAAiB;YAYjB,UAAU;YAYV,qBAAqB;YAqBrB,sBAAsB;IA0EpC,OAAO,CAAC,YAAY;YAYN,wBAAwB;YAsDxB,iBAAiB;YA2CjB,sBAAsB;IAsDpC,OAAO,CAAC,0BAA0B;IA6BlC,OAAO,CAAC,eAAe;YAkBT,kBAAkB;CAcjC"}
|
|
@@ -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]="1466cc82-6ec9-54b8-9d89-0a3f6cb158f3")}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);
|
|
@@ -33,14 +33,9 @@ const ImportStorybookConfig = z.object({
|
|
|
33
33
|
name: z.string().optional(),
|
|
34
34
|
sourceId: z.string().optional(),
|
|
35
35
|
});
|
|
36
|
-
const storybookEndpoint = (environment, designSystemId, name,
|
|
36
|
+
const storybookEndpoint = (environment, designSystemId, name, format = "html") => {
|
|
37
37
|
const host = storybookUrlForEnvironment(environment);
|
|
38
|
-
|
|
39
|
-
if (accessToken) {
|
|
40
|
-
const encodedAccessToken = encodeURIComponent(accessToken);
|
|
41
|
-
url += `?authorization=${encodedAccessToken}`;
|
|
42
|
-
}
|
|
43
|
-
return url;
|
|
38
|
+
return `${host}/design-systems/${designSystemId}/alias/${name}/index.${format}`;
|
|
44
39
|
};
|
|
45
40
|
export default class ImportStorybook extends SentryCommand {
|
|
46
41
|
static args = {};
|
|
@@ -56,7 +51,6 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
56
51
|
}),
|
|
57
52
|
name: Flags.string({ char: "n", description: "Import storybooks with name of" }),
|
|
58
53
|
sourceId: Flags.string({ char: "s", description: "Import storybooks to source of" }),
|
|
59
|
-
next: Flags.boolean({ hidden: true, default: false }),
|
|
60
54
|
};
|
|
61
55
|
get commandId() {
|
|
62
56
|
return ImportStorybook.id;
|
|
@@ -99,7 +93,6 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
99
93
|
sourceId,
|
|
100
94
|
storybookDirectory,
|
|
101
95
|
storybookName,
|
|
102
|
-
next: flags.next,
|
|
103
96
|
});
|
|
104
97
|
action.stop("\n✅ Storybook stories have been updated!");
|
|
105
98
|
this.configService.update({
|
|
@@ -286,14 +279,10 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
286
279
|
}
|
|
287
280
|
}
|
|
288
281
|
async importStorybookStories(input) {
|
|
289
|
-
const { apiClient, brandPersistentId, designSystemId, storybookDirectory, storybookName
|
|
282
|
+
const { apiClient, brandPersistentId, designSystemId, storybookDirectory, storybookName } = input;
|
|
290
283
|
let { sourceId } = input;
|
|
291
284
|
const sourcesEndpoint = apiClient.designSystems.sources;
|
|
292
|
-
const
|
|
293
|
-
const accessToken = next
|
|
294
|
-
? undefined
|
|
295
|
-
: (await storybookHostingEndpoint.getAccessToken(designSystemId, storybookName)).accessToken;
|
|
296
|
-
const storybookUrl = storybookEndpoint(this.env, designSystemId, storybookName, accessToken);
|
|
285
|
+
const storybookUrl = storybookEndpoint(this.env, designSystemId, storybookName);
|
|
297
286
|
try {
|
|
298
287
|
let storiesCount = 0;
|
|
299
288
|
if (sourceId) {
|
|
@@ -307,7 +296,7 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
307
296
|
const { source } = await sourcesEndpoint.create(designSystemId, {
|
|
308
297
|
brandPersistentId,
|
|
309
298
|
description: "CLI",
|
|
310
|
-
indexUrl: storybookEndpoint(this.env, designSystemId, storybookName,
|
|
299
|
+
indexUrl: storybookEndpoint(this.env, designSystemId, storybookName, "json"),
|
|
311
300
|
payload: this.getIndexJson(storybookDirectory),
|
|
312
301
|
type: "Storybook",
|
|
313
302
|
userUrl: storybookUrl,
|
|
@@ -372,4 +361,4 @@ __decorate([
|
|
|
372
361
|
__metadata("design:returntype", Promise)
|
|
373
362
|
], ImportStorybook.prototype, "run", null);
|
|
374
363
|
//# sourceMappingURL=storybook-import.js.map
|
|
375
|
-
//# debugId=
|
|
364
|
+
//# debugId=1466cc82-6ec9-54b8-9d89-0a3f6cb158f3
|
|
@@ -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})\n\ntype ImportStorybookConfig = z.infer<typeof ImportStorybookConfig>\n\nconst storybookEndpoint = (\n environment: TargetEnv,\n designSystemId: string,\n name: string,\n accessToken: string | undefined,\n format: \"html\" | \"json\" = \"html\",\n): string => {\n const host = storybookUrlForEnvironment(environment)\n\n let url = `${host}/design-systems/${designSystemId}/alias/${name}/index.${format}`\n if (accessToken) {\n const encodedAccessToken = encodeURIComponent(accessToken)\n url += `?authorization=${encodedAccessToken}`\n }\n\n return url\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 next: Flags.boolean({ hidden: true, default: false }),\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 = await 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\n const apiClient = await this.apiClient()\n\n const { designSystems } = apiClient\n const { storybookHosting } = designSystems\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 { signedUrl, storybookUploadId } = await storybookHosting.getSignedUploadUrl(designSystemId, {\n name: storybookName,\n })\n\n await this.uploadArchiveToSignedUrl({ designSystemId, storybookName, signedUrl, storybookUploadId, zipPath })\n this.log(\"✅ Upload complete.\")\n\n action.start(\"Deploying Storybook to private Supernova hosting service\")\n await this.waitForPublishing({ apiClient, designSystemId, storybookUploadId })\n action.stop(\"\\n✅ Private Storybook deployed successfully!\")\n\n action.start(\"Updating Storybook stories\")\n const { sourceId: finalSourceId } = await this.importStorybookStories({\n apiClient,\n designSystemId,\n brandPersistentId,\n sourceId,\n storybookDirectory,\n storybookName,\n next: flags.next,\n })\n action.stop(\"\\n✅ Storybook stories have been updated!\")\n\n this.configService.update({\n storybook: {\n designSystemId,\n from: storybookDirectory,\n name: storybookName,\n brandId: brandPersistentId,\n sourceId: finalSourceId,\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 async 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 //\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 \"{}\"\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 signedUrl: string\n storybookName?: string\n storybookUploadId: string\n zipPath: string\n }): Promise<void> {\n const { designSystemId, storybookName, signedUrl, storybookUploadId, 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(signedUrl, fileBuffer, {\n headers: {\n \"Content-Length\": fileSize,\n \"Content-Type\": \"application/zip\",\n designSystemId,\n storybookUploadId,\n ...(storybookName && { name: storybookName }),\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 waitForPublishing(input: {\n apiClient: SupernovaApiClient\n designSystemId: string\n storybookUploadId: string\n }): Promise<void> {\n const { apiClient, designSystemId, storybookUploadId } = input\n\n const getStatus = async () => {\n const { status } = await apiClient.designSystems.storybookHosting.getUploadStatus(\n designSystemId,\n storybookUploadId,\n )\n return status\n }\n\n let lastStatus: Awaited<ReturnType<typeof getStatus>> = \"Unknown\"\n let unknownStatusCount = 0\n\n // Wait for publishing to complete\n // Do 15 * 60 tries roughly correspond to at least 15 minutes\n for (let i = 0; unknownStatusCount < 10 && i < 15 * 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 === \"Unknown\") unknownStatusCount++\n else unknownStatusCount = 0\n\n if (lastStatus === \"Completed\" || lastStatus === \"Failed\") break\n\n await sleep(1000)\n }\n\n // React to publishing status\n switch (lastStatus) {\n case \"Unknown\":\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 next: boolean\n }): Promise<{ sourceId: string }> {\n const { apiClient, brandPersistentId, designSystemId, storybookDirectory, storybookName, next } = input\n let { sourceId } = input\n\n const sourcesEndpoint = apiClient.designSystems.sources\n const storybookHostingEndpoint = apiClient.designSystems.storybookHosting\n\n // In the upcoming version access token is no longer required\n const accessToken = next\n ? undefined\n : (await storybookHostingEndpoint.getAccessToken(designSystemId, storybookName)).accessToken\n\n const storybookUrl = storybookEndpoint(this.env, designSystemId, storybookName, accessToken)\n\n try {\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, accessToken, \"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 } catch (error) {\n this.error(\n `Failed to connect Storybook as data source: ${error instanceof Error ? error.message : String(error)}`,\n )\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: 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 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"],"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,uB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,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;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;;AAvbY;IADZ,YAAY,EAAE;;;;0CA4Dd","debug_id":"0aa02c55-a3e8-5396-8f63-75a78bf5ef75"}
|
|
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})\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 }\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 = await 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\n const apiClient = await this.apiClient()\n\n const { designSystems } = apiClient\n const { storybookHosting } = designSystems\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 { signedUrl, storybookUploadId } = await storybookHosting.getSignedUploadUrl(designSystemId, {\n name: storybookName,\n })\n\n await this.uploadArchiveToSignedUrl({ designSystemId, storybookName, signedUrl, storybookUploadId, zipPath })\n this.log(\"✅ Upload complete.\")\n\n action.start(\"Deploying Storybook to private Supernova hosting service\")\n await this.waitForPublishing({ apiClient, designSystemId, storybookUploadId })\n action.stop(\"\\n✅ Private Storybook deployed successfully!\")\n\n action.start(\"Updating Storybook stories\")\n const { sourceId: finalSourceId } = await this.importStorybookStories({\n apiClient,\n designSystemId,\n brandPersistentId,\n sourceId,\n storybookDirectory,\n storybookName,\n })\n action.stop(\"\\n✅ Storybook stories have been updated!\")\n\n this.configService.update({\n storybook: {\n designSystemId,\n from: storybookDirectory,\n name: storybookName,\n brandId: brandPersistentId,\n sourceId: finalSourceId,\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 async 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 //\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 \"{}\"\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 signedUrl: string\n storybookName?: string\n storybookUploadId: string\n zipPath: string\n }): Promise<void> {\n const { designSystemId, storybookName, signedUrl, storybookUploadId, 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(signedUrl, fileBuffer, {\n headers: {\n \"Content-Length\": fileSize,\n \"Content-Type\": \"application/zip\",\n designSystemId,\n storybookUploadId,\n ...(storybookName && { name: storybookName }),\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 waitForPublishing(input: {\n apiClient: SupernovaApiClient\n designSystemId: string\n storybookUploadId: string\n }): Promise<void> {\n const { apiClient, designSystemId, storybookUploadId } = input\n\n const getStatus = async () => {\n const { status } = await apiClient.designSystems.storybookHosting.getUploadStatus(\n designSystemId,\n storybookUploadId,\n )\n return status\n }\n\n let lastStatus: Awaited<ReturnType<typeof getStatus>> = \"Unknown\"\n let unknownStatusCount = 0\n\n // Wait for publishing to complete\n // Do 15 * 60 tries roughly correspond to at least 15 minutes\n for (let i = 0; unknownStatusCount < 10 && i < 15 * 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 === \"Unknown\") unknownStatusCount++\n else unknownStatusCount = 0\n\n if (lastStatus === \"Completed\" || lastStatus === \"Failed\") break\n\n await sleep(1000)\n }\n\n // React to publishing status\n switch (lastStatus) {\n case \"Unknown\":\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 try {\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 } catch (error) {\n this.error(\n `Failed to connect Storybook as data source: ${error instanceof Error ? error.message : String(error)}`,\n )\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: 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 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"],"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,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAC9D,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAEvE,MAAM,qBA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AAA;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;;AA9aY;IADZ,YAAY,EAAE;;;;0CA2Dd","debug_id":"1466cc82-6ec9-54b8-9d89-0a3f6cb158f3"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-upload.d.ts","sourceRoot":"","sources":["../../src/commands/template-upload.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGhC,OAAO,EAAe,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAQ9D,QAAA,MAAM,oBAAoB,gDAAe,CAAA;AAEzC,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"template-upload.d.ts","sourceRoot":"","sources":["../../src/commands/template-upload.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGhC,OAAO,EAAe,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAQ9D,QAAA,MAAM,oBAAoB,gDAAe,CAAA;AAEzC,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAsBhE,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;;;;;MAmBpB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAEhD;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAsDnB,oBAAoB;IAMlC,OAAO,CAAC,cAAc;YAIR,cAAc;YAId,kBAAkB;YAclB,gBAAgB;YAyBhB,eAAe;YAkBf,mBAAmB;CAyBlC"}
|
|
@@ -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]="c9729bc9-3c4b-5c58-92b2-ffe5959f9549")}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);
|
|
@@ -46,9 +46,9 @@ RUN node docker-scripts/extract-private-packages.js
|
|
|
46
46
|
`;
|
|
47
47
|
export default class TemplateUpload extends SentryCommand {
|
|
48
48
|
static args = {};
|
|
49
|
-
static description = "Upload
|
|
49
|
+
static description = "Upload component container template to Supernova";
|
|
50
50
|
static examples = ["<%= config.bin %> <%= command.id %> TemplateUpload "];
|
|
51
|
-
static hidden =
|
|
51
|
+
static hidden = false;
|
|
52
52
|
static flags = {
|
|
53
53
|
...commonFlags,
|
|
54
54
|
workspaceId: Flags.string({ char: "w", description: "Workspace ID to upload the template to", required: true }),
|
|
@@ -225,4 +225,4 @@ function imageUrl(build) {
|
|
|
225
225
|
return `${build.dockerRegistryDomain}${build.build.dockerImagePath}`;
|
|
226
226
|
}
|
|
227
227
|
//# sourceMappingURL=template-upload.js.map
|
|
228
|
-
//# debugId=
|
|
228
|
+
//# debugId=c9729bc9-3c4b-5c58-92b2-ffe5959f9549
|
|
@@ -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\"\n\nimport { commonFlags, SentryCommand } from \"../types/index.js\"\n\nimport { DTOSandboxTemplateBuildCreateResponse, SupernovaApiClient } from \"@supernova-studio/client\"\nimport { sleep } from \"../utils/common.js\"\nimport { tmpdir } from \"node:os\"\n\nconst exec = promisify(execCallback)\n\nconst TemplateUploadConfig = z.object({})\n\ntype TemplateUploadConfig = z.infer<typeof TemplateUploadConfig>\n\nasync function fileExists(p: string) {\n try {\n await fs.access(p)\n return true\n } catch {\n return false\n }\n}\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 && rm -f .npmrc\nRUN node docker-scripts/extract-private-packages.js\n`\n\nexport default class TemplateUpload extends SentryCommand<TemplateUploadConfig> {\n static override args = {}\n static override description = \"Upload custom prototype app sandbox template\"\n static override examples = [\"<%= config.bin %> <%= command.id %> TemplateUpload \"]\n static override hidden: boolean = true\n static override flags = {\n ...commonFlags,\n workspaceId: Flags.string({ char: \"w\", description: \"Workspace ID to upload the template to\", required: true }),\n designSystemId: Flags.string({\n char: \"d\",\n description: \"Design system ID to upload the template to\",\n required: true,\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 }\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 // 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 // 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 })\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 --progress=plain -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\ntype PackageJson = {\n name: string\n version: string\n dependencies: Record<string, string>\n supernova:\n | {\n privateDependencies: string[] | undefined\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"],"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,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAChC,OAAO,GAAG,MAAM,UAAU,CAAA;AAE1B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAG9D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;AAEpC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAIzC,KAAK,UAAU,UAAU,CAAC,CAAS;IACjC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;Q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mB,GAAG,GAAG,CAAC,SAAS,EAAE,mBAAmB,CAAA;QAC9D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAA;QAE9G,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC;YACnD,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;gBAC1B,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,oBAAoB,CAAC,CAAA;YAC7E,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,kCAAkC,CAAC,CAAA;YAC5E,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,QAAQ,CAAC,KAA4C;IAC5D,OAAO,GAAG,KAAK,CAAC,oBAAoB,GAAG,KAAK,CAAC,KAAK,CAAC,eAAe,EAAE,CAAA;AACtE,CAAC","debug_id":"f847cf3b-8c21-5dff-b0e5-47770ca3820c"}
|
|
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\"\n\nimport { commonFlags, SentryCommand } from \"../types/index.js\"\n\nimport { DTOSandboxTemplateBuildCreateResponse, SupernovaApiClient } from \"@supernova-studio/client\"\nimport { sleep } from \"../utils/common.js\"\nimport { tmpdir } from \"node:os\"\n\nconst exec = promisify(execCallback)\n\nconst TemplateUploadConfig = z.object({})\n\ntype TemplateUploadConfig = z.infer<typeof TemplateUploadConfig>\n\nasync function fileExists(p: string) {\n try {\n await fs.access(p)\n return true\n } catch {\n return false\n }\n}\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 && rm -f .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: true }),\n designSystemId: Flags.string({\n char: \"d\",\n description: \"Design system ID to upload the template to\",\n required: true,\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 }\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 // 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 // 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 })\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 --progress=plain -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\ntype PackageJson = {\n name: string\n version: string\n dependencies: Record<string, string>\n supernova:\n | {\n privateDependencies: string[] | undefined\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"],"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,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAChC,OAAO,GAAG,MAAM,UAAU,CAAA;AAE1B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAG9D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,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,CAAA;AAE7D,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,kBAAkB;IAEvD,KAAK;;;;;;;
|
|
1
|
+
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../src/services/user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE7D,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,kBAAkB;IAEvD,KAAK;;;;;;;wBAImx0ne,CAAC;sBAA4C,CAAC;0BAAgD,CAAC;+BAAmC,CAAC;uCAA6D,CAAC;8CAAoE,CAAC;8BAAoD,CAAC;4BAAoG,CAAC;yBAA+C,CAAC;4BAAkD,CAAC;oCAA+G,CAAC;sCAA4D,CAAC;iDAAuE,CAAC;4BAAmD,CAAC;iDAAuE,CAAC;;qBAA2E,CAAC;mCAAuC,CAAC;+BAAqD,CAAC;4BAAkD,CAAC;sCAA4D,CAAC;4CAAmE,CAAC;qCAA2D,CAAC;iCAAuD,CAAC;0BAAiD,CAAC;;2BAA8M,CAAC;mCAAuC,CAAC;+BAAqD,CAAC;4BAAkD,CAAC;sCAA4D,CAAC;4CAAmE,CAAC;qCAA2D,CAAC;iCAAuD,CAAC;0BAAiD,CAAC;;;;;;uBAAiU,CAAC;kBAAsC,CAAC;;;CADjo5ne"}
|
package/dist/utils/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/utils/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/utils/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAA;AAO5C,OAAO,QAAQ,CAAA;AAKf,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC;IACjF,KAAK,EAAE,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAA;IAC5B,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAA;IACnC,EAAE,EAAE,QAAQ,CAAC,gCAAgC,CAAA;IAC7C,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAA;IAC5B,KAAK,EAAE,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAA;IACjC,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAA;CACtC,CAAC,CAuDD"}
|
package/dist/utils/sdk.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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]="de98c81d-6cc8-5916-9893-faba2cec1873")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
+
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
4
5
|
import { apiUrlForEnvironment, getTargetEnv } from "../types/environment.js";
|
|
5
6
|
import "colors";
|
|
6
7
|
const require = createRequire(import.meta.url);
|
|
@@ -15,8 +16,9 @@ export async function getWritableVersion(flags) {
|
|
|
15
16
|
const apiUrl = flags.apiUrl && flags.apiUrl.length > 0 ? flags.apiUrl : apiUrlForEnvironment(getTargetEnv());
|
|
16
17
|
const instance = new sdkProvider.Supernova(flags.apiKey, {
|
|
17
18
|
apiUrl,
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
customProxyLib: flags.proxyUrl
|
|
20
|
+
? new HttpsProxyAgent(flags.proxyUrl)
|
|
21
|
+
: null,
|
|
20
22
|
});
|
|
21
23
|
const designSystem = await instance.designSystems.designSystem(flags.designSystemId);
|
|
22
24
|
if (!designSystem) {
|
|
@@ -50,4 +52,4 @@ export async function getWritableVersion(flags) {
|
|
|
50
52
|
return { brand, designSystem, id, instance, theme, version };
|
|
51
53
|
}
|
|
52
54
|
//# sourceMappingURL=sdk.js.map
|
|
53
|
-
//# debugId=
|
|
55
|
+
//# debugId=de98c81d-6cc8-5916-9893-faba2cec1873
|
package/dist/utils/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/utils/sdk.ts"],"sourceRoot":"","sourcesContent":["import * as sdkTypes from \"@supernovaio/sdk\"\nimport { createRequire } from \"node:module\"\n\nimport { apiUrlForEnvironment, getTargetEnv } from \"../types/environment.js\"\n\n// eslint-disable-next-line no-restricted-imports\nimport \"colors\"\n\nconst require = createRequire(import.meta.url)\nconst sdkProvider = require(\"@supernovaio/sdk\") as typeof sdkTypes\n\nexport interface DefaultDesignSystemFlags {\n apiKey: string\n apiUrl?: string\n brandId?: string\n designSystemId: string\n proxyUrl?: string\n themeId?: string\n}\n\nexport async function getWritableVersion(flags: DefaultDesignSystemFlags): Promise<{\n brand: null | sdkTypes.Brand\n designSystem: sdkTypes.DesignSystem\n id: sdkTypes.RemoteWorkspaceVersionIdentifier\n instance: sdkTypes.Supernova\n theme: null | sdkTypes.TokenTheme\n version: sdkTypes.DesignSystemVersion\n}> {\n if (!flags.apiKey || flags.apiKey.length === 0) {\n throw new Error(`API key must not be empty`)\n }\n\n if (!flags.designSystemId || flags.designSystemId.length === 0) {\n throw new Error(`Design System ID must not be empty`)\n }\n\n // Create instance for prod / dev\n const apiUrl = flags.apiUrl && flags.apiUrl.length > 0 ? flags.apiUrl : apiUrlForEnvironment(getTargetEnv())\n const instance = new sdkProvider.Supernova(flags.apiKey, {\n apiUrl,\n
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../src/utils/sdk.ts"],"sourceRoot":"","sourcesContent":["import * as sdkTypes from \"@supernovaio/sdk\"\nimport { createRequire } from \"node:module\"\nimport { HttpsProxyAgent } from 'https-proxy-agent'\n\nimport { apiUrlForEnvironment, getTargetEnv } from \"../types/environment.js\"\n\n// eslint-disable-next-line no-restricted-imports\nimport \"colors\"\n\nconst require = createRequire(import.meta.url)\nconst sdkProvider = require(\"@supernovaio/sdk\") as typeof sdkTypes\n\nexport interface DefaultDesignSystemFlags {\n apiKey: string\n apiUrl?: string\n brandId?: string\n designSystemId: string\n proxyUrl?: string\n themeId?: string\n}\n\nexport async function getWritableVersion(flags: DefaultDesignSystemFlags): Promise<{\n brand: null | sdkTypes.Brand\n designSystem: sdkTypes.DesignSystem\n id: sdkTypes.RemoteWorkspaceVersionIdentifier\n instance: sdkTypes.Supernova\n theme: null | sdkTypes.TokenTheme\n version: sdkTypes.DesignSystemVersion\n}> {\n if (!flags.apiKey || flags.apiKey.length === 0) {\n throw new Error(`API key must not be empty`)\n }\n\n if (!flags.designSystemId || flags.designSystemId.length === 0) {\n throw new Error(`Design System ID must not be empty`)\n }\n\n // Create instance for prod / dev\n const apiUrl = flags.apiUrl && flags.apiUrl.length > 0 ? flags.apiUrl : apiUrlForEnvironment(getTargetEnv())\n const instance = new sdkProvider.Supernova(flags.apiKey, {\n apiUrl,\n customProxyLib: flags.proxyUrl\n ? new HttpsProxyAgent(flags.proxyUrl)\n : null,\n })\n\n const designSystem = await instance.designSystems.designSystem(flags.designSystemId)\n if (!designSystem) {\n throw new Error(`Design system ${flags.designSystemId} not found or not available under provided API key`)\n }\n\n const version = await instance.versions.getActiveVersion(flags.designSystemId)\n if (!version) {\n throw new Error(\n `Design system ${flags.designSystemId} writable version not found or not available under provided API key`,\n )\n }\n\n const id: sdkTypes.RemoteWorkspaceVersionIdentifier = {\n designSystemId: flags.designSystemId,\n versionId: version.id,\n workspaceId: designSystem.workspaceId,\n }\n\n let brand: null | sdkTypes.Brand = null\n if (flags.brandId) {\n const brands = await instance.brands.getBrands(id)\n brand = brands.find(brand => brand.id === flags.brandId || brand.idInVersion === flags.brandId) ?? null\n if (!brand) {\n throw new Error(`Brand ${flags.brandId} not found in specified design system`)\n }\n }\n\n let theme: null | sdkTypes.TokenTheme = null\n if (flags.themeId) {\n const themes = await instance.tokens.getTokenThemes(id)\n theme = themes.find(theme => theme.id === flags.themeId || theme.idInVersion === flags.themeId) ?? null\n if (!theme) {\n throw new Error(`Theme ${flags.themeId} not found in specified brand`)\n }\n }\n\n return { brand, designSystem, id, instance, theme, version }\n}\n"],"names":[],"mappings":";;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAG5E,OAAO,QAAQ,CAAA;AAEf,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAoB,CAAA;AAWlE,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAA+B;IAQtE,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,KAAK,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,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAClD,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;QACvG,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,OAAO,uCAAuC,CAAC,CAAA;QAChF,CAAC;IACH,CAAC;IAED,IAAI,KAAK,GAA+B,IAAI,CAAA;IAC5C,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QACvD,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;QACvG,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;QACxE,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC9D,CAAC","debug_id":"de98c81d-6cc8-5916-9893-faba2cec1873"}
|
package/oclif.manifest.json
CHANGED
|
@@ -403,12 +403,6 @@
|
|
|
403
403
|
"hasDynamicHelp": false,
|
|
404
404
|
"multiple": false,
|
|
405
405
|
"type": "option"
|
|
406
|
-
},
|
|
407
|
-
"next": {
|
|
408
|
-
"hidden": true,
|
|
409
|
-
"name": "next",
|
|
410
|
-
"allowNo": false,
|
|
411
|
-
"type": "boolean"
|
|
412
406
|
}
|
|
413
407
|
},
|
|
414
408
|
"hasDynamicHelp": false,
|
|
@@ -510,7 +504,7 @@
|
|
|
510
504
|
"template-upload": {
|
|
511
505
|
"aliases": [],
|
|
512
506
|
"args": {},
|
|
513
|
-
"description": "Upload
|
|
507
|
+
"description": "Upload component container template to Supernova",
|
|
514
508
|
"examples": [
|
|
515
509
|
"<%= config.bin %> <%= command.id %> TemplateUpload "
|
|
516
510
|
],
|
|
@@ -551,7 +545,7 @@
|
|
|
551
545
|
}
|
|
552
546
|
},
|
|
553
547
|
"hasDynamicHelp": false,
|
|
554
|
-
"hidden":
|
|
548
|
+
"hidden": false,
|
|
555
549
|
"hiddenAliases": [],
|
|
556
550
|
"id": "template-upload",
|
|
557
551
|
"pluginAlias": "@supernovaio/cli",
|
|
@@ -588,5 +582,5 @@
|
|
|
588
582
|
]
|
|
589
583
|
}
|
|
590
584
|
},
|
|
591
|
-
"version": "2.0.
|
|
585
|
+
"version": "2.0.28"
|
|
592
586
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supernovaio/cli",
|
|
3
3
|
"description": "Supernova.io Command Line Interface",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.28",
|
|
5
5
|
"author": "Supernova.io",
|
|
6
6
|
"bin": {
|
|
7
7
|
"supernova": "./bin/run"
|
|
@@ -16,18 +16,19 @@
|
|
|
16
16
|
"@sentry/node": "^9.9.0",
|
|
17
17
|
"@sentry/profiling-node": "^9.9.0",
|
|
18
18
|
"@sindresorhus/slugify": "^2.2.1",
|
|
19
|
-
"@supernova-studio/client": "1.
|
|
20
|
-
"@supernova-studio/pulsar-core": "2.
|
|
21
|
-
"@supernova-studio/pulsar-language": "
|
|
19
|
+
"@supernova-studio/client": "1.66.0",
|
|
20
|
+
"@supernova-studio/pulsar-core": "2.7.10",
|
|
21
|
+
"@supernova-studio/pulsar-language": "2.7.10",
|
|
22
22
|
"@supernovaio/code-analyzer": "^1.0.1-alpha.2",
|
|
23
|
-
"@supernovaio/sdk": "2.
|
|
23
|
+
"@supernovaio/sdk": "2.2.54",
|
|
24
24
|
"@types/fs-extra": "^11.0.4",
|
|
25
25
|
"adm-zip": "^0.5.16",
|
|
26
|
-
"axios": "^1.
|
|
26
|
+
"axios": "^1.13.4",
|
|
27
27
|
"cli-progress": "^3.12.0",
|
|
28
28
|
"colors": "^1.4.0",
|
|
29
29
|
"dotenv": "^16.4.7",
|
|
30
30
|
"fs-extra": "^11.3.2",
|
|
31
|
+
"https-proxy-agent": "^7.0.6",
|
|
31
32
|
"inquirer": "^12.5.2",
|
|
32
33
|
"ip-cidr": "^4.0.2",
|
|
33
34
|
"jwt-decode": "^4.0.0",
|