Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
reposAddCollaborator: Promise.promisify(github.repos.addCollaborator),
pullRequestsCreate: Promise.promisify(github.pullRequests.create),
pullRequestsGetAll: Promise.promisify(github.pullRequests.getAll),
pullRequestsMerge: Promise.promisify(github.pullRequests.merge),
reposCreateHook: Promise.promisify(github.repos.createHook),
reposDeleteHook: Promise.promisify(github.repos.deleteHook),
reposFork: Promise.promisify(github.repos.fork),
reposGetCollaborators: Promise.promisify(github.repos.getCollaborators),
searchIssues: Promise.promisify(github.search.issues),
};
}
// Authorize the bot.
const bot = new GitHubApi({});
bot.authenticate({
type: "oauth",
token: process.env.GITHUB_TOKEN,
});
// An express middleware that adds a github api instance to the request for the currently
// authenticated user. If no user is logged in, the property isn't set.
function authedGithubInstance(req, res, next) {
req.github = {};
// Add the bot api instance to the request.
req.github.bot = constructor(bot);
// If a user is logged in, create an add a user instance.
if (req.user) {
const github = new GitHubApi({});
import GitHubApi from 'github';
import {constructor} from './github';
// Authorize the bot.
const bot = new GitHubApi({});
bot.authenticate({
type: "oauth",
token: process.env.GITHUB_TOKEN,
});
// An express middleware that adds a github api instance to the request for the currently
// authenticated user. If no user is logged in, the property isn't set.
export default function authedGithubInstance(req, res, next) {
req.github = {};
// Add the bot api instance to the request.
req.github.bot = constructor(bot);
// If a user is logged in, create an add a user instance.
if (req.user) {
const github = new GitHubApi({});
init(options) {
const api = new GitHub(options);
api.authenticate(options.authenticate);
start = options.content.start;
end = options.content.end;
this.api = api;
return this;
},
(async function() {
try {
let github = new GitHubApi({
version: "3.0.0",
debug: true
});
await authenticate(github);
await releaseCommit();
gulp.src(['package.json'], { base: '.' })
.pipe(gulp.dest(PATHS.APP));
let dists = await executable();
await zipExe(dists);
let {id} = await createRelease(github);
await uploadAsset(github, id, dists);
function newGithub(token) {
var api = new GitHubApi({
version: '3.0.0'
});
api.authenticate({
type: 'oauth',
token: token
});
return api;
};
export default ({githubConfig}) => {
const apiOpts = {
protocol: githubConfig.api.protocol,
host: githubConfig.api.host,
port: githubConfig.api.port,
version: githubConfig.api.version,
pathPrefix: githubConfig.api.pathPrefix,
timeout: githubConfig.api.timeout,
ca: (githubConfig.api.caFile ? fs.readFileSync(githubConfig.api.caFile) : undefined)
}
const defaultInstance = new GitHubApi(apiOpts)
if (githubConfig.token) {
defaultInstance.authenticate({type: 'oauth', token: githubConfig.token})
}
const Github = {
/**
* Create an authenticated instance of the GitHub API accessor.
*
* @param {String} authToken OAuth access token
* - If a user-specific token is not supplied, uses the master OAuth token
*/
getInstance (authToken) {
if (!authToken) return defaultInstance
const instance = new GitHubApi(apiOpts)
instance.authenticate({type: 'oauth', token: authToken})
checkNewRelease(cb) {
cb = cb ? cb : function() {};
try {
let api = new GitHubApi({
version: "3.0.0"
});
api.releases.listReleases({
owner: 'princejwesley',
repo: 'Mancy'
}, (err, data) => {
if(err) { return cb(); }
let {tag_name, assets} = data[0];
let assetName = `Mancy-${process.platform}-${process.arch}.zip`;
let asset = _.find(assets, (asset) => asset.name === assetName);
if(asset) {
this.latestRelease = {
url: asset.browser_download_url,
release: tag_name
};
}
import GithubAPI from 'github'
const {GITHUB_TOKEN} = process.env
const headers = {
'user-agent': 'approve-ci-bot'
}
const gh = new GithubAPI({
version: '3.0.0',
debug: false,
protocol: 'https',
host: 'api.github.com',
pathPrefix: '',
timeout: 5000,
headers
})
gh.authenticate({
type: 'oauth',
token: GITHUB_TOKEN
})
function responseHandler (resolve, reject) {
return function (err, response) {
constructor({ token, org }) {
this.api = new GitHubApi({
version: '3.0.0'
});
this.api.authenticate({
type: 'token',
token: token
});
this.org = org;
}