@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.
- package/README.md +201 -0
- package/bin/dev +7 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +57 -0
- package/bin/run.cmd +3 -0
- package/dist/commands/describe-design-system.d.ts +45 -0
- package/dist/commands/describe-design-system.d.ts.map +1 -0
- package/dist/commands/describe-design-system.js +75 -0
- package/dist/commands/describe-design-system.js.map +1 -0
- package/dist/commands/describe-workspaces.d.ts +54 -0
- package/dist/commands/describe-workspaces.d.ts.map +1 -0
- package/dist/commands/describe-workspaces.js +111 -0
- package/dist/commands/describe-workspaces.js.map +1 -0
- package/dist/commands/import-components.d.ts +50 -0
- package/dist/commands/import-components.d.ts.map +1 -0
- package/dist/commands/import-components.js +93 -0
- package/dist/commands/import-components.js.map +1 -0
- package/dist/commands/import-storybook.d.ts +69 -0
- package/dist/commands/import-storybook.d.ts.map +1 -0
- package/dist/commands/import-storybook.js +348 -0
- package/dist/commands/import-storybook.js.map +1 -0
- package/dist/commands/login.d.ts +30 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +78 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +28 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +46 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/publish-documentation.d.ts +63 -0
- package/dist/commands/publish-documentation.d.ts.map +1 -0
- package/dist/commands/publish-documentation.js +136 -0
- package/dist/commands/publish-documentation.js.map +1 -0
- package/dist/commands/sync-tokens.d.ts +70 -0
- package/dist/commands/sync-tokens.d.ts.map +1 -0
- package/dist/commands/sync-tokens.js +109 -0
- package/dist/commands/sync-tokens.js.map +1 -0
- package/dist/hooks/postrun/save-config.d.ts +4 -0
- package/dist/hooks/postrun/save-config.d.ts.map +1 -0
- package/dist/hooks/postrun/save-config.js +17 -0
- package/dist/hooks/postrun/save-config.js.map +1 -0
- package/dist/hooks/prerun/load-config.d.ts +4 -0
- package/dist/hooks/prerun/load-config.d.ts.map +1 -0
- package/dist/hooks/prerun/load-config.js +24 -0
- package/dist/hooks/prerun/load-config.js.map +1 -0
- package/dist/hooks/prerun/sentry.d.ts +4 -0
- package/dist/hooks/prerun/sentry.d.ts.map +1 -0
- package/dist/hooks/prerun/sentry.js +17 -0
- package/dist/hooks/prerun/sentry.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/services/auth.service.d.ts +12 -0
- package/dist/services/auth.service.d.ts.map +1 -0
- package/dist/services/auth.service.js +104 -0
- package/dist/services/auth.service.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +3 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/vault.service.d.ts +28 -0
- package/dist/services/vault.service.d.ts.map +1 -0
- package/dist/services/vault.service.js +181 -0
- package/dist/services/vault.service.js.map +1 -0
- package/dist/types/base-command.d.ts +23 -0
- package/dist/types/base-command.d.ts.map +1 -0
- package/dist/types/base-command.js +127 -0
- package/dist/types/base-command.js.map +1 -0
- package/dist/types/flags.d.ts +4 -0
- package/dist/types/flags.d.ts.map +1 -0
- package/dist/types/flags.js +11 -0
- package/dist/types/flags.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/login.d.ts +189 -0
- package/dist/types/login.d.ts.map +1 -0
- package/dist/types/login.js +39 -0
- package/dist/types/login.js.map +1 -0
- package/dist/types/not-authorized.error.d.ts +6 -0
- package/dist/types/not-authorized.error.d.ts.map +1 -0
- package/dist/types/not-authorized.error.js +13 -0
- package/dist/types/not-authorized.error.js.map +1 -0
- package/dist/types/sentry-command.d.ts +15 -0
- package/dist/types/sentry-command.d.ts.map +1 -0
- package/dist/types/sentry-command.js +50 -0
- package/dist/types/sentry-command.js.map +1 -0
- package/dist/types/types.d.ts +29 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +17 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/api-client.d.ts +4 -0
- package/dist/utils/api-client.d.ts.map +1 -0
- package/dist/utils/api-client.js +11 -0
- package/dist/utils/api-client.js.map +1 -0
- package/dist/utils/common.d.ts +2 -0
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/common.js +6 -0
- package/dist/utils/common.js.map +1 -0
- package/dist/utils/config.service.d.ts +17 -0
- package/dist/utils/config.service.d.ts.map +1 -0
- package/dist/utils/config.service.js +70 -0
- package/dist/utils/config.service.js.map +1 -0
- package/dist/utils/figma-tokens-data-loader.d.ts +17 -0
- package/dist/utils/figma-tokens-data-loader.d.ts.map +1 -0
- package/dist/utils/figma-tokens-data-loader.js +193 -0
- package/dist/utils/figma-tokens-data-loader.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/network.d.ts +3 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +13 -0
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/run-exporter/exporter-utils.d.ts +14 -0
- package/dist/utils/run-exporter/exporter-utils.d.ts.map +1 -0
- package/dist/utils/run-exporter/exporter-utils.js +16 -0
- package/dist/utils/run-exporter/exporter-utils.js.map +1 -0
- package/dist/utils/sdk.d.ts +20 -0
- package/dist/utils/sdk.d.ts.map +1 -0
- package/dist/utils/sdk.js +52 -0
- package/dist/utils/sdk.js.map +1 -0
- package/oclif.manifest.json +534 -0
- package/package.json +143 -0
package/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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
|
+
|
|
3
|
+
# Supernova CLI []() []() []()
|
|
4
|
+
|
|
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.
|
|
6
|
+
|
|
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!
|
|
8
|
+
|
|
9
|
+
### Installing CLI globally
|
|
10
|
+
|
|
11
|
+
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:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
npm install -g @supernovaio/cli
|
|
15
|
+
yarn global add @supernovaio/cli
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
You can now test that everything was properly set up by running the `supernova` command:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
~ % supernova --version
|
|
22
|
+
> @supernovaio/cli/1.x.x ...
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`Node 21` or newer environment is required to run the Supernova CLI.
|
|
26
|
+
|
|
27
|
+
### Updating CLI globally
|
|
28
|
+
|
|
29
|
+
You can update globally installed CLI by running npm update command on the package:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
npm update -g @supernovaio/cli
|
|
33
|
+
yarn global upgrade @supernovaio/cli
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This will upgrade the CLI to the latest version and make it immediately last default used version.
|
|
37
|
+
|
|
38
|
+
## Login Command
|
|
39
|
+
|
|
40
|
+
The login command is a crucial part of the Supernova CLI, as it establishes authentication required before using any other commands. This section explains how the login process works and how to use it effectively.
|
|
41
|
+
### Overview
|
|
42
|
+
The login command authenticates you with Supernova services using a secure OAuth flow with PKCE (Proof Key for Code Exchange). This authentication method is secure and follows modern best practices for CLI authorization.
|
|
43
|
+
``` bash
|
|
44
|
+
supernova login
|
|
45
|
+
```
|
|
46
|
+
### How It Works
|
|
47
|
+
The login process follows these steps:
|
|
48
|
+
1. **Initiate Authentication**: The CLI generates a secure code challenge using PKCE.
|
|
49
|
+
2. **Browser Authentication**: Your default browser will open automatically to Supernova's authentication page.
|
|
50
|
+
3. **Authorization**: Complete the authentication in your browser.
|
|
51
|
+
4. **Token Storage**: Once authenticated, the CLI securely stores your tokens for future use.
|
|
52
|
+
5. **Completion**: You'll see a confirmation message when successfully logged in.
|
|
53
|
+
|
|
54
|
+
### Command Options
|
|
55
|
+
|
|
56
|
+
| Flag | Description |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `--environment` | Specify the environment (production by default) |
|
|
59
|
+
### Token Storage
|
|
60
|
+
Your authentication tokens are securely stored using one of the following methods:
|
|
61
|
+
1. **System Keychain** (Primary method): The CLI uses your operating system's secure credential store.
|
|
62
|
+
2. **Local File** (Fallback): If keychain access fails, tokens are stored in . `~/.supernova/tokens.json`
|
|
63
|
+
3. **Environment Variable**: You can bypass the login process by setting the environment variable. `SUPERNOVA_TOKEN`
|
|
64
|
+
|
|
65
|
+
### Automatic Token Refresh
|
|
66
|
+
The CLI automatically handles token refreshing:
|
|
67
|
+
- Tokens nearing expiration (within 5 minutes) are automatically refreshed.
|
|
68
|
+
- If a refresh token fails, you'll be prompted to log in again.
|
|
69
|
+
|
|
70
|
+
### Usage Examples
|
|
71
|
+
Standard login to production environment:
|
|
72
|
+
``` bash
|
|
73
|
+
supernova login
|
|
74
|
+
```
|
|
75
|
+
Login to a specific environment:
|
|
76
|
+
``` bash
|
|
77
|
+
supernova login --environment=staging
|
|
78
|
+
```
|
|
79
|
+
### Troubleshooting
|
|
80
|
+
If your browser doesn't open automatically, the CLI will display a URL that you can manually copy and paste into your browser to complete the authentication process.
|
|
81
|
+
If you encounter authentication issues, you can try:
|
|
82
|
+
1. Running the login command again
|
|
83
|
+
2. Checking your internet connection
|
|
84
|
+
3. Ensuring you have the correct permissions in Supernova
|
|
85
|
+
|
|
86
|
+
### Important Notes
|
|
87
|
+
- You must complete the authentication process within 5 minutes (300 seconds)
|
|
88
|
+
- All other CLI commands will verify authentication before execution
|
|
89
|
+
- To log out, you can use the `logout` command (which removes stored tokens)
|
|
90
|
+
|
|
91
|
+
## Configuration File
|
|
92
|
+
The Supernova CLI supports configuration files to streamline your workflow by persisting command options and preferences.
|
|
93
|
+
|
|
94
|
+
### Overview
|
|
95
|
+
When working with Supernova CLI, you can use a configuration file named located in your current working directory. This file stores your command-specific options, eliminating the need to repeatedly provide the same flags and parameters in subsequent commands. `.supernova.json`
|
|
96
|
+
|
|
97
|
+
### File Structure
|
|
98
|
+
The configuration file uses a simple JSON structure:
|
|
99
|
+
``` json
|
|
100
|
+
{
|
|
101
|
+
"commands": {
|
|
102
|
+
"command-name": {
|
|
103
|
+
"option1": "value1",
|
|
104
|
+
"option2": "value2"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"global": {}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The file consists of two main sections:
|
|
112
|
+
- **commands**: Contains configurations for specific CLI commands, organized by command ID
|
|
113
|
+
- **global**: Reserved for future global settings that apply across all commands
|
|
114
|
+
|
|
115
|
+
### How Configuration Works
|
|
116
|
+
The configuration system operates through the following mechanisms:
|
|
117
|
+
1. **Automatic Loading**: When you run a command, the CLI checks for a file in your current directory `.supernova.json`
|
|
118
|
+
2. **Command Options**: Any options defined in the configuration file for the current command are automatically applied
|
|
119
|
+
3. **Override Precedence**: Command-line flags take precedence over configuration file values
|
|
120
|
+
4. **Automatic Saving**: After a successful command execution, the CLI saves the used options back to the configuration file
|
|
121
|
+
|
|
122
|
+
### Example Configuration
|
|
123
|
+
Here's an example of a configuration file for token synchronization:
|
|
124
|
+
``` json
|
|
125
|
+
{
|
|
126
|
+
"commands": {
|
|
127
|
+
"login": {
|
|
128
|
+
"environment": "production"
|
|
129
|
+
},
|
|
130
|
+
"figma-tokens-sync": {
|
|
131
|
+
"mode": "single-file",
|
|
132
|
+
"dryRun": false
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"global": {}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Benefits
|
|
140
|
+
Using the configuration file offers several advantages:
|
|
141
|
+
- **Simplifies Command Usage**: No need to repeatedly type the same options
|
|
142
|
+
- **Improves Workflow Efficiency**: Saves time and reduces errors when executing commands
|
|
143
|
+
- **Enhances Team Collaboration**: Share consistent settings across your team by committing the configuration file to version control
|
|
144
|
+
- **Supports CI/CD Integration**: Makes it easier to integrate CLI commands into automated pipelines
|
|
145
|
+
|
|
146
|
+
### Command-Specific Configuration
|
|
147
|
+
Each command can store its specific configuration options. For example:
|
|
148
|
+
1. **Login Command**: Stores the target environment
|
|
149
|
+
``` json
|
|
150
|
+
"login": {
|
|
151
|
+
"environment": "production"
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
1. **Import Storybook Command**: Stores paths and IDs needed for importing
|
|
155
|
+
``` json
|
|
156
|
+
"import-storybook": {
|
|
157
|
+
"environment": "production",
|
|
158
|
+
"dir": "./storybook-static",
|
|
159
|
+
"designSystemId": "37355",
|
|
160
|
+
"versionId": "37352"
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
### Managing Configuration
|
|
164
|
+
The CLI handles configuration automatically:
|
|
165
|
+
- **Required Flags**: If a required flag has a value in the configuration file, it becomes optional in the command line
|
|
166
|
+
- **Updating Values**: When you provide a flag in the command line, its value is saved back to the configuration file for future use
|
|
167
|
+
- **Feedback**: The CLI will inform you when configuration is loaded and saved
|
|
168
|
+
|
|
169
|
+
### Best Practices
|
|
170
|
+
- **Version Control**: Consider adding the file to version control if you want to share settings with your team `.supernova.json`
|
|
171
|
+
- **Sensitive Information**: Avoid storing sensitive information in the configuration file as it might be committed to version control
|
|
172
|
+
|
|
173
|
+
### Troubleshooting
|
|
174
|
+
If you encounter issues with your configuration:
|
|
175
|
+
1. **Check File Format**: Ensure the JSON is valid and properly formatted
|
|
176
|
+
2. **Check Permissions**: Ensure the CLI has write permissions in the current directory
|
|
177
|
+
3. **Reset Configuration**: Simply delete the file to start fresh `.supernova.json`
|
|
178
|
+
|
|
179
|
+
By leveraging the configuration file, you can significantly streamline your workflow when working with the Supernova CLI.
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
## Next Steps
|
|
183
|
+
After successfully logging in, you can use other Supernova CLI commands.
|
|
184
|
+
See the additional use cases section for more information about available commands.
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
### Use cases
|
|
188
|
+
|
|
189
|
+
Following is the list of use cases for Supernova CLI. We will be adding more over time, stay tuned!
|
|
190
|
+
|
|
191
|
+
- [Host private storybook](./docs/storybook-hosting.md)
|
|
192
|
+
- [Synchronize Figma Token Plugin data](./docs/figma-tokens-sync.md)
|
|
193
|
+
- [List workspaces, design systems, brands and themes](./docs/list-workspaces.md)
|
|
194
|
+
|
|
195
|
+
## Contributions
|
|
196
|
+
|
|
197
|
+
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.
|
|
198
|
+
|
|
199
|
+
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.
|
|
200
|
+
|
|
201
|
+
Supernova Engineering Team
|
package/bin/dev
ADDED
package/bin/dev.cmd
ADDED
package/bin/run
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {execute, handle} from '@oclif/core'
|
|
4
|
+
import * as Sentry from '@sentry/node'
|
|
5
|
+
import {nodeProfilingIntegration} from '@sentry/profiling-node'
|
|
6
|
+
import dotenv from 'dotenv'
|
|
7
|
+
|
|
8
|
+
// Load environment variables from .env file
|
|
9
|
+
dotenv.config()
|
|
10
|
+
|
|
11
|
+
const SENSITIVE_KEYS = new Set(['password', 'secret', 'token'])
|
|
12
|
+
|
|
13
|
+
const sanitizeEvent = (event) => {
|
|
14
|
+
if (event.request?.data) {
|
|
15
|
+
event.request.data = maskValues(event.request.data)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return event
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const sanitizeBreadcrumb = (breadcrumb) => {
|
|
22
|
+
if (breadcrumb.data) {
|
|
23
|
+
breadcrumb.data = maskValues(breadcrumb.data)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return breadcrumb
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
30
|
+
const maskValues = (obj) =>
|
|
31
|
+
Object.keys(obj).reduce((acc, key) => {
|
|
32
|
+
acc[key] = SENSITIVE_KEYS.has(key) ? '[REDACTED]' : obj[key]
|
|
33
|
+
return acc
|
|
34
|
+
}, {})
|
|
35
|
+
|
|
36
|
+
Sentry.init({
|
|
37
|
+
beforeBreadcrumb(breadcrumb) {
|
|
38
|
+
return sanitizeBreadcrumb(breadcrumb)
|
|
39
|
+
},
|
|
40
|
+
beforeSend(event) {
|
|
41
|
+
return sanitizeEvent(event)
|
|
42
|
+
},
|
|
43
|
+
beforeSendTransaction(transaction) {
|
|
44
|
+
return sanitizeEvent(transaction)
|
|
45
|
+
},
|
|
46
|
+
debug: false,
|
|
47
|
+
dsn: 'https://9d6591df6378a22920996bd4d12722e3@o337704.ingest.us.sentry.io/4508840260730880',
|
|
48
|
+
ignoreErrors: ['NotAuthorizedError'],
|
|
49
|
+
integrations: [nodeProfilingIntegration()],
|
|
50
|
+
profilesSampleRate: 1,
|
|
51
|
+
tracesSampleRate: 1,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
await Sentry.startSpan({name: 'cli', forceTransaction: true}, () =>
|
|
55
|
+
execute({dir: import.meta.url}).catch((err) => handle(err)),
|
|
56
|
+
)
|
|
57
|
+
await Sentry.flush(1000)
|
package/bin/run.cmd
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Environment, SentryCommand } from "../types/index.js";
|
|
3
|
+
declare const DescribeDesignSystemConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
apiKey: z.ZodString;
|
|
5
|
+
designSystemId: z.ZodString;
|
|
6
|
+
environment: z.ZodNativeEnum<typeof Environment>;
|
|
7
|
+
proxyUrl: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
designSystemId: string;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
environment: Environment;
|
|
12
|
+
proxyUrl?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
designSystemId: string;
|
|
15
|
+
apiKey: string;
|
|
16
|
+
environment: Environment;
|
|
17
|
+
proxyUrl?: string | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
environment: Environment;
|
|
20
|
+
designSystemId: string;
|
|
21
|
+
apiKey: string;
|
|
22
|
+
proxyUrl?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
designSystemId: string;
|
|
25
|
+
apiKey: string;
|
|
26
|
+
environment: Environment;
|
|
27
|
+
proxyUrl?: string | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
type DescribeDesignSystemConfig = z.infer<typeof DescribeDesignSystemConfigSchema>;
|
|
30
|
+
export declare class DescribeDesignSystem extends SentryCommand<DescribeDesignSystemConfig> {
|
|
31
|
+
static aliases: ["describe-design-system"];
|
|
32
|
+
static description: string;
|
|
33
|
+
static examples: string[];
|
|
34
|
+
static flags: {
|
|
35
|
+
apiKey: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
36
|
+
designSystemId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
37
|
+
proxyUrl: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
38
|
+
environment: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
39
|
+
};
|
|
40
|
+
get commandId(): string;
|
|
41
|
+
get configSchema(): z.ZodType<DescribeDesignSystemConfig>;
|
|
42
|
+
run(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=describe-design-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-design-system.d.ts","sourceRoot":"","sources":["../../src/commands/describe-design-system.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAS,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAYrE,QAAA,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;EAUjC,CAAA;AAEL,KAAK,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAGlF,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,0BAA0B,CAAC;IAKjF,OAAgB,OAAO,EAAE,CAAC,wBAAwB,CAAC,CAAA;IAEnD,OAAgB,WAAW,SAA8D;IAEzF,OAAgB,QAAQ,WAEvB;IAED,OAAgB,KAAK;;;;;MASpB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAExD;IAMK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAyB3B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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, flags, SentryCommand } from "../types/index.js";
|
|
14
|
+
import { getWritableVersion } from "../utils/sdk.js";
|
|
15
|
+
const DescribeDesignSystemConfigSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
apiKey: z.string(),
|
|
18
|
+
designSystemId: z.string(),
|
|
19
|
+
environment: z.nativeEnum(Environment),
|
|
20
|
+
proxyUrl: z.string().url().optional(),
|
|
21
|
+
})
|
|
22
|
+
.transform(data => ({
|
|
23
|
+
...data,
|
|
24
|
+
environment: data.environment ?? Environment.production,
|
|
25
|
+
}));
|
|
26
|
+
export class DescribeDesignSystem extends SentryCommand {
|
|
27
|
+
static aliases;
|
|
28
|
+
static description = "Describe structure of single design system by provided ID";
|
|
29
|
+
static examples = [
|
|
30
|
+
`$ @supernovaio/cli describe-design-system --apiKey="{xxx-xxx-xxx}" --designSystemId="{1234}"`,
|
|
31
|
+
];
|
|
32
|
+
static flags = {
|
|
33
|
+
...flags,
|
|
34
|
+
apiKey: Flags.string({ description: "API key to use for accessing Supernova instance", required: true }),
|
|
35
|
+
designSystemId: Flags.string({ description: "Design System to describe structure of", required: true }),
|
|
36
|
+
proxyUrl: Flags.string({
|
|
37
|
+
description: "When set, CLI will use provided proxy URL for all requests",
|
|
38
|
+
hidden: true,
|
|
39
|
+
required: false,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
get commandId() {
|
|
43
|
+
return DescribeDesignSystem.id;
|
|
44
|
+
}
|
|
45
|
+
get configSchema() {
|
|
46
|
+
return DescribeDesignSystemConfigSchema;
|
|
47
|
+
}
|
|
48
|
+
async run() {
|
|
49
|
+
const { flags } = await this.parse(DescribeDesignSystem);
|
|
50
|
+
const { designSystem, id, instance } = await getWritableVersion(flags);
|
|
51
|
+
const brands = await instance.brands.getBrands(id);
|
|
52
|
+
const themes = await instance.tokens.getTokenThemes(id);
|
|
53
|
+
this.log(`\n↳ Design system "${designSystem.name}", id: ${designSystem.id}`.cyan);
|
|
54
|
+
for (const brand of brands) {
|
|
55
|
+
this.log(` ↳ Brand: "${brand.name}", id: ${brand.id}`);
|
|
56
|
+
const brandThemes = themes.filter(t => t.brandId === brand.id);
|
|
57
|
+
if (brandThemes.length > 0) {
|
|
58
|
+
for (const theme of brandThemes) {
|
|
59
|
+
this.log(` ↳ Theme: "${theme.name}", id: ${theme.id}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.log(` ↳ No themes defined in this brand`.gray);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this.log("\nDone".green);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
__decorate([
|
|
70
|
+
SentryTraced(),
|
|
71
|
+
__metadata("design:type", Function),
|
|
72
|
+
__metadata("design:paramtypes", []),
|
|
73
|
+
__metadata("design:returntype", Promise)
|
|
74
|
+
], DescribeDesignSystem.prototype, "run", null);
|
|
75
|
+
//# sourceMappingURL=describe-design-system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-design-system.js","sourceRoot":"","sources":["../../src/commands/describe-design-system.ts"],"names":[],"mappings":";;;;;;;;;AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;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Supernova.io. All rights reserved.\n//\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Imports\n\nimport { Flags } from \"@oclif/core\"\nimport { SentryTraced } from \"@sentry/nestjs\"\nimport { z } from \"zod\"\n\nimport { Environment, flags, SentryCommand } from \"../types/index.js\"\nimport { getWritableVersion } from \"../utils/sdk.js\"\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Definition\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Configuration\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Tool implementation\n\nconst DescribeDesignSystemConfigSchema = z\n .object({\n apiKey: z.string(),\n designSystemId: z.string(),\n environment: z.nativeEnum(Environment),\n proxyUrl: z.string().url().optional(),\n })\n .transform(data => ({\n ...data,\n environment: data.environment ?? Environment.production,\n }))\n\ntype DescribeDesignSystemConfig = z.infer<typeof DescribeDesignSystemConfigSchema>\n\n/** Command that describes the structure of provided design system */\nexport class DescribeDesignSystem extends SentryCommand<DescribeDesignSystemConfig> {\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command configuration\n\n // How this command can be run\n static override aliases: [\"describe-design-system\"]\n // Command help description\n static override description = \"Describe structure of single design system by provided ID\"\n // Examples how to use the command\n static override examples = [\n `$ @supernovaio/cli describe-design-system --apiKey=\"{xxx-xxx-xxx}\" --designSystemId=\"{1234}\"`,\n ]\n // Static flags to enable / disable features\n static override flags = {\n ...flags,\n apiKey: Flags.string({ description: \"API key to use for accessing Supernova instance\", required: true }),\n designSystemId: Flags.string({ description: \"Design System to describe structure of\", required: true }),\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 }\n\n get commandId(): string {\n return DescribeDesignSystem.id\n }\n\n get configSchema(): z.ZodType<DescribeDesignSystemConfig> {\n return DescribeDesignSystemConfigSchema\n }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command runtime\n\n @SentryTraced()\n async run(): Promise<void> {\n const { flags } = await this.parse(DescribeDesignSystem)\n\n // Get workspace -> design system –> version\n const { designSystem, id, instance } = await getWritableVersion(flags)\n\n // Get brands and themes\n const brands = await instance.brands.getBrands(id)\n const themes = await instance.tokens.getTokenThemes(id)\n\n this.log(`\\n↳ Design system \"${designSystem.name}\", id: ${designSystem.id}`.cyan)\n for (const brand of brands) {\n this.log(` ↳ Brand: \"${brand.name}\", id: ${brand.id}`)\n const brandThemes = themes.filter(t => t.brandId === brand.id)\n if (brandThemes.length > 0) {\n for (const theme of brandThemes) {\n this.log(` ↳ Theme: \"${theme.name}\", id: ${theme.id}`)\n }\n } else {\n this.log(` ↳ No themes defined in this brand`.gray)\n }\n }\n\n this.log(\"\\nDone\".green)\n }\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as sdkTypes from "@supernovaio/sdk";
|
|
2
|
+
import { z, ZodType } from "zod";
|
|
3
|
+
import { Environment, SentryCommand } from "../types/index.js";
|
|
4
|
+
interface DescribeWorkspacesFlags {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
environment: string;
|
|
7
|
+
proxyUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const DescribeWorkspaceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
10
|
+
apiKey: z.ZodString;
|
|
11
|
+
environment: z.ZodNativeEnum<typeof Environment>;
|
|
12
|
+
proxyUrl: z.ZodOptional<z.ZodString>;
|
|
13
|
+
workspaceId: z.ZodString;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
apiKey: string;
|
|
17
|
+
environment: Environment;
|
|
18
|
+
proxyUrl?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
workspaceId: string;
|
|
21
|
+
apiKey: string;
|
|
22
|
+
environment: Environment;
|
|
23
|
+
proxyUrl?: string | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
environment: Environment;
|
|
26
|
+
workspaceId: string;
|
|
27
|
+
apiKey: string;
|
|
28
|
+
proxyUrl?: string | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
workspaceId: string;
|
|
31
|
+
apiKey: string;
|
|
32
|
+
environment: Environment;
|
|
33
|
+
proxyUrl?: string | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
type DescribeWorkspaceConfig = z.infer<typeof DescribeWorkspaceConfigSchema>;
|
|
36
|
+
export declare class DescribeWorkspaces extends SentryCommand<DescribeWorkspaceConfig> {
|
|
37
|
+
static aliases: ["describe-workspaces"];
|
|
38
|
+
static description: string;
|
|
39
|
+
static examples: string[];
|
|
40
|
+
static flags: {
|
|
41
|
+
apiKey: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
42
|
+
proxyUrl: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
43
|
+
environment: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
44
|
+
};
|
|
45
|
+
get commandId(): string;
|
|
46
|
+
get configSchema(): ZodType<DescribeWorkspaceConfig>;
|
|
47
|
+
getWorkspaces(flags: DescribeWorkspacesFlags): Promise<{
|
|
48
|
+
instance: sdkTypes.Supernova;
|
|
49
|
+
workspaces: Array<sdkTypes.Workspace>;
|
|
50
|
+
}>;
|
|
51
|
+
run(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=describe-workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-workspaces.d.ts","sourceRoot":"","sources":["../../src/commands/describe-workspaces.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAS,aAAa,EAAE,MAAM,mBAAmB,CAAA;AASrE,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAKD,QAAA,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;EAU9B,CAAA;AAEL,KAAK,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAM5E,qBAAa,kBAAmB,SAAQ,aAAa,CAAC,uBAAuB,CAAC;IAK5E,MAAM,CAAC,OAAO,EAAE,CAAC,qBAAqB,CAAC,CAAA;IAEvC,MAAM,CAAC,WAAW,SAC0G;IAE5H,MAAM,CAAC,QAAQ,WAAsE;IAErF,MAAM,CAAC,KAAK;;;;MAQX;IAKD,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,YAAY,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAEnD;IAGK,aAAa,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC;QAC3D,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAA;QAC5B,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;KACtC,CAAC;IAqBI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA0C3B"}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 { createRequire } from "node:module";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { Environment, flags, SentryCommand } from "../types/index.js";
|
|
15
|
+
import { environmentAPI } from "../utils/network.js";
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
const sdkProvider = require("@supernovaio/sdk");
|
|
18
|
+
const DescribeWorkspaceConfigSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
apiKey: z.string(),
|
|
21
|
+
environment: z.nativeEnum(Environment),
|
|
22
|
+
proxyUrl: z.string().url().optional(),
|
|
23
|
+
workspaceId: z.string(),
|
|
24
|
+
})
|
|
25
|
+
.transform(data => ({
|
|
26
|
+
...data,
|
|
27
|
+
environment: data.environment ?? Environment.production,
|
|
28
|
+
}));
|
|
29
|
+
export class DescribeWorkspaces extends SentryCommand {
|
|
30
|
+
static aliases;
|
|
31
|
+
static description = "Describe structure of all workspaces and design systems available under those workspaces available for specified API key";
|
|
32
|
+
static examples = [`$ @supernovaio/cli describe-workspaces --apiKey="{xxx-xxx-xxx}"`];
|
|
33
|
+
static flags = {
|
|
34
|
+
...flags,
|
|
35
|
+
apiKey: Flags.string({ description: "API key to use for accessing Supernova instance", required: true }),
|
|
36
|
+
proxyUrl: Flags.string({
|
|
37
|
+
description: "When set, CLI will use provided proxy URL for all requests",
|
|
38
|
+
hidden: true,
|
|
39
|
+
required: false,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
get commandId() {
|
|
43
|
+
return DescribeWorkspaces.id;
|
|
44
|
+
}
|
|
45
|
+
get configSchema() {
|
|
46
|
+
return DescribeWorkspaceConfigSchema;
|
|
47
|
+
}
|
|
48
|
+
async getWorkspaces(flags) {
|
|
49
|
+
if (!flags.apiKey || flags.apiKey.length === 0) {
|
|
50
|
+
throw new Error(`API key must not be empty`);
|
|
51
|
+
}
|
|
52
|
+
const apiUrl = environmentAPI(flags.environment, "v2");
|
|
53
|
+
const sdkInstance = new sdkProvider.Supernova(flags.apiKey, {
|
|
54
|
+
apiUrl,
|
|
55
|
+
bypassEnvFetch: true,
|
|
56
|
+
proxyUrl: flags.proxyUrl,
|
|
57
|
+
});
|
|
58
|
+
const user = await sdkInstance.me.me();
|
|
59
|
+
const workspaces = await sdkInstance.workspaces.workspaces(user.id);
|
|
60
|
+
return {
|
|
61
|
+
instance: sdkInstance,
|
|
62
|
+
workspaces,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async run() {
|
|
66
|
+
const { flags } = await this.parse(DescribeWorkspaces);
|
|
67
|
+
const { instance, workspaces } = await this.getWorkspaces(flags);
|
|
68
|
+
this.log(`\n`);
|
|
69
|
+
for (const workspace of workspaces) {
|
|
70
|
+
const designSystems = await instance.designSystems.designSystems(workspace.id);
|
|
71
|
+
this.log(`↳ Workspace "${workspace.profile.name}", id: ${workspace.id}`.magenta);
|
|
72
|
+
for (const designSystem of designSystems) {
|
|
73
|
+
this.log(` ↳ Design system "${designSystem.name}", id: ${designSystem.id}`.cyan);
|
|
74
|
+
const version = await instance.versions.getActiveVersion(designSystem.id);
|
|
75
|
+
if (!version) {
|
|
76
|
+
this.log(`Design system ${designSystem.id} active version not found or not available under provided API key`);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const id = { designSystemId: designSystem.id, versionId: version.id };
|
|
80
|
+
const brands = await instance.brands.getBrands(id);
|
|
81
|
+
const themes = await instance.tokens.getTokenThemes(id);
|
|
82
|
+
for (const brand of brands) {
|
|
83
|
+
this.log(` ↳ Brand: "${brand.name}", id: ${brand.id}`);
|
|
84
|
+
const brandThemes = themes.filter(t => t.brandId === brand.id);
|
|
85
|
+
if (brandThemes.length > 0) {
|
|
86
|
+
for (const theme of brandThemes) {
|
|
87
|
+
this.log(` ↳ Theme: "${theme.name}", id: ${theme.id}`.gray);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.log(` ↳ No themes defined in this brand`.gray);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
this.log("\nDone".green);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
__decorate([
|
|
100
|
+
SentryTraced(),
|
|
101
|
+
__metadata("design:type", Function),
|
|
102
|
+
__metadata("design:paramtypes", [Object]),
|
|
103
|
+
__metadata("design:returntype", Promise)
|
|
104
|
+
], DescribeWorkspaces.prototype, "getWorkspaces", null);
|
|
105
|
+
__decorate([
|
|
106
|
+
SentryTraced(),
|
|
107
|
+
__metadata("design:type", Function),
|
|
108
|
+
__metadata("design:paramtypes", []),
|
|
109
|
+
__metadata("design:returntype", Promise)
|
|
110
|
+
], DescribeWorkspaces.prototype, "run", null);
|
|
111
|
+
//# sourceMappingURL=describe-workspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-workspaces.js","sourceRoot":"","sources":["../../src/commands/describe-workspaces.ts"],"names":[],"mappings":";;;;;;;;;AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBA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,CAAC,yCAAyC,CAAC,IAAI,CAAC,CAAA;oBAC1D,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;;AAjEK;IADL,YAAY,EAAE;;;;uDAsBd;AAGK;IADL,YAAY,EAAE;;;;6CA0Cd","sourcesContent":["//\n// describe-workspaces.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 { createRequire } from \"node:module\"\nimport { z, ZodType } from \"zod\"\n\nimport { Environment, flags, SentryCommand } from \"../types/index.js\"\nimport { environmentAPI } from \"../utils/network.js\"\n\nconst require = createRequire(import.meta.url)\nconst sdkProvider = require(\"@supernovaio/sdk\") as typeof sdkTypes\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Definition\n\ninterface DescribeWorkspacesFlags {\n apiKey: string\n environment: string\n proxyUrl?: string\n}\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Configuration\n\nconst DescribeWorkspaceConfigSchema = z\n .object({\n apiKey: z.string(),\n environment: z.nativeEnum(Environment),\n proxyUrl: z.string().url().optional(),\n workspaceId: z.string(),\n })\n .transform(data => ({\n ...data,\n environment: data.environment ?? Environment.production,\n }))\n\ntype DescribeWorkspaceConfig = z.infer<typeof DescribeWorkspaceConfigSchema>\n\n// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n// MARK: - Tool implementation\n\n/** Command that describes the structure of provided design system */\nexport class DescribeWorkspaces extends SentryCommand<DescribeWorkspaceConfig> {\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command configuration\n\n // How this command can be run\n static aliases: [\"describe-workspaces\"]\n // Command help description\n static description =\n \"Describe structure of all workspaces and design systems available under those workspaces available for specified API key\"\n // Examples how to use the command\n static examples = [`$ @supernovaio/cli describe-workspaces --apiKey=\"{xxx-xxx-xxx}\"`]\n // Static flags to enable / disable features\n static flags = {\n ...flags,\n apiKey: Flags.string({ description: \"API key to use for accessing Supernova instance\", required: true }),\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 }\n\n // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n // MARK: - Command runtime\n\n get commandId(): string {\n return DescribeWorkspaces.id\n }\n\n get configSchema(): ZodType<DescribeWorkspaceConfig> {\n return DescribeWorkspaceConfigSchema\n }\n\n @SentryTraced()\n async getWorkspaces(flags: DescribeWorkspacesFlags): Promise<{\n instance: sdkTypes.Supernova\n workspaces: Array<sdkTypes.Workspace>\n }> {\n if (!flags.apiKey || flags.apiKey.length === 0) {\n throw new Error(`API key must not be empty`)\n }\n\n // Create instance for prod / dev\n const apiUrl = environmentAPI(flags.environment as Environment, \"v2\")\n const sdkInstance = new sdkProvider.Supernova(flags.apiKey, {\n apiUrl,\n bypassEnvFetch: true,\n proxyUrl: flags.proxyUrl,\n })\n const user = await sdkInstance.me.me()\n const workspaces = await sdkInstance.workspaces.workspaces(user.id)\n return {\n instance: sdkInstance,\n workspaces,\n }\n }\n\n @SentryTraced()\n async run(): Promise<void> {\n const { flags } = await this.parse(DescribeWorkspaces)\n\n // Get workspaces\n const { instance, workspaces } = await this.getWorkspaces(flags)\n this.log(`\\n`)\n\n for (const workspace of workspaces) {\n // Get design systems and log\n // eslint-disable-next-line no-await-in-loop\n const designSystems = await instance.designSystems.designSystems(workspace.id)\n this.log(`↳ Workspace \"${workspace.profile.name}\", id: ${workspace.id}`.magenta)\n for (const designSystem of designSystems) {\n this.log(` ↳ Design system \"${designSystem.name}\", id: ${designSystem.id}`.cyan)\n // eslint-disable-next-line no-await-in-loop\n const version = await instance.versions.getActiveVersion(designSystem.id)\n if (!version) {\n this.log(`Design system ${designSystem.id} active version not found or not available under provided API key`)\n continue\n }\n\n const id: sdkTypes.RemoteVersionIdentifier = { designSystemId: designSystem.id, versionId: version.id }\n // eslint-disable-next-line no-await-in-loop\n const brands = await instance.brands.getBrands(id)\n // eslint-disable-next-line no-await-in-loop\n const themes = await instance.tokens.getTokenThemes(id)\n for (const brand of brands) {\n this.log(` ↳ Brand: \"${brand.name}\", id: ${brand.id}`)\n const brandThemes = themes.filter(t => t.brandId === brand.id)\n if (brandThemes.length > 0) {\n for (const theme of brandThemes) {\n this.log(` ↳ Theme: \"${theme.name}\", id: ${theme.id}`.gray)\n }\n } else {\n this.log(` ↳ No themes defined in this brand`.gray)\n }\n }\n }\n }\n\n this.log(\"\\nDone\".green)\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z, ZodType } from "zod";
|
|
2
|
+
import { Environment, SentryCommand } from "../types/index.js";
|
|
3
|
+
declare const ImportComponentsConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
designSystemId: z.ZodString;
|
|
5
|
+
environment: z.ZodNativeEnum<typeof Environment>;
|
|
6
|
+
importFrom: z.ZodString;
|
|
7
|
+
rootDir: z.ZodString;
|
|
8
|
+
versionId: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
designSystemId: string;
|
|
11
|
+
environment: Environment;
|
|
12
|
+
importFrom: string;
|
|
13
|
+
rootDir: string;
|
|
14
|
+
versionId: string;
|
|
15
|
+
}, {
|
|
16
|
+
designSystemId: string;
|
|
17
|
+
environment: Environment;
|
|
18
|
+
importFrom: string;
|
|
19
|
+
rootDir: string;
|
|
20
|
+
versionId: string;
|
|
21
|
+
}>, {
|
|
22
|
+
environment: Environment;
|
|
23
|
+
rootDir: string;
|
|
24
|
+
designSystemId: string;
|
|
25
|
+
importFrom: string;
|
|
26
|
+
versionId: string;
|
|
27
|
+
}, {
|
|
28
|
+
designSystemId: string;
|
|
29
|
+
environment: Environment;
|
|
30
|
+
importFrom: string;
|
|
31
|
+
rootDir: string;
|
|
32
|
+
versionId: string;
|
|
33
|
+
}>;
|
|
34
|
+
type ImportComponentsConfig = z.infer<typeof ImportComponentsConfigSchema>;
|
|
35
|
+
export default class ImportComponents extends SentryCommand<ImportComponentsConfig> {
|
|
36
|
+
static args: {};
|
|
37
|
+
static description: string;
|
|
38
|
+
static examples: string[];
|
|
39
|
+
static flags: {
|
|
40
|
+
designSystemId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
41
|
+
importFrom: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
42
|
+
rootDir: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
43
|
+
versionId: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
44
|
+
};
|
|
45
|
+
get commandId(): string;
|
|
46
|
+
get configSchema(): ZodType<ImportComponentsConfig>;
|
|
47
|
+
run(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=import-components.d.ts.map
|