@workday/canvas-kit-codemod 16.0.0-alpha.0396-next.0 → 16.0.0-alpha.0424-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.
@@ -0,0 +1,4 @@
1
+ import { Transform } from 'jscodeshift';
2
+ declare const transform: Transform;
3
+ export default transform;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v16/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,QAAA,MAAM,SAAS,EAAE,SAIhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ const transform = (file, api, options) => {
2
+ // These will run in order. If your transform depends on others, place yours after dependent transforms
3
+ const fixes = [];
4
+ return fixes.reduce((source, fix) => fix({ ...file, source }, api, options), file.source);
5
+ };
6
+ export default transform;
@@ -0,0 +1,7 @@
1
+ import { Collection, JSCodeshift } from 'jscodeshift';
2
+ export declare function getImportRenameMap(j: JSCodeshift, root: Collection<any>, mainPackage?: string, packageName?: string): {
3
+ containsCanvasImports: boolean;
4
+ importMap: Record<string, string>;
5
+ styledMap: Record<string, string>;
6
+ };
7
+ //# sourceMappingURL=getImportRenameMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getImportRenameMap.d.ts","sourceRoot":"","sources":["../../../../lib/v16/utils/getImportRenameMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAEpE,wBAAgB,kBAAkB,CAChC,CAAC,EAAE,WAAW,EACd,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,EACrB,WAAW,SAA8B,EACzC,WAAW,SAAK;;;;EAuDjB"}
@@ -0,0 +1,44 @@
1
+ export function getImportRenameMap(j, root, mainPackage = '@workday/canvas-kit-react', packageName = '') {
2
+ let containsCanvasImports = false;
3
+ // build import name remapping - in case someone renamed imports...
4
+ // i.e. `import { IconButton as StyledIconButton } ...`
5
+ const importMap = {};
6
+ const styledMap = {};
7
+ root.find(j.ImportDeclaration, node => {
8
+ // imports our module
9
+ const value = node.source.value;
10
+ if (typeof value === 'string' &&
11
+ (value === mainPackage || value.startsWith(mainPackage) || value === packageName)) {
12
+ containsCanvasImports = true;
13
+ (node.specifiers || []).forEach(specifier => {
14
+ if (specifier.type === 'ImportSpecifier') {
15
+ if (!specifier.local || specifier.local.name === specifier.imported.name) {
16
+ importMap[specifier.imported.name] = specifier.imported.name;
17
+ }
18
+ else {
19
+ importMap[specifier.imported.name] = specifier.local.name;
20
+ }
21
+ }
22
+ });
23
+ }
24
+ return false;
25
+ });
26
+ root
27
+ .find(j.CallExpression, (node) => node.callee.type === 'Identifier' &&
28
+ node.callee.name === 'styled' &&
29
+ node.arguments[0].type === 'Identifier')
30
+ .forEach(nodePath => {
31
+ // const StyledName = styled(OriginalName)({})
32
+ // const StyledName = styled(OriginalName)`` // Tagged template
33
+ if ((nodePath.parent.value.type === 'CallExpression' ||
34
+ nodePath.parent.value.type === 'TaggedTemplateExpression') &&
35
+ nodePath.parent.parent.value.type === 'VariableDeclarator' &&
36
+ nodePath.parent.parent.value.id.type === 'Identifier') {
37
+ const styledName = nodePath.parent.parent.value.id.name;
38
+ if (nodePath.value.arguments[0].type === 'Identifier') {
39
+ styledMap[nodePath.value.arguments[0].name] = styledName;
40
+ }
41
+ }
42
+ });
43
+ return { containsCanvasImports, importMap, styledMap };
44
+ }
package/index.js CHANGED
@@ -138,6 +138,13 @@ const {
138
138
  });
139
139
  }
140
140
  )
141
+ .command('v16 [path]', chalk.gray('Canvas Kit v15 > v16 upgrade transform'), yargs => {
142
+ yargs.positional('path', {
143
+ type: 'string',
144
+ default: '.',
145
+ describe: chalk.gray('The path to execute the transform in (recursively).'),
146
+ });
147
+ })
141
148
  .demandCommand(1, chalk.red.bold('You must provide a transform to apply.'))
142
149
  .strictCommands()
143
150
  .fail((msg, err, yargs) => {
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": "16.0.0-alpha.0396-next.0",
5
+ "version": "16.0.0-alpha.0424-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": "70f2ee99c66df706e5101477f62799d1967358ad"
49
+ "gitHead": "cebd41107b3d9b3a051bfe89c62ee33f9665f0a7"
50
50
  }