2024-09-02 15:54:40 +01:00
|
|
|
import type { Transform } from 'jscodeshift';
|
|
|
|
|
import { changeImportSpecifier } from '../../utils/change-import';
|
|
|
|
|
import { replaceJSXElement } from '../../utils/replace-jsx';
|
|
|
|
|
|
|
|
|
|
/**
|
2024-09-05 15:13:02 +02:00
|
|
|
* change CheckPagePermissions import from '@strapi/helper-plugin' to Page from '@strapi/strapi/admin'
|
|
|
|
|
* And replace all uses of CheckPagePermissions with Page
|
2024-09-02 15:54:40 +01:00
|
|
|
*/
|
|
|
|
|
const transform: Transform = (file, api) => {
|
|
|
|
|
const { j } = api;
|
|
|
|
|
|
|
|
|
|
const root = j.withParser('tsx')(file.source);
|
|
|
|
|
|
|
|
|
|
replaceJSXElement(root, j, {
|
2024-09-05 15:13:02 +02:00
|
|
|
oldElementName: 'CheckPagePermissions',
|
|
|
|
|
newElementName: 'Page',
|
2024-09-02 15:54:40 +01:00
|
|
|
oldDependency: '@strapi/helper-plugin',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
changeImportSpecifier(root, j, {
|
2024-09-05 15:13:02 +02:00
|
|
|
oldMethodName: 'CheckPagePermissions',
|
|
|
|
|
newMethodName: 'Page',
|
2024-09-02 15:54:40 +01:00
|
|
|
oldDependency: '@strapi/helper-plugin',
|
2024-09-05 15:13:02 +02:00
|
|
|
newDependency: '@strapi/strapi/admin',
|
2024-09-02 15:54:40 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return root.toSource();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default transform;
|