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

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;AAItC,QAAA,MAAM,SAAS,EAAE,SAKhB,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;AAOtC,QAAA,MAAM,SAAS,EAAE,SAUhB,CAAC;AACF,eAAe,SAAS,CAAC"}
@@ -9,10 +9,18 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ import softDeprecateDrawer from './softDeprecateDrawer';
13
+ import softDeprecateLayout from './softDeprecateLayout';
14
+ import softDeprecatePreviewMenu from './softDeprecatePreviewMenu';
12
15
  import revomeDefaultImports from './removeDefaultImports';
13
16
  var transform = function (file, api, options) {
14
17
  // These will run in order. If your transform depends on others, place yours after dependent transforms
15
- var fixes = [revomeDefaultImports];
18
+ var fixes = [
19
+ revomeDefaultImports,
20
+ softDeprecateDrawer,
21
+ softDeprecateLayout,
22
+ softDeprecatePreviewMenu,
23
+ ];
16
24
  return fixes.reduce(function (source, fix) { return fix(__assign(__assign({}, file), { source: source }), api, options); }, file.source);
17
25
  };
18
26
  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=softDeprecateDrawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softDeprecateDrawer.d.ts","sourceRoot":"","sources":["../../../lib/v8/softDeprecateDrawer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAiC,OAAO,EAAC,MAAM,aAAa,CAAC;AAYlF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA0G7E"}
@@ -0,0 +1,103 @@
1
+ var mainPackage = '@workday/canvas-kit-labs-react';
2
+ var drawerPackage = '@workday/canvas-kit-labs-react/drawer';
3
+ var drawerImportNames = [
4
+ 'Drawer',
5
+ 'DrawerProps',
6
+ 'DrawerHeaderProps',
7
+ 'DrawerHeader',
8
+ 'DrawerDirection',
9
+ ];
10
+ export default function transformer(file, api, options) {
11
+ var j = api.jscodeshift;
12
+ var root = j(file.source);
13
+ var hasDrawerImports = false;
14
+ // This toggles the failsafe that prevents us from accidentally transforming something unintentionally.
15
+ root.find(j.ImportDeclaration, function (nodePath) {
16
+ var value = nodePath.source.value;
17
+ // If there's an import from the drawer package, set the import boolean check to true
18
+ if (value === drawerPackage) {
19
+ hasDrawerImports = true;
20
+ return false;
21
+ }
22
+ // If there's an import from the main package, check to see if Drawer or DrawerProps are among the named imports
23
+ // e.g. import {Drawer} from '@workday/canvas-kit-labs-react';
24
+ if (value === mainPackage) {
25
+ (nodePath.specifiers || []).forEach(function (specifier) {
26
+ if (specifier.type === 'ImportSpecifier' &&
27
+ drawerImportNames.includes(specifier.imported.name)) {
28
+ hasDrawerImports = true;
29
+ }
30
+ });
31
+ }
32
+ return false;
33
+ });
34
+ // Failsafe to skip transforms unless a Drawer import is detected
35
+ if (!hasDrawerImports) {
36
+ return root.toSource();
37
+ }
38
+ root
39
+ .find(j.ImportDeclaration, {
40
+ source: { value: function (value) { return value.includes(mainPackage); } },
41
+ })
42
+ .forEach(function (nodePath) {
43
+ var _a;
44
+ (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(function (specifier) {
45
+ if (specifier.type === 'ImportSpecifier') {
46
+ // `import {Drawer}` becomes `import {DeprecatedDrawer}`
47
+ // `import {DrawerProps}` becomes `import {DeprecatedDrawerProps}`
48
+ // `import {DrawerHeader}` becomes `import {DeprecatedDrawerHeader}`
49
+ // `import {DrawerHeaderProps}` becomes `import {DeprecatedDrawerHeaderProps}`
50
+ if (drawerImportNames.includes(specifier.imported.name)) {
51
+ specifier.imported.name = "Deprecated" + specifier.imported.name;
52
+ }
53
+ }
54
+ return specifier;
55
+ });
56
+ });
57
+ // Transform DrawerProps type references
58
+ // e.g. `type CustomProps = DrawerProps;` becomes `type CustomProps = DeprecatedDrawerProps;`
59
+ // Transform DrawerHeaderProps type references
60
+ // e.g. `type CustomProps = DrawerHeaderProps;` becomes `type CustomProps = DeprecatedDrawerHeaderProps;`
61
+ var typeNames = ['DrawerProps', 'DrawerHeaderProps'];
62
+ root
63
+ .find(j.TSTypeReference, {
64
+ typeName: {
65
+ type: 'Identifier',
66
+ name: function (value) { return typeNames.includes(value); },
67
+ },
68
+ })
69
+ .forEach(function (nodePath) {
70
+ var identifier = nodePath.value.typeName;
71
+ identifier.name = "Deprecated" + identifier.name;
72
+ });
73
+ // Transform DrawerProps type interface declaration references
74
+ // e.g. `interface CustomProps extends DrawerProps` becomes `interface CustomProps extends DeprecatedDrawerProps`
75
+ root.find(j.TSInterfaceDeclaration).forEach(function (nodePath) {
76
+ var _a;
77
+ // If the interface is extending DrawerProps, transform the extension name to DeprecatedDrawerProps
78
+ (_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(function (typeExtension) {
79
+ if (typeExtension.expression.type === 'Identifier') {
80
+ var typeExtensionName = typeExtension.expression.name;
81
+ if (typeExtension.expression.type === 'Identifier' &&
82
+ typeNames.includes(typeExtensionName)) {
83
+ typeExtension.expression.name = "Deprecated" + typeExtensionName;
84
+ }
85
+ }
86
+ });
87
+ });
88
+ // Transform `<DrawerDirection>` to `<DeprecatedDrawerDirection>`
89
+ root.find(j.Identifier, { name: 'DrawerDirection' }).forEach(function (nodePath) {
90
+ nodePath.value.name = 'DeprecatedDrawerDirection';
91
+ });
92
+ // Transform Drawer JSXElements
93
+ // e.g. `<Drawer>` becomes `<DeprecatedDrawer>`
94
+ root.find(j.JSXIdentifier, { name: 'Drawer' }).forEach(function (nodePath) {
95
+ nodePath.node.name = 'DeprecatedDrawer';
96
+ });
97
+ // Transform Drawer JSXElements
98
+ // e.g. `<DrawerHeader>` becomes `<DeprecatedDrawerHeader>`
99
+ root.find(j.JSXIdentifier, { name: 'DrawerHeader' }).forEach(function (nodePath) {
100
+ nodePath.node.name = 'DeprecatedDrawerHeader';
101
+ });
102
+ return root.toSource();
103
+ }
@@ -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=softDeprecateLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softDeprecateLayout.d.ts","sourceRoot":"","sources":["../../../lib/v8/softDeprecateLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAiC,OAAO,EAAC,MAAM,aAAa,CAAC;AAMlF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAwF7E"}
@@ -0,0 +1,84 @@
1
+ var mainPackage = '@workday/canvas-kit-react';
2
+ var layoutPackage = '@workday/canvas-kit-react/layout';
3
+ var allImportNames = ['Layout', 'LayoutProps', 'Column', 'ColumnProps'];
4
+ export default function transformer(file, api, options) {
5
+ var j = api.jscodeshift;
6
+ var root = j(file.source);
7
+ var hasLayoutImports = false;
8
+ // This toggles the failsafe that prevents us from accidentally transforming something unintentionally.
9
+ root.find(j.ImportDeclaration, function (nodePath) {
10
+ var value = nodePath.source.value;
11
+ // If there's an import from the layout package, set the import boolean check to true
12
+ if (value === layoutPackage) {
13
+ hasLayoutImports = true;
14
+ return false;
15
+ }
16
+ // If there's an import from the main package, check to see if Layout or LayoutProps are among the named imports
17
+ // e.g. import {Layout} from '@workday/canvas-kit-react';
18
+ if (value === mainPackage) {
19
+ (nodePath.specifiers || []).forEach(function (specifier) {
20
+ if (specifier.type === 'ImportSpecifier') {
21
+ if (allImportNames.includes(specifier.imported.name)) {
22
+ hasLayoutImports = true;
23
+ }
24
+ }
25
+ });
26
+ }
27
+ return false;
28
+ });
29
+ // Failsafe to skip transforms unless a Layout import is detected
30
+ if (!hasLayoutImports) {
31
+ return root.toSource();
32
+ }
33
+ root
34
+ .find(j.ImportDeclaration, {
35
+ source: { value: function (value) { return value.includes(mainPackage); } },
36
+ })
37
+ .forEach(function (nodePath) {
38
+ var _a;
39
+ (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(function (specifier) {
40
+ if (specifier.type === 'ImportSpecifier') {
41
+ // Adds Deprecated part to a import name for Layout, LayoutProps, Column, ColumnProps
42
+ if (allImportNames.includes(specifier.imported.name)) {
43
+ specifier.imported.name = "Deprecated" + specifier.imported.name;
44
+ }
45
+ }
46
+ return specifier;
47
+ });
48
+ });
49
+ // Add Deprecated in menu types and type interfaces
50
+ var typeNames = ['LayoutProps', 'ColumnProps'];
51
+ root
52
+ .find(j.TSTypeReference, {
53
+ typeName: {
54
+ type: 'Identifier',
55
+ name: function (name) { return typeNames.includes(name); },
56
+ },
57
+ })
58
+ .forEach(function (nodePath) {
59
+ var identifier = nodePath.value.typeName;
60
+ identifier.name = "Deprecated" + identifier.name;
61
+ });
62
+ // Add Deprecated to all interface names
63
+ root.find(j.TSInterfaceDeclaration).forEach(function (nodePath) {
64
+ var _a;
65
+ // If the interface is extending menu interfaces it should add Deprecated to them
66
+ (_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(function (typeExtension) {
67
+ if (typeExtension.expression.type === 'Identifier' &&
68
+ typeNames.includes(typeExtension.expression.name)) {
69
+ typeExtension.expression.name = "Deprecated" + typeExtension.expression.name;
70
+ }
71
+ });
72
+ });
73
+ // Transform Layout and LayoutItem JSXElements
74
+ // e.g. `<Layout>` becomes `<DeprecatedLayout>`
75
+ // e.g. `<Column>` becomes `<DeprecatedColumn>`
76
+ root
77
+ .find(j.JSXIdentifier, { name: function (name) { return name === 'Layout' || name === 'Column'; } })
78
+ .forEach(function (nodePath) {
79
+ if (nodePath.name !== 'property') {
80
+ nodePath.node.name = "Deprecated" + nodePath.node.name;
81
+ }
82
+ });
83
+ return root.toSource();
84
+ }
@@ -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=softDeprecatePreviewMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softDeprecatePreviewMenu.d.ts","sourceRoot":"","sources":["../../../lib/v8/softDeprecatePreviewMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAiC,OAAO,EAAC,MAAM,aAAa,CAAC;AAMlF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAmF7E"}
@@ -0,0 +1,79 @@
1
+ var mainPackage = '@workday/canvas-kit-preview-react';
2
+ var menuPackage = '@workday/canvas-kit-preview-react/menu';
3
+ var allImportNames = ['Menu', 'MenuProps', 'MenuState', 'MenuItem', 'MenuItemProps'];
4
+ export default function transformer(file, api, options) {
5
+ var j = api.jscodeshift;
6
+ var root = j(file.source);
7
+ var hasMenuImports = false;
8
+ // This toggles the failsafe that prevents us from accidentally transforming something unintentionally.
9
+ root.find(j.ImportDeclaration, function (nodePath) {
10
+ var value = nodePath.source.value;
11
+ // If there's an import from the menu preview package, set the import boolean check to true
12
+ if (value === menuPackage) {
13
+ hasMenuImports = true;
14
+ return false;
15
+ }
16
+ // If there's an import from the main package, check to see if Menu or MenuProps are among the named imports
17
+ // e.g. import {Menu} from '@workday/canvas-kit-preview-react';
18
+ if (value === mainPackage) {
19
+ (nodePath.specifiers || []).forEach(function (specifier) {
20
+ if (specifier.type === 'ImportSpecifier') {
21
+ if (allImportNames.includes(specifier.imported.name)) {
22
+ hasMenuImports = true;
23
+ }
24
+ }
25
+ });
26
+ }
27
+ return false;
28
+ });
29
+ // Failsafe to skip transforms unless a Menu import is detected
30
+ if (!hasMenuImports) {
31
+ return root.toSource();
32
+ }
33
+ root
34
+ .find(j.ImportDeclaration, {
35
+ source: { value: function (value) { return value.includes(mainPackage); } },
36
+ })
37
+ .forEach(function (nodePath) {
38
+ var _a;
39
+ (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(function (specifier) {
40
+ if (specifier.type === 'ImportSpecifier') {
41
+ // Adds Deprecated part to a import name for Menu, MenuProps, MenuState, MenuItem, MenuItemProps
42
+ if (allImportNames.includes(specifier.imported.name)) {
43
+ specifier.imported.name = "Deprecated" + specifier.imported.name;
44
+ }
45
+ }
46
+ return specifier;
47
+ });
48
+ });
49
+ // Add Deprecated in types using menu interfaces
50
+ var typeNames = ['MenuProps', 'MenuState', 'MenuItemProps'];
51
+ root
52
+ .find(j.TSTypeReference, {
53
+ typeName: { type: 'Identifier', name: function (name) { return typeNames.includes(name); } },
54
+ })
55
+ .forEach(function (nodePath) {
56
+ var identifier = nodePath.value.typeName;
57
+ identifier.name = "Deprecated" + identifier.name;
58
+ });
59
+ // Add Deprecated to all interface names
60
+ root.find(j.TSInterfaceDeclaration).forEach(function (nodePath) {
61
+ var _a;
62
+ // If the interface is extending menu interfaces it should add Deprecated to them
63
+ (_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(function (typeExtension) {
64
+ if (typeExtension.expression.type === 'Identifier' &&
65
+ typeNames.includes(typeExtension.expression.name)) {
66
+ typeExtension.expression.name = "Deprecated" + typeExtension.expression.name;
67
+ }
68
+ });
69
+ });
70
+ // Transform Menu and MenuItem JSXElements
71
+ // e.g. `<Menu>` becomes `<DeprecatedMenu>`
72
+ // e.g. `<MenuItem>` becomes `<DeprecatedMenuItem>`
73
+ root
74
+ .find(j.JSXIdentifier, { name: function (name) { return name === 'Menu' || name === 'MenuItem'; } })
75
+ .forEach(function (nodePath) {
76
+ nodePath.node.name = "Deprecated" + nodePath.node.name;
77
+ });
78
+ return root.toSource();
79
+ }
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.192-next.1+f60e379b",
5
+ "version": "8.0.0-alpha.194-next.2+bc1f2fe6",
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": "f60e379b0083b092707830478248ba5d78b2c96e"
46
+ "gitHead": "bc1f2fe6cdb9fccd4592698f6c1cdad5a64e84de"
47
47
  }