Skip to content

Instantly share code, notes, and snippets.

@stjordanis
Forked from sammcj/github_repo_settings.md
Created December 4, 2022 01:08
Show Gist options
  • Save stjordanis/f294c9bca941e10bb6d8915d100e61c8 to your computer and use it in GitHub Desktop.
Save stjordanis/f294c9bca941e10bb6d8915d100e61c8 to your computer and use it in GitHub Desktop.
trying out upg

"typescript" "manage and configure a list of Github repositories and their settings including branch protection rules"

$ upg

    __  ______  ____ _    UPG CLI
   / / / / __ \/ __ `/    Public Beta
  / /_/ / /_/ / /_/ /
  \__,_/ .___/\__, /      πŸ‡ΊπŸ‡Έ  Built by GPT Labs
      /_/    /____/       We put Leetcode out of business!
                          (c) 2022 MIT License


    Logged in.

    βœ” Checking subscription...

βœ” What language is this program written in? … typescript
βœ” What will this program do? … manage and configure a list of Github repositories and their settings including branch protection rules
var github = require('github-api');

// basic auth
var gh = new github({
   username: 'yourusername',
   password: 'yourpassword'
});

// or oauth
var gh = new github({
   token: 'yourtoken'
});

// or oauth key/secret
var gh = new github({
   key: 'yourkey',
   secret: 'yoursecret'
});

// list repositories
gh.getRepos().list(function(err, repos) {
   console.log(repos);
});

// get a specific repository
var repo = gh.getRepo('username', 'reponame');

// list branches
repo.listBranches(function(err, branches) {
   console.log(branches);
});

// get a specific branch
repo.getBranch('master', function(err, branch) {
   console.log(branch);
});

// create a new branch
repo.createBranch('newBranch', 'master', function(err, branch) {
   console.log(branch);
});

// delete a branch
repo.deleteBranch('newBranch', function(err) {
   console.log(err);
});

// protect a branch
repo.protectBranch('master', function(err) {
   console.log(err);
});

// unprotect a branch
repo.unprotectBranch('master', function(err) {
   console.log(err);
});

fail

"a tool to authenticate with the Mastodon API, then downloads all your content (toots, filters, profile, media, replies etc...) and backs it up"

βœ” What language is this program written in? … typescript
βœ” What will this program do? … a tool to authenticate with the Mastodon API, then downloads all your content (toots, filters, profile, media, replies etc...) and backs it up
var Mastodon = require('mastodon-api');
var fs = require('fs');

var M = new Mastodon({
  access_token: 'your-access-token',
  api_url: 'https://mastodon.social/api/v1/'
});

M.get('accounts/verify_credentials', {}, function(err, data, response) {
  if (err) {
    console.log(err);
  } else {
    console.log(data);
  }
});

fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment