packages/github-client/docs/miscellaneous/variables.html
<!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> (src/.../index.ts)</a>
</li>
<li>
<a href="#getFile" title="src/helpers/utils.ts" ><b>getFile</b> (src/.../utils.ts)</a>
</li>
<li>
<a href="#gh" title="src/index.ts" ><b>gh</b> (src/.../index.ts)</a>
</li>
<li>
<a href="#isUserInOrg" title="src/helpers/utils.ts" ><b>isUserInOrg</b> (src/.../utils.ts)</a>
</li>
<li>
<a href="#leaveIssue" title="src/helpers/utils.ts" ><b>leaveIssue</b> (src/.../utils.ts)</a>
</li>
<li>
<a href="#log" title="src/index.ts" ><b>log</b> (src/.../index.ts)</a>
</li>
<li>
<a href="#main" title="src/index.ts" ><b>main</b> (src/.../index.ts)</a>
</li>
<li>
<a href="#org" title="src/index.ts" ><b>org</b> (src/.../index.ts)</a>
</li>
<li>
<a href="#repoCache" title="src/index.ts" ><b>repoCache</b> (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) => {
const readme = await getFile(gh, repo, "README.md")
if (!readme) {
log(repo, "Could not find a README")
return
}
const pp = /__Point People:__ (.*)/g
const pointMatches = readme.match(pp)
// http://stackoverflow.com/questions/1500260/detect-urls-in-text-with-javascript
const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
if (!pointMatches || pointMatches.length === 0) {
const contributors = await gh.rest.repos.getContributorsStats({owner: org, repo: repo.name})
log(repo, `No point person found, perhaps @${contributors.data[0].login}.`)
} else {
const ownerString = pointMatches[0] as string
const urls = ownerString.match(urlRegex) || []
const githubOwners = urls.filter(u => u.includes("github")).map(f => f.split("/").pop())
const slackUrls = urls.filter(u => u.includes("slack")).map(f => f.split("/").pop())
if (githubOwners.length === 0 && slackUrls.length === 0) {
log(repo, "Has no owners")
} else {
const usersNotInOrg: any[] = []
for (const owner of githubOwners) {
const inOrg = await isUserInOrg(gh, org, owner)
if (!inOrg) {
usersNotInOrg.push(owner)
}
}
if (usersNotInOrg.length) {
log(repo, "Found someone not in the org: " + 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: {"user-agent": "Org README checker"}})</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) => {
console.log(`[${repo}] - ${message}`)
}</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 () => {
let repoSets: any[]
if (fs.existsSync(repoCache)) {
repoSets = JSON.parse(fs.readFileSync(repoCache).toString())
} else {
repoSets = await getAllOrgRepos(gh, org)
fs.writeFileSync(repoCache, JSON.stringify(repoSets))
}
const repos = repoSets["data"]
const eigen = _.find(repos, r => r.name === "eigen")
// const gravity = _.find(repos, r => r.name === "gravity")
// const artsyD = _.find(repos, r => r.name === "artsy-danger")
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>`${process.env.GITHUB_ORG}`</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>`${process.env.CACHE_DIR}/repos.json`</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<string | null> => {
try {
const content = await gh.repos.getContent({
owner: repo.owner.login,
repo: repo.name,
path
})
const buffer = new Buffer(content.data.content, "base64")
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) => {
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) => {
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>