@workday/canvas-kit-codemod 14.0.0-alpha.1212-next.0 → 14.0.0-alpha.1213-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/v14/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAItC,QAAA,MAAM,SAAS,EAAE,SAIhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v14/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAMtC,QAAA,MAAM,SAAS,EAAE,SAIhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,7 +1,9 @@
1
1
  import updateStatusIndicatorPreview from './updateStatusIndicatorPreview';
2
+ import updatePillAvatarProp from './updatePillAvatarProp';
3
+ import updateExpandableAvatarProp from './updateExpandableAvatarProp';
2
4
  const transform = (file, api, options) => {
3
5
  // These will run in order. If your transform depends on others, place yours after dependent transforms
4
- const fixes = [updateStatusIndicatorPreview];
6
+ const fixes = [updateStatusIndicatorPreview, updatePillAvatarProp, updateExpandableAvatarProp];
5
7
  return fixes.reduce((source, fix) => fix({ ...file, source }, api, options), file.source);
6
8
  };
7
9
  export default transform;
@@ -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=updateExpandableAvatarProp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateExpandableAvatarProp.d.ts","sourceRoot":"","sources":["../../../lib/v14/updateExpandableAvatarProp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAA6B,OAAO,EAAC,MAAM,aAAa,CAAC;AAM9E,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAiD7E"}
@@ -0,0 +1,42 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ import { hasImportSpecifiers } from '../v6/utils';
3
+ const expandablePackage = '@workday/canvas-kit-react/expandable';
4
+ export default function transformer(file, api, options) {
5
+ const j = api.jscodeshift;
6
+ const root = j(file.source);
7
+ // Skip transformation if Expandable is not imported from the target package
8
+ if (!hasImportSpecifiers(api, root, expandablePackage, ['Expandable'])) {
9
+ return file.source;
10
+ }
11
+ const { importMap, styledMap } = getImportRenameMap(j, root, '@workday/canvas-kit-react');
12
+ root
13
+ .find(j.JSXElement, (value) => value.openingElement.name.type === 'JSXIdentifier' &&
14
+ (value.openingElement.name.name === importMap.Expandable ||
15
+ value.openingElement.name.name === styledMap.Expandable))
16
+ .forEach(nodePath => {
17
+ var _a;
18
+ // Get the local name of the Expandable component (e.g., Expandable, MyExpandable, StyledExpandable)
19
+ const expandableName = nodePath.node.openingElement.name.name;
20
+ // Look for Expandable.Avatar elements and rename altText prop to name
21
+ (_a = nodePath.node.children) === null || _a === void 0 ? void 0 : _a.forEach(child => {
22
+ var _a;
23
+ if (child.type === 'JSXElement' &&
24
+ child.openingElement.type === 'JSXOpeningElement' &&
25
+ child.openingElement.name.type === 'JSXMemberExpression' &&
26
+ child.openingElement.name.object.type === 'JSXIdentifier' &&
27
+ child.openingElement.name.object.name === expandableName &&
28
+ child.openingElement.name.property.name === 'Avatar') {
29
+ // This is an Expandable.Avatar element, check for altText prop
30
+ (_a = child.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.forEach(attr => {
31
+ if (attr.type === 'JSXAttribute' &&
32
+ attr.name.type === 'JSXIdentifier' &&
33
+ attr.name.name === 'altText') {
34
+ // Rename altText to name
35
+ attr.name.name = 'name';
36
+ }
37
+ });
38
+ }
39
+ });
40
+ });
41
+ return root.toSource();
42
+ }
@@ -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=updatePillAvatarProp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updatePillAvatarProp.d.ts","sourceRoot":"","sources":["../../../lib/v14/updatePillAvatarProp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAA6B,OAAO,EAAC,MAAM,aAAa,CAAC;AAM9E,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAiD7E"}
@@ -0,0 +1,42 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ import { hasImportSpecifiers } from '../v6/utils';
3
+ const pillPackage = '@workday/canvas-kit-preview-react/pill';
4
+ export default function transformer(file, api, options) {
5
+ const j = api.jscodeshift;
6
+ const root = j(file.source);
7
+ // Skip transformation if Pill is not imported from the target package
8
+ if (!hasImportSpecifiers(api, root, pillPackage, ['Pill'])) {
9
+ return file.source;
10
+ }
11
+ const { importMap, styledMap } = getImportRenameMap(j, root, '@workday/canvas-kit-preview-react');
12
+ root
13
+ .find(j.JSXElement, (value) => value.openingElement.name.type === 'JSXIdentifier' &&
14
+ (value.openingElement.name.name === importMap.Pill ||
15
+ value.openingElement.name.name === styledMap.Pill))
16
+ .forEach(nodePath => {
17
+ var _a;
18
+ // Get the local name of the Pill component (e.g., Pill, MyPill, StyledPill)
19
+ const pillName = nodePath.node.openingElement.name.name;
20
+ // Look for Pill.Avatar elements and rename altText prop to name
21
+ (_a = nodePath.node.children) === null || _a === void 0 ? void 0 : _a.forEach(child => {
22
+ var _a;
23
+ if (child.type === 'JSXElement' &&
24
+ child.openingElement.type === 'JSXOpeningElement' &&
25
+ child.openingElement.name.type === 'JSXMemberExpression' &&
26
+ child.openingElement.name.object.type === 'JSXIdentifier' &&
27
+ child.openingElement.name.object.name === pillName &&
28
+ child.openingElement.name.property.name === 'Avatar') {
29
+ // This is a Pill.Avatar element, check for altText prop
30
+ (_a = child.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.forEach(attr => {
31
+ if (attr.type === 'JSXAttribute' &&
32
+ attr.name.type === 'JSXIdentifier' &&
33
+ attr.name.name === 'altText') {
34
+ // Rename altText to name
35
+ attr.name.name = 'name';
36
+ }
37
+ });
38
+ }
39
+ });
40
+ });
41
+ return root.toSource();
42
+ }
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": "14.0.0-alpha.1212-next.0",
5
+ "version": "14.0.0-alpha.1213-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": "4061f71f096822b9165e03d503a7f22ee01c1565"
49
+ "gitHead": "b5997d670fcef518d13ff761d9a15d54e1d60a21"
50
50
  }