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

deployerjs

v0.2.2

Published

Yet Another Deployement Tool : **soon™**

Downloads

14

Readme

DeployerJS

Yet Another Deployement Tool : soon™

Why Another Deployement Tool ?

Pure javascript, no binary needed on the local machine, forget about under-the-hood shellscript or rsync/ssh binary spawn. I just want to run this tool everywhere (even under windows, yes, windows) i can run NodeJS.

How to use it ?

CLI Overview
deployer update        <environement|group> [file]       # update remote to latest
deployer rollback      <environement|group> [file] [n]   # revert to [n]th last
deployer currrent      <environement|group> [file]       # output current release commit
deployer previous      <environement|group> [file]       # output previous release commit
deployer execute <cmd> <environement|group> [file]       # execute the given <cmd>
deployer list          <environement|group> [file]       # list previous deployements

CLI options

You can specify some options when using the CLI :

  • -d or --details when set to true, a file containing detailed logs of the deployement will be created in the current directory
  • -s [strategy] or --strategy [strategy] choose the strategy used to deploy, see below for explanation
  • -r [reporter] or --reporter [reporter] choose the reporter used to show deployement info, see below for explanation

Configuration

DeployerJS is based on the configuration architecture of PM2, so we represent a remote environnement like this (where production is the environnement name) :

{
  "production": {
      "user": "totallynotroot",                             // ssh user
      "host": "127.0.0.1:22"                                // host adress + ssh port
      "ref": "origin/master",                               // remote branch
      "repo": "[email protected]:vmarchaud/deployerjs.git",    // git repo
      "path": "/home/totallynotroot/myprod/",               // path where the deployement will be done 
      "passphrase" : true,                                  //  if my rsa key have a passphrase
      "post-deploy": "npm install",                         // will be executed after update on remote system
      "post-deploy-local": "touch deploy.done",             // will be executed after update on local system
      "env" : {                                             // all remote hooks will be executed with this env
        "NODE_ENV": "production"
      }
  }
 }

To list all environnements you have two choices, put the list at the root of the JSON document (like above) or specify deploy object that will list them (example here with a package.json file) :

  {
  "name": "myproject",
  "version": "0.0.1",
  "scripts": {
    ...
  },
  "dependencies": {
    ...
  },
  "deploy" : {              // here you can define the environnement entries
    "staging" : { ... },    // define here your staging environnement
    "production" : { ... }  // define here you production environnement
  }
}

Here are the principal options you can set in a environnement :

| Option key | Value Type | Default | Example | Description | | ---------: | -----------:| -------:| --------:| -----------:| | user | String | | root | username used to authenticate to the ssh server | | host | String or Array | | ['localhost:22'] or localhost | can contains port of the remote host, array may contains multiple hosts | | port | String or Number | 22 | 22 or "22" | port of the remote ssh server | | password | Boolean | false | true or false | set a password to connect | | privateKey | String | ~/.ssh/id_rsa | a valid path on local system | use a rsa key to connect | | passphrase | Boolean | false | true or false | set a passphrase to use the rsa key | | path | String ||| remote path where the deployement will be done | | group | String | | production | set the group of the environnement (usefull to deploy on a group of servers) | | path | String ||| remote path where the deployement will be done | | env | Object || { "NODE_ENV": "production" }| environnement used to execute remote hooks | | ssh_options | Object | | { "agent": "myagent_path" } | options for ssh see ssh2 connect doc |

Hooks

You can tell deployerjs to execute commands for you, we call them hooks, they can be run either on remote or local system, you just need an entry in the configuration (like the above example), here are the current hooks :

  • pre-setup & pre-setup-local
  • post-setup & post-setup-local
  • post-rollback & post-rollback-local
  • post-deploy & post-deploy-local

Deployement Strategy

Deployement action (like updating/rollbacking) are done via Strategy, the default is theGitStrategy that will simply use git on the remote server to execute all commands necessary to deploy the code, they use their own key/value configuration, so i split their configuration.

Available strategies (and the corresponding CLI option to use) :

  • GitStrategy (--strategy git)

GitStrategy

Configuration

| Option key | Value Type | Default | Example | Description | | ---------: | -----------:| -------:| --------:| -----------:| | ref | String | origin/master| any origin and branch separed by slash | Which remote and branch should be used | | branch | String | master | | branch used (override ref) | | origin | String | origin | | origin used (override ref) | | repo | String | | github.com/vmarchaud/deployer | Git repo URI |

Deployment Reporter

To display information relative to deployement, we use a reporter (just a class with some methods) that will handle display of information.

By default the StdReporter is used, it will just print all data to STDOUT.

Available reporters (and the corresponding CLI option to use) :

  • StdReporter (--reporter std)
  • SpinnerReporter (--reporter spinner)

Architecture

Because you want to know how to fork this and start hacking it :

soon™

Relevant documentation

  • ssh2 - the module used to connect over a SSH connection to the servers
  • ssh2-streams - the module used by ssh2 to implement some protocols (sftp mainly used here).

TODO:

  • More reporters
  • More strategies
  • Things to remember to fix :
    • [ ] git clone without host verified