@atlaskit/codemod-cli 0.21.0 → 0.21.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,11 @@
1
1
  # @atlaskit/codemod-cli
2
2
 
3
+ ## 0.21.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#87918](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87918) [`1de8dc826f8d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1de8dc826f8d) - Fixed the duplicated label issue and the missing JSX pragma comment.
8
+
3
9
  ## 0.21.0
4
10
 
5
11
  ### Minor Changes
package/dist/cjs/main.js CHANGED
@@ -305,7 +305,7 @@ function _main() {
305
305
  case 4:
306
306
  _yield$parseArgs = _context5.sent;
307
307
  packages = _yield$parseArgs.packages;
308
- _process$env$_PACKAGE = "0.21.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
308
+ _process$env$_PACKAGE = "0.21.1", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
309
309
  logger.log(_chalk.default.bgBlue(_chalk.default.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
310
310
  if (packages && packages.length > 0) {
311
311
  logger.log(_chalk.default.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
@@ -141,7 +141,12 @@ var transformer = function transformer(file, api) {
141
141
  }
142
142
  }
143
143
  if (specifiers.length) {
144
- oldButtonImport.replaceWith(j.importDeclaration(specifiers, j.stringLiteral(_constants.NEW_BUTTON_ENTRY_POINT)));
144
+ var newButtonImport = j.importDeclaration(specifiers, j.stringLiteral(_constants.NEW_BUTTON_ENTRY_POINT));
145
+ oldButtonImport.forEach(function (path) {
146
+ var _path$node;
147
+ newButtonImport.comments = path !== null && path !== void 0 && (_path$node = path.node) !== null && _path$node !== void 0 && _path$node.comments ? path.node.comments : undefined;
148
+ });
149
+ oldButtonImport.replaceWith(newButtonImport);
145
150
  }
146
151
 
147
152
  // remove empty import declarations
@@ -43,11 +43,16 @@ var moveSizeAndLabelAttributes = exports.moveSizeAndLabelAttributes = function m
43
43
  }
44
44
 
45
45
  // move label and size attributes from icon to the root Button prop
46
- var labelAttribute = iconJSXElementAttributes.find(function (attribute) {
46
+ var buttonAlreadyHasLabelProp = attributes === null || attributes === void 0 ? void 0 : attributes.find(function (attribute) {
47
47
  return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
48
48
  });
49
- if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
50
- attributes === null || attributes === void 0 || attributes.push(labelAttribute);
49
+ if (!buttonAlreadyHasLabelProp) {
50
+ var labelAttribute = iconJSXElementAttributes.find(function (attribute) {
51
+ return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
52
+ });
53
+ if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
54
+ attributes === null || attributes === void 0 || attributes.push(labelAttribute);
55
+ }
51
56
  }
52
57
  var sizeAttribute = iconJSXElementAttributes.find(function (attribute) {
53
58
  var _attribute$value, _attribute$value2;
@@ -113,7 +113,12 @@ const transformer = (file, api) => {
113
113
  }
114
114
  }
115
115
  if (specifiers.length) {
116
- oldButtonImport.replaceWith(j.importDeclaration(specifiers, j.stringLiteral(NEW_BUTTON_ENTRY_POINT)));
116
+ const newButtonImport = j.importDeclaration(specifiers, j.stringLiteral(NEW_BUTTON_ENTRY_POINT));
117
+ oldButtonImport.forEach(path => {
118
+ var _path$node;
119
+ newButtonImport.comments = path !== null && path !== void 0 && (_path$node = path.node) !== null && _path$node !== void 0 && _path$node.comments ? path.node.comments : undefined;
120
+ });
121
+ oldButtonImport.replaceWith(newButtonImport);
117
122
  }
118
123
 
119
124
  // remove empty import declarations
@@ -34,9 +34,12 @@ export const moveSizeAndLabelAttributes = (element, j, iconRenamed = false) => {
34
34
  }
35
35
 
36
36
  // move label and size attributes from icon to the root Button prop
37
- const labelAttribute = iconJSXElementAttributes.find(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === 'label');
38
- if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
39
- attributes === null || attributes === void 0 ? void 0 : attributes.push(labelAttribute);
37
+ const buttonAlreadyHasLabelProp = attributes === null || attributes === void 0 ? void 0 : attributes.find(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === 'label');
38
+ if (!buttonAlreadyHasLabelProp) {
39
+ const labelAttribute = iconJSXElementAttributes.find(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === 'label');
40
+ if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
41
+ attributes === null || attributes === void 0 ? void 0 : attributes.push(labelAttribute);
42
+ }
40
43
  }
41
44
  const sizeAttribute = iconJSXElementAttributes.find(attribute => {
42
45
  var _attribute$value, _attribute$value2;
package/dist/esm/main.js CHANGED
@@ -298,7 +298,7 @@ function _main() {
298
298
  case 4:
299
299
  _yield$parseArgs = _context5.sent;
300
300
  packages = _yield$parseArgs.packages;
301
- _process$env$_PACKAGE = "0.21.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
301
+ _process$env$_PACKAGE = "0.21.1", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
302
302
  logger.log(chalk.bgBlue(chalk.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
303
303
  if (packages && packages.length > 0) {
304
304
  logger.log(chalk.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
@@ -135,7 +135,12 @@ var transformer = function transformer(file, api) {
135
135
  }
136
136
  }
137
137
  if (specifiers.length) {
138
- oldButtonImport.replaceWith(j.importDeclaration(specifiers, j.stringLiteral(NEW_BUTTON_ENTRY_POINT)));
138
+ var newButtonImport = j.importDeclaration(specifiers, j.stringLiteral(NEW_BUTTON_ENTRY_POINT));
139
+ oldButtonImport.forEach(function (path) {
140
+ var _path$node;
141
+ newButtonImport.comments = path !== null && path !== void 0 && (_path$node = path.node) !== null && _path$node !== void 0 && _path$node.comments ? path.node.comments : undefined;
142
+ });
143
+ oldButtonImport.replaceWith(newButtonImport);
139
144
  }
140
145
 
141
146
  // remove empty import declarations
@@ -37,11 +37,16 @@ export var moveSizeAndLabelAttributes = function moveSizeAndLabelAttributes(elem
37
37
  }
38
38
 
39
39
  // move label and size attributes from icon to the root Button prop
40
- var labelAttribute = iconJSXElementAttributes.find(function (attribute) {
40
+ var buttonAlreadyHasLabelProp = attributes === null || attributes === void 0 ? void 0 : attributes.find(function (attribute) {
41
41
  return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
42
42
  });
43
- if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
44
- attributes === null || attributes === void 0 || attributes.push(labelAttribute);
43
+ if (!buttonAlreadyHasLabelProp) {
44
+ var labelAttribute = iconJSXElementAttributes.find(function (attribute) {
45
+ return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
46
+ });
47
+ if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
48
+ attributes === null || attributes === void 0 || attributes.push(labelAttribute);
49
+ }
45
50
  }
46
51
  var sizeAttribute = iconJSXElementAttributes.find(function (attribute) {
47
52
  var _attribute$value, _attribute$value2;
@@ -1,3 +1,3 @@
1
- import type { API, FileInfo } from 'jscodeshift';
1
+ import { API, FileInfo } from 'jscodeshift';
2
2
  declare const transformer: (file: FileInfo, api: API) => string;
3
3
  export default transformer;
@@ -1,3 +1,3 @@
1
- import type { API, FileInfo } from 'jscodeshift';
1
+ import { API, FileInfo } from 'jscodeshift';
2
2
  declare const transformer: (file: FileInfo, api: API) => string;
3
3
  export default transformer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.21.0",
3
+ "version": "0.21.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/"
@@ -40,7 +40,7 @@
40
40
  "bin": "./bin/codemod-cli.js",
41
41
  "dependencies": {
42
42
  "@atlaskit/codemod-utils": "^4.2.0",
43
- "@atlaskit/tokens": "^1.42.0",
43
+ "@atlaskit/tokens": "^1.43.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@codeshift/utils": "^0.2.4",
46
46
  "@hypermod/utils": "^0.4.2",