@workday/canvas-kit-codemod 8.4.8 → 8.4.10

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":"softDeprecateStack.d.ts","sourceRoot":"","sources":["../../../../lib/softDeprecate/Stack/softDeprecateStack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAA+C,OAAO,EAAC,MAAM,aAAa,CAAC;AAOhG,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAyN7E"}
1
+ {"version":3,"file":"softDeprecateStack.d.ts","sourceRoot":"","sources":["../../../../lib/softDeprecate/Stack/softDeprecateStack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAA+C,OAAO,EAAC,MAAM,aAAa,CAAC;AAOhG,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA2N7E"}
@@ -10,13 +10,9 @@ export default function transformer(file, api, options) {
10
10
  root.find(j.ImportDeclaration, function (nodePath) {
11
11
  var value = nodePath.source.value;
12
12
  // If there's an import from the stack package, set the import boolean check to true
13
- if (value === stackPackage) {
14
- hasStackImports = true;
15
- return false;
16
- }
17
13
  // If there's an import from the main package, check to see if Stack or Stackprops are among the named imports
18
14
  // e.g. import {Stack} from '@workday/canvas-kit-react/layout';
19
- if (value === mainPackage) {
15
+ if (value === mainPackage || value === stackPackage) {
20
16
  (nodePath.specifiers || []).forEach(function (specifier) {
21
17
  if ((specifier.type === 'ImportSpecifier' &&
22
18
  stackImportNames.includes(specifier.imported.name)) ||
@@ -128,19 +124,28 @@ export default function transformer(file, api, options) {
128
124
  });
129
125
  // Transform Stack JSXElements
130
126
  // Transform `<Stack spacing="l">` to `<Flex gap="l">`
131
- root
132
- .findJSXElements('Stack')
133
- .find(j.JSXIdentifier, { name: 'spacing' })
134
- .forEach(function (nodePath) {
135
- nodePath.node.name = 'gap';
136
- });
137
- // Transform Stack JSXElements
127
+ // Transform `<VStack spacing="l">` to `<Flex gap="l">`
128
+ // Transform `<HStack spacing="l">` to `<Flex gap="l">`
138
129
  // Transform `<Stack shouldWrapChildren>` to `<Flex >`
139
- root
140
- .findJSXElements('Stack')
141
- .find(j.JSXIdentifier)
142
- .filter(function (path) { return path.node.name === 'shouldWrapChildren'; })
143
- .remove();
130
+ root.find(j.JSXOpeningElement).forEach(function (nodePath) {
131
+ var _a;
132
+ if (nodePath.node.type === 'JSXOpeningElement') {
133
+ if (nodePath.node.name.type === 'JSXIdentifier') {
134
+ if (stackImportNames.includes(nodePath.node.name.name)) {
135
+ (_a = nodePath.node.attributes) === null || _a === void 0 ? void 0 : _a.forEach(function (path) {
136
+ if (path.type === 'JSXAttribute') {
137
+ if (path.name.name === 'spacing') {
138
+ path.name.name = 'gap';
139
+ }
140
+ if (path.name.name === 'shouldWrapChildren') {
141
+ path.name.name = '';
142
+ }
143
+ }
144
+ });
145
+ }
146
+ }
147
+ }
148
+ });
144
149
  // Transform styled compoents
145
150
  // e.g. `const StyledStack = styled(Stack)({});`
146
151
  // becomes `const StyledStack = styled(Flex)({});`
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.4.8",
5
+ "version": "8.4.10",
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": "985ff1a3fe4c497dba33cfd757921abeafb14936"
46
+ "gitHead": "b3482f7d39d0b4b7359961ab1b57063df57edfa6"
47
47
  }