@supernovaio/cli 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <img src="https://github.com/Supernova-Studio/sdk-typescript/blob/main/readme-icon.png?raw=true" alt="Supernova SDK" style="max-width:100%; margin-bottom: 20px;" />
1
+ <img src="https://github.com/Supernova-Studio/cli/blob/main/docs/images/cli.png?raw=true" alt="Supernova CLI" style="max-width:100%; margin-bottom: 20px;" />
2
2
 
3
3
  # Supernova CLI [![All passing](https://img.shields.io/badge/Test-passing-success)]() [![Version 1.0.0](https://img.shields.io/badge/Version-1.0.0-success)]()
4
4
 
@@ -11,7 +11,7 @@ CLI is separated into different commands that you can use to automate certain as
11
11
  To install, simply run:
12
12
 
13
13
  ```bash
14
- npm install @supernovaio/supernova-sdk
14
+ npm install --save-dev @supernovaio/supernova-sdk
15
15
  yarn add --dev @supernovaio/cli
16
16
  ```
17
17
 
@@ -43,11 +43,23 @@ You can now test that everything was properly set up by running the `supernova`
43
43
 
44
44
  `Node 12.21.0` or newer environment is required to run the Supernova CLI.
45
45
 
46
+ ### Updating CLI globally
47
+
48
+ You can update globally installed CLI by running npm update command on the package:
49
+
50
+ ```
51
+ npm update -g @supernovaio/cli
52
+ yarn global upgrade @supernovaio/cli
53
+ ```
54
+
55
+ This will upgrade the CLI to the latest version and make it immediately last default used version.
56
+
46
57
  ## Use cases
47
58
 
48
59
  Following is the list of use cases for Supernova CLI. We will be adding more over time, stay tuned!
49
60
 
50
61
  - [Synchronize Figma Token Plugin data](./docs/figma-tokens-sync.md)
62
+ - [List workspaces, design systems, brands and themes](./docs/list-workspaces.md)
51
63
 
52
64
  ## Contributions
53
65
 
@@ -0,0 +1,26 @@
1
+ import { Command } from "@oclif/core";
2
+ import { DesignSystem, DesignSystemVersion, Supernova } from "@supernovaio/supernova-sdk";
3
+ interface SyncDesignTokensFlags {
4
+ apiKey: string;
5
+ designSystemId: string;
6
+ dev: boolean;
7
+ }
8
+ /** Command that describes the structure of provided design system */
9
+ export declare class SyncDesignTokens extends Command {
10
+ static description: string;
11
+ static examples: string[];
12
+ static aliases: ["describe-design-system"];
13
+ static flags: {
14
+ apiKey: import("@oclif/core/lib/interfaces").OptionFlag<string>;
15
+ designSystemId: import("@oclif/core/lib/interfaces").OptionFlag<string>;
16
+ dev: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
17
+ };
18
+ static args: never[];
19
+ run(): Promise<void>;
20
+ getWritableVersion(flags: SyncDesignTokensFlags): Promise<{
21
+ instance: Supernova;
22
+ designSystem: DesignSystem;
23
+ version: DesignSystemVersion;
24
+ }>;
25
+ }
26
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ //
3
+ // describe-design-system.ts
4
+ // Supernova CLI
5
+ //
6
+ // Created by Jiri Trecak.
7
+ // Copyright © 2022 Supernova.io. All rights reserved.
8
+ //
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SyncDesignTokens = void 0;
11
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
12
+ // MARK: - Imports
13
+ const core_1 = require("@oclif/core");
14
+ const supernova_sdk_1 = require("@supernovaio/supernova-sdk");
15
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
16
+ // MARK: - Configuration
17
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
18
+ // MARK: - Tool implementation
19
+ /** Command that describes the structure of provided design system */
20
+ class SyncDesignTokens extends core_1.Command {
21
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
22
+ // MARK: - Command runtime
23
+ async run() {
24
+ const { args, flags } = await this.parse(SyncDesignTokens);
25
+ // Get workspace -> design system –> version
26
+ let connected = await this.getWritableVersion(flags);
27
+ // Get brands and themes
28
+ let version = connected.version;
29
+ let brands = await version.brands();
30
+ let themes = await version.themes();
31
+ console.log(`--- Design system "${connected.designSystem.name}", id: ${connected.designSystem.id}:`);
32
+ console.log(`\n`);
33
+ for (let brand of brands) {
34
+ console.log(` ↳ Brand: "${brand.name}", id: ${brand.persistentId}`);
35
+ let brandThemes = themes.filter(t => t.brandId === brand.persistentId);
36
+ if (brandThemes.length > 0) {
37
+ for (let theme of brandThemes) {
38
+ console.log(` ↳ Theme: "${theme.name}", id: ${theme.id}`);
39
+ }
40
+ }
41
+ else {
42
+ console.log(` ↳ No themes defined in this brand`);
43
+ }
44
+ console.log("\n");
45
+ }
46
+ }
47
+ async getWritableVersion(flags) {
48
+ if (!flags.apiKey || flags.apiKey.length === 0) {
49
+ throw new Error(`API key must not be empty`);
50
+ }
51
+ if (!flags.designSystemId || flags.designSystemId.length === 0) {
52
+ throw new Error(`Design System ID must not be empty`);
53
+ }
54
+ // Create instance for prod / dev
55
+ const devAPIhost = "https://dev.api2.supernova.io/api";
56
+ let sdkInstance = new supernova_sdk_1.Supernova(flags.apiKey, flags.dev ? devAPIhost : null, null);
57
+ let designSystem = await sdkInstance.designSystem(flags.designSystemId);
58
+ if (!designSystem) {
59
+ throw new Error(`Design system ${flags.designSystemId} not found or not available under provided API key`);
60
+ }
61
+ let version = await designSystem.activeVersion();
62
+ if (!version) {
63
+ throw new Error(`Design system ${flags.designSystemId} writable version not found or not available under provided API key`);
64
+ }
65
+ return {
66
+ instance: sdkInstance,
67
+ designSystem: designSystem,
68
+ version: version,
69
+ };
70
+ }
71
+ }
72
+ exports.SyncDesignTokens = SyncDesignTokens;
73
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
74
+ // MARK: - Command configuration
75
+ // Command help description
76
+ SyncDesignTokens.description = "Describe structure of single design system by provided ID";
77
+ // Examples how to use the command
78
+ SyncDesignTokens.examples = [`$ @supernovaio/cli describe-design-system --apiKey="{xxx-xxx-xxx}" --designSystemId="{1234}"`];
79
+ // Static flags to enable / disable features
80
+ SyncDesignTokens.flags = {
81
+ apiKey: core_1.Flags.string({ description: "API key to use for accessing Supernova instance", required: true }),
82
+ designSystemId: core_1.Flags.string({ description: "Design System to describe structure of", required: true }),
83
+ dev: core_1.Flags.boolean({ description: "When enabled, CLI will target dev server", hidden: true, default: false }),
84
+ };
85
+ // Required and optional attributes
86
+ SyncDesignTokens.args = [];
@@ -0,0 +1,23 @@
1
+ import { Command } from "@oclif/core";
2
+ import { Supernova, Workspace } from "@supernovaio/supernova-sdk";
3
+ interface SyncDesignTokensFlags {
4
+ apiKey: string;
5
+ dev: boolean;
6
+ }
7
+ /** Command that describes the structure of provided design system */
8
+ export declare class SyncDesignTokens extends Command {
9
+ static description: string;
10
+ static examples: string[];
11
+ static aliases: ["describe-workspaces"];
12
+ static flags: {
13
+ apiKey: import("@oclif/core/lib/interfaces").OptionFlag<string>;
14
+ dev: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ static args: never[];
17
+ run(): Promise<void>;
18
+ getWorkspaces(flags: SyncDesignTokensFlags): Promise<{
19
+ instance: Supernova;
20
+ workspaces: Array<Workspace>;
21
+ }>;
22
+ }
23
+ export {};
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ //
3
+ // describe-workspaces.ts
4
+ // Supernova CLI
5
+ //
6
+ // Created by Jiri Trecak.
7
+ // Copyright © 2022 Supernova.io. All rights reserved.
8
+ //
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SyncDesignTokens = void 0;
11
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
12
+ // MARK: - Imports
13
+ const core_1 = require("@oclif/core");
14
+ const supernova_sdk_1 = require("@supernovaio/supernova-sdk");
15
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
16
+ // MARK: - Configuration
17
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
18
+ // MARK: - Tool implementation
19
+ /** Command that describes the structure of provided design system */
20
+ class SyncDesignTokens extends core_1.Command {
21
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
22
+ // MARK: - Command runtime
23
+ async run() {
24
+ const { args, flags } = await this.parse(SyncDesignTokens);
25
+ // Get workspaces
26
+ let connected = await this.getWorkspaces(flags);
27
+ for (let workspace of connected.workspaces) {
28
+ // Get design systems and log
29
+ let designSystems = await workspace.designSystems();
30
+ console.log(`\n`);
31
+ console.log(`--- Workspace "${workspace.name}", handle: "${workspace.handle}":`);
32
+ for (let designSystem of designSystems) {
33
+ console.log(`\n`);
34
+ console.log(` ↳ DS "${designSystem.name}", id: ${designSystem.id}:`);
35
+ let version = await designSystem.activeVersion();
36
+ let brands = await version.brands();
37
+ let themes = await version.themes();
38
+ for (let brand of brands) {
39
+ console.log(` ↳ Brand: "${brand.name}", id: ${brand.persistentId}`);
40
+ let brandThemes = themes.filter((t) => t.brandId === brand.persistentId);
41
+ if (brandThemes.length > 0) {
42
+ for (let theme of brandThemes) {
43
+ console.log(` ↳ Theme: "${theme.name}", id: ${theme.id}`);
44
+ }
45
+ }
46
+ else {
47
+ console.log(` ↳ No themes defined in this brand`);
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ async getWorkspaces(flags) {
54
+ if (!flags.apiKey || flags.apiKey.length === 0) {
55
+ throw new Error(`API key must not be empty`);
56
+ }
57
+ // Create instance for prod / dev
58
+ const devAPIhost = "https://dev.api2.supernova.io/api";
59
+ let sdkInstance = new supernova_sdk_1.Supernova(flags.apiKey, flags.dev ? devAPIhost : null, null);
60
+ let workspaces = await sdkInstance.workspaces();
61
+ return {
62
+ instance: sdkInstance,
63
+ workspaces: workspaces,
64
+ };
65
+ }
66
+ }
67
+ exports.SyncDesignTokens = SyncDesignTokens;
68
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
69
+ // MARK: - Command configuration
70
+ // Command help description
71
+ SyncDesignTokens.description = "Describe structure of all workspaces and design systems available under those workspaces available for specified API key";
72
+ // Examples how to use the command
73
+ SyncDesignTokens.examples = [`$ @supernovaio/cli describe-workspaces --apiKey="{xxx-xxx-xxx}"`];
74
+ // Static flags to enable / disable features
75
+ SyncDesignTokens.flags = {
76
+ apiKey: core_1.Flags.string({ description: "API key to use for accessing Supernova instance", required: true }),
77
+ dev: core_1.Flags.boolean({ description: "When enabled, CLI will target dev server", hidden: true, default: false }),
78
+ };
79
+ // Required and optional attributes
80
+ SyncDesignTokens.args = [];
@@ -12,9 +12,7 @@ interface SyncDesignTokensFlags {
12
12
  export declare class SyncDesignTokens extends Command {
13
13
  static description: string;
14
14
  static examples: string[];
15
- static aliases: [
16
- "sync-tokens"
17
- ];
15
+ static aliases: ["sync-tokens"];
18
16
  static flags: {
19
17
  apiKey: import("@oclif/core/lib/interfaces").OptionFlag<string>;
20
18
  designSystemId: import("@oclif/core/lib/interfaces").OptionFlag<string>;
@@ -54,7 +54,7 @@ class SyncDesignTokens extends core_1.Command {
54
54
  return {
55
55
  instance: sdkInstance,
56
56
  designSystem: designSystem,
57
- version: version
57
+ version: version,
58
58
  };
59
59
  }
60
60
  }
@@ -70,12 +70,18 @@ SyncDesignTokens.examples = [
70
70
  ];
71
71
  // Static flags to enable / disable features
72
72
  SyncDesignTokens.flags = {
73
- apiKey: core_1.Flags.string({ description: 'API key to use for accessing Supernova instance', required: true }),
74
- designSystemId: core_1.Flags.string({ description: 'Design System to synchronize contents with', required: true }),
75
- tokenFilePath: core_1.Flags.string({ description: 'Path to JSON file containing token definitions', exactlyOne: ["tokenDirPath", "tokenFilePath"] }),
76
- tokenDirPath: core_1.Flags.string({ description: 'Path to directory of JSON files containing token definitions', exactlyOne: ["tokenDirPath", "tokenFilePath"] }),
77
- configFilePath: core_1.Flags.string({ description: 'Path to configuration JSON file', required: true, exclusive: [] }),
78
- dev: core_1.Flags.boolean({ description: 'When enabled, CLI will target dev server', hidden: true, default: false })
73
+ apiKey: core_1.Flags.string({ description: "API key to use for accessing Supernova instance", required: true }),
74
+ designSystemId: core_1.Flags.string({ description: "Design System to synchronize contents with", required: true }),
75
+ tokenFilePath: core_1.Flags.string({
76
+ description: "Path to JSON file containing token definitions",
77
+ exactlyOne: ["tokenDirPath", "tokenFilePath"],
78
+ }),
79
+ tokenDirPath: core_1.Flags.string({
80
+ description: "Path to directory of JSON files containing token definitions",
81
+ exactlyOne: ["tokenDirPath", "tokenFilePath"],
82
+ }),
83
+ configFilePath: core_1.Flags.string({ description: "Path to configuration JSON file", required: true, exclusive: [] }),
84
+ dev: core_1.Flags.boolean({ description: "When enabled, CLI will target dev server", hidden: true, default: false }),
79
85
  };
80
86
  // Required and optional attributes
81
87
  SyncDesignTokens.args = [];
@@ -1 +1 @@
1
- {"version":"0.9.0","commands":{"sync-tokens":{"id":"sync-tokens","description":"Synchronize tokens from Figma Tokens plugin to Supernova workspaces","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenFilePath \"/path/to/tokens.json\" --configFilePath \"/path/to/config.json\"","$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenDirPath \"/path/to/tokens/\" --configFilePath \"/path/to/config.json\""],"flags":{"apiKey":{"name":"apiKey","type":"option","description":"API key to use for accessing Supernova instance","required":true,"multiple":false},"designSystemId":{"name":"designSystemId","type":"option","description":"Design System to synchronize contents with","required":true,"multiple":false},"tokenFilePath":{"name":"tokenFilePath","type":"option","description":"Path to JSON file containing token definitions","multiple":false},"tokenDirPath":{"name":"tokenDirPath","type":"option","description":"Path to directory of JSON files containing token definitions","multiple":false},"configFilePath":{"name":"configFilePath","type":"option","description":"Path to configuration JSON file","required":true,"multiple":false,"exclusive":[]},"dev":{"name":"dev","type":"boolean","description":"When enabled, CLI will target dev server","hidden":true,"allowNo":false}},"args":[],"_globalFlags":{}}}}
1
+ {"version":"0.9.2","commands":{"describe-design-system":{"id":"describe-design-system","description":"Describe structure of single design system by provided ID","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli describe-design-system --apiKey=\"{xxx-xxx-xxx}\" --designSystemId=\"{1234}\""],"flags":{"apiKey":{"name":"apiKey","type":"option","description":"API key to use for accessing Supernova instance","required":true,"multiple":false},"designSystemId":{"name":"designSystemId","type":"option","description":"Design System to describe structure of","required":true,"multiple":false},"dev":{"name":"dev","type":"boolean","description":"When enabled, CLI will target dev server","hidden":true,"allowNo":false}},"args":[],"_globalFlags":{}},"describe-workspaces":{"id":"describe-workspaces","description":"Describe structure of all workspaces and design systems available under those workspaces available for specified API key","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli describe-workspaces --apiKey=\"{xxx-xxx-xxx}\""],"flags":{"apiKey":{"name":"apiKey","type":"option","description":"API key to use for accessing Supernova instance","required":true,"multiple":false},"dev":{"name":"dev","type":"boolean","description":"When enabled, CLI will target dev server","hidden":true,"allowNo":false}},"args":[],"_globalFlags":{}},"sync-tokens":{"id":"sync-tokens","description":"Synchronize tokens from Figma Tokens plugin to Supernova workspaces","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenFilePath \"/path/to/tokens.json\" --configFilePath \"/path/to/config.json\"","$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenDirPath \"/path/to/tokens/\" --configFilePath \"/path/to/config.json\""],"flags":{"apiKey":{"name":"apiKey","type":"option","description":"API key to use for accessing Supernova instance","required":true,"multiple":false},"designSystemId":{"name":"designSystemId","type":"option","description":"Design System to synchronize contents with","required":true,"multiple":false},"tokenFilePath":{"name":"tokenFilePath","type":"option","description":"Path to JSON file containing token definitions","multiple":false},"tokenDirPath":{"name":"tokenDirPath","type":"option","description":"Path to directory of JSON files containing token definitions","multiple":false},"configFilePath":{"name":"configFilePath","type":"option","description":"Path to configuration JSON file","required":true,"multiple":false,"exclusive":[]},"dev":{"name":"dev","type":"boolean","description":"When enabled, CLI will target dev server","hidden":true,"allowNo":false}},"args":[],"_globalFlags":{}}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@supernovaio/cli",
3
3
  "description": "Supernova.io Command Line Interface",
4
- "version": "0.9.0",
4
+ "version": "0.9.2",
5
5
  "author": "Supernova.io",
6
6
  "homepage": "https://supernova.io/",
7
7
  "keywords": [
@@ -25,7 +25,7 @@
25
25
  "@oclif/core": "^1",
26
26
  "@oclif/plugin-help": "^5",
27
27
  "@oclif/plugin-plugins": "^2.0.1",
28
- "@supernovaio/supernova-sdk": "^1.8.10",
28
+ "@supernovaio/supernova-sdk": "^1.8.13",
29
29
  "chalk": "^5.0.1",
30
30
  "node-fetch": "^3.2.4",
31
31
  "dotenv": "^16.0.0"
@@ -73,6 +73,12 @@
73
73
  "topics": {
74
74
  "sync-tokens": {
75
75
  "description": "Synchronize tokens from Figma Tokens plugin to Supernova workspaces"
76
+ },
77
+ "describe-design-system": {
78
+ "description": "Describe structure (brands and themes) of selected design system"
79
+ },
80
+ "describe-workspaces": {
81
+ "description": "Describe structure of all workspaces provided API key has access to"
76
82
  }
77
83
  }
78
84
  },