-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Allow migrating legacy services to services/ affects [continuousphp shippable] #1931
Conversation
Generated by 🚫 dangerJS |
|
||
// registerFn: ({ camp, cache }) => { camp.route(/.../, cache(...)) } | ||
class LegacyService extends BaseService { | ||
static registerLegacyRouteHandler({ camp, cache }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By making this a dictionary, we can easily inject more collaborators from server.js
via register()
, if that turns out to be necessary.
I haven't found that so much, but if it can be done quickly I can definitely see advantages to getting the bulk of legacy code (or at least the stuff that has tests) into a more consistent structure like this:
Where do you see this fitting in to the wider refactoring process? The code itself is good - just wondering more about..the plan for using it :) |
Sounds like we've had slightly different experiences, though both think there are good reasons to move forward with this.
I'm thinking we can empty Migrating the badge examples manually would be a bear, and error prone. I'm guessing we should at least partially automate that process, like I did when originally built that file in #1163. I think moving the services should come first anyway; it's less risky to move the legacy services while the examples are staying the same. |
This builds on the work of #1931 by moving the legacy services into `services/`.
all-badge-examples is a common cause of merge conflicts. It’s difficult to adjust the badge categorization in that file – or to understand the diff – because it requires moving a block from one point to another. It’s much easier to edit a badge’s category in one place. This starts the process of breaking up what’s left of that file, following up on the work from #1931.
all-badge-examples is a common cause of merge conflicts. It’s difficult to adjust the badge categorization in that file – or to understand the diff – because it requires moving a block from one point to another. It’s much easier to edit a badge’s category in one place. This starts the process of breaking up what’s left of that file, following up on the work from #1931. New-style services can only be in one category, which means legacy service examples have to be split along category lines. I split out separate legacy service classes where I could do so easily, leaving behind the ones which require more work, for one reason or another.
This change would allow us to break up both
server.js
andall-badge-examples.json
. After rewriting a few of these, I'm convinced the rewriting process would be more pleasant and less error-prone if we break it up into pieces. Porting the badge examples is particularly error prone, since the way they're specified is changing. I think it will be more efficient, and more correct, to port whole categories at once rather than one service at a time. When rewriting a service, I use the old implementation as a reference, and having it on hand in the service folder will make that easier. It'll also let us harmonize the code style; we've been putting off updatingserver.js
. Finally, we'll get more helpful production stack traces which have the service name in them, rather than a server.js line number which is only valid for the specific commit, and thus time consuming to track down.We seem very close to accepting new services as new-style services, though if we end up taking a couple in this form, it wouldn't be the end of the world.
If folks are cool with this approach, I'll update the developer docs.
Here's the process for moving a service over:
Paste in the service code from
server.js
and add two closing braces.Run prettier and
npm run lint -- --fix
.Add any additional helper imports that may be needed.
I have included one example with the examples migrated, and one without them migrated, to show that both setups are possible. I'd suggest we move over the badge implementations first, and then take a second pass through with the examples. If we move all the implementations at once, it will be really easy to dig past the single commit in
server.js
to see the blame info for each implementation.Todo post merge: