Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AssetMapper] Warning thrown when dependency version is within valid range #54610

Open
tacman opened this issue Apr 15, 2024 · 4 comments
Open

Comments

@tacman
Copy link
Contributor

tacman commented Apr 15, 2024

Symfony version(s) affected

6.4

Description

when installing a package, I'm getting

 [warning] datatables.net-scroller-bs5 requires datatables.net-bs5@1.11 - 2 but version 2.0.3 is installed.

but 1.11 - 2 includes 2.0.3

image

Checking with the npm SemVer Calculator appears to confirm this:

How to reproduce

bin/console importmap:require datatables.net-scroller-bs5
bin/console importmap:update
[warning] datatables.net-scroller-bs5 requires datatables.net-bs5@1.11 - 2 but version 2.0.3 is installed.
[warning] datatables.net-scroller-bs5 requires datatables.net-bs5@1.11 - 2 but version 2.0.3 is installed.

 [OK] Updated all packages in importmap.php.                                                                            

Possible Solution

Perhaps the way the semver string is being parsed isn't including the minor / patch releases. I had a different but similar issue with phar-io/version

phar-io/version#34

Additional Context

No response

@tacman tacman added the Bug label Apr 15, 2024
@tacman tacman changed the title [AssetMapper] Infa [AssetMapper] Warning thrown when dependency version is within valid range Apr 15, 2024
@Jean-Beru
Copy link
Contributor

The AssetMapper version checker converts 1.11 - 2 to >=1.11 <=2 which is still valid.

image

But Semver::statisfies from https://github.com/composer/semver returns false when comparing this range to 2.3.0.

IMO, we can open an issue in this repository.

@tacman
Copy link
Contributor Author

tacman commented Apr 16, 2024

It looks like the tests don't cover a version range without a minor version.

https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php#L308-L311

// Hyphen Ranges
        yield 'hyphen range simple' => [
            '1.0.0 - 2.0.0',
            '>=1.0.0 <=2.0.0',
        ];

        yield 'hyphen range with v prefix' => [
            'v1.0.0 - 2.0.0',
            '>=1.0.0 <=2.0.0',
        ];

        yield 'hyphen range without patch' => [
            '1.0 - 2.0',
            '>=1.0 <=2.0',
        ];

        yield 'hyphen range with no spaces' => [
            '1.0-v2.0',
            '>=1.0 <=2.0',
        ];

@stof
Copy link
Member

stof commented Apr 16, 2024

<=2 does not have the same meaning in Composer and in npm. In Composer, 2, 2.0 and 2.0.0 are the same version, even when using in constraint bounds.

@Jean-Beru
Copy link
Contributor

Jean-Beru commented Apr 16, 2024

An other solution may be to keep the 1.11 - 2 syntax, instead of converting it, since Composer supports it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants