Comments (5)
There's no way to do it from the CLI, and unfortunately @codemod/cli
doesn't expose enough to make it easy to do programmatically either. If I exposed CLIEngine
and ConfigBuilder
you could make a script like so to do what you want:
// This does NOT work with any released version yet.
import { CLIEngine, ConfigBuilder } from '@codemod/cli'
const config = new ConfigBuilder()
.ignore((path: string, basename: string) => {
// return false to ignore any path you want
})
.addSourcePath('./packages')
.addLocalPlugin('my-codemod-package')
.build()
const engine = new CLIEngine(config)
await engine.run()
That's probably not what you really wanted though. So instead, I just made #697 to ignore node_modules
by default. It'll be published soon.
from codemod.
Published in @codemod/cli
v2.2.1.
from codemod.
Awesome, thanks :) That makes sense IMO as I can't really imagine somebody running a codemod against node_modules :)
Prettier, babel all those are ignoring it by default AFAIR so it makes sense :)
About a programmatic use case that would be also pretty helpful. Especially for some internal CLI tools for migrations and stuff.
Like you install company-name-cli
and then run company-name-cli codemod migrate-internal-lib-v4-to-v5 --dir ./my-app
And inside you build this CLI engine and run codemod against the source dir given.
Sounds redundant :) But on a big scale, you want it to be as easy as possible to make people actually using it :)
from codemod.
Do you have a specific example of how you'd use it? I'm happy to expose an API to make it easier.
from codemod.
Exactly how you wrote above.
I'm developing a company wide CLI that has a lot of stuff in it, like scaffolding of libraries, apps, microfrontends and potentially other handy tools for maintaining, migration and refactorings.
And for now if we run codemod it requires few steps, installing of at least 2 dependencies, a plugin and a CLI and then running this cli with some particular flags like prettier etc. It's a simple task, but for many even reading 4-5 steps README is too much. So in order to simplify all that having it all abstracted away into a tool, like create-react-app that will install all the recommended codemods under the hood, proactively will ask what codemod person wants, then dir and all is done, will be the best thing.
So as an example.
cli codemod
Select codemod you want to apply:
fix-this
migrate-that
rename-that
Please provide a directory with the source files:./src
Working... ⚒
//Output of codemod is here
It's all in interactive shell like Yeoman or similar.
All defaults, like formatter, what's the plugin, or what's the options of the plugin, also can be abstracted away, or a choice can be given if it's not against our standards.
So as you can run babel or prettier, webpack programmatically running codemod the same way would be awesome.
Hope that I explained good enough :) From the phone, so sorry if not too much details.
from codemod.
Related Issues (20)
- The automated release is failing 🚨
- All-or-nothing matches HOT 7
- `and` matches HOT 1
- Difference between codemod-js and jscodeshift HOT 1
- Error: Requires Babel "^7.0.0-beta.41", but was loaded with "7.9.0" HOT 4
- Options are not passed into the plugin HOT 6
- Bug? (babelrc options not work) + Use case (need to pass fn to plugin options) HOT 2
- Suggestion: replace custom file path resolver with globby HOT 5
- Suggestion: use Piscina for faster codemods HOT 1
- ASTExplorer latest revision link does not work with `--remote-plugin` HOT 1
- Debug mode? HOT 1
- [Question] How to create npx compatible codemod runners
- [Question] How to list changed files? HOT 1
- 3.1.0 Breaking Changes? HOT 6
- Adding an onComplete function HOT 1
- .match issues with TypeScript and fromCapture HOT 3
- Decorators cannot be used to decorate parameters. HOT 1
- Run with a custom babel.config.js HOT 1
- combine spacers and matchers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codemod.