Skip to content

Instantly share code, notes, and snippets.

@sammcj
Created November 20, 2022 00:36
Show Gist options
  • Save sammcj/e4984bcc731af3bf1ef51bead03d4887 to your computer and use it in GitHub Desktop.
Save sammcj/e4984bcc731af3bf1ef51bead03d4887 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