dopstick 0.0.1 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +4 -0
- data/.github/FUNDING.yml +1 -1
- data/.rubocop.yml +11 -6
- data/CHANGELOG.md +30 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +22 -9
- data/dopstick.gemspec +3 -2
- data/dopstick.svg +1 -0
- data/lib/dopstick.rb +7 -1
- data/lib/dopstick/cli.rb +52 -16
- data/lib/dopstick/generator.rb +3 -208
- data/lib/dopstick/{templates → generator/base/templates}/bug_report.erb +1 -1
- data/lib/dopstick/{templates/CHANGELOG.md → generator/base/templates/changelog.erb} +0 -0
- data/lib/dopstick/{templates → generator/base/templates}/coc.erb +1 -1
- data/lib/dopstick/generator/base/templates/codeowners.erb +4 -0
- data/lib/dopstick/{templates → generator/base/templates}/contributing.erb +5 -5
- data/lib/dopstick/generator/base/templates/dependabot.erb +15 -0
- data/lib/dopstick/{templates → generator/base/templates}/feature_request.erb +0 -0
- data/lib/dopstick/generator/base/templates/funding.erb +4 -0
- data/lib/dopstick/{templates → generator/base/templates}/gitignore.erb +0 -0
- data/lib/dopstick/{templates → generator/base/templates}/issue.erb +0 -0
- data/lib/dopstick/{templates → generator/base/templates}/license.erb +1 -1
- data/lib/dopstick/{templates → generator/base/templates}/pull_request.erb +0 -0
- data/lib/dopstick/{templates → generator/base/templates}/setup.erb +0 -0
- data/lib/dopstick/generator/gem/generator.rb +160 -0
- data/lib/dopstick/generator/gem/options.rb +34 -0
- data/lib/dopstick/{templates → generator/gem/templates}/active_record.erb +25 -0
- data/lib/dopstick/generator/gem/templates/bin.erb +5 -0
- data/lib/dopstick/{templates → generator/gem/templates}/cli.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/cli_class.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/console.erb +1 -1
- data/lib/dopstick/generator/gem/templates/entry_file.erb +3 -0
- data/lib/dopstick/generator/gem/templates/gem_entry_file.erb +3 -0
- data/lib/dopstick/{templates → generator/gem/templates}/gemfile.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/gemspec.erb +14 -14
- data/lib/dopstick/{templates → generator/gem/templates}/generator.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/generator_class.erb +0 -0
- data/lib/dopstick/{templates → generator/gem/templates}/rakefile.erb +0 -0
- data/lib/dopstick/generator/gem/templates/readme.erb +50 -0
- data/lib/dopstick/generator/gem/templates/rubocop.erb +12 -0
- data/lib/dopstick/{templates → generator/gem/templates}/test_file.erb +1 -1
- data/lib/dopstick/{templates → generator/gem/templates}/test_helper.erb +1 -1
- data/lib/dopstick/{templates → generator/gem/templates}/tests_workflow.erb +6 -4
- data/lib/dopstick/{templates → generator/gem/templates}/version.erb +0 -0
- data/lib/dopstick/generator/npm/generator.rb +100 -0
- data/lib/dopstick/generator/npm/options.rb +26 -0
- data/lib/dopstick/generator/npm/templates/babel.erb +15 -0
- data/lib/dopstick/generator/npm/templates/eslint.erb +4 -0
- data/lib/dopstick/generator/npm/templates/index.erb +12 -0
- data/lib/dopstick/generator/npm/templates/index_test.erb +7 -0
- data/lib/dopstick/generator/npm/templates/jest.erb +12 -0
- data/lib/dopstick/generator/npm/templates/package.erb +42 -0
- data/lib/dopstick/generator/npm/templates/prettier.erb +1 -0
- data/lib/dopstick/generator/npm/templates/readme.erb +52 -0
- data/lib/dopstick/generator/npm/templates/tests_workflow.erb +46 -0
- data/lib/dopstick/generator/npm/templates/tsconfig.erb +14 -0
- data/lib/dopstick/generator/npm/templates/webpack.erb +33 -0
- data/lib/dopstick/generator/options.rb +65 -0
- data/lib/dopstick/version.rb +1 -1
- metadata +57 -37
- data/lib/dopstick/templates/bin.erb +0 -5
- data/lib/dopstick/templates/entry_file.erb +0 -3
- data/lib/dopstick/templates/funding.erb +0 -4
- data/lib/dopstick/templates/gem_entry_file.erb +0 -3
- data/lib/dopstick/templates/readme.erb +0 -50
- data/lib/dopstick/templates/rubocop.erb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17fe9695f451b433549bf25b5d8d5484388771739fc32333c4d3a4a6bcfa9348
|
4
|
+
data.tar.gz: 4791e172a00147a6e7e920eff00e15b26c6ec73d3964a4854e91847989049da3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65edec1f5c5d373b5ead2dd1631fe4b5638cd396a11d10ad727e35ac6fc8f010134a06f9fb0c4b27b4b95ef62fb9d4556abfe2123252e3d933a07a36348065f1
|
7
|
+
data.tar.gz: df7abe336abf35acaea9cc3e295cd547a5c376f448ffe80e9862d909d78b15d3ad300930c376c50c0a0ee2d5f3415b9a18b595ec75e9ff2ee94a7752aaf86ada
|
data/.github/CODEOWNERS
ADDED
data/.github/FUNDING.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -11,11 +11,16 @@ AllCops:
|
|
11
11
|
- vendor/**/*
|
12
12
|
|
13
13
|
Metrics/BlockLength:
|
14
|
-
|
15
|
-
- test/**/*
|
16
|
-
- "**/*.gemspec"
|
14
|
+
Enabled: false
|
17
15
|
|
18
16
|
Metrics/ClassLength:
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/MethodLength:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/AbcSize:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/OptionalBooleanParameter:
|
26
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,36 @@ Prefix your message with one of the following:
|
|
11
11
|
- [Security] in case of vulnerabilities.
|
12
12
|
-->
|
13
13
|
|
14
|
+
## Unreleased
|
15
|
+
|
16
|
+
- [Fixed] Babel loader's order is backwards, so TypeScript first, then
|
17
|
+
JavaScript.
|
18
|
+
|
19
|
+
## v0.0.5 - 2020-11-14
|
20
|
+
|
21
|
+
- [Fixed] Jest configuration wasn't considering the full import path.
|
22
|
+
|
23
|
+
## v0.0.4 - 2020-11-14
|
24
|
+
|
25
|
+
- [Added] Generate
|
26
|
+
[dependabot](https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates)
|
27
|
+
configuration.
|
28
|
+
- [Changed] Add Postgres env vars so tests can run smoothly.
|
29
|
+
- [Added] Add helper method to create migration classes with `--active-record`.
|
30
|
+
- [Added] Generate `.github/CODEOWNERS` template.
|
31
|
+
- [Changed] Generate Ruby packages with `--type gem`
|
32
|
+
- [Added] Generate NPM packages with `--type npm`.
|
33
|
+
|
34
|
+
## v0.0.3 - 2020-11-03
|
35
|
+
|
36
|
+
- [Changed] Remove unused `--repository` switch.
|
37
|
+
- [Changed] Make `--help` and `-h` work with `dopstick new`.
|
38
|
+
|
39
|
+
## v0.0.2 - 2020-11-02
|
40
|
+
|
41
|
+
- [Fixed] Link added to gemspec's meta info now open the correct code browser.
|
42
|
+
- [Fixed] Use correct key name for custom funding urls.
|
43
|
+
|
14
44
|
## v0.0.1 - 2020-11-02
|
15
45
|
|
16
46
|
- Initial release.
|
data/CONTRIBUTING.md
CHANGED
@@ -38,7 +38,7 @@ your contribution is according to how this project works.
|
|
38
38
|
"Unreleased" section. If this section is not available, create one right
|
39
39
|
before the last version.
|
40
40
|
5. Push to your branch - `git push origin my_branch`
|
41
|
-
6. [Create a pull request](https://
|
41
|
+
6. [Create a pull request](https://help.github.com/articles/creating-a-pull-request)
|
42
42
|
7. That's it!
|
43
43
|
|
44
44
|
## Styleguides
|
data/README.md
CHANGED
@@ -1,18 +1,31 @@
|
|
1
|
-
|
1
|
+
<p align="center">
|
2
|
+
<a href="https://github.com/fnando/dopstick/">
|
3
|
+
<img width="250" src="https://github.com/fnando/dopstick/raw/main/dopstick.svg" alt="Dopstick">
|
4
|
+
</a>
|
5
|
+
</p>
|
2
6
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
[![Gem](https://img.shields.io/gem/dt/dopstick.svg)](https://rubygems.org/gems/dopstick)
|
7
|
+
<p align="center">
|
8
|
+
Generate a project skeleton for creating a Ruby/Node package.
|
9
|
+
</p>
|
7
10
|
|
8
|
-
|
11
|
+
<p align="center">
|
12
|
+
<a href="https://github.com/fnando/dopstick"><img src="https://github.com/fnando/dopstick/workflows/Tests/badge.svg" alt="Tests"></a>
|
13
|
+
<a href="https://codeclimate.com/github/fnando/dopstick"><img src="https://codeclimate.com/github/fnando/dopstick/badges/gpa.svg" alt="Code Climate"></a>
|
14
|
+
<a href="https://rubygems.org/gems/dopstick"><img src="https://img.shields.io/gem/v/dopstick.svg" alt="Gem"></a>
|
15
|
+
<a href="https://rubygems.org/gems/dopstick"><img src="https://img.shields.io/gem/dt/dopstick.svg" alt="Gem"></a>
|
16
|
+
</p>
|
9
17
|
|
10
|
-
|
18
|
+
---
|
19
|
+
|
20
|
+
Features:
|
11
21
|
|
12
22
|
- Github templates
|
13
23
|
- Changelog
|
14
|
-
-
|
15
|
-
|
24
|
+
- Generate Ruby packages
|
25
|
+
+ ActiveRecord setup (via `--active-record`)
|
26
|
+
+ CLI setup (via `--bin NAME`)
|
27
|
+
- Generate NPM packages
|
28
|
+
+ Setup TypeScript, Jest, and more!
|
16
29
|
|
17
30
|
## Installation
|
18
31
|
|
data/dopstick.gemspec
CHANGED
@@ -8,13 +8,14 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Nando Vieira"]
|
9
9
|
spec.email = ["me@fnando.com"]
|
10
10
|
|
11
|
-
spec.summary = "Generate a project skeleton for creating a
|
11
|
+
spec.summary = "Generate a project skeleton for creating a Ruby/NPM " \
|
12
|
+
"package."
|
12
13
|
spec.description = spec.summary
|
13
14
|
spec.license = "MIT"
|
14
15
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
15
16
|
|
16
17
|
github_url = "https://github.com/fnando/dopstick"
|
17
|
-
github_tree_url = "#{github_url}/
|
18
|
+
github_tree_url = "#{github_url}/tree/v#{spec.version}"
|
18
19
|
|
19
20
|
spec.homepage = github_url
|
20
21
|
spec.metadata["homepage_uri"] = spec.homepage
|
data/dopstick.svg
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="2283" height="512" viewBox="0 0 2283 512"><g fill="none"><path fill="#E8546A" d="M220.504 9.988L10.5 129.992v252.004L220.504 502l210.004-120.004V129.992z"/><path fill="#C42B4C" d="M350.508 333.996v2.711l-130.004 71.988-130-71.988V175.281l130-71.988 130.004 71.988z"/><path fill="#000" d="M130.504 291.996c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10z"/><path fill="#000" d="M435.504 121.332l-.035-.023-210.004-120a10.061 10.061 0 0 0-9.922 0l-210.004 120-.035.023C2.5 123.062.5 126.363.5 129.992v252.004c0 6.067 5.023 8.633 5.125 8.73L215.543 510.68l.066.035a10.177 10.177 0 0 0 4.895 1.285c1.633 0 3.371-.43 4.894-1.285l.067-.035s209.902-119.946 209.914-119.95c3.254-2.367 5.129-4.171 5.129-8.734V129.992c0-.047-.008-.094-.008-.14-.047-3.665-2.102-6.856-4.996-8.52zm-205-94.11l180.215 102.981-58.063 34.84-122.152-67.645V27.223zm-20 0v70.176L88.352 165.043l-58.063-34.84 180.215-102.98zM20.5 147.653l60.004 36.004v144.676L20.5 364.336V147.652zm190.004 337.114L30.289 381.786l58.066-34.84 122.149 67.644v70.176zm10-87.5l-120-66.454V181.177l120-66.453 120.004 66.453v149.637l-120.004 66.453zm10 87.5V414.59l122.152-67.645 58.063 34.84-180.215 102.98zm190.004-120.43l-60-36.004V183.656l60-36.004v216.684z"/><path fill="#000" d="M175.66 162.422l-50.004 27.691a10.003 10.003 0 0 0-5.152 8.75v63.13c0 5.523 4.476 10 10 10 5.52 0 10-4.477 10-10v-57.24l44.844-24.835c4.832-2.676 6.582-8.762 3.906-13.59-2.676-4.832-8.762-6.578-13.594-3.906z"/><path fill="#434C50" d="M653.311 372c29.222 0 50.896-13.942 58.25-35.242h3.677v33.5H794V92h-78.762v102.628h-3.677c-7.354-21.3-29.028-34.855-58.25-34.855-45.283 0-74.311 34.08-74.311 98.174v15.491c0 63.9 29.028 98.562 74.311 98.562zm34.092-59C671.66 313 660 299.654 660 271.61v-11.412C660 232.346 671.66 219 687.403 219 703.145 219 715 232.152 715 260.198v11.411C715 299.654 703.145 313 687.403 313zm247.388 61C1000.648 374 1039 336.8 1039 269.569v-10.463C1039 198.656 1000.648 157 934.79 157 868.547 157 830 199.238 830 259.688v10.268C830 336.8 868.546 374 934.79 374zm-.195-57c-21.108 0-24.47-25.01-24.592-43.178L910 257.045c0-20.567 3.843-44.045 24.596-44.045 20.56 0 24.404 23.09 24.404 44.045v15.716c0 18.627-3.075 44.239-24.404 44.239zm217.237 122V336.107h3.874c8.135 21.315 28.86 35.267 58.108 35.267 45.518 0 74.185-33.523 74.185-98.63v-15.502c0-65.3-28.667-98.242-74.185-98.242-29.247 0-49.973 13.564-58.108 34.879h-3.874v-33.135H1073V439h78.833zm27.667-126c-15.603 0-27.5-13.346-27.5-41.39v-11.412c0-28.046 11.897-41.198 27.5-41.198 16.188 0 27.5 13.346 27.5 41.198v11.411c0 28.045-11.312 41.391-27.5 41.391zm230.438 61c64.28 0 98.062-28.288 98.062-73.044 0-35.262-20.848-52.7-58.297-59.481-4.36-.79-9.073-1.46-13.856-2.134l-4.317-.611-2.877-.42c-18.66-2.769-36.28-6.555-36.28-18.729 0-6.975 5.79-14.143 18.917-14.143 13.898 0 20.268 8.137 21.812 17.05h67.177c0-45.144-37.835-65.488-88.217-65.488-49.61 0-93.236 19.762-93.236 69.556 0 39.913 28.183 57.156 63.315 64.519 22.778 4.844 50.575 5.425 50.575 20.15 0 7.362-6.756 13.95-19.496 13.95-13.706 0-22.778-7.556-23.55-17.631H1314c0 37.006 30.5 66.456 95.938 66.456zm231.066-4c15.437 0 27.4-1.162 32.996-1.936v-55.182c-1.93.193-8.49.387-14.279.387-15.244 0-24.699-6.196-24.699-20.718v-73.189H1674v-58.086h-38.978V115h-75.061v46.276H1526v58.086h31.645v90.615c0 45.114 27.787 60.023 83.359 60.023zm114.593-227c22.144 0 40.403-13.349 40.403-35.597C1796 85.35 1777.741 72 1755.597 72 1733.26 72 1715 85.349 1715 107.403c0 22.248 18.259 35.597 40.597 35.597zM1794 370V161h-78v209h78zm138.801 4c51.577 0 95.813-24.219 96.199-87.188h-69.348c-.387 14.92-5.023 28.87-23.567 28.87-16.42 0-26.078-15.888-26.078-46.307V257.75c0-25.769 10.431-42.238 25.885-42.238 14.101 0 23.373 13.175 23.76 29.45H2029c-.386-52.506-36.51-87.962-95.813-87.962C1869.441 157 1831 197.881 1831 257.944v12.4C1831 338.93 1872.145 374 1932.801 374zm209.606-4v-65.582l8.112-11.608 42.293 77.19H2283l-71.455-119.364 66.434-89.184h-86.712l-44.997 75.835h-3.863V92H2064v278h78.407z"/></g></svg>
|
data/lib/dopstick.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "json"
|
3
4
|
require "date"
|
4
5
|
require "pathname"
|
5
6
|
require "thor"
|
6
7
|
|
7
8
|
module Dopstick
|
8
|
-
require_relative "dopstick/refinements"
|
9
9
|
require_relative "dopstick/version"
|
10
|
+
require_relative "dopstick/refinements"
|
10
11
|
require_relative "dopstick/generator"
|
12
|
+
require_relative "dopstick/generator/options"
|
13
|
+
require_relative "dopstick/generator/gem/options"
|
14
|
+
require_relative "dopstick/generator/gem/generator"
|
15
|
+
require_relative "dopstick/generator/npm/options"
|
16
|
+
require_relative "dopstick/generator/npm/generator"
|
11
17
|
require_relative "dopstick/cli"
|
12
18
|
end
|
data/lib/dopstick/cli.rb
CHANGED
@@ -9,10 +9,14 @@ module Dopstick
|
|
9
9
|
true
|
10
10
|
end
|
11
11
|
|
12
|
-
desc "new PATH", "Create a new
|
12
|
+
desc "new PATH", "Create a new package"
|
13
|
+
option :type,
|
14
|
+
default: "",
|
15
|
+
desc: "Set the package type you want to create. Must be one of " \
|
16
|
+
"#{Generator.registered.keys.inspect}."
|
13
17
|
option :name,
|
14
18
|
default: "",
|
15
|
-
desc: "Set the
|
19
|
+
desc: "Set the package name. Defaults to path's basename."
|
16
20
|
option :active_record,
|
17
21
|
default: false,
|
18
22
|
type: :boolean,
|
@@ -30,12 +34,9 @@ module Dopstick
|
|
30
34
|
default: "",
|
31
35
|
desc: "Set Paypal account for donations. Defaults to " \
|
32
36
|
"`git config user.paypal`."
|
33
|
-
option :repository,
|
34
|
-
default: "",
|
35
|
-
desc: "Set Github repository name. Defaults to gem name."
|
36
37
|
option :description,
|
37
|
-
default: "",
|
38
|
-
desc: "Set
|
38
|
+
default: "TODO: add a description",
|
39
|
+
desc: "Set package description."
|
39
40
|
option :version,
|
40
41
|
default: "0.0.0",
|
41
42
|
desc: "Set package initial version."
|
@@ -51,29 +52,64 @@ module Dopstick
|
|
51
52
|
type: :array,
|
52
53
|
desc: "Set Ruby versions that are officially supported. Multiple " \
|
53
54
|
"versions must separated by space."
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
option :node_versions,
|
56
|
+
default: %w[14.x 12.x],
|
57
|
+
type: :array,
|
58
|
+
desc: "Set Node versions that are officially supported. Multiple " \
|
59
|
+
"versions must separated by space."
|
60
|
+
option :skip_install,
|
61
|
+
default: false,
|
62
|
+
type: :boolean,
|
63
|
+
desc: "Skip `bundle install` (gem) and `yarn install` (npm)"
|
64
|
+
option :help,
|
65
|
+
aliases: "-h",
|
66
|
+
type: :boolean,
|
67
|
+
hide: true
|
68
|
+
def new(path = nil)
|
69
|
+
interrupt_with_help(:new) if options[:help] || path.to_s.strip.empty?
|
57
70
|
|
58
|
-
|
71
|
+
unless Generator.registered.include?(options[:type])
|
72
|
+
interrupt_with_error(
|
73
|
+
"--type must be one of #{Generator.registered.keys.inspect}"
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
package_name, namespace = expand_gem_name_and_namespace(path)
|
78
|
+
|
79
|
+
generator_module = Generator.registered[options[:type]]
|
80
|
+
generator_class = generator_module.const_get(:Generator)
|
81
|
+
options_class = generator_module.const_get(:Options)
|
82
|
+
generator = generator_class.new
|
59
83
|
generator.destination_root = File.expand_path(path)
|
60
|
-
generator.options =
|
61
|
-
|
62
|
-
|
63
|
-
|
84
|
+
generator.options = options_class.new(
|
85
|
+
dup_options.merge(
|
86
|
+
package_name: package_name,
|
87
|
+
namespace: namespace,
|
88
|
+
entry_path: namespace.underscore("/")
|
89
|
+
)
|
64
90
|
)
|
65
91
|
|
66
92
|
generator.invoke_all
|
67
93
|
end
|
68
94
|
|
69
95
|
no_commands do
|
96
|
+
private def interrupt_with_help(command)
|
97
|
+
help(command)
|
98
|
+
exit
|
99
|
+
end
|
100
|
+
|
101
|
+
private def interrupt_with_error(message)
|
102
|
+
shell.say "ERROR: #{message}", :red
|
103
|
+
exit 1
|
104
|
+
end
|
105
|
+
|
70
106
|
private def dup_options
|
71
107
|
options.each_with_object({}) do |(key, value), buffer|
|
72
108
|
buffer[key.to_sym] = value
|
73
109
|
end
|
74
110
|
end
|
75
111
|
|
76
|
-
private def expand_gem_name_and_namespace(path)
|
112
|
+
private def expand_gem_name_and_namespace(path)
|
77
113
|
if options[:name].presence && options[:namespace].presence
|
78
114
|
[options[:name], options[:namespace]]
|
79
115
|
elsif options[:name].presence
|
data/lib/dopstick/generator.rb
CHANGED
@@ -1,214 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Dopstick
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
include Thor::Actions
|
8
|
-
|
9
|
-
def self.exit_on_failure?
|
10
|
-
true
|
11
|
-
end
|
12
|
-
|
13
|
-
attr_accessor :options
|
14
|
-
|
15
|
-
desc "Generate a new gem folder structure"
|
16
|
-
|
17
|
-
def self.source_root
|
18
|
-
File.join(__dir__, "templates")
|
19
|
-
end
|
20
|
-
|
21
|
-
def copy_gemspec
|
22
|
-
template "gemspec.erb", "#{gem_name}.gemspec"
|
23
|
-
end
|
24
|
-
|
25
|
-
def copy_license
|
26
|
-
template "license.erb", "LICENSE.md"
|
27
|
-
end
|
28
|
-
|
29
|
-
def copy_coc
|
30
|
-
template "coc.erb", "CODE_OF_CONDUCT.md"
|
31
|
-
end
|
32
|
-
|
33
|
-
def copy_readme
|
34
|
-
template "readme.erb", "README.md"
|
35
|
-
end
|
36
|
-
|
37
|
-
def copy_changelog
|
38
|
-
copy_file "CHANGELOG.md"
|
39
|
-
end
|
40
|
-
|
41
|
-
def copy_contributing
|
42
|
-
template "contributing.erb", "CONTRIBUTING.md"
|
43
|
-
end
|
44
|
-
|
45
|
-
def copy_github_templates
|
46
|
-
template "funding.erb", ".github/FUNDING.yml"
|
47
|
-
template "tests_workflow.erb", ".github/workflows/tests.yml"
|
48
|
-
template "bug_report.erb", ".github/ISSUE_TEMPLATE/bug_report.md"
|
49
|
-
template "feature_request.erb",
|
50
|
-
".github/ISSUE_TEMPLATE/feature_request.md"
|
51
|
-
template "pull_request.erb", ".github/PULL_REQUEST_TEMPLATE.md"
|
52
|
-
end
|
53
|
-
|
54
|
-
def copy_rakefile
|
55
|
-
template "rakefile.erb", "Rakefile"
|
56
|
-
end
|
57
|
-
|
58
|
-
def copy_rubocop
|
59
|
-
template "rubocop.erb", ".rubocop.yml"
|
60
|
-
end
|
61
|
-
|
62
|
-
def copy_gitignore
|
63
|
-
template "gitignore.erb", ".gitignore"
|
64
|
-
end
|
65
|
-
|
66
|
-
def copy_gemfile
|
67
|
-
template "gemfile.erb", "Gemfile"
|
68
|
-
end
|
69
|
-
|
70
|
-
def copy_bins
|
71
|
-
template "console.erb", "bin/console"
|
72
|
-
template "setup.erb", "bin/setup"
|
73
|
-
in_root { run "chmod +x bin/*" }
|
74
|
-
end
|
75
|
-
|
76
|
-
def create_entry_file
|
77
|
-
if entry_path.include?("/")
|
78
|
-
template "gem_entry_file.erb", "lib/#{gem_name}.rb"
|
79
|
-
end
|
80
|
-
|
81
|
-
template "entry_file.erb", "lib/#{entry_path}.rb"
|
82
|
-
end
|
83
|
-
|
84
|
-
def create_version_file
|
85
|
-
template "version.erb", "lib/#{entry_path}/version.rb"
|
86
|
-
end
|
87
|
-
|
88
|
-
def copy_test_files
|
89
|
-
template "test_helper.erb", "test/test_helper.rb"
|
90
|
-
template "test_file.erb", "test/#{entry_path}_test.rb"
|
91
|
-
end
|
92
|
-
|
93
|
-
def copy_binary_files
|
94
|
-
return unless options[:bin].presence
|
95
|
-
|
96
|
-
template "cli.erb", "lib/#{entry_path}/cli.rb"
|
97
|
-
template "generator.erb", "lib/#{entry_path}/generator.rb"
|
98
|
-
template "bin.erb", "exe/#{options[:bin]}"
|
99
|
-
create_file "lib/#{entry_path}/templates/.keep"
|
100
|
-
in_root { run "chmod +x exe/*" }
|
101
|
-
end
|
102
|
-
|
103
|
-
def copy_active_record_files
|
104
|
-
return unless options[:active_record]
|
105
|
-
|
106
|
-
template "active_record.erb", "test/support/active_record.rb"
|
107
|
-
end
|
108
|
-
|
109
|
-
def initialize_repo
|
110
|
-
in_root do
|
111
|
-
run "git init --initial-branch=main", capture: true
|
112
|
-
run "git add .", capture: true
|
113
|
-
run "git add bin --force", capture: true
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
no_commands do # rubocop:disable Metrics/BlockLength
|
118
|
-
def gem_name
|
119
|
-
options[:gem_name]
|
120
|
-
end
|
121
|
-
|
122
|
-
def entry_path
|
123
|
-
options[:entry_path]
|
124
|
-
end
|
125
|
-
|
126
|
-
def user_name
|
127
|
-
@user_name ||= options[:author_name].presence ||
|
128
|
-
`git config --global user.name`.chomp
|
129
|
-
end
|
130
|
-
|
131
|
-
def user_email
|
132
|
-
@user_email ||= options[:author_email].presence ||
|
133
|
-
`git config --global user.email`.chomp
|
134
|
-
end
|
135
|
-
|
136
|
-
def github_user
|
137
|
-
@github_user ||= options[:author_github].presence || begin
|
138
|
-
user = `git config --global user.github`.chomp
|
139
|
-
user.empty? ? "[USER]" : user
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def paypal_user
|
144
|
-
@paypal_user ||= options[:author_paypal].presence || begin
|
145
|
-
user = `git config --global user.paypal`.chomp
|
146
|
-
user.empty? ? "[USER]" : user
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
def github_url
|
151
|
-
"https://github.com/#{github_user}/#{gem_name}"
|
152
|
-
end
|
153
|
-
|
154
|
-
def ruby_versions
|
155
|
-
options[:ruby_versions]
|
156
|
-
end
|
157
|
-
|
158
|
-
def const_names
|
159
|
-
@const_names ||= options[:namespace].split("::")
|
160
|
-
end
|
161
|
-
|
162
|
-
def const_names_size
|
163
|
-
@const_names_size ||= const_names.size
|
164
|
-
end
|
165
|
-
|
166
|
-
def render_tree(skip_content_spaces = false, &block) # rubocop:disable Style/OptionalBooleanParameter
|
167
|
-
content = []
|
168
|
-
|
169
|
-
const_names.each_with_index do |name, count|
|
170
|
-
content << (" " * count) + "module #{name}"
|
171
|
-
end
|
172
|
-
|
173
|
-
spacer = skip_content_spaces ? "" : " "
|
174
|
-
|
175
|
-
content << (spacer * const_names_size) + block.call
|
176
|
-
|
177
|
-
(const_names_size - 1).downto(0) do |count|
|
178
|
-
content << "#{' ' * count}end"
|
179
|
-
end
|
180
|
-
|
181
|
-
content.join("\n")
|
182
|
-
end
|
183
|
-
|
184
|
-
def erb(file)
|
185
|
-
ERB.new(File.read("#{__dir__}/templates/#{file}")).result binding
|
186
|
-
end
|
187
|
-
|
188
|
-
def render_cli
|
189
|
-
cli_class = erb("cli_class.erb")
|
190
|
-
.chomp
|
191
|
-
.gsub(/^(.)/m, "#{' ' * const_names_size}\\1")
|
192
|
-
|
193
|
-
render_tree(true) { cli_class }
|
194
|
-
end
|
195
|
-
|
196
|
-
def render_generator
|
197
|
-
generator_class = erb("generator_class.erb")
|
198
|
-
.chomp
|
199
|
-
.gsub(/^(.)/m, "#{' ' * const_names_size}\\1")
|
200
|
-
|
201
|
-
render_tree(true) { generator_class }
|
202
|
-
end
|
203
|
-
|
204
|
-
def oldest_ruby_version
|
205
|
-
version = options[:ruby_versions]
|
206
|
-
.map {|v| Gem::Version.new(v) }
|
207
|
-
.min
|
208
|
-
.canonical_segments
|
209
|
-
|
210
|
-
[*version, 0].take(3).join(".")
|
211
|
-
end
|
4
|
+
module Generator
|
5
|
+
def self.registered
|
6
|
+
@registered ||= {}
|
212
7
|
end
|
213
8
|
end
|
214
9
|
end
|