@atlaskit/codemod-cli 0.8.0 → 0.8.4

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +12 -2
  3. package/dist/cjs/cli.js +3 -2
  4. package/dist/cjs/index.js +4 -4
  5. package/dist/cjs/main.js +6 -4
  6. package/dist/cjs/presets/index.js +4 -2
  7. package/dist/cjs/presets/theme-to-design-tokens/theme-to-design-tokens.js +181 -0
  8. package/dist/cjs/presets/theme-to-design-tokens/types.js +5 -0
  9. package/dist/cjs/presets/theme-to-design-tokens/utils/ast-meta.js +104 -0
  10. package/dist/cjs/presets/theme-to-design-tokens/utils/ast.js +19 -0
  11. package/dist/cjs/presets/theme-to-design-tokens/utils/color-difference.js +174 -0
  12. package/dist/cjs/presets/theme-to-design-tokens/utils/color-palette-tokens-map.js +129 -0
  13. package/dist/cjs/presets/theme-to-design-tokens/utils/color-to-token.js +88 -0
  14. package/dist/cjs/presets/theme-to-design-tokens/utils/color.js +59 -0
  15. package/dist/cjs/presets/theme-to-design-tokens/utils/fuzzy-search.js +348 -0
  16. package/dist/cjs/presets/theme-to-design-tokens/utils/legacy-colors.js +81 -0
  17. package/dist/cjs/presets/theme-to-design-tokens/utils/named-colors.js +8 -0
  18. package/dist/cjs/transforms.js +1 -1
  19. package/dist/cjs/types.js +5 -3
  20. package/dist/cjs/version.json +1 -1
  21. package/dist/es2019/cli.js +3 -2
  22. package/dist/es2019/main.js +3 -1
  23. package/dist/es2019/presets/index.js +2 -1
  24. package/dist/es2019/presets/theme-to-design-tokens/theme-to-design-tokens.js +137 -0
  25. package/dist/es2019/presets/theme-to-design-tokens/types.js +1 -0
  26. package/dist/es2019/presets/theme-to-design-tokens/utils/ast-meta.js +70 -0
  27. package/dist/es2019/presets/theme-to-design-tokens/utils/ast.js +10 -0
  28. package/dist/es2019/presets/theme-to-design-tokens/utils/color-difference.js +150 -0
  29. package/dist/es2019/presets/theme-to-design-tokens/utils/color-palette-tokens-map.js +122 -0
  30. package/dist/es2019/presets/theme-to-design-tokens/utils/color-to-token.js +75 -0
  31. package/dist/es2019/presets/theme-to-design-tokens/utils/color.js +35 -0
  32. package/dist/es2019/presets/theme-to-design-tokens/utils/fuzzy-search.js +336 -0
  33. package/dist/es2019/presets/theme-to-design-tokens/utils/legacy-colors.js +72 -0
  34. package/dist/es2019/presets/theme-to-design-tokens/utils/named-colors.js +1 -0
  35. package/dist/es2019/version.json +1 -1
  36. package/dist/esm/cli.js +3 -2
  37. package/dist/esm/main.js +6 -4
  38. package/dist/esm/presets/index.js +3 -2
  39. package/dist/esm/presets/theme-to-design-tokens/theme-to-design-tokens.js +165 -0
  40. package/dist/esm/presets/theme-to-design-tokens/types.js +1 -0
  41. package/dist/esm/presets/theme-to-design-tokens/utils/ast-meta.js +88 -0
  42. package/dist/esm/presets/theme-to-design-tokens/utils/ast.js +10 -0
  43. package/dist/esm/presets/theme-to-design-tokens/utils/color-difference.js +160 -0
  44. package/dist/esm/presets/theme-to-design-tokens/utils/color-palette-tokens-map.js +122 -0
  45. package/dist/esm/presets/theme-to-design-tokens/utils/color-to-token.js +78 -0
  46. package/dist/esm/presets/theme-to-design-tokens/utils/color.js +39 -0
  47. package/dist/esm/presets/theme-to-design-tokens/utils/fuzzy-search.js +340 -0
  48. package/dist/esm/presets/theme-to-design-tokens/utils/legacy-colors.js +72 -0
  49. package/dist/esm/presets/theme-to-design-tokens/utils/named-colors.js +1 -0
  50. package/dist/esm/types.js +3 -2
  51. package/dist/esm/version.json +1 -1
  52. package/dist/types/presets/index.d.ts +1 -0
  53. package/dist/types/presets/theme-to-design-tokens/theme-to-design-tokens.d.ts +2 -0
  54. package/dist/types/presets/theme-to-design-tokens/types.d.ts +2 -0
  55. package/dist/types/presets/theme-to-design-tokens/utils/ast-meta.d.ts +4 -0
  56. package/dist/types/presets/theme-to-design-tokens/utils/ast.d.ts +3 -0
  57. package/dist/types/presets/theme-to-design-tokens/utils/color-difference.d.ts +66 -0
  58. package/dist/types/presets/theme-to-design-tokens/utils/color-palette-tokens-map.d.ts +21 -0
  59. package/dist/types/presets/theme-to-design-tokens/utils/color-to-token.d.ts +12 -0
  60. package/dist/types/presets/theme-to-design-tokens/utils/color.d.ts +4 -0
  61. package/dist/types/presets/theme-to-design-tokens/utils/fuzzy-search.d.ts +5 -0
  62. package/dist/types/presets/theme-to-design-tokens/utils/legacy-colors.d.ts +3 -0
  63. package/dist/types/presets/theme-to-design-tokens/utils/named-colors.d.ts +1 -0
  64. package/package.json +4 -2
@@ -0,0 +1,35 @@
1
+ import { legacyColorMixins, legacyColors } from './legacy-colors';
2
+ import { namedColors } from './named-colors';
3
+ export const isLegacyColor = value => legacyColors.includes(value);
4
+ export const isLegacyNamedColor = value => legacyColorMixins.includes(value);
5
+ export const includesHardCodedColor = raw => {
6
+ const value = raw.toLowerCase();
7
+
8
+ if (/#(?:[a-f0-9]{3}|[a-f0-9]{6}|[a-f0-9]{8})\b|(?:rgb|hsl)a?\([^\)]*\)/.exec(value.toLowerCase())) {
9
+ return true;
10
+ }
11
+
12
+ for (let i = 0; i < namedColors.length; i++) {
13
+ if (value.includes(`${namedColors[i]};`)) {
14
+ return true;
15
+ }
16
+ }
17
+
18
+ return false;
19
+ };
20
+ export const isHardCodedColor = value => {
21
+ if (namedColors.includes(value.toLowerCase())) {
22
+ return true;
23
+ }
24
+
25
+ if (value.startsWith('rgb(') || value.startsWith('rgba(') || value.startsWith('hsl(') || value.startsWith('hsla(') || value.startsWith('lch(') || value.startsWith('lab(') || value.startsWith('color(')) {
26
+ return true;
27
+ }
28
+
29
+ if (value.startsWith('#') && ( // short hex, hex, or hex with alpha
30
+ value.length === 4 || value.length === 7 || value.length === 9)) {
31
+ return true;
32
+ }
33
+
34
+ return false;
35
+ };
@@ -0,0 +1,336 @@
1
+ /* eslint-disable */
2
+
3
+ /**
4
+ * Fuzzy search ripped from the internet.
5
+ */
6
+ const FuzzySet = function (arr = [], useLevenshtein, gramSizeLower = 2, gramSizeUpper = 3) {
7
+ var fuzzyset = {
8
+ gramSizeLower: gramSizeLower,
9
+ gramSizeUpper: gramSizeUpper,
10
+ useLevenshtein: typeof useLevenshtein !== 'boolean' ? true : useLevenshtein,
11
+ exactSet: {},
12
+ matchDict: {},
13
+ items: {}
14
+ };
15
+
16
+ var levenshtein = function (str1, str2) {
17
+ var current = [];
18
+ var prev;
19
+ var value;
20
+
21
+ for (var i = 0; i <= str2.length; i++) {
22
+ for (var j = 0; j <= str1.length; j++) {
23
+ if (i && j) {
24
+ if (str1.charAt(j - 1) === str2.charAt(i - 1)) {
25
+ // @ts-expect-error
26
+ value = prev;
27
+ } else {
28
+ // @ts-expect-error
29
+ value = Math.min(current[j], current[j - 1], prev) + 1;
30
+ }
31
+ } else {
32
+ value = i + j;
33
+ }
34
+
35
+ prev = current[j];
36
+ current[j] = value;
37
+ }
38
+ }
39
+
40
+ return current.pop();
41
+ }; // return an edit distance from 0 to 1
42
+
43
+
44
+ var _distance = function (str1, str2) {
45
+ if (str1 === null && str2 === null) {
46
+ throw new Error('Trying to compare two null values');
47
+ }
48
+
49
+ if (str1 === null || str2 === null) {
50
+ return 0;
51
+ }
52
+
53
+ str1 = String(str1);
54
+ str2 = String(str2);
55
+ var distance = levenshtein(str1, str2);
56
+
57
+ if (str1.length > str2.length) {
58
+ return 1 - distance / str1.length;
59
+ } else {
60
+ return 1 - distance / str2.length;
61
+ }
62
+ };
63
+
64
+ var _nonWordRe = /[^a-zA-Z0-9\u00C0-\u00FF, ]+/g;
65
+
66
+ var _iterateGrams = function (value, gramSize) {
67
+ gramSize = gramSize || 2;
68
+ var simplified = '-' + value.toLowerCase().replace(_nonWordRe, '') + '-',
69
+ lenDiff = gramSize - simplified.length,
70
+ results = [];
71
+
72
+ if (lenDiff > 0) {
73
+ for (var i = 0; i < lenDiff; ++i) {
74
+ simplified += '-';
75
+ }
76
+ }
77
+
78
+ for (var i = 0; i < simplified.length - gramSize + 1; ++i) {
79
+ results.push(simplified.slice(i, i + gramSize));
80
+ }
81
+
82
+ return results;
83
+ };
84
+
85
+ var _gramCounter = function (value, gramSize) {
86
+ // return an object where key=gram, value=number of occurrences
87
+ gramSize = gramSize || 2;
88
+
89
+ var result = {},
90
+ grams = _iterateGrams(value, gramSize),
91
+ i = 0;
92
+
93
+ for (i; i < grams.length; ++i) {
94
+ if (grams[i] in result) {
95
+ // @ts-expect-error
96
+ result[grams[i]] += 1;
97
+ } else {
98
+ // @ts-expect-error
99
+ result[grams[i]] = 1;
100
+ }
101
+ }
102
+
103
+ return result;
104
+ }; // the main functions
105
+
106
+
107
+ fuzzyset.get = function (value, defaultValue, minMatchScore) {
108
+ // check for value in set, returning defaultValue or null if none found
109
+ if (minMatchScore === undefined) {
110
+ minMatchScore = 0.33;
111
+ }
112
+
113
+ var result = this._get(value, minMatchScore);
114
+
115
+ if (!result && typeof defaultValue !== 'undefined') {
116
+ return defaultValue;
117
+ }
118
+
119
+ return result;
120
+ };
121
+
122
+ fuzzyset._get = function (value, minMatchScore) {
123
+ var results = []; // start with high gram size and if there are no results, go to lower gram sizes
124
+
125
+ for (var gramSize = this.gramSizeUpper; gramSize >= this.gramSizeLower; --gramSize) {
126
+ results = this.__get(value, gramSize, minMatchScore);
127
+
128
+ if (results && results.length > 0) {
129
+ return results;
130
+ }
131
+ }
132
+
133
+ return null;
134
+ };
135
+
136
+ fuzzyset.__get = function (value, gramSize, minMatchScore) {
137
+ var normalizedValue = this._normalizeStr(value),
138
+ matches = {},
139
+ gramCounts = _gramCounter(normalizedValue, gramSize),
140
+ items = this.items[gramSize],
141
+ sumOfSquareGramCounts = 0,
142
+ gram,
143
+ gramCount,
144
+ i,
145
+ index,
146
+ otherGramCount;
147
+
148
+ for (gram in gramCounts) {
149
+ // @ts-expect-error
150
+ gramCount = gramCounts[gram];
151
+ sumOfSquareGramCounts += Math.pow(gramCount, 2);
152
+
153
+ if (gram in this.matchDict) {
154
+ for (i = 0; i < this.matchDict[gram].length; ++i) {
155
+ index = this.matchDict[gram][i][0];
156
+ otherGramCount = this.matchDict[gram][i][1];
157
+
158
+ if (index in matches) {
159
+ // @ts-expect-error
160
+ matches[index] += gramCount * otherGramCount;
161
+ } else {
162
+ // @ts-expect-error
163
+ matches[index] = gramCount * otherGramCount;
164
+ }
165
+ }
166
+ }
167
+ }
168
+
169
+ function isEmptyObject(obj) {
170
+ for (var prop in obj) {
171
+ if (obj.hasOwnProperty(prop)) {
172
+ return false;
173
+ }
174
+ }
175
+
176
+ return true;
177
+ }
178
+
179
+ if (isEmptyObject(matches)) {
180
+ return null;
181
+ }
182
+
183
+ var vectorNormal = Math.sqrt(sumOfSquareGramCounts),
184
+ results = [],
185
+ matchScore; // build a results list of [score, str]
186
+
187
+ for (var matchIndex in matches) {
188
+ // @ts-expect-error
189
+ matchScore = matches[matchIndex];
190
+ results.push([matchScore / (vectorNormal * items[matchIndex][0]), items[matchIndex][1]]);
191
+ }
192
+
193
+ var sortDescending = function (a, b) {
194
+ if (a[0] < b[0]) {
195
+ return 1;
196
+ } else if (a[0] > b[0]) {
197
+ return -1;
198
+ } else {
199
+ return 0;
200
+ }
201
+ };
202
+
203
+ results.sort(sortDescending);
204
+
205
+ if (this.useLevenshtein) {
206
+ var newResults = [],
207
+ endIndex = Math.min(50, results.length); // truncate somewhat arbitrarily to 50
208
+ // @ts-expect-error
209
+
210
+ for (var i = 0; i < endIndex; ++i) {
211
+ // @ts-expect-error
212
+ newResults.push([_distance(results[i][1], normalizedValue), results[i][1]]);
213
+ }
214
+
215
+ results = newResults;
216
+ results.sort(sortDescending);
217
+ }
218
+
219
+ newResults = [];
220
+ results.forEach(function (scoreWordPair) {
221
+ if (scoreWordPair[0] >= minMatchScore) {
222
+ // @ts-expect-error
223
+ newResults.push([scoreWordPair[0], this.exactSet[scoreWordPair[1]]]);
224
+ }
225
+ }.bind(this));
226
+ return newResults;
227
+ };
228
+
229
+ fuzzyset.add = function (value) {
230
+ var normalizedValue = this._normalizeStr(value);
231
+
232
+ if (normalizedValue in this.exactSet) {
233
+ return false;
234
+ }
235
+
236
+ var i = this.gramSizeLower;
237
+
238
+ for (i; i < this.gramSizeUpper + 1; ++i) {
239
+ this._add(value, i);
240
+ }
241
+ };
242
+
243
+ fuzzyset._add = function (value, gramSize) {
244
+ var normalizedValue = this._normalizeStr(value),
245
+ items = this.items[gramSize] || [],
246
+ index = items.length;
247
+
248
+ items.push(0);
249
+
250
+ var gramCounts = _gramCounter(normalizedValue, gramSize);
251
+
252
+ var sumOfSquareGramCounts = 0;
253
+ var gram;
254
+ var gramCount;
255
+
256
+ for (gram in gramCounts) {
257
+ // @ts-expect-error
258
+ gramCount = gramCounts[gram];
259
+ sumOfSquareGramCounts += Math.pow(gramCount, 2);
260
+
261
+ if (gram in this.matchDict) {
262
+ this.matchDict[gram].push([index, gramCount]);
263
+ } else {
264
+ this.matchDict[gram] = [[index, gramCount]];
265
+ }
266
+ }
267
+
268
+ var vectorNormal = Math.sqrt(sumOfSquareGramCounts);
269
+ items[index] = [vectorNormal, normalizedValue];
270
+ this.items[gramSize] = items;
271
+ this.exactSet[normalizedValue] = value;
272
+ };
273
+
274
+ fuzzyset._normalizeStr = function (str) {
275
+ if (Object.prototype.toString.call(str) !== '[object String]') {
276
+ throw new Error('Must use a string as argument to FuzzySet functions');
277
+ }
278
+
279
+ return str.toLowerCase();
280
+ }; // return length of items in set
281
+
282
+
283
+ fuzzyset.length = function () {
284
+ var count = 0,
285
+ prop;
286
+
287
+ for (prop in this.exactSet) {
288
+ if (this.exactSet.hasOwnProperty(prop)) {
289
+ count += 1;
290
+ }
291
+ }
292
+
293
+ return count;
294
+ }; // return is set is empty
295
+
296
+
297
+ fuzzyset.isEmpty = function () {
298
+ for (var prop in this.exactSet) {
299
+ if (this.exactSet.hasOwnProperty(prop)) {
300
+ return false;
301
+ }
302
+ }
303
+
304
+ return true;
305
+ }; // return list of values loaded into set
306
+
307
+
308
+ fuzzyset.values = function () {
309
+ var values = [],
310
+ prop;
311
+
312
+ for (prop in this.exactSet) {
313
+ if (this.exactSet.hasOwnProperty(prop)) {
314
+ values.push(this.exactSet[prop]);
315
+ }
316
+ }
317
+
318
+ return values;
319
+ }; // initialization
320
+
321
+
322
+ var i = fuzzyset.gramSizeLower;
323
+
324
+ for (i; i < fuzzyset.gramSizeUpper + 1; ++i) {
325
+ fuzzyset.items[i] = [];
326
+ } // add all the items to the set
327
+
328
+
329
+ for (i = 0; i < arr.length; ++i) {
330
+ fuzzyset.add(arr[i]);
331
+ }
332
+
333
+ return fuzzyset;
334
+ };
335
+
336
+ export default FuzzySet;
@@ -0,0 +1,72 @@
1
+ export const legacyColors = ['R50', 'R75', 'R100', 'R200', 'R300', 'R400', 'R500', 'Y50', 'Y75', 'Y100', 'Y200', 'Y300', 'Y400', 'Y500', 'G50', 'G75', 'G100', 'G200', 'G300', 'G400', 'G500', 'B50', 'B75', 'B100', 'B200', 'B300', 'B400', 'B500', 'P50', 'P75', 'P100', 'P200', 'P300', 'P400', 'P500', 'T50', 'T75', 'T100', 'T200', 'T300', 'T400', 'T500', 'N0', 'N10', 'N20', 'N30', 'N40', 'N50', 'N60', 'N70', 'N80', 'N90', 'N100', 'N200', 'N300', 'N400', 'N500', 'N600', 'N700', 'N800', 'N900', 'N10A', 'N20A', 'N30A', 'N40A', 'N50A', 'N60A', 'N70A', 'N80A', 'N90A', 'N100A', 'N200A', 'N300A', 'N400A', 'N500A', 'N600A', 'N700A', 'N800A', 'DN900', 'DN800', 'DN700', 'DN600', 'DN500', 'DN400', 'DN300', 'DN200', 'DN100', 'DN90', 'DN80', 'DN70', 'DN60', 'DN50', 'DN40', 'DN30', 'DN20', 'DN10', 'DN0', 'DN800A', 'DN700A', 'DN600A', 'DN500A', 'DN400A', 'DN300A', 'DN200A', 'DN100A', 'DN90A', 'DN80A', 'DN70A', 'DN60A', 'DN50A', 'DN40A', 'DN30A', 'DN20A', 'DN10A'];
2
+ export const legacyColorMixins = ['background', 'backgroundActive', 'backgroundHover', 'backgroundOnLayer', 'text', 'textHover', 'textActive', 'subtleText', 'placeholderText', 'heading', 'subtleHeading', 'codeBlock', 'link', 'linkHover', 'linkActive', 'linkOutline', 'primary', 'blue', 'teal', 'purple', 'red', 'yellow', 'green', 'skeleton'];
3
+ export const legacyColorMetaMap = {
4
+ R50: ['danger'],
5
+ R75: ['danger'],
6
+ R100: ['danger'],
7
+ R200: ['danger'],
8
+ R300: ['danger'],
9
+ R400: ['danger'],
10
+ R500: ['danger'],
11
+ Y50: ['warning'],
12
+ Y75: ['warning'],
13
+ Y100: ['warning'],
14
+ Y200: ['warning'],
15
+ Y300: ['warning'],
16
+ Y400: ['warning'],
17
+ Y500: ['warning'],
18
+ G50: ['success'],
19
+ G75: ['success'],
20
+ G100: ['success'],
21
+ G200: ['success'],
22
+ G300: ['success'],
23
+ G400: ['success'],
24
+ G500: ['success'],
25
+ B50: ['brand'],
26
+ B75: ['brand'],
27
+ B100: ['brand'],
28
+ B200: ['brand'],
29
+ B300: ['brand'],
30
+ B400: ['brand'],
31
+ B500: ['brand'],
32
+ P50: ['discovery'],
33
+ P75: ['discovery'],
34
+ P100: ['discovery'],
35
+ P200: ['discovery'],
36
+ P300: ['discovery'],
37
+ P400: ['discovery'],
38
+ P500: ['discovery'],
39
+ T50: ['accent', 'teal'],
40
+ T75: ['accent', 'teal'],
41
+ T100: ['accent', 'teal'],
42
+ T200: ['accent', 'teal'],
43
+ T300: ['accent', 'teal'],
44
+ T400: ['accent', 'teal'],
45
+ T500: ['accent', 'teal'],
46
+ N0: ['onBold'],
47
+ N800: ['text'],
48
+ background: ['background', 'default'],
49
+ backgroundActive: ['background', 'selected'],
50
+ backgroundHover: ['background', 'hovered'],
51
+ backgroundOnLayer: ['background', 'blanket'],
52
+ text: ['text'],
53
+ textHover: ['text', 'subtle'],
54
+ textActive: ['text', 'link', 'pressed'],
55
+ subtleText: ['text', 'subtlest'],
56
+ placeholderText: ['text', 'subtlest'],
57
+ heading: ['text'],
58
+ subtleHeading: ['text', 'subtle'],
59
+ link: ['text', 'link'],
60
+ linkHover: ['text', 'link', 'hovered'],
61
+ linkActive: ['text', 'link', 'pressed'],
62
+ linkOutline: ['border', 'selected'],
63
+ primary: ['brand'],
64
+ blue: ['accent', 'blue'],
65
+ teal: ['accent', 'teal'],
66
+ purple: ['accent', 'purple'],
67
+ red: ['accent', 'red'],
68
+ yellow: ['accent', 'orange'],
69
+ green: ['accent', 'green'],
70
+ grey: ['background', 'neutral'],
71
+ skeleton: ['background', 'neutral']
72
+ };
@@ -0,0 +1 @@
1
+ export const namedColors = ['black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple', 'fuchsia', 'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua', 'orange', 'aliceblue', 'antiquewhite', 'aquamarine', 'azure', 'beige', 'bisque', 'blanchedalmond', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'limegreen', 'linen', 'magenta', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'oldlace', 'olivedrab', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'whitesmoke', 'yellowgreen', 'rebeccapurple'];
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.8.0"
3
+ "version": "0.8.4"
4
4
  }
package/dist/esm/cli.js CHANGED
@@ -15,7 +15,7 @@ function _run() {
15
15
  while (1) {
16
16
  switch (_context.prev = _context.next) {
17
17
  case 0:
18
- cli = meow("\nUsage\n $ npx @atlaskit/codemod-cli [options] <file-paths>...\n\nOptions\n --transform, -t the transform to run, will prompt for a transform if not provided and no module is passed\n --since-ref, runs transforms for all packages that have been upgraded since the specified git ref\n --packages, runs transforms for the specified comma separated list of packages, optionally include a version for each package to run all transforms since that version\n --parser, -p babel|babylon|flow|ts|tsx parser to use for parsing the source files (default: babel)\n --extensions, -e transform files with these file extensions (comma separated list) (default: js)\n --ignore-pattern, ignore files that match a provided glob expression\n --fail-on-error, return a 1 exit code when errors were found during execution of codemods\n --version, -v version number\n --filterPaths filters source paths to package directories that declare a dependency on the package being upgraded\n --help Help me \uD83D\uDE31\n\nExamples\n # Run a codemod over the /project/src directory, will be prompted for which codemod to run\n $ npx @atlaskit/codemod-cli /project/src\n\n # Run the \"4.0.0-remove-appearance-prop\" transform of the \"button\" package\n $ npx @atlaskit/codemod-cli -t button@4.0.0-remove-appearance-prop /project/src\n\n # Run all transforms for \"@atlaskit/button\" greater than version 3.0.0 and @atlaskit/range greater than 4.0.0\n $ npx @atlaskit/codemod-cli --packages @atlaskit/button@3.0.0,@atlaskit/range@4.0.0 /project/src\n", {
18
+ cli = meow("\nUsage\n $ npx @atlaskit/codemod-cli [options] <file-paths>...\n\nOptions\n --transform, -t the transform to run, will prompt for a transform if not provided and no module is passed\n --since-ref, runs transforms for all packages that have been upgraded since the specified git ref\n --packages, runs transforms for the specified comma separated list of packages, optionally include a version for each package to run all transforms since that version\n --parser, -p babel|babylon|flow|ts|tsx parser to use for parsing the source files (default: babel)\n --extensions, -e transform files with these file extensions (comma separated list) (default: js)\n --ignore-pattern, ignore files that match a provided glob expression\n --fail-on-error, return a 1 exit code when errors were found during execution of codemods\n --version, -v version number\n --no-filter-paths disables dependant package file path filtering logic \n --help Help me \uD83D\uDE31\n\nExamples\n # Run a codemod over the /project/src directory, will be prompted for which codemod to run\n $ npx @atlaskit/codemod-cli /project/src\n\n # Run the \"4.0.0-remove-appearance-prop\" transform of the \"button\" package\n $ npx @atlaskit/codemod-cli -t button@4.0.0-remove-appearance-prop /project/src\n\n # Run all transforms for \"@atlaskit/button\" greater than version 3.0.0 and @atlaskit/range greater than 4.0.0\n $ npx @atlaskit/codemod-cli --packages @atlaskit/button@3.0.0,@atlaskit/range@4.0.0 /project/src\n", {
19
19
  flags: {
20
20
  transform: {
21
21
  type: 'string',
@@ -42,7 +42,8 @@ function _run() {
42
42
  type: 'boolean'
43
43
  },
44
44
  filterPaths: {
45
- type: 'boolean'
45
+ type: 'boolean',
46
+ default: true
46
47
  }
47
48
  }
48
49
  });
package/dist/esm/main.js CHANGED
@@ -9,9 +9,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
9
9
 
10
10
  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
11
 
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
12
+ 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
13
 
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
14
+ 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; }
15
15
 
16
16
  import chalk from 'chalk';
17
17
  import fs from 'fs';
@@ -159,7 +159,9 @@ var runTransform = /*#__PURE__*/function () {
159
159
  codemodDirs = _context3.sent;
160
160
 
161
161
  if (codemodDirs.length === 0) {
162
- logger.log(chalk.yellow("Filtering for module ".concat(transform.module, " returned no directories, please validate specified paths.")));
162
+ // Fallback to non-filter logic if filtering returns no directories
163
+ logger.log(chalk.yellow("Could not filter source paths for ".concat(transform.module, ", falling back to running over all specified paths. (See --no-filter-paths flag)")));
164
+ codemodDirs = filePaths;
163
165
  } else {
164
166
  logger.log(chalk.green("Running transform '".concat(chalk.bold(transform.name), "' over filtered dirs ").concat(chalk.bold(codemodDirs.join(', ')), "...")));
165
167
  }
@@ -338,7 +340,7 @@ function _main() {
338
340
  case 4:
339
341
  _yield$parseArgs = _context5.sent;
340
342
  packages = _yield$parseArgs.packages;
341
- _process$env$_PACKAGE = "0.8.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
343
+ _process$env$_PACKAGE = "0.8.4", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
342
344
  logger.log(chalk.bgBlue(chalk.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
343
345
 
344
346
  if (packages && packages.length > 0) {
@@ -5,7 +5,8 @@ import path from 'path';
5
5
  */
6
6
 
7
7
  import './styled-to-emotion/styled-to-emotion';
8
- var presets = ['styled-to-emotion'].map(function (preset) {
9
- return path.join(__dirname, preset, "".concat(preset, ".@(ts|js)"));
8
+ import './theme-to-design-tokens/theme-to-design-tokens';
9
+ var presets = ['styled-to-emotion', 'theme-to-design-tokens'].map(function (preset) {
10
+ return path.join(__dirname, preset, "".concat(preset, ".@(ts|js|tsx)"));
10
11
  });
11
12
  export default presets;