hanami-cli 2.3.3 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +346 -225
- data/LICENSE +20 -0
- data/README.md +11 -20
- data/hanami-cli.gemspec +28 -30
- data/lib/hanami/cli/commands/app/assets/command.rb +1 -1
- data/lib/hanami/cli/commands/app/command.rb +3 -3
- data/lib/hanami/cli/commands/app/console.rb +1 -1
- data/lib/hanami/cli/commands/app/db/command.rb +3 -3
- data/lib/hanami/cli/commands/app/db/prepare.rb +1 -1
- data/lib/hanami/cli/commands/app/db/rollback.rb +6 -2
- data/lib/hanami/cli/commands/app/db/structure/dump.rb +1 -1
- data/lib/hanami/cli/commands/app/db/structure/load.rb +1 -1
- data/lib/hanami/cli/commands/app/db/utils/postgres.rb +2 -2
- data/lib/hanami/cli/commands/app/db/utils/sqlite.rb +3 -4
- data/lib/hanami/cli/commands/app/db/version.rb +1 -1
- data/lib/hanami/cli/commands/app/generate/action.rb +0 -2
- data/lib/hanami/cli/commands/app/generate/command.rb +2 -2
- data/lib/hanami/cli/commands/app/generate/component.rb +1 -1
- data/lib/hanami/cli/commands/app/generate/migration.rb +1 -1
- data/lib/hanami/cli/commands/app/generate/operation.rb +1 -1
- data/lib/hanami/cli/commands/app/generate/part.rb +1 -1
- data/lib/hanami/cli/commands/app/generate/relation.rb +1 -1
- data/lib/hanami/cli/commands/app/generate/repo.rb +1 -1
- data/lib/hanami/cli/commands/app/generate/slice.rb +1 -1
- data/lib/hanami/cli/commands/app/generate/struct.rb +1 -1
- data/lib/hanami/cli/commands/app/generate/view.rb +1 -1
- data/lib/hanami/cli/commands/app/install.rb +2 -0
- data/lib/hanami/cli/commands/app/middleware.rb +1 -1
- data/lib/hanami/cli/commands/app/routes.rb +1 -1
- data/lib/hanami/cli/commands/app/run.rb +10 -10
- data/lib/hanami/cli/commands/app.rb +1 -1
- data/lib/hanami/cli/commands/gem/new.rb +1 -4
- data/lib/hanami/cli/commands.rb +21 -12
- data/lib/hanami/cli/generators/app/action.rb +1 -3
- data/lib/hanami/cli/generators/app/component.rb +1 -1
- data/lib/hanami/cli/generators/app/migration.rb +1 -1
- data/lib/hanami/cli/generators/app/operation.rb +1 -1
- data/lib/hanami/cli/generators/app/relation.rb +1 -1
- data/lib/hanami/cli/generators/app/repo.rb +1 -1
- data/lib/hanami/cli/generators/app/ruby_file.rb +3 -3
- data/lib/hanami/cli/generators/app/slice.rb +4 -4
- data/lib/hanami/cli/generators/app/struct.rb +1 -1
- data/lib/hanami/cli/generators/app/view.rb +2 -2
- data/lib/hanami/cli/generators/constants.rb +1 -1
- data/lib/hanami/cli/ruby_file_generator.rb +1 -1
- data/lib/hanami/cli/version.rb +1 -1
- data/lib/hanami/console/plugins/unbooted_slice_warnings.rb +8 -0
- metadata +12 -79
- data/.github/FUNDING.yml +0 -1
- data/.github/workflows/ci.yml +0 -76
- data/.gitignore +0 -13
- data/.repobot.yml +0 -9
- data/.rspec +0 -2
- data/.rubocop.yml +0 -48
- data/.rubocop_todo.yml +0 -150
- data/.yardopts +0 -3
- data/CODE_OF_CONDUCT.md +0 -84
- data/Gemfile +0 -33
- data/LICENSE.md +0 -22
- data/Rakefile +0 -12
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/docker-compose.yml +0 -14
- data/project.yml +0 -2
- data/script/ci +0 -31
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2026 Hanakai team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
<!--- This file is synced from hanakai-rb/repo-sync -->
|
|
2
|
+
|
|
3
|
+
[rubygem]: https://rubygems.org/gems/hanami-cli
|
|
4
|
+
[actions]: https://github.com/hanami/hanami-cli/actions
|
|
5
|
+
|
|
6
|
+
# Hanami CLI [][rubygem] [][actions]
|
|
2
7
|
|
|
3
8
|
This library contains all of the CLI commands for [full-stack Hanami applications](`https://github.com/hanami/hanami`).
|
|
4
9
|
|
|
@@ -6,19 +11,6 @@ This library contains all of the CLI commands for [full-stack Hanami application
|
|
|
6
11
|
That library has since been renamed to [dry-rb/dry-cli](https://github.com/dry-rb/dry-cli).
|
|
7
12
|
Please update your Gemfiles accordingly.
|
|
8
13
|
|
|
9
|
-
## Status
|
|
10
|
-
|
|
11
|
-
[](https://badge.fury.io/rb/hanami-cli)
|
|
12
|
-
[](https://github.com/hanami/hanami-cli/actions?query=workflow%3Aci+branch%3Amain)
|
|
13
|
-
|
|
14
|
-
## Contact
|
|
15
|
-
|
|
16
|
-
- Home page: http://hanamirb.org
|
|
17
|
-
- Mailing List: http://hanamirb.org/mailing-list
|
|
18
|
-
- Bugs/Issues: https://github.com/hanami/cli/issues
|
|
19
|
-
- API Doc: http://rubydoc.info/gems/hanami-cli
|
|
20
|
-
- Chat: http://chat.hanamirb.org
|
|
21
|
-
|
|
22
14
|
## Installation
|
|
23
15
|
|
|
24
16
|
This library is a dependency of the main `hanami` gem, so installing that is the best way to get and use this gem.
|
|
@@ -37,14 +29,13 @@ In order to run all of the tests, you should run `docker compose up` separately,
|
|
|
37
29
|
|
|
38
30
|
Bug reports and pull requests are welcome on GitHub at https://github.com/hanami/cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/hanami/cli/blob/main/CODE_OF_CONDUCT.md).
|
|
39
31
|
|
|
40
|
-
##
|
|
32
|
+
## Links
|
|
41
33
|
|
|
42
|
-
|
|
34
|
+
- [User documentation](https://hanamirb.org)
|
|
35
|
+
- [API documentation](http://rubydoc.info/gems/hanami-cli)
|
|
43
36
|
|
|
44
|
-
## Code of Conduct
|
|
45
37
|
|
|
46
|
-
|
|
38
|
+
## License
|
|
47
39
|
|
|
48
|
-
|
|
40
|
+
See `LICENSE` file.
|
|
49
41
|
|
|
50
|
-
Copyright © 2014–2024 Hanami Team – Released under MIT License
|
data/hanami-cli.gemspec
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
|
|
4
|
+
|
|
5
|
+
lib = File.expand_path("lib", __dir__)
|
|
6
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
7
|
+
require "hanami/cli/version"
|
|
4
8
|
|
|
5
9
|
Gem::Specification.new do |spec|
|
|
6
10
|
spec.name = "hanami-cli"
|
|
7
|
-
spec.version = Hanami::CLI::VERSION
|
|
8
11
|
spec.authors = ["Hanakai team"]
|
|
9
12
|
spec.email = ["info@hanakai.org"]
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
spec.version = Hanami::CLI::VERSION.dup
|
|
10
15
|
|
|
11
|
-
spec.summary = "Hanami
|
|
12
|
-
spec.description =
|
|
16
|
+
spec.summary = "The CLI for the Hanami framework"
|
|
17
|
+
spec.description = spec.summary
|
|
13
18
|
spec.homepage = "https://hanamirb.org"
|
|
14
|
-
spec.
|
|
19
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "hanami-cli.gemspec", "lib/**/*"]
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = Dir["exe/*"].map { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
15
23
|
|
|
16
|
-
spec.
|
|
24
|
+
spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
|
|
17
25
|
|
|
18
|
-
spec.metadata["
|
|
19
|
-
spec.metadata["
|
|
20
|
-
spec.metadata["
|
|
26
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
27
|
+
spec.metadata["changelog_uri"] = "https://github.com/hanami/hanami-cli/blob/main/CHANGELOG.md"
|
|
28
|
+
spec.metadata["source_code_uri"] = "https://github.com/hanami/hanami-cli"
|
|
29
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/hanami/hanami-cli/issues"
|
|
30
|
+
spec.metadata["funding_uri"] = "https://github.com/sponsors/hanami"
|
|
21
31
|
|
|
22
|
-
# Specify which files should be added to the gem when it is released.
|
|
23
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
24
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
25
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
26
|
-
end
|
|
27
|
-
spec.bindir = "exe"
|
|
28
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
29
|
-
spec.require_paths = ["lib"]
|
|
30
|
-
spec.metadata["rubygems_mfa_required"] = "true"
|
|
31
32
|
spec.required_ruby_version = ">= 3.2"
|
|
32
33
|
|
|
33
|
-
spec.
|
|
34
|
-
spec.
|
|
35
|
-
spec.
|
|
36
|
-
spec.
|
|
37
|
-
spec.
|
|
38
|
-
spec.
|
|
39
|
-
spec.
|
|
40
|
-
spec.
|
|
41
|
-
|
|
42
|
-
spec.add_development_dependency "rspec", "~> 3.9"
|
|
43
|
-
spec.add_development_dependency "rubocop", "~> 1.0"
|
|
44
|
-
spec.add_development_dependency "puma"
|
|
34
|
+
spec.add_runtime_dependency "bundler", ">= 2.1"
|
|
35
|
+
spec.add_runtime_dependency "dry-cli", "~> 1.0", ">= 1.1.0"
|
|
36
|
+
spec.add_runtime_dependency "dry-files", "~> 1.0", ">= 1.0.2"
|
|
37
|
+
spec.add_runtime_dependency "dry-inflector", "~> 1.0"
|
|
38
|
+
spec.add_runtime_dependency "irb"
|
|
39
|
+
spec.add_runtime_dependency "rake", "~> 13.0"
|
|
40
|
+
spec.add_runtime_dependency "zeitwerk", "~> 2.6"
|
|
41
|
+
spec.add_runtime_dependency "rackup"
|
|
45
42
|
end
|
|
43
|
+
|
|
@@ -44,8 +44,8 @@ module Hanami
|
|
|
44
44
|
Hanami::Env.load
|
|
45
45
|
|
|
46
46
|
super
|
|
47
|
-
rescue FileAlreadyExistsError =>
|
|
48
|
-
err.puts(
|
|
47
|
+
rescue FileAlreadyExistsError => exception
|
|
48
|
+
err.puts(exception.message)
|
|
49
49
|
exit(1)
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -85,7 +85,7 @@ module Hanami
|
|
|
85
85
|
def run_command(klass, ...)
|
|
86
86
|
klass.new(
|
|
87
87
|
out: out,
|
|
88
|
-
fs: Hanami::CLI::Files
|
|
88
|
+
fs: Hanami::CLI::Files
|
|
89
89
|
).call(...)
|
|
90
90
|
end
|
|
91
91
|
|
|
@@ -42,7 +42,7 @@ module Hanami
|
|
|
42
42
|
fs: fs,
|
|
43
43
|
system_call: system_call,
|
|
44
44
|
test_env_executor: test_env_executor,
|
|
45
|
-
nested_command: true
|
|
45
|
+
nested_command: true
|
|
46
46
|
).call(...)
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -90,7 +90,7 @@ module Hanami
|
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
def all_databases # rubocop:disable Metrics/AbcSize
|
|
93
|
+
def all_databases # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
|
|
94
94
|
slices = [app] + app.slices.with_nested
|
|
95
95
|
|
|
96
96
|
slice_gateways_by_database_url = slices.each_with_object({}) { |slice, hsh|
|
|
@@ -117,7 +117,7 @@ module Hanami
|
|
|
117
117
|
system_call: system_call
|
|
118
118
|
)
|
|
119
119
|
|
|
120
|
-
warn_on_misconfigured_database
|
|
120
|
+
warn_on_misconfigured_database(database, slice_gateways_with_config.map { _1.fetch(:slice) })
|
|
121
121
|
|
|
122
122
|
arr << database
|
|
123
123
|
}
|
|
@@ -9,7 +9,7 @@ module Hanami
|
|
|
9
9
|
class Prepare < DB::Command
|
|
10
10
|
desc "Prepare databases"
|
|
11
11
|
|
|
12
|
-
def call(app: false, slice: nil, **)
|
|
12
|
+
def call(app: false, slice: nil, **) # rubocop:disable Metrics/AbcSize
|
|
13
13
|
command_exit = -> code { throw :command_exited, code }
|
|
14
14
|
command_exit_arg = {command_exit: command_exit}
|
|
15
15
|
|
|
@@ -16,6 +16,7 @@ module Hanami
|
|
|
16
16
|
option :dump, desc: "Dump structure after rolling back", default: true
|
|
17
17
|
option :gateway, required: false, desc: "Use database for gateway"
|
|
18
18
|
|
|
19
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
19
20
|
def call(
|
|
20
21
|
steps: nil,
|
|
21
22
|
app: false,
|
|
@@ -67,6 +68,7 @@ module Hanami
|
|
|
67
68
|
|
|
68
69
|
re_run_development_command_in_test
|
|
69
70
|
end
|
|
71
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
70
72
|
|
|
71
73
|
private
|
|
72
74
|
|
|
@@ -142,11 +144,11 @@ module Hanami
|
|
|
142
144
|
elsif app_databases.size > 1
|
|
143
145
|
err.puts "Multiple gateways found in app. Please specify --gateway option."
|
|
144
146
|
command_exit.(1)
|
|
145
|
-
|
|
147
|
+
nil
|
|
146
148
|
else
|
|
147
149
|
err.puts "Multiple database contexts found. Please specify --app or --slice option."
|
|
148
150
|
command_exit.(1)
|
|
149
|
-
|
|
151
|
+
nil
|
|
150
152
|
end
|
|
151
153
|
end
|
|
152
154
|
end
|
|
@@ -165,6 +167,7 @@ module Hanami
|
|
|
165
167
|
slice
|
|
166
168
|
end
|
|
167
169
|
|
|
170
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
168
171
|
def find_migration_target(target, steps_count, database)
|
|
169
172
|
applied_migrations = database.applied_migrations
|
|
170
173
|
|
|
@@ -195,6 +198,7 @@ module Hanami
|
|
|
195
198
|
|
|
196
199
|
[migration_code, migration_name]
|
|
197
200
|
end
|
|
201
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
198
202
|
|
|
199
203
|
def initial_state(applied_migrations)
|
|
200
204
|
migration = applied_migrations.first
|
|
@@ -14,7 +14,7 @@ module Hanami
|
|
|
14
14
|
option :gateway, required: false, desc: "Use database for gateway"
|
|
15
15
|
|
|
16
16
|
# @api private
|
|
17
|
-
def call(app: false, slice: nil, gateway: nil, command_exit: method(:exit), **)
|
|
17
|
+
def call(app: false, slice: nil, gateway: nil, command_exit: method(:exit), **) # rubocop:disable Metrics/AbcSize
|
|
18
18
|
exit_codes = []
|
|
19
19
|
|
|
20
20
|
databases(app: app, slice: slice, gateway: gateway).each do |database|
|
|
@@ -17,7 +17,7 @@ module Hanami
|
|
|
17
17
|
option :gateway, required: false, desc: "Use database for gateway"
|
|
18
18
|
|
|
19
19
|
# @api private
|
|
20
|
-
def call(app: false, slice: nil, gateway: nil, command_exit: method(:exit), **)
|
|
20
|
+
def call(app: false, slice: nil, gateway: nil, command_exit: method(:exit), **) # rubocop:disable Metrics/AbcSize
|
|
21
21
|
exit_codes = []
|
|
22
22
|
|
|
23
23
|
databases(app: app, slice: slice, gateway: gateway).each do |database|
|
|
@@ -15,7 +15,7 @@ module Hanami
|
|
|
15
15
|
class Postgres < Database
|
|
16
16
|
SCHEMA_DUMP_FILTERS = [
|
|
17
17
|
/^\\(un)?restrict/,
|
|
18
|
-
/^-- Dumped (from|by) (database version|pg_dump version)
|
|
18
|
+
/^-- Dumped (from|by) (database version|pg_dump version)/
|
|
19
19
|
].freeze
|
|
20
20
|
|
|
21
21
|
# @api private
|
|
@@ -86,7 +86,7 @@ module Hanami
|
|
|
86
86
|
Shellwords.escape(name)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
def cli_env_vars
|
|
89
|
+
def cli_env_vars # rubocop:disable Metrics/AbcSize
|
|
90
90
|
@cli_env_vars ||= {}.tap do |vars|
|
|
91
91
|
vars["PGHOST"] = database_uri.host.to_s if database_uri.host
|
|
92
92
|
vars["PGPORT"] = database_uri.port.to_s if database_uri.port
|
|
@@ -38,9 +38,9 @@ module Hanami
|
|
|
38
38
|
def exec_drop_command
|
|
39
39
|
begin
|
|
40
40
|
File.unlink(file_path) if exists?
|
|
41
|
-
rescue =>
|
|
41
|
+
rescue => exception # rubocop:disable Style/RescueStandardError
|
|
42
42
|
# Mimic a system_call result
|
|
43
|
-
return Failure.new(
|
|
43
|
+
return Failure.new(exception.message)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
true
|
|
@@ -76,13 +76,12 @@ module Hanami
|
|
|
76
76
|
private
|
|
77
77
|
|
|
78
78
|
def file_path
|
|
79
|
-
@file_path ||=
|
|
79
|
+
@file_path ||=
|
|
80
80
|
if File.absolute_path?(name)
|
|
81
81
|
name
|
|
82
82
|
else
|
|
83
83
|
slice.app.root.join(name).to_s
|
|
84
84
|
end
|
|
85
|
-
end
|
|
86
85
|
end
|
|
87
86
|
end
|
|
88
87
|
end
|
|
@@ -18,7 +18,7 @@ module Hanami
|
|
|
18
18
|
unless database.migrations_dir?
|
|
19
19
|
relative_migrations_path = database.migrations_path.relative_path_from(database.slice.app.root)
|
|
20
20
|
out.puts "=> Cannot find version for database #{database.name}: no migrations directory at #{relative_migrations_path}/"
|
|
21
|
-
return
|
|
21
|
+
return # rubocop:disable Lint/NonLocalExitFromIterator
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
migration = database.applied_migrations.last
|
|
@@ -78,7 +78,6 @@ module Hanami
|
|
|
78
78
|
|
|
79
79
|
# @since 2.0.0
|
|
80
80
|
# @api private
|
|
81
|
-
# rubocop:disable Metrics/ParameterLists
|
|
82
81
|
def call(
|
|
83
82
|
name:,
|
|
84
83
|
slice: nil,
|
|
@@ -102,7 +101,6 @@ module Hanami
|
|
|
102
101
|
skip_tests: skip_tests
|
|
103
102
|
)
|
|
104
103
|
end
|
|
105
|
-
# rubocop:enable Metrics/ParameterLists
|
|
106
104
|
end
|
|
107
105
|
end
|
|
108
106
|
end
|
|
@@ -43,7 +43,7 @@ module Hanami
|
|
|
43
43
|
key: name,
|
|
44
44
|
namespace: app.namespace,
|
|
45
45
|
base_path: "app",
|
|
46
|
-
**opts
|
|
46
|
+
**opts
|
|
47
47
|
)
|
|
48
48
|
return
|
|
49
49
|
end
|
|
@@ -55,7 +55,7 @@ module Hanami
|
|
|
55
55
|
key: name,
|
|
56
56
|
namespace: slice,
|
|
57
57
|
base_path: slice_root,
|
|
58
|
-
**opts
|
|
58
|
+
**opts
|
|
59
59
|
)
|
|
60
60
|
end
|
|
61
61
|
|
|
@@ -18,7 +18,7 @@ module Hanami
|
|
|
18
18
|
%(isbn_decoder (MyApp::IsbnDecoder)),
|
|
19
19
|
%(recommenders.fiction (MyApp::Recommenders::Fiction)),
|
|
20
20
|
%(isbn_decoder --slice=admin (Admin::IsbnDecoder)),
|
|
21
|
-
%(Exporters::Complete::CSV (MyApp::Exporters::Complete::CSV))
|
|
21
|
+
%(Exporters::Complete::CSV (MyApp::Exporters::Complete::CSV))
|
|
22
22
|
]
|
|
23
23
|
|
|
24
24
|
# @since 2.2.0
|
|
@@ -15,7 +15,7 @@ module Hanami
|
|
|
15
15
|
%(books (MyApp::Relation::Book)),
|
|
16
16
|
%(books/drafts (MyApp::Relations::Books::Drafts)),
|
|
17
17
|
%(books --slice=admin (Admin::Relations::Books)),
|
|
18
|
-
%(books --slice=admin --gateway=extra (Admin::Relations::Books))
|
|
18
|
+
%(books --slice=admin --gateway=extra (Admin::Relations::Books))
|
|
19
19
|
]
|
|
20
20
|
|
|
21
21
|
# @since 2.2.0
|
|
@@ -36,6 +36,7 @@ module Hanami
|
|
|
36
36
|
# @api private
|
|
37
37
|
private attr_reader :bundler
|
|
38
38
|
|
|
39
|
+
# rubocop:disable Lint/MissingSuper
|
|
39
40
|
def initialize(
|
|
40
41
|
fs:,
|
|
41
42
|
bundler: CLI::Bundler.new(fs: fs),
|
|
@@ -43,6 +44,7 @@ module Hanami
|
|
|
43
44
|
)
|
|
44
45
|
@bundler = bundler
|
|
45
46
|
end
|
|
47
|
+
# rubocop:enable Lint/MissingSuper
|
|
46
48
|
|
|
47
49
|
# @since 2.0.0
|
|
48
50
|
# @api private
|
|
@@ -38,7 +38,7 @@ module Hanami
|
|
|
38
38
|
|
|
39
39
|
example [
|
|
40
40
|
"middleware # Print app Rack middleware stack",
|
|
41
|
-
"middleware --with-arguments # Print app Rack middleware stack, including initialize arguments"
|
|
41
|
+
"middleware --with-arguments # Print app Rack middleware stack, including initialize arguments"
|
|
42
42
|
]
|
|
43
43
|
|
|
44
44
|
# @since 2.0.0
|
|
@@ -27,7 +27,7 @@ module Hanami
|
|
|
27
27
|
|
|
28
28
|
example [
|
|
29
29
|
"path/to/script.rb # Run a Ruby script in the context of the application",
|
|
30
|
-
"'puts Hanami.app[\"repos.user_repo\"].all.count' # Run inline Ruby code in the context of the application"
|
|
30
|
+
"'puts Hanami.app[\"repos.user_repo\"].all.count' # Run inline Ruby code in the context of the application"
|
|
31
31
|
]
|
|
32
32
|
|
|
33
33
|
argument :code_or_path, required: true, desc: "Path to a Ruby file or inline Ruby code to be executed"
|
|
@@ -48,15 +48,15 @@ module Hanami
|
|
|
48
48
|
validate_inline_code!(code_or_path)
|
|
49
49
|
begin
|
|
50
50
|
eval(code_or_path, binding, __FILE__, __LINE__) # rubocop:disable Security/Eval
|
|
51
|
-
rescue SyntaxError =>
|
|
52
|
-
err.puts "Syntax error in code: #{
|
|
53
|
-
raise RunError, "Syntax error in code: #{
|
|
54
|
-
rescue NameError =>
|
|
55
|
-
err.puts "Name error in code: #{
|
|
56
|
-
raise RunError, "Name error in code: #{
|
|
57
|
-
rescue StandardError =>
|
|
58
|
-
err.puts "Error executing code: #{
|
|
59
|
-
raise RunError, "Error executing code: #{
|
|
51
|
+
rescue SyntaxError => exception
|
|
52
|
+
err.puts "Syntax error in code: #{exception.message}"
|
|
53
|
+
raise RunError, "Syntax error in code: #{exception.message}"
|
|
54
|
+
rescue NameError => exception
|
|
55
|
+
err.puts "Name error in code: #{exception.message}"
|
|
56
|
+
raise RunError, "Name error in code: #{exception.message}"
|
|
57
|
+
rescue StandardError => exception
|
|
58
|
+
err.puts "Error executing code: #{exception.class}: #{exception.message}"
|
|
59
|
+
raise RunError, "Error executing code: #{exception.class}: #{exception.message}"
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
rescue RunError
|
|
@@ -10,7 +10,7 @@ module Hanami
|
|
|
10
10
|
module App
|
|
11
11
|
# @since 2.0.0
|
|
12
12
|
# @api private
|
|
13
|
-
def self.extended(base)
|
|
13
|
+
def self.extended(base) # rubocop:disable Metrics/AbcSize
|
|
14
14
|
base.module_eval do
|
|
15
15
|
register "version", Commands::App::Version, aliases: ["v", "-v", "--version"]
|
|
16
16
|
register "install", Commands::App::Install
|
|
@@ -116,12 +116,10 @@ module Hanami
|
|
|
116
116
|
"bookshelf --skip-assets # Generate a new Hanami app without hanami-assets",
|
|
117
117
|
"bookshelf --skip-db # Generate a new Hanami app without hanami-db",
|
|
118
118
|
"bookshelf --skip-view # Generate a new Hanami app without hanami-view",
|
|
119
|
-
"bookshelf --database={sqlite|postgres|mysql} # Generate a new Hanami app with a specified database (default: sqlite)"
|
|
119
|
+
"bookshelf --database={sqlite|postgres|mysql} # Generate a new Hanami app with a specified database (default: sqlite)"
|
|
120
120
|
]
|
|
121
121
|
# rubocop:enable Layout/LineLength
|
|
122
122
|
|
|
123
|
-
# rubocop:disable Metrics/ParameterLists
|
|
124
|
-
|
|
125
123
|
# @since 2.0.0
|
|
126
124
|
# @api private
|
|
127
125
|
def initialize(
|
|
@@ -151,7 +149,6 @@ module Hanami
|
|
|
151
149
|
skip_view: SKIP_VIEW_DEFAULT,
|
|
152
150
|
database: nil
|
|
153
151
|
)
|
|
154
|
-
# rubocop:enable Metrics/ParameterLists
|
|
155
152
|
app = inflector.underscore(app)
|
|
156
153
|
|
|
157
154
|
raise PathAlreadyExistsError.new(app) if fs.exist?(app)
|
data/lib/hanami/cli/commands.rb
CHANGED
|
@@ -15,12 +15,20 @@ module Hanami
|
|
|
15
15
|
require "hanami"
|
|
16
16
|
|
|
17
17
|
!!Hanami.app_path
|
|
18
|
-
rescue LoadError =>
|
|
19
|
-
|
|
18
|
+
rescue LoadError => exception
|
|
19
|
+
# Only rescue:
|
|
20
|
+
#
|
|
21
|
+
# 1. LoadError, due to hanami itself being missing, or
|
|
22
|
+
# 2. Gem::LoadError, indicating gem version conflicts or other gem-related issues while
|
|
23
|
+
# loading hanami.
|
|
24
|
+
#
|
|
25
|
+
# This allows us to work around global gem version conflicts (e.g. with gems like bigdecimal,
|
|
26
|
+
# which can come bundled with Ruby while also being upgraded independently) while still
|
|
27
|
+
# raising errors for other missing requires.
|
|
28
|
+
raise exception unless exception.path == "hanami" || exception.is_a?(Gem::LoadError)
|
|
20
29
|
|
|
21
|
-
# If
|
|
22
|
-
|
|
23
|
-
File.exist?("config/app.rb") || File.exist?("app.rb")
|
|
30
|
+
# If we can't load the hanami gem, fall back to a simple file check.
|
|
31
|
+
File.exist?("config/app.rb")
|
|
24
32
|
end
|
|
25
33
|
|
|
26
34
|
# Contains the commands available for the current `hanami` CLI execution, depending on whether
|
|
@@ -35,13 +43,14 @@ module Hanami
|
|
|
35
43
|
|
|
36
44
|
# @api private
|
|
37
45
|
def self.register_commands!(within_hanami_app = within_hanami_app?)
|
|
38
|
-
commands =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
commands =
|
|
47
|
+
if within_hanami_app
|
|
48
|
+
require_relative "commands/app"
|
|
49
|
+
Commands::App
|
|
50
|
+
else
|
|
51
|
+
require_relative "commands/gem"
|
|
52
|
+
Commands::Gem
|
|
53
|
+
end
|
|
45
54
|
|
|
46
55
|
extend(commands)
|
|
47
56
|
end
|