hanami 2.0.0.alpha7.1 → 2.0.0.beta1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +457 -237
- data/FEATURES.md +30 -9
- data/README.md +1 -3
- data/hanami.gemspec +21 -11
- data/lib/hanami/app.rb +141 -0
- data/lib/hanami/assets/application_configuration.rb +10 -4
- data/lib/hanami/configuration/actions/content_security_policy.rb +118 -0
- data/lib/hanami/configuration/actions/cookies.rb +29 -0
- data/lib/hanami/configuration/actions/sessions.rb +46 -0
- data/lib/hanami/configuration/actions.rb +23 -12
- data/lib/hanami/configuration/logger.rb +13 -10
- data/lib/hanami/configuration/router.rb +2 -6
- data/lib/hanami/configuration/sessions.rb +1 -1
- data/lib/hanami/configuration/views.rb +86 -0
- data/lib/hanami/configuration.rb +139 -82
- data/lib/hanami/constants.rb +30 -2
- data/lib/hanami/errors.rb +4 -1
- data/lib/hanami/extensions/action/slice_configured_action.rb +103 -0
- data/lib/hanami/extensions/action.rb +79 -0
- data/lib/hanami/extensions/view/context.rb +106 -0
- data/lib/hanami/extensions/view/slice_configured_context.rb +71 -0
- data/lib/hanami/extensions/view/slice_configured_view.rb +107 -0
- data/lib/hanami/extensions/view.rb +33 -0
- data/lib/hanami/extensions.rb +10 -0
- data/lib/hanami/providers/inflector.rb +13 -0
- data/lib/hanami/providers/logger.rb +13 -0
- data/lib/hanami/providers/rack.rb +27 -0
- data/lib/hanami/providers/routes.rb +33 -0
- data/lib/hanami/providers/settings.rb +23 -0
- data/lib/hanami/rake_tasks.rb +61 -0
- data/lib/hanami/routes.rb +51 -0
- data/lib/hanami/server.rb +1 -1
- data/lib/hanami/settings/dotenv_store.rb +58 -0
- data/lib/hanami/settings.rb +90 -0
- data/lib/hanami/setup.rb +4 -2
- data/lib/hanami/{application → slice}/router.rb +18 -13
- data/lib/hanami/slice/routes_helper.rb +37 -0
- data/lib/hanami/{application → slice}/routing/middleware/stack.rb +43 -5
- data/lib/hanami/slice/routing/resolver.rb +97 -0
- data/lib/hanami/slice/view_name_inferrer.rb +63 -0
- data/lib/hanami/slice.rb +252 -82
- data/lib/hanami/slice_configurable.rb +62 -0
- data/lib/hanami/slice_name.rb +111 -0
- data/lib/hanami/slice_registrar.rb +119 -0
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/web/rack_logger.rb +1 -1
- data/lib/hanami.rb +34 -26
- data/spec/integration/application_middleware_stack_spec.rb +84 -0
- data/spec/integration/assets/cdn_spec.rb +48 -0
- data/spec/integration/assets/fingerprint_spec.rb +42 -0
- data/spec/integration/assets/helpers_spec.rb +50 -0
- data/spec/integration/assets/serve_spec.rb +70 -0
- data/spec/integration/assets/subresource_integrity_spec.rb +54 -0
- data/spec/integration/body_parsers_spec.rb +50 -0
- data/spec/integration/cli/assets/precompile_spec.rb +147 -0
- data/spec/integration/cli/assets_spec.rb +14 -0
- data/spec/integration/cli/console_spec.rb +105 -0
- data/spec/integration/cli/db/apply_spec.rb +74 -0
- data/spec/integration/cli/db/console_spec.rb +40 -0
- data/spec/integration/cli/db/create_spec.rb +50 -0
- data/spec/integration/cli/db/drop_spec.rb +54 -0
- data/spec/integration/cli/db/migrate_spec.rb +108 -0
- data/spec/integration/cli/db/prepare_spec.rb +36 -0
- data/spec/integration/cli/db/rollback_spec.rb +96 -0
- data/spec/integration/cli/db/version_spec.rb +38 -0
- data/spec/integration/cli/db_spec.rb +21 -0
- data/spec/integration/cli/destroy/action_spec.rb +143 -0
- data/spec/integration/cli/destroy/app_spec.rb +118 -0
- data/spec/integration/cli/destroy/mailer_spec.rb +74 -0
- data/spec/integration/cli/destroy/migration_spec.rb +70 -0
- data/spec/integration/cli/destroy/model_spec.rb +113 -0
- data/spec/integration/cli/destroy_spec.rb +18 -0
- data/spec/integration/cli/generate/action_spec.rb +469 -0
- data/spec/integration/cli/generate/app_spec.rb +215 -0
- data/spec/integration/cli/generate/mailer_spec.rb +189 -0
- data/spec/integration/cli/generate/migration_spec.rb +72 -0
- data/spec/integration/cli/generate/model_spec.rb +290 -0
- data/spec/integration/cli/generate/secret_spec.rb +56 -0
- data/spec/integration/cli/generate_spec.rb +19 -0
- data/spec/integration/cli/new/database_spec.rb +235 -0
- data/spec/integration/cli/new/hanami_head_spec.rb +27 -0
- data/spec/integration/cli/new/template_spec.rb +118 -0
- data/spec/integration/cli/new/test_spec.rb +274 -0
- data/spec/integration/cli/new_spec.rb +970 -0
- data/spec/integration/cli/plugins_spec.rb +39 -0
- data/spec/integration/cli/routes_spec.rb +49 -0
- data/spec/integration/cli/server_spec.rb +626 -0
- data/spec/integration/cli/version_spec.rb +85 -0
- data/spec/integration/early_hints_spec.rb +35 -0
- data/spec/integration/handle_exceptions_spec.rb +244 -0
- data/spec/integration/head_spec.rb +89 -0
- data/spec/integration/http_headers_spec.rb +29 -0
- data/spec/integration/mailer_spec.rb +32 -0
- data/spec/integration/middleware_spec.rb +81 -0
- data/spec/integration/mount_applications_spec.rb +88 -0
- data/spec/integration/project_initializers_spec.rb +40 -0
- data/spec/integration/rackup_spec.rb +35 -0
- data/spec/integration/rake/with_minitest_spec.rb +67 -0
- data/spec/integration/rake/with_rspec_spec.rb +69 -0
- data/spec/integration/routing_helpers_spec.rb +61 -0
- data/spec/integration/security/content_security_policy_spec.rb +46 -0
- data/spec/integration/security/csrf_protection_spec.rb +42 -0
- data/spec/integration/security/force_ssl_spec.rb +29 -0
- data/spec/integration/security/x_content_type_options_spec.rb +46 -0
- data/spec/integration/security/x_frame_options_spec.rb +46 -0
- data/spec/integration/security/x_xss_protection_spec.rb +46 -0
- data/spec/integration/send_file_spec.rb +51 -0
- data/spec/integration/sessions_spec.rb +247 -0
- data/spec/integration/static_middleware_spec.rb +21 -0
- data/spec/integration/streaming_spec.rb +41 -0
- data/spec/integration/unsafe_send_file_spec.rb +52 -0
- data/spec/isolation/hanami/application/already_configured_spec.rb +19 -0
- data/spec/isolation/hanami/application/inherit_anonymous_class_spec.rb +10 -0
- data/spec/isolation/hanami/application/inherit_concrete_class_spec.rb +14 -0
- data/spec/isolation/hanami/application/not_configured_spec.rb +9 -0
- data/spec/isolation/hanami/application/routes/configured_spec.rb +44 -0
- data/spec/isolation/hanami/application/routes/not_configured_spec.rb +16 -0
- data/spec/isolation/hanami/boot/success_spec.rb +50 -0
- data/spec/new_integration/action/configuration_spec.rb +26 -0
- data/spec/new_integration/action/cookies_spec.rb +58 -0
- data/spec/new_integration/action/csrf_protection_spec.rb +54 -0
- data/spec/new_integration/action/routes_spec.rb +73 -0
- data/spec/new_integration/action/sessions_spec.rb +50 -0
- data/spec/new_integration/action/view_integration_spec.rb +165 -0
- data/spec/new_integration/action/view_rendering/automatic_rendering_spec.rb +247 -0
- data/spec/new_integration/action/view_rendering/paired_view_inference_spec.rb +115 -0
- data/spec/new_integration/action/view_rendering_spec.rb +107 -0
- data/spec/new_integration/code_loading/loading_from_app_spec.rb +152 -0
- data/spec/new_integration/code_loading/loading_from_slice_spec.rb +165 -0
- data/spec/new_integration/container/application_routes_helper_spec.rb +48 -0
- data/spec/new_integration/container/auto_injection_spec.rb +53 -0
- data/spec/new_integration/container/auto_registration_spec.rb +86 -0
- data/spec/new_integration/container/autoloader_spec.rb +80 -0
- data/spec/new_integration/container/imports_spec.rb +253 -0
- data/spec/new_integration/container/prepare_container_spec.rb +123 -0
- data/spec/new_integration/container/shutdown_spec.rb +91 -0
- data/spec/new_integration/container/standard_bootable_components_spec.rb +124 -0
- data/spec/new_integration/rack_app/middleware_spec.rb +215 -0
- data/spec/new_integration/rack_app/non_booted_rack_app_spec.rb +105 -0
- data/spec/new_integration/rack_app/rack_app_spec.rb +524 -0
- data/spec/new_integration/settings_spec.rb +115 -0
- data/spec/new_integration/slices/external_slice_spec.rb +92 -0
- data/spec/new_integration/slices/slice_configuration_spec.rb +40 -0
- data/spec/new_integration/slices/slice_routing_spec.rb +226 -0
- data/spec/new_integration/slices/slice_settings_spec.rb +141 -0
- data/spec/new_integration/slices_spec.rb +101 -0
- data/spec/new_integration/view/configuration_spec.rb +49 -0
- data/spec/new_integration/view/context/assets_spec.rb +67 -0
- data/spec/new_integration/view/context/inflector_spec.rb +48 -0
- data/spec/new_integration/view/context/request_spec.rb +61 -0
- data/spec/new_integration/view/context/routes_spec.rb +86 -0
- data/spec/new_integration/view/context/settings_spec.rb +50 -0
- data/spec/new_integration/view/inflector_spec.rb +57 -0
- data/spec/new_integration/view/part_namespace_spec.rb +96 -0
- data/spec/new_integration/view/path_spec.rb +56 -0
- data/spec/new_integration/view/template_spec.rb +68 -0
- data/spec/new_integration/view/views_spec.rb +103 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/app_integration.rb +91 -0
- data/spec/support/coverage.rb +1 -0
- data/spec/support/fixtures/hanami-plugin/Gemfile +8 -0
- data/spec/support/fixtures/hanami-plugin/README.md +35 -0
- data/spec/support/fixtures/hanami-plugin/Rakefile +4 -0
- data/spec/support/fixtures/hanami-plugin/bin/console +15 -0
- data/spec/support/fixtures/hanami-plugin/bin/setup +8 -0
- data/spec/support/fixtures/hanami-plugin/hanami-plugin.gemspec +28 -0
- data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/cli.rb +19 -0
- data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/version.rb +7 -0
- data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin.rb +8 -0
- data/spec/support/rspec.rb +27 -0
- data/spec/support/shared_examples/cli/generate/app.rb +494 -0
- data/spec/support/shared_examples/cli/generate/migration.rb +32 -0
- data/spec/support/shared_examples/cli/generate/model.rb +81 -0
- data/spec/support/shared_examples/cli/new.rb +97 -0
- data/spec/unit/hanami/configuration/actions/content_security_policy_spec.rb +102 -0
- data/spec/unit/hanami/configuration/actions/cookies_spec.rb +46 -0
- data/spec/unit/hanami/configuration/actions/csrf_protection_spec.rb +57 -0
- data/spec/unit/hanami/configuration/actions/default_values_spec.rb +52 -0
- data/spec/unit/hanami/configuration/actions/sessions_spec.rb +50 -0
- data/spec/unit/hanami/configuration/actions_spec.rb +78 -0
- data/spec/unit/hanami/configuration/base_url_spec.rb +25 -0
- data/spec/unit/hanami/configuration/inflector_spec.rb +35 -0
- data/spec/unit/hanami/configuration/logger_spec.rb +203 -0
- data/spec/unit/hanami/configuration/views_spec.rb +120 -0
- data/spec/unit/hanami/configuration_spec.rb +43 -0
- data/spec/unit/hanami/env_spec.rb +54 -0
- data/spec/unit/hanami/routes_spec.rb +25 -0
- data/spec/unit/hanami/settings/dotenv_store_spec.rb +119 -0
- data/spec/unit/hanami/settings_spec.rb +56 -0
- data/spec/unit/hanami/slice_configurable_spec.rb +104 -0
- data/spec/unit/hanami/slice_name_spec.rb +47 -0
- data/spec/unit/hanami/slice_spec.rb +17 -0
- data/spec/unit/hanami/version_spec.rb +7 -0
- data/spec/unit/hanami/web/rack_logger_spec.rb +78 -0
- metadata +363 -55
- data/lib/hanami/application/container/providers/inflector.rb +0 -7
- data/lib/hanami/application/container/providers/logger.rb +0 -7
- data/lib/hanami/application/container/providers/rack_logger.rb +0 -15
- data/lib/hanami/application/container/providers/rack_monitor.rb +0 -12
- data/lib/hanami/application/container/providers/routes_helper.rb +0 -9
- data/lib/hanami/application/container/providers/settings.rb +0 -7
- data/lib/hanami/application/routes.rb +0 -55
- data/lib/hanami/application/routes_helper.rb +0 -34
- data/lib/hanami/application/routing/resolver/node.rb +0 -50
- data/lib/hanami/application/routing/resolver/trie.rb +0 -59
- data/lib/hanami/application/routing/resolver.rb +0 -87
- data/lib/hanami/application/routing/router.rb +0 -36
- data/lib/hanami/application/settings/dotenv_store.rb +0 -60
- data/lib/hanami/application/settings.rb +0 -93
- data/lib/hanami/application/slice_registrar.rb +0 -106
- data/lib/hanami/application.rb +0 -299
- data/lib/hanami/boot/source_dirs.rb +0 -44
- data/lib/hanami/cli/application/cli.rb +0 -40
- data/lib/hanami/cli/application/command.rb +0 -47
- data/lib/hanami/cli/application/commands/console.rb +0 -81
- data/lib/hanami/cli/application/commands.rb +0 -16
- data/lib/hanami/cli/base_command.rb +0 -48
- data/lib/hanami/cli/commands/command.rb +0 -171
- data/lib/hanami/cli/commands/server.rb +0 -88
- data/lib/hanami/cli/commands.rb +0 -65
- data/lib/hanami/configuration/middleware.rb +0 -20
- data/lib/hanami/configuration/source_dirs.rb +0 -42
@@ -1,171 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "hanami"
|
4
|
-
require "hanami/cli/command"
|
5
|
-
require "concurrent"
|
6
|
-
require "hanami/utils/files"
|
7
|
-
require "erb"
|
8
|
-
|
9
|
-
module Hanami
|
10
|
-
# Hanami CLI
|
11
|
-
#
|
12
|
-
# @since 1.1.0
|
13
|
-
class CLI
|
14
|
-
module Commands
|
15
|
-
# Abstract command
|
16
|
-
#
|
17
|
-
# @since 1.1.0
|
18
|
-
class Command < Dry::CLI::Command
|
19
|
-
# @since 1.1.0
|
20
|
-
# @api private
|
21
|
-
def self.inherited(component)
|
22
|
-
super
|
23
|
-
|
24
|
-
component.class_eval do
|
25
|
-
@_requirements = Concurrent::Array.new
|
26
|
-
extend ClassMethods
|
27
|
-
prepend InstanceMethods
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Class level interface
|
32
|
-
#
|
33
|
-
# @since 1.1.0
|
34
|
-
module ClassMethods
|
35
|
-
# Requires an internal Hanami component
|
36
|
-
#
|
37
|
-
# @param names [Array<String>] the name of one or more components
|
38
|
-
#
|
39
|
-
# @since 1.1.0
|
40
|
-
#
|
41
|
-
# @example
|
42
|
-
# require "hanami/cli/commands"
|
43
|
-
#
|
44
|
-
# module HanamiDatabaseHelpers
|
45
|
-
# class TruncateTables < Hanami::CLI::Commands::Command
|
46
|
-
# requires "model.configuration"
|
47
|
-
#
|
48
|
-
# def call(*)
|
49
|
-
# url = requirements["model.configuration"].url
|
50
|
-
# # ...
|
51
|
-
# end
|
52
|
-
# end
|
53
|
-
# end
|
54
|
-
#
|
55
|
-
# Hanami::CLI.register "db truncate", HanamiDatabaseHelpers::TruncateTables
|
56
|
-
def requires(*names)
|
57
|
-
requirements.concat(names)
|
58
|
-
end
|
59
|
-
|
60
|
-
# @since 1.1.0
|
61
|
-
# @api private
|
62
|
-
def requirements
|
63
|
-
@_requirements
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# @since 1.1.0
|
68
|
-
# @api private
|
69
|
-
module InstanceMethods
|
70
|
-
# @since 1.1.0
|
71
|
-
# @api private
|
72
|
-
def call(**options)
|
73
|
-
# FIXME: merge ENV vars (like HANAMI_ENV) into **options
|
74
|
-
super(options)
|
75
|
-
rescue StandardError => exception
|
76
|
-
warn exception.message
|
77
|
-
warn exception.backtrace.join("\n\t")
|
78
|
-
exit(1)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# @since 1.1.0
|
83
|
-
# @api private
|
84
|
-
def initialize(command_name:, out: $stdout, files: Utils::Files)
|
85
|
-
super(command_name: command_name)
|
86
|
-
|
87
|
-
@out = out
|
88
|
-
@files = files
|
89
|
-
end
|
90
|
-
|
91
|
-
private
|
92
|
-
|
93
|
-
# Template renderer
|
94
|
-
#
|
95
|
-
# @since 1.1.0
|
96
|
-
# @api private
|
97
|
-
class Renderer
|
98
|
-
# @since 1.1.0
|
99
|
-
# @api private
|
100
|
-
TRIM_MODE = "-"
|
101
|
-
|
102
|
-
# @since 1.1.0
|
103
|
-
# @api private
|
104
|
-
def initialize
|
105
|
-
freeze
|
106
|
-
end
|
107
|
-
|
108
|
-
# @since 1.1.0
|
109
|
-
# @api private
|
110
|
-
def call(template, context)
|
111
|
-
::ERB.new(template, nil, TRIM_MODE).result(context)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# @since 1.1.0
|
116
|
-
# @api private
|
117
|
-
SAY_FORMATTER = "%<operation>12s %<path>s\n"
|
118
|
-
|
119
|
-
# @since 1.1.0
|
120
|
-
# @api private
|
121
|
-
attr_reader :out
|
122
|
-
|
123
|
-
# @since 1.1.0
|
124
|
-
# @api private
|
125
|
-
attr_reader :files
|
126
|
-
|
127
|
-
# @since 1.1.0
|
128
|
-
# @api private
|
129
|
-
attr_reader :templates
|
130
|
-
|
131
|
-
# @since 1.1.0
|
132
|
-
# @api private
|
133
|
-
def render(path, context)
|
134
|
-
template = File.read(path)
|
135
|
-
renderer = Renderer.new
|
136
|
-
|
137
|
-
renderer.call(template, context.binding)
|
138
|
-
end
|
139
|
-
|
140
|
-
# @since 1.1.0
|
141
|
-
# @api private
|
142
|
-
def generate_file(source, destination, context)
|
143
|
-
files.write(
|
144
|
-
destination,
|
145
|
-
render(source, context)
|
146
|
-
)
|
147
|
-
end
|
148
|
-
|
149
|
-
# @since 1.1.0
|
150
|
-
# @api private
|
151
|
-
def say(operation, path)
|
152
|
-
out.puts(SAY_FORMATTER % { operation: operation, path: path }) # rubocop:disable Style/FormatString
|
153
|
-
end
|
154
|
-
|
155
|
-
# @since 1.1.0
|
156
|
-
# @api private
|
157
|
-
def project
|
158
|
-
# FIXME: is this still useful?
|
159
|
-
raise "it used to be implemented as Project"
|
160
|
-
end
|
161
|
-
|
162
|
-
# @since 1.1.0
|
163
|
-
# @api private
|
164
|
-
def requirements
|
165
|
-
# FIXME: require components via the new Hanami::Container
|
166
|
-
raise "it used to be implemented as Hanami::Components"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Hanami
|
4
|
-
# Hanami CLI
|
5
|
-
#
|
6
|
-
# @since 1.1.0
|
7
|
-
class CLI
|
8
|
-
module Commands
|
9
|
-
# @since 1.1.0
|
10
|
-
# @api private
|
11
|
-
class Server < Command
|
12
|
-
desc "Start Hanami server (only for development)"
|
13
|
-
|
14
|
-
option :server, desc: "Force a server engine (eg, webrick, puma, thin, etc..)"
|
15
|
-
option :host, desc: "The host address to bind to"
|
16
|
-
option :port, desc: "The port to run the server on", aliases: ["-p"]
|
17
|
-
option :debug, desc: "Turn on debug output", type: :boolean
|
18
|
-
option :warn, desc: "Turn on warnings", type: :boolean
|
19
|
-
option :daemonize, desc: "Daemonize the server", type: :boolean
|
20
|
-
option :pid, desc: "Path to write a pid file after daemonize"
|
21
|
-
|
22
|
-
example [
|
23
|
-
" # Basic usage (it uses the bundled server engine)",
|
24
|
-
"--server=webrick # Force `webrick` server engine",
|
25
|
-
"--host=0.0.0.0 # Bind to a host",
|
26
|
-
"--port=2306 # Bind to a port"
|
27
|
-
]
|
28
|
-
|
29
|
-
# @since 1.1.0
|
30
|
-
# @api private
|
31
|
-
def call(**args)
|
32
|
-
require "hanami"
|
33
|
-
require "hanami/container"
|
34
|
-
require "hanami/server"
|
35
|
-
|
36
|
-
options = parse_arguments(args)
|
37
|
-
Hanami::Server.new(options).start
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
DEFAULT_CONFIG = "config.ru"
|
43
|
-
private_constant :DEFAULT_CONFIG
|
44
|
-
|
45
|
-
DEFAULT_HOST = "0.0.0.0"
|
46
|
-
private_constant :DEFAULT_HOST
|
47
|
-
|
48
|
-
DEFAULT_PORT = "2300"
|
49
|
-
private_constant :DEFAULT_PORT
|
50
|
-
|
51
|
-
OPTIONAL_SETTINGS = %i[
|
52
|
-
server
|
53
|
-
debug
|
54
|
-
warn
|
55
|
-
daemonize
|
56
|
-
pid
|
57
|
-
].freeze
|
58
|
-
|
59
|
-
def parse_arguments(args)
|
60
|
-
Hanami::Container.start(:env)
|
61
|
-
|
62
|
-
{
|
63
|
-
config: DEFAULT_CONFIG,
|
64
|
-
Host: host(args),
|
65
|
-
Port: port(args),
|
66
|
-
AccessLog: []
|
67
|
-
}.merge(
|
68
|
-
args.slice(*OPTIONAL_SETTINGS)
|
69
|
-
)
|
70
|
-
end
|
71
|
-
|
72
|
-
def host(args)
|
73
|
-
args.fetch(:host) do
|
74
|
-
ENV.fetch("HANAMI_HOST", DEFAULT_HOST)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def port(args)
|
79
|
-
args.fetch(:port) do
|
80
|
-
ENV.fetch("HANAMI_PORT", DEFAULT_PORT)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
register "server", Commands::Server, aliases: ["s"]
|
87
|
-
end
|
88
|
-
end
|
data/lib/hanami/cli/commands.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dry/cli"
|
4
|
-
require "ostruct"
|
5
|
-
|
6
|
-
module Hanami
|
7
|
-
# Hanami CLI
|
8
|
-
#
|
9
|
-
# @since 1.1.0
|
10
|
-
class CLI
|
11
|
-
# Register a command to expand Hanami CLI
|
12
|
-
#
|
13
|
-
# @param name [String] the command name
|
14
|
-
# @param command [NilClass,Hanami::CLI::Command,Hanami::CLI::Commands::Command]
|
15
|
-
# the optional command
|
16
|
-
# @param aliases [Array<String>] an optional list of aliases
|
17
|
-
#
|
18
|
-
# @since 1.1.0
|
19
|
-
#
|
20
|
-
# @example Third party gem
|
21
|
-
# require "hanami/cli/commands"
|
22
|
-
#
|
23
|
-
# module Hanami
|
24
|
-
# module Webpack
|
25
|
-
# module CLI
|
26
|
-
# module Commands
|
27
|
-
# class Generate < Hanami::CLI::Command
|
28
|
-
# desc "Generate Webpack configuration"
|
29
|
-
#
|
30
|
-
# def call(*)
|
31
|
-
# # ...
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# Hanami::CLI.register "generate webpack", Hanami::Webpack::CLI::Commands::Generate
|
40
|
-
#
|
41
|
-
# # $ bundle exec hanami generate
|
42
|
-
# # Commands:
|
43
|
-
# # hanami generate action APP ACTION # Generate an action for app
|
44
|
-
# # hanami generate app APP # Generate an app
|
45
|
-
# # hanami generate mailer MAILER # Generate a mailer
|
46
|
-
# # hanami generate migration MIGRATION # Generate a migration
|
47
|
-
# # hanami generate model MODEL # Generate a model
|
48
|
-
# # hanami generate secret [APP] # Generate session secret
|
49
|
-
# # hanami generate webpack # Generate Webpack configuration
|
50
|
-
def self.register(name, command = nil, aliases: [], &blk)
|
51
|
-
Commands.register(name, command, aliases: aliases, &blk)
|
52
|
-
end
|
53
|
-
|
54
|
-
# CLI commands registry
|
55
|
-
#
|
56
|
-
# @since 1.1.0
|
57
|
-
# @api private
|
58
|
-
module Commands
|
59
|
-
extend Dry::CLI::Registry
|
60
|
-
|
61
|
-
require "hanami/cli/commands/command"
|
62
|
-
require "hanami/cli/commands/server"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Hanami
|
4
|
-
class Configuration
|
5
|
-
# Hanami application configured Rack middleware
|
6
|
-
#
|
7
|
-
# @since 2.0.0
|
8
|
-
class Middleware
|
9
|
-
attr_reader :stack
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@stack = []
|
13
|
-
end
|
14
|
-
|
15
|
-
def use(middleware, *args, &block)
|
16
|
-
stack.push([middleware, *args, block].compact)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dry/configurable"
|
4
|
-
require "dry/system/config/component_dirs"
|
5
|
-
|
6
|
-
module Hanami
|
7
|
-
class Configuration
|
8
|
-
# Configuration for slice source dirs
|
9
|
-
#
|
10
|
-
# @since 2.0.0
|
11
|
-
class SourceDirs
|
12
|
-
DEFAULT_COMPONENT_DIR_PATHS = %w[lib actions repositories views].freeze
|
13
|
-
private_constant :DEFAULT_COMPONENT_DIR_PATHS
|
14
|
-
|
15
|
-
include Dry::Configurable
|
16
|
-
|
17
|
-
setting :component_dirs,
|
18
|
-
default: Dry::System::Config::ComponentDirs.new.tap { |dirs|
|
19
|
-
DEFAULT_COMPONENT_DIR_PATHS.each do |path|
|
20
|
-
dirs.add path
|
21
|
-
end
|
22
|
-
},
|
23
|
-
cloneable: true
|
24
|
-
|
25
|
-
setting :autoload_paths, default: %w[entities]
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def method_missing(name, *args, &block)
|
30
|
-
if config.respond_to?(name)
|
31
|
-
config.public_send(name, *args, &block)
|
32
|
-
else
|
33
|
-
super
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def respond_to_missing?(name, _include_all = false)
|
38
|
-
config.respond_to?(name) || super
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|