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

heroku-wp-environment-sync

v0.3.9

Published

A heroku plugin to sync different wordpress environments.

Downloads

11

Readme

heroku-wp-environment-sync

A heroku plugin to sync different wordpress environments. Especially to sync databases, ya hear?

Requirements

  • Heroku cli (https://devcenter.heroku.com/articles/heroku-cli)
  • MySQL command line client
  • PHP

Installation

Installing the plugin is done by running this command:

heroku plugins:install heroku-wp-environment-sync

Usage

First you need to create syncfile.json in your project folder. You can create one from a template by running this command:

heroku sync:init

The initialization command will ask you questions and creates a syncfile according to those answers. The syncfile can (and probably have to) be modified by hand afterwards.

Then you need to edit your syncfile.json to correspond the different environments. The search and replaces can be added as many as needed and are defined as followed:

"replaces" : [
    {
        "from" : [
            "http://www.domain.com",
            "https://www.domain.com"
        ],
        "to" : "http://localhost"
    }
]

Every string in the "from" array is changed into the "to" string, so you can funnel multiple urls into one.

You can also use regular expression in the search and replace with the regex -option, like so:

"replaces" : [
    {
        "from" : [
            "https?:\\/\\/www\.domain\.com"
        ],
        "to" : "http://localhost",
        "regex" : true
    }
]

In the syncfile, you need to set the environments that you can sync to as mutable (unless you have specified the --no-mutable-checks -option). Like so:

{
    "name": "production",
    "app": "production_heroku_app_name"
},
{
    "name": "staging",
    "app": "staging_heroku_app_name",
    "mutable": true
}

Syncing

To sync your default setup (which, if you created the syncfile using heroku sync:init, is the local), use:

heroku sync:dbsync

If you want to specify the setup, use:

heroku sync:dbsync setup_name

You can also use --to and --from to specify locations, bypassing the setups entirely.

heroku sync:dbsync --from from_environment_name --to to_environment_name

Currently by default, the sync will store a dump to the cache folder which locates in ~/.heroku-wp-environment-sync/cache/. If for some reason you don't want to fetch a fresh dump (for instance, you might have an error in your syncfile search and replaces and after correcting the error you don't need a fresh dump) you can use --use-cache -flag.

Dumping

To dump a database from an environment in the syncfile, use:

heroku sync:dump environment_name

You can also specify just a app and bypass the syncfile:

heroku sync:dump --app heroku_app_name

Or you can just paste a mysql url, like so:

heroku sync:dump --mysql-url mysql://test:[email protected]/test_db

Connecting

To connect to a database, simply type:

heroku sync:connect environment_name

User configurations

User configurations are stored in the ~/.heroku-wp-environment-sync/user_config.json -file. At it's current state, there isn't really that much to configure except the dump caching. The available options are as follows:

{
    "store_cache" : true
}
  • store_cache defines if cache are stored. The cache folder is ~/.heroku-wp-environment-sync/cache/.

Help

You can get more information about different commands with the help command. For example:

heroku help sync:dbsync

Also for troubleshooting consider using the --verbose and --more-verbose -flags.

Changelog

0.3.1 / 4.9.2017

  • Added dump caching for situations where fresh database dump doesn't matter. You can utilize earlier dump by using the --use-cache -flag.
  • Added user configurations for future user specific configurations. For starters, you can modify if the script stores cache.

0.3.0 / 23.8.2017

  • Fixes to bugs conserning initialize and other stuff.
  • More notifications.

0.2.9 / 8.8.2017

  • Made changes to the library structure and refactored a bunch of stuff for the future.
  • Made error reporting more useful and added verbose mode and more-verbose mode for debugging uses.
  • Removed "show-command-outputs" -flag, because of the verbose additions.
  • Added notifications so that if you don't respond to a question in about 1 minute, it will notify you in case you forgot.
  • Added a new feature for cleaning up databases, that creates a home directory (~/.heroku-wp-environment-sync) and a temp database -file in there, that holds the temporary database names for later cleanup. This is useful for example if you exit the process before the cleanup happens, we can clean up the temporary database later.
  • Other bug fixes and changes.