bin_install 0.0.6 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b60f285eadaf3e28288b02505d085339c566b5d5
4
- data.tar.gz: 3f509887bcc072b5e1048416175bec8185370053
2
+ SHA256:
3
+ metadata.gz: 96f9c33f5d35b85b9836e6a3232b10e1054884c631a6b4d13fadb059823a15bd
4
+ data.tar.gz: f57792c95e3adabf40ebf6dfc0a7b34407802da95aa82091251434022a901e69
5
5
  SHA512:
6
- metadata.gz: 67e204865a474c81d5eed57e01ac200678bdd9d94e15f38bbaba4559e724e3b454f4570cfee0cdf2f2be9181fdd29bba0431a350b055d6fd9bf3f1f547450e61
7
- data.tar.gz: 3a8304046f51d80ac8783c0c14de51a0f39efbc9725b9070c2a55e8eca3b718987b38b94df9b9002ef877177ee08a9daa8bb0c18dadbc912c2822a3b590d06e9
6
+ metadata.gz: 2b074c09735d1d11638db627d3d13bf724a4ccedbfde6680753c519ea033ffdc2773c2a427ceb75c35a366c5098a9780976a774ee21de9bf45cd38439ae0e26f
7
+ data.tar.gz: d843aad8c2309e77d3fb1efe34ac23ea15015ba5b2c03308a5fb8096ac50e326af891eeac9b4689106b02c09c72d76f11b187b4940a91826012e2f7c648e4968
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/README.md CHANGED
@@ -26,6 +26,20 @@ Will create the following files with some common defaults:
26
26
 
27
27
  Most methods in this library have also have a bang version that will halt all further execution. No bang methods will only display the error output of the command but execution will continue.
28
28
 
29
+ ### Atom
30
+
31
+ Install [Atom](https://atom.io/):
32
+
33
+ BinInstall::Atom.install # or install!
34
+
35
+ Ask before installing [Atom](https://atom.io/):
36
+
37
+ BinInstall::Atom.ask # or ask!
38
+
39
+ Ask before installing popular [packages](https://atom.io/packages):
40
+
41
+ BinInstall::Atom::Package.ask_popular # or ask_popular!
42
+
29
43
  ### Brew
30
44
 
31
45
  Require [Homebrew](https://brew.sh/) before continuing:
@@ -38,15 +52,15 @@ Update [Homebrew](https://brew.sh/):
38
52
 
39
53
  Install [Homebrew](https://brew.sh/) package:
40
54
 
41
- BinInstall::Brew.install('package') # or install!('package')
55
+ BinInstall::Brew::Package.install('package') # or install!('package')
42
56
 
43
57
  Upgrade [Homebrew](https://brew.sh/) package:
44
58
 
45
- BinInstall::Brew.upgrade('package') # upgrade!('package')
59
+ BinInstall::Brew::Package.upgrade('package') # upgrade!('package')
46
60
 
47
61
  Install or Upgrade with one command:
48
62
 
49
- BinInstall::Brew.install_or_upgrade('package') # or install_or_upgrade!('package')
63
+ BinInstall::Brew::Package.install_or_upgrade('package') # or install_or_upgrade!('package')
50
64
 
51
65
  ### Gem
52
66
 
@@ -137,3 +151,9 @@ Forcefully kill the server with:
137
151
  ## Contributing
138
152
 
139
153
  All pull requests must pass [RuboCop](https://github.com/bbatsov/rubocop).
154
+
155
+ # TODO
156
+
157
+ - [] GitHub SSH stuff
158
+ - [] Mysql dev stuff
159
+ - [] test brew install without root
data/bin/build ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'awesome_print'
5
+ require 'bin_install'
6
+
7
+ puts "Building bin_install #{BinInstall::VERSION}.".white
8
+ system('git pull origin master')
9
+ system('gem build bin_install.gemspec')
10
+ system("gem install bin_install-#{BinInstall::VERSION}.gem")
11
+ puts 'Done.'.green
data/bin/setup CHANGED
@@ -4,5 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/bin_install.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = 'david@ramaboo.com'
11
11
 
12
12
  spec.summary = 'Simple DSL for creating install scripts.'
13
- spec.description = 'Simple DSL for creating install scripts.'
13
+ spec.description = 'Create install scripts without the complexity of shell commands.'
14
14
  spec.homepage = 'https://github.com/ramaboo/bin_install'
15
15
  spec.license = 'MIT'
16
16
 
@@ -22,11 +22,10 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ['lib']
23
23
 
24
24
  spec.add_runtime_dependency 'awesome_print', '~> 1.8'
25
- spec.add_runtime_dependency('railties', '>= 4.2.0', '< 6.0')
26
25
 
27
26
  spec.add_development_dependency 'bundler', '~> 1.16'
28
- spec.add_development_dependency 'pry', '>= 0.10.0'
29
- spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'pry', '~> 0.11'
28
+ spec.add_development_dependency 'rake', '~> 12'
30
29
  spec.add_development_dependency 'rspec', '~> 3.6'
31
30
  spec.add_development_dependency 'rubocop', '~> 0.56.0'
32
31
  end
@@ -0,0 +1,44 @@
1
+ module BinInstall
2
+ module Brew
3
+ module Package
4
+ # https://atom.io/packages/list?direction=desc&sort=downloads
5
+ POPULAR_PACKAGES = %w[file-icons minimap atom-beautify linter linter-ui-default pigments git-plus busy-signal linter-eslint react].freeze
6
+
7
+ def self.ask_popular
8
+ return unless installed?
9
+
10
+ print 'Would you like to install popular packages for Atom? [Y/n]: '
11
+ install_popular if Shell.default_yes?(gets.chomp)
12
+ end
13
+
14
+ def self.ask_popular!
15
+ print 'Would you like to install popular packages for Atom? [Y/n]: '
16
+ install_popular! if Shell.default_yes?(gets.chomp)
17
+ end
18
+
19
+ def self.install_popular
20
+ return unless installed?
21
+
22
+ puts 'Installing popular Atom packages...'.white
23
+ POPULAR_PACKAGES.each { |p| install(p) }
24
+ end
25
+
26
+ def self.install_popular!
27
+ puts 'Installing popular Atom packages...'.white
28
+ POPULAR_PACKAGES.each { |p| install!(p) }
29
+ end
30
+
31
+ def self.install(package)
32
+ system("apm install #{package}")
33
+ end
34
+
35
+ def self.install!(package)
36
+ BinInstall.system!("apm install #{package}")
37
+ end
38
+
39
+ def self.installed?
40
+ Shell.executable_exists?('apm')
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,37 @@
1
+ require 'bin_install/atom/package'
2
+
3
+ module BinInstall
4
+ module Atom
5
+ def self.install
6
+ if installed?
7
+ puts 'Atom already installed. Skipping.'.blue
8
+ else
9
+ Brew::Cask.install('atom')
10
+ end
11
+ end
12
+
13
+ def self.install!
14
+ if installed?
15
+ puts 'Atom already installed. Skipping.'.blue
16
+ else
17
+ Brew::Cask.install!('atom')
18
+ end
19
+ end
20
+
21
+ def self.ask
22
+ return if installed?
23
+
24
+ print 'Would you like to install Atom? [Y/n]: '
25
+ install if Shell.default_yes?(gets.chomp)
26
+ end
27
+
28
+ def self.ask!
29
+ print 'Would you like to install Atom? [Y/n]: '
30
+ install! if Shell.default_yes?(gets.chomp)
31
+ end
32
+
33
+ def self.installed?
34
+ Shell.executable_exists?('atom')
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ module BinInstall
2
+ module Brew
3
+ module Cask
4
+ def self.install(package)
5
+ system("brew cask install #{package}")
6
+ end
7
+
8
+ def self.install!(package)
9
+ BinInstall.system!("brew cask install #{package}")
10
+ end
11
+
12
+ def self.tap
13
+ system('brew tap caskroom/cask')
14
+ end
15
+
16
+ def self.tap!
17
+ BinInstall.system!('brew tap caskroom/cask')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,53 @@
1
+ module BinInstall
2
+ module Brew
3
+ module Package
4
+ def self.install(package)
5
+ system("brew install #{package}")
6
+ end
7
+
8
+ def self.install!(package)
9
+ BinInstall.system!("brew install #{package}")
10
+ end
11
+
12
+ def self.upgrade(package)
13
+ if latest_version?(package)
14
+ puts "#{package} is already the latest version. Skipping.".blue
15
+ else
16
+ system("brew upgrade #{package}")
17
+ end
18
+ end
19
+
20
+ def self.upgrade!(package)
21
+ if latest_version?(package)
22
+ puts "#{package} is already the latest version. Skipping.".blue
23
+ else
24
+ BinInstall.system!("brew upgrade #{package}")
25
+ end
26
+ end
27
+
28
+ def self.install_or_upgrade(package)
29
+ if installed?(package)
30
+ upgrade(package)
31
+ else
32
+ install(package)
33
+ end
34
+ end
35
+
36
+ def self.install_or_upgrade!(package)
37
+ if installed?(package)
38
+ upgrade!(package)
39
+ else
40
+ install!(package)
41
+ end
42
+ end
43
+
44
+ def self.installed?(package)
45
+ system("brew list --versions #{package}")
46
+ end
47
+
48
+ def self.latest_version?(package)
49
+ system("brew outdated #{package}")
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,80 @@
1
+ module BinInstall
2
+ module Brew
3
+ module Service
4
+ def self.run(service)
5
+ if started?(service)
6
+ puts "Service #{service} already started. Skipping.".blue
7
+ else
8
+ system("brew services run #{service}")
9
+ end
10
+ end
11
+
12
+ def self.run!(service)
13
+ if started?(service)
14
+ puts "Service #{service} already started. Skipping.".blue
15
+ else
16
+ BinInstall.system!("brew services run #{service}")
17
+ end
18
+ end
19
+
20
+ def self.start(service)
21
+ if started?(service)
22
+ puts "Service #{service} already started. Skipping.".blue
23
+ else
24
+ system("brew services start #{service}")
25
+ end
26
+ end
27
+
28
+ def self.start!(service)
29
+ if started?(service)
30
+ puts "Service #{service} already started. Skipping.".blue
31
+ else
32
+ BinInstall.system!("brew services start #{service}")
33
+ end
34
+ end
35
+
36
+ def self.stop(service)
37
+ if stopped?(service)
38
+ puts "Service #{service} already stopped. Skipping.".blue
39
+ else
40
+ system("brew services stop #{service}")
41
+ end
42
+ end
43
+
44
+ def self.stop!(service)
45
+ if stopped?(service)
46
+ puts "Service #{service} already stopped. Skipping.".blue
47
+ else
48
+ BinInstall.system!("brew services stop #{service}")
49
+ end
50
+ end
51
+
52
+ def self.restart(service)
53
+ system("brew services restart #{service}")
54
+ end
55
+
56
+ def self.restart!(service)
57
+ BinInstall.system!("brew services restart #{service}")
58
+ end
59
+
60
+ def self.started?(service)
61
+ services[service.to_sym] == :started
62
+ end
63
+
64
+ def self.stopped?(service)
65
+ services[service.to_sym] == :stopped
66
+ end
67
+
68
+ def self.services
69
+ output = `brew services list`
70
+ lines = output.split("\n")
71
+ lines.shift # Remove header from table.
72
+
73
+ lines.map do |row|
74
+ columns = row.split(' ')
75
+ [columns[0].to_sym, columns[1].to_sym]
76
+ end.to_h
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,75 +1,56 @@
1
+ require 'bin_install/brew/cask'
2
+ require 'bin_install/brew/package'
3
+ require 'bin_install/brew/service'
4
+
1
5
  module BinInstall
2
6
  module Brew
3
7
  def self.require!
4
8
  if installed?
5
9
  update!
6
10
  else
7
- abort('Homebrew is required! Visit https://brew.sh/ to install.'.red)
11
+ puts 'Homebrew is required.'.red
12
+ puts 'Visit https://brew.sh/ for more information.'
13
+ ask!
14
+ abort('Can not continue without Homebrew.'.red) unless installed?
8
15
  end
9
16
  end
10
17
 
11
- def self.update
12
- puts 'Updating Homebrew...'.white
13
- system('brew update')
14
- system('brew tap caskroom/cask')
15
- end
16
-
17
- def self.update!
18
- puts 'Updating Homebrew...'.white
19
- BinInstall.system!('brew update')
20
- BinInstall.system!('brew tap caskroom/cask')
18
+ def self.install
19
+ puts 'Installing Homebrew...'.white
20
+ system('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
21
21
  end
22
22
 
23
- def self.install(package)
24
- system("brew install #{package}")
23
+ def self.install!
24
+ puts 'Installing Homebrew...'.white
25
+ BinInstall.system!('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
25
26
  end
26
27
 
27
- def self.install!(package)
28
- BinInstall.system!("brew install #{package}")
29
- end
28
+ def self.ask
29
+ return if installed?
30
30
 
31
- def self.upgrade(package)
32
- if package_latest_version?(package)
33
- puts "#{package} is already the latest version. Skipping.".blue
34
- else
35
- system("brew upgrade #{package}")
36
- end
31
+ print 'Would you like to install Homebrew? [Y/n]: '
32
+ install if Shell.default_yes?(gets.chomp)
37
33
  end
38
34
 
39
- def self.upgrade!(package)
40
- if package_latest_version?(package)
41
- puts "#{package} is already the latest version. Skipping.".blue
42
- else
43
- BinInstall.system!("brew upgrade #{package}")
44
- end
35
+ def self.ask!
36
+ print 'Would you like to install Homebrew? [Y/n]: '
37
+ install! if Shell.default_yes?(gets.chomp)
45
38
  end
46
39
 
47
- def self.install_or_upgrade(package)
48
- if package_installed?(package)
49
- upgrade(package)
50
- else
51
- install(package)
52
- end
40
+ def self.update
41
+ puts 'Updating Homebrew...'.white
42
+ system('brew update')
43
+ Cask.tap
53
44
  end
54
45
 
55
- def self.install_or_upgrade!(package)
56
- if package_installed?(package)
57
- upgrade!(package)
58
- else
59
- install!(package)
60
- end
46
+ def self.update!
47
+ puts 'Updating Homebrew...'.white
48
+ BinInstall.system!('brew update')
49
+ Cask.tap!
61
50
  end
62
51
 
63
52
  def self.installed?
64
- system('brew --version')
65
- end
66
-
67
- def self.package_installed?(package)
68
- system("brew list --versions #{package}")
69
- end
70
-
71
- def self.package_latest_version?(package)
72
- system("brew outdated #{package}")
53
+ Shell.executable_exists?('brew')
73
54
  end
74
55
  end
75
56
  end
@@ -11,5 +11,9 @@ module BinInstall
11
11
  BinInstall.system!('gem install bundler --conservative')
12
12
  BinInstall.system!('bundle install')
13
13
  end
14
+
15
+ def self.installed?
16
+ Shell.executable_exists?('gem')
17
+ end
14
18
  end
15
19
  end
@@ -2,12 +2,12 @@ module BinInstall
2
2
  module Git
3
3
  def self.install
4
4
  puts 'Installing Git...'.white
5
- Brew.install_or_upgrade('git')
5
+ Brew::Package.install_or_upgrade('git')
6
6
  end
7
7
 
8
8
  def self.install!
9
9
  puts 'Installing Git...'.white
10
- Brew.install_or_upgrade!('git')
10
+ Brew::Package.install_or_upgrade!('git')
11
11
  end
12
12
 
13
13
  def self.add_remote(name, url)
@@ -26,8 +26,12 @@ module BinInstall
26
26
  end
27
27
  end
28
28
 
29
- def remote?(name)
29
+ def self.remote?(name)
30
30
  system("git remote get-url #{name}")
31
31
  end
32
+
33
+ def self.installed?
34
+ Shell.executable_exists?('git')
35
+ end
32
36
  end
33
37
  end
@@ -2,14 +2,14 @@ module BinInstall
2
2
  module Mysql
3
3
  def self.install
4
4
  puts 'Installing MySQL...'.white
5
- Brew.install_or_upgrade('mysql')
6
- system('brew services start mysql')
5
+ Brew::Package.install_or_upgrade('mysql')
6
+ Brew::Service.start('mysql')
7
7
  end
8
8
 
9
9
  def self.install!
10
10
  puts 'Installing MySQL...'.white
11
- Brew.install_or_upgrade!('mysql')
12
- BinInstall.system!('brew services start mysql')
11
+ Brew::Package.install_or_upgrade!('mysql')
12
+ Brew::Service.start!('mysql')
13
13
  end
14
14
 
15
15
  def self.create_root
@@ -29,5 +29,9 @@ module BinInstall
29
29
  BinInstall.system!(%(mysql --user=root --execute="CREATE USER '#{username}'@'localhost' IDENTIFIED BY '#{password}';"))
30
30
  BinInstall.system!(%(mysql --user=root --execute="GRANT ALL PRIVILEGES ON *.* TO '#{username}'@'localhost' WITH GRANT OPTION;"))
31
31
  end
32
+
33
+ def self.installed?
34
+ Shell.executable_exists?('mysql')
35
+ end
32
36
  end
33
37
  end
@@ -1,31 +1,19 @@
1
1
  module BinInstall
2
2
  module Node
3
3
  def self.install
4
- Brew.install_or_upgrade('node')
5
- Brew.install_or_upgrade('yarn')
6
- yarn_install
4
+ Brew::Package.install_or_upgrade('node')
5
+ Brew::Package.install_or_upgrade('yarn')
6
+ Yarn.install
7
7
  end
8
8
 
9
9
  def self.install!
10
- Brew.install_or_upgrade!('node')
11
- Brew.install_or_upgrade!('yarn')
12
- yarn_install!
10
+ Brew::Package.install_or_upgrade!('node')
11
+ Brew::Package.install_or_upgrade!('yarn')
12
+ Yarn.install!
13
13
  end
14
14
 
15
- def self.yarn_install
16
- system('bin/yarn install')
17
- end
18
-
19
- def self.yarn_install!
20
- BinInstall.system!('bin/yarn install')
21
- end
22
-
23
- def self.yarn_upgrade
24
- system('bin/yarn upgrade')
25
- end
26
-
27
- def self.yarn_upgrade!
28
- BinInstall.system!('bin/yarn upgrade')
15
+ def self.installed?
16
+ Shell.executable_exists?('node')
29
17
  end
30
18
  end
31
19
  end
@@ -0,0 +1,25 @@
1
+ module BinInstall
2
+ module OhMyZsh
3
+ def self.require!
4
+ abort('Oh My Zsh is required. Visit http://ohmyz.sh/ to install.'.red) unless installed?
5
+ end
6
+
7
+ def self.install
8
+ puts 'Installing Oh My Zsh...'.white
9
+ Brew::Package.install_or_upgrade('zsh')
10
+ Brew::Package.install_or_upgrade('zsh-completions')
11
+ system(%(sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"))
12
+ end
13
+
14
+ def self.install!
15
+ puts 'Installing Oh My Zsh...'.white
16
+ Brew::Package.install_or_upgrade!('zsh')
17
+ Brew::Package.install_or_upgrade!('zsh-completions')
18
+ BinInstall.system!(%(sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"))
19
+ end
20
+
21
+ def self.installed?
22
+ Shell.executable_exists?('zsh')
23
+ end
24
+ end
25
+ end
@@ -2,12 +2,12 @@ module BinInstall
2
2
  module Postgres
3
3
  def self.install
4
4
  puts 'Installing PostgreSQL...'.white
5
- Brew.install_or_upgrade('postgresql')
5
+ Brew::Package.install_or_upgrade('postgresql')
6
6
  end
7
7
 
8
8
  def self.install!
9
9
  puts 'Installing PostgreSQL...'.white
10
- Brew.install_or_upgrade!('postgresql')
10
+ Brew::Package.install_or_upgrade!('postgresql')
11
11
  end
12
12
 
13
13
  def self.create_superuser(username = 'postgres')
@@ -25,5 +25,9 @@ module BinInstall
25
25
  def self.create_user!(username = 'postgres')
26
26
  BinInstall.system!("createuser #{username}")
27
27
  end
28
+
29
+ def self.installed?
30
+ Shell.executable_exists?('psql')
31
+ end
28
32
  end
29
33
  end
@@ -1,5 +1,3 @@
1
- require 'rails'
2
-
3
1
  module BinInstall
4
2
  module Rails
5
3
  def self.db_setup
@@ -53,7 +51,10 @@ module BinInstall
53
51
  end
54
52
 
55
53
  def self.rails5?
54
+ require 'rails'
56
55
  ::Rails::VERSION::MAJOR >= 5
56
+ rescue LoadError
57
+ false
57
58
  end
58
59
  end
59
60
  end
@@ -2,12 +2,16 @@ module BinInstall
2
2
  module Redis
3
3
  def self.install
4
4
  puts 'Installing Redis...'.white
5
- Brew.install_or_upgrade('redis')
5
+ Brew::Package.install_or_upgrade('redis')
6
6
  end
7
7
 
8
8
  def self.install!
9
9
  puts 'Installing Redis...'.white
10
- Brew.install_or_upgrade!('redis')
10
+ Brew::Package.install_or_upgrade!('redis')
11
+ end
12
+
13
+ def self.installed?
14
+ Shell.executable_exists?('redis-server')
11
15
  end
12
16
  end
13
17
  end
@@ -1,42 +1,112 @@
1
1
  module BinInstall
2
2
  module RubyEnvironmentManager
3
- module Rbevn
4
- def self.install(version = nil)
3
+ module Rbenv
4
+ def self.install
5
+ if installed?
6
+ puts 'rbenv is already installed. Skipping.'.blue
7
+ Brew::Package.upgrade('rbenv')
8
+ Brew::Package.install_or_upgrade('ruby-build')
9
+ else
10
+ first_install
11
+ end
12
+ end
13
+
14
+ def self.install!
15
+ if installed?
16
+ puts 'rbenv is already installed. Skipping.'.blue
17
+ Brew::Package.upgrade!('rbenv')
18
+ Brew::Package.install_or_upgrade!('ruby-build')
19
+ else
20
+ first_install!
21
+ end
22
+ end
23
+
24
+ def self.first_install
5
25
  puts 'Installing rbenv...'.white
6
- Brew.install_or_upgrade('rbenv')
7
- Brew.install_or_upgrade('ruby-build')
8
- install_ruby(version)
26
+ Brew::Package.install('rbenv')
27
+ Brew::Package.install_or_upgrade('ruby-build')
28
+ Shell.append_to_profiles(%{eval "$(rbenv init -)"\n})
29
+
30
+ version
31
+ rehash
32
+ doctor
33
+ reload_shell!
9
34
  end
10
35
 
11
- def self.install!(version = nil)
36
+ def self.first_install!
12
37
  puts 'Installing rbenv...'.white
13
- Brew.install_or_upgrade!('rbenv')
14
- Brew.install_or_upgrade!('ruby-build')
15
- install_ruby!(version)
38
+ Brew::Package.install!('rbenv')
39
+ Brew::Package.install_or_upgrade!('ruby-build')
40
+ Shell.append_to_profiles(%{eval "$(rbenv init -)"\n})
41
+
42
+ version!
43
+ rehash!
44
+ doctor!
45
+ reload_shell!
46
+ end
47
+
48
+ def self.reload_shell!
49
+ puts 'Shell must be reloaded.'.red
50
+ puts 'Close this window and restart installer with:'
51
+ puts '$ gem install bin_install'.yellow
52
+ puts '$ bin/install'.yellow
53
+ abort('Can not continue until shell is reloaded.'.red)
16
54
  end
17
55
 
18
56
  def self.install_ruby(version = nil)
19
- version ||= RubyEnvironmentManager.ruby_version
57
+ version ||= RubyEnvironmentManager.required_ruby_version
20
58
 
21
59
  if version
22
- system("rbenv install #{version}")
60
+ if RubyEnvironmentManager.ruby_version_installed?(version)
61
+ puts "Ruby #{version} is already installed. Skipping.".blue
62
+ else
63
+ system("rbenv install #{version}")
64
+ end
23
65
  else
24
- puts 'Unknown Ruby version. Create `.ruby-version` file.'
66
+ puts 'Unknown Ruby version. Create .ruby-version file.'
25
67
  end
26
68
  end
27
69
 
28
70
  def self.install_ruby!(version = nil)
29
- version ||= RubyEnvironmentManager.ruby_version
71
+ version ||= RubyEnvironmentManager.required_ruby_version
30
72
 
31
73
  if version
32
- BinInstall.system!("rbenv install #{version}")
74
+ if RubyEnvironmentManager.ruby_version_installed?(version)
75
+ puts "Ruby #{version} is already installed. Skipping.".blue
76
+ else
77
+ BinInstall.system!("rbenv install #{version}")
78
+ end
33
79
  else
34
- abort('Unknown Ruby version. Create `.ruby-version` file.')
80
+ abort('Unknown Ruby version. Create .ruby-version file.'.red)
35
81
  end
36
82
  end
37
83
 
84
+ def self.doctor
85
+ system('curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash')
86
+ end
87
+
88
+ def self.doctor!
89
+ BinInstall.system!('curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash')
90
+ end
91
+
92
+ def self.rehash
93
+ system('rbenv rehash')
94
+ end
95
+
96
+ def self.rehash!
97
+ BinInstall.system!('rbenv rehash')
98
+ end
99
+
100
+ def self.version
101
+ system('rbenv version')
102
+ end
103
+
104
+ def self.version!
105
+ BinInstall.system!('rbenv version')
106
+ end
107
+
38
108
  def self.installed?
39
- system('rbenv --version')
109
+ Shell.executable_exists?('rbenv')
40
110
  end
41
111
  end
42
112
  end
@@ -2,27 +2,29 @@ module BinInstall
2
2
  module RubyEnvironmentManager
3
3
  module Rvm
4
4
  def self.install_ruby(version = nil)
5
- version ||= RubyEnvironmentManager.ruby_version
5
+ version ||= RubyEnvironmentManager.required_ruby_version
6
6
 
7
7
  if version
8
8
  system("rvm install #{version}")
9
+ system("rvm use #{version}")
9
10
  else
10
- puts 'Unknown Ruby version. Create `.ruby-version` file.'
11
+ puts 'Unknown Ruby version. Create .ruby-version file.'
11
12
  end
12
13
  end
13
14
 
14
15
  def self.install_ruby!(version = nil)
15
- version ||= RubyEnvironmentManager.ruby_version
16
+ version ||= RubyEnvironmentManager.required_ruby_version
16
17
 
17
18
  if version
18
19
  BinInstall.system!("rvm install #{version}")
20
+ BinInstall.system!("rvm use #{version}")
19
21
  else
20
- abort('Unknown Ruby version. Create `.ruby-version` file.')
22
+ abort('Unknown Ruby version. Create .ruby-version file.'.red)
21
23
  end
22
24
  end
23
25
 
24
26
  def self.installed?
25
- system('rvm --version')
27
+ Shell.executable_exists?('rvm')
26
28
  end
27
29
  end
28
30
  end
@@ -3,28 +3,59 @@ require 'bin_install/ruby_environment_manager/rvm'
3
3
 
4
4
  module BinInstall
5
5
  module RubyEnvironmentManager
6
- def self.install(version = nil)
6
+ def self.install
7
7
  if RubyEnvironmentManager::Rvm.installed?
8
8
  puts 'RVM is already installed. Skipping rbenv install.'.blue
9
- RubyEnvironmentManager::Rvm.install_ruby(version)
10
- return
9
+ else
10
+ RubyEnvironmentManager::Rbenv.install
11
11
  end
12
12
 
13
- RubyEnvironmentManager::Rbenv.install(version)
13
+ install_ruby
14
14
  end
15
15
 
16
- def self.install!(version = nil)
16
+ def self.install!
17
17
  if RubyEnvironmentManager::Rvm.installed?
18
18
  puts 'RVM is already installed. Skipping rbenv install.'.blue
19
- RubyEnvironmentManager::Rvm.install_ruby!(version)
20
- return
19
+ else
20
+ RubyEnvironmentManager::Rbenv.install!
21
21
  end
22
22
 
23
- RubyEnvironmentManager::Rbenv.install!(version)
23
+ install_ruby!
24
24
  end
25
25
 
26
- def self.ruby_version
26
+ def self.install_ruby(version = nil)
27
+ case find_environment_manager!
28
+ when :rbenv then RubyEnvironmentManager::Rbenv.install_ruby(version)
29
+ when :rvm then RubyEnvironmentManager::Rvm.install_ruby(version)
30
+ end
31
+ end
32
+
33
+ def self.install_ruby!(version = nil)
34
+ case find_environment_manager!
35
+ when :rbenv then RubyEnvironmentManager::Rbenv.install_ruby(version)
36
+ when :rvm then RubyEnvironmentManager::Rvm.install_ruby(version)
37
+ end
38
+ end
39
+
40
+ def self.required_ruby_version
27
41
  Dir.chdir(Dir.pwd) { `cat .ruby-version` }
28
42
  end
43
+
44
+ def self.ruby_version
45
+ Dir.chdir(Dir.pwd) { `ruby --version` }
46
+ end
47
+
48
+ def self.ruby_version_installed?(version)
49
+ ruby_version.start_with?("ruby #{version}")
50
+ end
51
+
52
+ def self.find_environment_manager
53
+ return :rbenv if RubyEnvironmentManager::Rbenv.installed?
54
+ return :rvm if RubyEnvironmentManager::Rvm.installed?
55
+ end
56
+
57
+ def self.find_environment_manager!
58
+ find_environment_manager || abort('No Ruby environment manager found.'.red)
59
+ end
29
60
  end
30
61
  end
@@ -8,9 +8,9 @@ module BinInstall
8
8
  server_pid = `cat tmp/pids/server.pid`
9
9
 
10
10
  if system("kill -9 #{server_pid}")
11
- puts "PID `#{server_pid}` killed.".green
11
+ puts "PID #{server_pid} killed.".green
12
12
  else
13
- puts "PID `#{server_pid}` can not be killed!".red
13
+ puts "PID #{server_pid} can not be killed!".red
14
14
  end
15
15
  end
16
16
  end
@@ -23,9 +23,9 @@ module BinInstall
23
23
  server_pid = `cat tmp/pids/server.pid`
24
24
 
25
25
  if system("kill -9 #{server_pid}")
26
- puts "PID `#{server_pid}` killed.".green
26
+ puts "PID #{server_pid} killed.".green
27
27
  else
28
- abort("PID `#{server_pid}` can not be killed!".red)
28
+ abort("PID #{server_pid} can not be killed!".red)
29
29
  end
30
30
  end
31
31
  end
@@ -0,0 +1,42 @@
1
+ module BinInstall
2
+ module Shell
3
+ def self.yes?(value)
4
+ %w[y yes].include?(value.downcase)
5
+ end
6
+
7
+ def self.default_yes?(value)
8
+ ['', 'y', 'yes'].include?(value.downcase)
9
+ end
10
+
11
+ def self.no?(value)
12
+ %w[n no].include?(value.downcase)
13
+ end
14
+
15
+ def self.default_no?(value)
16
+ ['', 'n', 'no'].include?(value.downcase)
17
+ end
18
+
19
+ def self.executable_exists?(executable)
20
+ system("which #{executable}")
21
+ end
22
+
23
+ def self.append_to_profiles(value)
24
+ profile_paths.each do |path|
25
+ file = File.open(path, 'a+')
26
+
27
+ if file.read.include?(value)
28
+ puts "Value already exist in #{path}. Skipping.".blue
29
+ else
30
+ puts "Writing to #{path}:\n#{value.to_s.purple}"
31
+ file << value.to_s
32
+ end
33
+
34
+ file.close
35
+ end
36
+ end
37
+
38
+ def self.profile_paths
39
+ [File.expand_path('~/.zshrc'), File.expand_path('.bash_profile')]
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module BinInstall
2
- VERSION = '0.0.6'.freeze
2
+ VERSION = '0.0.9'.freeze
3
3
  end
@@ -0,0 +1,11 @@
1
+ module BinInstall
2
+ module Xcode
3
+ def self.install
4
+ system('xcode-select --install')
5
+ end
6
+
7
+ def self.install!
8
+ BinInstall.system!('xcode-select --install')
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ module BinInstall
2
+ module Yarn
3
+ def self.install
4
+ system('bin/yarn install')
5
+ end
6
+
7
+ def self.install!
8
+ BinInstall.system!('bin/yarn install')
9
+ end
10
+
11
+ def self.upgrade
12
+ system('bin/yarn upgrade')
13
+ end
14
+
15
+ def self.upgrade!
16
+ BinInstall.system!('bin/yarn upgrade')
17
+ end
18
+
19
+ def self.installed?
20
+ Shell.executable_exists?('yarn')
21
+ end
22
+ end
23
+ end
data/lib/bin_install.rb CHANGED
@@ -1,19 +1,25 @@
1
1
  require 'awesome_print'
2
2
 
3
+ require 'bin_install/atom'
3
4
  require 'bin_install/brew'
4
5
  require 'bin_install/gem'
5
6
  require 'bin_install/git'
6
7
  require 'bin_install/mysql'
7
8
  require 'bin_install/node'
9
+ require 'bin_install/oh_my_zsh'
8
10
  require 'bin_install/postgres'
9
11
  require 'bin_install/rails'
12
+ require 'bin_install/redis'
10
13
  require 'bin_install/ruby_environment_manager'
11
14
  require 'bin_install/server'
15
+ require 'bin_install/shell'
12
16
  require 'bin_install/version'
17
+ require 'bin_install/xcode'
18
+ require 'bin_install/yarn'
13
19
 
14
20
  module BinInstall
15
21
  def self.system!(*args)
16
- system(*args) || abort("Command `#{args}` failed!".red)
22
+ system(*args) || abort("Command #{args} failed!".red)
17
23
  end
18
24
 
19
25
  def app_name
@@ -5,11 +5,12 @@ APP_ROOT = File.expand_path('..', __dir__)
5
5
 
6
6
  Dir.chdir(APP_ROOT) do
7
7
  BinInstall::Brew.require!
8
- BinInstall::Gem.install!
9
- BinInstall::Git.install
8
+ BinInstall::OhMyZsh.install
10
9
  BinInstall::RubyEnvironmentManager.install
11
10
  BinInstall::Postgres.install
12
11
  BinInstall::Postgres.create_superuser('postgres')
12
+ BinInstall::Gem.install!
13
+ BinInstall::Git.install
13
14
  BinInstall::Node.install
14
15
  BinInstall::Redis.install
15
16
  BinInstall::Rails.db_setup
@@ -5,7 +5,7 @@ APP_ROOT = File.expand_path('..', __dir__)
5
5
 
6
6
  Dir.chdir(APP_ROOT) do
7
7
  BinInstall::Gem.install!
8
- BinInstall::Node.yarn_install
8
+ BinInstall::Yarn.install
9
9
  BinInstall::Rails.db_migrate
10
10
  BinInstall::Rails.clear
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bin_install
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Singer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-18 00:00:00.000000000 Z
11
+ date: 2018-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -24,26 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.8'
27
- - !ruby/object:Gem::Dependency
28
- name: railties
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 4.2.0
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '6.0'
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 4.2.0
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '6.0'
47
27
  - !ruby/object:Gem::Dependency
48
28
  name: bundler
49
29
  requirement: !ruby/object:Gem::Requirement
@@ -62,30 +42,30 @@ dependencies:
62
42
  name: pry
63
43
  requirement: !ruby/object:Gem::Requirement
64
44
  requirements:
65
- - - ">="
45
+ - - "~>"
66
46
  - !ruby/object:Gem::Version
67
- version: 0.10.0
47
+ version: '0.11'
68
48
  type: :development
69
49
  prerelease: false
70
50
  version_requirements: !ruby/object:Gem::Requirement
71
51
  requirements:
72
- - - ">="
52
+ - - "~>"
73
53
  - !ruby/object:Gem::Version
74
- version: 0.10.0
54
+ version: '0.11'
75
55
  - !ruby/object:Gem::Dependency
76
56
  name: rake
77
57
  requirement: !ruby/object:Gem::Requirement
78
58
  requirements:
79
59
  - - "~>"
80
60
  - !ruby/object:Gem::Version
81
- version: '10.0'
61
+ version: '12'
82
62
  type: :development
83
63
  prerelease: false
84
64
  version_requirements: !ruby/object:Gem::Requirement
85
65
  requirements:
86
66
  - - "~>"
87
67
  - !ruby/object:Gem::Version
88
- version: '10.0'
68
+ version: '12'
89
69
  - !ruby/object:Gem::Dependency
90
70
  name: rspec
91
71
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +94,7 @@ dependencies:
114
94
  - - "~>"
115
95
  - !ruby/object:Gem::Version
116
96
  version: 0.56.0
117
- description: Simple DSL for creating install scripts.
97
+ description: Create install scripts without the complexity of shell commands.
118
98
  email: david@ramaboo.com
119
99
  executables: []
120
100
  extensions: []
@@ -123,21 +103,29 @@ files:
123
103
  - ".gitignore"
124
104
  - ".rspec"
125
105
  - ".rubocop.yml"
106
+ - ".ruby-version"
126
107
  - ".travis.yml"
127
108
  - CODE_OF_CONDUCT.md
128
109
  - Gemfile
129
110
  - LICENSE.txt
130
111
  - README.md
131
112
  - Rakefile
113
+ - bin/build
132
114
  - bin/console
133
115
  - bin/setup
134
116
  - bin_install.gemspec
135
117
  - lib/bin_install.rb
118
+ - lib/bin_install/atom.rb
119
+ - lib/bin_install/atom/package.rb
136
120
  - lib/bin_install/brew.rb
121
+ - lib/bin_install/brew/cask.rb
122
+ - lib/bin_install/brew/package.rb
123
+ - lib/bin_install/brew/service.rb
137
124
  - lib/bin_install/gem.rb
138
125
  - lib/bin_install/git.rb
139
126
  - lib/bin_install/mysql.rb
140
127
  - lib/bin_install/node.rb
128
+ - lib/bin_install/oh_my_zsh.rb
141
129
  - lib/bin_install/postgres.rb
142
130
  - lib/bin_install/rails.rb
143
131
  - lib/bin_install/redis.rb
@@ -145,7 +133,10 @@ files:
145
133
  - lib/bin_install/ruby_environment_manager/rbenv.rb
146
134
  - lib/bin_install/ruby_environment_manager/rvm.rb
147
135
  - lib/bin_install/server.rb
136
+ - lib/bin_install/shell.rb
148
137
  - lib/bin_install/version.rb
138
+ - lib/bin_install/xcode.rb
139
+ - lib/bin_install/yarn.rb
149
140
  - lib/generators/bin_install/install_generator.rb
150
141
  - lib/generators/bin_install/templates/install
151
142
  - lib/generators/bin_install/templates/kill
@@ -170,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
161
  version: '0'
171
162
  requirements: []
172
163
  rubyforge_project:
173
- rubygems_version: 2.6.13
164
+ rubygems_version: 2.7.6
174
165
  signing_key:
175
166
  specification_version: 4
176
167
  summary: Simple DSL for creating install scripts.