Skip to content

Commit bbf5291

Browse files
committed
create workflow
1 parent ef79b22 commit bbf5291

File tree

7 files changed

+99
-8
lines changed

7 files changed

+99
-8
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
ci:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Cache Composer packages
21+
id: composer-cache
22+
uses: actions/cache@v3
23+
with:
24+
path: vendor
25+
key: ${{ runner.os }}-ci-${{ hashFiles('**/composer.json') }}
26+
restore-keys: |
27+
${{ runner.os }}-ci-
28+
29+
- name: Install dependencies
30+
run: composer install --prefer-dist --no-progress
31+
32+
- name: Run ci checks
33+
run: composer ci

composer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
}
1717
},
1818
"scripts": {
19+
"lint": "XDEBUG_MODE=off pint --test",
20+
"lint.fix": "XDEBUG_MODE=off pint",
21+
"stan": "XDEBUG_MODE=off phpstan analyse --ansi --memory-limit=-1",
22+
"test.arch": "XDEBUG_MODE=off pest --testsuite=Architecture",
23+
"test.unit": "XDEBUG_MODE=off pest --testsuite=Unit",
24+
"test.feature": "XDEBUG_MODE=coverage pest --testsuite=Feature --coverage --min=90",
25+
"rector": "XDEBUG_MODE=off rector process --dry-run",
26+
"rector.fix": "XDEBUG_MODE=off rector process",
27+
"ci": [
28+
"@lint",
29+
"@rector"
30+
],
31+
"ci.fix": [
32+
"@rector.fix",
33+
"@lint.fix"
34+
]
1935
},
2036
"extra": {
2137
"laravel": {

phpstan.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
includes:
2+
- vendor/larastan/larastan/extension.neon
3+
- vendor/nesbot/carbon/extension.neon
4+
5+
parameters:
6+
7+
paths:
8+
- src/
9+
10+
level: max

rector.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__.'/config',
10+
__DIR__.'/src',
11+
])
12+
// uncomment to reach your current PHP version
13+
// ->withPhpSets()
14+
->withTypeCoverageLevel(0)
15+
->withDeadCodeLevel(0)
16+
->withCodeQualityLevel(0);

resources/views/banner.blade.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div>
2+
<div class="px-1 bg-green-600">CodeBuddy</div>
3+
<em class="ml-1">
4+
All-in-one tool for your codebase quality
5+
</em>
6+
</div>

src/CodebuddyServiceProvider.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ public function boot()
2323
__DIR__.'/../config/codebuddy.php' => config_path('codebuddy.php'),
2424
]);
2525
}
26+
27+
$this->loadViewsFrom(__DIR__.'/../resources/views', 'codebuddy');
2628
}
2729

28-
public function provides()
30+
/**
31+
* @return array<string>
32+
*/
33+
public function provides(): array
2934
{
3035
return [
3136
Configure::class,
3237
];
3338
}
34-
}
39+
}

src/Commands/Configure.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Console\Command;
66
use Illuminate\Filesystem\Filesystem;
7+
78
use function Termwind\render;
89

910
class Configure extends Command
@@ -14,33 +15,37 @@ class Configure extends Command
1415

1516
public function handle(): void
1617
{
17-
$filesystem = new Filesystem();
18+
$filesystem = new Filesystem;
1819

1920
$configs = [
2021
'rector.php',
2122
'phpstan.neon',
2223
'pint.json',
2324
];
2425

26+
render(view('codebuddy::banner'));
27+
2528
foreach ($configs as $file) {
26-
$sourceFile = __DIR__ . "/../../config/laravel/{$file}";
29+
$sourceFile = __DIR__."/../../config/laravel/{$file}";
2730
$destinationFile = base_path($file);
2831

29-
if (!$filesystem->exists($sourceFile)) {
32+
if (! $filesystem->exists($sourceFile)) {
3033
$this->error("Source file not found: {$sourceFile}");
34+
3135
continue;
3236
}
3337

3438
if ($filesystem->exists($destinationFile)) {
3539
$overwrite = $this->confirmOverwrite($destinationFile);
36-
if (!$overwrite) {
40+
if (! $overwrite) {
3741
$this->warn("Skipped: {$destinationFile} already exists");
42+
3843
continue;
3944
}
4045
}
4146

4247
$filesystem->copy($sourceFile, $destinationFile);
43-
$this->info("Copied: {$file} to project root");
48+
$this->info("Created: {$file} in project root");
4449
$this->newLine();
4550
}
4651
}
@@ -51,6 +56,6 @@ private function confirmOverwrite(string $file): bool
5156
sprintf('%s already exists. Do you want to overwrite it?', $file)
5257
);
5358

54-
return $this->ask('Overwrite?', false);
59+
return $this->confirm('Overwrite?', true);
5560
}
5661
}

0 commit comments

Comments
 (0)