hanami-cli 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +17 -2
- data/Gemfile +1 -0
- data/lib/hanami/cli/commands/app/command.rb +0 -1
- data/lib/hanami/cli/commands/app/console.rb +1 -0
- data/lib/hanami/cli/commands/app/generate/action.rb +9 -9
- data/lib/hanami/cli/commands/app/middlewares.rb +47 -0
- data/lib/hanami/cli/commands/app.rb +9 -11
- data/lib/hanami/cli/commands.rb +12 -3
- data/lib/hanami/cli/generators/app/action/action.erb +5 -5
- data/lib/hanami/cli/generators/app/action/slice_action.erb +13 -0
- data/lib/hanami/cli/generators/app/action.rb +42 -25
- data/lib/hanami/cli/generators/app/action_context.rb +2 -2
- data/lib/hanami/cli/generators/app/slice/action.erb +0 -2
- data/lib/hanami/cli/generators/app/slice/routes.erb +3 -2
- data/lib/hanami/cli/generators/app/slice/slice.erb +6 -0
- data/lib/hanami/cli/generators/app/slice.rb +11 -10
- data/lib/hanami/cli/generators/gem/app/gemfile.erb +8 -3
- data/lib/hanami/cli/generators/gem/app/routes.erb +0 -2
- data/lib/hanami/cli/generators/gem/app/settings.erb +3 -1
- data/lib/hanami/cli/generators/gem/app/types.erb +3 -2
- data/lib/hanami/cli/middleware_stack_inspector.rb +41 -0
- data/lib/hanami/cli/version.rb +1 -1
- metadata +7 -10
- data/lib/hanami/cli/generators/gem/app/operation.erb +0 -9
- data/lib/hanami/cli/generators/gem/app/relation.erb +0 -7
- data/lib/hanami/cli/generators/gem/app/repository.erb +0 -9
- data/lib/hanami/cli/generators/gem/app/transformations.erb +0 -13
- data/lib/hanami/cli/generators/gem/app/view.erb +0 -9
- data/lib/hanami/cli/generators/gem/app/view_context.erb +0 -10
- data/lib/hanami/cli/generators/gem/app/view_part.erb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 511daafabba67025eb83dd27f06c62a9809ab89c8901445e5c00f15bbf8fd8ca
|
4
|
+
data.tar.gz: 7d303b0c72fb47c2cf0ba107af0e6899d83b14b580565f4b30c43f4bc87ab4f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 716e634d4c572a09cd9954484d9dafc6affaafc13d03ec1e79703436b3efd305d1823dc4d35e92207b5388ebc33aef9f9ba603089cf73b3aec904957fe760bd6
|
7
|
+
data.tar.gz: e7d545d1cd6bfabcc5b4305b755c319c06a4e688e74a4639765c8f0026aac6b039d3459d670014a096ebd726b4a3192f694e273285341698b52a02b0762ae4a4
|
data/.rubocop.yml
CHANGED
@@ -7,9 +7,10 @@ inherit_from:
|
|
7
7
|
Layout/LineLength:
|
8
8
|
Exclude:
|
9
9
|
- Gemfile
|
10
|
+
- 'spec/**/*.rb'
|
10
11
|
Lint/EmptyFile:
|
11
12
|
Exclude:
|
12
|
-
-
|
13
|
+
- 'spec/fixtures/**/*.rb'
|
13
14
|
Naming/HeredocDelimiterNaming:
|
14
15
|
Enabled: false
|
15
16
|
Naming/MethodParameterName:
|
@@ -29,3 +30,5 @@ Style/TrailingCommaInArrayLiteral:
|
|
29
30
|
Enabled: false
|
30
31
|
Style/TrailingCommaInHashLiteral:
|
31
32
|
Enabled: false
|
33
|
+
Style/StringConcatenation:
|
34
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -2,14 +2,29 @@
|
|
2
2
|
|
3
3
|
Hanami Command Line Interface
|
4
4
|
|
5
|
+
## v2.0.0.beta2 - 2022-08-16
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- [Luca Guidi] Added `hanami generate slice` command, for generating a new slice [#32]
|
10
|
+
- [Luca Guidi] Added `hanami generate action` command, for generating a new action in the app or a slice [#33]
|
11
|
+
- [Marc Busqué] Added `hanami middlewares` command, for listing middleware configed in app and/or in `config/routes.rb` [#30]
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
- [Marc Busqué, Tim Riley] `hanami` command will detect the app even when called inside nested subdirectories [#34]
|
16
|
+
- [Seb Wilgosz] Include hanami-validations in generated app’s `Gemfile`, allowing action classes to specify `.params` [#31]
|
17
|
+
- [Tim Riley] Include dry-types in generated app’s `Gemfile`, which is used by the types module defined in `lib/[app_name]/types.rb` (dry-types is no longer a hard dependency of the hanami gem as of 2.0.0.beta2) [#29]
|
18
|
+
- [Tim Riley] Include dotenv in generated app’s `Gemfile`, allowing `ENV` values to be loaded from `.env*` files [#29]
|
19
|
+
|
5
20
|
## v2.0.0.beta1 - 2022-07-20
|
6
21
|
|
7
22
|
### Added
|
8
23
|
|
9
24
|
- [Luca Guidi] Implemented `hanami new` to generate a new Hanami app
|
10
25
|
- [Piotr Solnica] Implemented `hanami console` to start an interactive console (REPL)
|
11
|
-
- [Marc
|
12
|
-
- [Marc
|
26
|
+
- [Marc Busqué] Implemented `hanami server` to start a HTTP server based on Rack
|
27
|
+
- [Marc Busqué] Implemented `hanami routes` to print app routes
|
13
28
|
- [Luca Guidi] Implemented `hanami version` to print app Hanami version
|
14
29
|
|
15
30
|
## v2.0.0.alpha8.1 - 2022-05-23
|
data/Gemfile
CHANGED
@@ -8,6 +8,7 @@ unless ENV["CI"]
|
|
8
8
|
gem "yard", require: false
|
9
9
|
end
|
10
10
|
|
11
|
+
gem "dry-files", require: false, github: "dry-rb/dry-files", branch: :main
|
11
12
|
gem "hanami", require: false, github: "hanami/hanami", branch: :main
|
12
13
|
gem "hanami-router", github: "hanami/router", branch: :main
|
13
14
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/cli/command"
|
3
|
+
require "hanami/cli/commands/app/command"
|
4
4
|
require "hanami/cli/generators/app/action"
|
5
5
|
require "dry/inflector"
|
6
6
|
require "dry/files"
|
@@ -11,7 +11,7 @@ module Hanami
|
|
11
11
|
module Commands
|
12
12
|
module App
|
13
13
|
module Generate
|
14
|
-
class Action < Command
|
14
|
+
class Action < App::Command
|
15
15
|
# TODO: ideally the default format should lookup
|
16
16
|
# slice configuration (Action's `default_response_format`)
|
17
17
|
DEFAULT_FORMAT = "html"
|
@@ -20,13 +20,13 @@ module Hanami
|
|
20
20
|
DEFAULT_SKIP_VIEW = false
|
21
21
|
private_constant :DEFAULT_SKIP_VIEW
|
22
22
|
|
23
|
-
argument :slice, required: true, desc: "Slice name"
|
24
23
|
argument :name, required: true, desc: "Action name"
|
25
24
|
option :url, required: false, type: :string, desc: "Action URL"
|
26
25
|
option :http, required: false, type: :string, desc: "Action HTTP method"
|
27
|
-
option :format, required: false, type: :string, default: DEFAULT_FORMAT, desc: "Template format"
|
28
|
-
option :skip_view, required: false, type: :boolean, default: DEFAULT_SKIP_VIEW,
|
29
|
-
|
26
|
+
# option :format, required: false, type: :string, default: DEFAULT_FORMAT, desc: "Template format"
|
27
|
+
# option :skip_view, required: false, type: :boolean, default: DEFAULT_SKIP_VIEW,
|
28
|
+
# desc: "Skip view and template generation"
|
29
|
+
option :slice, required: false, desc: "Slice name"
|
30
30
|
|
31
31
|
def initialize(fs: Dry::Files.new, inflector: Dry::Inflector.new,
|
32
32
|
generator: Generators::App::Action.new(fs: fs, inflector: inflector), **)
|
@@ -35,8 +35,8 @@ module Hanami
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# rubocop:disable Metrics/ParameterLists
|
38
|
-
def call(
|
39
|
-
slice = inflector.underscore(Shellwords.shellescape(slice))
|
38
|
+
def call(name:, url: nil, http: nil, format: DEFAULT_FORMAT, skip_view: DEFAULT_SKIP_VIEW, slice: nil, **)
|
39
|
+
slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
|
40
40
|
name = inflector.underscore(Shellwords.shellescape(name))
|
41
41
|
*controller, action = name.split(ACTION_SEPARATOR)
|
42
42
|
|
@@ -44,7 +44,7 @@ module Hanami
|
|
44
44
|
raise ArgumentError.new("cannot parse controller and action name: `#{name}'\n\texample: users.show")
|
45
45
|
end
|
46
46
|
|
47
|
-
generator.call(
|
47
|
+
generator.call(app.namespace, controller, action, url, http, format, skip_view, slice)
|
48
48
|
end
|
49
49
|
# rubocop:enable Metrics/ParameterLists
|
50
50
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hanami"
|
4
|
+
require "hanami/cli/middleware_stack_inspector"
|
5
|
+
|
6
|
+
module Hanami
|
7
|
+
module CLI
|
8
|
+
module Commands
|
9
|
+
module App
|
10
|
+
# List registered middlewares in the app router
|
11
|
+
#
|
12
|
+
# It outputs middlewares registered along with the paths where they
|
13
|
+
# apply:
|
14
|
+
#
|
15
|
+
# ```
|
16
|
+
# $ hanami middlewares
|
17
|
+
# / Rack::Session::Cookie
|
18
|
+
# ```
|
19
|
+
#
|
20
|
+
# Given arguments can be inspected:
|
21
|
+
#
|
22
|
+
# ```
|
23
|
+
# $ hanami middlewares --with-arguments
|
24
|
+
# / Rack::Session::Cookie args: [{:secret=>"foo"}]
|
25
|
+
# ```
|
26
|
+
class Middlewares < Hanami::CLI::Command
|
27
|
+
desc "List all the registered middlewares"
|
28
|
+
|
29
|
+
DEFAULT_WITH_ARGUMENTS = false
|
30
|
+
|
31
|
+
option :with_arguments, default: DEFAULT_WITH_ARGUMENTS, required: false,
|
32
|
+
desc: "Include inspected arguments", type: :boolean
|
33
|
+
|
34
|
+
# @api private
|
35
|
+
def call(with_arguments: DEFAULT_WITH_ARGUMENTS)
|
36
|
+
require "hanami/prepare"
|
37
|
+
|
38
|
+
if Hanami.app.router
|
39
|
+
inspector = MiddlewareStackInspector.new(stack: Hanami.app.router.middleware_stack)
|
40
|
+
out.puts inspector.inspect(include_arguments: with_arguments)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -9,7 +9,8 @@ module Hanami
|
|
9
9
|
require_relative "app/console"
|
10
10
|
require_relative "app/server"
|
11
11
|
require_relative "app/routes"
|
12
|
-
|
12
|
+
require_relative "app/generate"
|
13
|
+
require_relative "app/middlewares"
|
13
14
|
# require_relative "app/db/create"
|
14
15
|
# require_relative "app/db/create_migration"
|
15
16
|
# require_relative "app/db/drop"
|
@@ -27,17 +28,14 @@ module Hanami
|
|
27
28
|
register "version", Commands::App::Version, aliases: ["v", "-v", "--version"]
|
28
29
|
register "install", Commands::App::Install
|
29
30
|
register "console", Commands::App::Console, aliases: ["c"]
|
30
|
-
register "server",
|
31
|
-
register "routes",
|
31
|
+
register "server", Commands::App::Server, aliases: ["s"]
|
32
|
+
register "routes", Commands::App::Routes
|
33
|
+
register "middlewares", Commands::App::Middlewares
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# register "generate", aliases: ["g"] do |prefix|
|
38
|
-
# prefix.register "slice", Generate::Slice
|
39
|
-
# prefix.register "action", Generate::Action
|
40
|
-
# end
|
35
|
+
register "generate", aliases: ["g"] do |prefix|
|
36
|
+
prefix.register "slice", Generate::Slice
|
37
|
+
prefix.register "action", Generate::Action
|
38
|
+
end
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
data/lib/hanami/cli/commands.rb
CHANGED
@@ -1,16 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "hanami"
|
4
|
+
|
3
5
|
module Hanami
|
4
6
|
module CLI
|
7
|
+
# Returns true if the CLI is being called from inside an Hanami app.
|
8
|
+
#
|
9
|
+
# This is typically used to determine whether to register commands that are applicable either
|
10
|
+
# inside or outside an app.
|
11
|
+
#
|
12
|
+
# @api public
|
13
|
+
# @since 2.0.0
|
5
14
|
def self.within_hanami_app?
|
6
|
-
|
7
|
-
File.exist?("app.rb")
|
15
|
+
!!Hanami.app_path
|
8
16
|
end
|
9
17
|
|
10
18
|
module Commands
|
11
19
|
end
|
12
20
|
|
13
|
-
|
21
|
+
# @api private
|
22
|
+
def self.register_commands!(within_hanami_app = within_hanami_app?)
|
14
23
|
commands = if within_hanami_app
|
15
24
|
require_relative "commands/app"
|
16
25
|
Commands::App
|
@@ -1,12 +1,12 @@
|
|
1
|
-
# auto_register: false
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
module <%= classified_slice_name %>
|
3
|
+
module <%= classified_app_name %>
|
7
4
|
module Actions
|
8
5
|
<%= module_controller_declaration %>
|
9
|
-
<%= module_controller_offset %>class <%= classified_action_name %> < <%=
|
6
|
+
<%= module_controller_offset %>class <%= classified_action_name %> < <%= classified_app_name %>::Action
|
7
|
+
<%= module_controller_offset %> def handle(*, response)
|
8
|
+
<%= module_controller_offset %> response.body = self.class.name
|
9
|
+
<%= module_controller_offset %> end
|
10
10
|
<%= module_controller_offset %>end
|
11
11
|
<%= module_controller_end %>
|
12
12
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module <%= classified_slice_name %>
|
4
|
+
module Actions
|
5
|
+
<%= module_controller_declaration %>
|
6
|
+
<%= module_controller_offset %>class <%= classified_action_name %> < <%= classified_slice_name %>::Action
|
7
|
+
<%= module_controller_offset %> def handle(*, response)
|
8
|
+
<%= module_controller_offset %> response.body = self.class.name
|
9
|
+
<%= module_controller_offset %> end
|
10
|
+
<%= module_controller_offset %>end
|
11
|
+
<%= module_controller_end %>
|
12
|
+
end
|
13
|
+
end
|
@@ -5,6 +5,7 @@ require "dry/files"
|
|
5
5
|
require "hanami/cli/generators/app/action_context"
|
6
6
|
require "hanami/cli/url"
|
7
7
|
|
8
|
+
# rubocop:disable Metrics/ParameterLists
|
8
9
|
module Hanami
|
9
10
|
module CLI
|
10
11
|
module Generators
|
@@ -15,35 +16,15 @@ module Hanami
|
|
15
16
|
@inflector = inflector
|
16
17
|
end
|
17
18
|
|
18
|
-
# rubocop:disable Metrics/AbcSize
|
19
|
-
# rubocop:disable Metrics/ParameterLists
|
20
19
|
# rubocop:disable Layout/LineLength
|
21
|
-
def call(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
fs.join("config", "routes.rb"),
|
27
|
-
slice_matcher(slice),
|
28
|
-
route(controller, action, url, http)
|
29
|
-
)
|
30
|
-
|
31
|
-
fs.chdir(slice_directory) do
|
32
|
-
fs.mkdir(directory = fs.join("actions", controller))
|
33
|
-
fs.write(fs.join(directory, "#{action}.rb"), t("action.erb", context))
|
34
|
-
|
35
|
-
unless skip_view
|
36
|
-
fs.mkdir(directory = fs.join("views", controller))
|
37
|
-
fs.write(fs.join(directory, "#{action}.rb"), t("view.erb", context))
|
38
|
-
|
39
|
-
fs.mkdir(directory = fs.join("templates", controller))
|
40
|
-
fs.write(fs.join(directory, "#{action}.#{format}.erb"), t(template_format(format), context))
|
41
|
-
end
|
20
|
+
def call(app, controller, action, url, http, format, skip_view, slice, context: ActionContext.new(inflector, app, slice, controller, action))
|
21
|
+
if slice
|
22
|
+
generate_for_slice(controller, action, url, http, format, skip_view, slice, context)
|
23
|
+
else
|
24
|
+
generate_for_app(controller, action, url, http, format, skip_view, context)
|
42
25
|
end
|
43
26
|
end
|
44
27
|
# rubocop:enable Layout/LineLength
|
45
|
-
# rubocop:enable Metrics/ParameterLists
|
46
|
-
# rubocop:enable Metrics/AbcSize
|
47
28
|
|
48
29
|
private
|
49
30
|
|
@@ -75,6 +56,41 @@ module Hanami
|
|
75
56
|
|
76
57
|
attr_reader :inflector
|
77
58
|
|
59
|
+
def generate_for_slice(controller, action, url, http, _format, _skip_view, slice, context)
|
60
|
+
slice_directory = fs.join("slices", slice)
|
61
|
+
raise ArgumentError.new("slice not found `#{slice}'") unless fs.directory?(slice_directory)
|
62
|
+
|
63
|
+
fs.inject_line_at_block_bottom(
|
64
|
+
fs.join("config", "routes.rb"),
|
65
|
+
slice_matcher(slice),
|
66
|
+
route(controller, action, url, http)
|
67
|
+
)
|
68
|
+
|
69
|
+
fs.chdir(slice_directory) do
|
70
|
+
fs.mkdir(directory = fs.join("actions", controller))
|
71
|
+
fs.write(fs.join(directory, "#{action}.rb"), t("slice_action.erb", context))
|
72
|
+
|
73
|
+
# unless skip_view
|
74
|
+
# fs.mkdir(directory = fs.join("views", controller))
|
75
|
+
# fs.write(fs.join(directory, "#{action}.rb"), t("view.erb", context))
|
76
|
+
#
|
77
|
+
# fs.mkdir(directory = fs.join("templates", controller))
|
78
|
+
# fs.write(fs.join(directory, "#{action}.#{format}.erb"), t(template_format(format), context))
|
79
|
+
# end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def generate_for_app(controller, action, url, http, _format, _skip_view, context)
|
84
|
+
fs.inject_line_at_block_bottom(
|
85
|
+
fs.join("config", "routes.rb"),
|
86
|
+
/define/,
|
87
|
+
route(controller, action, url, http)
|
88
|
+
)
|
89
|
+
|
90
|
+
fs.mkdir(directory = fs.join("app", "actions", controller))
|
91
|
+
fs.write(fs.join(directory, "#{action}.rb"), t("action.erb", context))
|
92
|
+
end
|
93
|
+
|
78
94
|
def slice_matcher(slice)
|
79
95
|
/slice[[:space:]]*:#{slice}/
|
80
96
|
end
|
@@ -121,3 +137,4 @@ module Hanami
|
|
121
137
|
end
|
122
138
|
end
|
123
139
|
end
|
140
|
+
# rubocop:enable Metrics/ParameterLists
|
@@ -8,10 +8,10 @@ module Hanami
|
|
8
8
|
module Generators
|
9
9
|
module App
|
10
10
|
class ActionContext < SliceContext
|
11
|
-
def initialize(inflector, slice, controller, action)
|
11
|
+
def initialize(inflector, app, slice, controller, action)
|
12
12
|
@controller = controller
|
13
13
|
@action = action
|
14
|
-
super(inflector,
|
14
|
+
super(inflector, app, slice, nil)
|
15
15
|
end
|
16
16
|
|
17
17
|
def classified_controller_name
|
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
|
2
|
+
slice :<%= underscored_slice_name %>, at: "<%= slice_url_prefix %>" do
|
3
|
+
end
|
@@ -14,23 +14,24 @@ module Hanami
|
|
14
14
|
@inflector = inflector
|
15
15
|
end
|
16
16
|
|
17
|
-
def call(app, slice, slice_url_prefix, context: SliceContext.new(inflector, app, slice, slice_url_prefix))
|
18
|
-
fs.
|
17
|
+
def call(app, slice, slice_url_prefix, context: SliceContext.new(inflector, app, slice, slice_url_prefix))
|
18
|
+
fs.inject_line_at_block_bottom(fs.join("config", "routes.rb"), /define/, t("routes.erb", context).chomp)
|
19
19
|
|
20
20
|
fs.mkdir(directory = "slices/#{slice}")
|
21
21
|
|
22
22
|
fs.chdir(directory) do
|
23
|
+
# fs.write("config/slice.rb", t("slice.erb", context))
|
23
24
|
fs.write("action.rb", t("action.erb", context))
|
24
|
-
fs.write("view.rb", t("view.erb", context))
|
25
|
-
fs.write("entities.rb", t("entities.erb", context))
|
26
|
-
fs.write("repository.rb", t("repository.erb", context))
|
25
|
+
# fs.write("view.rb", t("view.erb", context))
|
26
|
+
# fs.write("entities.rb", t("entities.erb", context))
|
27
|
+
# fs.write("repository.rb", t("repository.erb", context))
|
27
28
|
|
28
29
|
fs.write("actions/.keep", t("keep.erb", context))
|
29
|
-
fs.write("views/.keep", t("keep.erb", context))
|
30
|
-
fs.write("templates/.keep", t("keep.erb", context))
|
31
|
-
fs.write("templates/layouts/.keep", t("keep.erb", context))
|
32
|
-
fs.write("entities/.keep", t("keep.erb", context))
|
33
|
-
fs.write("repositories/.keep", t("keep.erb", context))
|
30
|
+
# fs.write("views/.keep", t("keep.erb", context))
|
31
|
+
# fs.write("templates/.keep", t("keep.erb", context))
|
32
|
+
# fs.write("templates/layouts/.keep", t("keep.erb", context))
|
33
|
+
# fs.write("entities/.keep", t("keep.erb", context))
|
34
|
+
# fs.write("repositories/.keep", t("keep.erb", context))
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
@@ -2,13 +2,18 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "
|
6
|
-
|
5
|
+
gem "hanami", "<%= hanami_version %>"
|
7
6
|
gem "hanami-router", "<%= hanami_version %>"
|
8
7
|
gem "hanami-controller", "<%= hanami_version %>"
|
9
|
-
gem "hanami", "<%= hanami_version %>"
|
8
|
+
gem "hanami-validations", "<%= hanami_version %>"
|
10
9
|
|
10
|
+
gem "dry-types"
|
11
11
|
gem "puma"
|
12
|
+
gem "rake"
|
13
|
+
|
14
|
+
group :development, :test do
|
15
|
+
gem "dotenv"
|
16
|
+
end
|
12
17
|
|
13
18
|
group :cli, :development, :test do
|
14
19
|
gem "hanami-rspec"
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "<%= underscored_app_name %>/types"
|
4
|
-
require "hanami/settings"
|
5
4
|
|
6
5
|
module <%= classified_app_name %>
|
7
6
|
class Settings < Hanami::Settings
|
7
|
+
# Define your app settings here, for example:
|
8
|
+
#
|
9
|
+
# setting :my_flag, default: false, constructor: Types::Params::Bool
|
8
10
|
end
|
9
11
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hanami
|
4
|
+
module CLI
|
5
|
+
# @api private
|
6
|
+
class MiddlewareStackInspector
|
7
|
+
def initialize(stack:)
|
8
|
+
@stack = stack
|
9
|
+
end
|
10
|
+
|
11
|
+
def inspect(include_arguments: false)
|
12
|
+
max_path_length = @stack.map { |(path)| path.length }.max
|
13
|
+
|
14
|
+
@stack.map { |path, middlewares|
|
15
|
+
middlewares.map { |(middleware, arguments)|
|
16
|
+
"#{path.ljust(max_path_length + 3)} #{format_middleware(middleware)}".tap { |line|
|
17
|
+
line << " #{format_arguments(arguments)}" if include_arguments
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}.join("\n") + "\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def format_middleware(middleware)
|
26
|
+
case middleware
|
27
|
+
when Class
|
28
|
+
middleware.name || "(class)"
|
29
|
+
when Module
|
30
|
+
middleware.name || "(module)"
|
31
|
+
else
|
32
|
+
"#{middleware.class.name} (instance)"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def format_arguments(arguments)
|
37
|
+
"args: #{arguments.inspect}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/hanami/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/hanami/cli/commands/app/generate/action.rb
|
176
176
|
- lib/hanami/cli/commands/app/generate/slice.rb
|
177
177
|
- lib/hanami/cli/commands/app/install.rb
|
178
|
+
- lib/hanami/cli/commands/app/middlewares.rb
|
178
179
|
- lib/hanami/cli/commands/app/routes.rb
|
179
180
|
- lib/hanami/cli/commands/app/server.rb
|
180
181
|
- lib/hanami/cli/commands/app/version.rb
|
@@ -189,6 +190,7 @@ files:
|
|
189
190
|
- lib/hanami/cli/error.rb
|
190
191
|
- lib/hanami/cli/generators/app/action.rb
|
191
192
|
- lib/hanami/cli/generators/app/action/action.erb
|
193
|
+
- lib/hanami/cli/generators/app/action/slice_action.erb
|
192
194
|
- lib/hanami/cli/generators/app/action/template.erb
|
193
195
|
- lib/hanami/cli/generators/app/action/template.html.erb
|
194
196
|
- lib/hanami/cli/generators/app/action/view.erb
|
@@ -199,6 +201,7 @@ files:
|
|
199
201
|
- lib/hanami/cli/generators/app/slice/keep.erb
|
200
202
|
- lib/hanami/cli/generators/app/slice/repository.erb
|
201
203
|
- lib/hanami/cli/generators/app/slice/routes.erb
|
204
|
+
- lib/hanami/cli/generators/app/slice/slice.erb
|
202
205
|
- lib/hanami/cli/generators/app/slice/view.erb
|
203
206
|
- lib/hanami/cli/generators/app/slice_context.rb
|
204
207
|
- lib/hanami/cli/generators/context.rb
|
@@ -209,20 +212,14 @@ files:
|
|
209
212
|
- lib/hanami/cli/generators/gem/app/env.erb
|
210
213
|
- lib/hanami/cli/generators/gem/app/gemfile.erb
|
211
214
|
- lib/hanami/cli/generators/gem/app/keep.erb
|
212
|
-
- lib/hanami/cli/generators/gem/app/operation.erb
|
213
215
|
- lib/hanami/cli/generators/gem/app/rakefile.erb
|
214
216
|
- lib/hanami/cli/generators/gem/app/readme.erb
|
215
|
-
- lib/hanami/cli/generators/gem/app/relation.erb
|
216
|
-
- lib/hanami/cli/generators/gem/app/repository.erb
|
217
217
|
- lib/hanami/cli/generators/gem/app/routes.erb
|
218
218
|
- lib/hanami/cli/generators/gem/app/settings.erb
|
219
|
-
- lib/hanami/cli/generators/gem/app/transformations.erb
|
220
219
|
- lib/hanami/cli/generators/gem/app/types.erb
|
221
220
|
- lib/hanami/cli/generators/gem/app/validator.erb
|
222
|
-
- lib/hanami/cli/generators/gem/app/view.erb
|
223
|
-
- lib/hanami/cli/generators/gem/app/view_context.erb
|
224
|
-
- lib/hanami/cli/generators/gem/app/view_part.erb
|
225
221
|
- lib/hanami/cli/generators/version.rb
|
222
|
+
- lib/hanami/cli/middleware_stack_inspector.rb
|
226
223
|
- lib/hanami/cli/rake_tasks.rb
|
227
224
|
- lib/hanami/cli/repl/core.rb
|
228
225
|
- lib/hanami/cli/repl/irb.rb
|
@@ -258,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
255
|
- !ruby/object:Gem::Version
|
259
256
|
version: 1.3.1
|
260
257
|
requirements: []
|
261
|
-
rubygems_version: 3.3.
|
258
|
+
rubygems_version: 3.3.7
|
262
259
|
signing_key:
|
263
260
|
specification_version: 4
|
264
261
|
summary: Hanami CLI
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# auto_register: false
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dry/transformer"
|
5
|
-
|
6
|
-
module <%= classified_app_name %>
|
7
|
-
module Transformations
|
8
|
-
extend Dry::Transformer::Registry
|
9
|
-
|
10
|
-
import Dry::Transformer::ArrayTransformations
|
11
|
-
import Dry::Transformer::HashTransformations
|
12
|
-
end
|
13
|
-
end
|