Skip to content

Commit

Permalink
!!! TASK: Deprecate additional site kickstart generators and show hel…
Browse files Browse the repository at this point in the history
…pful output for default afx case

```
neos-manufacture-90 git:(9.0) ✗ flow kickstart:site Vendor.Site
Created .../Document.Page.yaml
Created .../Document.Homepage.yaml

Create a new site based on the new package "Vendor.Site" by running the site create command
./flow site:create vendor-site Vendor.Site Vendor.Site:Document.Homepage
```
  • Loading branch information
mhsdesign committed Jun 19, 2024
1 parent ec698da commit 8698dc0
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 15 deletions.
44 changes: 29 additions & 15 deletions Neos.SiteKickstarter/Classes/Command/KickstartCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
use Neos\Flow\Package\PackageManager;
use Neos\SiteKickstarter\Generator\AfxTemplateGenerator;
use Neos\SiteKickstarter\Service\SiteGeneratorCollectingService;
use Neos\SiteKickstarter\Service\SitePackageGeneratorNameService;

Expand Down Expand Up @@ -62,27 +63,40 @@ public function siteCommand($packageKey): void

$generatorClasses = $this->siteGeneratorCollectingService->getAllGenerators();

$selection = [];
$nameToClassMap = [];
foreach ($generatorClasses as $generatorClass) {
$name = $this->sitePackageGeneratorNameService->getNameOfSitePackageGenerator($generatorClass);
if (count($generatorClasses) > 1) {
// legacy custom additional generators installed, so we need to show the select box
$selection = [];
$nameToClassMap = [];
foreach ($generatorClasses as $generatorClass) {
$name = $this->sitePackageGeneratorNameService->getNameOfSitePackageGenerator($generatorClass);

$selection[] = $name;
$nameToClassMap[$name] = $generatorClass;
}

/** @var string $generatorName */
$generatorName = $this->output->select(
sprintf('What generator do you want to use? (<info>%s</info>): ', array_key_first($selection)),
$selection,
array_key_first($selection)
);
$selection[] = $name;
$nameToClassMap[$name] = $generatorClass;
}

$generatorClass = $nameToClassMap[$generatorName];
/** @var string $generatorName */
$generatorName = $this->output->select(
sprintf('What generator do you want to use? (<info>%s</info>): ', array_key_first($selection)),
$selection,
array_key_first($selection)
);
$generatorClass = $nameToClassMap[$generatorName];
} else {
// default happy case, only one generator which MUST be the afx default
$generatorClass = AfxTemplateGenerator::class;
}

$generatorService = $this->objectManager->get($generatorClass);

$generatedFiles = $generatorService->generateSitePackage($packageKey);
$this->outputLine(implode(PHP_EOL, $generatedFiles));

$this->outputLine();
$this->outputLine(sprintf('Create a new site based on the new package "%s" by running the site create command', $packageKey));

if ($generatorClass === AfxTemplateGenerator::class) {
$guessedSiteName = strtolower(str_replace('.', '-', $packageKey));
$this->outputLine(sprintf('./flow site:create %1$s %2$s %2$s:Document.Homepage', $guessedSiteName, $packageKey));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/**
* Service to generate site packages
*
* @internal
*/
class AfxTemplateGenerator extends GeneratorService implements SitePackageGeneratorInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* source code.
*/

/**
* @deprecated with Neos 9. Custom generators for "kickstart:site" are discouraged.
*/
interface SitePackageGeneratorInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Neos\Flow\Annotations as Flow;

/**
* @internal
*/
class FusionRecursiveDirectoryRenderer
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* source code.
*/

/**
* @internal
*/
class SimpleTemplateRenderer
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Neos\Flow\Annotations as Flow;
use Neos\SiteKickstarter\Generator\SitePackageGeneratorInterface;

/**
* @internal
*/
class SiteGeneratorCollectingService
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Neos\Flow\Annotations as Flow;
use Neos\SiteKickstarter\Generator\SitePackageGeneratorInterface;

/**
* @internal
*/
class SitePackageGeneratorNameService
{
/**
Expand Down

0 comments on commit 8698dc0

Please sign in to comment.