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
1 parent 73e2dd8 commit 83e0b77
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions bin/sync
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ require __DIR__.'/../vendor/autoload.php';

$files = new Illuminate\Filesystem\Filesystem();

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 @@ -17,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 @@ -31,9 +37,11 @@ $files->copyDirectory("{$workingPath}/vendor/orchestra/testbench-core/workbench/
$files->copyDirectory("{$workingPath}/vendor/orchestra/testbench-core/workbench/routes", "{$workingPath}/workbench/routes");
$files->copy("{$workingPath}/vendor/laravel/dusk/stubs/phpunit.xml", "{$workingPath}/stubs/phpunit.xml");

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

require $configureSkeleton;

Expand All @@ -46,4 +54,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();

0 comments on commit 83e0b77

Please sign in to comment.