-
Notifications
You must be signed in to change notification settings - Fork 38
Add transform docs in the readme #11
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
Open
ssutar
wants to merge
1
commit into
ember-codemods:main
Choose a base branch
from
ssutar:readme_update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not sure we should be tiering based on type of object, but instead based on features required for a given class to be transformed. Any one of these classes could require decorators, mixins, or class fields, so it's not enough to delineate by class type.
Additionally, it'll be hard to figure out what category subclasses belong to, and this strategy could result in half transformed files where one class is transpiled, but the other isn't.
I think instead we should add support for globbing, where users can define a folder or pattern that they want to apply the transforms to. This means that we always transform a whole file, no matter how many classes are part of it, but it also allows us to transform roughly by category (e.g. to transform all Routes, you would pass
--include "routes/**/*"
).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.
The
jscodeshift
has support for glob. As per the issue here: facebook/jscodeshift#215 it relies on the shell to expand the glob. So I don't think any thing is needed from the codemods to support that, since the files passed totransform
function will already be matched against the path (or pattern) passed.I like the idea of transforming by types, but as you mentioned it might be difficult or we might be in a state where part the file can be transformed and rest can not.
The current state of codemods is designed with command line options:
--decorators=true
)--mixins=true
)--mixins=true
and--decorators=true
)To support types - my initial approach would be to add additional parameter
--type=Controller|Route|Service|..
Using this parameter we can add different transform, for exampleroute-transforms
would have--type=route
set by default. I haven't fully explored this approach yet, but I see there might be some cases where it is difficult to identify the type of the object.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.
Added #12, it matches the path to resolve the type.