Skip to content

Commit

Permalink
Merge pull request #5151 from mhsdesign/task/deprecateCustomSiteKicks…
Browse files Browse the repository at this point in the history
…tarter

TASK: Deprecate additional site kickstart generators and show helpful output for default afx case
mhsdesign authored Jan 28, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 35127cd + 8698dc0 commit d91e439
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
@@ -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;

@@ -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
@@ -24,6 +24,7 @@
/**
* Service to generate site packages
*
* @internal
*/
class AfxTemplateGenerator extends GeneratorService implements SitePackageGeneratorInterface
{
Original file line number Diff line number Diff line change
@@ -13,6 +13,9 @@
* source code.
*/

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

use Neos\Flow\Annotations as Flow;

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

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

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

/**
* @internal
*/
class SitePackageGeneratorNameService
{
/**

0 comments on commit d91e439

Please sign in to comment.