@workday/canvas-kit-codemod 15.0.0-alpha.0045-next.0 → 15.0.0-alpha.0056-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/v15/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAGtC,QAAA,MAAM,SAAS,EAAE,SAIhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v15/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAItC,QAAA,MAAM,SAAS,EAAE,SAIhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,7 +1,8 @@
1
+ import promoteInformationHighlight from './promoteInformationHighlight';
1
2
  import promoteSegmentedControl from './promoteSegmentedControl';
2
3
  const transform = (file, api, options) => {
3
4
  // These will run in order. If your transform depends on others, place yours after dependent transforms
4
- const fixes = [promoteSegmentedControl];
5
+ const fixes = [promoteSegmentedControl, promoteInformationHighlight];
5
6
  return fixes.reduce((source, fix) => fix({ ...file, source }, api, options), file.source);
6
7
  };
7
8
  export default transform;
@@ -0,0 +1,4 @@
1
+ import { Transform } from 'jscodeshift';
2
+ declare const transform: Transform;
3
+ export default transform;
4
+ //# sourceMappingURL=promoteInformationHighlight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promoteInformationHighlight.d.ts","sourceRoot":"","sources":["../../../lib/v15/promoteInformationHighlight.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 informationHighlightSpecifiers = [];
5
+ const foundImport = [];
6
+ root
7
+ .find(j.ImportDeclaration, {
8
+ source: { value: (value) => value.includes('@workday/canvas-kit-preview-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 === 'InformationHighlight') {
16
+ informationHighlightSpecifiers.push({
17
+ importedName: specifier.imported.name,
18
+ name: specifier.local.name,
19
+ });
20
+ return false;
21
+ }
22
+ return true;
23
+ });
24
+ if (informationHighlightSpecifiers.length) {
25
+ foundImport.push(nodePath);
26
+ }
27
+ });
28
+ const existingInformationHighlightImports = root.find(j.ImportDeclaration, {
29
+ source: { value: '@workday/canvas-kit-react/information-highlight' },
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 (existingInformationHighlightImports.length) {
36
+ existingInformationHighlightImports.forEach(nodePath => {
37
+ var _a;
38
+ nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.concat(informationHighlightSpecifiers.map(mapToSpecifiers));
39
+ });
40
+ }
41
+ else {
42
+ // create new import
43
+ if (foundImport.length) {
44
+ foundImport[0].insertBefore(j.importDeclaration(informationHighlightSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/information-highlight')));
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-preview-react/information-highlight') {
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": "15.0.0-alpha.0045-next.0",
5
+ "version": "15.0.0-alpha.0056-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": "38005cde6b12236ba0376e1a360b8e22ca6b1e18"
49
+ "gitHead": "7ea41be00e30b2df431c3b8a49d5d2c24f3a9b8c"
50
50
  }