|
8 | 8 | RUBY |
9 | 9 | end |
10 | 10 |
|
11 | | -insert_into_file "Gemfile", after: /^group :development, :test do\n/ do |
12 | | - <<~RUBY |
13 | | - gem "dotenv" |
14 | | - RUBY |
15 | | -end |
16 | | - |
17 | 11 | # replace bin/rails db:prepare with bin/rails db:setup in bin/setup |
18 | 12 | gsub_file "bin/setup", "bin/rails db:prepare", "bin/rails db:setup" |
19 | 13 |
|
20 | | -# add the renuo fetch-secrets command and copying the dotenv file in bin/setup, before bin/rails db:setup |
| 14 | +# add the renuo fetch-secrets command in bin/setup, before bin/rails db:setup |
21 | 15 | insert_into_file "bin/setup", before: "\n puts \"\\n== Preparing database ==\"" do |
22 | 16 | <<-RUBY |
23 | 17 | puts "\\n== Fetching 1password dependencies ==" |
24 | 18 | system! 'renuo fetch-secrets' |
25 | | - |
26 | | - puts "\n== Copying sample files ==" |
27 | | - unless File.exist?('.env') |
28 | | - system! 'cp .env.example .env' |
29 | | - end |
30 | 19 | RUBY |
31 | 20 | end |
32 | 21 |
|
|
48 | 37 | RUBOCOP |
49 | 38 | end |
50 | 39 |
|
| 40 | +answer = ask("Do you want to setup dotenv? (y/n)", default: "y") |
51 | 41 |
|
52 | | -create_file ".env.example", force: true do |
53 | | - <<~ENV |
54 | | - SECRET_KEY_BASE=<%= `bin/rails secret`.strip %> |
55 | | - APP_PORT=3000 |
56 | | - ENV |
57 | | -end |
| 42 | +if answer.downcase == "y" |
| 43 | + insert_into_file "Gemfile", after: /^group :development, :test do\n/ do |
| 44 | + <<~RUBY |
| 45 | + gem "dotenv" |
| 46 | + RUBY |
| 47 | + end |
58 | 48 |
|
59 | | -create_file ".env", force: true do |
60 | | - <<~ENV |
61 | | - SECRET_KEY_BASE=#{`bin/rails secret`.strip} |
62 | | - APP_PORT=3000 |
63 | | - ENV |
64 | | -end |
| 49 | + create_file ".env.example", force: true do |
| 50 | + <<~ENV |
| 51 | + SECRET_KEY_BASE=<%= `bin/rails secret`.strip %> |
| 52 | + APP_PORT=3000 |
| 53 | + ENV |
| 54 | + end |
| 55 | + |
| 56 | + create_file ".env", force: true do |
| 57 | + <<~ENV |
| 58 | + SECRET_KEY_BASE=#{SecureRandom.hex(64)} |
| 59 | + APP_PORT=3000 |
| 60 | + ENV |
| 61 | + end |
| 62 | + |
| 63 | + create_file "config/initializers/dotenv.rb", force: true do |
| 64 | + <<~DOTENV |
| 65 | + Dotenv.require_keys(Dotenv.parse(".env.example").keys) |
| 66 | + DOTENV |
| 67 | + end |
65 | 68 |
|
66 | | -create_file "config/initializers/dotenv.rb", force: true do |
67 | | - <<~DOTENV |
68 | | - Dotenv.require_keys(Dotenv.parse(".env.example").keys) |
69 | | - DOTENV |
| 69 | + insert_into_file "bin/setup", before: "\n puts \"\\n== Preparing database ==\"" do |
| 70 | + <<-RUBY |
| 71 | + puts "\n== Copying sample files ==" |
| 72 | + unless File.exist?('.env') |
| 73 | + system! 'cp .env.example .env' |
| 74 | + end |
| 75 | + RUBY |
| 76 | + end |
70 | 77 | end |
71 | 78 |
|
72 | 79 | create_file "bin/run", force: true do |
|
0 commit comments