@workday/canvas-kit-codemod 7.0.2 → 7.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":"recategorizeIconButtons.d.ts","sourceRoot":"","sources":["../../../lib/v7/recategorizeIconButtons.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,QAAQ,EACR,OAAO,EAMR,MAAM,aAAa,CAAC;AAcrB,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"recategorizeIconButtons.d.ts","sourceRoot":"","sources":["../../../lib/v7/recategorizeIconButtons.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,QAAQ,EACR,OAAO,EAMR,MAAM,aAAa,CAAC;AAcrB,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA8K7E"}
|
|
@@ -111,14 +111,14 @@ export default function transformer(file, api, options) {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
114
|
-
buttonImports.forEach(function (
|
|
115
|
-
var _b;
|
|
116
|
-
var node =
|
|
114
|
+
buttonImports.forEach(function (nodePath) {
|
|
115
|
+
var _a, _b, _c;
|
|
116
|
+
var node = nodePath.node;
|
|
117
117
|
var specifiersToRemove = ['IconButton'];
|
|
118
118
|
// Remove old specifiers
|
|
119
119
|
if (typeof node.source.value === 'string' &&
|
|
120
120
|
node.source.value.includes('@workday/canvas-kit-react')) {
|
|
121
|
-
(
|
|
121
|
+
(_a = node.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(function (specifier) {
|
|
122
122
|
var _a, _b;
|
|
123
123
|
if (specifier.type === 'ImportSpecifier' &&
|
|
124
124
|
specifiersToRemove.includes(specifier.imported.name)) {
|
|
@@ -131,9 +131,17 @@ export default function transformer(file, api, options) {
|
|
|
131
131
|
requiredImportSpecifiers.forEach(function (specifier) {
|
|
132
132
|
var _a, _b;
|
|
133
133
|
if (!((_a = node.specifiers) === null || _a === void 0 ? void 0 : _a.find(function (existing) { return existing.type === 'ImportSpecifier' && existing.imported.name === specifier; }))) {
|
|
134
|
-
|
|
134
|
+
// Only add a specifier if it has not already been declared
|
|
135
|
+
if (!importMap[buttonType]) {
|
|
136
|
+
(_b = node.specifiers) === null || _b === void 0 ? void 0 : _b.push(j.importSpecifier(j.identifier(specifier)));
|
|
137
|
+
}
|
|
135
138
|
}
|
|
136
139
|
});
|
|
140
|
+
console.log((_b = node.specifiers) === null || _b === void 0 ? void 0 : _b.length);
|
|
141
|
+
// if we removed all specifiers, remove the import
|
|
142
|
+
if (!((_c = node.specifiers) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
143
|
+
nodePath.prune();
|
|
144
|
+
}
|
|
137
145
|
});
|
|
138
146
|
}
|
|
139
147
|
return root.toSource();
|
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": "7.0.
|
|
5
|
+
"version": "7.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,
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"test": "TZ=UTC jest -c ../../jest.config.js",
|
|
43
43
|
"typecheck:src": "tsc -p . --noEmit --incremental false"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "1d2d2983803cf570b34a48a0c05b8e7ffe7e3956"
|
|
46
46
|
}
|