@yahoo/uds 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/cli/README.md +50 -0
  2. package/cli/bin/uds-darwin-arm64-baseline +0 -0
  3. package/cli/bin/uds-linux-arm64 +0 -0
  4. package/cli/bin/uds-linux-x64-baseline +0 -0
  5. package/cli/cli.ts +21 -4
  6. package/cli/commands/codemod/codemod.ts +12 -9
  7. package/cli/commands/codemod/sizingProps.ts +1 -1
  8. package/cli/commands/login.ts +30 -0
  9. package/cli/commands/logout.ts +27 -0
  10. package/cli/commands/purge.ts +3 -1
  11. package/cli/commands/sync.ts +2 -0
  12. package/cli/commands/uds.ts +6 -1
  13. package/cli/commands/version.ts +2 -0
  14. package/cli/compile.ts +8 -9
  15. package/cli/consts.ts +5 -1
  16. package/cli/env.d.ts +5 -0
  17. package/cli/exec.ts +1 -1
  18. package/cli/preload.ts +17 -0
  19. package/cli/tsconfig.json +4 -4
  20. package/cli/uds-cli +6 -2
  21. package/cli/utils/analytics.ts +26 -0
  22. package/cli/utils/auth.ts +338 -0
  23. package/cli/utils/client_secrets.json +23 -0
  24. package/cli/utils/client_secrets.json.enc +0 -0
  25. package/cli/utils/configWorker.ts +3 -2
  26. package/cli/utils/getDirChoices.ts +0 -1
  27. package/cli/utils/secrets.ts +40 -0
  28. package/dist/analytics/server.cjs +1 -0
  29. package/dist/analytics/server.d.cts +1 -0
  30. package/dist/analytics/server.d.ts +1 -0
  31. package/dist/analytics/server.js +1 -0
  32. package/dist/chunk-3PK6DOFO.js +3 -0
  33. package/dist/chunk-5WBROFT5.cjs +1 -0
  34. package/dist/chunk-DCXVARRB.cjs +1 -0
  35. package/dist/chunk-DMMTEAJW.cjs +2 -0
  36. package/dist/chunk-EYFQOFYW.cjs +1 -0
  37. package/dist/chunk-FWF2C6TL.cjs +1 -0
  38. package/dist/chunk-GIJ2FHY5.cjs +1 -0
  39. package/dist/chunk-IUL5ZI4O.js +2 -0
  40. package/dist/chunk-JGIKFUBH.cjs +2 -0
  41. package/dist/chunk-P5B5IOMM.js +2 -0
  42. package/dist/chunk-PE2P7J44.js +2 -0
  43. package/dist/chunk-PFT3UA6K.cjs +2 -0
  44. package/dist/chunk-SUASN3GG.js +2 -0
  45. package/dist/chunk-VPR62GYQ.js +2 -0
  46. package/dist/chunk-X6F5UEQ5.js +2 -0
  47. package/dist/chunk-YM5TKITI.js +2 -0
  48. package/dist/chunk-YUHY3FXT.cjs +1 -0
  49. package/dist/chunk-ZV62SW5G.js +1 -0
  50. package/dist/client/index.cjs +3 -0
  51. package/dist/client/index.d.cts +97 -0
  52. package/dist/client/index.d.ts +97 -0
  53. package/dist/client/index.js +4 -0
  54. package/dist/experimental/index.cjs +2 -0
  55. package/dist/experimental/index.d.cts +469 -0
  56. package/dist/experimental/index.d.ts +469 -0
  57. package/dist/experimental/index.js +2 -0
  58. package/dist/fixtures.cjs +1506 -0
  59. package/dist/fixtures.d.cts +94 -0
  60. package/dist/fixtures.d.ts +94 -0
  61. package/dist/fixtures.js +1449 -0
  62. package/dist/flags.cjs +1 -0
  63. package/dist/flags.d.cts +17 -0
  64. package/dist/flags.d.ts +17 -0
  65. package/dist/flags.js +2 -0
  66. package/dist/index.cjs +1 -0
  67. package/dist/index.d.cts +385 -0
  68. package/dist/index.d.ts +385 -0
  69. package/dist/index.js +1 -0
  70. package/dist/metafile-cjs.json +1 -0
  71. package/dist/metafile-esm.json +1 -0
  72. package/dist/motionFeatures-I76FFCTS.js +1 -0
  73. package/dist/motionFeatures-P3FQL2KP.cjs +1 -0
  74. package/dist/styles/toast.css +3 -0
  75. package/dist/styles/toast.d.cts +2 -0
  76. package/dist/styles/toast.d.ts +2 -0
  77. package/dist/tailwind/plugin.cjs +2 -0
  78. package/dist/tailwind/plugin.d.cts +60 -0
  79. package/dist/tailwind/plugin.d.ts +60 -0
  80. package/dist/tailwind/plugin.js +2 -0
  81. package/dist/tailwind/purger.cjs +5 -0
  82. package/dist/tailwind/purger.d.cts +17 -0
  83. package/dist/tailwind/purger.d.ts +17 -0
  84. package/dist/tailwind/purger.js +6 -0
  85. package/dist/tailwind/tsMorph.cjs +1 -0
  86. package/dist/tailwind/tsMorph.d.cts +31 -0
  87. package/dist/tailwind/tsMorph.d.ts +31 -0
  88. package/dist/tailwind/tsMorph.js +1 -0
  89. package/dist/tailwind/utils.cjs +1 -0
  90. package/dist/tailwind/utils.d.cts +99 -0
  91. package/dist/tailwind/utils.d.ts +99 -0
  92. package/dist/tailwind/utils.js +1 -0
  93. package/dist/tokens/index.cjs +1 -0
  94. package/dist/tokens/index.d.cts +1127 -0
  95. package/dist/tokens/index.d.ts +1127 -0
  96. package/dist/tokens/index.js +1 -0
  97. package/dist/tokens/parseTokens.cjs +1 -0
  98. package/dist/tokens/parseTokens.d.cts +59 -0
  99. package/dist/tokens/parseTokens.d.ts +59 -0
  100. package/dist/tokens/parseTokens.js +1 -0
  101. package/dist/types-Pyccco5Q.d.cts +949 -0
  102. package/dist/types-Pyccco5Q.d.ts +949 -0
  103. package/fonts/mobile.cjs +1 -1
  104. package/package.json +48 -21
  105. package/cli/codemods/propsToClass.test.tsx +0 -97
  106. package/cli/utils/purgeCSS.test.ts +0 -210
package/fonts/mobile.cjs CHANGED
@@ -25,5 +25,5 @@ var fonts = [
25
25
  require.resolve('@yahoo/uds/fonts/yahoo-serif-display-bold.otf'),
26
26
  ];
27
27
 
28
- // eslint-disable-next-line no-undef
28
+
29
29
  module.exports.fonts = fonts;
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@yahoo/uds",
3
3
  "description": "Yahoo Universal System",
4
- "version": "2.0.0",
4
+ "version": "2.1.0",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "uds": "./cli/uds-cli"
8
8
  },
9
9
  "files": [
10
10
  "cli/**",
11
+ "!cli/**/*.test.*",
11
12
  "dist/**",
12
- "fonts/**",
13
- "package.json"
13
+ "fonts/**"
14
14
  ],
15
15
  "sideEffects": false,
16
16
  "exports": {
@@ -24,6 +24,26 @@
24
24
  "default": "./dist/index.cjs"
25
25
  }
26
26
  },
27
+ "./analytics/server": {
28
+ "import": {
29
+ "types": "./dist/analytics/server.d.ts",
30
+ "default": "./dist/analytics/server.js"
31
+ },
32
+ "require": {
33
+ "types": "./dist/analytics/server.d.cts",
34
+ "default": "./dist/analytics/server.cjs"
35
+ }
36
+ },
37
+ "./flags": {
38
+ "import": {
39
+ "types": "./dist/flags.d.ts",
40
+ "default": "./dist/flags.js"
41
+ },
42
+ "require": {
43
+ "types": "./dist/flags.d.cts",
44
+ "default": "./dist/flags.cjs"
45
+ }
46
+ },
27
47
  "./client": {
28
48
  "import": {
29
49
  "types": "./dist/client/index.d.ts",
@@ -95,23 +115,23 @@
95
115
  }
96
116
  },
97
117
  "scripts": {
98
- "build": "bun run ./scripts/prebuild.ts && tsup && bun run ./scripts/postbuild.ts",
99
- "build:cli": "bun ./cli/compile.ts",
100
- "build:fixtures": "bun run ./scripts/buildFixtures.ts",
101
- "build:purgeCSSData": "bun run ./scripts/generatePurgeCSSData.ts",
118
+ "build": "bun run ./scripts/build.ts",
119
+ "build:cli": "bun run ./cli/utils/secrets.ts decrypt && bun ./cli/compile.ts",
102
120
  "ci:publish": "bun semantic-release -e semantic-release-monorepo",
103
- "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .coverage",
121
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .coverage && rm -rf cli/bin",
104
122
  "dev": "concurrently bun:dev:*",
105
123
  "dev:fixtures": "bun run ./scripts/buildFixtures.ts --watch",
106
124
  "dev:purgeCSSData": "bun run ./scripts/generatePurgeCSSData.ts --watch",
107
125
  "dev:ts": "tsup --watch",
108
- "lint": "ESLINT_USE_FLAT_CONFIG=true eslint -c eslint.config.mjs .",
126
+ "lint": "eslint -c eslint.config.mjs .",
127
+ "lint:fix": "bun run lint --fix",
109
128
  "lint:pkg": "bun publint",
110
129
  "test": "vitest run",
111
130
  "test:bun": "bun run test:bun:scripts && bun run test:bun:cli",
112
131
  "test:bun:cli": "cd ./cli && bun test",
113
132
  "test:bun:scripts": "cd ./scripts && bun test",
114
133
  "test:coverage": "vitest run --coverage",
134
+ "test:e2e": "bun run e2e/verifyCLI.ts",
115
135
  "test:ui": "vitest --ui --coverage",
116
136
  "test:watch": "vitest",
117
137
  "typecheck": "concurrently bun:typecheck:*",
@@ -120,37 +140,44 @@
120
140
  "typecheck:uds": "tsc -p . --noEmit"
121
141
  },
122
142
  "dependencies": {
123
- "@ariakit/react": "^0.4.11",
143
+ "@ariakit/react": "^0.4.12",
124
144
  "bluebun": "^0.0.34",
125
145
  "clsx": "^2.1.1",
126
- "framer-motion": "^11.5.4",
146
+ "firebase": "^11.0.0",
147
+ "framer-motion": "^11.11.4",
148
+ "googleapis": "^144.0.0",
127
149
  "imurmurhash": "^0.1.4",
128
150
  "lodash-es": "^4.17.21",
151
+ "open": "^10.1.0",
129
152
  "prompts": "^2.4.2",
130
153
  "react-toastify": "^10.0.5",
131
154
  "semver": "^7.6.3",
132
- "tailwind-merge": "^2.5.2",
133
- "ts-morph": "^23.0.0"
155
+ "tailwind-merge": "^2.5.3",
156
+ "ts-morph": "^24.0.0",
157
+ "uuid": "^11.0.3"
134
158
  },
135
159
  "devDependencies": {
136
- "@fullhuman/postcss-purgecss": "^6.0.0",
160
+ "@fullhuman/postcss-purgecss": "^7.0.0",
161
+ "@next/env": "^14.2.15",
162
+ "@types/bun": "1.1.14",
137
163
  "@types/imurmurhash": "^0.1.4",
138
164
  "@types/prompts": "^2.4.9",
139
- "@types/react": "^18.3.5",
165
+ "@types/react": "^18.3.11",
140
166
  "@types/react-dom": "^18.3.0",
141
167
  "@yahoo/uds-icons": "workspace:*",
142
168
  "autoprefixer": "^10.4.20",
143
169
  "chalk": "^5.3.0",
144
- "concurrently": "^8.2.2",
145
- "postcss": "^8.4.45",
146
- "tailwindcss": "^3.4.10",
147
- "terser": "^5.31.6",
170
+ "concurrently": "^9.0.1",
171
+ "node-mocks-http": "^1.16.1",
172
+ "postcss": "^8.4.47",
173
+ "tailwindcss": "^3.4.13",
174
+ "terser": "^5.34.1",
148
175
  "tsconfig": "workspace:*",
149
- "tsup": "^8.2.4"
176
+ "tsup": "^8.3.0"
150
177
  },
151
178
  "peerDependencies": {
152
179
  "react": "^18.3.1",
153
180
  "react-dom": "^18.3.1",
154
- "tailwindcss": "^3.4.10"
181
+ "tailwindcss": "^3.4.13"
155
182
  }
156
183
  }
@@ -1,97 +0,0 @@
1
- import { unlink } from 'node:fs';
2
- import path from 'node:path';
3
-
4
- import * as bluebun from 'bluebun';
5
- import { afterEach, beforeAll, beforeEach, describe, expect, it, mock, spyOn } from 'bun:test';
6
- import { IndentationText, Project } from 'ts-morph';
7
-
8
- import { propsToClass } from './propsToClass';
9
- import { sizingPropToClassMap } from './utils/sizingPropToClassMap';
10
-
11
- const FILE_NAME = 'PropsToClass.mock.tsx';
12
- const FILE_BEFORE = `
13
- import { Button, cx, HStack, Text } from '@yahoo/uds';
14
- const textClassName = cx('text-primary');
15
- const otherProps = { height: 'fit' };
16
-
17
- export const PageA = () => {
18
- return (
19
- <HStack width="full" maxHeight="screen">
20
- <Button minWidth="full">Click me</Button>
21
- <Text width="10/12" className={textClassName}>Some text</Text>
22
- <Text {...otherProps}>Some text</Text>
23
- </HStack>
24
- );
25
- }
26
- `.trim();
27
- const FILE_AFTER = `
28
- import { Button, cx, HStack, Text } from '@yahoo/uds';
29
- const textClassName = cx('text-primary');
30
- const otherProps = { height: 'fit' };
31
-
32
- export const PageA = () => {
33
- return (
34
- <HStack className="w-full max-h-screen">
35
- <Button className="min-w-full">Click me</Button>
36
- {/* 🙏 TODO: Add w-10/12 to your className attribute */}
37
- <Text className={textClassName}>Some text</Text>
38
- <Text {...otherProps}>Some text</Text>
39
- </HStack>
40
- );
41
- }
42
- `.trim();
43
-
44
- describe('propsToClass', () => {
45
- const workspaceDir = Bun.env.PWD;
46
- const srcDir = path.join(workspaceDir, 'tsconfig.json');
47
- const project = new Project({
48
- tsConfigFilePath: srcDir,
49
- manipulationSettings: { indentationText: IndentationText.TwoSpaces },
50
- });
51
-
52
- beforeAll(async () => {
53
- // setup mocks
54
- mock.module('bluebun', () => ({ print: () => 'mocked' }));
55
- });
56
-
57
- beforeEach(async () => {
58
- // Setup files
59
- project.createSourceFile(FILE_NAME, FILE_BEFORE, {
60
- overwrite: true,
61
- });
62
- });
63
- afterEach(async () => {
64
- // teardown files
65
- unlink(FILE_NAME, (err) => {
66
- if (err) {
67
- throw err;
68
- }
69
- });
70
- });
71
-
72
- it('converts props to classNames', async () => {
73
- // Sanity check
74
- const fileBefore = project.getSourceFile(FILE_NAME)?.getText();
75
- expect(fileBefore).toEqual(FILE_BEFORE);
76
-
77
- // Apply the codemod
78
- await propsToClass({ propToClassMap: sizingPropToClassMap, project });
79
-
80
- // Confirm it's been transformed
81
- const fileAfter = project.getSourceFile(FILE_NAME)?.getText();
82
- expect(fileAfter).toEqual(FILE_AFTER);
83
- });
84
- it('logs a warning when a complex expression is found', async () => {
85
- // Spy on the bun logger
86
- const spy = spyOn(bluebun, 'print');
87
-
88
- // Apply the codemod
89
- await propsToClass({
90
- propToClassMap: sizingPropToClassMap,
91
- project,
92
- });
93
-
94
- // We print 3 times for each complex expression, and 2 times for each spread expression
95
- expect(spy).toHaveBeenCalledTimes(5);
96
- });
97
- });
@@ -1,210 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { Project } from 'ts-morph';
3
-
4
- import {
5
- getClassesForEnabledThemesAndScales,
6
- getComponentsToConvertToTW,
7
- getFiles,
8
- getTailwindSafelist,
9
- getUsedProps,
10
- isUDSComponent,
11
- parseFiles,
12
- scanGetStylesReferences,
13
- } from './purgeCSS';
14
-
15
- const PAGE_A_CODE = `
16
- import { HStack, Button, getStyles } from '@yahoo/uds';
17
-
18
- const functionWithProp = () => {
19
- const vars = {
20
- isActive: false
21
- };
22
-
23
- return {
24
- ...vars,
25
- color: 'blue'
26
- }
27
- }
28
-
29
- const AnotherComponent = () => {
30
- const propsList = functionWithProp();
31
-
32
- const classNames = getStyles({
33
- borderStartColor: 'primary'
34
- });
35
-
36
- return <HStack testProp="testValue" classNames={classNames} {...propsList}>meow</HStack>
37
- }
38
-
39
- const PageA = () => {
40
- const justifyContent = 'justify-start';
41
- const classNames = getStyles({
42
- justifyContent
43
- });
44
-
45
- return (
46
- <div>
47
- <HStack />
48
- <Button> Click me </Button>
49
- </div>
50
- )
51
- }
52
- `;
53
-
54
- const PAGE_B_CODE = `
55
- import { HStack, Spinner } from '@yahoo/uds';
56
- import { noop } from 'lodash';
57
-
58
- const PageB = () => {
59
- return (
60
- <div>
61
- <HStack flexGrow="1" alignItems="center" justifyContent="center">
62
- <Spinner />
63
- </HStack>
64
- </div>
65
- )
66
- }
67
- `;
68
-
69
- const FILES = ['/pages/PageA.tsx', '/pages/PageB.tsx'];
70
- const IMPORTED_UDS_COMPONENTS = ['HStack', 'Button', 'getStyles', 'Spinner'];
71
-
72
- describe('purgeCSS', () => {
73
- const project = new Project();
74
-
75
- describe('getFiles', () => {
76
- it('returns the list of files', async () => {
77
- const files = await getFiles('./src/');
78
-
79
- expect(files).toEqual(FILES);
80
- });
81
- });
82
-
83
- describe('parseFiles', () => {
84
- it('returns the list of imports from @yahoo/uds', () => {
85
- project.createSourceFile(FILES[0], PAGE_A_CODE, {
86
- overwrite: true,
87
- });
88
- project.createSourceFile(FILES[1], PAGE_B_CODE, {
89
- overwrite: true,
90
- });
91
-
92
- const res = parseFiles(project, FILES);
93
-
94
- expect(res).toEqual(IMPORTED_UDS_COMPONENTS);
95
- });
96
- });
97
-
98
- describe('getTailwindSafelist', () => {
99
- it('returns the tailwind classes required for all the components', () => {
100
- project.createSourceFile(FILES[0], PAGE_A_CODE, {
101
- overwrite: true,
102
- });
103
- project.createSourceFile(FILES[1], PAGE_B_CODE, {
104
- overwrite: true,
105
- });
106
-
107
- const res = getTailwindSafelist(project, IMPORTED_UDS_COMPONENTS);
108
-
109
- expect(res).toEqual([
110
- 'container',
111
- 'fill',
112
- 'items-start',
113
- 'items-center',
114
- 'justify-start',
115
- 'justify-center',
116
- 'text-accent',
117
- 'text-alert',
118
- 'text-black',
119
- 'text-brand',
120
- 'text-positive',
121
- 'text-warning',
122
- 'text-white',
123
- 'text-transparent',
124
- 'text-muted',
125
- 'text-on-color',
126
- 'text-primary',
127
- 'text-secondary',
128
- 'text-tertiary',
129
- 'text-current',
130
- 'border-s-primary',
131
- ]);
132
- });
133
- });
134
-
135
- describe('getComponentsToConvertToTW', () => {
136
- it('should get just exports which are components from UDS', () => {
137
- const res = getComponentsToConvertToTW(['Button', 'HStack', 'randomThingy']);
138
-
139
- expect(res).toEqual(['Button', 'Icon', 'Pressable', 'Text', 'HStack', 'Box']);
140
- });
141
- });
142
-
143
- describe('isUDSComponent', () => {
144
- it('returns true if the component is exported from UDS', () => {
145
- const res = isUDSComponent('HStack');
146
-
147
- expect(res).toBeTrue();
148
- });
149
-
150
- it('returns false if the component is not exported from UDS', () => {
151
- const res = isUDSComponent('NotUdsComponent');
152
-
153
- expect(res).toBeFalse();
154
- });
155
- });
156
-
157
- describe('getUsedProps', () => {
158
- it('return the list of all used props in the project for a given component', () => {
159
- project.createSourceFile(FILES[0], PAGE_A_CODE, {
160
- overwrite: true,
161
- });
162
- project.createSourceFile(FILES[1], PAGE_B_CODE, {
163
- overwrite: true,
164
- });
165
-
166
- const usedProps = getUsedProps(project, 'HStack');
167
-
168
- expect(usedProps).toEqual([
169
- ['testProp', ['testValue']],
170
- ['classNames', []],
171
- ['color', []],
172
- ['isActive', []],
173
- ['flexGrow', ['1']],
174
- ['alignItems', ['center']],
175
- ['justifyContent', ['center']],
176
- ]);
177
- });
178
- });
179
-
180
- describe('getClassesForEnabledThemesAndScales', () => {
181
- it('returns the list of classes related to the mode/themes we have in the config', () => {
182
- const classes = getClassesForEnabledThemesAndScales();
183
-
184
- expect(classes).toEqual([
185
- 'uds-color-mode-dark',
186
- 'uds-color-mode-light',
187
- 'uds-scale-mode-large',
188
- ]);
189
- });
190
- });
191
-
192
- describe('scanGetStylesReferences', () => {
193
- it('should scan the project for getStyles references and return the used variants', () => {
194
- project.createSourceFile(FILES[0], PAGE_A_CODE, {
195
- overwrite: true,
196
- });
197
- project.createSourceFile(FILES[1], PAGE_B_CODE, {
198
- overwrite: true,
199
- });
200
-
201
- const res = scanGetStylesReferences(project);
202
-
203
- const expectedResult = new Map();
204
- expectedResult.set('borderStartColor', new Set(['primary']));
205
- expectedResult.set('justifyContent', new Set([]));
206
-
207
- expect(res).toEqual(expectedResult);
208
- });
209
- });
210
- });