gemaker 0.6.0 → 1.0.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/.circleci/config.yml +1 -1
- data/.rubocop.yml +61 -603
- data/CHANGELOG.md +9 -0
- data/README.md +10 -0
- data/gemaker.gemspec +5 -6
- data/lib/gemaker.rb +2 -2
- data/lib/gemaker/cli.rb +2 -3
- data/lib/gemaker/commands/add_cli_structure.rb +1 -0
- data/lib/gemaker/commands/add_install_generator.rb +30 -6
- data/lib/gemaker/commands/configure_continuous_integration.rb +23 -0
- data/lib/gemaker/commands/configure_editor_config.rb +10 -0
- data/lib/gemaker/commands/configure_test_env.rb +9 -8
- data/lib/gemaker/commands/create_gem.rb +3 -6
- data/lib/gemaker/commands/customize_engine.rb +31 -4
- data/lib/gemaker/config.rb +1 -9
- data/lib/gemaker/templates/circle_config.yml.erb +103 -0
- data/lib/gemaker/templates/circleci-setup-script.sh +3 -0
- data/lib/gemaker/templates/editorconfig +24 -0
- data/lib/gemaker/templates/engine/Guardfile +6 -9
- data/lib/gemaker/templates/engine/README.md.erb +45 -2
- data/lib/gemaker/templates/engine/development.rb.erb +81 -0
- data/lib/gemaker/templates/engine/gemspec.erb +8 -5
- data/lib/gemaker/templates/engine/gitignore +1 -0
- data/lib/gemaker/templates/engine/install_generator.rb.erb +0 -2
- data/lib/gemaker/templates/engine/rails_helper.rb.erb +2 -7
- data/lib/gemaker/templates/engine/rubocop.yml.erb +503 -0
- data/lib/gemaker/templates/normal/README.md.erb +14 -0
- data/lib/gemaker/templates/normal/gemspec.erb +9 -6
- data/lib/gemaker/templates/normal/rubocop.yml.erb +496 -0
- data/lib/gemaker/templates/ruby-version.erb +1 -1
- data/lib/gemaker/util.rb +3 -2
- data/lib/gemaker/version.rb +7 -2
- metadata +51 -50
- data/.coveralls.yml +0 -1
- data/.hound.yml +0 -4
- data/lib/gemaker/commands/add_hound_rules.rb +0 -12
- data/lib/gemaker/commands/configure_travis.rb +0 -15
- data/lib/gemaker/templates/coveralls.yml +0 -1
- data/lib/gemaker/templates/engine/travis.yml.erb +0 -15
- data/lib/gemaker/templates/normal/travis.yml.erb +0 -13
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
### 1.0.0
|
6
|
+
##### Changed
|
7
|
+
|
8
|
+
- Generate gems with Circle CI instead of Travis.
|
9
|
+
- Generate dummy app with Rails 6.
|
10
|
+
- Use Review Dog instead of Hound.
|
11
|
+
- Always create mountable engines.
|
12
|
+
- Move specs out of dummy app.
|
13
|
+
|
5
14
|
### 0.6.0
|
6
15
|
|
7
16
|
##### Changed
|
data/README.md
CHANGED
@@ -28,6 +28,16 @@ gemaker new my_gem
|
|
28
28
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
29
|
5. Create new Pull Request
|
30
30
|
|
31
|
+
## Publishing
|
32
|
+
|
33
|
+
On master/main branch...
|
34
|
+
|
35
|
+
1. Change `VERSION` in `lib/gemaker/version.rb`.
|
36
|
+
2. Change `Unreleased` title to current version in `CHANGELOG.md`.
|
37
|
+
3. Commit new release. For example: `Releasing v0.1.0`.
|
38
|
+
4. Create tag. For example: `git tag v0.1.0`.
|
39
|
+
5. Push tag. For example: `git push origin v0.1.0`.
|
40
|
+
|
31
41
|
## Credits
|
32
42
|
|
33
43
|
Thank you [contributors](https://github.com/platanus/gemaker/graphs/contributors)!
|
data/gemaker.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'gemaker/version'
|
@@ -18,16 +17,16 @@ Gem::Specification.new do |spec|
|
|
18
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
21
|
-
spec.add_dependency "power-types"
|
22
|
-
spec.add_dependency "commander"
|
23
20
|
spec.add_dependency "activesupport"
|
24
|
-
spec.add_dependency "colorize", "~> 0.7", ">= 0.7.7"
|
25
21
|
spec.add_dependency "artii", "~> 2.1", ">= 2.1.1"
|
22
|
+
spec.add_dependency "colorize", "~> 0.7", ">= 0.7.7"
|
23
|
+
spec.add_dependency "commander"
|
24
|
+
spec.add_dependency "power-types"
|
26
25
|
|
27
26
|
spec.add_development_dependency "bundler", "~> 2.2.15"
|
27
|
+
spec.add_development_dependency "coveralls"
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
30
|
spec.add_development_dependency "rspec_junit_formatter"
|
31
|
-
spec.add_development_dependency "rubocop", "~>
|
32
|
-
spec.add_development_dependency "coveralls"
|
31
|
+
spec.add_development_dependency "rubocop", "~> 1.9"
|
33
32
|
end
|
data/lib/gemaker.rb
CHANGED
@@ -10,6 +10,7 @@ require "gemaker/commands/base"
|
|
10
10
|
require "gemaker/commands/create_gem"
|
11
11
|
require "gemaker/commands/add_readme"
|
12
12
|
require "gemaker/commands/add_changelog"
|
13
|
+
require "gemaker/commands/configure_editor_config"
|
13
14
|
require "gemaker/commands/customize_gemspec"
|
14
15
|
require "gemaker/commands/add_license"
|
15
16
|
require "gemaker/commands/add_cli_structure"
|
@@ -20,8 +21,7 @@ require "gemaker/commands/customize_engine"
|
|
20
21
|
require "gemaker/commands/customize_rakefile"
|
21
22
|
require "gemaker/commands/customize_main_lib_file"
|
22
23
|
require "gemaker/commands/add_install_generator"
|
23
|
-
require "gemaker/commands/
|
24
|
-
require "gemaker/commands/configure_travis"
|
24
|
+
require "gemaker/commands/configure_continuous_integration"
|
25
25
|
|
26
26
|
module Gemaker
|
27
27
|
end
|
data/lib/gemaker/cli.rb
CHANGED
@@ -25,7 +25,7 @@ module Gemaker
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
# rubocop:disable Metrics/MethodLength
|
28
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
29
29
|
def fill_config(gem_name, config)
|
30
30
|
config.gem_name = gem_name
|
31
31
|
|
@@ -48,13 +48,12 @@ module Gemaker
|
|
48
48
|
config.engine = agree("Is the gem a Rails engine?")
|
49
49
|
|
50
50
|
if config.engine?
|
51
|
-
config.mountable = agree("Is the engine mountable?")
|
52
51
|
config.installable = agree("Need an installer?")
|
53
52
|
else
|
54
53
|
config.cli = agree("Is it a CLI (Command-line interface)?")
|
55
54
|
end
|
56
55
|
end
|
57
|
-
# rubocop:enable Metrics/MethodLength
|
56
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
58
57
|
|
59
58
|
def draw_artii(text)
|
60
59
|
a = Artii::Base.new font: 'slant'
|
@@ -3,6 +3,7 @@ module Gemaker
|
|
3
3
|
class AddCliStructure < Gemaker::Cmd::Base
|
4
4
|
def perform
|
5
5
|
return unless @config.cli?
|
6
|
+
|
6
7
|
copy_template("exe", "exe/#{@config.gem_name}", config: @config)
|
7
8
|
copy_template("cli.rb", "lib/#{@config.gem_name}/cli.rb", config: @config)
|
8
9
|
info "Add CLI structure"
|
@@ -3,14 +3,38 @@ module Gemaker
|
|
3
3
|
class AddInstallGenerator < Gemaker::Cmd::Base
|
4
4
|
def in_engine_context
|
5
5
|
return unless @config.installable?
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
copy_template("engine/install_usage",
|
11
|
-
"lib/generators/#{@config.gem_name}/install/USAGE", config: @config)
|
6
|
+
|
7
|
+
copy_initializer
|
8
|
+
copy_install_generator
|
9
|
+
copy_install_usage_file
|
12
10
|
info "Add Installer"
|
13
11
|
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def copy_initializer
|
16
|
+
copy_template(
|
17
|
+
"engine/initializer.rb",
|
18
|
+
"lib/generators/#{@config.gem_name}/install/templates/initializer.rb",
|
19
|
+
config: @config
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_install_generator
|
24
|
+
copy_template(
|
25
|
+
"engine/install_generator.rb",
|
26
|
+
"lib/generators/#{@config.gem_name}/install/install_generator.rb",
|
27
|
+
config: @config
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def copy_install_usage_file
|
32
|
+
copy_template(
|
33
|
+
"engine/install_usage",
|
34
|
+
"lib/generators/#{@config.gem_name}/install/USAGE",
|
35
|
+
config: @config
|
36
|
+
)
|
37
|
+
end
|
14
38
|
end
|
15
39
|
end
|
16
40
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class ConfigureContinuousIntegration < Gemaker::Cmd::Base
|
4
|
+
def in_normal_context
|
5
|
+
configure_ci("normal")
|
6
|
+
end
|
7
|
+
|
8
|
+
def in_engine_context
|
9
|
+
configure_ci("engine")
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def configure_ci(tpl_dir)
|
15
|
+
copy_template("#{tpl_dir}/rubocop.yml", ".rubocop.yml", config: @config)
|
16
|
+
create_dir(".circleci")
|
17
|
+
copy_template("circle_config.yml", ".circleci/config.yml", config: @config)
|
18
|
+
copy_file("circleci-setup-script.sh", ".circleci/setup-rubygems.sh")
|
19
|
+
info "Configure CricleCI"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -4,7 +4,6 @@ module Gemaker
|
|
4
4
|
def in_normal_context
|
5
5
|
copy_template("normal/spec_helper.rb", "spec/spec_helper.rb", config: @config)
|
6
6
|
copy_file("test_helpers.rb", "spec/support/test_helpers.rb")
|
7
|
-
copy_file("coveralls.yml", ".coveralls.yml")
|
8
7
|
copy_template("normal/test_example.rb", "spec/#{@config.gem_name}_spec.rb", config: @config)
|
9
8
|
copy_file("normal/Guardfile", "Guardfile")
|
10
9
|
info "Configure Rspec"
|
@@ -13,13 +12,15 @@ module Gemaker
|
|
13
12
|
def in_engine_context
|
14
13
|
copy_template("engine/spec_helper.rb", "spec/spec_helper.rb", config: @config)
|
15
14
|
copy_template("engine/rails_helper.rb", "spec/rails_helper.rb", config: @config)
|
16
|
-
copy_template(
|
17
|
-
"
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
copy_file("
|
15
|
+
copy_template(
|
16
|
+
"engine/test_example.rb",
|
17
|
+
"spec/#{@config.gem_name}_spec.rb",
|
18
|
+
config: @config
|
19
|
+
)
|
20
|
+
create_dir("spec/factories")
|
21
|
+
copy_file("test_helpers.rb", "spec/support/test_helpers.rb")
|
22
|
+
copy_file("image.png", "spec/fixtures/files/image.png")
|
23
|
+
copy_file("video.mp4", "spec/fixtures/files/video.mp4")
|
23
24
|
copy_file("engine/rspec", ".rspec")
|
24
25
|
copy_file("engine/Guardfile", "Guardfile")
|
25
26
|
info "Configure Rspec"
|
@@ -2,13 +2,11 @@ module Gemaker
|
|
2
2
|
module Cmd
|
3
3
|
class CreateGem < Gemaker::Cmd::Base
|
4
4
|
def in_engine_context
|
5
|
-
mountable_opt = "--mountable" if @config.mountable?
|
6
|
-
|
7
5
|
commands = [
|
8
6
|
"echo \"source 'https://rubygems.org'\" > GemakerGemfile",
|
9
7
|
"echo \"gem 'rails', '~> #{Gemaker::RAILS_VERSION}'\" > GemakerGemfile",
|
10
8
|
"BUNDLE_GEMFILE=GemakerGemfile bundle install",
|
11
|
-
"BUNDLE_GEMFILE=GemakerGemfile bundle exec rails plugin new #{@config.gem_name} -T
|
9
|
+
"BUNDLE_GEMFILE=GemakerGemfile bundle exec rails plugin new #{@config.gem_name} -T --mountable --dummy-path=spec/dummy", # rubocop:disable Metrics/LineLength
|
12
10
|
"rm -f GemakerGemfile GemakerGemfile.lock"
|
13
11
|
]
|
14
12
|
|
@@ -21,11 +19,11 @@ module Gemaker
|
|
21
19
|
|
22
20
|
private
|
23
21
|
|
24
|
-
# rubocop:disable Metrics/MethodLength
|
25
22
|
def create_customized_gem(cmd)
|
26
23
|
execute(cmd)
|
27
24
|
Gemaker::Cmd::AddReadme.for(config: @config)
|
28
25
|
Gemaker::Cmd::AddChangelog.for(config: @config)
|
26
|
+
Gemaker::Cmd::ConfigureEditorConfig.for(config: @config)
|
29
27
|
Gemaker::Cmd::CustomizeGemspec.for(config: @config)
|
30
28
|
Gemaker::Cmd::AddLicense.for(config: @config)
|
31
29
|
Gemaker::Cmd::AddCliStructure.for(config: @config)
|
@@ -35,8 +33,7 @@ module Gemaker
|
|
35
33
|
Gemaker::Cmd::CustomizeRakefile.for(config: @config)
|
36
34
|
Gemaker::Cmd::CustomizeMainLibFile.for(config: @config)
|
37
35
|
Gemaker::Cmd::AddInstallGenerator.for(config: @config)
|
38
|
-
Gemaker::Cmd::
|
39
|
-
Gemaker::Cmd::ConfigureTravis.for(config: @config)
|
36
|
+
Gemaker::Cmd::ConfigureContinuousIntegration.for(config: @config)
|
40
37
|
Gemaker::Cmd::ConfigureGit.for(config: @config)
|
41
38
|
info("Done!")
|
42
39
|
end
|
@@ -2,12 +2,39 @@ module Gemaker
|
|
2
2
|
module Cmd
|
3
3
|
class CustomizeEngine < Gemaker::Cmd::Base
|
4
4
|
def in_engine_context
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
replace_development_file
|
6
|
+
replace_engine_file
|
7
|
+
add_example_class
|
8
|
+
|
9
9
|
info "Customize engine.rb"
|
10
10
|
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def replace_development_file
|
15
|
+
remove_in_gem("spec/dummy/config/environments/development.rb")
|
16
|
+
copy_template(
|
17
|
+
"engine/development.rb",
|
18
|
+
"spec/dummy/config/environments/development.rb",
|
19
|
+
config: @config
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def replace_engine_file
|
24
|
+
copy_template(
|
25
|
+
"engine/engine.rb",
|
26
|
+
"lib/#{@config.gem_name}/engine.rb",
|
27
|
+
config: @config
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_example_class
|
32
|
+
copy_template(
|
33
|
+
"engine/example_class.rb",
|
34
|
+
"lib/#{@config.gem_name}/example_class.rb",
|
35
|
+
config: @config
|
36
|
+
)
|
37
|
+
end
|
11
38
|
end
|
12
39
|
end
|
13
40
|
end
|
data/lib/gemaker/config.rb
CHANGED
@@ -2,7 +2,7 @@ module Gemaker
|
|
2
2
|
class Config
|
3
3
|
RUBY_VERSION = 2.3
|
4
4
|
|
5
|
-
attr_accessor :gem_name, :summary, :engine, :cli, :
|
5
|
+
attr_accessor :gem_name, :summary, :engine, :cli, :installable
|
6
6
|
attr_reader :authors, :emails
|
7
7
|
attr_writer :human_gem_name, :description, :homepage
|
8
8
|
|
@@ -45,18 +45,10 @@ module Gemaker
|
|
45
45
|
!!cli
|
46
46
|
end
|
47
47
|
|
48
|
-
def mountable?
|
49
|
-
!!mountable
|
50
|
-
end
|
51
|
-
|
52
48
|
def installable?
|
53
49
|
!!installable
|
54
50
|
end
|
55
51
|
|
56
|
-
def ruby_version
|
57
|
-
RUBY_VERSION
|
58
|
-
end
|
59
|
-
|
60
52
|
private
|
61
53
|
|
62
54
|
def string_to_array(value)
|
@@ -0,0 +1,103 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
env-vars: &env-vars
|
4
|
+
RAILS_ENV: test
|
5
|
+
NODE_ENV: test
|
6
|
+
BUNDLE_PATH: vendor/bundle
|
7
|
+
|
8
|
+
orbs:
|
9
|
+
ruby: circleci/ruby@0.1.2
|
10
|
+
|
11
|
+
executors:
|
12
|
+
main-executor:
|
13
|
+
parameters:
|
14
|
+
ruby-version:
|
15
|
+
description: "Ruby version"
|
16
|
+
default: "<%= Gemaker::RUBY_VERSION %>"
|
17
|
+
type: string
|
18
|
+
docker:
|
19
|
+
- image: circleci/ruby:<<parameters.ruby-version>>-node
|
20
|
+
environment: *env-vars
|
21
|
+
|
22
|
+
commands:
|
23
|
+
setup:
|
24
|
+
description: checkout code and install dependencies
|
25
|
+
steps:
|
26
|
+
- checkout
|
27
|
+
- run:
|
28
|
+
name: Install bundle dependencies
|
29
|
+
command: |
|
30
|
+
BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")
|
31
|
+
gem install bundler:$BUNDLER_VERSION
|
32
|
+
bundle _$(echo $BUNDLER_VERSION)_ install
|
33
|
+
|
34
|
+
jobs:
|
35
|
+
lint:
|
36
|
+
executor: main-executor
|
37
|
+
steps:
|
38
|
+
- setup
|
39
|
+
- run:
|
40
|
+
name: Install reviewdog
|
41
|
+
command: |
|
42
|
+
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b ./bin
|
43
|
+
- run:
|
44
|
+
name: Get files to lint
|
45
|
+
command: |
|
46
|
+
mkdir tmp
|
47
|
+
git diff origin/master --name-only --diff-filter=d > tmp/files_to_lint
|
48
|
+
- run:
|
49
|
+
name: Run rubocop
|
50
|
+
shell: /bin/bash
|
51
|
+
command: |
|
52
|
+
cat tmp/files_to_lint | grep -E '.+\.(rb)$' | xargs bundle exec rubocop --force-exclusion \
|
53
|
+
| ./bin/reviewdog -reporter=github-pr-review -f=rubocop
|
54
|
+
test:
|
55
|
+
parameters:
|
56
|
+
ruby-version:
|
57
|
+
description: "Ruby version"
|
58
|
+
default: "<%= Gemaker::RUBY_VERSION %>"
|
59
|
+
type: string
|
60
|
+
executor:
|
61
|
+
name: main-executor
|
62
|
+
ruby-version: <<parameters.ruby-version>>
|
63
|
+
steps:
|
64
|
+
- setup
|
65
|
+
- run:
|
66
|
+
name: Run Tests
|
67
|
+
command: |
|
68
|
+
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter -f RspecJunitFormatter -o test_results/rspec.xml"
|
69
|
+
RSPEC_FORMAT_ARGS="-f progress --no-color -p 10"
|
70
|
+
bundle exec rspec ./spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
|
71
|
+
- store_test_results:
|
72
|
+
path: test_results
|
73
|
+
deploy:
|
74
|
+
executor: main-executor
|
75
|
+
steps:
|
76
|
+
- setup
|
77
|
+
- run:
|
78
|
+
name: Setup rubygems
|
79
|
+
command: bash .circleci/setup-rubygems.sh
|
80
|
+
- run:
|
81
|
+
name: Publish to rubygems
|
82
|
+
command: |
|
83
|
+
gem build active_job_log.gemspec
|
84
|
+
version_tag=$(git describe --tags)
|
85
|
+
gem push active_job_log-${version_tag#v}.gem
|
86
|
+
|
87
|
+
workflows:
|
88
|
+
version: 2
|
89
|
+
main:
|
90
|
+
jobs:
|
91
|
+
- lint:
|
92
|
+
context: org-global
|
93
|
+
- test:
|
94
|
+
matrix:
|
95
|
+
parameters:
|
96
|
+
ruby-version: <%= Gemaker::RUBY_VERSIONS %>
|
97
|
+
- deploy:
|
98
|
+
context: org-global
|
99
|
+
filters:
|
100
|
+
tags:
|
101
|
+
only: /.*/
|
102
|
+
branches:
|
103
|
+
ignore: /.*/
|