@yahoo/uds 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cli/PropsToClass.mock.tsx +14 -0
- package/cli/bin/uds-darwin-arm64-baseline +0 -0
- package/cli/bin/uds-linux-arm64 +0 -0
- package/cli/bin/uds-linux-x64-baseline +0 -0
- package/cli/cli.ts +1 -2
- package/cli/utils/auth.ts +39 -202
- package/dist/Text-CwmyqrBk.d.cts +243 -0
- package/dist/Text-CwmyqrBk.d.ts +243 -0
- package/dist/client/index.cjs +2 -2
- package/dist/client/index.d.cts +46 -6
- package/dist/client/index.d.ts +46 -6
- package/dist/client/index.js +3 -3
- package/dist/experimental/client/index.cjs +3 -0
- package/dist/experimental/client/index.d.cts +146 -0
- package/dist/experimental/client/index.d.ts +146 -0
- package/dist/experimental/client/index.js +3 -0
- package/dist/experimental/index.cjs +2 -2
- package/dist/experimental/index.d.cts +5 -387
- package/dist/experimental/index.d.ts +5 -387
- package/dist/experimental/index.js +1 -2
- package/dist/fixtures.cjs +1 -1
- package/dist/fixtures.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -42
- package/dist/index.d.ts +4 -42
- package/dist/index.js +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/tailwind/plugin.cjs +2 -2
- package/dist/tailwind/plugin.d.cts +1 -1
- package/dist/tailwind/plugin.d.ts +1 -1
- package/dist/tailwind/plugin.js +2 -2
- package/dist/tailwind/purger.cjs +1 -1
- package/dist/tailwind/purger.js +1 -1
- package/dist/tailwind/utils.d.cts +1 -1
- package/dist/tailwind/utils.d.ts +1 -1
- package/dist/tokens/index.d.cts +2 -2
- package/dist/tokens/index.d.ts +2 -2
- package/dist/tokens/parseTokens.d.cts +1 -1
- package/dist/tokens/parseTokens.d.ts +1 -1
- package/dist/{types-Pyccco5Q.d.cts → types-DsMvZpWN.d.cts} +1 -1
- package/dist/{types-Pyccco5Q.d.ts → types-DsMvZpWN.d.ts} +1 -1
- package/package.json +13 -6
- package/cli/README.md +0 -208
- package/cli/utils/client_secrets.json +0 -23
- package/cli/utils/client_secrets.json.enc +0 -0
- package/cli/utils/secrets.ts +0 -40
package/cli/README.md
DELETED
@@ -1,208 +0,0 @@
|
|
1
|
-
import { DocTabs } from '~/components/DocTabs';
|
2
|
-
import { Box, VStack } from '@yahoo/uds';
|
3
|
-
import { RequiredChip } from '~/components/RequiredChip';
|
4
|
-
import { DocImage } from '~/components/DocImage';
|
5
|
-
import { PACKAGE_MANAGERS, CommandSnippet } from '~/components/CommandSnippet';
|
6
|
-
import { toPageTitle } from '~/utils/toPageTitle';
|
7
|
-
|
8
|
-
export const metadata = {
|
9
|
-
title: toPageTitle({ title: 'CLI', category: 'Tools' }),
|
10
|
-
};
|
11
|
-
|
12
|
-
# Universal CLI
|
13
|
-
|
14
|
-
> **Update**: The CLI tool no longer requires Bun. You can use any node package manager to run the CLI (e.g. `npx uds sync`).
|
15
|
-
|
16
|
-
The Universal CLI is available as command, `uds`. The tool was created with [Bluebun](https://github.com/jamonholmgren/bluebun/) (inspired by [Gluegun](https://github.com/infinitered/gluegun)). The UDS CLI is a standalone binary that doesn't require having Bun installed locally in order to use it.
|
17
|
-
|
18
|
-
<Box justifyContent="center">
|
19
|
-
<DocImage light={{ src: '/images/cli-screenshot.png', width: 500, height: 356 }} />
|
20
|
-
</Box>
|
21
|
-
|
22
|
-
## Requirements
|
23
|
-
|
24
|
-
1. To use the CLI, first [install](/docs/getting-started/quick-start#installation) the `@yahoo/uds` package as a dependency in your package.json, which has the UDS CLI as a binary.
|
25
|
-
|
26
|
-
2. Log in to the CLI
|
27
|
-
|
28
|
-
<VStack spacingBottom="2">
|
29
|
-
<DocTabs
|
30
|
-
items={PACKAGE_MANAGERS.map((packageManager) => ({
|
31
|
-
label: packageManager,
|
32
|
-
content: <CommandSnippet name={packageManager} command="bun uds login" />,
|
33
|
-
}))}
|
34
|
-
/>
|
35
|
-
</VStack>
|
36
|
-
|
37
|
-
## Commands
|
38
|
-
|
39
|
-
> **Note**: If you are _not_ running the CLI from a package.json script you will need to call your package manager execute command before the binary in order to run it directly. i.e. `npx uds purge`
|
40
|
-
|
41
|
-
<VStack spacingBottom="2">
|
42
|
-
<DocTabs
|
43
|
-
items={PACKAGE_MANAGERS.map((packageManager) => ({
|
44
|
-
label: packageManager,
|
45
|
-
content: <CommandSnippet name={packageManager} command="bunx uds purge" />,
|
46
|
-
}))}
|
47
|
-
/>
|
48
|
-
</VStack>
|
49
|
-
|
50
|
-
The following command are available after installing `@yahoo/uds`:
|
51
|
-
|
52
|
-
### Sync
|
53
|
-
|
54
|
-
The `uds sync` command fetches the latest design config from the [Configurator](/docs/getting-started/using-configurator) and writes it to a file in your project.
|
55
|
-
|
56
|
-
#### Flags
|
57
|
-
|
58
|
-
| Flag | Description | Default | Required |
|
59
|
-
| --------- | --------------------------- | --------------- | ---------------- |
|
60
|
-
| `id` | ID from the Configurator | | <RequiredChip /> |
|
61
|
-
| `outFile` | File to write the output to | ./uds.config.ts | |
|
62
|
-
|
63
|
-
**Example:**
|
64
|
-
|
65
|
-
```shell
|
66
|
-
uds sync --id [id] --outFile [path]
|
67
|
-
uds sync --id [id]
|
68
|
-
uds sync --id [id] --outFile=uds.config.js # pass a file with a JS extension if you are using Javascript
|
69
|
-
```
|
70
|
-
|
71
|
-
#### Environment variables
|
72
|
-
|
73
|
-
Alternatively, you can use environment variables instead of flags.
|
74
|
-
|
75
|
-
| Variable | Description | Default | Required |
|
76
|
-
| -------------- | --------------------------- | --------------- | ---------------- |
|
77
|
-
| `UDS_ID` | ID from the Configurator | | <RequiredChip /> |
|
78
|
-
| `UDS_OUT_FILE` | File to write the output to | ./uds.config.ts | |
|
79
|
-
|
80
|
-
**Example:**
|
81
|
-
|
82
|
-
```shell
|
83
|
-
UDS_ID=[id] UDS_OUT_FILE=[path] uds sync
|
84
|
-
```
|
85
|
-
|
86
|
-
### Purge
|
87
|
-
|
88
|
-
The `uds purge` command is used to optimize and reduce the amount of CSS produced by your app.
|
89
|
-
|
90
|
-
Running this command produces a `./dist/safelist.ts` file in the root of your project. This file imported in your `tailwind.config.js` and passed to the `safelist` configuration option.
|
91
|
-
|
92
|
-
```typescript
|
93
|
-
/** @type {import('tailwindcss').Config} */
|
94
|
-
const { safelist } = require(`${__dirname}/dist/safelist.ts`);
|
95
|
-
|
96
|
-
module.exports = {
|
97
|
-
content: ['./pages/**/*.{html,jsx,tsx}', './components/**/*.{html,jsx,tsx}'],
|
98
|
-
safelist,
|
99
|
-
// ...
|
100
|
-
};
|
101
|
-
```
|
102
|
-
|
103
|
-
For more information about safelisting classes in Tailwind, visit the [official documentation](https://tailwindcss.com/docs/content-configuration#safelisting-classes)
|
104
|
-
|
105
|
-
**Example:**
|
106
|
-
|
107
|
-
```shell
|
108
|
-
uds purge
|
109
|
-
```
|
110
|
-
|
111
|
-
#### Flags
|
112
|
-
|
113
|
-
| Flag | Description | Default | Required |
|
114
|
-
| -------- | --------------------------- | ------------------ | -------- |
|
115
|
-
| `entry` | The entry to source files | ./src/ | |
|
116
|
-
| `output` | Output path of the safelist | ./dist/safelist.ts | |
|
117
|
-
| `config` | UDS config | ./uds.config.ts | |
|
118
|
-
|
119
|
-
**Example:**
|
120
|
-
|
121
|
-
```shell
|
122
|
-
uds purge --output output/dir
|
123
|
-
```
|
124
|
-
|
125
|
-
#### Environment variables
|
126
|
-
|
127
|
-
| Variable | Description | Default | Required |
|
128
|
-
| ------------------------------- | ------------------------------------------- | ------- | -------- |
|
129
|
-
| `ENABLED_SCALE_AND_COLOR_MODES` | Selects which color and scale modes to keep | all | |
|
130
|
-
|
131
|
-
**Example:**
|
132
|
-
|
133
|
-
```shell
|
134
|
-
ENABLED_SCALE_AND_COLOR_MODES="dark,large" uds purge
|
135
|
-
```
|
136
|
-
|
137
|
-
### Codemod
|
138
|
-
|
139
|
-
The `uds codemod` command is here to help you run one-off codemods. In the future, we'll likely apply codemodes via `uds migrate` for you, but this will provide more fine grained control over applying codemods to help you deal with breaking changes to our system. We're flying fast right now, and investing too much energy in full blown migrations is silly as things will just keep changing, but this is a step into an _easy_ migration future!
|
140
|
-
|
141
|
-
Any file added to commands/codemod will be available in prompt land.
|
142
|
-
|
143
|
-
```shell
|
144
|
-
uds codemod
|
145
|
-
```
|
146
|
-
|
147
|
-
### Login
|
148
|
-
|
149
|
-
The `uds login` command is used to authenticate the user to the CLI. We use
|
150
|
-
Google's OAuth2 flow, which is the same login flow used by the [Configurator](/docs/getting-started/using-configurator) and the documentation site. Logging in to the CLI helps us identify and track CLI usage and metrics.
|
151
|
-
|
152
|
-
### Circumventing Login
|
153
|
-
|
154
|
-
There may be situations (such as CI runs) where you can't authenticate your personal account with the CLI. For this case, providing the `CI=true` and `UDS_TEAM_SLUG` env variables is required when using the CLI in a CI environment:
|
155
|
-
|
156
|
-
```env
|
157
|
-
CI=true
|
158
|
-
UDS_TEAM_SLUG=<your-team-slug> uds <command>
|
159
|
-
```
|
160
|
-
|
161
|
-
Your team slug can be found in your team's Configurator URL path:
|
162
|
-
|
163
|
-
<DocImage light={{ src: '/images/team-slug-screenshot.png' }} />
|
164
|
-
|
165
|
-
### Expo (WIP)
|
166
|
-
|
167
|
-
The `uds expo` command is for building and launching React Native apps using Expo.
|
168
|
-
This command is still a WIP and is only used internally at the moment.
|
169
|
-
|
170
|
-
```shell
|
171
|
-
uds expo build --profile [profile] --platform [ios|android]
|
172
|
-
uds expo dev --profile [profile] --platform [ios|android]
|
173
|
-
uds expo launch --profile [profile] --platform [ios|android]
|
174
|
-
uds expo update --profile [profile] --platform [ios|android]
|
175
|
-
uds expo --help
|
176
|
-
```
|
177
|
-
|
178
|
-
## Development
|
179
|
-
|
180
|
-
The CLI is created with [Bluebun](https://github.com/jamonholmgren/bluebun/) (inspired by [Gluegun](https://github.com/infinitered/gluegun)), but specifically designed to be used with [Bun](https://bun.sh). Bluebun relies on Bun APIs and is designed to be extremely fast, with no-dependencies.
|
181
|
-
|
182
|
-
### Adding a command
|
183
|
-
|
184
|
-
Commands are organized in a tree structure in `uds/cli/commands`. The root command is the name of the CLI (`uds`) and in `uds.ts`, which subcommand being in its own file. See the Bluebun [Command docs](https://github.com/jamonholmgren/bluebun/blob/main/docs/commands.md) for more information on usage docs and creating command files.
|
185
|
-
|
186
|
-
**Important note:**
|
187
|
-
|
188
|
-
Adding nested commands, i.e. `uds expo dev` does work correctly when UDS is consumed from npm. As a workaround, please see code for expo/expo.ts for re-routing sub-commands from the root command file. To verify your CLI command works correctly you should run `npm pack` within the packages/uds directory. Once you have your generated tarball you should copy that tarball to a test application such as https://github.com/yahoo-uds/uds-nextjs-demo, then add `"@yahoo/uds": "file:./tarball-generated-from-npm-pack.tgz` to it's dependencies and run an install. Now you should be able to run `bun uds [your command name]` to test your functionality.
|
189
|
-
|
190
|
-
### Testing the login flow
|
191
|
-
|
192
|
-
To test the login flow, the CLI starts a web server and opens browser window to
|
193
|
-
a login page in Configurator. In prod, it opens https://config.uds.build/login.
|
194
|
-
In local dev, http://localhost:4001/login is opened.
|
195
|
-
|
196
|
-
In the root of the UDS monorepo, run the following commands:
|
197
|
-
|
198
|
-
```
|
199
|
-
# Start configurator app web server:
|
200
|
-
turbo --filter uds-configurator dev
|
201
|
-
|
202
|
-
# Run the CLI login command:
|
203
|
-
bun run --cwd packages/uds uds login
|
204
|
-
```
|
205
|
-
|
206
|
-
### API Reference
|
207
|
-
|
208
|
-
Bluebun comes with a number of built-in utilities that are exported from the main `bluebun` package. See [reference guide](https://github.com/jamonholmgren/bluebun/blob/main/docs/reference.md) for more.
|
@@ -1,23 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"web": {
|
3
|
-
"client_id": "700524957090-6uju02gp6i0rlm3p17nt1v6vbrretfka.apps.googleusercontent.com",
|
4
|
-
"project_id": "uds-poc",
|
5
|
-
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
6
|
-
"token_uri": "https://oauth2.googleapis.com/token",
|
7
|
-
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
8
|
-
"client_secret": "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",
|
9
|
-
"redirect_uris": [
|
10
|
-
"http://localhost:3000/oauth2callback",
|
11
|
-
"https://uds.build/oauth2callback",
|
12
|
-
"https://config.uds.build/oauth2callback"
|
13
|
-
]
|
14
|
-
},
|
15
|
-
"firebaseConfig": {
|
16
|
-
"apiKey": "AIzaSyDZEsm1GQ1lkK7T8NxJ9D_Pqmcz5u5D2hc",
|
17
|
-
"authDomain": "uds-poc.firebaseapp.com",
|
18
|
-
"projectId": "uds-poc",
|
19
|
-
"storageBucket": "uds-poc.appspot.com",
|
20
|
-
"messagingSenderId": "700524957090",
|
21
|
-
"appId": "1:700524957090:web:b4b5cdba42f694bb5cf6fb"
|
22
|
-
}
|
23
|
-
}
|
Binary file
|
package/cli/utils/secrets.ts
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
import path from 'node:path';
|
2
|
-
|
3
|
-
// eslint-disable-next-line n/no-unpublished-import
|
4
|
-
import { loadEnvConfig } from '@next/env';
|
5
|
-
import { $ } from 'bun';
|
6
|
-
|
7
|
-
loadEnvConfig(process.cwd());
|
8
|
-
|
9
|
-
const secretsFile = path.resolve(import.meta.dir, 'client_secrets.json');
|
10
|
-
const encryptedFilename = `${secretsFile}.enc`;
|
11
|
-
|
12
|
-
async function encrypt() {
|
13
|
-
await $`openssl enc -aes-256-cbc -in ${secretsFile} -out ${encryptedFilename}`;
|
14
|
-
}
|
15
|
-
|
16
|
-
async function decrypt() {
|
17
|
-
const f = Bun.file(secretsFile);
|
18
|
-
if (!(await f.exists())) {
|
19
|
-
await $`openssl enc -aes-256-cbc -in ${encryptedFilename} -out ${secretsFile} -d -pass env:UDS_CLI_SECRETS_PW`;
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
async function main() {
|
24
|
-
if (!process.env.UDS_CLI_SECRETS_PW) {
|
25
|
-
console.error('Please set the UDS_CLI_SECRETS_PW env variable. The password is in LastPass.');
|
26
|
-
process.exitCode = 1;
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
|
30
|
-
const cmd = Bun.argv[2];
|
31
|
-
if (cmd === 'encrypt') {
|
32
|
-
await encrypt();
|
33
|
-
console.log(`Secrets file encrypted to ${encryptedFilename}`);
|
34
|
-
} else if (cmd === 'decrypt') {
|
35
|
-
await decrypt();
|
36
|
-
console.log(`Secrets file saved to ${secretsFile}`);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
main();
|