@workday/canvas-kit-codemod 8.0.0-alpha.194-next.2 → 8.0.0-alpha.199-next.1

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;AAOtC,QAAA,MAAM,SAAS,EAAE,SAUhB,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;AAStC,QAAA,MAAM,SAAS,EAAE,SAYhB,CAAC;AACF,eAAe,SAAS,CAAC"}
@@ -13,9 +13,13 @@ import softDeprecateDrawer from './softDeprecateDrawer';
13
13
  import softDeprecateLayout from './softDeprecateLayout';
14
14
  import softDeprecatePreviewMenu from './softDeprecatePreviewMenu';
15
15
  import revomeDefaultImports from './removeDefaultImports';
16
+ import promoteBreadcrumbs from './promoteBreadcrumbs';
17
+ import restructureBreadcrumbs from './restructureBreadcrumbs';
16
18
  var transform = function (file, api, options) {
17
19
  // These will run in order. If your transform depends on others, place yours after dependent transforms
18
20
  var fixes = [
21
+ promoteBreadcrumbs,
22
+ restructureBreadcrumbs,
19
23
  revomeDefaultImports,
20
24
  softDeprecateDrawer,
21
25
  softDeprecateLayout,
@@ -0,0 +1,4 @@
1
+ import { Transform } from 'jscodeshift';
2
+ declare const transform: Transform;
3
+ export default transform;
4
+ //# sourceMappingURL=promoteBreadcrumbs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promoteBreadcrumbs.d.ts","sourceRoot":"","sources":["../../../lib/v8/promoteBreadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAA6B,MAAM,aAAa,CAAC;AAIlE,QAAA,MAAM,SAAS,EAAE,SAuEhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,54 @@
1
+ var transform = function (file, api) {
2
+ var j = api.jscodeshift;
3
+ var root = j(file.source);
4
+ var reactLayoutSpecifiers = [];
5
+ var foundImport = [];
6
+ root
7
+ .find(j.ImportDeclaration, {
8
+ source: { value: function (value) { return value.includes('@workday/canvas-kit-preview-react'); } },
9
+ })
10
+ .forEach(function (nodePath) {
11
+ var _a;
12
+ nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.filter(function (specifier) {
13
+ if (specifier.type === 'ImportSpecifier' &&
14
+ specifier.local &&
15
+ specifier.imported.name === 'Breadcrumbs') {
16
+ reactLayoutSpecifiers.push({
17
+ importedName: specifier.imported.name,
18
+ name: specifier.local.name,
19
+ });
20
+ return false;
21
+ }
22
+ return true;
23
+ });
24
+ foundImport.push(nodePath);
25
+ });
26
+ var existingLayoutImports = root.find(j.ImportDeclaration, {
27
+ source: { value: '@workday/canvas-kit-react/breadcrumbs' },
28
+ });
29
+ var mapToSpecifiers = function (specifier) {
30
+ return j.importSpecifier(j.identifier(specifier.importedName), specifier.name ? j.identifier(specifier.name) : undefined);
31
+ };
32
+ // add to existing import
33
+ if (existingLayoutImports.length) {
34
+ existingLayoutImports.forEach(function (nodePath) {
35
+ var _a;
36
+ nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.concat(reactLayoutSpecifiers.map(mapToSpecifiers));
37
+ });
38
+ }
39
+ else {
40
+ // create new import
41
+ if (foundImport.length) {
42
+ foundImport[0].insertBefore(j.importDeclaration(reactLayoutSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/breadcrumbs')));
43
+ }
44
+ }
45
+ foundImport.forEach(function (importPath) {
46
+ var _a;
47
+ if (((_a = importPath.value.specifiers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
48
+ importPath.value.source.value === '@workday/canvas-kit-preview-react/breadcrumbs') {
49
+ importPath.prune();
50
+ }
51
+ });
52
+ return root.toSource();
53
+ };
54
+ 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=restructureBreadcrumbs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restructureBreadcrumbs.d.ts","sourceRoot":"","sources":["../../../lib/v8/restructureBreadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAa,MAAM,aAAa,CAAC;AAM/D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAwE7E"}
@@ -0,0 +1,59 @@
1
+ import { getImportRenameMap } from '../v7/utils/getImportRenameMap';
2
+ import { hasImportSpecifiers } from '../v6/utils';
3
+ var breadcrumbsPackage = '@workday/canvas-kit-react/breadcrumbs';
4
+ export default function transformer(file, api, options) {
5
+ var j = api.jscodeshift;
6
+ var root = j(file.source);
7
+ if (!hasImportSpecifiers(api, root, breadcrumbsPackage, ['Breadcrumbs'])) {
8
+ return file.source;
9
+ }
10
+ var _a = getImportRenameMap(j, root, breadcrumbsPackage), importMap = _a.importMap, styledMap = _a.styledMap;
11
+ root
12
+ .find(j.JSXElement, function (value) {
13
+ return value.openingElement.name.type === 'JSXMemberExpression' &&
14
+ value.openingElement.name.object.type === 'JSXIdentifier' &&
15
+ (value.openingElement.name.object.name === importMap.Breadcrumbs ||
16
+ value.openingElement.name.object.name === styledMap.Breadcrumbs) &&
17
+ value.openingElement.name.property.name === 'Nav';
18
+ })
19
+ .forEach(function (nodePath) {
20
+ // Select all props from opening tag
21
+ var attributes = nodePath.value.openingElement.attributes || [];
22
+ if (attributes) {
23
+ nodePath.value.openingElement.attributes = attributes.filter(function (item) { return !(item.type === 'JSXAttribute' && item.name.type === 'JSXIdentifier'); });
24
+ }
25
+ nodePath.value.openingElement = j.jsxOpeningElement(j.jsxIdentifier(importMap.Breadcrumbs));
26
+ nodePath.value.openingElement.attributes = attributes;
27
+ nodePath.value.closingElement = j.jsxClosingElement(j.jsxIdentifier(importMap.Breadcrumbs));
28
+ (nodePath.value.children || []).forEach(function (child) {
29
+ if (child.type === 'JSXElement' &&
30
+ child.openingElement.name.type === 'JSXMemberExpression' &&
31
+ child.openingElement.name.property.name === 'CollapsibleList') {
32
+ if (child.openingElement.name.type === 'JSXMemberExpression') {
33
+ child.openingElement.name.property.name = 'List';
34
+ }
35
+ if (child.closingElement && child.closingElement.name.type === 'JSXMemberExpression') {
36
+ child.closingElement.name.property.name = 'List';
37
+ }
38
+ }
39
+ });
40
+ });
41
+ root
42
+ .find(j.JSXElement, function (value) {
43
+ return value.openingElement.name.type === 'JSXMemberExpression' &&
44
+ value.openingElement.name.object.type === 'JSXIdentifier' &&
45
+ (value.openingElement.name.object.name === importMap.Breadcrumbs ||
46
+ value.openingElement.name.object.name === styledMap.Breadcrumbs) &&
47
+ value.openingElement.name.property.name === 'ListItem';
48
+ })
49
+ .forEach(function (nodePath) {
50
+ if (nodePath.value.openingElement.name.type === 'JSXMemberExpression') {
51
+ nodePath.value.openingElement.name.property.name = 'Item';
52
+ }
53
+ if (nodePath.value.closingElement &&
54
+ nodePath.value.closingElement.name.type === 'JSXMemberExpression') {
55
+ nodePath.value.closingElement.name.property.name = 'Item';
56
+ }
57
+ });
58
+ return root.toSource();
59
+ }
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.194-next.2+bc1f2fe6",
5
+ "version": "8.0.0-alpha.199-next.1+c26207e7",
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": "bc1f2fe6cdb9fccd4592698f6c1cdad5a64e84de"
46
+ "gitHead": "c26207e70259cfd18d24449c51d9f9eb19fb1dca"
47
47
  }