-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
create-rails-app
executable file
·649 lines (571 loc) · 20.4 KB
/
create-rails-app
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
#!/bin/bash -ex
#
RAILS_VERSION="7-2-stable"
BOOTSTRAP_VERSION="5.3"
download() {
(git clone -b 7-1-stable --single-branch https://github.com/rails/rails /tmp/rails) || true
}
generate() {
pushd /tmp/rails
gem install bundler --pre # Temporary
rm Gemfile.lock # Temporary
bundle install
bundle exec railties/exe/rails new /tmp/created-rails-app --dev --database=postgresql --javascript=esbuild --css=bootstrap
cd /tmp/created-rails-app
# this is a one time thing
if [ "$(uname)" == "Darwin" ]; then
true # dp nothing on macos
else
git config --global init.defaultBranch main
git config --global user.email "[email protected]"
git config --global user.name "Sam Bot"
fi
commit "Initial commit - did rails new --database=postgresql ..."
popd
}
# repoint gemfile to github rails/rails
repoint() {
pushd /tmp/created-rails-app
replace_line 'gem "rails' "gem 'rails', :github => 'rails/rails', :branch => '"$RAILS_VERSION"'" Gemfile
rm Gemfile.lock
bundle install
bundle lock --add-platform ruby # is this needed nowadays?
remove_line_containing_word "Use local checkout of Rails" Gemfile
./bin/setup
commit "Using rails branch at github"
popd
}
randomize_name() {
pushd /tmp/created-rails-app
npm install --global haikunator-cli
name=$(haikunator | cut -f 2 -d '-')
name2=$(echo $name | perl -nle 'print uc')
name3=$(echo $name | perl -nle 'print ucfirst lc')
echo "Names: $name $name2 $name2"
# replace_string 'CreatedRailsApp' $name3 config/application.rb
perl -p -i -e 's/CreatedRailsApp/'$name3'/g' config/application.rb
perl -p -i -e 's/CreatedRailsApp/'$name3'/g' app/views/layouts/application.html.erb
perl -p -i -e 's/created_rails_app/'$name'/g' config/*.yml
perl -p -i -e 's/CREATED_RAILS_APP/'$name2'/g' config/*.yml
perl -p -i -e 's/created_rails_app/'$name'/g' config/environments/*.rb
commit "Using unique name for rails application"
popd
}
# turbo / stimulus / hotwire / ...
hotwired() {
pushd /tmp/created-rails-app
replace_line 'gem "turbo-rails' "gem 'turbo-rails', :github => 'hotwired/turbo-rails', :branch => 'main'" Gemfile
bundle install
insert_line_after 'viewport' ' <meta name="turbo-refresh-method" content="morph">' app/views/layouts/application.html.erb
commit "Turbo setup"
popd
}
# adds devise gem
devise() {
pushd /tmp/created-rails-app
bundle add devise --git "https://github.com/heartcombo/devise" --branch "main" &>/dev/null
bundle install &>/dev/null
./bin/rails generate devise:install
./bin/rails generate devise User
insert_as_first_line '# frozen_string_literal: true\n' app/models/user.rb
./bin/rails db:migrate
prepend_all_lines '# ' test/fixtures/users.yml
insert_line_after 'class ActiveSupport' ' include Devise::Test::IntegrationHelpers' test/test_helper.rb
commit "Installed devise"
popd
}
# adds pundit for authorization
pundit() {
pushd /tmp/created-rails-app
bundle add pundit &>/dev/null
bundle install &>/dev/null
# TODO:
# ...Include Pundit::Authorization in your application controller:
# class ApplicationController < ActionController::Base
# include Pundit::Authorization
# end
./bin/rails g pundit:install
insert_line_after 'class ApplicationController' ' include Pundit::Authorization' app/controllers/application_controller.rb
mv app/policies/application_policy.rb app/policies/application_policy.rb.txt
# so coverage metric is not affected
commit "Install pundit"
popd
}
activejob() {
pushd /tmp/created-rails-app
bundle add sidekiq
cp ~/work/create-rails-app/create-rails-app/templates/config/initializers/sidekiq.rb config/initializers/
# is this needed? i guess without it rails uses the memory cache store
# insert_before_last_line 'config.cache_store = :redis_cache_store, { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/0") }' config/environments/production.rb
insert_before_last_line 'config.active_job.queue_adapter = :sidekiq' config/environments/development.rb
insert_before_last_line 'config.active_job.queue_adapter = :sidekiq' config/environments/production.rb
insert_file_before_last_line ~/work/create-rails-app/create-rails-app/templates/config/routes_sidekiq.rb config/routes.rb
commit "Setup activejob"
popd
}
# Some extra setup useful for production running of activestorage
activestorage() {
pushd /tmp/created-rails-app
echo 'gem "aws-sdk-s3", require: false' >> Gemfile
bundle install &>/dev/null
commit "Setup activestorage"
popd
}
#
#
#
#
#
# some widgets still expect jquery in the window. namespace
jquery() {
pushd /tmp/created-rails-app
(cd /tmp;
curl -s -O https://code.jquery.com/jquery-3.6.0.min.js)
cp /tmp/jquery-3.6.0.min.js public/
echo '<script src="/jquery-3.6.0.min.js"></script>' >> app/views/_javascripts.html.erb
insert_line_after 'javascript_include_tag' ' <%= render "/javascripts" %>' app/views/layouts/application.html.erb
insert_line_before "stylesheet_link_tag" " <%= render '/stylesheets' %>" app/views/layouts/application.html.erb
touch app/views/_stylesheets.html.erb
commit "Installed jquery"
popd
}
bootstrap() {
pushd /tmp/created-rails-app
# Download and compile bootstrap
(cd /tmp/
(git clone [email protected]:twbs/bootstrap.git || true)
cd /tmp/bootstrap
npm install &>/dev/null
npm run dist &>/dev/null)
cp /tmp/bootstrap/dist/css/bootstrap.css* public/
echo '<link rel="stylesheet" href="/bootstrap.css">' >> app/views/_stylesheets.html.erb
cp /tmp/bootstrap/dist/js/bootstrap.bundle.js* public/
echo '<script src="/bootstrap.bundle.js"></script>' >> app/views/_javascripts.html.erb
prepend_all_lines '\/\/ ' app/assets/stylesheets/application.bootstrap.scss
echo "// instead using bootstrap at app/views/_javascripts" >> app/assets/stylesheets/application.bootstrap.scss
replace_line 'import \* as bootstrap' '// import * as bootstrap from "bootstrap"' app/javascript/application.js
commit "Installed bootstrap"
popd
}
bootstrap_icons() {
pushd /tmp/created-rails-app
(cd /tmp/
curl -s -L -O https://github.com/twbs/icons/archive/refs/heads/main.zip
myunzip main.zip &>/dev/null)
cp /tmp/icons-main/font/bootstrap-icons.css public/
mkdir public/fonts
cp /tmp/icons-main/font/fonts/* public/fonts/
echo '<link rel="stylesheet" href="/bootstrap-icons.css">' >> app/views/_stylesheets.html.erb
commit "Installed bootstrap icons"
popd
}
fontawesome() {
pushd /tmp/created-rails-app
(cd /tmp/
curl -s -L -O https://github.com/FortAwesome/Font-Awesome/archive/refs/heads/6.x.zip
myunzip 6.x.zip &>/dev/null)
mkdir -p public/Font-Awesome/css
mkdir -p public/Font-Awesome/webfonts
cp /tmp/Font-Awesome-6.x/css/all.css public/Font-Awesome/css/
cp /tmp/Font-Awesome-6.x/webfonts/* public/Font-Awesome/webfonts/
echo '<link rel="stylesheet" href="/Font-Awesome/css/all.css">' >> app/views/_stylesheets.html.erb
commit "Installed fontawesome"
popd
}
administrate() {
pushd /tmp/created-rails-app
bundle add administrate &>/dev/null
commit "Installed administrate"
popd
}
# a pagination gem
kaminari() {
pushd /tmp/created-rails-app
bundle add kaminari &>/dev/null
commit "Installed kaminari"
popd
}
# Basic setup for rails flash messages
flash() {
pushd /tmp/created-rails-app
cp ~/work/create-rails-app/create-rails-app/templates/app/views/_flashes.html.erb app/views/
cp ~/work/create-rails-app/create-rails-app/templates/app/javascript/controllers/fade_out_controller.js app/javascript/controllers/
insert_line_after '<body' ' <%= render "/flashes" %>' app/views/layouts/application.html.erb
commit "Setup flash messages"
popd
}
# Adding modal wrapper element
modals() {
pushd /tmp/created-rails-app
cp ~/work/create-rails-app/create-rails-app/templates/app/javascript/controllers/modalopener_controller.js app/javascript/controllers/
cp ~/work/create-rails-app/create-rails-app/templates/app/views/_modal_wrapper.html.erb app/views/
insert_line_after 'yield' " <%= render '/modal_wrapper' %>" app/views/layouts/application.html.erb
commit "Adding modal wrapper element"
popd
}
# some extra styles
stylesheets() {
pushd /tmp/created-rails-app
cp ~/work/create-rails-app/create-rails-app/templates/app/assets/stylesheets/debug.css app/assets/stylesheets/
echo "// @import 'debug';" >> app/assets/stylesheets/application.bootstrap.scss
commit "Added some extra css"
popd
}
constants() {
pushd /tmp/created-rails-app
cp ~/work/create-rails-app/create-rails-app/templates/config/constants.rb config/
echo 'require Rails.root.join("config/constants")' >> config/application.rb
commit "Simple constant overriding mechanism"
popd
}
# Prefer factories over fixtures
factory_bot() {
pushd /tmp/created-rails-app
bundle add factory_bot_rails --group "test,development" &>/dev/null
bundle add faker &>/dev/null
mkdir test/factories
insert_line_after 'class ActiveSupport' ' include FactoryBot::Syntax::Methods' test/test_helper.rb
commit "Installed factory_bot"
popd
}
# tweaks related to test framework
testing() {
pushd /tmp/created-rails-app
# a custom script for autotesting
cp ~/work/create-rails-app/create-rails-app/templates/bin/autotest bin/
chmod +x ./bin/autotest
# parallelize not used atm
replace_string 'parallelize' "\x23\x20parallelize" test/test_helper.rb # using escapes to avoid 'not terminated' error
replace_string 'chrome' 'headless_chrome' test/application_system_test_case.rb
commit "Setup test framework"
# Fix time in tests
mkdir test/support || true
cp ~/work/create-rails-app/create-rails-app/templates/test/support/time_travel.rb test/support/
insert_line_before 'require_relative' 'require_relative "support/time_travel"' test/test_helper.rb
insert_line_after 'Add more helper methods' 'include TimeTravel' test/test_helper.rb
insert_line_after "time_zone" ' config.time_zone = "UTC"' config/application.rb
commit "Fix time in tests"
popd
}
# should output: Coverage report generated ... 1328 / 1328 LOC (100.0%) covered.
# when you do COVERAGE=1 ./bin/rails test
simplecov() {
pushd /tmp/created-rails-app
echo "gem 'simplecov', require: false, group: :test" >> Gemfile
bundle install &>/dev/null
echo "coverage" >> .gitignore
cat ~/work/create-rails-app/create-rails-app/templates/test/test_helper.rb.tt test/test_helper.rb > /tmp/file3
mv /tmp/file3 test/test_helper.rb
cp ~/work/create-rails-app/create-rails-app/templates/test/support/00_simplecov.rb test/support/
string='Dir[File.expand_path('\''support/**/*.rb'\'', __dir__)].sort.each { |rb| require(rb) }'
mysed -i "/class ActiveSupport.*/i $string" test/test_helper.rb
# ^ add line before matched line
mysed -i -r 's/(class ActiveSupport::TestCase)/\n\1/g' test/test_helper.rb
# ^ adds a newline before matched line
# adding minitest-test_profile gem
bundle add minitest-test_profile --group "test"&>/dev/null
cp ~/work/create-rails-app/create-rails-app/templates/test/support/minitest-test_profile.rb test/support/
commit "Installed simplecov"
popd
}
# Prevent test suite making outgoing network connections
# with the message: WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled
webmock() {
pushd /tmp/created-rails-app
bundle add webmock --group "test" &>/dev/null
cp ~/work/create-rails-app/create-rails-app/templates/test/support/webmock.rb test/support/
commit "Use webmock for http requests"
popd
}
# cron like scheduling
scheduler() {
pushd /tmp/created-rails-app
# REVISIT: was getting pid=4 tid=jz0 ERROR: undefined method `merge' for ["name", "example_job", "klass", "Examp
# on heroki
# bundle add sidekiq-cron --git "https://github.com/ondrejbartas/sidekiq-cron" --branch "master" &>/dev/null
# cp ~/work/create-rails-app/create-rails-app/templates/config/initializers/sidekiq_cron.rb config/initializers/
# commit "Installed sidekiq-cron"
popd
}
# using sengrid for email
sendgrid() {
pushd /tmp/created-rails-app
bundle add sendgrid-ruby --optimistic &>/dev/null
commit "Install sendgrid"
popd
}
# ruby gem for error monitoring
rollbar() {
pushd /tmp/created-rails-app
bundle add rollbar &>/dev/null
./bin/rails generate rollbar '<%= ENV["ROLLBAR_POST_SERVER_ITEM_ACCESS_TOKEN"] %>'
# ^ this ends up needing some manual editing
echo '<%= render "/rollbar" if Rails.env.production? %>' >> app/views/_javascripts.html.erb
cp ~/work/create-rails-app/create-rails-app/templates/app/views/_rollbar.html.erb app/views/
# cat config/initializers/rollbar.rb
replace_string "Rails.env.test" "\!Rails.env.production" config/initializers/rollbar.rb
commit "Install rollbar"
popd
}
# flipper for feature flagging
# flipper() {
# pushd /tmp/created-rails-app
# bundle add flipper &>/dev/null
# bundle add flipper-active_record &>/dev/null
# ./bin/rails g flipper:active_record
# commit "Install flipper"
# popd
# }
# Adds a procfile - heroku uses this
procfile() {
pushd /tmp/created-rails-app
cp ~/work/create-rails-app/create-rails-app/templates/Procfile.tt Procfile
commit "Added Procfile"
popd
}
#
#
#
#
#
view_component() {
pushd /tmp/created-rails-app
bundle add view_component &>/dev/null
commit "Install view_component"
popd
}
# Aid debuggability
tracing() {
pushd /tmp/created-rails-app
cp ~/work/create-rails-app/create-rails-app/templates/app/javascript/debug.js app/javascript/
popd
}
# generates soe scaffolds to serve as examples
example() {
pushd /tmp/created-rails-app
# ./bin/rails generate scaffold Example title:string body:text seed:boolean
# mysed -i 's/examples(:one)/FactoryBot.create(:example)/' test/controllers/examples_controller_test.rb
# ^ simple replacement with sed
./bin/rails db:migrate
# ./bin/rails g factory_bot:model Example title:string body:text seed:boolean
# echo 'Example.where(seed: true).destroy_all' >> db/seeds.rb
# echo '10.times { FactoryBot.create(:example, seed: true) }' >> db/seeds.rb
# reduce noise
# rm test/system/examples_test.rb
# rm test/controllers/examples_controller_test.rb
# rm app/controllers/examples_controller.rb
# rm app/models/example.rb
# rm -rf app/views/examples/
# commit "Added example model, controller, etc"
popd
}
# adding booking app as an example
example2() {
pushd /tmp/created-rails-app
mkdir app/components/
mkdir app/reflexes/ || true
cp -r ~/work/create-rails-app/create-rails-app/templates/app/views/bookings app/views/
cp ~/work/create-rails-app/create-rails-app/templates/app/controllers/bookings_controller.rb app/controllers/
cp ~/work/create-rails-app/create-rails-app/templates/app/models/booking.rb app/models/
cp ~/work/create-rails-app/create-rails-app/templates/app/models/concerns/auto_color.rb app/models/concerns/
cp ~/work/create-rails-app/create-rails-app/templates/app/components/bookings* app/components/
cp ~/work/create-rails-app/create-rails-app/templates/app/assets/stylesheets/bookings.css app/assets/stylesheets/
cp ~/work/create-rails-app/create-rails-app/templates/app/reflexes/* app/reflexes/
cp ~/work/create-rails-app/create-rails-app/templates/test/fixtures/bookings.yml test/fixtures/
cp ~/work/create-rails-app/create-rails-app/templates/test/system/bookings* test/system/
cp ~/work/create-rails-app/create-rails-app/templates/app/helpers/application_helper.rb app/helpers/
insert_file_before_last_line ~/work/create-rails-app/create-rails-app/templates/db/schema_bookings.rb db/schema.rb
insert_file_before_last_line ~/work/create-rails-app/create-rails-app/templates/config/routes_bookings.rb config/routes.rb
echo "@import 'bookings';" >> app/assets/stylesheets/application.bootstrap.scss
echo "Booking.seed" >> db/seeds.rb
commit "Added example booking app"
popd
}
# react/jsx/tsx via esbuild
react() {
pushd /tmp/created-rails-app
yarn add react react-dom
mkdir app/javascript/components
cp ~/work/create-rails-app/create-rails-app/templates/hello.tsx app/javascript/components/
echo 'import "./components/hello"' >> app/javascript/application.js
commit "React is available if needed"
popd
}
# sets up automated testing (ci) via github actions
ci() {
pushd /tmp/created-rails-app
mkdir -p .github/workflows/
cp ~/work/create-rails-app/create-rails-app/templates/.github/workflows/tests.yml .github/workflows/
# RUBOCOP
rubocop --auto-gen-config app/ lib/ &>/dev/null
insert_file_after_last_line ~/work/create-rails-app/create-rails-app/templates/.rubocop.yml.tt .rubocop.yml
# REEK
gem install reek
cp ~/work/create-rails-app/create-rails-app/templates/.reek.yml.tt .reek.yml
# ^ some "sensible" reek ignores for rails
commit "Set up CI"
popd
}
#
#
#
#
#
stimulus_reflex() {
pushd /tmp/created-rails-app
echo 'gem "stimulus_reflex", github: "la-ruby/stimulus_reflex", branch: "noprompt"' >> Gemfile
bundle install
yarn add stimulus_reflex@https://github.com/stimulusreflex/dev-builds/archive/refs/tags/stimulus_reflex/496e560.tar.gz
yarn install
~/work/create-rails-app/create-rails-app/installer.exp
# bundle add stimulus_reflex
# ./bin/rails stimulus_reflex:install esbuild
# ./bin/rails stimulus_reflex:install
# gem "stimulus_reflex", github: "stimulusreflex/stimulus_reflex", branch: "main"
# yarn add stimulus_reflex@https://github.com/stimulusreflex/dev-builds/archive/refs/tags/stimulus_reflex/[commit sha].tar.gz
# rubocop -A app/ --only Layout
commit "Install stimulus reflex"
popd
}
# ViewComponentReflex allows you to write reflexes right in your view component code.
# It builds upon stimulus_reflex and view_component
view_component_reflex() {
pushd /tmp/created-rails-app
echo 'gem "view_component_reflex", :github => "joshleblanc/view_component_reflex", :branch => "main"' >> Gemfile
bundle install
commit "Install view_component_reflex gem"
popd
}
readme() {
pushd /tmp/created-rails-app
cp ~/work/create-rails-app/create-rails-app/templates/README.md.tt README.md
commit "Added README"
popd
}
# some additional gitignores
gitignore() {
pushd /tmp/created-rails-app
echo ".envrc" >> .gitignore
echo "**/.DS_Store" >> .gitignore
commit "Updated .gitignore"
popd
}
upload() {
pushd /tmp/created-rails-app
if [ "$(uname)" == "Darwin" ]; then
echo "not uploading on Darwin"
else
git remote add myremote [email protected]:la-ruby/created-rails-app.git
git checkout -b latest
git push -f myremote latest
git checkout main
git clone [email protected]:la-ruby/created-rails-app.git /tmp/downloaded-rails-app
cd /tmp/downloaded-rails-app/
find -not -path "./.git/*" -not -name ".git" -delete
rsync --stats -aP --exclude='.git/' --exclude='node_modules/*' /tmp/created-rails-app/ /tmp/downloaded-rails-app/ &>/dev/null
git add --all
git commit -m "Updates for $(date +%D)"
git push origin main
fi
popd
}
lame1674001972() {
pushd /tmp/created-rails-app
replace_string "class User < ApplicationRecord" "class User < ApplicationRecord #nodoc" app/models/user.rb
commit "lame1674001972"
popd
}
commit() {
git add --all &>/dev/null
git commit -m "$1" &>/dev/null
}
mysed () {
case $(uname -s) in
*[Dd]arwin* | *BSD* ) gsed "$@";;
*) sed -i "$@";;
esac
}
# TODO: is this needed?
myunzip () {
case $(uname -s) in
*[Dd]arwin* | *BSD* ) unzip "$@";;
*) unzip "$@";;
esac
}
replace_line() {
mysed -i "/^$1/c\REMOVED" $3 # replaces matched line with given string
mysed -i "/^REMOVED/c\\$2" $3 # replaces matched line with given string
}
replace_string() {
perl -p -i -e 's/'$1'/'$2'/g' $3
}
prepend_all_lines() {
mysed -i -e "s/^/$1/" $2 # prepend string to all lines
}
# add line after matched line
insert_line_after() {
perl -s -p -i -e '$_.="$bbb\n" if /$aaa/' -- -aaa="$1" -bbb="$2" $3
}
# add line before matched line
insert_line_before() {
perl -s -p -i -e '$_ = "$bbb\n$_" if /$aaa/' -- -aaa="$1" -bbb="$2" $3
}
# TODO: make two spaces optional
insert_before_last_line() {
mysed -i '$i\
'"$1" $2
}
insert_file_before_last_line() {
mysed -i '$ d' $2 # remove last line from file
cat $1 >> $2
echo "end" >> $2
}
insert_file_after_last_line() {
cat $1 >> $2
}
insert_as_first_line() {
awk -v TEXT="$1" 'BEGIN {print TEXT};1' $2
}
remove_line_containing_word() {
gawk -i inplace '!'"/$1/" $2
}
main() {
download
generate
randomize_name
repoint
hotwired
devise
pundit
activejob
activestorage
jquery
bootstrap
bootstrap_icons
fontawesome
administrate
kaminari
flash
modals
stylesheets
constants
factory_bot
testing
simplecov
webmock
scheduler
sendgrid
rollbar
# flipper
procfile
view_component
stimulus_reflex
example
example2
react
ci
readme
gitignore
upload
}
main