rebuild 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -14
- data/lib/rebuild/cli.rb +27 -11
- data/lib/rebuild/git_config.rb +75 -0
- data/lib/rebuild/logger.rb +1 -1
- data/lib/rebuild/version.rb +1 -1
- data/rebuild.gemspec +2 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e33526c3d57fa8c7990afa9c11a72aa765bcfc4c
|
4
|
+
data.tar.gz: 8218f4d7b9208c2e70ac068b1ca9c85d364883ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2f0ad4b13f6489ff0d3aa7cb8f89d1c224f947ee31aa4741d9f50a18e5eb90b03e0c82d41b1c9523760248e9de10951e2fafe645689f2e90e369a554c86452f
|
7
|
+
data.tar.gz: 9ac96105ce30d59d538c68ce7421b5eb0204e5288dc65156f233d4cb49d5d6bf7c2baa0de4d0070164635fc9091718692e3b1a148d0fef0d10c35355c7a6ca1c
|
data/README.md
CHANGED
@@ -2,35 +2,44 @@
|
|
2
2
|
|
3
3
|
Development environment bootstrap automation toolkit for OSX
|
4
4
|
|
5
|
-
![](http://pic.k0kubun.com/
|
5
|
+
![](http://pic.k0kubun.com/174syGrQYpdTo0N.gif)
|
6
6
|
|
7
7
|
## What's this?
|
8
8
|
|
9
9
|
`rebuild` allows you to achieve mouse-free command line tools installation in OSX Yosemite.
|
10
|
-
|
10
|
+
And `rebuild` clones your GitHub repository and runs all of your bootstrap scripts.
|
11
11
|
|
12
12
|
You can setup or synchronize your environment by just executing `rebuild <username>/<project>`
|
13
13
|
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
```bash
|
17
|
+
$ gem install rebuild
|
18
|
+
```
|
19
|
+
|
14
20
|
## Usage
|
15
21
|
|
16
|
-
###
|
22
|
+
### Clean-installed bootstrap
|
17
23
|
|
18
24
|
```bash
|
19
|
-
|
20
|
-
$ rebuild
|
25
|
+
# For example: rebuild k0kubun/dotfiles
|
26
|
+
$ rebuild [username]/[repository]
|
21
27
|
```
|
22
28
|
|
23
|
-
|
29
|
+
**No need to touch your mouse.** Rebuild will click buttons for you in command line tools installation.
|
30
|
+
Just typing the command allows you to reproduce your development environment.
|
24
31
|
|
25
|
-
###
|
32
|
+
### Sync multiple environments
|
33
|
+
|
34
|
+
![](http://pic.k0kubun.com/treCcBeBSil20o7.gif)
|
26
35
|
|
27
36
|
```bash
|
28
|
-
|
29
|
-
$ rebuild k0kubun/dotfiles
|
37
|
+
# force update repository by `-f`
|
38
|
+
$ rebuild -f k0kubun/dotfiles
|
30
39
|
```
|
31
40
|
|
32
|
-
|
33
|
-
|
41
|
+
If you manage your development environment on GitHub repository,
|
42
|
+
you can use this gem to synchronize multiple environments.
|
34
43
|
|
35
44
|
## Options
|
36
45
|
|
@@ -46,13 +55,34 @@ $ rebuild -d ~/src/github.com/k0kubun/dotfiles
|
|
46
55
|
$ rebuild -s script
|
47
56
|
|
48
57
|
# You can choose which script to run first by shell pipeline
|
49
|
-
echo "first.sh second.sh" | rebuild
|
50
58
|
rebuild <<-EOS
|
51
59
|
first.sh
|
52
60
|
second.sh
|
53
61
|
EOS
|
54
62
|
```
|
55
63
|
|
64
|
+
## Config
|
65
|
+
|
66
|
+
You can skip choosing option by ~/.gitconfig
|
67
|
+
|
68
|
+
```aconf
|
69
|
+
# ~/.gitconfig
|
70
|
+
# You can append config template by `rebuild config`
|
71
|
+
|
72
|
+
[rebuild]
|
73
|
+
# if true, everytime git pull
|
74
|
+
update = false
|
75
|
+
|
76
|
+
# you can change script run directory
|
77
|
+
scriptdir = script
|
78
|
+
|
79
|
+
# if present, you can `rebuild` without argument
|
80
|
+
repo = k0kubun/dotfiles
|
81
|
+
|
82
|
+
# cloned directory path
|
83
|
+
directory = ~/src/github.com/k0kubun/dotfiles
|
84
|
+
```
|
85
|
+
|
56
86
|
## Supported OS
|
57
87
|
|
58
88
|
- 10.10 Yosemite
|
@@ -62,8 +92,7 @@ Prior to 10.8 Mountain Lion, features except command line tools installation are
|
|
62
92
|
|
63
93
|
## TODO
|
64
94
|
|
65
|
-
-
|
66
|
-
- more flexible upstream pull
|
95
|
+
- Write test with rspec
|
67
96
|
|
68
97
|
## License
|
69
98
|
|
data/lib/rebuild/cli.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rebuild'
|
2
2
|
require 'optparse'
|
3
|
+
require 'unindent'
|
3
4
|
|
4
5
|
module Rebuild
|
5
6
|
class CLI
|
@@ -10,7 +11,9 @@ module Rebuild
|
|
10
11
|
|
11
12
|
class << self
|
12
13
|
def start
|
13
|
-
|
14
|
+
@installed = CommandLineTools.installed?
|
15
|
+
@gitconfig = GitConfig.instance
|
16
|
+
options = DEFAULT_OPTIONS.merge(@gitconfig.rebuild_config)
|
14
17
|
|
15
18
|
opt = OptionParser.new
|
16
19
|
opt.on('-v', '--version') { |v| options[:version] = true }
|
@@ -20,19 +23,21 @@ module Rebuild
|
|
20
23
|
|
21
24
|
args = opt.parse!(ARGV)
|
22
25
|
return print_version if options[:version]
|
23
|
-
return show_usage if args.empty? && CommandLineTools.installed?
|
24
26
|
|
25
27
|
CommandLineTools.install unless CommandLineTools.installed?
|
26
28
|
License.agree unless License.agreed?
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
stdin = STDIN.read unless STDIN.isatty
|
31
|
+
if args.empty?
|
32
|
+
if options[:repo]
|
33
|
+
bootstrap(options[:repo], stdin, options)
|
34
|
+
elsif @installed
|
35
|
+
show_usage
|
36
|
+
end
|
37
|
+
elsif args.first.include?('/')
|
38
|
+
bootstrap(args.first, stdin, options)
|
34
39
|
else
|
35
|
-
run_command(
|
40
|
+
run_command(args.first)
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
@@ -49,7 +54,10 @@ module Rebuild
|
|
49
54
|
def run_command(command)
|
50
55
|
case command
|
51
56
|
when 'brew'
|
57
|
+
# This is a secret feature because it is not so useful now
|
52
58
|
command_brew
|
59
|
+
when 'config'
|
60
|
+
command_config
|
53
61
|
else
|
54
62
|
puts "Command #{command} is not found."
|
55
63
|
puts
|
@@ -65,12 +73,20 @@ module Rebuild
|
|
65
73
|
end
|
66
74
|
end
|
67
75
|
|
76
|
+
def command_config
|
77
|
+
if @gitconfig.has_rebuild_config?
|
78
|
+
puts '.gitconfig is already initialized for rebuild.'
|
79
|
+
else
|
80
|
+
@gitconfig.add_rebuild_config
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
68
84
|
def show_usage
|
69
|
-
puts
|
85
|
+
puts <<-EOS.unindent
|
70
86
|
Commands:
|
71
87
|
rebuild install command line tools, done
|
72
88
|
rebuild USER/PROJECT execute all scripts in GitHub repo's root directory
|
73
|
-
rebuild
|
89
|
+
rebuild config add rebuild config template to ~/.gitconfig
|
74
90
|
|
75
91
|
Options:
|
76
92
|
-v, [--version] Print version
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rebuild'
|
2
|
+
require 'singleton'
|
3
|
+
require 'parseconfig'
|
4
|
+
|
5
|
+
module Rebuild
|
6
|
+
class GitConfig
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
return unless File.exists?(gitconfig_path)
|
11
|
+
@config = ParseConfig.new(gitconfig_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def has_rebuild_config?
|
15
|
+
@config.params["rebuild"] != nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_rebuild_config
|
19
|
+
git_config =
|
20
|
+
if File.exists?(gitconfig_path)
|
21
|
+
File.read(gitconfig_path)
|
22
|
+
else
|
23
|
+
''
|
24
|
+
end
|
25
|
+
rebuild_config = <<-EOS.unindent
|
26
|
+
[rebuild]
|
27
|
+
# if true, everytime git pull
|
28
|
+
update = false
|
29
|
+
|
30
|
+
# you can change script run directory
|
31
|
+
scriptdir = /
|
32
|
+
|
33
|
+
# if present, you can `rebuild` without argument
|
34
|
+
# repo = username/dotfiles
|
35
|
+
|
36
|
+
# cloned directory path
|
37
|
+
# directory = ~/src/dotfiles
|
38
|
+
EOS
|
39
|
+
|
40
|
+
File.write(gitconfig_path, "#{git_config}\n#{rebuild_config}")
|
41
|
+
Logger.info('Succeed to update ~/.gitconfig')
|
42
|
+
end
|
43
|
+
|
44
|
+
def rebuild_config
|
45
|
+
symbolize_keys(@config.params["rebuild"] || {})
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def symbolize_keys(hash)
|
51
|
+
symbolized = {}
|
52
|
+
|
53
|
+
hash.each do |key, value|
|
54
|
+
symbolized[key.to_sym] = normalize_value(value)
|
55
|
+
end
|
56
|
+
symbolized
|
57
|
+
end
|
58
|
+
|
59
|
+
# TODO: Migrate from parseconfig
|
60
|
+
def normalize_value(value)
|
61
|
+
case value
|
62
|
+
when 'true'
|
63
|
+
true
|
64
|
+
when 'false'
|
65
|
+
false
|
66
|
+
else
|
67
|
+
value
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def gitconfig_path
|
72
|
+
File.expand_path('~/.gitconfig')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/rebuild/logger.rb
CHANGED
data/lib/rebuild/version.rb
CHANGED
data/rebuild.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_runtime_dependency "unindent", "~> 1.0"
|
22
|
+
spec.add_runtime_dependency "parseconfig", "~> 1.0.6"
|
21
23
|
spec.add_development_dependency "pry", "~> 0.10"
|
22
24
|
spec.add_development_dependency "bundler", "~> 1.7"
|
23
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rebuild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: unindent
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: parseconfig
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.6
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: pry
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +101,7 @@ files:
|
|
73
101
|
- lib/rebuild.rb
|
74
102
|
- lib/rebuild/cli.rb
|
75
103
|
- lib/rebuild/command_line_tools.rb
|
104
|
+
- lib/rebuild/git_config.rb
|
76
105
|
- lib/rebuild/homebrew.rb
|
77
106
|
- lib/rebuild/license.rb
|
78
107
|
- lib/rebuild/logger.rb
|