bin_install 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 2a2e4626da5353ef03c0da52c52aac16413ed77064cbb29a60ae29dc34012469
4
- data.tar.gz: 5fda4f42d2217f3152a1ca7960a11f5d79df65697866d98430ad82f5be126b9a
2
+ SHA1:
3
+ metadata.gz: e203c040d0df24296e7d0e2e1070458f2582e513
4
+ data.tar.gz: bae7535e9e2627489ff80f08752d904c31621bf2
5
5
  SHA512:
6
- metadata.gz: 356494c7d54e530fb331d6db8ce54f53d4912909a40d91fccddc073d26434168c6bdbcae984ada5db906af846e7ce3bc234e66e549b98869beeb53d7ef270549
7
- data.tar.gz: bc591902a6cbe9c4e61c6a29a56a9fd82b2f23ae245ae15f65e81287baa985779cff4094e1b296b1219e05b9e23ce7a810d26e91eac265936e05aac505950713
6
+ metadata.gz: 1e5190d4ea6a4e51359e8ffc231fe950ed6caddaab47f8bdd7830267351a3d0b1f66dcee8059541f3e0e23d6aeadd8f8807125adfaa35e418a4cd182d85c9744
7
+ data.tar.gz: 2b3682f8a659c63f9d7abd91e939433f33e536c715ec65444cb67687dd0fd46ba03f89460f66b975890a55a235c89e4024e6ab15a60454e5de82f57705f2f3d9
data/.rubocop.yml CHANGED
@@ -5,6 +5,9 @@ AllCops:
5
5
  Documentation:
6
6
  Enabled: false
7
7
 
8
+ Lint/ScriptPermission:
9
+ Enabled: false
10
+
8
11
  Metrics/LineLength:
9
12
  Max: 240
10
13
 
data/README.md CHANGED
@@ -66,9 +66,13 @@ Install [Node.js](https://nodejs.org/en/) and [Yarn](https://yarnpkg.com/en/) wi
66
66
 
67
67
  BinInstall::Node.install # or install!
68
68
 
69
- Upgrade [Yarn](https://yarnpkg.com/en/) with:
69
+ Install packages with:
70
70
 
71
- BinInstall::Node.upgrade_yarn # or upgrade_yarn!
71
+ BinInstall::Node.yarn_install # or yarn_install!
72
+
73
+ Upgrade packages with:
74
+
75
+ BinInstall::Node.yarn_upgrade # or yarn_upgrade!
72
76
 
73
77
  ### Postgres
74
78
 
data/bin_install.gemspec CHANGED
@@ -22,6 +22,8 @@ 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.1.0', '< 6.0')
26
+
25
27
  spec.add_development_dependency 'bundler', '~> 1.16'
26
28
  spec.add_development_dependency 'pry', '>= 0.10.0'
27
29
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -3,11 +3,31 @@ module BinInstall
3
3
  def self.install
4
4
  puts 'Installing MySQL...'.white
5
5
  Brew.install_or_upgrade('mysql')
6
+ system('brew services start mysql')
6
7
  end
7
8
 
8
9
  def self.install!
9
10
  puts 'Installing MySQL...'.white
10
11
  Brew.install_or_upgrade!('mysql')
12
+ BinInstall.system!('brew services start mysql')
13
+ end
14
+
15
+ def self.create_root
16
+ system("mysqladmin --user=root password ''")
17
+ end
18
+
19
+ def self.create_root!
20
+ BinInstall.system!("mysqladmin --user=root password ''")
21
+ end
22
+
23
+ def self.create_user(username, password = nil)
24
+ system(%(mysql --user=root --execute="CREATE USER '#{username}'@'localhost' IDENTIFIED BY '#{password}';"))
25
+ system(%(mysql --user=root --execute="GRANT ALL PRIVILEGES ON *.* TO '#{username}'@'localhost' WITH GRANT OPTION;"))
26
+ end
27
+
28
+ def self.create_user!(username, password = nil)
29
+ BinInstall.system!(%(mysql --user=root --execute="CREATE USER '#{username}'@'localhost' IDENTIFIED BY '#{password}';"))
30
+ BinInstall.system!(%(mysql --user=root --execute="GRANT ALL PRIVILEGES ON *.* TO '#{username}'@'localhost' WITH GRANT OPTION;"))
11
31
  end
12
32
  end
13
33
  end
@@ -3,13 +3,21 @@ module BinInstall
3
3
  def self.install
4
4
  Brew.install_or_upgrade('node')
5
5
  Brew.install_or_upgrade('yarn')
6
- yarn_upgrade
6
+ yarn_install
7
7
  end
8
8
 
9
9
  def self.install!
10
10
  Brew.install_or_upgrade!('node')
11
11
  Brew.install_or_upgrade!('yarn')
12
- yarn_upgrade!
12
+ yarn_install!
13
+ end
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')
13
21
  end
14
22
 
15
23
  def self.yarn_upgrade
@@ -1,33 +1,57 @@
1
+ require 'rails'
2
+
1
3
  module BinInstall
2
4
  module Rails
3
5
  def self.db_setup
4
6
  puts 'Preparing database...'.white
5
- system('bin/rails db:setup')
7
+ rails_or_rake('db:setup')
6
8
  end
7
9
 
8
10
  def self.db_setup!
9
11
  puts 'Preparing database...'.white
10
- BinInstall.system!('bin/rails db:setup')
12
+ rails_or_rake!('db:setup')
11
13
  end
12
14
 
13
15
  def self.db_migrate
14
16
  puts 'Migrating database...'.white
15
- system('bin/rails db:migrate')
17
+ rails_or_rake('db:migrate')
16
18
  end
17
19
 
18
20
  def self.db_migrate!
19
21
  puts 'Migrating database...'.white
20
- BinInstall.system!('bin/rails db:migrate')
22
+ rails_or_rake!('db:migrate')
21
23
  end
22
24
 
23
25
  def self.clear
24
26
  puts 'Removing unnecessary files...'.white
25
- system('bin/rails log:clear tmp:clear')
27
+ rails_or_rake('log:clear')
28
+ rails_or_rake('tmp:clear')
26
29
  end
27
30
 
28
- def self.clear
31
+ def self.clear!
29
32
  puts 'Removing unnecessary files...'.white
30
- BinInstall.system!('bin/rails log:clear tmp:clear')
33
+ rails_or_rake!('log:clear')
34
+ rails_or_rake!('tmp:clear')
35
+ end
36
+
37
+ def self.rails_or_rake(command)
38
+ if rails5?
39
+ system("bin/rails #{command}")
40
+ else
41
+ system("rake #{command}")
42
+ end
43
+ end
44
+
45
+ def self.rails_or_rake!(command)
46
+ if rails5?
47
+ BinInstall.system!("bin/rails #{command}")
48
+ else
49
+ BinInstall.system!("rake #{command}")
50
+ end
51
+ end
52
+
53
+ def self.rails5?
54
+ ::Rails::VERSION::MAJOR >= 5
31
55
  end
32
56
  end
33
57
  end
@@ -1,16 +1,38 @@
1
1
  module BinInstall
2
2
  module RubyEnvironmentManager
3
3
  module Rbevn
4
- def self.install
4
+ def self.install(version = nil)
5
5
  puts 'Installing rbenv...'.white
6
6
  Brew.install_or_upgrade('rbenv')
7
7
  Brew.install_or_upgrade('ruby-build')
8
+ install_ruby(version)
8
9
  end
9
10
 
10
- def self.install!
11
+ def self.install!(version = nil)
11
12
  puts 'Installing rbenv...'.white
12
13
  Brew.install_or_upgrade!('rbenv')
13
14
  Brew.install_or_upgrade!('ruby-build')
15
+ install_ruby!(version)
16
+ end
17
+
18
+ def self.install_ruby(version = nil)
19
+ version ||= RubyEnvironmentManager.ruby_version
20
+
21
+ if version
22
+ system("rbenv install #{version}")
23
+ else
24
+ puts 'Unknown Ruby version. Create `.ruby-version` file.'
25
+ end
26
+ end
27
+
28
+ def self.install_ruby!(version = nil)
29
+ version ||= RubyEnvironmentManager.ruby_version
30
+
31
+ if version
32
+ BinInstall.system!("rbenv install #{version}")
33
+ else
34
+ abort('Unknown Ruby version. Create `.ruby-version` file.')
35
+ end
14
36
  end
15
37
 
16
38
  def self.installed?
@@ -1,6 +1,26 @@
1
1
  module BinInstall
2
2
  module RubyEnvironmentManager
3
3
  module Rvm
4
+ def self.install_ruby(version = nil)
5
+ version ||= RubyEnvironmentManager.ruby_version
6
+
7
+ if version
8
+ system("rvm install #{version}")
9
+ else
10
+ puts 'Unknown Ruby version. Create `.ruby-version` file.'
11
+ end
12
+ end
13
+
14
+ def self.install_ruby!(version = nil)
15
+ version ||= RubyEnvironmentManager.ruby_version
16
+
17
+ if version
18
+ BinInstall.system!("rvm install #{version}")
19
+ else
20
+ abort('Unknown Ruby version. Create `.ruby-version` file.')
21
+ end
22
+ end
23
+
4
24
  def self.installed?
5
25
  system('rvm --version')
6
26
  end
@@ -3,22 +3,28 @@ require 'bin_install/ruby_environment_manager/rvm'
3
3
 
4
4
  module BinInstall
5
5
  module RubyEnvironmentManager
6
- def self.install
6
+ def self.install(version = nil)
7
7
  if RubyEnvironmentManager::Rvm.installed?
8
8
  puts 'RVM is already installed. Skipping rbenv install.'.blue
9
+ RubyEnvironmentManager::Rvm.install_ruby(version)
9
10
  return
10
11
  end
11
12
 
12
- RubyEnvironmentManager::Rbenv.install
13
+ RubyEnvironmentManager::Rbenv.install(version)
13
14
  end
14
15
 
15
- def self.install!
16
+ def self.install!(version = nil)
16
17
  if RubyEnvironmentManager::Rvm.installed?
17
18
  puts 'RVM is already installed. Skipping rbenv install.'.blue
19
+ RubyEnvironmentManager::Rvm.install_ruby!(version)
18
20
  return
19
21
  end
20
22
 
21
- RubyEnvironmentManager::Rbenv.install!
23
+ RubyEnvironmentManager::Rbenv.install!(version)
24
+ end
25
+
26
+ def self.ruby_version
27
+ Dir.chdir(Dir.pwd) { `cat .ruby-version` }
22
28
  end
23
29
  end
24
30
  end
@@ -1,3 +1,3 @@
1
1
  module BinInstall
2
- VERSION = '0.0.4'.freeze
2
+ VERSION = '0.0.5'.freeze
3
3
  end
@@ -16,7 +16,7 @@ module BinInstall
16
16
 
17
17
  def copy_bin_file(file)
18
18
  copy_file file, "bin/#{file}"
19
- FileUtils.chmod(0744, "bin/#{file}")
19
+ FileUtils.chmod(0o744, "bin/#{file}")
20
20
  end
21
21
  end
22
22
  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
4
+ version: 0.0.5
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-17 00:00:00.000000000 Z
11
+ date: 2018-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -24,6 +24,26 @@ 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.1.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.1.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '6.0'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: bundler
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
168
  version: '0'
149
169
  requirements: []
150
170
  rubyforge_project:
151
- rubygems_version: 2.7.6
171
+ rubygems_version: 2.6.13
152
172
  signing_key:
153
173
  specification_version: 4
154
174
  summary: Simple DSL for creating install scripts.