mirror of
https://github.com/strapi/strapi.git
synced 2025-07-09 18:13:00 +00:00

* feat: upgrade tool refactor for updated specs (v5) * chore: format code (prettier) * chore: remove debug comments * feat: upgrade the strapi dependencies in project's package.json * feat: install dependencies during the upgrade process * chore: fix lint issue * chore: rephrase requirement sentence's sentiment * feat: add a --yes option for the upgrade CLI * enh: make properties readonly to avoid mutations * chore: adding better logs to the upgrade CLI * chore: remove unused import * feat: add minor and patch commands * fix: use major and minor instead of premajor and preminor * fix: re-add type casting * fix: make major requirements required * chore: revert sentiment update on GIT_CLEAN requirement * fix: make promisify working by mocking the entire file-system * fix: yarn.lock update * feat: Select and run codemods only (#19083) * chore: add unit tests for upgrader tasks * fix: rename tests * chore: Update packages/utils/upgrade/src/tasks/__tests__/upgrade.test.ts * chore: Add unit tests for upgrade tool (#19056) * chore: move example codemods (#19156) * chore: fix yarn.lock * fix: sync glob versions * chore: add comment * chore: update docs --------- Co-authored-by: Convly <jean-sebastien.herbaux@epitech.eu> Co-authored-by: Bassel Kanso <basselkanso82@gmail.com> Co-authored-by: Christian <christian.capeans.perez@strapi.io> Co-authored-by: Christian Capeans <christiancp100@gmail.com>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import type { Transform } from 'jscodeshift';
|
|
|
|
/**
|
|
* Note: This codemod is only for development purposes and should be deleted before releasing
|
|
*/
|
|
|
|
const transform: Transform = (file, api) => {
|
|
// Extract the jscodeshift API
|
|
const { j } = api;
|
|
// Parse the file content
|
|
const root = j(file.source);
|
|
|
|
root
|
|
// Find console.log calls expressions
|
|
.find(j.CallExpression, {
|
|
callee: { object: { name: 'console' }, property: { name: 'log' } },
|
|
})
|
|
// For each call expression
|
|
.forEach((path) => {
|
|
const { callee } = path.node;
|
|
|
|
if (
|
|
// Make sure the callee is a member expression (object/property)
|
|
j.MemberExpression.check(callee) &&
|
|
// Make sure the property is an actual identifier (contains a name property)
|
|
j.Identifier.check(callee.property)
|
|
) {
|
|
// Update the property's identifier name
|
|
callee.property.name = 'info';
|
|
}
|
|
});
|
|
|
|
// Return the updated file content
|
|
return root.toSource();
|
|
};
|
|
|
|
export default transform;
|