bin_install 0.0.2 → 0.0.3
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/.rubocop.yml +12 -0
- data/README.md +89 -1
- data/lib/bin_install/brew.rb +75 -0
- data/lib/bin_install/gem.rb +15 -0
- data/lib/bin_install/node.rb +23 -0
- data/lib/bin_install/postgres.rb +23 -0
- data/lib/bin_install/rails.rb +33 -0
- data/lib/bin_install/ruby_environment_manager/rbenv.rb +21 -0
- data/lib/bin_install/ruby_environment_manager/rvm.rb +9 -0
- data/lib/bin_install/ruby_environment_manager.rb +24 -0
- data/lib/bin_install/server.rb +33 -0
- data/lib/bin_install/version.rb +1 -1
- data/lib/bin_install.rb +3 -6
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d7cc7be65e21a4b462e317507a1923ce5de2c952cedea6cca4cf5150d228947
|
4
|
+
data.tar.gz: c172cbeca434d96f882fa1f2330f51128886db0006be8607e6c4d4f8ecd202ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddc577bc489edd7029a2c28c6f565224498f44055251fc1b38e86f7a717844d44b8bedfc56938251c20a3e6e89b863bd9599c58cc823626d73f93508a8d95110
|
7
|
+
data.tar.gz: 6a4a4d09094f0839a4069d1aec4523f49e9a0aa0ed362b1d7ceff4ef4efc3a6becdcadb09fb5bf33b1dd7edad6bb506b5e2242effaab4d8e8f8a9e5bd1c7ef34
|
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -12,6 +12,94 @@ Add this line to your application's Gemfile:
|
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
-
To create
|
15
|
+
To create install scripts run:
|
16
16
|
|
17
17
|
$ rails generate bin_install:install
|
18
|
+
|
19
|
+
Will create the following files with some common defaults:
|
20
|
+
|
21
|
+
* `bin/install`
|
22
|
+
* `bin/update`
|
23
|
+
* `bin/kill`
|
24
|
+
|
25
|
+
## Bang! vs No Bang
|
26
|
+
|
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
|
+
|
29
|
+
### [Brew](https://brew.sh/)
|
30
|
+
|
31
|
+
Require [Homebrew](https://brew.sh/) before continuing:
|
32
|
+
|
33
|
+
BinInstall::Brew.require!
|
34
|
+
|
35
|
+
Update [Homebrew](https://brew.sh/):
|
36
|
+
|
37
|
+
BinInstall::Brew.update # or update!
|
38
|
+
|
39
|
+
Install [Homebrew](https://brew.sh/) package:
|
40
|
+
|
41
|
+
BinInstall::Brew.install('package') # or install!('package')
|
42
|
+
|
43
|
+
Upgrade [Homebrew](https://brew.sh/) package:
|
44
|
+
|
45
|
+
BinInstall::Brew.upgrade('package') # upgrade!('package')
|
46
|
+
|
47
|
+
Install or Upgrade with one command:
|
48
|
+
|
49
|
+
BinInstall::Brew.install_or_upgrade('package') # or install_or_upgrade!('package')
|
50
|
+
|
51
|
+
### [Gem](https://rubygems.org/)
|
52
|
+
|
53
|
+
Install all [gems](https://rubygems.org/) with:
|
54
|
+
|
55
|
+
BinInstall::Gem.install # or install!
|
56
|
+
|
57
|
+
### [Node](https://nodejs.org/en/)
|
58
|
+
|
59
|
+
Install [Node.js](https://nodejs.org/en/) and [Yarn](https://yarnpkg.com/en/) with:
|
60
|
+
|
61
|
+
BinInstall::Node.install # or install!
|
62
|
+
|
63
|
+
Upgrade [Yarn](https://yarnpkg.com/en/) with:
|
64
|
+
|
65
|
+
BinInstall::Node.upgrade_yarn # or upgrade_yarn!
|
66
|
+
|
67
|
+
### [Postgres](https://www.postgresql.org/)
|
68
|
+
|
69
|
+
Install [PostgreSQL](https://www.postgresql.org/) with:
|
70
|
+
|
71
|
+
BinInstall::Postgres.install # or install!
|
72
|
+
|
73
|
+
Create a user with the username *postgres* and a blank password:
|
74
|
+
|
75
|
+
BinInstall::Postgres.create_default_user # or create_default_user!
|
76
|
+
|
77
|
+
### [Rails](https://rubyonrails.org/)
|
78
|
+
|
79
|
+
Setup database with:
|
80
|
+
|
81
|
+
BinInstall::Rails.db_setup # or db_setup!
|
82
|
+
|
83
|
+
Migrate database with:
|
84
|
+
|
85
|
+
BinInstall::Rails.db_migrate # db_migrate!
|
86
|
+
|
87
|
+
Clear log and tmp files:
|
88
|
+
|
89
|
+
BinInstall::Rails.clear # or clear!
|
90
|
+
|
91
|
+
### RubyEnvironmentManager
|
92
|
+
|
93
|
+
Install [rbenv](https://github.com/rbenv/rbenv) unless [RVM](https://rvm.io/) is installed with:
|
94
|
+
|
95
|
+
BinInstall::RubyEnvironmentManager.install # or install!
|
96
|
+
|
97
|
+
### Server
|
98
|
+
|
99
|
+
Forcefully kill the server with:
|
100
|
+
|
101
|
+
BinInstall::Server.kill # or kill!
|
102
|
+
|
103
|
+
## Contributing
|
104
|
+
|
105
|
+
All pull requests must pass [RuboCop](https://github.com/bbatsov/rubocop).
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module BinInstall
|
2
|
+
module Brew
|
3
|
+
def self.require!
|
4
|
+
if installed?
|
5
|
+
update!
|
6
|
+
else
|
7
|
+
abort('Homebrew is required! Visit https://brew.sh/ to install.'.red)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
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')
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.install(package)
|
24
|
+
system("brew install #{package}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.install!(package)
|
28
|
+
BinInstall.system!("brew install #{package}")
|
29
|
+
end
|
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
|
37
|
+
end
|
38
|
+
|
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
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.install_or_upgrade(package)
|
48
|
+
if package_installed?(package)
|
49
|
+
upgrade(package)
|
50
|
+
else
|
51
|
+
install(package)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.install_or_upgrade!(package)
|
56
|
+
if package_installed?(package)
|
57
|
+
upgrade!(package)
|
58
|
+
else
|
59
|
+
install!(package)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
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}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module BinInstall
|
2
|
+
module Gem
|
3
|
+
def self.install
|
4
|
+
puts 'Installing gems...'.white
|
5
|
+
system('gem install bundler --conservative')
|
6
|
+
system('bundle install')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.install!
|
10
|
+
puts 'Installing gems...'.white
|
11
|
+
BinInstall.system!('gem install bundler --conservative')
|
12
|
+
BinInstall.system!('bundle install')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module BinInstall
|
2
|
+
module Node
|
3
|
+
def self.install
|
4
|
+
Brew.install_or_upgrade('node')
|
5
|
+
Brew.install_or_upgrade('yarn')
|
6
|
+
yarn_upgrade
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.install!
|
10
|
+
Brew.install_or_upgrade!('node')
|
11
|
+
Brew.install_or_upgrade!('yarn')
|
12
|
+
yarn_upgrade!
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.yarn_upgrade
|
16
|
+
system('bin/yarn upgrade')
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.yarn_upgrade!
|
20
|
+
BinInstall.system!('bin/yarn upgrade')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module BinInstall
|
2
|
+
module Postgres
|
3
|
+
def self.install
|
4
|
+
puts 'Installing PostgreSQL...'.white
|
5
|
+
Brew.install_or_upgrade('postgresql')
|
6
|
+
create_default_user
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.install!
|
10
|
+
puts 'Installing PostgreSQL...'.white
|
11
|
+
Brew.install_or_upgrade!('postgresql')
|
12
|
+
create_default_user!
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.create_default_user
|
16
|
+
system('createuser -s postgres')
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.create_default_user!
|
20
|
+
BinInstall.system!('createuser -s postgres')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module BinInstall
|
2
|
+
module Rails
|
3
|
+
def self.db_setup
|
4
|
+
puts 'Preparing database...'.white
|
5
|
+
system('bin/rails db:setup')
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.db_setup!
|
9
|
+
puts 'Preparing database...'.white
|
10
|
+
BinInstall.system!('bin/rails db:setup')
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.db_migrate
|
14
|
+
puts 'Migrating database...'.white
|
15
|
+
system('bin/rails db:migrate')
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.db_migrate!
|
19
|
+
puts 'Migrating database...'.white
|
20
|
+
BinInstall.system!('bin/rails db:migrate')
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.clear
|
24
|
+
puts 'Removing unnecessary files...'.white
|
25
|
+
system('bin/rails log:clear tmp:clear')
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.clear
|
29
|
+
puts 'Removing unnecessary files...'.white
|
30
|
+
BinInstall.system!('bin/rails log:clear tmp:clear')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BinInstall
|
2
|
+
module RubyEnvironmentManager
|
3
|
+
module Rbevn
|
4
|
+
def self.install
|
5
|
+
puts 'Installing rbenv...'.white
|
6
|
+
Brew.install_or_upgrade('rbenv')
|
7
|
+
Brew.install_or_upgrade('ruby-build')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.install!
|
11
|
+
puts 'Installing rbenv...'.white
|
12
|
+
Brew.install_or_upgrade!('rbenv')
|
13
|
+
Brew.install_or_upgrade!('ruby-build')
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.installed?
|
17
|
+
system('rbenv --version')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bin_install/ruby_environment_manager/rbenv'
|
2
|
+
require 'bin_install/ruby_environment_manager/rvm'
|
3
|
+
|
4
|
+
module BinInstall
|
5
|
+
module RubyEnvironmentManager
|
6
|
+
def self.install
|
7
|
+
if RubyEnvironmentManager::Rvm.installed?
|
8
|
+
puts 'RVM is already installed. Skipping rbenv install.'.blue
|
9
|
+
return
|
10
|
+
end
|
11
|
+
|
12
|
+
RubyEnvironmentManager::Rbenv.install
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.install!
|
16
|
+
if RubyEnvironmentManager::Rvm.installed?
|
17
|
+
puts 'RVM is already installed. Skipping rbenv install.'.blue
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
21
|
+
RubyEnvironmentManager::Rbenv.install!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module BinInstall
|
2
|
+
module Server
|
3
|
+
def self.kill
|
4
|
+
Dir.chdir(Dir.pwd) do
|
5
|
+
pid_file = 'tmp/pids/server.pid'
|
6
|
+
puts 'Server is not running!'.yellow unless File.exist?(pid_file)
|
7
|
+
|
8
|
+
server_pid = `cat tmp/pids/server.pid`
|
9
|
+
|
10
|
+
if system("kill -9 #{server_pid}")
|
11
|
+
puts "PID `#{server_pid}` killed.".green
|
12
|
+
else
|
13
|
+
puts "PID `#{server_pid}` can not be killed!".red
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.kill!
|
19
|
+
Dir.chdir(Dir.pwd) do
|
20
|
+
pid_file = 'tmp/pids/server.pid'
|
21
|
+
abort('Server is not running!'.yellow) unless File.exist?(pid_file)
|
22
|
+
|
23
|
+
server_pid = `cat tmp/pids/server.pid`
|
24
|
+
|
25
|
+
if system("kill -9 #{server_pid}")
|
26
|
+
puts "PID `#{server_pid}` killed.".green
|
27
|
+
else
|
28
|
+
abort("PID `#{server_pid}` can not be killed!".red)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/bin_install/version.rb
CHANGED
data/lib/bin_install.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
require 'awesome_print'
|
2
2
|
|
3
3
|
require 'bin_install/brew'
|
4
|
+
require 'bin_install/gem'
|
4
5
|
require 'bin_install/node'
|
5
6
|
require 'bin_install/postgres'
|
6
7
|
require 'bin_install/rails'
|
8
|
+
require 'bin_install/ruby_environment_manager'
|
9
|
+
require 'bin_install/server'
|
7
10
|
require 'bin_install/version'
|
8
11
|
|
9
12
|
module BinInstall
|
10
13
|
def self.system!(*args)
|
11
14
|
system(*args) || abort("Command `#{args}` failed!".red)
|
12
15
|
end
|
13
|
-
|
14
|
-
def self.install_gems!
|
15
|
-
puts 'Installing gems...'.white
|
16
|
-
system!('gem install bundler --conservative')
|
17
|
-
system!('bundle install')
|
18
|
-
end
|
19
16
|
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.
|
4
|
+
version: 0.0.3
|
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-
|
11
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -102,6 +102,7 @@ extra_rdoc_files: []
|
|
102
102
|
files:
|
103
103
|
- ".gitignore"
|
104
104
|
- ".rspec"
|
105
|
+
- ".rubocop.yml"
|
105
106
|
- ".travis.yml"
|
106
107
|
- CODE_OF_CONDUCT.md
|
107
108
|
- Gemfile
|
@@ -112,6 +113,15 @@ files:
|
|
112
113
|
- bin/setup
|
113
114
|
- bin_install.gemspec
|
114
115
|
- lib/bin_install.rb
|
116
|
+
- lib/bin_install/brew.rb
|
117
|
+
- lib/bin_install/gem.rb
|
118
|
+
- lib/bin_install/node.rb
|
119
|
+
- lib/bin_install/postgres.rb
|
120
|
+
- lib/bin_install/rails.rb
|
121
|
+
- lib/bin_install/ruby_environment_manager.rb
|
122
|
+
- lib/bin_install/ruby_environment_manager/rbenv.rb
|
123
|
+
- lib/bin_install/ruby_environment_manager/rvm.rb
|
124
|
+
- lib/bin_install/server.rb
|
115
125
|
- lib/bin_install/version.rb
|
116
126
|
homepage: https://github.com/ramaboo/bin_install
|
117
127
|
licenses:
|