phenaproxima / starshot-prototype

Prototype of a new kind of Drupal, based on recipes and loaded up with contrib's best modules and themes. Not a fork or a distribution.
https://drupal.org/starshot
118 stars 46 forks source link

Define install tasks for choosing the site template and add-ons #151

Closed narendra-drupal closed 3 months ago

narendra-drupal commented 4 months ago

While working on this I found that if we try to install starshot in other language it gives error Drupal\Core\DefaultContent\InvalidEntityException: recipes/starshot/content/user/c6fc2154-25c0-4b9d-ad4d-8d04a6a52f05.yml: preferred_langcode.0.value=The value you selected is not a valid choice.||preferred_langcode.0=The value you selected is not a valid choice.||preferred_admin_langcode.0.value=The value you selected is not a valid choice.||preferred_admin_langcode.0=The value you selected is not a valid choice. in Drupal\Core\DefaultContent\Importer->importContent() (line 113 of Sites/starshot/web/core/lib/Drupal/Core/DefaultContent/Importer.php).

phenaproxima commented 4 months ago

Oooh, I think I see the problem you mention, @narendra-drupal. It's not in scope here, but the default content in Starshot is in the English language. The thing we probably need to do is move the demo content to its own recipe, and have it explicitly install in English only.

phenaproxima commented 4 months ago

I tested this at the command line and one problem we have is that, if you run vendor/bin/drush cget core.extension, you'll see this at the end:

profile: starshot_installer

It should be false, I think. So the installer isn't getting uninstalled, which is a problem. We probably should add test coverage; doing that in my next commit.

phenaproxima commented 4 months ago

The closer I look at this, the more troublesome it becomes...

I think what we might need to do here is actually not use hook_install_tasks_alter(), but rather, create a new install task as part of the installer that allows you to choose a recipe, and then ensure that recipe is applied by starshot_installer_apply_recipes(). Obviously, for now the choice of recipe is hard-coded but ideally we'd later replace that with a real choice.

phenaproxima commented 4 months ago

After discussion with @timplunkett, I think we should change the approach here. We should not use hook_install_tasks_alter(), but instead we should define two additional install tasks beyond what's in HEAD.

  1. Choose your template: this is where you'd choose whether to start from the Starshot base recipe, or a commerce recipe, or a headless recipe, or...whatever. For now, this should hard-code the choice of recipe to recipes/starshot, and not present anything to the user. It should save the choice in $install_state['parameters']['template'] or similar. starshot_installer_apply_recipes() should use that install parameter to apply the chosen recipe, rather than hardcode recipes/starshot. That can all be done in one PR (this one).
  2. Choose additional recipes: after the template is applied, this is where we'd show additional recipes for people to add, probably by using a mini-Project Browser. For now, this can just be an empty callback function. We can do this in a second PR.

To put it another way: you cannot skip the installer, and you cannot install the site from a recipe instead of using the starshot_installer profile. But the profile should define additional steps that let you choose a base recipe (the "main course", if you like), and some add-ons (the side dishes). And then, it uninstalls itself.

narendra-drupal commented 3 months ago

After discussion with @timplunkett, I think we should change the approach here. We should not use hook_install_tasks_alter(), but instead we should define two additional install tasks beyond what's in HEAD.

  1. Choose your template: this is where you'd choose whether to start from the Starshot base recipe, or a commerce recipe, or a headless recipe, or...whatever. For now, this should hard-code the choice of recipe to recipes/starshot, and not present anything to the user. It should save the choice in $install_state['parameters']['template'] or similar. starshot_installer_apply_recipes() should use that install parameter to apply the chosen recipe, rather than hardcode recipes/starshot. That can all be done in one PR (this one).
  2. Choose additional recipes: after the template is applied, this is where we'd show additional recipes for people to add, probably by using a mini-Project Browser. For now, this can just be an empty callback function. We can do this in a second PR.

To put it another way: you cannot skip the installer, and you cannot install the site from a recipe instead of using the starshot_installer profile. But the profile should define additional steps that let you choose a base recipe (the "main course", if you like), and some add-ons (the side dishes). And then, it uninstalls itself.

Done