hanamismith 2.3.0 → 3.1.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
- checksums.yaml.gz.sig +0 -0
- data/hanamismith.gemspec +2 -2
- data/lib/hanamismith/builders/bundler.rb +20 -18
- data/lib/hanamismith/builders/caliber.rb +20 -9
- data/lib/hanamismith/builders/core.rb +8 -0
- data/lib/hanamismith/builders/providers/logger.rb +2 -6
- data/lib/hanamismith/builders/rack/attack.rb +4 -1
- data/lib/hanamismith/builders/rack/deflater.rb +4 -2
- data/lib/hanamismith/builders/rake/configuration.rb +11 -2
- data/lib/hanamismith/builders/reek.rb +15 -6
- data/lib/hanamismith/templates/%project_name%/app/contract.rb.erb +17 -0
- data/lib/hanamismith/templates/%project_name%/app/mailer.rb.erb +9 -0
- data/lib/hanamismith/templates/%project_name%/app/providers/logger.rb.erb +18 -1
- data/lib/hanamismith/templates/%project_name%/config/app.rb.erb +0 -16
- data/lib/hanamismith/templates/%project_name%/config/initializers/rack_attack.rb.erb +4 -3
- data/lib/hanamismith/templates/%project_name%/config/initializers/universal_logger_patch.rb.erb +24 -0
- data/lib/hanamismith/templates/%project_name%/config/puma.rb.erb +3 -4
- data/lib/hanamismith/templates/%project_name%/package.json.erb +6 -2
- data/lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb +14 -9
- data.tar.gz.sig +4 -6
- metadata +7 -8
- metadata.gz.sig +0 -0
- data/lib/hanamismith/templates/%project_name%/app/aspects/logging/rack_adapter.rb.erb +0 -21
- data/lib/hanamismith/templates/%project_name%/config/initializers/rack_logger_patch.rb.erb +0 -21
- data/lib/hanamismith/templates/%project_name%/config/initializers/sql_logger_patch.rb.erb +0 -13
- data/lib/hanamismith/templates/%project_name%/spec/app/aspects/logging/rack_adapter_spec.rb.erb +0 -34
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4e6465af13be82767b09daf96a78a165ec3d75ea5a06c5996bb231898054e70
|
|
4
|
+
data.tar.gz: c5ae3527f7210a600d383d6ad0af738e96bfbf65a36aadd3ad31cc9a17b8eed3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3117fdf9052c7ed06089b83d559118c9ee404b07fd2b99132e5fc3d734ab530f18d37826e379dc32b9693ca83e38583f9e8f4b5e18e1e6a9ad1a829ec09b5eb0
|
|
7
|
+
data.tar.gz: 0a0e943ef27c675f0a8782816614f7d97a8d021490324ac71f88a29c3f58c5e22b40968459c8fd52ca465b21f25e377b112efcabd63fd2a31441f538112e5b91
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/hanamismith.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = "hanamismith"
|
|
5
|
-
spec.version = "
|
|
5
|
+
spec.version = "3.1.0"
|
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
|
8
8
|
spec.homepage = "https://alchemists.io/projects/hanamismith"
|
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
|
32
32
|
spec.add_dependency "htmx", "~> 3.0"
|
|
33
33
|
spec.add_dependency "infusible", "~> 5.0"
|
|
34
34
|
spec.add_dependency "refinements", "~> 14.0"
|
|
35
|
-
spec.add_dependency "rubysmith", "~>
|
|
35
|
+
spec.add_dependency "rubysmith", "~> 10.0"
|
|
36
36
|
spec.add_dependency "runcom", "~> 13.0"
|
|
37
37
|
spec.add_dependency "sod", "~> 2.0"
|
|
38
38
|
spec.add_dependency "spek", "~> 5.0"
|
|
@@ -35,35 +35,37 @@ module Hanamismith
|
|
|
35
35
|
|
|
36
36
|
def insert_hanami
|
|
37
37
|
with_template.insert_after "source", <<~CONTENT.strip
|
|
38
|
-
gem "hanami", "~>
|
|
39
|
-
gem "hanami-
|
|
40
|
-
gem "hanami-
|
|
41
|
-
gem "hanami-db", "~>
|
|
42
|
-
gem "hanami-
|
|
43
|
-
gem "hanami-
|
|
44
|
-
gem "hanami-view", "~>
|
|
38
|
+
gem "hanami", "~> 3.0"
|
|
39
|
+
gem "hanami-action", "~> 3.0"
|
|
40
|
+
gem "hanami-assets", "~> 3.0"
|
|
41
|
+
gem "hanami-db", "~> 3.0"
|
|
42
|
+
gem "hanami-mailer", "~> 3.0"
|
|
43
|
+
gem "hanami-router", "~> 3.0"
|
|
44
|
+
gem "hanami-view", "~> 3.0"
|
|
45
45
|
CONTENT
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def insert_main
|
|
49
49
|
with_template.insert_after "source", <<~CONTENT
|
|
50
|
-
gem "
|
|
50
|
+
gem "cogger", "~> 2.4"
|
|
51
|
+
gem "core", "~> 3.2"
|
|
52
|
+
gem "dry-schema", "~> 1.16"
|
|
51
53
|
gem "dry-types", "~> 1.9"
|
|
52
54
|
gem "dry-validation", "~> 1.11"
|
|
53
|
-
gem "htmx", "~> 3.
|
|
54
|
-
gem "
|
|
55
|
-
gem "puma", "~>
|
|
56
|
-
gem "rack-attack", "~> 6.
|
|
55
|
+
gem "htmx", "~> 3.2"
|
|
56
|
+
gem "i18n", "~> 1.15"
|
|
57
|
+
gem "puma", "~> 8.0"
|
|
58
|
+
gem "rack-attack", "~> 6.8"
|
|
57
59
|
CONTENT
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
def insert_persistence
|
|
61
63
|
with_template.insert_after "source", <<~CONTENT
|
|
62
64
|
|
|
63
|
-
gem "pg", "~> 1.
|
|
65
|
+
gem "pg", "~> 1.6", force_ruby_platform: true
|
|
64
66
|
gem "rom", "~> 5.4"
|
|
65
67
|
gem "rom-sql", "~> 3.7"
|
|
66
|
-
gem "sequel", "~> 5.
|
|
68
|
+
gem "sequel", "~> 5.106"
|
|
67
69
|
CONTENT
|
|
68
70
|
end
|
|
69
71
|
|
|
@@ -75,7 +77,7 @@ module Hanamismith
|
|
|
75
77
|
with_template.insert_before(/group :development/, <<~CONTENT)
|
|
76
78
|
|
|
77
79
|
group :development, :test do
|
|
78
|
-
gem "dotenv", "~> 3.
|
|
80
|
+
gem "dotenv", "~> 3.2"
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
CONTENT
|
|
@@ -83,8 +85,8 @@ module Hanamismith
|
|
|
83
85
|
|
|
84
86
|
def insert_development
|
|
85
87
|
with_template.insert_after(/group :development do/, <<~CONTENT.gsub("gem", " gem"))
|
|
86
|
-
gem "hanami-webconsole", "~>
|
|
87
|
-
gem "localhost", "~> 1.
|
|
88
|
+
gem "hanami-webconsole", "~> 3.0"
|
|
89
|
+
gem "localhost", "~> 1.8"
|
|
88
90
|
CONTENT
|
|
89
91
|
end
|
|
90
92
|
|
|
@@ -92,7 +94,7 @@ module Hanamismith
|
|
|
92
94
|
with_template.insert_after(/group :test/, <<~CONTENT.gsub("gem", " gem"))
|
|
93
95
|
gem "capybara", "~> 3.40"
|
|
94
96
|
gem "capybara-validate_html5", "~> 2.1"
|
|
95
|
-
gem "cuprite", "~> 0.
|
|
97
|
+
gem "cuprite", "~> 0.17"
|
|
96
98
|
gem "database_cleaner-sequel", "~> 2.0"
|
|
97
99
|
gem "launchy", "~> 3.1"
|
|
98
100
|
gem "rack-test", "~> 2.2"
|
|
@@ -12,17 +12,28 @@ module Hanamismith
|
|
|
12
12
|
return false unless settings.build_caliber
|
|
13
13
|
|
|
14
14
|
super
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.append("\nplugins: rubocop-sequel\n\n")
|
|
18
|
-
.append(<<~CONTENT)
|
|
19
|
-
RSpec/SpecFilePathFormat:
|
|
20
|
-
CustomTransform:
|
|
21
|
-
#{settings.project_namespaced_class}: ""
|
|
22
|
-
CONTENT
|
|
23
|
-
|
|
15
|
+
with_template.append "\nplugins: rubocop-sequel\n\n"
|
|
16
|
+
add_configuration
|
|
24
17
|
true
|
|
25
18
|
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def add_configuration
|
|
23
|
+
with_template.append <<~CONTENT
|
|
24
|
+
Metrics/MethodLength:
|
|
25
|
+
Exclude:
|
|
26
|
+
- config/initializers/universal_logger_patch.rb
|
|
27
|
+
RSpec/SpecFilePathFormat:
|
|
28
|
+
CustomTransform:
|
|
29
|
+
#{settings.project_namespaced_class}: ""
|
|
30
|
+
CONTENT
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def with_template
|
|
34
|
+
path = "%project_name%/.config/rubocop/config.yml.erb"
|
|
35
|
+
builder.call settings.with(template_path: path)
|
|
36
|
+
end
|
|
26
37
|
end
|
|
27
38
|
end
|
|
28
39
|
end
|
|
@@ -31,6 +31,14 @@ module Hanamismith
|
|
|
31
31
|
builder.call(settings.with(template_path: "%project_name%/app/action.rb.erb")).render
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def add_contract
|
|
35
|
+
builder.call(settings.with(template_path: "%project_name%/app/contract.rb.erb")).render
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def add_mailer
|
|
39
|
+
builder.call(settings.with(template_path: "%project_name%/app/mailer.rb.erb")).render
|
|
40
|
+
end
|
|
41
|
+
|
|
34
42
|
def add_view
|
|
35
43
|
builder.call(settings.with(template_path: "%project_name%/app/view.rb.erb")).render
|
|
36
44
|
end
|
|
@@ -22,10 +22,7 @@ module Hanamismith
|
|
|
22
22
|
%project_name%/app/providers/logger.rb.erb
|
|
23
23
|
%project_name%/spec/app/providers/logger_spec.rb.erb
|
|
24
24
|
%project_name%/config/providers/logger.rb.erb
|
|
25
|
-
%project_name%/
|
|
26
|
-
%project_name%/spec/app/aspects/logging/rack_adapter_spec.rb.erb
|
|
27
|
-
%project_name%/config/initializers/rack_logger_patch.rb.erb
|
|
28
|
-
%project_name%/config/initializers/sql_logger_patch.rb.erb
|
|
25
|
+
%project_name%/config/initializers/universal_logger_patch.rb.erb
|
|
29
26
|
].each { build it }
|
|
30
27
|
end
|
|
31
28
|
|
|
@@ -37,8 +34,7 @@ module Hanamismith
|
|
|
37
34
|
/require/,
|
|
38
35
|
<<~REQUIRES
|
|
39
36
|
|
|
40
|
-
require_relative "initializers/
|
|
41
|
-
require_relative "initializers/sql_logger_patch"
|
|
37
|
+
require_relative "initializers/universal_logger_patch"
|
|
42
38
|
REQUIRES
|
|
43
39
|
)
|
|
44
40
|
end
|
|
@@ -25,7 +25,10 @@ module Hanamismith
|
|
|
25
25
|
def add_middleware
|
|
26
26
|
builder.call(settings.with(template_path: "%project_name%/config/app.rb.erb"))
|
|
27
27
|
.insert_after(/require/, %(\nrequire_relative "initializers/rack_attack"\n))
|
|
28
|
-
.
|
|
28
|
+
.insert_after(
|
|
29
|
+
"rubocop:enable Layout/FirstArrayElementLineBreak\n",
|
|
30
|
+
"\n config.middleware.use Rack::Attack\n"
|
|
31
|
+
)
|
|
29
32
|
end
|
|
30
33
|
end
|
|
31
34
|
end
|
|
@@ -11,8 +11,10 @@ module Hanamismith
|
|
|
11
11
|
|
|
12
12
|
def call
|
|
13
13
|
builder.call(settings.with(template_path: "%project_name%/config/app.rb.erb"))
|
|
14
|
-
.insert_after(
|
|
15
|
-
|
|
14
|
+
.insert_after(
|
|
15
|
+
"rubocop:enable Layout/FirstArrayElementLineBreak\n",
|
|
16
|
+
"\n config.middleware.use Rack::Deflater\n"
|
|
17
|
+
)
|
|
16
18
|
true
|
|
17
19
|
end
|
|
18
20
|
end
|
|
@@ -13,12 +13,21 @@ module Hanamismith
|
|
|
13
13
|
return false unless settings.build_rake
|
|
14
14
|
|
|
15
15
|
super
|
|
16
|
+
process
|
|
17
|
+
true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def process
|
|
16
23
|
builder.call(settings.with(template_path: "%project_name%/Rakefile.erb"))
|
|
17
24
|
.render
|
|
25
|
+
.replace(
|
|
26
|
+
"Reek::Rake::Task.new",
|
|
27
|
+
%(Reek::Rake::Task.new { it.source_files = "{app,config,lib,slices}/**/*.rb" })
|
|
28
|
+
)
|
|
18
29
|
.insert_after(%r(bundler/setup), %(require "hanami/rake_tasks"))
|
|
19
30
|
.insert_after(/RuboCop::RakeTask/, %(\nRake.add_rakelib "lib/tasks"\n))
|
|
20
|
-
|
|
21
|
-
true
|
|
22
31
|
end
|
|
23
32
|
end
|
|
24
33
|
end
|
|
@@ -12,20 +12,29 @@ module Hanamismith
|
|
|
12
12
|
return false unless settings.build_reek
|
|
13
13
|
|
|
14
14
|
super
|
|
15
|
-
|
|
15
|
+
add_duplicate_exclusion
|
|
16
|
+
add_too_many_statements_exclusion
|
|
16
17
|
true
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
def
|
|
20
|
+
def add_duplicate_exclusion
|
|
21
|
+
with_template.insert_before(
|
|
22
|
+
/LongParameterList:\n/,
|
|
23
|
+
<<~DETECTORS.gsub(/^/, " ")
|
|
24
|
+
DuplicateMethodCall:
|
|
25
|
+
exclude:
|
|
26
|
+
- UniversalLoggerPatch#_log_structured
|
|
27
|
+
DETECTORS
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def add_too_many_statements_exclusion
|
|
20
32
|
with_template.insert_after(
|
|
21
33
|
/enabled:\sfalse\n/,
|
|
22
34
|
<<~DETECTORS.gsub(/^/, " ")
|
|
23
35
|
TooManyStatements:
|
|
24
36
|
exclude:
|
|
25
|
-
-
|
|
26
|
-
UtilityFunction:
|
|
27
|
-
exclude:
|
|
28
|
-
- SQLLoggerPatch#log_query
|
|
37
|
+
- UniversalLoggerPatch#_log_structured
|
|
29
38
|
DETECTORS
|
|
30
39
|
)
|
|
31
40
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# auto_register: false
|
|
2
|
+
|
|
3
|
+
require "dry/validation"
|
|
4
|
+
|
|
5
|
+
<% namespace do %>
|
|
6
|
+
# The application base contract.
|
|
7
|
+
class Contract < Dry::Validation::Contract
|
|
8
|
+
config.messages.backend = :i18n
|
|
9
|
+
|
|
10
|
+
Hanami.app.config.i18n.tap do |i18n|
|
|
11
|
+
(i18n.shared_load_path + i18n.load_path).each do |entry|
|
|
12
|
+
path = Hanami.app.root.join entry.sub(/\*.*/, "")
|
|
13
|
+
config.messages.load_paths.merge path.glob("**/*.yml")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
<% end %>
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
def prepare = require "cogger"
|
|
17
17
|
|
|
18
18
|
def start
|
|
19
|
+
add_aliases
|
|
19
20
|
add_filters
|
|
20
21
|
register :logger, build_instance
|
|
21
22
|
end
|
|
@@ -24,7 +25,23 @@
|
|
|
24
25
|
|
|
25
26
|
attr_reader :environment, :resolver, :id
|
|
26
27
|
|
|
27
|
-
def
|
|
28
|
+
def add_aliases
|
|
29
|
+
cogger.add_formatter(
|
|
30
|
+
:rack,
|
|
31
|
+
Cogger::Formatters::Emoji,
|
|
32
|
+
"%<emoji:dynamic>s <dynamic>[%<id>s] [%<level>s] [%<at>s] %<verb>s " \
|
|
33
|
+
"%<status>s %<elapsed>s %<ip>s %<path>s %<length>s </dynamic>"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
cogger.add_formatter :sql,
|
|
37
|
+
Cogger::Formatters::Emoji,
|
|
38
|
+
"%<emoji:dynamic>s <dynamic>[%<id>s] [%<level>s] [%<at>s] %<db>s " \
|
|
39
|
+
"%<elapsed>s%<elapsed_unit>s %<query>s</dynamic>"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def add_filters
|
|
43
|
+
cogger.add_filters :csrf, :HTTP_ID, :mac_address, :password, :password_confirmation
|
|
44
|
+
end
|
|
28
45
|
|
|
29
46
|
def build_instance
|
|
30
47
|
io = "log/#{environment}.log"
|
|
@@ -10,12 +10,6 @@ require "hanami"
|
|
|
10
10
|
Dry::Schema.load_extensions :monads
|
|
11
11
|
Dry::Validation.load_extensions :monads
|
|
12
12
|
|
|
13
|
-
prepare_container do |container|
|
|
14
|
-
container.config.component_dirs.dir "app" do |dir|
|
|
15
|
-
dir.memoize = -> component { component.key.start_with? "repositories." }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
13
|
config.actions.content_security_policy.then do |csp|
|
|
20
14
|
csp[:manifest_src] = "'self'"
|
|
21
15
|
csp[:script_src] += " 'unsafe-eval' 'unsafe-inline'"
|
|
@@ -29,15 +23,5 @@ require "hanami"
|
|
|
29
23
|
expire_after: 3_600 # 1 hour.
|
|
30
24
|
}
|
|
31
25
|
# rubocop:enable Layout/FirstArrayElementLineBreak
|
|
32
|
-
|
|
33
|
-
environment :development do
|
|
34
|
-
# :nocov:
|
|
35
|
-
config.logger.options[:colorize] = true
|
|
36
|
-
|
|
37
|
-
config.logger = config.logger.instance.add_backend(
|
|
38
|
-
colorize: false,
|
|
39
|
-
stream: root.join("log/development.log")
|
|
40
|
-
)
|
|
41
|
-
end
|
|
42
26
|
end
|
|
43
27
|
<% end %>
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
require "ipaddr"
|
|
2
2
|
require "rack/attack"
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
allowed_subnets = [
|
|
5
5
|
IPAddr.new("10.0.0.0/8"),
|
|
6
6
|
IPAddr.new("172.16.0.0/12"),
|
|
7
7
|
IPAddr.new("192.168.0.0/16"),
|
|
8
8
|
IPAddr.new("127.0.0.1"),
|
|
9
|
-
IPAddr.new("::1")
|
|
9
|
+
IPAddr.new("::1"),
|
|
10
|
+
*ENV.fetch("RACK_ATTACK_ALLOWED_SUBNETS", "").split(",").map { IPAddr.new it }
|
|
10
11
|
]
|
|
11
12
|
|
|
12
13
|
Rack::Attack.safelist "allow private network" do |request|
|
|
13
|
-
|
|
14
|
+
allowed_subnets.any? { |subnet| subnet.include? request.ip }
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
Rack::Attack.throttle("requests by IP", limit: 100, period: 60, &:ip)
|
data/lib/hanamismith/templates/%project_name%/config/initializers/universal_logger_patch.rb.erb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# auto_register: false
|
|
2
|
+
|
|
3
|
+
# Patches Hanami's universal logger to work with Cogger.
|
|
4
|
+
module UniversalLoggerPatch
|
|
5
|
+
def _log_structured method, message, payload
|
|
6
|
+
tags = _current_tags
|
|
7
|
+
block_content = yield if block_given?
|
|
8
|
+
|
|
9
|
+
logger.formatter = case tags
|
|
10
|
+
in [:rack] then tags.delete :rack
|
|
11
|
+
in [:sql] if block_content.is_a? Hash then tags.delete :sql
|
|
12
|
+
else Hanami.env == :development ? :emoji : :json
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
unless block_content.is_a? Hash
|
|
16
|
+
message = block_content
|
|
17
|
+
block_content = {}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
logger.public_send method, message, tags:, **block_content.merge!(payload)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Hanami::UniversalLogger.prepend UniversalLoggerPatch
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
development = ENV.fetch("HANAMI_ENV", "development") == "development"
|
|
2
2
|
|
|
3
|
-
require "concurrent"
|
|
4
3
|
require "localhost" if development
|
|
5
4
|
|
|
6
5
|
Bundler.require :tools if development
|
|
@@ -8,9 +7,10 @@ Bundler.root.join("tmp").then { |path| path.mkdir unless path.exist? }
|
|
|
8
7
|
|
|
9
8
|
max_threads = ENV.fetch "HANAMI_MAX_THREADS", 5
|
|
10
9
|
min_threads = ENV.fetch "HANAMI_MIN_THREADS", max_threads
|
|
11
|
-
concurrency = ENV.fetch "HANAMI_WEB_CONCURRENCY",
|
|
10
|
+
concurrency = Integer ENV.fetch "HANAMI_WEB_CONCURRENCY", 0
|
|
12
11
|
|
|
13
12
|
threads min_threads, max_threads
|
|
13
|
+
max_io_threads 5
|
|
14
14
|
port ENV.fetch("HANAMI_PORT", 2300)
|
|
15
15
|
environment ENV.fetch("HANAMI_ENV", "development")
|
|
16
16
|
workers concurrency
|
|
@@ -18,5 +18,4 @@ worker_timeout 3600 if development
|
|
|
18
18
|
ssl_bind "localhost", 2443 if development
|
|
19
19
|
pidfile ENV.fetch("PIDFILE", "tmp/server.pid")
|
|
20
20
|
plugin :tmp_restart
|
|
21
|
-
|
|
22
|
-
preload_app! && before_fork { Hanami.shutdown } if concurrency.to_i.positive?
|
|
21
|
+
before_fork { Hanami.shutdown } if concurrency > 1
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"keywords": ["hanami", "htmx", "ruby"],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"esbuild": "^0.28.1",
|
|
12
|
+
"hanami-assets": "^3.0.0",
|
|
13
|
+
"htmx.org": "^2.0.10"
|
|
14
|
+
},
|
|
15
|
+
"allowScripts": {
|
|
16
|
+
"esbuild@0.28.1": true
|
|
13
17
|
}
|
|
14
18
|
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
+
ENV["HANAMI_ENV"] = "test"
|
|
2
|
+
|
|
1
3
|
require "capybara/cuprite"
|
|
2
4
|
require "capybara/rspec"
|
|
3
5
|
require "capybara/validate_html5"
|
|
4
6
|
require "database_cleaner/sequel"
|
|
5
7
|
require "dry/monads"
|
|
8
|
+
require "hanami/prepare"
|
|
6
9
|
require "rack/test"
|
|
7
10
|
require "rom-factory"
|
|
8
11
|
require "spec_helper"
|
|
9
12
|
|
|
10
|
-
ENV["HANAMI_ENV"] = "test"
|
|
11
|
-
|
|
12
|
-
require "hanami/prepare"
|
|
13
|
-
|
|
14
13
|
using Refinements::Pathname
|
|
15
14
|
|
|
16
15
|
ENV["LD_PRELOAD"] = nil
|
|
17
16
|
Capybara.app = Hanami.app
|
|
18
|
-
Capybara.server = :puma, {Silent: true, Threads: "
|
|
17
|
+
Capybara.server = :puma, {Silent: true, Threads: "2:2"}
|
|
19
18
|
Capybara.javascript_driver = :cuprite
|
|
20
19
|
Capybara.save_path = Hanami.app.root.join "tmp/capybara"
|
|
21
20
|
Capybara.register_driver :cuprite do |app|
|
|
@@ -36,10 +35,10 @@ RSpec.configure do |config|
|
|
|
36
35
|
config.include_context "with application dependencies", type: :feature
|
|
37
36
|
|
|
38
37
|
databases = proc do
|
|
39
|
-
Hanami.app.
|
|
38
|
+
Hanami.app.with_slices.each_with_object Set.new do |slice, databases|
|
|
40
39
|
next unless slice.key? "db.rom"
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
databases.merge slice["db.rom"].gateways.values.map(&:connection)
|
|
43
42
|
end
|
|
44
43
|
end
|
|
45
44
|
|
|
@@ -56,7 +55,13 @@ RSpec.configure do |config|
|
|
|
56
55
|
end
|
|
57
56
|
end
|
|
58
57
|
|
|
59
|
-
config.
|
|
60
|
-
|
|
58
|
+
config.prepend_before :each, :mailers do
|
|
59
|
+
Hanami.app.with_slices.each do |slice|
|
|
60
|
+
next unless slice.key? "mailers.delivery_method"
|
|
61
|
+
|
|
62
|
+
slice["mailers.delivery_method"].clear
|
|
63
|
+
end
|
|
61
64
|
end
|
|
65
|
+
|
|
66
|
+
config.after(:each, :db) { databases.call.each { DatabaseCleaner[:sequel, db: it].clean } }
|
|
62
67
|
end
|
data.tar.gz.sig
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
�]��̜��vy�=���)���R'�+� �'�ٲ�©)�p�
|
|
6
|
-
��
|
|
1
|
+
G��I����ޫ�p�^v)��/V ���U���I����L��cQ&a�~Bv�?F"���o�/�d8k���ny\P�
|
|
2
|
+
̢�� {��wU��R�bZtFQ2�*�j�7vJ�+gk��
|
|
3
|
+
�:����T�u�`��A5��e{�n�fwM~�"���/`�jtD%5�4S�������ő69�nK��
|
|
4
|
+
�9�*�s?�7�nc?l�$�]�R�/siov,�}� ���(Z�f�0B�?D��XNB�ξ�2��s=�{l��BT)^�)�|qQ�
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hanamismith
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brooke Kuhlmann
|
|
@@ -153,14 +153,14 @@ dependencies:
|
|
|
153
153
|
requirements:
|
|
154
154
|
- - "~>"
|
|
155
155
|
- !ruby/object:Gem::Version
|
|
156
|
-
version: '
|
|
156
|
+
version: '10.0'
|
|
157
157
|
type: :runtime
|
|
158
158
|
prerelease: false
|
|
159
159
|
version_requirements: !ruby/object:Gem::Requirement
|
|
160
160
|
requirements:
|
|
161
161
|
- - "~>"
|
|
162
162
|
- !ruby/object:Gem::Version
|
|
163
|
-
version: '
|
|
163
|
+
version: '10.0'
|
|
164
164
|
- !ruby/object:Gem::Dependency
|
|
165
165
|
name: runcom
|
|
166
166
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -283,7 +283,6 @@ files:
|
|
|
283
283
|
- lib/hanamismith/templates/%project_name%/Procfile.dev.erb
|
|
284
284
|
- lib/hanamismith/templates/%project_name%/Procfile.erb
|
|
285
285
|
- lib/hanamismith/templates/%project_name%/app/action.rb.erb
|
|
286
|
-
- lib/hanamismith/templates/%project_name%/app/aspects/logging/rack_adapter.rb.erb
|
|
287
286
|
- lib/hanamismith/templates/%project_name%/app/assets/css/colors.css.erb
|
|
288
287
|
- lib/hanamismith/templates/%project_name%/app/assets/css/defaults.css.erb
|
|
289
288
|
- lib/hanamismith/templates/%project_name%/app/assets/css/layout.css.erb
|
|
@@ -292,9 +291,11 @@ files:
|
|
|
292
291
|
- lib/hanamismith/templates/%project_name%/app/assets/images/icon.svg.erb
|
|
293
292
|
- lib/hanamismith/templates/%project_name%/app/assets/js/app.js.erb
|
|
294
293
|
- lib/hanamismith/templates/%project_name%/app/assets/pwa/manifest.webmanifest.erb
|
|
294
|
+
- lib/hanamismith/templates/%project_name%/app/contract.rb.erb
|
|
295
295
|
- lib/hanamismith/templates/%project_name%/app/db/relation.rb.erb
|
|
296
296
|
- lib/hanamismith/templates/%project_name%/app/db/repository.rb.erb
|
|
297
297
|
- lib/hanamismith/templates/%project_name%/app/db/struct.rb.erb
|
|
298
|
+
- lib/hanamismith/templates/%project_name%/app/mailer.rb.erb
|
|
298
299
|
- lib/hanamismith/templates/%project_name%/app/providers/logger.rb.erb
|
|
299
300
|
- lib/hanamismith/templates/%project_name%/app/templates/layouts/app.html.erb.erb
|
|
300
301
|
- lib/hanamismith/templates/%project_name%/app/view.rb.erb
|
|
@@ -304,8 +305,7 @@ files:
|
|
|
304
305
|
- lib/hanamismith/templates/%project_name%/config/app.rb.erb
|
|
305
306
|
- lib/hanamismith/templates/%project_name%/config/assets.js.erb
|
|
306
307
|
- lib/hanamismith/templates/%project_name%/config/initializers/rack_attack.rb.erb
|
|
307
|
-
- lib/hanamismith/templates/%project_name%/config/initializers/
|
|
308
|
-
- lib/hanamismith/templates/%project_name%/config/initializers/sql_logger_patch.rb.erb
|
|
308
|
+
- lib/hanamismith/templates/%project_name%/config/initializers/universal_logger_patch.rb.erb
|
|
309
309
|
- lib/hanamismith/templates/%project_name%/config/providers/db.rb.erb
|
|
310
310
|
- lib/hanamismith/templates/%project_name%/config/providers/htmx.rb.erb
|
|
311
311
|
- lib/hanamismith/templates/%project_name%/config/providers/logger.rb.erb
|
|
@@ -336,7 +336,6 @@ files:
|
|
|
336
336
|
- lib/hanamismith/templates/%project_name%/slices/home/view.rb.erb
|
|
337
337
|
- lib/hanamismith/templates/%project_name%/slices/home/views/context.rb.erb
|
|
338
338
|
- lib/hanamismith/templates/%project_name%/slices/home/views/show.rb.erb
|
|
339
|
-
- lib/hanamismith/templates/%project_name%/spec/app/aspects/logging/rack_adapter_spec.rb.erb
|
|
340
339
|
- lib/hanamismith/templates/%project_name%/spec/app/providers/logger_spec.rb.erb
|
|
341
340
|
- lib/hanamismith/templates/%project_name%/spec/features/home_spec.rb.erb
|
|
342
341
|
- lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
|
|
@@ -368,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
368
367
|
- !ruby/object:Gem::Version
|
|
369
368
|
version: '0'
|
|
370
369
|
requirements: []
|
|
371
|
-
rubygems_version: 4.0.
|
|
370
|
+
rubygems_version: 4.0.15
|
|
372
371
|
specification_version: 4
|
|
373
372
|
summary: A command line interface for smithing Hanami projects.
|
|
374
373
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<% namespace do %>
|
|
2
|
-
module Aspects
|
|
3
|
-
module Logging
|
|
4
|
-
# Adapts Cogger Rack middleware for provider registration.
|
|
5
|
-
module RackAdapter
|
|
6
|
-
module_function
|
|
7
|
-
|
|
8
|
-
def with logger
|
|
9
|
-
@logger = logger
|
|
10
|
-
self
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def new application
|
|
14
|
-
@application = Cogger::Rack::Logger.new application, {logger: @logger}
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def call(environment) = @application.call environment
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
<% end %>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require "dry/system"
|
|
2
|
-
|
|
3
|
-
# Patches Hanami's default providers.
|
|
4
|
-
module RackLoggerPatch
|
|
5
|
-
def prepare_app_providers
|
|
6
|
-
require "hanami/providers/inflector"
|
|
7
|
-
|
|
8
|
-
logger = Class.new Hanami::Provider::Source do
|
|
9
|
-
def start
|
|
10
|
-
slice.start :logger
|
|
11
|
-
register :monitor, <%= settings.project_namespaced_class %>::Aspects::Logging::RackAdapter.with(slice[:logger])
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
register_provider :inflector, source: Hanami::Providers::Inflector
|
|
16
|
-
register_provider :rack, source: logger, namespace: true
|
|
17
|
-
register_provider :db_logging, source: Hanami::Providers::DBLogging
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
Hanami::App::ClassMethods.prepend RackLoggerPatch
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
require "dry-monitor"
|
|
2
|
-
require "dry/monitor/sql/logger"
|
|
3
|
-
|
|
4
|
-
# Patches Hanami's default SQL logger.
|
|
5
|
-
module SQLLoggerPatch
|
|
6
|
-
def log_query time:, name:, query:
|
|
7
|
-
# :nocov:
|
|
8
|
-
Hanami.app[:logger].info { {message: query, tags: [{db: name, duration: time}]} }
|
|
9
|
-
# :nocov:
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Dry::Monitor::SQL::Logger.prepend SQLLoggerPatch
|
data/lib/hanamismith/templates/%project_name%/spec/app/aspects/logging/rack_adapter_spec.rb.erb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require "hanami_helper"
|
|
2
|
-
|
|
3
|
-
RSpec.describe <%= settings.project_namespaced_class %>::Aspects::Logging::RackAdapter do
|
|
4
|
-
subject(:adapter) { described_class }
|
|
5
|
-
|
|
6
|
-
include_context "with application dependencies"
|
|
7
|
-
|
|
8
|
-
let(:application) { proc { [200, {"Content-Type" => "text/plain"}, "test"] } }
|
|
9
|
-
|
|
10
|
-
describe ".with" do
|
|
11
|
-
it "answers itself" do
|
|
12
|
-
expect(adapter.with(nil)).to eq(adapter)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe ".new" do
|
|
17
|
-
it "answers Cogger middleware" do
|
|
18
|
-
expect(adapter.with(logger).new(application)).to be_a(Cogger::Rack::Logger)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe ".call" do
|
|
23
|
-
let(:middleware) { adapter.with(logger).new application }
|
|
24
|
-
|
|
25
|
-
it "answers application" do
|
|
26
|
-
expect(middleware.call({})).to eq([200, {"Content-Type" => "text/plain"}, "test"])
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "logs request" do
|
|
30
|
-
middleware.call({})
|
|
31
|
-
expect(logger.reread).to match(/level.+INFO.+status.+200/)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|