-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mior Muhammad Zaki <[email protected]>
- Loading branch information
Showing
72 changed files
with
1,389 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ jobs: | |
- "windows-latest" | ||
php: | ||
- 8.2 | ||
- 8.3 | ||
dependencies: | ||
- "highest" | ||
- "lowest" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: "update-stubs" | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update: | ||
name: Update Stubs | ||
|
||
runs-on: ubuntu-latest | ||
continue-on-error: false | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Dependencies | ||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress | ||
|
||
- name: Installed dependencies | ||
run: composer show -D | ||
|
||
- name: Sync changes | ||
run: | | ||
php bin/sync | ||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Update Stubs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
$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'; | ||
|
||
Illuminate\Support\Collection::make([ | ||
'factory.stub' => 'Database/Console/Factories/stubs/factory.stub', | ||
'pest.stub' => 'Foundation/Console/stubs/pest.stub', | ||
'pest.unit.stub' => 'Foundation/Console/stubs/pest.unit.stub', | ||
'test.stub' => 'Foundation/Console/stubs/test.stub', | ||
'test.unit.stub' => 'Foundation/Console/stubs/test.unit.stub', | ||
'view.stub' => 'Foundation/Console/stubs/view.stub', | ||
'view.test.stub' => 'Foundation/Console/stubs/view.test.stub', | ||
])->transform(fn ($file) => "{$workingPath}/vendor/laravel/framework/src/Illuminate/{$file}") | ||
->each(function ($file, $name) use ($files, $workingPath) { | ||
$files->copy($file, "{$workingPath}/src/Console/stubs/{$name}"); | ||
}); | ||
|
||
transform([ | ||
'use Illuminate\Database\Eloquent\Factories\Factory;' => 'use Illuminate\Database\Eloquent\Factories\Factory;'.PHP_EOL.'use {{ namespacedModel }};', | ||
' * @extends \Illuminate\Database\Eloquent\Factories\Factory<\{{ namespacedModel }}>' => ' * @template TModel of \{{ namespacedModel }} | ||
* | ||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<TModel>', | ||
' /** | ||
* Define the model\'s default state.'.PHP_EOL => ' /** | ||
* The name of the factory\'s corresponding model. | ||
* | ||
* @var class-string<TModel> | ||
*/ | ||
protected $model = {{ model }}::class; | ||
/** | ||
* Define the model\'s default state.'.PHP_EOL, | ||
], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/src/Console/stubs/factory.stub")); | ||
|
||
transform([ | ||
'use Tests\TestCase;' => 'use NamespacedDummyTestCase;', | ||
'class {{ class }} extends TestCase' => 'class {{ class }} extends DummyTestCase', | ||
], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/src/Console/stubs/test.stub")); | ||
|
||
transform([ | ||
'use PHPUnit\Framework\TestCase;' => 'use NamespacedDummyTestCase;', | ||
'class {{ class }} extends TestCase' => 'class {{ class }} extends DummyTestCase', | ||
], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/src/Console/stubs/test.unit.stub")); | ||
|
||
transform([ | ||
'use Tests\TestCase;' => 'use NamespacedDummyTestCase;'.PHP_EOL.'use Illuminate\Foundation\Testing\Concerns\InteractsWithViews;', | ||
'class {{ class }} extends TestCase'.PHP_EOL.'{' => 'class {{ class }} extends DummyTestCase'.PHP_EOL.'{'.PHP_EOL.' use InteractsWithViews;'.PHP_EOL, | ||
], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/src/Console/stubs/view.test.stub")); | ||
|
||
if ($files->isDirectory("{$workingPath}/vendor/laravel/framework/tests")) { | ||
Illuminate\Support\Collection::make([ | ||
...$files->glob("{$workingPath}/vendor/laravel/framework/tests/Integration/Generators/*.php") | ||
])->flatten() | ||
->each(function ($file) use ($files, $workingPath) { | ||
$files->copy($file, "{$workingPath}/workbench/tests/".basename($file)); | ||
}); | ||
} | ||
|
||
$files->deleteDirectory("{$workingPath}/skeleton"); | ||
|
||
Symfony\Component\Process\Process::fromShellCommandline( | ||
'composer create-project "laravel/laravel:'.$version.'" skeleton --no-install --no-scripts --no-plugins --quiet', $workingPath | ||
)->mustRun(); | ||
|
||
$files->copy("{$workingPath}/skeleton/app/Models/User.php", "{$workingPath}/src/Console/stubs/user-model.stub"); | ||
transform([ | ||
'namespace App\Models;' => 'namespace {{ namespace }};', | ||
], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/src/Console/stubs/user-model.stub")); | ||
|
||
$files->copy("{$workingPath}/skeleton/database/factories/UserFactory.php", "{$workingPath}/src/Console/stubs/user-factory.stub"); | ||
transform([ | ||
'namespace Database\Factories;' => 'namespace {{ factoryNamespace }};', | ||
'use Illuminate\Support\Str;'.PHP_EOL => 'use Illuminate\Support\Str;'.PHP_EOL.'use {{ namespacedModel }};'.PHP_EOL, | ||
'\Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>' => '\Illuminate\Database\Eloquent\Factories\Factory<\{{ namespacedModel }}>', | ||
' /** | ||
* Define the model\'s default state.' => ' /** | ||
* The name of the factory\'s corresponding model. | ||
* | ||
* @var string | ||
*/ | ||
protected $model = {{ model }}::class; | ||
/** | ||
* Define the model\'s default state.' | ||
], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/src/Console/stubs/user-factory.stub")); | ||
|
||
$files->deleteDirectory("{$workingPath}/skeleton"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Orchestra\Canvas\Console; | ||
|
||
use Illuminate\Filesystem\Filesystem; | ||
use Illuminate\Support\Composer; | ||
use Orchestra\Canvas\Core\Concerns\MigrationGenerator; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
|
||
/** | ||
* @see https://github.com/laravel/framework/blob/9.x/src/Illuminate/Queue/Console/BatchesTableCommand.php | ||
*/ | ||
#[AsCommand(name: 'queue:batches-table', description: 'Create a migration for the batches database table')] | ||
class BatchesTableCommand extends \Illuminate\Queue\Console\BatchesTableCommand | ||
{ | ||
use MigrationGenerator; | ||
|
||
/** | ||
* Create a new notifications table command instance. | ||
* | ||
* @param \Illuminate\Filesystem\Filesystem $files | ||
* @param \Illuminate\Support\Composer $composer | ||
* @return void | ||
*/ | ||
public function __construct(Filesystem $files, Composer $composer) | ||
{ | ||
parent::__construct($files, $composer); | ||
|
||
$this->addGeneratorPresetOptions(); | ||
} | ||
|
||
/** | ||
* Create a base migration file for the table. | ||
* | ||
* @param string $table | ||
* @return string | ||
*/ | ||
protected function createBaseMigration($table) | ||
{ | ||
return $this->createBaseMigrationUsingCanvas($table); | ||
} | ||
|
||
/** | ||
* Determine whether a migration for the table already exists. | ||
* | ||
* @param string $table | ||
* @return bool | ||
*/ | ||
protected function migrationExists($table) | ||
{ | ||
return $this->migrationExistsUsingCanvas($table); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Orchestra\Canvas\Console; | ||
|
||
use Illuminate\Filesystem\Filesystem; | ||
use Illuminate\Support\Composer; | ||
use Orchestra\Canvas\Core\Concerns\MigrationGenerator; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
|
||
/** | ||
* @see https://github.com/laravel/framework/blob/9.x/src/Illuminate/Cache/Console/CacheTableCommand.php | ||
*/ | ||
#[AsCommand(name: 'cache:table', description: 'Create a migration for the cache database table')] | ||
class CacheTableCommand extends \Illuminate\Cache\Console\CacheTableCommand | ||
{ | ||
use MigrationGenerator; | ||
|
||
/** | ||
* Create a new session table command instance. | ||
* | ||
* @param \Illuminate\Filesystem\Filesystem $files | ||
* @param \Illuminate\Support\Composer $composer | ||
* @return void | ||
*/ | ||
public function __construct(Filesystem $files, Composer $composer) | ||
{ | ||
parent::__construct($files, $composer); | ||
|
||
$this->addGeneratorPresetOptions(); | ||
} | ||
|
||
/** | ||
* Create a base migration file for the table. | ||
* | ||
* @param string $table | ||
* @return string | ||
*/ | ||
protected function createBaseMigration($table) | ||
{ | ||
return $this->createBaseMigrationUsingCanvas($table); | ||
} | ||
|
||
/** | ||
* Determine whether a migration for the table already exists. | ||
* | ||
* @param string $table | ||
* @return bool | ||
*/ | ||
protected function migrationExists($table) | ||
{ | ||
return $this->migrationExistsUsingCanvas($table); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.