@supernovaio/cli-next 2.0.12 → 2.0.14
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/README.md +47 -31
- package/dist/commands/describe-design-system.d.ts +1 -7
- package/dist/commands/describe-design-system.d.ts.map +1 -1
- package/dist/commands/describe-design-system.js +2 -4
- package/dist/commands/describe-design-system.js.map +1 -1
- package/dist/commands/describe-workspaces.d.ts +1 -8
- package/dist/commands/describe-workspaces.d.ts.map +1 -1
- package/dist/commands/describe-workspaces.js +3 -6
- package/dist/commands/describe-workspaces.js.map +1 -1
- package/dist/commands/import-components.d.ts +1 -6
- package/dist/commands/import-components.d.ts.map +1 -1
- package/dist/commands/import-components.js +1 -3
- package/dist/commands/import-components.js.map +1 -1
- package/dist/commands/import-storybook.d.ts +1 -8
- package/dist/commands/import-storybook.d.ts.map +1 -1
- package/dist/commands/import-storybook.js +7 -25
- package/dist/commands/import-storybook.js.map +1 -1
- package/dist/commands/login.d.ts +5 -20
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +3 -10
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +5 -20
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +3 -10
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/publish-documentation.d.ts +3 -23
- package/dist/commands/publish-documentation.d.ts.map +1 -1
- package/dist/commands/publish-documentation.js +3 -16
- package/dist/commands/publish-documentation.js.map +1 -1
- package/dist/commands/sync-tokens.d.ts +2 -24
- package/dist/commands/sync-tokens.d.ts.map +1 -1
- package/dist/commands/sync-tokens.js +3 -16
- package/dist/commands/sync-tokens.js.map +1 -1
- package/dist/hooks/postrun/save-config.d.ts.map +1 -1
- package/dist/hooks/postrun/save-config.js +1 -14
- package/dist/hooks/postrun/save-config.js.map +1 -1
- package/dist/services/auth.service.d.ts +2 -2
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/auth.service.js +5 -7
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/vault.service.d.ts +2 -1
- package/dist/services/vault.service.d.ts.map +1 -1
- package/dist/services/vault.service.js +1 -0
- package/dist/services/vault.service.js.map +1 -1
- package/dist/types/base-command.d.ts +2 -2
- package/dist/types/base-command.d.ts.map +1 -1
- package/dist/types/base-command.js +5 -9
- package/dist/types/base-command.js.map +1 -1
- package/dist/types/environment.d.ts +8 -0
- package/dist/types/environment.d.ts.map +1 -0
- package/dist/types/environment.js +60 -0
- package/dist/types/environment.js.map +1 -0
- package/dist/types/flags.d.ts +1 -3
- package/dist/types/flags.d.ts.map +1 -1
- package/dist/types/flags.js +1 -10
- package/dist/types/flags.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/login.d.ts +1 -11
- package/dist/types/login.d.ts.map +1 -1
- package/dist/types/login.js +2 -10
- package/dist/types/login.js.map +1 -1
- package/dist/types/types.d.ts +0 -7
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +0 -8
- package/dist/types/types.js.map +1 -1
- package/dist/utils/api-client.d.ts +2 -2
- package/dist/utils/api-client.d.ts.map +1 -1
- package/dist/utils/api-client.js +3 -4
- package/dist/utils/api-client.js.map +1 -1
- package/dist/utils/sdk.d.ts +1 -2
- package/dist/utils/sdk.d.ts.map +1 -1
- package/dist/utils/sdk.js +3 -5
- package/dist/utils/sdk.js.map +1 -1
- package/oclif.manifest.json +3 -128
- package/package.json +2 -1
- package/dist/utils/network.d.ts +0 -3
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js +0 -13
- package/dist/utils/network.js.map +0 -1
|
@@ -17,9 +17,8 @@ import cliProgress from "cli-progress";
|
|
|
17
17
|
import inquirer from "inquirer";
|
|
18
18
|
import * as fs from "node:fs";
|
|
19
19
|
import path from "node:path";
|
|
20
|
-
import { match } from "ts-pattern";
|
|
21
20
|
import { z } from "zod";
|
|
22
|
-
import {
|
|
21
|
+
import { commonFlags, getTargetEnv, SentryCommand, storybookUrlForEnvironment } from "../types/index.js";
|
|
23
22
|
import { sleep } from "../utils/common.js";
|
|
24
23
|
import { getClient } from "../utils/index.js";
|
|
25
24
|
const MAX_ZIP_SIZE_BYTES = 500 * 1024 * 1024;
|
|
@@ -30,23 +29,15 @@ const ImportStorybookConfigSchema = z
|
|
|
30
29
|
brandId: z.string().optional(),
|
|
31
30
|
designSystemId: z.string().optional(),
|
|
32
31
|
dir: z.string().optional(),
|
|
33
|
-
environment: z.nativeEnum(Environment),
|
|
34
32
|
name: z.string().optional(),
|
|
35
33
|
sourceId: z.string().optional(),
|
|
36
34
|
versionId: z.string().optional(),
|
|
37
35
|
})
|
|
38
36
|
.transform(data => ({
|
|
39
37
|
...data,
|
|
40
|
-
environment: data.environment ?? Environment.production,
|
|
41
38
|
}));
|
|
42
39
|
const storybookEndpoint = (environment, designSystemId, name, accessToken) => {
|
|
43
|
-
const host =
|
|
44
|
-
.with("demo", () => `https://storybook.romansudo.sst.supernova.io`)
|
|
45
|
-
.with("development", () => `https://storybook.dev.supernova.io`)
|
|
46
|
-
.with("production", () => `https://storybook.supernova.io`)
|
|
47
|
-
.with("staging", () => `https://storybook.staging.supernova.io`)
|
|
48
|
-
.with("local", () => ` https://storybook.${process.env.LOCAL_STAGE}.sst.supernova.io`)
|
|
49
|
-
.exhaustive();
|
|
40
|
+
const host = storybookUrlForEnvironment(environment);
|
|
50
41
|
const encodedAccessToken = encodeURIComponent(accessToken);
|
|
51
42
|
return `${host}/design-systems/${designSystemId}/alias/${name}/index.html?storybook_jwt=${encodedAccessToken}`;
|
|
52
43
|
};
|
|
@@ -57,7 +48,7 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
57
48
|
"<%= config.bin %> <%= command.id %> import-storybook --designSystemId=123 --dir ./storybook-static.zip",
|
|
58
49
|
];
|
|
59
50
|
static flags = {
|
|
60
|
-
...
|
|
51
|
+
...commonFlags,
|
|
61
52
|
brandId: Flags.string({ char: "b", description: "Import storybooks to brand of" }),
|
|
62
53
|
designSystemId: Flags.string({ char: "D", description: "Import storybooks to design system of" }),
|
|
63
54
|
dir: Flags.string({
|
|
@@ -67,7 +58,6 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
67
58
|
}),
|
|
68
59
|
name: Flags.string({ char: "a", description: "Import storybooks with name of" }),
|
|
69
60
|
sourceId: Flags.string({ char: "s", description: "Import storybooks to source of" }),
|
|
70
|
-
versionId: Flags.string({ char: "v", default: "head", description: "Import storybooks to version of" }),
|
|
71
61
|
};
|
|
72
62
|
get commandId() {
|
|
73
63
|
return ImportStorybook.id;
|
|
@@ -78,12 +68,11 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
78
68
|
async run() {
|
|
79
69
|
const startTime = Date.now();
|
|
80
70
|
const { flags } = await this.parse(ImportStorybook);
|
|
81
|
-
const
|
|
71
|
+
const env = getTargetEnv();
|
|
72
|
+
const { brandId: bId, designSystemId: dsId, dir, name: nameInput, sourceId } = flags;
|
|
82
73
|
const name = slugify(await this.askName(nameInput), { lowercase: true });
|
|
83
74
|
let designSystemId = dsId;
|
|
84
|
-
let versionId = vId;
|
|
85
75
|
let brandId = bId;
|
|
86
|
-
const env = environment;
|
|
87
76
|
const apiClient = await getClient(env);
|
|
88
77
|
const { designSystems } = apiClient;
|
|
89
78
|
const { sources, storybookHosting } = designSystems;
|
|
@@ -94,15 +83,8 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
94
83
|
}
|
|
95
84
|
this.saveConfig({ designSystemId });
|
|
96
85
|
}
|
|
97
|
-
if (!versionId) {
|
|
98
|
-
versionId = await this.getVersionId(env, designSystemId);
|
|
99
|
-
if (!versionId) {
|
|
100
|
-
this.error("Version ID is required");
|
|
101
|
-
}
|
|
102
|
-
this.saveConfig({ versionId });
|
|
103
|
-
}
|
|
104
86
|
if (!brandId) {
|
|
105
|
-
brandId = await this.getBrandId(env, designSystemId,
|
|
87
|
+
brandId = await this.getBrandId(env, designSystemId, "head");
|
|
106
88
|
if (!brandId) {
|
|
107
89
|
this.error("Brand ID is required");
|
|
108
90
|
}
|
|
@@ -154,7 +136,7 @@ export default class ImportStorybook extends SentryCommand {
|
|
|
154
136
|
this.log(`Connecting Storybook as a data source in Supernova...`);
|
|
155
137
|
let storiesCount = 0;
|
|
156
138
|
if (sourceId) {
|
|
157
|
-
const { storiesCount: updatedStoriesCount } = await sources.updateStorybookImport(designSystemId,
|
|
139
|
+
const { storiesCount: updatedStoriesCount } = await sources.updateStorybookImport(designSystemId, "head", {
|
|
158
140
|
payload: this.getIndexJson(dir),
|
|
159
141
|
sourceId,
|
|
160
142
|
});
|
|
@@ -1 +1 @@
|
|
|
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,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,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA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,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;;AAvWY;IAFZ,YAAY,EAAE;;;;0CAgJd","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 { match } from \"ts-pattern\"\nimport { z, ZodType } from \"zod\"\n\nimport { Environment, flags, SentryCommand, TargetEnv } from \"../types/index.js\"\nimport { sleep } from \"../utils/common.js\"\nimport { getClient } 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 environment: z.nativeEnum(Environment),\n name: z.string().optional(),\n sourceId: z.string().optional(),\n versionId: z.string().optional(),\n })\n .transform(data => ({\n ...data,\n environment: data.environment ?? Environment.production,\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 = match(environment)\n .with(\"demo\", () => `https://storybook.romansudo.sst.supernova.io`)\n .with(\"development\", () => `https://storybook.dev.supernova.io`)\n .with(\"production\", () => `https://storybook.supernova.io`)\n .with(\"staging\", () => `https://storybook.staging.supernova.io`)\n .with(\"local\", () => ` https://storybook.${process.env.LOCAL_STAGE}.sst.supernova.io`)\n .exhaustive()\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 ...flags,\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 versionId: Flags.string({ char: \"v\", default: \"head\", description: \"Import storybooks to version 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 { brandId: bId, designSystemId: dsId, dir, environment, name: nameInput, sourceId, versionId: vId } = flags\n const name = slugify(await this.askName(nameInput), { lowercase: true })\n let designSystemId = dsId\n let versionId = vId\n let brandId = bId\n const env = environment as TargetEnv\n\n const apiClient = await getClient(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 (!versionId) {\n versionId = await this.getVersionId(env, designSystemId)\n\n if (!versionId) {\n this.error(\"Version ID is required\")\n }\n\n this.saveConfig({ versionId })\n }\n\n if (!brandId) {\n brandId = await this.getBrandId(env, designSystemId, versionId)\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 versionId,\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,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,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,0BAA0B,EAAa,MAAM,mBAAmB,CAAA;AACnH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAG7C,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,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C,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 { getClient } 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 getClient(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"]}
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -1,30 +1,15 @@
|
|
|
1
|
-
import { z
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
environment: z.ZodNativeEnum<typeof Environment>;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
environment: Environment;
|
|
7
|
-
}, {
|
|
8
|
-
environment: Environment;
|
|
9
|
-
}>, {
|
|
10
|
-
environment: Environment;
|
|
11
|
-
}, {
|
|
12
|
-
environment: Environment;
|
|
13
|
-
}>;
|
|
14
|
-
type LoginConfig = z.infer<typeof LoginConfigSchema>;
|
|
15
|
-
export default class Login extends SentryCommand<LoginConfig> {
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { SentryCommand } from "../types/index.js";
|
|
3
|
+
export default class Login extends SentryCommand<object> {
|
|
16
4
|
static args: {};
|
|
17
5
|
static description: string;
|
|
18
6
|
static examples: string[];
|
|
19
|
-
static flags: {
|
|
20
|
-
environment: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
-
};
|
|
7
|
+
static flags: {};
|
|
22
8
|
private readonly authService;
|
|
23
9
|
private readonly vaultService;
|
|
24
10
|
get commandId(): string;
|
|
25
|
-
get configSchema():
|
|
11
|
+
get configSchema(): z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
26
12
|
run(): Promise<void>;
|
|
27
13
|
private openBrowser;
|
|
28
14
|
}
|
|
29
|
-
export {};
|
|
30
15
|
//# sourceMappingURL=login.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAe,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAEzE,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,aAAa,CAAC,MAAM,CAAC;IACtD,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAA2B;IACtD,OAAgB,QAAQ,WAA0C;IAClE,OAAgB,KAAK,KAAc;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiC;IAC7D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmC;IAEhE,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,mDAEf;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAwBnB,WAAW;CAQ1B"}
|
package/dist/commands/login.js
CHANGED
|
@@ -12,26 +12,19 @@ import open from "open";
|
|
|
12
12
|
import pkceChallenge from "pkce-challenge";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
import { AuthService, VaultService } from "../services/index.js";
|
|
15
|
-
import {
|
|
16
|
-
const LoginConfigSchema = z
|
|
17
|
-
.object({
|
|
18
|
-
environment: z.nativeEnum(Environment),
|
|
19
|
-
})
|
|
20
|
-
.transform(data => ({
|
|
21
|
-
environment: data.environment ?? Environment.production,
|
|
22
|
-
}));
|
|
15
|
+
import { commonFlags, SentryCommand } from "../types/index.js";
|
|
23
16
|
export default class Login extends SentryCommand {
|
|
24
17
|
static args = {};
|
|
25
18
|
static description = "Login to the Supernova";
|
|
26
19
|
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
27
|
-
static flags =
|
|
20
|
+
static flags = commonFlags;
|
|
28
21
|
authService = new AuthService();
|
|
29
22
|
vaultService = new VaultService();
|
|
30
23
|
get commandId() {
|
|
31
24
|
return Login.id;
|
|
32
25
|
}
|
|
33
26
|
get configSchema() {
|
|
34
|
-
return
|
|
27
|
+
return z.object({});
|
|
35
28
|
}
|
|
36
29
|
async run() {
|
|
37
30
|
const { flags } = await this.parse(Login);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAEzE,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,aAAqB;IACtD,MAAM,CAAU,IAAI,GAAG,EAAE,CAAA;IACzB,MAAM,CAAU,WAAW,GAAG,wBAAwB,CAAA;IACtD,MAAM,CAAU,QAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAA;IAClE,MAAM,CAAU,KAAK,GAAG,WAAW,CAAA;IAClB,WAAW,GAAgB,IAAI,WAAW,EAAE,CAAA;IAC5C,YAAY,GAAiB,IAAI,YAAY,EAAE,CAAA;IAEhE,IAAI,SAAS;QACX,OAAO,KAAK,CAAC,EAAE,CAAA;IACjB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACrB,CAAC;IAGY,AAAN,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAEzC,MAAM,GAAG,GAAG,KAAK,CAAC,WAAwB,C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;;gCAsBd;AAGa;IADb,YAAY,EAAE;;;;wCAQd","sourcesContent":["import { SentryTraced } from \"@sentry/nestjs\"\nimport open from \"open\"\nimport pkceChallenge from \"pkce-challenge\"\nimport { z } from \"zod\"\n\nimport { AuthService, VaultService } from \"../services/index.js\"\nimport { commonFlags, SentryCommand, TargetEnv } from \"../types/index.js\"\n\nexport default class Login extends SentryCommand<object> {\n static override args = {}\n static override description = \"Login to the Supernova\"\n static override examples = [\"<%= config.bin %> <%= command.id %>\"]\n static override flags = commonFlags\n private readonly authService: AuthService = new AuthService()\n private readonly vaultService: VaultService = new VaultService()\n\n get commandId(): string {\n return Login.id\n }\n\n get configSchema() {\n return z.object({})\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const { flags } = await this.parse(Login)\n\n const env = flags.environment as TargetEnv\n\n const { code_challenge: codeChallenge, code_verifier: codeVerifier } = await pkceChallenge()\n\n this.log(\"\\n🔐 Authentication Process\\n\".green)\n this.log(\"1. Opening browser for authentication...\")\n const { authorizeUrl, readKey } = await this.authService.getAuthUrlFromServer(env, codeChallenge)\n await this.openBrowser(authorizeUrl)\n this.log(\"2. Waiting for authentication to complete...\")\n const tokens = await this.authService.getTokensFromServer(env, codeVerifier, readKey)\n if (tokens) {\n this.log(\"3. Login successful!\")\n this.log(\"4. Storing tokens...\")\n await this.vaultService.storeTokensToVault(tokens, env)\n this.log(\"5. You are now logged in\".green)\n } else {\n this.log(\"3. Login timed out\".red)\n }\n }\n\n @SentryTraced()\n private async openBrowser(url: string) {\n try {\n await open(url)\n } catch {\n this.log(\"Unable to open browser automatically - please visit the URL manually\")\n this.log(`\\u001B[4m\\u001B[34m${url}\\u001B[0m\\n`)\n }\n }\n}\n"]}
|
|
@@ -1,28 +1,13 @@
|
|
|
1
|
-
import { z
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
environment: z.ZodNativeEnum<typeof Environment>;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
environment: Environment;
|
|
7
|
-
}, {
|
|
8
|
-
environment: Environment;
|
|
9
|
-
}>, {
|
|
10
|
-
environment: Environment;
|
|
11
|
-
}, {
|
|
12
|
-
environment: Environment;
|
|
13
|
-
}>;
|
|
14
|
-
type LogouConfig = z.infer<typeof LogoutConfigSchema>;
|
|
15
|
-
export default class Logout extends SentryCommand<LogouConfig> {
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { SentryCommand } from "../types/index.js";
|
|
3
|
+
export default class Logout extends SentryCommand<object> {
|
|
16
4
|
static args: {};
|
|
17
5
|
static description: string;
|
|
18
6
|
static examples: string[];
|
|
19
|
-
static flags: {
|
|
20
|
-
environment: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
-
};
|
|
7
|
+
static flags: {};
|
|
22
8
|
private vaultService;
|
|
23
9
|
get commandId(): string;
|
|
24
|
-
get configSchema():
|
|
10
|
+
get configSchema(): z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
25
11
|
run(): Promise<void>;
|
|
26
12
|
}
|
|
27
|
-
export {};
|
|
28
13
|
//# sourceMappingURL=logout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAe,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAEzE,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,aAAa,CAAC,MAAM,CAAC;IACvD,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAA8B;IACzD,OAAgB,QAAQ,WAA0C;IAClE,OAAgB,KAAK,KAAc;IACnC,OAAO,CAAC,YAAY,CAAqB;IAEzC,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,mDAEf;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAOlC"}
|
package/dist/commands/logout.js
CHANGED
|
@@ -10,25 +10,18 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { SentryTraced } from "@sentry/nestjs";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { VaultService } from "../services/index.js";
|
|
13
|
-
import {
|
|
14
|
-
const LogoutConfigSchema = z
|
|
15
|
-
.object({
|
|
16
|
-
environment: z.nativeEnum(Environment),
|
|
17
|
-
})
|
|
18
|
-
.transform(data => ({
|
|
19
|
-
environment: data.environment ?? Environment.production,
|
|
20
|
-
}));
|
|
13
|
+
import { commonFlags, SentryCommand } from "../types/index.js";
|
|
21
14
|
export default class Logout extends SentryCommand {
|
|
22
15
|
static args = {};
|
|
23
16
|
static description = "Logout from the Supernova";
|
|
24
17
|
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
25
|
-
static flags =
|
|
18
|
+
static flags = commonFlags;
|
|
26
19
|
vaultService = new VaultService();
|
|
27
20
|
get commandId() {
|
|
28
21
|
return Logout.id;
|
|
29
22
|
}
|
|
30
23
|
get configSchema() {
|
|
31
|
-
return
|
|
24
|
+
return z.object({});
|
|
32
25
|
}
|
|
33
26
|
async run() {
|
|
34
27
|
const { flags } = await this.parse(Logout);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAEzE,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,aAAqB;IACvD,MAAM,CAAU,IAAI,GAAG,EAAE,CAAA;IACzB,MAAM,CAAU,WAAW,GAAG,2BAA2B,CAAA;IACzD,MAAM,CAAU,QAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAA;IAClE,MAAM,CAAU,KAAK,GAAG,WAAW,CAAA;IAC3B,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;IAEzC,IAAI,SAAS;QACX,OAAO,MAAM,CAAC,EAAE,CAAA;IAClB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACrB,CAAC;IAGY,AAAN,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAE1C,MAAM,GAAG,GAAG,KAAK,CAAC,MAAmB,CAAA;QACrC,MAAM,IAAI,CAAC,YAAY,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;QAClD,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;IACtC,CAAC;;AANY;IADZ,YAAY,EAAE;;;;iCAOd","sourcesContent":["import { SentryTraced } from \"@sentry/nestjs\"\nimport { z } from \"zod\"\n\nimport { VaultService } from \"../services/index.js\"\nimport { commonFlags, SentryCommand, TargetEnv } from \"../types/index.js\"\n\nexport default class Logout extends SentryCommand<object> {\n static override args = {}\n static override description = \"Logout from the Supernova\"\n static override examples = [\"<%= config.bin %> <%= command.id %>\"]\n static override flags = commonFlags\n private vaultService = new VaultService()\n\n get commandId(): string {\n return Logout.id\n }\n\n get configSchema() {\n return z.object({})\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const { flags } = await this.parse(Logout)\n\n const env = flags.target as TargetEnv\n await this.vaultService.deleteTokensFromVault(env)\n this.log(\"You have been logged out\")\n }\n}\n"]}
|
|
@@ -1,44 +1,25 @@
|
|
|
1
1
|
import { z, ZodType } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
declare const PublishDocumentationConfigSchema: z.
|
|
2
|
+
import { SentryCommand } from "../types/index.js";
|
|
3
|
+
declare const PublishDocumentationConfigSchema: z.ZodObject<{
|
|
4
4
|
apiKey: z.ZodString;
|
|
5
5
|
awaitPublishJob: z.ZodBoolean;
|
|
6
6
|
designSystemId: z.ZodString;
|
|
7
7
|
dev: z.ZodBoolean;
|
|
8
|
-
environment: z.ZodNativeEnum<typeof Environment>;
|
|
9
8
|
proxyUrl: z.ZodOptional<z.ZodString>;
|
|
10
9
|
target: z.ZodString;
|
|
11
10
|
}, "strip", z.ZodTypeAny, {
|
|
12
11
|
designSystemId: string;
|
|
13
12
|
apiKey: string;
|
|
14
|
-
environment: Environment;
|
|
15
|
-
target: string;
|
|
16
13
|
awaitPublishJob: boolean;
|
|
17
14
|
dev: boolean;
|
|
18
|
-
proxyUrl?: string | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
designSystemId: string;
|
|
21
|
-
apiKey: string;
|
|
22
|
-
environment: Environment;
|
|
23
15
|
target: string;
|
|
24
|
-
awaitPublishJob: boolean;
|
|
25
|
-
dev: boolean;
|
|
26
|
-
proxyUrl?: string | undefined;
|
|
27
|
-
}>, {
|
|
28
|
-
environment: Environment;
|
|
29
|
-
designSystemId: string;
|
|
30
|
-
apiKey: string;
|
|
31
|
-
target: string;
|
|
32
|
-
awaitPublishJob: boolean;
|
|
33
|
-
dev: boolean;
|
|
34
16
|
proxyUrl?: string | undefined;
|
|
35
17
|
}, {
|
|
36
18
|
designSystemId: string;
|
|
37
19
|
apiKey: string;
|
|
38
|
-
environment: Environment;
|
|
39
|
-
target: string;
|
|
40
20
|
awaitPublishJob: boolean;
|
|
41
21
|
dev: boolean;
|
|
22
|
+
target: string;
|
|
42
23
|
proxyUrl?: string | undefined;
|
|
43
24
|
}>;
|
|
44
25
|
type PublishDocumentationConfig = z.infer<typeof PublishDocumentationConfigSchema>;
|
|
@@ -51,7 +32,6 @@ export declare class PublishDocumentation extends SentryCommand<PublishDocumenta
|
|
|
51
32
|
awaitPublishJob: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
52
33
|
designSystemId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
53
34
|
dev: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
54
|
-
environment: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
55
35
|
proxyUrl: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
56
36
|
target: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
57
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-documentation.d.ts","sourceRoot":"","sources":["../../src/commands/publish-documentation.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"publish-documentation.d.ts","sourceRoot":"","sources":["../../src/commands/publish-documentation.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAUjD,QAAA,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;EAOpC,CAAA;AAEF,KAAK,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAMlF,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,0BAA0B,CAAC;IAKjF,MAAM,CAAC,OAAO,EAAE,CAAC,uBAAuB,CAAC,CAAA;IAEzC,MAAM,CAAC,WAAW,SAAgD;IAElE,MAAM,CAAC,QAAQ,WAAkG;IAEjH,MAAM,CAAC,KAAK;;;;;;;MAsBX;IAKD,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,0BAA0B,CAAC,CAEtD;IAGK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAyD3B"}
|
|
@@ -11,23 +11,17 @@ import { Flags } from "@oclif/core";
|
|
|
11
11
|
import { SentryTraced } from "@sentry/nestjs";
|
|
12
12
|
import * as sdkTypes from "@supernovaio/sdk";
|
|
13
13
|
import { z } from "zod";
|
|
14
|
-
import {
|
|
14
|
+
import { SentryCommand } from "../types/index.js";
|
|
15
15
|
import { sleep } from "../utils/common.js";
|
|
16
16
|
import { getWritableVersion } from "../utils/sdk.js";
|
|
17
|
-
const PublishDocumentationConfigSchema = z
|
|
18
|
-
.object({
|
|
17
|
+
const PublishDocumentationConfigSchema = z.object({
|
|
19
18
|
apiKey: z.string(),
|
|
20
19
|
awaitPublishJob: z.boolean(),
|
|
21
20
|
designSystemId: z.string(),
|
|
22
21
|
dev: z.boolean(),
|
|
23
|
-
environment: z.nativeEnum(Environment),
|
|
24
22
|
proxyUrl: z.string().url().optional(),
|
|
25
23
|
target: z.string(),
|
|
26
|
-
})
|
|
27
|
-
.transform(data => ({
|
|
28
|
-
...data,
|
|
29
|
-
environment: data.environment ?? Environment.production,
|
|
30
|
-
}));
|
|
24
|
+
});
|
|
31
25
|
export class PublishDocumentation extends SentryCommand {
|
|
32
26
|
static aliases;
|
|
33
27
|
static description = "Publish latest version of the documentation";
|
|
@@ -43,13 +37,6 @@ export class PublishDocumentation extends SentryCommand {
|
|
|
43
37
|
}),
|
|
44
38
|
designSystemId: Flags.string({ description: "Design System to publish the documentation", required: true }),
|
|
45
39
|
dev: Flags.boolean({ default: false, description: "When enabled, CLI will target dev server", hidden: true }),
|
|
46
|
-
environment: Flags.string({
|
|
47
|
-
default: Environment.production,
|
|
48
|
-
description: "When set, CLI will target a specific environment",
|
|
49
|
-
hidden: true,
|
|
50
|
-
options: Object.values(Environment),
|
|
51
|
-
required: false,
|
|
52
|
-
}),
|
|
53
40
|
proxyUrl: Flags.string({
|
|
54
41
|
description: "When set, CLI will use provided proxy URL for all requests",
|
|
55
42
|
hidden: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-documentation.js","sourceRoot":"","sources":["../../src/commands/publish-documentation.ts"],"names":[],"mappings":";;;;;;;;;AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAQpD,MAAM,gCAAgC,GAAG,CAAC;KACvC,MAAM,CAAC;IACN,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE;IAC5B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC;IACtC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACrC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;CACnB,CAAC;KACD,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,GAAG,IAAI;IACP,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,WA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AC,iBAAiB,CAAC,MAAM;QAC5C,MAAM,KAAK,QAAQ,CAAC,iBAAiB,CAAC,OAAO;QAC7C,MAAM,KAAK,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAC9C,CAAA;AACH,CAAC","sourcesContent":["//\n// publish-documentation.ts\n// Supernova CLI\n//\n// Created by Jiri Trecak.\n// Copyright © Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\nimport { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport * as sdkTypes from \"@supernovaio/sdk\"\nimport { z, ZodType } from \"zod\"\n\nimport { Environment, SentryCommand } from \"../types/index.js\"\nimport { sleep } from \"../utils/common.js\"\nimport { getWritableVersion } from \"../utils/sdk.js\"\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Definition\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Configuration\n\nconst PublishDocumentationConfigSchema = z\n .object({\n apiKey: z.string(),\n awaitPublishJob: z.boolean(),\n designSystemId: z.string(),\n dev: z.boolean(),\n environment: z.nativeEnum(Environment),\n proxyUrl: z.string().url().optional(),\n target: z.string(),\n })\n .transform(data => ({\n ...data,\n environment: data.environment ?? Environment.production,\n }))\n\ntype PublishDocumentationConfig = z.infer<typeof PublishDocumentationConfigSchema>\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Tool implementation\n\n/** Command that publishes documentation */\nexport class PublishDocumentation extends SentryCommand<PublishDocumentationConfig> {\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command configuration\n\n // How this command can be run\n static aliases: [\"publish-documentation\"]\n // Command help description\n static description = \"Publish latest version of the documentation\"\n // Examples how to use the command\n static examples = [`$ @supernovaio/cli publish-documentation --apiKey=\"{xxx-xxx-xxx}\" --designSystemId=\"{1234}\"`]\n // Static flags to enable / disable features\n static flags = {\n apiKey: Flags.string({ description: \"API key to use for accessing Supernova instance\", required: true }),\n awaitPublishJob: Flags.boolean({\n default: true,\n description:\n \"Whether to block the process until the publishing is done. \" +\n \"Setting the flag to false will exit with success as long as documentation publish was successfully triggered, \" +\n \"but before the publish is completed. Setting the flag to true will exit once the publish is complete and will \" +\n \"throw if documentation publish is not successful.\",\n }),\n designSystemId: Flags.string({ description: \"Design System to publish the documentation\", required: true }),\n dev: Flags.boolean({ default: false, description: \"When enabled, CLI will target dev server\", hidden: true }),\n environment: Flags.string({\n default: Environment.production,\n description: \"When set, CLI will target a specific environment\",\n hidden: true,\n options: Object.values(Environment),\n required: false,\n }),\n proxyUrl: Flags.string({\n description: \"When set, CLI will use provided proxy URL for all requests\",\n hidden: true,\n required: false,\n }),\n target: Flags.string({\n default: \"Live\",\n description: \"Environment to use for publishing: Live or Preview\",\n required: false,\n }),\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command runtime\n\n get commandId(): string {\n return PublishDocumentation.id\n }\n\n get configSchema(): ZodType<PublishDocumentationConfig> {\n return PublishDocumentationConfigSchema\n }\n\n @SentryTraced()\n async run(): Promise<void> {\n const { flags } = await this.parse(PublishDocumentation)\n\n const environment = tryParseDocsEnvironment(flags.target)\n if (!environment) {\n const supportedEnvs = [sdkTypes.DocumentationEnvironment.live, sdkTypes.DocumentationEnvironment.preview]\n this.error(`Unknown target ${flags.target}, must be one of [${supportedEnvs.join(\", \")}]`)\n }\n\n // Get workspace -> design system –> version\n const { designSystem, id, instance } = await getWritableVersion(flags)\n\n this.log(`Queueing documentation publish in ${designSystem.name}...`)\n\n let publishJob = await instance.documentation.publishDrafts(id, environment, {\n groupPersistentIds: [],\n pagePersistentIds: [],\n })\n\n this.log(`Documentation queued for publishing`.green)\n\n if (!flags.awaitPublishJob) {\n this.log(`Documentation publish await is disabled, exiting before the publish is finished.`.yellow)\n return\n }\n\n this.log(`Waiting for the documentation publish to be finished...`)\n\n // Timeout is roughly 30 minutes\n for (let i = 0; i < 30 * 60; i++) {\n // eslint-disable-next-line no-await-in-loop\n await sleep(1000)\n // eslint-disable-next-line no-await-in-loop\n publishJob = await instance.documentation.getDocumentationBuild(designSystem.workspaceId, publishJob.id)\n if (isJobStatusDone(publishJob.status)) break\n }\n\n switch (publishJob.status) {\n case \"Success\": {\n this.log(\"\\nDone: Documentation queued for publishing\".green)\n\n break\n }\n\n case \"Failed\": {\n throw new Error(`Documentation publish failed`)\n }\n\n case \"Timeout\": {\n throw new Error(`Documentation publish timed out`)\n }\n\n default: {\n throw new Error(`Error awaiting publish job`)\n }\n }\n }\n}\n\nfunction tryParseDocsEnvironment(targetArg: string) {\n switch (targetArg.toLowerCase()) {\n case \"live\": {\n return sdkTypes.DocumentationEnvironment.live\n }\n\n case \"preview\": {\n return sdkTypes.DocumentationEnvironment.preview\n }\n\n default: {\n return null\n }\n }\n}\n\nfunction isJobStatusDone(status: sdkTypes.ExportBuildStatus): boolean {\n return (\n status === sdkTypes.ExportBuildStatus.Failed ||\n status === sdkTypes.ExportBuildStatus.Success ||\n status === sdkTypes.ExportBuildStatus.Timeout\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"publish-documentation.js","sourceRoot":"","sources":["../../src/commands/publish-documentation.ts"],"names":[],"mappings":";;;;;;;;;AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EA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,wBAAwB,CAAC,OAAO,CAAA;QAClD,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,MAAkC;IACzD,OAAO,CACL,MAAM,KAAK,QAAQ,CAAC,iBAAiB,CAAC,MAAM;QAC5C,MAAM,KAAK,QAAQ,CAAC,iBAAiB,CAAC,OAAO;QAC7C,MAAM,KAAK,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAC9C,CAAA;AACH,CAAC","sourcesContent":["//\n// publish-documentation.ts\n// Supernova CLI\n//\n// Created by Jiri Trecak.\n// Copyright © Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\nimport { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport * as sdkTypes from \"@supernovaio/sdk\"\nimport { z, ZodType } from \"zod\"\n\nimport { SentryCommand } from \"../types/index.js\"\nimport { sleep } from \"../utils/common.js\"\nimport { getWritableVersion } from \"../utils/sdk.js\"\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Definition\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Configuration\n\nconst PublishDocumentationConfigSchema = z.object({\n apiKey: z.string(),\n awaitPublishJob: z.boolean(),\n designSystemId: z.string(),\n dev: z.boolean(),\n proxyUrl: z.string().url().optional(),\n target: z.string(),\n})\n\ntype PublishDocumentationConfig = z.infer<typeof PublishDocumentationConfigSchema>\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Tool implementation\n\n/** Command that publishes documentation */\nexport class PublishDocumentation extends SentryCommand<PublishDocumentationConfig> {\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command configuration\n\n // How this command can be run\n static aliases: [\"publish-documentation\"]\n // Command help description\n static description = \"Publish latest version of the documentation\"\n // Examples how to use the command\n static examples = [`$ @supernovaio/cli publish-documentation --apiKey=\"{xxx-xxx-xxx}\" --designSystemId=\"{1234}\"`]\n // Static flags to enable / disable features\n static flags = {\n apiKey: Flags.string({ description: \"API key to use for accessing Supernova instance\", required: true }),\n awaitPublishJob: Flags.boolean({\n default: true,\n description:\n \"Whether to block the process until the publishing is done. \" +\n \"Setting the flag to false will exit with success as long as documentation publish was successfully triggered, \" +\n \"but before the publish is completed. Setting the flag to true will exit once the publish is complete and will \" +\n \"throw if documentation publish is not successful.\",\n }),\n designSystemId: Flags.string({ description: \"Design System to publish the documentation\", required: true }),\n dev: Flags.boolean({ default: false, description: \"When enabled, CLI will target dev server\", hidden: true }),\n proxyUrl: Flags.string({\n description: \"When set, CLI will use provided proxy URL for all requests\",\n hidden: true,\n required: false,\n }),\n target: Flags.string({\n default: \"Live\",\n description: \"Environment to use for publishing: Live or Preview\",\n required: false,\n }),\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command runtime\n\n get commandId(): string {\n return PublishDocumentation.id\n }\n\n get configSchema(): ZodType<PublishDocumentationConfig> {\n return PublishDocumentationConfigSchema\n }\n\n @SentryTraced()\n async run(): Promise<void> {\n const { flags } = await this.parse(PublishDocumentation)\n\n const environment = tryParseDocsEnvironment(flags.target)\n if (!environment) {\n const supportedEnvs = [sdkTypes.DocumentationEnvironment.live, sdkTypes.DocumentationEnvironment.preview]\n this.error(`Unknown target ${flags.target}, must be one of [${supportedEnvs.join(\", \")}]`)\n }\n\n // Get workspace -> design system –> version\n const { designSystem, id, instance } = await getWritableVersion(flags)\n\n this.log(`Queueing documentation publish in ${designSystem.name}...`)\n\n let publishJob = await instance.documentation.publishDrafts(id, environment, {\n groupPersistentIds: [],\n pagePersistentIds: [],\n })\n\n this.log(`Documentation queued for publishing`.green)\n\n if (!flags.awaitPublishJob) {\n this.log(`Documentation publish await is disabled, exiting before the publish is finished.`.yellow)\n return\n }\n\n this.log(`Waiting for the documentation publish to be finished...`)\n\n // Timeout is roughly 30 minutes\n for (let i = 0; i < 30 * 60; i++) {\n // eslint-disable-next-line no-await-in-loop\n await sleep(1000)\n // eslint-disable-next-line no-await-in-loop\n publishJob = await instance.documentation.getDocumentationBuild(designSystem.workspaceId, publishJob.id)\n if (isJobStatusDone(publishJob.status)) break\n }\n\n switch (publishJob.status) {\n case \"Success\": {\n this.log(\"\\nDone: Documentation queued for publishing\".green)\n\n break\n }\n\n case \"Failed\": {\n throw new Error(`Documentation publish failed`)\n }\n\n case \"Timeout\": {\n throw new Error(`Documentation publish timed out`)\n }\n\n default: {\n throw new Error(`Error awaiting publish job`)\n }\n }\n }\n}\n\nfunction tryParseDocsEnvironment(targetArg: string) {\n switch (targetArg.toLowerCase()) {\n case \"live\": {\n return sdkTypes.DocumentationEnvironment.live\n }\n\n case \"preview\": {\n return sdkTypes.DocumentationEnvironment.preview\n }\n\n default: {\n return null\n }\n }\n}\n\nfunction isJobStatusDone(status: sdkTypes.ExportBuildStatus): boolean {\n return (\n status === sdkTypes.ExportBuildStatus.Failed ||\n status === sdkTypes.ExportBuildStatus.Success ||\n status === sdkTypes.ExportBuildStatus.Timeout\n )\n}\n"]}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { z, ZodType } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { SentryCommand } from "../types/index.js";
|
|
3
3
|
import "colors";
|
|
4
|
-
declare const SyncDesignTokensConfigSchema: z.
|
|
4
|
+
declare const SyncDesignTokensConfigSchema: z.ZodObject<{
|
|
5
5
|
apiKey: z.ZodString;
|
|
6
6
|
apiUrl: z.ZodOptional<z.ZodString>;
|
|
7
7
|
configFilePath: z.ZodString;
|
|
8
8
|
designSystemId: z.ZodString;
|
|
9
|
-
environment: z.ZodNativeEnum<typeof Environment>;
|
|
10
9
|
proxyUrl: z.ZodOptional<z.ZodString>;
|
|
11
10
|
tokenDirPath: z.ZodOptional<z.ZodString>;
|
|
12
11
|
tokenFilePath: z.ZodOptional<z.ZodString>;
|
|
13
12
|
}, "strip", z.ZodTypeAny, {
|
|
14
13
|
designSystemId: string;
|
|
15
14
|
apiKey: string;
|
|
16
|
-
environment: Environment;
|
|
17
15
|
configFilePath: string;
|
|
18
16
|
apiUrl?: string | undefined;
|
|
19
17
|
proxyUrl?: string | undefined;
|
|
@@ -22,25 +20,6 @@ declare const SyncDesignTokensConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
22
20
|
}, {
|
|
23
21
|
designSystemId: string;
|
|
24
22
|
apiKey: string;
|
|
25
|
-
environment: Environment;
|
|
26
|
-
configFilePath: string;
|
|
27
|
-
apiUrl?: string | undefined;
|
|
28
|
-
proxyUrl?: string | undefined;
|
|
29
|
-
tokenDirPath?: string | undefined;
|
|
30
|
-
tokenFilePath?: string | undefined;
|
|
31
|
-
}>, {
|
|
32
|
-
environment: Environment;
|
|
33
|
-
designSystemId: string;
|
|
34
|
-
apiKey: string;
|
|
35
|
-
configFilePath: string;
|
|
36
|
-
apiUrl?: string | undefined;
|
|
37
|
-
proxyUrl?: string | undefined;
|
|
38
|
-
tokenDirPath?: string | undefined;
|
|
39
|
-
tokenFilePath?: string | undefined;
|
|
40
|
-
}, {
|
|
41
|
-
designSystemId: string;
|
|
42
|
-
apiKey: string;
|
|
43
|
-
environment: Environment;
|
|
44
23
|
configFilePath: string;
|
|
45
24
|
apiUrl?: string | undefined;
|
|
46
25
|
proxyUrl?: string | undefined;
|
|
@@ -57,7 +36,6 @@ export declare class SyncDesignTokens extends SentryCommand<SyncDesignTokensConf
|
|
|
57
36
|
apiUrl: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
58
37
|
configFilePath: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
59
38
|
designSystemId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
60
|
-
environment: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
61
39
|
proxyUrl: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
62
40
|
tokenDirPath: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
63
41
|
tokenFilePath: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|