comby-wrapper

2.1.0 • Public • Published

Comby Wrapper

Wrapper around Comby. Comby is a tool for searching and changing code structure

Quckstart

  1. Install Comby Server
git clone https://github.com/obenjiro/comby-server.git
cd comby-server
docker-compose up
  1. Install comby-wrapper and rambdax
npm i comby-wrapper, rambdax
  1. Create script file (script.js) and import comby-wrapper and install functional helper lib (I recommend you to use rambdax)
const CW = require('comby-wrapper');
const R = require('rambdax');
  1. Write other code for the script file (script.js)
async function main() {
    const files = await CW.getFiles(["./react_app/**/*.js"], {
        ignore: ['**/node_modules/**']
    });

    await R.pipedAsync(
        files,
        // query
        CW.match(`const :[[cname]] = props => {:[hole]}`),
        // here we preparing replacments
        CW.replaceWithSmartIndent(`class :[[cname]] extends React.Component {
            render() {
                const props = this.props;
                :[hole]
            }
        }`),
        // this command is applying all the replacments in original files
        CW.flushWith(CW.flushInPlace) 
    )
}
main();
  1. Run script
node script.js

# or if you want to see progress bar
PROGRESS=1 node script.js

Documentation

Plz read this before you start to use comby-wrapper:

  1. official comby docs https://comby.dev/docs/overview
  2. official rambdax docs https://github.com/selfrefactor/rambdax#api
  3. examples folder for query and replace example

Readme

Keywords

none

Package Sidebar

Install

npm i comby-wrapper

Weekly Downloads

0

Version

2.1.0

License

MIT

Unpacked Size

36 kB

Total Files

34

Last publish

Collaborators

  • aiboy