private function findComposerVersion(string $packageName, string $projectDir): ?string
    {
        // A library app, but being ran from source so use git version.
        if (file_exists("$projectDir/vendor")) {
            return $this->findGitVersion($projectDir);
        }

        $composerFile = "$projectDir/../../../composer.lock";
        if (!file_exists($composerFile)) {
            return null;
        }
        $composer = Json::parse(file_get_contents($composerFile));

        foreach (['packages', 'packages-dev'] as $group) {
            foreach ($composer[$group] as $package) {
                if ($package['name'] === $packageName) {
                    return ltrim($package['version'] ?? null, 'v');
                }
            }
        }

        return null;
    }