Skip to content

Commit

Permalink
Merge pull request #71 from aternosorg/fabric-mod-dependencies-with-name
Browse files Browse the repository at this point in the history
Detect fabric mod dependency problems if the name is installed in the wrong version
  • Loading branch information
matthi4s authored Jun 14, 2024
2 parents 699d99b + 9cb6dc5 commit 91a1731
Show file tree
Hide file tree
Showing 4 changed files with 401 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Analysis/Problem/Fabric/FabricModDependencyProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function getMessage(): string
public static function getPatterns(): array
{
return [
'short-error' => '/net\.fabricmc\.loader\.discovery\.ModResolutionException: Could not find required mod: '. static::$modNamePattern .' requires {'. static::$modIDPattern .' @ \[([^\]]+)\]}/',
'any' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version of (?:mod )?". static::$modIDPattern .",/",
'minimum' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires version ([^ ]+) or later of (?:mod )?". static::$modIDPattern .",/",
'any-after' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version after ([^ ]+) of (?:mod )?". static::$modIDPattern .",/",
'any-before' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version before ([^ ]+) of (?:mod )?". static::$modIDPattern .",/",
'specific' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires version ([^ ]+) of (?:mod )?". static::$modIDPattern .",/",
'short-error' => '/net\.fabricmc\.loader\.discovery\.ModResolutionException: Could not find required mod: '. static::$modNamePattern .' requires {'. static::$modNamePattern .' @ \[([^\]]+)\]}/',
'any' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version of (?:mod )?". static::$modNamePattern .",/",
'minimum' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires version ([^ ]+) or later of (?:mod )?". static::$modNamePattern .",/",
'any-after' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version after ([^ ]+) of (?:mod )?". static::$modNamePattern .",/",
'any-before' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version before ([^ ]+) of (?:mod )?". static::$modNamePattern .",/",
'specific' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires version ([^ ]+) of (?:mod )?". static::$modNamePattern .",/",
'between' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version between ([^ ]+) \((inclusive|exclusive)\) and ([^ ]+) \((inclusive|exclusive)\) of (?:mod )?". static::$modNamePattern .",/"
];
}
Expand All @@ -59,17 +59,17 @@ public function setMatches(array $matches, mixed $patternKey): void
switch ($patternKey) {
case 'short-error':
$this->setModName($matches[2]);
$this->setDependency($matches[3]);
$this->setDependency($matches[empty($matches[3]) ? 4 : 3]);
$solution = (new ModInstallSolution())->setModName($this->getDependency());
if ($matches[4] != '*') {
$solution->setModVersion($matches[4]);
if ($matches[5] != '*') {
$solution->setModVersion($matches[5]);
}
$this->addSolution($solution);
return;

case 'any':
$this->setModName($matches[1]);
$this->setDependency($matches[3]);
$this->setDependency($matches[empty($matches[3]) ? 4 : 3]);
$this->addSolution((new ModInstallSolution())->setModName($this->getDependency()));
return;

Expand Down Expand Up @@ -103,7 +103,7 @@ public function setMatches(array $matches, mixed $patternKey): void
}

$this->setModName($matches[1]);
$this->setDependency($matches[4]);
$this->setDependency($matches[empty($matches[4]) ? 5 : 4]);
$this->addSolution((new ModInstallSolution())->setModName($this->getDependency())->setModVersion($symbol . $matches[3]));
}

Expand Down
Loading

0 comments on commit 91a1731

Please sign in to comment.