@atlaskit/codemod-cli 0.23.0 → 0.23.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,13 @@
1
1
  # @atlaskit/codemod-cli
2
2
 
3
+ ## 0.23.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#98241](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98241)
8
+ [`41fe923d46ae`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/41fe923d46ae) -
9
+ Fix duplicated button imports when migrating LoadingButtons in test files.
10
+
3
11
  ## 0.23.0
4
12
 
5
13
  ### 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.23.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
308
+ _process$env$_PACKAGE = "0.23.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) {
@@ -110,9 +110,18 @@ var transformer = function transformer(file, api) {
110
110
 
111
111
  // Loading buttons map back to default imports
112
112
  if (specifierIdentifier === loadingButtonImportName) {
113
+ fileSource
114
+ // rename LoadingButton to Button in all call expressions i.e. render(LoadingButton), find(LoadingButton)
115
+ .find(j.CallExpression).find(j.Identifier).forEach(function (path) {
116
+ if (path.node.name === loadingButtonImportName) {
117
+ path.node.name = _constants.NEW_BUTTON_VARIANTS.default;
118
+ }
119
+ });
113
120
  specifiers.push(j.importDefaultSpecifier(j.identifier(_constants.NEW_BUTTON_VARIANTS.default)));
114
121
  }
115
- if (remainingDefaultButtons) {
122
+ if (!specifiers.find(function (specifier) {
123
+ return specifier.type === 'ImportDefaultSpecifier';
124
+ }) && remainingDefaultButtons) {
116
125
  specifiers.push(j.importDefaultSpecifier(j.identifier(_constants.NEW_BUTTON_VARIANTS.default)));
117
126
  }
118
127
 
@@ -88,9 +88,16 @@ const transformer = (file, api) => {
88
88
 
89
89
  // Loading buttons map back to default imports
90
90
  if (specifierIdentifier === loadingButtonImportName) {
91
+ fileSource
92
+ // rename LoadingButton to Button in all call expressions i.e. render(LoadingButton), find(LoadingButton)
93
+ .find(j.CallExpression).find(j.Identifier).forEach(path => {
94
+ if (path.node.name === loadingButtonImportName) {
95
+ path.node.name = NEW_BUTTON_VARIANTS.default;
96
+ }
97
+ });
91
98
  specifiers.push(j.importDefaultSpecifier(j.identifier(NEW_BUTTON_VARIANTS.default)));
92
99
  }
93
- if (remainingDefaultButtons) {
100
+ if (!specifiers.find(specifier => specifier.type === 'ImportDefaultSpecifier') && remainingDefaultButtons) {
94
101
  specifiers.push(j.importDefaultSpecifier(j.identifier(NEW_BUTTON_VARIANTS.default)));
95
102
  }
96
103
 
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.23.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
301
+ _process$env$_PACKAGE = "0.23.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) {
@@ -104,9 +104,18 @@ var transformer = function transformer(file, api) {
104
104
 
105
105
  // Loading buttons map back to default imports
106
106
  if (specifierIdentifier === loadingButtonImportName) {
107
+ fileSource
108
+ // rename LoadingButton to Button in all call expressions i.e. render(LoadingButton), find(LoadingButton)
109
+ .find(j.CallExpression).find(j.Identifier).forEach(function (path) {
110
+ if (path.node.name === loadingButtonImportName) {
111
+ path.node.name = NEW_BUTTON_VARIANTS.default;
112
+ }
113
+ });
107
114
  specifiers.push(j.importDefaultSpecifier(j.identifier(NEW_BUTTON_VARIANTS.default)));
108
115
  }
109
- if (remainingDefaultButtons) {
116
+ if (!specifiers.find(function (specifier) {
117
+ return specifier.type === 'ImportDefaultSpecifier';
118
+ }) && remainingDefaultButtons) {
110
119
  specifiers.push(j.importDefaultSpecifier(j.identifier(NEW_BUTTON_VARIANTS.default)));
111
120
  }
112
121
 
@@ -1,3 +1,3 @@
1
- import { API, FileInfo } from 'jscodeshift';
1
+ import { type API, type FileInfo } from 'jscodeshift';
2
2
  declare const transformer: (file: FileInfo, api: API) => string;
3
3
  export default transformer;
@@ -1,3 +1,3 @@
1
- import { API, FileInfo } from 'jscodeshift';
1
+ import { type API, type 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.23.0",
3
+ "version": "0.23.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/"