padrino-gen 0.18.5 → 0.18.7
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/lib/padrino-gen/generators/actions.rb +33 -0
- data/lib/padrino-gen/generators/components/stylesheets/tailwind.rb +1 -1
- data/lib/padrino-gen/generators/project.rb +1 -0
- data/lib/padrino-gen/generators/templates/Gemfile.tt +2 -0
- data/test/test_component_generator.rb +15 -0
- data/test/test_project_generator.rb +35 -0
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 23fb0a89138d0cf284ce9b340c53194e367febccea6abdfd299a8f662624769d
|
|
4
|
+
data.tar.gz: cb29c03995946930667120c71a956adf8f8925810758fbb1244e295239092731
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e0db41a700e8b5c2f49d54b4353319a5448b3da709eb2b2a8b8efbd0b955ab667a44c367d9c6529ef8775aa923863ac61f7f77834b2eeeab51a5b067d301a30
|
|
7
|
+
data.tar.gz: d82701691e6947a5d2b4ca97d06dab09ea94a168adc71be84af70bc67c86f9e8255101247083a35ab895e351058601387b9ee74fa8c085985caf51b50314fd41
|
|
@@ -16,6 +16,16 @@ module Padrino
|
|
|
16
16
|
SQL_ADAPTERS = %w[mysql mysql2 mysql-gem postgres sqlite].freeze
|
|
17
17
|
SQL_ADAPTER_ORMS = %w[activerecord sequel].freeze
|
|
18
18
|
|
|
19
|
+
##
|
|
20
|
+
# Choices whose generated gem requirement needs a newer Ruby than Padrino's own floor, by type, with
|
|
21
|
+
# the gem and the Ruby it needs. The requirements are in templates/Gemfile.tt (falcon) and
|
|
22
|
+
# components/stylesheets/tailwind.rb (tailwindcss-ruby).
|
|
23
|
+
#
|
|
24
|
+
MINIMUM_RUBY = {
|
|
25
|
+
server: { 'falcon' => %w[falcon 3.0] },
|
|
26
|
+
stylesheet: { 'tailwind' => %w[tailwindcss-ruby 3.0] }
|
|
27
|
+
}.freeze
|
|
28
|
+
|
|
19
29
|
##
|
|
20
30
|
# Common actions needed to support project and component generation.
|
|
21
31
|
#
|
|
@@ -47,10 +57,33 @@ module Padrino
|
|
|
47
57
|
def execute_component_setup(component, choice)
|
|
48
58
|
return say_status(:skipping, "#{component} component...") if choice.to_s == 'none'
|
|
49
59
|
say_status(:applying, "#{choice} (#{component})...")
|
|
60
|
+
warn_unless_ruby_supports(component, choice)
|
|
50
61
|
apply_component_for(choice, component)
|
|
51
62
|
send("setup_#{component}") if respond_to?("setup_#{component}")
|
|
52
63
|
end
|
|
53
64
|
|
|
65
|
+
##
|
|
66
|
+
# Warns when the choice's gem needs a newer Ruby than the one running the generator, as
|
|
67
|
+
# bundle install will then fail. The project is still generated.
|
|
68
|
+
#
|
|
69
|
+
# @example
|
|
70
|
+
# warn_unless_ruby_supports(:server, 'falcon')
|
|
71
|
+
#
|
|
72
|
+
def warn_unless_ruby_supports(type, choice)
|
|
73
|
+
gem, minimum = MINIMUM_RUBY.dig(type.to_sym, choice.to_s)
|
|
74
|
+
return unless gem && Gem::Version.new(running_ruby_version) < Gem::Version.new(minimum)
|
|
75
|
+
|
|
76
|
+
say "The #{choice} #{type} uses the #{gem} gem, which needs Ruby #{minimum} or later; " \
|
|
77
|
+
"bundle install will fail on Ruby #{running_ruby_version}.", :yellow
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# The version of the Ruby running the generator.
|
|
82
|
+
#
|
|
83
|
+
def running_ruby_version
|
|
84
|
+
RUBY_VERSION
|
|
85
|
+
end
|
|
86
|
+
|
|
54
87
|
##
|
|
55
88
|
# Returns the related module for a given component and option.
|
|
56
89
|
#
|
|
@@ -31,7 +31,7 @@ def setup_stylesheet
|
|
|
31
31
|
append_file path, content.empty? || content.end_with?("\n") ? text : "\n#{text}"
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
require_dependencies 'tailwindcss-ruby', version: '~> 4.0'
|
|
34
|
+
require_dependencies 'tailwindcss-ruby', version: '~> 4.0' # The Ruby it needs is in MINIMUM_RUBY (actions.rb).
|
|
35
35
|
previous = fetch_component_choice(:stylesheet).to_s
|
|
36
36
|
preprocessed = %w[sass scss less].include?(previous)
|
|
37
37
|
# Tailwind writes its build to public/stylesheets/application.css, so carry
|
|
@@ -72,6 +72,7 @@ module Padrino
|
|
|
72
72
|
append_file destination_root('config/apps.rb'), "Padrino.mount('#{@project_name}::#{@app_name}', app_file: Padrino.root('app/app.rb')).to('/')\n"
|
|
73
73
|
end
|
|
74
74
|
template 'templates/Gemfile.tt', destination_root('Gemfile')
|
|
75
|
+
warn_unless_ruby_supports(:server, options[:server])
|
|
75
76
|
template 'templates/Rakefile.tt', destination_root('Rakefile')
|
|
76
77
|
template 'templates/project_bin.tt', destination_root("exe/#{name}")
|
|
77
78
|
File.chmod(0o755, destination_root("exe/#{name}"))
|
|
@@ -10,6 +10,7 @@ source 'https://rubygems.org'
|
|
|
10
10
|
<% if options.server == 'trinidad' -%>
|
|
11
11
|
gem 'trinidad', platform: 'jruby'
|
|
12
12
|
<% elsif options.server == 'falcon' -%>
|
|
13
|
+
<%# The Ruby this falcon requirement needs is in MINIMUM_RUBY (actions.rb). -%>
|
|
13
14
|
gem 'falcon', '>= 0.43'
|
|
14
15
|
<% else -%>
|
|
15
16
|
gem '<%= options.server %>'
|
|
@@ -28,6 +29,7 @@ gem 'rake'
|
|
|
28
29
|
<% if options.api? -%>
|
|
29
30
|
<% if options.dev? -%>
|
|
30
31
|
gem 'padrino-core', path: '<%= Padrino::Generators::DEV_PATH %>/padrino-core'
|
|
32
|
+
gem 'padrino-support', path: '<%= Padrino::Generators::DEV_PATH %>/padrino-support'
|
|
31
33
|
gem 'padrino-gen', path: '<%= Padrino::Generators::DEV_PATH %>/padrino-gen'
|
|
32
34
|
<% else -%>
|
|
33
35
|
gem 'padrino-core', '<%= Padrino.version %>'
|
|
@@ -34,6 +34,21 @@ describe 'ComponentGenerator' do
|
|
|
34
34
|
assert_equal 'activerecord', components_chosen[:orm]
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
it 'should warn when adding tailwind on Ruby 2.7' do
|
|
38
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
|
39
|
+
Padrino::Generators::Component.any_instance.stubs(:running_ruby_version).returns('2.7.8')
|
|
40
|
+
out, = capture_io { generate(:component, '--stylesheet=tailwind', "-r=#{@apptmp}/sample_project") }
|
|
41
|
+
assert_includes out, 'The tailwind stylesheet uses the tailwindcss-ruby gem, which needs Ruby 3.0 or later; bundle install will fail on Ruby 2.7.8.'
|
|
42
|
+
assert_match_in_file(/gem 'tailwindcss-ruby', '~> 4.0'$/, "#{@apptmp}/sample_project/Gemfile")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should not warn when adding tailwind on Ruby 3.0' do
|
|
46
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
|
47
|
+
Padrino::Generators::Component.any_instance.stubs(:running_ruby_version).returns('3.0.0')
|
|
48
|
+
out, = capture_io { generate(:component, '--stylesheet=tailwind', "-r=#{@apptmp}/sample_project") }
|
|
49
|
+
refute_match(/needs Ruby/, out)
|
|
50
|
+
end
|
|
51
|
+
|
|
37
52
|
it 'should move existing public styles into the tailwind source' do
|
|
38
53
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
|
39
54
|
File.write("#{@apptmp}/sample_project/public/stylesheets/application.css", "body { color: red; }\n")
|
|
@@ -170,6 +170,13 @@ describe 'ProjectGenerator' do
|
|
|
170
170
|
assert_match_in_file(/^\s*set :protect_from_csrf, proc \{ sessions\? && Padrino\.env != :test \}$/, "#{@apptmp}/sample_project/config/apps.rb")
|
|
171
171
|
end
|
|
172
172
|
|
|
173
|
+
it 'should take padrino-support from the checkout in a --dev api project' do
|
|
174
|
+
capture_io { generate(:project, 'sample_project', '--api', '--dev', "--root=#{@apptmp}") }
|
|
175
|
+
%w[core support gen].each do |name|
|
|
176
|
+
assert_match_in_file(%r{^gem 'padrino-#{name}', path: '[^']+/padrino-#{name}'$}, "#{@apptmp}/sample_project/Gemfile")
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
173
180
|
it 'should generate a tiny api project without mailers' do
|
|
174
181
|
capture_io { generate(:project, 'sample_project', '--api', '--tiny', "--root=#{@apptmp}") }
|
|
175
182
|
assert_no_file_exists("#{@apptmp}/sample_project/app/mailers.rb")
|
|
@@ -888,6 +895,34 @@ describe 'ProjectGenerator' do
|
|
|
888
895
|
end
|
|
889
896
|
end
|
|
890
897
|
|
|
898
|
+
describe 'choices that need a newer Ruby' do
|
|
899
|
+
{
|
|
900
|
+
'--server=falcon' => 'The falcon server uses the falcon gem, which needs Ruby 3.0 or later; bundle install will fail on Ruby 2.7.8.',
|
|
901
|
+
'--stylesheet=tailwind' => 'The tailwind stylesheet uses the tailwindcss-ruby gem, which needs Ruby 3.0 or later; bundle install will fail on Ruby 2.7.8.'
|
|
902
|
+
}.each do |option, warning|
|
|
903
|
+
it "should warn on Ruby 2.7 for #{option} and still generate the project" do
|
|
904
|
+
Padrino::Generators::Project.any_instance.stubs(:running_ruby_version).returns('2.7.8')
|
|
905
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", option) }
|
|
906
|
+
assert_includes out, warning
|
|
907
|
+
assert_match(/is ready for development!/, out)
|
|
908
|
+
end
|
|
909
|
+
|
|
910
|
+
it "should not warn on Ruby 3.0 for #{option}" do
|
|
911
|
+
Padrino::Generators::Project.any_instance.stubs(:running_ruby_version).returns('3.0.0')
|
|
912
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", option) }
|
|
913
|
+
refute_match(/needs Ruby/, out)
|
|
914
|
+
end
|
|
915
|
+
end
|
|
916
|
+
|
|
917
|
+
it 'should not warn on Ruby 2.7 for choices that support it' do
|
|
918
|
+
Padrino::Generators::Project.any_instance.stubs(:running_ruby_version).returns('2.7.8')
|
|
919
|
+
out, = capture_io do
|
|
920
|
+
generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=puma', '--stylesheet=sass', '--orm=sequel', '--renderer=haml', '--script=vite', '--test=rspec', '--mock=mocha')
|
|
921
|
+
end
|
|
922
|
+
refute_match(/needs Ruby/, out)
|
|
923
|
+
end
|
|
924
|
+
end
|
|
925
|
+
|
|
891
926
|
describe 'tiny app skeleton generator for test component' do
|
|
892
927
|
{ 'minitest' => /skip "add some examples/, 'testunit' => /pend "add some examples/, 'shoulda' => /pend "add some examples/ }.each do |test, pending|
|
|
893
928
|
it "should mark the tiny skeleton's #{test} placeholders pending, so a new project passes its own tests" do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: padrino-gen
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.18.
|
|
4
|
+
version: 0.18.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Padrino Team
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2026-11-
|
|
14
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: padrino-core
|
|
@@ -19,14 +19,14 @@ dependencies:
|
|
|
19
19
|
requirements:
|
|
20
20
|
- - '='
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 0.18.
|
|
22
|
+
version: 0.18.7
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - '='
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 0.18.
|
|
29
|
+
version: 0.18.7
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
31
|
name: bundler
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,28 +53,28 @@ dependencies:
|
|
|
53
53
|
requirements:
|
|
54
54
|
- - '='
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: 0.18.
|
|
56
|
+
version: 0.18.7
|
|
57
57
|
type: :development
|
|
58
58
|
prerelease: false
|
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
|
60
60
|
requirements:
|
|
61
61
|
- - '='
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
|
-
version: 0.18.
|
|
63
|
+
version: 0.18.7
|
|
64
64
|
- !ruby/object:Gem::Dependency
|
|
65
65
|
name: padrino-mailer
|
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
|
67
67
|
requirements:
|
|
68
68
|
- - '='
|
|
69
69
|
- !ruby/object:Gem::Version
|
|
70
|
-
version: 0.18.
|
|
70
|
+
version: 0.18.7
|
|
71
71
|
type: :development
|
|
72
72
|
prerelease: false
|
|
73
73
|
version_requirements: !ruby/object:Gem::Requirement
|
|
74
74
|
requirements:
|
|
75
75
|
- - '='
|
|
76
76
|
- !ruby/object:Gem::Version
|
|
77
|
-
version: 0.18.
|
|
77
|
+
version: 0.18.7
|
|
78
78
|
description: Generators for easily creating and building padrino applications from
|
|
79
79
|
the console
|
|
80
80
|
email: padrinorb@gmail.com
|