Open RamblingCookieMonster opened 6 years ago
@RamblingCookieMonster - would it be easier if instead of a single Version parameter you could use RequiredVersion, MinVersion, MaxVersion...or some variation of the 3? Readability-wise would be nice...not sure if it would be helpful on the backend, though. This would obviously deviate from the syntax that is similar to others, but still seems pretty clear and readable. Thoughts?
Makes sense to me!
I'd probably think of supporting both to allow flexibility in the simplified syntax (e.g. @{somemodule='>2.0.0'}
, and a more readable implementation like you mentioned for use with flexible syntax (e.g. @{somemodule=@{ MinimumVersion='2.0.0' }}
)
Also, I see no need for these to be implemented together at the same time! If you or anyone else is up for tackling either of these, feel free : ) Still decompressing after the summit, so might not have time in the near future... also... shoot! Saw you were at the summit but didn't get the chance to say hi! Next year hopefully? : )
I agree - I think they could certainly be done separately too. If so, I would assume you'd prefer that get filed as a separate issue as an enhancement, and yeah, maybe I'll look into taking it on. Thanks!
Yup, I was at Summit - had a great time. I'm definitely hoping to get back next year.
You know what's hard with this: Version = '>=1.2.9', '<2.0'
What does the coma ,
represents? an -and
, couldn't it be an -or
in some cases like =1.2.3 -or (>=1.2.9 -and <2.0)
So in the end, maybe using a syntax that looks like a filter -eq 1.2.3 -or (-ge 1.2.9 -and -lt 2.0)
would be better (as we might be able to leverage the PS engine to tokenize this.
The next problem is if we're using semver, we don't have a type that works (even the current code is dangerously buggy for SemVer comparison)...
And if we create a custom [SemVer]
type that implements IComparable
, using PS Class, we're limiting ourselves with 5.1+
Is that a problem?
I think I managed to get a custom filter working: https://github.com/RamblingCookieMonster/PSDepend/compare/master...gaelcolas:semverfilter It creates a custom filter so that you can do stuff like:
@{
MyModule = '-gt 1.0 -and (-lt 1.8.3 -or -gt 2.0)'
MyOtherModule = 'latest' # or ''
MyThirdOne = '2.3.4'
}
Obviously it is backward compatible, but also supports SemVer.
Writing tests and will send a PR in the next few days...
Implementing -MimimumVersion
, -RequiredVersion
, -MaximumVersion
would need different parameter sets, as Find-Module -AllVersion
is not compatible with those params.
So, does that makes sense?
pip, bundler, and other dependency handlers often support comparison operators, and more than one of these (e.g. lower and upper bounds).
Either single string, with delimited (comma, semicolon, multiple, whatever), or an array of strings. For example:
Version = '>2.2.3,<3.0'
Version = '>=1.2.9', '<2.0'
Single string is a little awkward looking but less complex in code. Multiple versions would be nicer looking but will add some complexity to what's already some painful logic.
If this sounds like anyone would use it, or has thoughts on these or other formats, hit me up!
Thanks to the reminder from Ravikanth!