protected function findBestConstraint($existingVersion)
    {
        // Cannot guess without existing version
        if (!$existingVersion) {
            return null;
        }

        // Existing version is already a ^1.0.0 or ~1.0.0 constraint
        if (preg_match('#^[~^]#', $existingVersion)) {
            return $existingVersion;
        }

        // Existing version is already a dev constraint
        if (stristr($existingVersion, 'dev') !== false) {
            return $existingVersion;
        }

        // Numeric-only version maps to semver constraint
        if (preg_match('#^([\d.]+)$#', $existingVersion)) {
            return "^{$existingVersion}";
        }

        // Cannot guess; Let composer choose (equivalent to `composer require vendor/library`)
        return null;
    }