Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Nov 26, 2024
2 parents 8f26dd3 + 83e0b77 commit 83b3f93
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 43 deletions.
29 changes: 20 additions & 9 deletions bin/sync
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ $workingPath = getcwd();

require __DIR__.'/../vendor/autoload.php';

$input = new Symfony\Component\Console\Input\ArgvInput();
$files = new Illuminate\Filesystem\Filesystem();

$version = ($input->hasParameterOption('--dev') && $input->hasParameterOption('--stable') === false) ? '10.x-dev' : '^10.0';
if (! is_file($configureSkeleton = Orchestra\Testbench\join_paths($workingPath, 'vendor', 'orchestra', 'testbench-core', 'bin', 'configure-skeleton.php'))) {
throw new RuntimeException(sprintf('Misssing [%s] file from `orchestra/testbench-core`', $configureSkeleton));
}

$purgeSkeletonDirectories = static function () use ($files, $workingPath) {
$files->delete("{$workingPath}/laravel/.env");
Expand All @@ -20,11 +21,13 @@ function line(string $code, int $tab = 0): string {
return implode('', [PHP_EOL, str_repeat(' ', ($tab * 4)), $code]);
}

$purgeSkeletonDirectories();
/**
* ----------------------------------------------------------------------
* Prepare skeleton folder
* ----------------------------------------------------------------------
*/

if (! is_file($configureSkeleton = Orchestra\Testbench\join_paths($workingPath, 'vendor', 'orchestra', 'testbench-core', 'bin', 'configure-skeleton.php'))) {
throw new RuntimeException(sprintf('Misssing [%s] file from `orchestra/testbench-core`', $configureSkeleton));
}
$purgeSkeletonDirectories();

$files->copy("{$workingPath}/vendor/orchestra/testbench-core/laravel/bootstrap/app.php", "{$workingPath}/laravel/bootstrap/app.php");
$files->copy("{$workingPath}/vendor/orchestra/testbench-core/laravel/server.php", "{$workingPath}/laravel/server.php");
Expand All @@ -38,9 +41,11 @@ if ($files->exists("{$workingPath}/vendor/laravel/dusk/stubs/phpunit9.xml")) {
$files->copy("{$workingPath}/vendor/laravel/dusk/stubs/phpunit9.xml", "{$workingPath}/stubs/phpunit9.xml");
}

Symfony\Component\Process\Process::fromShellCommandline(
'composer create-project "laravel/laravel:'.$version.'" skeleton --no-scripts --no-plugins --quiet --no-install', $workingPath
)->mustRun();
/**
* ----------------------------------------------------------------------
* Copy files from `laravel/laravel`
* ----------------------------------------------------------------------
*/

require $configureSkeleton;

Expand All @@ -53,4 +58,10 @@ transform([
line('use Orchestra\Testbench\Foundation\Application;') => line('use Orchestra\Testbench\Dusk\Foundation\Application;'),
], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/laravel/bootstrap/app.php"));

/**
* ----------------------------------------------------------------------
* Cleanup
* ----------------------------------------------------------------------
*/

$purgeSkeletonDirectories();
35 changes: 6 additions & 29 deletions src/Foundation/Console/DuskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ class DuskCommand extends Command
*/
protected $description = 'Run the package Dusk tests';

/**
* Create a new command instance.
*/
/** {@inheritDoc} */
public function __construct()
{
parent::__construct();
Expand All @@ -42,11 +40,7 @@ public function __construct()
}
}

/**
* Execute the console command.
*
* @return mixed
*/
/** {@inheritDoc} */
#[\Override]
public function handle()
{
Expand All @@ -55,12 +49,7 @@ public function handle()
return parent::handle();
}

/**
* Get the array of arguments for running PHPUnit.
*
* @param array $options
* @return array
*/
/** {@inheritDoc} */
#[\Override]
protected function phpunitArguments($options)
{
Expand All @@ -82,11 +71,7 @@ protected function phpunitArguments($options)
return ! \is_null($file) ? array_merge(['-c', $file], $options) : $options;
}

/**
* Write the Dusk PHPUnit configuration.
*
* @return void
*/
/** {@inheritDoc} */
#[\Override]
protected function writeConfiguration()
{
Expand All @@ -113,11 +98,7 @@ protected function writeConfiguration()
$this->hasPhpUnitConfiguration = true;
}

/**
* Remove the Dusk PHPUnit configuration.
*
* @return void
*/
/** {@inheritDoc} */
#[\Override]
protected function removeConfiguration()
{
Expand All @@ -126,11 +107,7 @@ protected function removeConfiguration()
}
}

/**
* Get the PHP binary environment variables.
*
* @return array|null
*/
/** {@inheritDoc} */
#[\Override]
protected function env()
{
Expand Down
6 changes: 1 addition & 5 deletions src/Foundation/Console/PurgeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ class PurgeCommand extends Command
*/
protected $description = 'Purge the package debugging files for Dusk';

/**
* Create a new command instance.
*
* @return void
*/
/** {@inheritDoc} */
public function __construct()
{
parent::__construct();
Expand Down

0 comments on commit 83b3f93

Please sign in to comment.