Skip to content

Commit dcbd8c3

Browse files
authored
Merge pull request #6 from RonasIT/remove_package_in_console_command
feat: remove package in console command
2 parents ae2173b + ca8a1e9 commit dcbd8c3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Commands/InitCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ public function handle(): void
113113
}
114114
}
115115
}
116+
117+
if ($this->confirm('Do you want to uninstall project-initializator package?', true)) {
118+
$command = 'composer remove ronasit/laravel-project-initializator';
119+
$path = base_path();
120+
121+
exec("cd {$path} && {$command}");
122+
}
116123
}
117124

118125
protected function createAdminUser(string $kebabName): void

tests/InitCommandTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function testRunWithoutAdminAndReadmeCreation()
2929
->expectsQuestion('Please enter an application URL', 'https://mysite.com')
3030
->expectsConfirmation('Do you want to generate an admin user?')
3131
->expectsConfirmation('Do you want to generate a README file?')
32+
->expectsConfirmation('Do you want to uninstall project-initializator package?')
3233
->assertExitCode(0);
3334
}
3435

@@ -64,6 +65,7 @@ public function testRunWithAdminAndWithoutReadmeCreation()
6465
->expectsQuestion('Please enter an admin password', '123456')
6566
->expectsQuestion('Please enter an admin role id', 1)
6667
->expectsConfirmation('Do you want to generate a README file?')
68+
->expectsConfirmation('Do you want to uninstall project-initializator package?')
6769
->assertExitCode(0);
6870
}
6971

@@ -193,6 +195,7 @@ public function testRunWithAdminAndDefaultReadmeCreation()
193195
->expectsOutput('- ArgoCD link')
194196
->expectsOutput('- Manager\'s email')
195197
->expectsOutput('- Code Owner/Team Lead\'s email')
198+
->expectsConfirmation('Do you want to uninstall project-initializator package?')
196199
->assertExitCode(0);
197200
}
198201

@@ -295,10 +298,11 @@ public function testRunWithAdminAndPartialReadmeCreation()
295298
->expectsOutput('Don`t forget to fill the following empty values:')
296299
->expectsOutput('- Issue Tracker link')
297300
->expectsOutput('- Code Owner/Team Lead\'s email')
301+
->expectsConfirmation('Do you want to uninstall project-initializator package?')
298302
->assertExitCode(0);
299303
}
300304

301-
public function testRunWithAdminAndFullReadmeCreation()
305+
public function testRunWithAdminAndFullReadmeCreationAndRemovingInitializator()
302306
{
303307
$this->mockShellExec();
304308

@@ -360,6 +364,14 @@ public function testRunWithAdminAndFullReadmeCreation()
360364
]
361365
);
362366

367+
$this->mockNativeFunction('RonasIT\ProjectInitializator\Commands', [
368+
$this->functionCall('exec', [
369+
'cd /app/tests/.. && composer remove ronasit/laravel-project-initializator',
370+
'optionalParameter',
371+
'optionalParameter',
372+
], 'success'),
373+
]);
374+
363375
$this
364376
->artisan('init "My App"')
365377
->expectsOutput('Project initialized successfully!')
@@ -418,6 +430,7 @@ public function testRunWithAdminAndFullReadmeCreation()
418430
->expectsQuestion('Please enter a Laravel Nova\'s admin email', '[email protected]')
419431
->expectsQuestion('Please enter a Laravel Nova\'s admin password', '654321')
420432
->expectsOutput('README generated successfully!')
433+
->expectsConfirmation('Do you want to uninstall project-initializator package?', 'yes')
421434
->assertExitCode(0);
422435
}
423436
}

0 commit comments

Comments
 (0)