hanami-cli_bulma 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +7 -0
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/ci.yml +68 -0
  4. data/.gitignore +13 -0
  5. data/.repobot.yml +9 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +46 -0
  8. data/.tool-versions +1 -0
  9. data/.yardopts +3 -0
  10. data/CHANGELOG.md +374 -0
  11. data/CODE_OF_CONDUCT.md +84 -0
  12. data/Gemfile +31 -0
  13. data/LICENSE.md +22 -0
  14. data/README.md +61 -0
  15. data/Rakefile +12 -0
  16. data/bin/console +15 -0
  17. data/bin/setup +8 -0
  18. data/docker-compose.yml +14 -0
  19. data/exe/hanami +15 -0
  20. data/hanami-cli_bulma.gemspec +47 -0
  21. data/lib/hanami/cli_bulma/bundler.rb +16 -0
  22. data/lib/hanami/cli_bulma/commands/app/command.rb +21 -0
  23. data/lib/hanami/cli_bulma/commands/app/generate/action.rb +25 -0
  24. data/lib/hanami/cli_bulma/commands/app/generate/slice.rb +27 -0
  25. data/lib/hanami/cli_bulma/commands/app/generate/view.rb +23 -0
  26. data/lib/hanami/cli_bulma/commands/app/generate.rb +16 -0
  27. data/lib/hanami/cli_bulma/commands/app.rb +30 -0
  28. data/lib/hanami/cli_bulma/commands/gem/new.rb +28 -0
  29. data/lib/hanami/cli_bulma/commands/gem.rb +21 -0
  30. data/lib/hanami/cli_bulma/commands.rb +35 -0
  31. data/lib/hanami/cli_bulma/generators/app/action/action.erb +17 -0
  32. data/lib/hanami/cli_bulma/generators/app/action/slice_action.erb +17 -0
  33. data/lib/hanami/cli_bulma/generators/app/action.rb +72 -0
  34. data/lib/hanami/cli_bulma/generators/app/slice/action.erb +7 -0
  35. data/lib/hanami/cli_bulma/generators/app/slice/app_css.erb +7 -0
  36. data/lib/hanami/cli_bulma/generators/app/slice/app_js.erb +1 -0
  37. data/lib/hanami/cli_bulma/generators/app/slice/app_layout.erb +46 -0
  38. data/lib/hanami/cli_bulma/generators/app/slice/favicon.ico +0 -0
  39. data/lib/hanami/cli_bulma/generators/app/slice/helpers.erb +10 -0
  40. data/lib/hanami/cli_bulma/generators/app/slice/keep.erb +0 -0
  41. data/lib/hanami/cli_bulma/generators/app/slice/operation.erb +7 -0
  42. data/lib/hanami/cli_bulma/generators/app/slice/relation.erb +8 -0
  43. data/lib/hanami/cli_bulma/generators/app/slice/repo.erb +8 -0
  44. data/lib/hanami/cli_bulma/generators/app/slice/routes.erb +3 -0
  45. data/lib/hanami/cli_bulma/generators/app/slice/struct.erb +8 -0
  46. data/lib/hanami/cli_bulma/generators/app/slice/view.erb +7 -0
  47. data/lib/hanami/cli_bulma/generators/app/slice.rb +26 -0
  48. data/lib/hanami/cli_bulma/generators/app/view/app_template-edit.html.erb +24 -0
  49. data/lib/hanami/cli_bulma/generators/app/view/app_template-index.html.erb +24 -0
  50. data/lib/hanami/cli_bulma/generators/app/view/app_template-new.html.erb +24 -0
  51. data/lib/hanami/cli_bulma/generators/app/view/app_template-show.html.erb +5 -0
  52. data/lib/hanami/cli_bulma/generators/app/view/app_template.html.erb +5 -0
  53. data/lib/hanami/cli_bulma/generators/app/view/app_view-edit.erb +10 -0
  54. data/lib/hanami/cli_bulma/generators/app/view/app_view-index.erb +10 -0
  55. data/lib/hanami/cli_bulma/generators/app/view/app_view-new.erb +10 -0
  56. data/lib/hanami/cli_bulma/generators/app/view/app_view-show.erb +10 -0
  57. data/lib/hanami/cli_bulma/generators/app/view/app_view.erb +10 -0
  58. data/lib/hanami/cli_bulma/generators/app/view/slice_template-edit.html.erb +24 -0
  59. data/lib/hanami/cli_bulma/generators/app/view/slice_template-index.html.erb +26 -0
  60. data/lib/hanami/cli_bulma/generators/app/view/slice_template-new.html.erb +24 -0
  61. data/lib/hanami/cli_bulma/generators/app/view/slice_template-show.html.erb +5 -0
  62. data/lib/hanami/cli_bulma/generators/app/view/slice_template.html.erb +5 -0
  63. data/lib/hanami/cli_bulma/generators/app/view/slice_view-edit.erb +10 -0
  64. data/lib/hanami/cli_bulma/generators/app/view/slice_view-index.erb +13 -0
  65. data/lib/hanami/cli_bulma/generators/app/view/slice_view-new.erb +10 -0
  66. data/lib/hanami/cli_bulma/generators/app/view/slice_view-show.erb +10 -0
  67. data/lib/hanami/cli_bulma/generators/app/view/slice_view.erb +10 -0
  68. data/lib/hanami/cli_bulma/generators/app/view.rb +73 -0
  69. data/lib/hanami/cli_bulma/generators/app/view_context.rb +19 -0
  70. data/lib/hanami/cli_bulma/generators/gem/app/404.html +82 -0
  71. data/lib/hanami/cli_bulma/generators/gem/app/500.html +82 -0
  72. data/lib/hanami/cli_bulma/generators/gem/app/action.erb +12 -0
  73. data/lib/hanami/cli_bulma/generators/gem/app/app.erb +8 -0
  74. data/lib/hanami/cli_bulma/generators/gem/app/app_css.erb +7 -0
  75. data/lib/hanami/cli_bulma/generators/gem/app/app_js.erb +1 -0
  76. data/lib/hanami/cli_bulma/generators/gem/app/app_layout.erb +45 -0
  77. data/lib/hanami/cli_bulma/generators/gem/app/assets.js +16 -0
  78. data/lib/hanami/cli_bulma/generators/gem/app/config_ru.erb +5 -0
  79. data/lib/hanami/cli_bulma/generators/gem/app/dev +8 -0
  80. data/lib/hanami/cli_bulma/generators/gem/app/env.erb +4 -0
  81. data/lib/hanami/cli_bulma/generators/gem/app/favicon.ico +0 -0
  82. data/lib/hanami/cli_bulma/generators/gem/app/gemfile.erb +44 -0
  83. data/lib/hanami/cli_bulma/generators/gem/app/gitignore.erb +9 -0
  84. data/lib/hanami/cli_bulma/generators/gem/app/helpers.erb +10 -0
  85. data/lib/hanami/cli_bulma/generators/gem/app/keep.erb +0 -0
  86. data/lib/hanami/cli_bulma/generators/gem/app/operation.erb +13 -0
  87. data/lib/hanami/cli_bulma/generators/gem/app/package.json.erb +8 -0
  88. data/lib/hanami/cli_bulma/generators/gem/app/procfile.erb +4 -0
  89. data/lib/hanami/cli_bulma/generators/gem/app/puma.erb +47 -0
  90. data/lib/hanami/cli_bulma/generators/gem/app/rakefile.erb +3 -0
  91. data/lib/hanami/cli_bulma/generators/gem/app/readme.erb +1 -0
  92. data/lib/hanami/cli_bulma/generators/gem/app/relation.erb +10 -0
  93. data/lib/hanami/cli_bulma/generators/gem/app/repo.erb +10 -0
  94. data/lib/hanami/cli_bulma/generators/gem/app/routes.erb +7 -0
  95. data/lib/hanami/cli_bulma/generators/gem/app/settings.erb +9 -0
  96. data/lib/hanami/cli_bulma/generators/gem/app/struct.erb +10 -0
  97. data/lib/hanami/cli_bulma/generators/gem/app/types.erb +11 -0
  98. data/lib/hanami/cli_bulma/generators/gem/app/validator.erb +12 -0
  99. data/lib/hanami/cli_bulma/generators/gem/app/view.erb +9 -0
  100. data/lib/hanami/cli_bulma/generators/gem/app.rb +114 -0
  101. data/lib/hanami/cli_bulma/version.rb +11 -0
  102. data/lib/hanami/cli_bulma.rb +50 -0
  103. data/lib/hanami-cli_bulma.rb +3 -0
  104. data/project.yml +2 -0
  105. metadata +242 -0
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Hanami::CLI
2
+
3
+ This gem adds support to [Bulma CSS Framework](https://bulma.io) for hanamai generators.
4
+
5
+ NOTE:
6
+ This library contains all of the CLI commands for [full-stack Hanami applications](`https://github.com/hanami/hanami`).
7
+
8
+ ## Contact
9
+
10
+ - Home page: https://github.com/swilgosz/hanami-cli_bulma
11
+ - Mailing List: [Hanami Mastery Newsletter](https://mailchi.mp/6ac8f64f3c5d/hanami-mastery-newsletter)
12
+ - Bugs/Issues: https://github.com/swilgosz/hanami-cli_bulma/issues
13
+ - API Doc: http://rubydoc.info/gems/hanami-cli_bulma
14
+ - Chat: http://discourse.hanamirb.org
15
+
16
+ ## Installation
17
+
18
+ **Hanami::CLIBulma** supports Ruby (MRI) 3.1+
19
+
20
+ Add gem to your gemfile
21
+
22
+ ```shell
23
+ # Gemfile
24
+ gem 'hanami-cli_bulma'
25
+ ```
26
+
27
+ ```shell
28
+ bundle install
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```shell
34
+ hanami g view users.show
35
+ ```
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ In order to run all of the tests, you should run `docker compose up` separately, to run a `postgres` server.
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/swilgosz/hanami-cli_bulma. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/swilgosz/hanami-cli_bulma/blob/main/CODE_OF_CONDUCT.md).
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52
+
53
+ ## Code of Conduct
54
+
55
+ Everyone interacting in the `Hanami::CLIBulma` project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/swilgosz/hanami-cli_Bulma/blob/main/CODE_OF_CONDUCT.md).
56
+
57
+ ## Copyright
58
+
59
+ Gem is extracted from `hanami-cli`, and managed by Sebastian Wilgosz
60
+
61
+ Copyright © 2014–2024 Sebastian Wilgosz – Released under MIT License
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "hanami-cli_bulma"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,14 @@
1
+ services:
2
+ mysql:
3
+ image: mysql:latest
4
+ ports:
5
+ - 3307:3306
6
+ environment:
7
+ MYSQL_ROOT_PASSWORD: password
8
+ postgres:
9
+ image: postgres:latest
10
+ ports:
11
+ - 5433:5432
12
+ environment:
13
+ POSTGRES_USER: postgres
14
+ POSTGRES_PASSWORD: password
data/exe/hanami ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "hanami/cli_bulma"
6
+
7
+ cli = Dry::CLI.new(Hanami::CLIBulma)
8
+ # Hanami::CLIBulma::Bundler.require(:cli)
9
+
10
+ begin
11
+ cli.call
12
+ rescue Hanami::CLI::Error => exception
13
+ $stderr.puts(exception.message) # rubocop:disable Style/StderrPuts
14
+ exit(1)
15
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require_relative "lib/hanami/cli_bulma/version"
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "hanami-cli_bulma"
10
+ spec.version = Hanami::CLIBulma::VERSION
11
+ spec.authors = ["Sebastian Wilgosz"]
12
+ spec.email = ["sebastian@hanamimastery.com"]
13
+
14
+ spec.summary = "Hanami CLI generators extension for Bulma"
15
+ spec.description = "Hanami command line Bulma CSS Framework integration"
16
+ spec.homepage = "https://github.com/swilgosz/hanami-cli_bulma"
17
+ spec.license = "MIT"
18
+
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/swilgosz/hanami-cli_bulma"
23
+ spec.metadata["changelog_uri"] = "https://github.com/swilgosz/hanami-cli_bulma/blob/main/CHANGELOG.md"
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
29
+ end
30
+
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
+
34
+ # spec.bindir = "exe"
35
+ # spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+ spec.metadata["rubygems_mfa_required"] = "true"
38
+ spec.required_ruby_version = ">= 3.1"
39
+
40
+ spec.add_dependency "bundler", "~> 2.1"
41
+ spec.add_dependency "hanami-cli", "= 2.2.0.beta2"
42
+ spec.add_dependency "zeitwerk", "~> 2.6"
43
+
44
+ spec.add_development_dependency "dry-inflector", "~> 1.0", "< 2"
45
+ spec.add_development_dependency "rspec", "~> 3.9"
46
+ spec.add_development_dependency "rubocop", "~> 1.0"
47
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler"
4
+ require "open3"
5
+ require "etc"
6
+
7
+ module Hanami
8
+ module CLIBulma
9
+ # Conveniences for running `bundler` from CLI commands.
10
+ #
11
+ # @since 0.0.1
12
+ # @api public
13
+ class Bundler < Hanami::CLI::Bundler
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/env"
4
+ require_relative "db/utils/database"
5
+ require_relative "../../files"
6
+
7
+ module Hanami
8
+ module CLIBulma
9
+ module Commands
10
+ module App
11
+ # Base class for `hanami` CLI commands intended to be executed within an existing Hanami
12
+ # app.
13
+ #
14
+ # @since 0.0.1
15
+ # @api public
16
+ class Command < Hanami::CLI::Commands::App::Command
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLIBulma
5
+ module Commands
6
+ module App
7
+ module Generate
8
+ # @since 0.0.1
9
+ # @api private
10
+ class Action < Hanami::CLI::Commands::App::Generate::Action
11
+ # @since 0.0.1
12
+ # @api private
13
+ def initialize(
14
+ fs:, inflector:,
15
+ generator: Generators::App::Action.new(fs: fs, inflector: inflector),
16
+ **opts
17
+ )
18
+ super(fs: fs, inflector: inflector, generator: generator, **opts)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ module Hanami
5
+ module CLIBulma
6
+ module Commands
7
+ module App
8
+ module Generate
9
+ # @since 0.0.1
10
+ # @api private
11
+ class Slice < Hanami::CLI::Commands::App::Generate::Slice
12
+ # @since 0.0.1
13
+ # @api private
14
+ def initialize(
15
+ fs:, inflector:,
16
+ generator: Generators::App::Slice.new(fs: fs, inflector: inflector),
17
+ **opts
18
+ )
19
+ super(fs: fs, inflector: inflector, generator: generator, **opts)
20
+ @generator = generator
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLIBulma
5
+ module Commands
6
+ module App
7
+ module Generate
8
+ # @since 0.0.1
9
+ # @api private
10
+ class View < ::Hanami::CLI::Commands::App::Generate::View
11
+ def initialize(
12
+ fs:, inflector:,
13
+ generator: Generators::App::View.new(fs: fs, inflector: inflector),
14
+ **opts
15
+ )
16
+ super(fs: fs, inflector: inflector, generator: generator, **opts)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLIBulma
5
+ module Commands
6
+ module App
7
+ # @since 0.0.1
8
+ # @api private
9
+ module Generate
10
+ require_relative "generate/slice"
11
+ require_relative "generate/action"
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLIBulma
5
+ module Commands
6
+ # Commands made available when the `hanami` CLI is executed within an Hanami app.
7
+ #
8
+ # @api private
9
+ # @since 0.0.1
10
+ module App
11
+ # @since 0.0.1
12
+ # @api private
13
+ def self.extended(base)
14
+ base.module_eval do
15
+ register "generate", aliases: ["g"] do |prefix|
16
+ prefix.register "slice", Generate::Slice
17
+ if Hanami.bundled?("hanami-controller")
18
+ prefix.register "action", Generate::Action
19
+ end
20
+
21
+ if Hanami.bundled?("hanami-view")
22
+ prefix.register "view", Generate::View
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLIBulma
5
+ module Commands
6
+ module Gem
7
+ # @since 2.0.0
8
+ # @api private
9
+ class New < Hanami::CLI::Commands::Gem::New
10
+ # @since 2.0.0
11
+ # @api private
12
+ def initialize(
13
+ fs:, inflector:,
14
+ bundler: CLIBulma::Bundler.new(fs: fs),
15
+ generator: Generators::Gem::App.new(fs: fs, inflector: inflector),
16
+ system_call: Hanami::CLI::SystemCall.new,
17
+ **opts
18
+ )
19
+ super(fs: fs, inflector: inflector, **opts)
20
+ @bundler = bundler
21
+ @generator = generator
22
+ @system_call = system_call
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLIBulma
5
+ module Commands
6
+ # Commands made available when the `hanami` CLI is executed outside of an Hanami app.
7
+ #
8
+ # @since 2.0.0
9
+ # @api public
10
+ module Gem
11
+ # @since 2.0.0
12
+ # @api private
13
+ def self.extended(base)
14
+ base.module_eval do
15
+ register "new", Commands::Gem::New
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'hanami/cli'
4
+
5
+ module Hanami
6
+ module CLIBulma
7
+ # Contains the commands available for the current `hanami` CLI execution, depending on whether
8
+ # the CLI is executed inside or outside an Hanami app.
9
+ #
10
+ # @see .within_hanami_app?
11
+ #
12
+ # @api public
13
+ # @since 0.0.1
14
+ module Commands
15
+ end
16
+
17
+ # @api private
18
+ def self.register_commands!(within_hanami_app = within_hanami_app?)
19
+ commands =
20
+ if within_hanami_app
21
+ require "hanami/cli/commands/app"
22
+ extend(Hanami::CLI::Commands::App)
23
+
24
+ require_relative "commands/app"
25
+ extend(Hanami::CLIBulma::Commands::App)
26
+ else
27
+ require "hanami/cli/commands/gem"
28
+ extend(Hanami::CLI::Commands::Gem)
29
+
30
+ require_relative "commands/gem"
31
+ extend(Hanami::CLIBulma::Commands::Gem)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= camelized_app_name %>
4
+ module Actions
5
+ <%= module_controller_declaration %>
6
+ <%= module_controller_offset %>class <%= camelized_action_name %> < <%= camelized_app_name %>::Action
7
+ <%- if bundled_views? -%>
8
+ <%= module_controller_offset %> def handle(request, response)
9
+ <%- else -%>
10
+ <%= module_controller_offset %> def handle(request, response)
11
+ <%= module_controller_offset %> response.body = self.class.name
12
+ <%- end -%>
13
+ <%= module_controller_offset %> end
14
+ <%= module_controller_offset %>end
15
+ <%= module_controller_end %>
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= camelized_slice_name %>
4
+ module Actions
5
+ <%= module_controller_declaration %>
6
+ <%= module_controller_offset %>class <%= camelized_action_name %> < <%= camelized_slice_name %>::Action
7
+ <%- if bundled_views? -%>
8
+ <%= module_controller_offset %> def handle(request, response)
9
+ <%- else -%>
10
+ <%= module_controller_offset %> def handle(request, response)
11
+ <%= module_controller_offset %> response.body = self.class.name
12
+ <%- end -%>
13
+ <%= module_controller_offset %> end
14
+ <%= module_controller_offset %>end
15
+ <%= module_controller_end %>
16
+ end
17
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "erb"
4
+
5
+ # rubocop:disable Metrics/ParameterLists
6
+ module Hanami
7
+ module CLIBulma
8
+ module Generators
9
+ module App
10
+ # @since 0.0.1
11
+ # @api private
12
+ class Action < Hanami::CLI::Generators::App::Action
13
+ def call(app, controller, action, url, http, format, skip_view, slice, context: nil)
14
+ context ||= Hanami::CLI::Generators::App::ActionContext.new(inflector, app, slice, controller, action)
15
+ if slice
16
+ generate_for_slice(controller, action, url, http, format, skip_view, slice, context)
17
+ else
18
+ generate_for_app(controller, action, url, http, format, skip_view, context)
19
+ end
20
+
21
+ view_directory = fs.join("app", "views", controller)
22
+ if generate_view?(skip_view, action, view_directory)
23
+ view_generator = Generators::App::View.new(fs: fs, inflector: inflector)
24
+ view_name = [controller, action].join(Hanami::CLI::Commands::App::Command::ACTION_SEPARATOR)
25
+ view_generator.call(app, view_name, format, slice)
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ # rubocop:disable Metrics/AbcSize
32
+ def generate_for_slice(controller, action, url, http, format, skip_view, slice, context)
33
+ slice_directory = fs.join("slices", slice)
34
+ raise Hanami::CLI::Errors::MissingSliceError.new(slice) unless fs.directory?(slice_directory)
35
+
36
+ fs.inject_line_at_block_bottom(
37
+ fs.join("config", "routes.rb"),
38
+ slice_matcher(slice),
39
+ route(controller, action, url, http)
40
+ )
41
+
42
+ fs.mkdir(directory = fs.join(slice_directory, "actions", controller))
43
+ fs.write(fs.join(directory, "#{action}.rb"), t("slice_action.erb", context))
44
+ end
45
+
46
+ def generate_for_app(controller, action, url, http, format, skip_view, context)
47
+ fs.inject_line_at_class_bottom(
48
+ fs.join("config", "routes.rb"),
49
+ "class Routes",
50
+ route(controller, action, url, http)
51
+ )
52
+
53
+ fs.mkdir(directory = fs.join("app", "actions", controller))
54
+ fs.write(fs.join(directory, "#{action}.rb"), t("action.erb", context))
55
+ end
56
+ # rubocop:enable Metrics/AbcSize
57
+
58
+ def template(path, context)
59
+ require "erb"
60
+
61
+ ERB.new(
62
+ File.read(__dir__ + "/action/#{path}"), trim_mode: "-",
63
+ ).result(context.ctx)
64
+ end
65
+
66
+ alias_method :t, :template
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ # rubocop:enable Metrics/ParameterLists
@@ -0,0 +1,7 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ module <%= camelized_slice_name %>
5
+ class Action < <%= camelized_app_name %>::Action
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ @import "https://cdn.jsdelivr.net/npm/bulma@0.9.2/css/bulma.min.css";
2
+
3
+ body {
4
+ background-color: #fff;
5
+ color: #000;
6
+ font-family: sans-serif;
7
+ }
@@ -0,0 +1 @@
1
+ import "../css/app.css";
@@ -0,0 +1,46 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title><%= humanized_app_name %> - <%= humanized_slice_name %></title>
7
+ <%- if bundled_assets? -%>
8
+ <%%= favicon_tag %>
9
+ <%= stylesheet_erb_tag %>
10
+ <%- end -%>
11
+ </head>
12
+ <body>
13
+ <nav class="navbar" role="navigation" aria-label="main navigation">
14
+ <div class="navbar-brand">
15
+ <a class="navbar-item" href="https://hanamimastery.com">
16
+ <img src="https://hanamimastery.com/logo-hm-letter.jpeg" height="28">
17
+ </a>
18
+ </div>
19
+ <div id="top-navigation" class="navbar-menu">
20
+ <div class="navbar-start">
21
+ <%%= link_to 'Home', '/', class: 'navbar-item' %>
22
+ </div>
23
+ </div>
24
+ </nav>
25
+
26
+ <section class="section">
27
+ <div class="container">
28
+ <%%= yield %>
29
+ </div>
30
+ </section>
31
+
32
+ <footer class="footer">
33
+ <div class="content has-text-centered">
34
+ <p>
35
+ <strong><%= humanized_app_name %></strong>. The source code is licensed
36
+ <a href="http://opensource.org/licenses/mit-license.php">MIT</a>. The website content
37
+ is licensed <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY NC SA 4.0</a>.
38
+ </p>
39
+ </div>
40
+ </footer>
41
+
42
+ <%- if bundled_assets? -%>
43
+ <%= javascript_erb_tag %>
44
+ <%- end -%>
45
+ </body>
46
+ </html>
@@ -0,0 +1,10 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ module <%= camelized_slice_name %>
5
+ module Views
6
+ module Helpers
7
+ # Add your view helpers here
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ # auto_register: false
2
+ # frozen_string_literal: true
3
+
4
+ module <%= camelized_slice_name %>
5
+ class Operation < <%= camelized_app_name %>::Operation
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= camelized_slice_name %>
4
+ module DB
5
+ class Relation < <%= camelized_app_name %>::DB::Relation
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= camelized_slice_name %>
4
+ module DB
5
+ class Repo < <%= camelized_app_name %>::DB::Repo
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+
2
+ slice :<%= underscored_slice_name %>, at: "<%= url %>" do
3
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= camelized_slice_name %>
4
+ module DB
5
+ class Struct < <%= camelized_app_name %>::DB::Struct
6
+ end
7
+ end
8
+ end