Skip to content

Commit

Permalink
Merge pull request #155 from laravel-shift/windows-eol
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmccreary authored Apr 29, 2020
2 parents 6b98d99 + fd1584d commit 799612c
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 24 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Build

on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
Expand Down Expand Up @@ -66,11 +65,6 @@ jobs:
key: dependencies-os-${{ matrix.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: dependencies-os-${{ matrix.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}

- uses: jasonmccreary/PHP-Lint@fetch-signature

- name: Validate composer.json and composer.lock
run: composer validate

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/phplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: PHPLint

on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: jasonmccreary/PHP-Lint@fetch-signature

- name: Validate composer.json and composer.lock
run: composer validate
7 changes: 6 additions & 1 deletion src/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Blueprint;

use Blueprint\Contracts\Generator;
use Blueprint\Contracts\Lexer;
use Illuminate\Support\Str;
use Symfony\Component\Yaml\Yaml;
use Blueprint\Contracts\Generator;

class Blueprint
{
Expand All @@ -24,6 +24,11 @@ public static function relativeNamespace(string $fullyQualifiedClassName)
return $reference;
}

public static function appPath()
{
return str_replace('\\', '/', config('blueprint.app_path'));
}

public function parse($content)
{
$content = str_replace(["\r\n", "\r"], "\n", $content);
Expand Down
8 changes: 4 additions & 4 deletions src/Commands/TraceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public function handle()

private function appClasses()
{
$dir = config('blueprint.app_path');
$dir = Blueprint::appPath('app');

if (config('blueprint.models_namespace')) {
$dir .= DIRECTORY_SEPARATOR . str_replace('\\', '/', config('blueprint.models_namespace'));
$dir .= '/' . str_replace('\\', '/', config('blueprint.models_namespace'));
}

if (!$this->files->exists($dir)) {
Expand All @@ -89,9 +89,9 @@ private function appClasses()

return array_map(function (\SplFIleInfo $file) {
return str_replace(
[config('blueprint.app_path') . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR],
[Blueprint::appPath() . '/', '/'],
[config('blueprint.namespace') . '\\', '\\'],
$file->getPath() . DIRECTORY_SEPARATOR . $file->getBasename('.php')
$file->getPath() . '/' . $file->getBasename('.php')
);
}, $this->files->allFiles($dir));
}
Expand Down
3 changes: 1 addition & 2 deletions src/FileMixins.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Blueprint;

class FileMixins
Expand All @@ -11,7 +10,7 @@ public function stub()
{
return function ($path) {
if (!isset($this->stubs[$path])) {
$this->stubs[$path] = $this->get(STUBS_PATH . DIRECTORY_SEPARATOR . $path);
$this->stubs[$path] = $this->get(STUBS_PATH . '/' . $path);
}

return $this->stubs[$path];
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/ControllerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ protected function getPath(Controller $controller)
{
$path = str_replace('\\', '/', Blueprint::relativeNamespace($controller->fullyQualifiedClassName()));

return config('blueprint.app_path') . '/' . $path . '.php';
return Blueprint::appPath() . '/' . $path . '.php';
}

private function addImport(Controller $controller, $class)
Expand Down
6 changes: 3 additions & 3 deletions src/Generators/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected function getPath(Model $model)
{
$path = str_replace('\\', '/', Blueprint::relativeNamespace($model->fullyQualifiedClassName()));

return config('blueprint.app_path') . '/' . $path . '.php';
return Blueprint::appPath() . '/' . $path . '.php';
}

private function fillableColumns(array $columns)
Expand Down Expand Up @@ -233,7 +233,7 @@ private function pretty_print_array(array $data, $assoc = true)
$output = preg_replace('/^(\s+)[^=]+=>\s+/m', '$1', $output);
}

return trim($output);
return trim(str_replace("\n", PHP_EOL, $output));
}

private function addTraits(Model $model, $stub)
Expand All @@ -243,7 +243,7 @@ private function addTraits(Model $model, $stub)
}

$stub = str_replace('use Illuminate\\Database\\Eloquent\\Model;', 'use Illuminate\\Database\\Eloquent\\Model;' . PHP_EOL . 'use Illuminate\\Database\\Eloquent\\SoftDeletes;', $stub);
$stub = preg_replace('/^\\{$/m', '{' . PHP_EOL . ' use SoftDeletes;' . PHP_EOL, $stub);
$stub = Str::replaceFirst('{', '{' . PHP_EOL . ' use SoftDeletes;' . PHP_EOL, $stub);

return $stub;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Generators/Statements/EventGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Blueprint\Generators\Statements;

use Blueprint\Blueprint;
use Blueprint\Contracts\Generator;
use Blueprint\Models\Statements\FireStatement;

Expand Down Expand Up @@ -57,7 +58,7 @@ public function output(array $tree): array

protected function getPath(string $name)
{
return config('blueprint.app_path') . '/Events/' . $name . '.php';
return Blueprint::appPath() . '/Events/' . $name . '.php';
}

protected function populateStub(string $stub, FireStatement $fireStatement)
Expand Down
3 changes: 2 additions & 1 deletion src/Generators/Statements/FormRequestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Blueprint\Generators\Statements;

use Blueprint\Blueprint;
use Blueprint\Contracts\Generator;
use Blueprint\Models\Controller;
use Blueprint\Models\Statements\ValidateStatement;
Expand Down Expand Up @@ -64,7 +65,7 @@ public function output(array $tree): array

protected function getPath(Controller $controller, string $name)
{
return config('blueprint.app_path') . '/Http/Requests/' . ($controller->namespace() ? $controller->namespace() . '/' : '') . $name . '.php';
return Blueprint::appPath() . '/Http/Requests/' . ($controller->namespace() ? $controller->namespace() . '/' : '') . $name . '.php';
}

protected function populateStub(string $stub, string $name, $context, ValidateStatement $validateStatement, Controller $controller)
Expand Down
3 changes: 2 additions & 1 deletion src/Generators/Statements/JobGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Blueprint\Generators\Statements;

use Blueprint\Blueprint;
use Blueprint\Contracts\Generator;
use Blueprint\Models\Statements\DispatchStatement;

Expand Down Expand Up @@ -53,7 +54,7 @@ public function output(array $tree): array

protected function getPath(string $name)
{
return config('blueprint.app_path') . '/Jobs/' . $name . '.php';
return Blueprint::appPath() . '/Jobs/' . $name . '.php';
}

protected function populateStub(string $stub, DispatchStatement $dispatchStatement)
Expand Down
3 changes: 2 additions & 1 deletion src/Generators/Statements/MailGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Blueprint\Generators\Statements;

use Blueprint\Blueprint;
use Blueprint\Contracts\Generator;
use Blueprint\Models\Statements\SendStatement;

Expand Down Expand Up @@ -53,7 +54,7 @@ public function output(array $tree): array

protected function getPath(string $name)
{
return config('blueprint.app_path') . '/Mail/' . $name . '.php';
return Blueprint::appPath() . '/Mail/' . $name . '.php';
}

protected function populateStub(string $stub, SendStatement $sendStatement)
Expand Down
3 changes: 2 additions & 1 deletion src/Generators/Statements/ResourceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Blueprint\Generators\Statements;

use Blueprint\Blueprint;
use Blueprint\Contracts\Generator;
use Blueprint\Models\Controller;
use Blueprint\Models\Model;
Expand Down Expand Up @@ -61,7 +62,7 @@ public function output(array $tree): array

protected function getPath(string $name)
{
return config('blueprint.app_path').'/Http/Resources/'.$name.'.php';
return Blueprint::appPath().'/Http/Resources/'.$name.'.php';
}

protected function populateStub(string $stub, ResourceStatement $resource)
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/Statements/ViewGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function output(array $tree): array

protected function getPath(string $view)
{
return 'resources/views/' . str_replace('.', DIRECTORY_SEPARATOR, $view) . '.blade.php';
return 'resources/views/' . str_replace('.', '/', $view) . '.blade.php';
}

protected function populateStub(string $stub, RenderStatement $renderStatement)
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ protected function getEnvironmentSetUp($app)

public function fixture(string $path)
{
return file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR));
return file_get_contents(__DIR__ . '/' . 'fixtures' . '/' . ltrim($path, '/'));
}
}

0 comments on commit 799612c

Please sign in to comment.