feat: temp run.js script to quickly run local codemods#65
Closed
kiprasmel wants to merge 4 commits intohypermod-io:mainfrom
pipedrive:feat/temp-run-utility-to-quickly-run-local-codemods
Closed
feat: temp run.js script to quickly run local codemods#65kiprasmel wants to merge 4 commits intohypermod-io:mainfrom pipedrive:feat/temp-run-utility-to-quickly-run-local-codemods
run.js script to quickly run local codemods#65kiprasmel wants to merge 4 commits intohypermod-io:mainfrom
pipedrive:feat/temp-run-utility-to-quickly-run-local-codemods
Conversation
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
…ter in main cli) Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
kiprasmel
commented
Nov 3, 2021
| return resolveTransformsFromShorthand(shorthands[t]); | ||
| } else { | ||
| const dir = path.dirname(t); | ||
| const cmd = `yarn --cwd ${dir} build`; |
Contributor
Author
There was a problem hiding this comment.
wouldn't need this if we implemented it properly in the actual codeshift-cli because then we could just use ts-node for the source files as well, right?
thought, maybe another use case would be someone also having codemods in .ts in their own repo like thought about in #58, so perhaps we'd need to point ts-node dynamically, and not only to own our source files?
run.js
Outdated
| } | ||
|
|
||
| function resolveTransformsFromShorthand([pathToCodemodPkg, transformVersion]) { | ||
| cp.execSync(`yarn --cwd ${pathToCodemodPkg} build`); |
Contributor
Author
There was a problem hiding this comment.
same here re: building
Comment on lines
+74
to
+77
| const cliPath = path.join(__dirname, './packages/cli/bin/codeshift-cli.js'); | ||
|
|
||
| const cmdToExec = `${cliPath} --parser ${parser} -e ${extensions} -t ${transformsToRun} ${fileOrDirectoryToModify}`; | ||
| console.log({ cmdToExec }); |
Contributor
Author
There was a problem hiding this comment.
as you can see i'm just forwarding stuff to the actual cli 😅
depends on: https://github.com/pipedrive/CodeshiftCommunity/pull/5 Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
554c39c to
ad71e7b
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
see how to test:
https://github.com/pipedrive/CodeshiftCommunity/pull/3
depends on: #63, but in our fork we have it already included in the PR so if you're following the above instructions it's already included.
note - this script kinda hacky, and I'm creating this here not to merge but to show the use-case. (that's why marked as draft).
this also showcases why i needed #64.
ideally this functionaly / ease-of-use would end-up in the
codeshift-cliitself. perhaps after #58 is done to avoid conflicts:Dthought not sure about the
shorthands.json- kinda hides what's actually going on, and i think making the consumer more aware would actually be a benefit.another note - didn't test this w/ existing "reduced" codemods - would likely need to update a few places where logic w/ paths / file structure exists.
also depends on: #66