@atlaskit/codemod-cli 0.32.0 → 0.32.2
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 +15 -0
- package/dist/cjs/main.js +2 -2
- package/dist/cjs/presets/lozenge-to-tag-migration/codemods/lozenge-to-tag-migration.js +23 -1
- package/dist/cjs/presets/remove-token-fallbacks/utils/token-processor.js +1 -1
- package/dist/es2019/main.js +1 -1
- package/dist/es2019/presets/lozenge-to-tag-migration/codemods/lozenge-to-tag-migration.js +23 -1
- package/dist/es2019/presets/remove-token-fallbacks/utils/token-processor.js +1 -1
- package/dist/es2019/sinceRef.js +1 -1
- package/dist/esm/main.js +2 -2
- package/dist/esm/presets/lozenge-to-tag-migration/codemods/lozenge-to-tag-migration.js +23 -1
- package/dist/esm/presets/remove-token-fallbacks/utils/token-processor.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/codemod-cli
|
|
2
2
|
|
|
3
|
+
## 0.32.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a60a82196851a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a60a82196851a) -
|
|
8
|
+
Internal refactors to remove unused variables. No functional or public changes.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 0.32.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`b866a7f72dab4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b866a7f72dab4) -
|
|
16
|
+
Updated lozenge-to-tag-migration codemod to handle variable lozenge children
|
|
17
|
+
|
|
3
18
|
## 0.32.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/dist/cjs/main.js
CHANGED
|
@@ -186,7 +186,7 @@ var runTransform = /*#__PURE__*/function () {
|
|
|
186
186
|
_fs.default.writeFileSync(jscodeshift, jscodeshiftContentNew);
|
|
187
187
|
try {
|
|
188
188
|
transformModule = require(transformPath);
|
|
189
|
-
} catch (
|
|
189
|
+
} catch (_unused) {
|
|
190
190
|
// eslint-disable-next-line no-console
|
|
191
191
|
console.warn("Error loading transform module: ".concat(transformPath, ". Skipping lifecycle hooks."));
|
|
192
192
|
}
|
|
@@ -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.
|
|
365
|
+
_process$env$_PACKAGE = "0.32.1", _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
|
}
|
|
@@ -601,7 +601,7 @@ var TokenProcessor = exports.TokenProcessor = /*#__PURE__*/function () {
|
|
|
601
601
|
});
|
|
602
602
|
this.logVerbose("Resolved module path: ".concat(_chalk.default.green(resolvedPath), " for ").concat(_chalk.default.cyan(moduleName)));
|
|
603
603
|
return resolvedPath;
|
|
604
|
-
} catch (
|
|
604
|
+
} catch (_unused) {
|
|
605
605
|
return null;
|
|
606
606
|
}
|
|
607
607
|
}
|
package/dist/es2019/main.js
CHANGED
|
@@ -115,7 +115,7 @@ const runTransform = async (filePaths, transform, flags) => {
|
|
|
115
115
|
let transformModule;
|
|
116
116
|
try {
|
|
117
117
|
transformModule = require(transformPath);
|
|
118
|
-
} catch
|
|
118
|
+
} catch {
|
|
119
119
|
// eslint-disable-next-line no-console
|
|
120
120
|
console.warn(`Error loading transform module: ${transformPath}. Skipping lifecycle hooks.`);
|
|
121
121
|
}
|
|
@@ -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/es2019/sinceRef.js
CHANGED
|
@@ -23,7 +23,7 @@ export const getPackagesSinceRef = async ref => {
|
|
|
23
23
|
let commit;
|
|
24
24
|
try {
|
|
25
25
|
commit = await git.revparse(['--verify', ref]);
|
|
26
|
-
} catch
|
|
26
|
+
} catch {
|
|
27
27
|
throw new ValidationError(`Invalid git ref "${ref}"`);
|
|
28
28
|
}
|
|
29
29
|
const diff = await git.diff([commit, '--', 'package.json']);
|
package/dist/esm/main.js
CHANGED
|
@@ -179,7 +179,7 @@ var runTransform = /*#__PURE__*/function () {
|
|
|
179
179
|
fs.writeFileSync(jscodeshift, jscodeshiftContentNew);
|
|
180
180
|
try {
|
|
181
181
|
transformModule = require(transformPath);
|
|
182
|
-
} catch (
|
|
182
|
+
} catch (_unused) {
|
|
183
183
|
// eslint-disable-next-line no-console
|
|
184
184
|
console.warn("Error loading transform module: ".concat(transformPath, ". Skipping lifecycle hooks."));
|
|
185
185
|
}
|
|
@@ -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.
|
|
358
|
+
_process$env$_PACKAGE = "0.32.1", _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
|
}
|
|
@@ -594,7 +594,7 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
594
594
|
});
|
|
595
595
|
this.logVerbose("Resolved module path: ".concat(chalk.green(resolvedPath), " for ").concat(chalk.cyan(moduleName)));
|
|
596
596
|
return resolvedPath;
|
|
597
|
-
} catch (
|
|
597
|
+
} catch (_unused) {
|
|
598
598
|
return null;
|
|
599
599
|
}
|
|
600
600
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/codemod-cli",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.2",
|
|
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.
|
|
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",
|