diff --git a/PHPCI/Application.php b/PHPCI/Application.php index 1c89c44e..bfae830c 100644 --- a/PHPCI/Application.php +++ b/PHPCI/Application.php @@ -65,7 +65,7 @@ class Application extends b8\Application $this->response->setContent(''); } else { $this->response = new RedirectResponse($this->response); - $this->response->setHeader('Location', '/session/login'); + $this->response->setHeader('Location', PHPCI_URL.'session/login'); } return false; diff --git a/PHPCI/Controller/SessionController.php b/PHPCI/Controller/SessionController.php index b6fd0a43..4dd87d81 100644 --- a/PHPCI/Controller/SessionController.php +++ b/PHPCI/Controller/SessionController.php @@ -21,7 +21,7 @@ class SessionController extends \PHPCI\Controller { public function init() { - $this->response->disableLayout(); + $this->response->disableLayout(); $this->_userStore = b8\Store\Factory::getStore('User'); } @@ -29,7 +29,7 @@ class SessionController extends \PHPCI\Controller * Handles user login (form and processing) */ public function login() - { + { if ($this->request->getMethod() == 'POST') { $user = $this->_userStore->getByEmail($this->getParam('email')); @@ -42,7 +42,7 @@ class SessionController extends \PHPCI\Controller $form = new b8\Form(); $form->setMethod('POST'); - $form->setAction('/session/login'); + $form->setAction(PHPCI_URL.'session/login'); $email = new b8\Form\Element\Email('email'); $email->setLabel('Email Address'); diff --git a/PHPCI/Controller/UserController.php b/PHPCI/Controller/UserController.php index 0a814b9c..92f1ed46 100644 --- a/PHPCI/Controller/UserController.php +++ b/PHPCI/Controller/UserController.php @@ -129,7 +129,7 @@ class UserController extends \PHPCI\Controller { $form = new Form(); $form->setMethod('POST'); - $form->setAction('/user/' . $type); + $form->setAction(PHPCI_URL.'user/' . $type); $form->addField(new Form\Element\Csrf('csrf')); $field = new Form\Element\Email('email'); diff --git a/PHPCI/Plugin/Grunt.php b/PHPCI/Plugin/Grunt.php new file mode 100644 index 00000000..892d8303 --- /dev/null +++ b/PHPCI/Plugin/Grunt.php @@ -0,0 +1,56 @@ + +* @package PHPCI +* @subpackage Plugins +*/ +class Grunt implements \PHPCI\Plugin +{ + protected $directory; + protected $task; + protected $preferDist; + protected $phpci; + protected $grunt; + protected $gruntfile; + + public function __construct(\PHPCI\Builder $phpci, array $options = array()) + { + $path = $phpci->buildPath; + $this->phpci = $phpci; + $this->directory = isset($options['directory']) ? $path . '/' . $options['directory'] : $path; + $this->task = isset($options['task']) ? $options['task'] : null; + $this->grunt = isset($options['grunt']) ? $options['grunt'] : 'grunt'; + $this->gruntfile = isset($options['gruntfile']) ? $options['gruntfile'] : 'Gruntfile.js'; + } + + /** + * Executes grunt and runs a specified command (e.g. install / update) + */ + public function execute() + { + // if npm does not work, we cannot use grunt, so we return false + if ( !$this->phpci->executeCommand( 'cd %s && npm install', $this->directory ) ) { + return false; + } + + // build the grunt command + $cmd = 'cd %s && ' . $this->grunt; + $cmd .= ' --no-color'; + $cmd .= ' --gruntfile %s'; + $cmd .= ' %s'; // the task that will be executed + + // and execute it + return $this->phpci->executeCommand($cmd, $this->directory, $this->gruntfile, $this->task); + } +} diff --git a/README.md b/README.md index aa1eff8a..917ec901 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ _**Please be aware that PHPCI is a beta-release project, so whilst it is very st ####Installing from Github: * Step 1: `git clone https://github.com/Block8/PHPCI.git` * Step 2: `cd PHPCI` -* Step 3: `chmod +x ./console && ./console phpci:install` +* Step 3: `composer install` +* Step 4: `chmod +x ./console && ./console phpci:install` * When prompted, enter your database host, username, password and the database name that PHPCI should use. * The script will attempt to create the database if it does not exist already. * If you intend to use the MySQL plugin to create / destroy databases, the user you entered above will need CREATE / DELETE permissions on the server. @@ -51,7 +52,7 @@ _**Please be aware that PHPCI is a beta-release project, so whilst it is very st **Apache Example**: RewriteEngine On - RewriteBase /path-to-phpci + RewriteBase /path-to-phpci/public RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*)? index.php [L,E=PATH_INFO:/$1] @@ -103,6 +104,8 @@ Similar to Travis CI, to support PHPCI in your project, you simply need to add a standard: "PSR2" php_cpd: allow_failures: true + grunt: + task: "build" complete: mysql: diff --git a/console b/console index f571c454..dd71d058 100755 --- a/console +++ b/console @@ -14,14 +14,9 @@ define('ENABLE_SHELL_PLUGIN', false); // If this is the first time ./console has been run, we probably don't have Composer or any of our dependencies yet. // So we need to install and run Composer. -if (!file_exists(PHPCI_DIR . 'vendor/autoload.php') || !file_exists(PHPCI_DIR . 'composer.phar')) { - print 'INSTALLING: Composer' . PHP_EOL; - file_put_contents(PHPCI_DIR . 'composerinstaller.php', file_get_contents('https://getcomposer.org/installer')); - shell_exec('php ' . escapeshellarg(PHPCI_DIR . 'composerinstaller.php')); - unlink(PHPCI_DIR . 'composerinstaller.php'); - - print 'RUNNING: Composer' . PHP_EOL; - shell_exec('php '.escapeshellarg(PHPCI_DIR.'composer.phar').' install'); +if (!file_exists(PHPCI_DIR . 'vendor/autoload.php')) { + file_put_contents('php://stderr', 'Please install PHPCI with "composer install" before using console'); + exit( 1 ); } require('bootstrap.php'); diff --git a/assets/css/bootstrap.min.css b/public/assets/css/bootstrap.min.css similarity index 100% rename from assets/css/bootstrap.min.css rename to public/assets/css/bootstrap.min.css diff --git a/assets/css/phpci.css b/public/assets/css/phpci.css similarity index 84% rename from assets/css/phpci.css rename to public/assets/css/phpci.css index cfb886d4..71071625 100644 --- a/assets/css/phpci.css +++ b/public/assets/css/phpci.css @@ -57,22 +57,22 @@ td .label { margin-right: 5px; } .icon-build-ok { - background: url('/assets/img/icon-build-ok.png') no-repeat top left; + background: url('../img/icon-build-ok.png') no-repeat top left; } .icon-build-failed { - background: url('/assets/img/icon-build-failed.png') no-repeat top left; + background: url('../img/icon-build-failed.png') no-repeat top left; } .icon-build-pending { - background: url('/assets/img/icon-build-pending.png') no-repeat top left; + background: url('../img/icon-build-pending.png') no-repeat top left; } .icon-build-running { - background: url('/assets/img/icon-build-running.png') no-repeat top left; + background: url('../img/icon-build-running.png') no-repeat top left; } h3 diff --git a/assets/img/build-failed.png b/public/assets/img/build-failed.png similarity index 100% rename from assets/img/build-failed.png rename to public/assets/img/build-failed.png diff --git a/assets/img/build-ok.png b/public/assets/img/build-ok.png similarity index 100% rename from assets/img/build-ok.png rename to public/assets/img/build-ok.png diff --git a/assets/img/glyphicons-halflings-white.png b/public/assets/img/glyphicons-halflings-white.png similarity index 100% rename from assets/img/glyphicons-halflings-white.png rename to public/assets/img/glyphicons-halflings-white.png diff --git a/assets/img/glyphicons-halflings.png b/public/assets/img/glyphicons-halflings.png similarity index 100% rename from assets/img/glyphicons-halflings.png rename to public/assets/img/glyphicons-halflings.png diff --git a/assets/img/icon-build-failed.png b/public/assets/img/icon-build-failed.png similarity index 100% rename from assets/img/icon-build-failed.png rename to public/assets/img/icon-build-failed.png diff --git a/assets/img/icon-build-ok.png b/public/assets/img/icon-build-ok.png similarity index 100% rename from assets/img/icon-build-ok.png rename to public/assets/img/icon-build-ok.png diff --git a/assets/img/icon-build-pending.png b/public/assets/img/icon-build-pending.png similarity index 100% rename from assets/img/icon-build-pending.png rename to public/assets/img/icon-build-pending.png diff --git a/assets/img/icon-build-running.png b/public/assets/img/icon-build-running.png similarity index 100% rename from assets/img/icon-build-running.png rename to public/assets/img/icon-build-running.png diff --git a/assets/js/bootstrap.min.js b/public/assets/js/bootstrap.min.js similarity index 100% rename from assets/js/bootstrap.min.js rename to public/assets/js/bootstrap.min.js diff --git a/assets/js/phpci.js b/public/assets/js/phpci.js similarity index 100% rename from assets/js/phpci.js rename to public/assets/js/phpci.js diff --git a/index.php b/public/index.php similarity index 91% rename from index.php rename to public/index.php index a0b81e9d..e1754b62 100644 --- a/index.php +++ b/public/index.php @@ -12,7 +12,7 @@ session_start(); error_reporting(E_ALL); ini_set('display_errors', 'on'); -require_once('bootstrap.php'); +require_once('../bootstrap.php'); $fc = new PHPCI\Application($config, new b8\Http\Request()); print $fc->handleRequest();