@workday/canvas-kit-codemod 15.0.0-alpha.0076-next.0 → 15.0.0-alpha.0090-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/v15/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v15/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAOtC,QAAA,MAAM,SAAS,EAAE,SAShB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/es6/v15/index.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import promoteInformationHighlight from './promoteInformationHighlight';
|
|
2
2
|
import promotePill from './promotePill';
|
|
3
3
|
import promoteSegmentedControl from './promoteSegmentedControl';
|
|
4
|
+
import promoteAvatar from './promoteAvatar';
|
|
4
5
|
const transform = (file, api, options) => {
|
|
5
6
|
// These will run in order. If your transform depends on others, place yours after dependent transforms
|
|
6
|
-
const fixes = [
|
|
7
|
+
const fixes = [
|
|
8
|
+
promoteSegmentedControl,
|
|
9
|
+
promoteInformationHighlight,
|
|
10
|
+
promotePill,
|
|
11
|
+
promoteAvatar,
|
|
12
|
+
];
|
|
7
13
|
return fixes.reduce((source, fix) => fix({ ...file, source }, api, options), file.source);
|
|
8
14
|
};
|
|
9
15
|
export default transform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promoteAvatar.d.ts","sourceRoot":"","sources":["../../../lib/v15/promoteAvatar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAA6B,MAAM,aAAa,CAAC;AAqBlE,QAAA,MAAM,SAAS,EAAE,SAyEhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// List of all Avatar-related exports from preview that should be promoted
|
|
2
|
+
const AVATAR_EXPORTS = [
|
|
3
|
+
'Avatar',
|
|
4
|
+
'AvatarProps',
|
|
5
|
+
'avatarStencil',
|
|
6
|
+
'AvatarImage',
|
|
7
|
+
'AvatarImageProps',
|
|
8
|
+
'avatarImageStencil',
|
|
9
|
+
'AvatarName',
|
|
10
|
+
'AvatarNameProps',
|
|
11
|
+
'avatarNameStencil',
|
|
12
|
+
'BaseAvatar',
|
|
13
|
+
'BaseAvatarProps',
|
|
14
|
+
'baseAvatarStencil',
|
|
15
|
+
'getInitialsFromName',
|
|
16
|
+
];
|
|
17
|
+
const transform = (file, api) => {
|
|
18
|
+
const j = api.jscodeshift;
|
|
19
|
+
const root = j(file.source);
|
|
20
|
+
const avatarSpecifiers = [];
|
|
21
|
+
const foundImport = [];
|
|
22
|
+
root
|
|
23
|
+
.find(j.ImportDeclaration, {
|
|
24
|
+
source: { value: (value) => value.includes('@workday/canvas-kit-preview-react') },
|
|
25
|
+
})
|
|
26
|
+
.forEach(nodePath => {
|
|
27
|
+
var _a;
|
|
28
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.filter(specifier => {
|
|
29
|
+
if (specifier.type === 'ImportSpecifier' &&
|
|
30
|
+
specifier.local &&
|
|
31
|
+
AVATAR_EXPORTS.includes(specifier.imported.name)) {
|
|
32
|
+
avatarSpecifiers.push({
|
|
33
|
+
importedName: specifier.imported.name,
|
|
34
|
+
name: specifier.local.name,
|
|
35
|
+
});
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
});
|
|
40
|
+
if (avatarSpecifiers.length) {
|
|
41
|
+
foundImport.push(nodePath);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const existingAvatarImports = root.find(j.ImportDeclaration, {
|
|
45
|
+
source: { value: '@workday/canvas-kit-react/avatar' },
|
|
46
|
+
});
|
|
47
|
+
const mapToSpecifiers = (specifier) => {
|
|
48
|
+
return j.importSpecifier(j.identifier(specifier.importedName), specifier.name ? j.identifier(specifier.name) : undefined);
|
|
49
|
+
};
|
|
50
|
+
// add to existing import
|
|
51
|
+
if (existingAvatarImports.length) {
|
|
52
|
+
existingAvatarImports.forEach(nodePath => {
|
|
53
|
+
var _a;
|
|
54
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.concat(avatarSpecifiers.map(mapToSpecifiers));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// create new import
|
|
59
|
+
if (foundImport.length) {
|
|
60
|
+
foundImport[0].insertBefore(j.importDeclaration(avatarSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/avatar')));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
foundImport.forEach(importPath => {
|
|
64
|
+
var _a;
|
|
65
|
+
if (!((_a = importPath.value.specifiers) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
66
|
+
importPath.value.source.value === '@workday/canvas-kit-preview-react/avatar') {
|
|
67
|
+
importPath.prune();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return root.toSource();
|
|
71
|
+
};
|
|
72
|
+
export default transform;
|
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": "15.0.0-alpha.
|
|
5
|
+
"version": "15.0.0-alpha.0090-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": "54d08f77d0527af840c9f102ce9a8f44942a5e9d"
|
|
50
50
|
}
|