Skip to content

Commit

Permalink
updated builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-the-Diamond committed Mar 6, 2024
1 parent b57c68d commit 0fa2bca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public function up(): void
{
Schema::create('builder', function (Blueprint $table) {
Schema::create('items', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
$table->timestamp('started_at')->nullable()->index();
Expand All @@ -25,6 +25,7 @@ public function up(): void
* Reverse the migrations.
*/
public function down(): void

{
Schema::dropIfExists('builder');
}
Expand Down
7 changes: 4 additions & 3 deletions packages/builder/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function replaceForAllOtherOSes(): array
$variableName = lcfirst($className);
$description = ask('Package description', "This is my package {$packageSlug}");
$entity = ask('Package Entity', "{$className}");
$entityPlural = ask('Tablename', lcfirst($className).'s');
$entityPlural = ask('Tablename', title_snake($packageSlug).'s');

writeln('------');
writeln("Author : {$authorName}");
Expand Down Expand Up @@ -206,18 +206,19 @@ function replaceForAllOtherOSes(): array
'Here are some things missing, like an overview with screenshots about this package, or simply a link to the package\'s docs.' => $description,
]);


match (true) {
str_contains($file, determineSeparator('src/BuilderPlugin.php')) => rename($file, determineSeparator('./src/'.$className.'Plugin.php')),
str_contains($file, determineSeparator('src/BuilderServiceProvider.php')) => rename($file, determineSeparator('./src/'.$className.'ServiceProvider.php')),
str_contains($file, determineSeparator('src/Resources/BuilderResource.php')) => rename($file, determineSeparator('./src/Resources/'.$className.'Resource.php')),
str_contains($file, determineSeparator('src/Models/Builder.php')) => rename($file, determineSeparator('./src/Models/'.$className.'.php')),
str_contains($file, determineSeparator('src/Models/Item.php')) => rename($file, determineSeparator('./src/Models/'.$entity.'.php')),
str_contains($file, determineSeparator('src/Resources/BuilderResource/Widgets/BuilderWidgets.php')) => rename($file, determineSeparator('./src/Resources/BuilderResource/Widgets/'.$className.'Widgets.php')),
str_contains($file, determineSeparator('database/migrations/create_items_table.php.stub')) => rename($file, determineSeparator('./database/migrations/create_'.title_snake($entityPlural).'_table.php.stub')),
str_contains($file, determineSeparator('config/builder.php')) => rename($file, determineSeparator('./config/'.$packageSlugWithoutPrefix.'.php')),
str_contains($file, 'README.md') => replace_readme_paragraphs($file, $description),
default => [],
};
}
rename(determineSeparator('config/builder.php'), determineSeparator('./config/'.$packageSlugWithoutPrefix.'.php'));
rename(determineSeparator('src/Resources/BuilderResource'), determineSeparator('./src/Resources/'.$className.'Resource'));

confirm('Execute `composer install` and run tests?') && run('composer install && composer test');
Expand Down
12 changes: 7 additions & 5 deletions packages/builder/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ public function publish_configuration(): void

public function publish_migrations(): void
{
if (Schema::hasTable('items')) {
warning('The items table already exists. The migrations will not be published.');
} elseif (confirm('Do you wish to publish the migrations?', true)) {
info('Publishing Builder Migrations...');
$this->callSilent('vendor:publish', ['--tag' => 'builder-migrations']);
if (confirm('Do you wish to publish the mugrations?', true)) {
if (Schema::hasTable('items')) {
warning('The items table already exists. The migrations will not be published.');
} elseif (confirm('Do you wish to publish the migrations?', true)) {
info('Publishing Builder Migrations...');
$this->callSilent('vendor:publish', ['--tag' => 'builder-migrations']);
}
}
}

Expand Down

0 comments on commit 0fa2bca

Please sign in to comment.