@atlaskit/codemod-cli 0.8.3 → 0.8.6
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/CHANGELOG.md +20 -0
- package/README.md +12 -2
- package/dist/cjs/main.js +3 -3
- package/dist/cjs/presets/index.js +4 -2
- package/dist/cjs/presets/theme-to-design-tokens/theme-to-design-tokens.js +145 -0
- package/dist/cjs/presets/theme-to-design-tokens/types.js +5 -0
- package/dist/cjs/presets/theme-to-design-tokens/utils/ast-meta.js +88 -0
- package/dist/cjs/presets/theme-to-design-tokens/utils/ast.js +19 -0
- package/dist/cjs/presets/theme-to-design-tokens/utils/color.js +59 -0
- package/dist/cjs/presets/theme-to-design-tokens/utils/fuzzy-search.js +348 -0
- package/dist/cjs/presets/theme-to-design-tokens/utils/legacy-colors.js +83 -0
- package/dist/cjs/presets/theme-to-design-tokens/utils/named-colors.js +8 -0
- package/dist/cjs/presets/theme-to-design-tokens/utils/tokens.js +38 -0
- package/dist/cjs/types.js +4 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/presets/index.js +2 -1
- package/dist/es2019/presets/theme-to-design-tokens/theme-to-design-tokens.js +100 -0
- package/dist/es2019/presets/theme-to-design-tokens/types.js +1 -0
- package/dist/es2019/presets/theme-to-design-tokens/utils/ast-meta.js +63 -0
- package/dist/es2019/presets/theme-to-design-tokens/utils/ast.js +10 -0
- package/dist/es2019/presets/theme-to-design-tokens/utils/color.js +35 -0
- package/dist/es2019/presets/theme-to-design-tokens/utils/fuzzy-search.js +336 -0
- package/dist/es2019/presets/theme-to-design-tokens/utils/legacy-colors.js +74 -0
- package/dist/es2019/presets/theme-to-design-tokens/utils/named-colors.js +1 -0
- package/dist/es2019/presets/theme-to-design-tokens/utils/tokens.js +12 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/main.js +3 -3
- package/dist/esm/presets/index.js +3 -2
- package/dist/esm/presets/theme-to-design-tokens/theme-to-design-tokens.js +130 -0
- package/dist/esm/presets/theme-to-design-tokens/types.js +1 -0
- package/dist/esm/presets/theme-to-design-tokens/utils/ast-meta.js +75 -0
- package/dist/esm/presets/theme-to-design-tokens/utils/ast.js +10 -0
- package/dist/esm/presets/theme-to-design-tokens/utils/color.js +39 -0
- package/dist/esm/presets/theme-to-design-tokens/utils/fuzzy-search.js +340 -0
- package/dist/esm/presets/theme-to-design-tokens/utils/legacy-colors.js +74 -0
- package/dist/esm/presets/theme-to-design-tokens/utils/named-colors.js +1 -0
- package/dist/esm/presets/theme-to-design-tokens/utils/tokens.js +24 -0
- package/dist/esm/types.js +3 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/presets/index.d.ts +1 -0
- package/dist/types/presets/theme-to-design-tokens/theme-to-design-tokens.d.ts +2 -0
- package/dist/types/presets/theme-to-design-tokens/utils/ast-meta.d.ts +3 -0
- package/dist/types/presets/theme-to-design-tokens/utils/ast.d.ts +3 -0
- package/dist/types/presets/theme-to-design-tokens/utils/color.d.ts +4 -0
- package/dist/types/presets/theme-to-design-tokens/utils/fuzzy-search.d.ts +5 -0
- package/dist/types/presets/theme-to-design-tokens/utils/legacy-colors.d.ts +3 -0
- package/dist/types/presets/theme-to-design-tokens/utils/named-colors.d.ts +1 -0
- package/dist/types/presets/theme-to-design-tokens/utils/tokens.d.ts +2 -0
- package/package.json +3 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getUniqueWordsFromTokens } from './tokens';
|
|
2
|
+
export function getMetaFromAncestors(j, path, meta = []) {
|
|
3
|
+
const parent = path.parentPath;
|
|
4
|
+
const grandParent = parent && parent.parentPath;
|
|
5
|
+
|
|
6
|
+
if (parent && parent.value.type === 'ObjectProperty') {
|
|
7
|
+
let value = '';
|
|
8
|
+
|
|
9
|
+
if (parent.value.key.type === 'Literal' || parent.value.key.type === 'StringLiteral' || parent.value.key.type === 'NumericLiteral') {
|
|
10
|
+
value = parent.value.key.value.toString();
|
|
11
|
+
} else {
|
|
12
|
+
value = parent.value.key.name;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
meta.push(value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (parent && grandParent && grandParent.value.type === 'TemplateLiteral') {
|
|
19
|
+
const expressionIndex = grandParent.value.expressions.findIndex(exp => exp.name === path.value.name);
|
|
20
|
+
const quasi = grandParent.value.quasis[expressionIndex];
|
|
21
|
+
const propertyName = (quasi.value.cooked || quasi.value.raw || '').replace(/\n/g, '').split(/;|{|}/).filter(el => !el.match(/\.|\@|\(|\)/)).pop().split(/:/g)[0].trim();
|
|
22
|
+
grandParent.value.quasis.slice(0, expressionIndex + 1).map(q => q.value.cooked) // We reverse so the most nested one is first which we're more likely than not interested in
|
|
23
|
+
.reverse().some(str => {
|
|
24
|
+
const result = /(hover|active|disabled|focus)/.exec(str.toLowerCase());
|
|
25
|
+
|
|
26
|
+
if (result) {
|
|
27
|
+
meta.push(result[0]);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
meta.push(propertyName);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (parent && parent.value.type === 'JSXAttribute') {
|
|
35
|
+
if (!['css', 'styles', 'style'].includes(parent.value.name.name)) {
|
|
36
|
+
meta.push(parent.value.name.name);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (parent && parent.value.type === 'VariableDeclarator') {
|
|
41
|
+
meta.push(parent.value.id.name);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (parent) {
|
|
45
|
+
return getMetaFromAncestors(j, parent, meta);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return meta;
|
|
49
|
+
}
|
|
50
|
+
export function cleanMeta(meta) {
|
|
51
|
+
return meta.reduce((accum, val) => [...accum, ...(typeof val === 'string' ? val.split(/(?=[A-Z])/g).map(e => e.toLowerCase()) : [])], []).reduce((accum, val) => {
|
|
52
|
+
accum.push(val.replace(/:/g, '').replace(/,/g, '').replace('grey', 'neutral').replace('skeleton', '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('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'));
|
|
53
|
+
return accum;
|
|
54
|
+
}, []).filter(val => {
|
|
55
|
+
return getUniqueWordsFromTokens.includes(val);
|
|
56
|
+
}).reduce((accum, val) => {
|
|
57
|
+
if (!accum.includes(val)) {
|
|
58
|
+
accum.push(val);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return accum;
|
|
62
|
+
}, []);
|
|
63
|
+
}
|
|
@@ -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,74 @@
|
|
|
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: ['inverse'],
|
|
47
|
+
N700: ['text'],
|
|
48
|
+
N800: ['text'],
|
|
49
|
+
N900: ['text'],
|
|
50
|
+
background: ['background', 'default'],
|
|
51
|
+
backgroundActive: ['background', 'pressed'],
|
|
52
|
+
backgroundHover: ['background', 'hovered'],
|
|
53
|
+
backgroundOnLayer: ['background', 'blanket'],
|
|
54
|
+
text: ['text'],
|
|
55
|
+
textHover: ['text', 'subtle'],
|
|
56
|
+
textActive: ['text', 'link', 'pressed'],
|
|
57
|
+
subtleText: ['text', 'subtlest'],
|
|
58
|
+
placeholderText: ['text', 'subtlest'],
|
|
59
|
+
heading: ['text'],
|
|
60
|
+
subtleHeading: ['text', 'subtle'],
|
|
61
|
+
link: ['link'],
|
|
62
|
+
linkHover: ['link', 'hovered'],
|
|
63
|
+
linkActive: ['link', 'pressed'],
|
|
64
|
+
linkOutline: ['border', 'selected'],
|
|
65
|
+
primary: ['brand'],
|
|
66
|
+
blue: ['accent', 'blue'],
|
|
67
|
+
teal: ['accent', 'teal'],
|
|
68
|
+
purple: ['accent', 'purple'],
|
|
69
|
+
red: ['accent', 'red'],
|
|
70
|
+
yellow: ['accent', 'orange'],
|
|
71
|
+
green: ['accent', 'green'],
|
|
72
|
+
grey: ['background', 'neutral'],
|
|
73
|
+
skeleton: ['background', 'neutral']
|
|
74
|
+
};
|
|
@@ -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'];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import designTokens from '@atlaskit/tokens/token-names';
|
|
2
|
+
import renameMapping from '@atlaskit/tokens/rename-mapping';
|
|
3
|
+
export const tokens = Object.keys(designTokens).filter(t => !t.includes('UNSAFE') && !t.includes('interaction')).filter(t => !renameMapping.find(({
|
|
4
|
+
path
|
|
5
|
+
}) => t === path.replace(/\.[default]\g/, '')));
|
|
6
|
+
export 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) => {
|
|
7
|
+
if (!accum.includes(val)) {
|
|
8
|
+
accum.push(val);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return accum;
|
|
12
|
+
}, []);
|
package/dist/es2019/version.json
CHANGED
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);
|
|
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]
|
|
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';
|
|
@@ -340,7 +340,7 @@ function _main() {
|
|
|
340
340
|
case 4:
|
|
341
341
|
_yield$parseArgs = _context5.sent;
|
|
342
342
|
packages = _yield$parseArgs.packages;
|
|
343
|
-
_process$env$_PACKAGE = "0.8.
|
|
343
|
+
_process$env$_PACKAGE = "0.8.6", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
|
|
344
344
|
logger.log(chalk.bgBlue(chalk.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
|
|
345
345
|
|
|
346
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
|
-
|
|
9
|
-
|
|
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;
|