diff --git a/app/Robo/Plugin/Commands/EjectCommands.php b/app/Robo/Plugin/Commands/EjectCommands.php index 89cd5b9..295973e 100644 --- a/app/Robo/Plugin/Commands/EjectCommands.php +++ b/app/Robo/Plugin/Commands/EjectCommands.php @@ -42,6 +42,7 @@ final public function eject(): void { die(); } + // Destroy the files in the Controllers/Sample directory and the Controllers/Sample directory itself $sampleDirPath = self::CONTROLLERS_PATH . 'Sample'; array_map('unlink', glob("$sampleDirPath/*.*")); if (file_exists($sampleDirPath)) { @@ -50,7 +51,12 @@ final public function eject(): void { } } - // Get a file list of any controllers + // Remove the SampleCommands.php file if it exists + if (file_exists(__DIR__ . '/SampleCommands.php')) { + unlink(__DIR__ . '/SampleCommands.php'); + } + + // Get a file list of any controllers in the Controllers directory $dirList = glob(self::CONTROLLERS_PATH . '*', GLOB_ONLYDIR); // No need to register controllers if there are none. if ($dirList === false || count($dirList) === 0) { diff --git a/app/Robo/Plugin/Commands/MakeCommands.php b/app/Robo/Plugin/Commands/MakeCommands.php index 0380d2b..161c11b 100644 --- a/app/Robo/Plugin/Commands/MakeCommands.php +++ b/app/Robo/Plugin/Commands/MakeCommands.php @@ -222,46 +222,4 @@ final public function reset(): void { RoboBase::showThrowableAndDie($e); } } - - /** - * Remove Sample controller, routes, & other artifacts from the project - */ - final public function eject(): void { - $cli = $this->cli; - $cli->br(); - $cli - ->bold() - ->backgroundLightRed() - ->white() - ->border('*'); - $cli - ->bold() - ->backgroundLightRed() - ->white('eject is a destructive operation. It removes the Sample controller, route, etc.'); - $cli - ->bold() - ->backgroundLightRed() - ->white('It will also overwrite the RegisterControllers.php file.'); - $cli - ->bold() - ->backgroundLightRed() - ->white() - ->border('*'); - $cli->br(); - /** @var Input $input */ - $input = $cli->bold()->lightGray()->confirm('Are you sure you want to proceed?'); - if (!$input->confirmed()) { - die(); - } - - $sampleDirPath = __DIR__ . '/../../../Controllers/Sample'; - array_map('unlink', glob("$sampleDirPath/*.*")); - unlink($sampleDirPath); - - // Rebuild RegisterControllers.php - $loader = new FilesystemLoader(__DIR__ . '/Templates'); - $twig = new Twig($loader); - $registerControllers = new RegisterForge($twig); - $registerControllers->forgeRegisterControllers(); - } } diff --git a/app/Robo/Plugin/Commands/SampleCommands.php b/app/Robo/Plugin/Commands/SampleCommands.php new file mode 100644 index 0000000..27c8e42 --- /dev/null +++ b/app/Robo/Plugin/Commands/SampleCommands.php @@ -0,0 +1,20 @@ +taskServer(8088) + ->host('127.0.0.1') + ->dir(__DIR__ . '/../../../../public') + ->background() + ->run(); + $this->taskOpenBrowser('http://localhost:8088/v1/sample/Hello-World')->run(); + sleep(15); + } +} diff --git a/app/Robo/Plugin/Commands/WillowCommands.php b/app/Robo/Plugin/Commands/WillowCommands.php index 988bcc9..bc9467a 100644 --- a/app/Robo/Plugin/Commands/WillowCommands.php +++ b/app/Robo/Plugin/Commands/WillowCommands.php @@ -14,19 +14,6 @@ final public function docs(): void { $this->taskOpenBrowser('https://www.notion.so/ryannerd/Get-Started-bf56317580884ccd95ed8d3889f83c72')->run(); } - /** - * Launch the built-in PHP server and load the Sample in a web browser - */ - final public function sample(): void { - $this->taskServer(8088) - ->host('127.0.0.1') - ->dir(__DIR__ . '/../../../../public') - ->background() - ->run(); - $this->taskOpenBrowser('http://localhost:8088/v1/sample/Hello-World')->run(); - sleep(15); - } - /** * Show Willow's fancy banner */