Problem/Motivation

The current approach on #3050384: Provide a starterkit theme in core only support single starterkit theme to be used as the starting point for generated themes. However, it could be useful to have other themes be available as the starting point.

Proposed resolution

Allow themes to indicate if they can be used as a starting point on the starterkit theme generator. We probably should also provide command that allows finding themes that can be used a starterkit theme.

Scope of this issue

This issue only consists of

1) Allowing themes to specify starterkit: true in the info.yml file
2) Theme generator will only be able to duplicate themes that have this specified
3) Appropriate test coverage.

Testing instructions

  1. Run help php core/scripts/drupal generate-theme --help , and verify starterkit info is ouput
  2. Verify that bartik cannot be used by this script by running php core/scripts/drupal generate-theme --starterkit bartik mike
  3. Add starterkit: true to bartik.info.yml
  4. verify that bartik gets copied over as a starter theme by once again running php core/scripts/drupal generate-theme --starterkit bartik mike

Release notes snippet

Issue fork drupal-3206219

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lauriii created an issue. See original summary.

mherchel’s picture

💯 on board for this.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

rembrandx’s picture

Am I right in assuming this feature request is different from https://www.drupal.org/project/drupal/issues/3206217
because this request means giving the possibility to provide your own template files (not just a starter kit in Core) and thus generate a completely custom theme? But with passing extra options/functionality, much like drupal console allowed you to do?
Would this include the possibility to hook into the generate command and extend it so you can have the generator copy extra files and folders or replace custom variables inside twig and yml files for example?

andypost’s picture

Version: 9.3.x-dev » 9.4.x-dev
Parent issue: » #3050378: [meta] Replace Classy with a starterkit theme

no longer fits into 9.3

mglaman’s picture

Assigned: Unassigned » mglaman

I'm going to take a stab at this. If anything, to push for some more requirements.

Per #4: #3206217: Allow starterkit themes to control how the theme is generated seems to be more about the theme hooking into the generation process, so it is less static instead of the current "this is the way, and that's it."

The way I see this issue is that the info.yml has a new flag like starterkit: true and this says "k, we can scaffold from this sucker."

Once we have this, it would make it easier to test out #3206217: Allow starterkit themes to control how the theme is generated because then we could create a test starter kit theme and not rely on the current one.

mglaman’s picture

Status: Active » Needs review

Here is the initial work. I didn't add a starterkit_theme_test which could help verify this works. I wanted to keep the MR tidy until then. I used this to make a new theme from Olivero (hacked it locally to have the flag) and it worked like a charm.

ranjith_kumar_k_u’s picture

Fixed CS errors.

mglaman’s picture

Fixed phpcs in MR and added mystarterkit to cspell

mherchel’s picture

Status: Needs review » Needs work

Thanks for working on this! I found a number of issues:

I tested this by adding starterkit: true to olivero.info.yml and then running php core/scripts/drupal generate-theme --name "mike" --starterkit olivero mike

If you search the new theme (named "mike") for the olivero string, there's a lot of returns. Some of these are worse than others.

  • "Olivero" namespace in mike.breakpoints.yml
  • Dependencies on Olivero libraries within mike.info.yml
  • Dependencies on Olivero within mike.theme
  • Olivero namespace within theme-settings.php
  • Olivero named files and "olivero" theme dependency within all of the config yml files within /themes/mike/config/install
  • Lots of Olivero namespaced items within both the CSS and JS

IMO, the new theme should be a duplicate of Olivero but have absolutely no dependencies and not use the Olivero namespace within it. Maybe we could create a test that verifies this?

mglaman’s picture

I agree we need some kind of test. I missed the things named Olivero 😬. One problem is that Olivero isn't designed for a starterkit.

We'd need to make another starterkit test theme.

The problem is: is the problem for this issue or is this now becoming meta to flush out missing features when generating a starterkit?

mherchel’s picture

Yeah, my thought is that we have some Olivero namespaced JavaScript objects, etc. Should these be namespaced something more generic like "theme"? Because what if a user decides they want the machine name of the theme to be "this" or something. It'd break everything.

Should we modify Olivero (and other themes) to make them more friendly to being a starterkit? If so, what needs to be done? I'm not opposed to doing so. Giving a quick look at the CSS and JS, it'd be pretty simple to refactor it out and call it "theme" or "drupaltheme" or something.

mglaman’s picture

Status: Needs work » Needs review

Should we modify Olivero (and other themes) to make them more friendly to being a starterkit?

To me, that is up to the developer who created the starterkit.

Because what if a user decides they want the machine name of the theme to be "this" or something.

We can come up with "reserved" words.

---

These problems arise if we allow any theme to be a starterkit. And that's not the intent. So any of these problems are valid, but I don't think they block this issue. They are follow ups and things to address as starterkits are used more often.

I'm putting it back to Needs Review as we need input from @lauriii and others

mglaman’s picture

Assigned: mglaman » Unassigned

Copying in some information from Slack: https://drupal.slack.com/archives/C1BMUQ9U6/p1640798812123800

I pinged @lauriii about scope creep with things found in Olivero.

I’m wondering if we should figure those things out in https://www.drupal.org/project/drupal/issues/3206217
I would think it would be fine as long as we don’t add starterkit: true to Olivero in this issue

#3206217: Allow starterkit themes to control how the theme is generated

mglaman’s picture

Status: Needs review » Needs work

We need to add tests to \Drupal\Tests\Core\Command\GenerateThemeTest

mglaman’s picture

Status: Needs work » Needs review

Added test case for

* Specifying a starterkit that is a non-existent theme
* Specifying a theme that is not flagged as a starterkit (explicitly false)

mherchel’s picture

Issue summary: View changes

Adding scope to summary

mherchel’s picture

Issue summary: View changes

Adding testing instructions to summary

mherchel’s picture

Issue summary: View changes
mherchel’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
175.44 KB

This looks great! It works well, seems to be full tested (and tests pass).

I created and followed the testing instructions in the summary and this works as expected!

  • lauriii committed 440bcc0 on 10.0.x
    Issue #3206219 by mglaman, mherchel: Allow configuring which theme is...

  • lauriii committed 203860a on 9.4.x
    Issue #3206219 by mglaman, mherchel: Allow configuring which theme is...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed 440bcc0 and pushed to 10.0.x. Also committed to 9.4.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.