Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme generator changes #65

Merged
merged 8 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .templates/CONTACTS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Contacts

Should you need assistance or have questions, feel free to connect with the following individuals:
- Manager: If you have any high-level project concerns, feel free to get in touch with our project manager. [Connect with Manager](:manager_link)
- Code Owner/Team Lead: For specific questions about the codebase or technical aspects, reach out to our team lead. [Connect with Team Lead](:team_lead_link)
- Manager: If you have any high-level project concerns, feel free to get in touch with our project manager. [Connect with Manager](mailto::manager_link)
- Code Owner/Team Lead: For specific questions about the codebase or technical aspects, reach out to our team lead. [Connect with Team Lead](mailto::team_lead_link)

Please be mindful of each individual's preferred contact method and office hours.
4 changes: 3 additions & 1 deletion .templates/CREDENTIALS_AND_ACCESS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## Credentials and Access

{admin_credentials}Default admin email and password: `:admin_email`/`:admin_password`{/admin_credentials}
{admin_credentials}Default admin access:
- email `:admin_email`
- password `:admin_password`{/admin_credentials}
6 changes: 6 additions & 0 deletions .templates/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Clone this repository to your local machine.
git clone :git_project_path
```

Open project directory.

```sh
cd :project_directory
```

Build and start containers. It may takes some time.

```sh
Expand Down
13 changes: 7 additions & 6 deletions .templates/RESOURCES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
### Resources

Below are links to tools and services used in this project:
{issue_tracker}- Issue Tracker: Here, you can report any issues or bugs related to the project. [Issue Tracker](:issue_tracker_link){/issue_tracker}
{figma}- Figma: This is where we maintain all our design assets and mock-ups. [Figma](:figma_link){/figma}
{sentry}- Sentry: To monitor application performance and error tracking. [Sentry](:sentry_link){/sentry}
{datadog}- DataDog: This is where we monitor our logs, and server performance, and receive alerts. [DataDog](:datadog_link){/datadog}
{argocd}- ArgoCD: Is a kubernetes controller which continuously monitors running applications. [ArgoCD](:argocd_link){/argocd}
{telescope}- Laravel Telescope: This is debug assistant for the Laravel framework. [Laravel Telescope](:telescope_link){/telescope}
{issue_tracker}- [Issue Tracker](:issue_tracker_link): Here, you can report any issues or bugs related to the project.{/issue_tracker}
{figma}- [Figma](:figma_link): This is where we maintain all our design assets and mock-ups.{/figma}
{sentry}- [Sentry](:sentry_link): To monitor application performance and error tracking.{/sentry}
{datadog}- [DataDog](:datadog_link): This is where we monitor our logs, and server performance, and receive alerts.{/datadog}
{argocd}- [ArgoCD](:argocd_link): Is a kubernetes controller which continuously monitors running applications.{/argocd}
{telescope}- [Laravel Telescope](:telescope_link): This is debug assistant for the Laravel framework.{/telescope}
{nova}- [Laravel Nova](:nova_link): This is admin panel for the Laravel framework.{/nova}
- [API Documentation](:api_link)
14 changes: 8 additions & 6 deletions app/Console/Commands/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Init extends Command
'datadog' => 'DataDog',
'argocd' => 'ArgoCD',
'telescope' => 'Laravel Telescope',
'nova' => 'Laravel Nova',
];

const CONTACTS_ITEMS = [
Expand Down Expand Up @@ -48,9 +49,7 @@ public function handle(): void
'DATA_COLLECTOR_KEY' => "{$kebabName}-local"
]);

$envFile = (file_exists('.env'))
? '.env'
: '.env.example';
$envFile = (file_exists('.env')) ? '.env' : '.env.example';

$this->updateConfigFile($envFile, '=', [
'APP_NAME' => $appName,
Expand Down Expand Up @@ -172,10 +171,10 @@ protected function fillContacts(): void
$filePart = $this->loadReadmePart('CONTACTS.md');

foreach (self::CONTACTS_ITEMS as $key => $title) {
if ($link = $this->ask("Please enter a {$title} contact", '')) {
if ($link = $this->ask("Please enter a {$title}'s email", '')) {
$this->setReadmeValue($filePart, "{$key}_link", $link);
} else {
$this->emptyValuesList[] = "{$title} contact";
$this->emptyValuesList[] = "{$title}'s email";
}

$this->removeTag($filePart, $key);
Expand All @@ -194,9 +193,12 @@ protected function fillPrerequisites(): void
protected function fillGettingStarted(): void
{
$gitProjectPath = trim((string) shell_exec('git ls-remote --get-url origin'));
$projectDirectory = basename($gitProjectPath, '.git');
$filePart = $this->loadReadmePart('GETTING_STARTED.md');

$this->setReadmeValue($filePart, 'git_project_path', $gitProjectPath);
$this->setReadmeValue($filePart, 'project_directory', $projectDirectory);

$this->updateReadmeFile($filePart);
}

Expand Down Expand Up @@ -272,7 +274,7 @@ protected function updateReadmeFile(string $filePart): void

protected function removeStringByTag(string &$text, string $tag): void
{
$text = preg_replace("#({{$tag}.*?}).*?({/{$tag}})#", '', $text);
$text = preg_replace("#({{$tag}})(.|\s)*?({/{$tag}})#", '', $text);
}

protected function removeTag(string &$text, string $tag): void
Expand Down
2 changes: 0 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
</include>
<exclude>
<directory suffix=".php">./app/Modules/Media/tests</directory>
</exclude>
<exclude>
<directory suffix=".php">./app/Modules/Media/database</directory>
</exclude>
</coverage>
Expand Down
53 changes: 29 additions & 24 deletions tests/InitCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public function testRunWithoutAdminAndReadmeCreation()

public function testRunWithAdminAndWithoutReadmeCreation()
{
$this->mockFilePutContent([
'database/migrations/2018_11_11_111111_add_default_user.php' => $this->getFixture('migration.php'),
]);
$this->mockFilePutContent(
['database/migrations/2018_11_11_111111_add_default_user.php', $this->getFixture('migration.php')]
);

$this
->artisan('init "My App"')
Expand All @@ -45,10 +45,10 @@ public function testRunWithAdminAndDefaultReadmeCreation()
{
$this->mockShellExec();

$this->mockFilePutContent([
'database/migrations/2018_11_11_111111_add_default_user.php' => $this->getFixture('migration.php'),
'README.md' => $this->getFixture('default_readme.md'),
]);
$this->mockFilePutContent(
['database/migrations/2018_11_11_111111_add_default_user.php', $this->getFixture('migration.php')],
['README.md', $this->getFixture('default_readme.md')]
);

$this
->artisan('init "My App"')
Expand All @@ -72,8 +72,10 @@ public function testRunWithAdminAndDefaultReadmeCreation()
->expectsQuestion('Please enter a ArgoCD link', '')
->expectsConfirmation('Are you going to use Laravel Telescope?', 'yes')
->expectsQuestion('Please enter a Laravel Telescope link', '')
->expectsQuestion('Please enter a Manager contact', '')
->expectsQuestion('Please enter a Code Owner/Team Lead contact', '')
->expectsConfirmation('Are you going to use Laravel Nova?', 'yes')
->expectsQuestion('Please enter a Laravel Nova link', '')
->expectsQuestion('Please enter a Manager\'s email', '')
->expectsQuestion('Please enter a Code Owner/Team Lead\'s email', '')
->expectsConfirmation('Do you need a `Prerequisites` part?', 'yes')
->expectsConfirmation('Do you need a `Getting Started` part?', 'yes')
->expectsConfirmation('Do you need an `Environments` part?', 'yes')
Expand All @@ -85,16 +87,16 @@ public function testRunWithAdminAndDefaultReadmeCreation()
->expectsOutput('- Sentry link')
->expectsOutput('- DataDog link')
->expectsOutput('- ArgoCD link')
->expectsOutput('- Manager contact')
->expectsOutput('- Code Owner/Team Lead contact')
->expectsOutput('- Manager\'s email')
->expectsOutput('- Code Owner/Team Lead\'s email')
->assertExitCode(0);
}

public function testRunWithAdminAndPartialReadmeCreation()
{
$this->mockFilePutContent([
'README.md' => $this->getFixture('partial_readme.md'),
]);
$this->mockFilePutContent(
['README.md', $this->getFixture('partial_readme.md')]
);

$this
->artisan('init "My App"')
Expand All @@ -110,27 +112,28 @@ public function testRunWithAdminAndPartialReadmeCreation()
->expectsConfirmation('Are you going to use DataDog?')
->expectsConfirmation('Are you going to use ArgoCD?')
->expectsConfirmation('Are you going to use Laravel Telescope?')
->expectsQuestion('Please enter a Manager contact', '[email protected]')
->expectsQuestion('Please enter a Code Owner/Team Lead contact', '')
->expectsConfirmation('Are you going to use Laravel Nova?')
->expectsQuestion('Please enter a Manager\'s email', '[email protected]')
->expectsQuestion('Please enter a Code Owner/Team Lead\'s email', '')
->expectsConfirmation('Do you need a `Prerequisites` part?')
->expectsConfirmation('Do you need a `Getting Started` part?')
->expectsConfirmation('Do you need an `Environments` part?', 'yes')
->expectsConfirmation('Do you need a `Credentials and Access` part?', 'yes')
->expectsOutput('README generated successfully!')
->expectsOutput('Don`t forget to fill the following empty values:')
->expectsOutput('- Issue Tracker link')
->expectsOutput('- Code Owner/Team Lead contact')
->expectsOutput('- Code Owner/Team Lead\'s email')
->assertExitCode(0);
}

public function testRunWithAdminAndFullReadmeCreation()
{
$this->mockShellExec();

$this->mockFilePutContent([
'database/migrations/2018_11_11_111111_add_default_user.php' => $this->getFixture('migration.php'),
'README.md' => $this->getFixture('full_readme.md'),
]);
$this->mockFilePutContent(
['database/migrations/2018_11_11_111111_add_default_user.php', $this->getFixture('migration.php')],
['README.md', $this->getFixture('full_readme.md')]
);

$this
->artisan('init "My App"')
Expand All @@ -154,13 +157,15 @@ public function testRunWithAdminAndFullReadmeCreation()
->expectsQuestion('Please enter a ArgoCD link', 'https://argocd.com/my-project')
->expectsConfirmation('Are you going to use Laravel Telescope?', 'yes')
->expectsQuestion('Please enter a Laravel Telescope link', 'https://mypsite.com/telescope-link')
->expectsQuestion('Please enter a Manager contact', '[email protected]')
->expectsQuestion('Please enter a Code Owner/Team Lead contact', '[email protected]')
->expectsConfirmation('Are you going to use Laravel Nova?', 'yes')
->expectsQuestion('Please enter a Laravel Nova link', 'https://mypsite.com/nova-link')
->expectsQuestion('Please enter a Manager\'s email', '[email protected]')
->expectsQuestion('Please enter a Code Owner/Team Lead\'s email', '[email protected]')
->expectsConfirmation('Do you need a `Prerequisites` part?', 'yes')
->expectsConfirmation('Do you need a `Getting Started` part?', 'yes')
->expectsConfirmation('Do you need an `Environments` part?', 'yes')
->expectsConfirmation('Do you need a `Credentials and Access` part?', 'yes')
->expectsOutput('README generated successfully!')
->assertExitCode(0);
}
}
}
3 changes: 2 additions & 1 deletion tests/Support/AuthTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

trait AuthTestTrait
{
use MockClassTrait, PHPMock;
use MockClassTrait;
use PHPMock;

public function mockOpensslRandomPseudoBytes(): void
{
Expand Down
23 changes: 10 additions & 13 deletions tests/Support/InitCommandMockTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ trait InitCommandMockTrait
{
use PHPMock;

public function mockFilePutContent(array $fileContents = []): void
public function mockFilePutContent(...$arguments): void
{
$defaultFileContents = [
'.env.testing' => $this->getFixture('env.testing.yml'),
'.env.example' => $this->getFixture('env.example.yml'),
'.env.development' => $this->getFixture('env.development.yml'),
'.env.ci-testing' => $this->getFixture('env.ci-testing.yml'),
];

$fileContents = $defaultFileContents + $fileContents;

$mock = $this->getFunctionMock('App\Console\Commands', 'file_put_contents');

$mock
->expects($this->exactly(count($fileContents)))
->willReturnCallback(fn ($file) => $fileContents[$file]);
->expects($this->exactly(4 + count($arguments)))
->withConsecutive(
DenTray marked this conversation as resolved.
Show resolved Hide resolved
['.env.testing', $this->getFixture('env.testing.yml')],
['.env.example', $this->getFixture('env.example.yml')],
['.env.development', $this->getFixture('env.development.yml')],
['.env.ci-testing', $this->getFixture('env.ci-testing.yml')],
...$arguments
);
}

public function mockShellExec(): void
Expand All @@ -35,4 +32,4 @@ public function mockShellExec(): void
->with('git ls-remote --get-url origin')
->willReturn('https://github.com/ronasit/laravel-helpers.git');
}
}
}
29 changes: 19 additions & 10 deletions tests/fixtures/InitCommandTest/default_readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ process, so you can efficiently find what you need or reach out to who you need.
### Resources

Below are links to tools and services used in this project:
- Issue Tracker: Here, you can report any issues or bugs related to the project. [Issue Tracker](:issue_tracker_link)
- Figma: This is where we maintain all our design assets and mock-ups. [Figma](:figma_link)
- Sentry: To monitor application performance and error tracking. [Sentry](:sentry_link)
- DataDog: This is where we monitor our logs, and server performance, and receive alerts. [DataDog](:datadog_link)
- ArgoCD: Is a kubernetes controller which continuously monitors running applications. [ArgoCD](:argocd_link)
- Laravel Telescope: This is debug assistant for the Laravel framework. [Laravel Telescope](:telescope_link)
- [Issue Tracker](:issue_tracker_link): Here, you can report any issues or bugs related to the project.
- [Figma](:figma_link): This is where we maintain all our design assets and mock-ups.
- [Sentry](:sentry_link): To monitor application performance and error tracking.
- [DataDog](:datadog_link): This is where we monitor our logs, and server performance, and receive alerts.
- [ArgoCD](:argocd_link): Is a kubernetes controller which continuously monitors running applications.
- [Laravel Telescope](:telescope_link): This is debug assistant for the Laravel framework.
- [Laravel Nova](:nova_link): This is admin panel for the Laravel framework.
- [API Documentation](https://mysite.com)

### Contacts

Should you need assistance or have questions, feel free to connect with the following individuals:
- Manager: If you have any high-level project concerns, feel free to get in touch with our project manager. [Connect with Manager](:manager_link)
- Code Owner/Team Lead: For specific questions about the codebase or technical aspects, reach out to our team lead. [Connect with Team Lead](:team_lead_link)
- Manager: If you have any high-level project concerns, feel free to get in touch with our project manager. [Connect with Manager](mailto::manager_link)
- Code Owner/Team Lead: For specific questions about the codebase or technical aspects, reach out to our team lead. [Connect with Team Lead](mailto::team_lead_link)

Please be mindful of each individual's preferred contact method and office hours.

Expand All @@ -41,7 +42,13 @@ To get started with this repository, follow these steps:
Clone this repository to your local machine.

```sh
git clone https://github.com/RonasIT/laravel-empty-project
git clone https://github.com/ronasit/laravel-helpers.git
```

Open project directory.

```sh
cd laravel-helpers
```

Build and start containers. It may takes some time.
Expand All @@ -63,4 +70,6 @@ and `testing`. Each environment is represented by an appropriate environment fil

## Credentials and Access

Default admin email and password: `[email protected]`/`123456`
Default admin access:
- email `[email protected]`
- password `123456`
29 changes: 19 additions & 10 deletions tests/fixtures/InitCommandTest/full_readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ process, so you can efficiently find what you need or reach out to who you need.
### Resources

Below are links to tools and services used in this project:
- Issue Tracker: Here, you can report any issues or bugs related to the project. [Issue Tracker](https://gitlab.com/my-project)
- Figma: This is where we maintain all our design assets and mock-ups. [Figma](https://figma.com/my-project)
- Sentry: To monitor application performance and error tracking. [Sentry](https://sentry.com/my-project)
- DataDog: This is where we monitor our logs, and server performance, and receive alerts. [DataDog](https://datadoghq.com/my-project)
- ArgoCD: Is a kubernetes controller which continuously monitors running applications. [ArgoCD](https://argocd.com/my-project)
- Laravel Telescope: This is debug assistant for the Laravel framework. [Laravel Telescope](https://mypsite.com/telescope-link)
- [Issue Tracker](https://gitlab.com/my-project): Here, you can report any issues or bugs related to the project.
- [Figma](https://figma.com/my-project): This is where we maintain all our design assets and mock-ups.
- [Sentry](https://sentry.com/my-project): To monitor application performance and error tracking.
- [DataDog](https://datadoghq.com/my-project): This is where we monitor our logs, and server performance, and receive alerts.
- [ArgoCD](https://argocd.com/my-project): Is a kubernetes controller which continuously monitors running applications.
- [Laravel Telescope](https://mypsite.com/telescope-link): This is debug assistant for the Laravel framework.
- [Laravel Nova](https://mypsite.com/nova-link): This is admin panel for the Laravel framework.
- [API Documentation](https://mysite.com)

### Contacts

Should you need assistance or have questions, feel free to connect with the following individuals:
- Manager: If you have any high-level project concerns, feel free to get in touch with our project manager. [Connect with Manager]([email protected])
- Code Owner/Team Lead: For specific questions about the codebase or technical aspects, reach out to our team lead. [Connect with Team Lead]([email protected])
- Manager: If you have any high-level project concerns, feel free to get in touch with our project manager. [Connect with Manager](mailto:[email protected])
- Code Owner/Team Lead: For specific questions about the codebase or technical aspects, reach out to our team lead. [Connect with Team Lead](mailto:[email protected])

Please be mindful of each individual's preferred contact method and office hours.

Expand All @@ -41,7 +42,13 @@ To get started with this repository, follow these steps:
Clone this repository to your local machine.

```sh
git clone https://github.com/RonasIT/laravel-empty-project
git clone https://github.com/ronasit/laravel-helpers.git
```

Open project directory.

```sh
cd laravel-helpers
```

Build and start containers. It may takes some time.
Expand All @@ -63,4 +70,6 @@ and `testing`. Each environment is represented by an appropriate environment fil

## Credentials and Access

Default admin email and password: `[email protected]`/`123456`
Default admin access:
- email `[email protected]`
- password `123456`
Loading