Skip to content

Commit

Permalink
add starter-kit that includes all current scaffolds and and applicati…
Browse files Browse the repository at this point in the history
…on shell
  • Loading branch information
kbond committed Mar 31, 2022
1 parent 2b68dd6 commit 6272058
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Resources/scaffolds/6.0/bootstrapcss.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
],
'configure' => function(FileManager $files) {
$packageJson = json_decode($files->getFileContents('package.json'), true);
$packageJson['devDependencies']['bootstrap'] = '^5.0.0';
$packageJson['devDependencies']['@popperjs/core'] = '^2.0.0';
$devDeps = $packageJson['devDependencies'];
$devDeps['bootstrap'] = '^5.0.0';
$devDeps['@popperjs/core'] = '^2.0.0';

ksort($devDeps);

$packageJson['devDependencies'] = $devDeps;
$files->dumpFile('package.json', json_encode($packageJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));

$twig = new YamlSourceManipulator($files->getFileContents('config/packages/twig.yaml'));
Expand Down
30 changes: 30 additions & 0 deletions src/Resources/scaffolds/6.0/starter-kit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Symfony\Bundle\MakerBundle\FileManager;

return [
'description' => 'Starting kit with authentication, registration, password reset, user profile management with an application shell styled with Bootstrap CSS.',
'dependents' => [
'bootstrapcss',
'register',
'reset-password',
'change-password',
'profile',
],
'configure' => function(FileManager $files) {
$files->dumpFile('templates/base.html.twig', file_get_contents(__DIR__.'/starter-kit/templates/base.html.twig'));

$login = $files->getFileContents('templates/login.html.twig');
$forgotPassword = "</button>\n <a class=\"btn btn-link\" href=\"{{ path('reset_password_request') }}\">Forgot your password?</a>";

if (str_contains($login, $forgotPassword)) {
return;
}

$files->dumpFile('templates/login.html.twig', str_replace(
'</button>',
$forgotPassword,
$login
));
},
];
53 changes: 53 additions & 0 deletions src/Resources/scaffolds/6.0/starter-kit/templates/base.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text></svg>">
{# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #}
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}

{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light mb-3">
<div class="container">
<a class="navbar-brand" href="{{ path('homepage') }}">My App</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
{% if app.user %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
{{ app.user.email }}
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="{{ path('profile') }}">Manage Profile</a></li>
<li><a class="dropdown-item" href="{{ path('change_password') }}">Change Password</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="{{ path('logout') }}">Logout</a></li>
</ul>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{{ path('register') }}">Register</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ path('login') }}">Login</a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>
<div class="container">
{% block body %}{% endblock %}
</div>
</body>
</html>
10 changes: 9 additions & 1 deletion tests/Maker/MakeScaffoldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

class MakeScaffoldTest extends MakerTestCase
{
private const STARTER_KITS = ['starter-kit'];

protected function setUp(): void
{
parent::setUp();
Expand All @@ -43,6 +45,12 @@ public function getTestDetails(): iterable
)
->run(function (MakerTestRunner $runner) use ($name) {
$runner->runMaker([$name]);

if (in_array($name, self::STARTER_KITS, true)) {
$runner->runProcess('yarn install');
$runner->runProcess('yarn dev');
}

$runner->runTests();

$this->assertTrue(true); // successfully ran tests
Expand All @@ -58,7 +66,7 @@ protected function getMakerClass(): string

private static function scaffoldProvider(): iterable
{
$excluded = ['bootstrapcss', 'starter-kit'];
$excluded = ['bootstrapcss'];

foreach (Finder::create()->in(__DIR__.'/../../src/Resources/scaffolds/6.0')->name('*.php')->depth(0) as $file) {
if (\in_array($name = $file->getFilenameWithoutExtension(), $excluded, true)) {
Expand Down

0 comments on commit 6272058

Please sign in to comment.