lolipop-mc-starter-rails 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 778bbebfe613a61916a27819254569e4350a0617ef5c4142d8953ada5bff9a28
4
+ data.tar.gz: fabae70d12678374862d72a8f6546c5e07f234d6b7447dae0368f6d408965707
5
+ SHA512:
6
+ metadata.gz: f2d7926bea6b63328f89f42b1881401c6fb21930cf02ae62d4694f2d8526d1b95adda7ac269ef7c74cb1ec5c417b87f889e36ec1cb70a21c1aa90bdfd15b18af
7
+ data.tar.gz: '025739b9fed40e083cf4c42f1c71269c308e0a038bb8d8c8738e4f4519c9bc53121e7c627dc6de2440076e595d66188523b4eaa3f8f4bd1f8635050efa829457'
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .mc-rails.yml
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 1.17.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at k1low@pepabo.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in lolipop-mc-starter-rails.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 k1low
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ # ロリポップ!マネージドクラウド スターター for Ruby on Rails
2
+
3
+ ## インストール
4
+
5
+ ```ruby
6
+ gem install lolipop-mc-starter-rails
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ Railsプロジェクトのソースコードがあるディレクトリで以下のコマンドを実行すると、ロリポップ!マネージドクラウドにデプロイするまでに必要な設定についてチェックしてくれます
12
+
13
+ ```ruby
14
+ $ cd your_rails/
15
+ $ mc-rails check
16
+ ```
17
+
18
+ ## License
19
+
20
+ the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require 'octorelease'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lolipop/mc/starter"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'lolipop/mc/starter/rails'
4
+
5
+ Lolipop::Mc::Starter::Rails::CLI.start
@@ -0,0 +1,17 @@
1
+ require 'dry/inflector'
2
+ require 'paint'
3
+ require 'yaml'
4
+ require 'tty-prompt'
5
+
6
+ require 'lolipop/mc/starter/rails/version'
7
+ require 'lolipop/mc/starter/rails/cli'
8
+
9
+ module Lolipop
10
+ module Mc
11
+ module Starter
12
+ module Rails
13
+ class Error < StandardError; end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,52 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class Base
7
+ NOCHECK = '-'.freeze
8
+ SKIPCHECK = 'skip'.freeze
9
+
10
+ def initialize
11
+ @item_name = item_name
12
+ end
13
+
14
+ def item_name
15
+ inflector = Dry::Inflector.new
16
+ inflector.underscore(self.class.to_s.split('::').last)
17
+ end
18
+
19
+ def desc
20
+ "call #{@item_name} desc"
21
+ end
22
+
23
+ def check
24
+ "call #{@item_name} check"
25
+ end
26
+
27
+ def hint
28
+ puts "まだ #{@item_name} のヒントが書かれていません"
29
+ 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
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,35 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class EnvDatabase < Base
7
+ def check
8
+ config = load_config
9
+ ssh_command = config['ssh']
10
+ if ssh_command == NOCHECK
11
+ raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください'
12
+ end
13
+ begin
14
+ stdout = `#{ssh_command} env`
15
+ rescue => e
16
+ raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
17
+ end
18
+ raise '環境変数 `DATABASE_URL` が設定されていません' unless stdout.match(/DATABASE_URL=/)
19
+ key = File.read(key_path)
20
+ raise '環境変数 `DATABASE_URL` のアダプターがmysql2ではありません' unless stdout.match("DATABASE_URL=mysql2://")
21
+ '環境変数 `DATABASE_URL` が設定されています'
22
+ end
23
+
24
+ def hint
25
+ puts 'Railsは環境変数に `DATABASE_URL` を設定すると config/database.yml ではなく `DATABASE_URL` のDB接続設定を優先します'
26
+ puts 'マネージドクラウドのプロジェクト詳細の `データベース` の記載を組み合わせて `DATABASE_URL` を作成して、同じくマネージドクラウドのプロジェクト詳細の `環境変数の設定と管理` で環境変数 `DATABASE_URL` を追加してください'
27
+ puts '`DATABASE_URL` はマネージドクラウドのプロジェクト詳細の `データベース` の記載から `mysql2://[ユーザ名]:[パスワード]@[データベースのホスト名]/[データベース名]` のようになります'
28
+ puts '例: `mysql2://33dcdbandusername4854d40bb41698b53a:DataBasePassW0rd@mysql-1.mc.lolipop.lan/33dcdbandusername4854d40bb41698b53a'
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,37 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class EnvRailsKey < Base
7
+ def check
8
+ key_path = "#{Dir.pwd}/config/master.key"
9
+ raise 'config/master.keyがありません' unless File.exist?(key_path)
10
+
11
+ config = load_config
12
+ ssh_command = config['ssh']
13
+ if ssh_command == NOCHECK
14
+ raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください'
15
+ end
16
+ begin
17
+ stdout = `#{ssh_command} env`
18
+ rescue => e
19
+ raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
20
+ end
21
+ raise '環境変数 `RAILS_MASTER_KEY` が設定されていません' unless stdout.match(/RAILS_MASTER_KEY/)
22
+ key = File.read(key_path)
23
+ raise '環境変数 `RAILS_MASTER_KEY` の値がconfig/master.keyと異なります' unless stdout.match("RAILS_MASTER_KEY=#{key}")
24
+ '環境変数 `RAILS_MASTER_KEY` が設定されています'
25
+ end
26
+
27
+ def hint
28
+ puts 'Railsではconfig/credentials.yml.encの情報を復号化して読み取るためにconfig/master.keyが必要です'
29
+ puts 'config/master.keyを本番環境に設置する代わりに、環境変数 `RAILS_MASTER_KEY` にconfig/master.keyの値を設定することが可能です'
30
+ puts 'マネージドクラウドのプロジェクト詳細の `環境変数の設定と管理` で環境変数 `RAILS_MASTER_KEY` にconfig/master.keyの値を追加してください'
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,34 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class EnvRailsStatic < Base
7
+ def check
8
+ config = load_config
9
+ ssh_command = config['ssh']
10
+ if ssh_command == NOCHECK
11
+ raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください'
12
+ end
13
+ begin
14
+ stdout = `#{ssh_command} env`
15
+ rescue => e
16
+ raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
17
+ end
18
+ raise '環境変数 `RAILS_SERVE_STATIC_FILES` が設定されていません' unless stdout.match(/RAILS_SERVE_STATIC_FILES=/)
19
+ key = File.read(key_path)
20
+ raise '環境変数 `RAILS_SERVE_STATIC_FILES` が `true` ではありません' unless stdout.match("RAILS_SERVE_STATIC_FILES=true")
21
+ '環境変数 `RAILS_SERVE_STATIC_FILES=true` が設定されています'
22
+ end
23
+
24
+ def hint
25
+ puts 'Railsは環境変数に `RAILS_SERVE_STATIC_FILES=true` を設定すると public/ ディレクトリの静的ファイルをNGINXやApache直接ではなくRailsが配信するようになります'
26
+ puts 'マネージドクラウドでは静的ファイルの配信もRailsで実施する必要があります'
27
+ puts 'マネージドクラウドのプロジェクト詳細の `環境変数の設定と管理` で環境変数 `RAILS_SERVE_STATIC_FILES` (値 `true` ) を追加してください'
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,39 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class EnvRuby < Base
7
+ def check
8
+ config = load_config
9
+ ssh_command = config['ssh']
10
+ if ssh_command == NOCHECK
11
+ raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください'
12
+ end
13
+ begin
14
+ stdout = `#{ssh_command} env`
15
+ rescue => e
16
+ raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
17
+ end
18
+ version = '0.0.0'
19
+ md = stdout.match(/RUBY_VERSION=(\d\.\d\.\d)/)
20
+ if md
21
+ version = md[1]
22
+ else
23
+ raise '環境変数 `RUBY_VERSION` が設定されていません。マネージドクラウドのプロジェクトがRailsプロジェクトではない可能性があります'
24
+ end
25
+ local_version = config['ruby']
26
+ "マネージドクラウドのRailsプロジェクトのRubyのバージョンとローカルのRubyのバージョンが同じでないようです\nマネージドクラウド:#{version} ローカル:#{local_version}" unless local_version.include?(version)
27
+ 'マネージドクラウドのRailsプロジェクトのRubyのバージョンとローカルのRubyのバージョンが同じです'
28
+ end
29
+
30
+ def hint
31
+ puts 'ローカルのRubyのバージョンとマネージドクラウドのRailsプロジェクトのRubyのバージョンを合わせる必要があります'
32
+ puts 'マネージドクラウドのプロジェクト詳細でRubyのバージョンを確認して、同じRubyをインストールしてください'
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,24 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class GemMysql2 < Base
7
+ def check
8
+ gemfile_path = "#{Dir.pwd}/Gemfile"
9
+ raise 'Gemfileがありません' unless File.exist?(key_path)
10
+ content = File.read(gemfile_path)
11
+ raise 'Gemfileでgem `mysql2`が呼ばれていません' unless content.match("gem 'mysql2'")
12
+ 'Gemfileでgem `mysql2`が呼ばれています'
13
+ end
14
+
15
+ def hint
16
+ puts 'マネージドクラウドのRailsプロジェクトはMySQLが利用できます'
17
+ puts "本番環境ではMySQLを利用するためGemfileに`gem 'mysql2'`の記載が必要です"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class Git < Base
7
+ def check
8
+ begin
9
+ stdout = `git version`
10
+ rescue => e
11
+ raise "Gitコマンドがみつかりません #{e.message}"
12
+ end
13
+ raise "Gitコマンドが古いです #{stdout.strip}" unless stdout.match(/git version 2/)
14
+ config = load_config
15
+ config['git'] = stdout.strip
16
+ dump_config(config)
17
+ "Gitコマンドがインストールされています [#{stdout.strip}]"
18
+ end
19
+
20
+ def hint
21
+ puts 'ソースコードをバージョン管理するためにGitコマンドを利用します'
22
+ puts 'またマネージドクラウドのRailsプロジェクトではデプロイの仕組みにGitを活用しています'
23
+ puts 'Macであれば `brew install git` コマンドなどでGitをインストールしてください'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class GitLog < Base
7
+ def check
8
+ begin
9
+ stdout = `git log`
10
+ rescue => e
11
+ raise "まだローカルのGitリポジトリにコミットがないようです #{e.message}"
12
+ end
13
+ 'ローカルのGitリポジトリにコミットがあります'
14
+ end
15
+
16
+ def hint
17
+ puts 'ロリポップ!マネージドクラウドのRailsプロジェクトでは `git push` をすることでマネージドクラウドにRailsアプリケーションをデプロイします'
18
+ puts 'そのためにはローカルのGitリポジトリに`git commit`が必要です'
19
+ puts "`git add . && git commit -m'First commit'` などを実行してコミットを作成してください"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class GitRemote < Base
7
+ def check
8
+ begin
9
+ stdout = `git remote`
10
+ rescue => e
11
+ raise "Gitコマンドがみつかりません #{e.message}"
12
+ end
13
+ raise "リモートリポジトリ `lolipop` がないようです #{stdout.strip}" unless stdout.match(/lolipop/)
14
+ 'リモートリポジトリ `lolipop` が設定されています'
15
+ end
16
+
17
+ def hint
18
+ puts 'マネージドクラウドにデプロイするためにマネージドクラウド側のGitリポジトリをリモートリポジトリとして登録する必要があります'
19
+ puts 'マネージドクラウドのプロジェクト詳細に `リポジトリ` にコマンドの記載があります'
20
+ puts '例: `git remote add lolipop ssh://dreamy-kanoya-1234@ssh-1.mc.lolipop.jp:123456/`'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class Rails < Base
7
+ def check
8
+ begin
9
+ stdout = `#{Dir.pwd}/bin/rails -v`
10
+ rescue => e
11
+ raise "Railsコマンドがインストールされていません #{e.message}"
12
+ end
13
+ raise 'Railsのバージョンが5.2.xではありません' unless stdout.match(/5\.2/)
14
+ config = load_config
15
+ config['rails'] = stdout.strip
16
+ dump_config(config)
17
+ "Rails5.2がインストールされています [#{stdout.strip}]"
18
+ end
19
+
20
+ def hint
21
+ puts 'このコマンドではRails5.2を指定しています'
22
+ puts '`rails _5.2.3_ new your_app` のようにバージョンを指定することで特定バージョンのRailsプロジェクトを作成できます'
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class RailsDir < Base
7
+ def check
8
+ %w(Rakefile app bin config config.ru db lib log public storage test tmp vendor).each do |f|
9
+ raise 'カレントディレクトリにRailsプロジェクトのソースコードが設置されていません' unless File.exist?("#{Dir.pwd}/#{f}")
10
+ end
11
+ 'カレントディレクトリにRailsプロジェクトのソースコードが設置されてます'
12
+ end
13
+
14
+ def hint
15
+ puts 'Railsプロジェクトのソースコードが設置されているディレクトリに移動して、もう一度 `mc-rails check` を実行してください'
16
+ puts 'もしくは、 `rails new your_app` コマンドでRailsプロジェクトを新規作成してください'
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class RailsKey < Base
7
+ def check
8
+ key_path = "#{Dir.pwd}/config/master.key"
9
+ raise 'config/master.keyがありません' unless File.exist?(key_path)
10
+ 'config/master.keyがあります'
11
+ end
12
+
13
+ def hint
14
+ puts 'Rails5.2ではconfig/master.keyでconfig/credentials.yml.encを暗号化/復号化します'
15
+ puts 'config/master.keyもconfig/credentials.yml.encもない状態で `bin/rails credentials:edit` を実行することで新たにconfig/master.keyとconfig/credentials.yml.encを生成できます'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class Ruby < Base
7
+ def check
8
+ stdout = `ruby -v`
9
+ raise "マネージドクラウドがサポートしているバージョンのRubyがみつかりません [#{stdout.strip}]" unless stdout.match(/ruby 2\.[56]\.\d/)
10
+ config = load_config
11
+ config['ruby'] = stdout.strip
12
+ dump_config(config)
13
+ "マネージドクラウドがサポートしているバージョンのRubyがインストールされています [#{stdout.strip}]"
14
+ end
15
+
16
+ def hint
17
+ puts 'マネージドクラウドがサポートしているRuby2.6.xかRuby2.5.xをインストールしてください'
18
+ puts 'マネージドクラウドで作成するRailsプロジェクトのRubyのバージョンと合わせるのが望ましいです'
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,49 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckItem
6
+ class SSH < Base
7
+ def check
8
+ config = load_config
9
+ ssh_command = config['ssh']
10
+
11
+ if ssh_command != NOCHECK
12
+ begin
13
+ stdout = `#{ssh_command} hostname`
14
+ rescue => e
15
+ puts "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
16
+ ssh_command = ''
17
+ end
18
+ end
19
+
20
+ if [NOCHECK, ''].include?(ssh_command)
21
+ prompt = TTY::Prompt.new(active_color: :cyan)
22
+ ssh_command = prompt.ask('SSHコマンドを入力してください(マネージドクラウドのプロジェクト詳細に記載があります):')
23
+ begin
24
+ stdout = `#{ssh_command} hostname`
25
+ rescue => e
26
+ raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}"
27
+ end
28
+ end
29
+ raise 'SSHコマンドの実行に失敗しました。入力したコマンドを確認してください' unless stdout.match(/^gitpush-ruby.+lolipop\.io/)
30
+ config['ssh'] = ssh_command
31
+ dump_config(config)
32
+ "SSHコマンドの設定が完了しています [#{ssh_command}]"
33
+ end
34
+
35
+ def hint
36
+ puts 'マネージドクラウドのプロジェクト詳細に `SSHコマンド` に記載があります'
37
+ puts '例: `ssh -p 123456 dreamy-kanoya-1234@ssh-1.mc.lolipop.jp'
38
+ puts ''
39
+ puts 'もし `SSHコマンド` を入力してもSSHコマンドの実行失敗する場合は以下の点を確認してみてください'
40
+ puts '- マネージドクラウドに公開鍵を設定しているか?'
41
+ puts '- 秘密鍵を~/.ssh/に設置しているか?'
42
+ puts '- ~/.ssh/config の設定をしているか?'
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,53 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ module CheckList
6
+ require 'lolipop/mc/starter/rails/check_item/base'
7
+ require 'lolipop/mc/starter/rails/check_item/git'
8
+ require 'lolipop/mc/starter/rails/check_item/ruby'
9
+ require 'lolipop/mc/starter/rails/check_item/rails_dir'
10
+ require 'lolipop/mc/starter/rails/check_item/ssh'
11
+ require 'lolipop/mc/starter/rails/check_item/rails'
12
+ require 'lolipop/mc/starter/rails/check_item/git_log'
13
+ require 'lolipop/mc/starter/rails/check_item/git_remote'
14
+ require 'lolipop/mc/starter/rails/check_item/rails_key'
15
+ require 'lolipop/mc/starter/rails/check_item/env_rails_key'
16
+ require 'lolipop/mc/starter/rails/check_item/env_database'
17
+ require 'lolipop/mc/starter/rails/check_item/gem_mysql2'
18
+ require 'lolipop/mc/starter/rails/check_item/env_rails_static'
19
+
20
+ LIST = [
21
+ Lolipop::Mc::Starter::Rails::CheckItem::Git,
22
+ Lolipop::Mc::Starter::Rails::CheckItem::Ruby,
23
+ Lolipop::Mc::Starter::Rails::CheckItem::RailsDir,
24
+ Lolipop::Mc::Starter::Rails::CheckItem::SSH,
25
+ Lolipop::Mc::Starter::Rails::CheckItem::Rails,
26
+ Lolipop::Mc::Starter::Rails::CheckItem::GitLog,
27
+ Lolipop::Mc::Starter::Rails::CheckItem::GitRemote,
28
+ Lolipop::Mc::Starter::Rails::CheckItem::RailsKey,
29
+ Lolipop::Mc::Starter::Rails::CheckItem::EnvRailsKey,
30
+ Lolipop::Mc::Starter::Rails::CheckItem::EnvDatabase,
31
+ Lolipop::Mc::Starter::Rails::CheckItem::GemMysql2,
32
+ Lolipop::Mc::Starter::Rails::CheckItem::EnvRailsStatic
33
+ ]
34
+
35
+ def self.check_all
36
+ LIST.each do |item|
37
+ i = item.new
38
+ begin
39
+ puts '✅ ' + Paint[i.check, :green].to_s
40
+ rescue => e
41
+ puts '❌ ' + Paint[e.message, :red]
42
+ puts ''
43
+ puts '[ヒント]'
44
+ i.hint
45
+ break
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,26 @@
1
+ require 'thor'
2
+ require 'lolipop/mc/starter/rails/check_list'
3
+
4
+ module Lolipop
5
+ module Mc
6
+ module Starter
7
+ module Rails
8
+ class CLI < Thor
9
+ desc 'check', 'Check your Rails project'
10
+ def check
11
+ Lolipop::Mc::Starter::Rails::CheckList.check_all
12
+ end
13
+
14
+ option :version, type: :boolean, aliases: :v
15
+ def help(version = nil)
16
+ if version
17
+ puts Lolipop::Mc::Starter::Rails::VERSION
18
+ else
19
+ super
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ module Lolipop
2
+ module Mc
3
+ module Starter
4
+ module Rails
5
+ VERSION = '0.1.0'.freeze
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "lolipop/mc/starter/rails/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'lolipop-mc-starter-rails'
8
+ spec.version = Lolipop::Mc::Starter::Rails::VERSION
9
+ spec.authors = ['k1low']
10
+ spec.email = ['k1low@pepabo.com']
11
+
12
+ spec.summary = 'Lolipop! Managed Cloud Starter for Rails.'
13
+ spec.description = 'Lolipop! Managed Cloud Starter for Rails.'
14
+ spec.homepage = 'https://github.com/k1LoW/lolipop-mc-starter-rails'
15
+ spec.license = 'MIT'
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.required_ruby_version = '>= 2.5'
27
+ spec.add_runtime_dependency 'dry-inflector'
28
+ spec.add_runtime_dependency 'paint'
29
+ spec.add_runtime_dependency 'thor'
30
+ spec.add_runtime_dependency 'tty-prompt'
31
+ spec.add_development_dependency 'bundler', '~> 1.17'
32
+ spec.add_development_dependency 'octorelease'
33
+ spec.add_development_dependency 'rake', '~> 12.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lolipop-mc-starter-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - k1low
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-08-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dry-inflector
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: paint
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-prompt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.17'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.17'
83
+ - !ruby/object:Gem::Dependency
84
+ name: octorelease
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '12.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '12.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ description: Lolipop! Managed Cloud Starter for Rails.
126
+ email:
127
+ - k1low@pepabo.com
128
+ executables:
129
+ - mc-rails
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - CODE_OF_CONDUCT.md
137
+ - Gemfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - bin/console
142
+ - bin/setup
143
+ - exe/mc-rails
144
+ - lib/lolipop/mc/starter/rails.rb
145
+ - lib/lolipop/mc/starter/rails/check_item/base.rb
146
+ - lib/lolipop/mc/starter/rails/check_item/env_database.rb
147
+ - lib/lolipop/mc/starter/rails/check_item/env_rails_key.rb
148
+ - lib/lolipop/mc/starter/rails/check_item/env_rails_static.rb
149
+ - lib/lolipop/mc/starter/rails/check_item/env_ruby.rb
150
+ - lib/lolipop/mc/starter/rails/check_item/gem_mysql2.rb
151
+ - lib/lolipop/mc/starter/rails/check_item/git.rb
152
+ - lib/lolipop/mc/starter/rails/check_item/git_log.rb
153
+ - lib/lolipop/mc/starter/rails/check_item/git_remote.rb
154
+ - lib/lolipop/mc/starter/rails/check_item/rails.rb
155
+ - lib/lolipop/mc/starter/rails/check_item/rails_dir.rb
156
+ - lib/lolipop/mc/starter/rails/check_item/rails_key.rb
157
+ - lib/lolipop/mc/starter/rails/check_item/ruby.rb
158
+ - lib/lolipop/mc/starter/rails/check_item/ssh.rb
159
+ - lib/lolipop/mc/starter/rails/check_list.rb
160
+ - lib/lolipop/mc/starter/rails/cli.rb
161
+ - lib/lolipop/mc/starter/rails/version.rb
162
+ - lolipop-mc-starter-rails.gemspec
163
+ homepage: https://github.com/k1LoW/lolipop-mc-starter-rails
164
+ licenses:
165
+ - MIT
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '2.5'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubygems_version: 3.0.3
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Lolipop! Managed Cloud Starter for Rails.
186
+ test_files: []