@workday/canvas-kit-codemod 7.0.0 → 7.0.3

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,UAoK7E"}
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 (_a) {
115
- var _b;
116
- var node = _a.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
- (_b = node.specifiers) === null || _b === void 0 ? void 0 : _b.forEach(function (specifier) {
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
- (_b = node.specifiers) === null || _b === void 0 ? void 0 : _b.push(j.importSpecifier(j.identifier(specifier)));
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.0",
5
+ "version": "7.0.3",
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": "5f2a5c83ce927fa64ac24447f5391e467f51a406"
45
+ "gitHead": "09bdc519b58ba2b5675111025b861928e0b4e149"
46
46
  }