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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.yardopts +3 -0
  4. data/CHANGELOG.md +12 -0
  5. data/Gemfile +3 -4
  6. data/exe/hanami +6 -1
  7. data/hanami-cli.gemspec +3 -2
  8. data/lib/hanami/cli/bundler.rb +95 -5
  9. data/lib/hanami/cli/command.rb +41 -0
  10. data/lib/hanami/cli/commands/app/command.rb +63 -2
  11. data/lib/hanami/cli/commands/app/console.rb +7 -3
  12. data/lib/hanami/cli/commands/app/db/create.rb +2 -0
  13. data/lib/hanami/cli/commands/app/db/create_migration.rb +3 -0
  14. data/lib/hanami/cli/commands/app/db/drop.rb +2 -0
  15. data/lib/hanami/cli/commands/app/db/migrate.rb +2 -0
  16. data/lib/hanami/cli/commands/app/db/reset.rb +2 -0
  17. data/lib/hanami/cli/commands/app/db/rollback.rb +2 -0
  18. data/lib/hanami/cli/commands/app/db/sample_data.rb +2 -0
  19. data/lib/hanami/cli/commands/app/db/seed.rb +2 -0
  20. data/lib/hanami/cli/commands/app/db/setup.rb +2 -0
  21. data/lib/hanami/cli/commands/app/db/structure/dump.rb +3 -0
  22. data/lib/hanami/cli/commands/app/db/utils/database.rb +155 -0
  23. data/lib/hanami/cli/commands/app/db/utils/database_config.rb +60 -0
  24. data/lib/hanami/cli/commands/app/db/utils/mysql.rb +33 -0
  25. data/lib/hanami/cli/commands/app/db/utils/postgres.rb +64 -0
  26. data/lib/hanami/cli/commands/app/db/utils/sqlite.rb +45 -0
  27. data/lib/hanami/cli/commands/app/db/version.rb +2 -0
  28. data/lib/hanami/cli/commands/app/generate/action.rb +10 -3
  29. data/lib/hanami/cli/commands/app/generate/slice.rb +9 -6
  30. data/lib/hanami/cli/commands/app/generate.rb +2 -0
  31. data/lib/hanami/cli/commands/app/install.rb +13 -2
  32. data/lib/hanami/cli/commands/app/middleware.rb +7 -1
  33. data/lib/hanami/cli/commands/app/routes.rb +8 -0
  34. data/lib/hanami/cli/commands/app/server.rb +10 -0
  35. data/lib/hanami/cli/commands/app/version.rb +4 -2
  36. data/lib/hanami/cli/commands/app.rb +6 -19
  37. data/lib/hanami/cli/commands/gem/new.rb +12 -13
  38. data/lib/hanami/cli/commands/gem/version.rb +4 -2
  39. data/lib/hanami/cli/commands/gem.rb +8 -5
  40. data/lib/hanami/cli/commands.rb +19 -3
  41. data/lib/hanami/cli/errors.rb +65 -0
  42. data/lib/hanami/cli/files.rb +10 -0
  43. data/lib/hanami/cli/generators/app/action.rb +11 -5
  44. data/lib/hanami/cli/generators/app/action_context.rb +22 -0
  45. data/lib/hanami/cli/generators/app/slice.rb +6 -1
  46. data/lib/hanami/cli/generators/app/slice_context.rb +8 -0
  47. data/lib/hanami/cli/generators/context.rb +14 -0
  48. data/lib/hanami/cli/generators/gem/app.rb +9 -5
  49. data/lib/hanami/cli/generators/version.rb +8 -6
  50. data/lib/hanami/cli/middleware_stack_inspector.rb +5 -0
  51. data/lib/hanami/cli/rake_tasks.rb +0 -1
  52. data/lib/hanami/cli/repl/core.rb +12 -4
  53. data/lib/hanami/cli/repl/irb.rb +3 -2
  54. data/lib/hanami/cli/repl/pry.rb +1 -3
  55. data/lib/hanami/cli/server.rb +11 -0
  56. data/lib/hanami/cli/system_call.rb +65 -7
  57. data/lib/hanami/cli/url.rb +9 -2
  58. data/lib/hanami/cli/version.rb +4 -1
  59. data/lib/hanami/cli.rb +26 -3
  60. data/lib/hanami/console/context.rb +4 -2
  61. data/lib/hanami/console/plugins/slice_readers.rb +1 -0
  62. data/lib/hanami-cli.rb +3 -0
  63. metadata +46 -25
  64. data/lib/hanami/cli/command_line.rb +0 -17
  65. data/lib/hanami/cli/commands/db/utils/database.rb +0 -133
  66. data/lib/hanami/cli/commands/db/utils/database_config.rb +0 -48
  67. data/lib/hanami/cli/commands/db/utils/mysql.rb +0 -27
  68. data/lib/hanami/cli/commands/db/utils/postgres.rb +0 -54
  69. data/lib/hanami/cli/commands/db/utils/sqlite.rb +0 -37
  70. 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
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Hanami
4
- module CLI
5
- class Error < StandardError
6
- end
7
- end
8
- end