@atlaskit/codemod-cli 0.32.0 → 0.32.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/codemod-cli
2
2
 
3
+ ## 0.32.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b866a7f72dab4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b866a7f72dab4) -
8
+ Updated lozenge-to-tag-migration codemod to handle variable lozenge children
9
+
3
10
  ## 0.32.0
4
11
 
5
12
  ### Minor Changes
package/dist/cjs/main.js CHANGED
@@ -362,7 +362,7 @@ function _main() {
362
362
  case 4:
363
363
  _yield$parseArgs = _context6.sent;
364
364
  packages = _yield$parseArgs.packages;
365
- _process$env$_PACKAGE = "0.31.2", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
365
+ _process$env$_PACKAGE = "0.0.0-development", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
366
366
  logger.log(_chalk.default.bgBlue(_chalk.default.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
367
367
  if (packages && packages.length > 0) {
368
368
  logger.log(_chalk.default.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
@@ -99,6 +99,8 @@ var transformer = function transformer(file, api) {
99
99
  var unknownAppearanceValue = '';
100
100
 
101
101
  // Process children to extract text
102
+ var hasVariableChild = false;
103
+ var variableChildExpression = null;
102
104
  if (element.children && element.children.length > 0) {
103
105
  if (element.children.length === 1) {
104
106
  var child = element.children[0];
@@ -109,7 +111,21 @@ var transformer = function transformer(file, api) {
109
111
  }
110
112
  } else if (j.JSXExpressionContainer.check(child) && j.StringLiteral.check(child.expression)) {
111
113
  textContent = child.expression.value;
114
+ } else if (j.JSXExpressionContainer.check(child)) {
115
+ // Check if it's a simple identifier (variable) or member expression
116
+ if (j.Identifier.check(child.expression)) {
117
+ hasVariableChild = true;
118
+ variableChildExpression = child.expression;
119
+ } else if (j.MemberExpression.check(child.expression)) {
120
+ // Handle member expressions like obj.prop
121
+ hasVariableChild = true;
122
+ variableChildExpression = child.expression;
123
+ } else {
124
+ // Complex expression or JSX element
125
+ hasComplexChildren = true;
126
+ }
112
127
  } else {
128
+ // JSX elements or other complex children
113
129
  hasComplexChildren = true;
114
130
  }
115
131
  } else {
@@ -159,8 +175,11 @@ var transformer = function transformer(file, api) {
159
175
  });
160
176
 
161
177
  // Assemble attributes in correct order: text, other props, color
162
- if (textContent && !hasComplexChildren) {
178
+ if (textContent && !hasComplexChildren && !hasVariableChild) {
163
179
  newAttributes.push(j.jsxAttribute(j.jsxIdentifier('text'), j.stringLiteral(textContent)));
180
+ } else if (hasVariableChild && variableChildExpression) {
181
+ // Use the variable expression as the text prop
182
+ newAttributes.push(j.jsxAttribute(j.jsxIdentifier('text'), j.jsxExpressionContainer(variableChildExpression)));
164
183
  }
165
184
 
166
185
  // Add other attributes
@@ -182,6 +201,9 @@ var transformer = function transformer(file, api) {
182
201
  if (hasComplexChildren) {
183
202
  warnings.push("FIXME: This Tag component has complex children that couldn't be automatically migrated to the text prop.\nTag component only supports simple text via the text prop. Please manually convert the children content.");
184
203
  }
204
+ if (hasVariableChild) {
205
+ warnings.push('FIXME: This Tag component uses a variable as the text prop. Please verify that the variable contains a string value.');
206
+ }
185
207
  if (hasMaxWidthProp) {
186
208
  warnings.push('FIXME: maxWidth prop was removed during migration from Lozenge to Tag.\nTag component does not support maxWidth. Please review if width constraints are needed.');
187
209
  }
@@ -90,6 +90,8 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
90
90
  let unknownAppearanceValue = '';
91
91
 
92
92
  // Process children to extract text
93
+ let hasVariableChild = false;
94
+ let variableChildExpression = null;
93
95
  if (element.children && element.children.length > 0) {
94
96
  if (element.children.length === 1) {
95
97
  const child = element.children[0];
@@ -100,7 +102,21 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
100
102
  }
101
103
  } else if (j.JSXExpressionContainer.check(child) && j.StringLiteral.check(child.expression)) {
102
104
  textContent = child.expression.value;
105
+ } else if (j.JSXExpressionContainer.check(child)) {
106
+ // Check if it's a simple identifier (variable) or member expression
107
+ if (j.Identifier.check(child.expression)) {
108
+ hasVariableChild = true;
109
+ variableChildExpression = child.expression;
110
+ } else if (j.MemberExpression.check(child.expression)) {
111
+ // Handle member expressions like obj.prop
112
+ hasVariableChild = true;
113
+ variableChildExpression = child.expression;
114
+ } else {
115
+ // Complex expression or JSX element
116
+ hasComplexChildren = true;
117
+ }
103
118
  } else {
119
+ // JSX elements or other complex children
104
120
  hasComplexChildren = true;
105
121
  }
106
122
  } else {
@@ -150,8 +166,11 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
150
166
  });
151
167
 
152
168
  // Assemble attributes in correct order: text, other props, color
153
- if (textContent && !hasComplexChildren) {
169
+ if (textContent && !hasComplexChildren && !hasVariableChild) {
154
170
  newAttributes.push(j.jsxAttribute(j.jsxIdentifier('text'), j.stringLiteral(textContent)));
171
+ } else if (hasVariableChild && variableChildExpression) {
172
+ // Use the variable expression as the text prop
173
+ newAttributes.push(j.jsxAttribute(j.jsxIdentifier('text'), j.jsxExpressionContainer(variableChildExpression)));
155
174
  }
156
175
 
157
176
  // Add other attributes
@@ -173,6 +192,9 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
173
192
  if (hasComplexChildren) {
174
193
  warnings.push("FIXME: This Tag component has complex children that couldn't be automatically migrated to the text prop.\nTag component only supports simple text via the text prop. Please manually convert the children content.");
175
194
  }
195
+ if (hasVariableChild) {
196
+ warnings.push('FIXME: This Tag component uses a variable as the text prop. Please verify that the variable contains a string value.');
197
+ }
176
198
  if (hasMaxWidthProp) {
177
199
  warnings.push('FIXME: maxWidth prop was removed during migration from Lozenge to Tag.\nTag component does not support maxWidth. Please review if width constraints are needed.');
178
200
  }
package/dist/esm/main.js CHANGED
@@ -355,7 +355,7 @@ function _main() {
355
355
  case 4:
356
356
  _yield$parseArgs = _context6.sent;
357
357
  packages = _yield$parseArgs.packages;
358
- _process$env$_PACKAGE = "0.31.2", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
358
+ _process$env$_PACKAGE = "0.0.0-development", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
359
359
  logger.log(chalk.bgBlue(chalk.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
360
360
  if (packages && packages.length > 0) {
361
361
  logger.log(chalk.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
@@ -93,6 +93,8 @@ var transformer = function transformer(file, api) {
93
93
  var unknownAppearanceValue = '';
94
94
 
95
95
  // Process children to extract text
96
+ var hasVariableChild = false;
97
+ var variableChildExpression = null;
96
98
  if (element.children && element.children.length > 0) {
97
99
  if (element.children.length === 1) {
98
100
  var child = element.children[0];
@@ -103,7 +105,21 @@ var transformer = function transformer(file, api) {
103
105
  }
104
106
  } else if (j.JSXExpressionContainer.check(child) && j.StringLiteral.check(child.expression)) {
105
107
  textContent = child.expression.value;
108
+ } else if (j.JSXExpressionContainer.check(child)) {
109
+ // Check if it's a simple identifier (variable) or member expression
110
+ if (j.Identifier.check(child.expression)) {
111
+ hasVariableChild = true;
112
+ variableChildExpression = child.expression;
113
+ } else if (j.MemberExpression.check(child.expression)) {
114
+ // Handle member expressions like obj.prop
115
+ hasVariableChild = true;
116
+ variableChildExpression = child.expression;
117
+ } else {
118
+ // Complex expression or JSX element
119
+ hasComplexChildren = true;
120
+ }
106
121
  } else {
122
+ // JSX elements or other complex children
107
123
  hasComplexChildren = true;
108
124
  }
109
125
  } else {
@@ -153,8 +169,11 @@ var transformer = function transformer(file, api) {
153
169
  });
154
170
 
155
171
  // Assemble attributes in correct order: text, other props, color
156
- if (textContent && !hasComplexChildren) {
172
+ if (textContent && !hasComplexChildren && !hasVariableChild) {
157
173
  newAttributes.push(j.jsxAttribute(j.jsxIdentifier('text'), j.stringLiteral(textContent)));
174
+ } else if (hasVariableChild && variableChildExpression) {
175
+ // Use the variable expression as the text prop
176
+ newAttributes.push(j.jsxAttribute(j.jsxIdentifier('text'), j.jsxExpressionContainer(variableChildExpression)));
158
177
  }
159
178
 
160
179
  // Add other attributes
@@ -176,6 +195,9 @@ var transformer = function transformer(file, api) {
176
195
  if (hasComplexChildren) {
177
196
  warnings.push("FIXME: This Tag component has complex children that couldn't be automatically migrated to the text prop.\nTag component only supports simple text via the text prop. Please manually convert the children content.");
178
197
  }
198
+ if (hasVariableChild) {
199
+ warnings.push('FIXME: This Tag component uses a variable as the text prop. Please verify that the variable contains a string value.');
200
+ }
179
201
  if (hasMaxWidthProp) {
180
202
  warnings.push('FIXME: maxWidth prop was removed during migration from Lozenge to Tag.\nTag component does not support maxWidth. Please review if width constraints are needed.');
181
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.32.0",
3
+ "version": "0.32.1",
4
4
  "description": "A cli for distributing codemods for atlassian-frontend components and services",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  "bin": "./bin/codemod-cli.js",
30
30
  "dependencies": {
31
31
  "@atlaskit/codemod-utils": "^4.2.0",
32
- "@atlaskit/tokens": "^8.0.0",
32
+ "@atlaskit/tokens": "^8.4.0",
33
33
  "@babel/runtime": "^7.0.0",
34
34
  "@codeshift/utils": "^0.2.4",
35
35
  "@hypermod/utils": "^0.4.2",