Skip to content

Conversation

@ishaqibrahimbot
Copy link

Played around with the evcodeshift api and succeeded in creating a very minimal transformer. Next steps include making this more robust and complete, figuring out the proper file structure, adding the edit option to the cli, and writing tests.

ElonVolo and others added 30 commits October 14, 2021 09:06
Previously, arg parser would display the arguments in the help section in alphabetical order. Since we're now moving in the direction of grouping arguments by functionality independent of names (like for upcoming --gitignore flag), we now have to come up with a quick refactoring that allows arguments to be displayed in a specified order regardless of what alphabetical order the arguments themselves occupy.
Remove dependency on argument name alphabetical order
Adding js usage to the README using `Runner.run`
One of the code blocks was using tabs instead of spaces, which was inconsistent with the rest of the README.
Tabs to spaces in code examples for consistency
Majorly bumping version

Bumping changelog. Again.

alsdkfj

alsdkfj
Due to the lack of maintenance on the upstream recast library, evcodeshift is switching to @coderaiser's excellently maintained @putout/recast fork. logitall unit tests were breaking due to a recast bug, and @putout/recast fixes it.
…tput

Adding ability to save actual test output
Changed name of executable in README that was causing debugging not to work.
Fixing typo
Grammar corrections.
@ishaqibrahimbot ishaqibrahimbot changed the title add very basic transformer for editing property value Add a "splice into" feature for Javascript/Typescript May 23, 2023
@ishaqibrahimbot
Copy link
Author

Hey @ElonVolo! I've made some good progress. There is now an --edit option for the cli runner that can directly edit properties inside objects.

To see it in action, follow these steps:

  • checkout the code in this PR
  • install the package globally by running npm install -g . in the root
  • Run the following command to do the edit:
evcodeshift --edit path-to-config.js-file --propertyName="propertyValue"

Note that propertyValue above expects a JSON-stringified value at the moment. That means you can pass literals such as strings/numbers/booleans as well as arrays and objects.

Next up, I'll be adding some test cases to cover this functionality before wrapping up the PR.

Let me know your thoughts and feedback!

@ishaqibrahimbot
Copy link
Author

ishaqibrahimbot commented May 28, 2023

Update: Have added 3 test cases under an 'edit' describe block in the cli tests file. Covered these scenarios:

  • replacing string
  • replacing array
  • replacing object

This PR is now ready to be reviewed.

@ishaqibrahimbot ishaqibrahimbot marked this pull request as ready for review May 28, 2023 18:53
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.

5 participants