rubymonolith 0.1.5 → 0.1.7

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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +30 -4
  3. data/Rakefile +2 -0
  4. data/app/assets/images/monolith/logo.svg +6 -0
  5. data/app/assets/stylesheets/monolith/application.tailwind.css +14 -0
  6. data/app/components/monolith/base.rb +6 -0
  7. data/app/components/monolith/table.rb +37 -0
  8. data/app/controllers/monolith/application_controller.rb +68 -2
  9. data/app/controllers/monolith/emails_controller.rb +61 -0
  10. data/app/controllers/monolith/exceptions_controller.rb +370 -0
  11. data/app/controllers/monolith/gems_controller.rb +230 -0
  12. data/app/controllers/monolith/generators_controller.rb +377 -0
  13. data/app/controllers/monolith/home_controller.rb +10 -0
  14. data/app/controllers/monolith/models_controller.rb +319 -0
  15. data/app/controllers/monolith/routes_controller.rb +157 -0
  16. data/app/controllers/monolith/tables_controller.rb +168 -0
  17. data/app/views/monolith/base.rb +3 -0
  18. data/app/views/monolith/layouts/base.rb +23 -0
  19. data/config/routes.rb +14 -0
  20. data/lib/generators/monolith/content/USAGE +8 -0
  21. data/lib/generators/monolith/content/content_generator.rb +25 -0
  22. data/lib/generators/monolith/generators/base.rb +38 -0
  23. data/lib/generators/monolith/install/install_generator.rb +14 -95
  24. data/lib/generators/monolith/view/USAGE +8 -0
  25. data/lib/generators/monolith/view/view_generator.rb +20 -0
  26. data/lib/monolith/cli/template.rb +78 -5
  27. data/lib/monolith/cli.rb +22 -3
  28. data/lib/monolith/engine.rb +31 -0
  29. data/lib/monolith/version.rb +1 -1
  30. data/lib/tasks/monolith_tasks.rake +13 -4
  31. metadata +66 -10
  32. data/app/assets/stylesheets/monolith/application.css +0 -15
  33. data/app/views/layouts/monolith/application.html.erb +0 -15
@@ -0,0 +1,25 @@
1
+ require_relative "../generators/base.rb"
2
+
3
+ class Monolith::ContentGenerator < Monolith::Generators::Base
4
+ source_root File.expand_path("templates", __dir__)
5
+
6
+ desc "Installs gems to manage content"
7
+
8
+ def append_gemfile
9
+ # Manage content via Sitepress in ./app/content
10
+ gem "sitepress-rails", git: "https://github.com/sitepress/sitepress.git"
11
+
12
+ # Hackable markdown renderers that make plugging Markdown into Rails a
13
+ # much more sane proposition.
14
+ gem "markdown-rails", git: "https://github.com/sitepress/markdown-rails.git"
15
+ end
16
+
17
+ def bundle_gems
18
+ bundle_command "install"
19
+ end
20
+
21
+ def install_gems
22
+ generate "sitepress:install"
23
+ generate "markdown_rails:install"
24
+ end
25
+ end
@@ -0,0 +1,38 @@
1
+ module Monolith
2
+ module Generators
3
+ class Base < Rails::Generators::Base
4
+
5
+ protected
6
+
7
+ # Lifted from https://github.com/bradgessler/rails/blob/bbd298d7b036c550912139b41903f9f37087befe/railties/lib/rails/generators/app_base.rb#L380-L404,
8
+ # which is not ideal. I tried to inherit `AppBase`, which also didn't work because it wanted an argument, which
9
+ # this generator does not need. Look into moving this into a module in Rails core and the including that in here
10
+ # or decomposing the `AppBase` Thor class in a way that would let me inherit it.
11
+ def bundle_command(command, env = {})
12
+ say_status :run, "bundle #{command}"
13
+
14
+ # We are going to shell out rather than invoking Bundler::CLI.new(command)
15
+ # because `rails new` loads the Thor gem and on the other hand bundler uses
16
+ # its own vendored Thor, which could be a different version. Running both
17
+ # things in the same process is a recipe for a night with paracetamol.
18
+ #
19
+ # Thanks to James Tucker for the Gem tricks involved in this call.
20
+ _bundle_command = Gem.bin_path("bundler", "bundle")
21
+
22
+ require "bundler"
23
+ Bundler.with_original_env do
24
+ exec_bundle_command(_bundle_command, command, env)
25
+ end
26
+ end
27
+
28
+ def exec_bundle_command(bundle_command, command, env)
29
+ full_command = %Q["#{Gem.ruby}" "#{bundle_command}" #{command}]
30
+ if options[:quiet]
31
+ system(env, full_command, out: File::NULL)
32
+ else
33
+ system(env, full_command)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,63 +1,29 @@
1
- class Monolith::InstallGenerator < Rails::Generators::Base
1
+ require_relative "../generators/base.rb"
2
+
3
+ class Monolith::InstallGenerator < Monolith::Generators::Base
2
4
  source_root File.expand_path("templates", __dir__)
3
5
 
4
- desc "Installs the base gems for Monolith"
6
+ desc "Installs gems and frameworks for Monolith"
5
7
 
6
8
  def append_gemfile
7
- ###### Authorization & Authentication ######
8
-
9
- # Huh!? No omni-auth! Correct ... we just handle logins via email to start. Way
10
- # less configuration and you need email addresses.
11
- gem "nopassword", git: "https://github.com/rocketshipio/nopassword.git", branch: "main"
12
-
13
- # Objects for authorizing user actions.
14
- gem "pundit"
15
-
16
- ###### Views & UI ######
17
-
18
- # Encapsulate views (instead of using partials)
19
- gem "view_component"
20
-
21
- # Displays UTC times from the database in the users local time, all computed client-side.
22
- # Super duper useful for keeping times sane
23
- gem "local_time"
24
-
25
- # Instead of HAML or Erb. What's that? You don't like these shorthand template
26
- # languages? I don't like chasing down empty Erb tags in a heavily compentized
27
- # application, so slim wins the day.
28
- gem "slim-rails", "~> 3.3"
29
-
30
- ###### Content Management ######
31
-
32
- # Content is managed via Sitepress
33
- gem "sitepress-rails", git: "https://github.com/sitepress/sitepress.git"
34
-
35
- # Lots of markdown content for help, feature, and how-to articles.
36
- gem "markdown-rails", "~> 1.0"
37
-
38
- ###### Analytics ######
39
-
40
- # First-party analytics keeps privacy sane and Google out.
41
- gem "ahoy_matey"
9
+ gem "rubymonolith"
10
+ end
42
11
 
43
- # Useful for running queries against Ahoy.
44
- gem "groupdate"
12
+ def bundle_gems
13
+ bundle_command "install"
14
+ end
45
15
 
46
- ###### Testing ######
16
+ def install_gems
17
+ generate "monolith:content"
18
+ generate "monolith:view"
19
+ end
47
20
 
21
+ def append_gemfile
48
22
  # Some people hate rspec. No idea why, but I dig it, so its part of monolith.
49
23
  gem "rspec-rails", group: [:development, :test]
50
24
 
51
25
  # More sane than fixtures
52
26
  gem "factory_bot", group: [:development, :test]
53
-
54
- ##### Other gems ######
55
-
56
- # Parses dates
57
- gem "chronic", "~> 0.10.2"
58
-
59
- # Send all web addresses to the URL defined via CANONICAL_HOST, if present.
60
- gem "rack-canonical-host", "~> 1.1"
61
27
  end
62
28
 
63
29
  def copy_files
@@ -65,22 +31,6 @@ class Monolith::InstallGenerator < Rails::Generators::Base
65
31
  directory "github", ".github"
66
32
  end
67
33
 
68
- def bundle_gems
69
- bundle_command "install"
70
- end
71
-
72
- def install_sitepress
73
- generate "sitepress:install"
74
- end
75
-
76
- def install_nopassword
77
- generate "nopassword:install"
78
- end
79
-
80
- def install_ahoy
81
- generate "ahoy:install"
82
- end
83
-
84
34
  def post_install_message
85
35
  say_status "next steps", <<~DOCS
86
36
  [ ] Run `./bin/rails db:create db:migrate`
@@ -88,35 +38,4 @@ class Monolith::InstallGenerator < Rails::Generators::Base
88
38
  [ ] Open `http://localhost:3000` in your browser
89
39
  DOCS
90
40
  end
91
-
92
- private
93
- # Lifted from https://github.com/bradgessler/rails/blob/bbd298d7b036c550912139b41903f9f37087befe/railties/lib/rails/generators/app_base.rb#L380-L404,
94
- # which is not ideal. I tried to inherit `AppBase`, which also didn't work because it wanted an argument, which
95
- # this generator does not need. Look into moving this into a module in Rails core and the including that in here
96
- # or decomposing the `AppBase` Thor class in a way that would let me inherit it.
97
- def bundle_command(command, env = {})
98
- say_status :run, "bundle #{command}"
99
-
100
- # We are going to shell out rather than invoking Bundler::CLI.new(command)
101
- # because `rails new` loads the Thor gem and on the other hand bundler uses
102
- # its own vendored Thor, which could be a different version. Running both
103
- # things in the same process is a recipe for a night with paracetamol.
104
- #
105
- # Thanks to James Tucker for the Gem tricks involved in this call.
106
- _bundle_command = Gem.bin_path("bundler", "bundle")
107
-
108
- require "bundler"
109
- Bundler.with_original_env do
110
- exec_bundle_command(_bundle_command, command, env)
111
- end
112
- end
113
-
114
- def exec_bundle_command(bundle_command, command, env)
115
- full_command = %Q["#{Gem.ruby}" "#{bundle_command}" #{command}]
116
- if options[:quiet]
117
- system(env, full_command, out: File::NULL)
118
- else
119
- system(env, full_command)
120
- end
121
- end
122
41
  end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ bin/rails generate install Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,20 @@
1
+ require_relative "../generators/base.rb"
2
+
3
+ class Monolith::ViewGenerator < Monolith::Generators::Base
4
+ source_root File.expand_path("templates", __dir__)
5
+
6
+ desc "Installs gems to manage views in Monolith"
7
+
8
+ def append_gemfile
9
+ # Encapsulate views (instead of using partials)
10
+ gem "phlex-rails"
11
+ end
12
+
13
+ def bundle_gems
14
+ bundle_command "install"
15
+ end
16
+
17
+ def install_gems
18
+ generate "phlex:install"
19
+ end
20
+ end
@@ -1,9 +1,82 @@
1
- if path = ENV["MONOLITH_GEM_PATH"]
2
- gem "monolith", path: path
3
- else
4
- gem "monolith"
1
+ # High-performance async web server built on fibers for better concurrency
2
+ gem "falcon"
3
+
4
+ # Remove puma (Rails default)
5
+ gsub_file "Gemfile", /^gem ["']puma["'].*$/, ""
6
+
7
+ after_bundle do
8
+ # Remove Puma configuration file
9
+ remove_file "config/puma.rb"
10
+ end
11
+
12
+ # Fast, object-oriented view components as an alternative to ERB templates
13
+ gem "phlex-rails"
14
+
15
+ after_bundle do
16
+ generate "phlex:install"
17
+ end
18
+
19
+ # Phlex components for views in controllers
20
+ gem "superview"
21
+
22
+ # A better way to handle forms with Phlex components
23
+ gem "superform"
24
+
25
+ after_bundle do
26
+ generate "superform:install"
27
+ end
28
+
29
+ # Component-based email templates using Phlex
30
+ gem "supermail"
31
+
32
+ after_bundle do
33
+ generate "supermail:install"
5
34
  end
6
35
 
7
36
  after_bundle do
8
- generate "monolith:install"
37
+ # Install DaisyUI and Tailwind plugins
38
+ run "npm init -y"
39
+ run "npm install daisyui@latest @tailwindcss/typography@latest"
40
+
41
+ # Add node_modules to .gitignore
42
+ append_to_file '.gitignore', <<~GITIGNORE
43
+
44
+ # Node modules
45
+ /node_modules/*
46
+ GITIGNORE
47
+
48
+ # Add sources and plugins to Tailwind CSS
49
+ append_to_file 'app/assets/tailwind/application.css', <<~CSS
50
+
51
+ @source "app/content/**/*";
52
+ @source "app/components/**/*";
53
+ @source "app/views/**/*";
54
+ @source "app/controllers/**/*";
55
+ @source "lib/**/*";
56
+
57
+ @plugin "@tailwindcss/typography";
58
+ @plugin "daisyui";
59
+ CSS
60
+
61
+ # Add Superview and Superform includes to ApplicationController
62
+ inject_into_class "app/controllers/application_controller.rb", "ApplicationController", <<~RUBY
63
+ include Superview::Actions
64
+ include Superform::Rails::StrongParameters
65
+ RUBY
66
+ end
67
+
68
+ # File-based content management system for static pages and markdown content
69
+ gem "sitepress-rails"
70
+
71
+ after_bundle do
72
+ generate "sitepress:install"
73
+ # Sitepress includes markdown_rails, so we must install it.
74
+ generate "markdown_rails:install"
75
+ end
76
+
77
+ # Behavior-driven development framework for testing Rails applications
78
+ gem "rspec-rails"
79
+
80
+ after_bundle do
81
+ generate "rspec:install"
9
82
  end
data/lib/monolith/cli.rb CHANGED
@@ -1,21 +1,40 @@
1
1
  require "thor"
2
+ require "foreman"
3
+ require "foreman/engine"
4
+ require "foreman/engine/cli"
2
5
  require "monolith/version"
3
6
 
4
7
  module Monolith
5
8
  class CLI < Thor
6
9
  include Thor::Actions
7
10
 
8
- DEFAULT_PROJECT_NAME = "server".freeze
11
+ DEFAULT_PATH = "server".freeze
9
12
 
10
13
  desc "new [PROJECT_NAME]", "create a new Rails monolith"
11
- def new(project_name = DEFAULT_PROJECT_NAME)
14
+ def new(path = DEFAULT_PATH)
12
15
  template_path = File.join File.expand_path(__dir__), "cli/template.rb"
13
- run "rails new #{project_name} --template #{template_path} --database postgresql --css tailwind"
16
+ run "rails new #{path} --template #{template_path} --css tailwind --skip-test --skip-system-test --skip-solid"
14
17
  end
15
18
 
16
19
  desc "version", "prints version of monolith"
17
20
  def version
18
21
  puts Monolith::VERSION
19
22
  end
23
+
24
+ desc "dev", "Runs a monolith application via Procfile.dev"
25
+ def dev
26
+ procfile = "Procfile.dev"
27
+
28
+ unless File.exist?(procfile)
29
+ puts "Error: #{procfile} not found in current directory"
30
+ exit 1
31
+ end
32
+
33
+ engine = Foreman::Engine::CLI.new(procfile: procfile)
34
+ engine.load_procfile(procfile)
35
+ engine.start
36
+ rescue Interrupt
37
+ puts "\nShutting down..."
38
+ end
20
39
  end
21
40
  end
@@ -1,5 +1,36 @@
1
+ require "phlex-rails"
2
+
1
3
  module Monolith
4
+ module Views
5
+ end
6
+
7
+ module Components
8
+ extend Phlex::Kit
9
+ end
10
+
2
11
  class Engine < ::Rails::Engine
3
12
  isolate_namespace Monolith
13
+
14
+ initializer "monolith.assets" do |app|
15
+ app.config.assets.paths << root.join("app/assets/builds")
16
+ end
17
+
18
+ initializer "monolith.mount", after: :load_config_initializers do |app|
19
+ if Rails.env.development?
20
+ app.routes.prepend do
21
+ mount Monolith::Engine => "/monolith"
22
+ end
23
+ end
24
+ end
25
+
26
+ initializer "monolith.autoloaders" do
27
+ Rails.autoloaders.main.push_dir(
28
+ root.join("app/views/monolith"), namespace: Monolith::Views
29
+ )
30
+
31
+ Rails.autoloaders.main.push_dir(
32
+ root.join("app/components/monolith"), namespace: Monolith::Components
33
+ )
34
+ end
4
35
  end
5
36
  end
@@ -1,3 +1,3 @@
1
1
  module Monolith
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -1,4 +1,13 @@
1
- # desc "Explaining what the task does"
2
- # task :monolith do
3
- # # Task goes here
4
- # end
1
+ namespace :monolith do
2
+ namespace :tailwind do
3
+ desc "Build Tailwind CSS for Monolith engine"
4
+ task :build do
5
+ system "bundle exec tailwindcss --input app/assets/stylesheets/monolith/application.tailwind.css --output app/assets/builds/monolith/tailwind.css --minify"
6
+ end
7
+
8
+ desc "Watch and rebuild Tailwind CSS for Monolith engine"
9
+ task :watch do
10
+ system "bundle exec tailwindcss --input app/assets/stylesheets/monolith/application.tailwind.css --output app/assets/builds/monolith/tailwind.css --watch"
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubymonolith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-04-20 00:00:00.000000000 Z
10
+ date: 2025-11-14 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -38,6 +37,48 @@ dependencies:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
39
  version: '1.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: phlex-rails
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: superview
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: foreman
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.87'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.87'
41
82
  description: CLI used to create Rails monoliths by Rocketship for quickly building
42
83
  applications.
43
84
  email:
@@ -51,19 +92,36 @@ files:
51
92
  - README.md
52
93
  - Rakefile
53
94
  - app/assets/config/monolith_manifest.js
54
- - app/assets/stylesheets/monolith/application.css
95
+ - app/assets/images/monolith/logo.svg
96
+ - app/assets/stylesheets/monolith/application.tailwind.css
97
+ - app/components/monolith/base.rb
98
+ - app/components/monolith/table.rb
55
99
  - app/controllers/monolith/application_controller.rb
100
+ - app/controllers/monolith/emails_controller.rb
101
+ - app/controllers/monolith/exceptions_controller.rb
102
+ - app/controllers/monolith/gems_controller.rb
103
+ - app/controllers/monolith/generators_controller.rb
104
+ - app/controllers/monolith/home_controller.rb
105
+ - app/controllers/monolith/models_controller.rb
106
+ - app/controllers/monolith/routes_controller.rb
107
+ - app/controllers/monolith/tables_controller.rb
56
108
  - app/helpers/monolith/application_helper.rb
57
109
  - app/jobs/monolith/application_job.rb
58
110
  - app/mailers/monolith/application_mailer.rb
59
111
  - app/models/monolith/application_record.rb
60
- - app/views/layouts/monolith/application.html.erb
112
+ - app/views/monolith/base.rb
113
+ - app/views/monolith/layouts/base.rb
61
114
  - config/routes.rb
62
115
  - exe/monolith
116
+ - lib/generators/monolith/content/USAGE
117
+ - lib/generators/monolith/content/content_generator.rb
118
+ - lib/generators/monolith/generators/base.rb
63
119
  - lib/generators/monolith/install/USAGE
64
120
  - lib/generators/monolith/install/install_generator.rb
65
121
  - lib/generators/monolith/install/templates/Brewfile
66
122
  - lib/generators/monolith/install/templates/github/workflows/ruby.yml
123
+ - lib/generators/monolith/view/USAGE
124
+ - lib/generators/monolith/view/view_generator.rb
67
125
  - lib/majestic-monolith.rb
68
126
  - lib/majesticmonolith.rb
69
127
  - lib/monolith.rb
@@ -79,9 +137,8 @@ licenses:
79
137
  metadata:
80
138
  allowed_push_host: https://rubygems.org
81
139
  homepage_uri: https://rubymonolith.org/
82
- source_code_uri: https://github.com/rubymonolith/monolith
83
- changelog_uri: https://github.com/rubymonolith/monolith/tags
84
- post_install_message:
140
+ source_code_uri: https://github.com/rubymonolith/gems
141
+ changelog_uri: https://github.com/rubymonolith/gems/tags
85
142
  rdoc_options: []
86
143
  require_paths:
87
144
  - lib
@@ -96,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
153
  - !ruby/object:Gem::Version
97
154
  version: '0'
98
155
  requirements: []
99
- rubygems_version: 3.4.6
100
- signing_key:
156
+ rubygems_version: 3.6.2
101
157
  specification_version: 4
102
158
  summary: CLI used to create Rails monoliths by Rocketship for quickly building applications.
103
159
  test_files: []
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Monolith</title>
5
- <%= csrf_meta_tags %>
6
- <%= csp_meta_tag %>
7
-
8
- <%= stylesheet_link_tag "monolith/application", media: "all" %>
9
- </head>
10
- <body>
11
-
12
- <%= yield %>
13
-
14
- </body>
15
- </html>