mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
chore: add a codemod to remove the @strapi/plugin-i18n dep from package.json
This commit is contained in:
parent
dc749a48e4
commit
1a677831d2
31
packages/utils/upgrade/resources/codemods/5.0.0/dependency-remove-strapi-plugin-i18n.json.ts
vendored
Normal file
31
packages/utils/upgrade/resources/codemods/5.0.0/dependency-remove-strapi-plugin-i18n.json.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import path from 'node:path';
|
||||
|
||||
import type { modules } from '../../../dist';
|
||||
|
||||
const STRAPI_I18N_DEP_NAME = '@strapi/plugin-i18n';
|
||||
const STRAPI_I18N_DEP_PATH = `dependencies.${STRAPI_I18N_DEP_NAME}`;
|
||||
|
||||
/**
|
||||
* Specifically targets the root package.json and removes the @strapi/plugin-i18n dependency.
|
||||
*
|
||||
* Why? The i18n plugin is now a hard dependency of @strapi/strapi and isn't needed in the package.json anymore.
|
||||
*/
|
||||
const transform: modules.runner.json.JSONTransform = (file, params) => {
|
||||
const { cwd, json } = params;
|
||||
|
||||
const rootPackageJsonPath = path.join(cwd, 'package.json');
|
||||
|
||||
if (file.path !== rootPackageJsonPath) {
|
||||
return file.json;
|
||||
}
|
||||
|
||||
const j = json(file.json);
|
||||
|
||||
if (j.has(STRAPI_I18N_DEP_PATH)) {
|
||||
j.remove(STRAPI_I18N_DEP_PATH);
|
||||
}
|
||||
|
||||
return j.root();
|
||||
};
|
||||
|
||||
export default transform;
|
||||
Loading…
x
Reference in New Issue
Block a user