Radix drush:create should possibly support none drupal/recommended-project as well

Created on 11 October 2023, about 1 year ago
Updated 24 November 2023, 12 months ago

Problem/Motivation

Of course it is great drush can reliably be used to create a fresh Starterkit theme, however now Drupal documentation describes a new process β†’ for doing so. Also, not every Drupal website has drush installed.

Steps to reproduce

On the Radix theme's profile page on drupal.org, the third step used to create a new Starterkit theme reads currently as:

3. Create a sub-theme using Drush (Considering you are using drupal/recommended-project):
drush --include="web/themes/contrib/radix" radix:create SUBTHEME_NAME

Proposed resolution

It should be possible to create a Starterkit theme using the following command:
php web/core/scripts/drupal generate-theme --starterkit radix my_new_starterkit_theme

To be clear, both methods work now as tested. However the documentation should be updated accordingly. Also, some people comfortable with other Starterkit themes might be more familiar using the PHP script than with drush.

✨ Feature request
Status

Fixed

Version

6.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States amstercad

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @amstercad
  • @amstercad opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States amstercad
  • Lee, this is actually using the starterkit to build the theme if you test it, drush is just a wrapper around it for two reasons:
    - backward compatibility
    - other goodies being done besides just a copy-paste

    you can try to check the files in play for the theme creation here: https://git.drupalcode.org/project/radix/-/tree/6.0.x/Commands/radix?ref...

    closing this

  • Status changed to Closed: works as designed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States ramez.gaberiel

    This is somewhat related but not entirely the same issue, the radix:create instruction only works assuming the user is using drupal/recommended-project, and hard codes the 'web' directory inside the drush commands.

    Would there be any opposition to making it more universal and remove the hardcoded 'web' directory from the drush commands and do something like this instead? Or is there a specific reason the generate starterkit instruction should only work with drupal/recommended project installations?

    <?php
    use Drush\Drush;
    .
    .
    .
        public function createSubTheme(string $name)
        {
          $drupal_root = Drush::bootstrapManager()->getRoot();
          try {
              $this->copyStarterKit($drupal_root);
              $this->generateTheme($name, $drupal_root);
              $this->removeCopiedStarterKit($drupal_root);
    .
    .
    .
        private function copyStarterKit(string $drupal_root)
        {
            $filesystem = new Filesystem();
            $source = "$drupal_root/themes/contrib/radix/src/kits/radix_starterkit";
            $destination = "$drupal_root/themes/custom/radix_starterkit";
            $filesystem->mirror($source, $destination);
        }
    .
    .
    .
    ?>
    
  • Good point ramez, not sure if there's a way to get the active directory of Drupal, I have to check, not sure if $drupal_root would translate into that or just the main drupal root

    I could possibly look into it later, but would appreciate a MR

  • Status changed to Needs work about 1 year ago
  • I renamed the ticket to reflect what is being mentioned here

  • πŸ‡ΊπŸ‡ΈUnited States amstercad

    IMHO, both the drush script and the core Drupal script should be supported, and why not? They both work so long as the Starterkit code meets the required specification. And valid documentation mentioning support for both scripts should exist.

    If the drush script offers more features and documents make that clear, then good. Many people will use Radix having used other themes before, and those themes might be using the Drupal core script at core/scripts/drupal. True, those are two different scripts with diverging capabilities perhaps, but either will get the job done. At the end of the day, I think it is fair to say that's what people want and if there's no additional development costs, why not support both scripted methods?

    One script only requires PHP while the other script requires a drush setup that some people might find too much of a hassle for the purpose.

  • All valid points Lee,

    Radix is rather a professional-level theme I'd say, so anyone here knows how to get around and use drush, at least they should if they don't.

    We are currently supporting both approaches, drush radix:create just uses the core starterkit under the hood (even though it doesn't really matter what approach we use as long as we get the subtheme built)

    I'd say Ramez is on a good angle, we need to make sure not to hardcode the web directory if it's possible, I'll look into it later when I get some free time

  • πŸ‡ΊπŸ‡ΈUnited States ramez.gaberiel

    Try this on for size

  • Thanks Ramez, the patch doesn't apply though

  • Anyways fixed it using Drush::bootstrapManager()->getRoot(), crediting you both. thanks

  • Status changed to Fixed 12 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024