@@ -20,8 +20,6 @@ class _MakeKeyCommand extends NyCustomCommand {
2020 CommandBuilder builder (CommandBuilder command) {
2121 command.addFlag ("help" ,
2222 abbr: "h" , help: 'Generates a secure APP_KEY for your .env file' );
23- command.addFlag ("force" ,
24- abbr: "f" , help: "Overwrites existing APP_KEY if present." );
2523 command.addOption ("file" ,
2624 abbr: "e" , help: "The .env file to update." , defaultValue: ".env" );
2725 return command;
@@ -30,7 +28,6 @@ class _MakeKeyCommand extends NyCustomCommand {
3028 @override
3129 Future <void > handle (CommandResult result) async {
3230 final envFile = result.getString ("file" , defaultValue: ".env" )! ;
33- final hasForceFlag = result.hasForceFlag;
3431
3532 // Generate a 32-character secure key
3633 final appKey = _generateSecureKey (32 );
@@ -42,15 +39,9 @@ class _MakeKeyCommand extends NyCustomCommand {
4239 if (await file.exists ()) {
4340 envContent = await file.readAsString ();
4441
45- // Check if APP_KEY already exists
42+ // Replace existing APP_KEY if present
4643 final appKeyRegex = RegExp (r'^APP_KEY=.*$' , multiLine: true );
4744 if (appKeyRegex.hasMatch (envContent)) {
48- if (! hasForceFlag) {
49- warning ('APP_KEY already exists in $envFile ' );
50- info ('Use --force to overwrite the existing key.' );
51- return ;
52- }
53- // Replace existing APP_KEY
5445 envContent = envContent.replaceAll (appKeyRegex, 'APP_KEY=$appKey ' );
5546 await file.writeAsString (envContent);
5647 success ('APP_KEY updated in $envFile ' );
0 commit comments