Skip to content

Commit

Permalink
Merge pull request #4 from Kocal/fix/enable-tty-if-supported
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal authored May 26, 2024
2 parents 05af236 + 02a2413 commit 1a26bb5
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 11 deletions.
53 changes: 52 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,55 @@ jobs:
run: symfony php vendor/bin/phpstan analyze

- name: Run PHPUnit
run: symfony php vendor/bin/phpunit
run: symfony php vendor/bin/phpunit

e2e:
name: E2E
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: symfony-cli

- name: Install Composer dependencies
run: symfony composer install --prefer-dist --no-interaction --no-progress

- name: Create a new Symfony project and install kocal/biome-js-bundle
run: |
git config --global user.email "[email protected]"
git config --global user.name "Hugo Alliaume"
symfony new my_app --webapp
cd my_app
symfony composer config minimum-stability dev
symfony composer config repositories.biome-js-bundle '{"type":"path", "url":"../","options":{"symlink":true}}'
symfony composer require 'kocal/biome-js-bundle:*' --dev
cat << EOF > biome.json
{
"files": {
"ignore": [
"composer.json",
"assets/vendor/*",
"vendor/*",
"public/bundles/*"
]
}
}
EOF
- name: Run Biome CI, which should fails
run: symfony console biome:ci .
continue-on-error: true
working-directory: my_app

- name: Run Biome Check, and apply fixes
run: symfony console biome:check . --apply
working-directory: my_app

- name: Run Biome CI, which should now pass
run: symfony console biome:ci .
working-directory: my_app

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/vendor/
composer.lock
.phpunit.result.cache

my_app/
5 changes: 3 additions & 2 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
use Kocal\BiomeJsBundle\Command\BiomeJsCheckCommand;
use Kocal\BiomeJsBundle\Command\BiomeJsCiCommand;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\Process\Process;
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)
->set('biomejs.use_tty', Process::isTtySupported())
;

$container->services()
Expand Down Expand Up @@ -40,4 +41,4 @@
service('biomejs'),
])
->tag('console.command');
};
};
6 changes: 3 additions & 3 deletions src/BiomeJs.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(
) {
}

public function setOutput(SymfonyStyle|null $output): void
public function setOutput(?SymfonyStyle $output): void
{
$this->output = $output;
}
Expand All @@ -33,7 +33,7 @@ public function check(
bool $organizeImportsEnabled,
bool $staged,
bool $changed,
string|null $since,
?string $since,
array $path,
): Process {
$arguments = [];
Expand Down Expand Up @@ -81,7 +81,7 @@ public function ci(
bool $linterEnabled,
bool $organizeImportsEnabled,
bool $changed,
string|null $since,
?string $since,
array $path,
): Process {
$arguments = [];
Expand Down
10 changes: 5 additions & 5 deletions src/BiomeJsBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@

final class BiomeJsBinary
{
private SymfonyStyle|null $output = null;
private ?SymfonyStyle $output = null;
private HttpClientInterface $httpClient;
private string|null $cachedVersion = null;
private ?string $cachedVersion = null;

public function __construct(
private readonly string $cwd,
private readonly string $binaryDownloadDir,
private readonly string|null $binaryVersion,
HttpClientInterface|null $httpClient = null,
private readonly ?string $binaryVersion,
?HttpClientInterface $httpClient = null,
) {
$this->httpClient = $httpClient ?? HttpClient::create();
}

public function setOutput(SymfonyStyle|null $output): void
public function setOutput(?SymfonyStyle $output): void
{
$this->output = $output;
}
Expand Down

0 comments on commit 1a26bb5

Please sign in to comment.