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

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.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26744ec7cba96a8251cd90d9589a9d0f0e291b4221af53ce951f584ced1b00c6
4
- data.tar.gz: 68c47e62e9c8fc493beee084c2815b57f9b57605bcd9bba7762a124cf16a0ba3
3
+ metadata.gz: 8d2d0f04510c5ac3d7c729c2830997ec692f9d9be7161b199cf87fcfd1284cf3
4
+ data.tar.gz: 970de26f0dfdaba799141c24b72ea84ab94721d378f62c3bbbfe494e9a63c3bd
5
5
  SHA512:
6
- metadata.gz: c2a419226b3050ef5fa6dc9281e3d81e16c19e905de8148f4c560fcc47687ee0e872b448a61f07b72c460bf8f993b66f4fcddec8b1d3915afd4a3129f79e6c82
7
- data.tar.gz: edfbff76a5d55b406b3d3886e5f5a315716044c6ac59bbe132dda837dcf8ad8df3ce4f98110ff0c72af1c9458ba8a870e95e3ac204a6021ccf791311384d5fd5
6
+ metadata.gz: 5dab4fa87022146327320394b66cdd8efb18ca9c2f98eb743bc65f38017a5904a0f06db3d45aca5990e51fac27868f0e9c026feab80639bf97791353670a219b
7
+ data.tar.gz: 594c4c1f6fa03910543700dbcfa0ff16f5be462cc4f39b19c9918d66de3b071beeb9e8b187ae39d3f55285296126d1378a188cd87b08d575d00d9ef1a0b21ffd
data/CHANGELOG.md CHANGED
@@ -1,46 +1,71 @@
1
1
  # Hanami::CLI
2
+
2
3
  Hanami Command Line Interface
3
4
 
4
- ## v2.0.0.alpha8.1 - 2020-05-23
5
+ ## v2.0.0.beta1 - 2022-07-20
6
+
7
+ ### Added
8
+
9
+ - [Luca Guidi] Implemented `hanami new` to generate a new Hanami app
10
+ - [Piotr Solnica] Implemented `hanami console` to start an interactive console (REPL)
11
+ - [Marc Busque] Implemented `hanami server` to start a HTTP server based on Rack
12
+ - [Marc Busque] Implemented `hanami routes` to print app routes
13
+ - [Luca Guidi] Implemented `hanami version` to print app Hanami version
14
+
15
+ ## v2.0.0.alpha8.1 - 2022-05-23
5
16
 
6
17
  ### Fixed
18
+
7
19
  - [Tim Riley] Ensure CLI starts properly by fixing use of `Slice.slice_name`
8
20
 
9
- ## v2.0.0.alpha8 - 2020-05-19
21
+ ## v2.0.0.alpha8 - 2022-05-19
10
22
 
11
23
  ### Fixed
24
+
12
25
  - [Andrew Croome] Respect HANAMI_ENV env var to set Hanami env if no `--env` option is supplied
13
26
  - [Lucas Mendelowski] Ensure Sequel migrations extension is loaded before related `db` commands are run
14
27
 
15
28
  ## v2.0.0.alpha7 - 2022-03-11
16
29
 
17
30
  ### Changed
31
+
18
32
  - [Tim Riley] [Internal] Update console slice readers to work with new `Hanami::Application.slices` API
19
33
 
20
34
  ## v2.0.0.alpha6.1 - 2022-02-11
35
+
21
36
  ### Fixed
37
+
22
38
  - [Viet Tran] Ensure `hanami db` commands to work with `hanami` `v2.0.0.alpha6`
23
39
 
24
40
  ## v2.0.0.alpha6 - 2022-02-10
41
+
25
42
  ### Added
43
+
26
44
  - [Luca Guidi] Official support for Ruby: MRI 3.1
27
45
 
28
46
  ### Changed
47
+
29
48
  - [Luca Guidi] Drop support for Ruby: MRI 2.6, and 2.7
30
49
 
31
50
  ## v2.0.0.alpha4 - 2021-12-07
51
+
32
52
  ### Added
53
+
33
54
  - [Tim Riley] Display a custom prompt when using irb-based console (consistent with pry-based console)
34
55
  - [Phil Arndt] Support `postgresql://` URL schemes (in addition to existing `postgres://` support) for `db` subcommands
35
56
 
36
57
  ### Fixed
58
+
37
59
  - [Tim Riley] Ensure slice helper methods work in console (e.g. top-level `main` method will return `Main::Slice` if an app has a "main" slice defined)
38
60
 
39
61
  ## v2.0.0.alpha3 - 2021-11-09
62
+
40
63
  No changes.
41
64
 
42
65
  ## v2.0.0.alpha2 - 2021-05-04
66
+
43
67
  ### Added
68
+
44
69
  - [Luca Guidi] Official support for Ruby: MRI 3.0
45
70
  - [Luca Guidi] Dynamically change the set of available commands depending on the context (outside or inside an Hanami app)
46
71
  - [Luca Guidi] Dynamically change the set of available commands depending on Hanami app architecture
@@ -49,32 +74,41 @@ No changes.
49
74
  - [Piotr Solnica] Implemented `console` command with support for `IRB` and `Pry` (`pry` is auto-detected)
50
75
 
51
76
  ### Changed
77
+
52
78
  - [Luca Guidi] Changed the purpose of this gem: the CLI Ruby framework has been extracted into `dry-cli` gem. `hanami-cli` is now the `hanami` command line.
53
79
  - [Luca Guidi] Drop support for Ruby: MRI 2.5.
54
80
 
55
81
  ## v1.0.0.alpha1 - 2019-01-30
82
+
56
83
  ### Added
84
+
57
85
  - [Luca Guidi] Inheritng from subclasses of `Hanami::CLI::Command`, allows to inherit arguments, options, description, and examples.
58
86
  - [Luca Guidi] Allow to use `super` from `#call`
59
87
 
60
88
  ### Changed
89
+
61
90
  - [Luca Guidi] Drop support for Ruby: MRI 2.3, and 2.4.
62
91
 
63
92
  ## v0.3.1 - 2019-01-18
93
+
64
94
  ### Added
95
+
65
96
  - [Luca Guidi] Official support for Ruby: MRI 2.6
66
97
  - [Luca Guidi] Support `bundler` 2.0+
67
98
 
68
99
  ## v0.3.0 - 2018-10-24
69
100
 
70
101
  ## v0.3.0.beta1 - 2018-08-08
102
+
71
103
  ### Added
104
+
72
105
  - [Anton Davydov & Alfonso Uceda] Introduce array type for arguments (`foo exec test spec/bookshelf/entities spec/bookshelf/repositories`)
73
106
  - [Anton Davydov & Alfonso Uceda] Introduce array type for options (`foo generate config --apps=web,api`)
74
107
  - [Alfonso Uceda] Introduce variadic arguments (`foo run ruby:latest -- ruby -v`)
75
108
  - [Luca Guidi] Official support for JRuby 9.2.0.0
76
109
 
77
110
  ### Fixed
111
+
78
112
  - [Anton Davydov] Print informative message when unknown or wrong option is passed (`"test" was called with arguments "--framework=unknown"`)
79
113
 
80
114
  ## v0.2.0 - 2018-04-11
@@ -84,21 +118,29 @@ No changes.
84
118
  ## v0.2.0.rc1 - 2018-03-30
85
119
 
86
120
  ## v0.2.0.beta2 - 2018-03-23
121
+
87
122
  ### Added
123
+
88
124
  - [Anton Davydov & Luca Guidi] Support objects as callbacks
89
125
 
90
126
  ### Fixed
127
+
91
128
  - [Anton Davydov & Luca Guidi] Ensure callbacks' context of execution (aka `self`) to be the command that is being executed
92
129
 
93
130
  ## v0.2.0.beta1 - 2018-02-28
131
+
94
132
  ### Added
133
+
95
134
  - [Anton Davydov] Register `before`/`after` callbacks for commands
96
135
 
97
136
  ## v0.1.1 - 2018-02-27
137
+
98
138
  ### Added
139
+
99
140
  - [Luca Guidi] Official support for Ruby: MRI 2.5
100
141
 
101
142
  ### Fixed
143
+
102
144
  - [Alfonso Uceda] Ensure default values for arguments to be sent to commands
103
145
  - [Alfonso Uceda] Ensure to fail when a missing required argument isn't provider, but an option is provided instead
104
146
 
@@ -109,13 +151,18 @@ No changes.
109
151
  ## v0.1.0.beta3 - 2017-10-04
110
152
 
111
153
  ## v0.1.0.beta2 - 2017-10-03
154
+
112
155
  ### Added
156
+
113
157
  - [Alfonso Uceda] Allow default value for arguments
114
158
 
115
159
  ## v0.1.0.beta1 - 2017-08-11
160
+
116
161
  ### Added
162
+
117
163
  - [Alfonso Uceda, Luca Guidi] Commands banner and usage
118
164
  - [Alfonso Uceda] Added support for subcommands
165
+
119
166
  - [Alfonso Uceda] Validations for arguments and options
120
167
  - [Alfonso Uceda] Commands arguments and options
121
168
  - [Alfonso Uceda] Commands description
data/Gemfile CHANGED
@@ -8,9 +8,8 @@ unless ENV["CI"]
8
8
  gem "yard", require: false
9
9
  end
10
10
 
11
- gem "hanami", require: false, git: "https://github.com/hanami/hanami.git", branch: "main"
12
- gem "hanami-router", require: false, git: "https://github.com/hanami/router.git", branch: "main"
13
- gem "hanami-view", require: false, git: "https://github.com/hanami/view.git", branch: "main"
11
+ gem "hanami", require: false, github: "hanami/hanami", branch: :main
12
+ gem "hanami-router", github: "hanami/router", branch: :main
14
13
 
15
14
  gem "rack"
16
15
 
data/README.md CHANGED
@@ -2,23 +2,25 @@
2
2
 
3
3
  CLI commands for [full-stack Hanami applications](`https://github.com/hanami/hanami`).
4
4
 
5
- **NOTE**: For versions 0.4 and below, there was a general purpose CLI utility library with this same name. That library has since been renamed to [dry-rb/cli](https://github.com/dry-rb/dry-cli). Please update your Gemfiles accordingly.
5
+ **NOTE**: For versions 0.4 and below, there was a general purpose CLI utility library with this same name. That library has since been renamed to [dry-rb/dry-cli](https://github.com/dry-rb/dry-cli). Please update your Gemfiles accordingly.
6
6
 
7
- ## Installation
7
+ ## Status
8
8
 
9
- Add this line to your application's Gemfile:
9
+ [![Gem Version](https://badge.fury.io/rb/hanami-cli.svg)](https://badge.fury.io/rb/hanami-cli)
10
+ [![CI](https://github.com/hanami/cli/workflows/ci/badge.svg?branch=main)](https://github.com/hanami/cli/actions?query=workflow%3Aci+branch%3Amain)
11
+ [![Depfu](https://badges.depfu.com/badges/a8545fb67cf32a2c75b6227bc0821027/overview.svg)](https://depfu.com/github/hanami/cli?project=Bundler)
10
12
 
11
- ```ruby
12
- gem 'hanami-cli'
13
- ```
13
+ ## Contact
14
14
 
15
- And then execute:
15
+ - Home page: http://hanamirb.org
16
+ - Mailing List: http://hanamirb.org/mailing-list
17
+ - Bugs/Issues: https://github.com/hanami/cli/issues
18
+ - Support: http://stackoverflow.com/questions/tagged/hanami
19
+ - Chat: http://chat.hanamirb.org
16
20
 
17
- $ bundle install
21
+ ## Rubies
18
22
 
19
- Or install it yourself as:
20
-
21
- $ gem install hanami-cli
23
+ **Hanami::RSpec** supports Ruby (MRI) 3.0+
22
24
 
23
25
  ## Usage
24
26
 
data/hanami-cli.gemspec CHANGED
@@ -32,10 +32,11 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_dependency "bundler", "~> 2.1"
34
34
  spec.add_dependency "rake", "~> 13.0"
35
- spec.add_dependency "dry-cli", "~> 0.6"
36
- spec.add_dependency "dry-files", "~> 0.1"
35
+ spec.add_dependency "dry-cli", "~> 0.7"
36
+ spec.add_dependency "dry-files", "~> 0.2", ">= 0.2.0"
37
37
  spec.add_dependency "dry-inflector", "~> 0.2"
38
38
 
39
39
  spec.add_development_dependency "rspec", "~> 3.9"
40
40
  spec.add_development_dependency "rubocop", "~> 1.0"
41
+ spec.add_development_dependency "puma"
41
42
  end
@@ -16,7 +16,7 @@ module Hanami
16
16
  private_constant :DEFAULT_GEMFILE_PATH
17
17
 
18
18
  def self.require(*groups)
19
- return unless File.exist?(ENV[BUNDLE_GEMFILE] || DEFAULT_GEMFILE_PATH)
19
+ return unless File.exist?(ENV.fetch(BUNDLE_GEMFILE) { DEFAULT_GEMFILE_PATH })
20
20
 
21
21
  ::Bundler.require(*groups)
22
22
  end
@@ -57,13 +57,9 @@ module Hanami
57
57
 
58
58
  # Adapted from https://stackoverflow.com/a/5471032/498386
59
59
  def which(cmd)
60
- exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
61
-
62
60
  ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
63
- exts.each do |ext|
64
- exe = fs.join(path, "#{cmd}#{ext}")
65
- return exe if fs.executable?(exe) && !fs.directory?(exe)
66
- end
61
+ exe = fs.join(path, cmd)
62
+ return exe if fs.executable?(exe) && !fs.directory?(exe)
67
63
  end
68
64
 
69
65
  nil
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/files"
4
+ require_relative "../db/utils/database"
5
+
6
+ module Hanami
7
+ module CLI
8
+ module Commands
9
+ module App
10
+ class Command < Hanami::CLI::Command
11
+ module Environment
12
+ def call(**opts)
13
+ env = opts[:env]
14
+
15
+ hanami_env = env ? env.to_s : ENV.fetch("HANAMI_ENV", "development")
16
+
17
+ ENV["HANAMI_ENV"] = hanami_env
18
+
19
+ super(**opts)
20
+ end
21
+ end
22
+
23
+ def self.inherited(klass)
24
+ super
25
+ klass.option(:env, required: false, desc: "App's environment")
26
+ klass.prepend(Environment)
27
+ end
28
+
29
+ def app
30
+ @app ||=
31
+ begin
32
+ require "hanami/prepare"
33
+ Hanami.app
34
+ end
35
+ end
36
+
37
+ def run_command(klass, *args)
38
+ klass.new(
39
+ out: out,
40
+ inflector: app.inflector,
41
+ fs: Dry::Files
42
+ ).call(*args)
43
+ end
44
+
45
+ def measure(desc)
46
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
47
+ result = yield
48
+ stop = Process.clock_gettime(Process::CLOCK_MONOTONIC)
49
+
50
+ if result
51
+ out.puts "=> #{desc} in #{(stop - start).round(4)}s"
52
+ else
53
+ out.puts "!!! => #{desc.inspect} FAILED"
54
+ end
55
+ end
56
+
57
+ def database
58
+ @database ||= Commands::DB::Utils::Database[app]
59
+ end
60
+
61
+ def database_config
62
+ database.config
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -2,14 +2,14 @@
2
2
 
3
3
  require "hanami/console/context"
4
4
 
5
- require_relative "../application"
5
+ require_relative "../app/command"
6
6
 
7
7
  module Hanami
8
8
  module CLI
9
9
  module Commands
10
- module Monolith
10
+ module App
11
11
  # @api public
12
- class Console < Application
12
+ class Console < App::Command
13
13
  REPLS = {
14
14
  "pry" => -> (*args) {
15
15
  begin
@@ -23,7 +23,7 @@ module Hanami
23
23
  },
24
24
  }.freeze
25
25
 
26
- desc "Application REPL"
26
+ desc "App REPL"
27
27
 
28
28
  option :repl, required: false, desc: "REPL gem that should be used ('pry' or 'irb')"
29
29
 
@@ -37,9 +37,9 @@ module Hanami
37
37
 
38
38
  def resolve_engine(repl, opts)
39
39
  if repl
40
- REPLS.fetch(repl).(application, opts)
40
+ REPLS.fetch(repl).(app, opts)
41
41
  else
42
- REPLS.map { |(_, loader)| loader.(application, opts) }.compact.first
42
+ REPLS.map { |(_, loader)| loader.(app, opts) }.compact.first
43
43
  end
44
44
  end
45
45
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
 
5
5
  module Hanami
6
6
  module CLI
7
7
  module Commands
8
- module Monolith
8
+ module App
9
9
  module DB
10
- class Create < Application
10
+ class Create < App::Command
11
11
  desc "Create database"
12
12
 
13
13
  def call(**)
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
  require_relative "structure/dump"
5
5
 
6
6
  module Hanami
7
7
  module CLI
8
8
  module Commands
9
- module Monolith
9
+ module App
10
10
  module DB
11
- class CreateMigration < Application
11
+ class CreateMigration < App::Command
12
12
  desc "Create new migration file"
13
13
 
14
14
  argument :name, desc: "Migration file name"
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
 
5
5
  module Hanami
6
6
  module CLI
7
7
  module Commands
8
- module Monolith
8
+ module App
9
9
  module DB
10
- class Drop < Application
10
+ class Drop < App::Command
11
11
  desc "Delete database"
12
12
 
13
13
  def call(**)
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
  require_relative "structure/dump"
5
5
 
6
6
  module Hanami
7
7
  module CLI
8
8
  module Commands
9
- module Monolith
9
+ module App
10
10
  module DB
11
- class Migrate < Application
11
+ class Migrate < App::Command
12
12
  desc "Migrates database"
13
13
 
14
14
  option :target, desc: "Target migration number", aliases: ["-t"]
15
15
 
16
16
  def call(target: nil, **)
17
- return true if Dir[File.join(application.root, "db/migrate/*.rb")].empty?
17
+ return true if Dir[File.join(app.root, "db/migrate/*.rb")].empty?
18
18
 
19
19
  measure "database #{database.name} migrated" do
20
20
  if target
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
  require_relative "create"
5
5
  require_relative "drop"
6
6
  require_relative "migrate"
@@ -8,9 +8,9 @@ require_relative "migrate"
8
8
  module Hanami
9
9
  module CLI
10
10
  module Commands
11
- module Monolith
11
+ module App
12
12
  module DB
13
- class Reset < Application
13
+ class Reset < App::Command
14
14
  desc "Drop, create, and migrate database"
15
15
 
16
16
  def call(**)
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
  require_relative "structure/dump"
5
5
 
6
6
  module Hanami
7
7
  module CLI
8
8
  module Commands
9
- module Monolith
9
+ module App
10
10
  module DB
11
- class Rollback < Application
11
+ class Rollback < App::Command
12
12
  desc "Rollback database to a previous migration"
13
13
 
14
14
  option :target, desc: "Target migration number", aliases: ["-t"]
@@ -32,7 +32,7 @@ module Hanami
32
32
  private
33
33
 
34
34
  def find_migration(code)
35
- migration = database.applied_migrations.yield_self { |migrations|
35
+ migration = database.applied_migrations.then { |migrations|
36
36
  if code
37
37
  migrations.detect { |m| m.split("_").first == code }
38
38
  else
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
  require_relative "structure/dump"
5
5
 
6
6
  module Hanami
7
7
  module CLI
8
8
  module Commands
9
- module Monolith
9
+ module App
10
10
  module DB
11
- class SampleData < Application
11
+ class SampleData < App::Command
12
12
  FILE_PATH = "db/sample_data.rb"
13
13
 
14
14
  desc "Load sample data"
@@ -26,7 +26,7 @@ module Hanami
26
26
  private
27
27
 
28
28
  def full_file_path
29
- File.join(application.root, FILE_PATH)
29
+ File.join(app.root, FILE_PATH)
30
30
  end
31
31
 
32
32
  def has_file?
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
  require_relative "structure/dump"
5
5
 
6
6
  module Hanami
7
7
  module CLI
8
8
  module Commands
9
- module Monolith
9
+ module App
10
10
  module DB
11
- class Seed < Application
11
+ class Seed < App::Command
12
12
  FILE_PATH = "db/seeds.rb"
13
13
 
14
14
  desc "Load seed data"
@@ -26,7 +26,7 @@ module Hanami
26
26
  private
27
27
 
28
28
  def full_file_path
29
- File.join(application.root, FILE_PATH)
29
+ File.join(app.root, FILE_PATH)
30
30
  end
31
31
 
32
32
  def has_file?
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
  require_relative "create"
5
5
  require_relative "migrate"
6
6
 
7
7
  module Hanami
8
8
  module CLI
9
9
  module Commands
10
- module Monolith
10
+ module App
11
11
  module DB
12
- class Setup < Application
12
+ class Setup < App::Command
13
13
  desc "Setup database"
14
14
 
15
15
  def call(**)
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../../application"
3
+ require_relative "../../../app/command"
4
4
 
5
5
  module Hanami
6
6
  module CLI
7
7
  module Commands
8
- module Monolith
8
+ module App
9
9
  module DB
10
10
  module Structure
11
- class Dump < Application
11
+ class Dump < App::Command
12
12
  desc "Dumps database structure to db/structure.sql file"
13
13
 
14
14
  def call(*)
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../../application"
3
+ require_relative "../../app/command"
4
4
 
5
5
  module Hanami
6
6
  module CLI
7
7
  module Commands
8
- module Monolith
8
+ module App
9
9
  module DB
10
- class Version < Application
10
+ class Version < App::Command
11
11
  desc "Print schema version"
12
12
 
13
13
  option :target, desc: "Target migration number", aliases: ["-t"]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "hanami/cli/command"
4
- require "hanami/cli/generators/monolith/action"
4
+ require "hanami/cli/generators/app/action"
5
5
  require "dry/inflector"
6
6
  require "dry/files"
7
7
  require "shellwords"
@@ -9,7 +9,7 @@ require "shellwords"
9
9
  module Hanami
10
10
  module CLI
11
11
  module Commands
12
- module Monolith
12
+ module App
13
13
  module Generate
14
14
  class Action < Command
15
15
  # TODO: ideally the default format should lookup
@@ -29,7 +29,7 @@ module Hanami
29
29
  desc: "Skip view and template generation"
30
30
 
31
31
  def initialize(fs: Dry::Files.new, inflector: Dry::Inflector.new,
32
- generator: Generators::Monolith::Action.new(fs: fs, inflector: inflector), **)
32
+ generator: Generators::App::Action.new(fs: fs, inflector: inflector), **)
33
33
  @generator = generator
34
34
  super(fs: fs)
35
35
  end