Skip to content

Commit

Permalink
feat: ask for vendor name
Browse files Browse the repository at this point in the history
  • Loading branch information
bensherred committed Aug 31, 2024
1 parent 8a6d859 commit d0ee6b0
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 13 deletions.
21 changes: 13 additions & 8 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,26 @@ public function handle(): void
{
$name = text(
label: 'Enter a name for your project',
placeholder: 'red-explosion/project-name',
validate: [
'name' => [
'required',
'regex:/^[a-z0-9\-]+\/[a-z0-9\-]+$/',
],
],
placeholder: 'Project Name',
required: true,
);

$vendor = text(
label: 'Enter a vendor name for your project',
placeholder: 'Red Explosion',
required: true,
);

$description = text(
label: 'Enter a description for your project',
placeholder: 'The source code for the Project Name website.',
);

$installData = new InstallData(name: $name, description: $description);
$installData = new InstallData(
name: $name,
vendor: $vendor,
description: $description,
);

$tasks = DefaultModule::tasks();

Expand Down
1 change: 1 addition & 0 deletions src/Data/InstallData.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class InstallData
{
public function __construct(
public readonly string $name,
public readonly string $vendor,
public readonly ?string $description,
) {
}
Expand Down
1 change: 1 addition & 0 deletions src/Modules/Default/DefaultModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static function tasks(): array
Tasks\InstallHorizon::class,
Tasks\InstallPulse::class,
Tasks\UseHasSqids::class,
Tasks\ReplaceReadmePlaceholders::class,
Tasks\RunRefactorScript::class,
Tasks\RunLintScript::class,
];
Expand Down
37 changes: 37 additions & 0 deletions src/Modules/Default/Tasks/ReplaceReadmePlaceholders.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace RedExplosion\Fabricate\Modules\Default\Tasks;

use RedExplosion\Fabricate\Actions\ReplaceInFileAction;
use RedExplosion\Fabricate\Data\InstallData;
use RedExplosion\Fabricate\Task;

class ReplaceReadmePlaceholders extends Task
{
public function __construct(
protected readonly ReplaceInFileAction $replaceInFile,
) {
}

public function progressLabel(): string
{
return 'Replacing README placeholders';
}

public function perform(InstallData $data): void
{
$this->replaceInFile->handle(
'project_name',
$data->name,
base_path('README.md'),
);

$this->replaceInFile->handle(
'vendor_name',
$data->vendor,
base_path('README.md'),
);
}
}
3 changes: 2 additions & 1 deletion src/Modules/Default/Tasks/UpdateComposerMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace RedExplosion\Fabricate\Modules\Default\Tasks;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use RedExplosion\Fabricate\Data\InstallData;
use RedExplosion\Fabricate\Task;
use Symfony\Component\Process\Process;
Expand All @@ -31,7 +32,7 @@ public function perform(InstallData $data): void

$contents = [
...$contents,
'name' => $data->name,
'name' => Str::slug($data->vendor) . '/' . Str::slug($data->name),
'license' => 'proprietary',
];

Expand Down
8 changes: 4 additions & 4 deletions stubs/default/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Project Name
# project_name

## Holla 👋

Hello and welcome to the Project Name codebase. This README has been written to provide you with all the information
Hello and welcome to the project_name codebase. This README has been written to provide you with all the information
you need to get up and running with the project. Like any piece of software, things are constantly changing and it's
easy for information to become outdated.

At Red Explosion, we take pride in the code we write to help deliver our companies mission. We love what we do and we
At vendor_name, we take pride in the code we write to help deliver our companies mission. We love what we do and we
take pride in our work. We're so excited to see what contributions you make to this project, but all we ask is that you
keep information such as installation steps, documentation and tests up to date 🙇

## Installation

Project Name is a regular Laravel application; it's build on top of Laravel 11 and uses X for the frontend. If you are
project_name is a regular Laravel application; it's build on top of Laravel 11 and uses X for the frontend. If you are
familiar with Laravel, you should feel right at home.

In terms of local development, you will need the following requirements:
Expand Down

0 comments on commit d0ee6b0

Please sign in to comment.