@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,78 @@
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 { SentryTraced } from "@sentry/nestjs";
11
+ import open from "open";
12
+ import pkceChallenge from "pkce-challenge";
13
+ import { z } from "zod";
14
+ import { AuthService, VaultService } from "../services/index.js";
15
+ import { Environment, flags, SentryCommand } from "../types/index.js";
16
+ const LoginConfigSchema = z
17
+ .object({
18
+ environment: z.nativeEnum(Environment),
19
+ })
20
+ .transform(data => ({
21
+ environment: data.environment ?? Environment.production,
22
+ }));
23
+ export default class Login extends SentryCommand {
24
+ static args = {};
25
+ static description = "Login to the Supernova";
26
+ static examples = ["<%= config.bin %> <%= command.id %>"];
27
+ static flags = flags;
28
+ authService = new AuthService();
29
+ vaultService = new VaultService();
30
+ get commandId() {
31
+ return Login.id;
32
+ }
33
+ get configSchema() {
34
+ return LoginConfigSchema;
35
+ }
36
+ async run() {
37
+ const { flags } = await this.parse(Login);
38
+ const env = flags.environment;
39
+ const { code_challenge: codeChallenge, code_verifier: codeVerifier } = await pkceChallenge();
40
+ this.log("\n🔐 Authentication Process\n".green);
41
+ this.log("1. Opening browser for authentication...");
42
+ const { authorizeUrl, readKey } = await this.authService.getAuthUrlFromServer(env, codeChallenge);
43
+ await this.openBrowser(authorizeUrl);
44
+ this.log("2. Waiting for authentication to complete...");
45
+ const tokens = await this.authService.getTokensFromServer(env, codeVerifier, readKey);
46
+ if (tokens) {
47
+ this.log("3. Login successful!");
48
+ this.log("4. Storing tokens...");
49
+ await this.vaultService.storeTokensToVault(tokens, env);
50
+ this.log("5. You are now logged in".green);
51
+ }
52
+ else {
53
+ this.log("3. Login timed out".red);
54
+ }
55
+ }
56
+ async openBrowser(url) {
57
+ try {
58
+ await open(url);
59
+ }
60
+ catch {
61
+ this.log("Unable to open browser automatically - please visit the URL manually");
62
+ this.log(`\u001B[4m\u001B[34m${url}\u001B[0m\n`);
63
+ }
64
+ }
65
+ }
66
+ __decorate([
67
+ SentryTraced(),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", []),
70
+ __metadata("design:returntype", Promise)
71
+ ], Login.prototype, "run", null);
72
+ __decorate([
73
+ SentryTraced(),
74
+ __metadata("design:type", Function),
75
+ __metadata("design:paramtypes", [String]),
76
+ __metadata("design:returntype", Promise)
77
+ ], Login.prototype, "openBrowser", null);
78
+ //# sourceMappingURL=login.js.map
@@ -0,0 +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,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAE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,CAAC,CAAA;QACpC,IAAI,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAA;QACxD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;QACrF,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;YAChC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;YAChC,MAAM,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;YACvD,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAA;QAC5C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;IAGa,AAAN,KAAK,CAAC,WAAW,CAAC,GAAW;QACnC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,GAAG,CAAC,CAAA;QACjB,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,GAAG,CAAC,sEAAsE,CAAC,CAAA;YAChF,IAAI,CAAC,GAAG,CAAC,sBAAsB,GAAG,aAAa,CAAC,CAAA;QAClD,CAAC;IACH,CAAC;;AA/BY;IADZ,YAAY,EAAE;;;;gCAsBd;AAGa;IADb,YAAY,EAAE;;;;wCAQd","sourcesContent":["import { SentryTraced } from \"@sentry/nestjs\"\nimport open from \"open\"\nimport pkceChallenge from \"pkce-challenge\"\nimport { z, ZodType } from \"zod\"\n\nimport { AuthService, VaultService } from \"../services/index.js\"\nimport { Environment, flags, SentryCommand, TargetEnv } from \"../types/index.js\"\n\nconst LoginConfigSchema = z\n .object({\n environment: z.nativeEnum(Environment),\n })\n .transform(data => ({\n environment: data.environment ?? Environment.production,\n }))\n\ntype LoginConfig = z.infer<typeof LoginConfigSchema>\n\nexport default class Login extends SentryCommand<LoginConfig> {\n static override args = {}\n static override description = \"Login to the Supernova\"\n static override examples = [\"<%= config.bin %> <%= command.id %>\"]\n static override flags = flags\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(): ZodType<LoginConfig> {\n return LoginConfigSchema\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"]}
@@ -0,0 +1,28 @@
1
+ import { z, ZodType } from "zod";
2
+ import { Environment, SentryCommand } from "../types/index.js";
3
+ declare const LogoutConfigSchema: 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 LogouConfig = z.infer<typeof LogoutConfigSchema>;
15
+ export default class Logout extends SentryCommand<LogouConfig> {
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 vaultService;
23
+ get commandId(): string;
24
+ get configSchema(): ZodType<LogouConfig>;
25
+ run(): Promise<void>;
26
+ }
27
+ export {};
28
+ //# sourceMappingURL=logout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGhC,OAAO,EAAE,WAAW,EAAS,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAEhF,QAAA,MAAM,kBAAkB;;;;;;;;;;EAMnB,CAAA;AAEL,KAAK,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAErD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,aAAa,CAAC,WAAW,CAAC;IAC5D,OAAgB,IAAI,KAAK;IACzB,OAAgB,WAAW,SAA8B;IACzD,OAAgB,QAAQ,WAA0C;IAClE,OAAgB,KAAK;;MAAQ;IAC7B,OAAO,CAAC,YAAY,CAAqB;IAEzC,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC,CAEvC;IAGY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAOlC"}
@@ -0,0 +1,46 @@
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 { SentryTraced } from "@sentry/nestjs";
11
+ import { z } from "zod";
12
+ import { VaultService } from "../services/index.js";
13
+ import { Environment, flags, SentryCommand } from "../types/index.js";
14
+ const LogoutConfigSchema = z
15
+ .object({
16
+ environment: z.nativeEnum(Environment),
17
+ })
18
+ .transform(data => ({
19
+ environment: data.environment ?? Environment.production,
20
+ }));
21
+ export default class Logout extends SentryCommand {
22
+ static args = {};
23
+ static description = "Logout from the Supernova";
24
+ static examples = ["<%= config.bin %> <%= command.id %>"];
25
+ static flags = flags;
26
+ vaultService = new VaultService();
27
+ get commandId() {
28
+ return Logout.id;
29
+ }
30
+ get configSchema() {
31
+ return LogoutConfigSchema;
32
+ }
33
+ async run() {
34
+ const { flags } = await this.parse(Logout);
35
+ const env = flags.target;
36
+ await this.vaultService.deleteTokensFromVault(env);
37
+ this.log("You have been logged out");
38
+ }
39
+ }
40
+ __decorate([
41
+ SentryTraced(),
42
+ __metadata("design:type", Function),
43
+ __metadata("design:paramtypes", []),
44
+ __metadata("design:returntype", Promise)
45
+ ], Logout.prototype, "run", null);
46
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +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,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAa,MAAM,mBAAmB,CAAA;AAEhF,MAAM,kBAAkB,GAAG,CAAC;KACzB,MAAM,CAAC;IACN,WAAW,EAAE,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC;CACvC,CAAC;KACD,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,UAAU;CACxD,CAAC,CAAC,CAAA;AAIL,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,aAA0B;IAC5D,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,KAAK,CAAA;IACrB,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;IAEzC,IAAI,SAAS;QACX,OAAO,MAAM,CAAC,EAAE,CAAA;IAClB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,kBAAkB,CAAA;IAC3B,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, ZodType } from \"zod\"\n\nimport { VaultService } from \"../services/index.js\"\nimport { Environment, flags, SentryCommand, TargetEnv } from \"../types/index.js\"\n\nconst LogoutConfigSchema = z\n .object({\n environment: z.nativeEnum(Environment),\n })\n .transform(data => ({\n environment: data.environment ?? Environment.production,\n }))\n\ntype LogouConfig = z.infer<typeof LogoutConfigSchema>\n\nexport default class Logout extends SentryCommand<LogouConfig> {\n static override args = {}\n static override description = \"Logout from the Supernova\"\n static override examples = [\"<%= config.bin %> <%= command.id %>\"]\n static override flags = flags\n private vaultService = new VaultService()\n\n get commandId(): string {\n return Logout.id\n }\n\n get configSchema(): ZodType<LogouConfig> {\n return LogoutConfigSchema\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"]}
@@ -0,0 +1,63 @@
1
+ import { z, ZodType } from "zod";
2
+ import { Environment, SentryCommand } from "../types/index.js";
3
+ declare const PublishDocumentationConfigSchema: z.ZodEffects<z.ZodObject<{
4
+ apiKey: z.ZodString;
5
+ awaitPublishJob: z.ZodBoolean;
6
+ designSystemId: z.ZodString;
7
+ dev: z.ZodBoolean;
8
+ environment: z.ZodNativeEnum<typeof Environment>;
9
+ proxyUrl: z.ZodOptional<z.ZodString>;
10
+ target: z.ZodString;
11
+ }, "strip", z.ZodTypeAny, {
12
+ designSystemId: string;
13
+ apiKey: string;
14
+ environment: Environment;
15
+ target: string;
16
+ awaitPublishJob: boolean;
17
+ dev: boolean;
18
+ proxyUrl?: string | undefined;
19
+ }, {
20
+ designSystemId: string;
21
+ apiKey: string;
22
+ environment: Environment;
23
+ 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
+ proxyUrl?: string | undefined;
35
+ }, {
36
+ designSystemId: string;
37
+ apiKey: string;
38
+ environment: Environment;
39
+ target: string;
40
+ awaitPublishJob: boolean;
41
+ dev: boolean;
42
+ proxyUrl?: string | undefined;
43
+ }>;
44
+ type PublishDocumentationConfig = z.infer<typeof PublishDocumentationConfigSchema>;
45
+ export declare class PublishDocumentation extends SentryCommand<PublishDocumentationConfig> {
46
+ static aliases: ["publish-documentation"];
47
+ static description: string;
48
+ static examples: string[];
49
+ static flags: {
50
+ apiKey: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
51
+ awaitPublishJob: import("@oclif/core/interfaces").BooleanFlag<boolean>;
52
+ designSystemId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
53
+ dev: import("@oclif/core/interfaces").BooleanFlag<boolean>;
54
+ environment: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
55
+ proxyUrl: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
56
+ target: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
57
+ };
58
+ get commandId(): string;
59
+ get configSchema(): ZodType<PublishDocumentationConfig>;
60
+ run(): Promise<void>;
61
+ }
62
+ export {};
63
+ //# sourceMappingURL=publish-documentation.d.ts.map
@@ -0,0 +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,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAU9D,QAAA,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAajC,CAAA;AAEL,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;;;;;;;;MA6BX;IAKD,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,0BAA0B,CAAC,CAEtD;IAGK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAyD3B"}
@@ -0,0 +1,136 @@
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 * as sdkTypes from "@supernovaio/sdk";
13
+ import { z } from "zod";
14
+ import { Environment, SentryCommand } from "../types/index.js";
15
+ import { sleep } from "../utils/common.js";
16
+ import { getWritableVersion } from "../utils/sdk.js";
17
+ const PublishDocumentationConfigSchema = z
18
+ .object({
19
+ apiKey: z.string(),
20
+ awaitPublishJob: z.boolean(),
21
+ designSystemId: z.string(),
22
+ dev: z.boolean(),
23
+ environment: z.nativeEnum(Environment),
24
+ proxyUrl: z.string().url().optional(),
25
+ target: z.string(),
26
+ })
27
+ .transform(data => ({
28
+ ...data,
29
+ environment: data.environment ?? Environment.production,
30
+ }));
31
+ export class PublishDocumentation extends SentryCommand {
32
+ static aliases;
33
+ static description = "Publish latest version of the documentation";
34
+ static examples = [`$ @supernovaio/cli publish-documentation --apiKey="{xxx-xxx-xxx}" --designSystemId="{1234}"`];
35
+ static flags = {
36
+ apiKey: Flags.string({ description: "API key to use for accessing Supernova instance", required: true }),
37
+ awaitPublishJob: Flags.boolean({
38
+ default: true,
39
+ description: "Whether to block the process until the publishing is done. " +
40
+ "Setting the flag to false will exit with success as long as documentation publish was successfully triggered, " +
41
+ "but before the publish is completed. Setting the flag to true will exit once the publish is complete and will " +
42
+ "throw if documentation publish is not successful.",
43
+ }),
44
+ designSystemId: Flags.string({ description: "Design System to publish the documentation", required: true }),
45
+ 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
+ proxyUrl: Flags.string({
54
+ description: "When set, CLI will use provided proxy URL for all requests",
55
+ hidden: true,
56
+ required: false,
57
+ }),
58
+ target: Flags.string({
59
+ default: "Live",
60
+ description: "Environment to use for publishing: Live or Preview",
61
+ required: false,
62
+ }),
63
+ };
64
+ get commandId() {
65
+ return PublishDocumentation.id;
66
+ }
67
+ get configSchema() {
68
+ return PublishDocumentationConfigSchema;
69
+ }
70
+ async run() {
71
+ const { flags } = await this.parse(PublishDocumentation);
72
+ const environment = tryParseDocsEnvironment(flags.target);
73
+ if (!environment) {
74
+ const supportedEnvs = [sdkTypes.DocumentationEnvironment.live, sdkTypes.DocumentationEnvironment.preview];
75
+ this.error(`Unknown target ${flags.target}, must be one of [${supportedEnvs.join(", ")}]`);
76
+ }
77
+ const { designSystem, id, instance } = await getWritableVersion(flags);
78
+ this.log(`Queueing documentation publish in ${designSystem.name}...`);
79
+ let publishJob = await instance.documentation.publishDrafts(id, environment, {
80
+ groupPersistentIds: [],
81
+ pagePersistentIds: [],
82
+ });
83
+ this.log(`Documentation queued for publishing`.green);
84
+ if (!flags.awaitPublishJob) {
85
+ this.log(`Documentation publish await is disabled, exiting before the publish is finished.`.yellow);
86
+ return;
87
+ }
88
+ this.log(`Waiting for the documentation publish to be finished...`);
89
+ for (let i = 0; i < 30 * 60; i++) {
90
+ await sleep(1000);
91
+ publishJob = await instance.documentation.getDocumentationBuild(designSystem.workspaceId, publishJob.id);
92
+ if (isJobStatusDone(publishJob.status))
93
+ break;
94
+ }
95
+ switch (publishJob.status) {
96
+ case "Success": {
97
+ this.log("\nDone: Documentation queued for publishing".green);
98
+ break;
99
+ }
100
+ case "Failed": {
101
+ throw new Error(`Documentation publish failed`);
102
+ }
103
+ case "Timeout": {
104
+ throw new Error(`Documentation publish timed out`);
105
+ }
106
+ default: {
107
+ throw new Error(`Error awaiting publish job`);
108
+ }
109
+ }
110
+ }
111
+ }
112
+ __decorate([
113
+ SentryTraced(),
114
+ __metadata("design:type", Function),
115
+ __metadata("design:paramtypes", []),
116
+ __metadata("design:returntype", Promise)
117
+ ], PublishDocumentation.prototype, "run", null);
118
+ function tryParseDocsEnvironment(targetArg) {
119
+ switch (targetArg.toLowerCase()) {
120
+ case "live": {
121
+ return sdkTypes.DocumentationEnvironment.live;
122
+ }
123
+ case "preview": {
124
+ return sdkTypes.DocumentationEnvironment.preview;
125
+ }
126
+ default: {
127
+ return null;
128
+ }
129
+ }
130
+ }
131
+ function isJobStatusDone(status) {
132
+ return (status === sdkTypes.ExportBuildStatus.Failed ||
133
+ status === sdkTypes.ExportBuildStatus.Success ||
134
+ status === sdkTypes.ExportBuildStatus.Timeout);
135
+ }
136
+ //# sourceMappingURL=publish-documentation.js.map
@@ -0,0 +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,CAA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B,CAAC,CAAA;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;;AAxDK;IADL,YAAY,EAAE;;;;+CAyDd;AAGH,SAAS,uBAAuB,CAAC,SAAiB;IAChD,QAAQ,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;QAChC,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,OAAO,QAAQ,CAAC,wBAAwB,CAAC,IAAI,CAAA;QAC/C,CAAC;QAED,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,QAAQ,CAAC,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 { 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"]}
@@ -0,0 +1,70 @@
1
+ import { z, ZodType } from "zod";
2
+ import { Environment, SentryCommand } from "../types/index.js";
3
+ import "colors";
4
+ declare const SyncDesignTokensConfigSchema: z.ZodEffects<z.ZodObject<{
5
+ apiKey: z.ZodString;
6
+ apiUrl: z.ZodOptional<z.ZodString>;
7
+ configFilePath: z.ZodString;
8
+ designSystemId: z.ZodString;
9
+ environment: z.ZodNativeEnum<typeof Environment>;
10
+ proxyUrl: z.ZodOptional<z.ZodString>;
11
+ tokenDirPath: z.ZodOptional<z.ZodString>;
12
+ tokenFilePath: z.ZodOptional<z.ZodString>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ designSystemId: string;
15
+ apiKey: string;
16
+ environment: Environment;
17
+ configFilePath: string;
18
+ apiUrl?: string | undefined;
19
+ proxyUrl?: string | undefined;
20
+ tokenDirPath?: string | undefined;
21
+ tokenFilePath?: string | undefined;
22
+ }, {
23
+ designSystemId: string;
24
+ 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
+ configFilePath: string;
45
+ apiUrl?: string | undefined;
46
+ proxyUrl?: string | undefined;
47
+ tokenDirPath?: string | undefined;
48
+ tokenFilePath?: string | undefined;
49
+ }>;
50
+ type SyncDesignTokensConfig = z.infer<typeof SyncDesignTokensConfigSchema>;
51
+ export declare class SyncDesignTokens extends SentryCommand<SyncDesignTokensConfig> {
52
+ static aliases: ["sync-tokens"];
53
+ static description: string;
54
+ static examples: string[];
55
+ static flags: {
56
+ apiKey: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
57
+ apiUrl: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
58
+ configFilePath: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
59
+ 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
+ proxyUrl: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
62
+ tokenDirPath: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
63
+ tokenFilePath: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
64
+ };
65
+ get commandId(): string;
66
+ get configSchema(): ZodType<SyncDesignTokensConfig>;
67
+ run(): Promise<void>;
68
+ }
69
+ export {};
70
+ //# sourceMappingURL=sync-tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-tokens.d.ts","sourceRoot":"","sources":["../../src/commands/sync-tokens.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAG9D,OAAO,QAAQ,CAAA;AAWf,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAc7B,CAAA;AAEL,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAM1E,qBAAa,gBAAiB,SAAQ,aAAa,CAAC,sBAAsB,CAAC;IAKzE,MAAM,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAA;IAE/B,MAAM,CAAC,WAAW,SAAwE;IAE1F,MAAM,CAAC,QAAQ,WAGd;IAED,MAAM,CAAC,KAAK;;;;;;;;;MA4BX;IAKD,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAElD;IAGK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAoC3B"}
@@ -0,0 +1,109 @@
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 { z } from "zod";
13
+ import { Environment, SentryCommand } from "../types/index.js";
14
+ import "colors";
15
+ import { FigmaTokensDataLoader } from "../utils/figma-tokens-data-loader.js";
16
+ import { getWritableVersion } from "../utils/sdk.js";
17
+ const SyncDesignTokensConfigSchema = z
18
+ .object({
19
+ apiKey: z.string(),
20
+ apiUrl: z.string().url().optional(),
21
+ configFilePath: z.string(),
22
+ designSystemId: z.string(),
23
+ environment: z.nativeEnum(Environment),
24
+ proxyUrl: z.string().url().optional(),
25
+ tokenDirPath: z.string().optional(),
26
+ tokenFilePath: z.string().optional(),
27
+ })
28
+ .transform(data => ({
29
+ ...data,
30
+ environment: data.environment ?? Environment.production,
31
+ }));
32
+ export class SyncDesignTokens extends SentryCommand {
33
+ static aliases;
34
+ static description = "Synchronize tokens from Figma Tokens plugin to Supernova workspaces";
35
+ static examples = [
36
+ `$ @supernovaio/cli sync-tokens --apiKey="{xxx-xxx-xxx}" --designSystemId={1234} --tokenFilePath "/path/to/tokens.json" --configFilePath "/path/to/config.json"`,
37
+ `$ @supernovaio/cli sync-tokens --apiKey="{xxx-xxx-xxx}" --designSystemId={1234} --tokenDirPath "/path/to/tokens/" --configFilePath "/path/to/config.json"`,
38
+ ];
39
+ static flags = {
40
+ apiKey: Flags.string({ description: "API key to use for accessing Supernova instance", required: true }),
41
+ apiUrl: Flags.string({
42
+ description: "API url to use for accessing Supernova instance, would ignore defaults",
43
+ hidden: true,
44
+ }),
45
+ configFilePath: Flags.string({ description: "Path to configuration JSON file", exclusive: [], required: true }),
46
+ designSystemId: Flags.string({ description: "Design System to synchronize contents with", required: true }),
47
+ environment: Flags.string({
48
+ default: Environment.production,
49
+ description: "When set, CLI will target a specific environment",
50
+ hidden: true,
51
+ options: Object.values(Environment),
52
+ required: false,
53
+ }),
54
+ proxyUrl: Flags.string({
55
+ description: "When set, CLI will use provided proxy URL for all requests",
56
+ hidden: true,
57
+ required: false,
58
+ }),
59
+ tokenDirPath: Flags.string({
60
+ description: "Path to directory of JSON files containing token definitions",
61
+ exactlyOne: ["tokenDirPath", "tokenFilePath"],
62
+ }),
63
+ tokenFilePath: Flags.string({
64
+ description: "Path to JSON file containing token definitions",
65
+ exactlyOne: ["tokenDirPath", "tokenFilePath"],
66
+ }),
67
+ };
68
+ get commandId() {
69
+ return SyncDesignTokens.id;
70
+ }
71
+ get configSchema() {
72
+ return SyncDesignTokensConfigSchema;
73
+ }
74
+ async run() {
75
+ const { flags } = await this.parse(SyncDesignTokens);
76
+ const { id, instance } = await getWritableVersion(flags);
77
+ const dataLoader = new FigmaTokensDataLoader();
78
+ const configDefinition = dataLoader.loadConfigFromPath(flags.configFilePath);
79
+ const { settings } = configDefinition;
80
+ if (flags.dry) {
81
+ settings.dryRun = true;
82
+ }
83
+ const buildData = (payload) => ({
84
+ connection: { name: "CLI" },
85
+ ...dataLoader.loadConfigFromPathAsIs(flags.configFilePath),
86
+ payload,
87
+ });
88
+ if (!flags.tokenFilePath && !flags.tokenDirPath) {
89
+ throw new Error(`Either tokenFilePath or tokenDirPath must be provided`);
90
+ }
91
+ const tokenDefinition = flags.tokenDirPath
92
+ ? await dataLoader.loadTokensFromDirectory(flags.tokenDirPath, flags.configFilePath)
93
+ : await dataLoader.loadTokensFromPath(flags.tokenFilePath);
94
+ const response = (await instance.versions.writeTokenStudioData(id, buildData(tokenDefinition)));
95
+ if (response?.result?.logs && response.result.logs.length > 0) {
96
+ for (const log of response.result.logs) {
97
+ this.log(log);
98
+ }
99
+ }
100
+ this.log(`\nTokens synchronized`.green);
101
+ }
102
+ }
103
+ __decorate([
104
+ SentryTraced(),
105
+ __metadata("design:type", Function),
106
+ __metadata("design:paramtypes", []),
107
+ __metadata("design:returntype", Promise)
108
+ ], SyncDesignTokens.prototype, "run", null);
109
+ //# sourceMappingURL=sync-tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-tokens.js","sourceRoot":"","sources":["../../src/commands/sync-tokens.ts"],"names":[],"mappings":";;;;;;;;;AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAG9D,OAAO,QAAQ,CAAA;AAEf,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAQpD,M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trecak.\n// Copyright © Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\nimport { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport { z, ZodType } from \"zod\"\n\nimport { Environment, SentryCommand } from \"../types/index.js\"\n\n// eslint-disable-next-line no-restricted-imports\nimport \"colors\"\n\nimport { FigmaTokensDataLoader } from \"../utils/figma-tokens-data-loader.js\"\nimport { getWritableVersion } from \"../utils/sdk.js\"\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Definition\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Configuration\n\nconst SyncDesignTokensConfigSchema = z\n .object({\n apiKey: z.string(),\n apiUrl: z.string().url().optional(),\n configFilePath: z.string(),\n designSystemId: z.string(),\n environment: z.nativeEnum(Environment),\n proxyUrl: z.string().url().optional(),\n tokenDirPath: z.string().optional(),\n tokenFilePath: z.string().optional(),\n })\n .transform(data => ({\n ...data,\n environment: data.environment ?? Environment.production,\n }))\n\ntype SyncDesignTokensConfig = z.infer<typeof SyncDesignTokensConfigSchema>\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Tool implementation\n\n/** Command that handles synchronization with design tokens plugin */\nexport class SyncDesignTokens extends SentryCommand<SyncDesignTokensConfig> {\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command configuration\n\n // How this command can be run\n static aliases: [\"sync-tokens\"]\n // Command help description\n static description = \"Synchronize tokens from Figma Tokens plugin to Supernova workspaces\"\n // Examples how to use the command\n static examples = [\n `$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenFilePath \"/path/to/tokens.json\" --configFilePath \"/path/to/config.json\"`,\n `$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenDirPath \"/path/to/tokens/\" --configFilePath \"/path/to/config.json\"`,\n ]\n // Static flags to enable / disable features\n static flags = {\n apiKey: Flags.string({ description: \"API key to use for accessing Supernova instance\", required: true }),\n apiUrl: Flags.string({\n description: \"API url to use for accessing Supernova instance, would ignore defaults\",\n hidden: true,\n }),\n configFilePath: Flags.string({ description: \"Path to configuration JSON file\", exclusive: [], required: true }),\n designSystemId: Flags.string({ description: \"Design System to synchronize contents with\", required: true }),\n 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 tokenDirPath: Flags.string({\n description: \"Path to directory of JSON files containing token definitions\",\n exactlyOne: [\"tokenDirPath\", \"tokenFilePath\"],\n }),\n tokenFilePath: Flags.string({\n description: \"Path to JSON file containing token definitions\",\n exactlyOne: [\"tokenDirPath\", \"tokenFilePath\"],\n }),\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command runtime\n\n get commandId(): string {\n return SyncDesignTokens.id\n }\n\n get configSchema(): ZodType<SyncDesignTokensConfig> {\n return SyncDesignTokensConfigSchema\n }\n\n @SentryTraced()\n async run(): Promise<void> {\n const { flags } = await this.parse(SyncDesignTokens)\n\n // Get workspace -> design system –> version\n const { id, instance } = await getWritableVersion(flags)\n const dataLoader = new FigmaTokensDataLoader()\n const configDefinition = dataLoader.loadConfigFromPath(flags.configFilePath)\n const { settings } = configDefinition\n if (flags.dry) {\n settings.dryRun = true\n }\n\n const buildData = (payload: unknown) => ({\n connection: { name: \"CLI\" },\n ...dataLoader.loadConfigFromPathAsIs(flags.configFilePath),\n payload,\n })\n\n if (!flags.tokenFilePath && !flags.tokenDirPath) {\n throw new Error(`Either tokenFilePath or tokenDirPath must be provided`)\n }\n\n const tokenDefinition = flags.tokenDirPath\n ? await dataLoader.loadTokensFromDirectory(flags.tokenDirPath, flags.configFilePath)\n : await dataLoader.loadTokensFromPath(flags.tokenFilePath!)\n const response = (await instance.versions.writeTokenStudioData(id, buildData(tokenDefinition))) as {\n result: { logs: string[] }\n }\n if (response?.result?.logs && response.result.logs.length > 0) {\n for (const log of response.result.logs) {\n this.log(log)\n }\n }\n\n this.log(`\\nTokens synchronized`.green)\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { Hook } from "@oclif/core";
2
+ declare const hook: Hook<"postrun">;
3
+ export default hook;
4
+ //# sourceMappingURL=save-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-config.d.ts","sourceRoot":"","sources":["../../../src/hooks/postrun/save-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAKlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,SAAS,CAYzB,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -0,0 +1,17 @@
1
+ import * as console from "node:console";
2
+ import { BaseCommand } from "../../types/index.js";
3
+ const hook = async function ({ argv, Command, config }) {
4
+ if (Command && Command.prototype instanceof BaseCommand) {
5
+ try {
6
+ const cmd = new Command(argv, config);
7
+ const { flags } = await cmd.parse(Command);
8
+ cmd.saveConfig(flags);
9
+ this.log("Configuration saved for future use in .supernova.json");
10
+ }
11
+ catch {
12
+ console.log("Cannot apply configuration from .supernova.json");
13
+ }
14
+ }
15
+ };
16
+ export default hook;
17
+ //# sourceMappingURL=save-config.js.map