hanami/cli -> dry/cli (#1021)

This commit is contained in:
Ivan Shamatov 2020-02-02 20:51:20 +03:00 committed by GitHub
parent 09d28ac432
commit 31103a7b47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 35 additions and 14 deletions

View File

@ -17,7 +17,6 @@ gem 'hanami-model', '~> 1.3', require: false, git: 'https://github.com/han
gem 'hanami-helpers', '~> 1.3', require: false, git: 'https://github.com/hanami/helpers.git', branch: 'master'
gem 'hanami-mailer', '~> 1.3', require: false, git: 'https://github.com/hanami/mailer.git', branch: 'master'
gem 'hanami-assets', '~> 1.3', require: false, git: 'https://github.com/hanami/assets.git', branch: 'master'
gem 'hanami-cli', '~> 0.3', require: false, git: 'https://github.com/hanami/cli.git', branch: 'master'
platforms :ruby do
gem 'sqlite3'

View File

@ -18,7 +18,6 @@ which provides the glue that ties all the parts together:
* [**Hanami::Helpers**](https://github.com/hanami/helpers) - View helpers for Ruby applications
* [**Hanami::Mailer**](https://github.com/hanami/mailer) - Mail for Ruby applications
* [**Hanami::Assets**](https://github.com/hanami/assets) - Assets management for Ruby
* [**Hanami::CLI**](https://github.com/hanami/cli) - Ruby command line interface
* [**Hanami::Utils**](https://github.com/hanami/utils) - Ruby core extensions and class utilities
These components are designed to be used independently or together in a Hanami application.

View File

@ -3,4 +3,4 @@ require 'bundler'
require 'hanami/cli/commands'
::Bundler.require(:plugins) if File.exist?(ENV["BUNDLE_GEMFILE"] || "Gemfile")
Hanami::CLI.new(Hanami::CLI::Commands).call
Dry::CLI.new(Hanami::CLI::Commands).call

View File

@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'hanami-helpers', '~> 1.3'
spec.add_dependency 'hanami-mailer', '~> 1.3'
spec.add_dependency 'hanami-assets', '~> 1.3'
spec.add_dependency 'hanami-cli', '~> 0.3'
spec.add_dependency 'dry-cli', '~> 0.5'
spec.add_dependency 'concurrent-ruby', '~> 1.0'
spec.add_dependency 'bundler', '>= 1.6', '< 3'

View File

@ -1,4 +1,4 @@
require 'hanami/cli'
require 'dry/cli'
require 'ostruct'
module Hanami
@ -54,7 +54,7 @@ module Hanami
# @since 1.1.0
# @api private
module Commands
extend Hanami::CLI::Registry
extend Dry::CLI::Registry
# CLI command context
#

View File

@ -1,7 +1,7 @@
require 'hanami'
require 'hanami/environment'
require 'hanami/components'
require 'hanami/cli/command'
require 'dry/cli/command'
require 'hanami/cli/commands/project'
require 'hanami/cli/commands/templates'
require 'concurrent'
@ -17,7 +17,7 @@ module Hanami
# Abstract command
#
# @since 1.1.0
class Command < Hanami::CLI::Command
class Command < Dry::CLI::Command
# @since 1.1.0
# @api private
def self.inherited(component)

View File

@ -10,7 +10,6 @@ gem 'hanami-controller', require: false, git: 'https://github.com/hanami/contro
gem 'hanami-view', require: false, git: 'https://github.com/hanami/view.git', branch: 'develop'
gem 'hanami-helpers', require: false, git: 'https://github.com/hanami/helpers.git', branch: 'develop'
gem 'hanami-mailer', require: false, git: 'https://github.com/hanami/mailer.git', branch: 'develop'
gem 'hanami-cli', require: false, git: 'https://github.com/hanami/cli.git', branch: 'develop'
gem 'hanami-assets', require: false, git: 'https://github.com/hanami/assets.git', branch: 'develop'
gem 'hanami-model', require: false, git: 'https://github.com/hanami/model.git', branch: 'develop'
gem 'hanami', git: 'https://github.com/hanami/hanami.git', branch: 'develop'

View File

@ -71,7 +71,7 @@ module Hanami
# @api private
def run_hanami_command(command)
require "hanami/cli/commands"
Hanami::CLI.new(Hanami::CLI::Commands).call(arguments: command.split(/[[:space:]]/))
Dry::CLI.new(Hanami::CLI::Commands).call(arguments: command.split(/[[:space:]]/))
end
# rubocop:enable Metrics/MethodLength
end

View File

@ -20,7 +20,7 @@ bundle_package() {
}
install_hanami_frameworks() {
declare -a frameworks=(utils validations router helpers model view controller mailer assets cli webconsole)
declare -a frameworks=(utils validations router helpers model view controller mailer assets webconsole)
for framework in "${frameworks[@]}"
do

View File

@ -3,7 +3,7 @@ set -euo pipefail
IFS=$'\n\t'
uninstall_hanami_gems() {
declare -a frameworks=(hanami hanami-assets hanami-mailer hanami-controller hanami-view hanami-model hanami-helpers hanami-router hanami-validations hanami-cli hanami-webconsole hanami-utils)
declare -a frameworks=(hanami hanami-assets hanami-mailer hanami-controller hanami-view hanami-model hanami-helpers hanami-router hanami-validations hanami-webconsole hanami-utils)
for framework in "${frameworks[@]}"
do

View File

@ -1,6 +1,6 @@
RSpec.describe "hanami db", type: :integration do
describe "apply" do
it "migrates, dumps structure, deletes migrations" do
it "migrates, dumps structure, deletes migrations", if: RUBY_VERSION < '2.4' do
with_project do
versions = generate_migrations
@ -24,6 +24,31 @@ SQL
end
end
it "migrates, dumps structure, deletes migrations", if: RUBY_VERSION >= '2.4' do
with_project do
versions = generate_migrations
hanami "db apply"
hanami "db version"
expect(out).to include(versions.last.to_s)
db = Pathname.new('db')
schema = db.join('schema.sql').to_s
migrations = db.join('migrations')
expect(schema).to have_file_content <<-SQL
CREATE TABLE `schema_migrations` (`filename` varchar(255) NOT NULL PRIMARY KEY);
CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255), `age` integer);
CREATE TABLE sqlite_sequence(name,seq);
INSERT INTO schema_migrations VALUES('#{versions.first}_create_users.rb');
INSERT INTO schema_migrations VALUES('#{versions.last}_add_age_to_users.rb');
SQL
expect(migrations.children).to be_empty
end
end
it "prints help message" do
with_project do
output = <<-OUT

View File

@ -16,7 +16,6 @@ RSpec.describe "hanami new", type: :integration do
expect('Gemfile').to have_file_content(%r{gem 'hanami-view', require: false, git: 'https://github.com/hanami/view.git', branch: 'develop'})
expect('Gemfile').to have_file_content(%r{gem 'hanami-helpers', require: false, git: 'https://github.com/hanami/helpers.git', branch: 'develop'})
expect('Gemfile').to have_file_content(%r{gem 'hanami-mailer', require: false, git: 'https://github.com/hanami/mailer.git', branch: 'develop'})
expect('Gemfile').to have_file_content(%r{gem 'hanami-cli', require: false, git: 'https://github.com/hanami/cli.git', branch: 'develop'})
expect('Gemfile').to have_file_content(%r{gem 'hanami-assets', require: false, git: 'https://github.com/hanami/assets.git', branch: 'develop'})
expect('Gemfile').to have_file_content(%r{gem 'hanami-model', require: false, git: 'https://github.com/hanami/model.git', branch: 'develop'})
expect('Gemfile').to have_file_content(%r{gem 'hanami', git: 'https://github.com/hanami/hanami.git', branch: 'develop'})