rails_app_generator 0.2.43 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +22 -1
- data/after_templates/addons/factory_bot/_.rb +82 -0
- data/after_templates/addons/factory_bot/app/controllers/home_controller.rb +10 -0
- data/after_templates/addons/factory_bot/app/services/seed_service.rb +35 -0
- data/after_templates/addons/factory_bot/app/views/home/index.html.erb +3 -0
- data/after_templates/addons/factory_bot/app/views/layouts/_footer.html.erb +0 -0
- data/after_templates/addons/factory_bot/app/views/layouts/_navbar.html.erb +10 -0
- data/after_templates/addons/factory_bot/app/views/layouts/application.html.erb +29 -0
- data/after_templates/addons/factory_bot/db/seeds.rb +1 -0
- data/after_templates/addons/factory_bot/factories.rb +73 -0
- data/after_templates/addons/factory_bot/factory-create-user.png +0 -0
- data/after_templates/addons/factory_bot/factory-employee-bad.png +0 -0
- data/after_templates/addons/factory_bot/factory-employee-good.png +0 -0
- data/after_templates/addons/factory_bot/factory-role.png +0 -0
- data/after_templates/addons/factory_bot/factory-video.png +0 -0
- data/after_templates/application/klueless/.rubocop.yml +40 -0
- data/after_templates/application/klueless/_.rb +31 -12
- data/after_templates/application/klueless/app/avo/cards/amount_raised.rb +14 -0
- data/after_templates/application/klueless/app/avo/cards/example_custom_partial.rb +7 -0
- data/after_templates/application/klueless/app/avo/cards/example_metric.rb +38 -0
- data/after_templates/application/klueless/app/avo/cards/percent_done.rb +10 -0
- data/after_templates/application/klueless/app/avo/cards/rubocop_card.rb +10 -0
- data/after_templates/application/klueless/app/avo/filters/rubocop_entry_cop_filter.rb +15 -0
- data/after_templates/application/klueless/app/avo/filters/rubocop_entry_filename_filter.rb +13 -0
- data/after_templates/application/klueless/app/avo/filters/rubocop_entry_message_filter.rb +13 -0
- data/after_templates/application/klueless/app/avo/filters/rubocop_entry_status_filter.rb +15 -0
- data/after_templates/application/klueless/app/avo/filters/table_count_entry_tablename_filter.rb +13 -0
- data/after_templates/application/klueless/app/avo/resource_tools/rubocop_info.rb +4 -0
- data/after_templates/application/klueless/app/avo/resources/rubocop_entry_resource.rb +28 -0
- data/after_templates/application/klueless/app/avo/resources/rubocop_resource.rb +9 -0
- data/after_templates/application/klueless/app/avo/resources/table_count_entry_resource.rb +18 -0
- data/after_templates/application/klueless/app/controllers/home_controller.rb +9 -1
- data/after_templates/application/klueless/app/services/seed_service.rb +49 -3
- data/after_templates/application/klueless/app/views/home/index.html.erb +2 -2
- data/after_templates/application/klueless/app/views/layouts/_navbar.html.erb +6 -3
- data/after_templates/application/klueless/config/initializers/avo.rb +4 -2
- data/after_templates/application/klueless/db/seeds.rb +1 -18
- data/after_templates/application/klueless/db/views/rubocop_entries_v01.sql +23 -0
- data/after_templates/application/klueless/db/views/table_count_entries_v01.sql +11 -0
- data/docs/last_run/app_generator_data.json +7 -7
- data/docs/last_run/rails_options_data.json +10 -8
- data/lib/rails_app_generator/app_generator.rb +18 -4
- data/lib/rails_app_generator/cli/profile.rb +1 -3
- data/lib/rails_app_generator/starter.rb +49 -8
- data/lib/rails_app_generator/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/profiles/addons/factory_bot.json +18 -0
- data/profiles/addons/faker.json +1 -1
- data/profiles/application/klueless.json +7 -3
- data/templates/README.md.erb +2 -2
- data/templates/thor_task/profile/app/services/seed_service.rb +8 -4
- data/templates/thor_task/profile/profile.json.tt +2 -1
- metadata +33 -2
@@ -0,0 +1,28 @@
|
|
1
|
+
class RubocopEntryResource < Avo::BaseResource
|
2
|
+
filter RubocopEntryFilenameFilter
|
3
|
+
filter RubocopEntryMessageFilter
|
4
|
+
filter RubocopEntryStatusFilter
|
5
|
+
filter RubocopEntryCopFilter
|
6
|
+
|
7
|
+
self.title = :file_name
|
8
|
+
self.includes = []
|
9
|
+
|
10
|
+
self.search_query = ->(params:) do
|
11
|
+
scope.ransack(
|
12
|
+
cop_cont: params[:q],
|
13
|
+
file_name_cont: params[:q],
|
14
|
+
position_cont: params[:q],
|
15
|
+
status_cont: params[:q],
|
16
|
+
status_message_cont: params[:q],
|
17
|
+
m: "or"
|
18
|
+
).result(distinct: false)
|
19
|
+
end
|
20
|
+
|
21
|
+
field :cop , as: :text
|
22
|
+
field :file_name , as: :text
|
23
|
+
# field :full_line , as: :text
|
24
|
+
field :position , as: :text
|
25
|
+
# field :status , as: :text
|
26
|
+
field :status_message , as: :text
|
27
|
+
field :message , as: :text
|
28
|
+
end
|
@@ -9,4 +9,13 @@ class RubocopResource < Avo::BaseResource
|
|
9
9
|
field :id, as: :id
|
10
10
|
# field :data, as: :textarea, only_on: [:edit]
|
11
11
|
# field :user_name, as: :text
|
12
|
+
tool RubocopInfo, show_on: :edit
|
13
|
+
|
14
|
+
# tabs do
|
15
|
+
# tab "List of Cops" do
|
16
|
+
# panel do
|
17
|
+
# field :id, as: :id
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
# end
|
12
21
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class TableCountEntryResource < Avo::BaseResource
|
2
|
+
filter TableCountEntryTablenameFilter
|
3
|
+
|
4
|
+
self.title = :table_count
|
5
|
+
self.includes = []
|
6
|
+
|
7
|
+
self.search_query = ->(params:) do
|
8
|
+
scope.ransack(
|
9
|
+
table_count_cont: params[:q],
|
10
|
+
m: "or"
|
11
|
+
).result(distinct: false)
|
12
|
+
end
|
13
|
+
|
14
|
+
field :table_count, as: :text
|
15
|
+
field :au, as: :text
|
16
|
+
field :eu, as: :text
|
17
|
+
field :us, as: :text
|
18
|
+
end
|
@@ -7,6 +7,14 @@ class HomeController < ApplicationController
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def reseed
|
10
|
-
SeedService.seed
|
10
|
+
SeedService.seed(variant: :refresh)
|
11
|
+
|
12
|
+
redirect_back_or_to root_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def refresh_material_view
|
16
|
+
RubocopEntry.refresh
|
17
|
+
|
18
|
+
redirect_back_or_to root_path
|
11
19
|
end
|
12
20
|
end
|
@@ -1,7 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class SeedService
|
4
|
+
PRINTSPEAK_DATA_PATH = "/Users/davidcruwys/dev/printspeak/printspeak-generator/.builders/.data/"
|
5
|
+
|
2
6
|
class << self
|
3
|
-
def seed
|
4
|
-
|
7
|
+
def seed(variant: :reset)
|
8
|
+
service = SeedService.new
|
9
|
+
service.call(variant: variant)
|
5
10
|
end
|
6
11
|
end
|
7
|
-
|
12
|
+
|
13
|
+
def call(variant: :reset)
|
14
|
+
reset if variant == :reset
|
15
|
+
refresh if variant == :refresh
|
16
|
+
create
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def get_data(filename)
|
22
|
+
json = File.read(File.join(PRINTSPEAK_DATA_PATH, filename))
|
23
|
+
JSON.parse(json)
|
24
|
+
end
|
25
|
+
|
26
|
+
def reset
|
27
|
+
User.delete_all
|
28
|
+
RailsApp.delete_all
|
29
|
+
Rubocop.delete_all
|
30
|
+
TableCount.delete_all
|
31
|
+
end
|
32
|
+
|
33
|
+
def refresh
|
34
|
+
end
|
35
|
+
|
36
|
+
def create
|
37
|
+
refresh_printspeak
|
38
|
+
|
39
|
+
RubocopEntry.refresh
|
40
|
+
end
|
41
|
+
|
42
|
+
def refresh_printspeak
|
43
|
+
david = User.create_with(name: 'david', password: 'password').find_or_create_by(email: 'david@site.com')
|
44
|
+
|
45
|
+
rails_app = RailsApp.create_with(user: david).find_or_create_by(name: 'Printspeak')
|
46
|
+
|
47
|
+
puts 'Create Rubocop Data'
|
48
|
+
Rubocop.create(rails_app: rails_app, data: get_data('rubocop.json'))
|
49
|
+
|
50
|
+
puts 'Create Table Count Data'
|
51
|
+
TableCount.create(rails_app: rails_app, data: get_data('sql_count.json'))
|
52
|
+
end
|
53
|
+
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
<%= link_to 'Home', root_path %>
|
2
|
-
<%= link_to '
|
3
|
-
<%= link_to '
|
1
|
+
<%= link_to 'Home', root_path %>
|
2
|
+
| <%= link_to 'Bookings', bookings_path %>
|
3
|
+
| <%= link_to 'Re-Seed', home_reseed_path, style: 'color: blue; font-weight: 600;' %>
|
4
|
+
| <%= link_to 'Refresh Material View', home_refresh_material_view_path, style: 'color: blue; font-weight: 600;' %>
|
5
|
+
| <%= link_to 'Quick Sign In', home_quick_signin_path %>
|
6
|
+
| <%= link_to 'Admin', avo_path %>
|
4
7
|
<hr />
|
@@ -78,8 +78,10 @@ Avo.configure do |config|
|
|
78
78
|
resource :table_count, label: 'Table Count'
|
79
79
|
end
|
80
80
|
|
81
|
-
|
82
|
-
|
81
|
+
group "Live Views", collapsable: true, collapsed: true do
|
82
|
+
resource :rubocop_entries, label: 'Rubo Cop'
|
83
|
+
resource :table_count_entries, label: 'Table Count'
|
84
|
+
end
|
83
85
|
|
84
86
|
group "Admin" do
|
85
87
|
resource :user
|
@@ -1,18 +1 @@
|
|
1
|
-
|
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
|
-
|
1
|
+
SeedService.seed
|
@@ -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
|
+
denormalized 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 row_number() OVER () AS id, * from denormalized
|
@@ -0,0 +1,11 @@
|
|
1
|
+
WITH
|
2
|
+
|
3
|
+
denormalized AS (
|
4
|
+
SELECT
|
5
|
+
jsonb_array_elements(data)->>'table_name' as table_name,
|
6
|
+
jsonb_array_elements(data)->>'au' as au,
|
7
|
+
jsonb_array_elements(data)->>'eu' as eu,
|
8
|
+
jsonb_array_elements(data)->>'us' as us
|
9
|
+
FROM table_counts
|
10
|
+
)
|
11
|
+
select * from denormalized order by table_name
|
@@ -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": "
|
7
|
-
"skip_git":
|
6
|
+
"database": "sqlite3",
|
7
|
+
"skip_git": false,
|
8
8
|
"skip_keeps": false,
|
9
9
|
"skip_action_mailer": false,
|
10
10
|
"skip_action_mailbox": false,
|
@@ -32,7 +32,7 @@
|
|
32
32
|
"test": "rspec",
|
33
33
|
"add_acts_as_list": false,
|
34
34
|
"add_administrate": false,
|
35
|
-
"add_annotate":
|
35
|
+
"add_annotate": true,
|
36
36
|
"add_avo": false,
|
37
37
|
"add_bcrypt": false,
|
38
38
|
"add_brakeman": false,
|
@@ -42,8 +42,8 @@
|
|
42
42
|
"add_devise": false,
|
43
43
|
"add_devise_masquerade": false,
|
44
44
|
"add_dotenv": false,
|
45
|
-
"add_factory_bot_rails":
|
46
|
-
"add_faker":
|
45
|
+
"add_factory_bot_rails": true,
|
46
|
+
"add_faker": true,
|
47
47
|
"add_friendly_id": false,
|
48
48
|
"add_groupdate": false,
|
49
49
|
"add_hexapdf": false,
|
@@ -60,12 +60,12 @@
|
|
60
60
|
"add_pretender": false,
|
61
61
|
"add_public_suffix": false,
|
62
62
|
"add_rails_html_sanitizer": false,
|
63
|
-
"add_scenic":
|
63
|
+
"add_scenic": false,
|
64
64
|
"add_ransack": false,
|
65
65
|
"add_redcarpet": false,
|
66
66
|
"add_rolify": false,
|
67
67
|
"add_rubocop": false,
|
68
68
|
"add_twilio_ruby": false,
|
69
|
-
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/
|
69
|
+
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/factory_bot/_.rb"
|
70
70
|
}
|
71
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/
|
11
|
-
"database": "
|
12
|
-
"skip_git":
|
10
|
+
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/factory_bot/_.rb",
|
11
|
+
"database": "sqlite3",
|
12
|
+
"skip_git": false,
|
13
13
|
"skip_keeps": false,
|
14
14
|
"skip_action_mailer": false,
|
15
15
|
"skip_action_mailbox": false,
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"test": "rspec",
|
43
43
|
"add_acts_as_list": false,
|
44
44
|
"add_administrate": false,
|
45
|
-
"add_annotate":
|
45
|
+
"add_annotate": true,
|
46
46
|
"add_avo": false,
|
47
47
|
"add_bcrypt": false,
|
48
48
|
"add_brakeman": false,
|
@@ -52,8 +52,8 @@
|
|
52
52
|
"add_devise": false,
|
53
53
|
"add_devise_masquerade": false,
|
54
54
|
"add_dotenv": false,
|
55
|
-
"add_factory_bot_rails":
|
56
|
-
"add_faker":
|
55
|
+
"add_factory_bot_rails": true,
|
56
|
+
"add_faker": true,
|
57
57
|
"add_friendly_id": false,
|
58
58
|
"add_groupdate": false,
|
59
59
|
"add_hexapdf": false,
|
@@ -70,11 +70,13 @@
|
|
70
70
|
"add_pretender": false,
|
71
71
|
"add_public_suffix": false,
|
72
72
|
"add_rails_html_sanitizer": false,
|
73
|
-
"add_scenic":
|
73
|
+
"add_scenic": false,
|
74
74
|
"add_ransack": false,
|
75
75
|
"add_redcarpet": false,
|
76
76
|
"add_rolify": false,
|
77
77
|
"add_rubocop": false,
|
78
|
-
"add_twilio_ruby": false
|
78
|
+
"add_twilio_ruby": false,
|
79
|
+
"add_factory_bot": true,
|
80
|
+
"add_rspec": true
|
79
81
|
}
|
80
82
|
}
|
@@ -71,7 +71,7 @@ module RailsAppGenerator
|
|
71
71
|
puts "gem not available for '#{gem_name}'"
|
72
72
|
|
73
73
|
# THIS CODE DOES NOT REALLY WORK
|
74
|
-
return Dir.pwd if Dir.pwd.end_with?('dev/kgems/rails_app_generator') # code smell: this is for my local
|
74
|
+
return Dir.pwd if Dir.pwd.end_with?('dev/kgems/rails_app_generator') # code smell: this is for my local test environment
|
75
75
|
|
76
76
|
raise "'#{gem_name}' not available"
|
77
77
|
end
|
@@ -103,7 +103,7 @@ module RailsAppGenerator
|
|
103
103
|
# def rails_customization
|
104
104
|
# puts 'rails customizations'
|
105
105
|
# # invoke :customize_gemfile
|
106
|
-
# # invoke :
|
106
|
+
# # invoke :setup_test_environment
|
107
107
|
# # invoke :setup_production_environment
|
108
108
|
# # invoke :setup_secret_token
|
109
109
|
# # invoke :configure_app
|
@@ -292,8 +292,17 @@ module RailsAppGenerator
|
|
292
292
|
rails_command('db:migrate')
|
293
293
|
end
|
294
294
|
|
295
|
-
def
|
295
|
+
def db_recreate(environment: nil)
|
296
|
+
db_environment(environment) if environment
|
297
|
+
# when a DB does not exist, the drop will fail, but we still need to run create separately
|
298
|
+
db(drop: true)
|
299
|
+
db(create: true)
|
300
|
+
end
|
301
|
+
|
302
|
+
def db(environment: nil, drop: false, create: false, migrate: false, seed: false)
|
296
303
|
commands = []
|
304
|
+
|
305
|
+
commands << "db:environment:set RAILS_ENV=#{environment}" if environment
|
297
306
|
commands << 'db:drop' if drop
|
298
307
|
commands << 'db:create' if create
|
299
308
|
commands << 'db:migrate' if migrate
|
@@ -301,6 +310,10 @@ module RailsAppGenerator
|
|
301
310
|
rails_command(commands.join(' '))
|
302
311
|
end
|
303
312
|
|
313
|
+
def db_environment(environment)
|
314
|
+
rails_command("db:environment:set RAILS_ENV=#{environment}")
|
315
|
+
end
|
316
|
+
|
304
317
|
def db_seed
|
305
318
|
rails_command('db:seed')
|
306
319
|
end
|
@@ -350,11 +363,12 @@ module RailsAppGenerator
|
|
350
363
|
|
351
364
|
# copy_file in railties and copy_file in thor have different signatures
|
352
365
|
# I may want to remove this method because it just causes pain at the moment
|
353
|
-
def copy_file(source, destination, args = {})
|
366
|
+
def copy_file(source, destination = nil, args = {})
|
354
367
|
# puts source
|
355
368
|
# puts destination
|
356
369
|
# puts args
|
357
370
|
args = { force: true }.merge(args) if force_copy?
|
371
|
+
destination ||= source
|
358
372
|
|
359
373
|
super(source, destination, args)
|
360
374
|
end
|
@@ -29,9 +29,7 @@ module RailsAppGenerator
|
|
29
29
|
RailsAppGenerator::Util.write_last_run('rails_options_data.json', opts.to_h)
|
30
30
|
|
31
31
|
starter = RailsAppGenerator::Starter.new(**args)
|
32
|
-
|
33
|
-
starter.delete_target_folder
|
34
|
-
starter.start(opts)
|
32
|
+
starter.start(opts) if starter.handle_target_folder_found?
|
35
33
|
end
|
36
34
|
# rubocop:enable Metrics/AbcSize
|
37
35
|
end
|
@@ -28,17 +28,22 @@ module RailsAppGenerator
|
|
28
28
|
# points to templates related to rails addons
|
29
29
|
attr_reader :addon_template_path
|
30
30
|
|
31
|
+
attr_reader :when_folder_exist # [abort destroy keep_git overwrite]
|
32
|
+
|
31
33
|
attr_reader :capture_output
|
32
34
|
attr_reader :console_output
|
33
35
|
|
36
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
34
37
|
def initialize(**args)
|
35
|
-
@app_path
|
36
|
-
@destination_root
|
37
|
-
@rails_template_path
|
38
|
-
@override_template_path
|
39
|
-
@addon_template_path
|
40
|
-
@
|
38
|
+
@app_path = args[:app_path] || '.'
|
39
|
+
@destination_root = args[:destination_root] || Dir.pwd
|
40
|
+
@rails_template_path = args[:rails_template_path] || AppGenerator.rails_template_path
|
41
|
+
@override_template_path = args[:override_template_path] || AppGenerator.override_template_path
|
42
|
+
@addon_template_path = args[:addon_template_path] || AppGenerator.addon_template_path
|
43
|
+
@when_folder_exist = args[:when_folder_exist] || 'abort'
|
44
|
+
@capture_output = args[:capture_output].nil? ? false : args[:capture_output]
|
41
45
|
end
|
46
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
42
47
|
|
43
48
|
def target_path
|
44
49
|
File.expand_path(File.join(destination_root, app_path))
|
@@ -58,12 +63,48 @@ module RailsAppGenerator
|
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
61
|
-
|
62
|
-
|
66
|
+
# rubocop:disable Metrics/AbcSize
|
67
|
+
def handle_target_folder_found?
|
68
|
+
return true unless File.directory?(target_path)
|
69
|
+
|
70
|
+
case when_folder_exist
|
71
|
+
when 'abort'
|
72
|
+
puts "Target folder [#{target_path}] already exists. Aborting"
|
73
|
+
puts 'Maybe you want to use when_folder_exist option with one of these values [destroy overwrite keep_git]'
|
74
|
+
false
|
75
|
+
when 'destroy'
|
76
|
+
puts "Target folder [#{target_path}] already exists. Destroying it"
|
77
|
+
FileUtils.rm_rf(target_path)
|
78
|
+
true
|
79
|
+
when 'keep_git'
|
80
|
+
puts "Target folder [#{target_path}] already exists. Wiping it but keeping git history"
|
81
|
+
clean_target_folder
|
82
|
+
true
|
83
|
+
when 'overwrite'
|
84
|
+
puts "Target folder [#{target_path}] already exists. Overwriting it"
|
85
|
+
true
|
86
|
+
else
|
87
|
+
raise "Invalid when_folder_exist: #{when_folder_exist}"
|
88
|
+
end
|
63
89
|
end
|
90
|
+
# rubocop:enable Metrics/AbcSize
|
64
91
|
|
65
92
|
private
|
66
93
|
|
94
|
+
def clean_target_folder
|
95
|
+
Dir.entries(target_path).each do |entry|
|
96
|
+
entry_path = File.join(target_path, entry)
|
97
|
+
|
98
|
+
next if ['.', '..', '.git'].include?(entry)
|
99
|
+
|
100
|
+
if File.file?(entry_path)
|
101
|
+
File.delete(entry_path)
|
102
|
+
elsif File.directory?(entry_path)
|
103
|
+
FileUtils.rm_rf(entry_path)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
67
108
|
# Rails options returns a flat array of options
|
68
109
|
#
|
69
110
|
# It can work accept a flat array of options or a
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "rails_app_generator",
|
3
|
-
"version": "0.2
|
3
|
+
"version": "0.3.2",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "rails_app_generator",
|
9
|
-
"version": "0.2
|
9
|
+
"version": "0.3.2",
|
10
10
|
"dependencies": {
|
11
11
|
"daisyui": "^2.20.0"
|
12
12
|
},
|
data/package.json
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"args": {
|
3
|
+
"app_path": "r7_factory_bot",
|
4
|
+
"destination_root": "/Users/davidcruwys/dev/kgems/rails_app_generator/a/addons",
|
5
|
+
"when_folder_exist": "keep_git"
|
6
|
+
},
|
7
|
+
"opts": {
|
8
|
+
"skip_git": false,
|
9
|
+
"skip_test": true,
|
10
|
+
"add_minimal_css": true,
|
11
|
+
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/factory_bot/_.rb",
|
12
|
+
"add_annotate": true,
|
13
|
+
"add_factory_bot": true,
|
14
|
+
"add_factory_bot_rails": true,
|
15
|
+
"add_faker": true,
|
16
|
+
"add_rspec": true
|
17
|
+
}
|
18
|
+
}
|
data/profiles/addons/faker.json
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
"args": {
|
3
3
|
"app_path": "klueless",
|
4
4
|
"destination_root": "/Users/davidcruwys/dev/kweb",
|
5
|
-
"note": "add sidekiq to handle the data import tasks, add impersonate"
|
5
|
+
"note": "add sidekiq to handle the data import tasks, add impersonate",
|
6
|
+
"when_folder_exist": "keep_git"
|
6
7
|
},
|
7
8
|
"opts": {
|
8
9
|
"skip_test": true,
|
@@ -17,7 +18,10 @@
|
|
17
18
|
"add_dotenv": true,
|
18
19
|
"add_factory_bot_rails": true,
|
19
20
|
"add_faker": true,
|
20
|
-
"
|
21
|
-
"
|
21
|
+
"add_kaminari": true,
|
22
|
+
"add_lograge": true,
|
23
|
+
"add_ransack": true,
|
24
|
+
"add_rubocop": true,
|
25
|
+
"add_scenic": true
|
22
26
|
}
|
23
27
|
}
|
data/templates/README.md.erb
CHANGED
@@ -18,9 +18,9 @@ Open your browser on [localhost:3000](http://localhost:3000).
|
|
18
18
|
|
19
19
|
## Development
|
20
20
|
|
21
|
-
This app was generated using [
|
21
|
+
This app was generated using [Klueless - RailsAppGenerator](https://github.com/klueless-io/rails_app_generator) - there are tons of little tweaks to simplify your development workflow.
|
22
22
|
|
23
|
-
For more details refer to the [Documentation](https://github.com/
|
23
|
+
For more details refer to the [Documentation](https://github.com/klueless-io/rails_app_generator)
|
24
24
|
|
25
25
|
## Deployment
|
26
26
|
|
@@ -1,13 +1,14 @@
|
|
1
1
|
class SeedService
|
2
2
|
class << self
|
3
|
-
def seed
|
3
|
+
def seed(variant: :reset)
|
4
4
|
service = SeedService.new
|
5
|
-
service.call
|
5
|
+
service.call(variant: variant)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
def call
|
10
|
-
reset
|
9
|
+
def call(variant: :reset)
|
10
|
+
reset if variant == :reset
|
11
|
+
refresh if variant == :refresh
|
11
12
|
create
|
12
13
|
end
|
13
14
|
|
@@ -19,6 +20,9 @@ class SeedService
|
|
19
20
|
# Project.delete_all
|
20
21
|
end
|
21
22
|
|
23
|
+
def refresh
|
24
|
+
end
|
25
|
+
|
22
26
|
def create
|
23
27
|
# FactoryBot.create_list(:post, rand(10..20))
|
24
28
|
# FactoryBot.create_list(:person, rand(10..20))
|