@workday/canvas-kit-codemod 8.0.0-alpha.216-next.4 → 8.0.0-alpha.224-next.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v8/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v8/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAUtC,QAAA,MAAM,SAAS,EAAE,SAahB,CAAC;AACF,eAAe,SAAS,CAAC"}
|
package/dist/es6/v8/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import softDeprecateDrawer from './softDeprecateDrawer';
|
|
|
13
13
|
import softDeprecateLayout from './softDeprecateLayout';
|
|
14
14
|
import softDeprecatePreviewMenu from './softDeprecatePreviewMenu';
|
|
15
15
|
import revomeDefaultImports from './removeDefaultImports';
|
|
16
|
+
import promoteComponentsToTesting from './promoteComponentsToTesting';
|
|
16
17
|
import promoteBreadcrumbs from './promoteBreadcrumbs';
|
|
17
18
|
import restructureBreadcrumbs from './restructureBreadcrumbs';
|
|
18
19
|
var transform = function (file, api, options) {
|
|
@@ -24,6 +25,7 @@ var transform = function (file, api, options) {
|
|
|
24
25
|
softDeprecateDrawer,
|
|
25
26
|
softDeprecateLayout,
|
|
26
27
|
softDeprecatePreviewMenu,
|
|
28
|
+
promoteComponentsToTesting,
|
|
27
29
|
];
|
|
28
30
|
return fixes.reduce(function (source, fix) { return fix(__assign(__assign({}, file), { source: source }), api, options); }, file.source);
|
|
29
31
|
};
|
|
@@ -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,SA8EhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var 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
|
+
var transform = function (file, api) {
|
|
16
|
+
var j = api.jscodeshift;
|
|
17
|
+
var root = j(file.source);
|
|
18
|
+
var commonLabsSpecifiers = [];
|
|
19
|
+
var foundImport = [];
|
|
20
|
+
// First move specifiers from labs or from main common
|
|
21
|
+
root
|
|
22
|
+
.find(j.ImportDeclaration, {
|
|
23
|
+
source: {
|
|
24
|
+
value: function (value) {
|
|
25
|
+
return value.includes('@workday/canvas-kit-labs-react') ||
|
|
26
|
+
value.includes('@workday/canvas-kit-react');
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
.forEach(function (nodePath) {
|
|
31
|
+
var _a;
|
|
32
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.filter(function (specifier) {
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
35
|
+
if (((_a = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _a === void 0 ? void 0 : _a.name) !== undefined &&
|
|
36
|
+
specifiersToMove.includes((_b = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _b === void 0 ? void 0 : _b.name)) {
|
|
37
|
+
commonLabsSpecifiers.push({
|
|
38
|
+
importedName: (_c = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _c === void 0 ? void 0 : _c.name,
|
|
39
|
+
name: (_d = specifier === null || specifier === void 0 ? void 0 : specifier.imported) === null || _d === void 0 ? void 0 : _d.name,
|
|
40
|
+
});
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
});
|
|
46
|
+
foundImport.push(nodePath);
|
|
47
|
+
});
|
|
48
|
+
var existingTestingImports = root.find(j.ImportDeclaration, {
|
|
49
|
+
source: { value: '@workday/canvas-kit-react/testing' },
|
|
50
|
+
});
|
|
51
|
+
var mapToSpecifiers = function (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(function (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(function (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;
|
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": "8.0.0-alpha.
|
|
5
|
+
"version": "8.0.0-alpha.224-next.7+e820f3ad",
|
|
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,
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"test": "TZ=UTC jest -c ../../jest.config.js",
|
|
44
44
|
"typecheck:src": "tsc -p . --noEmit --incremental false"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "e820f3adf6fd563cebc522cc02488965bc76b668"
|
|
47
47
|
}
|