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

reckless-node-perforce

v1.0.6

Published

Simplified fork of node-perforce with vulnerable dependencies removed and fixed commands

Downloads

89

Readme

reckless-node-perforce

A simplified fork of node-perforce with vulnerable dependencies removed and fixed commands.

Install

npm install reckless-node-perforce

Examples using callback syntax:

var p4 = require('reckless-node-perforce');

// create a new changelist
p4.changelist.create({description: 'hello world'}, function (err, changelist)
{
  if (err) return console.log(err);
  console.log('changelist:', changelist);
});

// revert files
p4.revert({files: ['*.bin']}, function(err)
{
  if (err) return console.log(err);
});

Now also supporting simpler await syntax - more examples:

var p4 = require('reckless-node-perforce');

try
{
  // create a new changelist
  let changelist = await p4.awaitCommand('changelist.create', {description: 'Hello world!'});
  console.log(`Changelist is ${changelist}.`);

  // view changelist info
  let info = await p4.awaitCommand('changelist.view', {changelist: changelist});

  // edit changelist 1234
  let editResult = await p4.awaitCommand('changelist.edit', {changelist: 1234, description: 'Hi'});

  // delete changelist 1234
  let deleteResult = await p4.awaitCommand('changelist.delete', {changelist: 1234});

  // add files to changelist 1234
  let addResult = await p4.awaitCommand('add', {
    changelist: 1234, filetype: 'binary', files: ['*.bin']});

  // check out files
  let editResult = await p4.awaitCommand('edit', {files: ['*.js']});
}
catch (err)
{
  return console.log(err);
}

Important note on how to use Perforce command options

To understand how to construct standard Perforce commands using this library's syntax, look at the option translations listed in the p4options.js file. Below is a list of those Perforce options followed by the options object format needed to use them in this library as parameters for your Perforce commands.

Unary options (no value needed) should simply have a value of true when you pass them. Other options show the value type that is expected, e.g. changelists are expected to be provided as Numbers, not Strings.

-am: {acceptmerged: true}
 -d: {delete: true}
 -c: {changelist: NumberValue}
 -s: {shelved: NumberValue}
 -S: {stream: StringValue}
 -t: {filetype: StringValue}
 -f: {force: true}
 -s: {switch: true}
 -a: {unchanged: true}
 -m: {max: NumberValue}
 -c: {client: StringValue}
 -l: {long: true}
 -L: {trunk: true}
 -s: {status: StringValue}
 -t: {time: true}
 -u: {user: StringValue}
 '': {custom: StringValue}      (any provided string will be appended to the initial command)
     {files: [StringValues]}    (provided array of file paths as strings will be used)
     {description: StringValue} (description is inserted for the new/edited changelist with stdin)

Debugging:

A debug option has been added to make it easier to see what commands are being run. Its output looks like this:

[P4 DEBUG] p4.exe edit -c 109 -t text //depot/MyFileName.json

To use it, simply call p4.setDebugMode(true) after requiring the library:

var p4 = require('reckless-node-perforce');

p4.setDebugMode(true);