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

TASK: Deprecate additional site kickstart generators and show helpful output for default afx case #5151

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading