@atlaskit/codemod-cli 0.20.0 → 0.20.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.
Files changed (25) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/cli/package.json +1 -1
  3. package/dist/cjs/main.js +1 -1
  4. package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +12 -0
  5. package/dist/cjs/presets/migrate-to-new-buttons/utils/import-types-from-new-entry-point.js +0 -1
  6. package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/update-safe-imports.js +0 -1
  7. package/dist/cjs/types.js +1 -1
  8. package/dist/es2019/main.js +0 -1
  9. package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +8 -0
  10. package/dist/es2019/presets/migrate-to-new-buttons/utils/import-types-from-new-entry-point.js +0 -1
  11. package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/update-safe-imports.js +0 -1
  12. package/dist/esm/main.js +1 -1
  13. package/dist/esm/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +12 -0
  14. package/dist/esm/presets/migrate-to-new-buttons/utils/import-types-from-new-entry-point.js +0 -1
  15. package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/update-safe-imports.js +0 -1
  16. package/dist/esm/types.js +1 -1
  17. package/dist/types/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +1 -1
  18. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +1 -1
  19. package/filepath/package.json +1 -1
  20. package/main/package.json +1 -1
  21. package/package.json +4 -4
  22. package/sinceRef/package.json +1 -1
  23. package/transforms/package.json +1 -1
  24. package/types/package.json +1 -1
  25. package/utils/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/codemod-cli
2
2
 
3
+ ## 0.20.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#83116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83116) [`8d4e99057fe0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d4e99057fe0) - Upgrade Typescript from `4.9.5` to `5.4.2`
8
+
3
9
  ## 0.20.0
4
10
 
5
11
  ### Minor Changes
package/cli/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module:es2019": "../dist/es2019/cli.js",
6
6
  "types": "../dist/types/cli.d.ts",
7
7
  "typesVersions": {
8
- ">=4.5 <4.9": {
8
+ ">=4.5 <5.4": {
9
9
  "*": [
10
10
  "../dist/types-ts4.5/cli.d.ts"
11
11
  ]
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.20.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
308
+ _process$env$_PACKAGE = "0.20.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) {
@@ -74,6 +74,18 @@ var generateNewElement = exports.generateNewElement = function generateNewElemen
74
74
 
75
75
  // rename iconBefore/iconAfter to icon
76
76
  iconAttrs[0].name.name = 'icon';
77
+ var ariaLabelAttr = j(element.openingElement).find(j.JSXAttribute).filter(function (attribute) {
78
+ return attribute.node.name.name === 'aria-label';
79
+ });
80
+ if (ariaLabelAttr.length) {
81
+ var hasNoLabelProp = !(attributes !== null && attributes !== void 0 && attributes.find(function (attribute) {
82
+ return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
83
+ }));
84
+ if (hasNoLabelProp && attributes) {
85
+ attributes.push(j.jsxAttribute(j.jsxIdentifier('label'), ariaLabelAttr.get().node.value));
86
+ }
87
+ ariaLabelAttr.remove();
88
+ }
77
89
  }
78
90
  return j.jsxElement(
79
91
  // self closing if it's an icon button or icon link button
@@ -37,6 +37,5 @@ var importTypesFromNewEntryPoint = exports.importTypesFromNewEntryPoint = functi
37
37
  j(specifier).remove(); // remove old one
38
38
  });
39
39
  }
40
-
41
40
  return specifiers;
42
41
  };
@@ -25,7 +25,6 @@ var importMap = {
25
25
  // '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer':
26
26
  // '@atlaskit/pragmatic-drag-and-drop/element/offset-from-pointer',
27
27
  };
28
-
29
28
  function updateSafeImports(file, api) {
30
29
  var j = api.jscodeshift;
31
30
  var root = j(file.source);
package/dist/cjs/types.js CHANGED
@@ -12,7 +12,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
12
12
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
13
13
  var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
14
14
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
15
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
15
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
16
16
  /** Converts required args to optional if they have a default
17
17
  * Example: export type UserFlags = Default<Flags, keyof typeof defaultFlags>;
18
18
  */
@@ -60,7 +60,6 @@ const resolveTransform = async (flags, transforms) => {
60
60
  return transform; // Return only if transform found.
61
61
  }
62
62
  }
63
-
64
63
  if (flags.transform && hasTransform(flags.transform)) {
65
64
  return parseTransformPath(flags.transform);
66
65
  }
@@ -65,6 +65,14 @@ export const generateNewElement = (variant, element, j) => {
65
65
 
66
66
  // rename iconBefore/iconAfter to icon
67
67
  iconAttrs[0].name.name = 'icon';
68
+ const ariaLabelAttr = j(element.openingElement).find(j.JSXAttribute).filter(attribute => attribute.node.name.name === 'aria-label');
69
+ if (ariaLabelAttr.length) {
70
+ const hasNoLabelProp = !(attributes !== null && attributes !== void 0 && attributes.find(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === 'label'));
71
+ if (hasNoLabelProp && attributes) {
72
+ attributes.push(j.jsxAttribute(j.jsxIdentifier('label'), ariaLabelAttr.get().node.value));
73
+ }
74
+ ariaLabelAttr.remove();
75
+ }
68
76
  }
69
77
  return j.jsxElement(
70
78
  // self closing if it's an icon button or icon link button
@@ -25,6 +25,5 @@ export const importTypesFromNewEntryPoint = (buttonImports, specifiers, j, fileS
25
25
  j(specifier).remove(); // remove old one
26
26
  });
27
27
  }
28
-
29
28
  return specifiers;
30
29
  };
@@ -19,7 +19,6 @@ const importMap = {
19
19
  // '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer':
20
20
  // '@atlaskit/pragmatic-drag-and-drop/element/offset-from-pointer',
21
21
  };
22
-
23
22
  export function updateSafeImports(file, api) {
24
23
  const j = api.jscodeshift;
25
24
  const root = j(file.source);
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.20.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
301
+ _process$env$_PACKAGE = "0.20.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) {
@@ -68,6 +68,18 @@ export var generateNewElement = function generateNewElement(variant, element, j)
68
68
 
69
69
  // rename iconBefore/iconAfter to icon
70
70
  iconAttrs[0].name.name = 'icon';
71
+ var ariaLabelAttr = j(element.openingElement).find(j.JSXAttribute).filter(function (attribute) {
72
+ return attribute.node.name.name === 'aria-label';
73
+ });
74
+ if (ariaLabelAttr.length) {
75
+ var hasNoLabelProp = !(attributes !== null && attributes !== void 0 && attributes.find(function (attribute) {
76
+ return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
77
+ }));
78
+ if (hasNoLabelProp && attributes) {
79
+ attributes.push(j.jsxAttribute(j.jsxIdentifier('label'), ariaLabelAttr.get().node.value));
80
+ }
81
+ ariaLabelAttr.remove();
82
+ }
71
83
  }
72
84
  return j.jsxElement(
73
85
  // self closing if it's an icon button or icon link button
@@ -31,6 +31,5 @@ export var importTypesFromNewEntryPoint = function importTypesFromNewEntryPoint(
31
31
  j(specifier).remove(); // remove old one
32
32
  });
33
33
  }
34
-
35
34
  return specifiers;
36
35
  };
@@ -19,7 +19,6 @@ var importMap = {
19
19
  // '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer':
20
20
  // '@atlaskit/pragmatic-drag-and-drop/element/offset-from-pointer',
21
21
  };
22
-
23
22
  export function updateSafeImports(file, api) {
24
23
  var j = api.jscodeshift;
25
24
  var root = j(file.source);
package/dist/esm/types.js CHANGED
@@ -5,7 +5,7 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
6
  import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
7
7
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
8
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
9
  /** Converts required args to optional if they have a default
10
10
  * Example: export type UserFlags = Default<Flags, keyof typeof defaultFlags>;
11
11
  */
@@ -1,4 +1,4 @@
1
- import type { API, JSXElement, JSXAttribute, JSXSpreadAttribute } from 'jscodeshift';
1
+ import { API, JSXElement, JSXAttribute, JSXSpreadAttribute } from 'jscodeshift';
2
2
  import { NEW_BUTTON_VARIANTS } from '../utils/constants';
3
3
  export declare const getIconAttributes: (attributes: (JSXAttribute | JSXSpreadAttribute)[]) => JSXAttribute[] | null;
4
4
  export declare const getIconElement: (iconAttr: JSXAttribute) => JSXElement | null;
@@ -1,4 +1,4 @@
1
- import type { API, JSXElement, JSXAttribute, JSXSpreadAttribute } from 'jscodeshift';
1
+ import { API, JSXElement, JSXAttribute, JSXSpreadAttribute } from 'jscodeshift';
2
2
  import { NEW_BUTTON_VARIANTS } from '../utils/constants';
3
3
  export declare const getIconAttributes: (attributes: (JSXAttribute | JSXSpreadAttribute)[]) => JSXAttribute[] | null;
4
4
  export declare const getIconElement: (iconAttr: JSXAttribute) => JSXElement | null;
@@ -5,7 +5,7 @@
5
5
  "module:es2019": "../dist/es2019/filepath.js",
6
6
  "types": "../dist/types/filepath.d.ts",
7
7
  "typesVersions": {
8
- ">=4.5 <4.9": {
8
+ ">=4.5 <5.4": {
9
9
  "*": [
10
10
  "../dist/types-ts4.5/filepath.d.ts"
11
11
  ]
package/main/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module:es2019": "../dist/es2019/main.js",
6
6
  "types": "../dist/types/main.d.ts",
7
7
  "typesVersions": {
8
- ">=4.5 <4.9": {
8
+ ">=4.5 <5.4": {
9
9
  "*": [
10
10
  "../dist/types-ts4.5/main.d.ts"
11
11
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.20.0",
3
+ "version": "0.20.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.38.0",
43
+ "@atlaskit/tokens": "^1.42.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@codeshift/utils": "^0.2.4",
46
46
  "@types/jscodeshift": "^0.11.0",
@@ -57,8 +57,8 @@
57
57
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
58
58
  "prettier": "^2.8.0",
59
59
  "ts-node": "^10.9.1",
60
- "typescript": "~4.9.5"
60
+ "typescript": "~5.4.2"
61
61
  },
62
62
  "homepage": "https://atlaskit.atlassian.com/packages/monorepo-tooling/codemod-cli",
63
63
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
64
- }
64
+ }
@@ -5,7 +5,7 @@
5
5
  "module:es2019": "../dist/es2019/sinceRef.js",
6
6
  "types": "../dist/types/sinceRef.d.ts",
7
7
  "typesVersions": {
8
- ">=4.5 <4.9": {
8
+ ">=4.5 <5.4": {
9
9
  "*": [
10
10
  "../dist/types-ts4.5/sinceRef.d.ts"
11
11
  ]
@@ -5,7 +5,7 @@
5
5
  "module:es2019": "../dist/es2019/transforms.js",
6
6
  "types": "../dist/types/transforms.d.ts",
7
7
  "typesVersions": {
8
- ">=4.5 <4.9": {
8
+ ">=4.5 <5.4": {
9
9
  "*": [
10
10
  "../dist/types-ts4.5/transforms.d.ts"
11
11
  ]
@@ -5,7 +5,7 @@
5
5
  "module:es2019": "../dist/es2019/types.js",
6
6
  "types": "../dist/types/types.d.ts",
7
7
  "typesVersions": {
8
- ">=4.5 <4.9": {
8
+ ">=4.5 <5.4": {
9
9
  "*": [
10
10
  "../dist/types-ts4.5/types.d.ts"
11
11
  ]
@@ -5,7 +5,7 @@
5
5
  "module:es2019": "../dist/es2019/utils.js",
6
6
  "types": "../dist/types/utils.d.ts",
7
7
  "typesVersions": {
8
- ">=4.5 <4.9": {
8
+ ">=4.5 <5.4": {
9
9
  "*": [
10
10
  "../dist/types-ts4.5/utils.d.ts"
11
11
  ]