@supernovaio/cli-next 2.0.1

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.
Files changed (127) hide show
  1. package/README.md +201 -0
  2. package/bin/dev +7 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/run +57 -0
  5. package/bin/run.cmd +3 -0
  6. package/dist/commands/describe-design-system.d.ts +45 -0
  7. package/dist/commands/describe-design-system.d.ts.map +1 -0
  8. package/dist/commands/describe-design-system.js +75 -0
  9. package/dist/commands/describe-design-system.js.map +1 -0
  10. package/dist/commands/describe-workspaces.d.ts +54 -0
  11. package/dist/commands/describe-workspaces.d.ts.map +1 -0
  12. package/dist/commands/describe-workspaces.js +111 -0
  13. package/dist/commands/describe-workspaces.js.map +1 -0
  14. package/dist/commands/import-components.d.ts +50 -0
  15. package/dist/commands/import-components.d.ts.map +1 -0
  16. package/dist/commands/import-components.js +93 -0
  17. package/dist/commands/import-components.js.map +1 -0
  18. package/dist/commands/import-storybook.d.ts +69 -0
  19. package/dist/commands/import-storybook.d.ts.map +1 -0
  20. package/dist/commands/import-storybook.js +348 -0
  21. package/dist/commands/import-storybook.js.map +1 -0
  22. package/dist/commands/login.d.ts +30 -0
  23. package/dist/commands/login.d.ts.map +1 -0
  24. package/dist/commands/login.js +78 -0
  25. package/dist/commands/login.js.map +1 -0
  26. package/dist/commands/logout.d.ts +28 -0
  27. package/dist/commands/logout.d.ts.map +1 -0
  28. package/dist/commands/logout.js +46 -0
  29. package/dist/commands/logout.js.map +1 -0
  30. package/dist/commands/publish-documentation.d.ts +63 -0
  31. package/dist/commands/publish-documentation.d.ts.map +1 -0
  32. package/dist/commands/publish-documentation.js +136 -0
  33. package/dist/commands/publish-documentation.js.map +1 -0
  34. package/dist/commands/sync-tokens.d.ts +70 -0
  35. package/dist/commands/sync-tokens.d.ts.map +1 -0
  36. package/dist/commands/sync-tokens.js +109 -0
  37. package/dist/commands/sync-tokens.js.map +1 -0
  38. package/dist/hooks/postrun/save-config.d.ts +4 -0
  39. package/dist/hooks/postrun/save-config.d.ts.map +1 -0
  40. package/dist/hooks/postrun/save-config.js +17 -0
  41. package/dist/hooks/postrun/save-config.js.map +1 -0
  42. package/dist/hooks/prerun/load-config.d.ts +4 -0
  43. package/dist/hooks/prerun/load-config.d.ts.map +1 -0
  44. package/dist/hooks/prerun/load-config.js +24 -0
  45. package/dist/hooks/prerun/load-config.js.map +1 -0
  46. package/dist/hooks/prerun/sentry.d.ts +4 -0
  47. package/dist/hooks/prerun/sentry.d.ts.map +1 -0
  48. package/dist/hooks/prerun/sentry.js +17 -0
  49. package/dist/hooks/prerun/sentry.js.map +1 -0
  50. package/dist/index.d.ts +2 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +2 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/services/auth.service.d.ts +12 -0
  55. package/dist/services/auth.service.d.ts.map +1 -0
  56. package/dist/services/auth.service.js +104 -0
  57. package/dist/services/auth.service.js.map +1 -0
  58. package/dist/services/index.d.ts +3 -0
  59. package/dist/services/index.d.ts.map +1 -0
  60. package/dist/services/index.js +3 -0
  61. package/dist/services/index.js.map +1 -0
  62. package/dist/services/vault.service.d.ts +28 -0
  63. package/dist/services/vault.service.d.ts.map +1 -0
  64. package/dist/services/vault.service.js +181 -0
  65. package/dist/services/vault.service.js.map +1 -0
  66. package/dist/types/base-command.d.ts +23 -0
  67. package/dist/types/base-command.d.ts.map +1 -0
  68. package/dist/types/base-command.js +127 -0
  69. package/dist/types/base-command.js.map +1 -0
  70. package/dist/types/flags.d.ts +4 -0
  71. package/dist/types/flags.d.ts.map +1 -0
  72. package/dist/types/flags.js +11 -0
  73. package/dist/types/flags.js.map +1 -0
  74. package/dist/types/index.d.ts +7 -0
  75. package/dist/types/index.d.ts.map +1 -0
  76. package/dist/types/index.js +7 -0
  77. package/dist/types/index.js.map +1 -0
  78. package/dist/types/login.d.ts +189 -0
  79. package/dist/types/login.d.ts.map +1 -0
  80. package/dist/types/login.js +39 -0
  81. package/dist/types/login.js.map +1 -0
  82. package/dist/types/not-authorized.error.d.ts +6 -0
  83. package/dist/types/not-authorized.error.d.ts.map +1 -0
  84. package/dist/types/not-authorized.error.js +13 -0
  85. package/dist/types/not-authorized.error.js.map +1 -0
  86. package/dist/types/sentry-command.d.ts +15 -0
  87. package/dist/types/sentry-command.d.ts.map +1 -0
  88. package/dist/types/sentry-command.js +50 -0
  89. package/dist/types/sentry-command.js.map +1 -0
  90. package/dist/types/types.d.ts +29 -0
  91. package/dist/types/types.d.ts.map +1 -0
  92. package/dist/types/types.js +17 -0
  93. package/dist/types/types.js.map +1 -0
  94. package/dist/utils/api-client.d.ts +4 -0
  95. package/dist/utils/api-client.d.ts.map +1 -0
  96. package/dist/utils/api-client.js +11 -0
  97. package/dist/utils/api-client.js.map +1 -0
  98. package/dist/utils/common.d.ts +2 -0
  99. package/dist/utils/common.d.ts.map +1 -0
  100. package/dist/utils/common.js +6 -0
  101. package/dist/utils/common.js.map +1 -0
  102. package/dist/utils/config.service.d.ts +17 -0
  103. package/dist/utils/config.service.d.ts.map +1 -0
  104. package/dist/utils/config.service.js +70 -0
  105. package/dist/utils/config.service.js.map +1 -0
  106. package/dist/utils/figma-tokens-data-loader.d.ts +17 -0
  107. package/dist/utils/figma-tokens-data-loader.d.ts.map +1 -0
  108. package/dist/utils/figma-tokens-data-loader.js +193 -0
  109. package/dist/utils/figma-tokens-data-loader.js.map +1 -0
  110. package/dist/utils/index.d.ts +2 -0
  111. package/dist/utils/index.d.ts.map +1 -0
  112. package/dist/utils/index.js +2 -0
  113. package/dist/utils/index.js.map +1 -0
  114. package/dist/utils/network.d.ts +3 -0
  115. package/dist/utils/network.d.ts.map +1 -0
  116. package/dist/utils/network.js +13 -0
  117. package/dist/utils/network.js.map +1 -0
  118. package/dist/utils/run-exporter/exporter-utils.d.ts +14 -0
  119. package/dist/utils/run-exporter/exporter-utils.d.ts.map +1 -0
  120. package/dist/utils/run-exporter/exporter-utils.js +16 -0
  121. package/dist/utils/run-exporter/exporter-utils.js.map +1 -0
  122. package/dist/utils/sdk.d.ts +20 -0
  123. package/dist/utils/sdk.d.ts.map +1 -0
  124. package/dist/utils/sdk.js +52 -0
  125. package/dist/utils/sdk.js.map +1 -0
  126. package/oclif.manifest.json +534 -0
  127. package/package.json +143 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-components.d.ts","sourceRoot":"","sources":["../../src/commands/import-components.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAE9D,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY7B,CAAA;AAEL,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAE1E,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,aAAa,CAAC,sBAAsB,CAAC;IACjF,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAA+E;IAC1G,OAAgB,QAAQ,WAGvB;IACD,OAAgB,KAAK;;;;;MAcpB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAElD;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAiDlC"}
@@ -0,0 +1,93 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Flags } from "@oclif/core";
11
+ import { SentryTraced } from "@sentry/nestjs";
12
+ import { analyzeComponents } from "@supernovaio/code-analyzer";
13
+ import * as process from "node:process";
14
+ import { z } from "zod";
15
+ import { Environment, SentryCommand } from "../types/index.js";
16
+ const ImportComponentsConfigSchema = z
17
+ .object({
18
+ designSystemId: z.string(),
19
+ environment: z.nativeEnum(Environment),
20
+ importFrom: z.string(),
21
+ rootDir: z.string(),
22
+ versionId: z.string(),
23
+ })
24
+ .transform(data => ({
25
+ ...data,
26
+ environment: data.environment ?? Environment.production,
27
+ rootDir: data.rootDir ?? process.cwd(),
28
+ }));
29
+ export default class ImportComponents extends SentryCommand {
30
+ static args = {};
31
+ static description = "Analyze react components from given package and import them into Supernova";
32
+ static examples = [
33
+ "<%= config.bin %> <%= command.id %> --importFrom components-package --rootDir ./src",
34
+ "<%= config.bin %> <%= command.id %> --importFrom @mui/material",
35
+ ];
36
+ static flags = {
37
+ designSystemId: Flags.string({ description: "Import code components to design system of", required: true }),
38
+ importFrom: Flags.string({
39
+ char: "i",
40
+ description: "Package or directory path to import components from",
41
+ required: true,
42
+ }),
43
+ rootDir: Flags.string({
44
+ char: "r",
45
+ default: process.cwd(),
46
+ description: "Root directory of the package where the import should resolve from. Defaults to the current directory",
47
+ }),
48
+ versionId: Flags.string({ description: "Import code components to version of", required: true }),
49
+ };
50
+ get commandId() {
51
+ return ImportComponents.id;
52
+ }
53
+ get configSchema() {
54
+ return ImportComponentsConfigSchema;
55
+ }
56
+ async run() {
57
+ const { flags } = await this.parse(ImportComponents);
58
+ const { importFrom, rootDir } = flags;
59
+ this.log("šŸ“¦ Component Import Summary".green);
60
+ this.log("========================");
61
+ this.log(`Source: ${importFrom}`);
62
+ this.log(`Root Directory: ${rootDir}`);
63
+ const components = await analyzeComponents({ importFrom, rootDir });
64
+ if (components.length > 0) {
65
+ this.log("\nComponent Summary Table:");
66
+ this.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
67
+ this.log("Component Name Props.Num Required Props Names ");
68
+ this.log("──────────────────────────────────────────────────────────");
69
+ for (const component of components) {
70
+ const propsCount = Object.keys(component.properties).length;
71
+ const requiredCount = Object.values(component.properties).filter(prop => prop.required).length;
72
+ const propsNames = new Set(Object.values(component.properties).map(prop => prop.name));
73
+ const name = component.exportName.padEnd(16, " ").slice(0, 16);
74
+ const propsNum = String(propsCount).padStart(5, " ");
75
+ const required = String(requiredCount).padStart(10, " ");
76
+ const props = [...propsNames].slice(0, 2).join(", ") + (propsNames.size > 2 ? ", ..." : "");
77
+ this.log(`${name} ${propsNum} ${required} ${props}`);
78
+ }
79
+ this.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
80
+ this.log("Importing to Supernova...");
81
+ }
82
+ else {
83
+ this.log("\nāš ļø No components were imported".green);
84
+ }
85
+ }
86
+ }
87
+ __decorate([
88
+ SentryTraced(),
89
+ __metadata("design:type", Function),
90
+ __metadata("design:paramtypes", []),
91
+ __metadata("design:returntype", Promise)
92
+ ], ImportComponents.prototype, "run", null);
93
+ //# sourceMappingURL=import-components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-components.js","sourceRoot":"","sources":["../../src/commands/import-components.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,aAAa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UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;gBAGtF,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;gBAC9D,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;gBACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;gBACxD,MAAM,KAAK,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;gBAE3F,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,QAAQ,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAA;YACvD,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAA;YACpE,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;QAUvC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,mCAAmC,CAAC,KAAK,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;;AAhDY;IADZ,YAAY,EAAE;;;;2CAiDd","sourcesContent":["import { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\n// eslint-disable-next-line n/no-extraneous-import\nimport { analyzeComponents } from \"@supernovaio/code-analyzer\"\nimport * as process from \"node:process\"\nimport { z, ZodType } from \"zod\"\n\nimport { Environment, SentryCommand } from \"../types/index.js\"\n\nconst ImportComponentsConfigSchema = z\n .object({\n designSystemId: z.string(),\n environment: z.nativeEnum(Environment),\n importFrom: z.string(),\n rootDir: z.string(),\n versionId: z.string(),\n })\n .transform(data => ({\n ...data,\n environment: data.environment ?? Environment.production,\n rootDir: data.rootDir ?? process.cwd(),\n }))\n\ntype ImportComponentsConfig = z.infer<typeof ImportComponentsConfigSchema>\n\nexport default class ImportComponents extends SentryCommand<ImportComponentsConfig> {\n static override args = {}\n static override description = \"Analyze react components from given package and import them into Supernova\"\n static override examples = [\n \"<%= config.bin %> <%= command.id %> --importFrom components-package --rootDir ./src\",\n \"<%= config.bin %> <%= command.id %> --importFrom @mui/material\",\n ]\n static override flags = {\n designSystemId: Flags.string({ description: \"Import code components to design system of\", required: true }),\n importFrom: Flags.string({\n char: \"i\",\n description: \"Package or directory path to import components from\",\n required: true,\n }),\n rootDir: Flags.string({\n char: \"r\",\n default: process.cwd(), // Defaults to the current directory\n description:\n \"Root directory of the package where the import should resolve from. Defaults to the current directory\",\n }),\n versionId: Flags.string({ description: \"Import code components to version of\", required: true }),\n }\n\n get commandId(): string {\n return ImportComponents.id\n }\n\n get configSchema(): ZodType<ImportComponentsConfig> {\n return ImportComponentsConfigSchema\n }\n\n @SentryTraced()\n public async run(): Promise<void> {\n const { flags } = await this.parse(ImportComponents)\n\n const { importFrom, rootDir } = flags\n\n // const client = await getClient(environment as TargetEnv)\n\n this.log(\"šŸ“¦ Component Import Summary\".green)\n this.log(\"========================\")\n this.log(`Source: ${importFrom}`)\n this.log(`Root Directory: ${rootDir}`)\n\n const components = await analyzeComponents({ importFrom, rootDir })\n\n if (components.length > 0) {\n this.log(\"\\nComponent Summary Table:\")\n this.log(\"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\")\n this.log(\"Component Name Props.Num Required Props Names \")\n this.log(\"──────────────────────────────────────────────────────────\")\n\n for (const component of components) {\n const propsCount = Object.keys(component.properties).length\n const requiredCount = Object.values(component.properties).filter(prop => prop.required).length\n const propsNames = new Set(Object.values(component.properties).map(prop => prop.name))\n\n // Format each row with fixed width columns\n const name = component.exportName.padEnd(16, \" \").slice(0, 16)\n const propsNum = String(propsCount).padStart(5, \" \")\n const required = String(requiredCount).padStart(10, \" \")\n const props = [...propsNames].slice(0, 2).join(\", \") + (propsNames.size > 2 ? \", ...\" : \"\")\n\n this.log(`${name} ${propsNum} ${required} ${props}`)\n }\n\n this.log(\"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\")\n this.log(\"Importing to Supernova...\")\n /*\n const result = await client.designSystems.versions.codeComponents.import(designSystemId, versionId, {\n codeComponents: components.map(c => ({\n ...c,\n persistentId: `${designSystemId}-${versionId}${c.exportName}}`,\n })),\n })\n this.log(`Total: ${result.created} components imported`.green)\n */\n } else {\n this.log(\"\\nāš ļø No components were imported\".green)\n }\n }\n}\n"]}
@@ -0,0 +1,69 @@
1
+ import { z, ZodType } from "zod";
2
+ import { Environment, SentryCommand } from "../types/index.js";
3
+ declare const ImportStorybookConfigSchema: z.ZodEffects<z.ZodObject<{
4
+ brandId: z.ZodOptional<z.ZodString>;
5
+ designSystemId: z.ZodOptional<z.ZodString>;
6
+ dir: z.ZodOptional<z.ZodString>;
7
+ environment: z.ZodNativeEnum<typeof Environment>;
8
+ name: z.ZodOptional<z.ZodString>;
9
+ sourceId: z.ZodOptional<z.ZodString>;
10
+ versionId: z.ZodOptional<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ environment: Environment;
13
+ name?: string | undefined;
14
+ designSystemId?: string | undefined;
15
+ versionId?: string | undefined;
16
+ brandId?: string | undefined;
17
+ dir?: string | undefined;
18
+ sourceId?: string | undefined;
19
+ }, {
20
+ environment: Environment;
21
+ name?: string | undefined;
22
+ designSystemId?: string | undefined;
23
+ versionId?: string | undefined;
24
+ brandId?: string | undefined;
25
+ dir?: string | undefined;
26
+ sourceId?: string | undefined;
27
+ }>, {
28
+ environment: Environment;
29
+ name?: string | undefined;
30
+ designSystemId?: string | undefined;
31
+ versionId?: string | undefined;
32
+ brandId?: string | undefined;
33
+ dir?: string | undefined;
34
+ sourceId?: string | undefined;
35
+ }, {
36
+ environment: Environment;
37
+ name?: string | undefined;
38
+ designSystemId?: string | undefined;
39
+ versionId?: string | undefined;
40
+ brandId?: string | undefined;
41
+ dir?: string | undefined;
42
+ sourceId?: string | undefined;
43
+ }>;
44
+ type ImportStorybookConfig = z.infer<typeof ImportStorybookConfigSchema>;
45
+ export default class ImportStorybook extends SentryCommand<ImportStorybookConfig> {
46
+ static args: {};
47
+ static description: string;
48
+ static examples: string[];
49
+ static flags: {
50
+ brandId: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
51
+ designSystemId: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
52
+ dir: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
53
+ name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
54
+ sourceId: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
55
+ versionId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
56
+ environment: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
57
+ };
58
+ get commandId(): string;
59
+ get configSchema(): ZodType<ImportStorybookConfig>;
60
+ run(): Promise<void>;
61
+ private askName;
62
+ private createZipFromDirectory;
63
+ private getIndexJson;
64
+ private uploadArchiveToSignedUrl;
65
+ private validateStorybookDirectory;
66
+ private validateZipSize;
67
+ }
68
+ export {};
69
+ //# sourceMappingURL=import-storybook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-storybook.d.ts","sourceRoot":"","sources":["../../src/commands/import-storybook.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAS,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAUhF,QAAA,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa5B,CAAA;AAEL,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAmBxE,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,aAAa,CAAC,qBAAqB,CAAC;IAC/E,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAAgD;IAC3E,OAAgB,QAAQ,WAEvB;IACD,OAAgB,KAAK;;;;;;;;MAYpB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAEjD;IAIY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAgJnB,OAAO;IAwBrB,OAAO,CAAC,sBAAsB;IA0E9B,OAAO,CAAC,YAAY;YAYN,wBAAwB;IA4DtC,OAAO,CAAC,0BAA0B;IA6BlC,OAAO,CAAC,eAAe;CAiBxB"}
@@ -0,0 +1,348 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Flags } from "@oclif/core";
11
+ import { action } from "@oclif/core/ux";
12
+ import { SentryTraced } from "@sentry/nestjs";
13
+ import slugify from "@sindresorhus/slugify";
14
+ import AdmZip from "adm-zip";
15
+ import axios from "axios";
16
+ import cliProgress from "cli-progress";
17
+ import inquirer from "inquirer";
18
+ import * as fs from "node:fs";
19
+ import path from "node:path";
20
+ import { match } from "ts-pattern";
21
+ import { z } from "zod";
22
+ import { Environment, flags, SentryCommand } from "../types/index.js";
23
+ import { sleep } from "../utils/common.js";
24
+ import { getClient } from "../utils/index.js";
25
+ const MAX_ZIP_SIZE_BYTES = 500 * 1024 * 1024;
26
+ const bytesToKB = (bytes) => (bytes / 1024).toFixed(2);
27
+ const bytesToMB = (bytes) => (bytes / (1024 * 1024)).toFixed(2);
28
+ const ImportStorybookConfigSchema = z
29
+ .object({
30
+ brandId: z.string().optional(),
31
+ designSystemId: z.string().optional(),
32
+ dir: z.string().optional(),
33
+ environment: z.nativeEnum(Environment),
34
+ name: z.string().optional(),
35
+ sourceId: z.string().optional(),
36
+ versionId: z.string().optional(),
37
+ })
38
+ .transform(data => ({
39
+ ...data,
40
+ environment: data.environment ?? Environment.production,
41
+ }));
42
+ const storybookEndpoint = (environment, designSystemId, name, accessToken) => {
43
+ const host = match(environment)
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();
50
+ const encodedAccessToken = encodeURIComponent(accessToken);
51
+ return `${host}/design-systems/${designSystemId}/alias/${name}/index.html?storybook_jwt=${encodedAccessToken}`;
52
+ };
53
+ export default class ImportStorybook extends SentryCommand {
54
+ static args = {};
55
+ static description = "Import storybook static export to Supernova";
56
+ static examples = [
57
+ "<%= config.bin %> <%= command.id %> import-storybook --designSystemId=123 --dir ./storybook-static.zip",
58
+ ];
59
+ static flags = {
60
+ ...flags,
61
+ brandId: Flags.string({ char: "b", description: "Import storybooks to brand of" }),
62
+ designSystemId: Flags.string({ char: "D", description: "Import storybooks to design system of" }),
63
+ dir: Flags.string({
64
+ char: "d",
65
+ default: "./storybook-static",
66
+ description: "Directory with storybook static export to import.",
67
+ }),
68
+ name: Flags.string({ char: "a", description: "Import storybooks with name of" }),
69
+ 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
+ };
72
+ get commandId() {
73
+ return ImportStorybook.id;
74
+ }
75
+ get configSchema() {
76
+ return ImportStorybookConfigSchema;
77
+ }
78
+ async run() {
79
+ const startTime = Date.now();
80
+ const { flags } = await this.parse(ImportStorybook);
81
+ const { brandId: bId, designSystemId: dsId, dir, environment, name: nameInput, sourceId, versionId: vId } = flags;
82
+ const name = slugify(await this.askName(nameInput), { lowercase: true });
83
+ let designSystemId = dsId;
84
+ let versionId = vId;
85
+ let brandId = bId;
86
+ const env = environment;
87
+ const apiClient = await getClient(env);
88
+ const { designSystems } = apiClient;
89
+ const { sources, storybookHosting } = designSystems;
90
+ if (!designSystemId) {
91
+ designSystemId = await this.getDesignSystemId(env, designSystemId);
92
+ if (!designSystemId) {
93
+ this.error("Design system ID is required");
94
+ }
95
+ this.saveConfig({ designSystemId });
96
+ }
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
+ if (!brandId) {
105
+ brandId = await this.getBrandId(env, designSystemId, versionId);
106
+ if (!brandId) {
107
+ this.error("Brand ID is required");
108
+ }
109
+ this.saveConfig({ brandId });
110
+ }
111
+ const directoryValidation = this.validateStorybookDirectory(dir);
112
+ if (!directoryValidation.isValid) {
113
+ this.error(directoryValidation.error);
114
+ }
115
+ this.log(`Preparing Storybook files from ${dir}...`);
116
+ const { sizeBytes, zipPath } = this.createZipFromDirectory(dir);
117
+ const sizeValidation = this.validateZipSize(zipPath, sizeBytes);
118
+ if (!sizeValidation.isValid) {
119
+ this.error(sizeValidation.error);
120
+ }
121
+ const { signedUrl, storybookUploadId } = await storybookHosting.getSignedUploadUrl(designSystemId, { name });
122
+ try {
123
+ await this.uploadArchiveToSignedUrl({ designSystemId, name, signedUrl, storybookUploadId, zipPath });
124
+ this.log("āœ… Upload complete.".green);
125
+ this.log("Processing Storybook files...");
126
+ let status;
127
+ action.start("Deploying Storybook to private Supernova hosting service...");
128
+ let unknownStatusCount = 0;
129
+ try {
130
+ do {
131
+ await sleep(1000);
132
+ status = await storybookHosting.getUploadStatus(designSystemId, storybookUploadId);
133
+ if (status.status === "Failed") {
134
+ break;
135
+ }
136
+ if (status.status === "Unknown") {
137
+ unknownStatusCount++;
138
+ }
139
+ else {
140
+ unknownStatusCount = 0;
141
+ }
142
+ if (unknownStatusCount >= 5) {
143
+ this.error("Failed to deploy Storybook: Internal server error".red);
144
+ }
145
+ } while (status.status !== "Completed" || (status.timestamp && status.timestamp < startTime));
146
+ if (status.status === "Failed") {
147
+ action.stop("\nFailed to deploy Storybook: Internal server error".red);
148
+ }
149
+ else {
150
+ const { accessToken } = await storybookHosting.getAccessToken(designSystemId, name);
151
+ const storybookUrl = storybookEndpoint(env, designSystemId, name, accessToken);
152
+ action.stop("\nāœ… Private Storybook deployed successfully!".green);
153
+ try {
154
+ this.log(`Connecting Storybook as a data source in Supernova...`);
155
+ let storiesCount = 0;
156
+ if (sourceId) {
157
+ const { storiesCount: updatedStoriesCount } = await sources.updateStorybookImport(designSystemId, versionId, {
158
+ payload: this.getIndexJson(dir),
159
+ sourceId,
160
+ });
161
+ storiesCount = updatedStoriesCount;
162
+ }
163
+ else {
164
+ const { source } = await sources.create(designSystemId, {
165
+ brandPersistentId: brandId,
166
+ description: "CLI",
167
+ indexUrl: storybookUrl,
168
+ payload: this.getIndexJson(dir),
169
+ type: "Storybook",
170
+ userUrl: storybookUrl,
171
+ });
172
+ storiesCount = source.storybook.storiesCount;
173
+ this.saveConfig({ sourceId: source.id });
174
+ }
175
+ this.log(`āœ… Imported ${storiesCount} component stories into Supernova!`.green);
176
+ this.log(`šŸ”’ Access your Storybook at: ${storybookUrl}`.green);
177
+ }
178
+ catch (error) {
179
+ this.error(`Failed to connect Storybook as data source: ${error instanceof Error ? error.message : String(error)}`
180
+ .red);
181
+ }
182
+ }
183
+ }
184
+ catch (error) {
185
+ action.stop(`\nFailed to deploy Storybook: ${error instanceof Error ? error.message : String(error)}`.red);
186
+ }
187
+ }
188
+ catch (error) {
189
+ this.error(`Failed to upload Storybook files: ${error instanceof Error ? error.message : String(error)}`);
190
+ }
191
+ }
192
+ async askName(inputedName) {
193
+ if (inputedName)
194
+ return inputedName;
195
+ const choice = await inquirer.prompt([
196
+ {
197
+ message: "What's storybook name",
198
+ name: "name",
199
+ type: "input",
200
+ },
201
+ ]);
202
+ if (choice.name === "exit") {
203
+ this.log("Exiting...");
204
+ this.exit(0);
205
+ }
206
+ const name = choice.name;
207
+ this.saveConfig({ name });
208
+ return name;
209
+ }
210
+ createZipFromDirectory(directoryPath) {
211
+ const zip = new AdmZip();
212
+ let totalFiles = 0;
213
+ let processedFiles = 0;
214
+ const countFiles = (currentPath) => {
215
+ const files = fs.readdirSync(currentPath);
216
+ for (const file of files) {
217
+ const filePath = path.join(currentPath, file);
218
+ const stat = fs.statSync(filePath);
219
+ if (stat.isDirectory()) {
220
+ countFiles(filePath);
221
+ }
222
+ else {
223
+ totalFiles++;
224
+ }
225
+ }
226
+ };
227
+ countFiles(directoryPath);
228
+ const progressBar = new cliProgress.SingleBar({
229
+ barCompleteChar: "\u2588",
230
+ barIncompleteChar: "\u2591",
231
+ format: "Creating zip [{bar}] {percentage}% | {value}/{total} files | Current: {filename}",
232
+ hideCursor: true,
233
+ }, cliProgress.Presets.shades_classic);
234
+ progressBar.start(totalFiles, 0, {
235
+ filename: "Initializing...",
236
+ });
237
+ const addFilesToZip = (currentPath, relativePath = "") => {
238
+ const files = fs.readdirSync(currentPath);
239
+ for (const file of files) {
240
+ const filePath = path.join(currentPath, file);
241
+ const stat = fs.statSync(filePath);
242
+ const displayPath = path.join(relativePath, file);
243
+ if (stat.isDirectory()) {
244
+ addFilesToZip(filePath, displayPath);
245
+ }
246
+ else {
247
+ processedFiles++;
248
+ progressBar.update(processedFiles, {
249
+ filename: displayPath.length > 40 ? "..." + displayPath.slice(Math.max(0, displayPath.length - 37)) : displayPath,
250
+ });
251
+ zip.addLocalFile(filePath, relativePath);
252
+ }
253
+ }
254
+ };
255
+ try {
256
+ addFilesToZip(directoryPath);
257
+ }
258
+ finally {
259
+ progressBar.stop();
260
+ }
261
+ const zipPath = `${directoryPath}.zip`;
262
+ zip.writeZip(zipPath);
263
+ const sizeBytes = fs.statSync(zipPath).size;
264
+ return { sizeBytes, zipPath };
265
+ }
266
+ getIndexJson(directoryPath) {
267
+ const indexJsonPath = path.join(directoryPath, "index.json");
268
+ if (!fs.existsSync(indexJsonPath)) {
269
+ return "{}";
270
+ }
271
+ return JSON.parse(fs.readFileSync(indexJsonPath, "utf8"));
272
+ }
273
+ async uploadArchiveToSignedUrl(input) {
274
+ const { designSystemId, name, signedUrl, storybookUploadId, zipPath } = input;
275
+ this.log(`Securely uploading ${zipPath} to Supernova...`);
276
+ const progressBar = new cliProgress.SingleBar({
277
+ barCompleteChar: "\u2588",
278
+ barIncompleteChar: "\u2591",
279
+ format: "Uploading |{bar}| {percentage}% || {value}/{total} kB",
280
+ hideCursor: true,
281
+ }, cliProgress.Presets.shades_classic);
282
+ const fileStream = fs.createReadStream(zipPath);
283
+ const stats = fs.statSync(zipPath);
284
+ const fileSize = stats.size;
285
+ const fileSizeKB = Number.parseFloat(bytesToKB(fileSize));
286
+ progressBar.start(fileSizeKB, 0);
287
+ try {
288
+ await axios.put(signedUrl, fileStream, {
289
+ headers: {
290
+ "Content-Length": fileSize,
291
+ "Content-Type": "application/zip",
292
+ designSystemId,
293
+ storybookUploadId,
294
+ ...(name && { name }),
295
+ },
296
+ onUploadProgress(progressEvent) {
297
+ const loaded = progressEvent.loaded || 0;
298
+ const loadedKB = Number.parseFloat(bytesToKB(loaded));
299
+ progressBar.update(loadedKB);
300
+ },
301
+ });
302
+ progressBar.update(fileSizeKB);
303
+ progressBar.stop();
304
+ }
305
+ catch (error) {
306
+ progressBar.stop();
307
+ throw error;
308
+ }
309
+ }
310
+ validateStorybookDirectory(directoryPath) {
311
+ if (!fs.existsSync(directoryPath)) {
312
+ return { error: `Directory not found: ${directoryPath}`, isValid: false };
313
+ }
314
+ if (!fs.statSync(directoryPath).isDirectory()) {
315
+ return { error: `Not a directory: ${directoryPath}`, isValid: false };
316
+ }
317
+ const requiredFiles = ["index.html", "iframe.html"];
318
+ const missingFiles = requiredFiles.filter(file => !fs.existsSync(path.join(directoryPath, file)));
319
+ if (missingFiles.length > 0) {
320
+ return {
321
+ error: `Directory does not appear to be a valid Storybook export. Missing files: ${missingFiles.join(", ")}`,
322
+ isValid: false,
323
+ };
324
+ }
325
+ return { isValid: true };
326
+ }
327
+ validateZipSize(zipPath, sizeBytes) {
328
+ if (sizeBytes > MAX_ZIP_SIZE_BYTES) {
329
+ try {
330
+ fs.unlinkSync(zipPath);
331
+ }
332
+ catch {
333
+ }
334
+ return {
335
+ error: `Zip file is too large: ${bytesToMB(sizeBytes)}MB. Maximum allowed size is ${bytesToMB(MAX_ZIP_SIZE_BYTES)}MB`,
336
+ isValid: false,
337
+ };
338
+ }
339
+ return { isValid: true };
340
+ }
341
+ }
342
+ __decorate([
343
+ SentryTraced(),
344
+ __metadata("design:type", Function),
345
+ __metadata("design:paramtypes", []),
346
+ __metadata("design:returntype", Promise)
347
+ ], ImportStorybook.prototype, "run", null);
348
+ //# sourceMappingURL=import-storybook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-storybook.js","sourceRoot":"","sources":["../../src/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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"]}
@@ -0,0 +1,30 @@
1
+ import { z, ZodType } from "zod";
2
+ import { Environment, SentryCommand } from "../types/index.js";
3
+ declare const LoginConfigSchema: z.ZodEffects<z.ZodObject<{
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> {
16
+ static args: {};
17
+ static description: string;
18
+ static examples: string[];
19
+ static flags: {
20
+ environment: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
21
+ };
22
+ private readonly authService;
23
+ private readonly vaultService;
24
+ get commandId(): string;
25
+ get configSchema(): ZodType<LoginConfig>;
26
+ run(): Promise<void>;
27
+ private openBrowser;
28
+ }
29
+ export {};
30
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGhC,OAAO,EAAE,WAAW,EAAS,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAEhF,QAAA,MAAM,iBAAiB;;;;;;;;;;EAMlB,CAAA;AAEL,KAAK,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEpD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,aAAa,CAAC,WAAW,CAAC;IAC3D,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAA2B;IACtD,OAAgB,QAAQ,WAA0C;IAClE,OAAgB,KAAK;;MAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiC;IAC7D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmC;IAEhE,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC,CAEvC;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAwBnB,WAAW;CAQ1B"}