Skip to content

Commit 8439eb7

Browse files
author
Emmanuel Campait
committed
chore: prepare 1.0.1 release
improve package quality checks and test coverage
1 parent af24fb2 commit 8439eb7

15 files changed

Lines changed: 645 additions & 4 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/vendor/
2-
/composer.lock
2+
/composer.lock
3+
/build/*
4+
!/build/.gitkeep

.php-cs-fixer.dist.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of domprojects/codeigniter4-bootstrap.
7+
*
8+
* (c) domProjects
9+
*
10+
* For the full copyright and license information, please view
11+
* the LICENSE file that was distributed with this source code.
12+
*/
13+
14+
use CodeIgniter\CodingStandard\CodeIgniter4;
15+
use Nexus\CsConfig\Factory;
16+
use PhpCsFixer\Finder;
17+
18+
$finder = Finder::create()
19+
->files()
20+
->in([
21+
__DIR__ . '/src/',
22+
__DIR__ . '/tests/',
23+
])
24+
->exclude([
25+
'build',
26+
])
27+
->append([
28+
__FILE__,
29+
__DIR__ . '/rector.php',
30+
]);
31+
32+
$options = [
33+
'finder' => $finder,
34+
'cacheFile' => 'build/.php-cs-fixer.cache',
35+
];
36+
37+
return Factory::create(new CodeIgniter4(), [], $options)->forLibrary(
38+
'domprojects/codeigniter4-bootstrap',
39+
'domProjects',
40+
);

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# domProjects CodeIgniter 4 Bootstrap
1+
# Bootstrap 5 for CodeIgniter 4
22

33
Bootstrap 5 asset publisher for CodeIgniter 4.
44

composer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,36 @@
2727
"codeigniter4/framework": "^4.7.2",
2828
"twbs/bootstrap": "^5.3.8"
2929
},
30+
"require-dev": {
31+
"codeigniter4/devkit": "^1.3"
32+
},
3033
"autoload": {
3134
"psr-4": {
3235
"domProjects\\CodeIgniterBootstrap\\": "src/"
3336
}
3437
},
38+
"autoload-dev": {
39+
"psr-4": {
40+
"domProjects\\CodeIgniterBootstrap\\Tests\\": "tests/"
41+
}
42+
},
43+
"config": {
44+
"allow-plugins": {
45+
"phpstan/extension-installer": true
46+
},
47+
"sort-packages": true
48+
},
49+
"scripts": {
50+
"analyze": [
51+
"Composer\\Config::disableProcessTimeout",
52+
"phpstan analyse -c phpstan.neon.dist --memory-limit=512M",
53+
"psalm --config=psalm.xml",
54+
"rector process --dry-run --config=rector.php"
55+
],
56+
"cs": "php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.dist.php",
57+
"cs-fix": "php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.dist.php",
58+
"test": "phpunit -c phpunit.xml.dist"
59+
},
3560
"extra": {
3661
"branch-alias": {
3762
"dev-main": "1.x-dev"

phpstan.neon.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
parameters:
2+
tmpDir: build/phpstan-tmp
3+
level: 6
4+
paths:
5+
- src/
6+
- tests/
7+
bootstrapFiles:
8+
- tests/bootstrap.php
9+
excludePaths:
10+
- tests/_support/*
11+
universalObjectCratesClasses:
12+
- CodeIgniter\Entity
13+
- CodeIgniter\Entity\Entity
14+
- Faker\Generator
15+
dynamicConstantNames:
16+
- APP_NAMESPACE
17+
- CI_DEBUG
18+
- ENVIRONMENT

phpunit.xml.dist

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
bootstrap="tests/bootstrap.php"
5+
backupGlobals="false"
6+
beStrictAboutOutputDuringTests="true"
7+
colors="true"
8+
executionOrder="random"
9+
failOnRisky="true"
10+
failOnWarning="true"
11+
stopOnError="false"
12+
stopOnFailure="false"
13+
stopOnIncomplete="false"
14+
stopOnSkipped="false"
15+
cacheDirectory="build/.phpunit.cache"
16+
beStrictAboutCoverageMetadata="true">
17+
<coverage includeUncoveredFiles="true">
18+
<report>
19+
<clover outputFile="build/phpunit/clover.xml"/>
20+
<html outputDirectory="build/phpunit/html"/>
21+
<php outputFile="build/phpunit/coverage.serialized"/>
22+
<text outputFile="php://stdout" showUncoveredFiles="false"/>
23+
<xml outputDirectory="build/phpunit/xml-coverage"/>
24+
</report>
25+
</coverage>
26+
<testsuites>
27+
<testsuite name="main">
28+
<directory>./tests</directory>
29+
</testsuite>
30+
</testsuites>
31+
<extensions>
32+
<bootstrap class="Nexus\PHPUnit\Tachycardia\TachycardiaExtension">
33+
<parameter name="time-limit" value="1.00"/>
34+
<parameter name="report-count" value="30"/>
35+
<parameter name="format" value="table"/>
36+
</bootstrap>
37+
</extensions>
38+
<logging>
39+
<testdoxHtml outputFile="build/phpunit/testdox.html"/>
40+
<testdoxText outputFile="build/phpunit/testdox.txt"/>
41+
<junit outputFile="build/phpunit/junit.xml"/>
42+
</logging>
43+
<php>
44+
<env name="XDEBUG_MODE" value="coverage"/>
45+
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
46+
<server name="app.baseURL" value="https://example.com/"/>
47+
</php>
48+
<source>
49+
<include>
50+
<directory suffix=".php">./src/</directory>
51+
</include>
52+
</source>
53+
</phpunit>

psalm.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="7"
4+
resolveFromConfigFile="true"
5+
allFunctionsGlobal="true"
6+
ensureOverrideAttribute="false"
7+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8+
xmlns="https://getpsalm.org/schema/config"
9+
xsi:schemaLocation="https://getpsalm.org/schema/config ../../../vendor/vimeo/psalm/config.xsd"
10+
autoloader="psalm_autoload.php"
11+
cacheDirectory="build/psalm/"
12+
findUnusedBaselineEntry="true"
13+
findUnusedCode="false"
14+
>
15+
<projectFiles>
16+
<directory name="src/" />
17+
<directory name="tests/" />
18+
<ignoreFiles>
19+
<directory name="build" />
20+
<directory name="../../../vendor" />
21+
<directory name="tests/_support" />
22+
</ignoreFiles>
23+
</projectFiles>
24+
</psalm>

psalm_autoload.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
spl_autoload_register(static function (string $class): void {
6+
$prefix = 'domProjects\\CodeIgniterBootstrap\\';
7+
8+
if (! str_starts_with($class, $prefix)) {
9+
return;
10+
}
11+
12+
$relativePath = str_replace('\\', '/', substr($class, strlen($prefix)));
13+
$file = __DIR__ . '/src/' . $relativePath . '.php';
14+
15+
if (is_file($file)) {
16+
require_once $file;
17+
}
18+
}, true, true);
19+
20+
require __DIR__ . '/tests/bootstrap.php';

rector.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of domprojects/codeigniter4-bootstrap.
7+
*
8+
* (c) domProjects
9+
*
10+
* For the full copyright and license information, please view
11+
* the LICENSE file that was distributed with this source code.
12+
*/
13+
14+
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
15+
use Rector\Config\RectorConfig;
16+
use Rector\PHPUnit\Set\PHPUnitSetList;
17+
use Rector\Set\ValueObject\LevelSetList;
18+
use Rector\Set\ValueObject\SetList;
19+
use Rector\ValueObject\PhpVersion;
20+
21+
return static function (RectorConfig $rectorConfig): void {
22+
$rectorConfig->sets([
23+
SetList::DEAD_CODE,
24+
LevelSetList::UP_TO_PHP_82,
25+
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
26+
PHPUnitSetList::PHPUNIT_100,
27+
]);
28+
29+
$rectorConfig->parallel();
30+
$rectorConfig->cacheClass(FileCacheStorage::class);
31+
32+
if (is_dir('/tmp')) {
33+
$rectorConfig->cacheDirectory('/tmp/rector');
34+
}
35+
36+
$rectorConfig->paths([
37+
__DIR__ . '/src/',
38+
__DIR__ . '/tests/',
39+
]);
40+
41+
$rectorConfig->autoloadPaths([
42+
__DIR__ . '/../../../vendor/autoload.php',
43+
]);
44+
45+
$rectorConfig->bootstrapFiles([
46+
__DIR__ . '/tests/bootstrap.php',
47+
]);
48+
49+
if (is_file(__DIR__ . '/phpstan.neon.dist')) {
50+
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon.dist');
51+
}
52+
53+
$rectorConfig->phpVersion(PhpVersion::PHP_82);
54+
$rectorConfig->importNames();
55+
56+
$rectorConfig->skip([
57+
__DIR__ . '/tests/_support',
58+
]);
59+
};

src/Commands/PublishBootstrap.php

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,76 @@
11
<?php
22

3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of domprojects/codeigniter4-bootstrap.
7+
*
8+
* (c) domProjects
9+
*
10+
* For the full copyright and license information, please view
11+
* the LICENSE file that was distributed with this source code.
12+
*/
13+
314
namespace domProjects\CodeIgniterBootstrap\Commands;
415

516
use CodeIgniter\CLI\BaseCommand;
617
use CodeIgniter\CLI\CLI;
718
use domProjects\CodeIgniterBootstrap\Publishers\BootstrapPublisher;
819
use Throwable;
920

21+
/**
22+
* Spark command used to publish Bootstrap distribution assets.
23+
*/
1024
class PublishBootstrap extends BaseCommand
1125
{
26+
/**
27+
* Command group shown in the Spark command list.
28+
*
29+
* @var string
30+
*/
1231
protected $group = 'Bootstrap';
32+
33+
/**
34+
* Command name used from the CLI.
35+
*
36+
* @var string
37+
*/
1338
protected $name = 'assets:publish-bootstrap';
39+
40+
/**
41+
* Short description displayed in Spark help.
42+
*
43+
* @var string
44+
*/
1445
protected $description = 'Publishes Bootstrap 5 assets to public/assets/bootstrap.';
46+
47+
/**
48+
* Usage string displayed in Spark help.
49+
*
50+
* @var string
51+
*/
1552
protected $usage = 'assets:publish-bootstrap [--force]';
53+
54+
/**
55+
* Supported command options.
56+
*
57+
* @var array<string, string>
58+
*/
1659
protected $options = [
1760
'--force' => 'Overwrite existing files.',
1861
'-f' => 'Alias of --force.',
1962
];
2063

21-
public function run(array $params)
64+
/**
65+
* Publishes the Bootstrap assets to the configured public destination.
66+
*
67+
* When `--force` is provided, existing files are overwritten.
68+
*
69+
* @param array<int|string, string|null> $params
70+
*
71+
* @return int CLI exit status code.
72+
*/
73+
public function run(array $params): int
2274
{
2375
$force = array_key_exists('force', $params)
2476
|| array_key_exists('f', $params)
@@ -29,7 +81,7 @@ public function run(array $params)
2981

3082
CLI::write(
3183
'Publishing Bootstrap assets to ' . $publisher->getDestination() . ($force ? ' with overwrite...' : '...'),
32-
'yellow'
84+
'yellow',
3385
);
3486

3587
try {

0 commit comments

Comments
 (0)