hanami-cli 2.0.0.alpha3 → 2.0.0.alpha4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97c84f390960fa47aa204b96a95fdd97fac6b35f0d2d312ec2b1f8ed4588fd94
4
- data.tar.gz: c97dc5ca0dd28614ba351b8211e3e865cb0be8fa3880dcded3b49f572b0527eb
3
+ metadata.gz: de637259c61267b5589f64a633fb38ba6e7eb5a8f5dcc0bd689a3942a57b6dba
4
+ data.tar.gz: 87be564477f075f9a357edcad9a39e69a74bc6971de10bd353f22f75f0964b01
5
5
  SHA512:
6
- metadata.gz: f20b1a99b59e31bca7e92b23da280cc569e1f08b86170f1c7ff546f870e95b71f83c8a6f94c061519df82bfe30e56e2a7c5767806cbe526849955b37b7f1f6b3
7
- data.tar.gz: c86e4af61a229eb8fc55ee45e6e0f8d999afe18ff8e595a93e2376df62a5b8ec4d13f68fec3b43f23f8e4d7a9147e6696331b159f52026deefa416e5c74916f9
6
+ metadata.gz: 23aa8295f0f6148ce79041296e4ea6a51a42378672ac95fadd0cbcd8b43f9e3325ff4fb7d263993331d620ae64daf099c3520a3b62ba253ebba5d9b6490cbebe
7
+ data.tar.gz: a5d92abd72e92442fb5c9e6a3471160906172dbd3013dd2248259deb233f1ceccb17faf9a320bec0b27a7fe9c44d2ab3d820af6b4152618e9f7b662e57e06832
data/.rubocop.yml CHANGED
@@ -3,10 +3,13 @@
3
3
  AllCops:
4
4
  SuggestExtensions: false
5
5
  inherit_from:
6
- - https://raw.githubusercontent.com/hanami/devtools/master/.rubocop-unstable.yml
6
+ - https://raw.githubusercontent.com/hanami/devtools/main/.rubocop.yml
7
7
  Layout/LineLength:
8
8
  Exclude:
9
9
  - Gemfile
10
+ Lint/EmptyFile:
11
+ Exclude:
12
+ - "spec/fixtures/**/*.rb"
10
13
  Naming/HeredocDelimiterNaming:
11
14
  Enabled: false
12
15
  Naming/MethodParameterName:
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Hanami::CLI
2
2
  Hanami Command Line Interface
3
3
 
4
+ ## v2.0.0.alpha4 - 2021-12-07
5
+ ### Added
6
+ - [Tim Riley] Display a custom prompt when using irb-based console (consistent with pry-based console)
7
+ - [Phil Arndt] Support `postgresql://` URL schemes (in addition to existing `postgres://` support) for `db` subcommands
8
+
9
+ ### Fixed
10
+ - [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)
11
+
4
12
  ## v2.0.0.alpha3 - 2021-11-09
5
13
  No changes.
6
14
 
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ unless ENV["CI"]
9
9
  end
10
10
 
11
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"
12
13
  gem "hanami-view", require: false, git: "https://github.com/hanami/view.git", branch: "main"
13
14
 
14
15
  gem "rack"
data/hanami-cli.gemspec CHANGED
@@ -37,4 +37,7 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.add_development_dependency "rspec", "~> 3.9"
39
39
  spec.add_development_dependency "rubocop", "~> 1.11"
40
+ spec.metadata = {
41
+ "rubygems_mfa_required" => "true"
42
+ }
40
43
  end
@@ -19,6 +19,10 @@ module Hanami
19
19
  require_relative("postgres")
20
20
  Postgres
21
21
  },
22
+ "postgresql" => -> {
23
+ require_relative("postgres")
24
+ Postgres
25
+ },
22
26
  "mysql" => -> {
23
27
  require_relative("mysql")
24
28
  Mysql
@@ -74,10 +78,6 @@ module Hanami
74
78
  config.db_name
75
79
  end
76
80
 
77
- def applied_migrations
78
- sequel_migrator.applied_migrations
79
- end
80
-
81
81
  def gateway
82
82
  rom_config.gateways[:default]
83
83
  end
@@ -11,13 +11,13 @@ module Hanami
11
11
  # @api public
12
12
  class Console < Application
13
13
  REPLS = {
14
- "pry" => -> *args {
14
+ "pry" => -> (*args) {
15
15
  begin
16
16
  require "hanami/cli/repl/pry"
17
17
  Repl::Pry.new(*args)
18
- rescue LoadError; end
18
+ rescue LoadError; end # rubocop:disable Lint/SuppressedException
19
19
  },
20
- "irb" => -> *args {
20
+ "irb" => -> (*args) {
21
21
  require "hanami/cli/repl/irb"
22
22
  Repl::Irb.new(*args)
23
23
  },
@@ -25,7 +25,7 @@ module Hanami
25
25
 
26
26
  desc "Application REPL"
27
27
 
28
- option :repl, required: false, desc: "REPL gem that should be used"
28
+ option :repl, required: false, desc: "REPL gem that should be used ('pry' or 'irb')"
29
29
 
30
30
  # @api private
31
31
  def call(repl: nil, **opts)
@@ -35,7 +35,6 @@ module Hanami
35
35
 
36
36
  private
37
37
 
38
- # @api private
39
38
  def resolve_engine(repl, opts)
40
39
  if repl
41
40
  REPLS.fetch(repl).(application, opts)
@@ -12,7 +12,7 @@ module Hanami
12
12
 
13
13
  option :target, desc: "Target migration number", aliases: ["-t"]
14
14
 
15
- def call(target: nil, **)
15
+ def call(target: nil, **) # rubocop:disable Lint/UnusedMethodArgument
16
16
  migration = database.applied_migrations.last
17
17
  version = migration ? File.basename(migration, ".*") : "not available"
18
18
 
@@ -104,7 +104,7 @@ module Hanami
104
104
  alias_method :t, :template
105
105
 
106
106
  def route_url(controller, action, url)
107
- CLI::URL.call(url || "/#{controller.join('/')}" + ROUTE_RESTFUL_URL_SUFFIXES.fetch(action))
107
+ CLI::URL.call(url || ("/#{controller.join('/')}" + ROUTE_RESTFUL_URL_SUFFIXES.fetch(action)))
108
108
  end
109
109
 
110
110
  def route_http(action, http)
@@ -11,29 +11,26 @@ module Hanami
11
11
  class Irb < Core
12
12
  # @api public
13
13
  def start
14
- ARGV.shift until ARGV.empty?
15
- TOPLEVEL_BINDING.eval('self').extend(context)
16
-
17
- IRB.conf[:PROMPT] = {}
14
+ $stdout.sync = true
18
15
 
19
- IRB.conf[:PROMPT][:MY_PROMPT] = {
20
- :AUTO_INDENT => true,
21
- :PROMPT_I => ">> ",
22
- :PROMPT_S => nil,
23
- :PROMPT_C => nil,
24
- :RETURN => " ==>%s\n"
16
+ ARGV.shift until ARGV.empty?
17
+ TOPLEVEL_BINDING.eval("self").extend(context)
18
+
19
+ # Initializes the IRB.conf; our own conf changes must be after this
20
+ IRB.setup(nil)
21
+
22
+ IRB.conf[:PROMPT][:HANAMI] = {
23
+ AUTO_INDENT: true,
24
+ PROMPT_I: "#{prompt}> ",
25
+ PROMPT_N: "#{prompt}> ",
26
+ PROMPT_S: "#{prompt} %l> ",
27
+ PROMPT_C: "#{prompt} ?> ",
28
+ RETURN: "=> %s\n"
25
29
  }
26
30
 
27
- IRB.conf[:PROMPT_MODE] = :MY_PROMPT
28
-
29
- IRB.start
30
- end
31
-
32
- private
31
+ IRB.conf[:PROMPT_MODE] = :HANAMI
33
32
 
34
- # @api private
35
- def conf
36
- @conf ||= IRB.conf
33
+ IRB::Irb.new.run
37
34
  end
38
35
  end
39
36
  end
@@ -10,7 +10,7 @@ module Hanami
10
10
  # @api public
11
11
  class Pry < Core
12
12
  # @api private
13
- class Context
13
+ class Context # rubocop:disable Lint/EmptyClass
14
14
  end
15
15
 
16
16
  # @api public
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Hanami
4
4
  module CLI
5
- VERSION = "2.0.0.alpha3"
5
+ VERSION = "2.0.0.alpha4"
6
6
  end
7
7
  end
@@ -9,24 +9,38 @@ module Hanami
9
9
  # @api private
10
10
  # @since 2.0.0
11
11
  class Context < Module
12
+ # @api private
13
+ attr_reader :application
14
+
12
15
  # @api private
13
16
  def initialize(application)
17
+ super()
14
18
  @application = application
19
+
20
+ define_context_methods
21
+ include Plugins::SliceReaders.new(application)
15
22
  end
16
23
 
17
- # @api private
18
- def extended(other)
19
- super
20
- app = @application
24
+ private
21
25
 
22
- extend(Plugins::SliceReaders.new(app))
26
+ def define_context_methods
27
+ app = application
23
28
 
24
29
  define_method(:inspect) do
25
30
  "#<#{self.class} application=#{app} env=#{app.config.env}>"
26
31
  end
27
32
 
33
+ define_method(:app) do
34
+ app
35
+ end
36
+
37
+ define_method(:application) do
38
+ app
39
+ end
40
+
28
41
  define_method(:method_missing) do |name, *args, &block|
29
42
  return app.public_send(name, *args, &block) if app.respond_to?(name)
43
+
30
44
  super(name, *args, &block)
31
45
  end
32
46
 
@@ -10,29 +10,11 @@ module Hanami
10
10
  class SliceReaders < Module
11
11
  # @api private
12
12
  def initialize(application)
13
+ super()
14
+
13
15
  application.slices.each do |(name, slice)|
14
16
  define_method(name) do
15
- SliceDelegator.new(slice)
16
- end
17
- end
18
- end
19
-
20
- # @api private
21
- # @since 2.0.0
22
- class SliceDelegator < SimpleDelegator
23
- # @api private
24
- def respond_to_missing?(name)
25
- key?(name)
26
- end
27
-
28
- private
29
-
30
- # @api private
31
- def method_missing(name, *args, &block)
32
- if args.empty? && key?(name)
33
- self[name]
34
- else
35
- super
17
+ slice
36
18
  end
37
19
  end
38
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha3
4
+ version: 2.0.0.alpha4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-09 00:00:00.000000000 Z
11
+ date: 2021-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -210,10 +210,7 @@ homepage: https://hanamirb.org
210
210
  licenses:
211
211
  - MIT
212
212
  metadata:
213
- allowed_push_host: https://rubygems.org
214
- homepage_uri: https://hanamirb.org
215
- source_code_uri: https://github.com/hanami/cli
216
- changelog_uri: https://github.com/hanami/cli/blob/master/CHANGELOG.md
213
+ rubygems_mfa_required: 'true'
217
214
  post_install_message:
218
215
  rdoc_options: []
219
216
  require_paths:
@@ -229,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
226
  - !ruby/object:Gem::Version
230
227
  version: 1.3.1
231
228
  requirements: []
232
- rubygems_version: 3.2.3
229
+ rubygems_version: 3.2.29
233
230
  signing_key:
234
231
  specification_version: 4
235
232
  summary: Hanami CLI