Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Adds readme builder
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster authored Dec 22, 2022
1 parent a8996ee commit 50ece29
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Spiral Application installer

[App Skeleton](https://github.com/spiral/app) | [**Documentation
**](https://spiral.dev/docs) | [Discord](https://discord.gg/TFeEmCs) | [Twitter](https://twitter.com/spiralphp) | [Contributing](https://spiral.dev/docs/about-contributing/)
[App Skeleton](https://github.com/spiral/app) | [**Documentation**](https://spiral.dev/docs) | [Discord](https://discord.gg/TFeEmCs) | [Twitter](https://twitter.com/spiralphp) | [Contributing](https://spiral.dev/docs/about-contributing/)

![Installer](https://user-images.githubusercontent.com/773481/208850084-891a9d6f-3e70-4a06-af57-4e63c37c9c47.png)

Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
],
"rr:download": "rr get-binary",
"rr:download-protoc": "rr download-protoc-binary",
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage",
"psalm:config": "psalm",
"deptrack": [
"deptrac analyze --report-uncovered"
Expand Down
59 changes: 57 additions & 2 deletions installer/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static function configure(Event $event): void
$conf->createRoadRunnerConfig();
$conf->runCommands();
$conf->showInstructions();
$conf->updateReadme();
$conf->removeInstaller();
$conf->finalize();
}
Expand Down Expand Up @@ -107,6 +108,59 @@ private function createRoadRunnerConfig(): void
});
}

private function updateReadme(): void
{
$readme = $this->projectRoot . '/README.md';
if (!\file_exists($readme)) {
return;
}

$content = \file_get_contents($readme);
$content = \str_replace(':app_name', $this->application->getName(), $content);
$content = \str_replace(':date', (new \DateTime())->format('r'), $content);

$nextSteps = ['## Configuration'];

foreach ($this->application->getInstructions() as $index => $instruction) {
$nextSteps[] = \sprintf('%d. %s', $index + 1, \strip_tags($instruction));
}

$showPackageInstruction = function (Package $package) use (&$nextSteps): void {
if ($package->getInstructions() === []) {
return;
}

$nextSteps[] = \sprintf('### %s', $package->getTitle());
foreach ($package->getInstructions() as $index => $instruction) {
$nextSteps[] = \sprintf('%s. %s', (int)$index + 1, \strip_tags($instruction));
}
};

// from required packages
foreach ($this->application->getPackages() as $package) {
$showPackageInstruction($package);
}

// from installed optional packages
foreach ($this->application->getQuestions() as $question) {
foreach ($question->getOptions() as $option) {
foreach ($option instanceof Option ? $option->getPackages() : [] as $package) {
if ($this->application->isPackageInstalled($package)) {
$showPackageInstruction($package);
}
}
}
}

$content = \str_replace(
':next_steps',
\implode(\PHP_EOL, $nextSteps),
$content
);

\file_put_contents($readme, $content);
}

private function showInstructions(): void
{
$this->io->write(' <comment>Next steps:</comment>');
Expand All @@ -117,10 +171,11 @@ private function showInstructions(): void
}

$showPackageInstruction = function (Package $package): void {
if ($package->getInstructions() !== []) {
$this->io->write(\sprintf(' <comment>%s</comment>', $package->getTitle()));
if ($package->getInstructions() === []) {
return;
}

$this->io->write(\sprintf(' <comment>%s</comment>', $package->getTitle()));
foreach ($package->getInstructions() as $index => $instruction) {
$this->io->write(\sprintf(' %s. %s', (int)$index + 1, $instruction));
}
Expand Down
2 changes: 1 addition & 1 deletion installer/Generator/EnvConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private function addRequiredValues(): void
priority: 2
);
$this->addGroup(
values: ['VERBOSITY_LEVEL' => '1 # 0, 1, 2'],
values: ['VERBOSITY_LEVEL' => 'verbose # basic, verbose, debug'],
comment: 'Verbosity level',
priority: 3
);
Expand Down
2 changes: 1 addition & 1 deletion installer/Package/SentryBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
new Env(),
],
array $instructions = [
'Please, configure the <comment>SENTRY_DSN</comment> environment variable',
'Please, configure the <comment>`SENTRY_DSN`</comment> environment variable',
'Documentation: <comment>https://spiral.dev/docs/extension-sentry</comment>',
]
) {
Expand Down
68 changes: 68 additions & 0 deletions installer/Resources/common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# My super :app_name application

Was created by [spiral/installer](https://github.com/spiral/installer) with `:app_name` skeleton at **:date**.

:next_steps

## Usage

if you need to start RoadRunner server after the project has been configured use the following command:

```bash
./rr serve
```

> **Note**:
> Read more about the RoadRunner CLI commands in the [documentation](https://roadrunner.dev/docs/app-server-cli/2.x/en).
<br />

After starting the RoadRunner server with HTTP plugin, you will be able to access your application in a web
browser by going to a specific URL: http://127.0.0.1:8080.

## Console commands

### Download or update RoadRunner

Allows to install the latest version of the RoadRunner compatible with your environment (operating system, processor
architecture, runtime, etc...).

```bash
composer rr:download
# or
./vendor/bin/rr get-binary
```

### Download or update protoc get GRPC plugin

Allows to install the latest version of the `protoc-gen-php-grpc` file compatible with your environment (operating
system, processor architecture, runtime, etc...).

```bash
composer rr:download-protoc
# or
./vendor/bin/rr download-protoc-binary
```

## Useful resources

- [**Spiral Framework documentation**](https://spiral.dev/docs)
- [**RoadRunner documentation**](https://roadrunner.dev/docs)
- [Community packages](https://github.com/spiral-packages).
- [Birddog](https://github.com/roadrunner-server/birddog) — OpenSource tool for monitoring RoadRunner instances.
- [Support us](https://github.com/sponsors/roadrunner-server)
- [Contributing](https://spiral.dev/docs/about-contributing/)

## Support

If you have any questions or need help with the project, please don't hesitate to reach out! You can find us on Discord
at the following link:

[Discord Server](https://discord.gg/TFeEmCs)

Alternatively, you can create an issue on GitHub to report a bug or request a feature:

[Create an Issue on GitHub](https://github.com/spiral/framework/issues/new/choose)

We welcome any feedback or suggestions you may have, and are always happy to help troubleshoot any issues you may
encounter.

0 comments on commit 50ece29

Please sign in to comment.