Skip to content

Commit

Permalink
Inital commit (v0.1.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
dale42 committed May 3, 2020
0 parents commit 2728856
Show file tree
Hide file tree
Showing 16 changed files with 2,437 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor
/sitesync.phar
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Robo Site Sync

A Robo based utility designed to synchronize website content for MySQL based websites such as Drupal and WordPress. It's intended use is keeping local and development websites up-to-date with the live website.

## Overview

The utility is installed by placing the phar file in the computer path.

Sites are defined indivually with the _site_ command. The _pair_ command creates a synchronization pair. The _sync_ command is then used synchronize the destination site to source site.

The site and pair definition files are placed in a directory named .robo-site-sync in the account home directory. The site-sync utility has minimal assistance for maintaining these files. They are primarily maintained through a text editor.

### Example

The example below assumes the site-sync.phar file has not been placed in the system path.

- `php site-sync.phar site create source-site`
- `php site-sync.phar site create destination-site`
- edit the config files
- `php site-sync.phar pair my-sync-pair source-site destination-site`
- edit the config file
- `php site-sync.phar sync my-sync-pair`

## Installation

- Download the site-sync.phar file
- Check if it works:
`php site-sync.phar --help`
- To be able to type `site-sync`, instead of `php site-sync.phar`, you need to make the file executable and move it to somewhere in your PATH. For example:
`chmod +x site-sync.phar`
`mv site-sync.phar ~/bin/site-sync` or `sudo mv site-sync.phar /usr/local/bin/site-sync`
- Test for successful installation:
`site-sync --help`

## Development

### Setup

- git clone the repository
- cd into the project root
- run composer install

### Creating a New phar File

- cd to project root
- `composer build`

### Running from the Project

This is useful for testing code changes without recompiling the phar file

- cd to project root
- `php init.php {command}`

50 changes: 50 additions & 0 deletions build.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

$dir = dirname(__FILE__);

$exclude = [
'bin',
'build',
'data',
'docs',
'docs-api',
'tests',
'.gitattributes',
'.gitignore',
'.travis.yml',
'composer.json',
'composer.json.dev',
'composer.lock',
'composer.phar',
'phpcs.xml',
'phpdoc.xml',
'phpunit.xml.dist',
'README.md',
'.git',
'.idea',
'build.php'
];

$filter = function ($file, $key, $iterator) use ($exclude) {
if ($iterator->hasChildren() && !in_array($file->getFilename(), $exclude)) {
return true;
}
return $file->isFile() && !in_array($file->getFilename(), $exclude);
};

$iterator = new RecursiveIteratorIterator(
new RecursiveCallbackFilterIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
$filter
)
);

$phar = new Phar("sitesync.phar");
$phar->setSignatureAlgorithm(\Phar::SHA1);
$phar->startBuffering();
$phar->buildFromIterator($iterator, $dir);
//default executable
$phar->setStub(
"#!/usr/bin/php \n" . $phar->createDefaultStub('init.php')
);
$phar->stopBuffering();
19 changes: 19 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "vendor_name/package_name",
"description": "description_text",
"minimum-stability": "stable",
"license": "proprietary",
"require": {
"consolidation/robo": "^2.0"
},
"autoload":{
"psr-4":{
"RoboSiteSync\\":"src"
}
},
"scripts": {
"build": [
"@php build.php"
]
}
}
Loading

0 comments on commit 2728856

Please sign in to comment.