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 🙏

© 2025 – Pkg Stats / Ryan Hefner

diff-machines

v1.0.5

Published

diff files between machines

Downloads

10

Readme

diff-machines

diff files between machines over ssh.

Install

npm i maboiteaspam/diff-machines -g

Usage

diff-machines is a binary to install globally.


  diff files between machines over ssh.

  Usage
     diff-machines [hostA] [hostB] [files or services...]
     diff-machines [opts] -- [hostA] [hostB] [files or services...]

  Options
     -v    verbose
     -h    show help

 Examples
     diff-machines user@hostA:port user@hostB:port php .bashrc
     diff-machines -v -- vagrant vagrant php .bashrc
     diff-machines -h

Example

It will diff the service php and the file .bashrc between vagrant and vagrant boxes.

     diff-machines -v -- vagrant@localhost:2222 vagrant@localhost:2222 php .bashrc

The result is sent to stdout and produce unified patch with support of jsdiff

# node bin.js vagrant vagrant php .bashrc


Index: /etc/php.ini
===================================================================
--- /etc/php.ini
+++ /etc/php.ini



Index: .bashrc
===================================================================
--- .bashrc
+++ .bashrc

password credentials-like requires you to register the machine into a configuration file located on cwd. See below.

Then you must use its alias when you invoke diff-machines

     diff-machines -v -- vagrant vagrant php .bashrc

Configuration

diff-machines can read a configuration file located on cwd.

This file exports a function() which returns an object.

This configuration object can configure ssh hosts and services by name.

service are functions resolver which receives an sshConn of ssh2-utils and invoke call(err, filePath).

filePath is the location of the file identified for the given service.

configuration

{
    host1:{},
    host2:{},
    services:{
        service1: function (sshConn, done){ done(err, filePath); },
        service2: function (sshConn, done){ done(err, filePath); }
    },
}

In this example, php ini file is resolved with the help of the php binary itself. Cross-distro.

notFound, demonstrate that passing anything into err will effectively stop the program.

diff-svc.js


var SSH2  = require('ssh2-utils')

module.exports = function () {
  var ssh = new SSH2();
  return {
    'vagrant': {
      'host':'127.0.0.1',
      port: 2222,
      username: 'vagrant',
      password: 'vagrant'
    },
    'services': {
      'php': function (conn, done) {
        ssh.exec(conn, 'php -r "echo php_ini_loaded_file();"', function (err, stdout, stderr) {
          done(err, stdout)
        })
      },
      'notFound': function (conn, done) {
        done(false)
      }
    }
  }
};

Re-usable services

It s possible to pass in not service name of the local config object, rather than, module names.

So if one would export the php service to a module name php-ini, that would look like,

index.js


var SSH2  = require('ssh2-utils')
var ssh = new SSH2();

module.exports = function (conn, done) {
    ssh.exec(conn, 'php -r "echo php_ini_loaded_file();"', function (err, stdout, stderr) {
        done(err, stdout)
    });
}

It would then be possible to invoke diff-machines in such fashion


diff-machines -v -- vagrant vagrant php-ini .bashrc

Obviously you d need to npm i php-ini --save before that. Thus lock the remote dependency into a package json of your projects.

Dev

Kick-start your hacks like this,

git clone..
vagrant up
node bin.js vagrant vagrant php .bashrc
node bin.js -v -- vagrant vagrant php .bashrc

More

  • https://github.com/kpdecker/jsdiff
  • https://github.com/sindresorhus/multiline
  • https://github.com/mscdex/ssh2/
  • https://github.com/maboiteaspam/ssh2-utils
  • https://github.com/maboiteaspam/diff-machines/blob/master/diff-svc.js

ssh & vagrant

~/.ssh/config

Host localhost
  HostName 127.0.0.1
  Port 2222
  StrictHostKeyChecking no
  • http://serverfault.com/questions/6233/how-to-remove-strict-rsa-key-checking-in-ssh-and-whats-the-problem-here