hanami-cli 1.0.0.alpha1 → 2.0.0.alpha6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +50 -0
  3. data/.gitignore +4 -2
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +28 -1
  6. data/CHANGELOG.md +32 -1
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +9 -2
  9. data/LICENSE.txt +21 -0
  10. data/README.md +12 -605
  11. data/Rakefile +5 -10
  12. data/exe/hanami +10 -0
  13. data/hanami-cli.gemspec +22 -17
  14. data/lib/hanami/cli/bundler.rb +73 -0
  15. data/lib/hanami/cli/command.rb +14 -386
  16. data/lib/hanami/cli/command_line.rb +17 -0
  17. data/lib/hanami/cli/commands/application.rb +63 -0
  18. data/lib/hanami/cli/commands/db/utils/database.rb +122 -0
  19. data/lib/hanami/cli/commands/db/utils/database_config.rb +48 -0
  20. data/lib/hanami/cli/commands/db/utils/mysql.rb +27 -0
  21. data/lib/hanami/cli/commands/db/utils/postgres.rb +49 -0
  22. data/lib/hanami/cli/commands/db/utils/sqlite.rb +37 -0
  23. data/lib/hanami/cli/commands/gem/new.rb +77 -0
  24. data/lib/hanami/cli/commands/gem/version.rb +18 -0
  25. data/lib/hanami/cli/commands/gem.rb +21 -0
  26. data/lib/hanami/cli/commands/monolith/console.rb +49 -0
  27. data/lib/hanami/cli/commands/monolith/db/create.rb +25 -0
  28. data/lib/hanami/cli/commands/monolith/db/create_migration.rb +29 -0
  29. data/lib/hanami/cli/commands/monolith/db/drop.rb +25 -0
  30. data/lib/hanami/cli/commands/monolith/db/migrate.rb +40 -0
  31. data/lib/hanami/cli/commands/monolith/db/reset.rb +26 -0
  32. data/lib/hanami/cli/commands/monolith/db/rollback.rb +55 -0
  33. data/lib/hanami/cli/commands/monolith/db/sample_data.rb +40 -0
  34. data/lib/hanami/cli/commands/monolith/db/seed.rb +40 -0
  35. data/lib/hanami/cli/commands/monolith/db/setup.rb +24 -0
  36. data/lib/hanami/cli/commands/monolith/db/structure/dump.rb +25 -0
  37. data/lib/hanami/cli/commands/monolith/db/version.rb +26 -0
  38. data/lib/hanami/cli/commands/monolith/generate/action.rb +62 -0
  39. data/lib/hanami/cli/commands/monolith/generate/slice.rb +62 -0
  40. data/lib/hanami/cli/commands/monolith/generate.rb +14 -0
  41. data/lib/hanami/cli/commands/monolith/install.rb +16 -0
  42. data/lib/hanami/cli/commands/monolith/version.rb +18 -0
  43. data/lib/hanami/cli/commands/monolith.rb +55 -0
  44. data/lib/hanami/cli/commands.rb +26 -0
  45. data/lib/hanami/cli/error.rb +8 -0
  46. data/lib/hanami/cli/generators/context.rb +38 -0
  47. data/lib/hanami/cli/generators/gem/application/monolith/action.erb +21 -0
  48. data/lib/hanami/cli/generators/gem/application/monolith/application.erb +8 -0
  49. data/lib/hanami/cli/generators/gem/application/monolith/config_ru.erb +5 -0
  50. data/lib/hanami/cli/generators/gem/application/monolith/entities.erb +9 -0
  51. data/lib/hanami/cli/generators/gem/application/monolith/env.erb +0 -0
  52. data/lib/hanami/cli/generators/gem/application/monolith/functions.erb +13 -0
  53. data/lib/hanami/cli/generators/gem/application/monolith/gemfile.erb +19 -0
  54. data/lib/hanami/cli/generators/gem/application/monolith/keep.erb +0 -0
  55. data/lib/hanami/cli/generators/gem/application/monolith/operation.erb +18 -0
  56. data/lib/hanami/cli/generators/gem/application/monolith/rakefile.erb +3 -0
  57. data/lib/hanami/cli/generators/gem/application/monolith/readme.erb +1 -0
  58. data/lib/hanami/cli/generators/gem/application/monolith/repository.erb +13 -0
  59. data/lib/hanami/cli/generators/gem/application/monolith/routes.erb +4 -0
  60. data/lib/hanami/cli/generators/gem/application/monolith/settings.erb +6 -0
  61. data/lib/hanami/cli/generators/gem/application/monolith/types.erb +10 -0
  62. data/lib/hanami/cli/generators/gem/application/monolith/validation_contract.erb +14 -0
  63. data/lib/hanami/cli/generators/gem/application/monolith/view_context.erb +15 -0
  64. data/lib/hanami/cli/generators/gem/application/monolith.rb +83 -0
  65. data/lib/hanami/cli/generators/gem/application.rb +21 -0
  66. data/lib/hanami/cli/generators/monolith/action/action.erb +13 -0
  67. data/lib/hanami/cli/generators/monolith/action/template.erb +0 -0
  68. data/lib/hanami/cli/generators/monolith/action/template.html.erb +2 -0
  69. data/lib/hanami/cli/generators/monolith/action/view.erb +13 -0
  70. data/lib/hanami/cli/generators/monolith/action.rb +123 -0
  71. data/lib/hanami/cli/generators/monolith/action_context.rb +76 -0
  72. data/lib/hanami/cli/generators/monolith/slice/action.erb +9 -0
  73. data/lib/hanami/cli/generators/monolith/slice/entities.erb +9 -0
  74. data/lib/hanami/cli/generators/monolith/slice/keep.erb +0 -0
  75. data/lib/hanami/cli/generators/monolith/slice/repository.erb +10 -0
  76. data/lib/hanami/cli/generators/monolith/slice/routes.erb +2 -0
  77. data/lib/hanami/cli/generators/monolith/slice/view.erb +9 -0
  78. data/lib/hanami/cli/generators/monolith/slice.rb +56 -0
  79. data/lib/hanami/cli/generators/monolith/slice_context.rb +33 -0
  80. data/lib/hanami/cli/repl/core.rb +55 -0
  81. data/lib/hanami/cli/repl/irb.rb +38 -0
  82. data/lib/hanami/cli/repl/pry.rb +29 -0
  83. data/lib/hanami/cli/system_call.rb +51 -0
  84. data/lib/hanami/cli/url.rb +34 -0
  85. data/lib/hanami/cli/version.rb +2 -3
  86. data/lib/hanami/cli.rb +9 -122
  87. data/lib/hanami/console/context.rb +53 -0
  88. data/lib/hanami/console/plugins/slice_readers.rb +24 -0
  89. data/lib/hanami/rake_tasks.rb +52 -0
  90. metadata +135 -43
  91. data/.circleci/config.yml +0 -63
  92. data/.travis.yml +0 -22
  93. data/lib/hanami/cli/banner.rb +0 -129
  94. data/lib/hanami/cli/command_registry.rb +0 -215
  95. data/lib/hanami/cli/errors.rb +0 -46
  96. data/lib/hanami/cli/option.rb +0 -134
  97. data/lib/hanami/cli/parser.rb +0 -144
  98. data/lib/hanami/cli/program_name.rb +0 -21
  99. data/lib/hanami/cli/registry.rb +0 -330
  100. data/lib/hanami/cli/usage.rb +0 -91
  101. data/script/ci +0 -61
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../application"
4
+ require_relative "structure/dump"
5
+
6
+ module Hanami
7
+ module CLI
8
+ module Commands
9
+ module Monolith
10
+ module DB
11
+ class Seed < Application
12
+ FILE_PATH = "db/seeds.rb"
13
+
14
+ desc "Load seed data"
15
+
16
+ def call(**)
17
+ if has_file?
18
+ measure "seed data loaded from #{FILE_PATH}" do
19
+ load full_file_path
20
+ end
21
+ else
22
+ out.puts "=> #{FILE_PATH} not found"
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def full_file_path
29
+ File.join(application.root, FILE_PATH)
30
+ end
31
+
32
+ def has_file?
33
+ File.exist?(full_file_path)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../application"
4
+ require_relative "create"
5
+ require_relative "migrate"
6
+
7
+ module Hanami
8
+ module CLI
9
+ module Commands
10
+ module Monolith
11
+ module DB
12
+ class Setup < Application
13
+ desc "Setup database"
14
+
15
+ def call(**)
16
+ run_command Create
17
+ run_command Migrate
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../application"
4
+
5
+ module Hanami
6
+ module CLI
7
+ module Commands
8
+ module Monolith
9
+ module DB
10
+ module Structure
11
+ class Dump < Application
12
+ desc "Dumps database structure to db/structure.sql file"
13
+
14
+ def call(*)
15
+ measure("#{database.name} structure dumped to db/structure.sql") do
16
+ database.dump_command
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../application"
4
+
5
+ module Hanami
6
+ module CLI
7
+ module Commands
8
+ module Monolith
9
+ module DB
10
+ class Version < Application
11
+ desc "Print schema version"
12
+
13
+ option :target, desc: "Target migration number", aliases: ["-t"]
14
+
15
+ def call(target: nil, **) # rubocop:disable Lint/UnusedMethodArgument
16
+ migration = database.applied_migrations.last
17
+ version = migration ? File.basename(migration, ".*") : "not available"
18
+
19
+ out.puts "=> current schema version is #{version}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/cli/command"
4
+ require "hanami/cli/generators/monolith/action"
5
+ require "dry/inflector"
6
+ require "dry/files"
7
+ require "shellwords"
8
+
9
+ module Hanami
10
+ module CLI
11
+ module Commands
12
+ module Monolith
13
+ module Generate
14
+ class Action < Command
15
+ # TODO: ideally the default format should lookup
16
+ # slice configuration (Action's `default_response_format`)
17
+ DEFAULT_FORMAT = "html"
18
+ private_constant :DEFAULT_FORMAT
19
+
20
+ DEFAULT_SKIP_VIEW = false
21
+ private_constant :DEFAULT_SKIP_VIEW
22
+
23
+ argument :slice, required: true, desc: "Slice name"
24
+ argument :name, required: true, desc: "Action name"
25
+ option :url, required: false, type: :string, desc: "Action URL"
26
+ option :http, required: false, type: :string, desc: "Action HTTP method"
27
+ option :format, required: false, type: :string, default: DEFAULT_FORMAT, desc: "Template format"
28
+ option :skip_view, required: false, type: :boolean, default: DEFAULT_SKIP_VIEW,
29
+ desc: "Skip view and template generation"
30
+
31
+ def initialize(fs: Dry::Files.new, inflector: Dry::Inflector.new,
32
+ generator: Generators::Monolith::Action.new(fs: fs, inflector: inflector), **)
33
+ @generator = generator
34
+ super(fs: fs)
35
+ end
36
+
37
+ # rubocop:disable Metrics/ParameterLists
38
+ def call(slice:, name:, url: nil, http: nil, format: DEFAULT_FORMAT, skip_view: DEFAULT_SKIP_VIEW, **)
39
+ slice = inflector.underscore(Shellwords.shellescape(slice))
40
+ name = inflector.underscore(Shellwords.shellescape(name))
41
+ *controller, action = name.split(ACTION_SEPARATOR)
42
+
43
+ if controller.empty?
44
+ raise ArgumentError.new("cannot parse controller and action name: `#{name}'\n\texample: users.show")
45
+ end
46
+
47
+ generator.call(slice, controller, action, url, http, format, skip_view)
48
+ end
49
+ # rubocop:enable Metrics/ParameterLists
50
+
51
+ private
52
+
53
+ ACTION_SEPARATOR = "."
54
+ private_constant :ACTION_SEPARATOR
55
+
56
+ attr_reader :generator
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/cli/command"
4
+ require "hanami/cli/generators/monolith/slice"
5
+ require "dry/inflector"
6
+ require "dry/files"
7
+ require "shellwords"
8
+ require "hanami/cli/url"
9
+
10
+ module Hanami
11
+ module CLI
12
+ module Commands
13
+ module Monolith
14
+ module Generate
15
+ class Slice < Command
16
+ argument :name, required: true, desc: "The slice name"
17
+ option :url_prefix, required: false, type: :string, desc: "The slice URL prefix"
18
+
19
+ def initialize(fs: Dry::Files.new, inflector: Dry::Inflector.new,
20
+ generator: Generators::Monolith::Slice.new(fs: fs, inflector: inflector), **)
21
+ @generator = generator
22
+ super(fs: fs)
23
+ end
24
+
25
+ def call(name:, url_prefix: nil, **)
26
+ require "hanami/setup"
27
+
28
+ app = inflector.underscore(Hanami.application.namespace)
29
+ name = inflector.underscore(Shellwords.shellescape(name))
30
+ url_prefix = sanitize_url_prefix(name, url_prefix)
31
+
32
+ generator.call(app, name, url_prefix)
33
+ end
34
+
35
+ private
36
+
37
+ DEFAULT_URL_PREFIX = "/"
38
+ private_constant :DEFAULT_URL_PREFIX
39
+
40
+ attr_reader :generator
41
+
42
+ def sanitize_url_prefix(name, url_prefix)
43
+ result = url_prefix
44
+ result = inflector.underscore(Shellwords.shellescape(result)) unless result.nil?
45
+
46
+ result ||= DEFAULT_URL_PREFIX + name
47
+ CLI::URL.call(result)
48
+ rescue ArgumentError
49
+ raise ArgumentError.new("invalid URL prefix: `#{url_prefix}'")
50
+ end
51
+
52
+ def valid_url?(url)
53
+ return false if url.nil?
54
+
55
+ url.start_with?(DEFAULT_URL_PREFIX)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLI
5
+ module Commands
6
+ module Monolith
7
+ module Generate
8
+ require_relative "./generate/slice"
9
+ require_relative "./generate/action"
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/cli/command"
4
+
5
+ module Hanami
6
+ module CLI
7
+ module Commands
8
+ module Monolith
9
+ class Install < Command
10
+ def call(*)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/cli/command"
4
+
5
+ module Hanami
6
+ module CLI
7
+ module Commands
8
+ module Monolith
9
+ class Version < Command
10
+ def call(*)
11
+ require "hanami/version"
12
+ out.puts "v#{Hanami::VERSION}"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLI
5
+ module Commands
6
+ module Monolith
7
+ require_relative "monolith/version"
8
+ # require_relative "monolith/install"
9
+ # require_relative "monolith/generate"
10
+ require_relative "monolith/install"
11
+ require_relative "monolith/generate"
12
+ require_relative "monolith/console"
13
+ require_relative "monolith/db/create"
14
+ require_relative "monolith/db/create_migration"
15
+ require_relative "monolith/db/drop"
16
+ require_relative "monolith/db/migrate"
17
+ require_relative "monolith/db/setup"
18
+ require_relative "monolith/db/reset"
19
+ require_relative "monolith/db/rollback"
20
+ require_relative "monolith/db/sample_data"
21
+ require_relative "monolith/db/seed"
22
+ require_relative "monolith/db/structure/dump"
23
+ require_relative "monolith/db/version"
24
+
25
+ def self.extended(base)
26
+ base.module_eval do
27
+ register "version", Version, aliases: ["v", "-v", "--version"]
28
+ # FIXME: temporary disabled for Hanami v2.0.0.alpha2
29
+ # register "install", Install
30
+
31
+ # FIXME: temporary disabled for Hanami v2.0.0.alpha2
32
+ # register "generate", aliases: ["g"] do |prefix|
33
+ # prefix.register "slice", Generate::Slice
34
+ # prefix.register "action", Generate::Action
35
+ # end
36
+
37
+ register "console", Commands::Monolith::Console
38
+
39
+ register "db create", Commands::Monolith::DB::Create
40
+ register "db create_migration", Commands::Monolith::DB::CreateMigration
41
+ register "db drop", Commands::Monolith::DB::Drop
42
+ register "db migrate", Commands::Monolith::DB::Migrate
43
+ register "db setup", Commands::Monolith::DB::Setup
44
+ register "db reset", Commands::Monolith::DB::Reset
45
+ register "db rollback", Commands::Monolith::DB::Rollback
46
+ register "db sample_data", Commands::Monolith::DB::SampleData
47
+ register "db seed", Commands::Monolith::DB::Seed
48
+ register "db structure dump", Commands::Monolith::DB::Structure::Dump
49
+ register "db version", Commands::Monolith::DB::Version
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ # TODO: move elsewhere
5
+ def self.architecture
6
+ return :monolith if File.exist?("config/application.rb")
7
+ end
8
+
9
+ module CLI
10
+ module Commands
11
+ end
12
+
13
+ def self.register_commands!(architecture = Hanami.architecture)
14
+ commands = case architecture
15
+ when :monolith
16
+ require_relative "commands/monolith"
17
+ Commands::Monolith
18
+ else
19
+ require_relative "commands/gem"
20
+ Commands::Gem
21
+ end
22
+
23
+ extend(commands)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLI
5
+ class Error < StandardError
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/version"
4
+
5
+ module Hanami
6
+ module CLI
7
+ module Generators
8
+ class Context
9
+ def initialize(inflector, app)
10
+ @inflector = inflector
11
+ @app = app
12
+ end
13
+
14
+ def ctx
15
+ binding
16
+ end
17
+
18
+ def hanami_version
19
+ Hanami::Version.gem_requirement
20
+ end
21
+
22
+ def classified_app_name
23
+ inflector.classify(app)
24
+ end
25
+
26
+ def underscored_app_name
27
+ inflector.underscore(app)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :inflector
33
+
34
+ attr_reader :app
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ require "json" # required for Hanami::Action::Flash to work
5
+ require "hanami/action"
6
+ require "hanami/action/cookies"
7
+ require "hanami/action/csrf_protection"
8
+ require "hanami/action/session"
9
+
10
+ module <%= classified_app_name %>
11
+ class Action < Hanami::Action
12
+ def self.inherited(klass)
13
+ super
14
+
15
+ # These will need to be sorted by the framework eventually
16
+ klass.include Hanami::Action::Cookies
17
+ klass.include Hanami::Action::Session
18
+ klass.include Hanami::Action::CSRFProtection
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami"
4
+
5
+ module <%= classified_app_name %>
6
+ class Application < Hanami::Application
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/boot"
4
+
5
+ run Hanami.app
@@ -0,0 +1,9 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ module <%= classified_app_name %>
5
+ module Entities
6
+ end
7
+ end
8
+
9
+ Dir[File.join(__dir__, "entities", "*.rb")].each(&method(:require))
@@ -0,0 +1,13 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ require "dry/transformer"
5
+
6
+ module <%= classified_app_name %>
7
+ module Functions
8
+ extend Dry::Transformer::Registry
9
+
10
+ import Dry::Transformer::ArrayTransformations
11
+ import Dry::Transformer::HashTransformations
12
+ end
13
+ end
@@ -0,0 +1,19 @@
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-validations", "<%= hanami_version %>"
10
+ gem "hanami-view", git: "https://github.com/hanami/view.git", branch: "master"
11
+ gem "dry-cli", "~> 0.6", require: false, git: "https://github.com/dry-rb/dry-cli.git", branch: "feature/file-utils-class"
12
+ gem "hanami-cli", git: "https://github.com/hanami/cli.git", branch: "main"
13
+ gem "hanami", require: false, git: "https://github.com/hanami/hanami.git", branch: "feature/hanami-2-cli"
14
+
15
+ gem "puma"
16
+
17
+ group :cli, :development, :test do
18
+ gem "hanami-rspec", git: "https://github.com/hanami/rspec.git", branch: "main"
19
+ end
@@ -0,0 +1,18 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ require "dry/monads"
5
+ require "dry/matcher/result_matcher"
6
+
7
+ module <%= classified_app_name %>
8
+ class Operation
9
+ include Dry::Monads[:result, :try]
10
+
11
+ class << self
12
+ def inherited(klass)
13
+ klass.include Dry::Monads[:do]
14
+ klass.include Dry::Matcher::ResultMatcher.for(:call)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/application/rake_tasks"
@@ -0,0 +1 @@
1
+ # <%= classified_app_name %>
@@ -0,0 +1,13 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ require "rom-repository"
5
+ require_relative "entities"
6
+
7
+ module <%= classified_app_name %>
8
+ class Repository < ROM::Repository::Root
9
+ include Deps[container: "persistence.rom"]
10
+
11
+ struct_namespace Entities
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ Hanami.application.routes do
4
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "<%= underscored_app_name %>/types"
4
+
5
+ Hanami.application.settings do
6
+ end
@@ -0,0 +1,10 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ require "dry/types"
5
+
6
+ module <%= classified_app_name %>
7
+ module Types
8
+ include Dry.Types
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ require "dry/validation"
5
+ require "dry/schema/messages/i18n"
6
+
7
+ module <%= classified_app_name %>
8
+ module Validation
9
+ class Contract < Dry::Validation::Contract
10
+ config.messages.backend = :i18n
11
+ config.messages.top_namespace = "validation"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/view/context"
4
+
5
+ module <%= classified_app_name %>
6
+ module View
7
+ class Context < Hanami::View::Context
8
+ def initialize(**args)
9
+ defaults = {content: {}}
10
+
11
+ super(**defaults.merge(args))
12
+ end
13
+ end
14
+ end
15
+ end