go-van

command module
v0.0.0-...-660c754 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 8 Imported by: 0

README

Caravan (go-van)

ci codecov

A simple project files watcher and deployer, which syncs dev files to remote machines at ease.

go-van is the Go implementation of Caravan.

Caravan in Civ5

This is the caravan in Sid Meier's Civilization V, where the project name originally comes from.

Migrate from Ruby Caravan

Compared to Ruby version of Caravan:

  • It highly depends on caravan.yml, which assumes that caravan.yml is already setup.
  • Only rsync is supported.
  • More powerful features (e.g. extra_args and log_format).

Installation

go get -u github.com/crispgm/go-van

Quick Start

  1. Init caravan.yml:

    $ go-van -init
    Created caravan.yml in /path/to/project
    
  2. Edit caravan.yml:

    # Open with your favorite editor, `vim` for example
    $ vim caravan.yml
    

    Specify src, dst, and other configuration in master scope:

    ---
    master:
      src: .
      dst: user@target:/path/to/project
      debug: false
      deploy_mode: rsync
      incremental: true
      extra_args:
        - "--delete"
        - "--exclude=.git"
      exclude:
        - ".git"
    
  3. Start to watch:

    $ go-van
    Reading configuration...
    => debug: false
    => once: false
    => source: .
    => destination: .
    => deploy_mode: rsync
    => incremental: true
    => extra_args: [--delete]
    => exclude: [.git .svn /node_modules]
    Starting to watch...
    
  4. When a file is changed, it syncs:

    [20:46:05] EVENT 0x41217e0 /Users/david/path/to/file.py
    

Usage

Generate an empty caravan.yml:

$ go-van -init
Created caravan.yml in /path/to/project

Run with default:

# Default run, with `caravan.yml` and `master` spec
$ go-van

And you may specify config file name and spec name:

# Special spec name
$ go-van -spec my_spec
# Specify config file name
$ go-van -conf another_caravan.yml
# And both
$ go-van -conf another_caravan.yml -spec my_spec

Deploy once:

$ go-van -once
Reading configuration...
=> debug: false
...
Deploying at once and for once...

Configuration

Debug

Show debug outputs.

Deploy Mode

Only support rsync in go-van, compared to caravan.

Exclusion

Exclusion denotes exclude path for watching, not deploying. Hence, use git/svn in source path instead of destination path or checkout Extra Arguments.

Extra Arguments

Extra arguments will be passed to deployer (e.g. rsync) as arguments.

Support Sync with Deletion
master:
  src: .
  dst: /path/to/project
  debug: false
  deploy_mode: rsync
  incremental: true
  extra_args:
    - "--delete"
  exclude:
    - ".git"
    - ".svn"
Ignore .git Files
extra_args:
  - "--exclude=.git"
Log Format

Format:

  • %t: Time string, e.g. 16:25:01
  • %T: Timestamp
  • %e: Event type
  • %p: Path
  • %f: File name
log_format: "[%t] EVENT <%e> %p"

Event Hooks (experimental)

Event hooks are designed to handle events of hooks, by which users may inject their scripts.

There are four hooks exposed, which are OnInit OnChange OnDeploy OnError.

e.g., You may add OnInit in caravan.yml:

on_init:
  - echo "go-van is initializing"
on_change:
  - make

License

MIT License.

Copyright (c) 2020 David Zhang.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL