hanami-cli 2.0.0.alpha7 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.action_hero.yml +11 -0
- data/.github/FUNDING.yml +1 -0
- data/CHANGELOG.md +58 -0
- data/Gemfile +2 -3
- data/LICENSE.md +22 -0
- data/README.md +14 -10
- data/hanami-cli.gemspec +3 -2
- data/lib/hanami/cli/bundler.rb +3 -7
- data/lib/hanami/cli/commands/app/command.rb +68 -0
- data/lib/hanami/cli/commands/{monolith → app}/console.rb +6 -6
- data/lib/hanami/cli/commands/{monolith → app}/db/create.rb +3 -3
- data/lib/hanami/cli/commands/{monolith → app}/db/create_migration.rb +3 -3
- data/lib/hanami/cli/commands/{monolith → app}/db/drop.rb +3 -3
- data/lib/hanami/cli/commands/{monolith → app}/db/migrate.rb +4 -4
- data/lib/hanami/cli/commands/{monolith → app}/db/reset.rb +3 -3
- data/lib/hanami/cli/commands/{monolith → app}/db/rollback.rb +4 -4
- data/lib/hanami/cli/commands/{monolith → app}/db/sample_data.rb +4 -4
- data/lib/hanami/cli/commands/{monolith → app}/db/seed.rb +4 -4
- data/lib/hanami/cli/commands/{monolith → app}/db/setup.rb +3 -3
- data/lib/hanami/cli/commands/{monolith → app}/db/structure/dump.rb +3 -3
- data/lib/hanami/cli/commands/{monolith → app}/db/version.rb +3 -3
- data/lib/hanami/cli/commands/{monolith → app}/generate/action.rb +3 -3
- data/lib/hanami/cli/commands/{monolith → app}/generate/slice.rb +4 -4
- data/lib/hanami/cli/commands/{monolith → app}/generate.rb +1 -1
- data/lib/hanami/cli/commands/{monolith → app}/install.rb +1 -1
- data/lib/hanami/cli/commands/app/routes.rb +82 -0
- data/lib/hanami/cli/commands/app/server.rb +58 -0
- data/lib/hanami/cli/commands/{monolith → app}/version.rb +1 -1
- data/lib/hanami/cli/commands/app.rb +46 -0
- data/lib/hanami/cli/commands/db/utils/database.rb +14 -10
- data/lib/hanami/cli/commands/gem/new.rb +29 -38
- data/lib/hanami/cli/commands/gem/version.rb +21 -1
- data/lib/hanami/cli/commands/gem.rb +2 -4
- data/lib/hanami/cli/commands.rb +9 -10
- data/lib/hanami/cli/generators/{monolith → app}/action/action.erb +0 -0
- data/lib/hanami/cli/generators/{monolith → app}/action/template.erb +0 -0
- data/lib/hanami/cli/generators/{monolith → app}/action/template.html.erb +0 -0
- data/lib/hanami/cli/generators/{monolith → app}/action/view.erb +0 -0
- data/lib/hanami/cli/generators/{monolith → app}/action.rb +2 -2
- data/lib/hanami/cli/generators/{monolith → app}/action_context.rb +1 -1
- data/lib/hanami/cli/generators/{monolith → app}/slice/action.erb +0 -0
- data/lib/hanami/cli/generators/{monolith → app}/slice/entities.erb +0 -0
- data/lib/hanami/cli/generators/{gem/application/monolith → app/slice}/keep.erb +0 -0
- data/lib/hanami/cli/generators/{monolith → app}/slice/repository.erb +0 -0
- data/lib/hanami/cli/generators/{monolith → app}/slice/routes.erb +0 -0
- data/lib/hanami/cli/generators/{monolith → app}/slice/view.erb +0 -0
- data/lib/hanami/cli/generators/{monolith → app}/slice.rb +2 -2
- data/lib/hanami/cli/generators/{monolith → app}/slice_context.rb +1 -1
- data/lib/hanami/cli/generators/context.rb +2 -2
- data/lib/hanami/cli/generators/gem/{application/monolith/entities.erb → app/action.erb} +3 -3
- data/lib/hanami/cli/generators/gem/{application/monolith/application.erb → app/app.erb} +1 -1
- data/lib/hanami/cli/generators/gem/{application/monolith → app}/config_ru.erb +0 -0
- data/lib/hanami/cli/generators/gem/{application/monolith → app}/env.erb +0 -0
- data/lib/hanami/cli/generators/gem/app/gemfile.erb +15 -0
- data/lib/hanami/cli/generators/{monolith/slice → gem/app}/keep.erb +0 -0
- data/lib/hanami/cli/generators/gem/app/operation.erb +9 -0
- data/lib/hanami/cli/generators/gem/app/rakefile.erb +3 -0
- data/lib/hanami/cli/generators/gem/{application/monolith → app}/readme.erb +0 -0
- data/lib/hanami/cli/generators/gem/app/relation.erb +7 -0
- data/lib/hanami/cli/generators/gem/app/repository.erb +9 -0
- data/lib/hanami/cli/generators/gem/app/routes.erb +11 -0
- data/lib/hanami/cli/generators/gem/app/settings.erb +9 -0
- data/lib/hanami/cli/generators/gem/{application/monolith/functions.erb → app/transformations.erb} +1 -1
- data/lib/hanami/cli/generators/gem/{application/monolith → app}/types.erb +0 -0
- data/lib/hanami/cli/generators/gem/app/validator.erb +12 -0
- data/lib/hanami/cli/generators/gem/app/view.erb +9 -0
- data/lib/hanami/cli/generators/gem/{application/monolith → app}/view_context.erb +1 -6
- data/lib/hanami/cli/generators/gem/app/view_part.erb +10 -0
- data/lib/hanami/cli/generators/gem/app.rb +64 -0
- data/lib/hanami/cli/generators/version.rb +55 -0
- data/lib/hanami/cli/rake_tasks.rb +54 -0
- data/lib/hanami/cli/repl/core.rb +7 -7
- data/lib/hanami/cli/server.rb +45 -0
- data/lib/hanami/cli/version.rb +1 -1
- data/lib/hanami/console/context.rb +12 -12
- data/lib/hanami/console/plugins/slice_readers.rb +3 -3
- data/project.yml +2 -0
- metadata +88 -60
- data/LICENSE.txt +0 -21
- data/lib/hanami/cli/commands/application.rb +0 -63
- data/lib/hanami/cli/commands/monolith.rb +0 -55
- data/lib/hanami/cli/generators/gem/application/monolith/action.erb +0 -21
- data/lib/hanami/cli/generators/gem/application/monolith/gemfile.erb +0 -19
- data/lib/hanami/cli/generators/gem/application/monolith/operation.erb +0 -18
- data/lib/hanami/cli/generators/gem/application/monolith/rakefile.erb +0 -3
- data/lib/hanami/cli/generators/gem/application/monolith/repository.erb +0 -13
- data/lib/hanami/cli/generators/gem/application/monolith/routes.erb +0 -4
- data/lib/hanami/cli/generators/gem/application/monolith/settings.erb +0 -6
- data/lib/hanami/cli/generators/gem/application/monolith/validation_contract.erb +0 -14
- data/lib/hanami/cli/generators/gem/application/monolith.rb +0 -83
- data/lib/hanami/cli/generators/gem/application.rb +0 -21
- 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/
|
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
|
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::
|
32
|
+
generator: Generators::App::Action.new(fs: fs, inflector: inflector), **)
|
33
33
|
@generator = generator
|
34
34
|
super(fs: fs)
|
35
35
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "hanami/cli/command"
|
4
|
-
require "hanami/cli/generators/
|
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
|
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::
|
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.
|
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
|
|
@@ -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
|
@@ -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 :
|
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.[](
|
33
|
-
config = DatabaseConfig.new(
|
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(
|
41
|
+
klass.new(app: app, config: config)
|
42
42
|
end
|
43
43
|
|
44
|
-
def initialize(
|
45
|
-
@
|
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
|
-
|
66
|
+
app.root
|
67
67
|
end
|
68
68
|
|
69
69
|
def rom_config
|
70
70
|
@rom_config ||=
|
71
71
|
begin
|
72
|
-
|
73
|
-
|
72
|
+
app.prepare(:persistence)
|
73
|
+
app.container["persistence.config"]
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -108,7 +108,11 @@ module Hanami
|
|
108
108
|
private
|
109
109
|
|
110
110
|
def sequel_migrator
|
111
|
-
|
111
|
+
@sequel_migrator ||= begin
|
112
|
+
require "sequel"
|
113
|
+
Sequel.extension :migration
|
114
|
+
Sequel::TimestampMigrator.new(migrator.connection, migrations_path, {})
|
115
|
+
end
|
112
116
|
end
|
113
117
|
|
114
118
|
def migrations_path
|
@@ -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/
|
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
|
-
|
15
|
-
private_constant :
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
34
|
+
@generator = generator
|
35
|
+
super(fs: fs, inflector: inflector, **other)
|
40
36
|
end
|
37
|
+
# rubocop:enable Metrics/ParameterLists
|
41
38
|
|
42
|
-
def call(app:,
|
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
|
49
|
-
|
50
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
15
|
-
# register "new", New
|
13
|
+
register "new", New
|
16
14
|
end
|
17
15
|
end
|
18
16
|
end
|
data/lib/hanami/cli/commands.rb
CHANGED
@@ -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!(
|
14
|
-
commands =
|
15
|
-
|
16
|
-
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
require "erb"
|
4
4
|
require "dry/files"
|
5
|
-
require "hanami/cli/generators/
|
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
|
11
|
+
module App
|
12
12
|
class Action
|
13
13
|
def initialize(fs:, inflector:)
|
14
14
|
@fs = fs
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
require "erb"
|
4
4
|
require "dry/files"
|
5
|
-
require "hanami/cli/generators/
|
5
|
+
require "hanami/cli/generators/app/slice_context"
|
6
6
|
|
7
7
|
module Hanami
|
8
8
|
module CLI
|
9
9
|
module Generators
|
10
|
-
module
|
10
|
+
module App
|
11
11
|
class Slice
|
12
12
|
def initialize(fs:, inflector:)
|
13
13
|
@fs = fs
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
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
|
-
|
19
|
+
Version.gem_requirement
|
20
20
|
end
|
21
21
|
|
22
22
|
def classified_app_name
|
File without changes
|
File without changes
|
@@ -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
|
File without changes
|