@yahoo/uds 0.2.0 → 0.2.2
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/cli/README.md +2 -8
- package/cli/bunfig.toml +3 -0
- package/cli/commands/expo/_setup.ts +1 -0
- package/cli/commands/expo/build.ts +1 -1
- package/cli/commands/expo/launch.ts +1 -1
- package/cli/commands/purge.ts +1 -1
- package/cli/commands/sync.ts +16 -4
- package/cli/commands/uds.ts +4 -1
- package/cli/commands/version.ts +1 -1
- package/cli/preload.ts +32 -0
- package/cli/utils/configWorker.ts +30 -11
- package/cli/utils/getCommandHelp.ts +22 -13
- package/cli/utils/purgeCSS.test.ts +99 -0
- package/cli/utils/purgeCSS.ts +5 -5
- package/cli/utils/setupConfigWorker.ts +8 -38
- package/cli/utils/types.ts +5 -2
- package/dist/{Image.native-tkOXN29I.d.ts → Image.native-C6kOWgnf.d.ts} +1 -1
- package/dist/{Image.native-jCNIrPZD.d.cts → Image.native-VeXt5aeI.d.cts} +1 -1
- package/dist/VStack-BSD9TbBd.d.cts +114 -0
- package/dist/VStack-Dk3-8IyU.d.ts +114 -0
- package/dist/experimental/index.cjs +1 -1
- package/dist/experimental/index.d.cts +5 -4
- package/dist/experimental/index.d.ts +5 -4
- package/dist/experimental/index.js +1 -1
- package/dist/experimental/index.native.cjs +1 -1
- package/dist/experimental/index.native.d.cts +3 -3
- package/dist/experimental/index.native.d.ts +3 -3
- package/dist/experimental/index.native.js +1 -1
- package/dist/fixtures/index.cjs +1 -1
- package/dist/fixtures/index.d.cts +15 -1
- package/dist/fixtures/index.d.ts +15 -1
- package/dist/fixtures/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +133 -184
- package/dist/index.d.ts +133 -184
- package/dist/index.js +1 -1
- package/dist/{index.native-xVHqKK0u.d.ts → index.native-CisPq4BI.d.ts} +1 -1
- package/dist/{index.native--Dm3KDDS.d.cts → index.native-DJlx-bfM.d.cts} +1 -1
- package/dist/index.native.cjs +1 -1
- package/dist/index.native.d.cts +5 -5
- package/dist/index.native.d.ts +5 -5
- package/dist/index.native.js +1 -1
- package/dist/tailwindPlugin.cjs +1 -1
- package/dist/tailwindPlugin.d.cts +1 -1
- package/dist/tailwindPlugin.d.ts +1 -1
- package/dist/tailwindPlugin.js +1 -1
- package/dist/tailwindPurge.cjs +1 -1
- package/dist/tailwindPurge.js +1 -1
- package/dist/tokens/index.cjs +1 -1
- package/dist/tokens/index.d.cts +2 -2
- package/dist/tokens/index.d.ts +2 -2
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/index.native.cjs +1 -1
- package/dist/tokens/index.native.d.cts +2 -2
- package/dist/tokens/index.native.d.ts +2 -2
- package/dist/tokens/index.native.js +1 -1
- package/dist/tokens/parseTokens.cjs +1 -1
- package/dist/tokens/parseTokens.d.cts +1 -1
- package/dist/tokens/parseTokens.d.ts +1 -1
- package/dist/tokens/parseTokens.js +1 -1
- package/dist/tokens/parseTokens.native.d.cts +1 -1
- package/dist/tokens/parseTokens.native.d.ts +1 -1
- package/dist/{types-7oEBWtMQ.d.cts → types-CzJpH_Oi.d.cts} +2 -2
- package/dist/{types-7oEBWtMQ.d.ts → types-CzJpH_Oi.d.ts} +2 -2
- package/package.json +4 -2
- package/dist/Pressable-2kgXQNVs.d.cts +0 -55
- package/dist/Pressable-LIDkIIAF.d.ts +0 -55
- /package/dist/{types-J4DLS6Xj.d.cts → types-FO65RM-W.d.cts} +0 -0
- /package/dist/{types-J4DLS6Xj.d.ts → types-FO65RM-W.d.ts} +0 -0
package/cli/README.md
CHANGED
@@ -8,10 +8,10 @@ Bluebun relies on Bun APIs and is designed to be extremely fast, with no-depende
|
|
8
8
|
|
9
9
|
# Commands
|
10
10
|
|
11
|
-
In any consumer of `@yahoo/uds` the following commands are available:
|
12
|
-
|
13
11
|
> Please note: If you are _not_ running the CLI from a package.json script you will need to add `bun` before the binary in order to run it directly. i.e. `bun uds purge`
|
14
12
|
|
13
|
+
In any consumer of `@yahoo/uds` the following commands are available:
|
14
|
+
|
15
15
|
## Config
|
16
16
|
|
17
17
|
### Using args
|
@@ -23,9 +23,7 @@ In any consumer of `@yahoo/uds` the following commands are available:
|
|
23
23
|
|
24
24
|
```shell
|
25
25
|
uds sync --id [id] --outFile [path]
|
26
|
-
```
|
27
26
|
|
28
|
-
```shell
|
29
27
|
uds sync --id [id]
|
30
28
|
```
|
31
29
|
|
@@ -36,10 +34,6 @@ uds sync --id [id]
|
|
36
34
|
| UDS_ID | true | |
|
37
35
|
| UDS_OUT_FILE | false | ./uds.config.ts |
|
38
36
|
|
39
|
-
```shell
|
40
|
-
UDS_ID=[id] uds sync --outFile [path]
|
41
|
-
```
|
42
|
-
|
43
37
|
```shell
|
44
38
|
UDS_ID=[id] UDS_OUT_FILE=[path] uds sync
|
45
39
|
```
|
package/cli/bunfig.toml
ADDED
@@ -1,6 +1,7 @@
|
|
1
1
|
import fs from 'node:fs';
|
2
2
|
import os from 'node:os';
|
3
3
|
|
4
|
+
// @ts-expect-error this is a transitive dep of expo, which is required in consumers to even run this setup
|
4
5
|
import { EasJsonAccessor, EasJsonUtils, Platform } from '@expo/eas-json';
|
5
6
|
import { print, type Props } from 'bluebun';
|
6
7
|
import { $, semver, which } from 'bun';
|
@@ -4,7 +4,7 @@ import { type MobileProps, needsBinary, needsBrewFormula, setup } from './_setup
|
|
4
4
|
|
5
5
|
export default {
|
6
6
|
name: 'build',
|
7
|
-
description: '
|
7
|
+
description: '🏗️ Build',
|
8
8
|
run: async (props: MobileProps) => {
|
9
9
|
const { platform, profile, output } = await setup({
|
10
10
|
props,
|
package/cli/commands/purge.ts
CHANGED
package/cli/commands/sync.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Props } from 'bluebun';
|
1
|
+
import { magenta, print, Props } from 'bluebun';
|
2
2
|
|
3
3
|
import { setupConfigWorker } from '../utils/setupConfigWorker';
|
4
4
|
import { SyncOptions } from '../utils/types';
|
@@ -9,10 +9,22 @@ interface SyncProps extends Props {
|
|
9
9
|
|
10
10
|
export default {
|
11
11
|
name: 'sync',
|
12
|
-
description: '
|
13
|
-
|
12
|
+
description: '🔄 Update to latest design config 🎨',
|
13
|
+
alias: ['update'],
|
14
|
+
run: async ({ name, commandPath, options }: SyncProps) => {
|
15
|
+
const { id = Bun.env.UDS_ID, outFile = Bun.env.UDS_OUT_FILE } = options;
|
16
|
+
|
17
|
+
if (!id || typeof id === 'boolean') {
|
18
|
+
console.error(
|
19
|
+
'\nMissing config ID. Please pass an --id flag or set the UDS_ID env variable.\n',
|
20
|
+
);
|
21
|
+
print(`${magenta('Usage:')} ${name} ${commandPath} --id <config-id>\n`);
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
|
14
25
|
await setupConfigWorker({
|
15
|
-
|
26
|
+
id,
|
27
|
+
outFile: outFile ?? './uds.config.ts',
|
16
28
|
onUpdate: ({ worker }) => {
|
17
29
|
if (!options.watch) {
|
18
30
|
worker.terminate();
|
package/cli/commands/uds.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type Props } from 'bluebun';
|
1
|
+
import { print, type Props, red } from 'bluebun';
|
2
2
|
|
3
3
|
import { getCommandHelp } from '../utils/getCommandHelp';
|
4
4
|
|
@@ -6,6 +6,9 @@ export default {
|
|
6
6
|
name: 'uds',
|
7
7
|
description: '',
|
8
8
|
run: async (props: Props) => {
|
9
|
+
if (props.first) {
|
10
|
+
print(red(`Unknown command: ${props.first}`));
|
11
|
+
}
|
9
12
|
await getCommandHelp(props);
|
10
13
|
},
|
11
14
|
};
|
package/cli/commands/version.ts
CHANGED
package/cli/preload.ts
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
import { jest, mock } from 'bun:test';
|
2
|
+
|
3
|
+
const mockFastGlob = jest.fn().mockResolvedValue(['/pages/PageA.tsx', '/pages/PageB.tsx']);
|
4
|
+
|
5
|
+
mock.module('fast-glob', () => ({ __esModule: true, default: mockFastGlob }));
|
6
|
+
|
7
|
+
mock.module('@yahoo/uds/tailwindPurge', () => ({
|
8
|
+
componentsDependencies: {
|
9
|
+
Button: ['Icon', 'Pressable', 'Text'],
|
10
|
+
Spinner: [],
|
11
|
+
HStack: ['Box'],
|
12
|
+
},
|
13
|
+
componentToVariants: {
|
14
|
+
Button: ['color'],
|
15
|
+
HStack: ['alignItems', 'justifyContent'],
|
16
|
+
Icon: ['color'],
|
17
|
+
Text: ['fontSize', 'fontFamily'],
|
18
|
+
Pressable: ['display'],
|
19
|
+
},
|
20
|
+
variantsList: ['color', 'alignItems', 'justifyContent', 'display', 'fontSize', 'fontFamily'],
|
21
|
+
variantToTailwindClass: {
|
22
|
+
color: 'text-accent text-alert text-black text-brand text-positive text-warning text-white',
|
23
|
+
alignItems: 'items-start items-end items-center items-stretch items-baseline',
|
24
|
+
justifyContent:
|
25
|
+
'justify-start justify-end justify-center justify-between justify-around justify-evenly',
|
26
|
+
display:
|
27
|
+
'block inline-block inline flex inline-flex table inline-table table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row-group table-row flow-root grid contents',
|
28
|
+
fontSize: 'font-size-display1 font-size-title1 ',
|
29
|
+
fontFamily:
|
30
|
+
'font-icons font-sans font-sans-beta font-sans-condensed font-serif-text font-serif-display font-display1 font-title1 font-title2 font-title3 font-title4 font-headline1 font-body1 font-label1 font-label2 font-caption1 font-caption2 font-legal1',
|
31
|
+
},
|
32
|
+
}));
|
@@ -1,30 +1,49 @@
|
|
1
1
|
// prevents TS errors
|
2
2
|
declare var self: Worker;
|
3
3
|
|
4
|
-
import {
|
4
|
+
import { UniversalTokensConfig } from '@yahoo/uds/tokens';
|
5
5
|
|
6
6
|
import { ConfigWorkerThreadMessage } from './types';
|
7
7
|
|
8
|
+
const CLOUD_FUNCTION = 'https://syncconfig-j57v6zmjrq-uc.a.run.app';
|
9
|
+
|
8
10
|
self.onmessage = async ({ data }: ConfigWorkerThreadMessage) => {
|
11
|
+
const { id } = data.resp;
|
12
|
+
|
9
13
|
if (data.type === 'init') {
|
10
14
|
try {
|
11
|
-
//
|
15
|
+
// The firebase packaage available if we're in the UDS monorepo. Listen for updates.
|
12
16
|
const firebase = await import('database/firebase');
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
// Bail if the branch doesn't exist in configurator.
|
19
|
+
const branchExists = await firebase.branchExists(id);
|
20
|
+
if (!branchExists) {
|
21
|
+
throw new Error(`Config id '${id}' does not exist in the Configurator.`);
|
22
|
+
}
|
23
|
+
|
24
|
+
console.log('Fetching using local database package...');
|
25
|
+
|
26
|
+
firebase.onBranchSnapshot(id, ({ config, status }) => {
|
15
27
|
postMessage({ type: 'update', resp: { config, status } });
|
16
28
|
});
|
17
29
|
} catch (err) {
|
18
30
|
try {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
throw Error;
|
31
|
+
console.log('Fetching from configurator...');
|
32
|
+
|
33
|
+
const resp = await fetch(`${CLOUD_FUNCTION}?id=${id}`);
|
34
|
+
if (!resp.ok) {
|
35
|
+
throw new Error(`Error fetching config id '${id}'. Does it exist in the Configurator?`);
|
25
36
|
}
|
37
|
+
|
38
|
+
const { config } = ((await resp.json()) as { config: UniversalTokensConfig }) ?? {};
|
39
|
+
if (!config) {
|
40
|
+
throw new Error('Config JSON could not be parsed.');
|
41
|
+
}
|
42
|
+
|
43
|
+
postMessage({ type: 'update', resp: { config, status: 'error' } });
|
26
44
|
} catch (err) {
|
27
|
-
|
45
|
+
console.error(`\n${(err as Error).message}\n`);
|
46
|
+
throw err;
|
28
47
|
}
|
29
48
|
}
|
30
49
|
}
|
@@ -1,21 +1,21 @@
|
|
1
1
|
import {
|
2
|
-
bold,
|
3
2
|
calcWidestCommandName,
|
4
|
-
CommandTree,
|
3
|
+
type CommandTree,
|
5
4
|
commandTree,
|
6
5
|
cyan,
|
7
6
|
gray,
|
7
|
+
green,
|
8
|
+
magenta,
|
8
9
|
print,
|
9
|
-
Props,
|
10
|
+
type Props,
|
10
11
|
white,
|
11
12
|
} from 'bluebun';
|
12
13
|
|
13
14
|
/**
|
14
|
-
*
|
15
15
|
* The formatting from bluebun for the help command is not great.
|
16
16
|
* I forked code from https://github.com/jamonholmgren/bluebun/blob/main/src/command-help.ts
|
17
17
|
*
|
18
|
-
* TODO:
|
18
|
+
* TODO: create helpers for better styling control for this & other features
|
19
19
|
*
|
20
20
|
* Some packages to checkout:
|
21
21
|
* - https://github.com/wobsoriano/blipgloss
|
@@ -29,7 +29,7 @@ async function formatHelp(initialProps: Props) {
|
|
29
29
|
const _tree = await commandTree(initialProps);
|
30
30
|
const tree = categoryToFilter ? { [categoryToFilter]: _tree[categoryToFilter] } : _tree;
|
31
31
|
|
32
|
-
const widest = calcWidestCommandName(tree) +
|
32
|
+
const widest = calcWidestCommandName(tree) + 10;
|
33
33
|
|
34
34
|
function generateHelp(cmdTree: CommandTree, prefix: string): string[] {
|
35
35
|
return Object.keys(cmdTree).flatMap((key) => {
|
@@ -49,16 +49,25 @@ async function formatHelp(initialProps: Props) {
|
|
49
49
|
|
50
50
|
const helpLines = generateHelp(tree, name);
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
// https://texteditor.com/multiline-text-art/
|
53
|
+
const banner = `
|
54
|
+
█ █ █▀▄ ▄▀▀ ▄▀▀ █ █
|
55
|
+
▀▄█ █▄▀ ▄██ ▀▄▄ █▄▄ █
|
56
|
+
Universal Design System
|
57
|
+
`.trim();
|
58
|
+
|
59
|
+
const help = `
|
60
|
+
${green(banner)}
|
61
|
+
|
62
|
+
${magenta(`Usage: ${white(`${name} <command>`)}`)}
|
63
|
+
|
64
|
+
${magenta('Commands:')}
|
65
|
+
${helpLines.join('\n')}
|
66
|
+
`;
|
56
67
|
|
57
68
|
return help;
|
58
69
|
}
|
59
70
|
|
60
71
|
export async function getCommandHelp(props: Props) {
|
61
|
-
print(
|
62
|
-
const helpText = await formatHelp(props);
|
63
|
-
print(helpText);
|
72
|
+
print(await formatHelp(props));
|
64
73
|
}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
2
|
+
import { Project } from 'ts-morph';
|
3
|
+
|
4
|
+
import {
|
5
|
+
getComponentsToConvertToTW,
|
6
|
+
getFiles,
|
7
|
+
getTailwindSafelist,
|
8
|
+
isUDSComponent,
|
9
|
+
parseFiles,
|
10
|
+
} from './purgeCSS';
|
11
|
+
|
12
|
+
const PAGE_A_CODE = `
|
13
|
+
import { Button } from '@yahoo/uds';
|
14
|
+
|
15
|
+
const PageA = () => {
|
16
|
+
return (
|
17
|
+
<div>
|
18
|
+
<Button> Click me </Button>
|
19
|
+
</div>
|
20
|
+
)
|
21
|
+
}
|
22
|
+
`;
|
23
|
+
|
24
|
+
const PAGE_B_CODE = `
|
25
|
+
import { HStack, Spinner } from '@yahoo/uds';
|
26
|
+
import { noop } from 'lodash';
|
27
|
+
|
28
|
+
const PageB = () => {
|
29
|
+
return (
|
30
|
+
<div>
|
31
|
+
<HStack flexGrow="1" alignItems="center" justifyContent="center">
|
32
|
+
<Spinner />
|
33
|
+
</HStack>
|
34
|
+
</div>
|
35
|
+
)
|
36
|
+
}
|
37
|
+
`;
|
38
|
+
|
39
|
+
const FILES = ['/pages/PageA.tsx', '/pages/PageB.tsx'];
|
40
|
+
const IMPORTED_UDS_COMPONENTS = ['Button', 'HStack', 'Spinner'];
|
41
|
+
|
42
|
+
describe('purgeCSS', () => {
|
43
|
+
const project = new Project();
|
44
|
+
|
45
|
+
describe('getFiles', () => {
|
46
|
+
it('returns the list of files', async () => {
|
47
|
+
const files = await getFiles();
|
48
|
+
|
49
|
+
expect(files).toEqual(FILES);
|
50
|
+
});
|
51
|
+
});
|
52
|
+
|
53
|
+
describe('parseFiles', () => {
|
54
|
+
it('returns the list of imports from @yahoo/uds', () => {
|
55
|
+
project.createSourceFile(FILES[0], PAGE_A_CODE, {
|
56
|
+
overwrite: true,
|
57
|
+
});
|
58
|
+
project.createSourceFile(FILES[1], PAGE_B_CODE, {
|
59
|
+
overwrite: true,
|
60
|
+
});
|
61
|
+
|
62
|
+
const res = parseFiles(project, FILES);
|
63
|
+
|
64
|
+
expect(res).toEqual(IMPORTED_UDS_COMPONENTS);
|
65
|
+
});
|
66
|
+
});
|
67
|
+
|
68
|
+
describe('getTailwindSafelist', () => {
|
69
|
+
it('returns the tailwind classes corresponding to the props on a component', () => {
|
70
|
+
const res = getTailwindSafelist(IMPORTED_UDS_COMPONENTS);
|
71
|
+
|
72
|
+
expect(res).toEqual(
|
73
|
+
'text-accent text-alert text-black text-brand text-positive text-warning text-white items-start items-end items-center items-stretch items-baseline justify-start justify-end justify-center justify-between justify-around justify-evenly ',
|
74
|
+
);
|
75
|
+
});
|
76
|
+
});
|
77
|
+
|
78
|
+
describe('getComponentsToConvertToTW', () => {
|
79
|
+
it('should get just exports which are components from UDS', () => {
|
80
|
+
const res = getComponentsToConvertToTW(['Button', 'HStack', 'randomThingy']);
|
81
|
+
|
82
|
+
expect(res).toEqual(['Button', 'Icon', 'Pressable', 'Text', 'HStack', 'Box']);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
86
|
+
describe('isUDSComponent', () => {
|
87
|
+
it('returns true if the component is exported from UDS', () => {
|
88
|
+
const res = isUDSComponent('Button');
|
89
|
+
|
90
|
+
expect(res).toBeTrue();
|
91
|
+
});
|
92
|
+
|
93
|
+
it('returns false if the component is not exported from UDS', () => {
|
94
|
+
const res = isUDSComponent('NotUdsComponent');
|
95
|
+
|
96
|
+
expect(res).toBeFalse();
|
97
|
+
});
|
98
|
+
});
|
99
|
+
});
|
package/cli/utils/purgeCSS.ts
CHANGED
@@ -17,7 +17,7 @@ type Files = string[];
|
|
17
17
|
// TODO: use CLI args to power the output file path
|
18
18
|
const OUTPUT_FILE_PATH = Bun.file(`${Bun.env.PWD}/dist/safelist.js`);
|
19
19
|
|
20
|
-
const getFiles = async (): Promise<Files> => {
|
20
|
+
export const getFiles = async (): Promise<Files> => {
|
21
21
|
const workspaceDir = Bun.env.PWD;
|
22
22
|
const srcDir = path.join(workspaceDir, '/src/');
|
23
23
|
const files = await FastGlob(`${srcDir}/**/*.{jsx,tsx}`);
|
@@ -28,7 +28,7 @@ const getFiles = async (): Promise<Files> => {
|
|
28
28
|
/**
|
29
29
|
* Given a file it returns the list of imports from @yahoo/uds
|
30
30
|
*/
|
31
|
-
const parseFiles = (project: Project, files: Files): ImportsList => {
|
31
|
+
export const parseFiles = (project: Project, files: Files): ImportsList => {
|
32
32
|
const importsSet = new Set();
|
33
33
|
|
34
34
|
const importsPerFile: string[] = files
|
@@ -59,7 +59,7 @@ const parseFiles = (project: Project, files: Files): ImportsList => {
|
|
59
59
|
return Array.from(importsSet) as string[];
|
60
60
|
};
|
61
61
|
|
62
|
-
const getTailwindSafelist = (componentList: string[]): SafeList => {
|
62
|
+
export const getTailwindSafelist = (componentList: string[]): SafeList => {
|
63
63
|
const validVariants = new Set<string>(variantsList);
|
64
64
|
const usedProps = new Set<string>();
|
65
65
|
componentList.forEach((component: string) => {
|
@@ -79,7 +79,7 @@ const getTailwindSafelist = (componentList: string[]): SafeList => {
|
|
79
79
|
return safeList;
|
80
80
|
};
|
81
81
|
|
82
|
-
const isUDSComponent = (component: string): boolean => {
|
82
|
+
export const isUDSComponent = (component: string): boolean => {
|
83
83
|
return !!componentToVariants[component];
|
84
84
|
};
|
85
85
|
|
@@ -94,7 +94,7 @@ const saveToFile = async (safeList: SafeList) => {
|
|
94
94
|
await Bun.write(OUTPUT_FILE_PATH, fileContent);
|
95
95
|
};
|
96
96
|
|
97
|
-
const getComponentsToConvertToTW = (udsImport: ImportsList): string[] => {
|
97
|
+
export const getComponentsToConvertToTW = (udsImport: ImportsList): string[] => {
|
98
98
|
// filter out just the components
|
99
99
|
const components = udsImport.filter((importedItem) => !!componentToVariants[importedItem]);
|
100
100
|
const set = new Set();
|
@@ -2,52 +2,22 @@ import path from 'node:path';
|
|
2
2
|
|
3
3
|
import { sortKeys } from './sortKeys';
|
4
4
|
import { ConfigWorkerMainThreadMessage, SyncOptions } from './types';
|
5
|
-
|
6
|
-
const workerPath = path.resolve(import.meta.dir, './configWorker');
|
7
|
-
const workerURL = new URL(Bun.pathToFileURL(workerPath)).href;
|
8
|
-
|
9
5
|
interface ConfigWorkerOptions extends SyncOptions {
|
10
6
|
onUpdate?: (params: { worker: Worker }) => void;
|
11
7
|
}
|
12
8
|
|
13
|
-
export async function setupConfigWorker({
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}: ConfigWorkerOptions = {}) {
|
18
|
-
const workspaceDir = Bun.env.PWD;
|
19
|
-
let configID = id;
|
20
|
-
let configOutFile = outFile ?? './uds.config.ts';
|
21
|
-
|
22
|
-
// If we didn't get the config ID from the command line or env vars, check for a uds.json file
|
23
|
-
if (!configID) {
|
24
|
-
const udsConfigFile = Bun.file(`${workspaceDir}/uds.json`);
|
25
|
-
const udsConfigFileExists = await udsConfigFile.exists();
|
26
|
-
if (udsConfigFileExists) {
|
27
|
-
const configJsonFile = (await udsConfigFile.json()) as { id: string; outFile: string };
|
28
|
-
|
29
|
-
configID = configJsonFile.id;
|
30
|
-
configOutFile = configJsonFile.outFile;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
// have _nothing_, warn the eng to do something
|
35
|
-
if (!configID) {
|
36
|
-
console.error(
|
37
|
-
'\nMissing config ID. Please pass in --id, set UDS_ID in your .env, or create a uds.json file with { "id": "your-config-id" } defined.\n',
|
38
|
-
);
|
39
|
-
process.exit(1);
|
40
|
-
}
|
41
|
-
|
42
|
-
const outFilePath = `${workspaceDir}/${configOutFile}`;
|
9
|
+
export async function setupConfigWorker({ id, outFile, onUpdate }: ConfigWorkerOptions) {
|
10
|
+
const workerPath = path.resolve(import.meta.dir, './configWorker');
|
11
|
+
const workerURL = Bun.pathToFileURL(workerPath).href;
|
12
|
+
const outFilePath = `${Bun.env.PWD}/${outFile}`;
|
43
13
|
|
44
14
|
const worker = new Worker(workerURL);
|
45
15
|
|
46
16
|
worker.addEventListener('open', () => {
|
47
|
-
worker.postMessage({ type: 'init', resp: { id
|
17
|
+
worker.postMessage({ type: 'init', resp: { id } });
|
48
18
|
});
|
49
19
|
|
50
|
-
worker.
|
20
|
+
worker.addEventListener('message', async ({ data }: ConfigWorkerMainThreadMessage) => {
|
51
21
|
if (data.type === 'update') {
|
52
22
|
// Firebase does not guarantee the order of the keys in the config
|
53
23
|
// this can give us a false diff when writing to existing file
|
@@ -59,11 +29,11 @@ import { type UniversalTokensConfig } from '@yahoo/uds';
|
|
59
29
|
export const config: UniversalTokensConfig = ${JSON.stringify(sortedConfig, null, 2)};
|
60
30
|
`.trimStart();
|
61
31
|
|
62
|
-
console.log(`✅ Synced UDS config ${
|
32
|
+
console.log(`✅ Synced UDS config ${id} to ${outFilePath}`);
|
63
33
|
await Bun.write(outFilePath, configContent);
|
64
34
|
onUpdate?.({ worker });
|
65
35
|
}
|
66
|
-
};
|
36
|
+
});
|
67
37
|
|
68
38
|
// Register a handler for the SIGINT signal (Ctrl + C)
|
69
39
|
process.on('SIGINT', () => {
|
package/cli/utils/types.ts
CHANGED
@@ -7,7 +7,10 @@ export type ConfigWorkerMainThreadMessage = MessageEvent<{
|
|
7
7
|
}>;
|
8
8
|
|
9
9
|
export type SyncOptions = {
|
10
|
-
id
|
11
|
-
|
10
|
+
/** Configurator (branch) id */
|
11
|
+
id: string;
|
12
|
+
/** The file to write the config to. Defaults to uds.config.ts. */
|
13
|
+
outFile: string;
|
14
|
+
/** Enable watch mode? */
|
12
15
|
watch?: boolean;
|
13
16
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as react from 'react';
|
2
|
-
import {
|
2
|
+
import { l as UniversalPressableProps, n as UniversalIconButtonProps, o as UniversalImageProps } from './types-CzJpH_Oi.js';
|
3
3
|
import { View, PressableProps as PressableProps$1, StyleProp, ViewStyle } from 'react-native';
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
5
5
|
import { ImageProps as ImageProps$1 } from 'expo-image';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as react from 'react';
|
2
|
-
import {
|
2
|
+
import { l as UniversalPressableProps, n as UniversalIconButtonProps, o as UniversalImageProps } from './types-CzJpH_Oi.cjs';
|
3
3
|
import { View, PressableProps as PressableProps$1, StyleProp, ViewStyle } from 'react-native';
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
5
5
|
import { ImageProps as ImageProps$1 } from 'expo-image';
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import * as react from 'react';
|
2
|
+
import { k as UniversalBoxProps, l as UniversalPressableProps, m as UniversalStackProps } from './types-CzJpH_Oi.cjs';
|
3
|
+
|
4
|
+
type DivProps = React.HTMLAttributes<HTMLDivElement>;
|
5
|
+
interface BoxProps extends UniversalBoxProps, DivProps {
|
6
|
+
}
|
7
|
+
/**
|
8
|
+
* A layout primitive that can be used to compose other components.
|
9
|
+
* @example
|
10
|
+
```tsx
|
11
|
+
import { Box } from "@yahoo/uds"
|
12
|
+
|
13
|
+
export function Demo() {
|
14
|
+
return (
|
15
|
+
<Box
|
16
|
+
bordered
|
17
|
+
backgroundColor="primary"
|
18
|
+
borderRadius="md"
|
19
|
+
spacing='6'
|
20
|
+
>
|
21
|
+
Any kind of content can go here!
|
22
|
+
</Box>
|
23
|
+
)
|
24
|
+
}
|
25
|
+
```
|
26
|
+
*/
|
27
|
+
declare const Box: react.ForwardRefExoticComponent<BoxProps & react.RefAttributes<HTMLDivElement>>;
|
28
|
+
|
29
|
+
type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'>;
|
30
|
+
interface PressableProps extends UniversalPressableProps, HtmlButtonProps {
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Provides press interactions with accessibility support.
|
34
|
+
* @example
|
35
|
+
```tsx
|
36
|
+
import { Pressable, Text } from "@yahoo/uds"
|
37
|
+
|
38
|
+
export function Demo() {
|
39
|
+
return (
|
40
|
+
<Pressable
|
41
|
+
onClick={console.log}
|
42
|
+
backgroundColor="secondary"
|
43
|
+
bordered
|
44
|
+
borderColor="primary"
|
45
|
+
borderRadius="lg"
|
46
|
+
>
|
47
|
+
<Text variant="body1" spacingHorizontal="7" spacingVertical="5">Click me...</Text>
|
48
|
+
</Pressable>
|
49
|
+
)
|
50
|
+
}
|
51
|
+
```
|
52
|
+
*/
|
53
|
+
declare const Pressable: react.ForwardRefExoticComponent<PressableProps & react.RefAttributes<HTMLButtonElement>>;
|
54
|
+
|
55
|
+
type VStackProps = UniversalStackProps & DivProps;
|
56
|
+
/**
|
57
|
+
* The VStack is essentially the same component as [Box](/components/box) where it uses [flexbox](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox) but it lays out content in a column. VStack also allows for gaps between children via the `gap` prop.
|
58
|
+
*
|
59
|
+
* You should use VStack when:
|
60
|
+
*
|
61
|
+
* - you want to lay content out in rows that are sized to their content (height only, by default each child will fill the width of the VStack)
|
62
|
+
* - you want to add gaps between columns
|
63
|
+
* - you want to lay content out in columns that fill the available space within the parent container
|
64
|
+
* - you need columns of proportionate size to each other (also known as a ratio-based layout)
|
65
|
+
*
|
66
|
+
* @example
|
67
|
+
* #### Rows with Gaps
|
68
|
+
*
|
69
|
+
* ```tsx
|
70
|
+
* import { Box, VStack } from "@yahoo/uds"
|
71
|
+
*
|
72
|
+
* export function Demo() {
|
73
|
+
* return (
|
74
|
+
* <VStack gap="6">
|
75
|
+
* <Box spacing="6" backgroundColor="secondary">
|
76
|
+
* First
|
77
|
+
* </Box>
|
78
|
+
* <Box spacing="6" backgroundColor="secondary">
|
79
|
+
* Second
|
80
|
+
* </Box>
|
81
|
+
* <Box spacing="6" backgroundColor="secondary">
|
82
|
+
* Third
|
83
|
+
* </Box>
|
84
|
+
* </VStack>
|
85
|
+
* )
|
86
|
+
* }
|
87
|
+
* ```
|
88
|
+
*
|
89
|
+
* #### Rows that Have Proportionate Sizes
|
90
|
+
*
|
91
|
+
* ```tsx
|
92
|
+
* import { Box, VStack } from "@yahoo/uds"
|
93
|
+
*
|
94
|
+
* export function Demo() {
|
95
|
+
* return (
|
96
|
+
* <VStack gap="6">
|
97
|
+
* <Box spacing="6" flexGrow="1" backgroundColor="secondary">
|
98
|
+
* First
|
99
|
+
* </Box>
|
100
|
+
* <Box spacing="6" flexGrow="2" backgroundColor="secondary">
|
101
|
+
* Second
|
102
|
+
* </Box>
|
103
|
+
* <Box spacing="6" flexGrow="3" backgroundColor="secondary">
|
104
|
+
* Third
|
105
|
+
* </Box>
|
106
|
+
* </VStack>
|
107
|
+
* )
|
108
|
+
* }
|
109
|
+
* ```
|
110
|
+
*
|
111
|
+
**/
|
112
|
+
declare const VStack: react.ForwardRefExoticComponent<UniversalStackProps & DivProps & react.RefAttributes<HTMLDivElement>>;
|
113
|
+
|
114
|
+
export { Box as B, type DivProps as D, Pressable as P, VStack as V, type BoxProps as a, type PressableProps as b, type VStackProps as c };
|