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

hubot-perforce

v0.1.3

Published

Hubot script for interacting with Perforce

Downloads

22

Readme

hubot-perforce

Build Status

Hubot script for receiving notifications from Perforce and interacting with Perforce.

THIS PROJECT IS IN AN EARLY STATE, USE AT YOUR OWN RISK

Installation

In hubot project repo, run:

npm install hubot-perforce --save

Then add hubot-perforce to your external-scripts.json:

["hubot-perforce"]

Quick Start

  1. Configure default p4

An instance of P4 is available at robot.p4. This instance needs to be configured for your Perforce server when Hubot starts. There are three different ways to accomplish this.

If you do nothing else, the default p4 will be configured using the standard Perforce environment variables (see the Perforce Manual for the details):

P4CHARSET  P4CLIENT   P4HOST
P4LANGUAGE P4PORT     P4USER

If you wish to override the standard Perforce environment variables, you may specify any of the following custom environment variables:

HUBOT_P4CHARSET  HUBOT_P4CLIENT   HUBOT_P4HOST
HUBOT_P4LANGUAGE HUBOT_P4PORT     HUBOT_P4USER

As a final alternative, you may configure the p4 instance at runtime:

module.exports = (robot) ->
  # Handle all notifications
  robot.on 'perforce:ready', (p4) ->
    p4.charset  = 'utf8'
    p4.client   = 'my-client'
    p4.host     = 'my-host'
    p4.port     = 'perforce:1666'
    p4.user     = 'me'

NOTE: It is expected, that the configured Perforce user will already be logged in when Hubot is started. If this is not the case, use the perforce:ready event to execute a P4.login as needed by your configuration.

  1. Configure Perforce trigger to notify Hubot

Use the p4 triggers command to notify hubot-perforce when a change is committed. In general, an HTTP POST to /hubot/perforce which the change number needs to be made. An example using curl is shown here:

hubot-perforce change-commit //... "curl -d 'change=%change' http://hubot.example.com/hubot/perforce"
  1. Listen for change events in your own code

hubot-perforce will emit a perforce:change event whenever a change is committed. That event will contain the full details of the change (as returned by p4 describe)

{ inspect } = require 'util'

module.exports = (robot) ->
  robot.on 'perforce:change', (change) ->
    robot.logger.info "Perforce Change: #{inspect change}"
[Wed Dec 03 2014 22:13:06 GMT-0800 (PST)] INFO Perforce Change: { code: 'stat',
change: 12345,
user: 'user',
client: 'client',
time: 1410399382,
desc: 'Change',
status: 'submitted',
changeType: 'public',
path: '//depot/path/...',
files:
[ { depotFile: '//depot/path/file.txt',
action: 'edit',
type: 'text',
rev: 42,
fileSize: 1024,
digest: 'C24816CC89E4B289F338F2FE87DC04A0' } ] }

P4 class

This section is intended to be an introduction to using robot.p4, but it has not been written yet.

  • All commands can be sent via p4.command which matches general p4 command line of form p4 [ options ] command [ arg ... ]

    opts = [ '-r', '3']
    command = 'opened'
    args = [ '-m', 100 ]
    robot.p4.command options, command, args, (error, output) ->
      robot.logger.info error
      robot.logger.info output
  • Convenience commands

    • p4.describe, p4.info, p4.istat, p4.streams, etc.
  • Response handling configuration

    • All default on, but can be turned off if needed/desired
    • p4.responseInfersType
    • p4.responseSingleElementArrayToObject
    • p4.responseOrganized
  • p4.maxBuffer defaults to 200KB, may need to be upped for many use cases