How to use the @octokit/rest function in @octokit/rest

To help you get started, we’ve selected a few @octokit/rest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MichaelJolley / io / services / api / src / github.ts View on Github external
private initializeOctokit(): Octokit {
    return new Octokit({
      auth: config.githubAuthToken,
      userAgent: config.githubUsername,
      // Comment this block and uncomment lower block for debugging
      // WARNING: ADDITIONAL INFO INCLUDES PERSONAL ACCESS TOKEN
      log: {
        debug: (message: any, info?: any) => log('debug', `Message: ${message}` ),
        info: (message: any, info?: any) => log('info', `Message: ${message}}` ),
        warn: (message: any, info?: any) => log('info', `Message: ${message}` ),
        error: (message: any, info?: any) => log('info', `Message: ${message}` )
      }
      /*log: {
        debug: (message: any, info?: any) => log('debug', `Message: ${message}, Additional Info: ${info ? JSON.stringify(info) : 'No additional Info'}` ),
        info: (message: any, info?: any) => log('info', `Message: ${message}, Additional Info: ${info ? JSON.stringify(info) : 'No additional Info'}` ),
        warn: (message: any, info?: any) => log('info', `Message: ${message}, Additional Info: ${info ? JSON.stringify(info) : 'No additional Info'}` ),
        error: (message: any, info?: any) => log('info', `Message: ${message}, Additional Info: ${info ? JSON.stringify(info) : 'No additional Info'}` )
      }*/
github danger / danger-js / source / platforms / github / GitHubAPI.ts View on Github external
getExternalAPI = (accessTokenForApp?: string): GitHubNodeAPI => {
    const host = process.env["DANGER_GITHUB_API_BASE_URL"] || undefined
    const options: GitHubNodeAPI.Options & { debug: boolean } = {
      debug: !!process.env.LOG_FETCH_REQUESTS,
      baseUrl: host,
      headers: {
        ...this.additionalHeaders,
      },
    }
    // A token should have been set by this point
    const token = accessTokenForApp || this.token!

    const api = new GitHubNodeAPI(options)
    api.authenticate({ type: "token", token: token })

    return api
  }
github ericclemmons / github-semantic-version / src / Github.js View on Github external
constructor(userRepo, apiOptions = {}) {
    this.defaultOptions = {
      owner: userRepo.user,
      repo: userRepo.repo,
    };

    this.github = new Github(apiOptions);

    // this buys you 5000 requests an hour in all but the Search API, where you get 30 requests/min
    const token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN;

    if (token) {
      this.github.authenticate({
        token: token,
        type: "oauth"
      });
    }
  }
github ZcashFoundation / zepio / scripts / release.js View on Github external
import '@babel/polyfill';
import fs from 'fs';
import path from 'path';
import cp from 'child_process';
import Octokit from '@octokit/rest';
import eres from 'eres';
import mime from 'mime-types';
import packageJson from '../package';

const DIST_FOLDER = path.join(__dirname, '..', './dist');
const VERSION = packageJson.version;
const GH_TOKEN = process.env.GH_TOKEN;
const OWNER = 'andrerfneves';
const PROJECT = 'zepio';

const octokit = new Octokit({ auth: GH_TOKEN });

const signBinaries = binaries => new Promise((resolve, reject) => {
  const signProcess = cp.spawn(`${__dirname}/codesign.sh`, binaries);
  signProcess.stdout.on('data', out => console.log('[Code Sign]', out.toString()));
  signProcess.on('exit', (code) => {
    if (code === 0) {
      resolve(path.join(__dirname, '..', 'signatures.zip'));
    } else {
      reject();
    }
  });
});

const getFileName = (name) => {
  const extension = name.substr(name.length - 3);
github azu / korefile / src / GitHubAdaptor.ts View on Github external
export const createGitHubAdaptor = (options: GitHubAdaptorOptions): KoreFileAdaptor => {
    const token = options.token || GITHUB_API_TOKEN;
    if (!token) {
        throw new Error(`token is not defined`);
    }
    const octKit = new Octokit({
        auth: token,
        type: "oauth",
        userAgent: "korefile"
    });
    const filledOptions = {
        owner: options.owner,
        repo: options.repo,
        ref: options.ref,
        forceUpdate: options.forceUpdate || false
    };
    return {
        readFile(filePath: string): Promise {
            return getContent(octKit, {
                repo: filledOptions.repo,
                owner: filledOptions.owner,
                path: filePath,
github chrismaltby / gb-studio / src / lib / helpers / updateChecker.js View on Github external
import { dialog, shell } from "electron";
import semver from "semver";
import Octokit from "@octokit/rest";
import settings from "electron-settings";
import meta from "../../../package.json";

const github = new Octokit();
const oneHour = 60 * 60 * 1000;

const cache = {
  latest: {
    value: null,
    timestamp: null
  }
};

export const getLatestVersion = async () => {
  const now = new Date().getTime();
  if (cache.latest.timestamp > now) {
    return cache.latest.value;
  }

  const latest = await github.repos.getLatestRelease({
github emyann / matron / packages / matron / src / templates / templates.list.ts View on Github external
export function githubClient() {
  const octokit = new Octokit();

  const owner = 'emyann';
  const repo = 'matron';
  const templatesLocation = 'packages/templates/src/';
  return {
    async downloadTemplate(templateName: string, directory: string) {
      const templatesDirectory: Response = await octokit.repos.getContents({
        owner,
        repo,
        path: templatesLocation
      });

      const templateDirectory = templatesDirectory.data.find(dir => dir.name === templateName);

      if (templateDirectory) {
        const result: Response = await octokit.git.getTree({
github hughrawlinson / github-repo-organizer / src / sagas / index.js View on Github external
export function* startLoadUser() {
  const accessToken = yield select(state => state.accessToken);

  octokit = new Octokit({
    auth: `token ${accessToken}`
  });

  const repo = {
    owner: 'hughrawlinson',
    repo: 'github-repo-organizer'
  };

  const {data} = yield call(() => octokit.users.getAuthenticated());
  if (data.login !== 'hughrawlinson') {
    try {
      yield call(() => octokit.activity.checkStarringRepo(repo));
    } catch (e) {
      yield call(() => octokit.activity.starRepo(repo));
    }
  }
github Azure / azure-sdk-for-js / .scripts / clean-autopr.ts View on Github external
export function getAuthenticatedClient(): Octokit {
    const octokit = new Octokit({ auth: getToken()});
    return octokit;
}
github atanasster / grommet-dashboard / components / github / GithubStats.js View on Github external
constructor() {
    this.github = Github();
  }
  catchError = apiCall => apiCall