goldfinch / enchantment

Styled Admin theme for Silverstripe, based on Bootstrap 5
MIT License
0 stars 1 forks source link

Incorrect package assumptions cause errors #2

Open dcentrica opened 1 day ago

dcentrica commented 1 day ago

silverstripe/framework 5.2.22 goldfinch/enchantment 1.0.20 silverstripe/admin 2.2.13

In a minimal Silverstripe project (see versions above) which does not use following packages, you'll see several errors emitted from EnchantmentAssetsExtension. Other projects will/won't use an entirely different set of packages:

This happens because there are no guards wrapped around every call to Requirements::block() .

Solutions:

1). Wrap all such code-blocks with:

if (
    InstalledVersions::isInstalled(
        'silverstripe/cms',
    )
) {
    Requirements::block(
        'silverstripe/cms: client/dist/styles/bundle.css',
    );
}
  1. Or remove all such code-blocks and allow userland config to control using config system instead, ala:
Goldfinch\Enchantment\Extensions\EnchantmentAssetsExtension:
    block_packages:
        - 'silverstripe-versioned-admin'
        - 'silverstripe/cms'
        - 'silverstripe/session-manager'
foreach ($this->config()->get('block_packages') as $packageName) {
    if (InstalledVersions::isInstalled($packageName)) {
        Requirements::block(sprintf('%s:client/dist/styles/bundle.css', $packageName));
        Requirements::block(sprintf('%s:client/dist/css/GroupedCmsMenu.css', $packageName));
    }
}
goldfinch commented 6 hours ago

Hey,

Good point. I have added additional conditions on those internal packages that weren't bothering me but you might need to block those custom internal assets manually in your project (in case of any glitches or conflicts) which are not covered by this package.

https://github.com/goldfinch/enchantment/releases/tag/v1.0.21