@workday/canvas-kit-codemod 13.2.42 → 13.2.43
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/dist/es6/v13.2/mapping/index.d.ts +58 -1
- package/dist/es6/v13.2/mapping/index.d.ts.map +1 -1
- package/dist/es6/v13.2/mapping/index.js +58 -1
- package/dist/es6/v13.2/migrateColorTokens.d.ts.map +1 -1
- package/dist/es6/v13.2/migrateColorTokens.js +48 -10
- package/dist/es6/v13.2/migrateDepthTokens.js +1 -1
- package/dist/es6/v13.2/migrateOtherTokens.d.ts.map +1 -1
- package/dist/es6/v13.2/migrateOtherTokens.js +19 -17
- package/dist/es6/v13.2/migrateTypeTokens.js +1 -1
- package/dist/es6/v13.2/utils/filterOutImports.d.ts.map +1 -1
- package/dist/es6/v13.2/utils/filterOutImports.js +2 -1
- package/package.json +2 -2
|
@@ -3,6 +3,63 @@ export declare const mapping: {
|
|
|
3
3
|
readonly type: "base";
|
|
4
4
|
readonly name: "colors";
|
|
5
5
|
};
|
|
6
|
+
readonly commonColors: {
|
|
7
|
+
readonly type: "system";
|
|
8
|
+
readonly name: "commonColors";
|
|
9
|
+
readonly keys: {
|
|
10
|
+
readonly background: "system.color.bg.default";
|
|
11
|
+
readonly backgroundAlt: "system.color.bg.alt.default";
|
|
12
|
+
readonly focusOutline: "system.color.border.primary.default";
|
|
13
|
+
readonly focusBackground: "system.color.bg.primary.default";
|
|
14
|
+
readonly hoverBackground: "system.color.bg.alt.strong";
|
|
15
|
+
readonly divider: "system.color.border.divider";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
readonly inputColors: {
|
|
19
|
+
readonly type: "system";
|
|
20
|
+
readonly name: "inputColors";
|
|
21
|
+
readonly keys: {
|
|
22
|
+
readonly background: "system.color.bg.default";
|
|
23
|
+
readonly border: "system.color.border.input.default";
|
|
24
|
+
readonly placeholder: "system.color.fg.muted.default";
|
|
25
|
+
readonly text: "system.color.fg.default";
|
|
26
|
+
readonly icon: "system.color.fg.muted.soft";
|
|
27
|
+
readonly iconHover: "system.color.fg.muted.stronger";
|
|
28
|
+
readonly selectionControlFill: "system.color.bg.primary.default";
|
|
29
|
+
readonly hoverBorder: "system.color.border.input.strong";
|
|
30
|
+
readonly focusBorder: "system.color.border.primary.default";
|
|
31
|
+
readonly disabled: {
|
|
32
|
+
readonly background: "system.color.bg.alt.softer";
|
|
33
|
+
readonly border: "system.color.border.input.strong";
|
|
34
|
+
readonly text: "system.color.fg.disabled";
|
|
35
|
+
readonly icon: "system.color.fg.disabled";
|
|
36
|
+
};
|
|
37
|
+
readonly error: {
|
|
38
|
+
readonly border: "system.color.border.critical.default";
|
|
39
|
+
readonly message: "system.color.fg.critical.default";
|
|
40
|
+
readonly icon: "system.color.fg.critical.default";
|
|
41
|
+
};
|
|
42
|
+
readonly alert: {
|
|
43
|
+
readonly border: "system.color.border.caution.default";
|
|
44
|
+
readonly message: "system.color.fg.caution.default";
|
|
45
|
+
readonly icon: "system.color.fg.caution.default";
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly typeColors: {
|
|
50
|
+
readonly type: "system";
|
|
51
|
+
readonly name: "typeColors";
|
|
52
|
+
readonly keys: {
|
|
53
|
+
readonly body: "system.color.fg.default";
|
|
54
|
+
readonly heading: "system.color.fg.strong";
|
|
55
|
+
readonly hint: "system.color.fg.muted.soft";
|
|
56
|
+
readonly inverse: "system.color.fg.inverse";
|
|
57
|
+
readonly label: "system.color.fg.default";
|
|
58
|
+
readonly link: "system.color.fg.primary.default";
|
|
59
|
+
readonly selectHighlight: "system.color.fg.primary.default";
|
|
60
|
+
readonly selectHighlightInverse: "system.color.fg.inverse";
|
|
61
|
+
};
|
|
62
|
+
};
|
|
6
63
|
readonly borderRadius: {
|
|
7
64
|
readonly name: "shape";
|
|
8
65
|
readonly type: "system";
|
|
@@ -215,7 +272,7 @@ export declare const systemColors: {
|
|
|
215
272
|
licorice400: string;
|
|
216
273
|
licorice500: string;
|
|
217
274
|
};
|
|
218
|
-
'border,borderColor,borderTopColor,borderRightColor,borderBottomColor,borderLeftColor,borderInlineColor,borderBlockColor,borderInlineStartColor,borderInlineEndColor,borderBlockStartColor,borderBlockEndColor,borderColorFocus,borderColorHover,borderColorActive': {
|
|
275
|
+
'border,borderColor,borderTop,borderTopColor,borderRight,borderRightColor,borderBottom,borderBottomColor,borderLeft,borderLeftColor,borderInlineColor,borderBlockColor,borderInline,borderInlineStart,borderInlineStartColor,borderInlineEnd,borderInlineEndColor,borderBlockStart,borderBlockStartColor,borderBlockEnd,borderBlockEndColor,borderColorFocus,borderColorHover,borderColorActive': {
|
|
219
276
|
blackPepper400: string;
|
|
220
277
|
blackPepper500: string;
|
|
221
278
|
blueberry400: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/v13.2/mapping/index.ts"],"names":[],"mappings":"AAqFA,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/v13.2/mapping/index.ts"],"names":[],"mappings":"AAqFA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFV,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DxB,CAAC"}
|
|
@@ -83,6 +83,63 @@ export const mapping = {
|
|
|
83
83
|
type: 'base',
|
|
84
84
|
name: 'colors',
|
|
85
85
|
},
|
|
86
|
+
commonColors: {
|
|
87
|
+
type: 'system',
|
|
88
|
+
name: 'commonColors',
|
|
89
|
+
keys: {
|
|
90
|
+
background: 'system.color.bg.default',
|
|
91
|
+
backgroundAlt: 'system.color.bg.alt.default',
|
|
92
|
+
focusOutline: 'system.color.border.primary.default',
|
|
93
|
+
focusBackground: 'system.color.bg.primary.default',
|
|
94
|
+
hoverBackground: 'system.color.bg.alt.strong',
|
|
95
|
+
divider: 'system.color.border.divider',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
inputColors: {
|
|
99
|
+
type: 'system',
|
|
100
|
+
name: 'inputColors',
|
|
101
|
+
keys: {
|
|
102
|
+
background: 'system.color.bg.default',
|
|
103
|
+
border: 'system.color.border.input.default',
|
|
104
|
+
placeholder: 'system.color.fg.muted.default',
|
|
105
|
+
text: 'system.color.fg.default',
|
|
106
|
+
icon: 'system.color.fg.muted.soft',
|
|
107
|
+
iconHover: 'system.color.fg.muted.stronger',
|
|
108
|
+
selectionControlFill: 'system.color.bg.primary.default',
|
|
109
|
+
hoverBorder: 'system.color.border.input.strong',
|
|
110
|
+
focusBorder: 'system.color.border.primary.default',
|
|
111
|
+
disabled: {
|
|
112
|
+
background: 'system.color.bg.alt.softer',
|
|
113
|
+
border: 'system.color.border.input.strong',
|
|
114
|
+
text: 'system.color.fg.disabled',
|
|
115
|
+
icon: 'system.color.fg.disabled',
|
|
116
|
+
},
|
|
117
|
+
error: {
|
|
118
|
+
border: 'system.color.border.critical.default',
|
|
119
|
+
message: 'system.color.fg.critical.default',
|
|
120
|
+
icon: 'system.color.fg.critical.default',
|
|
121
|
+
},
|
|
122
|
+
alert: {
|
|
123
|
+
border: 'system.color.border.caution.default',
|
|
124
|
+
message: 'system.color.fg.caution.default',
|
|
125
|
+
icon: 'system.color.fg.caution.default',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
typeColors: {
|
|
130
|
+
type: 'system',
|
|
131
|
+
name: 'typeColors',
|
|
132
|
+
keys: {
|
|
133
|
+
body: 'system.color.fg.default',
|
|
134
|
+
heading: 'system.color.fg.strong',
|
|
135
|
+
hint: 'system.color.fg.muted.soft',
|
|
136
|
+
inverse: 'system.color.fg.inverse',
|
|
137
|
+
label: 'system.color.fg.default',
|
|
138
|
+
link: 'system.color.fg.primary.default',
|
|
139
|
+
selectHighlight: 'system.color.fg.primary.default',
|
|
140
|
+
selectHighlightInverse: 'system.color.fg.inverse',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
86
143
|
borderRadius: {
|
|
87
144
|
name: 'shape',
|
|
88
145
|
type: 'system',
|
|
@@ -148,7 +205,7 @@ export const systemColors = {
|
|
|
148
205
|
licorice400: 'system.color.fg.muted.strong',
|
|
149
206
|
licorice500: 'system.color.fg.muted.stronger',
|
|
150
207
|
},
|
|
151
|
-
'border,borderColor,borderTopColor,borderRightColor,borderBottomColor,borderLeftColor,borderInlineColor,borderBlockColor,borderInlineStartColor,borderInlineEndColor,borderBlockStartColor,borderBlockEndColor,borderColorFocus,borderColorHover,borderColorActive': {
|
|
208
|
+
'border,borderColor,borderTop,borderTopColor,borderRight,borderRightColor,borderBottom,borderBottomColor,borderLeft,borderLeftColor,borderInlineColor,borderBlockColor,borderInline,borderInlineStart,borderInlineStartColor,borderInlineEnd,borderInlineEndColor,borderBlockStart,borderBlockStartColor,borderBlockEnd,borderBlockEndColor,borderColorFocus,borderColorHover,borderColorActive': {
|
|
152
209
|
blackPepper400: 'system.color.border.contrast.default',
|
|
153
210
|
blackPepper500: 'system.color.border.contrast.strong',
|
|
154
211
|
blueberry400: 'system.color.border.primary.default',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateColorTokens.d.ts","sourceRoot":"","sources":["../../../lib/v13.2/migrateColorTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"migrateColorTokens.d.ts","sourceRoot":"","sources":["../../../lib/v13.2/migrateColorTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAC,MAAM,aAAa,CAAC;AAiBlD,QAAA,MAAM,SAAS,EAAE,SA0JhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addMissingImports, filterOutImports, transformObjectPropertyRecursively } from './utils';
|
|
1
|
+
import { addMissingImports, filterOutImports, transformObjectPropertyRecursively, varToMemberExpression, } from './utils';
|
|
2
2
|
import { mapping } from './mapping';
|
|
3
3
|
const canvasImportSources = [
|
|
4
4
|
'@workday/canvas-kit-styling',
|
|
@@ -30,7 +30,7 @@ const transform = (file, api) => {
|
|
|
30
30
|
const name = nodePath.value.callee.name;
|
|
31
31
|
const stylesDeclaration = nodePath.value.arguments[0];
|
|
32
32
|
const isCanvasKitStyling = importDeclaration[name] === 'createStyles' || importDeclaration[name] === 'createStencil';
|
|
33
|
-
if (stylesDeclaration.type === 'ObjectExpression') {
|
|
33
|
+
if ((stylesDeclaration === null || stylesDeclaration === void 0 ? void 0 : stylesDeclaration.type) === 'ObjectExpression') {
|
|
34
34
|
stylesDeclaration.properties = stylesDeclaration.properties.map((prop) => transformObjectPropertyRecursively({ j, root }, prop, importDeclaration, isCanvasKitStyling));
|
|
35
35
|
}
|
|
36
36
|
});
|
|
@@ -39,21 +39,59 @@ const transform = (file, api) => {
|
|
|
39
39
|
});
|
|
40
40
|
root
|
|
41
41
|
.find(j.MemberExpression, (value) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
// Matches: commonColors.background
|
|
43
|
+
const isTwoParts = value.type === 'MemberExpression' &&
|
|
44
|
+
value.object.type === 'Identifier' &&
|
|
45
|
+
checkImport(value.object.name);
|
|
46
|
+
// Matches: inputColors.disabled.border
|
|
47
|
+
const isThreeParts = value.type === 'MemberExpression' &&
|
|
48
|
+
value.object.type === 'MemberExpression' &&
|
|
49
|
+
value.object.object.type === 'Identifier' &&
|
|
50
|
+
checkImport(value.object.object.name);
|
|
51
|
+
return isTwoParts || isThreeParts;
|
|
47
52
|
})
|
|
48
53
|
.replaceWith(nodePath => {
|
|
54
|
+
var _a;
|
|
49
55
|
const mainWrapper = nodePath.value.object;
|
|
50
|
-
if (mainWrapper.type === '
|
|
56
|
+
if (mainWrapper.type === 'MemberExpression') {
|
|
57
|
+
const mainObject = mainWrapper.object;
|
|
58
|
+
const mainName = mainObject.type === 'Identifier' ? mainObject.name : '';
|
|
59
|
+
const mainProperty = mainWrapper.property;
|
|
60
|
+
const lowestProperty = nodePath.value.property;
|
|
61
|
+
const importedName = importDeclaration[mainName];
|
|
62
|
+
const map = mapping[importedName];
|
|
63
|
+
if ((map === null || map === void 0 ? void 0 : map.type) === 'system' &&
|
|
64
|
+
importedName &&
|
|
65
|
+
importedName.toLowerCase().includes('colors') &&
|
|
66
|
+
mainProperty.type === 'Identifier' &&
|
|
67
|
+
lowestProperty.type === 'Identifier') {
|
|
68
|
+
const innerGroup = map.keys[mainProperty.name] || {};
|
|
69
|
+
const token = innerGroup[lowestProperty.name];
|
|
70
|
+
if (token) {
|
|
71
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
72
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
73
|
+
return j.callExpression(j.identifier('cssVar'), [varToMemberExpression(j, token)]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (mainWrapper.type === 'Identifier' &&
|
|
78
|
+
((_a = importDeclaration[mainWrapper.name]) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('colors'))) {
|
|
51
79
|
const mainObject = mainWrapper;
|
|
52
80
|
const mainName = mainObject.name;
|
|
53
81
|
const lowestProperty = nodePath.value.property;
|
|
54
82
|
const importedName = importDeclaration[mainName];
|
|
55
83
|
const map = mapping[importedName];
|
|
56
|
-
if (map
|
|
84
|
+
if ((map === null || map === void 0 ? void 0 : map.type) === 'system' &&
|
|
85
|
+
lowestProperty.type === 'Identifier' &&
|
|
86
|
+
importedName !== 'inputColors') {
|
|
87
|
+
const token = map.keys[lowestProperty.name];
|
|
88
|
+
if (token && typeof token === 'string') {
|
|
89
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
90
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
91
|
+
return j.callExpression(j.identifier('cssVar'), [varToMemberExpression(j, token)]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if ((map === null || map === void 0 ? void 0 : map.type) === 'base' && lowestProperty.type === 'Identifier') {
|
|
57
95
|
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['base'] });
|
|
58
96
|
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
59
97
|
return j.callExpression(j.identifier('cssVar'), [
|
|
@@ -61,7 +99,7 @@ const transform = (file, api) => {
|
|
|
61
99
|
]);
|
|
62
100
|
}
|
|
63
101
|
}
|
|
64
|
-
return nodePath;
|
|
102
|
+
return nodePath.value;
|
|
65
103
|
});
|
|
66
104
|
return root.toSource();
|
|
67
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateOtherTokens.d.ts","sourceRoot":"","sources":["../../../lib/v13.2/migrateOtherTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,SAAS,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"migrateOtherTokens.d.ts","sourceRoot":"","sources":["../../../lib/v13.2/migrateOtherTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,SAAS,EAAC,MAAM,aAAa,CAAC;AAcpE,QAAA,MAAM,SAAS,EAAE,SAqLhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -5,6 +5,7 @@ const canvasImportSources = [
|
|
|
5
5
|
'@workday/canvas-kit-react/tokens',
|
|
6
6
|
'@workday/canvas-space-web',
|
|
7
7
|
];
|
|
8
|
+
const tokens = ['space', 'borderRadius'];
|
|
8
9
|
const transform = (file, api) => {
|
|
9
10
|
const j = api.jscodeshift;
|
|
10
11
|
const root = j(file.source);
|
|
@@ -17,10 +18,10 @@ const transform = (file, api) => {
|
|
|
17
18
|
.forEach(nodePath => {
|
|
18
19
|
importDeclaration = {
|
|
19
20
|
...importDeclaration,
|
|
20
|
-
...filterOutImports(nodePath,
|
|
21
|
+
...filterOutImports(nodePath, tokens),
|
|
21
22
|
};
|
|
22
23
|
});
|
|
23
|
-
if (!Object.values(importDeclaration).some(value => value
|
|
24
|
+
if (!Object.values(importDeclaration).some(value => tokens.includes(value))) {
|
|
24
25
|
return root.toSource();
|
|
25
26
|
}
|
|
26
27
|
root
|
|
@@ -30,7 +31,6 @@ const transform = (file, api) => {
|
|
|
30
31
|
},
|
|
31
32
|
})
|
|
32
33
|
.forEach(nodePath => {
|
|
33
|
-
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
34
34
|
const name = nodePath.value.callee.name;
|
|
35
35
|
const stylesDeclaration = nodePath.value.arguments[0];
|
|
36
36
|
const isCanvasKitStyling = importDeclaration[name] === 'createStyles' || importDeclaration[name] === 'createStencil';
|
|
@@ -42,7 +42,7 @@ const transform = (file, api) => {
|
|
|
42
42
|
property.value.type === 'MemberExpression' &&
|
|
43
43
|
property.value.object.type === 'Identifier' &&
|
|
44
44
|
property.value.property.type === 'Identifier' &&
|
|
45
|
-
importDeclaration[property.value.object.name]
|
|
45
|
+
tokens.includes(importDeclaration[property.value.object.name])) {
|
|
46
46
|
const key = property.key.name;
|
|
47
47
|
const tokens = (_a = Object.entries(systemColors).find(([blockKey]) => blockKey.split(',').some(prop => prop === key))) === null || _a === void 0 ? void 0 : _a[1];
|
|
48
48
|
const { property: value } = property.value;
|
|
@@ -51,6 +51,7 @@ const transform = (file, api) => {
|
|
|
51
51
|
if (!isCanvasKitStyling) {
|
|
52
52
|
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
53
53
|
}
|
|
54
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
54
55
|
return j.objectProperty(j.identifier(key), isCanvasKitStyling
|
|
55
56
|
? varToMemberExpression(j, colorToken)
|
|
56
57
|
: j.callExpression(j.identifier('cssVar'), [varToMemberExpression(j, colorToken)]));
|
|
@@ -64,11 +65,12 @@ const transform = (file, api) => {
|
|
|
64
65
|
if (expr.type === 'MemberExpression' &&
|
|
65
66
|
expr.object.type === 'Identifier' &&
|
|
66
67
|
expr.property.type === 'Identifier' &&
|
|
67
|
-
importDeclaration[expr.object.name]
|
|
68
|
+
tokens.includes(importDeclaration[expr.object.name])) {
|
|
68
69
|
const tokens = (_a = Object.entries(systemColors).find(([blockKey]) => blockKey.split(',').some(prop => prop === property.key.name))) === null || _a === void 0 ? void 0 : _a[1];
|
|
69
70
|
const colorToken = tokens === null || tokens === void 0 ? void 0 : tokens[expr.property.name];
|
|
70
71
|
if (colorToken) {
|
|
71
72
|
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
73
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
72
74
|
return j.callExpression(j.identifier('cssVar'), [
|
|
73
75
|
varToMemberExpression(j, colorToken),
|
|
74
76
|
]);
|
|
@@ -96,23 +98,23 @@ const transform = (file, api) => {
|
|
|
96
98
|
})
|
|
97
99
|
.replaceWith(nodePath => {
|
|
98
100
|
const mainWrapper = nodePath.value.object;
|
|
99
|
-
if (mainWrapper.type === 'Identifier' &&
|
|
100
|
-
|
|
101
|
-
const mainName =
|
|
101
|
+
if (mainWrapper.type === 'Identifier' &&
|
|
102
|
+
tokens.includes(importDeclaration[mainWrapper.name])) {
|
|
103
|
+
const mainName = mainWrapper.name;
|
|
102
104
|
const lowestProperty = nodePath.value.property;
|
|
103
105
|
const importedName = importDeclaration[mainName];
|
|
104
106
|
const map = mapping[importedName];
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
])
|
|
112
|
-
|
|
107
|
+
if (['space', 'borderRadius'].includes(importedName) &&
|
|
108
|
+
(map === null || map === void 0 ? void 0 : map.type) === 'system' &&
|
|
109
|
+
lowestProperty.type === 'Identifier') {
|
|
110
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
111
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
112
|
+
return j.callExpression(j.identifier('cssVar'), [
|
|
113
|
+
j.memberExpression(j.memberExpression(j.identifier(map.type), j.identifier(map.name)), j.identifier(map.keys[lowestProperty.name])),
|
|
114
|
+
]);
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
|
-
return nodePath;
|
|
117
|
+
return nodePath.value;
|
|
116
118
|
});
|
|
117
119
|
return root.toSource();
|
|
118
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterOutImports.d.ts","sourceRoot":"","sources":["../../../../lib/v13.2/utils/filterOutImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAEvD,KAAK,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,cAAc,CAAC;AASzE,eAAO,MAAM,gBAAgB,aACjB,QAAQ,iBAAiB,CAAC,QAC9B,UAAU,GAAG,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"filterOutImports.d.ts","sourceRoot":"","sources":["../../../../lib/v13.2/utils/filterOutImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAEvD,KAAK,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,cAAc,CAAC;AASzE,eAAO,MAAM,gBAAgB,aACjB,QAAQ,iBAAiB,CAAC,QAC9B,UAAU,GAAG,UAAU,EAAE,2BA2BhC,CAAC"}
|
|
@@ -12,7 +12,8 @@ export const filterOutImports = (nodePath, type) => {
|
|
|
12
12
|
const localName = specifier.local.name.toString();
|
|
13
13
|
const importedName = specifier.imported.name.toString();
|
|
14
14
|
importName[localName] = importedName;
|
|
15
|
-
return !(type.includes(
|
|
15
|
+
return !(((typeof type === 'string' && importedName.toLowerCase().includes(type)) ||
|
|
16
|
+
type.includes(importedName)) &&
|
|
16
17
|
typeof nodePath.value.source.value === 'string' &&
|
|
17
18
|
canvasImportSources.includes(nodePath.value.source.value));
|
|
18
19
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@workday/canvas-kit-codemod",
|
|
3
3
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "13.2.
|
|
5
|
+
"version": "13.2.43",
|
|
6
6
|
"description": "A collection of codemods for use on Workday Canvas Kit packages.",
|
|
7
7
|
"main": "dist/es6/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"resolutions": {
|
|
47
47
|
"recast": "0.20.4"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "90bc7321a9d24b04f2e816ab8d7d33cb81f2edb0"
|
|
50
50
|
}
|