Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
vagrant committed Jun 19, 2015
2 parents deb4d98 + a69bc23 commit e7bc093
Show file tree
Hide file tree
Showing 131 changed files with 1,430 additions and 436 deletions.
5 changes: 3 additions & 2 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
$finder = Symfony\Component\Finder\Finder::create()
->files()
->in('app')
->in('database')
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
Expand All @@ -17,13 +18,13 @@ $fixers = [
'concat_with_spaces',
'double_arrow_multiline_whitespaces',
'duplicate_semicolon',
'-empty_return', // FIXME: There are a couple of places where return null is used
'empty_return',
'extra_empty_lines',
'include',
'join_function',
'list_commas',
'indentation',
'-multiline_array_trailing_comma',
'multiline_array_trailing_comma',
'namespace_no_leading_whitespace',
'no_blank_lines_after_class_opening',
'no_empty_lines_after_phpdocs',
Expand Down
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Stephen Ball

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![PHP Dependency Status](https://www.versioneye.com/user/projects/5531329410e7141211000f29/badge.svg)](https://www.versioneye.com/user/projects/5531329410e7141211000f29)
[![Nodge Dependency Status](https://www.versioneye.com/user/projects/5531329610e714f9e500109c/badge.svg)](https://www.versioneye.com/user/projects/5531329610e714f9e500109c)
[![Latest Version](https://img.shields.io/github/release/REBELinBLUE/deployer.svg)](https://github.com/REBELinBLUE/deployer/releases)
[![License](https://img.shields.io/github/license/rebelinblue/deployer.svg)](https://github.com/REBELinBLUE/deployer/blob/master/LICENSE.md)

**Development**

Expand All @@ -19,7 +20,7 @@ The code is written to follow PSR-2 standards, this can be tested using PHP_Code

Code mess can be checked with

$ phpmd app text design,unusedcode,naming
$ phpmd app text design,unusedcode,naming,codesize

PHP Docblocks can be checked with

Expand Down
12 changes: 6 additions & 6 deletions app/CheckUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CheckUrl extends Model
* @var array
*/
protected $casts = [
'is_report' => 'boolean'
'is_report' => 'boolean',
];

/**
Expand Down Expand Up @@ -66,11 +66,11 @@ public function notificationPayload()
[
'title' => Lang::get('notifications.project'),
'value' => sprintf('<%s|%s>', url('project', $this->project_id), $this->project->name),
'short' => true
]
]
]
]
'short' => true,
],
],
],
],
];

return $payload;
Expand Down
2 changes: 1 addition & 1 deletion app/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Command extends Model
*/
protected $casts = [
'step' => 'integer',
'optional' => 'boolean'
'optional' => 'boolean',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Kernel extends ConsoleKernel
*/
protected $commands = [
\App\Console\Commands\CheckHeartbeats::class,
\App\Console\Commands\CheckUrl::class
\App\Console\Commands\CheckUrl::class,
];

/**
Expand Down
2 changes: 1 addition & 1 deletion app/DeployStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DeployStep extends Model implements PresentableInterface
*/
protected $casts = [
'stage' => 'integer',
'optional' => 'boolean'
'optional' => 'boolean',
];

/**
Expand Down
12 changes: 11 additions & 1 deletion app/Deployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ public function isSuccessful()
return ($this->status === self::COMPLETED);
}

/**
* Determines whether the deployment failed.
*
* @return bool
*/
public function isFailed()
{
return ($this->status === self::FAILED);
}

/**
* Determines if the deployment is the latest deployment.
*
Expand All @@ -144,7 +154,7 @@ public function isCurrent()
public function runtime()
{
if (!$this->finished_at) {
return null;
return;
}

return $this->started_at->diffInSeconds($this->finished_at);
Expand Down
2 changes: 1 addition & 1 deletion app/Events/ModelTrashed.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct($model, $channel)
{
$this->model = [
'id' => $model->id,
'project_id' => $model->project_id
'project_id' => $model->project_id,
];

$this->channel = $channel;
Expand Down
2 changes: 1 addition & 1 deletion app/Events/ServerLogChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(ServerLog $log)
$this->finished_at = $log->finished_at ? $log->finished_at->toDateTimeString() : null;
$this->log_id = $log->id;
$this->output = ((is_null($log->output) || !strlen($log->output)) ? null : '');
$this->runtime = (is_null($log->runtime()) ? null : $log->getPresenter()->readable_runtime);
$this->runtime = (!$log->runtime() ? null : $log->getPresenter()->readable_runtime);
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Group extends Model
public function projects()
{
return $this->hasMany('App\Project')
->notTemplates()
->orderBy('name');
}

Expand Down
14 changes: 7 additions & 7 deletions app/Heartbeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Heartbeat extends Model
*/
protected $casts = [
'status' => 'integer',
'deploy_code' => 'boolean'
'deploy_code' => 'boolean',
];

/**
Expand Down Expand Up @@ -154,15 +154,15 @@ public function notificationPayload()
[
'title' => Lang::get('notifications.project'),
'value' => sprintf('<%s|%s>', url('project', $this->project_id), $this->project->name),
'short' => true
'short' => true,
], [
'title' => Lang::get('heartbeats.last_check_in'),
'value' => $heard_from,
'short' => true
]
]
]
]
'short' => true,
],
],
],
],
];

return $payload;
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Composers/NavigationComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function compose(View $view)
{
$active_group = null;
$active_project = null;
if (isset($view->project)) {

if (isset($view->project) && !$view->project->is_template) {
$active_group = $view->project->group_id;
$active_project = $view->project->id;
}
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Admin/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests;
use App\Http\Requests\StoreGroupRequest;
use App\Repositories\Contracts\GroupRepositoryInterface;
use Lang;
Expand Down Expand Up @@ -41,7 +40,7 @@ public function index()
{
return view('groups.listing', [
'title' => Lang::get('groups.manage'),
'groups' => $this->groupRepository->getAll()
'groups' => $this->groupRepository->getAll(),
]);
}

Expand Down
22 changes: 17 additions & 5 deletions app/Http/Controllers/Admin/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
use App\Http\Controllers\Controller;
use App\Http\Requests;
use App\Http\Requests\StoreProjectRequest;
use App\Jobs\SetupProject;
use App\Project;
use App\Repositories\Contracts\ProjectRepositoryInterface;
use App\Repositories\Contracts\TemplateRepositoryInterface;
use Lang;

/**
Expand All @@ -20,13 +22,16 @@ class ProjectController extends Controller
* @param ProjectRepositoryInterface $projectRepository
* @return Response
*/
public function index(ProjectRepositoryInterface $projectRepository)
{
public function index(
ProjectRepositoryInterface $projectRepository,
TemplateRepositoryInterface $templateRepository
) {
$projects = $projectRepository->getAll();

return view('projects.listing', [
'title' => Lang::get('projects.manage'),
'projects' => $projects->toJson() // Because PresentableInterface toJson() is not working in the view
'title' => Lang::get('projects.manage'),
'templates' => $templateRepository->getAll(),
'projects' => $projects->toJson(), // Because PresentableInterface toJson() is not working in the view
]);
}

Expand All @@ -48,6 +53,13 @@ public function store(StoreProjectRequest $request)
'build_url'
));

if ($request->has('template_id')) {
$this->dispatch(new SetupProject(
$project,
$request->template_id
));
}

return $project;
}

Expand Down Expand Up @@ -84,7 +96,7 @@ public function destroy(Project $project)
$project->delete();

return [
'success' => true
'success' => true,
];
}
}
96 changes: 96 additions & 0 deletions app/Http/Controllers/Admin/TemplateController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\StoreTemplateRequest;
use App\Repositories\Contracts\TemplateRepositoryInterface;
use Lang;

/**
* Controller for managing deployment template.
*/
class TemplateController extends Controller
{
/**
* The template repository.
*
* @var TemplateRepositoryInterface
*/
private $templateRepository;

/**
* Class constructor.
*
* @param TemplateRepositoryInterface $templateRepository
* @return void
*/
public function __construct(TemplateRepositoryInterface $templateRepository)
{
$this->templateRepository = $templateRepository;
}

/**
* Shows all templates.
*
* @return Response
*/
public function index()
{
$templates = $this->templateRepository->getAll();

return view('templates.listing', [
'title' => Lang::get('templates.manage'),
'templates' => $templates->toJson(), // Because PresentableInterface toJson() is not working in the view
]);
}

/**
* Show the template configuration.
*
* @param int $template_id
* @return Response
*/
public function show($template_id)
{
$template = $this->templateRepository->getById($template_id);

return view('templates.details', [
'breadcrumb' => [
['url' => url('admin/templates'), 'label' => Lang::get('templates.label')],
],
'title' => $template->name,
'sharedFiles' => $template->sharedFiles,
'projectFiles' => $template->projectFiles,
'project' => $template,
'route' => 'template.commands',
]);
}

/**
* Store a newly created template in storage.
*
* @param StoreTemplateRequest $request
* @return Response
*/
public function store(StoreTemplateRequest $request)
{
return $this->templateRepository->create($request->only(
'name'
));
}

/**
* Update the specified template in storage.
*
* @param int $template_id
* @param StoreTemplateRequest $request
* @return Response
*/
public function update($template_id, StoreTemplateRequest $request)
{
return $this->templateRepository->updateById($request->only(
'name'
), $template_id);
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function index()
{
return view('users.listing', [
'title' => Lang::get('users.manage'),
'users' => User::all()
'users' => User::all(),
]);
}

Expand Down Expand Up @@ -90,7 +90,7 @@ public function destroy(User $user)
$user->delete();

return [
'success' => true
'success' => true,
];
}
}
Loading

0 comments on commit e7bc093

Please sign in to comment.