@atlaskit/codemod-cli 0.17.1 → 0.17.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 +6 -0
- package/dist/cjs/main.js +1 -1
- package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +8 -7
- package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +8 -8
- package/dist/esm/main.js +1 -1
- package/dist/esm/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +8 -7
- package/dist/types/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +1 -1
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +1 -1
- package/package.json +1 -1
- package/tmp/api-report-tmp.d.ts +0 -66
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/codemod-cli
|
|
2
2
|
|
|
3
|
+
## 0.17.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#56711](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/56711) [`a48d9247ddb2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a48d9247ddb2) - Small changes in button migration codemod - renamed UNSAFE_size to UNSAFE_iconBefore/iconAfter_size for new link and default buttons
|
|
8
|
+
|
|
3
9
|
## 0.17.1
|
|
4
10
|
|
|
5
11
|
### Patch 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.17.
|
|
308
|
+
_process$env$_PACKAGE = "0.17.2", _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) {
|
|
@@ -16,6 +16,7 @@ var getIconAttribute = function getIconAttribute(attributes) {
|
|
|
16
16
|
};
|
|
17
17
|
var moveSizeAndLabelAttributes = exports.moveSizeAndLabelAttributes = function moveSizeAndLabelAttributes(element, j) {
|
|
18
18
|
var _iconAttr$value;
|
|
19
|
+
var iconRenamed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
19
20
|
var attributes = element.openingElement.attributes;
|
|
20
21
|
var iconAttr = attributes && getIconAttribute(attributes);
|
|
21
22
|
if (iconAttr && ((_iconAttr$value = iconAttr.value) === null || _iconAttr$value === void 0 ? void 0 : _iconAttr$value.type) === 'JSXExpressionContainer' && iconAttr.value.expression.type === 'JSXElement') {
|
|
@@ -26,14 +27,14 @@ var moveSizeAndLabelAttributes = exports.moveSizeAndLabelAttributes = function m
|
|
|
26
27
|
var labelAttribute = iconJSXElementAttributes.find(function (attribute) {
|
|
27
28
|
return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
|
|
28
29
|
});
|
|
29
|
-
if (labelAttribute && labelAttribute.type === 'JSXAttribute') {
|
|
30
|
+
if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
|
|
30
31
|
attributes === null || attributes === void 0 || attributes.push(labelAttribute);
|
|
31
32
|
}
|
|
32
33
|
var sizeAttribute = iconJSXElementAttributes.find(function (attribute) {
|
|
33
34
|
return attribute.type === 'JSXAttribute' && attribute.name.name === 'size';
|
|
34
35
|
});
|
|
35
36
|
if (sizeAttribute && sizeAttribute.type === 'JSXAttribute') {
|
|
36
|
-
sizeAttribute.name.name =
|
|
37
|
+
sizeAttribute.name.name = iconRenamed ? 'UNSAFE_size' : "UNSAFE_".concat(iconAttr.name.name, "_size");
|
|
37
38
|
attributes === null || attributes === void 0 || attributes.push(sizeAttribute);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -47,14 +48,14 @@ var moveSizeAndLabelAttributes = exports.moveSizeAndLabelAttributes = function m
|
|
|
47
48
|
var generateNewElement = exports.generateNewElement = function generateNewElement(variant, element, j) {
|
|
48
49
|
var attributes = element.openingElement.attributes;
|
|
49
50
|
var iconAttr = attributes && getIconAttribute(attributes);
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
var isIconOrLinkIcon = variant === _constants.NEW_BUTTON_VARIANTS.icon.as || variant === _constants.NEW_BUTTON_VARIANTS.linkIcon.as;
|
|
52
|
+
if (isIconOrLinkIcon && iconAttr) {
|
|
53
|
+
moveSizeAndLabelAttributes(element, j, true);
|
|
52
54
|
|
|
53
55
|
// rename iconBefore/iconAfter to icon
|
|
54
56
|
iconAttr.name.name = 'icon';
|
|
55
57
|
}
|
|
56
|
-
|
|
58
|
+
return j.jsxElement(
|
|
57
59
|
// self closing if it's an icon button or icon link button
|
|
58
|
-
|
|
59
|
-
return j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(variant), attributes, isSelfClosing), isSelfClosing ? null : j.jsxClosingElement(j.jsxIdentifier(variant)), element.children);
|
|
60
|
+
j.jsxOpeningElement(j.jsxIdentifier(variant), attributes, isIconOrLinkIcon), isIconOrLinkIcon ? null : j.jsxClosingElement(j.jsxIdentifier(variant)), element.children);
|
|
60
61
|
};
|
|
@@ -6,7 +6,7 @@ const getIconAttribute = attributes => {
|
|
|
6
6
|
}
|
|
7
7
|
return null;
|
|
8
8
|
};
|
|
9
|
-
export const moveSizeAndLabelAttributes = (element, j) => {
|
|
9
|
+
export const moveSizeAndLabelAttributes = (element, j, iconRenamed = false) => {
|
|
10
10
|
var _iconAttr$value;
|
|
11
11
|
const {
|
|
12
12
|
attributes
|
|
@@ -18,12 +18,12 @@ export const moveSizeAndLabelAttributes = (element, j) => {
|
|
|
18
18
|
if (Array.isArray(iconJSXElementAttributes)) {
|
|
19
19
|
// move label and size attributes from icon to the root Button prop
|
|
20
20
|
const labelAttribute = iconJSXElementAttributes.find(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === 'label');
|
|
21
|
-
if (labelAttribute && labelAttribute.type === 'JSXAttribute') {
|
|
21
|
+
if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
|
|
22
22
|
attributes === null || attributes === void 0 ? void 0 : attributes.push(labelAttribute);
|
|
23
23
|
}
|
|
24
24
|
const sizeAttribute = iconJSXElementAttributes.find(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === 'size');
|
|
25
25
|
if (sizeAttribute && sizeAttribute.type === 'JSXAttribute') {
|
|
26
|
-
sizeAttribute.name.name = `
|
|
26
|
+
sizeAttribute.name.name = iconRenamed ? 'UNSAFE_size' : `UNSAFE_${iconAttr.name.name}_size`;
|
|
27
27
|
attributes === null || attributes === void 0 ? void 0 : attributes.push(sizeAttribute);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -39,14 +39,14 @@ export const generateNewElement = (variant, element, j) => {
|
|
|
39
39
|
attributes
|
|
40
40
|
} = element.openingElement;
|
|
41
41
|
const iconAttr = attributes && getIconAttribute(attributes);
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const isIconOrLinkIcon = variant === NEW_BUTTON_VARIANTS.icon.as || variant === NEW_BUTTON_VARIANTS.linkIcon.as;
|
|
43
|
+
if (isIconOrLinkIcon && iconAttr) {
|
|
44
|
+
moveSizeAndLabelAttributes(element, j, true);
|
|
44
45
|
|
|
45
46
|
// rename iconBefore/iconAfter to icon
|
|
46
47
|
iconAttr.name.name = 'icon';
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
return j.jsxElement(
|
|
49
50
|
// self closing if it's an icon button or icon link button
|
|
50
|
-
|
|
51
|
-
return j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(variant), attributes, isSelfClosing), isSelfClosing ? null : j.jsxClosingElement(j.jsxIdentifier(variant)), element.children);
|
|
51
|
+
j.jsxOpeningElement(j.jsxIdentifier(variant), attributes, isIconOrLinkIcon), isIconOrLinkIcon ? null : j.jsxClosingElement(j.jsxIdentifier(variant)), element.children);
|
|
52
52
|
};
|
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.17.
|
|
301
|
+
_process$env$_PACKAGE = "0.17.2", _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) {
|
|
@@ -10,6 +10,7 @@ var getIconAttribute = function getIconAttribute(attributes) {
|
|
|
10
10
|
};
|
|
11
11
|
export var moveSizeAndLabelAttributes = function moveSizeAndLabelAttributes(element, j) {
|
|
12
12
|
var _iconAttr$value;
|
|
13
|
+
var iconRenamed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
13
14
|
var attributes = element.openingElement.attributes;
|
|
14
15
|
var iconAttr = attributes && getIconAttribute(attributes);
|
|
15
16
|
if (iconAttr && ((_iconAttr$value = iconAttr.value) === null || _iconAttr$value === void 0 ? void 0 : _iconAttr$value.type) === 'JSXExpressionContainer' && iconAttr.value.expression.type === 'JSXElement') {
|
|
@@ -20,14 +21,14 @@ export var moveSizeAndLabelAttributes = function moveSizeAndLabelAttributes(elem
|
|
|
20
21
|
var labelAttribute = iconJSXElementAttributes.find(function (attribute) {
|
|
21
22
|
return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
|
|
22
23
|
});
|
|
23
|
-
if (labelAttribute && labelAttribute.type === 'JSXAttribute') {
|
|
24
|
+
if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
|
|
24
25
|
attributes === null || attributes === void 0 || attributes.push(labelAttribute);
|
|
25
26
|
}
|
|
26
27
|
var sizeAttribute = iconJSXElementAttributes.find(function (attribute) {
|
|
27
28
|
return attribute.type === 'JSXAttribute' && attribute.name.name === 'size';
|
|
28
29
|
});
|
|
29
30
|
if (sizeAttribute && sizeAttribute.type === 'JSXAttribute') {
|
|
30
|
-
sizeAttribute.name.name =
|
|
31
|
+
sizeAttribute.name.name = iconRenamed ? 'UNSAFE_size' : "UNSAFE_".concat(iconAttr.name.name, "_size");
|
|
31
32
|
attributes === null || attributes === void 0 || attributes.push(sizeAttribute);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -41,14 +42,14 @@ export var moveSizeAndLabelAttributes = function moveSizeAndLabelAttributes(elem
|
|
|
41
42
|
export var generateNewElement = function generateNewElement(variant, element, j) {
|
|
42
43
|
var attributes = element.openingElement.attributes;
|
|
43
44
|
var iconAttr = attributes && getIconAttribute(attributes);
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
var isIconOrLinkIcon = variant === NEW_BUTTON_VARIANTS.icon.as || variant === NEW_BUTTON_VARIANTS.linkIcon.as;
|
|
46
|
+
if (isIconOrLinkIcon && iconAttr) {
|
|
47
|
+
moveSizeAndLabelAttributes(element, j, true);
|
|
46
48
|
|
|
47
49
|
// rename iconBefore/iconAfter to icon
|
|
48
50
|
iconAttr.name.name = 'icon';
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
return j.jsxElement(
|
|
51
53
|
// self closing if it's an icon button or icon link button
|
|
52
|
-
|
|
53
|
-
return j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(variant), attributes, isSelfClosing), isSelfClosing ? null : j.jsxClosingElement(j.jsxIdentifier(variant)), element.children);
|
|
54
|
+
j.jsxOpeningElement(j.jsxIdentifier(variant), attributes, isIconOrLinkIcon), isIconOrLinkIcon ? null : j.jsxClosingElement(j.jsxIdentifier(variant)), element.children);
|
|
54
55
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { API, JSXElement } from 'jscodeshift';
|
|
2
2
|
import { NEW_BUTTON_VARIANTS } from '../utils/constants';
|
|
3
|
-
export declare const moveSizeAndLabelAttributes: (element: JSXElement, j: API['jscodeshift']) => void;
|
|
3
|
+
export declare const moveSizeAndLabelAttributes: (element: JSXElement, j: API['jscodeshift'], iconRenamed?: boolean) => void;
|
|
4
4
|
export declare const generateNewElement: (variant: (typeof NEW_BUTTON_VARIANTS)[keyof typeof NEW_BUTTON_VARIANTS]['as'], element: JSXElement, j: API['jscodeshift']) => JSXElement;
|
package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { API, JSXElement } from 'jscodeshift';
|
|
2
2
|
import { NEW_BUTTON_VARIANTS } from '../utils/constants';
|
|
3
|
-
export declare const moveSizeAndLabelAttributes: (element: JSXElement, j: API['jscodeshift']) => void;
|
|
3
|
+
export declare const moveSizeAndLabelAttributes: (element: JSXElement, j: API['jscodeshift'], iconRenamed?: boolean) => void;
|
|
4
4
|
export declare const generateNewElement: (variant: (typeof NEW_BUTTON_VARIANTS)[keyof typeof NEW_BUTTON_VARIANTS]['as'], element: JSXElement, j: API['jscodeshift']) => JSXElement;
|
package/package.json
CHANGED
package/tmp/api-report-tmp.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
## API Report File for "@atlaskit/codemod-cli"
|
|
2
|
-
|
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
|
|
7
|
-
// @public (undocumented)
|
|
8
|
-
type CliFlags = {
|
|
9
|
-
transform?: string;
|
|
10
|
-
preset?: string;
|
|
11
|
-
packages?: string;
|
|
12
|
-
parser: 'babel' | 'babylon' | 'flow' | 'ts' | 'tsx';
|
|
13
|
-
extensions: string;
|
|
14
|
-
ignorePattern: string;
|
|
15
|
-
sinceRef?: string;
|
|
16
|
-
failOnError?: boolean;
|
|
17
|
-
filterPaths?: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// @public
|
|
21
|
-
type Default<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
22
|
-
|
|
23
|
-
// @public (undocumented)
|
|
24
|
-
const defaultFlags: {
|
|
25
|
-
parser: "babel";
|
|
26
|
-
extensions: string;
|
|
27
|
-
ignorePattern: string;
|
|
28
|
-
logger: Console;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// @public (undocumented)
|
|
32
|
-
type Flags_2 = CliFlags & {
|
|
33
|
-
logger: {
|
|
34
|
-
log: (...args: any) => void;
|
|
35
|
-
warn: (...args: any) => void;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export { Flags_2 as Flags }
|
|
39
|
-
|
|
40
|
-
// @public (undocumented)
|
|
41
|
-
function main(input: string[], userFlags: UserFlags): Promise<{
|
|
42
|
-
transforms: {
|
|
43
|
-
module: string;
|
|
44
|
-
root: string;
|
|
45
|
-
dir: string;
|
|
46
|
-
base: string;
|
|
47
|
-
ext: string;
|
|
48
|
-
name: string;
|
|
49
|
-
}[];
|
|
50
|
-
}>;
|
|
51
|
-
export default main;
|
|
52
|
-
|
|
53
|
-
// @public (undocumented)
|
|
54
|
-
export class NoTransformsExistError extends Error {
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// @public (undocumented)
|
|
58
|
-
export type UserFlags = Default<Flags_2, keyof typeof defaultFlags>;
|
|
59
|
-
|
|
60
|
-
// @public (undocumented)
|
|
61
|
-
export class ValidationError extends Error {
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// (No @packageDocumentation comment for this package)
|
|
65
|
-
|
|
66
|
-
```
|