Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-kuendig committed May 6, 2019
2 parents f2ef44a + 045f6ac commit 68e959a
Show file tree
Hide file tree
Showing 31 changed files with 864 additions and 743 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ Works on Windows via `Ubuntu Bash` or `Git Bash`.

## Example project

Take a look at the [OFFLINE-GmbH/octobertricks.com](https://github.com/OFFLINE-GmbH/octobertricks.com) repo to see an example setup of oc-bootstrapper.
While using `oc-bootstrapper` it is a good idea to keep `october.yaml`, project's theme and project's plugins (those that are not shared among other projects) in project's repo.

Take a look at the [OFFLINE-GmbH/octobertricks.com](https://github.com/OFFLINE-GmbH/octobertricks.com) repo to see an example setup of `oc-bootstrapper`.

## Installation

Expand Down Expand Up @@ -83,6 +84,7 @@ cms:
theme: name (user@remote.git)
edgeUpdates: false
enableSafeMode: false
# project: XXXX # Marketplace project ID

database:
connection: mysql
Expand Down Expand Up @@ -179,8 +181,15 @@ If you want to update the installation you can run
```
october update
```
### Push changes to remote git repo
The command will update all plugins, the October CMS core and all composer dependencies.
To push local changes to the current git remote run
```
october push
```
This command can be run as cron job to keep your git repo up-to-date with changes on production.
### SSH deployments
Expand Down Expand Up @@ -215,8 +224,8 @@ This will setup a [`.gitlab-ci.yml`](templates/gitlab-ci.yml) and a [`Envoy.blad
If a deployed website is edited by a customer directly on the prod server you might want to commit
those changes back to your git repository.
To do this, simply create a cronjob that executes `git.cron.sh` every X minutes. This script will commit all changes
to your git repo automatically.
To do this, simply create a cronjob that executes `october push` every X minutes. This command will commit all changes
to your git repo automatically with message `[ci skip] Added changes from $hostname`.
### File templates
Expand All @@ -240,4 +249,4 @@ cd ~/.config/composer/october
git clone your-central-templates-repo.git .
git branch --set-upstream-to=origin/master master
git pull # Make sure this works without any user interaction
```
```
3 changes: 2 additions & 1 deletion october
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ if (file_exists(__DIR__.'/../../autoload.php')) {
require __DIR__.'/vendor/autoload.php';
}

$app = new Symfony\Component\Console\Application('October CMS Bootstrapper', '0.5.0');
$app = new Symfony\Component\Console\Application('October CMS Bootstrapper', '0.5.1');
$app->add(new \OFFLINE\Bootstrapper\October\Console\InitCommand);
$app->add(new \OFFLINE\Bootstrapper\October\Console\InstallCommand);
$app->add(new \OFFLINE\Bootstrapper\October\Console\UpdateCommand);
$app->add(new \OFFLINE\Bootstrapper\October\Console\PushCommand);
$app->run();
1 change: 1 addition & 0 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace OFFLINE\Bootstrapper\October\Config;


Expand Down
54 changes: 12 additions & 42 deletions src/Console/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace OFFLINE\Bootstrapper\October\Console;

use InvalidArgumentException;
use OFFLINE\Bootstrapper\October\Util\ManageDirectory;
use OFFLINE\Bootstrapper\October\Util\UsesTemplate;
use RuntimeException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -16,13 +17,13 @@
*/
class InitCommand extends Command
{
use UsesTemplate;
use UsesTemplate, ManageDirectory;

/**
* Configure the command options.
*
* @throws InvalidArgumentException
* @return void
* @throws InvalidArgumentException
*/
protected function configure()
{
Expand All @@ -35,19 +36,19 @@ protected function configure()
/**
* Execute the command.
*
* @param InputInterface $input
* @param OutputInterface $output
* @param InputInterface $input
* @param OutputInterface $output
*
* @throws RuntimeException
* @return mixed
* @throws RuntimeException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('<info>Creating project directory...</info>');

$dir = getcwd() . DS . $input->getArgument('directory');
$dir = $this->pwd() . $input->getArgument('directory');

$this->createWorkingDirectory($dir);
$this->mkdir($dir);

$output->writeln('<info>Updating template files...</info>');
$this->updateTemplateFiles();
Expand All @@ -57,45 +58,14 @@ protected function execute(InputInterface $input, OutputInterface $output)

$output->writeln('<info>Creating default october.yaml...</info>');

if (file_exists($target)) {
if ($this->fileExists($target)) {
return $output->writeln('<comment>october.yaml already exists: ' . $target . '</comment>');
}

$this->copyYamlTemplate($template, $target);
$this->copy($template, $target);

$output->writeln('<comment>Done! Now edit your october.yaml and run october install.</comment>');

return true;
}

/**
* @param $dir
*
* @throws \RuntimeException
*/
protected function createWorkingDirectory($dir)
{
if ( ! @mkdir($dir) && ! is_dir($dir)) {
throw new RuntimeException('Cannot create target directory: ' . $dir);
}
}

/**
* @param $template
* @param $target
*
* @throws \RuntimeException
*/
protected function copyYamlTemplate($template, $target)
{
if ( ! file_exists($template)) {
throw new RuntimeException('Cannot find october.yaml template: ' . $template);
}

copy($template, $target);

if ( ! file_exists($target)) {
throw new RuntimeException('october.yaml could not be created');
}
}
}
}
Loading

0 comments on commit 68e959a

Please sign in to comment.