@workday/canvas-kit-codemod 6.3.1 → 7.0.0-alpha.0-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.
- package/dist/es6/v5/getImportRenameMap.d.ts.map +1 -1
- package/dist/es6/v5/getImportRenameMap.js +1 -0
- package/dist/es6/v5/removeButtonEnums.d.ts.map +1 -1
- package/dist/es6/v5/removeButtonEnums.js +3 -1
- package/dist/es6/v5/renamePreviewTokenImports.js +1 -1
- package/dist/es6/v6/deprecateCookieBanner.d.ts +3 -2
- package/dist/es6/v6/deprecateCookieBanner.d.ts.map +1 -1
- package/dist/es6/v6/deprecateCookieBanner.js +8 -110
- package/dist/es6/v6/deprecateHeader.d.ts +3 -2
- package/dist/es6/v6/deprecateHeader.d.ts.map +1 -1
- package/dist/es6/v6/deprecateHeader.js +5 -101
- package/dist/es6/v6/deprecatePageHeader.d.ts +3 -2
- package/dist/es6/v6/deprecatePageHeader.d.ts.map +1 -1
- package/dist/es6/v6/deprecatePageHeader.js +8 -100
- package/dist/es6/v6/index.d.ts +3 -2
- package/dist/es6/v6/index.d.ts.map +1 -1
- package/dist/es6/v6/index.js +3 -2
- package/dist/es6/v6/moveAndRenameSearchBar.d.ts +3 -2
- package/dist/es6/v6/moveAndRenameSearchBar.d.ts.map +1 -1
- package/dist/es6/v6/moveAndRenameSearchBar.js +8 -49
- package/dist/es6/v6/renameCanvasDepthValue.d.ts +3 -2
- package/dist/es6/v6/renameCanvasDepthValue.d.ts.map +1 -1
- package/dist/es6/v6/renameCanvasDepthValue.js +7 -72
- package/dist/es6/v6/utils/index.d.ts +20 -1
- package/dist/es6/v6/utils/index.d.ts.map +1 -1
- package/dist/es6/v6/utils/index.js +121 -0
- package/dist/es6/v7/compoundActionBar.d.ts +3 -0
- package/dist/es6/v7/compoundActionBar.d.ts.map +1 -0
- package/dist/es6/v7/compoundActionBar.js +42 -0
- package/dist/es6/v7/compoundBanner.d.ts +3 -0
- package/dist/es6/v7/compoundBanner.d.ts.map +1 -0
- package/dist/es6/v7/compoundBanner.js +133 -0
- package/dist/es6/v7/index.d.ts +3 -0
- package/dist/es6/v7/index.d.ts.map +1 -0
- package/dist/es6/v7/index.js +5 -0
- package/dist/es6/v7/utils/getImportRenameMap.d.ts +7 -0
- package/dist/es6/v7/utils/getImportRenameMap.d.ts.map +1 -0
- package/dist/es6/v7/utils/getImportRenameMap.js +50 -0
- package/dist/es6/v7/utils/hasImportSpecifiers.d.ts +20 -0
- package/dist/es6/v7/utils/hasImportSpecifiers.d.ts.map +1 -0
- package/dist/es6/v7/utils/hasImportSpecifiers.js +46 -0
- package/index.js +16 -9
- package/package.json +7 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getImportRenameMap.d.ts","sourceRoot":"","sources":["../../../lib/v5/getImportRenameMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"getImportRenameMap.d.ts","sourceRoot":"","sources":["../../../lib/v5/getImportRenameMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAiB,MAAM,aAAa,CAAC;AAEpE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,SAAK;;;;EAyDzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeButtonEnums.d.ts","sourceRoot":"","sources":["../../../lib/v5/removeButtonEnums.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,QAAQ,EACR,OAAO,EAKR,MAAM,aAAa,CAAC;AAkHrB,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"removeButtonEnums.d.ts","sourceRoot":"","sources":["../../../lib/v5/removeButtonEnums.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,QAAQ,EACR,OAAO,EAKR,MAAM,aAAa,CAAC;AAkHrB,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAqI7E"}
|
|
@@ -199,7 +199,9 @@ export default function transformer(file, api, options) {
|
|
|
199
199
|
}
|
|
200
200
|
return null;
|
|
201
201
|
}
|
|
202
|
-
root
|
|
202
|
+
root
|
|
203
|
+
.find(j.TSTypeReference, function (node) { return !!findTypeRename(node); })
|
|
204
|
+
.replaceWith(function (nodePath) {
|
|
203
205
|
var node = nodePath.value;
|
|
204
206
|
var matches = findTypeRename(node);
|
|
205
207
|
if (matches) {
|
|
@@ -24,7 +24,7 @@ export default function transformer(file, api) {
|
|
|
24
24
|
else {
|
|
25
25
|
// `insertBefore` ensures the import order multiple specifiers from labs-react/tokens
|
|
26
26
|
// are split into new imports. `insertAfter` would reverse the order, which isn't incorrect,
|
|
27
|
-
// but probably
|
|
27
|
+
// but probably not what you'd intuitively expect.
|
|
28
28
|
nodePath.insertBefore(j.importDeclaration([specifier], j.stringLiteral('@workday/canvas-kit-react/tokens')));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Transform } from 'jscodeshift';
|
|
2
|
+
declare const transform: Transform;
|
|
3
|
+
export default transform;
|
|
3
4
|
//# sourceMappingURL=deprecateCookieBanner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecateCookieBanner.d.ts","sourceRoot":"","sources":["../../../lib/v6/deprecateCookieBanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"deprecateCookieBanner.d.ts","sourceRoot":"","sources":["../../../lib/v6/deprecateCookieBanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAGtC,QAAA,MAAM,SAAS,EAAE,SAShB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,112 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
export default function transformer(file, api, options) {
|
|
1
|
+
import { renameImports } from './utils';
|
|
2
|
+
var transform = function (file, api) {
|
|
4
3
|
var j = api.jscodeshift;
|
|
5
4
|
var root = j(file.source);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
hasCookieBannerImports = true;
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
// If there's an import from the main package, check to see if CookieBanner or CookieBannerProps are among the named imports
|
|
16
|
-
// e.g. import {CookieBanner} from '@workday/canvas-kit-react';
|
|
17
|
-
if (value === mainPackage) {
|
|
18
|
-
(nodePath.specifiers || []).forEach(function (specifier) {
|
|
19
|
-
if (specifier.type === 'ImportSpecifier') {
|
|
20
|
-
var specifierName = specifier.imported.name;
|
|
21
|
-
if (specifierName === 'CookieBanner' || specifierName === 'CookieBannerProps') {
|
|
22
|
-
hasCookieBannerImports = true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
// Failsafe to skip transforms unless a CookieBanner import is detected
|
|
29
|
-
if (!hasCookieBannerImports) {
|
|
30
|
-
return root.toSource();
|
|
31
|
-
}
|
|
32
|
-
// Transform CookieBanner named import statements from the main package
|
|
33
|
-
// e.g. import { CookieBanner, CookieBannerProps } from '@workday/canvas-kit-react';
|
|
34
|
-
// becomes import { DeprecatedCookieBanner, DeprecatedCookieBannerProps } from '@workday/canvas-kit-react';
|
|
35
|
-
root
|
|
36
|
-
.find(j.ImportDeclaration, { source: { value: '@workday/canvas-kit-react' } })
|
|
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
|
-
// `import {CookieBanner}` becomes `import {DeprecatedCookieBanner}`
|
|
42
|
-
if (specifier.imported.name === 'CookieBanner') {
|
|
43
|
-
specifier.imported.name = 'DeprecatedCookieBanner';
|
|
44
|
-
}
|
|
45
|
-
if (specifier.imported.name === 'CookieBannerProps') {
|
|
46
|
-
specifier.imported.name = 'DeprecatedCookieBannerProps';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return specifier;
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
// Transform CookieBanner default and named import statements from the cookie-banner package
|
|
53
|
-
root
|
|
54
|
-
.find(j.ImportDeclaration, { source: { value: '@workday/canvas-kit-react/cookie-banner' } })
|
|
55
|
-
.forEach(function (nodePath) {
|
|
56
|
-
var _a;
|
|
57
|
-
(_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(function (specifier) {
|
|
58
|
-
var _a;
|
|
59
|
-
if (specifier.type === 'ImportDefaultSpecifier') {
|
|
60
|
-
// `import CookieBanner` becomes `import DeprecatedCookieBanner`
|
|
61
|
-
if (((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) === 'CookieBanner') {
|
|
62
|
-
specifier.local.name = 'DeprecatedCookieBanner';
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (specifier.type === 'ImportSpecifier') {
|
|
66
|
-
// `import {CookieBanner}` becomes `import {DeprecatedCookieBanner}`
|
|
67
|
-
if (specifier.imported.name === 'CookieBanner') {
|
|
68
|
-
specifier.imported.name = 'DeprecatedCookieBanner';
|
|
69
|
-
}
|
|
70
|
-
// `import {CookieBannerProps}` becomes `import {DeprecatedCookieBannerProps}`
|
|
71
|
-
if (specifier.imported.name === 'CookieBannerProps') {
|
|
72
|
-
specifier.imported.name = 'DeprecatedCookieBannerProps';
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return specifier;
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
// Transform CookieBannerProps type references
|
|
79
|
-
// e.g. `type CustomProps = CookieBannerProps;` becomes `type CustomProps = DeprecatedCookieBannerProps;`
|
|
80
|
-
root
|
|
81
|
-
.find(j.TSTypeReference, { typeName: { type: 'Identifier', name: 'CookieBannerProps' } })
|
|
82
|
-
.forEach(function (nodePath) {
|
|
83
|
-
var identifier = nodePath.value.typeName;
|
|
84
|
-
identifier.name = 'DeprecatedCookieBannerProps';
|
|
85
|
-
});
|
|
86
|
-
// Transform CookieBannerProps type interface declaration references
|
|
87
|
-
// e.g. `interface CustomProps extends CookieBannerProps` becomes `interface CustomProps extends DeprecatedCookieBannerProps`
|
|
88
|
-
root.find(j.TSInterfaceDeclaration).forEach(function (nodePath) {
|
|
89
|
-
var _a;
|
|
90
|
-
// If the interface is extending CookieBannerProps, transform the extension name to DeprecatedCookieBannerProps
|
|
91
|
-
(_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(function (typeExtension) {
|
|
92
|
-
if (typeExtension.expression.type === 'Identifier' &&
|
|
93
|
-
typeExtension.expression.name === 'CookieBannerProps') {
|
|
94
|
-
typeExtension.expression.name = 'DeprecatedCookieBannerProps';
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
// Transform CookieBanner JSXElements
|
|
99
|
-
// e.g. `<CookieBanner>` becomes `<DeprecatedCookieBanner>`
|
|
100
|
-
root.find(j.JSXIdentifier, { name: 'CookieBanner' }).forEach(function (nodePath) {
|
|
101
|
-
nodePath.node.name = 'DeprecatedCookieBanner';
|
|
102
|
-
});
|
|
103
|
-
// Transform CookieBanner MemberExpressions
|
|
104
|
-
// e.g. `CookieBanner.DefaultNotice` becomes `DeprecatedCookieBanner.DefaultNotice`
|
|
105
|
-
root
|
|
106
|
-
.find(j.MemberExpression, { object: { type: 'Identifier', name: 'CookieBanner' } })
|
|
107
|
-
.forEach(function (nodePath) {
|
|
108
|
-
var identifier = nodePath.value.object;
|
|
109
|
-
identifier.name = 'DeprecatedCookieBanner';
|
|
110
|
-
});
|
|
111
|
-
return root.toSource();
|
|
112
|
-
}
|
|
5
|
+
return renameImports(api, root, '@workday/canvas-kit-react/cookie-banner', {
|
|
6
|
+
CookieBanner: 'DeprecatedCookieBanner',
|
|
7
|
+
CookieBannerProps: 'DeprecatedCookieBannerProps',
|
|
8
|
+
}).toSource();
|
|
9
|
+
};
|
|
10
|
+
export default transform;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Transform } from 'jscodeshift';
|
|
2
|
+
declare const transform: Transform;
|
|
3
|
+
export default transform;
|
|
3
4
|
//# sourceMappingURL=deprecateHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecateHeader.d.ts","sourceRoot":"","sources":["../../../lib/v6/deprecateHeader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"deprecateHeader.d.ts","sourceRoot":"","sources":["../../../lib/v6/deprecateHeader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAgBtC,QAAA,MAAM,SAAS,EAAE,SAWhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
3
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
4
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
5
|
-
r[k] = a[j];
|
|
6
|
-
return r;
|
|
7
|
-
};
|
|
8
|
-
import { filterImportDefaultSpecifiers, filterImportSpecifiers, renameImportDefaultSpecifiers, renameImportSpecifiers, } from './utils';
|
|
9
|
-
var mainPackage = '@workday/canvas-kit-labs-react';
|
|
10
|
-
var headerPackage = '@workday/canvas-kit-labs-react/header';
|
|
11
|
-
var headerComponents = ['DubLogoTitle', 'Header', 'GlobalHeader', 'WorkdayLogoTitle'];
|
|
12
|
-
var headerUtils = ['themes'];
|
|
13
|
-
var headerTypes = ['Themes', 'ThemeAttributes', 'HeaderTheme', 'HeaderVariant', 'HeaderHeight'];
|
|
14
|
-
var headerImportSpecifiers = __spreadArrays(headerComponents, headerUtils, headerTypes);
|
|
15
|
-
var headerDefaultImportSpecifiers = ['Header'];
|
|
1
|
+
import { renameImports } from './utils';
|
|
16
2
|
var headerRenameMap = {
|
|
17
3
|
DubLogoTitle: 'DeprecatedDubLogoTitle',
|
|
18
4
|
GlobalHeader: 'DeprecatedGlobalHeader',
|
|
@@ -25,91 +11,9 @@ var headerRenameMap = {
|
|
|
25
11
|
WorkdayLogoTitle: 'DeprecatedWorkdayLogoTitle',
|
|
26
12
|
themes: 'deprecatedHeaderThemes',
|
|
27
13
|
};
|
|
28
|
-
|
|
14
|
+
var transform = function (file, api) {
|
|
29
15
|
var j = api.jscodeshift;
|
|
30
16
|
var root = j(file.source);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// if importing from the header package, set the failsafe to true
|
|
35
|
-
if (value === headerPackage) {
|
|
36
|
-
hasHeaderImports = true;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
// if importing from the main package, check for header imports and toggle the failsafe if any are found
|
|
40
|
-
if (value === mainPackage) {
|
|
41
|
-
var importSpecifiers = nodePath.specifiers || [];
|
|
42
|
-
var headerSpecifiers = filterImportSpecifiers(importSpecifiers, headerImportSpecifiers);
|
|
43
|
-
if (headerSpecifiers.length) {
|
|
44
|
-
hasHeaderImports = true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
// Failsafe to skip transforms unless a header import is detected
|
|
49
|
-
if (!hasHeaderImports) {
|
|
50
|
-
return root.toSource();
|
|
51
|
-
}
|
|
52
|
-
// Rename header named imports from @workday/canvas-kit-labs-react
|
|
53
|
-
// e.g. `import { Header } from '@workday/canvas-kit-labs-react';`
|
|
54
|
-
// becomes `import { DeprecatedHeader } from '@workday/canvas-kit-labs-react';`
|
|
55
|
-
root.find(j.ImportDeclaration, { source: { value: mainPackage } }).forEach(function (nodePath) {
|
|
56
|
-
var importSpecifiers = nodePath.value.specifiers || [];
|
|
57
|
-
// filter header imports
|
|
58
|
-
var headerImports = filterImportSpecifiers(importSpecifiers, headerImportSpecifiers);
|
|
59
|
-
renameImportSpecifiers(headerImports, headerRenameMap);
|
|
60
|
-
});
|
|
61
|
-
// Rename default and named header imports from @workday/canvas-kit-labs-react/header
|
|
62
|
-
// e.g. `import Header, { GlobalHeader } from '@workday/canvas-kit-labs-react/header';`
|
|
63
|
-
// becomes `import DeprecatedHeader, { DeprecatedGlobalHeader } from '@workday/canvas-kit-labs-react/header';`
|
|
64
|
-
root.find(j.ImportDeclaration, { source: { value: headerPackage } }).forEach(function (nodePath) {
|
|
65
|
-
var importSpecifiers = nodePath.value.specifiers || [];
|
|
66
|
-
// filter header named imports
|
|
67
|
-
var headerImports = filterImportSpecifiers(importSpecifiers, headerImportSpecifiers);
|
|
68
|
-
// rename header import specifiers
|
|
69
|
-
// e.g import { Header } becomes import { DeprecatedHeader }
|
|
70
|
-
renameImportSpecifiers(headerImports, headerRenameMap);
|
|
71
|
-
// filter header default imports
|
|
72
|
-
var headerDefaultImports = filterImportDefaultSpecifiers(importSpecifiers, headerDefaultImportSpecifiers);
|
|
73
|
-
// rename header import default specifiers
|
|
74
|
-
// e.g import Header becomes import DeprecatedHeader
|
|
75
|
-
renameImportDefaultSpecifiers(headerDefaultImports, headerRenameMap);
|
|
76
|
-
});
|
|
77
|
-
// Transform header type references
|
|
78
|
-
// e.g. `type CustomThemeAttributes = ThemeAttributes;` becomes `type CustomThemeAttributes = DeprecatedCThemeAttributes;`
|
|
79
|
-
root.find(j.TSTypeReference, { typeName: { type: 'Identifier' } }).forEach(function (nodePath) {
|
|
80
|
-
var identifier = nodePath.value.typeName;
|
|
81
|
-
if (headerTypes.includes(identifier.name)) {
|
|
82
|
-
identifier.name = headerRenameMap[identifier.name];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
// Transform header type interface declaration references
|
|
86
|
-
// e.g. `interface CustomThemeAttributes extends ThemeAttributes {}`
|
|
87
|
-
// becomes `interface CustomThemeAttributes extends DeprecatedHeaderThemeAttributes {}`
|
|
88
|
-
root.find(j.TSInterfaceDeclaration).forEach(function (nodePath) {
|
|
89
|
-
var _a;
|
|
90
|
-
// If the interface is extending header type, transform the extension name,
|
|
91
|
-
(_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(function (typeExtension) {
|
|
92
|
-
if (typeExtension.expression.type === 'Identifier' &&
|
|
93
|
-
headerTypes.includes(typeExtension.expression.name)) {
|
|
94
|
-
typeExtension.expression.name = headerRenameMap[typeExtension.expression.name];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
// Transform header JSXElements
|
|
99
|
-
// e.g. `<Header>` becomes `<DeprecatedHeader>`
|
|
100
|
-
root.find(j.JSXIdentifier).forEach(function (nodePath) {
|
|
101
|
-
var identifierName = nodePath.node.name;
|
|
102
|
-
if (headerComponents.includes(identifierName)) {
|
|
103
|
-
nodePath.node.name = headerRenameMap[identifierName];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
// Transform header MemberExpressions
|
|
107
|
-
// e.g. `HeaderHeight.Small` becomes `DeprecatedHeaderHeight.Small`
|
|
108
|
-
root.find(j.MemberExpression, { object: { type: 'Identifier' } }).forEach(function (nodePath) {
|
|
109
|
-
var identifier = nodePath.value.object;
|
|
110
|
-
if (identifier.name in headerRenameMap) {
|
|
111
|
-
identifier.name = headerRenameMap[identifier.name];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
return root.toSource();
|
|
115
|
-
}
|
|
17
|
+
return renameImports(api, root, '@workday/canvas-kit-labs-react/header', headerRenameMap).toSource();
|
|
18
|
+
};
|
|
19
|
+
export default transform;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Transform } from 'jscodeshift';
|
|
2
|
+
declare const transform: Transform;
|
|
3
|
+
export default transform;
|
|
3
4
|
//# sourceMappingURL=deprecatePageHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecatePageHeader.d.ts","sourceRoot":"","sources":["../../../lib/v6/deprecatePageHeader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"deprecatePageHeader.d.ts","sourceRoot":"","sources":["../../../lib/v6/deprecatePageHeader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAGtC,QAAA,MAAM,SAAS,EAAE,SAShB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,102 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
export default function transformer(file, api, options) {
|
|
1
|
+
import { renameImports } from './utils';
|
|
2
|
+
var transform = function (file, api) {
|
|
4
3
|
var j = api.jscodeshift;
|
|
5
4
|
var root = j(file.source);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
hasPageHeaderImports = true;
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
// If there's an import from the main package, check to see if PageHeader or PageHeaderProps are among the named imports
|
|
16
|
-
// e.g. import {PageHeader} from '@workday/canvas-kit-react';
|
|
17
|
-
if (value === mainPackage) {
|
|
18
|
-
(nodePath.specifiers || []).forEach(function (specifier) {
|
|
19
|
-
if (specifier.type === 'ImportSpecifier') {
|
|
20
|
-
var specifierName = specifier.imported.name;
|
|
21
|
-
if (specifierName === 'PageHeader' || specifierName === 'PageHeaderProps') {
|
|
22
|
-
hasPageHeaderImports = true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
// Failsafe to skip transforms unless a PageHeader import is detected
|
|
29
|
-
if (!hasPageHeaderImports) {
|
|
30
|
-
return root.toSource();
|
|
31
|
-
}
|
|
32
|
-
root
|
|
33
|
-
.find(j.ImportDeclaration, { source: { value: '@workday/canvas-kit-react' } })
|
|
34
|
-
.forEach(function (nodePath) {
|
|
35
|
-
var _a;
|
|
36
|
-
(_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(function (specifier) {
|
|
37
|
-
if (specifier.type === 'ImportSpecifier') {
|
|
38
|
-
// `import {PageHeader}` becomes `import {DeprecatedPageHeader}`
|
|
39
|
-
if (specifier.imported.name === 'PageHeader') {
|
|
40
|
-
specifier.imported.name = 'DeprecatedPageHeader';
|
|
41
|
-
}
|
|
42
|
-
// `import {PageHeaderProps}` becomes `import {DeprecatedPageHeaderProps}`
|
|
43
|
-
if (specifier.imported.name === 'PageHeaderProps') {
|
|
44
|
-
specifier.imported.name = 'DeprecatedPageHeaderProps';
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return specifier;
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
// Transform PageHeader default and named import statements from the page-header package
|
|
51
|
-
root
|
|
52
|
-
.find(j.ImportDeclaration, { source: { value: '@workday/canvas-kit-react/page-header' } })
|
|
53
|
-
.forEach(function (nodePath) {
|
|
54
|
-
var _a;
|
|
55
|
-
(_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(function (specifier) {
|
|
56
|
-
var _a;
|
|
57
|
-
if (specifier.type === 'ImportDefaultSpecifier') {
|
|
58
|
-
// `import PageHeader` becomes `import DeprecatedPageHeader`
|
|
59
|
-
if (((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) === 'PageHeader') {
|
|
60
|
-
specifier.local.name = 'DeprecatedPageHeader';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (specifier.type === 'ImportSpecifier') {
|
|
64
|
-
// `import {PageHeader}` becomes `import {DeprecatedPageHeader}`
|
|
65
|
-
if (specifier.imported.name === 'PageHeader') {
|
|
66
|
-
specifier.imported.name = 'DeprecatedPageHeader';
|
|
67
|
-
}
|
|
68
|
-
// `import {PageHeaderProps}` becomes `import {DeprecatedPageHeaderProps}`
|
|
69
|
-
if (specifier.imported.name === 'PageHeaderProps') {
|
|
70
|
-
specifier.imported.name = 'DeprecatedPageHeaderProps';
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return specifier;
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
// Transform PageHeaderProps type references
|
|
77
|
-
// e.g. `type CustomProps = PageHeaderProps;` becomes `type CustomProps = DeprecatedPageHeaderProps;`
|
|
78
|
-
root
|
|
79
|
-
.find(j.TSTypeReference, { typeName: { type: 'Identifier', name: 'PageHeaderProps' } })
|
|
80
|
-
.forEach(function (nodePath) {
|
|
81
|
-
var identifier = nodePath.value.typeName;
|
|
82
|
-
identifier.name = 'DeprecatedPageHeaderProps';
|
|
83
|
-
});
|
|
84
|
-
// Transform PageHeaderProps type interface declaration references
|
|
85
|
-
// e.g. `interface CustomProps extends PageHeaderProps` becomes `interface CustomProps extends DeprecatedPageHeaderProps`
|
|
86
|
-
root.find(j.TSInterfaceDeclaration).forEach(function (nodePath) {
|
|
87
|
-
var _a;
|
|
88
|
-
// If the interface is extending PageHeaderProps, transform the extension name to DeprecatedPageHeaderProps
|
|
89
|
-
(_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(function (typeExtension) {
|
|
90
|
-
if (typeExtension.expression.type === 'Identifier' &&
|
|
91
|
-
typeExtension.expression.name === 'PageHeaderProps') {
|
|
92
|
-
typeExtension.expression.name = 'DeprecatedPageHeaderProps';
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
// Transform PageHeader JSXElements
|
|
97
|
-
// e.g. `<PageHeader>` becomes `<DeprecatedPageHeader>`
|
|
98
|
-
root.find(j.JSXIdentifier, { name: 'PageHeader' }).forEach(function (nodePath) {
|
|
99
|
-
nodePath.node.name = 'DeprecatedPageHeader';
|
|
100
|
-
});
|
|
101
|
-
return root.toSource();
|
|
102
|
-
}
|
|
5
|
+
return renameImports(api, root, '@workday/canvas-kit-react/page-header', {
|
|
6
|
+
PageHeader: 'DeprecatedPageHeader',
|
|
7
|
+
PageHeaderProps: 'DeprecatedPageHeaderProps',
|
|
8
|
+
}).toSource();
|
|
9
|
+
};
|
|
10
|
+
export default transform;
|
package/dist/es6/v6/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Transform } from 'jscodeshift';
|
|
2
|
+
declare const transform: Transform;
|
|
3
|
+
export default transform;
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v6/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v6/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAYtC,QAAA,MAAM,SAAS,EAAE,SAYhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/es6/v6/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import moveAndRenameSearchBar from './moveAndRenameSearchBar';
|
|
|
19
19
|
import deprecateHeader from './deprecateHeader';
|
|
20
20
|
// rename CanvasDepthValue
|
|
21
21
|
import renameCanvasDepthValue from './renameCanvasDepthValue';
|
|
22
|
-
|
|
22
|
+
var transform = function (file, api, options) {
|
|
23
23
|
// These will run in order. If your transform depends on others, place yours after dependent transforms
|
|
24
24
|
var fixes = [
|
|
25
25
|
deprecatePageHeader,
|
|
@@ -30,4 +30,5 @@ export default function transformer(file, api, options) {
|
|
|
30
30
|
renameCanvasDepthValue,
|
|
31
31
|
];
|
|
32
32
|
return fixes.reduce(function (source, fix) { return fix(__assign(__assign({}, file), { source: source }), api, options); }, file.source);
|
|
33
|
-
}
|
|
33
|
+
};
|
|
34
|
+
export default transform;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Transform } from 'jscodeshift';
|
|
2
|
+
declare const transform: Transform;
|
|
3
|
+
export default transform;
|
|
3
4
|
//# sourceMappingURL=moveAndRenameSearchBar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moveAndRenameSearchBar.d.ts","sourceRoot":"","sources":["../../../lib/v6/moveAndRenameSearchBar.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"moveAndRenameSearchBar.d.ts","sourceRoot":"","sources":["../../../lib/v6/moveAndRenameSearchBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAqC,MAAM,aAAa,CAAC;AAyBnF,QAAA,MAAM,SAAS,EAAE,SA0EhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -5,7 +5,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
|
5
5
|
r[k] = a[j];
|
|
6
6
|
return r;
|
|
7
7
|
};
|
|
8
|
-
import { filterImportSpecifiers, renameImportSpecifiers, } from './utils';
|
|
8
|
+
import { filterImportSpecifiers, renameImportSpecifiers, renameImports, hasImportSpecifiers, } from './utils';
|
|
9
9
|
var mainPackage = '@workday/canvas-kit-labs-react';
|
|
10
10
|
var headerPackage = '@workday/canvas-kit-labs-react/header';
|
|
11
11
|
var searchBarRenameImports = ['SearchBar', 'SearchBarProps', 'SearchBarState'];
|
|
@@ -18,29 +18,15 @@ var renameMap = {
|
|
|
18
18
|
SearchBarProps: 'SearchFormProps',
|
|
19
19
|
SearchBarState: 'SearchFormState',
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
var transform = function (file, api) {
|
|
22
22
|
var j = api.jscodeshift;
|
|
23
23
|
var root = j(file.source);
|
|
24
|
-
|
|
24
|
+
if (!hasImportSpecifiers(api, root, '@workday/canvas-kit-labs-react/header', Object.keys(renameMap))) {
|
|
25
|
+
return file.source;
|
|
26
|
+
}
|
|
25
27
|
function insertImportDeclarationBefore(nodePath, specifiers, sourcePath) {
|
|
26
28
|
nodePath.insertBefore(j.importDeclaration(specifiers, j.stringLiteral(sourcePath)));
|
|
27
29
|
}
|
|
28
|
-
// This toggles the failsafe that prevents us from accidentally transforming something unintentionally.
|
|
29
|
-
root.find(j.ImportDeclaration, function (nodePath) {
|
|
30
|
-
var value = nodePath.source.value;
|
|
31
|
-
// if there's any SearchBar imports from either the main package or the header package, toggle the failsafe
|
|
32
|
-
if (value === mainPackage || value === headerPackage) {
|
|
33
|
-
var importSpecifiers = nodePath.specifiers || [];
|
|
34
|
-
var searchBarImports = filterImportSpecifiers(importSpecifiers, searchBarImportSpecifiers);
|
|
35
|
-
if (searchBarImports.length) {
|
|
36
|
-
hasSearchBarImports = true;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
// Failsafe to skip transforms unless a SearchBar import is detected
|
|
41
|
-
if (!hasSearchBarImports) {
|
|
42
|
-
return root.toSource();
|
|
43
|
-
}
|
|
44
30
|
// Rename search-bar named imports from @workday/canvas-kit-labs-react
|
|
45
31
|
// e.g. import { SearchBar, SearchBarProps } from '@workday/canvas-kit-labs-react';
|
|
46
32
|
// becomes import { SearchForm, SearchFormProps } from '@workday/canvas-kit-labs-react';
|
|
@@ -85,33 +71,6 @@ export default function transformer(file, api) {
|
|
|
85
71
|
insertImportDeclarationBefore(nodePath, headerSpecifiers, headerPackage);
|
|
86
72
|
}
|
|
87
73
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
nodePath.node.name = 'SearchForm';
|
|
92
|
-
});
|
|
93
|
-
// Transform SearchBarProps and SearchBarState type references
|
|
94
|
-
// e.g. type CustomSearchType = SearchBarProps & SearchBarState;
|
|
95
|
-
// becomes type CustomSearchType = SearchFormProps & SearchFormState;
|
|
96
|
-
root.find(j.TSTypeReference, { typeName: { type: 'Identifier' } }).forEach(function (nodePath) {
|
|
97
|
-
var identifier = nodePath.value.typeName;
|
|
98
|
-
if (identifier.name in renameMap) {
|
|
99
|
-
identifier.name = renameMap[identifier.name];
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
// Transform SearchBarProps type interface declaration references
|
|
103
|
-
// e.g. `interface CustomProps extends SearchBarProps` becomes `interface CustomProps extends SearchFormProps`
|
|
104
|
-
root.find(j.TSInterfaceDeclaration).forEach(function (nodePath) {
|
|
105
|
-
var _a;
|
|
106
|
-
// If the interface is extending SearchBarProps, transform the extension name to SearchFormProps
|
|
107
|
-
(_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(function (typeExtension) {
|
|
108
|
-
if (typeExtension.expression.type === 'Identifier') {
|
|
109
|
-
var typeName = typeExtension.expression.name;
|
|
110
|
-
if (typeName in renameMap) {
|
|
111
|
-
typeExtension.expression.name = renameMap[typeName];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
return root.toSource();
|
|
117
|
-
}
|
|
74
|
+
return renameImports(api, root, '@workday/canvas-kit-labs-react/header', renameMap).toSource();
|
|
75
|
+
};
|
|
76
|
+
export default transform;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Transform } from 'jscodeshift';
|
|
2
|
+
declare const transform: Transform;
|
|
3
|
+
export default transform;
|
|
3
4
|
//# sourceMappingURL=renameCanvasDepthValue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renameCanvasDepthValue.d.ts","sourceRoot":"","sources":["../../../lib/v6/renameCanvasDepthValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"renameCanvasDepthValue.d.ts","sourceRoot":"","sources":["../../../lib/v6/renameCanvasDepthValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAGtC,QAAA,MAAM,SAAS,EAAE,SAQhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|