@yahoo/uds 1.7.4 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cli/bin/uds-darwin-arm64-baseline +0 -0
- package/cli/bin/uds-linux-x64-baseline +0 -0
- package/cli/commands/codemod/codemod.ts +12 -9
- package/cli/commands/login.ts +2 -0
- package/cli/commands/logout.ts +3 -0
- package/cli/commands/purge.ts +2 -0
- package/cli/commands/sync.ts +2 -0
- package/cli/commands/uds.ts +2 -0
- package/cli/commands/version.ts +2 -0
- package/cli/tsconfig.json +4 -4
- package/cli/utils/analytics.ts +30 -0
- package/cli/utils/auth.ts +2 -2
- package/dist/analytics/server.cjs +1 -0
- package/dist/analytics/server.d.cts +1 -0
- package/dist/analytics/server.d.ts +1 -0
- package/dist/analytics/server.js +1 -0
- package/dist/chunk-3LHMB72F.cjs +1 -2
- package/dist/chunk-AWEUIM22.cjs +1 -3
- package/dist/chunk-FK7UKIGU.js +2 -0
- package/dist/chunk-FRZFCKD2.js +1 -2
- package/dist/chunk-J6D4HCFT.cjs +1 -2
- package/dist/chunk-LNFRMD6G.cjs +1 -2
- package/dist/chunk-LPM6JKIW.js +1 -2
- package/dist/chunk-PECN66KD.cjs +1 -3
- package/dist/chunk-PSTMMXTR.js +1 -2
- package/dist/chunk-QELQ6JY6.cjs +2 -0
- package/dist/chunk-RGE634O5.js +1 -2
- package/dist/chunk-SSMBE7SI.cjs +1 -2
- package/dist/chunk-VZAZKBYK.cjs +1 -2
- package/dist/chunk-WLOEKYUI.cjs +2 -4
- package/dist/chunk-YRYDHL65.js +1 -2
- package/dist/client/index.cjs +2 -3
- package/dist/client/index.js +3 -5
- package/dist/experimental/index.cjs +2 -3
- package/dist/experimental/index.js +2 -3
- package/dist/fixtures.cjs +1 -1
- package/dist/fixtures.js +1 -1
- package/dist/flags.cjs +1 -0
- package/dist/flags.d.cts +22 -0
- package/dist/flags.d.ts +22 -0
- package/dist/flags.js +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -22
- package/dist/index.d.ts +1 -22
- package/dist/index.js +1 -2
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/tailwind/plugin.cjs +2 -3
- package/dist/tailwind/plugin.js +2 -3
- package/dist/tailwind/purger.cjs +1 -2
- package/dist/tailwind/tsMorph.cjs +1 -3
- package/dist/tailwind/tsMorph.js +1 -2
- package/dist/tokens/index.cjs +1 -1
- package/dist/tokens/index.js +1 -1
- package/package.json +23 -3
- package/cli/codemods/propsToClass.test.tsx +0 -97
- package/cli/utils/auth.test.ts +0 -202
- package/cli/utils/purgeCSS.test.ts +0 -210
- package/dist/chunk-KEQTRKKF.js +0 -3
- package/dist/chunk-RILYWBPB.cjs +0 -1
@@ -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
|
-
});
|
package/dist/chunk-KEQTRKKF.js
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
import{normalIconSizes as e}from"./chunk-YRYDHL65.js";import{variants as r}from"./chunk-RGE634O5.js";import{lineColors as t,borderWidths as n,borderRadii as o,foregroundColors as s,spectrumColors as c,backgroundColors as i,textVariants as l}from"@yahoo/uds/fixtures";import a from"clsx";import u from"imurmurhash";import{extendTailwindMerge as f}from"tailwind-merge";import{forwardRef as m,Children as d,isValidElement as p,cloneElement as h}from"react";import{jsx as y}from"react/jsx-runtime";
|
2
|
-
/*! © 2024 Yahoo, Inc. UDS v0.0.0-development */
|
3
|
-
var v="undefined"!=typeof process,b={useGetStylesCache:!!v&&"true"===process.env.NEXT_PUBLIC_UDS_FEATURE_USE_STYLE_CACHE,useCLIAuth:!!v&&"true"===process.env.UDS_FEATURE_ENABLE_CLI_AUTH},g=e=>b={...b,...e},E=()=>b;function N(e){return"boolean"==typeof e?`${e}`:0===e?"0":e}function x(e){const r=Object.create(null),t=Object.keys(e);for(let n=0,o=t.length;n<o;n++){const o=t[n];void 0!==e[o]&&(r[o]=e[o])}return r}var C=f({extend:{theme:{borderColor:t,borderWidth:n,borderRadius:o}},override:{classGroups:{"text-color":[{text:[...s,...c]}],"bg-color":[{bg:i}],"font-family":[{font:["icons",...l]}],leading:[{leading:l}]},conflictingClassGroups:{}}}),_=(...e)=>{const r=a(e);return C(r)},j=e=>r=>{if(!e?.variants)return _(e?.base,r?.className);const{variants:t,defaultVariants:n}=e,o=Object.keys(t).map((e=>{const o=r?.[e],s=n?.[e],c=N(o)||N(s);return t[e][c]})),s={...n,...r&&x(r)},c=e?.compoundVariants?.reduce(((e,{className:r,...t})=>Object.entries(t).every((([e,r])=>s[e]===r))?_(e,r):e),"");return _(e?.base,o,c,r?.className)},w=j({variants:r}),S=new Map,A=e=>{const{useGetStylesCache:r}=E();if(r){const r=function(e){const r=Object.create(null),t=Object.keys(e).sort();for(let n=0,o=t.length;n<o;n++){const o=t[n];r[o]=e[o]}return r}(x(e)),t=(new u).hash(JSON.stringify(r)).result();if(S.has(t))return S.get(t);const n=w(r);return S.set(t,n),n}return w(e)},O=m((function({name:r,size:t="md",variant:n="outline",color:o="primary",className:s,...c},i){const l=A({color:o,flex:"none",className:s}),a=e[t];return y("svg",{ref:i,xmlns:"http://www.w3.org/2000/svg",width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":"true",focusable:"false",className:l,...c,children:y(r,{size:t,variant:n})})}));function U(...e){return r=>e.forEach((e=>function(e,r){"function"==typeof e?e(r):null!=e&&(e.current=r)}(e,r)))}function L(){const e=m(((e,t)=>{const{children:o,...s}=e,c=d.toArray(o),i=c.find(n);if(i){const e=i.props.children,n=c.map((r=>r===i?d.count(e)>1?d.only(null):p(e)?e.props.children:null:r));return y(r,{...s,ref:t,children:p(e)?h(e,void 0,n):null})}return y(r,{...s,ref:t,children:o})}));e.displayName="Slot";const r=m(((e,r)=>{const{children:t,...n}=e;return p(t)?h(t,{...o(n,t.props),ref:r?U(r,t.ref):t.ref}):d.count(t)>1?d.only(null):null}));r.displayName="SlotClone";const t=({children:e})=>e;function n(e){return p(e)&&e.type===t}function o(e,r){const t={...r};for(const n in r){const o=e[n],s=r[n];/^on[A-Z]/.test(n)?o&&s?t[n]=(...e)=>{s(...e),o(...e)}:o&&(t[n]=o):"style"===n&&(t[n]={...o,...s})}return{...e,...t}}return e}export{O as Icon,L as createSlot,j as cva,_ as cx,E as getFeatureFlags,A as getStyles,g as updateFeatureFlags};
|
package/dist/chunk-RILYWBPB.cjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";var e=require("./chunk-WLOEKYUI.cjs"),r=require("./chunk-LNFRMD6G.cjs"),t=require("@yahoo/uds/fixtures"),n=require("clsx"),s=require("imurmurhash"),o=require("tailwind-merge"),l=require("react"),i=require("react/jsx-runtime");function a(e){return e&&e.__esModule?e:{default:e}}var c=a(n),u=a(s),d="undefined"!=typeof process,f={useGetStylesCache:!!d&&"true"===process.env.NEXT_PUBLIC_UDS_FEATURE_USE_STYLE_CACHE,useCLIAuth:!!d&&"true"===process.env.UDS_FEATURE_ENABLE_CLI_AUTH},h=()=>f;function p(e){return"boolean"==typeof e?`${e}`:0===e?"0":e}function m(e){const r=Object.create(null),t=Object.keys(e);for(let n=0,s=t.length;n<s;n++){const s=t[n];void 0!==e[s]&&(r[s]=e[s])}return r}var x=o.extendTailwindMerge({extend:{theme:{borderColor:t.lineColors,borderWidth:t.borderWidths,borderRadius:t.borderRadii}},override:{classGroups:{"text-color":[{text:[...t.foregroundColors,...t.spectrumColors]}],"bg-color":[{bg:t.backgroundColors}],"font-family":[{font:["icons",...t.textVariants]}],leading:[{leading:t.textVariants}]},conflictingClassGroups:{}}}),g=(...e)=>{const r=c.default(e);return x(r)},y=e=>r=>{if(!e?.variants)return g(e?.base,r?.className);const{variants:t,defaultVariants:n}=e,s=Object.keys(t).map((e=>{const s=r?.[e],o=n?.[e],l=p(s)||p(o);return t[e][l]})),o={...n,...r&&m(r)},l=e?.compoundVariants?.reduce(((e,{className:r,...t})=>Object.entries(t).every((([e,r])=>o[e]===r))?g(e,r):e),"");return g(e?.base,s,l,r?.className)},v=y({variants:r.variants}),C=new Map,b=e=>{const{useGetStylesCache:r}=h();if(r){const r=function(e){const r=Object.create(null),t=Object.keys(e).sort();for(let n=0,s=t.length;n<s;n++){const s=t[n];r[s]=e[s]}return r}(m(e)),t=(new u.default).hash(JSON.stringify(r)).result();if(C.has(t))return C.get(t);const n=v(r);return C.set(t,n),n}return v(e)},E=l.forwardRef((function({name:r,size:t="md",variant:n="outline",color:s="primary",className:o,...l},a){const c=b({color:s,flex:"none",className:o}),u=e.normalIconSizes[t];return i.jsx("svg",{ref:a,xmlns:"http://www.w3.org/2000/svg",width:u,height:u,viewBox:`0 0 ${u} ${u}`,"aria-hidden":"true",focusable:"false",className:c,...l,children:i.jsx(r,{size:t,variant:n})})}));function j(...e){return r=>e.forEach((e=>function(e,r){"function"==typeof e?e(r):null!=e&&(e.current=r)}(e,r)))}exports.Icon=E,exports.createSlot=function(){const e=l.forwardRef(((e,t)=>{const{children:s,...o}=e,a=l.Children.toArray(s),c=a.find(n);if(c){const e=c.props.children,n=a.map((r=>r===c?l.Children.count(e)>1?l.Children.only(null):l.isValidElement(e)?e.props.children:null:r));return i.jsx(r,{...o,ref:t,children:l.isValidElement(e)?l.cloneElement(e,void 0,n):null})}return i.jsx(r,{...o,ref:t,children:s})}));e.displayName="Slot";const r=l.forwardRef(((e,r)=>{const{children:t,...n}=e;return l.isValidElement(t)?l.cloneElement(t,{...s(n,t.props),ref:r?j(r,t.ref):t.ref}):l.Children.count(t)>1?l.Children.only(null):null}));r.displayName="SlotClone";const t=({children:e})=>e;function n(e){return l.isValidElement(e)&&e.type===t}function s(e,r){const t={...r};for(const n in r){const s=e[n],o=r[n];/^on[A-Z]/.test(n)?s&&o?t[n]=(...e)=>{o(...e),s(...e)}:s&&(t[n]=s):"style"===n&&(t[n]={...s,...o})}return{...e,...t}}return e},exports.cva=y,exports.cx=g,exports.getFeatureFlags=h,exports.getStyles=b,exports.updateFeatureFlags=e=>f={...f,...e};
|