Allow StarterKit forked themes with prefix

Created on 13 September 2024, 9 months ago

Problem/Motivation

āÆ php public/core/scripts/drupal generate-theme --starterkit galactus --path themes/custom galactus_ta
Generating theme galactus_ta (galactus_ta) from galactus starterkit.
PHP Warning:  file_get_contents(/var/folders/1r/60zvgysn2y7_n__fym7d0_000000gp/T/drupal-starterkit-theme-1af82b4a8b7ab7165cf879b7acf47f9466e37d82d80063.32456974/galactus_ta.info.yml): Failed to open stream: No such file or directory in d11/public/core/lib/Drupal/Core/Command/GenerateTheme.php on line 168

Warning: file_get_contents(/var/folders/1r/60zvgysn2y7_n__fym7d0_000000gp/T/drupal-starterkit-theme-1af82b4a8b7ab7165cf879b7acf47f9466e37d82d80063.32456974/galactus_ta.info.yml): Failed to open stream: No such file or directory in /Users/pittet/Contrib/drupal/d11/public/core/lib/Drupal/Core/Command/GenerateTheme.php on line 168
PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #1 must be of type array, null given in /Users/pittet/Contrib/drupal/d11/public/core/lib/Drupal/Core/Command/GenerateTheme.php:170
Stack trace:
#0 /Users/pittet/Contrib/drupal/d11/public/core/lib/Drupal/Core/Command/GenerateTheme.php(170): array_merge(NULL, Array)
#1 /Users/pittet/Contrib/drupal/d11/vendor/symfony/console/Command/Command.php(279): Drupal\Core\Command\GenerateTheme->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /Users/pittet/Contrib/drupal/d11/vendor/symfony/console/Application.php(1029): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/pittet/Contrib/drupal/d11/vendor/symfony/console/Application.php(316): Symfony\Component\Console\Application->doRunCommand(Object(Drupal\Core\Command\GenerateTheme), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /Users/pittet/Contrib/drupal/d11/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /Users/pittet/Contrib/drupal/d11/public/core/scripts/drupal(30): Symfony\Component\Console\Application->run()
#6 {main}
  thrown in /Users/pittet/Contrib/drupal/d11/public/core/lib/Drupal/Core/Command/GenerateTheme.php on line 170

Fatal error: Uncaught TypeError: array_merge(): Argument #1 must be of type array, null given in /Users/pittet/Contrib/drupal/d11/public/core/lib/Drupal/Core/Command/GenerateTheme.php:170
Stack trace:
#0 /Users/pittet/Contrib/drupal/d11/public/core/lib/Drupal/Core/Command/GenerateTheme.php(170): array_merge(NULL, Array)
#1 /Users/pittet/Contrib/drupal/d11/vendor/symfony/console/Command/Command.php(279): Drupal\Core\Command\GenerateTheme->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /Users/pittet/Contrib/drupal/d11/vendor/symfony/console/Application.php(1029): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/pittet/Contrib/drupal/d11/vendor/symfony/console/Application.php(316): Symfony\Component\Console\Application->doRunCommand(Object(Drupal\Core\Command\GenerateTheme), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /Users/pittet/Contrib/drupal/d11/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /Users/pittet/Contrib/drupal/d11/public/core/scripts/drupal(30): Symfony\Component\Console\Application->run()
#6 {main}
  thrown in /Users/pittet/Contrib/drupal/d11/public/core/lib/Drupal/Core/Command/GenerateTheme.php on line 170

~/Contrib/drupal/d11                                                                          16:47:15
āÆ ll /var/folders/1r/60zvgysn2y7_n__fym7d0_000000gp/T/drupal-starterkit-theme-1af82b4a8b7ab7165cf879b7acf47f9466e37d82d80063.32456974/
total 192
-rw-r--r--   1 pittet  staff   1103 Aug 28 10:57 LICENSE
-rwxr-xr-x   1 pittet  staff   2580 Sep 12 16:47 README.md*
-rw-r--r--   1 pittet  staff    230 Sep 12 16:47 composer.json
drwxr-xr-x   5 pittet  staff    160 Sep 12 16:47 config/
drwxr-xr-x  14 pittet  staff    448 Sep 12 16:47 css/
-rwxr-xr-x   1 pittet  staff   1406 Aug 28 10:57 favicon.ico*
-rwxr-xr-x   1 pittet  staff    792 Sep 12 16:47 galactusTaTa_ta.breakpoints.yml*
-rw-r--r--   1 pittet  staff   1358 Sep 12 16:47 galactusTaTa_ta.info.yml
-rw-r--r--   1 pittet  staff   6202 Sep 12 16:47 galactusTaTa_ta.libraries.yml
-rw-r--r--   1 pittet  staff  17986 Sep 12 16:47 galactusTaTa_ta.theme
drwxr-xr-x   9 pittet  staff    288 Sep 12 16:47 img/
drwxr-xr-x   6 pittet  staff    192 Sep 12 16:47 js/
-rw-r--r--   1 pittet  staff   2504 Aug 28 10:57 logo.svg
-rw-r--r--   1 pittet  staff   8065 Sep 12 16:47 package-lock.json
-rw-r--r--   1 pittet  staff    161 Aug 28 10:57 package.json
drwxr-xr-x  16 pittet  staff    512 Sep 12 16:47 sass/
-rwxr-xr-x   1 pittet  staff   4529 Aug 28 10:57 screenshot.png*
drwxr-xr-x  13 pittet  staff    416 Sep 12 16:47 templates/
-rwxr-xr-x   1 pittet  staff  20104 Sep 12 16:47 theme-settings.php*

As you can see in the temp directory galactusTaTa_ta.info.yml

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

šŸ› Bug report
Status

Active

Version

11.0 šŸ”„

Component
ThemeĀ  →

Last updated 1 day ago

Created by

šŸ‡ØšŸ‡¦Canada joelpittet Vancouver

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

Merge Requests

Comments & Activities

  • Issue created by @joelpittet
  • šŸ‡ØšŸ‡¦Canada joelpittet Vancouver

    I'm narrowing down on šŸ“Œ Making a theme compatible with core's theme generator is too difficult Needs work

    Where this code was introduced in GenerateTheme:

      private static function namePatterns(string $machine_name, string $label): array {
        return [
          'machine_name' => $machine_name,
          'machine_name_camel' => u($machine_name)->camel(),
          'machine_name_pascal' => u($machine_name)->camel()->title(),
          'machine_name_title' => u($machine_name)->title(),
          'label' => $label,
          'label_camel' => u($label)->camel(),
          'label_pascal' => u($label)->camel()->title(),
          'label_title' => u($label)->title(),
        ];
      }
  • šŸ‡ØšŸ‡¦Canada joelpittet Vancouver

    Breaking that out with the Issue Summary example:

    $patterns = [
      'old' => [
        'machine_name' => 'galactus',
        'machine_name_camel' => 'galactus',
        'machine_name_pascal' => 'Galactus',
        'machine_name_title' => 'Galactus',
        'label' => 'Galactus',
        'label_camel' => 'galactus',
        'label_pascal' => 'Galactus',
        'label_title' => 'Galactus',
      ],
      'new' => [
        'machine_name' => 'galactus_ta',
        'machine_name_camel' => 'galactusTa',
        'machine_name_pascal' => 'GalactusTa',
        'machine_name_title' => 'Galactus_ta',
        'label' => 'galactus_ta',
        'label_camel' => 'galactusTa',
        'label_pascal' => 'GalactusTa',
        'label_title' => 'Galactus_ta',
      ],
    ];
    $filename = str_replace($patterns['old'], $patterns['new'], $old_filename);
    
    Why does it always add TaTa_ to the new $filename in these examples
    $old_filename = 'galactus.settings.yml'
    $filename = 'galactusTaTa_ta.settings.yml'
    $old_filename = 'block.block.galactus_mainpagecontent.yml'
    $filename = 'block.block.galactusTaTa_ta_mainpagecontent.yml'
    $old_filename = 'block.block.galactus_pagetitle.yml'
    $filename = 'block.block.galactusTaTa_ta_pagetitle.yml'
    $old_filename = 'block.block.galactus_tabs.yml'
    $filename = 'block.block.galactusTaTa_ta_tabs.yml'
    $old_filename = 'block.block.galactus_primaryadminactions.yml'
    $filename = 'block.block.galactusTaTa_ta_primaryadminactions.yml'
    $old_filename = 'block.block.galactus_main_menu.yml'
    $filename = 'block.block.galactusTaTa_ta_main_menu.yml'
    $old_filename = 'block.block.galactus_breadcrumbs.yml'
    $filename = 'block.block.galactusTaTa_ta_breadcrumbs.yml'
    $old_filename = 'block.block.galactus_help.yml'
    $filename = 'block.block.galactusTaTa_ta_help.yml'
    $old_filename = 'block.block.galactus_drawer.yml'
    $filename = 'block.block.galactusTaTa_ta_drawer.yml'
    $old_filename = 'galactus.schema.yml'
    $filename = 'galactusTaTa_ta.schema.yml'
    $old_filename = 'galactus.theme'
    $filename = 'galactusTaTa_ta.theme'
    $old_filename = 'galactus.libraries.yml'
    $filename = 'galactusTaTa_ta.libraries.yml'
    $old_filename = 'galactus.breakpoints.yml'
    $filename = 'galactusTaTa_ta.breakpoints.yml'
    $old_filename = 'galactus.info.yml'
    $filename = 'galactusTaTa_ta.info.yml'
    

    It applies to more than just files, it's only that this is easy to represent.

    Still working on a solution but it would be nice to know why so many variations for the replacements were needed in the first place.

  • Status changed to Needs review 9 months ago
  • šŸ‡ØšŸ‡¦Canada joelpittet Vancouver

    This affects themes like https://www.drupal.org/project/basic → which I would like to be a starterkit theme.

  • Pipeline finished with Failed
    9 months ago
    Total: 580s
    #282888
  • Status changed to Needs work 9 months ago
  • šŸ‡ŗšŸ‡øUnited States smustgrave

    Seems to have an error.

    Could issue summary also be filled out please

    Thanks.

  • Status changed to Needs review 9 months ago
  • šŸ‡ØšŸ‡¦Canada joelpittet Vancouver

    @smustgrave, I don't have a fix but the tests do demo the problem.

    Updated the issue summary to help make this clearer

  • Pipeline finished with Failed
    9 months ago
    Total: 791s
    #284883
  • Status changed to Needs work 9 months ago
  • šŸ‡ŗšŸ‡øUnited States smustgrave

    Awesome to already have test coverage. But moving to NW for the solution. Not sure it's likely to get picked up for development in review queue.

  • Pipeline finished with Failed
    7 months ago
    Total: 759s
    #325533
  • Pipeline finished with Failed
    7 months ago
    Total: 631s
    #325547
  • Pipeline finished with Failed
    6 months ago
    Total: 566s
    #351144
  • Pipeline finished with Failed
    6 months ago
    Total: 504s
    #351150
  • šŸ‡ŗšŸ‡øUnited States mortona2k Seattle

    Does this consider themes with SDC? Templates that reference components as THEME:COMPONENT need the theme part updated.

  • First commit to issue fork.
  • šŸ‡ØšŸ‡¦Canada garphy Montreal, Canada

    @joelpittet I pushed a little update to perform the two str_replace in file contents in one go, avoiding the intermediate content write to the file.

  • Pipeline finished with Failed
    27 days ago
    Total: 822s
    #490813
  • Pipeline finished with Failed
    27 days ago
    Total: 764s
    #490822
  • Pipeline finished with Failed
    27 days ago
    Total: 604s
    #490835
  • šŸ‡ØšŸ‡¦Canada joelpittet Vancouver

    Thanks @garphy for taking a crack at it. I dropped it because my brain needed a break... I felt close but for some reason no dice! Thanks for the test alterations as well!

  • šŸ‡ØšŸ‡¦Canada joelpittet Vancouver

    @mortona2k RE #9 I don't think I was thinking about that in this problem. But if it doesn't work now, it likely won't be fixed here...
    Feel free to add tests if you care to see if it has affects on it but try to avoid scope creeping this, please

Production build 0.71.5 2024