lolipop-mc-starter-rails 0.4.1 → 0.5.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/lib/lolipop/mc/starter/rails.rb +2 -0
- data/lib/lolipop/mc/starter/rails/check_item/base.rb +1 -20
- data/lib/lolipop/mc/starter/rails/check_item/env_database.rb +3 -3
- data/lib/lolipop/mc/starter/rails/check_item/env_rails_key.rb +3 -3
- data/lib/lolipop/mc/starter/rails/check_item/env_rails_static.rb +3 -3
- data/lib/lolipop/mc/starter/rails/check_item/env_ruby.rb +3 -3
- data/lib/lolipop/mc/starter/rails/check_item/git.rb +3 -3
- data/lib/lolipop/mc/starter/rails/check_item/git_log.rb +1 -1
- data/lib/lolipop/mc/starter/rails/check_item/git_remote.rb +1 -1
- data/lib/lolipop/mc/starter/rails/check_item/rails.rb +3 -3
- data/lib/lolipop/mc/starter/rails/check_item/ruby.rb +3 -3
- data/lib/lolipop/mc/starter/rails/check_item/ssh.rb +5 -5
- data/lib/lolipop/mc/starter/rails/cli.rb +6 -0
- data/lib/lolipop/mc/starter/rails/config.rb +24 -0
- data/lib/lolipop/mc/starter/rails/nodebrew.rb +79 -0
- data/lib/lolipop/mc/starter/rails/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c99ebc6101e516e3543ad91275a29684ed64fe9c9bcaa3b8e0dcb74e5ead9d6
|
4
|
+
data.tar.gz: c7a05b26a3591f44cfc3feab657730258c55c33f079941170887ce8a0f0ca84b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df5943d1d2088c42280ce67a36d70449829bb2d2c526a8fcc38941ec66200ceea1195508feec193579b9616b9e7562ffa551e4021b6e95272e745a4ad5f44be3
|
7
|
+
data.tar.gz: 4a1b0f5f3c8b797b66d6647b22e80f8b3af1f763ba0e09f70098db55a7b3a98d0bdca99ac0007aebaa04ed02c00bc9f95f071a38fd00ddbb11734cfef783cbde
|
@@ -4,11 +4,9 @@ module Lolipop
|
|
4
4
|
module Rails
|
5
5
|
module CheckItem
|
6
6
|
class Base
|
7
|
-
NOCHECK = '-'.freeze
|
8
|
-
SKIPCHECK = 'skip'.freeze
|
9
|
-
|
10
7
|
def initialize
|
11
8
|
@item_name = item_name
|
9
|
+
@config = Lolipop::Mc::Starter::Rails::Config
|
12
10
|
end
|
13
11
|
|
14
12
|
def item_name
|
@@ -27,23 +25,6 @@ module Lolipop
|
|
27
25
|
def hint
|
28
26
|
puts "まだ #{@item_name} のヒントが書かれていません"
|
29
27
|
end
|
30
|
-
|
31
|
-
def load_config
|
32
|
-
config_path = "#{Dir.pwd}/.mc-rails.yml"
|
33
|
-
unless File.exist?(config_path)
|
34
|
-
f = File.open(config_path, 'w')
|
35
|
-
YAML.dump({'git' => NOCHECK, 'ruby' => NOCHECK, 'rails' => NOCHECK, 'ssh' => NOCHECK}, f)
|
36
|
-
f.close
|
37
|
-
end
|
38
|
-
YAML.load_file(config_path)
|
39
|
-
end
|
40
|
-
|
41
|
-
def dump_config(obj)
|
42
|
-
config_path = "#{Dir.pwd}/.mc-rails.yml"
|
43
|
-
f = File.open(config_path, 'w')
|
44
|
-
YAML.dump(obj, f)
|
45
|
-
f.close
|
46
|
-
end
|
47
28
|
end
|
48
29
|
end
|
49
30
|
end
|
@@ -5,13 +5,13 @@ module Lolipop
|
|
5
5
|
module CheckItem
|
6
6
|
class EnvDatabase < Base
|
7
7
|
def check
|
8
|
-
config =
|
8
|
+
config = @config.load
|
9
9
|
ssh_command = config['ssh']
|
10
|
-
if ssh_command == NOCHECK
|
10
|
+
if ssh_command == @config::NOCHECK
|
11
11
|
raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください'
|
12
12
|
end
|
13
13
|
begin
|
14
|
-
stdout =
|
14
|
+
stdout, stderr, status = Open3.capture3("#{ssh_command} env")
|
15
15
|
rescue => e
|
16
16
|
raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
|
17
17
|
end
|
@@ -8,13 +8,13 @@ module Lolipop
|
|
8
8
|
key_path = "#{Dir.pwd}/config/master.key"
|
9
9
|
raise 'config/master.keyがありません' unless File.exist?(key_path)
|
10
10
|
|
11
|
-
config =
|
11
|
+
config = @config.load
|
12
12
|
ssh_command = config['ssh']
|
13
|
-
if ssh_command == NOCHECK
|
13
|
+
if ssh_command == @config::NOCHECK
|
14
14
|
raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください'
|
15
15
|
end
|
16
16
|
begin
|
17
|
-
stdout =
|
17
|
+
stdout, stderr, status = Open3.capture3("#{ssh_command} env")
|
18
18
|
rescue => e
|
19
19
|
raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
|
20
20
|
end
|
@@ -5,13 +5,13 @@ module Lolipop
|
|
5
5
|
module CheckItem
|
6
6
|
class EnvRailsStatic < Base
|
7
7
|
def check
|
8
|
-
config =
|
8
|
+
config = @config.load
|
9
9
|
ssh_command = config['ssh']
|
10
|
-
if ssh_command == NOCHECK
|
10
|
+
if ssh_command == @config::NOCHECK
|
11
11
|
raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください'
|
12
12
|
end
|
13
13
|
begin
|
14
|
-
stdout =
|
14
|
+
stdout, stderr, status = Open3.capture3("#{ssh_command} env")
|
15
15
|
rescue => e
|
16
16
|
raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
|
17
17
|
end
|
@@ -5,13 +5,13 @@ module Lolipop
|
|
5
5
|
module CheckItem
|
6
6
|
class EnvRuby < Base
|
7
7
|
def check
|
8
|
-
config =
|
8
|
+
config = @config.load
|
9
9
|
ssh_command = config['ssh']
|
10
|
-
if ssh_command == NOCHECK
|
10
|
+
if ssh_command == @config::NOCHECK
|
11
11
|
raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください'
|
12
12
|
end
|
13
13
|
begin
|
14
|
-
stdout =
|
14
|
+
stdout, stderr, status = Open3.capture3("#{ssh_command} env")
|
15
15
|
rescue => e
|
16
16
|
raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
|
17
17
|
end
|
@@ -6,14 +6,14 @@ module Lolipop
|
|
6
6
|
class Git < Base
|
7
7
|
def check
|
8
8
|
begin
|
9
|
-
stdout =
|
9
|
+
stdout, stderr, status = Open3.capture3("git version")
|
10
10
|
rescue => e
|
11
11
|
raise "Gitコマンドがみつかりません #{e.message}"
|
12
12
|
end
|
13
13
|
raise "Gitコマンドが古いです #{stdout.strip}" unless stdout.match(/git version 2/)
|
14
|
-
config =
|
14
|
+
config = @config.load
|
15
15
|
config['git'] = stdout.strip
|
16
|
-
|
16
|
+
@config.dump(config)
|
17
17
|
"Gitコマンドがインストールされています [#{stdout.strip}]"
|
18
18
|
end
|
19
19
|
|
@@ -6,15 +6,15 @@ module Lolipop
|
|
6
6
|
class Rails < Base
|
7
7
|
def check
|
8
8
|
begin
|
9
|
-
stdout =
|
9
|
+
stdout, stderr, status = Open3.capture3("#{Dir.pwd}/bin/rails -v")
|
10
10
|
rescue => e
|
11
11
|
raise "Railsコマンドがインストールされていません #{e.message}"
|
12
12
|
end
|
13
13
|
raise 'Railsコマンドでエラーが発生しています' unless stdout.match(/^Rails/)
|
14
14
|
raise 'Railsのバージョンが5.2.xではありません' unless stdout.match(/5\.2/)
|
15
|
-
config =
|
15
|
+
config = @config.load
|
16
16
|
config['rails'] = stdout.strip
|
17
|
-
|
17
|
+
@config.dump(config)
|
18
18
|
"Rails5.2がインストールされています [#{stdout.strip}]"
|
19
19
|
end
|
20
20
|
|
@@ -5,11 +5,11 @@ module Lolipop
|
|
5
5
|
module CheckItem
|
6
6
|
class Ruby < Base
|
7
7
|
def check
|
8
|
-
stdout =
|
8
|
+
stdout, stderr, status = Open3.capture3("ruby -v")
|
9
9
|
raise "マネージドクラウドがサポートしているバージョンのRubyがみつかりません [#{stdout.strip}]" unless stdout.match(/ruby 2\.[56]\.\d/)
|
10
|
-
config =
|
10
|
+
config = @config.load
|
11
11
|
config['ruby'] = stdout.strip
|
12
|
-
|
12
|
+
@config.dump(config)
|
13
13
|
"マネージドクラウドがサポートしているバージョンのRubyがインストールされています [#{stdout.strip}]"
|
14
14
|
end
|
15
15
|
|
@@ -5,19 +5,19 @@ module Lolipop
|
|
5
5
|
module CheckItem
|
6
6
|
class SSH < Base
|
7
7
|
def check
|
8
|
-
config =
|
8
|
+
config = @config.load
|
9
9
|
ssh_command = config['ssh']
|
10
10
|
|
11
|
-
if ssh_command != NOCHECK
|
11
|
+
if ssh_command != @config::NOCHECK
|
12
12
|
begin
|
13
|
-
stdout =
|
13
|
+
stdout, stderr, status = Open3.capture3("#{ssh_command} hostname")
|
14
14
|
rescue => e
|
15
15
|
puts "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
|
16
16
|
ssh_command = ''
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
if [NOCHECK, ''].include?(ssh_command)
|
20
|
+
if [@config::NOCHECK, ''].include?(ssh_command)
|
21
21
|
prompt = TTY::Prompt.new(active_color: :cyan)
|
22
22
|
ssh_command = prompt.ask('SSHコマンドを入力してください(マネージドクラウドのプロジェクト詳細に記載があります):')
|
23
23
|
begin
|
@@ -28,7 +28,7 @@ module Lolipop
|
|
28
28
|
end
|
29
29
|
raise 'SSHコマンドの実行に失敗しました。入力したコマンドを確認してください' unless stdout.match(/^gitpush-ruby.+lolipop\.io/)
|
30
30
|
config['ssh'] = ssh_command
|
31
|
-
|
31
|
+
@config.dump(config)
|
32
32
|
"SSHコマンドの設定が完了しています [#{ssh_command}]"
|
33
33
|
end
|
34
34
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'lolipop/mc/starter/rails/check_list'
|
3
3
|
require 'lolipop/mc/starter/rails/generators'
|
4
|
+
require 'lolipop/mc/starter/rails/nodebrew'
|
4
5
|
|
5
6
|
module Lolipop
|
6
7
|
module Mc
|
@@ -17,6 +18,11 @@ module Lolipop
|
|
17
18
|
Lolipop::Mc::Starter::Rails::Generators::DatabaseURL.run
|
18
19
|
end
|
19
20
|
|
21
|
+
desc 'nodebrew', 'マネージドクラウドのRailsプロジェクトにnodebrewをインストールしてNode.jsの最新のstable versionをインストールします'
|
22
|
+
def nodebrew
|
23
|
+
Lolipop::Mc::Starter::Rails::Nodebrew.run
|
24
|
+
end
|
25
|
+
|
20
26
|
option :version, type: :boolean, aliases: :v
|
21
27
|
def help(version = nil)
|
22
28
|
if version
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Lolipop::Mc::Starter::Rails
|
2
|
+
module Config
|
3
|
+
NOCHECK = '-'.freeze
|
4
|
+
SKIPCHECK = 'skip'.freeze
|
5
|
+
|
6
|
+
def self.load
|
7
|
+
config_path = "#{Dir.pwd}/.mc-rails.yml"
|
8
|
+
unless File.exist?(config_path)
|
9
|
+
f = File.open(config_path, 'w')
|
10
|
+
YAML.dump({'git' => NOCHECK, 'ruby' => NOCHECK, 'rails' => NOCHECK, 'ssh' => NOCHECK, 'nodejs' => NOCHECK}, f)
|
11
|
+
f.close
|
12
|
+
end
|
13
|
+
YAML.load_file(config_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.dump(obj)
|
17
|
+
config_path = "#{Dir.pwd}/.mc-rails.yml"
|
18
|
+
f = File.open(config_path, 'w')
|
19
|
+
YAML.dump(obj, f)
|
20
|
+
f.close
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Lolipop::Mc::Starter::Rails
|
2
|
+
module Nodebrew
|
3
|
+
def self.run
|
4
|
+
begin
|
5
|
+
@config = Lolipop::Mc::Starter::Rails::Config
|
6
|
+
config = @config.load
|
7
|
+
@ssh_command = config['ssh']
|
8
|
+
if @ssh_command == @config::NOCHECK
|
9
|
+
raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください'
|
10
|
+
end
|
11
|
+
install_nodebrew
|
12
|
+
check_env_path
|
13
|
+
install_node_stable
|
14
|
+
use_node_stable
|
15
|
+
cleanup
|
16
|
+
rescue => e
|
17
|
+
puts '❌ ' + Paint[e.message, :red]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.install_nodebrew
|
22
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} ls /var/app/.nodebrew")
|
23
|
+
if status == 0
|
24
|
+
puts '✅ ' + Paint['nodebrewはインストールされています', :green].to_s
|
25
|
+
return
|
26
|
+
end
|
27
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} wget git.io/nodebrew")
|
28
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} perl nodebrew setup")
|
29
|
+
puts '✅ ' + Paint['nodebrewをインストールしました', :green].to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.check_env_path
|
33
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} env")
|
34
|
+
md = stdout.match(/PATH=([^\s]+)/)
|
35
|
+
raise '環境変数 `PATH` ありません。マネージドクラウドのプロジェクトではない可能性があります' unless md
|
36
|
+
path = md[1]
|
37
|
+
raise "環境変数 `PATH` にnodebrewのPATH設定がないようです。マネージドクラウドのプロジェクト詳細の `環境変数の設定と管理` で環境変数 `PATH` に `/var/app/.nodebrew/current/bin:#{path}` を設定して追加してください" unless path.match(/nodebrew/)
|
38
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} which nodebrew")
|
39
|
+
if status == 0
|
40
|
+
puts '✅ ' + Paint['環境変数 `PATH` の設定を確認しました', :green].to_s
|
41
|
+
return
|
42
|
+
end
|
43
|
+
raise '環境変数 `PATH` の設定が間違っている可能性があります。マネージドクラウドのプロジェクト詳細の `環境変数の設定と管理` を確認してください'
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.install_node_stable
|
47
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} nodebrew install stable")
|
48
|
+
raise "Node.jsのインストールに失敗しました: #{stdout}" unless (status == 0 || stdout.match('already installed'))
|
49
|
+
puts stdout
|
50
|
+
puts '✅ ' + Paint["Node.jsをインストールしました", :green].to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.use_node_stable
|
54
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} nodebrew use stable")
|
55
|
+
raise "nodebrew use stableに失敗しました: #{stderr}" unless status == 0
|
56
|
+
puts stdout
|
57
|
+
|
58
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} which nodejs")
|
59
|
+
raise "nodejsコマンドの差し替えに失敗しました: #{stderr}" unless status == 0
|
60
|
+
unless stdout.match('/var/app/.nodebrew/current/bin/node')
|
61
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} ln -s /var/app/.nodebrew/current/bin/node /var/app/.nodebrew/current/bin/nodejs")
|
62
|
+
raise "nodejsコマンドの差し替えに失敗しました: #{stderr}" unless status == 0
|
63
|
+
end
|
64
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} nodejs -v")
|
65
|
+
raise "nodejsコマンドの差し替えに失敗しました: #{stderr}" if stdout.match(/^v4/)
|
66
|
+
puts stdout
|
67
|
+
|
68
|
+
config = @config.load
|
69
|
+
config['nodejs'] = stdout.strip
|
70
|
+
@config.dump(config)
|
71
|
+
puts '✅ ' + Paint["nodebrew use stableを実行しました。そしてstableバージョンをnodejsコマンドで実行できるようにしました", :green].to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.cleanup
|
75
|
+
stdout, stderr, status = Open3.capture3("#{@ssh_command} rf -f /var/app/nodebrew")
|
76
|
+
puts '✅ ' + Paint["cleanupを実行しました", :green].to_s
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolipop-mc-starter-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1low
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|
@@ -158,8 +158,10 @@ files:
|
|
158
158
|
- lib/lolipop/mc/starter/rails/check_item/ssh.rb
|
159
159
|
- lib/lolipop/mc/starter/rails/check_list.rb
|
160
160
|
- lib/lolipop/mc/starter/rails/cli.rb
|
161
|
+
- lib/lolipop/mc/starter/rails/config.rb
|
161
162
|
- lib/lolipop/mc/starter/rails/generators.rb
|
162
163
|
- lib/lolipop/mc/starter/rails/generators/database_url.rb
|
164
|
+
- lib/lolipop/mc/starter/rails/nodebrew.rb
|
163
165
|
- lib/lolipop/mc/starter/rails/version.rb
|
164
166
|
- lolipop-mc-starter-rails.gemspec
|
165
167
|
homepage: https://github.com/k1LoW/lolipop-mc-starter-rails
|