Skip to content

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

Closed
wants to merge 4 commits into from
Closed

feat: temp run.js script to quickly run local codemods #65

wants to merge 4 commits into from

Conversation

kiprasmel
Copy link
Contributor

@kiprasmel kiprasmel commented Nov 3, 2021

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:D

thought 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

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`;
Copy link
Contributor Author

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`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 });
Copy link
Contributor Author

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>
@danieldelcore danieldelcore force-pushed the main branch 3 times, most recently from 554c39c to ad71e7b Compare April 18, 2022 09:40
@pipedrive pipedrive closed this by deleting the head repository Apr 16, 2024
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.

2 participants