@workday/canvas-kit-codemod 13.0.0-alpha.1080-next.0 → 13.0.0-alpha.1084-next.0
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/v13/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v13/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAMtC,QAAA,MAAM,SAAS,EAAE,SAUhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/es6/v13/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import addPillLabel from './addPillLabel';
|
|
2
2
|
import renameDubLogosImports from './renameDubLogosImports';
|
|
3
3
|
import renameDubLogosReferences from './renameDubLogosReferences';
|
|
4
|
+
import promoteExpandable from './promoteExpandable';
|
|
4
5
|
const transform = (file, api, options) => {
|
|
5
6
|
// These will run in order. If your transform depends on others, place yours after dependent transforms
|
|
6
7
|
const fixes = [
|
|
7
8
|
// add codemods here
|
|
8
9
|
addPillLabel,
|
|
10
|
+
promoteExpandable,
|
|
9
11
|
renameDubLogosImports,
|
|
10
12
|
renameDubLogosReferences,
|
|
11
13
|
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promoteExpandable.d.ts","sourceRoot":"","sources":["../../../lib/v13/promoteExpandable.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 expandableSpecifiers = [];
|
|
5
|
+
const foundImport = [];
|
|
6
|
+
root
|
|
7
|
+
.find(j.ImportDeclaration, {
|
|
8
|
+
source: { value: (value) => value.includes('@workday/canvas-kit-labs-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 === 'Expandable') {
|
|
16
|
+
expandableSpecifiers.push({
|
|
17
|
+
importedName: specifier.imported.name,
|
|
18
|
+
name: specifier.local.name,
|
|
19
|
+
});
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
24
|
+
if (expandableSpecifiers.length) {
|
|
25
|
+
foundImport.push(nodePath);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const existinExpandableImports = root.find(j.ImportDeclaration, {
|
|
29
|
+
source: { value: '@workday/canvas-kit-react/expandable' },
|
|
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 (existinExpandableImports.length) {
|
|
36
|
+
existinExpandableImports.forEach(nodePath => {
|
|
37
|
+
var _a;
|
|
38
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.concat(expandableSpecifiers.map(mapToSpecifiers));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// create new import
|
|
43
|
+
if (foundImport.length) {
|
|
44
|
+
foundImport[0].insertBefore(j.importDeclaration(expandableSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/expandable')));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
foundImport.forEach(importPath => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (!((_a = importPath.value.specifiers) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
50
|
+
importPath.value.source.value === '@workday/canvas-kit-labs-react/expandable') {
|
|
51
|
+
importPath.prune();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return root.toSource();
|
|
55
|
+
};
|
|
56
|
+
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": "13.0.0-alpha.
|
|
5
|
+
"version": "13.0.0-alpha.1084-next.0",
|
|
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": "7e212f823aba1ffbb1965c6ffdf8e270ad575a96"
|
|
50
50
|
}
|