checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d2c408e038152445689bcb932f03fe9f4d806760f5ff93375524325b345a7d07
4
+ data.tar.gz: 93996cd550c3b21b227ed8703f1fd1a54175d7eea1953fcb9b6ecf19c2b2ebe2
5
+ SHA512:
6
+ metadata.gz: 0f8886f695aac92c4fbeabc8f6bd15063269090a8e0e3b1fa60c3e235cff039803fd5eac4b740d10a4efa5feb51836460e500edd3351d1aa97f8dae1fa423823
7
+ data.tar.gz: 6b4d9b807066652b8055546d70846b78928edcd0764b15705245a4acd4abba65cb9b5624f5ffaf3e8079dff11b3d10792045c4912de6c8eff3dfc95e2e6ec6b0
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ This Rails app builder gem is designed to easy our lifes at BetterDoc and allow us to quickly setup Rails projects for our typical project types (See https://dev.betterdoc.org/organization/2019/02/25/naming-things-part-3B.html for how we have named our project types and their typical content).
2
+
3
+ ## Usage
4
+
5
+ The gem is deployed to RubyGems.org so it can be installed as simply as any other Gem out there:
6
+
7
+ ```bash
8
+ $ gem install
9
+ ```
10
+
11
+ ## Development
data/bin/generate-rails-containerservice ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'betterdoc/generators/impl/containerservice_app_generator'
4
+
5
+ raise 'No project name specified on command line' if ARGV.empty?
6
+
7
+ Betterdoc::Generators::Impl::ContainerserviceAppGenerator.start(ARGV)
data/lib/betterdoc/generators/app_generator.rb ADDED
@@ -0,0 +1,64 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+ require 'yaml'
4
+ require_relative '../support/servicefile'
5
+
6
+ module Betterdoc
7
+ module Generators
8
+
9
+ class AppBuilder < Rails::AppBuilder; end
10
+
11
+ class AppGenerator < Rails::Generators::AppGenerator
12
+
13
+ class << self
14
+ def source_root(path = nil)
15
+ Rails::Generators::AppGenerator.source_root(path)
16
+ end
17
+
18
+ def start(options)
19
+ options.push("--skip-action-cable") unless options.include?("--enable-action-cable")
20
+ options.push("--skip-javascript") unless options.include?("--enable-javascript")
21
+ options.push("--skip-sprockets") unless options.include?("--enable-sprockets")
22
+ options.push("--skip-yarn") unless options.include?("--enable-yarn")
23
+ options.push("--skip-action-mailer") unless options.include?("--enable-action-mailer")
24
+ options.push("--skip-active-storage") unless options.include?("--enable-action-storage")
25
+ options.push("--skip-spring") unless options.include?("--enable-spring")
26
+ options.push("--skip-coffee") unless options.include?("--enable-coffee")
27
+ options.push("--skip-test") unless options.include?("--enable-test")
28
+ super(options)
29
+ end
30
+ end
31
+
32
+ def initialize(*args)
33
+ super
34
+ source_paths.unshift([File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'templates'))])
35
+ end
36
+
37
+ def get_builder_class
38
+ AppBuilder
39
+ end
40
+
41
+ def create_misc_files
42
+ template('env.development.local', '.env.development.local')
43
+ template('dockerignore', '.dockerignore')
44
+ template('rspec', '.rspec')
45
+ template('rubocop.yml', '.rubocop.yml')
46
+ template('Dockerfile', 'Dockerfile')
47
+ template('circleci-config', '.circleci/config.yml')
48
+ end
49
+
50
+ def create_servicefile_file
51
+ create_file('Servicefile', create_servicefile.to_yaml)
52
+ end
53
+
54
+ def create_servicefile
55
+ servicefile = Betterdoc::Support::Servicefile.new
56
+ servicefile.service_name = @app_name
57
+ servicefile.add_environment('PORT', 'The HTTP port on which the service should listen for incoming requests')
58
+ servicefile.add_environment('SECRET_KEY_BASE', 'The Rails secret key base string')
59
+ servicefile
60
+ end
61
+
62
+ end
63
+ end
64
+ end
data/lib/betterdoc/generators/impl/containerservice_app_generator.rb ADDED
@@ -0,0 +1,28 @@
1
+ require_relative '../app_generator'
2
+
3
+ module Betterdoc
4
+ module Generators
5
+ module Impl
6
+ class ContainerserviceAppGenerator < Betterdoc::Generators::AppGenerator
7
+
8
+ def create_servicefile
9
+ servicefile = super
10
+ servicefile.add_environment('JWT_PUBLIC_KEY', "The public key to decode the JWTs")
11
+ servicefile.add_environment('JWT_VALIDATION_ALGORITHM', "The algorithm to be used to decode the JWTs", true, "RS256")
12
+ servicefile
13
+ end
14
+
15
+ class ContainerserviceAppBuilder < Betterdoc::Generators::AppBuilder
16
+ def gemfile
17
+ template 'Gemfile-containerservice', 'Gemfile'
18
+ end
19
+ end
20
+
21
+ def get_builder_class
22
+ ContainerserviceAppBuilder
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
data/lib/betterdoc/support/servicefile.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'yaml'
2
+ require_relative 'servicefile_environment_entry'
3
+
4
+ module Betterdoc
5
+ module Support
6
+ class Servicefile
7
+
8
+ attr_accessor :service_name
9
+ attr_accessor :version
10
+ attr_accessor :environment
11
+
12
+ def initialize
13
+ @version = "1.0"
14
+ @environment = {}
15
+ end
16
+
17
+ def add_environment(variable_name, description, optional = false, default = nil)
18
+ entry = ServicefileEnvironmentEntry.new
19
+ entry.description = description
20
+ entry.optional = optional
21
+ entry.default = default
22
+ @environment[variable_name] = entry
23
+ end
24
+
25
+ def to_yaml
26
+ {
27
+ 'version' => '1.0',
28
+ 'service_name' => @app_name,
29
+ 'runtime' => {
30
+ 'env' => to_environment_hash
31
+ }
32
+ }.to_yaml
33
+ end
34
+
35
+ private
36
+
37
+ def to_environment_hash
38
+ environment = []
39
+ @environment.each do |key, environment_entry|
40
+ environment_item = { "name" => key }
41
+ environment_item['description'] = environment_entry.description unless environment_entry.description.nil?
42
+ environment_item['optional'] = true if environment_entry.optional
43
+ environment_item['default'] = environment_entry.default unless environment_entry.default.nil?
44
+ environment.push(environment_item)
45
+ end
46
+ environment
47
+ end
48
+
49
+ end
50
+ end
51
+ end
data/lib/betterdoc/support/servicefile_environment_entry.rb ADDED
@@ -0,0 +1,15 @@
1
+ module Betterdoc
2
+ module Support
3
+ class ServicefileEnvironmentEntry
4
+
5
+ attr_accessor :description
6
+ attr_accessor :optional
7
+ attr_accessor :default
8
+
9
+ def initialize
10
+ @optional = false
11
+ end
12
+
13
+ end
14
+ end
15
+ end
data/templates/Dockerfile.tt ADDED
@@ -0,0 +1,10 @@
1
+ FROM ruby:<%= "#{RUBY_VERSION}" %>
2
+
3
+ RUN mkdir /app
4
+ WORKDIR /app
5
+
6
+ ADD . /app
7
+ RUN gem install bundler
8
+ RUN bundle install --jobs=8
9
+
10
+ CMD BINDING=0.0.0.0 /app/bin/rails server
data/templates/Gemfile-containerservice.tt ADDED
@@ -0,0 +1,27 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) do |repo_name|
3
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
4
+ "https://github.com/#{repo_name}.git"
5
+ end
6
+
7
+ gem 'betterdoc-containerservice', git: 'https://github.com/betterdoc-org/general-gem-betterdoc-containerservice'
8
+ gem 'bootsnap', '>= 1.4.5', require: false
9
+ gem 'rails', '~> <%= "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" %>'
10
+ gem 'sentry-raven', '~> 2.13.0'
11
+
12
+ group :development, :test do
13
+ gem 'betterdoc-containerservice-testing', git: 'https://github.com/betterdoc-org/general-gem-betterdoc-containerservice-testing'
14
+ gem 'rspec-rails', '~> 3.9.0'
15
+ gem 'rspec_junit_formatter', '~> 0.4.1'
16
+ gem 'rubocop', '~> 0.79.0'
17
+ gem 'rubocop-junit-formatter', '~> 0.1.4'
18
+ gem 'rubocop-performance', '~> 1.5.2'
19
+ end
20
+
21
+ group :development do
22
+ gem 'awesome_print', '~> 1.8.0'
23
+ gem 'dotenv-rails', '~> 2.7.5'
24
+ gem 'listen', '>= 3.0.5', '< 3.2'
25
+ gem 'pry-rails', '~> 0.3.9'
26
+ gem 'web-console', '>= 4.0.1'
27
+ end
data/templates/circleci-config.tt ADDED
@@ -0,0 +1,35 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ recipe: "betterdoc/recipes-ruby@4"
5
+ deploy: "betterdoc/deploy-to-heroku@4"
6
+
7
+ workflows:
8
+ version: 2
9
+ build_and_deploy:
10
+ jobs:
11
+ - recipe/build-rails-rspec:
12
+ name: "build"
13
+ filters:
14
+ tags:
15
+ only: /release-.*/
16
+ - deploy/docker-build-release:
17
+ name: "deploy-to-test"
18
+ requires: [ "build" ]
19
+ context: heroku-deploy
20
+ app-name: t-<%= @app_name %>
21
+ filters:
22
+ branches:
23
+ only: /master/
24
+ tags:
25
+ ignore: /.*/
26
+ - deploy/docker-build-release:
27
+ name: "deploy-to-production"
28
+ requires: [ "build" ]
29
+ context: heroku-deploy
30
+ app-name: p-<%= @app_name %>
31
+ filters:
32
+ branches:
33
+ ignore: /.*/
34
+ tags:
35
+ only: /release-.*/
data/templates/dockerignore.tt ADDED
@@ -0,0 +1,6 @@
1
+ /.circleci
2
+ /.git
3
+ /log
4
+ /spec
5
+ /test
6
+ /tmp
data/templates/env.development.local ADDED
@@ -0,0 +1,3 @@
1
+ JWT_VALIDATION_ENABLED="false"
2
+
3
+ CONTAINERSERVICE_FULL_HTML="true"
data/templates/gitignore.tt ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle
2
+
3
+ /log/*
4
+ /tmp/*
5
+ !/log/.keep
6
+ !/tmp/.keep
7
+ /db/*.sqlite3
8
+
9
+ /test/reports
10
+ /public/assets
11
+ .byebug_history
12
+
13
+ /.idea
14
+ /.env*
15
+ .DS_Store
data/templates/rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/templates/rubocop.yml ADDED
@@ -0,0 +1,80 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'db/**/*.rb'
4
+ - 'vendor/**/*'
5
+ - 'bin/*'
6
+
7
+ Metrics/AbcSize:
8
+ Max: 40
9
+
10
+ Metrics/BlockLength:
11
+ Max: 75
12
+
13
+ Metrics/ClassLength:
14
+ Max: 150
15
+
16
+ Metrics/ModuleLength:
17
+ Max: 150
18
+
19
+ Metrics/CyclomaticComplexity:
20
+ Max: 15
21
+
22
+ Metrics/LineLength:
23
+ Enabled: false
24
+
25
+ Metrics/MethodLength:
26
+ Max: 30
27
+
28
+ Metrics/PerceivedComplexity:
29
+ Max: 15
30
+
31
+ Layout/EmptyLines:
32
+ Enabled: false
33
+
34
+ Layout/EmptyLinesAroundBeginBody:
35
+ Enabled: false
36
+
37
+ Layout/EmptyLinesAroundBlockBody:
38
+ Enabled: false
39
+
40
+ Layout/EmptyLinesAroundClassBody:
41
+ Enabled: false
42
+
43
+ Layout/EmptyLinesAroundExceptionHandlingKeywords:
44
+ Enabled: false
45
+
46
+ Layout/EmptyLinesAroundMethodBody:
47
+ Enabled: false
48
+
49
+ Layout/EmptyLinesAroundModuleBody:
50
+ Enabled: false
51
+
52
+ Lint/NonLocalExitFromIterator:
53
+ Enabled: false
54
+
55
+ Style/Documentation:
56
+ Enabled: false
57
+
58
+ Style/FrozenStringLiteralComment:
59
+ Enabled: false
60
+
61
+ Style/GuardClause:
62
+ Enabled: false
63
+
64
+ Style/StringLiterals:
65
+ Enabled: false
66
+
67
+ Style/WordArray:
68
+ Enabled: false
69
+
70
+ Style/Next:
71
+ Enabled: false
72
+
73
+ Style/MixinUsage:
74
+ Enabled: false
75
+
76
+ Style/ClassAndModuleChildren:
77
+ Enabled: false
78
+
79
+ Style/RegexpLiteral:
80
+ Enabled: false
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: betterdoc-rails-app-builder
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - BetterDoc GmbH
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.0.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.9.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.9.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec_junit_formatter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.4.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.68.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.68.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-junit-formatter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.1.4
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.4
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-performance
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.2.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.2.0
97
+ description:
98
+ email:
99
+ - development@betterdoc.org
100
+ executables:
101
+ - generate-rails-containerservice
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - README.md
106
+ - bin/generate-rails-containerservice
107
+ - lib/betterdoc/generators/app_generator.rb
108
+ - lib/betterdoc/generators/impl/containerservice_app_generator.rb
109
+ - lib/betterdoc/support/servicefile.rb
110
+ - lib/betterdoc/support/servicefile_environment_entry.rb
111
+ - templates/Dockerfile.tt
112
+ - templates/Gemfile-containerservice.tt
113
+ - templates/circleci-config.tt
114
+ - templates/dockerignore.tt
115
+ - templates/env.development.local
116
+ - templates/gitignore.tt
117
+ - templates/rspec
118
+ - templates/rubocop.yml
119
+ homepage: http://dev.betterdoc.org
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubygems_version: 3.0.3
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Generators for our common project types
142
+ test_files: []