From 143bfd57a957178ade2669627c5a8c55eeadc78b Mon Sep 17 00:00:00 2001 From: Ivica Puljic <ivicapuljic@gmail.com> Date: Fri, 28 Mar 2025 01:10:24 +0100 Subject: [PATCH] Remove theme-options.yml feature from theme generator (#3515918). --- src/Commands/BsLibCommands.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/Commands/BsLibCommands.php b/src/Commands/BsLibCommands.php index 83fe76a..17a29b9 100644 --- a/src/Commands/BsLibCommands.php +++ b/src/Commands/BsLibCommands.php @@ -84,19 +84,6 @@ class BsLibCommands extends DrushCommands { // Replace text in copied files. $this->reconfigureThemeFiles($options); - // Copy theme-options.yml from parent theme. Try first to copy template if - // it exists, if not copy theme-options.yml. - $theme_options_filename = FALSE; - if (file_exists($options['parent_path'] . '/template.theme-options.yml')) { - $theme_options_filename = 'template.theme-options.yml'; - } - elseif (file_exists($options['parent_path'] . '/theme-options.yml')) { - $theme_options_filename = 'theme-options.yml'; - } - if ($theme_options_filename && !copy($options['parent_path'] . '/' . $theme_options_filename, $options['child_path'] . '/' . 'theme-options.yml')) { - throw new \Exception("Failed to copy $theme_options_filename file from {$options['parent_path']} to {$options['child_path']}."); - } - // Generate some files from the scratch. $this->generateFile("config/schema/{$child_machine_name}.schema.yml", $options); $this->generateFile('gulp-options.yml', $options); @@ -644,7 +631,7 @@ class BsLibCommands extends DrushCommands { $content = file_get_contents($install_filepath); // Find update functions and first comment line. - if (preg_match_all('/\s\*\s(.*?)\n\s\*\/\nfunction\s' . $parent_theme . '_bs_update_(\d{4})/', $content, $matches)) { + if (preg_match_all('/\s\*\s(.*?)\n\s\*\/\nfunction\s' . $parent_theme . '_bs_update_(\d+)/', $content, $matches)) { $functions = array_combine($matches[2], $matches[1]); // Filter update functions that were run in the past. @@ -1107,7 +1094,7 @@ class BsLibCommands extends DrushCommands { break; case $options['child_machine_name'] . '.libraries.yml': - // Lets start from parent libraries file. + // Let's start from parent libraries file. $file_content = file_get_contents($options['parent_path'] . '/' . $options['parent_machine_name'] . '.libraries.yml'); $yaml_array = Yaml::decode($file_content); $yaml_array = ['global-styling' => $yaml_array['global-styling']]; @@ -1115,7 +1102,14 @@ class BsLibCommands extends DrushCommands { break; case 'sass/variables/_' . $options['child_machine_name'] . '.scss': - $content .= "// Variable overrides and custom variable definitions.\n// Note that first all variables from theme-options.yml file will be loaded and\n// then variables from this file.\n"; + // Copy content form parent theme template.variables.scss if it exists. + if (file_exists($options['parent_path'] . '/template.variables.scss')) { + $content .= file_get_contents($options['parent_path'] . '/template.variables.scss'); + } + else { + $content .= "// Variable overrides and custom variable definitions.\n"; + } + break; case 'sass/_init.scss': -- GitLab