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

ghsync

v1.0.0

Published

Sync local git repository and remote GitHub repository automatically.

Downloads

60

Readme

ghsync

Travis npm version npm downloads

This is a cli tool to sync local git repository and remote GitHub repository automatically.

For example, if your tech team and biz team share some codebase, tech team wants to manage it with git (and GitHub) but biz team wants to edit files directly via FTP, right?

You can resolve this problem with ghsync.

  1. At first, initialize your codebase on the FTP server as a local git repository and push them to GitHub.
  2. Let ghsync observe your local git repository and remote GitHub repository by starting ghsync server.
  3. if your biz team edits files directly, ghsync automatically git add, git commit and git push.
  4. if your tech team pushes some commits to GitHub, ghsync catches the webhook and automatically git pull.

Additionally, if some auto-push and auto-pull conflict, ghsync stops observing soon and sends you a notification email. So you don't have to worry about that ghsync destroys your codebase.

Requirements

This tool requires local git version 1.7.9.6 or later for using --no-edit option for git pull.

Installation

$ npm install -g ghsync

Configuration

At first run ghsync init to generate configuration file in ~/.config/ghsync/default.yml with initial content and tailor this file.

$ ghsync init
$ vi ~/.config/ghsync/default.yml

Required properties

  • Remote GitHub repository's name
  • Local git repository directory's path
  • GitHub webhook secret

Optional properties

  • Some local sub directories' paths you want to ignore in observing
  • Port number for catching GitHub webhook
  • Commit interval (When many files are directly edited at one time, ghsync waits a moment to git commit so that prevents creating many commits uselessly)
  • Email notification related settings

Usage

At first, configure webhook on GitHub.

image

And start ghsync server on your server.

$ ghsync run

That's it.

When local git repository is directly edited ghsync commits it with message "Automatically committed". And When remote GitHub repository is updated ghsync pulls it soon.

Email notification

If some auto-push and auto-pull conflict, ghsync stops observing soon and sends you a notification email like below.

Subject: [ghsync] Error occurred in auto git-pull

[path]
/path/to/local/repo

[stdout]
Updating 40a9764..dc47ada

[stderr]
From github.com:owner/repo
 * branch            master     -> FETCH_HEAD
   40a9764..dc47ada  master     -> origin/master
error: Your local changes to the following files would be overwritten by merge:
        some/changed/file
Please, commit your changes or stash them before you can merge.
Aborting

Then you should go to your server and resolve conflict by hand, and commit and push it.

After you push it, auto-pull runs because remote GitHub repository is updated just now by you, and this pulling will get successful. Then, ghsync starts observing again automatically.

Daemonize

You may want to run ghsync on background. You can use Supervisor or something to do that. But especially for Node.js script it's one of the easiest way to use forever.

# install forever
$ npm install -g forever

# run ghsync via forever
$ forever start $(which ghsync) run

# confirm process is running
$ forever list
info:    Forever processes running
data:        uid  command             script                    forever pid   id logfile                      uptime
data:    [0] H7wO /usr/local/bin/node /usr/local/bin/ghsync run 59716   59726    /home/user/.forever/H7wO.log 0:0:0:2.636

You can stop daemon by like below.

$ forever stop 0

Please learn more at forever GitHub repository.