@supernovaio/cli 0.1.0 → 0.9.0

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,319 +1,58 @@
1
- oclif-hello-world
2
- =================
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;" />
3
2
 
4
- oclif example Hello World CLI
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)]()
5
4
 
6
- [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7
- [![Version](https://img.shields.io/npm/v/oclif-hello-world.svg)](https://npmjs.org/package/oclif-hello-world)
8
- [![CircleCI](https://circleci.com/gh/oclif/hello-world/tree/main.svg?style=shield)](https://circleci.com/gh/oclif/hello-world/tree/main)
9
- [![Downloads/week](https://img.shields.io/npm/dw/oclif-hello-world.svg)](https://npmjs.org/package/oclif-hello-world)
10
- [![License](https://img.shields.io/npm/l/oclif-hello-world.svg)](https://github.com/oclif/hello-world/blob/main/package.json)
5
+ The [Supernova](https://supernova.io) CLI enables you to run specific tasks connected with Supernova from your CI/CD pipelines, from your action triggers (GitHub Actions and similar) or from your command line as well. Supernova CLI is powered by a [Supernova SDK](https://github.com/Supernova-Studio/sdk-typescript) that allows access to many more lower-level operations.
11
6
 
12
- <!-- toc -->
13
- * [Usage](#usage)
14
- * [Commands](#commands)
15
- <!-- tocstop -->
16
- # Usage
17
- <!-- usage -->
18
- ```sh-session
19
- $ npm install -g @supernovaio/cli
20
- $ supernova COMMAND
21
- running command...
22
- $ supernova (--version)
23
- @supernovaio/cli/0.1.0 darwin-x64 node-v12.21.0
24
- $ supernova --help [COMMAND]
25
- USAGE
26
- $ supernova COMMAND
27
- ...
28
- ```
29
- <!-- usagestop -->
30
- # Commands
31
- <!-- commands -->
32
- * [`supernova help [COMMAND]`](#supernova-help-command)
33
- * [`supernova plugins`](#supernova-plugins)
34
- * [`supernova plugins:install PLUGIN...`](#supernova-pluginsinstall-plugin)
35
- * [`supernova plugins:inspect PLUGIN...`](#supernova-pluginsinspect-plugin)
36
- * [`supernova plugins:install PLUGIN...`](#supernova-pluginsinstall-plugin-1)
37
- * [`supernova plugins:link PLUGIN`](#supernova-pluginslink-plugin)
38
- * [`supernova plugins:uninstall PLUGIN...`](#supernova-pluginsuninstall-plugin)
39
- * [`supernova plugins:uninstall PLUGIN...`](#supernova-pluginsuninstall-plugin-1)
40
- * [`supernova plugins:uninstall PLUGIN...`](#supernova-pluginsuninstall-plugin-2)
41
- * [`supernova plugins update`](#supernova-plugins-update)
42
- * [`supernova sync-design-tokens`](#supernova-sync-design-tokens)
43
-
44
- ## `supernova help [COMMAND]`
45
-
46
- Display help for supernova.
47
-
48
- ```
49
- USAGE
50
- $ supernova help [COMMAND] [-n]
51
-
52
- ARGUMENTS
53
- COMMAND Command to show help for.
54
-
55
- FLAGS
56
- -n, --nested-commands Include all nested commands in the output.
57
-
58
- DESCRIPTION
59
- Display help for supernova.
60
- ```
61
-
62
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.1.12/src/commands/help.ts)_
63
-
64
- ## `supernova plugins`
65
-
66
- List installed plugins.
67
-
68
- ```
69
- USAGE
70
- $ supernova plugins [--core]
71
-
72
- FLAGS
73
- --core Show core plugins.
74
-
75
- DESCRIPTION
76
- List installed plugins.
77
-
78
- EXAMPLES
79
- $ supernova plugins
80
- ```
81
-
82
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.1.0/src/commands/plugins/index.ts)_
83
-
84
- ## `supernova plugins:install PLUGIN...`
85
-
86
- Installs a plugin into the CLI.
87
-
88
- ```
89
- USAGE
90
- $ supernova plugins:install PLUGIN...
91
-
92
- ARGUMENTS
93
- PLUGIN Plugin to install.
94
-
95
- FLAGS
96
- -f, --force Run yarn install with force flag.
97
- -h, --help Show CLI help.
98
- -v, --verbose
99
-
100
- DESCRIPTION
101
- Installs a plugin into the CLI.
102
-
103
- Can be installed from npm or a git url.
104
-
105
- Installation of a user-installed plugin will override a core plugin.
106
-
107
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
108
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
109
- the CLI without the need to patch and update the whole CLI.
110
-
111
- ALIASES
112
- $ supernova plugins add
113
-
114
- EXAMPLES
115
- $ supernova plugins:install myplugin
116
-
117
- $ supernova plugins:install https://github.com/someuser/someplugin
118
-
119
- $ supernova plugins:install someuser/someplugin
120
- ```
121
-
122
- ## `supernova plugins:inspect PLUGIN...`
123
-
124
- Displays installation properties of a plugin.
125
-
126
- ```
127
- USAGE
128
- $ supernova plugins:inspect PLUGIN...
129
-
130
- ARGUMENTS
131
- PLUGIN [default: .] Plugin to inspect.
132
-
133
- FLAGS
134
- -h, --help Show CLI help.
135
- -v, --verbose
136
-
137
- DESCRIPTION
138
- Displays installation properties of a plugin.
139
-
140
- EXAMPLES
141
- $ supernova plugins:inspect myplugin
142
- ```
143
-
144
- ## `supernova plugins:install PLUGIN...`
7
+ CLI is separated into different commands that you can use to automate certain aspects of working with Supernova. More command line options are coming as well, stay tuned for those!
145
8
 
146
- Installs a plugin into the CLI.
9
+ ## Installing CLI dependency
147
10
 
148
- ```
149
- USAGE
150
- $ supernova plugins:install PLUGIN...
151
-
152
- ARGUMENTS
153
- PLUGIN Plugin to install.
154
-
155
- FLAGS
156
- -f, --force Run yarn install with force flag.
157
- -h, --help Show CLI help.
158
- -v, --verbose
159
-
160
- DESCRIPTION
161
- Installs a plugin into the CLI.
162
-
163
- Can be installed from npm or a git url.
164
-
165
- Installation of a user-installed plugin will override a core plugin.
166
-
167
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
168
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
169
- the CLI without the need to patch and update the whole CLI.
170
-
171
- ALIASES
172
- $ supernova plugins add
173
-
174
- EXAMPLES
175
- $ supernova plugins:install myplugin
176
-
177
- $ supernova plugins:install https://github.com/someuser/someplugin
178
-
179
- $ supernova plugins:install someuser/someplugin
180
- ```
181
-
182
- ## `supernova plugins:link PLUGIN`
183
-
184
- Links a plugin into the CLI for development.
185
-
186
- ```
187
- USAGE
188
- $ supernova plugins:link PLUGIN
189
-
190
- ARGUMENTS
191
- PATH [default: .] path to plugin
192
-
193
- FLAGS
194
- -h, --help Show CLI help.
195
- -v, --verbose
196
-
197
- DESCRIPTION
198
- Links a plugin into the CLI for development.
199
-
200
- Installation of a linked plugin will override a user-installed or core plugin.
201
-
202
- e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
203
- command will override the user-installed or core plugin implementation. This is useful for development work.
204
-
205
- EXAMPLES
206
- $ supernova plugins:link myplugin
207
- ```
208
-
209
- ## `supernova plugins:uninstall PLUGIN...`
210
-
211
- Removes a plugin from the CLI.
11
+ To install, simply run:
212
12
 
13
+ ```bash
14
+ npm install @supernovaio/supernova-sdk
15
+ yarn add --dev @supernovaio/cli
213
16
  ```
214
- USAGE
215
- $ supernova plugins:uninstall PLUGIN...
216
17
 
217
- ARGUMENTS
218
- PLUGIN plugin to uninstall
18
+ In your target environment, or include CLI dependency in your CI/CD pipelines, like this:
219
19
 
220
- FLAGS
221
- -h, --help Show CLI help.
222
- -v, --verbose
223
-
224
- DESCRIPTION
225
- Removes a plugin from the CLI.
226
-
227
- ALIASES
228
- $ supernova plugins unlink
229
- $ supernova plugins remove
20
+ ```json
21
+ {
22
+ "dependencies": {
23
+ "@supernovaio/cli": "latest"
24
+ }
25
+ }
230
26
  ```
231
27
 
232
- ## `supernova plugins:uninstall PLUGIN...`
28
+ ### Installing CLI globally
233
29
 
234
- Removes a plugin from the CLI.
30
+ You can also install the CLI as global package, and make the CLI globally available under `> supernova` command to your command line. To install the CLI globally, just run the following command:
235
31
 
236
32
  ```
237
- USAGE
238
- $ supernova plugins:uninstall PLUGIN...
239
-
240
- ARGUMENTS
241
- PLUGIN plugin to uninstall
242
-
243
- FLAGS
244
- -h, --help Show CLI help.
245
- -v, --verbose
246
-
247
- DESCRIPTION
248
- Removes a plugin from the CLI.
249
-
250
- ALIASES
251
- $ supernova plugins unlink
252
- $ supernova plugins remove
253
- ```
254
-
255
- ## `supernova plugins:uninstall PLUGIN...`
256
-
257
- Removes a plugin from the CLI.
258
-
33
+ npm install -g @supernovaio/cli
34
+ yarn global add @supernovaio/cli
259
35
  ```
260
- USAGE
261
- $ supernova plugins:uninstall PLUGIN...
262
-
263
- ARGUMENTS
264
- PLUGIN plugin to uninstall
265
36
 
266
- FLAGS
267
- -h, --help Show CLI help.
268
- -v, --verbose
37
+ You can now test that everything was properly set up by running the `supernova` command:
269
38
 
270
- DESCRIPTION
271
- Removes a plugin from the CLI.
272
-
273
- ALIASES
274
- $ supernova plugins unlink
275
- $ supernova plugins remove
276
39
  ```
277
-
278
- ## `supernova plugins update`
279
-
280
- Update installed plugins.
281
-
40
+ ~ % supernova --version
41
+ > @supernovaio/cli/1.x.x ...
282
42
  ```
283
- USAGE
284
- $ supernova plugins update [-h] [-v]
285
43
 
286
- FLAGS
287
- -h, --help Show CLI help.
288
- -v, --verbose
44
+ `Node 12.21.0` or newer environment is required to run the Supernova CLI.
289
45
 
290
- DESCRIPTION
291
- Update installed plugins.
292
- ```
46
+ ## Use cases
293
47
 
294
- ## `supernova sync-design-tokens`
48
+ Following is the list of use cases for Supernova CLI. We will be adding more over time, stay tuned!
295
49
 
296
- Supernova CLI description TODO
50
+ - [Synchronize Figma Token Plugin data](./docs/figma-tokens-sync.md)
297
51
 
298
- ```
299
- USAGE
300
- $ supernova sync-design-tokens -k <value> -d <value> [-b <value>] [-i <value> | -p <value>] [-r]
52
+ ## Contributions
301
53
 
302
- FLAGS
303
- -b, --brandName=<value> Brand to synchronize contents with
304
- -d, --designSystemId=<value> (required) Design System to synchronize contents with
305
- -i, --input=<value> Contents of design tokens plugin definition JSON file
306
- -k, --apiKey=<value> (required) API key to use for accessing Supernova instance
307
- -p, --inputPath=<value> Contents of design tokens plugin definition JSON file
308
- -r, --dryRun When enabled, CLI will validate entire setup including loading/parsing/merging of tokens
309
- but will stop before writing them to remote source
54
+ If you have additional ideas about how to make this project better, let us know by opening an issue! You can also open pull requests if you've worked on improving something yourself and would like to contribute back to the community.
310
55
 
311
- DESCRIPTION
312
- Supernova CLI description TODO
313
-
314
- EXAMPLES
315
- $ @supernovaio/cli sync-design-tokens --apiKey="{key}" --workspaceId=123 --designSystemId=456 --brandName="Test" --input "{}"
316
- ```
56
+ We will be reviewing feature-pull-requests on case-by-case basis, but in general, we are super open to your new ideas and we welcome them! And finally, thank you for your support! You are an amazing community.
317
57
 
318
- _See code: [dist/commands/sync-design-tokens.ts](https://github.com/Supernova-Studio/cli/blob/v0.1.0/dist/commands/sync-design-tokens.ts)_
319
- <!-- commandsstop -->
58
+ Supernova Engineering Team
@@ -1,27 +1,34 @@
1
1
  import { Command } from "@oclif/core";
2
- import { Brand, DesignSystem, DesignSystemVersion, Supernova } from "@supernovaio/supernova-sdk";
2
+ import { DesignSystem, DesignSystemVersion, Supernova } from "@supernovaio/supernova-sdk";
3
+ interface SyncDesignTokensFlags {
4
+ apiKey: string;
5
+ designSystemId: string;
6
+ tokenFilePath?: string;
7
+ tokenDirPath?: string;
8
+ configFilePath: string;
9
+ dev: boolean;
10
+ }
3
11
  /** Command that handles synchronization with design tokens plugin */
4
12
  export declare class SyncDesignTokens extends Command {
5
13
  static description: string;
6
14
  static examples: string[];
7
15
  static aliases: [
8
- "sync-design-tokens"
16
+ "sync-tokens"
9
17
  ];
10
18
  static flags: {
11
19
  apiKey: import("@oclif/core/lib/interfaces").OptionFlag<string>;
12
20
  designSystemId: import("@oclif/core/lib/interfaces").OptionFlag<string>;
13
- brandName: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
14
- input: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
15
- inputPath: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
16
- dryRun: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
21
+ tokenFilePath: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
22
+ tokenDirPath: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
23
+ configFilePath: import("@oclif/core/lib/interfaces").OptionFlag<string>;
17
24
  dev: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
25
  };
19
26
  static args: never[];
20
27
  run(): Promise<void>;
21
- getWritableBrand(flags: any): Promise<{
28
+ getWritableVersion(flags: SyncDesignTokensFlags): Promise<{
22
29
  instance: Supernova;
23
30
  designSystem: DesignSystem;
24
31
  version: DesignSystemVersion;
25
- brand: Brand;
26
32
  }>;
27
33
  }
34
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ //
3
+ // sync-tokens.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 handles synchronization with design tokens plugin */
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
+ let dsTool = new supernova_sdk_1.SupernovaToolsDesignTokensPlugin(connected.version);
28
+ if (flags.tokenDirPath) {
29
+ await dsTool.synchronizeTokensFromDirectory(flags.tokenDirPath, flags.configFilePath);
30
+ }
31
+ else if (flags.tokenFilePath) {
32
+ await dsTool.synchronizeTokensFromFile(flags.tokenFilePath, flags.configFilePath);
33
+ }
34
+ this.log(`Tokens synchronized`);
35
+ }
36
+ async getWritableVersion(flags) {
37
+ if (!flags.apiKey || flags.apiKey.length === 0) {
38
+ throw new Error(`API key must not be empty`);
39
+ }
40
+ if (!flags.designSystemId || flags.designSystemId.length === 0) {
41
+ throw new Error(`Design System ID must not be empty`);
42
+ }
43
+ // Create instance for prod / dev
44
+ const devAPIhost = "https://dev.api2.supernova.io/api";
45
+ let sdkInstance = new supernova_sdk_1.Supernova(flags.apiKey, flags.dev ? devAPIhost : null, null);
46
+ let designSystem = await sdkInstance.designSystem(flags.designSystemId);
47
+ if (!designSystem) {
48
+ throw new Error(`Design system ${flags.designSystemId} not found or not available under provided API key`);
49
+ }
50
+ let version = await designSystem.activeVersion();
51
+ if (!version) {
52
+ throw new Error(`Design system ${flags.designSystemId} writable version not found or not available under provided API key`);
53
+ }
54
+ return {
55
+ instance: sdkInstance,
56
+ designSystem: designSystem,
57
+ version: version
58
+ };
59
+ }
60
+ }
61
+ exports.SyncDesignTokens = SyncDesignTokens;
62
+ // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
63
+ // MARK: - Command configuration
64
+ // Command help description
65
+ SyncDesignTokens.description = "Synchronize tokens from Figma Tokens plugin to Supernova workspaces";
66
+ // Examples how to use the command
67
+ SyncDesignTokens.examples = [
68
+ `$ @supernovaio/cli sync-tokens --apiKey="{xxx-xxx-xxx}" --designSystemId={1234} --tokenFilePath "/path/to/tokens.json" --configFilePath "/path/to/config.json"`,
69
+ `$ @supernovaio/cli sync-tokens --apiKey="{xxx-xxx-xxx}" --designSystemId={1234} --tokenDirPath "/path/to/tokens/" --configFilePath "/path/to/config.json"`,
70
+ ];
71
+ // Static flags to enable / disable features
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 })
79
+ };
80
+ // Required and optional attributes
81
+ SyncDesignTokens.args = [];
@@ -1 +1 @@
1
- {"version":"0.1.0","commands":{"sync-design-tokens":{"id":"sync-design-tokens","description":"Supernova CLI description TODO","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli sync-design-tokens --apiKey=\"{key}\" --workspaceId=123 --designSystemId=456 --brandName=\"Test\" --input \"{}\""],"flags":{"apiKey":{"name":"apiKey","type":"option","char":"k","description":"API key to use for accessing Supernova instance","required":true,"multiple":false},"designSystemId":{"name":"designSystemId","type":"option","char":"d","description":"Design System to synchronize contents with","required":true,"multiple":false},"brandName":{"name":"brandName","type":"option","char":"b","description":"Brand to synchronize contents with","required":false,"multiple":false},"input":{"name":"input","type":"option","char":"i","description":"Contents of design tokens plugin definition JSON file","required":false,"multiple":false,"exclusive":["inputPath"]},"inputPath":{"name":"inputPath","type":"option","char":"p","description":"Contents of design tokens plugin definition JSON file","required":false,"multiple":false,"exclusive":["input"]},"dryRun":{"name":"dryRun","type":"boolean","char":"r","description":"When enabled, CLI will validate entire setup including loading/parsing/merging of tokens but will stop before writing them to remote source","required":false,"allowNo":false},"dev":{"name":"dev","type":"boolean","description":"When enabled, CLI will target dev server","hidden":true,"allowNo":false}},"args":[],"_globalFlags":{}}}}
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":{}}}}
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.1.0",
4
+ "version": "0.9.0",
5
5
  "author": "Supernova.io",
6
6
  "homepage": "https://supernova.io/",
7
7
  "keywords": [
@@ -25,11 +25,13 @@
25
25
  "@oclif/core": "^1",
26
26
  "@oclif/plugin-help": "^5",
27
27
  "@oclif/plugin-plugins": "^2.0.1",
28
- "@supernovaio/supernova-sdk": "^1.7.6",
28
+ "@supernovaio/supernova-sdk": "^1.8.10",
29
29
  "chalk": "^5.0.1",
30
- "node-fetch": "^3.2.4"
30
+ "node-fetch": "^3.2.4",
31
+ "dotenv": "^16.0.0"
31
32
  },
32
33
  "devDependencies": {
34
+ "@babel/register": "^7.18.9",
33
35
  "@oclif/test": "^2",
34
36
  "@types/chai": "^4",
35
37
  "@types/mocha": "^9.0.0",
@@ -44,7 +46,10 @@
44
46
  "shx": "^0.3.3",
45
47
  "ts-node": "^10.2.1",
46
48
  "tslib": "^2.3.1",
47
- "typescript": "^4.4.3"
49
+ "typescript": "^4.4.3",
50
+ "@babel/core": "^7.9.0",
51
+ "@babel/preset-env": "^7.3.4",
52
+ "@babel/preset-react": "7.18.6"
48
53
  },
49
54
  "engines": {
50
55
  "node": ">=12.0.0"
@@ -66,8 +71,8 @@
66
71
  ],
67
72
  "topicSeparator": " ",
68
73
  "topics": {
69
- "sync-design-tokens": {
70
- "description": "Synchronize tokens between design tokens plugin and Supernova design system"
74
+ "sync-tokens": {
75
+ "description": "Synchronize tokens from Figma Tokens plugin to Supernova workspaces"
71
76
  }
72
77
  }
73
78
  },
@@ -77,9 +82,8 @@
77
82
  "lint": "eslint . --ext .ts --config .eslintrc",
78
83
  "postpack": "shx rm -f oclif.manifest.json",
79
84
  "posttest": "yarn lint",
80
- "prepack": "yarn build && oclif manifest && oclif readme",
81
- "test": "mocha --forbid-only \"test/**/*.test.ts\"",
82
- "version": "oclif readme && git add README.md",
85
+ "prepack": "yarn build && oclif manifest",
86
+ "test": "npm run build && env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register --forbid-only \"test/**/*.test.ts\"",
83
87
  "publish-package": "npm run build && npm run prepack && npm publish --access public && npm run postpack"
84
88
  },
85
89
  "types": "dist/index.d.ts"
@@ -1,103 +0,0 @@
1
- "use strict";
2
- //
3
- // CommandSyncDesignTokens.ts
4
- // Supernova SDK
5
- //
6
- // Created by Jiri Trecak.
7
- // Copyright © 2021 Supernova. 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 handles synchronization with design tokens plugin */
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 -> brand
26
- let connected = await this.getWritableBrand(flags);
27
- let dsTool = new supernova_sdk_1.SupernovaToolsDesignTokensPlugin(connected.instance, connected.version, connected.brand);
28
- // Load from either flag or raw input, depending on what was set
29
- if (flags.input && flags.inputPath) {
30
- throw new Error("Unable to use both input and inputPath arguments at the same time. Choose one of them first and then run command again");
31
- }
32
- if (!flags.input && !flags.inputPath) {
33
- throw new Error("Either input or inputPath arguments must be provided and non-empty. Choose one of them first and then run command again");
34
- }
35
- let nodes;
36
- this.log(JSON.stringify(flags, null, 2));
37
- if (flags.input) {
38
- nodes = await dsTool.loadTokensFromDefinition(flags.input);
39
- }
40
- else if (flags.inputPath) {
41
- nodes = await dsTool.loadTokensFromPath(flags.inputPath);
42
- }
43
- else {
44
- throw new Error("Internal input error");
45
- }
46
- // Write tokens
47
- let merged = await dsTool.mergeWithRemoteSource(nodes.processedNodes, !flags.dryRun);
48
- this.log(`Synchronization done | Written or updated ${merged.tokens.length} tokens, ${merged.groups.length} groups`);
49
- }
50
- async getWritableBrand(flags) {
51
- // Create instance for prod / dev
52
- let supernova = new supernova_sdk_1.Supernova(flags.apiKey, flags.dev ? "https://dev.api2.supernova.io/api" : null, null);
53
- let designSystem = await supernova.designSystem(flags.designSystemId);
54
- if (!designSystem) {
55
- throw new Error(`Design system ${flags.designSystemId} not found or not available under provided API key`);
56
- }
57
- let version = await designSystem.activeVersion();
58
- if (!version) {
59
- throw new Error(`Design system ${flags.designSystemId} writable version not found or not available under provided API key`);
60
- }
61
- let brands = await version.brands();
62
- let brand = undefined;
63
- if (!brands) {
64
- throw new Error(`Unable to retrieve brands for design system ${flags.designSystemId} or not available under provided API key`);
65
- }
66
- if (flags.brandName) {
67
- brand = brands.filter(f => f.name.trim() === flags.brandName.trim())[0];
68
- }
69
- else {
70
- brand = brands[0];
71
- }
72
- if (!brand) {
73
- throw new Error(`No usable brand found in design system ${flags.designSystemId}`);
74
- }
75
- return {
76
- instance: supernova,
77
- designSystem: designSystem,
78
- version: version,
79
- brand: brand
80
- };
81
- }
82
- }
83
- exports.SyncDesignTokens = SyncDesignTokens;
84
- // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
85
- // MARK: - Command configuration
86
- // Command help description
87
- SyncDesignTokens.description = "Supernova CLI description TODO";
88
- // Examples how to use the command
89
- SyncDesignTokens.examples = [
90
- `$ @supernovaio/cli sync-design-tokens --apiKey="{key}" --workspaceId=123 --designSystemId=456 --brandName="Test" --input "{}"`,
91
- ];
92
- // Static flags to enable / disable features
93
- SyncDesignTokens.flags = {
94
- apiKey: core_1.Flags.string({ char: 'k', description: 'API key to use for accessing Supernova instance', required: true }),
95
- designSystemId: core_1.Flags.string({ char: 'd', description: 'Design System to synchronize contents with', required: true }),
96
- brandName: core_1.Flags.string({ char: 'b', description: 'Brand to synchronize contents with', required: false }),
97
- input: core_1.Flags.string({ char: 'i', description: 'Contents of design tokens plugin definition JSON file', required: false, exclusive: ['inputPath'] }),
98
- inputPath: core_1.Flags.string({ char: 'p', description: 'Contents of design tokens plugin definition JSON file', required: false, exclusive: ['input'] }),
99
- dryRun: core_1.Flags.boolean({ char: 'r', description: 'When enabled, CLI will validate entire setup including loading/parsing/merging of tokens but will stop before writing them to remote source', required: false }),
100
- dev: core_1.Flags.boolean({ description: 'When enabled, CLI will target dev server', hidden: true })
101
- };
102
- // Required and optional attributes
103
- SyncDesignTokens.args = [];