rails_app_generator 0.2.40 → 0.2.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/after_templates/application/klueless/_.rb +99 -0
  4. data/after_templates/application/klueless/app/avo/dashboards/dashboard.rb +13 -0
  5. data/after_templates/application/klueless/app/avo/resources/db_schema_resource.rb +12 -0
  6. data/after_templates/application/klueless/app/avo/resources/rails_app_resource.rb +15 -0
  7. data/after_templates/application/klueless/app/avo/resources/rubocop_resource.rb +12 -0
  8. data/after_templates/application/klueless/app/avo/resources/table_count_resource.rb +12 -0
  9. data/after_templates/application/klueless/app/avo/resources/user_resource.rb +24 -0
  10. data/after_templates/application/klueless/app/controllers/home_controller.rb +12 -0
  11. data/after_templates/application/klueless/app/models/db_schema.rb +11 -0
  12. data/after_templates/application/klueless/app/models/rails_app.rb +3 -0
  13. data/after_templates/application/klueless/app/models/rubocop.rb +11 -0
  14. data/after_templates/application/klueless/app/models/table_count.rb +11 -0
  15. data/after_templates/application/klueless/app/queries/rubocop_log.psql +23 -0
  16. data/after_templates/application/klueless/app/queries/rubocop_log_query.rb +10 -0
  17. data/after_templates/application/klueless/app/queries/sql_query.rb +40 -0
  18. data/after_templates/application/klueless/app/services/seed_service.rb +7 -0
  19. data/after_templates/application/klueless/app/views/home/index.html.erb +6 -0
  20. data/after_templates/application/klueless/app/views/home/quick_signin.html.erb +3 -0
  21. data/after_templates/application/klueless/app/views/layouts/_footer.html.erb +0 -0
  22. data/after_templates/application/klueless/app/views/layouts/_navbar.html.erb +4 -0
  23. data/after_templates/application/klueless/app/views/layouts/application.html.erb +29 -0
  24. data/after_templates/application/klueless/config/initializers/avo.rb +101 -0
  25. data/after_templates/application/klueless/config/locales/en.yml +4 -0
  26. data/after_templates/application/klueless/db/seeds.rb +18 -0
  27. data/after_templates/application/printspeak/_.rb +65 -23
  28. data/after_templates/application/printspeak/db/seeds.rb +3 -3
  29. data/docs/last_run/app_generator_data.json +12 -11
  30. data/docs/last_run/rails_options_data.json +12 -12
  31. data/lib/rails_app_generator/addons/avo.rb +2 -0
  32. data/lib/rails_app_generator/addons/scenic.rb +38 -0
  33. data/lib/rails_app_generator/app_generator.rb +9 -0
  34. data/lib/rails_app_generator/version.rb +1 -1
  35. data/package-lock.json +2 -2
  36. data/package.json +1 -1
  37. data/profiles/application/klueless.json +23 -0
  38. data/profiles/application/printspeak.json +7 -1
  39. data/templates/Gemfile.erb +0 -1
  40. metadata +28 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 635081352fed9b65ca6d9905c209e40edc4d74ea8eb1fcc5ae1f53b58c080fe6
4
- data.tar.gz: 0a0e858ef8a51a3c6ae1dca71ffb112e6e61cfb8802c6a3f4f2139d77195334d
3
+ metadata.gz: 6f266923a169ab15ff8606551f4e023723d947f785513dc89083e0762fd2d568
4
+ data.tar.gz: 55093884128eff848ef3a6b21e415c3739530110590d58308bb7037674022744
5
5
  SHA512:
6
- metadata.gz: b75d081dad75b16ff179fd916c3b25f0f1c2a1fbcd1def2749a7b5cceb2f6af77f950c07abd14fad51a7db3a2d4f12ae3b9c3a8d9ca87f018991c34f3e7889b6
7
- data.tar.gz: 537cac1df29fefd9294470bc47fcbe4510004189f637b7e0da70a815dc2b48a78f9ffb373be70d3b23c4cc0a85c0f8e1f2876f1a6fded9bb44e53de7a236fb3d
6
+ metadata.gz: aaf2fc71ee43c3d12c73b2ab6c91e1c7b5aacd31740a17284b845eb60aff94058634b7d346910242777d1e7ae17d4d75cde624002e6b67b2c5b73e530a6668d2
7
+ data.tar.gz: c2c8a7dbb9d0cf975b4e02d19309147a3a90ae5a58da010b007eba9f2713d8289b6e3dbe1ee5caa04b33ef95a9d6c9eae31f97ec4480cad7969d4fdb1796642f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.2.40](https://github.com/klueless-io/rails_app_generator/compare/v0.2.39...v0.2.40) (2022-08-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add factory_bot_rails profile ([8a6a7ef](https://github.com/klueless-io/rails_app_generator/commit/8a6a7ef6c4b1b26003930776724cedaeb5232f84))
7
+
1
8
  ## [0.2.39](https://github.com/klueless-io/rails_app_generator/compare/v0.2.38...v0.2.39) (2022-08-23)
2
9
 
3
10
 
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ # No Code as a Service Rails Application Builder
4
+ #
5
+ # exe/rag application/klueless
6
+
7
+ self.local_template_path = File.dirname(__FILE__)
8
+
9
+ gac 'base rails 7 image created'
10
+
11
+ prepare_environment
12
+
13
+ after_bundle do
14
+ force_copy
15
+ create_db
16
+ scaffolds
17
+ setup_customizations
18
+ migrate_db
19
+ setup_avo
20
+
21
+ swap1 = ' resources :users'
22
+ swap2 = " devise_for :users, controllers: { sessions: 'users/sessions', registrations: 'users/registrations' }"
23
+
24
+ swap_lines('config/routes.rb', swap1, swap2)
25
+ end
26
+
27
+ def scaffolds
28
+ add_scaffold_controller('users', 'name', 'email')
29
+
30
+ add_scaffold('rails_app', 'name', 'user:references') # name of the rails_app
31
+
32
+ # no of records in each table per region
33
+ add_scaffold('table_count', 'data:jsonb', 'rails_app:references')
34
+ # add_scaffold('table_count_table', 'name', 'region', 'count:integer', 'table_count:references')
35
+
36
+ # rubocop logs
37
+ add_scaffold('rubocop', 'data:jsonb', 'rails_app:references') # import_date is known as created_at
38
+
39
+ # database schema
40
+ add_scaffold('db_schema', 'data:jsonb', 'rails_app:references')
41
+ # add_scaffold('db_schema_table', 'name', 'primary_key', 'primary_key_type', 'db_schema:references')
42
+
43
+ # add_scaffold('db_schema_column', 'name', 'type', 'precision:integer', 'scale:integer', 'default', 'array:boolean', 'null:boolean', 'limit:integer', 'db_schema_table:references')
44
+ # add_scaffold('db_schema_foreign_key', 'left', 'right', 'name', 'on_update', 'on_delete', 'column', 'db_schema_table:references')
45
+ # add_scaffold('db_schema_index', 'name', 'fields', 'using', 'order:jsonb', 'where', 'unique', 'db_schema_table:references')
46
+ # add_scaffold('db_schema_view', 'name', 'materialized:boolean', 'sql_definition', 'db_schema_table:references')
47
+ end
48
+
49
+ def setup_customizations
50
+ route("root 'home#index'")
51
+
52
+ force_copy
53
+
54
+ add_controller('home', 'index', 'quick_signin', 'reseed')
55
+
56
+ directory "app/controllers"
57
+ directory "app/models"
58
+ directory "app/views"
59
+ template 'app/views/layouts/application.html.erb', 'app/views/layouts/application.html.erb'
60
+ directory "app/queries"
61
+ end
62
+
63
+ def setup_avo
64
+ # generate('avo:install')
65
+
66
+ generate('avo:resource RailsApp')
67
+ generate('avo:resource TableCount')
68
+ generate('avo:resource Rubocop')
69
+ generate('avo:resource DbSchema')
70
+ generate('avo:resource User')
71
+ # generate('avo:dashboard Dashboard')
72
+
73
+ directory "app/avo"
74
+ directory "config/initializers"
75
+ directory "config/locales"
76
+
77
+ # # add devise support
78
+ # gsub_file 'config/initializers/avo.rb', %(# config.current_user_method = {}), 'config.current_user_method = :current_user'
79
+ end
80
+
81
+ def create_db
82
+ gsub_file('config/database.yml', ' encoding: unicode', db_development_settings)
83
+ db(drop: true, create: true)
84
+ end
85
+
86
+ def migrate_db
87
+ template 'db/seeds.rb' , 'db/seeds.rb'
88
+
89
+ db(migrate: true, seed: true)
90
+ end
91
+
92
+ def db_development_settings
93
+ <<-'RUBY'
94
+ encoding: unicode
95
+ host: <%= ENV['DATABASE_HOST'] %>
96
+ username: <%= ENV['DATABASE_USERNAME'] %>
97
+ password: <%= ENV['DATABASE_PASSWORD'] %>
98
+ RUBY
99
+ end
@@ -0,0 +1,13 @@
1
+ class Dashboard < Avo::Dashboards::BaseDashboard
2
+ self.id = "dashboard"
3
+ self.name = "Dashboard"
4
+
5
+ # self.description = "Tiny dashboard description"
6
+ # self.grid_cols = 3
7
+ # self.visible = -> do
8
+ # true
9
+ # end
10
+
11
+ # cards go here
12
+ # card UsersCount
13
+ end
@@ -0,0 +1,12 @@
1
+ class DbSchemaResource < Avo::BaseResource
2
+ self.title = :display_name
3
+ self.includes = []
4
+
5
+ # self.search_query = ->(params:) do
6
+ # scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
7
+ # end
8
+
9
+ field :id, as: :id
10
+ # field :data, as: :textarea, only_on: [:edit]
11
+ # field :user_name, as: :text
12
+ end
@@ -0,0 +1,15 @@
1
+ class RailsAppResource < Avo::BaseResource
2
+ self.title = :display_name
3
+ self.includes = []
4
+
5
+ # self.search_query = ->(params:) do
6
+ # scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
7
+ # end
8
+
9
+ field :id, as: :id
10
+ field :name, as: :text
11
+
12
+ field :db_schema, as: :has_one
13
+ field :table_count, as: :has_one
14
+ field :rubocop, as: :has_one
15
+ end
@@ -0,0 +1,12 @@
1
+ class RubocopResource < Avo::BaseResource
2
+ self.title = :display_name
3
+ self.includes = []
4
+
5
+ # self.search_query = ->(params:) do
6
+ # scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
7
+ # end
8
+
9
+ field :id, as: :id
10
+ # field :data, as: :textarea, only_on: [:edit]
11
+ # field :user_name, as: :text
12
+ end
@@ -0,0 +1,12 @@
1
+ class TableCountResource < Avo::BaseResource
2
+ self.title = :display_name
3
+ self.includes = []
4
+
5
+ # self.search_query = ->(params:) do
6
+ # scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
7
+ # end
8
+
9
+ field :id, as: :id
10
+ # field :data, as: :textarea, only_on: [:edit]
11
+ # field :user_name, as: :text
12
+ end
@@ -0,0 +1,24 @@
1
+ # tutorial (user resource): https://youtu.be/WgNK-oINFww?t=599
2
+ class UserResource < Avo::BaseResource
3
+ # https://docs.avohq.io/2.0/resources.html#devise-password-optional
4
+ # you need to fill in the password when creating a new user,
5
+ # but when editing a user you can leave the password field empty
6
+ self.devise_password_optional = true
7
+
8
+ # tutorial (better search experience): https://youtu.be/WgNK-oINFww?t=649
9
+ self.title = :email
10
+ self.includes = []
11
+
12
+ self.search_query = ->(params:) do
13
+ scope
14
+ .ransack(id_eq: params[:q], name_cont: params[:q], email_cont: params[:q], m: "or")
15
+ .result(distinct: false)
16
+ end
17
+
18
+ field :id, as: :id
19
+ field :email, as: :gravatar, link_to_resource: true, as_avatar: true
20
+ field :name, as: :text
21
+ field :email, as: :text, as_description: true
22
+ field :password, as: :text
23
+ field :posts, as: :has_many
24
+ end
@@ -0,0 +1,12 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def quick_signin
6
+ sign_in(:user, User.first)
7
+ end
8
+
9
+ def reseed
10
+ SeedService.seed
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ class DbSchema < ApplicationRecord
2
+ belongs_to :rails_app
3
+
4
+ # def user_name
5
+ # rails_app.user.name
6
+ # end
7
+
8
+ def display_name
9
+ "DB Schema for #{rails_app.name} - #{created_at.strftime("%d/%m/%Y")}"
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ class RailsApp < ApplicationRecord
2
+ belongs_to :user
3
+ end
@@ -0,0 +1,11 @@
1
+ class Rubocop < ApplicationRecord
2
+ belongs_to :rails_app
3
+
4
+ # def user_name
5
+ # rails_app.user.name
6
+ # end
7
+
8
+ def display_name
9
+ "RuboCop for #{rails_app.name} - #{created_at.strftime("%d/%m/%Y")}"
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class TableCount < ApplicationRecord
2
+ belongs_to :rails_app
3
+
4
+ # def user_name
5
+ # rails_app.user.name
6
+ # end
7
+
8
+ def display_name
9
+ "Table Counts for #{rails_app.name} - #{created_at.strftime("%d/%m/%Y")}"
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ WITH
2
+
3
+ files AS (
4
+ SELECT jsonb_array_elements(data->'files') FROM rubocops
5
+ ),
6
+ lines AS (
7
+ SELECT
8
+ jsonb_array_elements(files)->>'file' as file,
9
+ jsonb_array_elements(files)->'lines' as lines
10
+ FROM files
11
+ ),
12
+ rubocop_log AS (
13
+ SELECT
14
+ jsonb_array_elements(lines)->>'position' as position,
15
+ jsonb_array_elements(lines)->>'status' as status,
16
+ jsonb_array_elements(lines)->>'status_message' as status_message,
17
+ jsonb_array_elements(lines)->>'cop' as cop,
18
+ jsonb_array_elements(lines)->>'message' as message,
19
+ jsonb_array_elements(lines)->>'full_line' as full_line,
20
+ jsonb_array_elements(lines)->>'file_name' as file_name
21
+ FROM lines
22
+ )
23
+ select * from rubocop_log
@@ -0,0 +1,10 @@
1
+ class RubocopLogQuery < SqlQuery
2
+ sql_resource './rubocop_log.psql'
3
+ fields %i(position status status_message cop message full_line file_name)
4
+
5
+ def call
6
+ sql_query = "#{sql} LIMIT 5"
7
+
8
+ query(sql_query)
9
+ end
10
+ end
@@ -0,0 +1,40 @@
1
+ class SqlQuery
2
+ attr_reader :opts
3
+ attr_reader :sql
4
+ attr_reader :record
5
+
6
+ def initialize(**opts)
7
+ @opts = opts
8
+ @sql = self.class.sql
9
+ @record = self.class.record
10
+ end
11
+
12
+ def query(sql_query)
13
+ result = connection.execute(sql_query)
14
+ result.map { |row| record.new(**row) }
15
+ end
16
+
17
+ class << self
18
+ attr_reader :sql
19
+ attr_reader :record
20
+
21
+ def query(**opts)
22
+ new(**opts).call
23
+ end
24
+
25
+ def sql_resource(filename)
26
+ sql_file = File.expand_path(filename, File.dirname(__FILE__))
27
+ @sql = File.read(sql_file)
28
+ end
29
+
30
+ def fields(fields)
31
+ @record = Struct.new(*fields, keyword_init: true)
32
+ end
33
+ end
34
+
35
+ protected
36
+
37
+ def connection
38
+ ActiveRecord::Base.connection
39
+ end
40
+ end
@@ -0,0 +1,7 @@
1
+ class SeedService
2
+ class << self
3
+ def seed
4
+ puts 'sssssssssssssssssssssss'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ <h1><%= I18n.t('application_name') %></h1>
2
+
3
+ <p>The Klue is to do Less</p>
4
+
5
+ <p>No Code as a Service - Rails Application Builder</p>
6
+
@@ -0,0 +1,3 @@
1
+ <h1>Quick SignIn</h1>
2
+
3
+ <p>You are signed in as: <b><%= current_user.email %></b></p>
@@ -0,0 +1,4 @@
1
+ <%= link_to 'Home', root_path %>
2
+ <%= link_to 'Quick Sign In', home_quick_signin_path %> |
3
+ <%= link_to 'Admin', avo_path %>
4
+ <hr />
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= camelized %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%%= csrf_meta_tags %>
7
+ <%%= csp_meta_tag %>
8
+
9
+ <%- if options[:skip_hotwire] || options[:skip_javascript] -%>
10
+ <%%= stylesheet_link_tag "application" %>
11
+ <%- else -%>
12
+ <%%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
13
+ <%- end -%>
14
+ </head>
15
+
16
+ <body>
17
+ <header>
18
+ <%%= render 'layouts/navbar' %>
19
+ <hr />
20
+ </header>
21
+ <main>
22
+ <%%= yield %>
23
+ </main>
24
+ <footer>
25
+ <%%= render 'layouts/footer' %>
26
+ </footer>
27
+ </body>
28
+ </html>
29
+
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ # For more information regaring these settings check out our docs https://docs.avohq.io
4
+ Avo.configure do |config|
5
+ ## == Routing ==
6
+ config.root_path = '/admin'
7
+
8
+ # https://docs.avohq.io/2.0/customization.html
9
+ config.app_name = 'Klueless NoCaaS'
10
+ config.id_links_to_resource = true
11
+ # config.resource_controls_placement = :left
12
+
13
+ # Where should the user be redirected when visting the `/avo` url
14
+ # config.home_path = nil
15
+
16
+ ## == Licensing ==
17
+ config.license = 'pro' # change this to 'pro' when you add the license key
18
+ config.license_key = ENV['AVO_LICENSE_KEY']
19
+
20
+ ## == Set the context ==
21
+ config.set_context do
22
+ # Return a context object that gets evaluated in Avo::ApplicationController
23
+ end
24
+
25
+ ## == Authentication ==
26
+ config.current_user_method = :current_user
27
+ # config.authenticate_with = {}
28
+
29
+ ## == Authorization ==
30
+ # config.authorization_methods = {
31
+ # index: 'index?',
32
+ # show: 'show?',
33
+ # edit: 'edit?',
34
+ # new: 'new?',
35
+ # update: 'update?',
36
+ # create: 'create?',
37
+ # destroy: 'destroy?',
38
+ # }
39
+ # config.raise_error_on_missing_policy = false
40
+
41
+ ## == Localization ==
42
+ # config.locale = 'en-US'
43
+
44
+ ## == Customization ==
45
+ # config.app_name = 'Avocadelicious'
46
+ # config.timezone = 'UTC'
47
+ # config.currency = 'USD'
48
+ # config.per_page = 24
49
+ # config.per_page_steps = [12, 24, 48, 72]
50
+ # config.via_per_page = 8
51
+ # config.default_view_type = :table
52
+ # config.hide_layout_when_printing = false
53
+ # config.id_links_to_resource = false
54
+ # config.full_width_container = false
55
+ # config.full_width_index_view = false
56
+ # config.cache_resources_on_index_view = true
57
+ # config.search_debounce = 300
58
+ # config.view_component_path = "app/components"
59
+ # config.display_license_request_timeout_error = true
60
+ # config.disabled_features = []
61
+
62
+ ## == Breadcrumbs ==
63
+ # config.display_breadcrumbs = true
64
+ config.set_initial_breadcrumbs do
65
+ add_breadcrumb "Home", '/admin'
66
+ end
67
+
68
+ ## == Menus ==
69
+ config.main_menu = -> {
70
+ section "Dashboards", icon: "dashboards" do
71
+ all_dashboards
72
+ end
73
+
74
+ section "Resources", icon: "resources" do
75
+ group "App Meta Data" do
76
+ resource :db_schema, label: 'DB Schema'
77
+ resource :rubocop, label: 'RuboCop'
78
+ resource :table_count, label: 'Table Count'
79
+ end
80
+
81
+ # group "Xxx" do # , collapsable: true, collapsed: true
82
+ # end
83
+
84
+ group "Admin" do
85
+ resource :user
86
+ end
87
+ end
88
+
89
+ section "Tools", icon: "tools" do
90
+ all_tools
91
+ end
92
+
93
+ section I18n.t('admin.external_links'), icon: "heroicons/outline/link", collapsable: true, collapsed: true do
94
+ link 'Appy Dave', path: 'https://appydave.com', target: :_blank
95
+ link 'Klueless', path: 'https://klueless.io/', target: :_blank
96
+ end
97
+ }
98
+ config.profile_menu = -> {
99
+ link "Profile", path: "/admin/profile", icon: "user-circle"
100
+ }
101
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ application_name: "KlueLess"
3
+ admin:
4
+ external_links: 'External Links'
@@ -0,0 +1,18 @@
1
+ @data_path = "/Users/davidcruwys/dev/printspeak/printspeak-generator/.builders/.data/"
2
+
3
+ david = User.create_with(name: 'david', password: 'password').find_or_create_by(email: 'david@site.com')
4
+
5
+ def get_data(filename)
6
+ json = File.read(File.join(@data_path, filename))
7
+ JSON.parse(json)
8
+ end
9
+
10
+ rails_app = RailsApp.create(name: 'Printspeak', user: david)
11
+
12
+ puts 'Create Rubocop Data'
13
+ Rubocop.create(rails_app: rails_app, data: get_data('rubocop.json'))
14
+
15
+ puts 'Create Table Count Data'
16
+ TableCount.create(rails_app: rails_app, data: get_data('sql_count.json'))
17
+
18
+
@@ -8,42 +8,84 @@ self.local_template_path = File.dirname(__FILE__)
8
8
 
9
9
  gac 'base rails 7 image created'
10
10
 
11
- add_controller('home', 'index')
12
- add_controller('page', 'benefits', 'faq', 'terms', 'privacy', '--skip-routes')
13
-
14
- route("root 'home#index'")
15
- route(<<-'RUBY')
16
- PageController.action_methods.each do |action|
17
- get "/#{action}", to: "page##{action}", as: "page_#{action}"
18
- end
19
- RUBY
11
+ prepare_environment
20
12
 
21
13
  after_bundle do
22
- customizations
14
+ force_copy
15
+ prepare_postgresql
16
+ scaffolds
17
+ setup_controllers
18
+ setup_customizations
23
19
  setup_db
24
- rubocop
20
+ setup_avo
25
21
  end
26
22
 
27
- def customizations
28
- force_copy
23
+ def scaffolds
24
+ add_scaffold('post', 'title', 'body:text')
25
+ add_scaffold('people', 'first_name', 'last_name', 'age:integer', 'address:text')
26
+ end
29
27
 
30
- directory "app/assets/images"
31
- directory "app/assets/stylesheets"
28
+ def setup_controllers
29
+ route("root 'home#index'")
32
30
 
33
- directory "app/controllers"
31
+ add_controller('home', 'index')
32
+ add_controller('page', 'benefits', 'faq', 'terms', 'privacy', '--skip-routes')
34
33
 
35
- directory "app/views/home"
36
- directory "app/views/page"
34
+ route("root 'home#index'")
35
+ route(<<-'RUBY')
36
+ PageController.action_methods.each do |action|
37
+ get "/#{action}", to: "page##{action}", as: "page_#{action}"
38
+ end
39
+ RUBY
40
+ end
37
41
 
38
- directory "app/views/layouts"
42
+ def setup_customizations
43
+ directory "app/assets/images"
44
+ directory "app/assets/stylesheets"
45
+ directory "app/controllers"
46
+ directory "app/models"
47
+ directory "app/views"
48
+ # directory "app/services"
39
49
  template 'app/views/layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
50
+ end
40
51
 
52
+ def setup_db
41
53
  template 'db/seeds.rb' , 'db/seeds.rb'
54
+
55
+ gsub_file('config/database.yml', ' encoding: unicode', db_development_settings)
56
+
57
+ db(drop: true, create: true, migrate: true, seed: true)
42
58
  end
43
59
 
44
- def setup_db
45
- add_scaffold('post', 'title', 'body:text')
46
- add_scaffold('people', 'first_name', 'last_name', 'age:integer', 'address:text')
60
+ def setup_avo
61
+ # generate('avo:install')
62
+
63
+ # generate('avo:resource Category')
64
+ # generate('avo:resource Post')
65
+ # generate('avo:resource Comment')
66
+ # generate('avo:resource Location')
67
+ # generate('avo:resource Room')
68
+ # generate('avo:resource Booking')
69
+ # generate('avo:resource User')
70
+ # generate('avo:dashboard Dashboard')
71
+
72
+ # directory "app/avo"
73
+ # directory "config/initializers"
74
+ # directory "config/locales"
75
+
76
+ # add devise support
77
+ # gsub_file 'config/initializers/avo.rb', %(# config.current_user_method = {}), 'config.current_user_method = :current_user'
78
+ end
79
+
80
+ def prepare_postgresql
81
+ gsub_file('config/database.yml', ' encoding: unicode', db_development_settings)
82
+ end
47
83
 
48
- db_migrate
84
+ def db_development_settings
85
+ <<-'RUBY'
86
+ encoding: unicode
87
+ host: <%= ENV['DATABASE_HOST'] %>
88
+ username: <%= ENV['DATABASE_USERNAME'] %>
89
+ password: <%= ENV['DATABASE_PASSWORD'] %>
90
+ RUBY
49
91
  end
@@ -11,6 +11,6 @@
11
11
  # bob = User.create(email: 'bob@site.com', name: 'bob', password: 'password')
12
12
  # lisa = User.create(email: 'lisa@site.com', name: 'lisa', password: 'password')
13
13
 
14
- # 10.times do |i|
15
- # Post.create(title: "Post #{i}", body: "This is the body of post #{i}", user: User.all.sample)
16
- # end
14
+ 10.times do |i|
15
+ Post.create(title: "Post #{i}", body: "This is the body of post #{i}")
16
+ end
@@ -3,8 +3,8 @@
3
3
  "skip_namespace": false,
4
4
  "skip_collision_check": false,
5
5
  "ruby": "/Users/davidcruwys/.asdf/installs/ruby/3.1.1/bin/ruby",
6
- "database": "sqlite3",
7
- "skip_git": true,
6
+ "database": "postgresql",
7
+ "skip_git": false,
8
8
  "skip_keeps": false,
9
9
  "skip_action_mailer": false,
10
10
  "skip_action_mailbox": false,
@@ -32,16 +32,16 @@
32
32
  "test": "rspec",
33
33
  "add_acts_as_list": false,
34
34
  "add_administrate": false,
35
- "add_annotate": false,
36
- "add_avo": false,
35
+ "add_annotate": true,
36
+ "add_avo": true,
37
37
  "add_bcrypt": false,
38
- "add_brakeman": false,
38
+ "add_brakeman": true,
39
39
  "add_browser": false,
40
- "add_bundler_audit": false,
40
+ "add_bundler_audit": true,
41
41
  "add_chartkick": false,
42
- "add_devise": false,
42
+ "add_devise": true,
43
43
  "add_devise_masquerade": false,
44
- "add_dotenv": false,
44
+ "add_dotenv": true,
45
45
  "add_factory_bot_rails": true,
46
46
  "add_faker": true,
47
47
  "add_friendly_id": false,
@@ -52,7 +52,7 @@
52
52
  "add_image_processing": false,
53
53
  "add_kaminari": false,
54
54
  "add_lograge": false,
55
- "add_minimal_css": true,
55
+ "add_minimal_css": false,
56
56
  "minimal_css_library": "water.css",
57
57
  "add_mini_magick": false,
58
58
  "add_motor_admin": false,
@@ -63,8 +63,9 @@
63
63
  "add_ransack": false,
64
64
  "add_redcarpet": false,
65
65
  "add_rolify": false,
66
- "add_rubocop": false,
66
+ "add_rubocop": true,
67
67
  "add_twilio_ruby": false,
68
- "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/factory_bot_rails/_.rb"
68
+ "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/application/klueless/_.rb",
69
+ "css": "tailwind"
69
70
  }
70
71
  }
@@ -7,9 +7,9 @@
7
7
  "quiet": false,
8
8
  "skip": false,
9
9
  "ruby": "/Users/davidcruwys/.asdf/installs/ruby/3.1.1/bin/ruby",
10
- "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/factory_bot_rails/_.rb",
11
- "database": "sqlite3",
12
- "skip_git": true,
10
+ "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/application/klueless/_.rb",
11
+ "database": "postgresql",
12
+ "skip_git": false,
13
13
  "skip_keeps": false,
14
14
  "skip_action_mailer": false,
15
15
  "skip_action_mailbox": false,
@@ -36,22 +36,22 @@
36
36
  "api": false,
37
37
  "minimal": false,
38
38
  "javascript": "importmap",
39
- "css": "",
39
+ "css": "tailwind",
40
40
  "skip_bundle": false,
41
41
  "note": "",
42
42
  "test": "rspec",
43
43
  "add_acts_as_list": false,
44
44
  "add_administrate": false,
45
- "add_annotate": false,
46
- "add_avo": false,
45
+ "add_annotate": true,
46
+ "add_avo": true,
47
47
  "add_bcrypt": false,
48
- "add_brakeman": false,
48
+ "add_brakeman": true,
49
49
  "add_browser": false,
50
- "add_bundler_audit": false,
50
+ "add_bundler_audit": true,
51
51
  "add_chartkick": false,
52
- "add_devise": false,
52
+ "add_devise": true,
53
53
  "add_devise_masquerade": false,
54
- "add_dotenv": false,
54
+ "add_dotenv": true,
55
55
  "add_factory_bot_rails": true,
56
56
  "add_faker": true,
57
57
  "add_friendly_id": false,
@@ -62,7 +62,7 @@
62
62
  "add_image_processing": false,
63
63
  "add_kaminari": false,
64
64
  "add_lograge": false,
65
- "add_minimal_css": true,
65
+ "add_minimal_css": false,
66
66
  "minimal_css_library": "water.css",
67
67
  "add_mini_magick": false,
68
68
  "add_motor_admin": false,
@@ -73,7 +73,7 @@
73
73
  "add_ransack": false,
74
74
  "add_redcarpet": false,
75
75
  "add_rolify": false,
76
- "add_rubocop": false,
76
+ "add_rubocop": true,
77
77
  "add_twilio_ruby": false
78
78
  }
79
79
  }
@@ -10,6 +10,8 @@ module RailsAppGenerator
10
10
  def apply
11
11
  # copy_file 'config/initializers/avo.rb'
12
12
 
13
+ bundle_install
14
+
13
15
  generate('avo:install')
14
16
 
15
17
  gsub_file 'config/routes.rb', %(mount Avo::Engine, at: Avo.configuration.root_path), <<-RUBY
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/rails_app_generator/rag_initializer.rb
4
+ # add_if(:scenic)
5
+ # rag.add_option :add_scenic , type: :boolean, default: false
6
+
7
+ module RailsAppGenerator
8
+ # Custom add-ons for RailsAppGenerator
9
+ module AddOns
10
+ # Add Scenic to rails application
11
+ class Scenic < RailsAppGenerator::Addon
12
+ required_gem gem.version('scenic', '1.6.0', '')
13
+
14
+ def apply
15
+ say 'Setting up Scenic'
16
+ # template('scenic_template.rb', 'target/scenic.rb', force: true)
17
+ # template('app/javascript/stylesheets/components.scss')
18
+ # create_file('target/scenic.rb', 'put your content here')
19
+ # directory 'app/template', 'app/target', force: true
20
+ # empty_directory 'app/target'
21
+ # inject_into_file('app/application.js', "some content")
22
+ # rails_command('tailwindcss:install')
23
+ end
24
+
25
+ def before_template
26
+ say 'Setting up Scenic - before custom template'
27
+ end
28
+
29
+ def before_bundle
30
+ say 'Setting up Scenic - before bundle install'
31
+ end
32
+
33
+ def after_bundle
34
+ say 'Setting up Scenic - after bundle install'
35
+ end
36
+ end
37
+ end
38
+ end
@@ -291,6 +291,15 @@ module RailsAppGenerator
291
291
  rails_command('db:migrate')
292
292
  end
293
293
 
294
+ def db(drop: false, create: false, migrate: false, seed: false)
295
+ commands = []
296
+ commands << 'db:drop' if drop
297
+ commands << 'db:create' if create
298
+ commands << 'db:migrate' if migrate
299
+ commands << 'db:seed' if seed
300
+ rails_command(commands.join(' '))
301
+ end
302
+
294
303
  def db_seed
295
304
  rails_command('db:seed')
296
305
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAppGenerator
4
- VERSION = '0.2.40'
4
+ VERSION = '0.2.41'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "rails_app_generator",
3
- "version": "0.2.40",
3
+ "version": "0.2.41",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "rails_app_generator",
9
- "version": "0.2.40",
9
+ "version": "0.2.41",
10
10
  "dependencies": {
11
11
  "daisyui": "^2.20.0"
12
12
  },
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rails_app_generator",
3
- "version": "0.2.40",
3
+ "version": "0.2.41",
4
4
  "description": "Create new Rails Application with custom opinions",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
@@ -0,0 +1,23 @@
1
+ {
2
+ "args": {
3
+ "app_path": "klueless",
4
+ "destination_root": "/Users/davidcruwys/dev/kweb",
5
+ "note": "add sidekiq to handle the data import tasks, add impersonate"
6
+ },
7
+ "opts": {
8
+ "skip_test": true,
9
+ "database": "postgresql",
10
+ "css": "tailwind",
11
+ "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/application/klueless/_.rb",
12
+ "add_avo": true,
13
+ "add_annotate": true,
14
+ "add_brakeman": true,
15
+ "add_bundler_audit": true,
16
+ "add_devise": true,
17
+ "add_dotenv": true,
18
+ "add_factory_bot_rails": true,
19
+ "add_faker": true,
20
+ "add_ransack": false,
21
+ "add_rubocop": true
22
+ }
23
+ }
@@ -5,10 +5,16 @@
5
5
  },
6
6
  "opts": {
7
7
  "skip_test": true,
8
- "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/application/printspeak/_.rb",
9
8
  "css": "bootstrap",
9
+ "database": "postgresql",
10
+ "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/application/printspeak/_.rb",
11
+ "add_avo": true,
10
12
  "add_annotate": true,
13
+ "add_devise": true,
11
14
  "add_dotenv": true,
15
+ "add_factory_bot_rails": true,
16
+ "add_faker": true,
17
+ "add_ransack": false,
12
18
  "add_rubocop": true
13
19
  }
14
20
  }
@@ -1,7 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
- # xmen
5
4
  ruby <%= "'#{RUBY_VERSION}'" -%>
6
5
 
7
6
  <% gems.each do |gem| %><%= gem %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_app_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.40
4
+ version: 0.2.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-23 00:00:00.000000000 Z
11
+ date: 2022-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootsnap
@@ -444,6 +444,30 @@ files:
444
444
  - after_templates/addons/twilio_ruby/app/controllers/home_controller.rb
445
445
  - after_templates/addons/twilio_ruby/app/views/home/index.html.erb
446
446
  - after_templates/addons/twilio_ruby/config/initializers/twilio.rb
447
+ - after_templates/application/klueless/_.rb
448
+ - after_templates/application/klueless/app/avo/dashboards/dashboard.rb
449
+ - after_templates/application/klueless/app/avo/resources/db_schema_resource.rb
450
+ - after_templates/application/klueless/app/avo/resources/rails_app_resource.rb
451
+ - after_templates/application/klueless/app/avo/resources/rubocop_resource.rb
452
+ - after_templates/application/klueless/app/avo/resources/table_count_resource.rb
453
+ - after_templates/application/klueless/app/avo/resources/user_resource.rb
454
+ - after_templates/application/klueless/app/controllers/home_controller.rb
455
+ - after_templates/application/klueless/app/models/db_schema.rb
456
+ - after_templates/application/klueless/app/models/rails_app.rb
457
+ - after_templates/application/klueless/app/models/rubocop.rb
458
+ - after_templates/application/klueless/app/models/table_count.rb
459
+ - after_templates/application/klueless/app/queries/rubocop_log.psql
460
+ - after_templates/application/klueless/app/queries/rubocop_log_query.rb
461
+ - after_templates/application/klueless/app/queries/sql_query.rb
462
+ - after_templates/application/klueless/app/services/seed_service.rb
463
+ - after_templates/application/klueless/app/views/home/index.html.erb
464
+ - after_templates/application/klueless/app/views/home/quick_signin.html.erb
465
+ - after_templates/application/klueless/app/views/layouts/_footer.html.erb
466
+ - after_templates/application/klueless/app/views/layouts/_navbar.html.erb
467
+ - after_templates/application/klueless/app/views/layouts/application.html.erb
468
+ - after_templates/application/klueless/config/initializers/avo.rb
469
+ - after_templates/application/klueless/config/locales/en.yml
470
+ - after_templates/application/klueless/db/seeds.rb
447
471
  - after_templates/application/printspeak/_.rb
448
472
  - after_templates/application/printspeak/app/assets/images/.keep
449
473
  - after_templates/application/printspeak/app/assets/images/about/1.jpg
@@ -703,6 +727,7 @@ files:
703
727
  - lib/rails_app_generator/addons/rspec.rb
704
728
  - lib/rails_app_generator/addons/rubocop.rb
705
729
  - lib/rails_app_generator/addons/scaffold.rb
730
+ - lib/rails_app_generator/addons/scenic.rb
706
731
  - lib/rails_app_generator/addons/services.rb
707
732
  - lib/rails_app_generator/addons/sidekiq.rb
708
733
  - lib/rails_app_generator/addons/stimulus.rb
@@ -776,6 +801,7 @@ files:
776
801
  - profiles/addons/rolify.json
777
802
  - profiles/addons/rubocop.json
778
803
  - profiles/addons/twilio_ruby.json
804
+ - profiles/application/klueless.json
779
805
  - profiles/application/printspeak.json
780
806
  - profiles/rag/bootstrap.json
781
807
  - profiles/rag/devise.json