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
- Run help
php core/scripts/drupal generate-theme --help
, and verify starterkit info is ouput - Verify that bartik cannot be used by this script by running
php core/scripts/drupal generate-theme --starterkit bartik mike
- Add
starterkit: true
to bartik.info.yml - 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
Comment | File | Size | Author |
---|---|---|---|
#21 | starterkit-command-test.png | 175.44 KB | mherchel |
Issue fork drupal-3206219
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:
Comments
Comment #2
mherchel💯 on board for this.
Comment #4
rembrandx CreditAttribution: rembrandx at Dropsolid commentedAm 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?
Comment #5
andypostno longer fits into 9.3
Comment #6
mglamanI'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 likestarterkit: 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.
Comment #8
mglamanHere 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.
Comment #9
ranjith_kumar_k_u CreditAttribution: ranjith_kumar_k_u at Zyxware Technologies commentedFixed CS errors.
Comment #10
mglamanFixed phpcs in MR and added mystarterkit to cspell
Comment #11
mherchelThanks for working on this! I found a number of issues:
I tested this by adding
starterkit: true
to olivero.info.yml and then runningphp 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.
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?
Comment #12
mglamanI 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?
Comment #13
mherchelYeah, 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.
Comment #14
mglamanTo me, that is up to the developer who created the starterkit.
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
Comment #15
mglamanCopying in some information from Slack: https://drupal.slack.com/archives/C1BMUQ9U6/p1640798812123800
I pinged @lauriii about scope creep with things found in Olivero.
#3206217: Allow starterkit themes to control how the theme is generated
Comment #16
mglamanWe need to add tests to \Drupal\Tests\Core\Command\GenerateThemeTest
Comment #17
mglamanAdded test case for
* Specifying a starterkit that is a non-existent theme
* Specifying a theme that is not flagged as a starterkit (explicitly false)
Comment #18
mherchelAdding scope to summary
Comment #19
mherchelAdding testing instructions to summary
Comment #20
mherchelComment #21
mherchelThis 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!
Comment #24
lauriiiCommitted 440bcc0 and pushed to 10.0.x. Also committed to 9.4.x. Thanks!