npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hubotbucket

v0.0.1

Published

Bitbucket API client plus Hubot scripts

Downloads

5

Readme

A Bitbucket API wrapper for Hubot

Build Status Dependency Status NPM version

Install

npm install hubotbucket

Require

Use it in your Hubot script:

module.exports = (robot) ->
  bitbucket = require('hubotbucket')(robot)

You can pass additional options to the constructor if needed.

Use

Make any call to the Bitbucket API and get the parsed JSON response:

bitbucket.get "1.0/repositories/you/your-repo/events", (events) ->
  console.log events.events[0].event

bitbucket.delete "1.0/users/you/ssh-keys/171052", (keys) ->
  console.log "deleted key " + keys[0].label

data = { "scm": "hg", "is_private": false, "description": "test repo" }
bitbucket.post "2.0/repostories/you/test", data, (repo) ->
  console.log repo.links.html.href

bitbucket.get "2.0/repositories/you/your-repo/pullrequests/20", (pr) ->
  pr.description = "a new description for an existsing PR"
  bitbucket.put pr.links.self.href, pr, (res) ->
    console.log "updated " + res.links.html.href

Authentication

You can make requests that don't need authentication without taking any special action. If you need to authenticate, you'll have to provide an OAuth consumer token in process.env.HUBOT_BITBUCKET_KEY and process.env.HUBOT_BITBUCKET_SECRET. If you don't yet have a token, you can create one from the "Integrated applications" tab of your user or team settings page. Just click the "Add consumer" button and fill the fields out however you like.

Helpful Hubot

If process.env.HUBOT_BITBUCKET_USER is present, we can help you guess a repo's full name:

bitbucket.qualifyRepo "hubotbucket" # => "elemecca/hubotbucket"

Similarly, if process.env.HUBOT_BITBUCKET_REPO is present its value will be used when no repo is given at all:

bitbucket.qualifyRepo() # => "elemecca/hubotbucket"

Options

Passing options

Options may be passed to hubotbucket in two different ways, in increasing order of precedence:

  1. Through shell environment variables.

  2. Through the constructor:

    bitbucket = require('hubotbucket')(robot, 'defaultUser': 'you') 

Available options

  • clientKey / process.env.HUBOT_BITBUCKET_KEY: Public half of the OAuth consumer token. Required to perform authenticated actions.

  • clientSecret / process.env.HUBOT_BITBUCKET_SECRET: Private half of the OAuth consumer token. Required to perform authenticated actions.

  • defaultUser / process.env.HUBOT_BITBUCKET_USER: Default username to use where one is not provided.

  • defaultRepo / process.env.HUBOT_BITBUCKET_REPO: Default repository to use where one is not provided. Must include the username.

  • apiRoot / process.env.HUBOT_BITBUCKET_API: The base API URL. Probably not useful.

  • concurrentRequests / process.env.HUBOT_CONCURRENT_REQUESTS: Limits the allowed number of concurrent requests to the Bitbucket API. Defaults to 20.

Contributing

Install the dependencies:

npm install

Pull requests encouraged!