|
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 |
|
|
49 | 43 | end |
50 | 44 |
|
51 | 45 |
|
52 | | -create_file ".env.example", force: true do |
53 | | - <<~ENV |
54 | | - SECRET_KEY_BASE=<%= `bin/rails secret`.strip %> |
55 | | - APP_PORT=3000 |
56 | | - ENV |
| 46 | +insert_into_file "Gemfile", after: /^group :development, :test do\n/ do |
| 47 | + <<~RUBY |
| 48 | + gem "dotenv" |
| 49 | + RUBY |
57 | 50 | end |
58 | 51 |
|
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 |
| 52 | +answer = ask("Do you want to setup dotenv? (y/n)", default: "y") |
| 53 | + |
| 54 | +if answer.downcase == "y" |
| 55 | + create_file ".env.example", force: true do |
| 56 | + <<~ENV |
| 57 | + SECRET_KEY_BASE=<%= `bin/rails secret`.strip %> |
| 58 | + APP_PORT=3000 |
| 59 | + ENV |
| 60 | + end |
| 61 | + |
| 62 | + create_file ".env", force: true do |
| 63 | + <<~ENV |
| 64 | + SECRET_KEY_BASE=#{SecureRandom.hex(64)} |
| 65 | + APP_PORT=3000 |
| 66 | + ENV |
| 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 | + create_file "config/initializers/dotenv.rb", force: true do |
| 70 | + <<~DOTENV |
| 71 | + Dotenv.require_keys(Dotenv.parse(".env.example").keys) |
| 72 | + DOTENV |
| 73 | + end |
70 | 74 | end |
71 | 75 |
|
72 | 76 | create_file "bin/run", force: true do |
|
0 commit comments