@@ -5,6 +5,7 @@ class InstallGenerator < Rails::Generators::Base
55 desc 'Forest Rails Liana installation generator'
66
77 argument :env_secret , type : :string , required : true , desc : 'required' , banner : 'env_secret'
8+ argument :application_url , type : :string , required : false , desc : 'optional' , banner : 'application_url' , default : 'http://localhost:3000'
89
910 def install
1011 if ForestLiana . env_secret . present?
@@ -27,35 +28,42 @@ def install
2728 if File . exist? 'config/secrets.yml'
2829 inject_into_file 'config/secrets.yml' , after : "development:\n " do
2930 " forest_env_secret: #{ env_secret } \n " +
30- " forest_auth_secret: #{ auth_secret } \n "
31+ " forest_auth_secret: #{ auth_secret } \n " +
32+ " forest_application_url: #{ application_url } \n "
3133 end
3234
3335 inject_into_file 'config/secrets.yml' , after : "staging:\n " , force : true do
3436 " forest_env_secret: <%= ENV[\" FOREST_ENV_SECRET\" ] %>\n " +
35- " forest_auth_secret: <%= ENV[\" FOREST_AUTH_SECRET\" ] %>\n "
37+ " forest_auth_secret: <%= ENV[\" FOREST_AUTH_SECRET\" ] %>\n " +
38+ " forest_application_url: <%= ENV[\" FOREST_APPLICATION_URL\" ] %>\n "
3639 end
3740
3841 inject_into_file 'config/secrets.yml' , after : "production:\n " , force : true do
3942 " forest_env_secret: <%= ENV[\" FOREST_ENV_SECRET\" ] %>\n " +
40- " forest_auth_secret: <%= ENV[\" FOREST_AUTH_SECRET\" ] %>\n "
43+ " forest_auth_secret: <%= ENV[\" FOREST_AUTH_SECRET\" ] %>\n " +
44+ " forest_application_url: <%= ENV[\" FOREST_APPLICATION_URL\" ] %>\n "
4145 end
4246 else
4347 create_file 'config/secrets.yml' do
4448 "development:\n " +
4549 " forest_env_secret: #{ env_secret } \n " +
4650 " forest_auth_secret: #{ auth_secret } \n " +
51+ " forest_application_url: #{ application_url } \n " +
4752 "staging:\n " +
4853 " forest_env_secret: <%= ENV[\" FOREST_ENV_SECRET\" ] %>\n " +
4954 " forest_auth_secret: <%= ENV[\" FOREST_AUTH_SECRET\" ] %>\n " +
55+ " forest_application_url: <%= ENV[\" FOREST_APPLICATION_URL\" ] %>\n " +
5056 "production:\n " +
5157 " forest_env_secret: <%= ENV[\" FOREST_ENV_SECRET\" ] %>\n " +
52- " forest_auth_secret: <%= ENV[\" FOREST_AUTH_SECRET\" ] %>\n "
58+ " forest_auth_secret: <%= ENV[\" FOREST_AUTH_SECRET\" ] %>\n " +
59+ " forest_application_url: <%= ENV[\" FOREST_APPLICATION_URL\" ] %>\n "
5360 end
5461 end
5562
5663 initializer 'forest_liana.rb' do
5764 "ForestLiana.env_secret = Rails.application.secrets.forest_env_secret" +
58- "\n ForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret"
65+ "\n ForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret" +
66+ "\n ForestLiana.application_url = Rails.application.secrets.forest_application_url"
5967 end
6068 end
6169 end
0 commit comments