@workday/canvas-kit-codemod 7.1.4 → 7.2.0-427-next.2
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/README.md +41 -5
- package/dist/es6/v5/compoundCard.js +19 -22
- package/dist/es6/v5/getImportRenameMap.js +11 -12
- package/dist/es6/v5/index.js +2 -13
- package/dist/es6/v5/mapTypeTokensToNewHierarchy.js +62 -62
- package/dist/es6/v5/maps.js +2 -2
- package/dist/es6/v5/moveInputProvider.js +6 -6
- package/dist/es6/v5/recategorizeButtons.js +34 -35
- package/dist/es6/v5/removeButtonEnums.js +26 -28
- package/dist/es6/v5/removeDefaultImports.js +7 -7
- package/dist/es6/v5/renameButtonRefs.js +8 -8
- package/dist/es6/v5/renameCoreImports.js +10 -10
- package/dist/es6/v5/renameInputRefs.js +17 -21
- package/dist/es6/v5/renamePreviewTokenImports.js +10 -10
- package/dist/es6/v5/renameSpacing.js +18 -18
- package/dist/es6/v5/slashImports.js +31 -33
- package/dist/es6/v6/deprecateCookieBanner.js +3 -3
- package/dist/es6/v6/deprecateHeader.js +4 -4
- package/dist/es6/v6/deprecatePageHeader.js +3 -3
- package/dist/es6/v6/index.js +3 -14
- package/dist/es6/v6/moveAndRenameSearchBar.js +23 -29
- package/dist/es6/v6/renameCanvasDepthValue.js +3 -3
- package/dist/es6/v6/utils/index.js +28 -31
- package/dist/es6/v7/compoundActionBar.js +27 -39
- package/dist/es6/v7/compoundBanner.js +40 -43
- package/dist/es6/v7/index.js +3 -14
- package/dist/es6/v7/recategorizeIconButtons.js +27 -31
- package/dist/es6/v7/removePropFromPopper.js +14 -18
- package/dist/es6/v7/renameIconPosition.js +13 -17
- package/dist/es6/v7/renameIconRef.js +17 -21
- package/dist/es6/v7/renameLayoutImports.js +14 -14
- package/dist/es6/v7/updateDisclosureShowHide.js +22 -22
- package/dist/es6/v7/updateModelSignatures.js +21 -21
- package/dist/es6/v7/updateSegmentedControl.js +8 -11
- package/dist/es6/v7/updateTabs.js +8 -8
- package/dist/es6/v7/utils/getImportRenameMap.js +11 -12
- package/dist/es6/v7/utils/hasImportSpecifiers.js +9 -11
- package/dist/es6/v8/index.d.ts +4 -0
- package/dist/es6/v8/index.d.ts.map +1 -0
- package/dist/es6/v8/index.js +25 -0
- package/dist/es6/v8/promoteBreadcrumbs.d.ts +4 -0
- package/dist/es6/v8/promoteBreadcrumbs.d.ts.map +1 -0
- package/dist/es6/v8/promoteBreadcrumbs.js +56 -0
- package/dist/es6/v8/promoteComponentsToTesting.d.ts +4 -0
- package/dist/es6/v8/promoteComponentsToTesting.d.ts.map +1 -0
- package/dist/es6/v8/promoteComponentsToTesting.js +76 -0
- package/dist/es6/v8/refactorActionBarOverflowButton.d.ts +3 -0
- package/dist/es6/v8/refactorActionBarOverflowButton.d.ts.map +1 -0
- package/dist/es6/v8/refactorActionBarOverflowButton.js +46 -0
- package/dist/es6/v8/removeDefaultImports.d.ts +3 -0
- package/dist/es6/v8/removeDefaultImports.d.ts.map +1 -0
- package/dist/es6/v8/removeDefaultImports.js +52 -0
- package/dist/es6/v8/renameLoadingAnimation.d.ts +3 -0
- package/dist/es6/v8/renameLoadingAnimation.d.ts.map +1 -0
- package/dist/es6/v8/renameLoadingAnimation.js +62 -0
- package/dist/es6/v8/restructureBreadcrumbs.d.ts +3 -0
- package/dist/es6/v8/restructureBreadcrumbs.d.ts.map +1 -0
- package/dist/es6/v8/restructureBreadcrumbs.js +55 -0
- package/dist/es6/v8/softDeprecateDrawer.d.ts +3 -0
- package/dist/es6/v8/softDeprecateDrawer.d.ts.map +1 -0
- package/dist/es6/v8/softDeprecateDrawer.js +103 -0
- package/dist/es6/v8/softDeprecateLayout.d.ts +3 -0
- package/dist/es6/v8/softDeprecateLayout.d.ts.map +1 -0
- package/dist/es6/v8/softDeprecateLayout.js +76 -0
- package/dist/es6/v8/softDeprecatePreviewMenu.d.ts +3 -0
- package/dist/es6/v8/softDeprecatePreviewMenu.d.ts.map +1 -0
- package/dist/es6/v8/softDeprecatePreviewMenu.js +79 -0
- package/dist/es6/v9/compoundToast.d.ts +3 -0
- package/dist/es6/v9/compoundToast.d.ts.map +1 -0
- package/dist/es6/v9/compoundToast.js +121 -0
- package/dist/es6/v9/deprecateStack.d.ts +3 -0
- package/dist/es6/v9/deprecateStack.d.ts.map +1 -0
- package/dist/es6/v9/deprecateStack.js +275 -0
- package/dist/es6/v9/index.d.ts +4 -0
- package/dist/es6/v9/index.d.ts.map +1 -0
- package/dist/es6/v9/index.js +16 -0
- package/dist/es6/v9/promoteToast.d.ts +4 -0
- package/dist/es6/v9/promoteToast.d.ts.map +1 -0
- package/dist/es6/v9/promoteToast.js +56 -0
- package/dist/es6/v9/promoteUseThemedRing.d.ts +4 -0
- package/dist/es6/v9/promoteUseThemedRing.d.ts.map +1 -0
- package/dist/es6/v9/promoteUseThemedRing.js +56 -0
- package/index.js +40 -5
- package/package.json +2 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// used to filter our imports we want to keep in @workday/canvas-kit-labs-react/common
|
|
2
|
-
|
|
2
|
+
const commonSpecifiers = [
|
|
3
3
|
'useTheme',
|
|
4
4
|
'ComponentStatesTable',
|
|
5
5
|
'permutateProps',
|
|
6
6
|
'useThemeRTL',
|
|
7
7
|
'useThemedRing',
|
|
8
8
|
];
|
|
9
|
-
|
|
9
|
+
const layoutSpecifiers = [
|
|
10
10
|
'Flex',
|
|
11
11
|
'Stack',
|
|
12
12
|
'StackProps',
|
|
@@ -46,18 +46,18 @@ var layoutSpecifiers = [
|
|
|
46
46
|
// 2. Filter through all imports from @workday/canvas-kit-labs-react/common and gather specifiers we care about
|
|
47
47
|
// 3. If there's an existing @workday/canvas-kit-react/layout add gathered specifiers to that import
|
|
48
48
|
// 4. If no existing import, create new import with specifiers and insert before closest canvas kit import
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
const transform = (file, api) => {
|
|
50
|
+
const j = api.jscodeshift;
|
|
51
|
+
const root = j(file.source);
|
|
52
|
+
const reactLayoutSpecifiers = [];
|
|
53
|
+
const foundImport = [];
|
|
54
54
|
root
|
|
55
55
|
.find(j.ImportDeclaration, {
|
|
56
|
-
source: { value:
|
|
56
|
+
source: { value: (value) => value.includes('@workday/canvas-kit-labs-react') },
|
|
57
57
|
})
|
|
58
|
-
.forEach(
|
|
58
|
+
.forEach(nodePath => {
|
|
59
59
|
var _a;
|
|
60
|
-
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.filter(
|
|
60
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.filter(specifier => {
|
|
61
61
|
var _a, _b, _c, _d;
|
|
62
62
|
if (specifier.type === 'ImportSpecifier' &&
|
|
63
63
|
!commonSpecifiers.includes(specifier.imported.name)) {
|
|
@@ -74,15 +74,15 @@ var transform = function (file, api) {
|
|
|
74
74
|
});
|
|
75
75
|
foundImport.push(nodePath);
|
|
76
76
|
});
|
|
77
|
-
|
|
77
|
+
const existingLayoutImports = root.find(j.ImportDeclaration, {
|
|
78
78
|
source: { value: '@workday/canvas-kit-react/layout' },
|
|
79
79
|
});
|
|
80
|
-
|
|
80
|
+
const mapToSpecifiers = (specifier) => {
|
|
81
81
|
return j.importSpecifier(j.identifier(specifier.name), specifier.importedName ? j.identifier(specifier.importedName) : undefined);
|
|
82
82
|
};
|
|
83
83
|
// add to existing import
|
|
84
84
|
if (existingLayoutImports.length) {
|
|
85
|
-
existingLayoutImports.forEach(
|
|
85
|
+
existingLayoutImports.forEach(nodePath => {
|
|
86
86
|
var _a;
|
|
87
87
|
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.concat(reactLayoutSpecifiers.map(mapToSpecifiers));
|
|
88
88
|
});
|
|
@@ -93,7 +93,7 @@ var transform = function (file, api) {
|
|
|
93
93
|
foundImport[0].insertBefore(j.importDeclaration(reactLayoutSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/layout')));
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
foundImport.forEach(
|
|
96
|
+
foundImport.forEach(importPath => {
|
|
97
97
|
var _a;
|
|
98
98
|
if (((_a = importPath.value.specifiers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
99
99
|
importPath.value.source.value === '@workday/canvas-kit-labs-react/layout') {
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { getImportRenameMap } from './utils/getImportRenameMap';
|
|
2
|
-
|
|
2
|
+
const keys = (input) => Object.keys(input);
|
|
3
3
|
export default function transformer(file, api, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const j = api.jscodeshift;
|
|
5
|
+
const root = j(file.source);
|
|
6
|
+
const { containsCanvasImports, importMap } = getImportRenameMap(j, root);
|
|
7
7
|
if (!containsCanvasImports) {
|
|
8
8
|
return file.source;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
const disclosureModels = [
|
|
11
11
|
'useDisclosureModel',
|
|
12
12
|
'usePopupModel',
|
|
13
13
|
'useModalModel',
|
|
14
14
|
'useDialogModel',
|
|
15
15
|
];
|
|
16
16
|
// inverse the import map. It is more useful this way for this function
|
|
17
|
-
|
|
17
|
+
const imports = Object.keys(importMap).reduce((result, key) => {
|
|
18
18
|
result[importMap[key]] = key;
|
|
19
19
|
return result;
|
|
20
20
|
}, {});
|
|
21
|
-
root.find(j.CallExpression).forEach(
|
|
22
|
-
|
|
21
|
+
root.find(j.CallExpression).forEach(nodePath => {
|
|
22
|
+
const { value } = nodePath;
|
|
23
23
|
// check if the identifier was imported from CK AND follows the `use{*}Model` naming convention
|
|
24
24
|
if (value.callee.type === 'Identifier' &&
|
|
25
25
|
disclosureModels.includes(imports[value.callee.name])) {
|
|
26
26
|
// loop over all the arguments of the `use{*}Model` hook
|
|
27
|
-
value.arguments.forEach(
|
|
27
|
+
value.arguments.forEach(argument => {
|
|
28
28
|
// look for object expressions: `use{*}Model({ /* here */ })`
|
|
29
29
|
if (argument.type === 'ObjectExpression') {
|
|
30
30
|
// loop over all the properties looking for `ObjectMethod` and `ObjectProperties` where
|
|
31
31
|
// the value is a function matching `on{*}` or `should{*}` naming convention
|
|
32
|
-
argument.properties.forEach(
|
|
32
|
+
argument.properties.forEach(property => {
|
|
33
33
|
// If it is an `ObjectMethod` or an `ObjectProperty` with an arrow function expression:
|
|
34
34
|
// {
|
|
35
35
|
// onShow() {}, // ObjectMethod
|
|
@@ -39,37 +39,37 @@ export default function transformer(file, api, options) {
|
|
|
39
39
|
(property.type === 'ObjectProperty' &&
|
|
40
40
|
property.value.type === 'ArrowFunctionExpression')) &&
|
|
41
41
|
property.key.type === 'Identifier') {
|
|
42
|
-
|
|
42
|
+
const propertyName = property.key.name;
|
|
43
43
|
// Both types have a `params`, but are at different places in the AST
|
|
44
|
-
|
|
44
|
+
const params = property.type === 'ObjectMethod'
|
|
45
45
|
? property.params
|
|
46
46
|
: property.value.type === 'ArrowFunctionExpression'
|
|
47
47
|
? property.value.params
|
|
48
48
|
: [];
|
|
49
49
|
// create a mapping for param names of callbacks and guards. This makes the logic more
|
|
50
50
|
// difficult to follow, but decreases duplication
|
|
51
|
-
|
|
51
|
+
const paramMapping = {
|
|
52
52
|
on: ['event'],
|
|
53
53
|
should: ['event'],
|
|
54
54
|
};
|
|
55
55
|
// We will be overriding the params with this variable later
|
|
56
|
-
|
|
56
|
+
const finalParams = [];
|
|
57
57
|
// loop over each `paramMapping` type. `on*` and `should*` functions have different signatures
|
|
58
|
-
keys(
|
|
58
|
+
keys(paramMapping).forEach(key => {
|
|
59
59
|
// matches `onShow` and `shouldShow`
|
|
60
|
-
if (new RegExp(key
|
|
61
|
-
|
|
60
|
+
if (new RegExp(`${key}[A-Za-z]+`).test(propertyName)) {
|
|
61
|
+
params.forEach(param => {
|
|
62
62
|
if (param.type === 'ObjectPattern') {
|
|
63
|
-
param.properties.forEach(
|
|
63
|
+
param.properties.forEach(property => {
|
|
64
64
|
if (property.type === 'ObjectProperty' &&
|
|
65
65
|
property.key.type === 'Identifier') {
|
|
66
66
|
if (property.value.type === 'Identifier' ||
|
|
67
67
|
property.value.type === 'ObjectPattern') {
|
|
68
|
-
|
|
68
|
+
const index = paramMapping[key].indexOf(property.key.name);
|
|
69
69
|
// use `property.value` instead of `property.key.name` in case they
|
|
70
70
|
// renamed it example `shouldShow({ data: myData })`. The key name is
|
|
71
71
|
// `data` while the value is `myData`
|
|
72
|
-
|
|
72
|
+
finalParams[index] = property.value;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
});
|
|
@@ -78,11 +78,11 @@ export default function transformer(file, api, options) {
|
|
|
78
78
|
// `ObjectMethod` and `ObjectProperty` have params in a different place in the
|
|
79
79
|
// AST, so apply `finalParams` where appropriate
|
|
80
80
|
if (property.type === 'ObjectMethod') {
|
|
81
|
-
property.params =
|
|
81
|
+
property.params = finalParams;
|
|
82
82
|
}
|
|
83
83
|
else if (property.type === 'ObjectProperty' &&
|
|
84
84
|
property.value.type === 'ArrowFunctionExpression') {
|
|
85
|
-
property.value.params =
|
|
85
|
+
property.value.params = finalParams;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
});
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { getImportRenameMap } from './utils/getImportRenameMap';
|
|
2
|
-
|
|
2
|
+
const keys = (input) => Object.keys(input);
|
|
3
3
|
export default function transformer(file, api, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const j = api.jscodeshift;
|
|
5
|
+
const root = j(file.source);
|
|
6
|
+
const { containsCanvasImports, importMap } = getImportRenameMap(j, root);
|
|
7
7
|
if (!containsCanvasImports) {
|
|
8
8
|
return file.source;
|
|
9
9
|
}
|
|
10
10
|
// inverse the import map. It is more useful this way for this function
|
|
11
|
-
|
|
11
|
+
const imports = Object.keys(importMap).reduce((result, key) => {
|
|
12
12
|
result[importMap[key]] = key;
|
|
13
13
|
return result;
|
|
14
14
|
}, {});
|
|
15
|
-
root.find(j.CallExpression).forEach(
|
|
16
|
-
|
|
15
|
+
root.find(j.CallExpression).forEach(nodePath => {
|
|
16
|
+
const { value } = nodePath;
|
|
17
17
|
// check if the identifier was imported from CK AND follows the `use{*}Model` naming convention
|
|
18
18
|
if (value.callee.type === 'Identifier' &&
|
|
19
19
|
/use[a-zA-Z]+Model/.test(imports[value.callee.name])) {
|
|
20
20
|
// loop over all the arguments of the `use{*}Model` hook
|
|
21
|
-
value.arguments.forEach(
|
|
21
|
+
value.arguments.forEach(argument => {
|
|
22
22
|
// look for object expressions: `use{*}Model({ /* here */ })`
|
|
23
23
|
if (argument.type === 'ObjectExpression') {
|
|
24
24
|
// loop over all the properties looking for `ObjectMethod` and `ObjectProperties` where
|
|
25
25
|
// the value is a function matching `on{*}` or `should{*}` naming convention
|
|
26
|
-
argument.properties.forEach(
|
|
26
|
+
argument.properties.forEach(property => {
|
|
27
27
|
// If it is an `ObjectMethod` or an `ObjectProperty` with an arrow function expression:
|
|
28
28
|
// {
|
|
29
29
|
// onShow() {}, // ObjectMethod
|
|
@@ -33,37 +33,37 @@ export default function transformer(file, api, options) {
|
|
|
33
33
|
(property.type === 'ObjectProperty' &&
|
|
34
34
|
property.value.type === 'ArrowFunctionExpression')) &&
|
|
35
35
|
property.key.type === 'Identifier') {
|
|
36
|
-
|
|
36
|
+
const propertyName = property.key.name;
|
|
37
37
|
// Both types have a `params`, but are at different places in the AST
|
|
38
|
-
|
|
38
|
+
const params = property.type === 'ObjectMethod'
|
|
39
39
|
? property.params
|
|
40
40
|
: property.value.type === 'ArrowFunctionExpression'
|
|
41
41
|
? property.value.params
|
|
42
42
|
: [];
|
|
43
43
|
// create a mapping for param names of callbacks and guards. This makes the logic more
|
|
44
44
|
// difficult to follow, but decreases duplication
|
|
45
|
-
|
|
45
|
+
const paramMapping = {
|
|
46
46
|
on: ['data', 'state'],
|
|
47
47
|
should: ['data', 'prevState'],
|
|
48
48
|
};
|
|
49
49
|
// We will be overriding the params with this variable later
|
|
50
|
-
|
|
50
|
+
const finalParams = [];
|
|
51
51
|
// loop over each `paramMapping` type. `on*` and `should*` functions have different signatures
|
|
52
|
-
keys(
|
|
52
|
+
keys(paramMapping).forEach(key => {
|
|
53
53
|
// matches `onShow` and `shouldShow`
|
|
54
|
-
if (new RegExp(key
|
|
55
|
-
|
|
54
|
+
if (new RegExp(`${key}[A-Za-z]+`).test(propertyName)) {
|
|
55
|
+
params.forEach(param => {
|
|
56
56
|
if (param.type === 'ObjectPattern') {
|
|
57
|
-
param.properties.forEach(
|
|
57
|
+
param.properties.forEach(property => {
|
|
58
58
|
if (property.type === 'ObjectProperty' &&
|
|
59
59
|
property.key.type === 'Identifier') {
|
|
60
60
|
if (property.value.type === 'Identifier' ||
|
|
61
61
|
property.value.type === 'ObjectPattern') {
|
|
62
|
-
|
|
62
|
+
const index = paramMapping[key].indexOf(property.key.name);
|
|
63
63
|
// use `property.value` instead of `property.key.name` in case they
|
|
64
64
|
// renamed it example `shouldShow({ data: myData })`. The key name is
|
|
65
65
|
// `data` while the value is `myData`
|
|
66
|
-
|
|
66
|
+
finalParams[index] = property.value;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
});
|
|
@@ -72,11 +72,11 @@ export default function transformer(file, api, options) {
|
|
|
72
72
|
// `ObjectMethod` and `ObjectProperty` have params in a different place in the
|
|
73
73
|
// AST, so apply `finalParams` where appropriate
|
|
74
74
|
if (property.type === 'ObjectMethod') {
|
|
75
|
-
property.params =
|
|
75
|
+
property.params = finalParams;
|
|
76
76
|
}
|
|
77
77
|
else if (property.type === 'ObjectProperty' &&
|
|
78
78
|
property.value.type === 'ArrowFunctionExpression') {
|
|
79
|
-
property.value.params =
|
|
79
|
+
property.value.params = finalParams;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
});
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { getImportRenameMap } from './utils/getImportRenameMap';
|
|
2
2
|
export default function transformer(file, api, options) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const j = api.jscodeshift;
|
|
4
|
+
const root = j(file.source);
|
|
5
|
+
const { containsCanvasImports, importMap, styledMap } = getImportRenameMap(j, root, '@workday/canvas-kit-react/segmented-control');
|
|
6
6
|
if (!containsCanvasImports) {
|
|
7
7
|
return file.source;
|
|
8
8
|
}
|
|
9
9
|
root
|
|
10
|
-
.find(j.JSXElement,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.forEach(function (nodePath) {
|
|
16
|
-
for (var _i = 0, _a = nodePath.value.children || []; _i < _a.length; _i++) {
|
|
17
|
-
var child = _a[_i];
|
|
10
|
+
.find(j.JSXElement, (value) => value.openingElement.name.type === 'JSXIdentifier' &&
|
|
11
|
+
(value.openingElement.name.name === importMap.SegmentedControl ||
|
|
12
|
+
value.openingElement.name.name === styledMap.SegmentedControl))
|
|
13
|
+
.forEach(nodePath => {
|
|
14
|
+
for (const child of nodePath.value.children || []) {
|
|
18
15
|
if (child.type === 'JSXElement' && child.openingElement.name.type === 'JSXIdentifier') {
|
|
19
16
|
child.openingElement.name.name = 'SegmentedControl.Button';
|
|
20
17
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getImportRenameMap } from './utils/getImportRenameMap';
|
|
2
2
|
export default function transformer(file, api, options) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const j = api.jscodeshift;
|
|
4
|
+
const root = j(file.source);
|
|
5
|
+
const { containsCanvasImports, importMap } = getImportRenameMap(j, root);
|
|
6
6
|
if (!containsCanvasImports) {
|
|
7
7
|
return file.source;
|
|
8
8
|
}
|
|
@@ -10,13 +10,13 @@ export default function transformer(file, api, options) {
|
|
|
10
10
|
// Find <Tabs
|
|
11
11
|
.find(j.JSXOpeningElement, { name: { object: { name: importMap.Tabs } } })
|
|
12
12
|
// Filter for <Tabs.Item and <Tabs.Panel
|
|
13
|
-
.filter(
|
|
13
|
+
.filter(path => {
|
|
14
14
|
return (path.value.name.type === 'JSXMemberExpression' &&
|
|
15
15
|
(path.value.name.property.name === 'Item' || path.value.name.property.name === 'Panel'));
|
|
16
16
|
})
|
|
17
|
-
.forEach(
|
|
17
|
+
.forEach(nodePath => {
|
|
18
18
|
var _a;
|
|
19
|
-
nodePath.value.attributes = (_a = nodePath.value.attributes) === null || _a === void 0 ? void 0 : _a.map(
|
|
19
|
+
nodePath.value.attributes = (_a = nodePath.value.attributes) === null || _a === void 0 ? void 0 : _a.map(attribute => {
|
|
20
20
|
if (attribute.type === 'JSXAttribute' &&
|
|
21
21
|
attribute.name.type === 'JSXIdentifier' &&
|
|
22
22
|
attribute.name.name === 'name') {
|
|
@@ -33,9 +33,9 @@ export default function transformer(file, api, options) {
|
|
|
33
33
|
property: { name: 'Item' },
|
|
34
34
|
},
|
|
35
35
|
})
|
|
36
|
-
.forEach(
|
|
36
|
+
.forEach(nodePath => {
|
|
37
37
|
var _a;
|
|
38
|
-
nodePath.value.attributes = (_a = nodePath.value.attributes) === null || _a === void 0 ? void 0 : _a.map(
|
|
38
|
+
nodePath.value.attributes = (_a = nodePath.value.attributes) === null || _a === void 0 ? void 0 : _a.map(attribute => {
|
|
39
39
|
if (attribute.type === 'JSXAttribute' &&
|
|
40
40
|
attribute.name.type === 'JSXIdentifier' &&
|
|
41
41
|
attribute.name.name === 'name') {
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
export function getImportRenameMap(j, root, packageName) {
|
|
2
|
-
|
|
3
|
-
var containsCanvasImports = false;
|
|
1
|
+
export function getImportRenameMap(j, root, packageName = '') {
|
|
2
|
+
let containsCanvasImports = false;
|
|
4
3
|
// build import name remapping - in case someone renamed imports...
|
|
5
4
|
// i.e. `import { IconButton as StyledIconButton } ...`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
root.find(j.ImportDeclaration,
|
|
5
|
+
const importMap = {};
|
|
6
|
+
const styledMap = {};
|
|
7
|
+
root.find(j.ImportDeclaration, node => {
|
|
9
8
|
// imports our module
|
|
10
|
-
|
|
9
|
+
const value = node.source.value;
|
|
11
10
|
if (typeof value === 'string' &&
|
|
12
11
|
(value === '@workday/canvas-kit-react' ||
|
|
13
12
|
value.startsWith('@workday/canvas-kit-react/') ||
|
|
14
13
|
value === packageName)) {
|
|
15
14
|
containsCanvasImports = true;
|
|
16
|
-
(node.specifiers || []).forEach(
|
|
15
|
+
(node.specifiers || []).forEach(specifier => {
|
|
17
16
|
if (specifier.type === 'ImportSpecifier') {
|
|
18
17
|
if (!specifier.local || specifier.local.name === specifier.imported.name) {
|
|
19
18
|
importMap[specifier.imported.name] = specifier.imported.name;
|
|
@@ -27,7 +26,7 @@ export function getImportRenameMap(j, root, packageName) {
|
|
|
27
26
|
return false;
|
|
28
27
|
});
|
|
29
28
|
root
|
|
30
|
-
.find(j.CallExpression,
|
|
29
|
+
.find(j.CallExpression, (node) => {
|
|
31
30
|
if (node.callee.type === 'Identifier' &&
|
|
32
31
|
node.callee.name === 'styled' &&
|
|
33
32
|
node.arguments[0].type === 'Identifier') {
|
|
@@ -35,18 +34,18 @@ export function getImportRenameMap(j, root, packageName) {
|
|
|
35
34
|
}
|
|
36
35
|
return false;
|
|
37
36
|
})
|
|
38
|
-
.forEach(
|
|
37
|
+
.forEach(nodePath => {
|
|
39
38
|
// const StyledName = styled(OriginalName)({})
|
|
40
39
|
// const StyledName = styled(OriginalName)`` // Tagged template
|
|
41
40
|
if ((nodePath.parent.value.type === 'CallExpression' ||
|
|
42
41
|
nodePath.parent.value.type === 'TaggedTemplateExpression') &&
|
|
43
42
|
nodePath.parent.parent.value.type === 'VariableDeclarator' &&
|
|
44
43
|
nodePath.parent.parent.value.id.type === 'Identifier') {
|
|
45
|
-
|
|
44
|
+
const styledName = nodePath.parent.parent.value.id.name;
|
|
46
45
|
if (nodePath.value.arguments[0].type === 'Identifier') {
|
|
47
46
|
styledMap[nodePath.value.arguments[0].name] = styledName;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
});
|
|
51
|
-
return { containsCanvasImports
|
|
50
|
+
return { containsCanvasImports, importMap, styledMap };
|
|
52
51
|
}
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
* }
|
|
17
17
|
*/
|
|
18
18
|
export function hasImportSpecifiers(api, root, packageName, specifiers) {
|
|
19
|
-
|
|
20
|
-
return !!root.find(j.ImportDeclaration,
|
|
21
|
-
|
|
19
|
+
const j = api.jscodeshift;
|
|
20
|
+
return !!root.find(j.ImportDeclaration, nodePath => {
|
|
21
|
+
const value = nodePath.source.value;
|
|
22
22
|
// package name was found
|
|
23
23
|
if (typeof packageName === 'string'
|
|
24
24
|
? value === packageName
|
|
@@ -26,16 +26,14 @@ export function hasImportSpecifiers(api, root, packageName, specifiers) {
|
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
// Extract the main package(s) from the import, and test specifiers against that package
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.join('/');
|
|
34
|
-
});
|
|
29
|
+
const mainPackage = (typeof packageName === 'string' ? [packageName] : packageName).map(s => s
|
|
30
|
+
.split('/')
|
|
31
|
+
.slice(0, -1)
|
|
32
|
+
.join('/'));
|
|
35
33
|
if (mainPackage.includes(value)) {
|
|
36
|
-
return !!(nodePath.specifiers || []).find(
|
|
34
|
+
return !!(nodePath.specifiers || []).find(specifier => {
|
|
37
35
|
if (specifier.type === 'ImportSpecifier') {
|
|
38
|
-
|
|
36
|
+
const specifierName = specifier.imported.name;
|
|
39
37
|
return specifiers.includes(specifierName);
|
|
40
38
|
}
|
|
41
39
|
return false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v8/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAYtC,QAAA,MAAM,SAAS,EAAE,SAehB,CAAC;AACF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import softDeprecateDrawer from './softDeprecateDrawer';
|
|
2
|
+
import softDeprecateLayout from './softDeprecateLayout';
|
|
3
|
+
import softDeprecatePreviewMenu from './softDeprecatePreviewMenu';
|
|
4
|
+
import revomeDefaultImports from './removeDefaultImports';
|
|
5
|
+
import promoteComponentsToTesting from './promoteComponentsToTesting';
|
|
6
|
+
import promoteBreadcrumbs from './promoteBreadcrumbs';
|
|
7
|
+
import restructureBreadcrumbs from './restructureBreadcrumbs';
|
|
8
|
+
import refactorActionBarOverflowButton from './refactorActionBarOverflowButton';
|
|
9
|
+
import renameLoadingAnimation from './renameLoadingAnimation';
|
|
10
|
+
const transform = (file, api, options) => {
|
|
11
|
+
// These will run in order. If your transform depends on others, place yours after dependent transforms
|
|
12
|
+
const fixes = [
|
|
13
|
+
promoteBreadcrumbs,
|
|
14
|
+
restructureBreadcrumbs,
|
|
15
|
+
revomeDefaultImports,
|
|
16
|
+
softDeprecateDrawer,
|
|
17
|
+
softDeprecateLayout,
|
|
18
|
+
softDeprecatePreviewMenu,
|
|
19
|
+
promoteComponentsToTesting,
|
|
20
|
+
refactorActionBarOverflowButton,
|
|
21
|
+
renameLoadingAnimation,
|
|
22
|
+
];
|
|
23
|
+
return fixes.reduce((source, fix) => fix({ ...file, source }, api, options), file.source);
|
|
24
|
+
};
|
|
25
|
+
export default transform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promoteBreadcrumbs.d.ts","sourceRoot":"","sources":["../../../lib/v8/promoteBreadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAA6B,MAAM,aAAa,CAAC;AAIlE,QAAA,MAAM,SAAS,EAAE,SAyEhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const transform = (file, api) => {
|
|
2
|
+
const j = api.jscodeshift;
|
|
3
|
+
const root = j(file.source);
|
|
4
|
+
const breadcrumbsSpecifiers = [];
|
|
5
|
+
const foundImport = [];
|
|
6
|
+
root
|
|
7
|
+
.find(j.ImportDeclaration, {
|
|
8
|
+
source: { value: (value) => value.includes('@workday/canvas-kit-preview-react') },
|
|
9
|
+
})
|
|
10
|
+
.forEach(nodePath => {
|
|
11
|
+
var _a;
|
|
12
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.filter(specifier => {
|
|
13
|
+
if (specifier.type === 'ImportSpecifier' &&
|
|
14
|
+
specifier.local &&
|
|
15
|
+
specifier.imported.name === 'Breadcrumbs') {
|
|
16
|
+
breadcrumbsSpecifiers.push({
|
|
17
|
+
importedName: specifier.imported.name,
|
|
18
|
+
name: specifier.local.name,
|
|
19
|
+
});
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
24
|
+
if (breadcrumbsSpecifiers.length) {
|
|
25
|
+
foundImport.push(nodePath);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const existingBreadcrumbsImports = root.find(j.ImportDeclaration, {
|
|
29
|
+
source: { value: '@workday/canvas-kit-react/breadcrumbs' },
|
|
30
|
+
});
|
|
31
|
+
const mapToSpecifiers = (specifier) => {
|
|
32
|
+
return j.importSpecifier(j.identifier(specifier.importedName), specifier.name ? j.identifier(specifier.name) : undefined);
|
|
33
|
+
};
|
|
34
|
+
// add to existing import
|
|
35
|
+
if (existingBreadcrumbsImports.length) {
|
|
36
|
+
existingBreadcrumbsImports.forEach(nodePath => {
|
|
37
|
+
var _a;
|
|
38
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.concat(breadcrumbsSpecifiers.map(mapToSpecifiers));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// create new import
|
|
43
|
+
if (foundImport.length) {
|
|
44
|
+
foundImport[0].insertBefore(j.importDeclaration(breadcrumbsSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/breadcrumbs')));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
foundImport.forEach(importPath => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (((_a = importPath.value.specifiers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
50
|
+
importPath.value.source.value === '@workday/canvas-kit-preview-react/breadcrumbs') {
|
|
51
|
+
importPath.prune();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return root.toSource();
|
|
55
|
+
};
|
|
56
|
+
export default transform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promoteComponentsToTesting.d.ts","sourceRoot":"","sources":["../../../lib/v8/promoteComponentsToTesting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAA6B,MAAM,aAAa,CAAC;AAiBlE,QAAA,MAAM,SAAS,EAAE,SAgFhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const specifiersToMove = [
|
|
2
|
+
'ComponentStatesTable',
|
|
3
|
+
'permutateProps',
|
|
4
|
+
'ComponentStatesTableProps',
|
|
5
|
+
'PropCombination',
|
|
6
|
+
'PropDeclaration',
|
|
7
|
+
'Props',
|
|
8
|
+
'PropsDeclaration',
|
|
9
|
+
'convertToStaticStates',
|
|
10
|
+
'StaticStates',
|
|
11
|
+
];
|
|
12
|
+
// 1. Gather all import specifiers from @workday/canvas-kit-labs-react/common & @workday/canvas-kit-react/common
|
|
13
|
+
// 2. Filter through all imports from @workday/canvas-kit-labs-react/common and gather specifiers we care about
|
|
14
|
+
// 3. If no existing import, create new import with specifiers and insert before closest canvas kit import
|
|
15
|
+
const transform = (file, api) => {
|
|
16
|
+
const j = api.jscodeshift;
|
|
17
|
+
const root = j(file.source);
|
|
18
|
+
const commonLabsSpecifiers = [];
|
|
19
|
+
const foundImport = [];
|
|
20
|
+
// First move specifiers from labs or from main common
|
|
21
|
+
root
|
|
22
|
+
.find(j.ImportDeclaration, {
|
|
23
|
+
source: {
|
|
24
|
+
value: (value) => value.includes('@workday/canvas-kit-labs-react') ||
|
|
25
|
+
value.includes('@workday/canvas-kit-react'),
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
.forEach(nodePath => {
|
|
29
|
+
var _a;
|
|
30
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.filter(specifier => {
|
|
31
|
+
var _a, _b, _c, _d;
|
|
32
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
33
|
+
if (((_a = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _a === void 0 ? void 0 : _a.name) !== undefined &&
|
|
34
|
+
specifiersToMove.includes((_b = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _b === void 0 ? void 0 : _b.name)) {
|
|
35
|
+
commonLabsSpecifiers.push({
|
|
36
|
+
importedName: (_c = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _c === void 0 ? void 0 : _c.name,
|
|
37
|
+
name: (_d = specifier === null || specifier === void 0 ? void 0 : specifier.imported) === null || _d === void 0 ? void 0 : _d.name,
|
|
38
|
+
});
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
});
|
|
44
|
+
if (commonLabsSpecifiers.length) {
|
|
45
|
+
foundImport.push(nodePath);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const existingTestingImports = root.find(j.ImportDeclaration, {
|
|
49
|
+
source: { value: '@workday/canvas-kit-react/testing' },
|
|
50
|
+
});
|
|
51
|
+
const mapToSpecifiers = (specifier) => {
|
|
52
|
+
return j.importSpecifier(j.identifier(specifier.name), specifier.importedName ? j.identifier(specifier.importedName) : undefined);
|
|
53
|
+
};
|
|
54
|
+
// add to existing import testing import
|
|
55
|
+
if (existingTestingImports.length) {
|
|
56
|
+
existingTestingImports.forEach(nodePath => {
|
|
57
|
+
var _a;
|
|
58
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.concat(commonLabsSpecifiers.map(mapToSpecifiers));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// create new testing import
|
|
63
|
+
if (foundImport.length) {
|
|
64
|
+
foundImport[0].insertBefore(j.importDeclaration(commonLabsSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/testing')));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
foundImport.forEach(importPath => {
|
|
68
|
+
var _a;
|
|
69
|
+
if (((_a = importPath.value.specifiers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
70
|
+
importPath.value.source.value === '@workday/canvas-kit-react/testing') {
|
|
71
|
+
importPath.prune();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return root.toSource();
|
|
75
|
+
};
|
|
76
|
+
export default transform;
|