Skip to content

Commit

Permalink
Move from React to VueJS
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioribeiro committed Sep 26, 2017
1 parent 771908e commit b896109
Show file tree
Hide file tree
Showing 59 changed files with 61,349 additions and 869 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["transform-object-rest-spread"]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
composer.phar
composer.lock
.DS_Store
.idea
.idea
/node_modules
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"php": ">=5.4.0",
"pragmarx/support": "~0.5",
"sensiolabs/ansi-to-html": "~1",
"cboden/ratchet": "^0.4"
"cboden/ratchet": "^0.4",
"jolicode/jolinotif": "^1.2"
},

"autoload": {
Expand Down
Binary file not shown.
288 changes: 288 additions & 0 deletions fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"/src/public/js/app.js": "/src/public/js/app.js",
"/src/public/css/app.css": "/src/public/css/app.css"
}
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.16.2",
"bootstrap": "4.0.0-beta",
"cross-env": "^5.0.1",
"jquery": "^3.1.1",
"laravel-mix": "^1.0",
"lodash": "^4.17.4",
"vue": "^2.1.10",
"vuex": "^2.4.0",
"webpack-livereload-plugin": "^0.11.0"
},
"dependencies": {
"babel-plugin-transform-object-rest-spread": "^6.26.0"
}
}
101 changes: 97 additions & 4 deletions src/Data/Repositories/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,51 @@ class Data

const STATE_RUNNING = 'running';

/**
/**
* Carriage return to <br>.
*
* @param $lines
* @return string
*/
private function CRToBr($lines)
{
return str_replace("\n", '<br>', $lines);
}

/**
* <br> to carriage return.
*
* @param $lines
* @return string
*/
private function brToCR($lines)
{
return str_replace('<br>', "\n", $lines);
}

/**
* Create links.
*
* @param $lines
* @param $matches
* @return mixed
*/
private function createLinks($lines, $matches)
{
foreach ($matches as $line) {
$fileName = base64_encode($line[1]);

if (count($line) > 0 && count($line[0]) > 0) {
$tag = "<a href=\"javascript:jQuery.get('/ci-watcher/file/open/{$fileName}/{$line[2]}');\" class=\"file\">{$line[0]}</a>";

$lines = str_replace($line[0], $tag, $lines);
}
}

return $lines;
}

/**
* Create or update a tester.
*
* @param $name
Expand Down Expand Up @@ -119,9 +163,39 @@ public function createOrUpdateTest($file, $suite)
}
}

/**
* Create links for files.
*
* @param $lines
* @return string
*/
private function linkFiles($lines)
{
var_dump($lines);
$lines = $this->brToCR($lines);

preg_match_all('/(\/.*\/.*):([0-9]+)/', $lines, $matches, PREG_SET_ORDER);

$matches = array_filter($matches);

if (count($matches) == 0) {
return $lines;
}

return $this->CRToBr($this->createLinks($lines, $matches));
}

/**
* Reset a test to idle state.
*
* @param $test
*/
private function resetTest($test)
{
$test->state = self::STATE_IDLE;

$test->timestamps = false;

$test->save();
}

/**
Expand Down Expand Up @@ -466,7 +540,13 @@ public function getTests($project_id = null)
*/
public function getProjects()
{
return Project::all();
return Project::all()->map(function($item) {
if (!isset($item['tests'])) {
$item['tests'] = [];
}

return $item;
});
}

/**
Expand All @@ -479,7 +559,7 @@ private function formatLog($log)
{
if ($log)
{
$log = $this->ansi2Html($log->log);
$log = $this->linkFiles($this->ansi2Html($log->log));
}

return $log;
Expand Down Expand Up @@ -697,4 +777,17 @@ private function queryTests($project_id = null, $test_id = null)

return $query;
}

/**
* Run all tests or projects tests.
*
* @param null $project_id
*/
public function reset($project_id = null)
{
foreach($this->queryTests($project_id)->get() as $test)
{
$this->resetTest($test);
}
}
}
5 changes: 2 additions & 3 deletions src/Services/Watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use JasonLewis\ResourceWatcher\Event;
use PragmaRX\Ci\Data\Repositories\Data as DataRepository;

class Watcher extends Base {

class Watcher extends Base
{
/**
* Is the watcher initialized?
*
Expand Down Expand Up @@ -322,5 +322,4 @@ private function queueTestSuites($path)

return $queued;
}

}
46 changes: 44 additions & 2 deletions src/Vendor/Laravel/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DashboardController extends Controller
/**
* @var Data
*/
private $dataRepository;
public $dataRepository;

public function __construct(Data $dataRepository)
{
Expand Down Expand Up @@ -40,6 +40,31 @@ public function enableTests($enable, $project_id, $test_id = null)
return $this->success(['enabled' => $enabled]);
}

private function makeNotificationCommand($title, $message)
{
$bin = str_replace('%title%', $title, config('ci.notifier.bin'));

return str_replace('%message%', $message, $bin);
}

public function makeOpenFileCommand($fileName, $line)
{
$fileName = base64_decode($fileName);

return
config('ci.editor.bin') .
(!is_null($line) ? " --line {$line}" : '') .
" {$fileName}"
;
}

public function reset($project_id)
{
$this->dataRepository->reset($project_id);

return $this->success();
}

public function runTest($test_id)
{
$this->dataRepository->runTest($test_id);
Expand All @@ -54,8 +79,25 @@ public function runAll($project_id)
return $this->success();
}

private function success($result = [])
public function success($result = [])
{
return Response::json(array_merge(['success' => true], $result));
}

public function openFile($fileName, $line = null)
{
shell_exec($this->makeOpenFileCommand($fileName, $line));

return $this->success();
}

public function notify($type = 'failed', $count = 0, $total = 0)
{
shell_exec($this->makeNotificationCommand(
$type == 'failed' ? 'FAILING TESTS' : 'Tests passing',
$type == 'failed' ? "At least {$count} of {$total} are failing" : 'All your tests are passing, congrats!'
));

return $this->success();
}
}
31 changes: 19 additions & 12 deletions src/Vendor/Laravel/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace PragmaRX\Ci\Vendor\Laravel;


use Illuminate\Support\Facades\Route;
use PragmaRX\Ci\Vendor\Laravel\Console\Commands\TestCommand;
use PragmaRX\Ci\Vendor\Laravel\Console\Commands\WatchCommand;
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
Expand Down Expand Up @@ -45,7 +46,7 @@ private function loadMigrations()
*/
private function loadViews()
{
$this->loadViewsFrom(__DIR__.'/../../views', 'pragmarx/ci');
$this->loadViewsFrom(__DIR__.'/../../resources/views', 'pragmarx/ci');
}

/**
Expand All @@ -55,7 +56,7 @@ private function loadViews()
private function publishConfiguration()
{
$this->publishes([
__DIR__.'/../../config/config.php' => config_path('ci.php'),
__DIR__.'/../../config/ci.php' => config_path('ci.php'),
]);
}

Expand All @@ -66,7 +67,11 @@ private function publishConfiguration()
*/
public function register()
{
$this->registerResourceWatcher();
if (! defined('CI_PATH')) {
define('CI_PATH', realpath(__DIR__.'/../../../'));
}

$this->registerResourceWatcher();

$this->registerWatcher();

Expand Down Expand Up @@ -107,7 +112,7 @@ private function registerWatchCommand()
*/
private function registerTestCommand()
{
$this->app->singleton('ci.test.command', function($app)
$this->app->singleton('ci.test.command', function()
{
return new TestCommand();
});
Expand All @@ -121,9 +126,7 @@ private function registerTestCommand()
*/
private function registerWatcher()
{
$me = $this;

$this->app->singleton('ci.watcher', function($app) use ($me)
$this->app->singleton('ci.watcher', function($app)
{
$watcher = $this->app->make('PragmaRX\Ci\Services\Watcher');

Expand All @@ -139,9 +142,7 @@ private function registerWatcher()
*/
private function registerTester()
{
$me = $this;

$this->app->singleton('ci.tester', function($app) use ($me)
$this->app->singleton('ci.tester', function($app)
{
$tester = $this->app->make('PragmaRX\Ci\Services\Tester');

Expand All @@ -166,7 +167,13 @@ private function registerResourceWatcher()
*/
private function loadRoutes()
{
$this->loadRoutesFrom(__DIR__.'/../../config/routes.php');
Route::group([
'prefix' => '/ci-watcher',
'namespace' => 'PragmaRX\Ci\Vendor\Laravel\Http\Controllers',
'middleware' => 'web',
], function () {
$this->loadRoutesFrom(__DIR__.'/../../routes/web.php');
});
}

/**
Expand Down
File renamed without changes.
16 changes: 0 additions & 16 deletions src/config/routes.php

This file was deleted.

Loading

0 comments on commit b896109

Please sign in to comment.