@atlaskit/codemod-cli 0.9.6 → 0.10.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.
@@ -13,11 +13,13 @@ require("./styled-to-emotion/styled-to-emotion");
13
13
 
14
14
  require("./theme-to-design-tokens/theme-to-design-tokens");
15
15
 
16
+ require("./css-to-design-tokens/css-to-design-tokens");
17
+
16
18
  /**
17
19
  * Manually import presets to make sure typescript includes them
18
20
  * in the final bundle
19
21
  */
20
- var presets = ['styled-to-emotion', 'theme-to-design-tokens'].map(function (preset) {
22
+ var presets = ['styled-to-emotion', 'theme-to-design-tokens', 'css-to-design-tokens'].map(function (preset) {
21
23
  return _path.default.join(__dirname, preset, "".concat(preset, ".@(ts|js|tsx)"));
22
24
  });
23
25
  var _default = presets;
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.9.6"
3
+ "version": "0.10.1"
4
4
  }
@@ -0,0 +1,176 @@
1
+ import postcss from 'postcss'; // @ts-ignore
2
+
3
+ import lessSyntax from 'postcss-less';
4
+ import designTokens from '@atlaskit/tokens/token-names';
5
+ import renameMapping from '@atlaskit/tokens/rename-mapping';
6
+ import Search from '../theme-to-design-tokens/utils/fuzzy-search';
7
+ import { knownVariables, knownColors, knownRawColors } from './utils/legacy-colors';
8
+ import { cleanMeta } from './utils/meta';
9
+ const tokens = Object.keys(designTokens).filter(t => !t.includes('UNSAFE') && !t.includes('interaction')).filter(t => !renameMapping.find(({
10
+ path
11
+ }) => t === path.replace(/\.[default]\g/, '')));
12
+ const search = Search(tokens, false);
13
+
14
+ function isRule(node) {
15
+ return node.type === 'rule';
16
+ }
17
+
18
+ function getParentSelectors(node) {
19
+ if (isRule(node)) {
20
+ // @ts-expect-error
21
+ return getParentSelectors(node.parent) + ' ' + node.selector;
22
+ }
23
+
24
+ if (node.parent) {
25
+ return getParentSelectors(node.parent);
26
+ }
27
+
28
+ return '';
29
+ }
30
+
31
+ function stripVar(prop) {
32
+ return prop.substring(prop.indexOf('(') + 1).split(/\,|\)/)[0];
33
+ }
34
+
35
+ function stripLessVar(prop) {
36
+ return prop.substring(1);
37
+ }
38
+
39
+ function isColorProperty(prop) {
40
+ return prop === 'color' || prop === 'background' || prop === 'background-color' || prop === 'box-shadow' || prop === 'border' || prop === 'border-left' || prop === 'border-right' || prop === 'border-top' || prop === 'border-bottom' || prop === 'border-color';
41
+ }
42
+
43
+ function getDeclarationMeta(decl) {
44
+ if (decl.prop === 'color') {
45
+ return 'text';
46
+ }
47
+
48
+ if (decl.prop.startsWith('background')) {
49
+ return 'background';
50
+ }
51
+
52
+ if (decl.prop.includes('shadow')) {
53
+ return 'shadow';
54
+ }
55
+
56
+ if (decl.prop.includes('border')) {
57
+ return 'border';
58
+ }
59
+
60
+ return '';
61
+ }
62
+
63
+ function isDesignToken(tokenName) {
64
+ return Boolean(Object.entries(designTokens).find(([_, value]) => tokenName === value));
65
+ }
66
+
67
+ function getMetaFromCssVar(tokenName) {
68
+ const meta = knownVariables[tokenName];
69
+
70
+ if (!meta || meta.length === 0) {
71
+ return tokenName.split('-');
72
+ }
73
+
74
+ return meta;
75
+ }
76
+
77
+ function getMetaFromRawColor(rawColor) {
78
+ let cleanColor = rawColor.toLowerCase();
79
+
80
+ if (cleanColor.length === 4) {
81
+ cleanColor = cleanColor + cleanColor.substring(cleanColor.indexOf('#') + 1);
82
+ }
83
+
84
+ return knownRawColors[cleanColor];
85
+ } // https://github.com/postcss/postcss/blob/main/docs/writing-a-plugin.md
86
+ // https://astexplorer.net/#/2uBU1BLuJ1
87
+
88
+
89
+ const plugin = () => {
90
+ const processed = Symbol('processed');
91
+ return {
92
+ postcssPlugin: 'UsingTokens',
93
+ Declaration: decl => {
94
+ // @ts-expect-error
95
+ if (decl[processed]) {
96
+ return;
97
+ }
98
+
99
+ if (!isColorProperty(decl.prop)) {
100
+ return;
101
+ }
102
+
103
+ const searchTerms = [getDeclarationMeta(decl), ...getParentSelectors(decl).split(/\-|\.|\,|\ |\:|\&/).filter(el => !!el)];
104
+ let match;
105
+ const cssVarRe = /var\([^\)]+\)/g;
106
+ const lessVarRe = /@[a-zA-Z0-9-]+/g;
107
+ const rawColorRe = /(#([0-9a-f]{3}){1,2}|(rgba|hsla)\(\d{1,3}%?(,\s?\d{1,3}%?){2},\s?(1|0|0?\.\d+)\)|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?){2}\))/i; // CSS variables
108
+
109
+ const cssVarMatch = decl.value.match(cssVarRe);
110
+
111
+ if (cssVarMatch) {
112
+ var _getMetaFromCssVar;
113
+
114
+ match = cssVarMatch[0];
115
+
116
+ if (isDesignToken(stripVar(match))) {
117
+ return;
118
+ }
119
+
120
+ searchTerms.push(...((_getMetaFromCssVar = getMetaFromCssVar(stripVar(match))) !== null && _getMetaFromCssVar !== void 0 ? _getMetaFromCssVar : []));
121
+ } // Less variables
122
+
123
+
124
+ const lassVarMatch = decl.value.match(lessVarRe);
125
+
126
+ if (lassVarMatch) {
127
+ var _getMetaFromCssVar2;
128
+
129
+ match = lassVarMatch[0];
130
+ searchTerms.push(...((_getMetaFromCssVar2 = getMetaFromCssVar(`--${stripLessVar(match)}`)) !== null && _getMetaFromCssVar2 !== void 0 ? _getMetaFromCssVar2 : []));
131
+ } // Raw colors
132
+
133
+
134
+ const rawColorMatch = decl.value.match(rawColorRe);
135
+
136
+ if (rawColorMatch) {
137
+ var _getMetaFromRawColor;
138
+
139
+ match = rawColorMatch[0];
140
+ searchTerms.push(...((_getMetaFromRawColor = getMetaFromRawColor(match)) !== null && _getMetaFromRawColor !== void 0 ? _getMetaFromRawColor : []));
141
+ } // Named colors
142
+
143
+
144
+ if (knownColors.hasOwnProperty(decl.value)) {
145
+ var _knownColors$decl$val;
146
+
147
+ match = decl.value;
148
+ searchTerms.push(...((_knownColors$decl$val = knownColors[decl.value.toLowerCase()]) !== null && _knownColors$decl$val !== void 0 ? _knownColors$decl$val : []));
149
+ }
150
+
151
+ if (!match) {
152
+ console.warn(`Unable to find match for declaration: ${decl.prop}: ${decl.value}`);
153
+ return;
154
+ }
155
+
156
+ const cleanSearchTerms = cleanMeta(searchTerms).join(' ');
157
+ const results = search.get(cleanSearchTerms);
158
+ const replacement = results ? results.map(result => result[1]) : ['utility.UNSAFE_util.MISSING_TOKEN'];
159
+
160
+ if (decl.prop === 'box-shadow') {
161
+ decl.value = `var(${designTokens[replacement[0]]}, ${decl.value})`;
162
+ } else {
163
+ decl.value = decl.value.split(match).join(`var(${designTokens[replacement[0]]}, ${match})`);
164
+ } // @ts-expect-error
165
+
166
+
167
+ decl[processed] = true;
168
+ }
169
+ };
170
+ };
171
+
172
+ export default async function transformer(file) {
173
+ return await postcss([plugin()]).process(file.source, {
174
+ syntax: lessSyntax
175
+ }).css;
176
+ }
@@ -0,0 +1,334 @@
1
+ export const knownVariables = {
2
+ '--adg3-color-R50': ['danger'],
3
+ '--adg3-color-R75': ['danger'],
4
+ '--adg3-color-R100': ['danger'],
5
+ '--adg3-color-R200': ['danger'],
6
+ '--adg3-color-R300': ['danger'],
7
+ '--adg3-color-R400': ['danger'],
8
+ '--adg3-color-R500': ['danger'],
9
+ '--adg3-color-Y50': ['warning'],
10
+ '--adg3-color-Y75': ['warning'],
11
+ '--adg3-color-Y100': ['warning'],
12
+ '--adg3-color-Y200': ['warning'],
13
+ '--adg3-color-Y300': ['warning'],
14
+ '--adg3-color-Y400': ['warning'],
15
+ '--adg3-color-Y500': ['warning'],
16
+ '--adg3-color-G50': ['success'],
17
+ '--adg3-color-G75': ['success'],
18
+ '--adg3-color-G100': ['success'],
19
+ '--adg3-color-G200': ['success'],
20
+ '--adg3-color-G300': ['success'],
21
+ '--adg3-color-G400': ['success'],
22
+ '--adg3-color-G500': ['success'],
23
+ '--adg3-color-B50': ['brand'],
24
+ '--adg3-color-B75': ['brand'],
25
+ '--adg3-color-B100': ['brand'],
26
+ '--adg3-color-B200': ['brand'],
27
+ '--adg3-color-B300': ['brand'],
28
+ '--adg3-color-B400': ['brand'],
29
+ '--adg3-color-B500': ['brand'],
30
+ '--adg3-color-P50': ['discovery'],
31
+ '--adg3-color-P75': ['discovery'],
32
+ '--adg3-color-P100': ['discovery'],
33
+ '--adg3-color-P200': ['discovery'],
34
+ '--adg3-color-P300': ['discovery'],
35
+ '--adg3-color-P400': ['discovery'],
36
+ '--adg3-color-P500': ['discovery'],
37
+ '--adg3-color-T50': ['accent', 'teal'],
38
+ '--adg3-color-T75': ['accent', 'teal'],
39
+ '--adg3-color-T100': ['accent', 'teal'],
40
+ '--adg3-color-T200': ['accent', 'teal'],
41
+ '--adg3-color-T300': ['accent', 'teal'],
42
+ '--adg3-color-T400': ['accent', 'teal'],
43
+ '--adg3-color-T500': ['accent', 'teal'],
44
+ '--adg3-color-N0': ['inverse'],
45
+ '--adg3-color-N10': [],
46
+ '--adg3-color-N20': [],
47
+ '--adg3-color-N30': [],
48
+ '--adg3-color-N40': [],
49
+ '--adg3-color-N50': [],
50
+ '--adg3-color-N60': [],
51
+ '--adg3-color-N70': [],
52
+ '--adg3-color-N80': [],
53
+ '--adg3-color-N90': [],
54
+ '--adg3-color-N100': [],
55
+ '--adg3-color-N200': ['text', 'subtlest'],
56
+ '--adg3-color-N300': [],
57
+ '--adg3-color-N400': ['text', 'subtle'],
58
+ '--adg3-color-N500': [],
59
+ '--adg3-color-N600': [],
60
+ '--adg3-color-N700': ['text'],
61
+ '--adg3-color-N800': ['text'],
62
+ '--adg3-color-N900': ['text'],
63
+ '--adg3-color-N10A': [],
64
+ '--adg3-color-N20A': [],
65
+ '--adg3-color-N30A': [],
66
+ '--adg3-color-N40A': [],
67
+ '--adg3-color-N50A': [],
68
+ '--adg3-color-N60A': [],
69
+ '--adg3-color-N70A': [],
70
+ '--adg3-color-N80A': [],
71
+ '--adg3-color-N90A': [],
72
+ '--adg3-color-N100A': [],
73
+ '--adg3-color-N200A': [],
74
+ '--adg3-color-N300A': [],
75
+ '--adg3-color-N400A': [],
76
+ '--adg3-color-N500A': [],
77
+ '--adg3-color-N600A': [],
78
+ '--adg3-color-N700A': [],
79
+ '--adg3-color-N800A': [],
80
+ '--adg3-color-DN900': [],
81
+ '--adg3-color-DN800': [],
82
+ '--adg3-color-DN700': [],
83
+ '--adg3-color-DN600': [],
84
+ '--adg3-color-DN500': [],
85
+ '--adg3-color-DN400': [],
86
+ '--adg3-color-DN300': [],
87
+ '--adg3-color-DN200': [],
88
+ '--adg3-color-DN100': [],
89
+ '--adg3-color-DN90': [],
90
+ '--adg3-color-DN80': [],
91
+ '--adg3-color-DN70': [],
92
+ '--adg3-color-DN60': [],
93
+ '--adg3-color-DN50': [],
94
+ '--adg3-color-DN40': [],
95
+ '--adg3-color-DN30': [],
96
+ '--adg3-color-DN20': [],
97
+ '--adg3-color-DN10': [],
98
+ '--adg3-color-DN0': [],
99
+ '--adg3-color-DN800A': [],
100
+ '--adg3-color-DN700A': [],
101
+ '--adg3-color-DN600A': [],
102
+ '--adg3-color-DN500A': [],
103
+ '--adg3-color-DN400A': [],
104
+ '--adg3-color-DN300A': [],
105
+ '--adg3-color-DN200A': [],
106
+ '--adg3-color-DN100A': [],
107
+ '--adg3-color-DN90A': [],
108
+ '--adg3-color-DN80A': [],
109
+ '--adg3-color-DN70A': [],
110
+ '--adg3-color-DN60A': [],
111
+ '--adg3-color-DN50A': [],
112
+ '--adg3-color-DN40A': [],
113
+ '--adg3-color-DN30A': [],
114
+ '--adg3-color-DN20A': [],
115
+ '--adg3-color-DN10A': [],
116
+ '--adg3-color-background-light': ['elevation', 'surface'],
117
+ '--adg3-color-background-dark': ['elevation', 'surface'],
118
+ '--adg3-color-text-light': ['text'],
119
+ '--adg3-color-text-dark': ['text'],
120
+ '--adg3-color-subtleText-light': ['text', 'subtle'],
121
+ '--adg3-color-subtleText-dark': ['text', 'subtle'],
122
+ '--adg3-color-placeholderText-light': ['text', 'subtlest'],
123
+ '--adg3-color-placeholderText-dark': ['text', 'subtlest'],
124
+ '--adg3-color-heading-light': ['text'],
125
+ '--adg3-color-heading-dark': ['text'],
126
+ '--adg3-color-subtleHeading-light': ['text', 'subtle'],
127
+ '--adg3-color-subtleHeading-dark': ['text', 'subtle'],
128
+ '--adg3-color-codeBlock-light': ['elevation', 'surface', 'sunken'],
129
+ '--adg3-color-codeBlock-dark': ['elevation', 'surface', 'sunken'],
130
+ '--adg3-color-link-light': ['link'],
131
+ '--adg3-color-link-dark': ['link'],
132
+ '--adg3-color-linkHover-light': ['link'],
133
+ '--adg3-color-linkHover-dark': ['link'],
134
+ '--adg3-color-linkActive-light': ['link', 'pressed'],
135
+ '--adg3-color-linkActive-dark': ['link', 'pressed'],
136
+ '--adg3-color-linkOutline-light': ['link', 'focused'],
137
+ '--adg3-color-linkOutline-dark': ['link', 'focused'],
138
+ '--adg3-color-primary-light': ['brand'],
139
+ '--adg3-color-primary-dark': ['brand'],
140
+ '--adg3-color-blue-light': ['accent', 'subtler', 'blue'],
141
+ '--adg3-color-blue-dark': ['accent', 'bolder', 'blue'],
142
+ '--adg3-color-teal-light': ['accent', 'subtler', 'teal'],
143
+ '--adg3-color-teal-dark': ['accent', 'bolder', 'teal'],
144
+ '--adg3-color-purple-light': ['accent', 'subtler', 'purple'],
145
+ '--adg3-color-purple-dark': ['accent', 'bolder', 'purple'],
146
+ '--adg3-color-red-light': ['accent', 'subtler', 'red'],
147
+ '--adg3-color-red-dark': ['accent', 'bolder', 'red'],
148
+ '--adg3-color-yellow-light': ['accent', 'subtler', 'yellow'],
149
+ '--adg3-color-yellow-dark': ['accent', 'bolder', 'yellow'],
150
+ '--adg3-color-green-light': ['accent', 'subtler', 'green'],
151
+ '--adg3-color-green-dark': ['accent', 'bolder', 'green'],
152
+ '--adg3-color-N20-transparent': [],
153
+
154
+ /* Alias variables */
155
+ '--jpo-theme-color': ['brand'],
156
+ '--jpo-text-default-color': ['text'],
157
+ '--jpo-text-secondary-color': ['text', 'subtle'],
158
+ '--jpo-text-muted-color': ['text', 'disabled'],
159
+ '--jpo-text-error-color': ['text', 'danger'],
160
+ '--jpo-bg-default-color': ['elevation', 'surface'],
161
+ '--jpo-bg-reverse-color': ['background', 'inverse'],
162
+ '--jpo-bg-warning-color': ['background', 'warning', 'subtle'],
163
+ '--jpo-bg-dark-color': ['background', 'netural', 'bold'],
164
+ '--jpo-border-default-color': ['border'],
165
+ '--jpo-border-secondary-color': ['border', 'subtle']
166
+ };
167
+ export const knownColors = {
168
+ aliceblue: ['blue'],
169
+ antiquewhite: [],
170
+ aqua: ['teal'],
171
+ aquamarine: ['teal'],
172
+ azure: ['teal', 'subtlest'],
173
+ beige: [],
174
+ bisque: [],
175
+ black: [],
176
+ blanchedalmond: [],
177
+ blue: ['blue'],
178
+ blueviolet: ['blue'],
179
+ brown: [],
180
+ burlywood: [],
181
+ cadetblue: ['blue'],
182
+ chartreuse: [],
183
+ chocolate: [],
184
+ coral: [],
185
+ cornflowerblue: ['blue'],
186
+ cornsilk: [],
187
+ crimson: ['accent', 'red'],
188
+ cyan: ['accent', 'teal', 'subtle'],
189
+ darkblue: ['accent', 'blue', 'bold'],
190
+ darkcyan: ['accent', 'teal', 'bold'],
191
+ darkgoldenrod: [],
192
+ darkgray: [],
193
+ darkgrey: [],
194
+ darkgreen: ['green'],
195
+ darkkhaki: [],
196
+ darkmagenta: ['magenta', 'bold'],
197
+ darkolivegreen: ['green'],
198
+ darkorange: [],
199
+ darkorchid: [],
200
+ darkred: ['accent', 'red', 'bold'],
201
+ darksalmon: [],
202
+ darkseagreen: ['green'],
203
+ darkslateblue: [],
204
+ darkslategray: [],
205
+ darkslategrey: [],
206
+ darkturquoise: ['teal', 'bold'],
207
+ darkviolet: ['purple', 'bold'],
208
+ deeppink: ['magenta'],
209
+ deepskyblue: ['blue'],
210
+ dimgray: [],
211
+ dimgrey: [],
212
+ dodgerblue: [],
213
+ firebrick: ['red', 'bold'],
214
+ floralwhite: [],
215
+ forestgreen: ['green'],
216
+ fuchsia: ['magenta', 'subtle'],
217
+ gainsboro: [],
218
+ ghostwhite: [],
219
+ gold: ['yellow'],
220
+ goldenrod: [],
221
+ gray: [],
222
+ grey: [],
223
+ green: ['green'],
224
+ greenyellow: [],
225
+ honeydew: [],
226
+ hotpink: ['magenta'],
227
+ indianred: [],
228
+ indigo: ['purple'],
229
+ ivory: [],
230
+ khaki: [],
231
+ lavender: ['purple'],
232
+ lavenderblush: ['purple'],
233
+ lawngreen: ['green'],
234
+ lemonchiffon: [],
235
+ lightblue: [],
236
+ lightcoral: [],
237
+ lightcyan: [],
238
+ lightgoldenrodyellow: [],
239
+ lightgray: [],
240
+ lightgrey: [],
241
+ lightgreen: ['green'],
242
+ lightpink: ['magenta'],
243
+ lightsalmon: ['pink', 'subtler'],
244
+ lightseagreen: ['green'],
245
+ lightskyblue: ['blue'],
246
+ lightslategray: [],
247
+ lightslategrey: [],
248
+ lightsteelblue: ['blue'],
249
+ lightyellow: [],
250
+ lime: ['green', 'subtler'],
251
+ limegreen: ['green'],
252
+ linen: [],
253
+ magenta: ['magenta'],
254
+ maroon: [],
255
+ mediumaquamarine: [],
256
+ mediumblue: [],
257
+ mediumorchid: [],
258
+ mediumpurple: [],
259
+ mediumseagreen: ['green'],
260
+ mediumslateblue: [],
261
+ mediumspringgreen: ['green'],
262
+ mediumturquoise: [],
263
+ mediumvioletred: [],
264
+ midnightblue: [],
265
+ mintcream: [],
266
+ mistyrose: [],
267
+ moccasin: [],
268
+ navajowhite: [],
269
+ navy: ['blue', 'bold'],
270
+ oldlace: [],
271
+ olive: [],
272
+ olivedrab: [],
273
+ orange: [],
274
+ orangered: [],
275
+ orchid: ['purple'],
276
+ palegoldenrod: [],
277
+ palegreen: ['green'],
278
+ paleturquoise: [],
279
+ palevioletred: [],
280
+ papayawhip: [],
281
+ peachpuff: [],
282
+ peru: [],
283
+ pink: ['magenta'],
284
+ plum: [],
285
+ powderblue: ['blue', 'subtle'],
286
+ purple: ['purple'],
287
+ red: ['accent', 'red', 'subtle'],
288
+ rosybrown: [],
289
+ royalblue: [],
290
+ saddlebrown: [],
291
+ salmon: [],
292
+ sandybrown: [],
293
+ seagreen: ['green'],
294
+ seashell: [],
295
+ sienna: [],
296
+ silver: [],
297
+ skyblue: ['blue', 'subtlest'],
298
+ slateblue: [],
299
+ slategray: [],
300
+ slategrey: [],
301
+ snow: [],
302
+ springgreen: ['green'],
303
+ steelblue: ['blue'],
304
+ tan: [],
305
+ teal: ['accent', 'teal'],
306
+ thistle: [],
307
+ tomato: ['red'],
308
+ turquoise: [],
309
+ violet: ['purple'],
310
+ wheat: [],
311
+ white: ['elevation', 'surface'],
312
+ whitesmoke: [],
313
+ yellow: ['yellow'],
314
+ yellowgreen: ['yellow']
315
+ };
316
+ export const knownRawColors = {
317
+ '#000000': ['text'],
318
+ '#cccccc': ['border'],
319
+ '#aaaaaa': ['border'],
320
+ '#bbbbbb': ['border'],
321
+ '#ffffff': ['elevation', 'surface'],
322
+ '#f0f0f0': ['elevation', 'surface'],
323
+ '#eeeeee': ['elevation', 'surface', 'sunken'],
324
+ '#ff0000': ['danger'],
325
+ '#d04437': ['danger'],
326
+ '#c00c00': ['danger'],
327
+ '#5243aa': ['discovery'],
328
+ '#ffc712': ['warning'],
329
+ '#292929': ['text'],
330
+ '#00f00f': ['brand'],
331
+ '#3b73af': ['brand'],
332
+ '#326ca6': ['brand'],
333
+ '#0052cc': ['brand']
334
+ };
@@ -0,0 +1,39 @@
1
+ import designTokens from '@atlaskit/tokens/token-names';
2
+ const getUniqueWordsFromTokens = Object.keys(designTokens).reduce((accum, val) => [...accum, ...val.split('.')], []).reduce((accum, val) => [...accum, ...val.split(/(?=[A-Z])/g).map(e => e.toLowerCase())], []).reduce((accum, val) => {
3
+ if (!accum.includes(val)) {
4
+ accum.push(val);
5
+ }
6
+
7
+ return accum;
8
+ }, []);
9
+
10
+ function filterDuplciateFoundations(meta) {
11
+ const foundations = ['text', 'background', 'shadow', 'border'];
12
+ let hasFoundation = false;
13
+ return meta.filter(val => {
14
+ if (!hasFoundation && foundations.includes(val)) {
15
+ hasFoundation = true;
16
+ return true;
17
+ }
18
+
19
+ if (hasFoundation && foundations.includes(val)) {
20
+ return false;
21
+ }
22
+
23
+ return true;
24
+ });
25
+ }
26
+
27
+ export function cleanMeta(meta) {
28
+ const cleanMeta = meta.reduce((accum, val) => [...accum, ...(typeof val === 'string' ? val.split(/(?=[A-Z])/g).map(e => e.toLowerCase()) : [])], []).reduce((accum, val) => {
29
+ accum.push(val.replace(/:/g, '').replace(/,/g, '').replace('grey', 'neutral').replace('texts', 'text').replace('red', 'danger').replace('error', 'danger').replace('invalid', 'danger').replace('removed', 'danger').replace('removal', 'danger').replace('remove', 'danger').replace('focus', 'focused').replace('valid', 'success').replace('successful', 'success').replace('risk', 'warning').replace('caution', 'warning').replace('warn', 'warning').replace('primary', 'bold').replace('info', 'bold').replace('secondary', 'subtle').replace('hyperlink', 'link').replace('anchor', 'link').replace('active', 'pressed').replace('hover', 'hovered').replace('dragged', 'overlay').replace('dragging', 'overlay').replace('drag', 'overlay').replace('background-color', 'background').replace('color', 'text').replace('icons', 'icon').replace('arrow', 'icon').replace('glyph', 'icon').replace('stroke', 'border').replace('border-left', 'border').replace('border-right', 'border').replace('border-top', 'border').replace('border-bottom', 'border').replace('box-shadow', 'shadow'));
30
+ return accum;
31
+ }, []).filter(val => getUniqueWordsFromTokens.includes(val)).reduce((accum, val) => {
32
+ if (!accum.includes(val)) {
33
+ accum.push(val);
34
+ }
35
+
36
+ return accum;
37
+ }, []);
38
+ return filterDuplciateFoundations(cleanMeta);
39
+ }
@@ -6,5 +6,6 @@ import path from 'path';
6
6
 
7
7
  import './styled-to-emotion/styled-to-emotion';
8
8
  import './theme-to-design-tokens/theme-to-design-tokens';
9
- const presets = ['styled-to-emotion', 'theme-to-design-tokens'].map(preset => path.join(__dirname, preset, `${preset}.@(ts|js|tsx)`));
9
+ import './css-to-design-tokens/css-to-design-tokens';
10
+ const presets = ['styled-to-emotion', 'theme-to-design-tokens', 'css-to-design-tokens'].map(preset => path.join(__dirname, preset, `${preset}.@(ts|js|tsx)`));
10
11
  export default presets;
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.9.6"
3
+ "version": "0.10.1"
4
4
  }
package/dist/esm/cli.js CHANGED
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import meow from 'meow';
4
4
  import { ValidationError, NoTransformsExistError } from './types';
5
5
  import main from './main';
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { glob } from 'glob';
4
4
  import { promises } from 'fs';
5
5
  var readFile = promises.readFile;
package/dist/esm/main.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
4
 
@@ -9,6 +8,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
9
8
 
10
9
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
11
10
 
11
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
12
+
12
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
14
 
14
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -364,7 +365,7 @@ function _main() {
364
365
  case 4:
365
366
  _yield$parseArgs = _context5.sent;
366
367
  packages = _yield$parseArgs.packages;
367
- _process$env$_PACKAGE = "0.9.6", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
368
+ _process$env$_PACKAGE = "0.10.1", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
368
369
  logger.log(chalk.bgBlue(chalk.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
369
370
 
370
371
  if (packages && packages.length > 0) {