@carbon/upgrade 11.32.0 → 11.34.0-rc.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 CHANGED
@@ -44386,7 +44386,7 @@ var upgrades = [
44386
44386
  var package_default = {
44387
44387
  name: "@carbon/upgrade",
44388
44388
  description: "A tool for upgrading Carbon versions",
44389
- version: "11.32.0",
44389
+ version: "11.34.0-rc.0",
44390
44390
  license: "Apache-2.0",
44391
44391
  bin: {
44392
44392
  "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.32.0",
4
+ "version": "11.34.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
7
7
  "carbon-upgrade": "./bin/carbon-upgrade.js"
@@ -60,5 +60,5 @@
60
60
  "@ibm/telemetry-js": "^1.5.0",
61
61
  "jscodeshift": "^17.0.0"
62
62
  },
63
- "gitHead": "7c8548ba752bea350cc1c6a4955b1b5184429015"
63
+ "gitHead": "eae1402aa3c86b644feefc43bd3202915404e924"
64
64
  }
@@ -1,2 +1,2 @@
1
1
  // eslint-disable-next-line no-unused-vars
2
- import { Tearsheet, SearchBar } from '@carbon/ibm-products';
2
+ import { Tearsheet, SearchBar, InlineTip } from '@carbon/ibm-products';
@@ -1,2 +1,5 @@
1
- // eslint-disable-next-line no-unused-vars
2
- import { Tearsheet, previewCandidate__SearchBar } from '@carbon/ibm-products';
1
+ import {
2
+ Tearsheet,
3
+ previewCandidate__SearchBar as SearchBar,
4
+ previewCandidate__InlineTip as InlineTip,
5
+ } from '@carbon/ibm-products';
@@ -1,4 +1,2 @@
1
- // eslint-disable-next-line no-unused-vars
2
- import { unstable__FluidTimePicker } from '@carbon/react';
3
- // eslint-disable-next-line no-unused-vars
1
+ import { unstable__FluidTimePicker as FluidTimePicker } from '@carbon/react';
4
2
  import { Tearsheet, SearchBar } from '@carbon/ibm-products';
@@ -1,4 +1,2 @@
1
- // eslint-disable-next-line no-unused-vars
2
- import { preview__FluidTimePicker } from '@carbon/react';
3
- // eslint-disable-next-line no-unused-vars
4
- import { Tearsheet, previewCandidate__SearchBar } from '@carbon/ibm-products';
1
+ import { preview__FluidTimePicker as FluidTimePicker } from '@carbon/react';
2
+ import { Tearsheet, previewCandidate__SearchBar as SearchBar } from '@carbon/ibm-products';
@@ -1,2 +1,2 @@
1
- // eslint-disable-next-line no-unused-vars
1
+ import { unstable__FluidTimePicker as FluidTimePicker } from '@carbon/react';
2
2
  import { unstable__FluidTimePicker } from '@carbon/react';
@@ -1,2 +1,2 @@
1
- // eslint-disable-next-line no-unused-vars
2
- import { preview__FluidTimePicker } from '@carbon/react';
1
+ import { preview__FluidTimePicker as FluidTimePicker } from '@carbon/react';
2
+ import { preview__FluidTimePicker } from '@carbon/react';
@@ -15,7 +15,7 @@ const { productsPreviewMap } = require('./nonStableMapping');
15
15
  * import { SearchBar, InlineTip } from '@carbon/ibm-products';
16
16
  *
17
17
  * After:
18
- * import { previewCandidate__SearchBar, previewCandidate__InlineTip } from "@carbon/ibm-products";
18
+ * import { previewCandidate__SearchBar as SearchBar, previewCandidate__InlineTip as InlineTip } from "@carbon/ibm-products";
19
19
  */
20
20
 
21
21
  const nonStableComponentKeys = Object.keys(productsPreviewMap);
@@ -29,15 +29,56 @@ function transformer(file, api) {
29
29
  value: '@carbon/ibm-products',
30
30
  },
31
31
  })
32
- .find(j.ImportSpecifier)
33
- .filter(
34
- (path) => !!nonStableComponentKeys.includes(path.node.imported.name)
35
- )
36
- .replaceWith((path) =>
37
- j.importSpecifier(
38
- j.identifier(productsPreviewMap[path.node.imported.name])
39
- )
40
- )
32
+ .forEach((path) => {
33
+ const uniqueSpecifiers = new Set();
34
+ const newSpecifiers = [];
35
+ path.node.specifiers.forEach((specifier) => {
36
+ if (specifier.type === 'ImportSpecifier') {
37
+ nonStableComponentKeys.forEach((c) => {
38
+ const importedName = specifier.imported.name;
39
+ const localName = specifier.local
40
+ ? specifier.local.name
41
+ : importedName;
42
+ let transformedImportedName = importedName;
43
+ if (importedName === c) {
44
+ transformedImportedName = productsPreviewMap[c];
45
+ specifier.imported.name = transformedImportedName;
46
+ // Build new import specifier so that
47
+ // products components changing exports
48
+ // are aliased to their original name.
49
+ // This will help to avoid additional changes
50
+ // within jsx.
51
+ const importSpecifier = j.importSpecifier(
52
+ j.identifier(transformedImportedName),
53
+ // Use the already specified alias if there is one
54
+ j.identifier(localName)
55
+ );
56
+ j(path).replaceWith(
57
+ j.importDeclaration(
58
+ [...path.node.specifiers, importSpecifier],
59
+ path.node.source
60
+ )
61
+ );
62
+
63
+ if (specifier.type === 'ImportSpecifier') {
64
+ if (!uniqueSpecifiers.has(importedName)) {
65
+ uniqueSpecifiers.add(importedName);
66
+ newSpecifiers.push(importSpecifier);
67
+ }
68
+ } else {
69
+ newSpecifiers.push(specifier);
70
+ }
71
+ }
72
+ });
73
+ // Replace the original specifiers with the new aliased ones
74
+ // to prevent further changes needed in jsx for products components
75
+ const others = path.node.specifiers.filter(
76
+ (c) => !Object.values(productsPreviewMap).includes(c.imported.name)
77
+ );
78
+ path.node.specifiers = [...others, ...newSpecifiers];
79
+ }
80
+ });
81
+ })
41
82
  .toSource();
42
83
  }
43
84
 
@@ -6,13 +6,61 @@
6
6
  */
7
7
 
8
8
  exports.reactPreviewMap = {
9
+ unstable_FeatureFlags: 'preview_FeatureFlags',
10
+ unstable_useFeatureFlag: 'preview_useFeatureFlag',
11
+ unstable_useFeatureFlags: 'preview_useFeatureFlags',
12
+ unstable__PageHeader: 'preview__PageHeader',
13
+ unstable__FluidComboBox: 'preview__FluidComboBox',
14
+ unstable__FluidComboBoxSkeleton: 'preview__FluidComboBoxSkeleton',
15
+ unstable__FluidDatePicker: 'preview__FluidDatePicker',
16
+ unstable__FluidDatePickerSkeleton: 'preview__FluidDatePickerSkeleton',
17
+ unstable__FluidDatePickerInput: 'preview__FluidDatePickerInput',
18
+ unstable__FluidDropdown: 'preview__FluidDropdown',
19
+ unstable__FluidDropdownSkeleton: 'preview__FluidDropdownSkeleton',
20
+ unstable__FluidMultiSelect: 'preview__FluidMultiSelect',
21
+ unstable__FluidMultiSelectSkeleton: 'preview__FluidMultiSelectSkeleton',
22
+ unstable__FluidSelect: 'preview__FluidSelect',
23
+ unstable__FluidSelectSkeleton: 'preview__FluidSelectSkeleton',
24
+ unstable__FluidSearch: 'preview__FluidSearch',
25
+ unstable__FluidSearchSkeleton: 'preview__FluidSearchSkeleton',
26
+ unstable__FluidTextArea: 'preview__FluidTextArea',
27
+ unstable__FluidTextAreaSkeleton: 'preview__FluidTextAreaSkeleton',
28
+ unstable__FluidTextInput: 'preview__FluidTextInput',
29
+ unstable__FluidTextInputSkeleton: 'preview__FluidTextInputSkeleton',
9
30
  unstable__FluidTimePicker: 'preview__FluidTimePicker',
31
+ unstable__FluidNumberInput: 'preview__FluidNumberInput',
32
+ unstable__FluidNumberInputSkeleton: 'preview__FluidNumberInputSkeleton',
33
+ unstable__FluidTimePickerSkeleton: 'preview__FluidTimePickerSkeleton',
34
+ unstable__FluidTimePickerSelect: 'preview__FluidTimePickerSelect',
35
+ unstable_LayoutDirection: 'preview_LayoutDirection',
36
+ unstable_useLayoutDirection: 'preview_useLayoutDirection',
37
+ unstable_Layout: 'preview_Layout',
38
+ unstable_PageSelector: 'preview_PageSelector',
39
+ unstable_Pagination: 'preview_Pagination',
40
+ unstable__IconIndicator: 'preview__IconIndicator',
41
+ unstable__ShapeIndicator: 'preview__ShapeIndicator',
42
+ unstable__Slug: 'preview__Slug',
43
+ unstable__SlugContent: 'preview__SlugContent',
44
+ unstable__SlugActions: 'preview__SlugActions',
45
+ unstable__ChatButton: 'preview__ChatButton',
46
+ unstable__ChatButtonSkeleton: 'preview__ChatButtonSkeleton',
47
+ unstable__AiSkeletonText: 'preview__AiSkeletonText',
48
+ unstable__AiSkeletonIcon: 'preview__AiSkeletonIcon',
49
+ unstable__AiSkeletonPlaceholder: 'preview__AiSkeletonPlaceholder',
50
+ unstable_Text: 'preview_Text',
51
+ unstable_TextDirection: 'preview_TextDirection',
10
52
  };
11
53
 
12
54
  exports.productsPreviewMap = {
13
55
  BigNumber: 'previewCandidate__BigNumber',
14
56
  BigNumbers: 'previewCandidate__BigNumber',
15
57
  Coachmark: 'previewCandidate__Coachmark',
58
+ CoachmarkBeacon: 'previewCandidate__CoachmarkBeacon',
59
+ CoachmarkButton: 'previewCandidate__CoachmarkButton',
60
+ CoachmarkFixed: 'previewCandidate__CoachmarkFixed',
61
+ CoachmarkOverlayElement: 'previewCandidate__CoachmarkOverlayElement',
62
+ CoachmarkOverlayElements: 'previewCandidate__CoachmarkOverlayElements',
63
+ CoachmarkStack: 'previewCandidate__CoachmarkStack',
16
64
  ConditionBuilder: 'previewCandidate__ConditionBuilder',
17
65
  DataSpreadsheet: 'previewCandidate__DataSpreadsheet',
18
66
  Decorator: 'previewCandidate__Decorator',
@@ -17,7 +17,7 @@ const { reactPreviewMap, productsPreviewMap } = require('./nonStableMapping');
17
17
  *
18
18
  * After:
19
19
  * import { preview__FluidTimePicker } from "@carbon/react";
20
- * import { previewCandidate__SearchBar } from '@carbon/ibm-products';
20
+ * import { previewCandidate__SearchBar as SearchBar } from '@carbon/ibm-products';
21
21
  */
22
22
 
23
23
  const allPreviews = { ...reactPreviewMap, ...productsPreviewMap };
@@ -36,11 +36,60 @@ function transformer(file, api) {
36
36
  value: p,
37
37
  },
38
38
  })
39
- .find(j.ImportSpecifier)
40
- .filter((path) => !!nonStableKeys.includes(path.node.imported.name))
41
- .replaceWith((path) =>
42
- j.importSpecifier(j.identifier(allPreviews[path.node.imported.name]))
43
- );
39
+ .forEach((path) => {
40
+ const uniqueSpecifiers = new Set();
41
+ const newSpecifiers = [];
42
+ path.node.specifiers.forEach((specifier) => {
43
+ if (specifier.type === 'ImportSpecifier') {
44
+ nonStableKeys.forEach((c) => {
45
+ const importedName = specifier.imported.name;
46
+ const localName = specifier.local
47
+ ? specifier.local.name
48
+ : importedName;
49
+ let transformedImportedName = importedName;
50
+ if (importedName === c) {
51
+ transformedImportedName = allPreviews[c];
52
+ specifier.imported.name = transformedImportedName;
53
+ if (p === '@carbon/ibm-products') {
54
+ // Build new import specifier so that
55
+ // products components changing exports
56
+ // are aliased to their original name.
57
+ // This will help to avoid additional changes
58
+ // within jsx.
59
+ const importSpecifier = j.importSpecifier(
60
+ j.identifier(transformedImportedName),
61
+ // Use the already specified alias if there is one
62
+ j.identifier(localName)
63
+ );
64
+ j(path).replaceWith(
65
+ j.importDeclaration(
66
+ [...path.node.specifiers, importSpecifier],
67
+ path.node.source
68
+ )
69
+ );
70
+ if (specifier.type === 'ImportSpecifier') {
71
+ if (!uniqueSpecifiers.has(importedName)) {
72
+ uniqueSpecifiers.add(importedName);
73
+ newSpecifiers.push(importSpecifier);
74
+ }
75
+ } else {
76
+ newSpecifiers.push(specifier);
77
+ }
78
+ }
79
+ }
80
+ });
81
+ // Replace the original specifiers with the new aliased ones
82
+ // to prevent further changes needed in jsx for products components
83
+ if (p === '@carbon/ibm-products') {
84
+ const others = path.node.specifiers.filter(
85
+ (c) =>
86
+ !Object.values(productsPreviewMap).includes(c.imported.name)
87
+ );
88
+ path.node.specifiers = [...others, ...newSpecifiers];
89
+ }
90
+ }
91
+ });
92
+ });
44
93
  });
45
94
  return root.toSource();
46
95
  }
@@ -12,9 +12,13 @@ const { reactPreviewMap } = require('./nonStableMapping');
12
12
  *
13
13
  * @example
14
14
  * Before:
15
+ * import { unstable__FluidTimePicker as FluidTimePicker } from '@carbon/react';
16
+ * or
15
17
  * import { unstable__FluidTimePicker } from '@carbon/react';
16
18
  *
17
19
  * After:
20
+ * import { preview__FluidTimePicker as FluidTimePicker } from "@carbon/react";
21
+ * or
18
22
  * import { preview__FluidTimePicker } from "@carbon/react";
19
23
  */
20
24
 
@@ -29,13 +33,20 @@ function transformer(file, api) {
29
33
  value: '@carbon/react',
30
34
  },
31
35
  })
32
- .find(j.ImportSpecifier)
33
- .filter(
34
- (path) => !!nonStableComponentKeys.includes(path.node.imported.name)
35
- )
36
- .replaceWith((path) =>
37
- j.importSpecifier(j.identifier(reactPreviewMap[path.node.imported.name]))
38
- )
36
+ .forEach((path) => {
37
+ path.node.specifiers.forEach((specifier) => {
38
+ if (specifier.type === 'ImportSpecifier') {
39
+ nonStableComponentKeys.forEach((c) => {
40
+ let importedName = specifier.imported.name;
41
+ let transformedImportedName = importedName;
42
+ if (importedName === c) {
43
+ transformedImportedName = reactPreviewMap[c];
44
+ specifier.imported.name = transformedImportedName;
45
+ }
46
+ });
47
+ }
48
+ });
49
+ })
39
50
  .toSource();
40
51
  }
41
52