lib/qx/tool/cli/commands/contrib/List.js
async function(qooxdoo_version) {
      if (this.argv.installed) {
        // local libraries
        const localPathRepoName = this.self(arguments).localPathRepoName;
        this.__repositories.push({
          name: localPathRepoName,
          description: "Libraries on local filesystem"
        });
        this.__libraries[localPathRepoName] = [];
        let libData = await this.getContribData();
        for (let lib of libData.libraries) {
          if (!lib.repo_name) {
            let manifest_path = path.join(process.cwd(), lib.path, qx.tool.cli.ConfigSchemas.library.filename);
            let manifest = await qx.tool.compiler.utils.Json.loadJsonAsync(manifest_path);
            let info = manifest.info;
            this.__libraries[localPathRepoName].push({
              name: info.name,
              namespace: manifest.provides.namespace,
              summary: info.summary,
              version: "v" + info.version,
              compatibility: semver.satisfies(qooxdoo_version, manifest.requires["qooxdoo-sdk"], true),
              path: path.relative(process.cwd(), path.dirname(manifest_path)),
              installedVersion: "v" + info.version
            });
          }
        }
      }

      // repositories
      let repos_cache = this.getCache().repos;
      let num_compat_repos = 0;
      if (this.__latestCompatible[qooxdoo_version] === undefined) {
        this.__latestCompatible[qooxdoo_version] = {};
      }

      // iterate over repositories
      for (let repo_name of repos_cache.list) {
        let repo_data = repos_cache.data[repo_name];

        // filter out repositories that are deprecated or should not be listed unless --all
        let d = repo_data.description;
        if (!this.argv.all && d && (d.includes("(deprecated)") || d.includes("(unlisted)"))) {
          continue;
        }

        let tag_names = repo_data.releases.list;
        let {description} = repo_data;
        let hasCompatibleRelease = false;
        let latestVersion = false;
        let repoInstalledVersion = false;

        // iterate over releases
        for (let tag_name of tag_names) {
          let release_data = repo_data.releases.data[tag_name];
          let {prerelease, manifests} = release_data;
          // iterate over library manifests in that release
          for (let {qx_versions, info, provides, path: manifest_path} of manifests) {
            let installedVersion = false;
            if (info === undefined) {
              if (this.argv.verbose) {
                console.warn(`>>> Ignoring ${repo_name} ${tag_name}: Undefined info field. `);
              }
              continue;
            }

            // library version MUST match tag name
            let library_name = info.name;
            let version = info.version;
            let tag_version = tag_name.replace(/v/, "");
            if (version !== tag_version) {
              if (this.argv.verbose) {
                console.warn(`>>> Ignoring ${repo_name} ${tag_name}, library '${library_name}': mismatch between tag version '${tag_version}' and library version '${version}'.`);
              }
              continue;
            }

            // save latest version
            try {
              if (!latestVersion || semver.gt(version, latestVersion, true)) {
                latestVersion = tag_name;
              }
            } catch (e) {
              if (this.argv.verbose) {
                console.warn(`>>> Ignoring ${repo_name} ${tag_name}, library '${library_name}': invalid version format '${version}'.`);
              }
            }

            // installed from GitHub?
            let installed = await this.getInstalledLibraryTag(repo_name, library_name);
            if (installed) {
              installedVersion = installed;
              repoInstalledVersion = installed;
            } else {
              let lib = await this.getInstalledLibraryData(library_name);
              if (lib) {
                installedVersion = "v" + lib.library_version;
              }
            }

            // check compatibility of library
            let compatibility = semver.satisfies(
              qooxdoo_version,
              qx_versions,
              true
            );

            // prepare indexes
            if (this.__libraries[repo_name] === undefined) {
              this.__libraries[repo_name] = [];
            }

            // use the latest compatible release, i.e the one that satisfies the following conditions:
            // 1) must be semver-compatible with the qooxdoo version
            // 2) must be the higher than any other version found so far
            // 3) should not be a pre-release unless there are no other compatible releases
            let latestCompatibleRelease = this.__latestCompatible[qooxdoo_version][repo_name];
            let latestCompatibleVersion = latestCompatibleRelease ? latestCompatibleRelease.replace(/v/, "") : undefined;
            if (compatibility === true &&
              (latestCompatibleRelease === undefined ||
                (semver.gt(tag_version, latestCompatibleVersion, false) && !prerelease)
              )
            ) {
              this.__latestCompatible[qooxdoo_version][repo_name] = tag_name;
              hasCompatibleRelease = true;
            }

            // save data
            this.__libraries[repo_name].push({
              name: info.name,
              namespace: provides ? provides.namespace : "",
              summary: info.summary,
              version,
              compatibility,
              required_qx_version: qx_versions,
              path: path.dirname(manifest_path),
              installedVersion
            });
          }
        }
        if (hasCompatibleRelease) {
          num_compat_repos++;
        }

        // add to list
        this.__repositories.push({
          name: repo_name,
          description,
          installedVersion: repoInstalledVersion,
          latestVersion,
          latestCompatible : hasCompatibleRelease ? this.__latestCompatible[qooxdoo_version][repo_name] : false
        });
      }
      return num_compat_repos;
    }
async function(qooxdoo_version) {
      if (this.argv.installed) {
        // local libraries
        const localPathRepoName = this.self(arguments).localPathRepoName;
        this.__repositories.push({
          name: localPathRepoName,
          description: "Libraries on local filesystem"
        });
        this.__libraries[localPathRepoName] = [];
        let libData = await this.getContribData();
        for (let lib of libData.libraries) {
          if (!lib.repo_name) {
            let manifest_path = path.join(process.cwd(), lib.path, qx.tool.cli.ConfigSchemas.library.filename);
            let manifest = await qx.tool.compiler.utils.Json.loadJsonAsync(manifest_path);
            let info = manifest.info;
            this.__libraries[localPathRepoName].push({
              name: info.name,
              namespace: manifest.provides.namespace,
              summary: info.summary,
              version: "v" + info.version,
              compatibility: semver.satisfies(qooxdoo_version, manifest.requires["qooxdoo-sdk"], true),
              path: path.relative(process.cwd(), path.dirname(manifest_path)),
              installedVersion: "v" + info.version
            });
          }
        }
      }

      // repositories
      let repos_cache = this.getCache().repos;
      let num_compat_repos = 0;
      if (this.__latestCompatible[qooxdoo_version] === undefined) {
        this.__latestCompatible[qooxdoo_version] = {};
      }

      // iterate over repositories
      for (let repo_name of repos_cache.list) {
        let repo_data = repos_cache.data[repo_name];

        // filter out repositories that are deprecated or should not be listed unless --all
        let d = repo_data.description;
        if (!this.argv.all && d && (d.includes("(deprecated)") || d.includes("(unlisted)"))) {
          continue;
        }

        let tag_names = repo_data.releases.list;
        let {description} = repo_data;
        let hasCompatibleRelease = false;
        let latestVersion = false;
        let repoInstalledVersion = false;

        // iterate over releases
        for (let tag_name of tag_names) {
          let release_data = repo_data.releases.data[tag_name];
          let {prerelease, manifests} = release_data;
          // iterate over library manifests in that release
          for (let {qx_versions, info, provides, path: manifest_path} of manifests) {
            let installedVersion = false;
            if (info === undefined) {
              if (this.argv.verbose) {
                console.warn(`>>> Ignoring ${repo_name} ${tag_name}: Undefined info field. `);
              }
              continue;
            }

            // library version MUST match tag name
            let library_name = info.name;
            let version = info.version;
            let tag_version = tag_name.replace(/v/, "");
            if (version !== tag_version) {
              if (this.argv.verbose) {
                console.warn(`>>> Ignoring ${repo_name} ${tag_name}, library '${library_name}': mismatch between tag version '${tag_version}' and library version '${version}'.`);
              }
              continue;
            }

            // save latest version
            try {
              if (!latestVersion || semver.gt(version, latestVersion, true)) {
                latestVersion = tag_name;
              }
            } catch (e) {
              if (this.argv.verbose) {
                console.warn(`>>> Ignoring ${repo_name} ${tag_name}, library '${library_name}': invalid version format '${version}'.`);
              }
            }

            // installed from GitHub?
            let installed = await this.getInstalledLibraryTag(repo_name, library_name);
            if (installed) {
              installedVersion = installed;
              repoInstalledVersion = installed;
            } else {
              let lib = await this.getInstalledLibraryData(library_name);
              if (lib) {
                installedVersion = "v" + lib.library_version;
              }
            }

            // check compatibility of library
            let compatibility = semver.satisfies(
              qooxdoo_version,
              qx_versions,
              true
            );

            // prepare indexes
            if (this.__libraries[repo_name] === undefined) {
              this.__libraries[repo_name] = [];
            }

            // use the latest compatible release, i.e the one that satisfies the following conditions:
            // 1) must be semver-compatible with the qooxdoo version
            // 2) must be the higher than any other version found so far
            // 3) should not be a pre-release unless there are no other compatible releases
            let latestCompatibleRelease = this.__latestCompatible[qooxdoo_version][repo_name];
            let latestCompatibleVersion = latestCompatibleRelease ? latestCompatibleRelease.replace(/v/, "") : undefined;
            if (compatibility === true &&
              (latestCompatibleRelease === undefined ||
                (semver.gt(tag_version, latestCompatibleVersion, false) && !prerelease)
              )
            ) {
              this.__latestCompatible[qooxdoo_version][repo_name] = tag_name;
              hasCompatibleRelease = true;
            }

            // save data
            this.__libraries[repo_name].push({
              name: info.name,
              namespace: provides ? provides.namespace : "",
              summary: info.summary,
              version,
              compatibility,
              required_qx_version: qx_versions,
              path: path.dirname(manifest_path),
              installedVersion
            });
          }
        }
        if (hasCompatibleRelease) {
          num_compat_repos++;
        }

        // add to list
        this.__repositories.push({
          name: repo_name,
          description,
          installedVersion: repoInstalledVersion,
          latestVersion,
          latestCompatible : hasCompatibleRelease ? this.__latestCompatible[qooxdoo_version][repo_name] : false
        });
      }
      return num_compat_repos;
    }
Create compatibilty indexes of repositories and the contained libraries
@param qooxdoo_version {String} The qooxdoo version to check compatibiity with
@return {Number} The number of contrib repositories containing compatible libraries