@workday/canvas-kit-codemod 8.0.0-alpha.250-next.19 → 8.0.0-alpha.252-next.21

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/v8/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAWtC,QAAA,MAAM,SAAS,EAAE,SAchB,CAAC;AACF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v8/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAYtC,QAAA,MAAM,SAAS,EAAE,SAehB,CAAC;AACF,eAAe,SAAS,CAAC"}
@@ -17,6 +17,7 @@ import promoteComponentsToTesting from './promoteComponentsToTesting';
17
17
  import promoteBreadcrumbs from './promoteBreadcrumbs';
18
18
  import restructureBreadcrumbs from './restructureBreadcrumbs';
19
19
  import refactorActionBarOverflowButton from './refactorActionBarOverflowButton';
20
+ import renameLoadingAnimation from './renameLoadingAnimation';
20
21
  var transform = function (file, api, options) {
21
22
  // These will run in order. If your transform depends on others, place yours after dependent transforms
22
23
  var fixes = [
@@ -28,6 +29,7 @@ var transform = function (file, api, options) {
28
29
  softDeprecatePreviewMenu,
29
30
  promoteComponentsToTesting,
30
31
  refactorActionBarOverflowButton,
32
+ renameLoadingAnimation,
31
33
  ];
32
34
  return fixes.reduce(function (source, fix) { return fix(__assign(__assign({}, file), { source: source }), api, options); }, file.source);
33
35
  };
@@ -0,0 +1,3 @@
1
+ import { API, FileInfo, Options } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API, options: Options): string;
3
+ //# sourceMappingURL=renameLoadingAnimation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renameLoadingAnimation.d.ts","sourceRoot":"","sources":["../../../lib/v8/renameLoadingAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,aAAa,CAAC;AASnD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA+D7E"}
@@ -0,0 +1,62 @@
1
+ import { getImportRenameMap } from '../v7/utils/getImportRenameMap';
2
+ import { hasImportSpecifiers } from '../v6/utils';
3
+ var mainPackage = '@workday/canvas-kit-react';
4
+ var loadingAnimationPackage = '@workday/canvas-kit-react/loading-animation';
5
+ var loadingDotsPackage = '@workday/canvas-kit-react/loading-dots';
6
+ var loadingAnimationImports = ['LoadingDots', 'LoadingAnimation'];
7
+ export default function transformer(file, api, options) {
8
+ var j = api.jscodeshift;
9
+ var root = j(file.source);
10
+ // exit if the named imports aren't found
11
+ if (!hasImportSpecifiers(api, root, loadingAnimationPackage, loadingAnimationImports)) {
12
+ return file.source;
13
+ }
14
+ // getImportRenameMap utility will tell us if the file containsCanvasImports
15
+ // and give us an importMap to track what identifiers we need to update
16
+ var importMap = getImportRenameMap(j, root, '@workday/canvas-kit-react/loading-animation').importMap;
17
+ root
18
+ .find(j.ImportDeclaration, {
19
+ // filter on imports from "@workday/canvas-kit/react" including slash imports
20
+ source: { value: function (value) { return value.includes(mainPackage); } },
21
+ })
22
+ .forEach(function (nodePath) {
23
+ var _a;
24
+ (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(function (specifier) {
25
+ if (specifier.type === 'ImportSpecifier') {
26
+ // Transform named import
27
+ // e.g. `import {LoadingAnimation}` becomes `import {LoadingDots}`
28
+ if (specifier.imported.name === 'LoadingAnimation') {
29
+ specifier.imported.name = 'LoadingDots';
30
+ }
31
+ // Transform slash imports
32
+ // e.g. `import {LoadingAnimation} from from "@workday/canvas-kit-react/loading-animation"`
33
+ // and `import {LoadingDots} from from "@workday/canvas-kit-react/loading-animation"`
34
+ // becomes `import {LoadingDots} from from "@workday/canvas-kit-react/loading-dots"`
35
+ if (nodePath.value.source.value === loadingAnimationPackage) {
36
+ nodePath.value.source.value = loadingDotsPackage;
37
+ }
38
+ }
39
+ return specifier;
40
+ });
41
+ });
42
+ // Transform LoadingAnimation JSXElements
43
+ // e.g. `<LoadingAnimation />` becomes `<LoadingDots />`
44
+ root.find(j.JSXIdentifier, { name: 'LoadingAnimation' }).forEach(function (nodePath) {
45
+ nodePath.node.name = 'LoadingDots';
46
+ });
47
+ // Transform styled compoents
48
+ // e.g. `const StyledLoadingAnimation = styled(LoadingAnimation)({});`
49
+ // becomes `const StyledLoadingAnimation = styled(LoadingDots)({});`
50
+ root.find(j.VariableDeclarator).forEach(function (nodePath) {
51
+ var _a;
52
+ if (((_a = nodePath.value.init) === null || _a === void 0 ? void 0 : _a.type) === 'CallExpression' &&
53
+ nodePath.value.init.callee.type === 'CallExpression' &&
54
+ nodePath.value.init.callee.callee.type === 'Identifier' &&
55
+ nodePath.value.init.callee.callee.name === 'styled' &&
56
+ nodePath.value.init.callee.arguments[0].type === 'Identifier' &&
57
+ nodePath.value.init.callee.arguments[0].name === importMap.LoadingAnimation) {
58
+ nodePath.value.init.callee.arguments[0].name = 'LoadingDots';
59
+ }
60
+ });
61
+ return root.toSource();
62
+ }
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.0-alpha.250-next.19+c91bf36c",
5
+ "version": "8.0.0-alpha.252-next.21+0ce754ca",
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": "c91bf36c41b82f12b0d8323da5fb1fc290e2d5b9"
46
+ "gitHead": "0ce754caca6bcdb3876ccb8e012cfecddaffb882"
47
47
  }