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

smuggle

v1.0.4

Published

Webhook interceptor

Downloads

4

Readme

Smuggle

Install

$ npm i

Config

Generate a starter config.

$ smuggle init

Run

$ smuggle [--config smuggle.json]

Options

Example Config

{
    "repos": {
        "smuggle-test": {
            "type": "gitlab",
            "path": "/home/user/localhost/smuggle-test",
            "requiredHeaders": {
                "x-gitlab-event": "Pipeline Hook",
                "x-gitlab-token": "abc123"
            },
            "requiredProps": {
                "object_attributes.status": "success"
            },
            "reset": true,
            "action": "pull",
            "branch": "master",
            "postActions": [
                "echo 'Building application'",
                "npm run build",
                "echo 'Restarting PM2 instance'",
                "pm2 restart smuggle-test",
                "echo 'Cleaning up'",
                "sh /path/to/cleanup.sh"
            ]
        }
    }
}

| Key | Type | Required | Default | Description | ------------------------------- | ----------------------------- | -------- | ---------- | ------------- | repos | Object | Yes | - | One or more repository config | repos.{name} | Object | Yes | - | Name of the repo (key) and config options (value) | repos.{name}.type | Enum("gitlab", "github") | Yes | - | Type of Git hosting service | repos.{name}.path | String | Yes | - | Source location of the repo | repos.{name}.requiredHeaders | Object | No | {} | Optional required headers to expect from webhook | repos.{name}.requiredProps | Object | No | {} | Optional required body props to expect from webhook | repos.{name}.reset | Boolean | No | False | If a git reset --hard should be performed before updating repo | repos.{name}.action | Enum("pull", "fetch/merge") | No | "pull" | Type of operation to use when updating repo | repos.{name}.branch | String | No | "master" | Branch to perform action on | repos.{name}.postActions | Array[String] | No | [] | Optional, arbitrary commands to execute after updating repo

Running sudo Commands

Experimental

If you need to execute postActions as root, run Smuggle as a user with privileges.

# Run Smuggle as 'myuser', assuming there
# is a 'smuggle.json' in the same directory
$ su -c smuggle myuser

# Run Smuggle as 'myuser' with options
$ su - myuser -c 'smuggle --config "/path/to/smuggle.json"'

Testing via Docker

The Docker/Compose files will start a PM2 session. The example includes a client, server, and Smuggle instance. You can have your existing Docker setup run Smuggle, or modify the example to pull a different repository.

See example/environment.json for PM2 config.

Running the example with docker-compose build && docker-compose up will:

  • Clone the sample repo
  • Run NPM install
  • Build client assets (Webpack in this case)
  • Copy the Smuggle config to the container
  • Start the API server, client, and Smuggle via PM2

You can use something like LocalTunnel to temporarily get a HTTPS link to your container, and use that to test your webhook via GitLab or GitHub.

$ lt -p 3100 # Smuggle port for this example

TODO

  • Add option to verify os.hostname() matches payload's reported host
  • Handle sudo more intelligently