hanami-cli 2.0.0.rc1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/.yardopts +3 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +3 -4
- data/exe/hanami +6 -1
- data/hanami-cli.gemspec +3 -2
- data/lib/hanami/cli/bundler.rb +95 -5
- data/lib/hanami/cli/command.rb +41 -0
- data/lib/hanami/cli/commands/app/command.rb +63 -2
- data/lib/hanami/cli/commands/app/console.rb +7 -3
- data/lib/hanami/cli/commands/app/db/create.rb +2 -0
- data/lib/hanami/cli/commands/app/db/create_migration.rb +3 -0
- data/lib/hanami/cli/commands/app/db/drop.rb +2 -0
- data/lib/hanami/cli/commands/app/db/migrate.rb +2 -0
- data/lib/hanami/cli/commands/app/db/reset.rb +2 -0
- data/lib/hanami/cli/commands/app/db/rollback.rb +2 -0
- data/lib/hanami/cli/commands/app/db/sample_data.rb +2 -0
- data/lib/hanami/cli/commands/app/db/seed.rb +2 -0
- data/lib/hanami/cli/commands/app/db/setup.rb +2 -0
- data/lib/hanami/cli/commands/app/db/structure/dump.rb +3 -0
- data/lib/hanami/cli/commands/app/db/utils/database.rb +155 -0
- data/lib/hanami/cli/commands/app/db/utils/database_config.rb +60 -0
- data/lib/hanami/cli/commands/app/db/utils/mysql.rb +33 -0
- data/lib/hanami/cli/commands/app/db/utils/postgres.rb +64 -0
- data/lib/hanami/cli/commands/app/db/utils/sqlite.rb +45 -0
- data/lib/hanami/cli/commands/app/db/version.rb +2 -0
- data/lib/hanami/cli/commands/app/generate/action.rb +10 -3
- data/lib/hanami/cli/commands/app/generate/slice.rb +9 -6
- data/lib/hanami/cli/commands/app/generate.rb +2 -0
- data/lib/hanami/cli/commands/app/install.rb +13 -2
- data/lib/hanami/cli/commands/app/middleware.rb +7 -1
- data/lib/hanami/cli/commands/app/routes.rb +8 -0
- data/lib/hanami/cli/commands/app/server.rb +10 -0
- data/lib/hanami/cli/commands/app/version.rb +4 -2
- data/lib/hanami/cli/commands/app.rb +6 -19
- data/lib/hanami/cli/commands/gem/new.rb +12 -13
- data/lib/hanami/cli/commands/gem/version.rb +4 -2
- data/lib/hanami/cli/commands/gem.rb +8 -5
- data/lib/hanami/cli/commands.rb +19 -3
- data/lib/hanami/cli/errors.rb +65 -0
- data/lib/hanami/cli/files.rb +10 -0
- data/lib/hanami/cli/generators/app/action.rb +11 -5
- data/lib/hanami/cli/generators/app/action_context.rb +22 -0
- data/lib/hanami/cli/generators/app/slice.rb +6 -1
- data/lib/hanami/cli/generators/app/slice_context.rb +8 -0
- data/lib/hanami/cli/generators/context.rb +14 -0
- data/lib/hanami/cli/generators/gem/app.rb +9 -5
- data/lib/hanami/cli/generators/version.rb +8 -6
- data/lib/hanami/cli/middleware_stack_inspector.rb +5 -0
- data/lib/hanami/cli/rake_tasks.rb +0 -1
- data/lib/hanami/cli/repl/core.rb +12 -4
- data/lib/hanami/cli/repl/irb.rb +3 -2
- data/lib/hanami/cli/repl/pry.rb +1 -3
- data/lib/hanami/cli/server.rb +11 -0
- data/lib/hanami/cli/system_call.rb +65 -7
- data/lib/hanami/cli/url.rb +9 -2
- data/lib/hanami/cli/version.rb +4 -1
- data/lib/hanami/cli.rb +26 -3
- data/lib/hanami/console/context.rb +4 -2
- data/lib/hanami/console/plugins/slice_readers.rb +1 -0
- data/lib/hanami-cli.rb +3 -0
- metadata +46 -25
- data/lib/hanami/cli/command_line.rb +0 -17
- data/lib/hanami/cli/commands/db/utils/database.rb +0 -133
- data/lib/hanami/cli/commands/db/utils/database_config.rb +0 -48
- data/lib/hanami/cli/commands/db/utils/mysql.rb +0 -27
- data/lib/hanami/cli/commands/db/utils/postgres.rb +0 -54
- data/lib/hanami/cli/commands/db/utils/sqlite.rb +0 -37
- data/lib/hanami/cli/error.rb +0 -8
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "shellwords"
|
4
|
-
require "open3"
|
5
|
-
require_relative "database"
|
6
|
-
|
7
|
-
module Hanami
|
8
|
-
module CLI
|
9
|
-
module Commands
|
10
|
-
module DB
|
11
|
-
module Utils
|
12
|
-
class Postgres < Database
|
13
|
-
def create_command
|
14
|
-
existing_stdout, status = Open3.capture2(cli_env_vars, "psql -t -c '\\l #{escaped_name}'")
|
15
|
-
|
16
|
-
return true if status.success? && existing_stdout.include?(escaped_name)
|
17
|
-
|
18
|
-
system(cli_env_vars, "createdb #{escaped_name}")
|
19
|
-
end
|
20
|
-
|
21
|
-
def drop_command
|
22
|
-
system(cli_env_vars, "dropdb #{escaped_name}")
|
23
|
-
end
|
24
|
-
|
25
|
-
def dump_command
|
26
|
-
system(cli_env_vars, "pg_dump --schema-only --no-owner #{escaped_name} > #{dump_file}")
|
27
|
-
end
|
28
|
-
|
29
|
-
def load_command
|
30
|
-
raise "Not Implemented Yet"
|
31
|
-
end
|
32
|
-
|
33
|
-
def escaped_name
|
34
|
-
Shellwords.escape(name)
|
35
|
-
end
|
36
|
-
|
37
|
-
def cli_env_vars
|
38
|
-
@cli_env_vars ||= {}.tap do |vars|
|
39
|
-
vars["PGHOST"] = config.host.to_s
|
40
|
-
vars["PGPORT"] = config.port.to_s if config.port
|
41
|
-
vars["PGUSER"] = config.user.to_s if config.user
|
42
|
-
vars["PGPASSWORD"] = config.pass.to_s if config.pass
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def dump_file
|
47
|
-
"#{root_path}/db/structure.sql"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "database"
|
4
|
-
|
5
|
-
module Hanami
|
6
|
-
module CLI
|
7
|
-
module Commands
|
8
|
-
module DB
|
9
|
-
module Utils
|
10
|
-
class Sqlite < Database
|
11
|
-
def create_command
|
12
|
-
rom_config
|
13
|
-
true
|
14
|
-
end
|
15
|
-
|
16
|
-
def drop_command
|
17
|
-
file_path.unlink
|
18
|
-
true
|
19
|
-
end
|
20
|
-
|
21
|
-
def dump_command
|
22
|
-
raise "Not Implemented Yet"
|
23
|
-
end
|
24
|
-
|
25
|
-
def load_command
|
26
|
-
raise "Not Implemented Yet"
|
27
|
-
end
|
28
|
-
|
29
|
-
def file_path
|
30
|
-
@file_path ||= Pathname("#{root_path}#{config.uri.path}").realpath
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|