AlexRogalskiy/java-patterns

View on GitHub
packages/github-client/docs/miscellaneous/variables.html

Summary

Maintainability
Test Coverage
<!doctype html>
<html class="no-js" lang="">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>@java-patterns/github-client documentation</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <link rel="icon" type="image/x-icon" href="../images/favicon.ico">
       <link rel="stylesheet" href="../styles/style.css">
        <link rel="stylesheet" href="../styles/dark.css">
    </head>
    <body>

        <div class="navbar navbar-default navbar-fixed-top visible-xs">
            <a href="../" class="navbar-brand">@java-patterns/github-client documentation</a>
            <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
        </div>

        <div class="xs-menu menu" id="mobile-menu">
                <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div>            <compodoc-menu></compodoc-menu>
        </div>

        <div class="container-fluid main">
           <div class="row main">
               <div class="hidden-xs menu">
                   <compodoc-menu mode="normal"></compodoc-menu>
               </div>
               <!-- START CONTENT -->
               <div class="content miscellaneous-variables">
                   <div class="content-data">


















<ol class="breadcrumb">
  <li>Miscellaneous</li>
  <li>Variables</li>
</ol>

<section>
    <h3 id="index">Index</h3>
    <table class="table table-sm table-bordered index-table">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <ul class="index-list">
                        <li>
                            <a href="#doWork" title="src/index.ts" ><b>doWork</b>&nbsp;&nbsp;&nbsp;(src/.../index.ts)</a>
                        </li>
                        <li>
                            <a href="#getFile" title="src/helpers/utils.ts" ><b>getFile</b>&nbsp;&nbsp;&nbsp;(src/.../utils.ts)</a>
                        </li>
                        <li>
                            <a href="#gh" title="src/index.ts" ><b>gh</b>&nbsp;&nbsp;&nbsp;(src/.../index.ts)</a>
                        </li>
                        <li>
                            <a href="#isUserInOrg" title="src/helpers/utils.ts" ><b>isUserInOrg</b>&nbsp;&nbsp;&nbsp;(src/.../utils.ts)</a>
                        </li>
                        <li>
                            <a href="#leaveIssue" title="src/helpers/utils.ts" ><b>leaveIssue</b>&nbsp;&nbsp;&nbsp;(src/.../utils.ts)</a>
                        </li>
                        <li>
                            <a href="#log" title="src/index.ts" ><b>log</b>&nbsp;&nbsp;&nbsp;(src/.../index.ts)</a>
                        </li>
                        <li>
                            <a href="#main" title="src/index.ts" ><b>main</b>&nbsp;&nbsp;&nbsp;(src/.../index.ts)</a>
                        </li>
                        <li>
                            <a href="#org" title="src/index.ts" ><b>org</b>&nbsp;&nbsp;&nbsp;(src/.../index.ts)</a>
                        </li>
                        <li>
                            <a href="#repoCache" title="src/index.ts" ><b>repoCache</b>&nbsp;&nbsp;&nbsp;(src/.../index.ts)</a>
                        </li>
                    </ul>
                </td>
            </tr>
        </tbody>
    </table>
</section>

    <h3>src/index.ts</h3>
    <section>
    <h3></h3>    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="doWork"></a>
                    <span class="name">
                        <span ><b>doWork</b></span>
                        <a href="#doWork"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Default value : </i><code>async (repo) &#x3D;&gt; {
  const readme &#x3D; await getFile(gh, repo, &quot;README.md&quot;)
  if (!readme) {
    log(repo, &quot;Could not find a README&quot;)
    return
  }

  const pp &#x3D; /__Point People:__ (.*)/g
  const pointMatches &#x3D; readme.match(pp)

  // http://stackoverflow.com/questions/1500260/detect-urls-in-text-with-javascript
  const urlRegex &#x3D; /(\b(https?|ftp|file):\/\/[-A-Z0-9+&amp;@#\/%?&#x3D;~_|!:,.;]*[-A-Z0-9+&amp;@#\/%&#x3D;~_|])/ig;

  if (!pointMatches || pointMatches.length &#x3D;&#x3D;&#x3D; 0) {
    const contributors &#x3D; await gh.rest.repos.getContributorsStats({owner: org, repo: repo.name})
    log(repo, &#x60;No point person found, perhaps @${contributors.data[0].login}.&#x60;)
  } else {
    const ownerString &#x3D; pointMatches[0] as string
    const urls &#x3D; ownerString.match(urlRegex) || []
    const githubOwners &#x3D; urls.filter(u &#x3D;&gt; u.includes(&quot;github&quot;)).map(f &#x3D;&gt; f.split(&quot;/&quot;).pop())
    const slackUrls &#x3D; urls.filter(u &#x3D;&gt; u.includes(&quot;slack&quot;)).map(f &#x3D;&gt; f.split(&quot;/&quot;).pop())

    if (githubOwners.length &#x3D;&#x3D;&#x3D; 0 &amp;&amp; slackUrls.length &#x3D;&#x3D;&#x3D; 0) {
      log(repo, &quot;Has no owners&quot;)
    } else {

      const usersNotInOrg: any[] &#x3D; []
      for (const owner of githubOwners) {
        const inOrg &#x3D; await isUserInOrg(gh, org, owner)
        if (!inOrg) {
          usersNotInOrg.push(owner)
        }
      }
      if (usersNotInOrg.length) {
        log(repo, &quot;Found someone not in the org: &quot; + usersNotInOrg)
      }
    }
  }
}</code>
                    </td>
                </tr>


        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="gh"></a>
                    <span class="name">
                        <span ><b>gh</b></span>
                        <a href="#gh"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Default value : </i><code>new Github.Octokit({headers: {&quot;user-agent&quot;: &quot;Org README checker&quot;}})</code>
                    </td>
                </tr>


        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="log"></a>
                    <span class="name">
                        <span ><b>log</b></span>
                        <a href="#log"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Default value : </i><code>(repo, message) &#x3D;&gt; {
  console.log(&#x60;[${repo}] - ${message}&#x60;)
}</code>
                    </td>
                </tr>


        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="main"></a>
                    <span class="name">
                        <span ><b>main</b></span>
                        <a href="#main"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Default value : </i><code>async () &#x3D;&gt; {
  let repoSets: any[]
  if (fs.existsSync(repoCache)) {
    repoSets &#x3D; JSON.parse(fs.readFileSync(repoCache).toString())
  } else {
    repoSets &#x3D; await getAllOrgRepos(gh, org)
    fs.writeFileSync(repoCache, JSON.stringify(repoSets))
  }

  const repos &#x3D; repoSets[&quot;data&quot;]

  const eigen &#x3D; _.find(repos, r &#x3D;&gt; r.name &#x3D;&#x3D;&#x3D; &quot;eigen&quot;)
  // const gravity &#x3D; _.find(repos, r &#x3D;&gt; r.name &#x3D;&#x3D;&#x3D; &quot;gravity&quot;)
  // const artsyD &#x3D; _.find(repos, r &#x3D;&gt; r.name &#x3D;&#x3D;&#x3D; &quot;artsy-danger&quot;)

  await doWork(eigen)
  // await doWork(gravity)
  // await doWork(artsyD)

  // for (const repo of repos) {
  //   await doWork(repo)
  // }
}</code>
                    </td>
                </tr>


        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="org"></a>
                    <span class="name">
                        <span ><b>org</b></span>
                        <a href="#org"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Default value : </i><code>&#x60;${process.env.GITHUB_ORG}&#x60;</code>
                    </td>
                </tr>


        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="repoCache"></a>
                    <span class="name">
                        <span ><b>repoCache</b></span>
                        <a href="#repoCache"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Default value : </i><code>&#x60;${process.env.CACHE_DIR}/repos.json&#x60;</code>
                    </td>
                </tr>


        </tbody>
    </table>
</section>
    <h3>src/helpers/utils.ts</h3>
    <section>
    <h3></h3>    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getFile"></a>
                    <span class="name">
                        <span ><b>getFile</b></span>
                        <a href="#getFile"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Default value : </i><code>async (gh, repo: any, path: string): Promise&lt;string | null&gt; &#x3D;&gt; {
  try {
    const content &#x3D; await gh.repos.getContent({
      owner: repo.owner.login,
      repo: repo.name,
      path
    })

    const buffer &#x3D; new Buffer(content.data.content, &quot;base64&quot;)
    return buffer.toString()

  } catch (error) {
    return null
  }
}</code>
                    </td>
                </tr>


        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="isUserInOrg"></a>
                    <span class="name">
                        <span ><b>isUserInOrg</b></span>
                        <a href="#isUserInOrg"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Default value : </i><code>async (gh, org, username) &#x3D;&gt; {
  try {
    await gh.orgs.checkMembership({org, username})
    return true
  } catch (error) {
    return false
  }
}</code>
                    </td>
                </tr>


        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="leaveIssue"></a>
                    <span class="name">
                        <span ><b>leaveIssue</b></span>
                        <a href="#leaveIssue"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Default value : </i><code>async (gh, repo, title, body) &#x3D;&gt; {
  await gh.issues.create({
    owner: repo.owner.login,
    repo: repo.name,
    title,
    body,
  })
}</code>
                    </td>
                </tr>


        </tbody>
    </table>
</section>



                   </div><div class="search-results">
    <div class="has-results">
        <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
        <ul class="search-results-list"></ul>
    </div>
    <div class="no-results">
        <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
    </div>
</div>
</div>
               <!-- END CONTENT -->
           </div>
       </div>

          <label class="dark-mode-switch">
               <input type="checkbox">
               <span class="slider">
                    <svg class="slider-icon" viewBox="0 0 24 24" fill="none" height="20" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" width="20" xmlns="http://www.w3.org/2000/svg">
                    <path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"></path>
                    </svg>
               </span>
          </label>

       <script>
            var COMPODOC_CURRENT_PAGE_DEPTH = 1;
            var COMPODOC_CURRENT_PAGE_CONTEXT = 'miscellaneous-variables';
            var COMPODOC_CURRENT_PAGE_URL = 'variables.html';
            var MAX_SEARCH_RESULTS = 15;
       </script>

       <script src="../js/libs/custom-elements.min.js"></script>
       <script src="../js/libs/lit-html.js"></script>

       <script src="../js/menu-wc.js" defer></script>
       <script nomodule src="../js/menu-wc_es5.js" defer></script>

       <script src="../js/libs/bootstrap-native.js"></script>

       <script src="../js/libs/es6-shim.min.js"></script>
       <script src="../js/libs/EventDispatcher.js"></script>
       <script src="../js/libs/promise.min.js"></script>
       <script src="../js/libs/zepto.min.js"></script>

       <script src="../js/compodoc.js"></script>

       <script src="../js/tabs.js"></script>
       <script src="../js/menu.js"></script>
       <script src="../js/libs/clipboard.min.js"></script>
       <script src="../js/libs/prism.js"></script>
       <script src="../js/sourceCode.js"></script>
          <script src="../js/search/search.js"></script>
          <script src="../js/search/lunr.min.js"></script>
          <script src="../js/search/search-lunr.js"></script>
          <script src="../js/search/search_index.js"></script>
       <script src="../js/lazy-load-graphs.js"></script>


    </body>
</html>