@supernovaio/cli 0.1.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/LICENSE +21 -0
- package/README.md +319 -0
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/dist/commands/sync-design-tokens.d.ts +27 -0
- package/dist/commands/sync-design-tokens.js +103 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/oclif.manifest.json +1 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Salesforce
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
oclif-hello-world
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
oclif example Hello World CLI
|
|
5
|
+
|
|
6
|
+
[](https://oclif.io)
|
|
7
|
+
[](https://npmjs.org/package/oclif-hello-world)
|
|
8
|
+
[](https://circleci.com/gh/oclif/hello-world/tree/main)
|
|
9
|
+
[](https://npmjs.org/package/oclif-hello-world)
|
|
10
|
+
[](https://github.com/oclif/hello-world/blob/main/package.json)
|
|
11
|
+
|
|
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...`
|
|
145
|
+
|
|
146
|
+
Installs a plugin into the CLI.
|
|
147
|
+
|
|
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.
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
USAGE
|
|
215
|
+
$ supernova plugins:uninstall PLUGIN...
|
|
216
|
+
|
|
217
|
+
ARGUMENTS
|
|
218
|
+
PLUGIN plugin to uninstall
|
|
219
|
+
|
|
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
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## `supernova plugins:uninstall PLUGIN...`
|
|
233
|
+
|
|
234
|
+
Removes a plugin from the CLI.
|
|
235
|
+
|
|
236
|
+
```
|
|
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
|
+
|
|
259
|
+
```
|
|
260
|
+
USAGE
|
|
261
|
+
$ supernova plugins:uninstall PLUGIN...
|
|
262
|
+
|
|
263
|
+
ARGUMENTS
|
|
264
|
+
PLUGIN plugin to uninstall
|
|
265
|
+
|
|
266
|
+
FLAGS
|
|
267
|
+
-h, --help Show CLI help.
|
|
268
|
+
-v, --verbose
|
|
269
|
+
|
|
270
|
+
DESCRIPTION
|
|
271
|
+
Removes a plugin from the CLI.
|
|
272
|
+
|
|
273
|
+
ALIASES
|
|
274
|
+
$ supernova plugins unlink
|
|
275
|
+
$ supernova plugins remove
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## `supernova plugins update`
|
|
279
|
+
|
|
280
|
+
Update installed plugins.
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
USAGE
|
|
284
|
+
$ supernova plugins update [-h] [-v]
|
|
285
|
+
|
|
286
|
+
FLAGS
|
|
287
|
+
-h, --help Show CLI help.
|
|
288
|
+
-v, --verbose
|
|
289
|
+
|
|
290
|
+
DESCRIPTION
|
|
291
|
+
Update installed plugins.
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## `supernova sync-design-tokens`
|
|
295
|
+
|
|
296
|
+
Supernova CLI description TODO
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
USAGE
|
|
300
|
+
$ supernova sync-design-tokens -k <value> -d <value> [-b <value>] [-i <value> | -p <value>] [-r]
|
|
301
|
+
|
|
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
|
|
310
|
+
|
|
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
|
+
```
|
|
317
|
+
|
|
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 -->
|
package/bin/dev
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const oclif = require('@oclif/core')
|
|
4
|
+
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const project = path.join(__dirname, '..', 'tsconfig.json')
|
|
7
|
+
|
|
8
|
+
// In dev mode -> use ts-node and dev plugins
|
|
9
|
+
process.env.NODE_ENV = 'development'
|
|
10
|
+
|
|
11
|
+
require('ts-node').register({project})
|
|
12
|
+
|
|
13
|
+
// In dev mode, always show stack traces
|
|
14
|
+
oclif.settings.debug = true;
|
|
15
|
+
|
|
16
|
+
// Start the CLI
|
|
17
|
+
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
|
package/bin/dev.cmd
ADDED
package/bin/run
ADDED
package/bin/run.cmd
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { Brand, DesignSystem, DesignSystemVersion, Supernova } from "@supernovaio/supernova-sdk";
|
|
3
|
+
/** Command that handles synchronization with design tokens plugin */
|
|
4
|
+
export declare class SyncDesignTokens extends Command {
|
|
5
|
+
static description: string;
|
|
6
|
+
static examples: string[];
|
|
7
|
+
static aliases: [
|
|
8
|
+
"sync-design-tokens"
|
|
9
|
+
];
|
|
10
|
+
static flags: {
|
|
11
|
+
apiKey: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
12
|
+
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>;
|
|
17
|
+
dev: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
};
|
|
19
|
+
static args: never[];
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
getWritableBrand(flags: any): Promise<{
|
|
22
|
+
instance: Supernova;
|
|
23
|
+
designSystem: DesignSystem;
|
|
24
|
+
version: DesignSystemVersion;
|
|
25
|
+
brand: Brand;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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 = [];
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +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":{}}}}
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@supernovaio/cli",
|
|
3
|
+
"description": "Supernova.io Command Line Interface",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"author": "Supernova.io",
|
|
6
|
+
"homepage": "https://supernova.io/",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"Supernova",
|
|
9
|
+
"Design Systems",
|
|
10
|
+
"Supernovaio",
|
|
11
|
+
"SDK",
|
|
12
|
+
"Design Tokens",
|
|
13
|
+
"Tokens",
|
|
14
|
+
"Assets",
|
|
15
|
+
"Components",
|
|
16
|
+
"Documentation",
|
|
17
|
+
"CMS"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"bin": {
|
|
21
|
+
"supernova": "./bin/run"
|
|
22
|
+
},
|
|
23
|
+
"bugs": "https://github.com/Supernova-Studio/cli/issues",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@oclif/core": "^1",
|
|
26
|
+
"@oclif/plugin-help": "^5",
|
|
27
|
+
"@oclif/plugin-plugins": "^2.0.1",
|
|
28
|
+
"@supernovaio/supernova-sdk": "^1.7.6",
|
|
29
|
+
"chalk": "^5.0.1",
|
|
30
|
+
"node-fetch": "^3.2.4"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@oclif/test": "^2",
|
|
34
|
+
"@types/chai": "^4",
|
|
35
|
+
"@types/mocha": "^9.0.0",
|
|
36
|
+
"@types/node": "^16.11.36",
|
|
37
|
+
"chai": "^4",
|
|
38
|
+
"eslint": "^7.32.0",
|
|
39
|
+
"eslint-config-oclif": "^4",
|
|
40
|
+
"eslint-config-oclif-typescript": "^1.0.2",
|
|
41
|
+
"globby": "^11",
|
|
42
|
+
"mocha": "^9",
|
|
43
|
+
"oclif": "^3",
|
|
44
|
+
"shx": "^0.3.3",
|
|
45
|
+
"ts-node": "^10.2.1",
|
|
46
|
+
"tslib": "^2.3.1",
|
|
47
|
+
"typescript": "^4.4.3"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=12.0.0"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"/bin",
|
|
54
|
+
"/dist",
|
|
55
|
+
"/npm-shrinkwrap.json",
|
|
56
|
+
"/oclif.manifest.json"
|
|
57
|
+
],
|
|
58
|
+
"main": "dist/index.js",
|
|
59
|
+
"oclif": {
|
|
60
|
+
"bin": "supernova",
|
|
61
|
+
"dirname": "supernova",
|
|
62
|
+
"commands": "./dist/commands",
|
|
63
|
+
"plugins": [
|
|
64
|
+
"@oclif/plugin-help",
|
|
65
|
+
"@oclif/plugin-plugins"
|
|
66
|
+
],
|
|
67
|
+
"topicSeparator": " ",
|
|
68
|
+
"topics": {
|
|
69
|
+
"sync-design-tokens": {
|
|
70
|
+
"description": "Synchronize tokens between design tokens plugin and Supernova design system"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"repository": "https://github.com/Supernova-Studio/cli",
|
|
75
|
+
"scripts": {
|
|
76
|
+
"build": "shx rm -rf dist && tsc -b",
|
|
77
|
+
"lint": "eslint . --ext .ts --config .eslintrc",
|
|
78
|
+
"postpack": "shx rm -f oclif.manifest.json",
|
|
79
|
+
"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",
|
|
83
|
+
"publish-package": "npm run build && npm run prepack && npm publish --access public && npm run postpack"
|
|
84
|
+
},
|
|
85
|
+
"types": "dist/index.d.ts"
|
|
86
|
+
}
|