@workday/canvas-kit-codemod 8.0.3 → 8.0.5
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":"promoteBreadcrumbs.d.ts","sourceRoot":"","sources":["../../../lib/v8/promoteBreadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAA6B,MAAM,aAAa,CAAC;AAIlE,QAAA,MAAM,SAAS,EAAE,
|
|
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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var transform = function (file, api) {
|
|
2
2
|
var j = api.jscodeshift;
|
|
3
3
|
var root = j(file.source);
|
|
4
|
-
var
|
|
4
|
+
var breadcrumbsSpecifiers = [];
|
|
5
5
|
var foundImport = [];
|
|
6
6
|
root
|
|
7
7
|
.find(j.ImportDeclaration, {
|
|
@@ -13,7 +13,7 @@ var transform = function (file, api) {
|
|
|
13
13
|
if (specifier.type === 'ImportSpecifier' &&
|
|
14
14
|
specifier.local &&
|
|
15
15
|
specifier.imported.name === 'Breadcrumbs') {
|
|
16
|
-
|
|
16
|
+
breadcrumbsSpecifiers.push({
|
|
17
17
|
importedName: specifier.imported.name,
|
|
18
18
|
name: specifier.local.name,
|
|
19
19
|
});
|
|
@@ -21,25 +21,27 @@ var transform = function (file, api) {
|
|
|
21
21
|
}
|
|
22
22
|
return true;
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
if (breadcrumbsSpecifiers.length) {
|
|
25
|
+
foundImport.push(nodePath);
|
|
26
|
+
}
|
|
25
27
|
});
|
|
26
|
-
var
|
|
28
|
+
var existingBreadcrumbsImports = root.find(j.ImportDeclaration, {
|
|
27
29
|
source: { value: '@workday/canvas-kit-react/breadcrumbs' },
|
|
28
30
|
});
|
|
29
31
|
var mapToSpecifiers = function (specifier) {
|
|
30
32
|
return j.importSpecifier(j.identifier(specifier.importedName), specifier.name ? j.identifier(specifier.name) : undefined);
|
|
31
33
|
};
|
|
32
34
|
// add to existing import
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
+
if (existingBreadcrumbsImports.length) {
|
|
36
|
+
existingBreadcrumbsImports.forEach(function (nodePath) {
|
|
35
37
|
var _a;
|
|
36
|
-
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.concat(
|
|
38
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.concat(breadcrumbsSpecifiers.map(mapToSpecifiers));
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
else {
|
|
40
42
|
// create new import
|
|
41
43
|
if (foundImport.length) {
|
|
42
|
-
foundImport[0].insertBefore(j.importDeclaration(
|
|
44
|
+
foundImport[0].insertBefore(j.importDeclaration(breadcrumbsSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/breadcrumbs')));
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
foundImport.forEach(function (importPath) {
|
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.
|
|
5
|
+
"version": "8.0.5",
|
|
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": "86b8480266f501df912171e640de93cc293638cb"
|
|
47
47
|
}
|