Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: add support for codemods command to run on plugins #19817

Merged
merged 16 commits into from Mar 19, 2024

Conversation

innerdvations
Copy link
Contributor

@innerdvations innerdvations commented Mar 18, 2024

What does it do?

Allows the codemods argument to run on plugins instead of only strapi projects

Why is it needed?

To help plugin writers migrate their plugins to Strapi 5

How to test it?

  • run the upgrade tool codemods command against a plugin; it should work
  • run it with upgrade and it should still require being in a Strapi project
  • run the above against a strapi project; it should still work

Related issue(s)/PR(s)

Let us know if this is related to any issue/pull request

@innerdvations innerdvations added pr: enhancement This PR adds or updates some part of the codebase or features source: utils:upgrade Source is utils/upgrade labels Mar 18, 2024
@innerdvations innerdvations self-assigned this Mar 18, 2024
Copy link

vercel bot commented Mar 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ❌ Failed (Inspect) Mar 19, 2024 2:15pm

@innerdvations innerdvations marked this pull request as ready for review March 18, 2024 14:00
innerdvations and others added 3 commits March 18, 2024 15:23
Co-authored-by: Jean-Sébastien Herbaux <jean-sebastien.herbaux@epitech.eu>
…ry.ts

Co-authored-by: Jean-Sébastien Herbaux <jean-sebastien.herbaux@epitech.eu>
Co-authored-by: Jean-Sébastien Herbaux <jean-sebastien.herbaux@epitech.eu>
} from './types';

export class Project implements ProjectInterface {
export class Project implements IProjectBase {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to find where we had this discussion (I think it's internal).
But let's keep our distance from the C# interface notation to stay consistent with the rest of the codebase (well, except DTS, but we'll need to worry about that later)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the problem is it interferes with the class imports of the same name. Do we have guidelines on that? I think we shouldn't be using classes at all, but I didn't want to refactor the entire thing for this little feature.

@@ -9,7 +9,7 @@ import * as f from '../../modules/format';
import { Version } from '../../modules/version';

import type { UpgradeOptions } from './types';
import { PluginProject } from '../../modules/project/project';
import { isPluginProject } from '../../modules/project/project';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import order? I'm surprised eslint didn't complain about that 🤔

Also, you can shorten the import by removing the last /project

@@ -21,6 +21,33 @@ import type {
IProjectBase,
} from './types';

export const isPluginProject = (project: unknown): project is IPluginProject => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about having a utils export within project to separate the class/main business logic from the utilities that lives outside?

The project exports in the utils/upgrade module have been restructured. Now, the classes 'Project', 'AppProject', and 'PluginProject' are exported as types.
Simplified the exports in the project module in utils/upgrade module. Instead of exporting each util individually, all the utils under './utils' are now being exported together.
Simplified `isPluginProject`, `assertPluginProject`, `isAppProject`, and `assertAppProject` functions by removing unnecessary conditions. The refactoring allows the functions to focus solely on type verification, reducing the complexity and improving the readability of the code.
Copy link
Member

@Bassel17 Bassel17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QAed, seems to be working well

@innerdvations innerdvations merged commit 6b73e9c into v5/main Mar 19, 2024
79 of 84 checks passed
@innerdvations innerdvations deleted the upgrade-tool/add-support-for-plugins branch March 19, 2024 15:50
@echoes-hq echoes-hq bot added the echoes/type: feature/enhancement For enhancements to existing functionality and tools label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes/type: feature/enhancement For enhancements to existing functionality and tools pr: enhancement This PR adds or updates some part of the codebase or features source: utils:upgrade Source is utils/upgrade version: 5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants