├── .bowerrc ├── .editorconfig ├── .env.example ├── .gitattributes ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SCREENSHOTS.md ├── app ├── Commands │ ├── AnalyseCommitCommand.php │ ├── DeleteAccountCommand.php │ ├── DisableRepoCommand.php │ ├── EnableRepoCommand.php │ └── LoginCommand.php ├── Composers │ ├── CurrentUrlComposer.php │ └── CurrentUserComposer.php ├── Console │ ├── Commands │ │ ├── AnalyseAllCommand.php │ │ └── AnalyseRepoCommand.php │ └── Kernel.php ├── Events │ ├── AnalysisHasCompletedEvent.php │ ├── AnalysisWasQueuedEvent.php │ ├── RepoWasDisabledEvent.php │ ├── RepoWasEnabledEvent.php │ ├── UserHasLoggedInEvent.php │ ├── UserHasRageQuitEvent.php │ └── UserHasSignedUpEvent.php ├── Exceptions │ └── Handler.php ├── GitHub │ ├── Branches.php │ ├── ClientFactory.php │ ├── Collaborators.php │ ├── Commits.php │ ├── Hooks.php │ ├── Repos.php │ ├── Status.php │ └── Tokens.php ├── Handlers │ ├── Commands │ │ ├── AnalyseCommitCommandHandler.php │ │ ├── DeleteAccountCommandHandler.php │ │ ├── DisableRepoCommandHandler.php │ │ ├── EnableRepoCommandHandler.php │ │ └── LoginCommandHandler.php │ ├── Events │ │ ├── AnalysisNotificationsHandler.php │ │ ├── AuthenticationHandler.php │ │ ├── CommitStatusHandler.php │ │ ├── DisableHooksHandler.php │ │ ├── EnableHooksHandler.php │ │ ├── RealTimeStatusHandler.php │ │ ├── RepoCacheFlushHandler.php │ │ └── RevokeTokenHandler.php │ └── Middleware │ │ └── UseDatabaseTransaction.php ├── Http │ ├── Controllers │ │ ├── AbstractController.php │ │ ├── AccountController.php │ │ ├── AuthController.php │ │ ├── CommitController.php │ │ ├── GitHubController.php │ │ ├── HomeController.php │ │ └── RepoController.php │ ├── Kernel.php │ ├── Middleware │ │ ├── Authenticate.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── RedirectIfAuthenticated.php │ │ └── VerifyCsrfToken.php │ └── Routes │ │ ├── AccountRoutes.php │ │ ├── MainRoutes.php │ │ └── RepoRoutes.php ├── Models │ ├── Commit.php │ ├── Fork.php │ ├── Repo.php │ └── User.php ├── Presenters │ ├── CommitPresenter.php │ └── UserPresenter.php ├── Providers │ ├── AppServiceProvider.php │ ├── BusServiceProvider.php │ ├── ComposerServiceProvider.php │ ├── EventServiceProvider.php │ ├── GitHubServiceProvider.php │ ├── RepositoryServiceProvider.php │ └── RouteServiceProvider.php └── Repositories │ ├── CommitRepository.php │ ├── ForkRepository.php │ ├── RepoRepository.php │ └── UserRepository.php ├── artisan ├── bootstrap ├── app.php └── autoload.php ├── bower.json ├── composer.json ├── composer.lock ├── config ├── analytics.php ├── app.php ├── auth.php ├── cache.php ├── compile.php ├── core.php ├── database.php ├── filesystems.php ├── github.php ├── htmlmin.php ├── mail.php ├── pusher.php ├── queue.php ├── security.php ├── services.php ├── session.php ├── styleci.php ├── trustedproxy.php └── view.php ├── database ├── .gitignore ├── migrations │ ├── 2015_01_18_120400_create_repos_table.php │ ├── 2015_01_18_120401_create_commits_table.php │ ├── 2015_01_18_120402_create_forks_table.php │ ├── 2015_01_18_120403_create_jobs_table.php │ ├── 2015_01_18_120404_create_failed_jobs_table.php │ └── 2015_01_24_072255_create_users_table.php └── seeds │ └── DatabaseSeeder.php ├── elixir.json ├── gulpfile.js ├── package.json ├── phpunit.xml.dist ├── public ├── .htaccess ├── build │ ├── dist │ │ ├── css │ │ │ └── app-ba7fd477.css │ │ └── js │ │ │ └── app-40cc34e4.js │ └── rev-manifest.json ├── dist │ └── .gitignore ├── favicon.ico ├── fonts │ ├── FontAwesome.otf │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.svg │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ └── fontawesome-webfont.woff2 ├── img │ └── styleci-og.png ├── index.php ├── packages │ └── .gitignore └── robots.txt ├── resources ├── assets │ ├── js │ │ ├── app.js │ │ └── modules │ │ │ └── shBrushDiff.js │ └── sass │ │ ├── _global.scss │ │ ├── _palette.scss │ │ ├── app.scss │ │ ├── modules │ │ ├── _alerts.scss │ │ ├── _badges.scss │ │ ├── _bootstrap.scss │ │ ├── _btns.scss │ │ ├── _icons.scss │ │ ├── _syntax.scss │ │ └── _variables.scss │ │ ├── pages │ │ ├── _account.scss │ │ ├── _commit.scss │ │ ├── _repo.scss │ │ └── _repos.scss │ │ └── partials │ │ ├── _navbar.scss │ │ └── _page-heading.scss ├── lang │ └── en │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php └── views │ ├── account.blade.php │ ├── commit.blade.php │ ├── emails │ └── failed.blade.php │ ├── index.blade.php │ ├── layouts │ ├── default.blade.php │ └── email.blade.php │ ├── maintenance.blade.php │ ├── partials │ ├── analytics.blade.php │ ├── footer.blade.php │ ├── header.blade.php │ ├── navbar.blade.php │ └── notifications.blade.php │ ├── repo.blade.php │ └── repos.blade.php ├── server.php ├── storage ├── .gitignore ├── app │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── views │ │ └── .gitignore ├── github │ └── .gitignore ├── logs │ └── .gitignore └── repos │ └── .gitignore └── tests ├── AbstractTestCase.php ├── Functional └── CommandTest.php └── ServiceProviderTest.php /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "vendor/bower_components", 3 | "interactive": false 4 | } 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_ENV=local 2 | APP_DEBUG=true 3 | APP_URL=http://localhost 4 | APP_KEY=SomeRandomString 5 | 6 | DB_HOST=localhost 7 | DB_DATABASE=homestead 8 | DB_USERNAME=homestead 9 | DB_PASSWORD=secret 10 | 11 | CACHE_DRIVER=file 12 | SESSION_DRIVER=file 13 | MAIL_DRIVER=smtp 14 | QUEUE_DRIVER=database 15 | 16 | GITHUB_CLIENT_ID=client 17 | GITHUB_CLIENT_SECRET=secret 18 | 19 | PUSHER_APP_KEY=public 20 | PUSHER_APP_SECRET=secret 21 | PUSHER_APP_ID=appid 22 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /vendor 3 | phpunit.xml 4 | .env 5 | /node_modules 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.5 5 | - 5.6 6 | - hhvm 7 | 8 | sudo: false 9 | 10 | install: 11 | - travis_retry composer install --no-interaction --prefer-source 12 | 13 | script: 14 | - bash -c 'if [ "$TRAVIS_PHP_VERSION" == "hhvm" ]; then vendor/bin/phpunit; fi;' 15 | - bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi;' 16 | 17 | after_script: 18 | - bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi;' 19 | - bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi;' 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGE LOG 2 | ========== 3 | ## 10 Minutes after V0.1 Alpha 4 | 5 | died because Graham pushed to production without handlindg errors and shared his secrets with the internet. 6 | 7 | ## V0.1 Alpha (Upcoming) 8 | 9 | * Initial testing release 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | CONTRIBUTING 2 | ============ 3 | 4 | 5 | Contributions are welcome, and are accepted via pull requests. Please review these guidelines before submitting any pull requests. 6 | 7 | 8 | ## Guidelines 9 | 10 | * Please follow the [PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) and [PHP-FIG Naming Conventions](https://github.com/php-fig/fig-standards/blob/master/bylaws/002-psr-naming-conventions.md). 11 | * Ensure that the current tests pass, and if you've added something new, add the tests where relevant. 12 | * Remember that we follow [SemVer](http://semver.org). If you are changing the behaviour, or the public api, you may need to update the docs. 13 | * Send a coherent commit history, making sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash](http://git-scm.com/book/en/Git-Tools-Rewriting-History) them before submitting. 14 | * You may also need to [rebase](http://git-scm.com/book/en/Git-Branching-Rebasing) to avoid merge conflicts. 15 | 16 | 17 | ## Running Tests 18 | 19 | You will need an install of [Composer](https://getcomposer.org) before continuing. 20 | 21 | First, install the dependencies: 22 | 23 | ```bash 24 | $ composer install 25 | ``` 26 | 27 | Then run phpunit: 28 | 29 | ```bash 30 | $ vendor/bin/phpunit 31 | ``` 32 | 33 | If the test suite passes on your local machine you should be good to go. 34 | 35 | When you make a pull request, the tests will automatically be run again by [Travis CI](https://travis-ci.org/) on multiple php versions and hhvm. 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2015 Graham Campbell 4 | Copyright (c) 2015 Joseph Cohen 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | StyleCI 2 | ======= 3 | 4 | StyleCI was created by, and is maintained by [Graham Campbell](https://github.com/GrahamCampbell), and is a PHP Coding Style Continuous Integration Service powered by [Laravel 5.0](http://laravel.com). Feel free to check out the [change log](CHANGELOG.md), [releases](https://github.com/StyleCI/StyleCI/releases), [license](LICENSE), [screenshots](SCREENSHOTS.md), [api docs](http://docs.grahamjcampbell.co.uk), and [contribution guidelines](CONTRIBUTING.md). 5 | 6 | ![StyleCI](https://cloud.githubusercontent.com/assets/2829600/5893831/e1bc86a6-a4ea-11e4-92b3-389d516f0f41.png) 7 | 8 |

9 | Build Status 10 | Coverage Status 11 | Quality Score 12 | Software License 13 | Latest Version 14 |

15 | 16 | 17 | ## Documentation 18 | 19 | We currently have essentially no documentation at the moment, but are working on it. 20 | 21 | 22 | ## Free Hosted Service 23 | 24 | Our free hosted service is available at https://styleci.io/. Enjoy! 25 | 26 | 27 | ## License 28 | 29 | StyleCI is licensed under [The MIT License (MIT)](LICENSE). 30 | -------------------------------------------------------------------------------- /SCREENSHOTS.md: -------------------------------------------------------------------------------- 1 | SCREENSHOTS 2 | =========== 3 | 4 | Coming soon. 5 | -------------------------------------------------------------------------------- /app/Commands/AnalyseCommitCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Commands; 14 | 15 | use Illuminate\Contracts\Queue\ShouldBeQueued; 16 | use Illuminate\Queue\SerializesModels; 17 | use StyleCI\StyleCI\Events\AnalysisWasQueuedEvent; 18 | use StyleCI\StyleCI\Models\Commit; 19 | 20 | /** 21 | * This is the analyse commit command. 22 | * 23 | * @author Graham Campbell 24 | */ 25 | class AnalyseCommitCommand implements ShouldBeQueued 26 | { 27 | use SerializesModels; 28 | 29 | /** 30 | * The commit to analyse. 31 | * 32 | * @var \StyleCI\StyleCI\Models\Commit 33 | */ 34 | protected $commit; 35 | 36 | /** 37 | * Create a new analyse commit command instance. 38 | * 39 | * @param \StyleCI\StyleCI\Models\Commit $commit 40 | * 41 | * @return void 42 | */ 43 | public function __construct(Commit $commit) 44 | { 45 | $this->commit = $commit; 46 | 47 | event(new AnalysisWasQueuedEvent($commit)); 48 | } 49 | 50 | /** 51 | * Get the commit to analyse. 52 | * 53 | * @return \StyleCI\StyleCI\Models\Commit 54 | */ 55 | public function getCommit() 56 | { 57 | return $this->commit; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/Commands/DeleteAccountCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Commands; 14 | 15 | use StyleCI\StyleCI\Models\User; 16 | 17 | /** 18 | * This is the delete account command class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class DeleteAccountCommand 23 | { 24 | /** 25 | * The user to delete. 26 | * 27 | * @var \StyleCI\StyleCI\Models\User 28 | */ 29 | protected $user; 30 | 31 | /** 32 | * Create a new delete account command instance. 33 | * 34 | * @param \StyleCI\StyleCI\Models\User $user 35 | * 36 | * @return void 37 | */ 38 | public function __construct(User $user) 39 | { 40 | $this->user = $user; 41 | } 42 | 43 | /** 44 | * Get the user to delete. 45 | * 46 | * @return \StyleCI\StyleCI\Models\User 47 | */ 48 | public function getUser() 49 | { 50 | return $this->user; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/Commands/DisableRepoCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Commands; 14 | 15 | use StyleCI\StyleCI\Models\Repo; 16 | 17 | /** 18 | * This is the disable repo command class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class DisableRepoCommand 23 | { 24 | /** 25 | * The repository to delete. 26 | * 27 | * @var \StyleCI\StyleCI\Models\Repo 28 | */ 29 | protected $repo; 30 | 31 | /** 32 | * Create a new disable repo command instance. 33 | * 34 | * @param \StyleCI\StyleCI\Models\Repo $repo 35 | * 36 | * @return void 37 | */ 38 | public function __construct(Repo $repo) 39 | { 40 | $this->repo = $repo; 41 | } 42 | 43 | /** 44 | * Get the repository to delete. 45 | * 46 | * @return \StyleCI\StyleCI\Models\Repo 47 | */ 48 | public function getRepo() 49 | { 50 | return $this->repo; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/Commands/EnableRepoCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Commands; 14 | 15 | use StyleCI\StyleCI\Models\User; 16 | 17 | /** 18 | * This is the enable repo command class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class EnableRepoCommand 23 | { 24 | /** 25 | * The repository id. 26 | * 27 | * @var int 28 | */ 29 | protected $id; 30 | 31 | /** 32 | * The repository name. 33 | * 34 | * @var string 35 | */ 36 | protected $name; 37 | 38 | /** 39 | * The associated user. 40 | * 41 | * @var \StyleCI\StyleCI\Models\User 42 | */ 43 | protected $user; 44 | 45 | /** 46 | * Create a new enable repo command instance. 47 | * 48 | * @param int $id 49 | * @param string $name 50 | * @param \StyleCI\StyleCI\Models\User $user 51 | * 52 | * @return void 53 | */ 54 | public function __construct($id, $name, User $user) 55 | { 56 | $this->id = $id; 57 | $this->name = $name; 58 | $this->user = $user; 59 | } 60 | 61 | /** 62 | * Get the repository id. 63 | * 64 | * @return string 65 | */ 66 | public function getId() 67 | { 68 | return $this->id; 69 | } 70 | 71 | /** 72 | * Get the repository name. 73 | * 74 | * @return string 75 | */ 76 | public function getName() 77 | { 78 | return $this->name; 79 | } 80 | 81 | /** 82 | * Get the associated user. 83 | * 84 | * @return \StyleCI\StyleCI\Models\User 85 | */ 86 | public function getUser() 87 | { 88 | return $this->user; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /app/Commands/LoginCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Commands; 14 | 15 | /** 16 | * This is the login command class. 17 | * 18 | * @author Graham Campbell 19 | * @author Joseph Cohen 20 | */ 21 | class LoginCommand 22 | { 23 | /** 24 | * The user's id. 25 | * 26 | * @var string 27 | */ 28 | protected $id; 29 | 30 | /** 31 | * The user's name. 32 | * 33 | * @var string 34 | */ 35 | protected $name; 36 | 37 | /** 38 | * The user's username. 39 | * 40 | * @var string 41 | */ 42 | protected $username; 43 | 44 | /** 45 | * The user's email address. 46 | * 47 | * @var string 48 | */ 49 | protected $email; 50 | 51 | /** 52 | * The user's access token. 53 | * 54 | * @var string 55 | */ 56 | protected $token; 57 | 58 | /** 59 | * Create a new login command instance. 60 | * 61 | * @param string $id 62 | * @param string $name 63 | * @param string $username 64 | * @param string $email 65 | * @param string $token 66 | * 67 | * @return void 68 | */ 69 | public function __construct($id, $name, $username, $email, $token) 70 | { 71 | $this->id = $id; 72 | $this->name = $name; 73 | $this->username = $username; 74 | $this->email = $email; 75 | $this->token = $token; 76 | } 77 | 78 | /** 79 | * Get the user's id. 80 | * 81 | * @return string 82 | */ 83 | public function getId() 84 | { 85 | return $this->id; 86 | } 87 | 88 | /** 89 | * Get the user's name. 90 | * 91 | * @return string 92 | */ 93 | public function getName() 94 | { 95 | return $this->name; 96 | } 97 | 98 | /** 99 | * Get the user's username. 100 | * 101 | * @return string 102 | */ 103 | public function getUsername() 104 | { 105 | return $this->username; 106 | } 107 | 108 | /** 109 | * Get the user's email address. 110 | * 111 | * @return string 112 | */ 113 | public function getEmail() 114 | { 115 | return $this->email; 116 | } 117 | 118 | /** 119 | * Get the user's access token. 120 | * 121 | * @return string 122 | */ 123 | public function getToken() 124 | { 125 | return $this->token; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /app/Composers/CurrentUrlComposer.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Composers; 14 | 15 | use Illuminate\Contracts\View\View; 16 | use Illuminate\Support\Facades\URL; 17 | 18 | /** 19 | * This is the current user composer class. 20 | * 21 | * @author Joseph Cohen 22 | */ 23 | class CurrentUrlComposer 24 | { 25 | /** 26 | * Bind data to the view. 27 | * 28 | * @param \Illuminate\Contracts\View\View $view 29 | * 30 | * @return void 31 | */ 32 | public function compose(View $view) 33 | { 34 | $view->with('currentUrl', URL::full()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Composers/CurrentUserComposer.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Composers; 14 | 15 | use Illuminate\Contracts\Auth\Guard; 16 | use Illuminate\Contracts\View\View; 17 | 18 | /** 19 | * This is the current user composer class. 20 | * 21 | * @author Graham Campbell 22 | * @author Joseph Cohen 23 | */ 24 | class CurrentUserComposer 25 | { 26 | /** 27 | * The authentication guard instance. 28 | * 29 | * @var \Illuminate\Contracts\Auth\Guard 30 | */ 31 | protected $auth; 32 | 33 | /** 34 | * Create a new current user composer instance. 35 | * 36 | * @param \Illuminate\Contracts\Auth\Guard $auth 37 | * 38 | * @return void 39 | */ 40 | public function __construct(Guard $auth) 41 | { 42 | $this->auth = $auth; 43 | } 44 | 45 | /** 46 | * Bind data to the view. 47 | * 48 | * @param \Illuminate\Contracts\View\View $view 49 | * 50 | * @return void 51 | */ 52 | public function compose(View $view) 53 | { 54 | $view->with('currentUser', $this->auth->user()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/Console/Commands/AnalyseAllCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Console\Commands; 14 | 15 | use Illuminate\Console\Command; 16 | use Illuminate\Foundation\Bus\DispatchesCommands; 17 | use StyleCI\StyleCI\Commands\AnalyseCommitCommand; 18 | use StyleCI\StyleCI\Models\Repo; 19 | 20 | /** 21 | * This is the analyse all command class. 22 | * 23 | * @author Graham Campbell 24 | */ 25 | class AnalyseAllCommand extends Command 26 | { 27 | use DispatchesCommands; 28 | 29 | /** 30 | * The console command name. 31 | * 32 | * @var string 33 | */ 34 | protected $name = 'analyse:all'; 35 | 36 | /** 37 | * The console command description. 38 | * 39 | * @var string 40 | */ 41 | protected $description = 'Analyse all the heads of every repo'; 42 | 43 | /** 44 | * Execute the console command. 45 | * 46 | * @return void 47 | */ 48 | public function handle() 49 | { 50 | foreach ($this->laravel['styleci.reporepository']->all() as $repo) { 51 | $this->analyse($repo); 52 | } 53 | } 54 | 55 | /** 56 | * Analyse all the branches on a repo. 57 | * 58 | * @param \StyleCI\StyleCI\Models\Repo $repo 59 | * 60 | * @return void 61 | */ 62 | protected function analyse(Repo $repo) 63 | { 64 | $this->comment('Getting the list of branches for "'.$repo->name.'".'); 65 | 66 | $branches = $this->laravel['styleci.branches']->get($repo); 67 | 68 | foreach ($branches as $branch) { 69 | $commit = $this->laravel['styleci.commitrepository']->findForAnalysis($branch['commit'], $repo->id, $branch['name']); 70 | $this->dispatch(new AnalyseCommitCommand($commit)); 71 | $this->info('Analysis of the "'.$branch['name'].'" branch has been scheduled.'); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/Console/Commands/AnalyseRepoCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Console\Commands; 14 | 15 | use Exception; 16 | use Illuminate\Console\Command; 17 | use Illuminate\Foundation\Bus\DispatchesCommands; 18 | use StyleCI\StyleCI\Commands\AnalyseCommitCommand; 19 | use StyleCI\StyleCI\Models\Repo; 20 | use Symfony\Component\Console\Input\InputArgument; 21 | 22 | /** 23 | * This is the analyse repo command class. 24 | * 25 | * @author Graham Campbell 26 | */ 27 | class AnalyseRepoCommand extends Command 28 | { 29 | use DispatchesCommands; 30 | 31 | /** 32 | * The console command name. 33 | * 34 | * @var string 35 | */ 36 | protected $name = 'analyse:repo'; 37 | 38 | /** 39 | * The console command description. 40 | * 41 | * @var string 42 | */ 43 | protected $description = 'Analyse all the heads of a repo'; 44 | 45 | /** 46 | * Execute the console command. 47 | * 48 | * @return void 49 | */ 50 | public function handle() 51 | { 52 | $repo = $this->laravel['styleci.reporepository']->findByName($this->argument('repo')); 53 | 54 | if (!$repo) { 55 | throw new Exception('Repo not found.'); 56 | } 57 | 58 | $this->comment('Getting the list of branches for "'.$repo->name.'".'); 59 | 60 | $branches = $this->laravel['styleci.branches']->get($repo); 61 | 62 | foreach ($branches as $branch) { 63 | $commit = $this->laravel['styleci.commitrepository']->findForAnalysis($branch['commit'], $repo->id, $branch['name']); 64 | $this->dispatch(new AnalyseCommitCommand($commit)); 65 | $this->info('Analysis of the "'.$branch['name'].'" branch has been scheduled.'); 66 | } 67 | } 68 | 69 | /** 70 | * Get the console command arguments. 71 | * 72 | * @return array 73 | */ 74 | protected function getArguments() 75 | { 76 | return [ 77 | ['repo', InputArgument::REQUIRED, 'The repo to analyse'], 78 | ]; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Console; 14 | 15 | use Illuminate\Console\Scheduling\Schedule; 16 | use Illuminate\Foundation\Console\Kernel as ConsoleKernel; 17 | 18 | /** 19 | * This is the console kernel class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class Kernel extends ConsoleKernel 24 | { 25 | /** 26 | * The Artisan commands provided by your application. 27 | * 28 | * @var string[] 29 | */ 30 | protected $commands = [ 31 | Commands\AnalyseAllCommand::class, 32 | Commands\AnalyseRepoCommand::class, 33 | ]; 34 | 35 | /** 36 | * Define the application's command schedule. 37 | * 38 | * @param \Illuminate\Console\Scheduling\Schedule $schedule 39 | * 40 | * @return void 41 | */ 42 | protected function schedule(Schedule $schedule) 43 | { 44 | // 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/Events/AnalysisHasCompletedEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Events; 14 | 15 | use Illuminate\Queue\SerializesModels; 16 | use StyleCI\StyleCI\Models\Commit; 17 | 18 | /** 19 | * This is the analysis has completed event class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class AnalysisHasCompletedEvent 24 | { 25 | use SerializesModels; 26 | 27 | /** 28 | * The commit that was analysed. 29 | * 30 | * @var \StyleCI\StyleCI\Models\Commit 31 | */ 32 | protected $commit; 33 | 34 | /** 35 | * Create a new analysis has completed event instance. 36 | * 37 | * @param \StyleCI\StyleCI\Models\Commit $commit 38 | * 39 | * @return void 40 | */ 41 | public function __construct(Commit $commit) 42 | { 43 | $this->commit = $commit; 44 | } 45 | 46 | /** 47 | * Get the commit that was analysed. 48 | * 49 | * @return \StyleCI\StyleCI\Models\Commit 50 | */ 51 | public function getCommit() 52 | { 53 | return $this->commit; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Events/AnalysisWasQueuedEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Events; 14 | 15 | use Illuminate\Queue\SerializesModels; 16 | use StyleCI\StyleCI\Models\Commit; 17 | 18 | /** 19 | * This is the analysis was queued event class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class AnalysisWasQueuedEvent 24 | { 25 | use SerializesModels; 26 | 27 | /** 28 | * The commit that will be analysed. 29 | * 30 | * @var \StyleCI\StyleCI\Models\Commit 31 | */ 32 | protected $commit; 33 | 34 | /** 35 | * Create a new analysis was queued event instance. 36 | * 37 | * @param \StyleCI\StyleCI\Models\Commit $commit 38 | * 39 | * @return void 40 | */ 41 | public function __construct(Commit $commit) 42 | { 43 | $this->commit = $commit; 44 | } 45 | 46 | /** 47 | * Get the commit that will be analysed. 48 | * 49 | * @return \StyleCI\StyleCI\Models\Commit 50 | */ 51 | public function getCommit() 52 | { 53 | return $this->commit; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Events/RepoWasDisabledEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Events; 14 | 15 | use Illuminate\Queue\SerializesModels; 16 | use StyleCI\StyleCI\Models\Repo; 17 | 18 | /** 19 | * This is the repo was disabled event class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class RepoWasDisabledEvent 24 | { 25 | use SerializesModels; 26 | 27 | /** 28 | * The repo that was disabled. 29 | * 30 | * @var \StyleCI\StyleCI\Models\Repo 31 | */ 32 | protected $repo; 33 | 34 | /** 35 | * Create a new repo was disabled event instance. 36 | * 37 | * @param \StyleCI\StyleCI\Models\Repo $repo 38 | * 39 | * @return void 40 | */ 41 | public function __construct(Repo $repo) 42 | { 43 | $this->repo = $repo; 44 | } 45 | 46 | /** 47 | * Get the repo that was disabled. 48 | * 49 | * @return \StyleCI\StyleCI\Models\Repo 50 | */ 51 | public function getRepo() 52 | { 53 | return $this->repo; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Events/RepoWasEnabledEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Events; 14 | 15 | use Illuminate\Queue\SerializesModels; 16 | use StyleCI\StyleCI\Models\Repo; 17 | 18 | /** 19 | * This is the repo was enabled event class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class RepoWasEnabledEvent 24 | { 25 | use SerializesModels; 26 | 27 | /** 28 | * The repo that was enabled. 29 | * 30 | * @var \StyleCI\StyleCI\Models\Repo 31 | */ 32 | protected $repo; 33 | 34 | /** 35 | * Create a new repo was enabled event instance. 36 | * 37 | * @param \StyleCI\StyleCI\Models\Repo $repo 38 | * 39 | * @return void 40 | */ 41 | public function __construct(Repo $repo) 42 | { 43 | $this->repo = $repo; 44 | } 45 | 46 | /** 47 | * Get the repo that was enabled. 48 | * 49 | * @return \StyleCI\StyleCI\Models\Repo 50 | */ 51 | public function getRepo() 52 | { 53 | return $this->repo; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Events/UserHasLoggedInEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Events; 14 | 15 | use Illuminate\Queue\SerializesModels; 16 | use StyleCI\StyleCI\Models\User; 17 | 18 | /** 19 | * This is the user has logged in event class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class UserHasLoggedInEvent 24 | { 25 | use SerializesModels; 26 | 27 | /** 28 | * The user that has logged in. 29 | * 30 | * @var \StyleCI\StyleCI\Models\User 31 | */ 32 | protected $user; 33 | 34 | /** 35 | * Create a new user has logged in event instance. 36 | * 37 | * @param \StyleCI\StyleCI\Models\User $user 38 | * 39 | * @return void 40 | */ 41 | public function __construct(User $user) 42 | { 43 | $this->user = $user; 44 | } 45 | 46 | /** 47 | * Get the user that has logged in. 48 | * 49 | * @return \StyleCI\StyleCI\Models\User 50 | */ 51 | public function getUser() 52 | { 53 | return $this->user; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Events/UserHasRageQuitEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Events; 14 | 15 | use Illuminate\Queue\SerializesModels; 16 | use StyleCI\StyleCI\Models\User; 17 | 18 | /** 19 | * This is the user has rage quit event class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class UserHasRageQuitEvent 24 | { 25 | use SerializesModels; 26 | 27 | /** 28 | * The user that has rage quit. 29 | * 30 | * @var \StyleCI\StyleCI\Models\User 31 | */ 32 | protected $user; 33 | 34 | /** 35 | * Create a new user has rage quit event instance. 36 | * 37 | * @param \StyleCI\StyleCI\Models\User $user 38 | * 39 | * @return void 40 | */ 41 | public function __construct(User $user) 42 | { 43 | $this->user = $user; 44 | } 45 | 46 | /** 47 | * Get the user that has rage quit. 48 | * 49 | * @return \StyleCI\StyleCI\Models\User 50 | */ 51 | public function getUser() 52 | { 53 | return $this->user; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Events/UserHasSignedUpEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Events; 14 | 15 | use Illuminate\Queue\SerializesModels; 16 | use StyleCI\StyleCI\Models\User; 17 | 18 | /** 19 | * This is the user signed up event class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class UserHasSignedUpEvent 24 | { 25 | use SerializesModels; 26 | 27 | /** 28 | * The user that has signed up. 29 | * 30 | * @var \StyleCI\StyleCI\Models\User 31 | */ 32 | protected $user; 33 | 34 | /** 35 | * Create a new user has signed up event instance. 36 | * 37 | * @param \StyleCI\StyleCI\Models\User $user 38 | * 39 | * @return void 40 | */ 41 | public function __construct(User $user) 42 | { 43 | $this->user = $user; 44 | } 45 | 46 | /** 47 | * Get the user that has signed up. 48 | * 49 | * @return \StyleCI\StyleCI\Models\User 50 | */ 51 | public function getUser() 52 | { 53 | return $this->user; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Exceptions; 14 | 15 | use GrahamCampbell\Exceptions\ExceptionHandler; 16 | 17 | /** 18 | * This is the exception hander class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class Handler extends ExceptionHandler 23 | { 24 | /** 25 | * A list of the exception types that should not be reported. 26 | * 27 | * @var string[] 28 | */ 29 | protected $dontReport = [ 30 | 'Symfony\Component\HttpKernel\Exception\HttpException', 31 | ]; 32 | } 33 | -------------------------------------------------------------------------------- /app/GitHub/Branches.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\GitHub; 14 | 15 | use Github\ResultPager; 16 | use StyleCI\StyleCI\Models\Repo; 17 | 18 | /** 19 | * This is the github branches class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class Branches 24 | { 25 | /** 26 | * The github client factory instance. 27 | * 28 | * @var \StyleCI\StyleCI\GitHub\ClientFactory 29 | */ 30 | protected $factory; 31 | 32 | /** 33 | * Create a new github branches instance. 34 | * 35 | * @param \StyleCI\StyleCI\GitHub\ClientFactory $factory 36 | * 37 | * @return void 38 | */ 39 | public function __construct(ClientFactory $factory) 40 | { 41 | $this->factory = $factory; 42 | } 43 | 44 | /** 45 | * Get the branches from a github repo. 46 | * 47 | * @param \StyleCI\StyleCI\Models\Repo $repo 48 | * 49 | * @return array 50 | */ 51 | public function get(Repo $repo) 52 | { 53 | $client = $this->factory->make($repo); 54 | $paginator = new ResultPager($client); 55 | 56 | $raw = $paginator->fetchAll($client->repos(), 'branches', explode('/', $repo->name)); 57 | 58 | $branches = []; 59 | 60 | foreach ($raw as $branch) { 61 | if ((strpos($branch['name'], 'gh-pages') === false)) { 62 | $branches[] = ['name' => $branch['name'], 'commit' => $branch['commit']['sha']]; 63 | } 64 | } 65 | 66 | return $branches; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/GitHub/ClientFactory.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\GitHub; 14 | 15 | use GrahamCampbell\GitHub\Factories\GitHubFactory; 16 | use Illuminate\Database\Eloquent\Model; 17 | use InvalidArgumentException; 18 | use StyleCI\StyleCI\Models\Repo; 19 | use StyleCI\StyleCI\Models\User; 20 | 21 | /** 22 | * This is the github client factory class. 23 | * 24 | * @author Graham Campbell 25 | */ 26 | class ClientFactory 27 | { 28 | /** 29 | * The github repo instance. 30 | * 31 | * @var \GrahamCampbell\GitHub\Factories\GitHubFactory 32 | */ 33 | protected $factory; 34 | 35 | /** 36 | * Create a new github client factory instance. 37 | * 38 | * @param \GrahamCampbell\GitHub\Factories\GitHubFactory $factory 39 | * 40 | * @return void 41 | */ 42 | public function __construct(GitHubFactory $factory) 43 | { 44 | $this->factory = $factory; 45 | } 46 | 47 | /** 48 | * Get the github api client for a model. 49 | * 50 | * @param \Illuminate\Database\Eloquent\Model $model 51 | * 52 | * @throws \InvalidArgumentException 53 | * 54 | * @return \Github\Client 55 | */ 56 | public function make(Model $model) 57 | { 58 | switch (get_class($model)) { 59 | case User::class: 60 | $token = $model->access_token; 61 | break; 62 | case Repo::class: 63 | $token = $model->user->access_token; 64 | break; 65 | default: 66 | throw new InvalidArgumentException('You must provide a user or repo model.'); 67 | } 68 | 69 | return $this->factory->make(['token' => $token, 'method' => 'token']); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/GitHub/Commits.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\GitHub; 14 | 15 | use StyleCI\StyleCI\Models\Commit; 16 | 17 | /** 18 | * This is the github commits class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class Commits 23 | { 24 | /** 25 | * The github client factory instance. 26 | * 27 | * @var \StyleCI\StyleCI\GitHub\ClientFactory 28 | */ 29 | protected $factory; 30 | 31 | /** 32 | * Create a new github commits instance. 33 | * 34 | * @param \StyleCI\StyleCI\GitHub\ClientFactory $factory 35 | * 36 | * @return void 37 | */ 38 | public function __construct(ClientFactory $factory) 39 | { 40 | $this->factory = $factory; 41 | } 42 | 43 | /** 44 | * Get information about a specific commit from github. 45 | * 46 | * @param \StyleCI\StyleCI\Models\Commit $commit 47 | * 48 | * @return array 49 | */ 50 | public function get(Commit $commit) 51 | { 52 | $repo = $commit->repo; 53 | 54 | $args = explode('/', $repo->name); 55 | 56 | return $this->factory->make($repo)->repos()->commits()->show($args[0], $args[1], $commit->id); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/GitHub/Hooks.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\GitHub; 14 | 15 | use Github\ResultPager; 16 | use Stringy\StaticStringy; 17 | use StyleCI\StyleCI\Models\Repo; 18 | 19 | /** 20 | * This is the github hooks class. 21 | * 22 | * @author Graham Campbell 23 | */ 24 | class Hooks 25 | { 26 | /** 27 | * The github client factory instance. 28 | * 29 | * @var \StyleCI\StyleCI\GitHub\ClientFactory 30 | */ 31 | protected $factory; 32 | 33 | /** 34 | * Create a new github hooks instance. 35 | * 36 | * @param \StyleCI\StyleCI\GitHub\ClientFactory $factory 37 | * 38 | * @return void 39 | */ 40 | public function __construct(ClientFactory $factory) 41 | { 42 | $this->factory = $factory; 43 | } 44 | 45 | /** 46 | * Enable the styleci webhook for the given repo. 47 | * 48 | * @param \StyleCI\StyleCI\Models\Repo $repo 49 | * 50 | * @return void 51 | */ 52 | public function enable(Repo $repo) 53 | { 54 | $url = route('webhook_callback'); 55 | $args = explode('/', $repo->name); 56 | $hooks = $this->factory->make($repo)->repo()->hooks(); 57 | 58 | $events = ['pull_request','push']; 59 | 60 | $config = [ 61 | 'url' => $url, 62 | 'content_type' => 'json', 63 | 'insecure_ssl' => 0, 64 | 'secret' => '', 65 | ]; 66 | 67 | $hooks->create($args[0], $args[1], ['name' => 'web', 'events' => $events, 'config' => $config]); 68 | } 69 | 70 | /** 71 | * Disable the styleci webhook for the given repo. 72 | * 73 | * @param \StyleCI\StyleCI\Models\Repo $repo 74 | * 75 | * @return void 76 | */ 77 | public function disable(Repo $repo) 78 | { 79 | $url = route('home'); // we want to remove all hooks containing the base url 80 | $args = explode('/', $repo->name); 81 | $client = $this->factory->make($repo); 82 | $hooks = $client->repo()->hooks(); 83 | $paginator = new ResultPager($client); 84 | 85 | foreach ($paginator->fetchAll($hooks, 'all', $args) as $hook) { 86 | if ($hook['name'] !== 'web' || StaticStringy::contains($hook['config']['url'], $url, false) !== true) { 87 | continue; 88 | } 89 | 90 | $hooks->remove($args[0], $args[1], $hook['id']); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/GitHub/Repos.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\GitHub; 14 | 15 | use Github\ResultPager; 16 | use Illuminate\Contracts\Cache\Repository; 17 | use StyleCI\StyleCI\Models\Repo; 18 | use StyleCI\StyleCI\Models\User; 19 | 20 | /** 21 | * This is the github repos class. 22 | * 23 | * @author Graham Campbell 24 | */ 25 | class Repos 26 | { 27 | /** 28 | * The github client factory instance. 29 | * 30 | * @var \StyleCI\StyleCI\GitHub\ClientFactory 31 | */ 32 | protected $factory; 33 | 34 | /** 35 | * The illuminate cache repository instance. 36 | * 37 | * @var \Illuminate\Contracts\Cache\Repository 38 | */ 39 | protected $cache; 40 | 41 | /** 42 | * Create a github repos instance. 43 | * 44 | * @param \StyleCI\StyleCI\GitHub\ClientFactory $factory 45 | * @param \Illuminate\Contracts\Cache\Repository $cache 46 | * 47 | * @return void 48 | */ 49 | public function __construct(ClientFactory $factory, Repository $cache) 50 | { 51 | $this->factory = $factory; 52 | $this->cache = $cache; 53 | } 54 | 55 | /** 56 | * Get a user's public repos. 57 | * 58 | * @param \StyleCI\StyleCI\Models\User $user 59 | * @param bool $admin 60 | * 61 | * @return array 62 | */ 63 | public function get(User $user, $admin = false) 64 | { 65 | // cache the repo info from github for 12 hours 66 | $list = $this->cache->remember($user->id.'repos', 720, function () use ($user) { 67 | return $this->fetchFromGitHub($user); 68 | }); 69 | 70 | if ($admin) { 71 | $list = array_filter($list, function ($item) { 72 | return $item['admin']; 73 | }); 74 | } 75 | 76 | foreach (Repo::whereIn('id', array_keys($list))->get(['id']) as $repo) { 77 | $list[$repo->id]['enabled'] = true; 78 | } 79 | 80 | return $list; 81 | } 82 | 83 | /** 84 | * Fetch a user's public repos from github. 85 | * 86 | * @param \StyleCI\StyleCI\Models\User $user 87 | * 88 | * @return array 89 | */ 90 | protected function fetchFromGitHub(User $user) 91 | { 92 | $client = $this->factory->make($user); 93 | $paginator = new ResultPager($client); 94 | 95 | $list = []; 96 | 97 | foreach ($paginator->fetchAll($client->me(), 'repositories') as $repo) { 98 | if ($repo['private']) { 99 | continue; 100 | } 101 | 102 | // set enabled to false by default 103 | // we'll mark those that are enabled at a later point 104 | $list[$repo['id']] = ['name' => $repo['full_name'], 'admin' => $repo['permissions']['admin'], 'enabled' => false]; 105 | } 106 | 107 | return $list; 108 | } 109 | 110 | /** 111 | * Flush our cache of the user's public repos. 112 | * 113 | * @param \StyleCI\StyleCI\Models\User $user 114 | * 115 | * @return void 116 | */ 117 | public function flush(User $user) 118 | { 119 | $this->cache->forget($user->id.'repos'); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /app/GitHub/Status.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\GitHub; 14 | 15 | use StyleCI\StyleCI\Models\Commit; 16 | 17 | /** 18 | * This is the github status class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class Status 23 | { 24 | /** 25 | * The github client factory instance. 26 | * 27 | * @var \StyleCI\StyleCI\GitHub\ClientFactory 28 | */ 29 | protected $factory; 30 | 31 | /** 32 | * The target url. 33 | * 34 | * @var string 35 | */ 36 | protected $url; 37 | 38 | /** 39 | * Create a new github status instance. 40 | * 41 | * @param \StyleCI\StyleCI\GitHub\ClientFactory $factory 42 | * @param string $url 43 | * 44 | * @return void 45 | */ 46 | public function __construct(ClientFactory $factory, $url) 47 | { 48 | $this->factory = $factory; 49 | $this->url = $url; 50 | } 51 | 52 | /** 53 | * Push the status on the github commit. 54 | * 55 | * @param \StyleCI\StyleCI\Models\Commit $commit 56 | * 57 | * @return void 58 | */ 59 | public function push(Commit $commit) 60 | { 61 | $repo = $commit->repo; 62 | 63 | $args = explode('/', $repo->name); 64 | 65 | $data = [ 66 | 'state' => $this->getState($commit->status), 67 | 'description' => $commit->description(), 68 | 'target_url' => $this->url.'/'.$commit->id, 69 | 'context' => 'StyleCI', 70 | ]; 71 | 72 | $this->factory->make($repo)->repos()->statuses()->create($args[0], $args[1], $commit->id, $data); 73 | } 74 | 75 | /** 76 | * Get the state of the commit by from its status integer. 77 | * 78 | * @param int $status 79 | * 80 | * @return string 81 | */ 82 | protected function getState($status) 83 | { 84 | switch ($status) { 85 | case 1: 86 | return 'success'; 87 | case 2: 88 | return 'failure'; 89 | default: 90 | return 'pending'; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/GitHub/Tokens.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\GitHub; 14 | 15 | use Github\Api\Authorizations; 16 | 17 | /** 18 | * This is the tokens hooks class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class Tokens 23 | { 24 | /** 25 | * The github authorizations instance. 26 | * 27 | * @var \Github\Api\Authorizations 28 | */ 29 | protected $auth; 30 | 31 | /** 32 | * The github client id. 33 | * 34 | * @var string 35 | */ 36 | protected $clientId; 37 | 38 | /** 39 | * Create a new github tokens instance. 40 | * 41 | * @param \Github\Api\Authorizations $auth 42 | * @param string $clientId 43 | * 44 | * @return void 45 | */ 46 | public function __construct(Authorizations $auth, $clientId) 47 | { 48 | $this->auth = $auth; 49 | $this->clientId = $clientId; 50 | } 51 | 52 | /** 53 | * Revoke the given token. 54 | * 55 | * @param string $token 56 | * 57 | * @return void 58 | */ 59 | public function revoke($token) 60 | { 61 | $this->auth->revoke($this->clientId, $token); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/Handlers/Commands/AnalyseCommitCommandHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Commands; 14 | 15 | use StyleCI\Fixer\Report; 16 | use StyleCI\Fixer\ReportBuilder; 17 | use StyleCI\StyleCI\Commands\AnalyseCommitCommand; 18 | use StyleCI\StyleCI\Events\AnalysisHasCompletedEvent; 19 | use StyleCI\StyleCI\Models\Commit; 20 | 21 | /** 22 | * This is the analyse commit command handler. 23 | * 24 | * @author Graham Campbell 25 | */ 26 | class AnalyseCommitCommandHandler 27 | { 28 | /** 29 | * The report builder instance. 30 | * 31 | * @var \StyleCI\Fixer\ReportBuilder 32 | */ 33 | protected $builder; 34 | 35 | /** 36 | * Create a new analyse commit command handler instance. 37 | * 38 | * @param \StyleCI\Fixer\ReportBuilder $builder 39 | * 40 | * @return void 41 | */ 42 | public function __construct(ReportBuilder $builder) 43 | { 44 | $this->builder = $builder; 45 | } 46 | 47 | /** 48 | * Handle the analyse commit command. 49 | * 50 | * @param \StyleCI\StyleCI\Commands\AnalyseCommitCommand $command 51 | * 52 | * @return void 53 | */ 54 | public function handle(AnalyseCommitCommand $command) 55 | { 56 | $commit = $command->getCommit(); 57 | 58 | $report = $this->builder->analyse($commit->name(), $commit->id); 59 | 60 | $this->saveReport($report, $commit); 61 | 62 | event(new AnalysisHasCompletedEvent($commit)); 63 | } 64 | 65 | /** 66 | * Save the main report to the database. 67 | * 68 | * @param \StyleCI\Fixer\Report $report 69 | * @param \StyleCI\StyleCI\Models\Commit $commit 70 | * 71 | * @return void 72 | */ 73 | protected function saveReport(Report $report, Commit $commit) 74 | { 75 | $commit->time = $report->time(); 76 | $commit->memory = $report->memory(); 77 | $commit->diff = $report->diff(); 78 | 79 | if ($report->successful()) { 80 | $commit->status = 1; 81 | } else { 82 | $commit->status = 2; 83 | } 84 | 85 | $commit->save(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/Handlers/Commands/DeleteAccountCommandHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Commands; 14 | 15 | use Illuminate\Foundation\Bus\DispatchesCommands; 16 | use StyleCI\StyleCI\Commands\DeleteAccountCommand; 17 | use StyleCI\StyleCI\Commands\DisableRepoCommand; 18 | use StyleCI\StyleCI\Events\UserHasRageQuitEvent; 19 | 20 | /** 21 | * This is the delete account command handler class. 22 | * 23 | * @author Graham Campbell 24 | */ 25 | class DeleteAccountCommandHandler 26 | { 27 | use DispatchesCommands; 28 | 29 | /** 30 | * Handle the delete account command. 31 | * 32 | * @param \StyleCI\StyleCI\Commands\DeleteAccountCommand $command 33 | * 34 | * @return void 35 | */ 36 | public function handle(DeleteAccountCommand $command) 37 | { 38 | $user = $command->getUser(); 39 | 40 | foreach ($user->repos as $repo) { 41 | $this->dispatch(new DisableRepoCommand($repo)); 42 | } 43 | 44 | event(new UserHasRageQuitEvent($user)); 45 | 46 | $user->delete(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/Handlers/Commands/DisableRepoCommandHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Commands; 14 | 15 | use StyleCI\StyleCI\Commands\DisableRepoCommand; 16 | use StyleCI\StyleCI\Events\RepoWasDisabledEvent; 17 | 18 | /** 19 | * This is the disable repo command handler class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class DisableRepoCommandHandler 24 | { 25 | /** 26 | * Handle the disable repo command. 27 | * 28 | * @param \StyleCI\StyleCI\Commands\DisableRepoCommand $command 29 | * 30 | * @return void 31 | */ 32 | public function handle(DisableRepoCommand $command) 33 | { 34 | $repo = $command->getRepo(); 35 | 36 | foreach ($repo->commits as $commit) { 37 | $commit->delete(); 38 | } 39 | 40 | foreach ($repo->forks as $fork) { 41 | $fork->delete(); 42 | } 43 | 44 | event(new RepoWasDisabledEvent($repo)); 45 | 46 | $repo->delete(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/Handlers/Commands/EnableRepoCommandHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Commands; 14 | 15 | use StyleCI\StyleCI\Commands\EnableRepoCommand; 16 | use StyleCI\StyleCI\Events\RepoWasEnabledEvent; 17 | use StyleCI\StyleCI\Models\Repo; 18 | 19 | /** 20 | * This is the enable repo command handler class. 21 | * 22 | * @author Graham Campbell 23 | */ 24 | class EnableRepoCommandHandler 25 | { 26 | /** 27 | * Handle the enable repo command. 28 | * 29 | * @param \StyleCI\StyleCI\Commands\EnableRepoCommand $command 30 | * 31 | * @return void 32 | */ 33 | public function handle(EnableRepoCommand $command) 34 | { 35 | $repo = new Repo(); 36 | 37 | $repo->id = $command->getId(); 38 | $repo->name = $command->getName(); 39 | $repo->user_id = $command->getUser()->id; 40 | 41 | $repo->save(); 42 | 43 | event(new RepoWasEnabledEvent($repo)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/Handlers/Commands/LoginCommandHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Commands; 14 | 15 | use StyleCI\StyleCI\Commands\LoginCommand; 16 | use StyleCI\StyleCI\Events\UserHasLoggedInEvent; 17 | use StyleCI\StyleCI\Events\UserHasSignedUpEvent; 18 | use StyleCI\StyleCI\Models\User; 19 | use StyleCI\StyleCI\Repositories\UserRepository; 20 | 21 | /** 22 | * This is the login command handler class. 23 | * 24 | * @author Graham Campbell 25 | * @author Joseph Cohen 26 | */ 27 | class LoginCommandHandler 28 | { 29 | /** 30 | * The user repository instance. 31 | * 32 | * @var \StyleCI\StyleCI\Repositories\UserRepository 33 | */ 34 | protected $userRepository; 35 | 36 | /** 37 | * Create a new login command handler instance. 38 | * 39 | * @param \StyleCI\StyleCI\Repositories\UserRepository $userRepository 40 | * 41 | * @return void 42 | */ 43 | public function __construct(UserRepository $userRepository) 44 | { 45 | $this->userRepository = $userRepository; 46 | } 47 | 48 | /** 49 | * Handle the login command. 50 | * 51 | * @param \StyleCI\StyleCI\Commands\LoginCommand $command 52 | * 53 | * @return void 54 | */ 55 | public function handle(LoginCommand $command) 56 | { 57 | $user = $this->userRepository->findOrGenerate($command->getId()); 58 | 59 | $new = $user->exists === false; 60 | 61 | $user->name = $command->getName(); 62 | $user->email = $command->getEmail(); 63 | $user->username = $command->getUsername(); 64 | $user->access_token = $command->getToken(); 65 | 66 | $user->save(); 67 | 68 | if ($new) { 69 | event(new UserHasSignedUpEvent($user)); 70 | } 71 | 72 | event(new UserHasLoggedInEvent($user)); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/Handlers/Events/AnalysisNotificationsHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Events; 14 | 15 | use Illuminate\Contracts\Mail\Mailer; 16 | use Illuminate\Mail\Message; 17 | use StyleCI\StyleCI\Events\AnalysisHasCompletedEvent; 18 | use StyleCI\StyleCI\Models\Commit; 19 | use StyleCI\StyleCI\Repositories\UserRepository; 20 | 21 | /** 22 | * This is the analysis notification handler class. 23 | * 24 | * @author Graham Campbell 25 | */ 26 | class AnalysisNotificationsHandler 27 | { 28 | /** 29 | * The user repository instance. 30 | * 31 | * @var \StyleCI\StyleCI\Repositories\UserRepository 32 | */ 33 | protected $userRepository; 34 | 35 | /** 36 | * The mailer instance. 37 | * 38 | * @var \Illuminate\Contracts\Mail\Mailer 39 | */ 40 | protected $mailer; 41 | 42 | /** 43 | * Create a new analysis notifications handler instance. 44 | * 45 | * @param \StyleCI\StyleCI\Repositories\UserRepository $userRepository 46 | * @param \Illuminate\Contracts\Mail\Mailer $mailer 47 | * 48 | * @return void 49 | */ 50 | public function __construct(UserRepository $userRepository, Mailer $mailer) 51 | { 52 | $this->userRepository = $userRepository; 53 | $this->mailer = $mailer; 54 | } 55 | 56 | /** 57 | * Handle the analysis has completed event. 58 | * 59 | * @param \StyleCI\StyleCI\Events\AnalysisHasCompletedEvent $event 60 | * 61 | * @return void 62 | */ 63 | public function handle(AnalysisHasCompletedEvent $event) 64 | { 65 | $commit = $event->getCommit(); 66 | 67 | // if the analysis didn't fail, then we don't need to notify anyone 68 | if ($commit->status !== 2) { 69 | return; 70 | } 71 | 72 | $this->sendMessages($commit); 73 | } 74 | 75 | /** 76 | * Send out messages to the relevant users. 77 | * 78 | * We're emailing all repo collaborators that have accounts on StyleCI. 79 | * 80 | * @todo Allow users to set their notification preferences, and support 81 | * notifying users though other mediums than just email. 82 | * 83 | * @param \StyleCI\StyleCI\Models\Commit $commit 84 | * 85 | * @return void 86 | */ 87 | protected function sendMessages(Commit $commit) 88 | { 89 | $mail = [ 90 | 'repo' => $commit->name(), 91 | 'commit' => $commit->message, 92 | 'link' => route('commit_path', $commit->id), 93 | 'subject' => 'Failed Analysis', 94 | ]; 95 | 96 | foreach ($this->userRepository->collaborators($commit) as $user) { 97 | $mail['email'] = $user->email; 98 | $this->mailer->send('emails.failed', $mail, function (Message $message) use ($mail) { 99 | $message->to($mail['email'])->subject($mail['subject']); 100 | }); 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/Handlers/Events/AuthenticationHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Events; 14 | 15 | use Illuminate\Contracts\Auth\Guard; 16 | use StyleCI\StyleCI\Events\UserHasLoggedInEvent; 17 | 18 | /** 19 | * This is the authentication handler class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class AuthenticationHandler 24 | { 25 | /** 26 | * The authentication guard instance. 27 | * 28 | * @var \Illuminate\Contracts\Auth\Guard 29 | */ 30 | protected $auth; 31 | 32 | /** 33 | * Create a new authentication handler instance. 34 | * 35 | * @param \Illuminate\Contracts\Auth\Guard $auth 36 | * 37 | * @return void 38 | */ 39 | public function __construct(Guard $auth) 40 | { 41 | $this->auth = $auth; 42 | } 43 | 44 | /** 45 | * Handle the user has logged in event. 46 | * 47 | * @param \StyleCI\StyleCI\Events\UserHasLoggedInEvent $event 48 | * 49 | * @return void 50 | */ 51 | public function handle(UserHasLoggedInEvent $event) 52 | { 53 | $user = $event->getUser(); 54 | 55 | $this->auth->login($user, true); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Handlers/Events/CommitStatusHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Events; 14 | 15 | use StyleCI\StyleCI\Events\AnalysisHasCompletedEvent; 16 | use StyleCI\StyleCI\GitHub\Status; 17 | 18 | /** 19 | * This is the commit status handler class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class CommitStatusHandler 24 | { 25 | /** 26 | * The status instance. 27 | * 28 | * @var \StyleCI\StyleCI\GitHub\Status 29 | */ 30 | protected $status; 31 | 32 | /** 33 | * Create a new commit status handler instance. 34 | * 35 | * @param \StyleCI\StyleCI\GitHub\Status $status 36 | * 37 | * @return void 38 | */ 39 | public function __construct(Status $status) 40 | { 41 | $this->status = $status; 42 | } 43 | 44 | /** 45 | * Handle the analysis has completed event. 46 | * 47 | * @param \StyleCI\StyleCI\Events\AnalysisHasCompletedEvent $event 48 | * 49 | * @return void 50 | */ 51 | public function handle(AnalysisHasCompletedEvent $event) 52 | { 53 | $commit = $event->getCommit(); 54 | 55 | $this->status->push($commit); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Handlers/Events/DisableHooksHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Events; 14 | 15 | use StyleCI\StyleCI\Events\RepoWasDisabledEvent; 16 | use StyleCI\StyleCI\GitHub\Hooks; 17 | 18 | /** 19 | * This is the disable hooks handler class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class DisableHooksHandler 24 | { 25 | /** 26 | * The hooks instance. 27 | * 28 | * @var \StyleCI\StyleCI\GitHub\Hooks 29 | */ 30 | protected $hooks; 31 | 32 | /** 33 | * Create a new disable hooks handler instance. 34 | * 35 | * @param \StyleCI\StyleCI\GitHub\Hooks $hooks 36 | * 37 | * @return void 38 | */ 39 | public function __construct(Hooks $hooks) 40 | { 41 | $this->hooks = $hooks; 42 | } 43 | 44 | /** 45 | * Handle the repo was disabled event. 46 | * 47 | * @param \StyleCI\StyleCI\Events\RepoWasDisabledEvent $event 48 | * 49 | * @return void 50 | */ 51 | public function handle(RepoWasDisabledEvent $event) 52 | { 53 | $repo = $event->getRepo(); 54 | 55 | $this->hooks->disable($repo); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Handlers/Events/EnableHooksHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Events; 14 | 15 | use StyleCI\StyleCI\Events\RepoWasEnabledEvent; 16 | use StyleCI\StyleCI\GitHub\Hooks; 17 | 18 | /** 19 | * This is the enable hooks handler class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class EnableHooksHandler 24 | { 25 | /** 26 | * The hooks instance. 27 | * 28 | * @var \StyleCI\StyleCI\GitHub\Hooks 29 | */ 30 | protected $hooks; 31 | 32 | /** 33 | * Create a new enable hooks handler instance. 34 | * 35 | * @param \StyleCI\StyleCI\GitHub\Hooks $hooks 36 | * 37 | * @return void 38 | */ 39 | public function __construct(Hooks $hooks) 40 | { 41 | $this->hooks = $hooks; 42 | } 43 | 44 | /** 45 | * Handle the repo was enabled event. 46 | * 47 | * @param \StyleCI\StyleCI\Events\RepoWasEnabledEvent $event 48 | * 49 | * @return void 50 | */ 51 | public function handle(RepoWasEnabledEvent $event) 52 | { 53 | $repo = $event->getRepo(); 54 | 55 | // cleanup existing hooks first 56 | $this->hooks->disable($repo); 57 | 58 | $this->hooks->enable($repo); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/Handlers/Events/RealTimeStatusHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Events; 14 | 15 | use McCool\LaravelAutoPresenter\PresenterDecorator; 16 | use StyleCI\StyleCI\Events\AnalysisHasCompletedEvent; 17 | use Vinkla\Pusher\PusherManager; 18 | 19 | /** 20 | * This is the real time status handler class. 21 | * 22 | * @author Graham Campbell 23 | * @author Joseph Cohen 24 | */ 25 | class RealTimeStatusHandler 26 | { 27 | /** 28 | * The pusher instance. 29 | * 30 | * @var \Vinkla\Pusher\PusherManager 31 | */ 32 | protected $pusher; 33 | 34 | /** 35 | * The presenter instance. 36 | * 37 | * @var \McCool\LaravelAutoPresenter\PresenterDecorator 38 | */ 39 | protected $presenter; 40 | 41 | /** 42 | * Create a new analysis notifications handler instance. 43 | * 44 | * @param \Vinkla\Pusher\PusherManager $pusher 45 | * @param \McCool\LaravelAutoPresenter\PresenterDecorator $presenter 46 | * 47 | * @return void 48 | */ 49 | public function __construct(PusherManager $pusher, PresenterDecorator $presenter) 50 | { 51 | $this->pusher = $pusher; 52 | $this->presenter = $presenter; 53 | } 54 | 55 | /** 56 | * Handle the analysis has completed event. 57 | * 58 | * @param \StyleCI\StyleCI\Events\AnalysisHasCompletedEvent|\StyleCI\StyleCI\Events\AnalysisWasQueuedEvent $event 59 | * 60 | * @return void 61 | */ 62 | public function handle($event) 63 | { 64 | $commit = $this->presenter->decorate($event->getCommit()); 65 | 66 | if ($commit->ref !== 'refs/heads/master') { 67 | return; 68 | } 69 | 70 | $this->pusher->trigger('ch-'.$commit->repo_id, 'CommitStatusUpdatedEvent', ['event' => $commit->toArray()]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/Handlers/Events/RepoCacheFlushHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Events; 14 | 15 | use StyleCI\StyleCI\Events\UserHasLoggedInEvent; 16 | use StyleCI\StyleCI\GitHub\Repos; 17 | 18 | /** 19 | * This is the repo cache flush handler class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class RepoCacheFlushHandler 24 | { 25 | /** 26 | * The github repos instance. 27 | * 28 | * @var \StyleCI\StyleCI\GitHub\Repos 29 | */ 30 | protected $repos; 31 | 32 | /** 33 | * Create a new repo cache flush handler instance. 34 | * 35 | * @param \StyleCI\StyleCI\GitHub\Repos $repos 36 | * 37 | * @return void 38 | */ 39 | public function __construct(Repos $repos) 40 | { 41 | $this->repos = $repos; 42 | } 43 | 44 | /** 45 | * Handle the user has logged in event. 46 | * 47 | * @param \StyleCI\StyleCI\Events\UserHasLoggedInEvent $event 48 | * 49 | * @return void 50 | */ 51 | public function handle(UserHasLoggedInEvent $event) 52 | { 53 | $user = $event->getUser(); 54 | 55 | $this->repos->flush($user); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Handlers/Events/RevokeTokenHandler.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Events; 14 | 15 | use StyleCI\StyleCI\Events\UserHasRageQuitEvent; 16 | use StyleCI\StyleCI\GitHub\Tokens; 17 | 18 | /** 19 | * This is the revoke token handler class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class RevokeTokenHandler 24 | { 25 | /** 26 | * The tokens instance. 27 | * 28 | * @var \StyleCI\StyleCI\GitHub\Tokens 29 | */ 30 | protected $tokens; 31 | 32 | /** 33 | * Create a new revoke token handler instance. 34 | * 35 | * @param \StyleCI\StyleCI\GitHub\Tokens $tokens 36 | * 37 | * @return void 38 | */ 39 | public function __construct(Tokens $tokens) 40 | { 41 | $this->tokens = $tokens; 42 | } 43 | 44 | /** 45 | * Handle the user has rage quit event. 46 | * 47 | * @param \StyleCI\StyleCI\Events\UserHasRageQuitEvent $event 48 | * 49 | * @return void 50 | */ 51 | public function handle(UserHasRageQuitEvent $event) 52 | { 53 | $user = $event->getUser(); 54 | 55 | $this->tokens->revoke($user->access_token); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Handlers/Middleware/UseDatabaseTransaction.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Handlers\Middleware; 14 | 15 | use Closure; 16 | use Illuminate\Database\DatabaseManager; 17 | 18 | /** 19 | * This is the use database transaction middleware class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class UseDatabaseTransaction 24 | { 25 | /** 26 | * The database manager. 27 | * 28 | * @var \Illuminate\Database\DatabaseManager 29 | */ 30 | protected $db; 31 | 32 | /** 33 | * Create a use database transaction middleware instance. 34 | * 35 | * @param \Illuminate\Database\DatabaseManager $db 36 | * 37 | * @return void 38 | */ 39 | public function __construct(DatabaseManager $db) 40 | { 41 | $this->db = $db; 42 | } 43 | 44 | /** 45 | * Handle the command. 46 | * 47 | * @param object $command 48 | * @param \Closure $next 49 | * 50 | * @return mixed 51 | */ 52 | public function handle($command, Closure $next) 53 | { 54 | return $this->db->transaction(function () use ($command, $next) { 55 | return $next($command); 56 | }); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/Http/Controllers/AbstractController.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Controllers; 14 | 15 | use Illuminate\Foundation\Bus\DispatchesCommands; 16 | use Illuminate\Foundation\Validation\ValidatesRequests; 17 | use Illuminate\Routing\Controller; 18 | 19 | /** 20 | * This is the abstract controller class. 21 | * 22 | * @author Graham Campbell 23 | */ 24 | abstract class AbstractController extends Controller 25 | { 26 | use DispatchesCommands, ValidatesRequests; 27 | } 28 | -------------------------------------------------------------------------------- /app/Http/Controllers/AuthController.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Controllers; 14 | 15 | use Illuminate\Contracts\Auth\Guard; 16 | use Illuminate\Support\Facades\Redirect; 17 | use Laravel\Socialite\Contracts\Factory as Socialite; 18 | use StyleCI\StyleCI\Commands\LoginCommand; 19 | 20 | /** 21 | * This is the auth controller class. 22 | * 23 | * @author Graham Campbell 24 | * @author Joseph Cohen 25 | */ 26 | class AuthController extends AbstractController 27 | { 28 | /** 29 | * Create a new authentication controller instance. 30 | * 31 | * @return void 32 | */ 33 | public function __construct() 34 | { 35 | $this->middleware('guest', ['except' => ['handleLogout']]); 36 | } 37 | 38 | /** 39 | * Connect to the GitHub provider using OAuth. 40 | * 41 | * @param \Laravel\Socialite\Contracts\Factory $socialite 42 | * 43 | * @return \Illuminate\Http\RedirectResponse 44 | */ 45 | public function handleLogin(Socialite $socialite) 46 | { 47 | $response = $socialite->driver('github'); 48 | 49 | $response->scopes([ 50 | 'read:org', 51 | 'user:email', 52 | 'public_repo', 53 | 'admin:repo_hook', 54 | ]); 55 | 56 | return $response->redirect(); 57 | } 58 | 59 | /** 60 | * Get the user access token to save notifications. 61 | * 62 | * @param \Laravel\Socialite\Contracts\Factory $socialite 63 | * 64 | * @return \Illuminate\Http\Response 65 | */ 66 | public function handleCallback(Socialite $socialite) 67 | { 68 | $socialiteUser = $socialite->driver('github')->user(); 69 | 70 | $this->dispatch(new LoginCommand($socialiteUser->id, $socialiteUser->name, $socialiteUser->nickname, $socialiteUser->email, $socialiteUser->token)); 71 | 72 | return Redirect::route('repos_path'); 73 | } 74 | 75 | /** 76 | * Logout a user account. 77 | * 78 | * @param \Illuminate\Contracts\Auth\Guard $auth 79 | * 80 | * @return \Illuminate\Http\Response 81 | */ 82 | public function handleLogout(Guard $auth) 83 | { 84 | $auth->logout(); 85 | 86 | return Redirect::route('home'); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /app/Http/Controllers/CommitController.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Controllers; 14 | 15 | use Illuminate\Support\Facades\Response; 16 | use Illuminate\Support\Facades\View; 17 | use StyleCI\StyleCI\Models\Commit; 18 | 19 | /** 20 | * This is the commit controller class. 21 | * 22 | * @author Graham Campbell 23 | */ 24 | class CommitController extends AbstractController 25 | { 26 | /** 27 | * Handles the request to show a commit. 28 | * 29 | * @param \StyleCI\StyleCI\Models\Commit $commit 30 | * 31 | * @return \Illuminate\View\View 32 | */ 33 | public function handleShow(Commit $commit) 34 | { 35 | return View::make('commit', compact('commit')); 36 | } 37 | 38 | /** 39 | * Handles the request to show a commit diff. 40 | * 41 | * @param \StyleCI\StyleCI\Models\Commit $commit 42 | * 43 | * @return \Illuminate\Http\Response 44 | */ 45 | public function handleDiff(Commit $commit) 46 | { 47 | return Response::make($commit->diff)->header('Content-Type', 'text/plain; charset=UTF-8'); 48 | } 49 | 50 | /** 51 | * Handles the request to download a commit diff. 52 | * 53 | * @param \StyleCI\StyleCI\Models\Commit $commit 54 | * 55 | * @return \Illuminate\Http\Response 56 | */ 57 | public function handleDiffDownload(Commit $commit) 58 | { 59 | return Response::make($commit->diff) 60 | ->header('Content-Type', 'text/plain; charset=UTF-8') 61 | ->header('Content-Disposition', 'attachment; filename=patch.txt'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/Http/Controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Controllers; 14 | 15 | use Illuminate\Support\Facades\View; 16 | 17 | /** 18 | * This is the home controller class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class HomeController extends AbstractController 23 | { 24 | /** 25 | * Handles the request to view the homepage. 26 | * 27 | * @return \Illuminate\View\View 28 | */ 29 | public function handle() 30 | { 31 | return View::make('index'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http; 14 | 15 | use Illuminate\Foundation\Http\Kernel as HttpKernel; 16 | 17 | /** 18 | * This is the http kernel class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class Kernel extends HttpKernel 23 | { 24 | /** 25 | * The application's global HTTP middleware stack. 26 | * 27 | * @var string[] 28 | */ 29 | protected $middleware = [ 30 | 'Fideloper\Proxy\TrustProxies', 31 | 'StyleCI\StyleCI\Http\Middleware\CheckForMaintenanceMode', 32 | 'Illuminate\Cookie\Middleware\EncryptCookies', 33 | 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', 34 | 'Illuminate\Session\Middleware\StartSession', 35 | 'Illuminate\View\Middleware\ShareErrorsFromSession', 36 | 'StyleCI\StyleCI\Http\Middleware\VerifyCsrfToken', 37 | ]; 38 | 39 | /** 40 | * The application's route middleware. 41 | * 42 | * @var string[] 43 | */ 44 | protected $routeMiddleware = [ 45 | 'auth' => 'StyleCI\StyleCI\Http\Middleware\Authenticate', 46 | 'guest' => 'StyleCI\StyleCI\Http\Middleware\RedirectIfAuthenticated', 47 | ]; 48 | } 49 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Middleware; 14 | 15 | use Closure; 16 | use Illuminate\Contracts\Auth\Guard; 17 | use Illuminate\Http\Request; 18 | use Symfony\Component\HttpKernel\Exception\HttpException; 19 | 20 | /** 21 | * This is the authenticate middleware class. 22 | * 23 | * @author Graham Campbell 24 | * @author Joseph Cohen 25 | */ 26 | class Authenticate 27 | { 28 | /** 29 | * The authentication guard instance. 30 | * 31 | * @var \Illuminate\Contracts\Auth\Guard 32 | */ 33 | protected $auth; 34 | 35 | /** 36 | * The allowed user ids. 37 | * 38 | * @var array 39 | */ 40 | protected $allowed; 41 | 42 | /** 43 | * Create a new filter instance. 44 | * 45 | * @param \Illuminate\Contracts\Auth\Guard $auth 46 | * @param array $allowed 47 | * 48 | * @return void 49 | */ 50 | public function __construct(Guard $auth, array $allowed) 51 | { 52 | $this->auth = $auth; 53 | $this->allowed = $allowed; 54 | } 55 | 56 | /** 57 | * Handle an incoming request. 58 | * 59 | * @param \Illuminate\Http\Request $request 60 | * @param \Closure $next 61 | * 62 | * @throws \Symfony\Component\HttpKernel\Exception\HttpException 63 | * 64 | * @return mixed 65 | */ 66 | public function handle(Request $request, Closure $next) 67 | { 68 | if ($this->auth->guest()) { 69 | throw new HttpException(401); 70 | } 71 | 72 | if (count($this->allowed) > 0 && !in_array($this->auth->user()->id, $this->allowed)) { 73 | throw new HttpException(403, 'You are not whitelisted.'); 74 | } 75 | 76 | return $next($request); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Middleware; 14 | 15 | use Closure; 16 | use Illuminate\Contracts\Foundation\Application; 17 | use Illuminate\Contracts\View\Factory as View; 18 | use Illuminate\Http\Request; 19 | use Illuminate\Http\Response; 20 | 21 | /** 22 | * This is the check for maintenance mode middleware class. 23 | * 24 | * @author Graham Campbell 25 | */ 26 | class CheckForMaintenanceMode 27 | { 28 | /** 29 | * The application instance. 30 | * 31 | * @var \Illuminate\Contracts\Foundation\Application 32 | */ 33 | protected $app; 34 | 35 | /** 36 | * The view factory instance. 37 | * 38 | * @var \Illuminate\Contracts\View\Factory 39 | */ 40 | protected $view; 41 | 42 | /** 43 | * Create a new check for maintenance mode instance. 44 | * 45 | * @param \Illuminate\Contracts\Foundation\Application $app 46 | * @param \Illuminate\Contracts\View\Factory $view 47 | * 48 | * @return void 49 | */ 50 | public function __construct(Application $app, View $view) 51 | { 52 | $this->app = $app; 53 | $this->view = $view; 54 | } 55 | 56 | /** 57 | * Handle an incoming request. 58 | * 59 | * @param \Illuminate\Http\Request $request 60 | * @param \Closure $next 61 | * 62 | * @return mixed 63 | */ 64 | public function handle(Request $request, Closure $next) 65 | { 66 | if ($this->app->isDownForMaintenance()) { 67 | return new Response($this->view->make('maintenance')->render(), 503); 68 | } 69 | 70 | return $next($request); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Middleware; 14 | 15 | use Closure; 16 | use Illuminate\Contracts\Auth\Guard; 17 | use Illuminate\Http\RedirectResponse; 18 | use Illuminate\Http\Request; 19 | use Illuminate\Support\Facades\URL; 20 | 21 | /** 22 | * This is the redirect if authenticated middleware class. 23 | * 24 | * @author Graham Campbell 25 | * @author Joseph Cohen 26 | */ 27 | class RedirectIfAuthenticated 28 | { 29 | /** 30 | * The authentication guard instance. 31 | * 32 | * @var \Illuminate\Contracts\Auth\Guard 33 | */ 34 | protected $auth; 35 | 36 | /** 37 | * Create a new filter instance. 38 | * 39 | * @param \Illuminate\Contracts\Auth\Guard $auth 40 | * 41 | * @return void 42 | */ 43 | public function __construct(Guard $auth) 44 | { 45 | $this->auth = $auth; 46 | } 47 | 48 | /** 49 | * Handle an incoming request. 50 | * 51 | * @param \Illuminate\Http\Request $request 52 | * @param \Closure $next 53 | * 54 | * @return mixed 55 | */ 56 | public function handle(Request $request, Closure $next) 57 | { 58 | if ($this->auth->check()) { 59 | return new RedirectResponse(URL::route('home')); 60 | } 61 | 62 | return $next($request); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Middleware; 14 | 15 | use Closure; 16 | use Illuminate\Http\Request; 17 | use Symfony\Component\HttpKernel\Exception\HttpException; 18 | use Symfony\Component\Security\Core\Util\StringUtils; 19 | 20 | /** 21 | * This is the verify CSRF token middleware class. 22 | * 23 | * @author Graham Campbell 24 | */ 25 | class VerifyCsrfToken 26 | { 27 | /** 28 | * Handle an incoming request. 29 | * 30 | * @param \Illuminate\Http\Request $request 31 | * @param \Closure $next 32 | * 33 | * @throws \Symfony\Component\HttpKernel\Exception\HttpException 34 | * 35 | * @return mixed 36 | */ 37 | public function handle(Request $request, Closure $next) 38 | { 39 | if ($this->isReading($request) || $this->tokensMatch($request)) { 40 | return $next($request); 41 | } 42 | 43 | throw new HttpException(403, 'The CSRF token could not be validated.'); 44 | } 45 | 46 | /** 47 | * Determine if the http request uses a read verb. 48 | * 49 | * @param \Illuminate\Http\Request $request 50 | * 51 | * @return bool 52 | */ 53 | protected function isReading(Request $request) 54 | { 55 | return in_array($request->method(), ['HEAD', 'GET', 'OPTIONS'], true); 56 | } 57 | 58 | /** 59 | * Determine if the session and input csrf tokens match. 60 | * 61 | * @param \Illuminate\Http\Request $request 62 | * 63 | * @return bool 64 | */ 65 | protected function tokensMatch(Request $request) 66 | { 67 | $token = $request->session()->token(); 68 | 69 | return StringUtils::equals($token, $request->input('_token')) || StringUtils::equals($token, $request->header('X-CSRF-TOKEN')); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/Http/Routes/AccountRoutes.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Routes; 14 | 15 | use Illuminate\Contracts\Routing\Registrar; 16 | 17 | /** 18 | * This is the account routes class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class AccountRoutes 23 | { 24 | /** 25 | * Define the account routes. 26 | * 27 | * @param \Illuminate\Contracts\Routing\Registrar $router 28 | * 29 | * @return void 30 | */ 31 | public function map(Registrar $router) 32 | { 33 | $router->post('auth/login', [ 34 | 'as' => 'auth_login_path', 35 | 'uses' => 'AuthController@handleLogin', 36 | ]); 37 | 38 | $router->get('auth/github-callback', [ 39 | 'as' => 'auth_callback_path', 40 | 'uses' => 'AuthController@handleCallback', 41 | ]); 42 | 43 | $router->post('auth/logout', [ 44 | 'as' => 'auth_logout_path', 45 | 'uses' => 'AuthController@handleLogout', 46 | ]); 47 | 48 | $router->get('account', [ 49 | 'as' => 'account_path', 50 | 'uses' => 'AccountController@handleShow', 51 | ]); 52 | 53 | $router->delete('account/delete', [ 54 | 'as' => 'account_delete_path', 55 | 'uses' => 'AccountController@handleDelete', 56 | ]); 57 | 58 | $router->get('account/repos', [ 59 | 'as' => 'account_repos_path', 60 | 'uses' => 'AccountController@handleListRepos', 61 | ]); 62 | 63 | $router->post('account/repos/sync', [ 64 | 'as' => 'account_repos_sync_path', 65 | 'uses' => 'AccountController@handleSync', 66 | ]); 67 | 68 | $router->post('account/enable/{id}', [ 69 | 'as' => 'enable_repo_path', 70 | 'uses' => 'AccountController@handleEnable', 71 | ]); 72 | 73 | $router->post('account/disable/{repo}', [ 74 | 'as' => 'disable_repo_path', 75 | 'uses' => 'AccountController@handleDisable', 76 | ]); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/Http/Routes/MainRoutes.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Routes; 14 | 15 | use Illuminate\Contracts\Routing\Registrar; 16 | 17 | /** 18 | * This is the main routes class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class MainRoutes 23 | { 24 | /** 25 | * Define the main routes. 26 | * 27 | * @param \Illuminate\Contracts\Routing\Registrar $router 28 | * 29 | * @return void 30 | */ 31 | public function map(Registrar $router) 32 | { 33 | $router->get('/', [ 34 | 'as' => 'home', 35 | 'uses' => 'HomeController@handle', 36 | ]); 37 | 38 | $router->post('github-callback', [ 39 | 'as' => 'webhook_callback', 40 | 'uses' => 'GitHubController@handle', 41 | ]); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/Http/Routes/RepoRoutes.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Http\Routes; 14 | 15 | use Illuminate\Contracts\Routing\Registrar; 16 | 17 | /** 18 | * This is the repo routes class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class RepoRoutes 23 | { 24 | /** 25 | * Define the repo routes. 26 | * 27 | * @param \Illuminate\Contracts\Routing\Registrar $router 28 | * 29 | * @return void 30 | */ 31 | public function map(Registrar $router) 32 | { 33 | $router->get('repos', [ 34 | 'as' => 'repos_path', 35 | 'uses' => 'RepoController@handleList' 36 | ]); 37 | 38 | $router->get('repos/{repo}', [ 39 | 'as' => 'repo_path', 40 | 'uses' => 'RepoController@handleShow' 41 | ]); 42 | 43 | $router->post('repos/{repo}/analyse', [ 44 | 'as' => 'repo_analyse_path', 45 | 'uses' => 'RepoController@handleAnalyse' 46 | ]); 47 | 48 | $router->get('commits/{commit}', [ 49 | 'as' => 'commit_path', 50 | 'uses' => 'CommitController@handleShow' 51 | ]); 52 | 53 | $router->get('commits/{commit}/diff', [ 54 | 'as' => 'commit_diff_path', 55 | 'uses' => 'CommitController@handleDiff', 56 | ]); 57 | 58 | $router->get('commits/{commit}/diff/download', [ 59 | 'as' => 'commit_download_path', 60 | 'uses' => 'CommitController@handleDiffDownload', 61 | ]); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/Models/Commit.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Models; 14 | 15 | use Illuminate\Database\Eloquent\Model; 16 | use McCool\LaravelAutoPresenter\HasPresenter; 17 | use StyleCI\StyleCI\Presenters\CommitPresenter; 18 | 19 | /** 20 | * This is the commit model class. 21 | * 22 | * @author Graham Campbell 23 | */ 24 | class Commit extends Model implements HasPresenter 25 | { 26 | /** 27 | * Indicates if the IDs are auto-incrementing. 28 | * 29 | * @var bool 30 | */ 31 | public $incrementing = false; 32 | 33 | /** 34 | * A list of methods protected from mass assignment. 35 | * 36 | * @var array 37 | */ 38 | protected $guarded = ['_token', '_method']; 39 | 40 | /** 41 | * The attributes that should be casted to native types. 42 | * 43 | * @var array 44 | */ 45 | protected $casts = [ 46 | 'status' => 'int', 47 | 'time' => 'float', 48 | 'memory' => 'float', 49 | ]; 50 | 51 | /** 52 | * Get the repo relation. 53 | * 54 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo 55 | */ 56 | public function repo() 57 | { 58 | return $this->belongsTo(Repo::class); 59 | } 60 | 61 | /** 62 | * Get the fork relation. 63 | * 64 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo 65 | */ 66 | public function fork() 67 | { 68 | return $this->belongsTo(Fork::class); 69 | } 70 | 71 | /** 72 | * Get the presenter class. 73 | * 74 | * @return string 75 | */ 76 | public function getPresenterClass() 77 | { 78 | return CommitPresenter::class; 79 | } 80 | 81 | /** 82 | * Get the commit status description. 83 | * 84 | * @return string 85 | */ 86 | public function description() 87 | { 88 | switch ($this->status) { 89 | case 1: 90 | return 'The StyleCI checks passed'; 91 | case 2: 92 | return 'The StyleCI checks failed'; 93 | default: 94 | return 'The StyleCI checks are pending'; 95 | } 96 | } 97 | 98 | /** 99 | * Get the commit's repo name. 100 | * 101 | * @return string 102 | */ 103 | public function name() 104 | { 105 | if (empty($this->fork_id)) { 106 | return $this->repo->name; 107 | } else { 108 | return $this->fork->name; 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/Models/Fork.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Models; 14 | 15 | use Illuminate\Database\Eloquent\Model; 16 | 17 | /** 18 | * This is the fork model class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class Fork extends Model 23 | { 24 | /** 25 | * Indicates if the IDs are auto-incrementing. 26 | * 27 | * @var bool 28 | */ 29 | public $incrementing = false; 30 | 31 | /** 32 | * A list of methods protected from mass assignment. 33 | * 34 | * @var array 35 | */ 36 | protected $guarded = ['_token', '_method']; 37 | 38 | /** 39 | * Get the repo relation. 40 | * 41 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo 42 | */ 43 | public function repo() 44 | { 45 | return $this->belongsTo(Repo::class); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/Models/Repo.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Models; 14 | 15 | use Illuminate\Database\Eloquent\Model; 16 | 17 | /** 18 | * This is the repo model class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class Repo extends Model 23 | { 24 | /** 25 | * Indicates if the IDs are auto-incrementing. 26 | * 27 | * @var bool 28 | */ 29 | public $incrementing = false; 30 | 31 | /** 32 | * A list of methods protected from mass assignment. 33 | * 34 | * @var array 35 | */ 36 | protected $guarded = ['_token', '_method']; 37 | 38 | /** 39 | * Get the commits relation. 40 | * 41 | * @return \Illuminate\Database\Eloquent\Relations\HasMany 42 | */ 43 | public function commits() 44 | { 45 | return $this->hasMany(Commit::class); 46 | } 47 | 48 | /** 49 | * Get the forks relation. 50 | * 51 | * @return \Illuminate\Database\Eloquent\Relations\HasMany 52 | */ 53 | public function forks() 54 | { 55 | return $this->hasMany(Fork::class); 56 | } 57 | 58 | /** 59 | * Get the user relation. 60 | * 61 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo 62 | */ 63 | public function user() 64 | { 65 | return $this->belongsTo(User::class); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Models; 14 | 15 | use Illuminate\Auth\Authenticatable; 16 | use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; 17 | use Illuminate\Database\Eloquent\Model; 18 | use McCool\LaravelAutoPresenter\HasPresenter; 19 | use StyleCI\StyleCI\Presenters\UserPresenter; 20 | 21 | /** 22 | * This is the user model class. 23 | * 24 | * @author Graham Campbell 25 | * @author Joseph Cohen 26 | */ 27 | class User extends Model implements AuthenticatableContract, HasPresenter 28 | { 29 | use Authenticatable; 30 | 31 | /** 32 | * Indicates if the IDs are auto-incrementing. 33 | * 34 | * @var bool 35 | */ 36 | public $incrementing = false; 37 | 38 | /** 39 | * The attributes that are mass assignable. 40 | * 41 | * @var array 42 | */ 43 | protected $fillable = ['name', 'email']; 44 | 45 | /** 46 | * The attributes excluded from the model's JSON form. 47 | * 48 | * @var array 49 | */ 50 | protected $hidden = ['access_token', 'remember_token']; 51 | 52 | /** 53 | * Get the repos relation. 54 | * 55 | * @return \Illuminate\Database\Eloquent\Relations\HasMany 56 | */ 57 | public function repos() 58 | { 59 | return $this->hasMany(Repo::class); 60 | } 61 | 62 | /** 63 | * Get the presenter class. 64 | * 65 | * @return string 66 | */ 67 | public function getPresenterClass() 68 | { 69 | return UserPresenter::class; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/Presenters/CommitPresenter.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Presenters; 14 | 15 | use Illuminate\Contracts\Support\Arrayable; 16 | use McCool\LaravelAutoPresenter\BasePresenter; 17 | 18 | /** 19 | * This is the commit presenter class. 20 | * 21 | * @author Graham Campbell 22 | * @author Joseph Cohen 23 | */ 24 | class CommitPresenter extends BasePresenter implements Arrayable 25 | { 26 | /** 27 | * Get the commit status summary. 28 | * 29 | * @return string 30 | */ 31 | public function summary() 32 | { 33 | switch ($this->wrappedObject->status) { 34 | case 1: 35 | return 'PASSED'; 36 | case 2: 37 | return 'FAILED'; 38 | default: 39 | return 'PENDING'; 40 | } 41 | } 42 | 43 | /** 44 | * Get the commit's repo shorthand id. 45 | * 46 | * @return string 47 | */ 48 | public function shorthandId() 49 | { 50 | return substr($this->wrappedObject->id, 0, 6); 51 | } 52 | 53 | /** 54 | * Get the commit's style check executed time. 55 | * 56 | * @return string 57 | */ 58 | public function excecutedTime() 59 | { 60 | // if analysis is pending, then we don't have a time yet 61 | if ($this->wrappedObject->status === 0) { 62 | return '-'; 63 | } 64 | 65 | $time = $this->wrappedObject->time; 66 | 67 | // display the time to 1 dp if less than 10 secs 68 | if ($time < 10) { 69 | return number_format(round($time, 1), 1).' sec'; 70 | } 71 | 72 | // display the time to nearest second if less than 2 min 73 | if ($time < 120) { 74 | return number_format(round($time, 0)).' sec'; 75 | } 76 | 77 | // display the time to nearest minute otherwise 78 | return number_format(round($time / 60, 0)).' min'; 79 | } 80 | 81 | /** 82 | * Get the commit's time ago. 83 | * 84 | * @return string 85 | */ 86 | public function timeAgo() 87 | { 88 | return $this->wrappedObject->created_at->diffForHumans(); 89 | } 90 | 91 | /** 92 | * Convert presented commit to an array. 93 | * 94 | * @return array 95 | */ 96 | public function toArray() 97 | { 98 | return [ 99 | 'id' => $this->wrappedObject->id, 100 | 'repo_id' => $this->wrappedObject->repo_id, 101 | 'repo_name' => $this->wrappedObject->repo->name, 102 | 'message' => $this->wrappedObject->message, 103 | 'description' => $this->wrappedObject->description(), 104 | 'status' => $this->wrappedObject->status, 105 | 'summary' => $this->summary(), 106 | 'timeAgo' => $this->timeAgo(), 107 | 'shorthandId' => $this->shorthandId(), 108 | 'excecutedTime' => $this->excecutedTime(), 109 | 'link' => route('commit_path', $this->wrappedObject->id), 110 | ]; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /app/Presenters/UserPresenter.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Presenters; 14 | 15 | use McCool\LaravelAutoPresenter\BasePresenter; 16 | 17 | /** 18 | * This is the user presenter class. 19 | * 20 | * @author Graham Campbell 21 | * @author Joseph Cohen 22 | */ 23 | class UserPresenter extends BasePresenter 24 | { 25 | /** 26 | * Returns a Gravatar URL for the users email address. 27 | * 28 | * @param int $size 29 | * 30 | * @return string 31 | */ 32 | public function gravatar($size = 200) 33 | { 34 | return sprintf('https://www.gravatar.com/avatar/%s?size=%d', md5($this->email), $size); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Providers; 14 | 15 | use Illuminate\Support\ServiceProvider; 16 | use StyleCI\StyleCI\Http\Middleware\Authenticate; 17 | 18 | /** 19 | * This is the app service provider class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class AppServiceProvider extends ServiceProvider 24 | { 25 | /** 26 | * Register the service provider. 27 | * 28 | * @return void 29 | */ 30 | public function register() 31 | { 32 | $this->registerAuthenticate(); 33 | } 34 | 35 | /** 36 | * Register the auth middleware. 37 | * 38 | * @return void 39 | */ 40 | protected function registerAuthenticate() 41 | { 42 | $this->app->singleton(Authenticate::class, function ($app) { 43 | $auth = $app['auth.driver']; 44 | $allowed = $app->config->get('styleci.allowed', []); 45 | 46 | return new Authenticate($auth, $allowed); 47 | }); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/Providers/BusServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Providers; 14 | 15 | use Illuminate\Bus\Dispatcher; 16 | use Illuminate\Support\ServiceProvider; 17 | use StyleCI\StyleCI\Handlers\Middleware\UseDatabaseTransaction; 18 | 19 | /** 20 | * This is the bus service provider class. 21 | * 22 | * @author Graham Campbell 23 | */ 24 | class BusServiceProvider extends ServiceProvider 25 | { 26 | /** 27 | * Boot the service provider. 28 | * 29 | * @param \Illuminate\Bus\Dispatcher $dispatcher 30 | * 31 | * @return void 32 | */ 33 | public function boot(Dispatcher $dispatcher) 34 | { 35 | $dispatcher->pipeThrough([UseDatabaseTransaction::class]); 36 | 37 | $dispatcher->mapUsing(function ($command) { 38 | return Dispatcher::simpleMapping($command, 'StyleCI\StyleCI\Commands', 'StyleCI\StyleCI\Handlers\Commands'); 39 | }); 40 | } 41 | 42 | /** 43 | * Register the service provider. 44 | * 45 | * @return void 46 | */ 47 | public function register() 48 | { 49 | // 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/Providers/ComposerServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Providers; 14 | 15 | use Illuminate\Support\ServiceProvider; 16 | 17 | /** 18 | * This is the view composer service provider class. 19 | * 20 | * @author Joseph Cohen 21 | */ 22 | class ComposerServiceProvider extends ServiceProvider 23 | { 24 | /** 25 | * Bootstrap the application services. 26 | * 27 | * @return void 28 | */ 29 | public function boot() 30 | { 31 | // 32 | } 33 | 34 | /** 35 | * Register the application services. 36 | * 37 | * @return void 38 | */ 39 | public function register() 40 | { 41 | $this->app->view->composer('*', 'StyleCI\StyleCI\Composers\CurrentUserComposer'); 42 | $this->app->view->composer('*', 'StyleCI\StyleCI\Composers\CurrentUrlComposer'); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Providers; 14 | 15 | use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; 16 | 17 | /** 18 | * This is the event service provider class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class EventServiceProvider extends ServiceProvider 23 | { 24 | /** 25 | * The event handler mappings for the application. 26 | * 27 | * @var array 28 | */ 29 | protected $listen = [ 30 | 'StyleCI\StyleCI\Events\AnalysisHasCompletedEvent' => [ 31 | 'StyleCI\StyleCI\Handlers\Events\CommitStatusHandler', 32 | 'StyleCI\StyleCI\Handlers\Events\AnalysisNotificationsHandler', 33 | 'StyleCI\StyleCI\Handlers\Events\RealTimeStatusHandler', 34 | ], 35 | 'StyleCI\StyleCI\Events\AnalysisWasQueuedEvent' => [ 36 | 'StyleCI\StyleCI\Handlers\Events\RealTimeStatusHandler', 37 | ], 38 | 'StyleCI\StyleCI\Events\RepoWasDisabledEvent' => [ 39 | 'StyleCI\StyleCI\Handlers\Events\DisableHooksHandler', 40 | ], 41 | 'StyleCI\StyleCI\Events\RepoWasEnabledEvent' => [ 42 | 'StyleCI\StyleCI\Handlers\Events\EnableHooksHandler', 43 | ], 44 | 'StyleCI\StyleCI\Events\UserHasLoggedInEvent' => [ 45 | 'StyleCI\StyleCI\Handlers\Events\AuthenticationHandler', 46 | 'StyleCI\StyleCI\Handlers\Events\RepoCacheFlushHandler', 47 | ], 48 | 'StyleCI\StyleCI\Events\UserHasRageQuitEvent' => [ 49 | 'StyleCI\StyleCI\Handlers\Events\RevokeTokenHandler', 50 | ], 51 | ]; 52 | } 53 | -------------------------------------------------------------------------------- /app/Providers/RepositoryServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Providers; 14 | 15 | use Illuminate\Support\ServiceProvider; 16 | use StyleCI\StyleCI\Repositories\CommitRepository; 17 | use StyleCI\StyleCI\Repositories\ForkRepository; 18 | use StyleCI\StyleCI\Repositories\RepoRepository; 19 | use StyleCI\StyleCI\Repositories\UserRepository; 20 | 21 | /** 22 | * This is the repository service provider class. 23 | * 24 | * @author Graham Campbell 25 | */ 26 | class RepositoryServiceProvider extends ServiceProvider 27 | { 28 | /** 29 | * Register the service provider. 30 | * 31 | * @return void 32 | */ 33 | public function register() 34 | { 35 | $this->registerCommitRepository(); 36 | $this->registerForkRepository(); 37 | $this->registerRepoRepository(); 38 | $this->registerUserRepository(); 39 | } 40 | 41 | /** 42 | * Register the commit repository. 43 | * 44 | * @return void 45 | */ 46 | protected function registerCommitRepository() 47 | { 48 | $this->app->singleton('styleci.commitrepository', function ($app) { 49 | $commits = $app['styleci.commits']; 50 | 51 | return new CommitRepository($commits); 52 | }); 53 | 54 | $this->app->alias('styleci.commitrepository', CommitRepository::class); 55 | } 56 | 57 | /** 58 | * Register the fork repository. 59 | * 60 | * @return void 61 | */ 62 | protected function registerForkRepository() 63 | { 64 | $this->app->singleton('styleci.forkrepository', function () { 65 | return new ForkRepository(); 66 | }); 67 | 68 | $this->app->alias('styleci.forkrepository', ForkRepository::class); 69 | } 70 | 71 | /** 72 | * Register the repo repository. 73 | * 74 | * @return void 75 | */ 76 | protected function registerRepoRepository() 77 | { 78 | $this->app->singleton('styleci.reporepository', function ($app) { 79 | $repos = $app['styleci.repos']; 80 | 81 | return new RepoRepository($repos); 82 | }); 83 | 84 | $this->app->alias('styleci.reporepository', RepoRepository::class); 85 | } 86 | 87 | /** 88 | * Register the user repository. 89 | * 90 | * @return void 91 | */ 92 | protected function registerUserRepository() 93 | { 94 | $this->app->singleton('styleci.userrepository', function ($app) { 95 | $collaborators = $app['styleci.collaborators']; 96 | 97 | return new UserRepository($collaborators); 98 | }); 99 | 100 | $this->app->alias('styleci.userrepository', UserRepository::class); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Providers; 14 | 15 | use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; 16 | use Illuminate\Routing\Router; 17 | 18 | /** 19 | * This is the route service provider class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class RouteServiceProvider extends ServiceProvider 24 | { 25 | /** 26 | * This namespace is applied to the controller routes in your routes file. 27 | * 28 | * In addition, it is set as the URL generator's root namespace. 29 | * 30 | * @var string 31 | */ 32 | protected $namespace = 'StyleCI\StyleCI\Http\Controllers'; 33 | 34 | /** 35 | * Define the route model bindings, pattern filters, etc. 36 | * 37 | * @param \Illuminate\Routing\Router $router 38 | * 39 | * @return void 40 | */ 41 | public function boot(Router $router) 42 | { 43 | parent::boot($router); 44 | 45 | $router->model('commit', 'StyleCI\StyleCI\Models\Commit'); 46 | $router->model('repo', 'StyleCI\StyleCI\Models\Repo'); 47 | } 48 | 49 | /** 50 | * Define the routes for the application. 51 | * 52 | * @param \Illuminate\Routing\Router $router 53 | * 54 | * @return void 55 | */ 56 | public function map(Router $router) 57 | { 58 | $router->group(['namespace' => $this->namespace], function (Router $router) { 59 | foreach (glob(app_path('Http//Routes').'/*.php') as $file) { 60 | $this->app->make('StyleCI\\StyleCI\\Http\\Routes\\'.basename($file, '.php'))->map($router); 61 | } 62 | }); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/Repositories/CommitRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Repositories; 14 | 15 | use StyleCI\StyleCI\GitHub\Commits; 16 | use StyleCI\StyleCI\Models\Commit; 17 | 18 | /** 19 | * This is the commit repository class. 20 | * 21 | * @author Graham Campbell 22 | */ 23 | class CommitRepository 24 | { 25 | /** 26 | * The commits instance. 27 | * 28 | * @var \StyleCI\StyleCI\GitHub\Commits 29 | */ 30 | protected $commits; 31 | 32 | /** 33 | * Create a new commit repository instance. 34 | * 35 | * @param \StyleCI\StyleCI\GitHub\Commits $commits 36 | * 37 | * @return void 38 | */ 39 | public function __construct(Commits $commits) 40 | { 41 | $this->commits = $commits; 42 | } 43 | 44 | /** 45 | * Find a commit by its id. 46 | * 47 | * @param string $id 48 | * 49 | * @return \StyleCI\StyleCI\Models\Commit|null 50 | */ 51 | public function find($id) 52 | { 53 | return Commit::find($id); 54 | } 55 | 56 | /** 57 | * Find a commit by its id, or generate a new one. 58 | * 59 | * @param string $id 60 | * @param array $attributes 61 | * 62 | * @return \StyleCI\StyleCI\Models\Commit 63 | */ 64 | public function findOrGenerate($id, array $attributes = []) 65 | { 66 | $commit = $this->find($id); 67 | 68 | // if the commit exists, we're done here 69 | if ($commit) { 70 | return $commit; 71 | } 72 | 73 | // otherwise, create a new commit, allowing the id to be overwritten 74 | return (new Commit())->forceFill(array_merge(['id' => $id], $attributes)); 75 | } 76 | 77 | /** 78 | * Find a commit by its id for analysis. 79 | * 80 | * @param string $id 81 | * @param string $repo 82 | * @param string $branch 83 | * 84 | * @return \StyleCI\StyleCI\Models\Commit 85 | */ 86 | public function findForAnalysis($id, $repo, $branch) 87 | { 88 | $commit = $this->findOrGenerate($id, ['repo_id' => $repo]); 89 | 90 | if (empty($commit->message)) { 91 | $commit->message = $this->commits->get($commit)['commit']['message']; 92 | } 93 | 94 | if (empty($commit->ref)) { 95 | $commit->ref = "refs/heads/$branch"; 96 | } 97 | 98 | $commit->status = 0; 99 | $commit->save(); 100 | 101 | return $commit; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/Repositories/ForkRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Repositories; 14 | 15 | use StyleCI\StyleCI\Models\Fork; 16 | 17 | /** 18 | * This is the fork repository class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class ForkRepository 23 | { 24 | /** 25 | * Find a fork by its id. 26 | * 27 | * @param string $id 28 | * 29 | * @return \StyleCI\StyleCI\Models\Fork|null 30 | */ 31 | public function find($id) 32 | { 33 | return Fork::find($id); 34 | } 35 | 36 | /** 37 | * Find a fork by its id, or generate a new one. 38 | * 39 | * @param string $id 40 | * @param array $attributes 41 | * 42 | * @return \StyleCI\StyleCI\Models\Fork 43 | */ 44 | public function findOrGenerate($id, array $attributes = []) 45 | { 46 | $fork = $this->find($id); 47 | 48 | // if the fork exists, we're done here 49 | if ($fork) { 50 | return $fork; 51 | } 52 | 53 | // otherwise, create a new fork, allowing the id to be overwritten 54 | return (new Fork())->forceFill(array_merge(['id' => $id], $attributes)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/Repositories/RepoRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Repositories; 14 | 15 | use StyleCI\StyleCI\GitHub\Repos; 16 | use StyleCI\StyleCI\Models\Repo; 17 | use StyleCI\StyleCI\Models\User; 18 | 19 | /** 20 | * This is the repo repository class. 21 | * 22 | * @author Graham Campbell 23 | */ 24 | class RepoRepository 25 | { 26 | /** 27 | * The github repos instance. 28 | * 29 | * @var \StyleCI\StyleCI\GitHub\Repos 30 | */ 31 | protected $repos; 32 | 33 | /** 34 | * Create a new repo repository instance. 35 | * 36 | * @param \StyleCI\StyleCI\GitHub\Repos $repos 37 | * 38 | * @return void 39 | */ 40 | public function __construct(Repos $repos) 41 | { 42 | $this->repos = $repos; 43 | } 44 | 45 | /** 46 | * Find all repos. 47 | * 48 | * @param string $id 49 | * 50 | * @return \Illuminate\Database\Eloquent\Collection 51 | */ 52 | public function all($id) 53 | { 54 | return Repo::orderBy('name', 'asc')->get(); 55 | } 56 | 57 | /** 58 | * Find all repos a user can view. 59 | * 60 | * @param \StyleCI\StyleCI\Models\User $user 61 | * @param bool $admin 62 | * 63 | * @return \Illuminate\Database\Eloquent\Collection 64 | */ 65 | public function allByUser(User $user, $admin = false) 66 | { 67 | return Repo::whereIn('id', array_keys($this->repos->get($user, $admin)))->orderBy('name', 'asc')->get(); 68 | } 69 | 70 | /** 71 | * Find a repo by its id. 72 | * 73 | * @param string $id 74 | * 75 | * @return \StyleCI\StyleCI\Models\Repo|null 76 | */ 77 | public function find($id) 78 | { 79 | return Repo::find($id); 80 | } 81 | 82 | /** 83 | * Find a repo by its name. 84 | * 85 | * @param string $name 86 | * 87 | * @return \StyleCI\StyleCI\Models\Repo|null 88 | */ 89 | public function findByName($name) 90 | { 91 | return Repo::where('name', $name)->first(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/Repositories/UserRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\StyleCI\Repositories; 14 | 15 | use Illuminate\Database\Eloquent\Model; 16 | use StyleCI\StyleCI\GitHub\Collaborators; 17 | use StyleCI\StyleCI\Models\User; 18 | 19 | /** 20 | * This is the user repository class. 21 | * 22 | * @author Graham Campbell 23 | */ 24 | class UserRepository 25 | { 26 | /** 27 | * The collaborators instance. 28 | * 29 | * @var \StyleCI\StyleCI\GitHub\Collaborators 30 | */ 31 | protected $collaborators; 32 | 33 | /** 34 | * Create a new user repository instance. 35 | * 36 | * @param \StyleCI\StyleCI\GitHub\Collaborators $collaborators 37 | * 38 | * @return void 39 | */ 40 | public function __construct(Collaborators $collaborators) 41 | { 42 | $this->collaborators = $collaborators; 43 | } 44 | 45 | /** 46 | * Find all users marked as collaborators to the provided model. 47 | * 48 | * @param \Illuminate\Database\Eloquent\Model 49 | * 50 | * @return \Illuminate\Database\Eloquent\Collection 51 | */ 52 | public function collaborators(Model $model) 53 | { 54 | return User::whereIn('id', $this->collaborators->get($model))->get(); 55 | } 56 | 57 | /** 58 | * Find a user by its id. 59 | * 60 | * @param string $id 61 | * 62 | * @return \StyleCI\StyleCI\Models\User|null 63 | */ 64 | public function find($id) 65 | { 66 | return User::find($id); 67 | } 68 | 69 | /** 70 | * Find a user by its id, or generate a new one. 71 | * 72 | * @param string $id 73 | * @param array $attributes 74 | * 75 | * @return \StyleCI\StyleCI\Models\User 76 | */ 77 | public function findOrGenerate($id, array $attributes = []) 78 | { 79 | $user = $this->find($id); 80 | 81 | // if the user exists, we're done here 82 | if ($user) { 83 | return $user; 84 | } 85 | 86 | // otherwise, create a new user, allowing the id to be overwritten 87 | return (new User())->forceFill(array_merge(['id' => $id], $attributes)); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 8 | * (c) Joseph Cohen 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | /* 15 | |-------------------------------------------------------------------------- 16 | | Register The Auto Loader 17 | |-------------------------------------------------------------------------- 18 | | 19 | | Composer provides a convenient, automatically generated class loader 20 | | for our application. We just need to utilize it! We'll require it 21 | | into the script here so that we do not have to worry about the 22 | | loading of any our classes "manually". Feels great to relax. 23 | | 24 | */ 25 | 26 | require __DIR__.'/bootstrap/autoload.php'; 27 | 28 | $app = require_once __DIR__.'/bootstrap/app.php'; 29 | 30 | /* 31 | |-------------------------------------------------------------------------- 32 | | Run The Artisan Application 33 | |-------------------------------------------------------------------------- 34 | | 35 | | When we run the console application, the current CLI command will be 36 | | executed in this console and the response sent back to a terminal 37 | | or another output device for the developers. Here goes nothing! 38 | | 39 | */ 40 | 41 | $kernel = $app->make('Illuminate\Contracts\Console\Kernel'); 42 | 43 | $status = $kernel->handle( 44 | $input = new Symfony\Component\Console\Input\ArgvInput(), 45 | new Symfony\Component\Console\Output\ConsoleOutput() 46 | ); 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Shutdown The Application 51 | |-------------------------------------------------------------------------- 52 | | 53 | | Once Artisan has finished running. We will fire off the shutdown events 54 | | so that any final work may be done by the application before we shut 55 | | down the process. This is the last thing to happen to the request. 56 | | 57 | */ 58 | 59 | $kernel->terminate($input, $status); 60 | 61 | exit($status); 62 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | /* 14 | |-------------------------------------------------------------------------- 15 | | Create The Application 16 | |-------------------------------------------------------------------------- 17 | | 18 | | The first thing we will do is create a new Laravel application instance 19 | | which serves as the "glue" for all the components of Laravel, and is 20 | | the IoC container for the system binding all of the various parts. 21 | | 22 | */ 23 | 24 | $app = new Illuminate\Foundation\Application(realpath(__DIR__.'/../')); 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Bind Important Interfaces 29 | |-------------------------------------------------------------------------- 30 | | 31 | | Next, we need to bind some important interfaces into the container so 32 | | we will be able to resolve them when needed. The kernels serve the 33 | | incoming requests to this application from both the web and CLI. 34 | | 35 | */ 36 | 37 | $app->singleton('Illuminate\Contracts\Http\Kernel', 'StyleCI\StyleCI\Http\Kernel'); 38 | 39 | $app->singleton('Illuminate\Contracts\Console\Kernel', 'StyleCI\StyleCI\Console\Kernel'); 40 | 41 | $app->singleton('Illuminate\Contracts\Debug\ExceptionHandler', 'StyleCI\StyleCI\Exceptions\Handler'); 42 | 43 | /* 44 | |-------------------------------------------------------------------------- 45 | | Return The Application 46 | |-------------------------------------------------------------------------- 47 | | 48 | | This script returns the application instance. The instance is given to 49 | | the calling script so we can separate the building of the instances 50 | | from the actual running of the application and sending responses. 51 | | 52 | */ 53 | 54 | return $app; 55 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | define('LARAVEL_START', microtime(true)); 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Register The Composer Auto Loader 18 | |-------------------------------------------------------------------------- 19 | | 20 | | Composer provides a convenient, automatically generated class loader 21 | | for our application. We just need to utilize it! We'll require it 22 | | into the script here so that we do not have to worry about the 23 | | loading of any our classes "manually". Feels great to relax. 24 | | 25 | */ 26 | 27 | require __DIR__.'/../vendor/autoload.php'; 28 | 29 | /* 30 | |-------------------------------------------------------------------------- 31 | | Include The Compiled Class File 32 | |-------------------------------------------------------------------------- 33 | | 34 | | To dramatically increase your application's performance, you may use a 35 | | compiled class file which contains all of the classes commonly used 36 | | by a request. The Artisan "optimize" is used to create this file. 37 | | 38 | */ 39 | 40 | $compiledPath = __DIR__.'/../storage/framework/compiled.php'; 41 | 42 | if (file_exists($compiledPath)) { 43 | require $compiledPath; 44 | } 45 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "StyleCI", 3 | "dependencies": { 4 | "animate-sass": "~0.6.2", 5 | "bootstrap-sass-official": "~3.3.3", 6 | "font-awesome": "~4.3.0", 7 | "jquery-timeago": "~1.4.1", 8 | "lodash": "~3.0.1", 9 | "pusher": "~2.2.3", 10 | "SyntaxHighlighter": "3.0.9" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "styleci/styleci", 3 | "description": "StyleCI Is A PHP Coding Style Continuous Integration Service", 4 | "keywords": ["laravel", "framework", "styleci", "ci", "cs", "coding standard", "StyleCI", "StyleCI", "Graham Campbell", "GrahamCampbell"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Graham Campbell", 9 | "email": "graham@mineuk.com" 10 | }, 11 | { 12 | "name": "Joseph Cohen", 13 | "email": "joseph.cohen@dinkbit.com" 14 | } 15 | ], 16 | "repositories": [ 17 | { 18 | "type": "vcs", 19 | "url": "https://github.com/StyleCI/PHP-CS-Fixer" 20 | }, 21 | { 22 | "type": "vcs", 23 | "url": "https://github.com/StyleCI/php-github-api" 24 | }, 25 | { 26 | "type": "vcs", 27 | "url": "https://github.com/StyleCI/socialite" 28 | } 29 | ], 30 | "require": { 31 | "php": ">=5.5.0", 32 | "laravel/framework": "5.0.*", 33 | "laravel/socialite": "~3.0", 34 | "fideloper/proxy": "~3.0", 35 | "guzzlehttp/guzzle": "~5.0", 36 | "graham-campbell/binput": "~3.0", 37 | "graham-campbell/exceptions": "~1.0", 38 | "graham-campbell/core": "~2.0", 39 | "graham-campbell/github": "~3.0", 40 | "graham-campbell/htmlmin": "~3.0", 41 | "knplabs/github-api": "~1.5", 42 | "mccool/laravel-auto-presenter": "~3.0", 43 | "styleci/fixer": "0.1.*", 44 | "vinkla/pusher": "~1.0" 45 | }, 46 | "require-dev": { 47 | "graham-campbell/testbench": "~2.0" 48 | }, 49 | "autoload": { 50 | "classmap": [ 51 | "database" 52 | ], 53 | "psr-4": { 54 | "StyleCI\\StyleCI\\": "app/" 55 | } 56 | }, 57 | "autoload-dev": { 58 | "psr-4": { 59 | "StyleCI\\Tests\\StyleCI\\": "tests/" 60 | } 61 | }, 62 | "scripts": { 63 | "post-install-cmd": [ 64 | "php artisan clear-compiled", 65 | "php artisan optimize --force" 66 | ], 67 | "pre-update-cmd": [ 68 | "php artisan clear-compiled" 69 | ], 70 | "post-update-cmd": [ 71 | "php artisan clear-compiled", 72 | "php artisan optimize --force" 73 | ], 74 | "post-create-project-cmd": [ 75 | "php artisan key:generate" 76 | ] 77 | }, 78 | "config": { 79 | "preferred-install": "dist" 80 | }, 81 | "extra": { 82 | "branch-alias": { 83 | "dev-master": "0.1-dev" 84 | } 85 | }, 86 | "minimum-stability": "dev", 87 | "prefer-stable": true 88 | } 89 | -------------------------------------------------------------------------------- /config/analytics.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Enable Google Analytics 18 | |-------------------------------------------------------------------------- 19 | | 20 | | This defines if Google Analytics is enabled. 21 | | 22 | | Requires a valid Google Analytics Tracking ID. 23 | | 24 | | Default to false. 25 | | 26 | */ 27 | 28 | 'google' => false, 29 | 30 | /* 31 | |-------------------------------------------------------------------------- 32 | | Google Analytics Tracking ID 33 | |-------------------------------------------------------------------------- 34 | | 35 | | This defines the Google Analytics Tracking ID to use. 36 | | 37 | | Default to 'UA-XXXXXXXX-X'. 38 | | 39 | */ 40 | 41 | 'googleid' => 'UA-XXXXXXXX-X', 42 | 43 | ]; 44 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Default Authentication Driver 18 | |-------------------------------------------------------------------------- 19 | | 20 | | This option controls the authentication driver that will be utilized. 21 | | This driver manages the retrieval and authentication of the users 22 | | attempting to get access to protected areas of your application. 23 | | 24 | | Supported: "database", "eloquent" 25 | | 26 | */ 27 | 28 | 'driver' => 'eloquent', 29 | 30 | /* 31 | |-------------------------------------------------------------------------- 32 | | Authentication Model 33 | |-------------------------------------------------------------------------- 34 | | 35 | | When using the "Eloquent" authentication driver, we need to know which 36 | | Eloquent model should be used to retrieve your users. Of course, it 37 | | is often just the "User" model but you may use whatever you like. 38 | | 39 | */ 40 | 41 | 'model' => 'StyleCI\StyleCI\Models\User', 42 | 43 | /* 44 | |-------------------------------------------------------------------------- 45 | | Authentication Table 46 | |-------------------------------------------------------------------------- 47 | | 48 | | When using the "Database" authentication driver, we need to know which 49 | | table should be used to retrieve your users. We have chosen a basic 50 | | default value but you may easily change it to any table you like. 51 | | 52 | */ 53 | 54 | 'table' => 'users', 55 | 56 | /* 57 | |-------------------------------------------------------------------------- 58 | | Password Reset Settings 59 | |-------------------------------------------------------------------------- 60 | | 61 | | Here you may set the options for resetting passwords including the view 62 | | that is your password reset e-mail. You can also set the name of the 63 | | table that maintains all of the reset tokens for your application. 64 | | 65 | | The expire time is the number of minutes that the reset token should be 66 | | considered valid. This security feature keeps tokens short-lived so 67 | | they have less time to be guessed. You may change this as needed. 68 | | 69 | */ 70 | 71 | 'password' => [ 72 | 'email' => 'emails.password', 73 | 'table' => 'password_resets', 74 | 'expire' => 60, 75 | ], 76 | 77 | ]; 78 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Default Cache Store 18 | |-------------------------------------------------------------------------- 19 | | 20 | | This option controls the default cache connection that gets used while 21 | | using this caching library. This connection is used when another is 22 | | not explicitly specified when executing a given caching function. 23 | | 24 | */ 25 | 26 | 'default' => env('CACHE_DRIVER', 'file'), 27 | 28 | /* 29 | |-------------------------------------------------------------------------- 30 | | Cache Stores 31 | |-------------------------------------------------------------------------- 32 | | 33 | | Here you may define all of the cache "stores" for your application as 34 | | well as their drivers. You may even define multiple stores for the 35 | | same cache driver to group types of items stored in your caches. 36 | | 37 | */ 38 | 39 | 'stores' => [ 40 | 41 | 'apc' => [ 42 | 'driver' => 'apc', 43 | ], 44 | 45 | 'array' => [ 46 | 'driver' => 'array', 47 | ], 48 | 49 | 'database' => [ 50 | 'driver' => 'database', 51 | 'table' => 'cache', 52 | 'connection' => null, 53 | ], 54 | 55 | 'file' => [ 56 | 'driver' => 'file', 57 | 'path' => storage_path().'/framework/cache', 58 | ], 59 | 60 | 'memcached' => [ 61 | 'driver' => 'memcached', 62 | 'servers' => [ 63 | [ 64 | 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100, 65 | ], 66 | ], 67 | ], 68 | 69 | 'redis' => [ 70 | 'driver' => 'redis', 71 | 'connection' => 'default', 72 | ], 73 | 74 | ], 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Cache Key Prefix 79 | |-------------------------------------------------------------------------- 80 | | 81 | | When utilizing a RAM based store such as APC or Memcached, there might 82 | | be other applications utilizing the same cache. So, we'll specify a 83 | | value to get prefixed to all our keys so we can avoid collisions. 84 | | 85 | */ 86 | 87 | 'prefix' => 'styleci', 88 | 89 | ]; 90 | -------------------------------------------------------------------------------- /config/compile.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Additional Compiled Classes 18 | |-------------------------------------------------------------------------- 19 | | 20 | | Here you may specify additional classes to include in the compiled file 21 | | generated by the `artisan optimize` command. These should be classes 22 | | that are included on basically every request into the application. 23 | | 24 | */ 25 | 26 | 'files' => [], 27 | 28 | /* 29 | |-------------------------------------------------------------------------- 30 | | Compiled File Providers 31 | |-------------------------------------------------------------------------- 32 | | 33 | | Here you may list service providers which define a "compiles" function 34 | | that returns additional files that should be compiled, providing an 35 | | easy way to get common files from any packages you are utilizing. 36 | | 37 | */ 38 | 39 | 'providers' => [], 40 | 41 | ]; 42 | -------------------------------------------------------------------------------- /config/core.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Site Name 18 | |-------------------------------------------------------------------------- 19 | | 20 | | This defines the site name. 21 | | 22 | | Default to 'Laravel Application'. 23 | | 24 | */ 25 | 26 | 'name' => 'StyleCI', 27 | 28 | /* 29 | |-------------------------------------------------------------------------- 30 | | Home Page URL 31 | |-------------------------------------------------------------------------- 32 | | 33 | | This defines the url to use for the home page. 34 | | 35 | | Default to '/'. 36 | | 37 | */ 38 | 39 | 'home' => '/', 40 | 41 | /* 42 | |-------------------------------------------------------------------------- 43 | | Page Layout 44 | |-------------------------------------------------------------------------- 45 | | 46 | | This specifies the your views should extend. 47 | | 48 | | Default to 'layouts.default'. 49 | | 50 | */ 51 | 52 | 'default' => 'layouts.default', 53 | 54 | /* 55 | |-------------------------------------------------------------------------- 56 | | Email Layout 57 | |-------------------------------------------------------------------------- 58 | | 59 | | This specifies the view that your email views should extend. 60 | | 61 | | Default to 'layouts.email'. 62 | | 63 | */ 64 | 65 | 'email' => 'layouts.email', 66 | 67 | /* 68 | |-------------------------------------------------------------------------- 69 | | Enable Commands 70 | |-------------------------------------------------------------------------- 71 | | 72 | | This enables the install/update/reset commands and bindings shipped with 73 | | this package. Other packages can read this config to save time by not 74 | | registering event command event listeners if command are disabled. 75 | | 76 | | Default to true. 77 | | 78 | */ 79 | 80 | 'commands' => true, 81 | 82 | ]; 83 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Default Filesystem Disk 18 | |-------------------------------------------------------------------------- 19 | | 20 | | Here you may specify the default filesystem disk that should be used 21 | | by the framework. A "local" driver, as well as a variety of cloud 22 | | based drivers are available for your choosing. Just store away! 23 | | 24 | | Supported: "local", "s3", "rackspace" 25 | | 26 | */ 27 | 28 | 'default' => 'local', 29 | 30 | /* 31 | |-------------------------------------------------------------------------- 32 | | Default Cloud Filesystem Disk 33 | |-------------------------------------------------------------------------- 34 | | 35 | | Many applications store files both locally and in the cloud. For this 36 | | reason, you may specify a default "cloud" driver here. This driver 37 | | will be bound as the Cloud disk implementation in the container. 38 | | 39 | */ 40 | 41 | 'cloud' => 's3', 42 | 43 | /* 44 | |-------------------------------------------------------------------------- 45 | | Filesystem Disks 46 | |-------------------------------------------------------------------------- 47 | | 48 | | Here you may configure as many filesystem "disks" as you wish, and you 49 | | may even configure multiple disks of the same driver. Defaults have 50 | | been setup for each driver as an example of the required options. 51 | | 52 | */ 53 | 54 | 'disks' => [ 55 | 56 | 'local' => [ 57 | 'driver' => 'local', 58 | 'root' => storage_path('app'), 59 | ], 60 | 61 | 's3' => [ 62 | 'driver' => 's3', 63 | 'key' => 'your-key', 64 | 'secret' => 'your-secret', 65 | 'region' => 'your-region', 66 | 'bucket' => 'your-bucket', 67 | ], 68 | 69 | 'rackspace' => [ 70 | 'driver' => 'rackspace', 71 | 'username' => 'your-username', 72 | 'key' => 'your-key', 73 | 'container' => 'your-container', 74 | 'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/', 75 | 'region' => 'IAD', 76 | ], 77 | 78 | ], 79 | 80 | ]; 81 | -------------------------------------------------------------------------------- /config/github.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Default Connection Name 18 | |-------------------------------------------------------------------------- 19 | | 20 | | Here you may specify which of the connections below you wish to use as 21 | | your default connection for all work. Of course, you may use many 22 | | connections at once using the manager class. 23 | | 24 | */ 25 | 26 | 'default' => 'main', 27 | 28 | /* 29 | |-------------------------------------------------------------------------- 30 | | GitHub Connections 31 | |-------------------------------------------------------------------------- 32 | | 33 | | Here are each of the connections setup for your application. Example 34 | | configuration has been included, but you may add as many connections as 35 | | you would like. Note that the 3 supported authentication methods are: 36 | | "application", "password", and "token". 37 | | 38 | */ 39 | 40 | 'connections' => [ 41 | 42 | 'main' => [ 43 | 'username' => env('GITHUB_CLIENT_ID'), 44 | 'password' => env('GITHUB_CLIENT_SECRET'), 45 | 'method' => 'password', 46 | ], 47 | 48 | ], 49 | 50 | ]; 51 | -------------------------------------------------------------------------------- /config/htmlmin.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Automatic Blade Optimizations 18 | |-------------------------------------------------------------------------- 19 | | 20 | | This option enables minification of the the blade views as they are 21 | | compiled. These optimizations have little impact on php processing time 22 | | as the optimizations are only applied once and are cached. This package 23 | | will do nothing by default to allow it to be used without minifying 24 | | pages automatically. 25 | | 26 | | Default: false 27 | | 28 | */ 29 | 30 | 'blade' => true, 31 | 32 | /* 33 | |-------------------------------------------------------------------------- 34 | | Force Blade Optimizations 35 | |-------------------------------------------------------------------------- 36 | | 37 | | This option forces blade minification on views where there such 38 | | minification may be dangerous. This should only be used if you are fully 39 | | aware of the potential issues this may cause. Obviously, this setting is 40 | | dependent on blade minification actually being enabled. 41 | | 42 | | PLEASE USE WITH CAUTION 43 | | 44 | | Default: false 45 | | 46 | */ 47 | 48 | 'force' => false, 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | Automatic Live Optimizations 53 | |-------------------------------------------------------------------------- 54 | | 55 | | This option enables minification of the html responses just before they 56 | | are served. These optimizations have greater impact on php processing 57 | | time as the optimizations are applied on every request. This package 58 | | will do nothing by default to allow it to be used without minifying 59 | | pages automatically. 60 | | 61 | | Default: false 62 | | 63 | */ 64 | 65 | 'live' => false, 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /config/pusher.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Default Connection Name 18 | |-------------------------------------------------------------------------- 19 | | 20 | | Here you may specify which of the connections below you wish to use as 21 | | your default connection for all work. Of course, you may use many 22 | | connections at once using the manager class. 23 | | 24 | */ 25 | 26 | 'default' => 'main', 27 | 28 | /* 29 | |-------------------------------------------------------------------------- 30 | | Pusher Connections 31 | |-------------------------------------------------------------------------- 32 | | 33 | | Here are each of the connections setup for your application. Example 34 | | configuration has been included, but you may add as many connections as 35 | | you would like. 36 | | 37 | */ 38 | 39 | 'connections' => [ 40 | 41 | 'main' => [ 42 | 'auth_key' => env('PUSHER_APP_KEY'), 43 | 'secret' => env('PUSHER_APP_SECRET'), 44 | 'app_id' => env('PUSHER_APP_ID'), 45 | 'options' => [], 46 | 'host' => null, 47 | 'port' => null, 48 | 'timeout' => null, 49 | ], 50 | 51 | ], 52 | 53 | ]; 54 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Default Queue Driver 18 | |-------------------------------------------------------------------------- 19 | | 20 | | The Laravel queue API supports a variety of back-ends via an unified 21 | | API, giving you convenient access to each back-end using the same 22 | | syntax for each one. Here you may set the default queue driver. 23 | | 24 | | Note that the styleci will not work with the "null", "sync", or "iron" 25 | | queue drivers. The recommended driver is "beanstalkd". 26 | | 27 | | Supported: "null", "sync", "database", "beanstalkd", 28 | | "sqs", "iron", "redis" 29 | | 30 | */ 31 | 32 | 'default' => env('QUEUE_DRIVER', 'database'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Queue Connections 37 | |-------------------------------------------------------------------------- 38 | | 39 | | Here you may configure the connection information for each server that 40 | | is used by your application. A default configuration has been added 41 | | for each back-end shipped with Laravel. You are free to add more. 42 | | 43 | */ 44 | 45 | 'connections' => [ 46 | 47 | 'sync' => [ 48 | 'driver' => 'sync', 49 | ], 50 | 51 | 'beanstalkd' => [ 52 | 'driver' => 'beanstalkd', 53 | 'host' => 'localhost', 54 | 'queue' => 'default', 55 | 'ttr' => 86400, 56 | ], 57 | 58 | 'database' => [ 59 | 'driver' => 'database', 60 | 'table' => 'jobs', 61 | 'queue' => 'default', 62 | 'expire' => 86400, 63 | ], 64 | 65 | 'sqs' => [ 66 | 'driver' => 'sqs', 67 | 'key' => 'your-public-key', 68 | 'secret' => 'your-secret-key', 69 | 'queue' => 'your-queue-url', 70 | 'region' => 'us-east-1', 71 | ], 72 | 73 | 'iron' => [ 74 | 'driver' => 'iron', 75 | 'host' => 'mq-aws-us-east-1.iron.io', 76 | 'token' => 'your-token', 77 | 'project' => 'your-project-id', 78 | 'queue' => 'your-queue-name', 79 | 'encrypt' => true, 80 | ], 81 | 82 | 'redis' => [ 83 | 'driver' => 'redis', 84 | 'queue' => 'default', 85 | 'expire' => 86400, 86 | ], 87 | 88 | ], 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Failed Queue Jobs 93 | |-------------------------------------------------------------------------- 94 | | 95 | | These options configure the behavior of failed queue job logging so you 96 | | can control which database and table are used to store the jobs that 97 | | have failed. You may change them to any database / table you wish. 98 | | 99 | */ 100 | 101 | 'failed' => [ 102 | 'database' => 'mysql', 'table' => 'failed_jobs', 103 | ], 104 | 105 | ]; 106 | -------------------------------------------------------------------------------- /config/security.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Evil attributes 18 | |-------------------------------------------------------------------------- 19 | | 20 | | This defines the evil attributes and they will be always be removed from 21 | | the input. 22 | | 23 | */ 24 | 'evil' => ['(? 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Third Party Services 18 | |-------------------------------------------------------------------------- 19 | | 20 | | This file is for storing the credentials for third party services such 21 | | as Stripe, Mailgun, Mandrill, and others. This file provides a sane 22 | | default location for this type of information, allowing packages 23 | | to have a conventional place to find your various credentials. 24 | | 25 | */ 26 | 27 | 'mailgun' => [ 28 | 'domain' => '', 29 | 'secret' => '', 30 | ], 31 | 32 | 'mandrill' => [ 33 | 'secret' => '', 34 | ], 35 | 36 | 'ses' => [ 37 | 'key' => '', 38 | 'secret' => '', 39 | 'region' => 'us-east-1', 40 | ], 41 | 42 | 'stripe' => [ 43 | 'model' => 'User', 44 | 'secret' => '', 45 | ], 46 | 47 | 'github' => [ 48 | 'client_id' => env('GITHUB_CLIENT_ID'), 49 | 'client_secret' => env('GITHUB_CLIENT_SECRET'), 50 | 'redirect' => env('APP_URL').'/auth/github-callback', 51 | ], 52 | 53 | ]; 54 | -------------------------------------------------------------------------------- /config/styleci.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Allowed Users 18 | |-------------------------------------------------------------------------- 19 | | 20 | | This defines list of allowed users. Empty means allow everyone. 21 | | 22 | | Default to []. 23 | | 24 | */ 25 | 26 | 'allowed' => [], 27 | 28 | ]; 29 | -------------------------------------------------------------------------------- /config/trustedproxy.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | use Illuminate\Http\Request; 14 | 15 | return [ 16 | 17 | /* 18 | |-------------------------------------------------------------------------- 19 | | Trusted Proxies 20 | |-------------------------------------------------------------------------- 21 | | 22 | | Set trusted proxy IP addresses. Both IPv4 and IPv6 addresses are 23 | | supported, along with CIDR notation. The "*" character is syntactic sugar 24 | | within TrustedProxy to trust any proxy; a requirement when you cannot 25 | | know the address of your proxy (e.g. if using Rackspace balancers). 26 | | 27 | | By default, we are trusting CloudFlare only. 28 | | 29 | */ 30 | 31 | 'proxies' => [ 32 | '204.93.240.0', 33 | '204.93.177.0', 34 | '199.27.128.0', 35 | '173.245.48.0', 36 | '103.21.244.0', 37 | '103.22.200.0', 38 | '103.31.4.0', 39 | '141.101.64.0', 40 | '108.162.192.0', 41 | '190.93.240.0', 42 | '188.114.96.0', 43 | '197.234.240.0', 44 | '198.41.128.0', 45 | '162.158.0.0', 46 | '2400:cb00::', 47 | '2606:4700::', 48 | '2803:f800::', 49 | '2405:b500::', 50 | '2405:8100::', 51 | ], 52 | 53 | /* 54 | |-------------------------------------------------------------------------- 55 | | Respected Headers 56 | |-------------------------------------------------------------------------- 57 | | 58 | | Change these if the proxy does not send the default header names. Note 59 | | that headers such as X-Forwarded-For are transformed to 60 | | HTTP_X_FORWARDED_FOR format. 61 | | 62 | | By default, we are using the Symfony defaults. 63 | | 64 | */ 65 | 66 | 'headers' => [ 67 | Request::HEADER_CLIENT_IP => 'X_FORWARDED_FOR', 68 | Request::HEADER_CLIENT_HOST => 'X_FORWARDED_HOST', 69 | Request::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO', 70 | Request::HEADER_CLIENT_PORT => 'X_FORWARDED_PORT', 71 | ], 72 | 73 | ]; 74 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | View Storage Paths 18 | |-------------------------------------------------------------------------- 19 | | 20 | | Most templating systems load templates from disk. Here you may specify 21 | | an array of paths that should be checked for your views. Of course 22 | | the usual Laravel view path has already been registered for you. 23 | | 24 | */ 25 | 26 | 'paths' => [realpath(base_path('resources/views'))], 27 | 28 | /* 29 | |-------------------------------------------------------------------------- 30 | | Compiled View Path 31 | |-------------------------------------------------------------------------- 32 | | 33 | | This option determines where all the compiled Blade templates will be 34 | | stored for your application. Typically, this is within the storage 35 | | directory. However, as usual, you are free to change this value. 36 | | 37 | */ 38 | 39 | 'compiled' => realpath(storage_path('framework/views')), 40 | 41 | ]; 42 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/migrations/2015_01_18_120400_create_repos_table.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | use Illuminate\Database\Migrations\Migration; 14 | use Illuminate\Database\Schema\Blueprint; 15 | use Illuminate\Support\Facades\Schema; 16 | 17 | /** 18 | * This is the create repos table migration class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class CreateReposTable extends Migration 23 | { 24 | /** 25 | * Run the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function up() 30 | { 31 | Schema::create('repos', function (Blueprint $table) { 32 | $table->bigInteger('id')->unsigned()->primary(); 33 | $table->string('user_id')->index(); 34 | $table->string('name', 128)->unique(); 35 | $table->timestamps(); 36 | }); 37 | } 38 | 39 | /** 40 | * Reverse the migrations. 41 | * 42 | * @return void 43 | */ 44 | public function down() 45 | { 46 | Schema::drop('repos'); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /database/migrations/2015_01_18_120401_create_commits_table.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | use Illuminate\Database\Migrations\Migration; 14 | use Illuminate\Database\Schema\Blueprint; 15 | use Illuminate\Support\Facades\Schema; 16 | 17 | /** 18 | * This is the create commits table migration class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class CreateCommitsTable extends Migration 23 | { 24 | /** 25 | * Run the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function up() 30 | { 31 | Schema::create('commits', function (Blueprint $table) { 32 | $table->char('id', 40)->primary(); 33 | $table->bigInteger('repo_id')->unsigned()->index(); 34 | $table->bigInteger('fork_id')->unsigned()->nullable(); 35 | $table->string('ref', 128); 36 | $table->string('message', 128); 37 | $table->tinyInteger('status')->unsigned()->default(0); 38 | $table->float('time'); 39 | $table->float('memory'); 40 | $table->longText('diff'); 41 | $table->timestamps(); 42 | }); 43 | } 44 | 45 | /** 46 | * Reverse the migrations. 47 | * 48 | * @return void 49 | */ 50 | public function down() 51 | { 52 | Schema::drop('commits'); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /database/migrations/2015_01_18_120402_create_forks_table.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | use Illuminate\Database\Migrations\Migration; 14 | use Illuminate\Database\Schema\Blueprint; 15 | use Illuminate\Support\Facades\Schema; 16 | 17 | /** 18 | * This is the create forks table migration class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class CreateForksTable extends Migration 23 | { 24 | /** 25 | * Run the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function up() 30 | { 31 | Schema::create('forks', function (Blueprint $table) { 32 | $table->bigInteger('id')->unsigned()->primary(); 33 | $table->bigInteger('repo_id')->unsigned()->index(); 34 | $table->string('name', 128)->unique(); 35 | $table->timestamps(); 36 | }); 37 | } 38 | 39 | /** 40 | * Reverse the migrations. 41 | * 42 | * @return void 43 | */ 44 | public function down() 45 | { 46 | Schema::drop('forks'); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /database/migrations/2015_01_18_120403_create_jobs_table.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | use Illuminate\Database\Migrations\Migration; 14 | use Illuminate\Database\Schema\Blueprint; 15 | use Illuminate\Support\Facades\Schema; 16 | 17 | /** 18 | * This is the create jobs table migration class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class CreateJobsTable extends Migration 23 | { 24 | /** 25 | * Run the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function up() 30 | { 31 | Schema::create('jobs', function (Blueprint $table) { 32 | $table->bigIncrements('id'); 33 | $table->string('queue'); 34 | $table->text('payload'); 35 | $table->tinyInteger('attempts')->unsigned(); 36 | $table->tinyInteger('reserved')->unsigned(); 37 | $table->unsignedInteger('reserved_at')->nullable(); 38 | $table->unsignedInteger('available_at'); 39 | $table->unsignedInteger('created_at'); 40 | }); 41 | } 42 | 43 | /** 44 | * Reverse the migrations. 45 | * 46 | * @return void 47 | */ 48 | public function down() 49 | { 50 | Schema::drop('jobs'); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /database/migrations/2015_01_18_120404_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | use Illuminate\Database\Migrations\Migration; 14 | use Illuminate\Database\Schema\Blueprint; 15 | use Illuminate\Support\Facades\Schema; 16 | 17 | /** 18 | * This is the create failed jobs table migration class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class CreateFailedJobsTable extends Migration 23 | { 24 | /** 25 | * Run the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function up() 30 | { 31 | Schema::create('failed_jobs', function (Blueprint $table) { 32 | $table->bigIncrements('id'); 33 | $table->text('connection'); 34 | $table->text('queue'); 35 | $table->text('payload'); 36 | $table->timestamp('failed_at'); 37 | }); 38 | } 39 | 40 | /** 41 | * Reverse the migrations. 42 | * 43 | * @return void 44 | */ 45 | public function down() 46 | { 47 | Schema::drop('failed_jobs'); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /database/migrations/2015_01_24_072255_create_users_table.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | use Illuminate\Database\Migrations\Migration; 14 | use Illuminate\Database\Schema\Blueprint; 15 | use Illuminate\Support\Facades\Schema; 16 | 17 | /** 18 | * This is the create users table migration class. 19 | * 20 | * @author Joseph Cohen 21 | */ 22 | class CreateUsersTable extends Migration 23 | { 24 | /** 25 | * Run the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function up() 30 | { 31 | Schema::create('users', function (Blueprint $table) { 32 | $table->bigInteger('id')->unsigned()->primary(); 33 | $table->string('name'); 34 | $table->string('username')->unique(); 35 | $table->string('email')->unique(); 36 | $table->string('access_token', 40)->unique(); 37 | $table->rememberToken(); 38 | $table->timestamps(); 39 | }); 40 | } 41 | 42 | /** 43 | * Reverse the migrations. 44 | * 45 | * @return void 46 | */ 47 | public function down() 48 | { 49 | Schema::drop('users'); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | use Illuminate\Database\Eloquent\Model as Eloquent; 14 | use Illuminate\Database\Seeder; 15 | 16 | /** 17 | * This is the database seeder class. 18 | * 19 | * @author Graham Campbell 20 | */ 21 | class DatabaseSeeder extends Seeder 22 | { 23 | /** 24 | * Run the database seeding. 25 | * 26 | * @return void 27 | */ 28 | public function run() 29 | { 30 | Eloquent::unguard(); 31 | 32 | // 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /elixir.json: -------------------------------------------------------------------------------- 1 | { 2 | "cssOutput": "public/dist/css", 3 | "jsOutput": "public/dist/js", 4 | "production": true 5 | } 6 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var elixir = require('laravel-elixir'); 2 | 3 | elixir(function(mix) { 4 | mix.sass('app.scss') 5 | .scripts([ 6 | 'vendor/bower_components/jquery/dist/jquery.js', 7 | 'vendor/bower_components/lodash/lodash.js', 8 | 'vendor/bower_components/jquery-timeago/jquery.timeago.js', 9 | 'vendor/bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js', 10 | 'vendor/bower_components/xregexp/xregexp-all.js', 11 | 'vendor/bower_components/SyntaxHighlighter/src/js/shCore.js', 12 | 'vendor/bower_components/pusher/dist/pusher.js', 13 | 'resources/assets/js/**/*.js', 14 | 'resources/assets/js/app.js', 15 | ], 'public/dist/js/app.js', './') 16 | .version(['dist/css/app.css', 'dist/js/app.js']) 17 | .copy("vendor/bower_components/font-awesome/fonts/", "public/fonts/"); 18 | }); 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "bower": "~1.3.12", 4 | "gulp": "~3.8.8", 5 | "laravel-elixir": "~0.10.7", 6 | "laravel-elixir-jshint": "~0.1.6" 7 | }, 8 | "private": true 9 | } 10 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | ./tests 20 | 21 | 22 | 23 | 24 | ./app 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | RewriteRule ^(.*)/$ /$1 [L,R=301] 9 | 10 | RewriteCond %{REQUEST_FILENAME} !-d 11 | RewriteCond %{REQUEST_FILENAME} !-f 12 | RewriteRule ^ index.php [L] 13 | 14 | -------------------------------------------------------------------------------- /public/build/rev-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dist/css/app.css": "dist/css/app-ba7fd477.css", 3 | "dist/js/app.js": "dist/js/app-40cc34e4.js" 4 | } -------------------------------------------------------------------------------- /public/dist/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikedugan/StyleCI/0e6d4ef48c2c1e1efec6a7ce0da04453d9be0988/public/favicon.ico -------------------------------------------------------------------------------- /public/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikedugan/StyleCI/0e6d4ef48c2c1e1efec6a7ce0da04453d9be0988/public/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /public/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikedugan/StyleCI/0e6d4ef48c2c1e1efec6a7ce0da04453d9be0988/public/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /public/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikedugan/StyleCI/0e6d4ef48c2c1e1efec6a7ce0da04453d9be0988/public/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /public/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikedugan/StyleCI/0e6d4ef48c2c1e1efec6a7ce0da04453d9be0988/public/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /public/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikedugan/StyleCI/0e6d4ef48c2c1e1efec6a7ce0da04453d9be0988/public/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /public/img/styleci-og.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikedugan/StyleCI/0e6d4ef48c2c1e1efec6a7ce0da04453d9be0988/public/img/styleci-og.png -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | /* 14 | |-------------------------------------------------------------------------- 15 | | Register The Auto Loader 16 | |-------------------------------------------------------------------------- 17 | | 18 | | Composer provides a convenient, automatically generated class loader for 19 | | our application. We just need to utilize it! We'll simply require it 20 | | into the script here so that we don't have to worry about manual 21 | | loading any of our classes later on. It feels nice to relax. 22 | | 23 | */ 24 | 25 | require __DIR__.'/../bootstrap/autoload.php'; 26 | 27 | /* 28 | |-------------------------------------------------------------------------- 29 | | Turn On The Lights 30 | |-------------------------------------------------------------------------- 31 | | 32 | | We need to illuminate PHP development, so let us turn on the lights. 33 | | This bootstraps the framework and gets it ready for use, then it 34 | | will load up this application so that we can run it and send 35 | | the responses back to the browser and delight our users. 36 | | 37 | */ 38 | 39 | $app = require_once __DIR__.'/../bootstrap/app.php'; 40 | 41 | /* 42 | |-------------------------------------------------------------------------- 43 | | Run The Application 44 | |-------------------------------------------------------------------------- 45 | | 46 | | Once we have the application, we can simply call the run method, 47 | | which will execute the request and send the response back to 48 | | the client's browser allowing them to enjoy the creative 49 | | and wonderful application we have prepared for them. 50 | | 51 | */ 52 | 53 | $kernel = $app->make('Illuminate\Contracts\Http\Kernel'); 54 | $request = Illuminate\Http\Request::capture(); 55 | $response = $kernel->handle($request); 56 | 57 | $response->send(); 58 | $kernel->terminate($request, $response); 59 | -------------------------------------------------------------------------------- /public/packages/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * Allow: / 2 | -------------------------------------------------------------------------------- /resources/assets/js/modules/shBrushDiff.js: -------------------------------------------------------------------------------- 1 | ;(function() 2 | { 3 | // CommonJS 4 | SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null); 5 | 6 | function Brush() 7 | { 8 | this.regexList = [ 9 | { regex: /^\+\+\+ .*$/gm, css: 'color2' }, // new file 10 | { regex: /^\-\-\- .*$/gm, css: 'color2' }, // old file 11 | { regex: /^\s.*$/gm, css: 'color1' }, // unchanged 12 | { regex: /^@@.*@@.*$/gm, css: 'variable' }, // location 13 | { regex: /^\+(?=[^\+\+]).*$/gm, css: 'string' }, // additions 14 | { regex: /^\-(?=[^\-\-]).*$/gm, css: 'color3' } // deletions 15 | ]; 16 | }; 17 | 18 | Brush.prototype = new SyntaxHighlighter.Highlighter(); 19 | Brush.aliases = ['diff', 'patch']; 20 | 21 | SyntaxHighlighter.brushes.Diff = Brush; 22 | 23 | // CommonJS 24 | typeof(exports) != 'undefined' ? exports.Brush = Brush : null; 25 | })(); 26 | -------------------------------------------------------------------------------- /resources/assets/sass/_global.scss: -------------------------------------------------------------------------------- 1 | body, html { 2 | font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif; 3 | height:100% 4 | } 5 | 6 | body, h1, h2, h3, h4 { 7 | font-weight: 300; 8 | } 9 | 10 | #wrap { 11 | min-height:100%; 12 | height:auto !important; 13 | height:100%; 14 | margin:0 auto -60px; 15 | padding:0 0 60px; 16 | } 17 | 18 | #wrap > .container { 19 | padding-right:15px; 20 | padding-left:15px; 21 | padding-bottom:60px; 22 | } 23 | 24 | #footer { 25 | height:60px; 26 | background-color:#f5f5f5; 27 | } 28 | 29 | #footer > .container { 30 | padding-left:15px; 31 | padding-right:15px; 32 | } 33 | 34 | .container .credit{ 35 | margin:20px 0; 36 | } 37 | -------------------------------------------------------------------------------- /resources/assets/sass/_palette.scss: -------------------------------------------------------------------------------- 1 | // StyleCI color palette 2 | 3 | $styleci-primary: #607D8B; 4 | $styleci-dark-primary: #455A64; 5 | $styleci-light: #CFD8DC; 6 | $styleci-text: #FFFFFF; 7 | $styleci-accent: #FF5252; 8 | $styleci-primary-text: #212121; 9 | $styleci-secondary-text: #727272; 10 | $styleci-divider: #B6B6B6; 11 | -------------------------------------------------------------------------------- /resources/assets/sass/app.scss: -------------------------------------------------------------------------------- 1 | // Import core 2 | @import "palette"; 3 | 4 | // Import modules 5 | @import "modules/bootstrap"; 6 | @import "modules/icons"; 7 | @import "modules/btns"; 8 | @import "modules/badges"; 9 | @import "modules/syntax"; 10 | @import "modules/alerts"; 11 | 12 | // Import partials 13 | @import "partials/navbar"; 14 | @import "partials/page-heading"; 15 | 16 | // Import pages 17 | @import "pages/repos"; 18 | @import "pages/repo"; 19 | @import "pages/commit"; 20 | @import "pages/account"; 21 | 22 | // General 23 | @import "global"; 24 | -------------------------------------------------------------------------------- /resources/assets/sass/modules/_alerts.scss: -------------------------------------------------------------------------------- 1 | .alert { 2 | margin-bottom: 0; 3 | } 4 | -------------------------------------------------------------------------------- /resources/assets/sass/modules/_badges.scss: -------------------------------------------------------------------------------- 1 | .badge-id { 2 | @extend .badge; 3 | background-color: #f8f8f8; 4 | color: $styleci-primary; 5 | border-radius: 2px; 6 | padding: 6px; 7 | border: 1px solid $styleci-divider; 8 | } 9 | 10 | .badge-id:hover { 11 | background-color: $styleci-primary; 12 | } 13 | -------------------------------------------------------------------------------- /resources/assets/sass/modules/_btns.scss: -------------------------------------------------------------------------------- 1 | .btn-dark { 2 | border-radius: 0; 3 | color: #fff; 4 | background-color: $styleci-primary; 5 | } 6 | 7 | .btn-dark:hover, 8 | .btn-dark:focus, 9 | .btn-dark:active { 10 | color: #fff; 11 | background-color: $styleci-dark-primary; 12 | } 13 | 14 | .btn-light { 15 | border-radius: 0; 16 | color: #333; 17 | background-color: $styleci-light; 18 | } 19 | 20 | .btn-light:hover, 21 | .btn-light:focus, 22 | .btn-light:active { 23 | color: #333; 24 | background-color: darken($styleci-light, 6.5%); 25 | } 26 | 27 | .btn-circle { 28 | width: 30px; 29 | height: 30px; 30 | text-align: center; 31 | padding: 6px 0; 32 | font-size: 12px; 33 | line-height: 1.428571429; 34 | border-radius: 15px; 35 | i { 36 | margin-top: 4px; 37 | } 38 | } 39 | 40 | .btn-circle.btn-lg { 41 | width: 50px; 42 | height: 50px; 43 | padding: 10px 16px; 44 | font-size: 18px; 45 | line-height: 1.33; 46 | border-radius: 25px; 47 | i { 48 | margin-top: 6px; 49 | } 50 | } 51 | 52 | .btn-circle.btn-xl { 53 | width: 70px; 54 | height: 70px; 55 | padding: 10px 16px; 56 | font-size: 24px; 57 | line-height: 1.33; 58 | border-radius: 35px; 59 | i { 60 | margin-top: 6px; 61 | } 62 | } 63 | 64 | .btn-float { 65 | box-shadow: 0 3px 3px rgba(0,0,0,.3); 66 | margin-top: -50px; 67 | } 68 | -------------------------------------------------------------------------------- /resources/assets/sass/modules/_icons.scss: -------------------------------------------------------------------------------- 1 | $fa-font-path: "../../../fonts" !default; 2 | @import "./vendor/bower_components/font-awesome/scss/font-awesome"; 3 | -------------------------------------------------------------------------------- /resources/assets/sass/modules/_syntax.scss: -------------------------------------------------------------------------------- 1 | $gutter_border_color: $styleci-light !default; 2 | $gutter_border: 3px solid $gutter_border_color !default; 3 | 4 | $code_plain: black !default; 5 | $code_functions: $styleci-dark-primary !default; 6 | $code_color2: $styleci-dark-primary !default; 7 | $code_color3: $styleci-dark-primary !default; 8 | 9 | @import "./vendor/bower_components/SyntaxHighlighter/src/sass/shCoreDefault"; 10 | 11 | .syntaxhighlighter { 12 | overflow: hidden !important; 13 | overflow-x: scroll !important; 14 | overflow-y: hidden !important; 15 | } 16 | 17 | .syntaxhighlighter table td.code .line { 18 | padding: 2px 1em !important; 19 | } 20 | 21 | .syntaxhighlighter table td.gutter .line { 22 | padding: 2px .5em 2px 1em !important; 23 | } 24 | 25 | .syntaxhighlighter code { 26 | padding: 3px 0 !important; 27 | } 28 | 29 | .syntaxhighlighter .string, 30 | .syntaxhighlighter .string a { 31 | color: $code_color2 !important; 32 | background-color: #eaffea !important; 33 | } 34 | 35 | .syntaxhighlighter .color3, 36 | .syntaxhighlighter .color3 a { 37 | color: $code_color3 !important; 38 | background-color: #ffecec !important; 39 | } 40 | -------------------------------------------------------------------------------- /resources/assets/sass/modules/_variables.scss: -------------------------------------------------------------------------------- 1 | //== Colors 2 | // 3 | //## Gray and brand colors for use across Bootstrap. 4 | 5 | $gray-base: #000 !default; 6 | $gray-darker: lighten($gray-base, 13.5%) !default; // #222 7 | $gray-dark: lighten($gray-base, 20%) !default; // #333 8 | $gray: lighten($gray-base, 33.5%) !default; // #555 9 | $gray-light: lighten($gray-base, 46.7%) !default; // #777 10 | $gray-lighter: lighten($gray-base, 93.5%) !default; // #eee 11 | 12 | $brand-primary: $styleci-primary !default; 13 | $brand-success: #5cb85c !default; 14 | $brand-info: #5bc0de !default; 15 | $brand-warning: #f0ad4e !default; 16 | $brand-danger: #d9534f !default; 17 | 18 | // Inverted navbar 19 | // Reset inverted navbar basics 20 | $navbar-inverse-color: lighten($gray-light, 15%) !default; 21 | $navbar-inverse-bg: $styleci-dark-primary !default; 22 | $navbar-inverse-border: darken($navbar-inverse-bg, 10%) !default; 23 | 24 | // Inverted navbar links 25 | $navbar-inverse-link-color: $styleci-text !default; 26 | $navbar-inverse-link-hover-color: #fff !default; 27 | $navbar-inverse-link-hover-bg: transparent !default; 28 | $navbar-inverse-link-active-color: $navbar-inverse-link-hover-color !default; 29 | $navbar-inverse-link-active-bg: darken($navbar-inverse-bg, 10%) !default; 30 | $navbar-inverse-link-disabled-color: #444 !default; 31 | $navbar-inverse-link-disabled-bg: transparent !default; 32 | 33 | // Inverted navbar brand label 34 | $navbar-inverse-brand-color: $navbar-inverse-link-color !default; 35 | $navbar-inverse-brand-hover-color: #fff !default; 36 | $navbar-inverse-brand-hover-bg: transparent !default; 37 | 38 | // Alerts 39 | $alert-border-radius: 0 !default; 40 | -------------------------------------------------------------------------------- /resources/assets/sass/pages/_account.scss: -------------------------------------------------------------------------------- 1 | dl.profile { 2 | 3 | dd { 4 | padding-bottom: 20px; 5 | } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /resources/assets/sass/pages/_commit.scss: -------------------------------------------------------------------------------- 1 | .commit { 2 | h2 { 3 | margin-top: 0; 4 | } 5 | 6 | .list-group-item > .fa { 7 | margin-right: 8px; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /resources/assets/sass/pages/_repo.scss: -------------------------------------------------------------------------------- 1 | .repo-table { 2 | .row { 3 | padding: 5px 0; 4 | border-bottom: 1px solid $styleci-light; 5 | } 6 | } 7 | 8 | @media (min-width: 768px) { 9 | .repo-buttons { 10 | text-align: right; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /resources/assets/sass/pages/_repos.scss: -------------------------------------------------------------------------------- 1 | .list-vcenter { 2 | margin-top: 20px; 3 | } 4 | 5 | @media (min-width: 768px) { 6 | .list-vcenter { 7 | text-align: right; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /resources/assets/sass/partials/_navbar.scss: -------------------------------------------------------------------------------- 1 | .navbar { 2 | margin-bottom: 0; 3 | } 4 | -------------------------------------------------------------------------------- /resources/assets/sass/partials/_page-heading.scss: -------------------------------------------------------------------------------- 1 | .page-heading { 2 | padding: 30px 0; 3 | color: $styleci-text; 4 | background-color: $styleci-primary; 5 | margin-bottom: 20px; 6 | 7 | h1 { 8 | font-weight: 100; 9 | margin-bottom: 2px; 10 | } 11 | 12 | p { 13 | color: $styleci-light; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Pagination Language Lines 18 | |-------------------------------------------------------------------------- 19 | | 20 | | The following language lines are used by the paginator library to build 21 | | the simple pagination links. You are free to change them to anything 22 | | you want to customize your views to better match your application. 23 | | 24 | */ 25 | 26 | 'previous' => '« Previous', 27 | 'next' => 'Next »', 28 | 29 | ]; 30 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | return [ 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Password Reminder Language Lines 18 | |-------------------------------------------------------------------------- 19 | | 20 | | The following language lines are the default lines which match reasons 21 | | that are given by the password broker for a password update attempt 22 | | has failed, such as for an invalid token or invalid new password. 23 | | 24 | */ 25 | 26 | 'password' => 'Passwords must be at least six characters and match the confirmation.', 27 | 'user' => 'We can\'t find a user with that e-mail address.', 28 | 'token' => 'This password reset token is invalid.', 29 | 'sent' => 'We have e-mailed your password reset link!', 30 | 'reset' => 'Your password has been reset!', 31 | 32 | ]; 33 | -------------------------------------------------------------------------------- /resources/views/commit.blade.php: -------------------------------------------------------------------------------- 1 | @extends(Config::get('core.default')) 2 | 3 | @section('title', 'Commit - '.$commit->message) 4 | @section('description', $commit->message) 5 | 6 | @section('top') 7 |
8 |
9 |

{{ $commit->repo->name }} — Commit Analysis

10 |

Here you can see the results of the analysed commit.

11 |
12 |
13 | @stop 14 | 15 | @section('content') 16 |
17 |

18 | {{ $commit->description() }} 19 |

20 |
21 |
22 |
23 |

{{ $commit->message }}

24 | {{ $commit->timeAgo }} 25 |
{{ $commit->id }}
26 |
27 |
28 | @if ($commit->status === 2) 29 | 37 | @endif 38 |
39 |
40 | @if ($commit->status === 2) 41 |
42 |
43 |         {{ $commit->diff }}
44 |     
45 | @endif 46 |
47 | @stop 48 | 49 | @section('js') 50 | 58 | @stop 59 | -------------------------------------------------------------------------------- /resources/views/emails/failed.blade.php: -------------------------------------------------------------------------------- 1 | @extends(Config::get('core.email')) 2 | 3 | @section('content') 4 |

The coding style analysis of your commit "{{ $commit }}" on repo "{{ $repo }}" revealed problems. 5 |

Click here to see the details.

6 | @stop 7 | -------------------------------------------------------------------------------- /resources/views/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends(Config::get('core.default')) 2 | 3 | @section('title', 'Coding Style Continuous Integration Service') 4 | 5 | @section('content') 6 |
7 |
8 |

StyleCI

9 |

Coding Style Continuous Integration Service

10 |
11 | @if($currentUser) 12 | Get Started 13 | @else 14 | Get Started 15 | @endif 16 |
17 |
18 | @stop 19 | 20 | @section('css') 21 | 42 | @stop 43 | -------------------------------------------------------------------------------- /resources/views/layouts/default.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ Config::get('core.name') }} - @yield('title', 'Coding Style Continuous Integration Service') 7 | @include('partials.header') 8 | 9 | 10 |
11 | @include('partials.navbar') 12 | @include('partials.notifications') 13 | @section('top') 14 | @show 15 |
16 | @section('content') 17 | @show 18 | @include('partials.footer') 19 | @section('bottom') 20 | @show 21 | 22 | 23 | -------------------------------------------------------------------------------- /resources/views/layouts/email.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

{{ $subject }}

8 | @section('content') 9 | @show 10 |
11 |

12 | Thank you,
13 | StyleCI 14 |

15 | 16 | 17 | -------------------------------------------------------------------------------- /resources/views/maintenance.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Site Maintenance 7 | 8 | 9 | 10 | 17 | 18 | 19 | 20 |
21 |

We'll be back soon!

22 |
23 |

24 | Sorry for the inconvenience, but we're performing some maintenance at 25 | the moment. Most site maintenance takes under 5 minutes, so you can 26 | expect us to be back online shortly! 27 |

28 |

29 | — The Web Team 30 |

31 |
32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /resources/views/partials/analytics.blade.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /resources/views/partials/footer.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 24 | 25 | 26 | @section('js') 27 | @show 28 | @if (Config::get('analytics.google')) 29 | @include('partials.analytics') 30 | @endif 31 | -------------------------------------------------------------------------------- /resources/views/partials/header.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | @section('css') 23 | @show 24 | 25 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /resources/views/partials/navbar.blade.php: -------------------------------------------------------------------------------- 1 | 35 | -------------------------------------------------------------------------------- /resources/views/partials/notifications.blade.php: -------------------------------------------------------------------------------- 1 |
2 | @if (isset($errors) && count($errors->all()) > 0) 3 |
4 | × 5 | Please check the form below for errors 6 |
7 | @endif 8 | 9 | 10 | 11 | @foreach ($types as $type) 12 | @if ($message = Session::get($type)) 13 | 14 |
15 | × 16 | @if (is_array($message)) 17 | {!! implode(', ', $message) !!} 18 | @else 19 | {!! $message !!} 20 | @endif 21 |
22 | @endif 23 | @endforeach 24 |
25 | -------------------------------------------------------------------------------- /resources/views/repos.blade.php: -------------------------------------------------------------------------------- 1 | @extends(Config::get('core.default')) 2 | 3 | @section('title', 'Repositories') 4 | 5 | @section('top') 6 |
7 |
8 |

Analysed Repos

9 |

Here you can see all your analysed repos.

10 |
11 |
12 | @stop 13 | 14 | @section('content') 15 | @forelse($repos as $repo) 16 |
17 |
18 |

{{ $repo->name }}

19 | @if ($commit = $commits->get($repo->id)) 20 |

21 | {{ $commit->summary }} 22 |

23 | @else 24 |

25 | No commits have been pushed to the master yet. 26 |

27 | @endif 28 |
29 |
30 | Show Commits 31 |
32 |
33 |
34 | @empty 35 |

We haven't analysed anything yet.

36 |

You can enable repos on your account page.

37 | @endforelse 38 | @stop 39 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | $uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); 14 | 15 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 16 | return false; 17 | } 18 | 19 | require_once __DIR__.'/public/index.php'; 20 | -------------------------------------------------------------------------------- /storage/.gitignore: -------------------------------------------------------------------------------- 1 | laravel.log 2 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | compiled.php 4 | services.json 5 | events.scanned.php 6 | routes.scanned.php 7 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/github/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/repos/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/AbstractTestCase.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\Tests\StyleCI; 14 | 15 | use GrahamCampbell\TestBench\AbstractAppTestCase; 16 | 17 | /** 18 | * This is the abstract test case class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | abstract class AbstractTestCase extends AbstractAppTestCase 23 | { 24 | /** 25 | * Get the service provider class. 26 | * 27 | * @param \Illuminate\Contracts\Foundation\Application $app 28 | * 29 | * @return string 30 | */ 31 | protected function getServiceProviderClass($app) 32 | { 33 | return 'StyleCI\StyleCI\Providers\AppServiceProvider'; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/Functional/CommandTest.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\Tests\StyleCI\Functional; 14 | 15 | use StyleCI\Tests\StyleCI\AbstractTestCase; 16 | 17 | /** 18 | * This is the command test class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class CommandTest extends AbstractTestCase 23 | { 24 | public function testInstall() 25 | { 26 | $this->assertSame(0, $this->getKernel()->call('app:install')); 27 | } 28 | 29 | public function testReset() 30 | { 31 | $this->assertSame(0, $this->getKernel()->call('migrate', ['--force' => true])); 32 | $this->assertSame(0, $this->getKernel()->call('app:reset')); 33 | } 34 | 35 | public function testUpdate() 36 | { 37 | $this->assertSame(0, $this->getKernel()->call('app:update')); 38 | } 39 | 40 | public function testResetAfterInstall() 41 | { 42 | $this->assertSame(0, $this->getKernel()->call('app:install')); 43 | $this->assertSame(0, $this->getKernel()->call('app:reset')); 44 | } 45 | 46 | protected function getKernel() 47 | { 48 | return $this->app->make('Illuminate\Contracts\Console\Kernel'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tests/ServiceProviderTest.php: -------------------------------------------------------------------------------- 1 | 7 | * (c) Joseph Cohen 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace StyleCI\Tests\StyleCI; 14 | 15 | use GrahamCampbell\TestBench\Traits\ServiceProviderTestCaseTrait; 16 | 17 | /** 18 | * This is the service provider test class. 19 | * 20 | * @author Graham Campbell 21 | */ 22 | class ServiceProviderTest extends AbstractTestCase 23 | { 24 | use ServiceProviderTestCaseTrait; 25 | 26 | public function testClientFactoryIsInjectable() 27 | { 28 | $this->assertIsInjectable('StyleCI\StyleCI\GitHub\ClientFactory'); 29 | } 30 | 31 | public function testGitHubBranchesIsInjectable() 32 | { 33 | $this->assertIsInjectable('StyleCI\StyleCI\GitHub\Branches'); 34 | } 35 | 36 | public function testGitHubStatusIsInjectable() 37 | { 38 | $this->assertIsInjectable('StyleCI\StyleCI\GitHub\Status'); 39 | } 40 | } 41 | --------------------------------------------------------------------------------