scatter_deploy 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +31 -0
- data/lib/scatter/cli.rb +39 -11
- data/lib/scatter/config.rb +45 -0
- data/lib/scatter.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bab3406e28bb818ffeb59f27b97313773833b01
|
4
|
+
data.tar.gz: 11cd3b6e94c18dc1e998cecc61c302e07f9a98dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c1ca71a24eceb70a5e25ce26282350329244a0896f94199a48c1235e4a7d33688ef00240298bee4fdff41fa91696334911ca755f10f9023a0a7e7d3e777a6b8
|
7
|
+
data.tar.gz: b65b6885d64853c74a23cd63d4dd50e4fc51be633c7c71eb51b01a57e3e2d4814a908c2dfe99866f0bbd8443dbaf3d29f3dede5ede471887a731f99df5b8a38c
|
data/README.md
CHANGED
@@ -49,9 +49,40 @@ Let's you run arbitrary Capistrano commands, e.g. `scatter cap nginx:restart`.
|
|
49
49
|
|
50
50
|
Let's you run arbitrary shell commands in the project-specific deploy directory, e.g. `scatter exec ls`.
|
51
51
|
|
52
|
+
## Config
|
53
|
+
|
54
|
+
You can set default configuration options in `~/.scatterconfig` using YAML. Currently used settings are:
|
55
|
+
|
56
|
+
* `directory` (string): Sets your default deploys directory, acts like using the `--directory` flag without having to specify it each time.
|
57
|
+
* `aliases` (array): Aliases Scatter commands to other Scatter commands. For example, you could alias `scatter foo` to `scatter -p ~/code/foo -d ~/.foodeploys`. Aliases will *always* prepend `scatter` to the aliased command.
|
58
|
+
|
59
|
+
Scatter exposes `config` and `alias` commands to manage these settings. You can also manually edit `~/.scatterconfig`. Here's an example config file:
|
60
|
+
|
61
|
+
```yml
|
62
|
+
---
|
63
|
+
directory: /Users/evan/code/mydeploys
|
64
|
+
aliases:
|
65
|
+
wp: -s wp
|
66
|
+
rgem: -s gem
|
67
|
+
foo: -p ~/code/foo -d ~/code/foodeploys
|
68
|
+
```
|
69
|
+
|
70
|
+
These settings could be achieved with these commands:
|
71
|
+
|
72
|
+
```shell
|
73
|
+
scatter config directory ~/code/mydeploys
|
74
|
+
scatter alias wp "-s wp"
|
75
|
+
scatter alias gem "-s gem"
|
76
|
+
scatter alias foo "-p ~/code/foo -d ~/code/foodeploys"
|
77
|
+
```
|
78
|
+
|
52
79
|
## Examples
|
53
80
|
|
54
81
|
* `scatter`: Deploy the current project.
|
55
82
|
* `scatter -p projectname`: Deploy the project in `./projectname`.
|
56
83
|
* `scatter -p ~/projectname`: Deploy the project in your home directory's `projectname` directory.
|
57
84
|
* `scatter -s wp`: Deploy the current project by calling `~/.deploys/__shared/wp` and passing your current Git repository's root as an argument.
|
85
|
+
|
86
|
+
### WordPress
|
87
|
+
|
88
|
+
One of my use cases for Scatter is deploying WordPress plugins versioned with Git to WordPress.org, which uses Subversion. I wrote a post on how I use Scatter to do it: [Git, WordPress plugins, and a bit of sanity: Scatter](http://evansolomon.me/notes/git-wordpress-plugins-and-a-bit-of-sanity-scatter/).
|
data/lib/scatter/cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'thor'
|
2
|
+
require 'scatter/config'
|
2
3
|
|
3
4
|
module Scatter
|
4
5
|
class CLI < Thor
|
@@ -6,7 +7,7 @@ module Scatter
|
|
6
7
|
class_option :directory,
|
7
8
|
:aliases => "-d",
|
8
9
|
:type => :string,
|
9
|
-
:default =>
|
10
|
+
:default => Config.get('directory'),
|
10
11
|
:desc => "Specify a deploys directory."
|
11
12
|
|
12
13
|
class_option :project,
|
@@ -41,7 +42,39 @@ module Scatter
|
|
41
42
|
say Scatter::VERSION
|
42
43
|
end
|
43
44
|
|
45
|
+
desc "alias FROM, TO", "Create an aliased Scatter command"
|
46
|
+
def alias(from, *to)
|
47
|
+
config = Config.get
|
48
|
+
config['aliases'] ||= {}
|
49
|
+
config['aliases'][from] = to.join ' '
|
50
|
+
Config.save config
|
51
|
+
|
52
|
+
say Config.show 'aliases'
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "config SETTING, VALUE", "Set a default config option in ~/.scatterconfig"
|
56
|
+
method_option :show, :type => :boolean, :desc => "Show your current config settings"
|
57
|
+
def config(*args)
|
58
|
+
unless options.show
|
59
|
+
abort "Incorrect number of arguments" unless args.length == 2
|
60
|
+
setting = args.first
|
61
|
+
value = args.last
|
62
|
+
Config.set setting, value
|
63
|
+
end
|
64
|
+
|
65
|
+
say Config.show
|
66
|
+
end
|
67
|
+
|
44
68
|
no_tasks do
|
69
|
+
# Process aliases
|
70
|
+
def method_missing(method, *args)
|
71
|
+
aliases = Config.get 'aliases'
|
72
|
+
_method = method.to_s
|
73
|
+
|
74
|
+
return super unless aliases.has_key?(_method) and aliases[_method].is_a?(String)
|
75
|
+
system "scatter #{aliases[_method]}"
|
76
|
+
end
|
77
|
+
|
45
78
|
def git?
|
46
79
|
unless system "which git >/dev/null 2>&1"
|
47
80
|
abort "Scatter requires Git if you want it to find projects automatically"
|
@@ -74,11 +107,11 @@ module Scatter
|
|
74
107
|
deploy = "#{project_deploy_dir}/deploy"
|
75
108
|
return false unless File.exists? deploy
|
76
109
|
|
77
|
-
|
78
|
-
return true
|
79
|
-
else
|
110
|
+
unless File.executable? deploy
|
80
111
|
abort "It looks like you have a deploy file, but it's not executable. Try something like: chmod +x #{deploy}"
|
81
112
|
end
|
113
|
+
|
114
|
+
return true
|
82
115
|
end
|
83
116
|
|
84
117
|
def generate_command
|
@@ -88,13 +121,8 @@ module Scatter
|
|
88
121
|
end
|
89
122
|
|
90
123
|
def run(command=nil)
|
91
|
-
unless project_deploy_dir
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
unless command ||= generate_command
|
96
|
-
abort "No deploy command found"
|
97
|
-
end
|
124
|
+
abort "No deploy directory found" unless project_deploy_dir
|
125
|
+
abort "No deploy command found" unless command ||= generate_command
|
98
126
|
|
99
127
|
system "cd #{project_deploy_dir} && #{command}"
|
100
128
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Scatter
|
4
|
+
class Config
|
5
|
+
CONFIG_FILE = "#{Dir.home}/.scatterconfig"
|
6
|
+
DEFAULTS = {'directory' => "#{Dir.home}/.deploys"}
|
7
|
+
|
8
|
+
def self.parse
|
9
|
+
return DEFAULTS unless File.exists? CONFIG_FILE
|
10
|
+
|
11
|
+
begin
|
12
|
+
return DEFAULTS.merge YAML.load(File.read CONFIG_FILE)
|
13
|
+
rescue
|
14
|
+
abort "There was a problem parsing #{CONFIG_FILE}, it should be valid YAML"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.get(key=nil)
|
19
|
+
config = self.parse
|
20
|
+
key ? config[key] : config
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.save(options)
|
24
|
+
File.open(CONFIG_FILE, 'w') do |f|
|
25
|
+
f.write options.to_yaml
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.set(key, value)
|
30
|
+
config = get
|
31
|
+
config[key] = value
|
32
|
+
save config
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.show(key=nil)
|
36
|
+
if key
|
37
|
+
value = get[key]
|
38
|
+
else
|
39
|
+
value = get
|
40
|
+
end
|
41
|
+
|
42
|
+
value.to_yaml
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/scatter.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scatter_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Solomon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- MIT-LICENSE
|
51
51
|
- bin/scatter
|
52
52
|
- lib/scatter/cli.rb
|
53
|
+
- lib/scatter/config.rb
|
53
54
|
- lib/scatter.rb
|
54
55
|
homepage: http://evansolomon.me/
|
55
56
|
licenses:
|