Skip to content

Commit 799612c

Browse files
Merge pull request #155 from laravel-shift/windows-eol
2 parents 6b98d99 + fd1584d commit 799612c

14 files changed

+43
-24
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Build
22

33
on:
4-
push:
54
pull_request:
65
schedule:
76
- cron: "0 0 * * *"
@@ -66,11 +65,6 @@ jobs:
6665
key: dependencies-os-${{ matrix.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}-composer-${{ hashFiles('**/composer.lock') }}
6766
restore-keys: dependencies-os-${{ matrix.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}
6867

69-
- uses: jasonmccreary/PHP-Lint@fetch-signature
70-
71-
- name: Validate composer.json and composer.lock
72-
run: composer validate
73-
7468
- name: Setup PHP
7569
uses: shivammathur/setup-php@v2
7670
with:

.github/workflows/phplint.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: PHPLint
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- uses: jasonmccreary/PHP-Lint@fetch-signature
14+
15+
- name: Validate composer.json and composer.lock
16+
run: composer validate

src/Blueprint.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Blueprint;
44

5+
use Blueprint\Contracts\Generator;
56
use Blueprint\Contracts\Lexer;
67
use Illuminate\Support\Str;
78
use Symfony\Component\Yaml\Yaml;
8-
use Blueprint\Contracts\Generator;
99

1010
class Blueprint
1111
{
@@ -24,6 +24,11 @@ public static function relativeNamespace(string $fullyQualifiedClassName)
2424
return $reference;
2525
}
2626

27+
public static function appPath()
28+
{
29+
return str_replace('\\', '/', config('blueprint.app_path'));
30+
}
31+
2732
public function parse($content)
2833
{
2934
$content = str_replace(["\r\n", "\r"], "\n", $content);

src/Commands/TraceCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ public function handle()
7777

7878
private function appClasses()
7979
{
80-
$dir = config('blueprint.app_path');
80+
$dir = Blueprint::appPath('app');
8181

8282
if (config('blueprint.models_namespace')) {
83-
$dir .= DIRECTORY_SEPARATOR . str_replace('\\', '/', config('blueprint.models_namespace'));
83+
$dir .= '/' . str_replace('\\', '/', config('blueprint.models_namespace'));
8484
}
8585

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

9090
return array_map(function (\SplFIleInfo $file) {
9191
return str_replace(
92-
[config('blueprint.app_path') . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR],
92+
[Blueprint::appPath() . '/', '/'],
9393
[config('blueprint.namespace') . '\\', '\\'],
94-
$file->getPath() . DIRECTORY_SEPARATOR . $file->getBasename('.php')
94+
$file->getPath() . '/' . $file->getBasename('.php')
9595
);
9696
}, $this->files->allFiles($dir));
9797
}

src/FileMixins.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace Blueprint;
54

65
class FileMixins
@@ -11,7 +10,7 @@ public function stub()
1110
{
1211
return function ($path) {
1312
if (!isset($this->stubs[$path])) {
14-
$this->stubs[$path] = $this->get(STUBS_PATH . DIRECTORY_SEPARATOR . $path);
13+
$this->stubs[$path] = $this->get(STUBS_PATH . '/' . $path);
1514
}
1615

1716
return $this->stubs[$path];

src/Generators/ControllerGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected function getPath(Controller $controller)
167167
{
168168
$path = str_replace('\\', '/', Blueprint::relativeNamespace($controller->fullyQualifiedClassName()));
169169

170-
return config('blueprint.app_path') . '/' . $path . '.php';
170+
return Blueprint::appPath() . '/' . $path . '.php';
171171
}
172172

173173
private function addImport(Controller $controller, $class)

src/Generators/ModelGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected function getPath(Model $model)
157157
{
158158
$path = str_replace('\\', '/', Blueprint::relativeNamespace($model->fullyQualifiedClassName()));
159159

160-
return config('blueprint.app_path') . '/' . $path . '.php';
160+
return Blueprint::appPath() . '/' . $path . '.php';
161161
}
162162

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

236-
return trim($output);
236+
return trim(str_replace("\n", PHP_EOL, $output));
237237
}
238238

239239
private function addTraits(Model $model, $stub)
@@ -243,7 +243,7 @@ private function addTraits(Model $model, $stub)
243243
}
244244

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

248248
return $stub;
249249
}

src/Generators/Statements/EventGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Blueprint\Generators\Statements;
44

5+
use Blueprint\Blueprint;
56
use Blueprint\Contracts\Generator;
67
use Blueprint\Models\Statements\FireStatement;
78

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

5859
protected function getPath(string $name)
5960
{
60-
return config('blueprint.app_path') . '/Events/' . $name . '.php';
61+
return Blueprint::appPath() . '/Events/' . $name . '.php';
6162
}
6263

6364
protected function populateStub(string $stub, FireStatement $fireStatement)

src/Generators/Statements/FormRequestGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Blueprint\Generators\Statements;
44

5+
use Blueprint\Blueprint;
56
use Blueprint\Contracts\Generator;
67
use Blueprint\Models\Controller;
78
use Blueprint\Models\Statements\ValidateStatement;
@@ -64,7 +65,7 @@ public function output(array $tree): array
6465

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

7071
protected function populateStub(string $stub, string $name, $context, ValidateStatement $validateStatement, Controller $controller)

src/Generators/Statements/JobGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Blueprint\Generators\Statements;
44

5+
use Blueprint\Blueprint;
56
use Blueprint\Contracts\Generator;
67
use Blueprint\Models\Statements\DispatchStatement;
78

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

5455
protected function getPath(string $name)
5556
{
56-
return config('blueprint.app_path') . '/Jobs/' . $name . '.php';
57+
return Blueprint::appPath() . '/Jobs/' . $name . '.php';
5758
}
5859

5960
protected function populateStub(string $stub, DispatchStatement $dispatchStatement)

0 commit comments

Comments
 (0)