Skip to content

Commit

Permalink
Merge pull request #2 from Kocal/feat/implem
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed May 17, 2024
2 parents 2dfe2af + a99552c commit 48d1e0a
Show file tree
Hide file tree
Showing 22 changed files with 884 additions and 29 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
fail-fast: false
matrix:
config:
# Minimum supported dependencies with the latest and oldest PHP version
# Minimum supported dependencies and minimum supported PHP version
- PHP_VERSION: '8.1'
COMPOSER_FLAGS: --prefer-stable --prefer-lowest
SYMFONY_VERSION: '6.4'
- PHP_VERSION: '8.1'
- PHP_VERSION: '8.2'
COMPOSER_FLAGS: --prefer-stable --prefer-lowest
SYMFONY_VERSION: '7.0'

Expand All @@ -52,21 +52,24 @@ jobs:
SYMFONY_VERSION: '6.4'

# Latest 7.0 stable releases
- PHP_VERSION: '8.1'
SYMFONY_VERSION: '7.0'
- PHP_VERSION: '8.2'
SYMFONY_VERSION: '7.0'
- PHP_VERSION: '8.3'
SYMFONY_VERSION: '7.0'

# Highest supported PHP version with the latest Symfony version, on Windows and macOS
- PHP_VERSION: '8.3'
SYMFONY_VERSION: '7.0'
OS: windows-latest
- PHP_VERSION: '8.3'
SYMFONY_VERSION: '7.0'
OS: macos-14

# Latest 7.x development releases
- PHP_VERSION: '8.1'
SYMFONY_VERSION: '7.*'
STABILITY: dev
- PHP_VERSION: '8.2'
SYMFONY_VERSION: '7.*'
STABILITY: dev
- PHP_VERSION: '8.2'
- PHP_VERSION: '8.3'
SYMFONY_VERSION: '7.*'
STABILITY: dev
env:
Expand Down
64 changes: 62 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,76 @@
# BiomeJsBundle

[![.github/workflows/ci.yaml](https://github.com/Kocal/BiomeJsBundle/actions/workflows/ci.yaml/badge.svg)](https://github.com/Kocal/BiomeJsBundle/actions/workflows/ci.yaml)

This bundle makes it easy to use [Biome.js](https://biomejs.dev/) in your Symfony project,
to lint and format your assets files without Node.js
(ex: when using Symfony's [AssetMapper Component](https://symfony.com/doc/current/frontend/asset_mapper.html)).

## Installation

Install the bundle with Composer:

```bash
composer require kocal/biome-js-bundle
composer require kocal/biome-js-bundle --dev
```

The bundle should have been automatically enabled in your Symfony application (`config/bundles.php`).
If that's not the case, you can enable it manually:

```php
// config/bundles.php
return [
// ...
Kocal\BiomeJsBundle\KocalBiomeJsBundle::class => ['all' => true],
];
```

## Configuration

If you want to use a specific version of Biome.js, you can configure it in your `config/packages/kocal_biome_js.yaml`:

```yaml
kocal_biome_js:
version: v1.7.3
```

To [configure Biome.js it-self](https://biomejs.dev/reference/configuration), you must create a `biome.json` file at the root of your project.

A recommended configuration for Symfony projects is to ignore files from `assets/vendor/`, `vendor/` and `public/bundles/`:
```json
{
"files": {
"ignore": [
"assets/vendor/*",
"vendor/*",
"public/bundles/*"
]
}
}
```

## Usage

TODO
The latest Biome.js CLI binary is automatically installed (if not already installed) when running one of the `biome:*` command.

### `biome:check`

Runs formatter, linter and import sorting to the requested files.

```bash
# Shows format and lint errors
php bin/console biome:check .

# Shows format and lint errors, and fix them if possible
php bin/console biome:check . --apply
```

### `biome:ci`

Command to use in CI environments. Runs formatter, linter and import sorting to the requested files.

Files won't be modified, the command is a read-only operation.

```bash
# Shows format and lint errors
php bin/console biome:ci .
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
}
],
"require": {
"php": ">=8.1"
"php": ">=8.1",
"symfony/console": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0",
"symfony/process": "^6.4|^7.0"
},
"require-dev": {
"phpstan/phpstan": "^1.11",
"symplify/easy-coding-standard": "^12.1",
"phpunit/phpunit": "^10.5 || ^11.1"
"phpunit/phpunit": "^10.5 || ^11.1",
"symplify/easy-coding-standard": "^12.1.2",
"symfony/framework-bundle": "^6.4|^7.0"
}
}
43 changes: 43 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

use Kocal\BiomeJsBundle\BiomeJs;
use Kocal\BiomeJsBundle\BiomeJsBinary;
use Kocal\BiomeJsBundle\Command\BiomeJsCheckCommand;
use Kocal\BiomeJsBundle\Command\BiomeJsCiCommand;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\abstract_arg;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $container): void {
$container->parameters()
// Internal parameter to enable/disable TTY mode, useful for tests (if someone has a better idea, feel free to suggest it!)
->set('biomejs.use_tty', true)
;

$container->services()
->set('biomejs.binary', BiomeJsBinary::class)
->args([
param('kernel.project_dir'),
param('kernel.project_dir').'/var/biomejs',
abstract_arg('Biome.js binary version'),
])

->set('biomejs', BiomeJs::class)
->args([
service('biomejs.binary'),
param('biomejs.use_tty')
])

->set('biomejs.command.ci', BiomeJsCiCommand::class)
->args([
service('biomejs')
])
->tag('console.command')

->set('biomejs.command.check', BiomeJsCheckCommand::class)
->args([
service('biomejs'),
])
->tag('console.command');
};
90 changes: 90 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\$apply of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:check\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCheckCommand.php

-
message: "#^Parameter \\$applyUnsafe of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:check\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCheckCommand.php

-
message: "#^Parameter \\$changed of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:check\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCheckCommand.php

-
message: "#^Parameter \\$formatterEnabled of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:check\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCheckCommand.php

-
message: "#^Parameter \\$linterEnabled of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:check\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCheckCommand.php

-
message: "#^Parameter \\$organizeImportsEnabled of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:check\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCheckCommand.php

-
message: "#^Parameter \\$path of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:check\\(\\) expects array\\<string\\>, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCheckCommand.php

-
message: "#^Parameter \\$since of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:check\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCheckCommand.php

-
message: "#^Parameter \\$staged of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:check\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCheckCommand.php

-
message: "#^Parameter \\$changed of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:ci\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCiCommand.php

-
message: "#^Parameter \\$formatterEnabled of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:ci\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCiCommand.php

-
message: "#^Parameter \\$linterEnabled of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:ci\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCiCommand.php

-
message: "#^Parameter \\$organizeImportsEnabled of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:ci\\(\\) expects bool, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCiCommand.php

-
message: "#^Parameter \\$path of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:ci\\(\\) expects array\\<string\\>, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCiCommand.php

-
message: "#^Parameter \\$since of method Kocal\\\\BiomeJsBundle\\\\BiomeJs\\:\\:ci\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: src/Command/BiomeJsCiCommand.php

-
message: "#^Cannot call method end\\(\\) on Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\|null\\.$#"
count: 1
path: src/DependencyInjection/BiomeJsExtension.php
-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:end\\(\\)\\.$#"
count: 1
path: src/DependencyInjection/BiomeJsExtension.php

-
message: "#^Method Kocal\\\\BiomeJsBundle\\\\DependencyInjection\\\\BiomeJsExtension\\:\\:getConfiguration\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/DependencyInjection/BiomeJsExtension.php
7 changes: 6 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
includes:
- phpstan-baseline.neon

parameters:
level: max

paths:
- src
- tests
- tests

reportUnmatchedIgnoredErrors: false
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<php>
<ini name="display_errors" value="1"/>
<ini name="error_reporting" value="-1"/>
<server name="KERNEL_CLASS" value="Kocal\BiomeJsBundle\Tests\fixtures\BiomeJsTestKernel" />
</php>

<testsuites>
Expand Down
Empty file removed src/.gitkeep
Empty file.
Loading

0 comments on commit 48d1e0a

Please sign in to comment.