@octaviaflow/upgrade 1.0.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/README.md +97 -0
- package/bin/carbon-upgrade.js +48 -0
- package/cli.js +53573 -0
- package/package.json +56 -0
- package/telemetry.yml +17 -0
- package/transforms/ARCHITECTURE.md +47 -0
- package/transforms/__testfixtures__/featureflag-deprecate-flags-prop.input.js +143 -0
- package/transforms/__testfixtures__/featureflag-deprecate-flags-prop.output.js +133 -0
- package/transforms/__testfixtures__/ibm-products-update-userprofileimage.input.js +57 -0
- package/transforms/__testfixtures__/ibm-products-update-userprofileimage.output.js +50 -0
- package/transforms/__testfixtures__/icons-react-size-prop-object-key.input.js +25 -0
- package/transforms/__testfixtures__/icons-react-size-prop-object-key.output.js +25 -0
- package/transforms/__testfixtures__/icons-react-size-prop-rename.input.js +53 -0
- package/transforms/__testfixtures__/icons-react-size-prop-rename.output.js +53 -0
- package/transforms/__testfixtures__/icons-react-size-prop-with-prop.input.js +25 -0
- package/transforms/__testfixtures__/icons-react-size-prop-with-prop.output.js +28 -0
- package/transforms/__testfixtures__/refactor-light-to-layer.input.js +23 -0
- package/transforms/__testfixtures__/refactor-light-to-layer.output.js +23 -0
- package/transforms/__testfixtures__/refactor-to-callout.input.js +34 -0
- package/transforms/__testfixtures__/refactor-to-callout.output.js +32 -0
- package/transforms/__testfixtures__/refactor-to-callout2.input.js +13 -0
- package/transforms/__testfixtures__/refactor-to-callout2.output.js +13 -0
- package/transforms/__testfixtures__/refactor-to-callout3.input.js +14 -0
- package/transforms/__testfixtures__/refactor-to-callout3.output.js +14 -0
- package/transforms/__testfixtures__/refactor-to-callout4.input.js +12 -0
- package/transforms/__testfixtures__/refactor-to-callout4.output.js +12 -0
- package/transforms/__testfixtures__/size-prop-update.input.js +152 -0
- package/transforms/__testfixtures__/size-prop-update.output.js +152 -0
- package/transforms/__testfixtures__/small-to-size-prop.input.js +20 -0
- package/transforms/__testfixtures__/small-to-size-prop.output.js +19 -0
- package/transforms/__testfixtures__/sort-prop-types.input.js +16 -0
- package/transforms/__testfixtures__/sort-prop-types.output.js +16 -0
- package/transforms/__testfixtures__/sort-prop-types2.input.js +16 -0
- package/transforms/__testfixtures__/sort-prop-types2.output.js +16 -0
- package/transforms/__testfixtures__/update-carbon-components-react-import-to-scoped.input.js +17 -0
- package/transforms/__testfixtures__/update-carbon-components-react-import-to-scoped.output.js +17 -0
- package/transforms/__testfixtures__/update-carbon-icons-react-import-to-carbon-react.input.js +17 -0
- package/transforms/__testfixtures__/update-carbon-icons-react-import-to-carbon-react.output.js +17 -0
- package/transforms/__tests__/featureflag-deprecate-flags-prop-test.js +15 -0
- package/transforms/__tests__/ibm-products-update-userprofileimage-test.js +21 -0
- package/transforms/__tests__/icons-react-size-prop.js +67 -0
- package/transforms/__tests__/refactor-light-to-layer-test.js +14 -0
- package/transforms/__tests__/refactor-to-callout.js +18 -0
- package/transforms/__tests__/size-prop-update-test.js +15 -0
- package/transforms/__tests__/small-to-size-test.js +15 -0
- package/transforms/__tests__/sort-prop-types-test.js +16 -0
- package/transforms/__tests__/update-carbon-components-react-import-to-scoped.js +15 -0
- package/transforms/__tests__/update-carbon-icons-react-import-to-carbon-react.js +15 -0
- package/transforms/featureflag-deprecate-flags-prop.js +89 -0
- package/transforms/ibm-products-update-userprofileimage.js +134 -0
- package/transforms/icons-react-size-prop.js +327 -0
- package/transforms/refactor-light-to-layer.js +117 -0
- package/transforms/refactor-to-callout.js +160 -0
- package/transforms/size-prop-update.js +143 -0
- package/transforms/small-to-size-prop.js +59 -0
- package/transforms/sort-prop-types.js +91 -0
- package/transforms/update-carbon-components-react-import-to-scoped.js +42 -0
- package/transforms/update-carbon-icons-react-import-to-carbon-react.js +42 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const defaultOptions = {
|
|
14
|
+
quote: 'auto',
|
|
15
|
+
trailingComma: true,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function transform(fileInfo, api, options) {
|
|
19
|
+
const printOptions = options.printOptions || defaultOptions;
|
|
20
|
+
const j = api.jscodeshift;
|
|
21
|
+
const root = j(fileInfo.source);
|
|
22
|
+
|
|
23
|
+
function replacePropForComponent(name) {
|
|
24
|
+
// Multiselect.Filterable has a different AST structure, so we need to
|
|
25
|
+
// adjust the query to find it properly. If it is not 'Filterable', we use
|
|
26
|
+
// the default query
|
|
27
|
+
let isFilterable = name === 'Filterable';
|
|
28
|
+
let openingElementQuery = {
|
|
29
|
+
name: {
|
|
30
|
+
name,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
if (isFilterable) {
|
|
34
|
+
openingElementQuery = {
|
|
35
|
+
name: {
|
|
36
|
+
object: {
|
|
37
|
+
name: 'MultiSelect',
|
|
38
|
+
},
|
|
39
|
+
property: {
|
|
40
|
+
name: name,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
root
|
|
46
|
+
.find(j.JSXOpeningElement, openingElementQuery)
|
|
47
|
+
.forEach((openingElement) => {
|
|
48
|
+
// Multiselect.Filterable has a different AST structure, so the name is located differently
|
|
49
|
+
const { name } = isFilterable
|
|
50
|
+
? openingElement.node.name.property
|
|
51
|
+
: openingElement.node.name;
|
|
52
|
+
|
|
53
|
+
// Some components were originally set to `xl`, but are being reduced to `lg`
|
|
54
|
+
const downsizedComponents = [
|
|
55
|
+
'Accordion',
|
|
56
|
+
'ComboBox',
|
|
57
|
+
'ContentSwitcher',
|
|
58
|
+
'DatePickerInput',
|
|
59
|
+
'Dropdown',
|
|
60
|
+
'MultiSelect',
|
|
61
|
+
'Filterable',
|
|
62
|
+
'NumberInput',
|
|
63
|
+
'OverflowMenu',
|
|
64
|
+
'Search',
|
|
65
|
+
'Select',
|
|
66
|
+
'TextInput',
|
|
67
|
+
'TimePicker',
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const isDownsized = downsizedComponents.includes(name);
|
|
71
|
+
|
|
72
|
+
j(openingElement)
|
|
73
|
+
.find(j.JSXAttribute, {
|
|
74
|
+
name: {
|
|
75
|
+
name: 'size',
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
.forEach((path) => {
|
|
79
|
+
j(path).replaceWith((nodePath) => {
|
|
80
|
+
const { node } = nodePath;
|
|
81
|
+
const { value } = node.value;
|
|
82
|
+
|
|
83
|
+
switch (value) {
|
|
84
|
+
case 'compact':
|
|
85
|
+
node.value.value = 'xs';
|
|
86
|
+
return node;
|
|
87
|
+
case 'short':
|
|
88
|
+
case 'small':
|
|
89
|
+
node.value.value = 'sm';
|
|
90
|
+
return node;
|
|
91
|
+
case 'field':
|
|
92
|
+
node.value.value = 'md';
|
|
93
|
+
return node;
|
|
94
|
+
case 'default':
|
|
95
|
+
case 'normal':
|
|
96
|
+
node.value.value = 'lg';
|
|
97
|
+
return node;
|
|
98
|
+
case 'tall':
|
|
99
|
+
case 'lg':
|
|
100
|
+
node.value.value = isDownsized ? 'md' : 'xl';
|
|
101
|
+
return node;
|
|
102
|
+
case 'xl':
|
|
103
|
+
node.value.value = isDownsized ? 'lg' : '2xl';
|
|
104
|
+
return node;
|
|
105
|
+
}
|
|
106
|
+
return node;
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const components = [
|
|
113
|
+
'Accordion',
|
|
114
|
+
'Button',
|
|
115
|
+
'ComboBox',
|
|
116
|
+
'ContentSwitcher',
|
|
117
|
+
'DataTable',
|
|
118
|
+
'DatePickerInput',
|
|
119
|
+
'Dropdown',
|
|
120
|
+
'FileUploader',
|
|
121
|
+
'FileUploaderButton',
|
|
122
|
+
'FileUploaderDropContainer',
|
|
123
|
+
'FileUploaderItem',
|
|
124
|
+
'MultiSelect',
|
|
125
|
+
'Filterable',
|
|
126
|
+
'NumberInput',
|
|
127
|
+
'OverflowMenu',
|
|
128
|
+
'Search',
|
|
129
|
+
'Select',
|
|
130
|
+
'Table',
|
|
131
|
+
'TableToolbar',
|
|
132
|
+
'TextInput',
|
|
133
|
+
'TimePicker',
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
for (const component of components) {
|
|
137
|
+
replacePropForComponent(component);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return root.toSource(printOptions);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = transform;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const defaultOptions = {
|
|
14
|
+
quote: 'auto',
|
|
15
|
+
trailingComma: true,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function transform(fileInfo, api, options) {
|
|
19
|
+
const printOptions = options.printOptions || defaultOptions;
|
|
20
|
+
const j = api.jscodeshift;
|
|
21
|
+
const root = j(fileInfo.source);
|
|
22
|
+
|
|
23
|
+
const sizeProp = j.jsxAttribute(j.jsxIdentifier('size'), j.literal('sm'));
|
|
24
|
+
|
|
25
|
+
function replacePropForComponent(name) {
|
|
26
|
+
root
|
|
27
|
+
.find(j.JSXOpeningElement, {
|
|
28
|
+
name: {
|
|
29
|
+
name,
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
.forEach((openingElement) => {
|
|
33
|
+
j(openingElement)
|
|
34
|
+
.find(j.JSXAttribute, {
|
|
35
|
+
name: {
|
|
36
|
+
name: 'small',
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
.forEach((path) => {
|
|
40
|
+
j(path).replaceWith(sizeProp);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const components = [
|
|
46
|
+
'Button',
|
|
47
|
+
'DangerButton',
|
|
48
|
+
'PrimaryButton',
|
|
49
|
+
'SecondaryButton',
|
|
50
|
+
'Search',
|
|
51
|
+
];
|
|
52
|
+
for (const component of components) {
|
|
53
|
+
replacePropForComponent(component);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return root.toSource(printOptions);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = transform;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const defaultOptions = {
|
|
14
|
+
quote: 'single',
|
|
15
|
+
trailingComma: true,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function transform(fileInfo, api, options) {
|
|
19
|
+
const printOptions = options.printOptions || defaultOptions;
|
|
20
|
+
const j = api.jscodeshift;
|
|
21
|
+
const root = j(fileInfo.source);
|
|
22
|
+
|
|
23
|
+
root
|
|
24
|
+
.find(j.AssignmentExpression, {
|
|
25
|
+
left: {
|
|
26
|
+
type: 'MemberExpression',
|
|
27
|
+
property: {
|
|
28
|
+
name: 'propTypes',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
.forEach((path) => {
|
|
33
|
+
path.node.right.properties.sort((a, b) => {
|
|
34
|
+
if (a.type === 'Property' && b.type === 'Property') {
|
|
35
|
+
if (getPropName(a) > getPropName(b)) {
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (a.type === 'SpreadElement' && b.type === 'SpreadElement') {
|
|
42
|
+
if (getPropName(a) > getPropName(b)) {
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
return -1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (a.type === 'SpreadElement') {
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return 1;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
root
|
|
57
|
+
.find(j.ClassProperty, {
|
|
58
|
+
key: {
|
|
59
|
+
name: 'propTypes',
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
.forEach((path) => {
|
|
63
|
+
path.node.value.properties.sort((a, b) => {
|
|
64
|
+
if (getPropName(a) > getPropName(b)) {
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
return -1;
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
function getPropName(node) {
|
|
72
|
+
if (node.type === 'SpreadElement') {
|
|
73
|
+
return node.argument.name;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (node.type === 'Property') {
|
|
77
|
+
if (node.key.type === 'Identifier') {
|
|
78
|
+
return node.key.name;
|
|
79
|
+
}
|
|
80
|
+
if (node.key.type === 'Literal') {
|
|
81
|
+
return node.key.value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
throw new Error(`Unknown node of type: ${node.type}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return root.toSource(printOptions);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = transform;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Copyright IBM Corp. 2016, 2023
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*
|
|
16
|
+
* Rewrites imports from 'carbon-components-react' to '@octaviaflow/react'
|
|
17
|
+
*
|
|
18
|
+
* Transforms:
|
|
19
|
+
*
|
|
20
|
+
* import { Button } from 'carbon-components-react';
|
|
21
|
+
*
|
|
22
|
+
* Into:
|
|
23
|
+
*
|
|
24
|
+
* import { Button } from "@octaviaflow/react";
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
function transformer(file, api) {
|
|
28
|
+
const j = api.jscodeshift;
|
|
29
|
+
|
|
30
|
+
return j(file.source)
|
|
31
|
+
.find(j.ImportDeclaration, {
|
|
32
|
+
source: {
|
|
33
|
+
value: 'carbon-components-react',
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
.forEach((path) => {
|
|
37
|
+
path.get('source').replace(j.stringLiteral('@octaviaflow/react'));
|
|
38
|
+
})
|
|
39
|
+
.toSource();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = transformer;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Copyright IBM Corp. 2016, 2023
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*
|
|
16
|
+
* Rewrites imports from '@octaviaflow/icons-react' to '@octaviaflow/react/icons'
|
|
17
|
+
*
|
|
18
|
+
* Transforms:
|
|
19
|
+
*
|
|
20
|
+
* import { Add } from '@octaviaflow/icons-react';
|
|
21
|
+
*
|
|
22
|
+
* Into:
|
|
23
|
+
*
|
|
24
|
+
* import { Add } from "@octaviaflow/react/icons";
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
function transformer(file, api) {
|
|
28
|
+
const j = api.jscodeshift;
|
|
29
|
+
|
|
30
|
+
return j(file.source)
|
|
31
|
+
.find(j.ImportDeclaration, {
|
|
32
|
+
source: {
|
|
33
|
+
value: '@octaviaflow/icons-react',
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
.forEach((path) => {
|
|
37
|
+
path.get('source').replace(j.stringLiteral('@octaviaflow/react/icons'));
|
|
38
|
+
})
|
|
39
|
+
.toSource();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = transformer;
|