@@ -167,26 +167,60 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do
167167 # CRITICAL: Check if required configuration exists BEFORE starting app
168168 # This prevents configuration timing issues where config is added via Igniter
169169 # but the app has already started with cached (missing) configuration
170+
171+ # Check if this is a retry pass (automatic restart after adding config)
172+ is_retry = Process . get ( :phoenix_kit_retry_pass , false )
170173 config_status = check_required_configuration ( )
171174
172- case config_status do
173- :missing ->
175+ case { config_status , is_retry } do
176+ { :missing , false } ->
174177 # First pass: Add configuration via Igniter without starting app
175178 # Store config status in Process dictionary for igniter/1 to read
176179 Process . put ( :phoenix_kit_config_status , :missing )
177180 show_missing_config_message ( argv )
178- result = super ( argv )
179- show_config_added_message ( argv )
180- result
181+ super ( argv )
182+
183+ # Automatic restart instead of manual prompt
184+ Mix . shell ( ) . info ( """
185+
186+ ✅ Configuration added successfully!
187+ 🔄 Automatically restarting to complete the update...
188+ """ )
181189
182- :ok ->
183- # Second pass: Configuration exists, safe to start app and update
190+ # Clean Process dictionary for fresh state
191+ Process . delete ( :phoenix_kit_config_status )
192+ Process . put ( :phoenix_kit_retry_pass , true )
193+
194+ # Recursive call with same arguments
195+ run ( argv )
196+
197+ { :ok , _ } ->
198+ # Second pass (automatic or manual): Configuration exists, safe to start app
184199 # Store config status in Process dictionary for igniter/1 to read
185200 Process . put ( :phoenix_kit_config_status , :ok )
186201 Mix.Task . run ( "app.start" )
187202 result = super ( argv )
188203 post_igniter_tasks ( elem ( opts , 0 ) )
204+
205+ # Clean retry flag
206+ Process . delete ( :phoenix_kit_retry_pass )
189207 result
208+
209+ { :missing , true } ->
210+ # Safety: Configuration still missing after retry
211+ Mix . shell ( ) . error ( """
212+
213+ ❌ Configuration was not added successfully after automatic retry.
214+
215+ This may indicate a problem with your config/config.exs file.
216+ Please check the file manually and ensure it's writable.
217+
218+ Then run manually:
219+ mix phoenix_kit.update #{ Enum . join ( argv , " " ) }
220+ """ )
221+
222+ Process . delete ( :phoenix_kit_retry_pass )
223+ :error
190224 end
191225 end
192226 end
@@ -201,6 +235,7 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do
201235 PhoenixKit requires configuration for:
202236 - Ueberauth (OAuth authentication)
203237 - Hammer (rate limiting)
238+ - Oban (background jobs for file processing)
204239
205240 This configuration will be added now.
206241
@@ -209,17 +244,6 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do
209244 """ )
210245 end
211246
212- # Display message after configuration is added
213- defp show_config_added_message ( argv ) do
214- Mix . shell ( ) . info ( """
215-
216- ✅ Configuration added successfully!
217-
218- Next step: Run the update command again to complete the upgrade:
219- mix phoenix_kit.update #{ Enum . join ( argv , " " ) }
220- """ )
221- end
222-
223247 # Check if all required configuration exists
224248 # Returns :ok if all config present, :missing if any config is missing
225249 defp check_required_configuration do
@@ -284,9 +308,10 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do
284308 has_oban_config =
285309 Enum . any? ( lines , fn line ->
286310 trimmed = String . trim ( line )
287- # Not a comment and contains config :phoenix_kit, Oban
311+ # Not a comment and contains config for any app with Oban
312+ # Matches: "config :any_app, Oban" or "config :any_app, Oban,"
288313 ! String . starts_with? ( trimmed , "#" ) and
289- String . contains? ( line , "config :phoenix_kit , Oban" )
314+ String . contains? ( line , ", Oban" )
290315 end )
291316
292317 has_queues =
0 commit comments