GithubHelp home page GithubHelp logo

isabella232 / newspack-custom-content-migrator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from automattic/newspack-custom-content-migrator

0.0 0.0 0.0 997 KB

Custom migration tasks for launching and migrating Newspack sites on Atomic

PHP 98.11% Shell 1.89%

newspack-custom-content-migrator's Introduction

Newspack Custom Content Migrator

This plugin is a set of WP CLI commands (Migrator classes), and scripts (Recipes) used during Newspack sites Live Launches and/or Content Updates.

TOC

Installation

Run composer install.

Usage

Newspack Live Launch

The Plugin is installed on a Launch Site, and executed there, to import the most recent content from the current live site.

In Newspack's Live Launch workflow, we begin by creating the Staging Site. This is a Newspack site-in-development, initially crated as a clone of their current live site. The Staging site will become the Publisher's (client's) new live site.

Once the Staging site development is complete, it is cloned into the Launch Site. The Launch Site needs a content update from the original Live site, before it can be switched to live. And that is where this Plugin is executed -- on the Launch Site.

Newspack Staging Site Update

Staging Sites occasionally need to get their content refreshed. In that scenario, the Plugin gets installed on the Staging site (or a new updated clone of the Staging site), and the Update Recipe is executed here.

Migrators and Recipes

The Plugin consists of the Migrators which register WP CLI commands, and Recipe shell scripts which get to execute these commands in proper order.

Migrators

Migrators are simple PHP classes located in src/Migrator which register WP CLI Commands.

They contain logic/scripts to customize the content migration and update.

There's two kinds of Migrator classes:

  • General purpose -- located in src/Migrator/General, these contain the standard WP content update logic, used by multiple Live Launches;
  • Publisher-specific -- located in src/Migrator/PublisherSpecific, these are custom scripts for individual Publisher's specific needs. They are used only once during that particular Publisher's Launch.

Recipes

Recipes are shell scripts located in the cli_scripts/update_recipes, which execute the Migrator Commands in specific order.

The 0_UPDATE_RECIPE_TEMPLATE.sh always contains the most recent version of the Update Recipe.

They also contain some glue-logic, for example switching current DB tables to newly imported ones. But as a rule, the Recipes should be as thin as possible, and all the migration logic should go into the Migrators as new WP CLI commands.

Creating a Migrator

New Migrator Class

Take any existing migrator from the src/Migrator and copy it either into the src/Migrator/General or the src/Migrator/PublisherSpecific with a new name.

Migrator classes implement the InterfaceMigrator which simply makes sure they register WP CLI commands.

Register the New Migrator

The new Migrator should be registered in the newspack-custom-content-migrator.php.

After creating a new Migrator, run composer dump-autoload to update the autoloading files.

Creating a Recipe

As mentioned, the 0_UPDATE_RECIPE_TEMPLATE.sh always contains the most recent version of the Update Recipe.

Start by creating a copy of the 0_UPDATE_RECIPE_TEMPLATE.sh into the cli_scripts/update_recipes folder, and give it a custom name, e.g. update_publishername.sh.

Next, edit the configuration variables at the top of the script. The config vars in the Update Recipe script are self-documented, with comments above their definitions and examples.

Running the Update Recipe

Once you've created a custom Update Recipe in the cli_scripts/update_recipes folder, set proper file permissions, and execute the Recipe scipt.

Sharing the Recipes and Team Workflow

The current workflow is a simplest one, and consists of:

  • we keep generating PRs for every update to the Plugin, Migrators and Recipes,
  • we keep all the Migrators and all the individual Publishers' Recipe scripts on the master branch, so that it's easily shared between team members.

newspack-custom-content-migrator's People

Contributors

adekbadek avatar claudiulodro avatar eddiesshop avatar iuravic avatar jeffersonrabb avatar kariae avatar miguelpeixe avatar philipjohn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.