mirror of
https://codeberg.org/icewind/flakelight-php.git
synced 2026-06-03 18:04:10 +02:00
initial version
This commit is contained in:
commit
1eceb2ce73
8 changed files with 428 additions and 0 deletions
47
composer-meta.nix
Normal file
47
composer-meta.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
lib,
|
||||
allVersions,
|
||||
}: let
|
||||
inherit (lib) splitString split trim map substring stringToCharacters foldr elemAt filter isString;
|
||||
inherit (lib.lists) findFirstIndex;
|
||||
inherit (lib.strings) charToInt compareVersions;
|
||||
in
|
||||
composerJson: let
|
||||
versionComparesForOperations = {
|
||||
"=" = i: i == 0;
|
||||
">" = i: i > 0;
|
||||
"<" = i: i < 0;
|
||||
">=" = i: i >= 0;
|
||||
"<=" = i: i <= 0;
|
||||
};
|
||||
isInt = c: let
|
||||
ascii = charToInt c;
|
||||
zero = charToInt "0";
|
||||
nine = charToInt "9";
|
||||
in
|
||||
ascii >= zero && ascii <= nine;
|
||||
|
||||
splitConstraint = constraint: let
|
||||
trimmed = trim constraint;
|
||||
startIndex = findFirstIndex isInt 0 (stringToCharacters constraint);
|
||||
in [(substring 0 startIndex trimmed) (substring startIndex (-1) trimmed)];
|
||||
matchesSingleConstraint = constraint: version: let
|
||||
parts = splitConstraint constraint;
|
||||
cmp = elemAt parts 0;
|
||||
against = elemAt parts 1;
|
||||
in
|
||||
versionComparesForOperations.${cmp} (compareVersions version against);
|
||||
|
||||
splitOrParts = expr: map trim (splitString "||" expr);
|
||||
splitAndParts = expr: filter isString (split "[, ]+" expr);
|
||||
|
||||
foldAnd = foldr (a: b: a && b) true;
|
||||
foldOr = foldr (a: b: a || b) false;
|
||||
matchesAnd = expression: version: foldAnd (map (ex: matchesSingleConstraint ex version) (splitAndParts expression));
|
||||
matchesConstraint = expression: version: foldOr (map (ex: matchesAnd ex version) (splitOrParts expression));
|
||||
|
||||
phpConstraint = composerJson.require.php;
|
||||
matches = matchesConstraint phpConstraint;
|
||||
in {
|
||||
phpVersions = filter matches allVersions;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue