-
-
Notifications
You must be signed in to change notification settings - Fork 19
feat: temp run.js
script to quickly run local codemods
#65
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: temp run.js
script to quickly run local codemods
#65
Conversation
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
…ter in main cli) Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
return resolveTransformsFromShorthand(shorthands[t]); | ||
} else { | ||
const dir = path.dirname(t); | ||
const cmd = `yarn --cwd ${dir} build`; |
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.
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`); |
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.
same here re: building
const cliPath = path.join(__dirname, './packages/cli/bin/codeshift-cli.js'); | ||
|
||
const cmdToExec = `${cliPath} --parser ${parser} -e ${extensions} -t ${transformsToRun} ${fileOrDirectoryToModify}`; | ||
console.log({ cmdToExec }); |
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.
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
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-cli
itself. 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