Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Nov 23, 2023
1 parent de73cfd commit 16311c2
Show file tree
Hide file tree
Showing 18 changed files with 403 additions and 63 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ name: build

jobs:
phpunit:
uses: yiisoft/actions/.github/workflows/phpunit.yml@master
uses: php-forge/actions/.github/workflows/phpunit.yml@main
with:
composer-command: |
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: compatibility

jobs:
phpunit:
uses: php-forge/actions/.github/workflows/phpunit.yml@main
with:
composer-command: |
composer require yiisoft/yii2:^2.0.49 --prefer-dist --no-progress --no-interaction --no-scripts --ansi
extensions: intl
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.1', '8.2', '8.3']
4 changes: 3 additions & 1 deletion .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ name: Composer require checker

jobs:
composer-require-checker:
uses: yiisoft/actions/.github/workflows/composer-require-checker.yml@master
uses: php-forge/actions/.github/workflows/composer-require-checker.yml@main
with:
composer-command: |
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
os: >-
['ubuntu-latest']
php: >-
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'psalm.xml'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'psalm.xml'

name: mutation test

jobs:
mutation:
uses: php-forge/actions/.github/workflows/roave-infection.yml@main
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
with:
composer-command: |
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
os: >-
['ubuntu-latest']
php: >-
['8.1']
2 changes: 2 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
phpstan:
uses: php-forge/actions/.github/workflows/phpstan.yml@main
with:
composer-command: |
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
os: >-
['ubuntu-latest']
php: >-
Expand Down
79 changes: 57 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,79 @@
<p align="center">
<a href="https://github.com/yii2-extensions/template" target="_blank">
<a href="https://github.com/yii2-extensions/asset-popper" target="_blank">
<img src="https://www.yiiframework.com/image/yii_logo_light.svg" height="100px;">
</a>
<h1 align="center">Yii2-Template.</h1>
<h1 align="center">Assset bundle for Popper.js.</h1>
<br>
</p>

<p align="center">
<a href="https://www.php.net/releases/8.1/en.php" target="_blank">
<img src="https://img.shields.io/badge/PHP-%3E%3D8.1-787CB5" alt="php-version">
</a>
<a href="https://github.com/yiisoft/yii2/tree/2.2" target="_blank">
<img src="https://img.shields.io/badge/Yii2%20version-2.2-blue" alt="yii2-version">
<a href="https://github.com/yii2-extensions/asset-popper/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii2-extensions/asset-popper/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii2-extensions/template/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
</a>
<a href="https://codecov.io/gh/yii2-extensions/template" target="_blank">
<img src="https://codecov.io/gh/yii2-extensions/template/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
<img src="https://github.com/yii2-extensions/gii/actions/workflows/static.yml/badge.svg" alt="PHPStan">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
<img src="https://img.shields.io/badge/PHPStan%20level-2-blue" alt="PHPStan level">
</a>
<a href="https://github.styleci.io/repos/698621511?branch=main" target="_blank">
<img src="https://github.styleci.io/repos/698621511/shield?branch=main" alt="Code style">
<a href="https://github.com/yii2-extensions/asset-popper/actions/workflows/compatibility.yml" target="_blank">
<img src="https://github.com/yii2-extensions/asset-popper/actions/workflows/compatibility.yml/badge.svg" alt="PHPUnit">
</a>
<a href="https://codecov.io/gh/yii2-extensions/asset-popper" target="_blank">
<img src="https://codecov.io/gh/yii2-extensions/asset-popper/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
</a>
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii2-extensions/asset-popper/main" target="_blank">
<img src="https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii2-extensions%2Fasset-popper%2Fmain" alt="Infection">
</a>
</p>

## Requirements
## Installation

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

The minimun version of `PHP` required by this package is `PHP 8.1`.
Either run

For install this package, you need [composer](https://getcomposer.org/).
```
composer require --dev --prefer-dist yii2-extensions/asset-popper
```

or add

```
"yii2-extensions/asset-popper": "dev-main"
```

to the require-dev section of your `composer.json` file.

## Usage

[Check the documentation docs](/docs/README.md) to learn about usage.
```php
<?php

declare(strict_types=1);

use Yii2\Asset\PopperAsset;

PopperAsset::register($this);
```

```php
<?php

declare(strict_types=1);

use Yii2\Asset\PopperCdnAsset;

PopperCdnAsset::register($this);
```

## Quality code

[![static-analysis](https://github.com/yii2-extensions/asset-popper/actions/workflows/static.yml/badge.svg)](https://github.com/yii2-extensions/asset-popper/actions/workflows/static.yml)
[![phpstan-level](https://img.shields.io/badge/PHPStan%20level-7-blue)](https://github.com/yii2-extensions/asset-popper/actions/workflows/static.yml)
[![StyleCI](https://github.styleci.io/repos/722496597/shield?branch=main)](https://github.styleci.io/repos/722496597?branch=main)

## Support versions Yii2

[![Yii20](https://img.shields.io/badge/Yii2%20version-2.0-blue)](https://github.com/yiisoft/yii2/tree/2.0.49.3)
[![Yii22](https://img.shields.io/badge/Yii2%20version-2.2-blue)](https://github.com/yiisoft/yii2/tree/2.2)

## Testing

Expand Down
31 changes: 25 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,60 @@
{
"name": "yii2/template",
"name": "yii2-extensions/asset-popper",
"type": "library",
"description": "_____",
"description": "Assset bundle for Popper.js for Yii Framework.",
"keywords": [
"_____"
"yii2",
"asset",
"popper"
],
"license": "mit",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"npm-asset/popperjs--core": "^2.11",
"oomphinc/composer-installers-extender": "^2.0",
"yiisoft/yii2": "^2.2"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.6",
"php-forge/support": "dev-main",
"phpunit/phpunit": "^10.2",
"roave/infection-static-analysis-plugin": "^1.32",
"yii2-extensions/phpstan": "dev-main"
},
"autoload": {
"psr-4": {
"yii\\template\\": "src"
"Yii2\\Asset\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"yii\\template\\tests\\": "tests"
"Yii2\\Asset\\Tests\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
},
"installer-types": [
"bower-asset",
"npm-asset"
],
"installer-paths": {
"./node_modules/{$name}": [
"type:bower-asset",
"type:npm-asset"
]
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"yiisoft/yii2-composer": true
"yiisoft/yii2-composer": true,
"infection/extension-installer": true,
"composer/installers": true,
"oomphinc/composer-installers-extender": true
}
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="vendor/autoload.php"
bootstrap="tests/Support/bootstrap.php"
cacheDirectory=".phpunit.cache"
colors="true"
executionOrder="depends,defects"
Expand All @@ -11,7 +11,7 @@
stopOnFailure="false"
>
<testsuites>
<testsuite name="Template">
<testsuite name="Yii2-Asset-Popper">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
20 changes: 20 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
</issueHandlers>
</psalm>
13 changes: 0 additions & 13 deletions src/Example.php

This file was deleted.

29 changes: 29 additions & 0 deletions src/PopperAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Yii2\Asset;

use yii\web\AssetBundle;

/**
* Popper JavaScript bundle.
*/
final class PopperAsset extends AssetBundle
{
/**
* @inheritDoc
*/
public $sourcePath = '@npm/popperjs--core/dist/umd';

public function init(): void
{
parent::init();

$assetPopper = YII_ENV === 'prod' ? ['popper.min.js'] : ['popper.js'];

Check failure on line 23 in src/PopperAsset.php

View workflow job for this annotation

GitHub Actions / phpstan / PHP 8.1-ubuntu-latest

Constant YII_ENV not found.

Check failure on line 23 in src/PopperAsset.php

View workflow job for this annotation

GitHub Actions / phpstan / PHP 8.1-ubuntu-latest

Constant YII_ENV not found.
$assetPopperMap = YII_ENV === 'prod' ? ['popper.min.js.map'] : ['popper.js.map'];

Check failure on line 24 in src/PopperAsset.php

View workflow job for this annotation

GitHub Actions / phpstan / PHP 8.1-ubuntu-latest

Constant YII_ENV not found.

Check failure on line 24 in src/PopperAsset.php

View workflow job for this annotation

GitHub Actions / phpstan / PHP 8.1-ubuntu-latest

Constant YII_ENV not found.

$this->css = $assetPopper;
$this->publishOptions['only'] = array_merge($assetPopper, $assetPopperMap);
}
}
32 changes: 32 additions & 0 deletions src/PopperCdnAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Yii2\Asset;

use yii\web\AssetBundle;

/**
* Popper CDN JavaScript bundle.
*/
final class PopperCdnAsset extends AssetBundle
{
/**
* @inheritDoc
*
* @phpstan-var array<array-key, mixed>
*/
public $js = [
'https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js',
];

/**
* @inheritDoc
*
* @phpstan-var array<array-key, mixed>
*/
public $jsOptions = [
'crossorigin' => 'anonymous',
'integrity' => 'sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r',
];
}
Loading

0 comments on commit 16311c2

Please sign in to comment.