caravan 0.7.0 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/README.md +15 -7
- data/docs/.gitignore +4 -0
- data/docs/Gemfile +30 -0
- data/docs/Rakefile +31 -0
- data/docs/_config.yml +34 -0
- data/docs/_data/changelog.yml +36 -0
- data/docs/about.md +10 -0
- data/docs/assets/civ-5-caravan.png +0 -0
- data/docs/changelog.html +23 -0
- data/docs/docs.md +114 -0
- data/docs/index.html +50 -0
- data/exe/caravan +26 -8
- data/lib/caravan.rb +10 -2
- data/lib/caravan/command.rb +1 -1
- data/lib/caravan/config.rb +34 -13
- data/lib/caravan/deploy.rb +5 -3
- data/lib/caravan/version.rb +1 -1
- metadata +14 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 347b4140ddb514fb5e09308d12b9d36cca9456b1
|
4
|
+
data.tar.gz: 0a84aa9ec43f5f0957e6af0dd34c38a0bf95e6fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97ee509584f9629bae857d6f1998b5db05137d2c44788af41a91fc45af09b8cf100600993fbcf19fa71989bd43df57e53006586ff6064547c58bf5927a155560
|
7
|
+
data.tar.gz: 4c2ecc7541ed788ed0e3aa8e5018843fcffb2eedcd4ce6f02dd57aed3d3322df134e31fe16dc8f076350640095f029f0589a52a5280d36ac695bdc62ab483891
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/caravan.svg)](https://badge.fury.io/rb/caravan)
|
4
4
|
[![](https://api.travis-ci.org/crispgm/gsm.svg)](https://travis-ci.org/crispgm/caravan)
|
5
|
-
[![
|
6
|
-
[![Test Coverage](https://codeclimate.com/
|
5
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/3d0007620855bd6ffea0/maintainability)](https://codeclimate.com/github/crispgm/caravan/maintainability)
|
6
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/3d0007620855bd6ffea0/test_coverage)](https://codeclimate.com/github/crispgm/caravan/test_coverage)
|
7
7
|
|
8
8
|
Simple project files watcher and deployer.
|
9
9
|
|
@@ -11,7 +11,7 @@ The scenario is when we are developing in your local workspace and the program o
|
|
11
11
|
|
12
12
|
![](/assets/civ-5-caravan.png)
|
13
13
|
|
14
|
-
This is the caravan in [Sid Meier's Civilization V](http://www.civilization5.com/),
|
14
|
+
This is the caravan in [Sid Meier's Civilization V](http://www.civilization5.com/), where the project name originally comes from.
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
@@ -30,6 +30,7 @@ $ caravan --help
|
|
30
30
|
-i, --ignore IGNORE_FILES Ignore files
|
31
31
|
-o, --once Deploy for once
|
32
32
|
-b, --debug Debug mode
|
33
|
+
-l, --load YAML_FILE YAML file (Default: ./caravan.yml)
|
33
34
|
--version Show version
|
34
35
|
```
|
35
36
|
|
@@ -79,11 +80,17 @@ You may also write `src` and `dst` to `caravan.yml`. Hence, deployment made even
|
|
79
80
|
$ caravan
|
80
81
|
```
|
81
82
|
|
83
|
+
`caravan.yml` can be named as you like. To load your own YAML file, use `--load`:
|
84
|
+
|
85
|
+
```
|
86
|
+
$ caravan --load my-caravan.yml
|
87
|
+
```
|
88
|
+
|
82
89
|
### Deploy Modes
|
83
90
|
|
84
|
-
*
|
91
|
+
* Shell
|
85
92
|
* `cp` in local.
|
86
|
-
* scp
|
93
|
+
* Secure copy (scp)
|
87
94
|
* `scp` to remote machines, _not recommended_.
|
88
95
|
* [rsync](https://rsync.samba.org/)
|
89
96
|
* `rsync` to remote machines, which is the default and recommended mode because it is incremental. Thus, it performs much better.
|
@@ -101,8 +108,9 @@ $ caravan
|
|
101
108
|
- [x] `before_deploy`
|
102
109
|
- [x] `after_deploy`
|
103
110
|
- [x] `before_destroy`
|
104
|
-
- [ ] Multiple deployment configurations
|
111
|
+
- [ ] ~~Multiple deployment configurations~~
|
112
|
+
- [ ] Extension to deploy methods
|
105
113
|
|
106
|
-
##
|
114
|
+
## License
|
107
115
|
|
108
116
|
[MIT](/LICENSE)
|
data/docs/.gitignore
ADDED
data/docs/Gemfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Hello! This is where you manage which Jekyll version is used to run.
|
4
|
+
# When you want to use a different version, change it below, save the
|
5
|
+
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
|
6
|
+
#
|
7
|
+
# bundle exec jekyll serve
|
8
|
+
#
|
9
|
+
# This will help ensure the proper Jekyll version is running.
|
10
|
+
# Happy Jekylling!
|
11
|
+
gem "jekyll", "~> 3.8.1"
|
12
|
+
|
13
|
+
# This is the default theme for new Jekyll sites. You may change this to anything you like.
|
14
|
+
gem "minima", "~> 2.0"
|
15
|
+
|
16
|
+
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
|
17
|
+
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
18
|
+
# gem "github-pages", group: :jekyll_plugins
|
19
|
+
|
20
|
+
# If you have any plugins, put them here!
|
21
|
+
group :jekyll_plugins do
|
22
|
+
gem "jekyll-feed", "~> 0.6"
|
23
|
+
gem "black-white-blue"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
27
|
+
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
28
|
+
|
29
|
+
# Performance-booster for watching directories on Windows
|
30
|
+
gem "wdm", "~> 0.1.0" if Gem.win_platform?
|
data/docs/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
namespace :site do
|
4
|
+
desc "Serve site"
|
5
|
+
task :serve do
|
6
|
+
sh "bundle exec jekyll serve --draft --future --livereload"
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Build jekyll and push to gh-pages branch"
|
10
|
+
task :build do
|
11
|
+
# Clone to gh-pages
|
12
|
+
unless File.exist?("gh-pages")
|
13
|
+
sh "git clone -b gh-pages https://github.com/crispgm/caravan.git gh-pages"
|
14
|
+
end
|
15
|
+
# Checkout and pull
|
16
|
+
Dir.chdir("gh-pages") do
|
17
|
+
sh "git checkout gh-pages"
|
18
|
+
sh "git pull origin gh-pages"
|
19
|
+
end
|
20
|
+
# Build site
|
21
|
+
Dir.chdir(".") do
|
22
|
+
sh "bundle exec jekyll build --destination=./gh-pages/"
|
23
|
+
end
|
24
|
+
# Push
|
25
|
+
Dir.chdir("gh-pages") do
|
26
|
+
sh "git add ."
|
27
|
+
sh "git commit --allow-empty -m \"Deployed at #{Time.now}\""
|
28
|
+
sh "git push origin gh-pages"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/docs/_config.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
baseurl: "/caravan"
|
2
|
+
project:
|
3
|
+
name: Caravan
|
4
|
+
subtitle: Simple project files watcher and deployer
|
5
|
+
description: >- # this means to ignore newlines until "baseurl:"
|
6
|
+
The scenario is when we are developing in your local workspace and the program only runs in specific runtime environment, we have to setup by ourself to make the program run and debug on runtime folders, or remote machines. Caravan is the automation tool designed for solving such kind of problems by watching the file changes, and deploy them automatically to its destination.
|
7
|
+
repo: "crispgm/caravan"
|
8
|
+
logo: "/caravan/assets/civ-5-caravan.png"
|
9
|
+
author: "David Zhang"
|
10
|
+
author_link: "https://crispgm.com/"
|
11
|
+
email: crispgm@gmail.com
|
12
|
+
twitter: crispgm
|
13
|
+
medium: "@crispgm"
|
14
|
+
highlightjs: true
|
15
|
+
|
16
|
+
# Build settings
|
17
|
+
markdown: kramdown
|
18
|
+
theme: black-white-blue
|
19
|
+
plugins:
|
20
|
+
- jekyll-feed
|
21
|
+
exclude:
|
22
|
+
- gh-pages
|
23
|
+
- Rakefile
|
24
|
+
# Exclude from processing.
|
25
|
+
# The following items will not be processed, by default. Create a custom list
|
26
|
+
# to override the default setting.
|
27
|
+
# exclude:
|
28
|
+
# - Gemfile
|
29
|
+
# - Gemfile.lock
|
30
|
+
# - node_modules
|
31
|
+
# - vendor/bundle/
|
32
|
+
# - vendor/cache/
|
33
|
+
# - vendor/gems/
|
34
|
+
# - vendor/ruby/
|
@@ -0,0 +1,36 @@
|
|
1
|
+
- version: "0.7.0"
|
2
|
+
changes:
|
3
|
+
- text: "Specify caravan.yml's name"
|
4
|
+
hash: 77df905
|
5
|
+
- version: "0.6.2"
|
6
|
+
changes:
|
7
|
+
- text: "Set default deploy_mode: rsync"
|
8
|
+
hash: 1ab105b
|
9
|
+
- version: "0.6.1"
|
10
|
+
changes:
|
11
|
+
- text: "Bugfix: use the right conf when merging with options"
|
12
|
+
hash: 6408066
|
13
|
+
- version: "0.6.0"
|
14
|
+
changes:
|
15
|
+
- text: "Use --init to generate caravan.yml"
|
16
|
+
- text: "Bugfix: exit after init caravan.yml"
|
17
|
+
- text: "Docs on examples and confs"
|
18
|
+
- version: "0.5.2"
|
19
|
+
changes:
|
20
|
+
- text: "Add deploy at once"
|
21
|
+
- text: "Parse caravan.yml for src & dst"
|
22
|
+
issue: 4
|
23
|
+
- version: "0.5.1"
|
24
|
+
changes:
|
25
|
+
- text: "Implement Hooks"
|
26
|
+
- version: "0.4.0"
|
27
|
+
changes:
|
28
|
+
- text: "Add full options in docs"
|
29
|
+
hash: b2d3774
|
30
|
+
- version: "0.4.0.beta"
|
31
|
+
changes:
|
32
|
+
- text: "Add caravan init to generate default conf file"
|
33
|
+
- version: "0.2.0"
|
34
|
+
changes:
|
35
|
+
- text: "Basically works"
|
36
|
+
hash: 7f0a548
|
data/docs/about.md
ADDED
Binary file
|
data/docs/changelog.html
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
layout: changelog
|
3
|
+
title: Changelog
|
4
|
+
---
|
5
|
+
|
6
|
+
<div class="article" id="changelog">
|
7
|
+
{% for change in site.data.changelog %}
|
8
|
+
<h3>Version {{ change.version }}</h3>
|
9
|
+
<ul>
|
10
|
+
{% for log in change.changes %}
|
11
|
+
<li>
|
12
|
+
{{ log.text }}
|
13
|
+
{% if log.issue != nil %}
|
14
|
+
<a href="https://github.com/{{ site.project.repo }}/issues/{{ log.issue }}">#{{ log.issue }}</a></li>
|
15
|
+
{% endif %}
|
16
|
+
{% if log.hash != nil %}
|
17
|
+
<a href="https://github.com/{{ site.project.repo }}/commit/{{ log.hash }}">#{{ log.hash }}</a>
|
18
|
+
{% endif %}
|
19
|
+
</li>
|
20
|
+
{% endfor %}
|
21
|
+
</ul>
|
22
|
+
{% endfor %}
|
23
|
+
</div>
|
data/docs/docs.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: Documentation
|
4
|
+
---
|
5
|
+
|
6
|
+
Simple project files watcher and deployer.
|
7
|
+
|
8
|
+
The scenario is when we are developing in your local workspace and the program only runs in specific runtime environment, we have to setup by ourself to make the program run and debug on runtime folders, or remote machines. Caravan is the automation tool designed for solving such kind of problems by watching the file changes, and deploy them automatically to its destination.
|
9
|
+
|
10
|
+
![](/assets/civ-5-caravan.png)
|
11
|
+
|
12
|
+
This is the caravan in [Sid Meier's Civilization V](http://www.civilization5.com/), where the project name originally comes from.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
```
|
17
|
+
$ gem install caravan
|
18
|
+
```
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```
|
23
|
+
$ caravan --help
|
24
|
+
|
25
|
+
-s, --source SOURCE_PATH Source path
|
26
|
+
-d, --dest DEST_PATH Destination path
|
27
|
+
-m, --mode DEPLOY_MODE Deploy mode
|
28
|
+
-i, --ignore IGNORE_FILES Ignore files
|
29
|
+
-o, --once Deploy for once
|
30
|
+
-b, --debug Debug mode
|
31
|
+
-l, --load YAML_FILE YAML file (Default: ./caravan.yml)
|
32
|
+
--version Show version
|
33
|
+
```
|
34
|
+
|
35
|
+
## Examples
|
36
|
+
|
37
|
+
Deploy to local directory:
|
38
|
+
|
39
|
+
```
|
40
|
+
$ caravan -s /path/to/project/. -d /path/to/deploy -m shell
|
41
|
+
```
|
42
|
+
|
43
|
+
Deploy to remote machines:
|
44
|
+
|
45
|
+
```
|
46
|
+
$ caravan -s /path/to/project/. -d user@remote_machines:/path/to/deploy -m rsync
|
47
|
+
```
|
48
|
+
|
49
|
+
Deploy only once:
|
50
|
+
|
51
|
+
```
|
52
|
+
$ caravan -s /path/to/project/. -d user@remote_machines:/path/to/deploy -m rsync --once
|
53
|
+
```
|
54
|
+
|
55
|
+
## Configuration
|
56
|
+
|
57
|
+
Generate default configuration:
|
58
|
+
|
59
|
+
```
|
60
|
+
$ cd /path/to/src
|
61
|
+
$ caravan --init
|
62
|
+
```
|
63
|
+
|
64
|
+
A `caravan.yml` will be generated as `/path/to/src/caravan.yml`. You may specify any options in command arguments except source path.
|
65
|
+
|
66
|
+
```
|
67
|
+
debug: false
|
68
|
+
deploy_mode: rsync_local
|
69
|
+
incremental: true
|
70
|
+
exclude:
|
71
|
+
- ".git"
|
72
|
+
- ".svn"
|
73
|
+
```
|
74
|
+
|
75
|
+
You may also write `src` and `dst` to `caravan.yml`. Hence, deployment made even easier.
|
76
|
+
|
77
|
+
```
|
78
|
+
$ caravan
|
79
|
+
```
|
80
|
+
|
81
|
+
`caravan.yml` can be named as you like. To load your own YAML file, use `--load`:
|
82
|
+
|
83
|
+
```
|
84
|
+
$ caravan --load my-caravan.yml
|
85
|
+
```
|
86
|
+
|
87
|
+
### Deploy Modes
|
88
|
+
|
89
|
+
* Shell
|
90
|
+
* `cp` in local.
|
91
|
+
* Secure copy (scp)
|
92
|
+
* `scp` to remote machines, _not recommended_.
|
93
|
+
* [rsync](https://rsync.samba.org/)
|
94
|
+
* `rsync` to remote machines, which is the default and recommended mode because it is incremental. Thus, it performs much better.
|
95
|
+
* rsync_local
|
96
|
+
* `rsync` in local.
|
97
|
+
|
98
|
+
## Plan
|
99
|
+
|
100
|
+
- [x] Basic watching and deploying
|
101
|
+
- [x] Exclude watching unwanted files
|
102
|
+
- [x] `caravan.yml` for project-specialized configuration
|
103
|
+
- [x] Callbacks for deployment
|
104
|
+
- [x] `after_create`
|
105
|
+
- [x] `after_change`
|
106
|
+
- [x] `before_deploy`
|
107
|
+
- [x] `after_deploy`
|
108
|
+
- [x] `before_destroy`
|
109
|
+
- [ ] ~~Multiple deployment configurations~~
|
110
|
+
- [ ] Extension to deploy methods
|
111
|
+
|
112
|
+
## License
|
113
|
+
|
114
|
+
[MIT](/LICENSE)
|
data/docs/index.html
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
layout: index
|
3
|
+
title: Home
|
4
|
+
---
|
5
|
+
|
6
|
+
<div class="section intro" id="introduction">
|
7
|
+
{% if site.project.logo != nil and site.project.logo != "" %}
|
8
|
+
<div class="intro-logo">
|
9
|
+
<img src="{{ site.project.logo }}">
|
10
|
+
</div>
|
11
|
+
{% endif %}
|
12
|
+
|
13
|
+
<div class="intro-text">
|
14
|
+
{{ site.project.subtitle }}
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class="intro-desc">
|
18
|
+
{{ site.project.description }}
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div class="intro-button">
|
22
|
+
<div class="install-item">
|
23
|
+
<a href="{{ site.baseurl }}/docs.html#getting-started">Getting Started</a>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div class="intro-version">
|
28
|
+
<span>Version <a href="{{ site.baseurl }}/changelog.html">{{ site.data.changelog[0].version }}</a> ·</span>
|
29
|
+
<span>Created by <a href="{{ site.project.author_link }}">{{ site.project.author }}</a></span>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div class="social">
|
33
|
+
<a class="github-button"
|
34
|
+
href="https://github.com/{{ site.project.repo }}"
|
35
|
+
data-icon="octicon-star"
|
36
|
+
data-count-href="/{{ site.project.repo }}/stargazers"
|
37
|
+
data-count-api="/repos/{{ site.project.repo }}#stargazers_count"
|
38
|
+
data-count-aria-label="# stargazers on GitHub"
|
39
|
+
aria-label="Star {{ site.project.repo }} on GitHub">Star
|
40
|
+
</a>
|
41
|
+
<a class="github-button"
|
42
|
+
href="https://github.com/{{ site.project.repo }}/fork"
|
43
|
+
data-icon="octicon-repo-forked"
|
44
|
+
data-count-href="/{{ site.project.repo }}/network"
|
45
|
+
data-count-api="/repos/{{ site.project.repo }}#forks_count"
|
46
|
+
data-count-aria-label="# forks on GitHub"
|
47
|
+
aria-label="Fork {{ site.project.repo }} on GitHub">Fork
|
48
|
+
</a>
|
49
|
+
</div>
|
50
|
+
</div>
|
data/exe/caravan
CHANGED
@@ -6,6 +6,7 @@ require "optparse"
|
|
6
6
|
require "caravan"
|
7
7
|
|
8
8
|
options = {}
|
9
|
+
# rubocop:disable Metrics/BlockLength
|
9
10
|
option_parser = OptionParser.new do |opts|
|
10
11
|
opts.banner = "Caravan #{Caravan::VERSION}\nCopyright (c) David Zhang 2018\n"
|
11
12
|
opts.separator ""
|
@@ -14,6 +15,10 @@ option_parser = OptionParser.new do |opts|
|
|
14
15
|
options[:yaml] = value
|
15
16
|
end
|
16
17
|
|
18
|
+
opts.on("-c SPEC_NAME", "--spec SPEC_NAME", "Spec name") do |value|
|
19
|
+
options[:spec] = value
|
20
|
+
end
|
21
|
+
|
17
22
|
opts.on("-s SOURCE_PATH", "--source SOURCE_PATH", "Source path") do |value|
|
18
23
|
options[:src] = value
|
19
24
|
end
|
@@ -53,19 +58,32 @@ option_parser = OptionParser.new do |opts|
|
|
53
58
|
exit
|
54
59
|
end
|
55
60
|
end
|
61
|
+
# rubocop:enable Metrics/BlockLength
|
56
62
|
|
57
|
-
|
58
|
-
|
63
|
+
spec_name = options[:spec] || Caravan::Config.default_spec_name
|
64
|
+
|
65
|
+
if ARGV.length.zero?
|
66
|
+
merged_conf = Caravan::Config.merge({}, Caravan.process_conf("."), spec_name)
|
59
67
|
else
|
60
68
|
option_parser.parse!(ARGV)
|
61
|
-
if options.key?(:yaml)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
69
|
+
merged_conf = if options.key?(:yaml)
|
70
|
+
Caravan::Config.merge(
|
71
|
+
options,
|
72
|
+
Caravan.process_conf(options[:src], options[:yaml]),
|
73
|
+
spec_name
|
74
|
+
)
|
75
|
+
else
|
76
|
+
Caravan::Config.merge(
|
77
|
+
options,
|
78
|
+
Caravan.process_conf(options[:src]),
|
79
|
+
spec_name
|
80
|
+
)
|
81
|
+
end
|
66
82
|
end
|
67
83
|
|
68
|
-
if merged_conf.key?("src") &&
|
84
|
+
if merged_conf.key?("src") &&
|
85
|
+
merged_conf.key?("dst") &&
|
86
|
+
merged_conf.key?("deploy_mode")
|
69
87
|
Caravan.start(merged_conf)
|
70
88
|
else
|
71
89
|
Caravan::Message.error("No src, dst, deploy_mode specified. Cannot deploy.")
|
data/lib/caravan.rb
CHANGED
@@ -21,7 +21,11 @@ module Caravan
|
|
21
21
|
|
22
22
|
Caravan::Config.pretty_puts(merged_conf)
|
23
23
|
|
24
|
-
deployer = Caravan::Deploy.create_deployer(
|
24
|
+
deployer = Caravan::Deploy.create_deployer(
|
25
|
+
src_path,
|
26
|
+
target_path,
|
27
|
+
deploy_mode
|
28
|
+
)
|
25
29
|
deployer.debug = true if debug
|
26
30
|
exit(-1) if deployer.nil?
|
27
31
|
|
@@ -62,6 +66,7 @@ module Caravan
|
|
62
66
|
return unless deployer.before_deploy
|
63
67
|
deployer.run
|
64
68
|
deployer.after_deploy
|
69
|
+
# rubocop:enable Lint/NonLocalExitFromIterator
|
65
70
|
end
|
66
71
|
end
|
67
72
|
|
@@ -78,7 +83,10 @@ module Caravan
|
|
78
83
|
end
|
79
84
|
|
80
85
|
def dump_default_conf
|
81
|
-
user_config_path = File.join(
|
86
|
+
user_config_path = File.join(
|
87
|
+
File.expand_path("."),
|
88
|
+
Caravan::Config.default_conf_name
|
89
|
+
)
|
82
90
|
default_conf = Caravan::Config.default_conf
|
83
91
|
|
84
92
|
Caravan::Config.dump(user_config_path, default_conf)
|
data/lib/caravan/command.rb
CHANGED
data/lib/caravan/config.rb
CHANGED
@@ -3,16 +3,19 @@ require "yaml"
|
|
3
3
|
module Caravan
|
4
4
|
class Config < Hash
|
5
5
|
DEFAULT_CONFIG = {
|
6
|
-
"
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
"master" => {
|
7
|
+
"debug" => false,
|
8
|
+
"deploy_mode" => "rsync",
|
9
|
+
"incremental" => true,
|
10
|
+
"exclude" => %w(
|
11
|
+
.git .svn
|
12
|
+
),
|
13
|
+
"once" => false
|
14
|
+
}
|
13
15
|
}.freeze
|
14
16
|
|
15
17
|
DEFAULT_CONFIG_NAME = "caravan.yml".freeze
|
18
|
+
DEFAULT_SPEC_NAME = "master".freeze
|
16
19
|
|
17
20
|
class << self
|
18
21
|
def default_conf
|
@@ -23,6 +26,10 @@ module Caravan
|
|
23
26
|
DEFAULT_CONFIG_NAME
|
24
27
|
end
|
25
28
|
|
29
|
+
def default_spec_name
|
30
|
+
DEFAULT_SPEC_NAME
|
31
|
+
end
|
32
|
+
|
26
33
|
def from(user_config_path)
|
27
34
|
if File.exist?(user_config_path)
|
28
35
|
YAML.load_file(user_config_path)
|
@@ -34,20 +41,24 @@ module Caravan
|
|
34
41
|
end
|
35
42
|
|
36
43
|
def dump(user_config_path, user_config)
|
44
|
+
# rubocop:disable Metrics/LineLength
|
37
45
|
File.open(user_config_path, "w") do |f|
|
38
46
|
f.write("# Generated Caravan's configuration file.\n")
|
39
47
|
f.write("# Use `caravan --help` for instructions on all the configuration values.\n")
|
40
48
|
f.write("# Add `src` and `dst` to specify the source and destination.\n")
|
41
49
|
f.write(user_config.to_yaml)
|
42
50
|
end
|
51
|
+
# rubocop:enable Metrics/LineLength
|
43
52
|
end
|
44
53
|
|
45
|
-
def merge(options, conf)
|
46
|
-
if conf.nil?
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
54
|
+
def merge(options, conf, spec = Caravan::Config.default_spec_name)
|
55
|
+
merged_conf = if conf.nil?
|
56
|
+
Caravan::Message.warn("Fail to load conf. Use default instead.")
|
57
|
+
default_spec_name = Caravan::Config.default_spec_name
|
58
|
+
Caravan::Config.default_conf[default_spec_name]
|
59
|
+
else
|
60
|
+
stringify_keys(conf)[spec]
|
61
|
+
end
|
51
62
|
|
52
63
|
merged_conf["src"] = options[:src] if options.key?(:src)
|
53
64
|
merged_conf["dst"] = options[:dst] if options.key?(:dst)
|
@@ -64,6 +75,16 @@ module Caravan
|
|
64
75
|
Caravan::Message.info("=> #{k}: #{v}")
|
65
76
|
end
|
66
77
|
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def stringify_keys(conf)
|
82
|
+
new_conf = {}
|
83
|
+
conf.each do |sym, v|
|
84
|
+
new_conf[sym.to_s] = v
|
85
|
+
end
|
86
|
+
new_conf
|
87
|
+
end
|
67
88
|
end
|
68
89
|
end
|
69
90
|
end
|
data/lib/caravan/deploy.rb
CHANGED
@@ -89,11 +89,11 @@ module Caravan
|
|
89
89
|
|
90
90
|
status = 0
|
91
91
|
if block_given?
|
92
|
-
status,
|
92
|
+
status, _output = yield src, dst
|
93
93
|
debug_msg("Block `run` returned #{status}")
|
94
94
|
end
|
95
95
|
|
96
|
-
Message.error("Deploying block returned false") unless status
|
96
|
+
Message.error("Deploying block returned false") unless status.zero?
|
97
97
|
status
|
98
98
|
end
|
99
99
|
|
@@ -120,7 +120,9 @@ module Caravan
|
|
120
120
|
def relative_path(path)
|
121
121
|
working_dir = Dir.pwd
|
122
122
|
path_routes = path.split(working_dir)
|
123
|
-
return nil if path_routes.nil? ||
|
123
|
+
return nil if path_routes.nil? ||
|
124
|
+
path_routes.empty? ||
|
125
|
+
path_routes.size < 2
|
124
126
|
|
125
127
|
path_routes[-1]
|
126
128
|
end
|
data/lib/caravan/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caravan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Zhang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -128,6 +128,16 @@ files:
|
|
128
128
|
- Rakefile
|
129
129
|
- _config.yml
|
130
130
|
- caravan.gemspec
|
131
|
+
- docs/.gitignore
|
132
|
+
- docs/Gemfile
|
133
|
+
- docs/Rakefile
|
134
|
+
- docs/_config.yml
|
135
|
+
- docs/_data/changelog.yml
|
136
|
+
- docs/about.md
|
137
|
+
- docs/assets/civ-5-caravan.png
|
138
|
+
- docs/changelog.html
|
139
|
+
- docs/docs.md
|
140
|
+
- docs/index.html
|
131
141
|
- exe/caravan
|
132
142
|
- lib/caravan.rb
|
133
143
|
- lib/caravan/command.rb
|
@@ -154,9 +164,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
164
|
version: 2.3.0
|
155
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
166
|
requirements:
|
157
|
-
- - "
|
167
|
+
- - ">"
|
158
168
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
169
|
+
version: 1.3.1
|
160
170
|
requirements: []
|
161
171
|
rubyforge_project:
|
162
172
|
rubygems_version: 2.6.11
|