@carbon/upgrade 11.23.0-rc.0 → 11.23.0
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/cli.js +44 -1
- package/package.json +2 -2
- package/transforms/__testfixtures__/slug-prop-to-decorator-prop.input.js +41 -0
- package/transforms/__testfixtures__/slug-prop-to-decorator-prop.input.tsx +41 -0
- package/transforms/__testfixtures__/slug-prop-to-decorator-prop.output.js +41 -0
- package/transforms/__testfixtures__/slug-prop-to-decorator-prop.output.tsx +41 -0
- package/transforms/__tests__/slug-prop-to-decorator-prop-test.js +12 -0
- package/transforms/slug-prop-to-decorator-prop.js +47 -0
package/cli.js
CHANGED
|
@@ -52641,6 +52641,49 @@ var upgrades = [
|
|
|
52641
52641
|
});
|
|
52642
52642
|
}
|
|
52643
52643
|
},
|
|
52644
|
+
{
|
|
52645
|
+
name: "slug-prop-to-decorator-prop",
|
|
52646
|
+
description: `
|
|
52647
|
+
Replace slug prop with decorator
|
|
52648
|
+
|
|
52649
|
+
Transforms:
|
|
52650
|
+
<Component slug="value">
|
|
52651
|
+
content
|
|
52652
|
+
</Component>
|
|
52653
|
+
|
|
52654
|
+
Into:
|
|
52655
|
+
<Component decorator="value">
|
|
52656
|
+
content
|
|
52657
|
+
</Component>
|
|
52658
|
+
`,
|
|
52659
|
+
migrate: async (options) => {
|
|
52660
|
+
const transform = import_path2.default.join(
|
|
52661
|
+
TRANSFORM_DIR,
|
|
52662
|
+
"slug-prop-to-decorator-prop.js"
|
|
52663
|
+
);
|
|
52664
|
+
const paths = Array.isArray(options.paths) && options.paths.length > 0 ? options.paths : await (0, import_fast_glob2.default)(["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"], {
|
|
52665
|
+
cwd: options.workspaceDir,
|
|
52666
|
+
ignore: [
|
|
52667
|
+
"**/es/**",
|
|
52668
|
+
"**/lib/**",
|
|
52669
|
+
"**/umd/**",
|
|
52670
|
+
"**/node_modules/**",
|
|
52671
|
+
"**/storybook-static/**",
|
|
52672
|
+
"**/dist/**",
|
|
52673
|
+
"**/build/**",
|
|
52674
|
+
"**/*.d.ts",
|
|
52675
|
+
"**/coverage/**"
|
|
52676
|
+
]
|
|
52677
|
+
});
|
|
52678
|
+
await run2({
|
|
52679
|
+
dry: !options.write,
|
|
52680
|
+
transform,
|
|
52681
|
+
paths,
|
|
52682
|
+
verbose: options.verbose,
|
|
52683
|
+
parser: "tsx"
|
|
52684
|
+
});
|
|
52685
|
+
}
|
|
52686
|
+
},
|
|
52644
52687
|
{
|
|
52645
52688
|
name: "refactor-light-to-layer",
|
|
52646
52689
|
description: `
|
|
@@ -52886,7 +52929,7 @@ var upgrades = [
|
|
|
52886
52929
|
var package_default = {
|
|
52887
52930
|
name: "@carbon/upgrade",
|
|
52888
52931
|
description: "A tool for upgrading Carbon versions",
|
|
52889
|
-
version: "11.23.0
|
|
52932
|
+
version: "11.23.0",
|
|
52890
52933
|
license: "Apache-2.0",
|
|
52891
52934
|
bin: {
|
|
52892
52935
|
"carbon-upgrade": "./bin/carbon-upgrade.js"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/upgrade",
|
|
3
3
|
"description": "A tool for upgrading Carbon versions",
|
|
4
|
-
"version": "11.23.0
|
|
4
|
+
"version": "11.23.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": {
|
|
7
7
|
"carbon-upgrade": "./bin/carbon-upgrade.js"
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@ibm/telemetry-js": "^1.5.0",
|
|
62
62
|
"jscodeshift": "^17.0.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "fd1b7ab668473833c250488e0f7fc4feb55f1d88"
|
|
65
65
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, Checkbox, Tag } from '@carbon/react';
|
|
3
|
+
|
|
4
|
+
function TestComponent() {
|
|
5
|
+
return (
|
|
6
|
+
//prettier-ignore
|
|
7
|
+
<div>
|
|
8
|
+
{/* Basic Dropdown usage */}
|
|
9
|
+
<Dropdown
|
|
10
|
+
label="Select an option"
|
|
11
|
+
slug="dropdown-1"
|
|
12
|
+
items={['Option 1', 'Option 2']}
|
|
13
|
+
id="dropdown-1"
|
|
14
|
+
titleText="Dropdown"
|
|
15
|
+
/>
|
|
16
|
+
{/* Checkbox with expression */}
|
|
17
|
+
<Checkbox
|
|
18
|
+
labelText="Check me"
|
|
19
|
+
slug={'checkbox-1'}
|
|
20
|
+
id="checkbox-1"
|
|
21
|
+
/>
|
|
22
|
+
{/* Tag with string literal */}
|
|
23
|
+
<Tag slug={'static-tag'} type="red">
|
|
24
|
+
Important
|
|
25
|
+
</Tag>
|
|
26
|
+
{/* Nested structure */}
|
|
27
|
+
<div>
|
|
28
|
+
<Tag slug="tag-1" type="blue">
|
|
29
|
+
Active
|
|
30
|
+
</Tag>
|
|
31
|
+
<Checkbox
|
|
32
|
+
slug="checkbox-2"
|
|
33
|
+
labelText="Enable feature"
|
|
34
|
+
id="checkbox-2"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default TestComponent;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, Checkbox, Tag } from '@carbon/react';
|
|
3
|
+
|
|
4
|
+
const TestComponent: React.FC = () => {
|
|
5
|
+
return (
|
|
6
|
+
//prettier-ignore
|
|
7
|
+
<div>
|
|
8
|
+
{/* Basic Dropdown usage */}
|
|
9
|
+
<Dropdown
|
|
10
|
+
label="Select an option"
|
|
11
|
+
slug="dropdown-1"
|
|
12
|
+
items={['Option 1', 'Option 2']}
|
|
13
|
+
id="dropdown-1"
|
|
14
|
+
titleText="Dropdown"
|
|
15
|
+
/>
|
|
16
|
+
{/* Checkbox with expression */}
|
|
17
|
+
<Checkbox
|
|
18
|
+
labelText="Check me"
|
|
19
|
+
slug={'checkbox-1'}
|
|
20
|
+
id="checkbox-1"
|
|
21
|
+
/>
|
|
22
|
+
{/* Tag with string literal */}
|
|
23
|
+
<Tag slug={'static-tag'} type="red">
|
|
24
|
+
Important
|
|
25
|
+
</Tag>
|
|
26
|
+
{/* Nested structure */}
|
|
27
|
+
<div>
|
|
28
|
+
<Tag slug="tag-1" type="blue">
|
|
29
|
+
Active
|
|
30
|
+
</Tag>
|
|
31
|
+
<Checkbox
|
|
32
|
+
slug="checkbox-2"
|
|
33
|
+
labelText="Enable feature"
|
|
34
|
+
id="checkbox-2"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default TestComponent;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, Checkbox, Tag } from '@carbon/react';
|
|
3
|
+
|
|
4
|
+
function TestComponent() {
|
|
5
|
+
return (
|
|
6
|
+
//prettier-ignore
|
|
7
|
+
(<div>
|
|
8
|
+
{/* Basic Dropdown usage */}
|
|
9
|
+
<Dropdown
|
|
10
|
+
label="Select an option"
|
|
11
|
+
decorator="dropdown-1"
|
|
12
|
+
items={['Option 1', 'Option 2']}
|
|
13
|
+
id="dropdown-1"
|
|
14
|
+
titleText="Dropdown"
|
|
15
|
+
/>
|
|
16
|
+
{/* Checkbox with expression */}
|
|
17
|
+
<Checkbox
|
|
18
|
+
labelText="Check me"
|
|
19
|
+
decorator={'checkbox-1'}
|
|
20
|
+
id="checkbox-1"
|
|
21
|
+
/>
|
|
22
|
+
{/* Tag with string literal */}
|
|
23
|
+
<Tag decorator={'static-tag'} type="red">
|
|
24
|
+
Important
|
|
25
|
+
</Tag>
|
|
26
|
+
{/* Nested structure */}
|
|
27
|
+
<div>
|
|
28
|
+
<Tag decorator="tag-1" type="blue">
|
|
29
|
+
Active
|
|
30
|
+
</Tag>
|
|
31
|
+
<Checkbox
|
|
32
|
+
decorator="checkbox-2"
|
|
33
|
+
labelText="Enable feature"
|
|
34
|
+
id="checkbox-2"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
</div>)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default TestComponent;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, Checkbox, Tag } from '@carbon/react';
|
|
3
|
+
|
|
4
|
+
const TestComponent: React.FC = () => {
|
|
5
|
+
return (
|
|
6
|
+
//prettier-ignore
|
|
7
|
+
(<div>
|
|
8
|
+
{/* Basic Dropdown usage */}
|
|
9
|
+
<Dropdown
|
|
10
|
+
label="Select an option"
|
|
11
|
+
decorator="dropdown-1"
|
|
12
|
+
items={['Option 1', 'Option 2']}
|
|
13
|
+
id="dropdown-1"
|
|
14
|
+
titleText="Dropdown"
|
|
15
|
+
/>
|
|
16
|
+
{/* Checkbox with expression */}
|
|
17
|
+
<Checkbox
|
|
18
|
+
labelText="Check me"
|
|
19
|
+
decorator={'checkbox-1'}
|
|
20
|
+
id="checkbox-1"
|
|
21
|
+
/>
|
|
22
|
+
{/* Tag with string literal */}
|
|
23
|
+
<Tag decorator={'static-tag'} type="red">
|
|
24
|
+
Important
|
|
25
|
+
</Tag>
|
|
26
|
+
{/* Nested structure */}
|
|
27
|
+
<div>
|
|
28
|
+
<Tag decorator="tag-1" type="blue">
|
|
29
|
+
Active
|
|
30
|
+
</Tag>
|
|
31
|
+
<Checkbox
|
|
32
|
+
decorator="checkbox-2"
|
|
33
|
+
labelText="Enable feature"
|
|
34
|
+
id="checkbox-2"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
</div>)
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default TestComponent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const { defineTest } = require('jscodeshift/dist/testUtils');
|
|
11
|
+
|
|
12
|
+
defineTest(__dirname, 'slug-prop-to-decorator-prop');
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* Replace slug prop with decorator
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const defaultOptions = {
|
|
13
|
+
quote: 'single',
|
|
14
|
+
trailingComma: true,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function transform(fileInfo, api, options) {
|
|
18
|
+
const j = api.jscodeshift;
|
|
19
|
+
const root = j(fileInfo.source);
|
|
20
|
+
const printOptions = options.printOptions || defaultOptions;
|
|
21
|
+
|
|
22
|
+
// Early return if no JSX elements with slug prop found
|
|
23
|
+
if (!root.find(j.JSXAttribute, { name: { name: 'slug' } }).size()) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Replace slug with decorator
|
|
28
|
+
root
|
|
29
|
+
.find(j.JSXAttribute, {
|
|
30
|
+
name: { name: 'slug' },
|
|
31
|
+
})
|
|
32
|
+
.forEach((path) => {
|
|
33
|
+
// Create new decorator attribute with same value as slug
|
|
34
|
+
const newAttribute = j.jsxAttribute(
|
|
35
|
+
j.jsxIdentifier('decorator'),
|
|
36
|
+
path.node.value
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Replace the slug attribute with decorator
|
|
40
|
+
j(path).replaceWith(newAttribute);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return root.toSource(printOptions);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = transform;
|
|
47
|
+
module.exports.parser = 'tsx';
|