Skip to content

Commit b33d0ba

Browse files
matthewgalloGururajj77tay1orjones
authored
feat(codemod): add preview import codemods for products, core, combined (#20253)
* feat(codemod): add codemod for ibm-product pdlc export changes * chore(codemod): format * fix(codemod): update fixtures * chore(codemod): update naming Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com> * fix(codemod): remove page header to avoid clashes b/w two versions * feat(codemod): add core codemod and combined version * refactor(codemod): update combined codemod * refactor(codemod): update combined codemod * fix(codemod): cjs changes * chore(codemod): update naming to be more clear --------- Co-authored-by: Gururaj J <89023023+Gururajj77@users.noreply.github.com> Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com>
1 parent 8052552 commit b33d0ba

14 files changed

+311
-0
lines changed

packages/upgrade/src/upgrades.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,97 @@ export const upgrades = [
664664
});
665665
},
666666
},
667+
{
668+
name: 'rename-ibm-products-imports-to-preview',
669+
description: 'Update imports after PDLC status integration',
670+
migrate: async (options) => {
671+
const transform = path.join(
672+
TRANSFORM_DIR,
673+
'ibm-products-update-pdlc-status.js'
674+
);
675+
const paths =
676+
Array.isArray(options.paths) && options.paths.length > 0
677+
? options.paths
678+
: await glob(['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'], {
679+
cwd: options.workspaceDir,
680+
ignore: [
681+
'**/es/**',
682+
'**/lib/**',
683+
'**/umd/**',
684+
'**/node_modules/**',
685+
'**/storybook-static/**',
686+
],
687+
});
688+
689+
await run({
690+
dry: !options.write,
691+
transform,
692+
paths,
693+
verbose: options.verbose,
694+
});
695+
},
696+
},
697+
{
698+
name: 'rename-carbon-imports-to-preview',
699+
description: 'Update imports after PDLC status integration',
700+
migrate: async (options) => {
701+
const transform = path.join(
702+
TRANSFORM_DIR,
703+
'rename-imports-to-preview.js'
704+
);
705+
const paths =
706+
Array.isArray(options.paths) && options.paths.length > 0
707+
? options.paths
708+
: await glob(['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'], {
709+
cwd: options.workspaceDir,
710+
ignore: [
711+
'**/es/**',
712+
'**/lib/**',
713+
'**/umd/**',
714+
'**/node_modules/**',
715+
'**/storybook-static/**',
716+
],
717+
});
718+
719+
await run({
720+
dry: !options.write,
721+
transform,
722+
paths,
723+
verbose: options.verbose,
724+
});
725+
},
726+
},
727+
{
728+
name: 'rename-imports-to-preview',
729+
description:
730+
'Update imports after PDLC status integration both `@carbon/react` and `@carbon/ibm-products`, this assumes both packages are upgraded together to adopt the preview export naming',
731+
migrate: async (options) => {
732+
const transform = path.join(
733+
TRANSFORM_DIR,
734+
'rename-imports-to-preview-core-and-products.js'
735+
);
736+
const paths =
737+
Array.isArray(options.paths) && options.paths.length > 0
738+
? options.paths
739+
: await glob(['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'], {
740+
cwd: options.workspaceDir,
741+
ignore: [
742+
'**/es/**',
743+
'**/lib/**',
744+
'**/umd/**',
745+
'**/node_modules/**',
746+
'**/storybook-static/**',
747+
],
748+
});
749+
750+
await run({
751+
dry: !options.write,
752+
transform,
753+
paths,
754+
verbose: options.verbose,
755+
});
756+
},
757+
},
667758
{
668759
name: 'enable-v12-structured-list-visible-icons',
669760
description: `
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line no-unused-vars
2+
import { Tearsheet, SearchBar } from '@carbon/ibm-products';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line no-unused-vars
2+
import { Tearsheet, previewCandidate__SearchBar } from '@carbon/ibm-products';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// eslint-disable-next-line no-unused-vars
2+
import { unstable__FluidTimePicker } from '@carbon/react';
3+
// eslint-disable-next-line no-unused-vars
4+
import { Tearsheet, SearchBar } from '@carbon/ibm-products';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
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';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line no-unused-vars
2+
import { unstable__FluidTimePicker } from '@carbon/react';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line no-unused-vars
2+
import { preview__FluidTimePicker } from '@carbon/react';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright IBM Corp. 2025, 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, 'ibm-products-update-pdlc-status');
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright IBM Corp. 2025, 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, 'rename-imports-to-preview-core-and-products');
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright IBM Corp. 2025, 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, 'rename-imports-to-preview');

0 commit comments

Comments
 (0)