@carbon/upgrade 11.43.0 → 11.44.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/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.43.0",
4
+ "version": "11.44.0",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
7
7
  "carbon-upgrade": "./bin/carbon-upgrade.js"
@@ -40,10 +40,10 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "chalk": "^6.0.0",
43
- "execa": "^9.6.0",
43
+ "execa": "^10.0.0",
44
44
  "fast-glob": "^3.3.3",
45
45
  "fs-extra": "^11.0.0",
46
- "inquirer": "^12.5.0",
46
+ "inquirer": "^14.0.0",
47
47
  "is-git-clean": "^1.1.0",
48
48
  "jest-diff": "^30.0.0",
49
49
  "lodash.clonedeep": "^4.5.0",
@@ -60,5 +60,5 @@
60
60
  "@ibm/telemetry-js": "^1.5.0",
61
61
  "jscodeshift": "^17.0.0"
62
62
  },
63
- "gitHead": "188d23202ec1092322dee92cf0df9d9958224ae4"
63
+ "gitHead": "7518c84ffd00f22434fe19d83119692c12fccb2f"
64
64
  }
@@ -0,0 +1,21 @@
1
+ // @ts-nocheck — preview_Pagination and preview_PageSelector are untyped JS
2
+ // components with no TypeScript declarations, so TS would error on every prop.
3
+ import React from 'react';
4
+ import {
5
+ preview_PageSelector as PageSelector,
6
+ preview_Pagination as Pagination,
7
+ } from '@carbon/react';
8
+
9
+ // No `pageSizes` — the stable Pagination must render without crashing on
10
+ // `sizes[0]` (regression guarded by making `pageSizes` optional).
11
+ export const WithoutPageSizes = () => (
12
+ <Pagination onChange={() => {}} pageSize={10} totalItems={100}>
13
+ {({ currentPage, onSetPage, totalPages }) => (
14
+ <PageSelector
15
+ currentPage={currentPage}
16
+ onChange={(e) => onSetPage(e.target.value)}
17
+ totalPages={totalPages}
18
+ />
19
+ )}
20
+ </Pagination>
21
+ );
@@ -0,0 +1,11 @@
1
+ // @ts-nocheck — preview_Pagination and preview_PageSelector are untyped JS
2
+ // components with no TypeScript declarations, so TS would error on every prop.
3
+ import React from 'react';
4
+ import { Pagination } from '@carbon/react';
5
+
6
+ // No `pageSizes` — the stable Pagination must render without crashing on
7
+ // `sizes[0]` (regression guarded by making `pageSizes` optional).
8
+ export const WithoutPageSizes = () => (
9
+ // TODO: manually migrate children to the renderPageSelect prop if necessary.
10
+ <Pagination onChange={() => {}} pageSize={10} totalItems={100} />
11
+ );
@@ -0,0 +1,23 @@
1
+ // @ts-nocheck — preview_Pagination and preview_PageSelector are untyped JS
2
+ // components with no TypeScript declarations, so TS would error on every prop.
3
+ import React from 'react';
4
+ import {
5
+ preview_PageSelector as PageSelector,
6
+ preview_Pagination as Pagination,
7
+ } from '@carbon/react';
8
+
9
+ export const Demo = () => (
10
+ <Pagination
11
+ onChange={() => {}}
12
+ pageSize={10}
13
+ pageSizes={[10, 20]}
14
+ totalItems={100}>
15
+ {({ currentPage, onSetPage, totalPages }) => (
16
+ <PageSelector
17
+ currentPage={currentPage}
18
+ onChange={(e) => onSetPage(e.target.value)}
19
+ totalPages={totalPages}
20
+ />
21
+ )}
22
+ </Pagination>
23
+ );
@@ -0,0 +1,9 @@
1
+ // @ts-nocheck — preview_Pagination and preview_PageSelector are untyped JS
2
+ // components with no TypeScript declarations, so TS would error on every prop.
3
+ import React from 'react';
4
+ import { Pagination } from '@carbon/react';
5
+
6
+ export const Demo = () => (
7
+ // TODO: manually migrate children to the renderPageSelect prop if necessary.
8
+ <Pagination onChange={() => {}} pageSize={10} pageSizes={[10, 20]} totalItems={100} />
9
+ );
@@ -0,0 +1,25 @@
1
+ // @ts-nocheck — unstable_Pagination and unstable_PageSelector are untyped JS
2
+ // components with no TypeScript declarations, so TS would error on every prop.
3
+ import React from 'react';
4
+ import {
5
+ unstable_PageSelector as PageSelector,
6
+ unstable_Pagination as Pagination,
7
+ } from '@carbon/react';
8
+
9
+ // Basic usage: unstable Pagination with a PageSelector
10
+ export const WithPageSelector = () => (
11
+ <Pagination
12
+ onChange={() => {}}
13
+ pageSize={10}
14
+ pageSizes={[10, 20, 30]}
15
+ totalItems={350}>
16
+ {({ currentPage, onSetPage, totalPages }) => (
17
+ <PageSelector
18
+ currentPage={currentPage}
19
+ id="select-1"
20
+ onChange={(event) => onSetPage(event.target.value)}
21
+ totalPages={totalPages}
22
+ />
23
+ )}
24
+ </Pagination>
25
+ );
@@ -0,0 +1,15 @@
1
+ // @ts-nocheck — unstable_Pagination and unstable_PageSelector are untyped JS
2
+ // components with no TypeScript declarations, so TS would error on every prop.
3
+ import React from 'react';
4
+ import { Pagination } from '@carbon/react';
5
+
6
+ // Basic usage: unstable Pagination with a PageSelector
7
+ export const WithPageSelector = () => (
8
+ // TODO: manually migrate children to the renderPageSelect prop if necessary.
9
+ <Pagination
10
+ onChange={() => {}}
11
+ pageSize={10}
12
+ pageSizes={[10, 20, 30]}
13
+ totalItems={350} />
14
+ );
15
+
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
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
+ // unstable_ prefix — PageSelector render-prop child + bare usage
13
+ defineTest(__dirname, 'unstable-pagination-to-pagination');
14
+
15
+ // preview_ prefix — same transform, different fixtures
16
+ defineTest(
17
+ __dirname,
18
+ 'unstable-pagination-to-pagination',
19
+ null,
20
+ 'preview-pagination-to-pagination'
21
+ );
22
+
23
+ // No `pageSizes` — migrated code must not crash on `sizes[0]`
24
+ defineTest(
25
+ __dirname,
26
+ 'unstable-pagination-to-pagination',
27
+ null,
28
+ 'preview-pagination-no-sizer'
29
+ );
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
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
+ /**
9
+ * Migrate unstable_Pagination / preview_Pagination to the stable Pagination
10
+ * component. Removes the PageSelector import and children render-prop, since
11
+ * the stable Pagination renders an equivalent page-select control by default.
12
+ */
13
+
14
+ 'use strict';
15
+
16
+ const defaultOptions = {
17
+ quote: 'single',
18
+ trailingComma: true,
19
+ };
20
+
21
+ // All known import names for the deprecated components
22
+ const UNSTABLE_PAGINATION_NAMES = new Set([
23
+ 'unstable_Pagination',
24
+ 'preview_Pagination',
25
+ ]);
26
+
27
+ const UNSTABLE_PAGE_SELECTOR_NAMES = new Set([
28
+ 'unstable_PageSelector',
29
+ 'preview_PageSelector',
30
+ ]);
31
+
32
+ function transform(fileInfo, api, options) {
33
+ const j = api.jscodeshift;
34
+ const root = j(fileInfo.source);
35
+ const printOptions = options.printOptions || defaultOptions;
36
+
37
+ // Collect the local names for the deprecated components from @carbon/react imports
38
+ let paginationLocalName = null; // local JSX name, e.g. "Pagination"
39
+ let paginationLocalAlias = null; // stable replacement name, e.g. "Pagination"
40
+
41
+ const carbonImports = root.find(j.ImportDeclaration, {
42
+ source: { value: '@carbon/react' },
43
+ });
44
+
45
+ if (!carbonImports.length) {
46
+ return null;
47
+ }
48
+
49
+ carbonImports.forEach((path) => {
50
+ path.node.specifiers.forEach((spec) => {
51
+ if (spec.type !== 'ImportSpecifier') return;
52
+ const importedName = spec.imported.name;
53
+ if (UNSTABLE_PAGINATION_NAMES.has(importedName) && !paginationLocalName) {
54
+ paginationLocalName = spec.local.name;
55
+ paginationLocalAlias =
56
+ paginationLocalName === importedName
57
+ ? 'Pagination'
58
+ : paginationLocalName;
59
+ }
60
+ });
61
+ });
62
+
63
+ if (!paginationLocalName) {
64
+ return null; // nothing to transform
65
+ }
66
+
67
+ // Rewrite import specifiers — swap unstable/preview for stable Pagination,
68
+ // drop PageSelector (no longer needed)
69
+ carbonImports.forEach((path) => {
70
+ const kept = [];
71
+ path.node.specifiers.forEach((spec) => {
72
+ if (spec.type !== 'ImportSpecifier') {
73
+ kept.push(spec);
74
+ return;
75
+ }
76
+ const importedName = spec.imported.name;
77
+
78
+ if (UNSTABLE_PAGINATION_NAMES.has(importedName)) {
79
+ // Replace with stable `Pagination`.
80
+ // Only emit `as localName` when the user chose a different local alias.
81
+ const localName = paginationLocalAlias;
82
+ const newSpec =
83
+ localName === 'Pagination'
84
+ ? j.importSpecifier(j.identifier('Pagination'))
85
+ : j.importSpecifier(
86
+ j.identifier('Pagination'),
87
+ j.identifier(localName)
88
+ );
89
+ kept.push(newSpec);
90
+ return;
91
+ }
92
+
93
+ if (UNSTABLE_PAGE_SELECTOR_NAMES.has(importedName)) {
94
+ // Drop — no longer needed once the children block is removed
95
+ return;
96
+ }
97
+
98
+ kept.push(spec);
99
+ });
100
+ path.node.specifiers = kept;
101
+ });
102
+
103
+ // Sort alphabetically for consistency
104
+ carbonImports
105
+ .get(0)
106
+ .node.specifiers.sort((a, b) =>
107
+ (a.imported?.name ?? '').localeCompare(b.imported?.name ?? '')
108
+ );
109
+
110
+ // Rename JSX elements to use the stable Pagination name
111
+ root
112
+ .find(j.JSXOpeningElement, { name: { name: paginationLocalName } })
113
+ .forEach((path) => {
114
+ path.node.name = j.jsxIdentifier(paginationLocalAlias);
115
+ });
116
+ root
117
+ .find(j.JSXClosingElement, { name: { name: paginationLocalName } })
118
+ .forEach((path) => {
119
+ path.node.name = j.jsxIdentifier(paginationLocalAlias);
120
+ });
121
+
122
+ // Drop any children and make the element self-closing, adding a TODO comment
123
+ // so the user knows to migrate manually using the renderPageSelect prop
124
+ root
125
+ .find(j.JSXElement, {
126
+ openingElement: { name: { name: paginationLocalAlias } },
127
+ })
128
+ .forEach((path) => {
129
+ const element = path.node;
130
+
131
+ // Filter out whitespace-only JSX text children
132
+ const meaningfulChildren = element.children.filter(
133
+ (child) => !(child.type === 'JSXText' && child.value.trim() === '')
134
+ );
135
+
136
+ if (meaningfulChildren.length === 0) return;
137
+
138
+ // Drop children, make self-closing, and attach a TODO comment so the
139
+ // user knows to migrate manually using the renderPageSelect prop
140
+ element.children = [];
141
+ element.openingElement.selfClosing = true;
142
+ element.closingElement = null;
143
+
144
+ const todoComment = j.line(
145
+ ' TODO: manually migrate children to the renderPageSelect prop if necessary.'
146
+ );
147
+ path.node.comments = path.node.comments || [];
148
+ todoComment.leading = true;
149
+ todoComment.trailing = false;
150
+ path.node.comments.push(todoComment);
151
+ });
152
+
153
+ return root.toSource(printOptions);
154
+ }
155
+
156
+ module.exports = transform;
157
+ module.exports.parser = 'tsx';