@supernovaio/cli 0.9.1 → 0.9.3

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
@@ -43,6 +43,17 @@ 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!
@@ -0,0 +1,26 @@
1
+ import { Command } from "@oclif/core";
2
+ import { DesignSystem, DesignSystemVersion, Supernova } from "@supernovaio/supernova-sdk";
3
+ interface PublishDocumentationFlags {
4
+ apiKey: string;
5
+ designSystemId: string;
6
+ dev: boolean;
7
+ }
8
+ /** Command that publishes documentation */
9
+ export declare class PublishDocumentation extends Command {
10
+ static description: string;
11
+ static examples: string[];
12
+ static aliases: ["publish-documentation"];
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: PublishDocumentationFlags): Promise<{
21
+ instance: Supernova;
22
+ designSystem: DesignSystem;
23
+ version: DesignSystemVersion;
24
+ }>;
25
+ }
26
+ export {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ //
3
+ // publish-documentation.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.PublishDocumentation = 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 publishes documentation */
20
+ class PublishDocumentation extends core_1.Command {
21
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
22
+ // MARK: - Command runtime
23
+ async run() {
24
+ const { args, flags } = await this.parse(PublishDocumentation);
25
+ // Get workspace -> design system –> version
26
+ let connected = await this.getWritableVersion(flags);
27
+ let documentation = await connected.version.documentation();
28
+ let result = await documentation.publish();
29
+ try {
30
+ if (result.status === "Queued") {
31
+ console.log("Documentation queued for publishing");
32
+ }
33
+ else if (result.status === "InProgress") {
34
+ console.log("Skipped documentation publish as another build is already in progress");
35
+ }
36
+ else if (result.status === "Failure") {
37
+ console.log("Unknown error: Documentation not published");
38
+ }
39
+ }
40
+ catch (error) {
41
+ throw error;
42
+ }
43
+ }
44
+ async getWritableVersion(flags) {
45
+ if (!flags.apiKey || flags.apiKey.length === 0) {
46
+ throw new Error(`API key must not be empty`);
47
+ }
48
+ if (!flags.designSystemId || flags.designSystemId.length === 0) {
49
+ throw new Error(`Design System ID must not be empty`);
50
+ }
51
+ // Create instance for prod / dev
52
+ const devAPIhost = "https://dev.api2.supernova.io/api";
53
+ let sdkInstance = new supernova_sdk_1.Supernova(flags.apiKey, flags.dev ? devAPIhost : null, null);
54
+ let designSystem = await sdkInstance.designSystem(flags.designSystemId);
55
+ if (!designSystem) {
56
+ throw new Error(`Design system ${flags.designSystemId} not found or not available under provided API key`);
57
+ }
58
+ let version = await designSystem.activeVersion();
59
+ if (!version) {
60
+ throw new Error(`Design system ${flags.designSystemId} writable version not found or not available under provided API key`);
61
+ }
62
+ return {
63
+ instance: sdkInstance,
64
+ designSystem: designSystem,
65
+ version: version,
66
+ };
67
+ }
68
+ }
69
+ exports.PublishDocumentation = PublishDocumentation;
70
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
71
+ // MARK: - Command configuration
72
+ // Command help description
73
+ PublishDocumentation.description = "Publish latest version of the documentation";
74
+ // Examples how to use the command
75
+ PublishDocumentation.examples = [`$ @supernovaio/cli publish-documentation --apiKey="{xxx-xxx-xxx}" --designSystemId="{1234}"`];
76
+ // Static flags to enable / disable features
77
+ PublishDocumentation.flags = {
78
+ apiKey: core_1.Flags.string({ description: "API key to use for accessing Supernova instance", required: true }),
79
+ designSystemId: core_1.Flags.string({ description: "Design System to publish the documentation", required: true }),
80
+ dev: core_1.Flags.boolean({ description: "When enabled, CLI will target dev server", hidden: true, default: false }),
81
+ };
82
+ // Required and optional attributes
83
+ PublishDocumentation.args = [];
@@ -1 +1 @@
1
- {"version":"0.9.1","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":{}}}}
1
+ {"version":"0.9.3","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":{}},"publish-documentation":{"id":"publish-documentation","description":"Publish latest version of the documentation","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli publish-documentation --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 publish the documentation","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.1",
4
+ "version": "0.9.3",
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.11",
28
+ "@supernovaio/supernova-sdk": "^1.8.23",
29
29
  "chalk": "^5.0.1",
30
30
  "node-fetch": "^3.2.4",
31
31
  "dotenv": "^16.0.0"
@@ -79,6 +79,9 @@
79
79
  },
80
80
  "describe-workspaces": {
81
81
  "description": "Describe structure of all workspaces provided API key has access to"
82
+ },
83
+ "publish-documentation": {
84
+ "description": "Publish current documentation draft from the CLI"
82
85
  }
83
86
  }
84
87
  },