hanami-cli 2.0.0.alpha8.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +49 -2
  3. data/Gemfile +2 -3
  4. data/README.md +13 -11
  5. data/hanami-cli.gemspec +3 -2
  6. data/lib/hanami/cli/bundler.rb +3 -7
  7. data/lib/hanami/cli/commands/app/command.rb +68 -0
  8. data/lib/hanami/cli/commands/{monolith → app}/console.rb +6 -6
  9. data/lib/hanami/cli/commands/{monolith → app}/db/create.rb +3 -3
  10. data/lib/hanami/cli/commands/{monolith → app}/db/create_migration.rb +3 -3
  11. data/lib/hanami/cli/commands/{monolith → app}/db/drop.rb +3 -3
  12. data/lib/hanami/cli/commands/{monolith → app}/db/migrate.rb +4 -4
  13. data/lib/hanami/cli/commands/{monolith → app}/db/reset.rb +3 -3
  14. data/lib/hanami/cli/commands/{monolith → app}/db/rollback.rb +4 -4
  15. data/lib/hanami/cli/commands/{monolith → app}/db/sample_data.rb +4 -4
  16. data/lib/hanami/cli/commands/{monolith → app}/db/seed.rb +4 -4
  17. data/lib/hanami/cli/commands/{monolith → app}/db/setup.rb +3 -3
  18. data/lib/hanami/cli/commands/{monolith → app}/db/structure/dump.rb +3 -3
  19. data/lib/hanami/cli/commands/{monolith → app}/db/version.rb +3 -3
  20. data/lib/hanami/cli/commands/{monolith → app}/generate/action.rb +3 -3
  21. data/lib/hanami/cli/commands/{monolith → app}/generate/slice.rb +4 -4
  22. data/lib/hanami/cli/commands/{monolith → app}/generate.rb +1 -1
  23. data/lib/hanami/cli/commands/{monolith → app}/install.rb +1 -1
  24. data/lib/hanami/cli/commands/app/routes.rb +82 -0
  25. data/lib/hanami/cli/commands/app/server.rb +58 -0
  26. data/lib/hanami/cli/commands/{monolith → app}/version.rb +1 -1
  27. data/lib/hanami/cli/commands/app.rb +46 -0
  28. data/lib/hanami/cli/commands/db/utils/database.rb +10 -10
  29. data/lib/hanami/cli/commands/gem/new.rb +29 -38
  30. data/lib/hanami/cli/commands/gem/version.rb +21 -1
  31. data/lib/hanami/cli/commands/gem.rb +2 -4
  32. data/lib/hanami/cli/commands.rb +9 -10
  33. data/lib/hanami/cli/generators/{monolith → app}/action/action.erb +0 -0
  34. data/lib/hanami/cli/generators/{monolith → app}/action/template.erb +0 -0
  35. data/lib/hanami/cli/generators/{monolith → app}/action/template.html.erb +0 -0
  36. data/lib/hanami/cli/generators/{monolith → app}/action/view.erb +0 -0
  37. data/lib/hanami/cli/generators/{monolith → app}/action.rb +2 -2
  38. data/lib/hanami/cli/generators/{monolith → app}/action_context.rb +1 -1
  39. data/lib/hanami/cli/generators/{monolith → app}/slice/action.erb +0 -0
  40. data/lib/hanami/cli/generators/{monolith → app}/slice/entities.erb +0 -0
  41. data/lib/hanami/cli/generators/{gem/application/monolith → app/slice}/keep.erb +0 -0
  42. data/lib/hanami/cli/generators/{monolith → app}/slice/repository.erb +0 -0
  43. data/lib/hanami/cli/generators/{monolith → app}/slice/routes.erb +0 -0
  44. data/lib/hanami/cli/generators/{monolith → app}/slice/view.erb +0 -0
  45. data/lib/hanami/cli/generators/{monolith → app}/slice.rb +2 -2
  46. data/lib/hanami/cli/generators/{monolith → app}/slice_context.rb +1 -1
  47. data/lib/hanami/cli/generators/context.rb +2 -2
  48. data/lib/hanami/cli/generators/gem/{application/monolith/entities.erb → app/action.erb} +3 -3
  49. data/lib/hanami/cli/generators/gem/{application/monolith/application.erb → app/app.erb} +1 -1
  50. data/lib/hanami/cli/generators/gem/{application/monolith → app}/config_ru.erb +0 -0
  51. data/lib/hanami/cli/generators/gem/{application/monolith → app}/env.erb +0 -0
  52. data/lib/hanami/cli/generators/gem/app/gemfile.erb +15 -0
  53. data/lib/hanami/cli/generators/{monolith/slice → gem/app}/keep.erb +0 -0
  54. data/lib/hanami/cli/generators/gem/app/operation.erb +9 -0
  55. data/lib/hanami/cli/generators/gem/app/rakefile.erb +3 -0
  56. data/lib/hanami/cli/generators/gem/{application/monolith → app}/readme.erb +0 -0
  57. data/lib/hanami/cli/generators/gem/app/relation.erb +7 -0
  58. data/lib/hanami/cli/generators/gem/app/repository.erb +9 -0
  59. data/lib/hanami/cli/generators/gem/app/routes.erb +11 -0
  60. data/lib/hanami/cli/generators/gem/app/settings.erb +9 -0
  61. data/lib/hanami/cli/generators/gem/{application/monolith/functions.erb → app/transformations.erb} +1 -1
  62. data/lib/hanami/cli/generators/gem/{application/monolith → app}/types.erb +0 -0
  63. data/lib/hanami/cli/generators/gem/app/validator.erb +12 -0
  64. data/lib/hanami/cli/generators/gem/app/view.erb +9 -0
  65. data/lib/hanami/cli/generators/gem/{application/monolith → app}/view_context.erb +1 -6
  66. data/lib/hanami/cli/generators/gem/app/view_part.erb +10 -0
  67. data/lib/hanami/cli/generators/gem/app.rb +64 -0
  68. data/lib/hanami/cli/generators/version.rb +55 -0
  69. data/lib/hanami/cli/rake_tasks.rb +54 -0
  70. data/lib/hanami/cli/repl/core.rb +7 -7
  71. data/lib/hanami/cli/server.rb +45 -0
  72. data/lib/hanami/cli/version.rb +1 -1
  73. data/lib/hanami/console/context.rb +12 -12
  74. data/lib/hanami/console/plugins/slice_readers.rb +2 -2
  75. metadata +85 -60
  76. data/lib/hanami/cli/commands/application.rb +0 -67
  77. data/lib/hanami/cli/commands/monolith.rb +0 -55
  78. data/lib/hanami/cli/generators/gem/application/monolith/action.erb +0 -21
  79. data/lib/hanami/cli/generators/gem/application/monolith/gemfile.erb +0 -19
  80. data/lib/hanami/cli/generators/gem/application/monolith/operation.erb +0 -18
  81. data/lib/hanami/cli/generators/gem/application/monolith/rakefile.erb +0 -3
  82. data/lib/hanami/cli/generators/gem/application/monolith/repository.erb +0 -13
  83. data/lib/hanami/cli/generators/gem/application/monolith/routes.erb +0 -4
  84. data/lib/hanami/cli/generators/gem/application/monolith/settings.erb +0 -6
  85. data/lib/hanami/cli/generators/gem/application/monolith/validation_contract.erb +0 -14
  86. data/lib/hanami/cli/generators/gem/application/monolith.rb +0 -83
  87. data/lib/hanami/cli/generators/gem/application.rb +0 -21
  88. data/lib/hanami/rake_tasks.rb +0 -52
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "hanami/cli/command"
4
- require "hanami/cli/generators/monolith/slice"
4
+ require "hanami/cli/generators/app/slice"
5
5
  require "dry/inflector"
6
6
  require "dry/files"
7
7
  require "shellwords"
@@ -10,14 +10,14 @@ require "hanami/cli/url"
10
10
  module Hanami
11
11
  module CLI
12
12
  module Commands
13
- module Monolith
13
+ module App
14
14
  module Generate
15
15
  class Slice < Command
16
16
  argument :name, required: true, desc: "The slice name"
17
17
  option :url_prefix, required: false, type: :string, desc: "The slice URL prefix"
18
18
 
19
19
  def initialize(fs: Dry::Files.new, inflector: Dry::Inflector.new,
20
- generator: Generators::Monolith::Slice.new(fs: fs, inflector: inflector), **)
20
+ generator: Generators::App::Slice.new(fs: fs, inflector: inflector), **)
21
21
  @generator = generator
22
22
  super(fs: fs)
23
23
  end
@@ -25,7 +25,7 @@ module Hanami
25
25
  def call(name:, url_prefix: nil, **)
26
26
  require "hanami/setup"
27
27
 
28
- app = inflector.underscore(Hanami.application.namespace)
28
+ app = inflector.underscore(Hanami.app.namespace)
29
29
  name = inflector.underscore(Shellwords.shellescape(name))
30
30
  url_prefix = sanitize_url_prefix(name, url_prefix)
31
31
 
@@ -3,7 +3,7 @@
3
3
  module Hanami
4
4
  module CLI
5
5
  module Commands
6
- module Monolith
6
+ module App
7
7
  module Generate
8
8
  require_relative "./generate/slice"
9
9
  require_relative "./generate/action"
@@ -5,7 +5,7 @@ require "hanami/cli/command"
5
5
  module Hanami
6
6
  module CLI
7
7
  module Commands
8
- module Monolith
8
+ module App
9
9
  class Install < Command
10
10
  def call(*)
11
11
  end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami"
4
+ require "hanami/router/inspector"
5
+
6
+ module Hanami
7
+ module CLI
8
+ module Commands
9
+ module App
10
+ # Inspect the application routes
11
+ #
12
+ # All the formatters available from `hanami-router` are available:
13
+ #
14
+ # ```
15
+ # $ hanami routes --format=csv
16
+ # ```
17
+ #
18
+ # Experimental: You can also use a custom formatter registered in the
19
+ # application container. You can identify it by its key:
20
+ #
21
+ # ```
22
+ # $ hanami routes --format=custom_routes_formatter
23
+ # ```
24
+ class Routes < Hanami::CLI::Command
25
+ DEFAULT_FORMAT = "human_friendly"
26
+ private_constant :DEFAULT_FORMAT
27
+
28
+ VALID_FORMATS = [
29
+ DEFAULT_FORMAT,
30
+ "csv"
31
+ ].freeze
32
+ private_constant :VALID_FORMATS
33
+
34
+ desc "Inspect application"
35
+
36
+ option :format,
37
+ default: DEFAULT_FORMAT,
38
+ required: false,
39
+ desc: "Output format"
40
+
41
+ # @api private
42
+ def call(format: DEFAULT_FORMAT, **)
43
+ require "hanami/prepare"
44
+ inspector = Hanami::Router::Inspector.new(formatter: resolve_formatter(format))
45
+ app.router(inspector: inspector)
46
+ out.puts inspector.call
47
+ end
48
+
49
+ private
50
+
51
+ def resolve_formatter(format)
52
+ if VALID_FORMATS.include?(format)
53
+ resolve_formatter_from_hanami_router(format)
54
+ else
55
+ resolve_formatter_from_app(format)
56
+ end
57
+ end
58
+
59
+ def resolve_formatter_from_hanami_router(format)
60
+ case format
61
+ when "human_friendly"
62
+ require "hanami/router/formatter/human_friendly"
63
+ Hanami::Router::Formatter::HumanFriendly.new
64
+ when "csv"
65
+ require "hanami/router/formatter/csv"
66
+ Hanami::Router::Formatter::CSV.new
67
+ end
68
+ end
69
+
70
+ # Experimental
71
+ def resolve_formatter_from_app(format)
72
+ app[format]
73
+ end
74
+
75
+ def app
76
+ Hanami.app
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rack"
4
+ require_relative "../app"
5
+ require_relative "../../server"
6
+
7
+ module Hanami
8
+ module CLI
9
+ module Commands
10
+ module App
11
+ # Launch Hanami web server.
12
+ #
13
+ # It's intended to be used only on development. For production, you
14
+ # should use the rack handler command directly (i.e. `bundle exec puma
15
+ # -C config/puma.rb`).
16
+ #
17
+ # The server is just a thin wrapper on top of Rack::Server. The options that it
18
+ # accepts fall into two different categories:
19
+ #
20
+ # - When not explicitly set, port and host are not passed to the rack
21
+ # server instance. This way, they can be configured through the
22
+ # configured rack handler (e.g., the puma configuration file).
23
+ #
24
+ # - All others are always given by the Hanami command.
25
+ #
26
+ # Run `bundle exec hanami server -h` to see all the supported options.
27
+ class Server < Command
28
+ DEFAULT_PORT = 2300
29
+ private_constant :DEFAULT_PORT
30
+
31
+ desc "Start Hanami server"
32
+
33
+ option :host, default: nil, required: false,
34
+ desc: "The host address to bind to (falls back to the rack handler)"
35
+ option :port, default: DEFAULT_PORT, required: false,
36
+ desc: "The port to run the server on (falls back to the rack handler)"
37
+ option :config, default: "config.ru", required: false, desc: "Rack configuration file"
38
+ option :debug, default: false, required: false, desc: "Turn on/off debug output", type: :boolean
39
+ option :warn, default: false, required: false, desc: "Turn on/off warnings", type: :boolean
40
+
41
+ def initialize(server: Hanami::CLI::Server.new)
42
+ super()
43
+ @server = server
44
+ end
45
+
46
+ # @api private
47
+ def call(port: DEFAULT_PORT, **kwargs)
48
+ server.call(port: port, **kwargs)
49
+ end
50
+
51
+ private
52
+
53
+ attr_reader :server
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -5,7 +5,7 @@ require "hanami/cli/command"
5
5
  module Hanami
6
6
  module CLI
7
7
  module Commands
8
- module Monolith
8
+ module App
9
9
  class Version < Command
10
10
  def call(*)
11
11
  require "hanami/version"
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLI
5
+ module Commands
6
+ module App
7
+ require_relative "app/version"
8
+ require_relative "app/install"
9
+ require_relative "app/console"
10
+ require_relative "app/server"
11
+ require_relative "app/routes"
12
+ # require_relative "app/generate"
13
+ # require_relative "app/db/create"
14
+ # require_relative "app/db/create_migration"
15
+ # require_relative "app/db/drop"
16
+ # require_relative "app/db/migrate"
17
+ # require_relative "app/db/setup"
18
+ # require_relative "app/db/reset"
19
+ # require_relative "app/db/rollback"
20
+ # require_relative "app/db/sample_data"
21
+ # require_relative "app/db/seed"
22
+ # require_relative "app/db/structure/dump"
23
+ # require_relative "app/db/version"
24
+
25
+ def self.extended(base)
26
+ base.module_eval do
27
+ register "version", Commands::App::Version, aliases: ["v", "-v", "--version"]
28
+ register "install", Commands::App::Install
29
+ register "console", Commands::App::Console, aliases: ["c"]
30
+ register "server", Commands::App::Server, aliases: ["s"]
31
+ register "routes", Commands::App::Routes
32
+
33
+ # FIXME: temporary disabled for Hanami v2.0.0.alpha2
34
+ # register "install", Install
35
+
36
+ # FIXME: temporary disabled for Hanami v2.0.0.alpha2
37
+ # register "generate", aliases: ["g"] do |prefix|
38
+ # prefix.register "slice", Generate::Slice
39
+ # prefix.register "action", Generate::Action
40
+ # end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -8,7 +8,7 @@ module Hanami
8
8
  module DB
9
9
  module Utils
10
10
  class Database
11
- attr_reader :application, :config
11
+ attr_reader :app, :config
12
12
 
13
13
  SCHEME_MAP = {
14
14
  "sqlite" => -> {
@@ -29,8 +29,8 @@ module Hanami
29
29
  }
30
30
  }.freeze
31
31
 
32
- def self.[](application)
33
- config = DatabaseConfig.new(application.settings.database_url)
32
+ def self.[](app)
33
+ config = DatabaseConfig.new(app.settings.database_url)
34
34
 
35
35
  resolver = SCHEME_MAP.fetch(config.db_type) do
36
36
  raise "#{config.db_type} is not a supported db scheme"
@@ -38,11 +38,11 @@ module Hanami
38
38
 
39
39
  klass = resolver.()
40
40
 
41
- klass.new(application: application, config: config)
41
+ klass.new(app: app, config: config)
42
42
  end
43
43
 
44
- def initialize(application:, config:)
45
- @application = application
44
+ def initialize(app:, config:)
45
+ @app = app
46
46
  @config = config
47
47
  end
48
48
 
@@ -63,14 +63,14 @@ module Hanami
63
63
  end
64
64
 
65
65
  def root_path
66
- application.root
66
+ app.root
67
67
  end
68
68
 
69
69
  def rom_config
70
70
  @rom_config ||=
71
71
  begin
72
- application.prepare(:persistence)
73
- application.container["persistence.config"]
72
+ app.prepare(:persistence)
73
+ app.container["persistence.config"]
74
74
  end
75
75
  end
76
76
 
@@ -109,7 +109,7 @@ module Hanami
109
109
 
110
110
  def sequel_migrator
111
111
  @sequel_migrator ||= begin
112
- require 'sequel'
112
+ require "sequel"
113
113
  Sequel.extension :migration
114
114
  Sequel::TimestampMigrator.new(migrator.connection, migrations_path, {})
115
115
  end
@@ -3,51 +3,49 @@
3
3
  require "hanami/cli/command"
4
4
  require "hanami/cli/bundler"
5
5
  require "hanami/cli/command_line"
6
- require "hanami/cli/generators/gem/application"
6
+ require "hanami/cli/generators/gem/app"
7
7
  require "dry/files"
8
+ require "dry/inflector"
8
9
 
9
10
  module Hanami
10
11
  module CLI
11
12
  module Commands
12
13
  module Gem
13
14
  class New < Command
14
- ARCHITECTURES = %w[monolith micro].freeze
15
- private_constant :ARCHITECTURES
16
-
17
- DEFAULT_ARCHITECTURE = ARCHITECTURES.first
18
- private_constant :DEFAULT_ARCHITECTURE
19
-
20
- DEFAULT_SLICE_NAME = "main"
21
- private_constant :DEFAULT_SLICE_NAME
22
-
23
- DEFAULT_SLICE_URL_PREFIX = "/"
24
- private_constant :DEFAULT_SLICE_URL_PREFIX
25
-
26
- argument :app, required: true, desc: "The application name"
27
-
28
- option :architecture, alias: "arch", default: DEFAULT_ARCHITECTURE,
29
- values: ARCHITECTURES, desc: "The architecture"
30
-
31
- option :slice, default: DEFAULT_SLICE_NAME, desc: %(The initial slice name, only for "monolith" architecture)
32
- option :slice_url_prefix, default: DEFAULT_SLICE_URL_PREFIX,
33
- desc: %(The initial slice URL prefix, only for "monolith" architecture)
34
-
35
- def initialize(fs: Dry::Files.new, bundler: CLI::Bundler.new(fs: fs),
36
- command_line: CLI::CommandLine.new(bundler: bundler), **other)
15
+ SKIP_BUNDLE_DEFAULT = false
16
+ private_constant :SKIP_BUNDLE_DEFAULT
17
+
18
+ argument :app, required: true, desc: "App name"
19
+
20
+ option :skip_bundle, type: :boolean, required: false,
21
+ default: SKIP_BUNDLE_DEFAULT, desc: "Skip bundle install"
22
+
23
+ # rubocop:disable Metrics/ParameterLists
24
+ def initialize(
25
+ fs: Dry::Files.new,
26
+ inflector: Dry::Inflector.new,
27
+ bundler: CLI::Bundler.new(fs: fs),
28
+ command_line: CLI::CommandLine.new(bundler: bundler),
29
+ generator: Generators::Gem::App.new(fs: fs, inflector: inflector, command_line: command_line),
30
+ **other
31
+ )
37
32
  @bundler = bundler
38
33
  @command_line = command_line
39
- super(fs: fs, **other)
34
+ @generator = generator
35
+ super(fs: fs, inflector: inflector, **other)
40
36
  end
37
+ # rubocop:enable Metrics/ParameterLists
41
38
 
42
- def call(app:, architecture: DEFAULT_ARCHITECTURE, slice: DEFAULT_SLICE_NAME,
43
- slice_url_prefix: DEFAULT_SLICE_URL_PREFIX, **)
39
+ def call(app:, skip_bundle: SKIP_BUNDLE_DEFAULT, **)
44
40
  app = inflector.underscore(app)
45
41
 
46
42
  fs.mkdir(app)
47
43
  fs.chdir(app) do
48
- generator(architecture).call(app, slice, slice_url_prefix) do
49
- bundler.install!
50
- run_install_commmand!
44
+ generator.call(app) do
45
+ unless skip_bundle
46
+ bundler.install!
47
+ run_install_commmand!
48
+ end
51
49
  end
52
50
  end
53
51
  end
@@ -56,14 +54,7 @@ module Hanami
56
54
 
57
55
  attr_reader :bundler
58
56
  attr_reader :command_line
59
-
60
- def generator(architecture)
61
- unless ARCHITECTURES.include?(architecture)
62
- raise ArgumentError.new("unknown architecture `#{architecture}'")
63
- end
64
-
65
- Generators::Gem::Application[architecture, fs, inflector, command_line]
66
- end
57
+ attr_reader :generator
67
58
 
68
59
  def run_install_commmand!
69
60
  command_line.call("hanami install").tap do |result|
@@ -8,8 +8,28 @@ module Hanami
8
8
  module Gem
9
9
  class Version < Command
10
10
  def call(*)
11
+ version = detect_version
12
+ out.puts "v#{version}"
13
+ end
14
+
15
+ private
16
+
17
+ def detect_version
18
+ hanami_version ||
19
+ hanami_cli_version
20
+ end
21
+
22
+ def hanami_version
11
23
  require "hanami/version"
12
- out.puts "v#{Hanami::VERSION}"
24
+
25
+ Hanami::VERSION
26
+ rescue LoadError # rubocop:disable Lint/SuppressedException
27
+ end
28
+
29
+ def hanami_cli_version
30
+ require "hanami/cli/version"
31
+
32
+ Hanami::CLI::VERSION
13
33
  end
14
34
  end
15
35
  end
@@ -5,14 +5,12 @@ module Hanami
5
5
  module Commands
6
6
  module Gem
7
7
  require_relative "gem/version"
8
- # FIXME: temporary disabled for Hanami v2.0.0.alpha2
9
- # require_relative "gem/new"
8
+ require_relative "gem/new"
10
9
 
11
10
  def self.extended(base)
12
11
  base.module_eval do
13
12
  register "version", Version, aliases: ["v", "-v", "--version"]
14
- # FIXME: temporary disabled for Hanami v2.0.0.alpha2
15
- # register "new", New
13
+ register "new", New
16
14
  end
17
15
  end
18
16
  end
@@ -1,20 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hanami
4
- # TODO: move elsewhere
5
- def self.architecture
6
- return :monolith if File.exist?("config/application.rb")
7
- end
8
-
9
4
  module CLI
5
+ def self.within_hanami_app?
6
+ File.exist?("config/app.rb") ||
7
+ File.exist?("app.rb")
8
+ end
9
+
10
10
  module Commands
11
11
  end
12
12
 
13
- def self.register_commands!(architecture = Hanami.architecture)
14
- commands = case architecture
15
- when :monolith
16
- require_relative "commands/monolith"
17
- Commands::Monolith
13
+ def self.register_commands!(within_hanami_app = Hanami::CLI.within_hanami_app?)
14
+ commands = if within_hanami_app
15
+ require_relative "commands/app"
16
+ Commands::App
18
17
  else
19
18
  require_relative "commands/gem"
20
19
  Commands::Gem
@@ -2,13 +2,13 @@
2
2
 
3
3
  require "erb"
4
4
  require "dry/files"
5
- require "hanami/cli/generators/monolith/action_context"
5
+ require "hanami/cli/generators/app/action_context"
6
6
  require "hanami/cli/url"
7
7
 
8
8
  module Hanami
9
9
  module CLI
10
10
  module Generators
11
- module Monolith
11
+ module App
12
12
  class Action
13
13
  def initialize(fs:, inflector:)
14
14
  @fs = fs
@@ -6,7 +6,7 @@ require "dry/files/path"
6
6
  module Hanami
7
7
  module CLI
8
8
  module Generators
9
- module Monolith
9
+ module App
10
10
  class ActionContext < SliceContext
11
11
  def initialize(inflector, slice, controller, action)
12
12
  @controller = controller
@@ -2,12 +2,12 @@
2
2
 
3
3
  require "erb"
4
4
  require "dry/files"
5
- require "hanami/cli/generators/monolith/slice_context"
5
+ require "hanami/cli/generators/app/slice_context"
6
6
 
7
7
  module Hanami
8
8
  module CLI
9
9
  module Generators
10
- module Monolith
10
+ module App
11
11
  class Slice
12
12
  def initialize(fs:, inflector:)
13
13
  @fs = fs
@@ -5,7 +5,7 @@ require_relative "../context"
5
5
  module Hanami
6
6
  module CLI
7
7
  module Generators
8
- module Monolith
8
+ module App
9
9
  class SliceContext < Generators::Context
10
10
  def initialize(inflector, app, slice, slice_url_prefix)
11
11
  @slice = slice
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "hanami/version"
3
+ require_relative "./version"
4
4
 
5
5
  module Hanami
6
6
  module CLI
@@ -16,7 +16,7 @@ module Hanami
16
16
  end
17
17
 
18
18
  def hanami_version
19
- Hanami::Version.gem_requirement
19
+ Version.gem_requirement
20
20
  end
21
21
 
22
22
  def classified_app_name
@@ -1,9 +1,9 @@
1
1
  # auto_register: false
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "hanami/action"
5
+
4
6
  module <%= classified_app_name %>
5
- module Entities
7
+ class Action < Hanami::Action
6
8
  end
7
9
  end
8
-
9
- Dir[File.join(__dir__, "entities", "*.rb")].each(&method(:require))
@@ -3,6 +3,6 @@
3
3
  require "hanami"
4
4
 
5
5
  module <%= classified_app_name %>
6
- class Application < Hanami::Application
6
+ class App < Hanami::App
7
7
  end
8
8
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+
7
+ gem "hanami-router", "<%= hanami_version %>"
8
+ gem "hanami-controller", "<%= hanami_version %>"
9
+ gem "hanami", "<%= hanami_version %>"
10
+
11
+ gem "puma"
12
+
13
+ group :cli, :development, :test do
14
+ gem "hanami-rspec"
15
+ end
@@ -0,0 +1,9 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ require "hanami/operation"
5
+
6
+ module <%= classified_app_name %>
7
+ class Operation < Hanami::Operation
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/rake_tasks"
@@ -0,0 +1,7 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ module <%= classified_app_name %>
5
+ class Relation < Hanami::Relation
6
+ end
7
+ end