Skip to content

How to use cbf in your project

Joshua Vernon edited this page Jan 3, 2020 · 3 revisions

How to run cbf files

cbf can run scripts in a lot of different ways...

  1. Save a cbf script and then run it via it's name or from the cbf menu
    $ cbf -s script.yml
    $ cbf -r script
    ? Choose an option (Use arrow keys)
    ❯ install
      build
      clean
      lint
    
    or
    $ cbf -s script.yml
    $ cbf
    ? Select a script to run it, display help or quit? (Use arrow keys)
    ❯ cbf ♚
      help ?
      quit ⦸
    
  2. Run a script directly from the file
    $ cbf -r script.yml
    Running dev script from cbf.yml file
    
    ? Choose an option (Use arrow keys)
    ❯ install
      build
      clean
      lint
      test
    
  3. Run scripts within package.json file
    $ cbf
    Running scripts from package.json file
    
    ? Choose an option (Use arrow keys)
    ❯ lint ↓
      circular
      format
      test
      build
      clean
    
    or
    $ cbf -j
    Running scripts from package.json file
    
    ? Choose an option (Use arrow keys)
    ❯ lint ↓
      circular
      format
      test
      build
      clean
    
  4. Run a script automatically by naming it cbf and adding it to your repo e.g. cbf.yml or cbf.json
    $ cbf
    Running dev script from cbf.yml file
    
    ? Choose an option (Use arrow keys)
    ❯ install
      build
      clean
      lint
      test
    

Examples

Set Up
---
# An example of a `getting started` setup script you could reference in your README.md
# in your repository to make setting up a new project a lot easier for new contributors
setup:
  step-1: "brew install python"
  "step-2:1": "curl -O http://python-distribute.org/distribute_setup.py"
  "step-2:2": "python distribute_setup.py"
  "step-2:3": "curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py"
  "step-2:4": "python get-pip.py"
  step-3: "pip install virtualenv"
  step-4: "virtualenv venv"
Running your project
---
# An example of a `common project commands` script that can be referenced from
# a repository to share commonly used commands within a repo with other contributors
example-project:
    message: "Run, build or test example project?"
    directory: "~/projects/example"
    options:
        run:
            message: "Running example project..."
            command: "yarn start"
        build:
            directory: "~/projects/example/src"
            message: "Building example project..."
            command: "yarn install"
        test:
            message: "Run unit or integration tests?"
            options:
                unit:
                    message: "Running example project unit tests"
                    command: "yarn test:unit"
                integration:
                    message: "Running example project integration tests"
                    command: "yarn test:integration"

Check out cbf's 🦥 site to get started!

Clone this wiki locally