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

npm-deploy-sync

v1.0.14

Published

Deploy compiled code to server using rsync on linux

Downloads

6

Readme

Deploy - sync for Node using rsync.

The library will allow deploying compiled code on a remote server using credentials and rsync and its options.

  • Any version prior to 1.0.6 is not functionnal, not recommended, not supported; but the wrapper for Rsync is functionnal.

ChangeLog:

Version 1.0.7: Fixed Rsync wrapper and created DeploySync with config loading, deployment and reporting.

Version 1.0.8: Added handling of cleartext and gpg authentication, using sshpass and gpg in linux.


USAGE

Here is an example of a simple deployment

DeploySync.loadConfigFromFile('deploy.conf.json');

const myDeployment = DeploySync.newDeployment('local-testing', 'localtest');
myDeployment.execute().then((deployment: Deployment) => {
    let res = deployment.getResults();
    console.log(res);
    DeploySync.listDeployments();
});
  1. We load the config from a file. (here deploy.conf.json located in the current working directory)
  2. We create a new deployment... First argument is the name we want to give it, second argument is the deployment model from the config. (The abstract deployment (deployer) on which it will be based) [A concrete deployment is an instance in time of the abstract deployment specified by the config, a concrete deployment is immutable, always new and can be modified before execution, it will always result in a new deployment with results]
  3. Then we execute the deployment and wait for the results.
  4. Once we get the results, we log them.
  5. We also here list all the deployments till now in this session.

Here is the configuration file used (deploy.conf.json)

{
  "users": [
    {
      "username": "my_username",
      "comment": "Local user",
      "type": "normal",
      "group": "my_group"
    }
  ],
  "sources": [
    {
      "id": "localdata",
      "comment": "local test data",
      "path": "/home/bchwalek/testdata/"
    }
  ],
  "destinations": [
    {
      "id": "tmp",
      "comment": "Temporary",
      "path": "/home/my_username/tmp/"
    }
  ],
  "options": [
    {
      "id": "update",
      "config": {
        "exclude": ["assets/stub/**"],
        "verbose": true,
        "update": true,
        "archive": true
      }
    },
    {
      "id": "create",
      "config": {
        "exclude": ["assets/stub/**"],
        "verbose": true,
        "archive": true
      }
    }
  ],
  "servers": [
    {
      "id": "local",
      "comment": "localhost loop",
      "location": "here",
      "responsible": "",
      "host": "127.0.0.1"
    }
  ],
  "deployments": [
    {
      "id": "localtest",
      "comment": "A local loop test",
      "server": "local",
      "source": "localdata",
      "dest": "tmp",
      "options": "update",
      "user": "my_username"
    }
  ]
}
  1. A full configuration is a json, is a set of arrays with the following keys:
    1. users : a list of different users we can use.
    2. sources : a list of sources (paths from, on the local server)
    3. destinations : a list of destinations (paths to, on the remote server)
    4. options : the options provided to the executor (Rsync here)
    5. servers : a list of remote servers/hosts to which we will sync
    6. deployments : a list of compatible configurations or combinations of these 5 variables we wish to base our deployments on, these are abstract deployments which will become concrete as we use them (reconfigure, deploy in time and get results)
  2. The configuration can be split in different files.
  3. The configuration can be create dynamically without using files.
  4. The configuration file must be json and respect he structure in order to be loaded properly.
  5. For now, Rsync is not fully implemented, so not all options are available, please feel free to fork and contribute.
  6. Other executors can be implemented (scp?)

Security and authentication

Authentication, added in 1.0.8

Is either cleartext, gpg or you usual pub/priv key pairs as rsync uses ssh by default.

  • npm-deploy-sync is dependant on some Linux libraries
  • The default executor for deployments is Rsync, so please have rsync installed
  • For automated authentication using passwords, have sshpass installed
  • If you specify a .gpg file, gpg will be used in combination with sshpass for rsync
  • SECURITY: preferably do not use cleartext passwords, but priv/pub keys or at least gpg

In the configuration here is the user structure:


  "users": [
    {
      "username": "insecureuser",
      "comment": "General user",
      "type": "normal",
      "group": "users",
      "authentication": {
        "password": "mycleartextpasswordinsecurehere"
      }
    },
    {
      "username": "secureduser",
      "comment": "Local user",
      "type": "normal",
      "group": "users",
      "authentication": {
        "file": ".pass.gpg"
      }
    }
  ]

I am relying on the premise that you should know how to secure your local passwords and use the most secure connection you can in your situation, hence know how to use pub/private keys and/or gpg. Cleartext is provided as convenience when you feel you just need to get it done and will not leave the passwords in the conf file...