mirror of
https://github.com/strapi/strapi.git
synced 2025-09-14 11:08:35 +00:00

* feat: add codemode for useRBAC import statement * fix: add admin and server as allowed root paths * fix: preserve aliases and add import statetment after other import statements * feat: change useAPIErrorHandler import to `@strapi/strapi/admin` codemod (#21025) * enhancement: abstract changeImportSpecifier as a utility method * fix: account for multiple aliases
22 lines
532 B
TypeScript
22 lines
532 B
TypeScript
import type { Transform } from 'jscodeshift';
|
|
import { changeImportSpecifier } from '../../utils/change-import';
|
|
|
|
/**
|
|
* change useRBAC import from '@strapi/helper-plugin' to '@strapi/strapi/admin'
|
|
*/
|
|
const transform: Transform = (file, api) => {
|
|
const { j } = api;
|
|
|
|
const root = j.withParser('tsx')(file.source);
|
|
|
|
changeImportSpecifier(root, j, {
|
|
methodName: 'useRBAC',
|
|
oldDependency: '@strapi/helper-plugin',
|
|
newDependency: '@strapi/strapi/admin',
|
|
});
|
|
|
|
return root.toSource();
|
|
};
|
|
|
|
export default transform;
|