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

FEATURE: Do not install demo site and instead offer a choice #42

Open
wants to merge 2 commits into
base: 5.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
96 changes: 96 additions & 0 deletions Build/Classes/Composer/InstallSitePackage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
namespace Neos\BaseDistribution\Composer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace Neos\BaseDistribution\Composer;
declare(strict_types=1);
namespace Neos\BaseDistribution\Composer;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)


use Composer\Console\Application;
use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\Composer;
use Composer\Factory;
use Composer\Json\JsonFile;
use Composer\Package\Version\VersionParser;
use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository;
use Composer\Script\Event;
use Composer\Installer\PackageEvent;
use Composer\Util\Silencer;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Yaml\Yaml;
use Neos\Utility\Files;
use Neos\Utility\Arrays;
use Neos\Splash\DistributionBuilder\Service\PackageService;
use Neos\Splash\DistributionBuilder\Service\JsonFileService;
use Neos\Splash\DistributionBuilder\Domain\ValueObjects\PackageRequirement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those used at all?


/**
*
*/
class InstallSitePackage
{
const LOCAL_SRC_PATH = 'DistributionPackages';
kitsunet marked this conversation as resolved.
Show resolved Hide resolved

/**
* Setup the neos distribution
*
* @param Event $event
* @throws \Neos\Utility\Exception\FilesException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @throws \Neos\Utility\Exception\FilesException

*/
public static function setupDistribution(Event $event)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static function setupDistribution(Event $event)
public static function setupDistribution(Event $event): void

{
if (!defined('FLOW_PATH_ROOT')) {
define('FLOW_PATH_ROOT', Files::getUnixStylePath(getcwd()) . '/');
}
$composer = $event->getComposer();
$io = $event->getIO();

$distributionReadyMessagesBase = [
'',
'Your Neos was prepared successfully.',
'',
'For local development you still have to:',
'1. Add database credentials to Configuration/Development/Settings.yaml (or start the setup by calling the /setup url)',
kitsunet marked this conversation as resolved.
Show resolved Hide resolved
'2. Migrate database "./flow doctrine:migrate"',
];

$io->write([
'',
'Welcome to Neos',
''
]);

if (!$io->isInteractive()) {
$io->write('Non-Interacctive installation, installing no additional package(s).');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$io->write('Non-Interacctive installation, installing no additional package(s).');
$io->write('Non-interactive installation, installing no additional package(s).');

$io->write($distributionReadyMessagesBase);
return;
}

$choices = [
'start with the Neos Demo content',
'empty Neos'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a mini suggestion:
Wouldn't it make more sense to have empty Neos the first (i.e. default) option since there will be more example content in the future probably.
Also is "empty Neos" a good name? It installs some packages that are not required per se (like neos/seo and neos/redirecthandler-*). I would totally love some kind of "bare bones" installation, too, that only requires the absolutely required packages

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..I guess it was an intentional decision to keep the current behavior the default, makes sense I guess! But it could be the default and not be the first option, too

];

$packages = [
'neos/demo',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make this a 1:n map we can easily add new distributions

''
];

$selection = $io->select('How would you like your Neos configured?', $choices, 1);
if ((int)$selection === 1) {
$io->write('No package will be installed.');
$io->write($distributionReadyMessagesBase);
$io->write('3. Create your site package "./flow site:create"');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$io->write('3. Create your site package "./flow site:create"');
$io->write('3. Create your own site package "./flow site:create"');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The site:create command will not kickstart a Site package!
I guess at least a package:create call is required first

return;
}

$output = new ConsoleOutput();
$composerApplication = new Application();
$composerApplication->doRun(new ArrayInput([
'command' => 'require',
'packages' => [$packages[(int)$selection]]
]), $output);

// success
$io->write($distributionReadyMessagesBase);
$io->write('3. Import site data "./flow site:import --package-key <Package.Name>" (where Package.Name could be Neos.Demo for example)');
}
}
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"require": {
"neos/neos": "@dev",
"neos/site-kickstarter": "@dev",

"neos/demo": "@dev",

"neos/neos-ui": "@dev",
"neos/seo": "@dev",
mficzel marked this conversation as resolved.
Show resolved Hide resolved
"neos/fusion-afx": "@dev",
Expand All @@ -42,6 +41,11 @@
"url": "./DistributionPackages/*"
}
},
"autoload": {
"psr-4": {
"Neos\\BaseDistribution\\": "Build/Classes/"
}
},
"replace": {
"neos/neos-base-distribution": "self.version"
},
Expand All @@ -52,6 +56,7 @@
"post-update-cmd": "Neos\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
"post-install-cmd": "Neos\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
"post-package-update": "Neos\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall",
"post-package-install": "Neos\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall"
"post-package-install": "Neos\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall",
"post-create-project-cmd": "Neos\\BaseDistribution\\Composer\\InstallSitePackage::setupDistribution"
}
}