dopstick 0.0.3 → 0.0.4
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/.rubocop.yml +11 -6
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +6 -3
- data/dopstick.gemspec +2 -1
- data/lib/dopstick.rb +7 -1
- data/lib/dopstick/cli.rb +40 -11
- 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 +56 -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: fe33ac2b2b1d210b9c5f54cf0f6039ebd8548dfc7893fdebf54e9118a6d44618
|
4
|
+
data.tar.gz: da37488ed41ebe8f16473376c0aad18c98da952bed00ace9b66220b6d13e46a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66650b1b3fb60790d1c750749d250bea61c7da3b6e88e116e87b5d93142d1922492edb887e95cd9fd013dec702a89deafc2c7d52d547e9b72ca347b419552898
|
7
|
+
data.tar.gz: 382c93b122eebd71c54e3b255159a72b89eed321cbd63e992547bd8565dd5710e7d2a6e6e23fdefceb712ca5bb80ccaafb53e27889645d82dddd1131037bcc07
|
data/.github/CODEOWNERS
ADDED
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,17 @@ Prefix your message with one of the following:
|
|
11
11
|
- [Security] in case of vulnerabilities.
|
12
12
|
-->
|
13
13
|
|
14
|
+
## Unreleased
|
15
|
+
|
16
|
+
- [Added] Generate
|
17
|
+
[dependabot](https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates)
|
18
|
+
configuration.
|
19
|
+
- [Changed] Add Postgres env vars so tests can run smoothly.
|
20
|
+
- [Added] Add helper method to create migration classes with `--active-record`.
|
21
|
+
- [Added] Generate `.github/CODEOWNERS` template.
|
22
|
+
- [Changed] Generate Ruby packages with `--type gem`
|
23
|
+
- [Added] Generate NPM packages with `--type npm`.
|
24
|
+
|
14
25
|
## v0.0.3 - 2020-11-03
|
15
26
|
|
16
27
|
- [Changed] Remove unused `--repository` switch.
|
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
@@ -5,7 +5,7 @@
|
|
5
5
|
</p>
|
6
6
|
|
7
7
|
<p align="center">
|
8
|
-
Generate a project skeleton for creating a
|
8
|
+
Generate a project skeleton for creating a Ruby/Node package.
|
9
9
|
</p>
|
10
10
|
|
11
11
|
<p align="center">
|
@@ -21,8 +21,11 @@ Features:
|
|
21
21
|
|
22
22
|
- Github templates
|
23
23
|
- Changelog
|
24
|
-
-
|
25
|
-
|
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!
|
26
29
|
|
27
30
|
## Installation
|
28
31
|
|
data/dopstick.gemspec
CHANGED
@@ -8,7 +8,8 @@ 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/Node" \
|
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")
|
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,
|
@@ -31,8 +35,8 @@ module Dopstick
|
|
31
35
|
desc: "Set Paypal account for donations. Defaults to " \
|
32
36
|
"`git config user.paypal`."
|
33
37
|
option :description,
|
34
|
-
default: "",
|
35
|
-
desc: "Set
|
38
|
+
default: "TODO: add a description",
|
39
|
+
desc: "Set package description."
|
36
40
|
option :version,
|
37
41
|
default: "0.0.0",
|
38
42
|
desc: "Set package initial version."
|
@@ -48,6 +52,15 @@ module Dopstick
|
|
48
52
|
type: :array,
|
49
53
|
desc: "Set Ruby versions that are officially supported. Multiple " \
|
50
54
|
"versions must separated by space."
|
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)"
|
51
64
|
option :help,
|
52
65
|
aliases: "-h",
|
53
66
|
type: :boolean,
|
@@ -55,14 +68,25 @@ module Dopstick
|
|
55
68
|
def new(path = nil)
|
56
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)
|
59
78
|
|
60
|
-
|
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
|
61
83
|
generator.destination_root = File.expand_path(path)
|
62
|
-
generator.options =
|
63
|
-
|
64
|
-
|
65
|
-
|
84
|
+
generator.options = options_class.new(
|
85
|
+
dup_options.merge(
|
86
|
+
package_name: package_name,
|
87
|
+
namespace: namespace,
|
88
|
+
entry_path: namespace.underscore("/")
|
89
|
+
)
|
66
90
|
)
|
67
91
|
|
68
92
|
generator.invoke_all
|
@@ -74,13 +98,18 @@ module Dopstick
|
|
74
98
|
exit
|
75
99
|
end
|
76
100
|
|
101
|
+
private def interrupt_with_error(message)
|
102
|
+
shell.say "ERROR: #{message}", :red
|
103
|
+
exit 1
|
104
|
+
end
|
105
|
+
|
77
106
|
private def dup_options
|
78
107
|
options.each_with_object({}) do |(key, value), buffer|
|
79
108
|
buffer[key.to_sym] = value
|
80
109
|
end
|
81
110
|
end
|
82
111
|
|
83
|
-
private def expand_gem_name_and_namespace(path)
|
112
|
+
private def expand_gem_name_and_namespace(path)
|
84
113
|
if options[:name].presence && options[:namespace].presence
|
85
114
|
[options[:name], options[:namespace]]
|
86
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
|
@@ -9,7 +9,7 @@ labels: 'Status: Unconfirmed'
|
|
9
9
|
<!--
|
10
10
|
- Please provide a clear and concise description of what the bug is.
|
11
11
|
- If possible, add an example reproducing your issue.
|
12
|
-
- Please test using the latest version of <%=
|
12
|
+
- Please test using the latest version of <%= options.package_name %>
|
13
13
|
to make sure your issue has not already been fixed.
|
14
14
|
-->
|
15
15
|
|
File without changes
|