@workday/canvas-kit-codemod 13.0.0-alpha.1074-next.0 → 13.0.0-alpha.1075-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.
- package/dist/es6/v13/index.d.ts.map +1 -1
- package/dist/es6/v13/index.js +4 -0
- package/dist/es6/v13/renameDubLogosImports.d.ts +3 -0
- package/dist/es6/v13/renameDubLogosImports.d.ts.map +1 -0
- package/dist/es6/v13/renameDubLogosImports.js +43 -0
- package/dist/es6/v13/renameDubLogosReferences.d.ts +3 -0
- package/dist/es6/v13/renameDubLogosReferences.d.ts.map +1 -0
- package/dist/es6/v13/renameDubLogosReferences.js +38 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v13/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v13/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAKtC,QAAA,MAAM,SAAS,EAAE,SAShB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/es6/v13/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import addPillLabel from './addPillLabel';
|
|
2
|
+
import renameDubLogosImports from './renameDubLogosImports';
|
|
3
|
+
import renameDubLogosReferences from './renameDubLogosReferences';
|
|
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
6
|
const fixes = [
|
|
5
7
|
// add codemods here
|
|
6
8
|
addPillLabel,
|
|
9
|
+
renameDubLogosImports,
|
|
10
|
+
renameDubLogosReferences,
|
|
7
11
|
];
|
|
8
12
|
return fixes.reduce((source, fix) => fix({ ...file, source }, api, options), file.source);
|
|
9
13
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renameDubLogosImports.d.ts","sourceRoot":"","sources":["../../../lib/v13/renameDubLogosImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,aAAa,CAAC;AAOnD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAsC7E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { hasImportSpecifiers } from '../v6/utils';
|
|
2
|
+
const mainPackage = '@workday/canvas-kit-react';
|
|
3
|
+
const dubLogoPackage = '@workday/canvas-kit-react/common';
|
|
4
|
+
const dubLogoImports = ['dubLogoBlue', 'dubLogoWhite', 'wdayLogoBlue', 'wdayLogoWhite'];
|
|
5
|
+
export default function transformer(file, api, options) {
|
|
6
|
+
const j = api.jscodeshift;
|
|
7
|
+
const root = j(file.source);
|
|
8
|
+
// exit if the named imports aren't found
|
|
9
|
+
if (!hasImportSpecifiers(api, root, dubLogoPackage, dubLogoImports)) {
|
|
10
|
+
return file.source;
|
|
11
|
+
}
|
|
12
|
+
root
|
|
13
|
+
.find(j.ImportDeclaration, {
|
|
14
|
+
// filter on imports from "@workday/canvas-kit/react" including slash imports
|
|
15
|
+
source: { value: (value) => value.includes(mainPackage) },
|
|
16
|
+
})
|
|
17
|
+
.forEach(nodePath => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(specifier => {
|
|
20
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
21
|
+
// Transform named import
|
|
22
|
+
// e.g. `import {dubLogoBlue}` becomes `import {dubLogoPrimary}`
|
|
23
|
+
if (specifier.imported.name === 'dubLogoBlue') {
|
|
24
|
+
specifier.imported.name = 'dubLogoPrimary';
|
|
25
|
+
// e.g. `import {dubLogoWhite}` becomes `import {dubLogoReversed}`
|
|
26
|
+
}
|
|
27
|
+
else if (specifier.imported.name === 'dubLogoWhite') {
|
|
28
|
+
specifier.imported.name = 'dubLogoReversed';
|
|
29
|
+
// e.g. `import {wdayLogoBlue}` becomes `import {wdayLogoPrimary}`
|
|
30
|
+
}
|
|
31
|
+
else if (specifier.imported.name === 'wdayLogoBlue') {
|
|
32
|
+
specifier.imported.name = 'wdayLogoPrimary';
|
|
33
|
+
// e.g. `import {wdayLogoWhite}` becomes `import {wdayLogoReversed}`
|
|
34
|
+
}
|
|
35
|
+
else if (specifier.imported.name === 'wdayLogoWhite') {
|
|
36
|
+
specifier.imported.name = 'wdayLogoReversed';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return specifier;
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
return root.toSource();
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renameDubLogosReferences.d.ts","sourceRoot":"","sources":["../../../lib/v13/renameDubLogosReferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAc,OAAO,EAAC,MAAM,aAAa,CAAC;AAQ/D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAyC7E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { hasImportSpecifiers } from '../v6/utils';
|
|
2
|
+
import { getImportRenameMap } from './utils/getImportRenameMap';
|
|
3
|
+
const dubLogoPackages = ['@workday/canvas-kit-react', '@workday/canvas-kit-react/common'];
|
|
4
|
+
const packageImports = ['dubLogoPrimary', 'dubLogoReversed', 'wdayLogoPrimary', 'wdayLogoReversed'];
|
|
5
|
+
const oldpackageImports = ['dubLogoBlue', 'dubLogoWhite', 'wdayLogoBlue', 'wdayLogoWhite'];
|
|
6
|
+
export default function transformer(file, api, options) {
|
|
7
|
+
const j = api.jscodeshift;
|
|
8
|
+
const root = j(file.source);
|
|
9
|
+
// exit if the named imports aren't found
|
|
10
|
+
if (!hasImportSpecifiers(api, root, dubLogoPackages, packageImports)) {
|
|
11
|
+
return file.source;
|
|
12
|
+
}
|
|
13
|
+
// getImportRenameMap utility will tell us if the file containsCanvasImports
|
|
14
|
+
// and give us an importMap to track what identifiers we need to update
|
|
15
|
+
const { importMap } = getImportRenameMap(j, root, '@workday/canvas-kit-react');
|
|
16
|
+
const expressions = root.find(j.JSXExpressionContainer);
|
|
17
|
+
// Transform attributes
|
|
18
|
+
expressions
|
|
19
|
+
.find(j.Identifier, (value) => {
|
|
20
|
+
const isCorrectImport = Object.entries(importMap).some(([original, imported]) => imported === original && oldpackageImports.includes(value.name));
|
|
21
|
+
return isCorrectImport;
|
|
22
|
+
})
|
|
23
|
+
.forEach(nodePath => {
|
|
24
|
+
if (nodePath.node.name === 'dubLogoBlue') {
|
|
25
|
+
nodePath.node.name = 'dubLogoPrimary';
|
|
26
|
+
}
|
|
27
|
+
else if (nodePath.node.name === 'dubLogoWhite') {
|
|
28
|
+
nodePath.node.name = 'dubLogoReversed';
|
|
29
|
+
}
|
|
30
|
+
if (nodePath.node.name === 'wdayLogoBlue') {
|
|
31
|
+
nodePath.node.name = 'wdayLogoPrimary';
|
|
32
|
+
}
|
|
33
|
+
if (nodePath.node.name === 'wdayLogoWhite') {
|
|
34
|
+
nodePath.node.name = 'wdayLogoReversed';
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return root.toSource();
|
|
38
|
+
}
|
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": "13.0.0-alpha.
|
|
5
|
+
"version": "13.0.0-alpha.1075-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": "
|
|
49
|
+
"gitHead": "423e097625d8c1cf8e48dcfc794313aae00ded67"
|
|
50
50
|
}
|