@atlaskit/codemod-cli 0.34.1 → 0.34.3

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,19 @@
1
1
  # @atlaskit/codemod-cli
2
2
 
3
+ ## 0.34.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 0.34.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`1aa97b0f3b4a8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1aa97b0f3b4a8) -
14
+ update lozenge-to-tag-migration to include the migration_fallback prop so that teams can adopt the
15
+ Tag API without triggering an immediate visual change.
16
+
3
17
  ## 0.34.1
4
18
 
5
19
  ### Patch 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.34.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
365
+ _process$env$_PACKAGE = "0.34.2", _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) {
@@ -101,6 +101,7 @@ var transformer = function transformer(file, api) {
101
101
  // Process children to extract text
102
102
  var hasVariableChild = false;
103
103
  var variableChildExpression = null;
104
+ var isFormatMessageCall = false;
104
105
  if (element.children && element.children.length > 0) {
105
106
  if (element.children.length === 1) {
106
107
  var child = element.children[0];
@@ -112,7 +113,7 @@ var transformer = function transformer(file, api) {
112
113
  } else if (j.JSXExpressionContainer.check(child) && j.StringLiteral.check(child.expression)) {
113
114
  textContent = child.expression.value;
114
115
  } else if (j.JSXExpressionContainer.check(child)) {
115
- // Check if it's a simple identifier (variable) or member expression
116
+ // Check if it's a simple identifier (variable), member expression, or call expression
116
117
  if (j.Identifier.check(child.expression)) {
117
118
  hasVariableChild = true;
118
119
  variableChildExpression = child.expression;
@@ -120,6 +121,14 @@ var transformer = function transformer(file, api) {
120
121
  // Handle member expressions like obj.prop
121
122
  hasVariableChild = true;
122
123
  variableChildExpression = child.expression;
124
+ } else if (j.CallExpression.check(child.expression)) {
125
+ // Handle call expressions like formatMessage(messages.label)
126
+ hasVariableChild = true;
127
+ variableChildExpression = child.expression;
128
+ // Check if it's a formatMessage call (which always returns a string)
129
+ if (j.Identifier.check(child.expression.callee) && child.expression.callee.name === 'formatMessage') {
130
+ isFormatMessageCall = true;
131
+ }
123
132
  } else {
124
133
  // Complex expression or JSX element
125
134
  hasComplexChildren = true;
@@ -174,7 +183,7 @@ var transformer = function transformer(file, api) {
174
183
  }
175
184
  });
176
185
 
177
- // Assemble attributes in correct order: text, other props, color
186
+ // Assemble attributes in correct order: text, other props, color, migration props
178
187
  if (textContent && !hasComplexChildren && !hasVariableChild) {
179
188
  newAttributes.push(j.jsxAttribute(j.jsxIdentifier('text'), j.stringLiteral(textContent)));
180
189
  } else if (hasVariableChild && variableChildExpression) {
@@ -185,7 +194,7 @@ var transformer = function transformer(file, api) {
185
194
  // Add other attributes
186
195
  newAttributes.push.apply(newAttributes, otherAttributes);
187
196
 
188
- // Add color attribute last (default to 'standard' if no appearance was found)
197
+ // Add color attribute (default to 'standard' if no appearance was found)
189
198
  if (colorAttribute) {
190
199
  newAttributes.push(colorAttribute);
191
200
  } else {
@@ -193,6 +202,10 @@ var transformer = function transformer(file, api) {
193
202
  newAttributes.push(j.jsxAttribute(j.jsxIdentifier('color'), j.stringLiteral('standard')));
194
203
  }
195
204
 
205
+ // Add migration-specific props
206
+ newAttributes.push(j.jsxAttribute(j.jsxIdentifier('isRemovable'), j.jsxExpressionContainer(j.booleanLiteral(false))));
207
+ newAttributes.push(j.jsxAttribute(j.jsxIdentifier('migration_fallback'), j.stringLiteral('lozenge')));
208
+
196
209
  // Create new Tag element
197
210
  var newElement = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier('Tag'), newAttributes, true), null, []);
198
211
 
@@ -201,7 +214,7 @@ var transformer = function transformer(file, api) {
201
214
  if (hasComplexChildren) {
202
215
  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.");
203
216
  }
204
- if (hasVariableChild) {
217
+ if (hasVariableChild && !isFormatMessageCall) {
205
218
  warnings.push('FIXME: This Tag component uses a variable as the text prop. Please verify that the variable contains a string value.');
206
219
  }
207
220
  if (hasMaxWidthProp) {
@@ -92,6 +92,7 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
92
92
  // Process children to extract text
93
93
  let hasVariableChild = false;
94
94
  let variableChildExpression = null;
95
+ let isFormatMessageCall = false;
95
96
  if (element.children && element.children.length > 0) {
96
97
  if (element.children.length === 1) {
97
98
  const child = element.children[0];
@@ -103,7 +104,7 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
103
104
  } else if (j.JSXExpressionContainer.check(child) && j.StringLiteral.check(child.expression)) {
104
105
  textContent = child.expression.value;
105
106
  } else if (j.JSXExpressionContainer.check(child)) {
106
- // Check if it's a simple identifier (variable) or member expression
107
+ // Check if it's a simple identifier (variable), member expression, or call expression
107
108
  if (j.Identifier.check(child.expression)) {
108
109
  hasVariableChild = true;
109
110
  variableChildExpression = child.expression;
@@ -111,6 +112,14 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
111
112
  // Handle member expressions like obj.prop
112
113
  hasVariableChild = true;
113
114
  variableChildExpression = child.expression;
115
+ } else if (j.CallExpression.check(child.expression)) {
116
+ // Handle call expressions like formatMessage(messages.label)
117
+ hasVariableChild = true;
118
+ variableChildExpression = child.expression;
119
+ // Check if it's a formatMessage call (which always returns a string)
120
+ if (j.Identifier.check(child.expression.callee) && child.expression.callee.name === 'formatMessage') {
121
+ isFormatMessageCall = true;
122
+ }
114
123
  } else {
115
124
  // Complex expression or JSX element
116
125
  hasComplexChildren = true;
@@ -165,7 +174,7 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
165
174
  }
166
175
  });
167
176
 
168
- // Assemble attributes in correct order: text, other props, color
177
+ // Assemble attributes in correct order: text, other props, color, migration props
169
178
  if (textContent && !hasComplexChildren && !hasVariableChild) {
170
179
  newAttributes.push(j.jsxAttribute(j.jsxIdentifier('text'), j.stringLiteral(textContent)));
171
180
  } else if (hasVariableChild && variableChildExpression) {
@@ -176,7 +185,7 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
176
185
  // Add other attributes
177
186
  newAttributes.push(...otherAttributes);
178
187
 
179
- // Add color attribute last (default to 'standard' if no appearance was found)
188
+ // Add color attribute (default to 'standard' if no appearance was found)
180
189
  if (colorAttribute) {
181
190
  newAttributes.push(colorAttribute);
182
191
  } else {
@@ -184,6 +193,10 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
184
193
  newAttributes.push(j.jsxAttribute(j.jsxIdentifier('color'), j.stringLiteral('standard')));
185
194
  }
186
195
 
196
+ // Add migration-specific props
197
+ newAttributes.push(j.jsxAttribute(j.jsxIdentifier('isRemovable'), j.jsxExpressionContainer(j.booleanLiteral(false))));
198
+ newAttributes.push(j.jsxAttribute(j.jsxIdentifier('migration_fallback'), j.stringLiteral('lozenge')));
199
+
187
200
  // Create new Tag element
188
201
  const newElement = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier('Tag'), newAttributes, true), null, []);
189
202
 
@@ -192,7 +205,7 @@ If isBold is typically false, consider migrating to <Tag /> from '@atlaskit/tag'
192
205
  if (hasComplexChildren) {
193
206
  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.");
194
207
  }
195
- if (hasVariableChild) {
208
+ if (hasVariableChild && !isFormatMessageCall) {
196
209
  warnings.push('FIXME: This Tag component uses a variable as the text prop. Please verify that the variable contains a string value.');
197
210
  }
198
211
  if (hasMaxWidthProp) {
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.34.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
358
+ _process$env$_PACKAGE = "0.34.2", _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) {
@@ -95,6 +95,7 @@ var transformer = function transformer(file, api) {
95
95
  // Process children to extract text
96
96
  var hasVariableChild = false;
97
97
  var variableChildExpression = null;
98
+ var isFormatMessageCall = false;
98
99
  if (element.children && element.children.length > 0) {
99
100
  if (element.children.length === 1) {
100
101
  var child = element.children[0];
@@ -106,7 +107,7 @@ var transformer = function transformer(file, api) {
106
107
  } else if (j.JSXExpressionContainer.check(child) && j.StringLiteral.check(child.expression)) {
107
108
  textContent = child.expression.value;
108
109
  } else if (j.JSXExpressionContainer.check(child)) {
109
- // Check if it's a simple identifier (variable) or member expression
110
+ // Check if it's a simple identifier (variable), member expression, or call expression
110
111
  if (j.Identifier.check(child.expression)) {
111
112
  hasVariableChild = true;
112
113
  variableChildExpression = child.expression;
@@ -114,6 +115,14 @@ var transformer = function transformer(file, api) {
114
115
  // Handle member expressions like obj.prop
115
116
  hasVariableChild = true;
116
117
  variableChildExpression = child.expression;
118
+ } else if (j.CallExpression.check(child.expression)) {
119
+ // Handle call expressions like formatMessage(messages.label)
120
+ hasVariableChild = true;
121
+ variableChildExpression = child.expression;
122
+ // Check if it's a formatMessage call (which always returns a string)
123
+ if (j.Identifier.check(child.expression.callee) && child.expression.callee.name === 'formatMessage') {
124
+ isFormatMessageCall = true;
125
+ }
117
126
  } else {
118
127
  // Complex expression or JSX element
119
128
  hasComplexChildren = true;
@@ -168,7 +177,7 @@ var transformer = function transformer(file, api) {
168
177
  }
169
178
  });
170
179
 
171
- // Assemble attributes in correct order: text, other props, color
180
+ // Assemble attributes in correct order: text, other props, color, migration props
172
181
  if (textContent && !hasComplexChildren && !hasVariableChild) {
173
182
  newAttributes.push(j.jsxAttribute(j.jsxIdentifier('text'), j.stringLiteral(textContent)));
174
183
  } else if (hasVariableChild && variableChildExpression) {
@@ -179,7 +188,7 @@ var transformer = function transformer(file, api) {
179
188
  // Add other attributes
180
189
  newAttributes.push.apply(newAttributes, otherAttributes);
181
190
 
182
- // Add color attribute last (default to 'standard' if no appearance was found)
191
+ // Add color attribute (default to 'standard' if no appearance was found)
183
192
  if (colorAttribute) {
184
193
  newAttributes.push(colorAttribute);
185
194
  } else {
@@ -187,6 +196,10 @@ var transformer = function transformer(file, api) {
187
196
  newAttributes.push(j.jsxAttribute(j.jsxIdentifier('color'), j.stringLiteral('standard')));
188
197
  }
189
198
 
199
+ // Add migration-specific props
200
+ newAttributes.push(j.jsxAttribute(j.jsxIdentifier('isRemovable'), j.jsxExpressionContainer(j.booleanLiteral(false))));
201
+ newAttributes.push(j.jsxAttribute(j.jsxIdentifier('migration_fallback'), j.stringLiteral('lozenge')));
202
+
190
203
  // Create new Tag element
191
204
  var newElement = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier('Tag'), newAttributes, true), null, []);
192
205
 
@@ -195,7 +208,7 @@ var transformer = function transformer(file, api) {
195
208
  if (hasComplexChildren) {
196
209
  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.");
197
210
  }
198
- if (hasVariableChild) {
211
+ if (hasVariableChild && !isFormatMessageCall) {
199
212
  warnings.push('FIXME: This Tag component uses a variable as the text prop. Please verify that the variable contains a string value.');
200
213
  }
201
214
  if (hasMaxWidthProp) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.34.1",
3
+ "version": "0.34.3",
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,9 +29,9 @@
29
29
  "bin": "./bin/codemod-cli.js",
30
30
  "dependencies": {
31
31
  "@atlaskit/codemod-utils": "^4.2.0",
32
- "@atlaskit/icon": "^29.4.0",
32
+ "@atlaskit/icon": "^30.0.0",
33
33
  "@atlaskit/icon-lab": "^5.14.0",
34
- "@atlaskit/tokens": "^10.0.0",
34
+ "@atlaskit/tokens": "^10.1.0",
35
35
  "@babel/runtime": "^7.0.0",
36
36
  "@codeshift/utils": "^0.2.4",
37
37
  "@hypermod/utils": "^0.4.2",