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

Conversation

kitsunet
Copy link
Member

@kitsunet kitsunet commented Oct 18, 2019

This can be tested via:

composer create-project --repository '{"type":"vcs", "url":"git@github.com:kitsunet/neos-base-distribution.git"}' neos/neos-base-distribution neos-dev-dist-demo-installer dev-feature/demo-installer

followup: kitsunet#1
related: https://discuss.neos.io/t/rfc-post-create-project-tasks/5141

Copy link
Member

@mficzel mficzel left a comment

Choose a reason for hiding this comment

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

I totally like this but cannot Test on my phone. So only two nitpicks as a start

Build/Classes/Composer/InstallSitePackage.php Outdated Show resolved Hide resolved
composer.json Show resolved Hide resolved
@gerhard-boden
Copy link
Contributor

gerhard-boden commented Oct 18, 2019

looks good so far, wanted to test it locally, but when running composer create-project (with this PR checkout out ofc) composer starts to run into a endless loop with the message Something's changed, looking at all rules again (pass #305) (verbose output)

What ist the best way to test the changes locally @kitsunet?

@gerhard-boden
Copy link
Contributor

gerhard-boden commented Oct 18, 2019

Tried it at home now on a completely different machine, same story (also for composer update). I think that 67a62e2 might have something to do with it, although I can't see what's wrong.

@gerhard-boden
Copy link
Contributor

Okay here is a hack:

  1. Remove all packages except for neos/neos
  2. Run composer update
  3. Add all other packages

Now composer update will succeed. It looks like composer is running into a dependency check endless loop, never seen anything like this before.

This way was at least able to test this PR, but the general issue inside the base distribution has to be addressed. I would have opened an issue, but we don't do issues in the base distribution.

Copy link
Contributor

@gerhard-boden gerhard-boden left a comment

Choose a reason for hiding this comment

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

Works great 👍 (but there's an general issue within the master branch of neos-base-distribution, see above).

We could have also gone with a Y/n dialogue for now, but for me it's good as it is. There's also an unused constant, but that can be easily removed before merging.

@kdambekalns kdambekalns self-requested a review October 18, 2019 20:25
@kitsunet
Copy link
Member Author

Alright, removed a lot of superfluous stuff from this, actually trying it is rather hard. while working on it I was using a branch in this repo that I then asked for in create-project ( composer create-project neos/neos-base-distribution my-folder dev-mybranch ) . Now I probably could move this PR over to the original repo if you want and it makes testing easier.

@gerhard-boden
Copy link
Contributor

gerhard-boden commented Oct 18, 2019

Now I probably could move this PR over to the original repo if you want and it makes testing easier.

Naw, I was able to test it in the end after some composer.json back and forth as mentioned above. Afterwards composer create-project within the folder would trigger the script. But the real troublemaker is that there is an issue in the master branch of the base distro (could you give composer create-project neos/neos-base-distribution . dev-master -vvv a try? Or should that never work because we have the dev distro for that?)

@kitsunet
Copy link
Member Author

I can install base-distribution dev-master just fine, but it takes quite a lot of memory and time. Probably composer resolving dependencies. Eventually it could install though.

@gerhard-boden
Copy link
Contributor

I can install base-distribution dev-master just fine, but it takes quite a lot of memory and time. Probably composer resolving dependencies. Eventually it could install though.

Thanks for checking, just tried it again:

Something's changed, looking at all rules again (pass #619)
Dependency resolution completed in 492.679 seconds
Analyzed 14727 packages to resolve dependencies
Analyzed 1402061 rules to resolve dependencies
Resolving dependencies through SAT
Looking at all rules.

I guess I wasn't patient enough on the train to wait 8 minutes for composer to just even start downloading packages 🙈

But at least it's working in general and this "issue" (if it is in one at some point), is definitely out of scope for this change. Just brought it up in here, because I noticed it while testing. 😊

Copy link
Member

@mficzel mficzel left a comment

Choose a reason for hiding this comment

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

In general it works like a charm with the "empty" option but when choosing "Neos.Demo" i run into the following composer errors:

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for neos/demo ^6.0 -> satisfiable by neos/demo[6.0.0].
    - Conclusion: remove neos/neos dev-master
    - Conclusion: don't install neos/neos dev-master
    - neos/demo 6.0.0 requires neos/neos ^5.0 -> satisfiable by neos/neos[5.0.0, 5.0.1, 5.0.2, 5.0.x-dev].
    - Can only install one of: neos/neos[5.0.0, dev-master].
    - Can only install one of: neos/neos[5.0.1, dev-master].
    - Can only install one of: neos/neos[5.0.2, dev-master].
    - Can only install one of: neos/neos[5.0.x-dev, dev-master].
    - Installation request for neos/neos (locked at dev-master, required as @dev) -> satisfiable by neos/neos[dev-master].

Installation failed, reverting ./composer.json to its original content.

Your Neos was prepared successfully.

The last line "Neos was installed sucessfully" is a bit misleading, maybe we can check wether the composer command was successfull before writing this. I suggest to not render any message when errors occured so the last output is the composer error so it can be spotted easily.

The fix to underlying dependency problem is to adjust the neos/neos constraints in Neos.Demo to allow dev-master.

@mficzel
Copy link
Member

mficzel commented Oct 21, 2019

FYI this line allows to test this without messing with the composer-configuration:

composer create-project --repository '{"type":"vcs", "url":"git@github.com:kitsunet/neos-base-distribution.git"}' neos/neos-base-distribution neos-dev-dist-demo-installer dev-feature/demo-installer

@kitsunet
Copy link
Member Author

Interesting for me it installed jusut fine, apparently something changed with some dependency declaration? I can try to test for success, but not sure I get any info about that....

@mficzel
Copy link
Member

mficzel commented Oct 21, 2019

@kitsunet https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Application.php#L194 returns 0 if all went fine and the composer application passes this trough. So this should be simple.

@mficzel
Copy link
Member

mficzel commented Oct 22, 2019

I am suspecting that the neos-base-distribution has a dependency problem on master:
I get Installing neos/flow (4.0.25): Loading from cache which is a bit oldish and also

Package typo3/neos-nodetypes is abandoned, you should avoid using it. Use neos/nodetypes instead.
Package typo3/kickstart is abandoned, you should avoid using it. Use neos/kickstarter instead.

The reason seems to be that dev-dist(master) requires (neos: @dev) which requires (flow: *).

How should the dependencies look on master?

@mficzel
Copy link
Member

mficzel commented Oct 24, 2019

@kitsunet i think i understand the problem now. The solution here requires neos/demo without version constraint wich allows composer to make all sorts of decisions.

As solution i suggest to use the "extras" section of the composer manifest as source like this.

{
    "extra": {
        "neos": {
            "create-project-sitePackageOptions": [
                {
                    "composerName": "",
                    "versionConstraint": "",
                    "description": "empty Neos"
                },
                {
                    "composerName": "neos/demo", 
                    "versionConstraint": "@dev", 
                    "description": "start with the Neos Demo content"
                }
            ]
        }
    }
}

or more compact

{
    "extra": {
        "neos": {
            "create-project-sitePackageOptions": {
                "": "empty Neos",
                "neos/demo:@dev": "start with the Neos Demo content"
            }
        }
    }
}

As side effect this will also make the life of release managers easier as they can still adjust all constraints in the composer.json of the base-dist. Also it will be much more intuitive to add more flavors of neos like neos/skeleton or neos/headless to the base distribution.

@kitsunet
Copy link
Member Author

Mmm, yes, that could work, let me think about the syntax, because I have some more ideas in mind about this in the future...

Copy link
Member

@daniellienert daniellienert left a comment

Choose a reason for hiding this comment

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

Apart of nitpicks, it looks good. Haven't testes it yet.

@@ -0,0 +1,77 @@
<?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.

:)

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"');

@mficzel
Copy link
Member

mficzel commented Nov 8, 2019

@kitsunet a way to make this even more useful and clean be to move the InstallSitePackage.php to Neos\Flow\Composer\InstallerScripts->PostCreateProjectCmd and use the path extra.neos.create-project-packageOptions from the main manifest for configuration. That way it would be available for the flow-base-distribution and even custom neos distributions.

Offcourse this would add a composer dependency to flow which we just added in neos/flow-development-collection#1837 anyways.

@mficzel
Copy link
Member

mficzel commented Nov 21, 2019

@kitsunet i played with moving the post create project command to the composer scripts in flow:
neos/flow-development-collection#1852 what do you think about this solution.

@albe
Copy link
Member

albe commented Apr 1, 2020

So, what's the status on this one?

@mficzel
Copy link
Member

mficzel commented Apr 2, 2020

It seems a bit unelegant to add a special class where all other composer magic is usually done in Neos\Flow\Composer\InstallerScripts .

I would really prefer a configurable solution via the Flow Composer Installer Scripts that can also be used for custom distributions like i sketched in neos/flow-development-collection#1852 . That would reduce this pr to some lines in the composer.json of the neos-base-distribution.

However as the other or did not get any feedback and this is still an improvement we might consider to merge this as it is an intermediate improvement.

@mficzel mficzel dismissed their stale review April 2, 2020 08:10

Dismissed to avoid blocking as i mainly suggested a more flexible solution but this here is an improvement already

@albe albe changed the base branch from master to 5.2 April 4, 2020 12:08
Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

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

First test works great, I would just suggest to tweak the initial choices slightly (see comment)


$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

use Neos\Splash\DistributionBuilder\Domain\ValueObjects\PackageRequirement;

/**
* A comopser post-create-project script to allow a choice of adding the demo site (and possible other things in the future)
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
* A comopser post-create-project script to allow a choice of adding the demo site (and possible other things in the future)
* A composer post-create-project script to allow a choice of adding the demo site (and possible other things in the future)

* 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

* @throws \Neos\Utility\Exception\FilesException
* @throws \Exception
*/
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

];

$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

]);

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).');

use Symfony\Component\Console\Output\ConsoleOutput;
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?

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.

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

Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

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

I had some nitpicks first, but I found some more issues that we should iron out before merging this one

@bwaidelich
Copy link
Member

FYI: I'll prepare a PR-PR with the suggested changes

bwaidelich added a commit to bwaidelich/neos-base-distribution that referenced this pull request Apr 6, 2020
* Apply cosmetic fixes from neos#42 (typos, unused namespace imports, ...)
* Extract installable "distributions" to static method (to make it
  easier to adjust/extend)
* Replace "empty Neos" with a bare bones installation that only contains
  the necessary packages
@bwaidelich
Copy link
Member

=> kitsunet#1

@bwaidelich
Copy link
Member

@mhsdesign
Copy link
Member

this would be a really valuable thing (especially for newcomers, then they wont get confused with uninstalling the demo site etc...)

i have another idea: how about that the Neos.Demo site is 'installed' in the DistributionPackages folder as one is likely to play around with it and this seems the right place. (maybe this could even work for custom git repos...).

@mficzel
Copy link
Member

mficzel commented Dec 9, 2021

I would like to eventually remove the Language Configuration from Neos.Demo ... that way it could coexist with other site packages without problems. In which case it could still be installed by default without doing harm. We could even move it to the neos-dev-collection.

... plus cli-commands to add remove dimensions/dimensionvalues.

Copy link
Member

@kdambekalns kdambekalns left a comment

Choose a reason for hiding this comment

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

Isn't this solved by now and can be closed?

@mhsdesign
Copy link
Member

as far as i know this is not solved. we only have a ./flow welcome command to setup neos but we want to hack into pre composer install logic ...

@mficzel
Copy link
Member

mficzel commented May 30, 2022

I also think this is not solved yet fully but am not sure we should keep this pr open as we will probably end up with a different solution anyways?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants