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

feat(codemod): add codemods for fastify v4 #1254

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

arshcodemod
Copy link
Contributor

Added codemods for fastify v4 upgrade :

fastify/4/await-register-calls
fastify/4/expose-head-routes
fastify/4/remove-app-use
fastify/4/reply-raw-access
fastify/4/url-params-optional
fastify/4/wrap-routes-plugin

Copy link

vercel bot commented Aug 19, 2024

@arshcodemod is attempting to deploy a commit to the Codemod Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -0,0 +1,33 @@
This codemod helps to improve error reporting in route definitions, route registration is now synchronous. As a result, if you specify an onRoute hook in a plugin you should now either:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is duplicated

Comment on lines 9 to 36
## Before

```jsx
const fastify = require('fastify')();

fastify.get('/example', (request, reply) => {
reply.send({ message: 'Hello, World!' });
});

fastify.listen(3000, () => {
console.log('Server is running on http://localhost:3000');
});

```

## After

```jsx
const fastify = require('fastify')();

fastify.get('/example', (request, reply) => {
reply.send({ message: 'Hello, World!' });
});
fastify.listen(3000, () => {
console.log('Server is running on http://localhost:3000');
});

```
Copy link
Contributor

Choose a reason for hiding this comment

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

before and after look identical to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is manual change and we might not need a codemod for this. this is not required.

Comment on lines 23 to 29
// Check if the route path matches the pattern '/posts/:id'
if (routePath === "/posts/:id") {
// Update the route path to '/posts/:id?'
firstArg.value = "/posts/:id?";
dirtyFlag = true;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this will work only for this specific url, rest is not handled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is manual change and we might not need a codemod for this. this is not required.

Copy link
Contributor

@mohebifar mohebifar left a comment

Choose a reason for hiding this comment

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

Please include

"private": true

in packages jsons for packages that aren't meant for npm

@@ -0,0 +1,15 @@
{
"name": "@codemod/fastify-4-await-register-calls",
"dependencies": {},
Copy link
Contributor

Choose a reason for hiding this comment

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

"private": true

@@ -0,0 +1,15 @@
{
"name": "@codemod/fastify-4-expose-head-routes",
"dependencies": {},
Copy link
Contributor

Choose a reason for hiding this comment

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

"private": true

"name": "@codemod/fastify-4-migration-recipe",
"files": ["./README.md", "./.codemodrc.json"],
"type": "module"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

"private": true

@@ -0,0 +1,15 @@
{
"name": "@codemod/fastify-4-remove-app-use",
"dependencies": {},
Copy link
Contributor

Choose a reason for hiding this comment

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

"private": true

@@ -0,0 +1,15 @@
{
"name": "@codemod/fastify-4-reply-raw-access",
"dependencies": {},
Copy link
Contributor

Choose a reason for hiding this comment

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

"private": true

@@ -0,0 +1,15 @@
{
"name": "@codemod/fastify-4-url-params-optional",
"dependencies": {},
Copy link
Contributor

Choose a reason for hiding this comment

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

"private": true

@@ -0,0 +1,15 @@
{
"name": "@codemod/fastify-4-wrap-routes-plugin",
"dependencies": {},
Copy link
Contributor

Choose a reason for hiding this comment

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

"private": true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants