Skip to content

Commit

Permalink
Clean all code. (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed May 19, 2023
1 parent b1165ea commit 5a3f917
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
preset: psr12
risky: true

version: 8.1
version: 8.2

finder:
exclude:
Expand Down
34 changes: 2 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,11 @@ composer require yii-tools/bootstrapicons-asset

## Usage

For use this package, read the [docs](/docs/install.md).

## Checking dependencies

This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`.

To run the checker, execute the following command:

```shell
composer run check-dependencies
```

## Mutation testing

Mutation testing is checked with [Infection](https://infection.github.io/). To run it:

```shell
composer run mutation
```

## Static analysis

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```shell
composer run psalm
```
[Check the documentation docs](/docs/README.md) to learn about usage.

## Testing

The code is tested with [PHPUnit](https://phpunit.de/). To run tests:

```
composer run test
```
[Check the documentation testing](/docs/testing.md) to learn about testing.

## CI status

Expand Down
9 changes: 7 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
Change Log
==========
Bootstrapicons Asset Change Log
===============================

## 1.0.0 May 19, 2023

- Initial release.

11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
"yiisoft/files": "^2.0"
},
"require-dev": {
"infection/infection": "^0.27",
"maglnet/composer-require-checker": "^4.3",
"phpunit/phpunit": "^10.0",
"roave/infection-static-analysis-plugin": "^1.29",
"vimeo/psalm": "^5.6"
"phpunit/phpunit": "^10.1",
"roave/infection-static-analysis-plugin": "^1.31",
"vimeo/psalm": "^5.8"
},
"autoload": {
"psr-4": {
"Yii\\BootstrapIcons\\Asset\\": "src"
"Yii\\Assets\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Yii\\BootstrapIcons\\Asset\\Tests\\": "tests"
"Yii\\Assets\\Tests\\": "tests"
}
},
"extra": {
Expand Down
13 changes: 7 additions & 6 deletions docs/install.md → docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Using assets
# Using assets

Assets are files that are not processed by Webpack. They are copied directly to the output folder. This includes images, fonts, and any other files that you want to use in your project.

Expand All @@ -13,14 +13,14 @@ file: ./resources/views/layout/main.php

declare(strict_types=1);

use Yii\BootstrapIcons\Asset\Npm\BootstrapIconsAsset;
use Yii\Assets\BootstrapIconsDev;

/**
* @var \Yiisoft\Assets\AssetManager $assetManager
*/

// Register the asset bundle with a asset manager component.
$assetManager->register(BootstrapIconsAsset::class);
$assetManager->register(BootstrapIconsDev::class);

// Set parameters for the registered asset bundle a view component.
$this->addCssFiles($assetManager->getCssFiles());
Expand All @@ -39,13 +39,13 @@ file: ./config/params.php

declare(strict_types=1);

use Yii\BootstrapIcons\Asset\Cdn\BootstrapIconsAsset;
use Yii\Assets\BootstrapIconsCdn;

return [
'yiisoft/assets' => [
'assetManager' => [
'register' => [
BootstrapIconsAsset::class,
BootstrapIconsCdn::class,
],
],
],
Expand All @@ -54,4 +54,5 @@ return [

## Using npm packages

[npm](https://www.npmjs.com/) packages are installed via [fxpio/foxy](https://github.com/fxpio/foxy) and are available in the `node_modules` directory.
You can install [npm](https://www.npmjs.com/) packages [fxpio/foxy](https://github.com/fxpio/foxy),
and they will be available in the `node_modules` directory.
35 changes: 35 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Testing

## Checking dependencies

This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`.

To run the checker, execute the following command:

```shell
composer run check-dependencies
```

## Mutation testing

Mutation testing is checked with [Infection](https://infection.github.io/). To run it:

```shell
composer run mutation
```

## Static analysis

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```shell
composer run psalm
```

## Unit tests

The code is tested with [PHPUnit](https://phpunit.de/). To run tests:

```
composer run test
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bootstrapicons-asset",
"version": "1.0.0",
"dependencies": {
"bootstrap-icons": "^1.10.3"
"bootstrap-icons": "^1.10.5"
},
"license": "mit"
}
16 changes: 8 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache">
<php>
<ini name="error_reporting" value="-1"/>
</php>
<coverage>
<testsuites>
<testsuite name="Bootstrapicons-Asset">
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory>./vendor</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Template">
<directory>./tests</directory>
</testsuite>
</testsuites>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/Cdn/BootstrapIconsAsset.php → src/BootstrapIconsCdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Yii\BootstrapIcons\Asset\Cdn;
namespace Yii\Assets;

use Yiisoft\Assets\AssetBundle;

final class BootstrapIconsAsset extends AssetBundle
final class BootstrapIconsCdn extends AssetBundle
{
public bool $cdn = true;
public array $css = ['https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css'];
Expand Down
4 changes: 2 additions & 2 deletions src/Npm/BootstrapIconsAsset.php → src/BootstrapIconsDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Yii\BootstrapIcons\Asset\Npm;
namespace Yii\Assets;

use Yiisoft\Assets\AssetBundle;
use Yiisoft\Files\PathMatcher\PathMatcher;

final class BootstrapIconsAsset extends AssetBundle
final class BootstrapIconsDev extends AssetBundle
{
public string|null $basePath = '@assets';
public string|null $baseUrl = '@assetsUrl';
Expand Down
6 changes: 3 additions & 3 deletions tests/CdnAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Yii\BootstrapIcons\Asset\Tests;
namespace Yii\Assets\Tests;

use PHPUnit\Framework\TestCase;
use Yii\BootstrapIcons\Asset\Tests\Support\TestTrait;
use Yii\Assets\Tests\Support\TestTrait;
use Yiisoft\Assets\Exception\InvalidConfigException;

/**
Expand All @@ -16,7 +16,7 @@ final class CdnAssetTest extends TestCase
use TestTrait;

/**
* @dataProvider \Yii\BootstrapIcons\Asset\Tests\Provider\CdnAssetProvider::assetBundles
* @dataProvider \Yii\Assets\Tests\Provider\CdnAssetProvider::assetBundles
*
* @psalm-suppress InvalidStringClass
* @psalm-suppress MixedArrayOffset
Expand Down
6 changes: 3 additions & 3 deletions tests/NpmAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Yii\BootstrapIcons\Asset\Tests;
namespace Yii\Assets\Tests;

use PHPUnit\Framework\TestCase;
use Yii\BootstrapIcons\Asset\Tests\Support\TestTrait;
use Yii\Assets\Tests\Support\TestTrait;
use Yiisoft\Assets\Exception\InvalidConfigException;
use Yiisoft\Files\PathMatcher\PathMatcher;

Expand All @@ -17,7 +17,7 @@ final class NpmAssetTest extends TestCase
use TestTrait;

/**
* @dataProvider \Yii\BootstrapIcons\Asset\Tests\Provider\NpmAssetProvider::assetBundles
* @dataProvider \Yii\Assets\Tests\Provider\NpmAssetProvider::assetBundles
*
* @throws InvalidConfigException
*
Expand Down
9 changes: 3 additions & 6 deletions tests/Provider/CdnAssetProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Yii\BootstrapIcons\Asset\Tests\Provider;
namespace Yii\Assets\Tests\Provider;

use Yii\BootstrapIcons\Asset\Cdn\BootstrapIconsAsset;
use Yii\Assets\BootstrapIconsCdn;

final class CdnAssetProvider
{
Expand All @@ -14,10 +14,7 @@ final class CdnAssetProvider
public static function assetBundles(): array
{
return [
[
'Css',
BootstrapIconsAsset::class,
],
['Css', BootstrapIconsCdn::class],
];
}
}
9 changes: 3 additions & 6 deletions tests/Provider/NpmAssetProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Yii\BootstrapIcons\Asset\Tests\Provider;
namespace Yii\Assets\Tests\Provider;

use Yii\BootstrapIcons\Asset\Npm\BootstrapIconsAsset;
use Yii\Assets\BootstrapIconsDev;

final class NpmAssetProvider
{
Expand All @@ -14,10 +14,7 @@ final class NpmAssetProvider
public static function assetBundles(): array
{
return [
[
'Css',
BootstrapIconsAsset::class,
],
['Css', BootstrapIconsDev::class],
];
}
}
2 changes: 1 addition & 1 deletion tests/Support/TestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\BootstrapIcons\Asset\Tests\Support;
namespace Yii\Assets\Tests\Support;

use Exception;
use Psr\Log\NullLogger;
Expand Down

0 comments on commit 5a3f917

Please sign in to comment.