Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
name: "Codesniffer"
uses: contributte/.github/.github/workflows/codesniffer.yml@master
with:
php: "8.2"
php: "8.3"
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 9 * * 1"

jobs:
coverage:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master
with:
php: "8.2"
php: "8.3"
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 10 * * 1"

jobs:
phpstan:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@master
with:
php: "8.2"
php: "8.3"
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ on:
workflow_dispatch:

push:
branches: [ "*" ]
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 10 * * 1"

jobs:
test83:
test84:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.3"
php: "8.4"

test82:
test83:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.2"
php: "8.3"

test81:
test82:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.1"
php: "8.2"

testlower:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.1"
php: "8.2"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
"issues": "https://github.com/contributte/vite/issues"
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"nette/application": "^3.0.8",
"nette/di": "^3.1.8",
"nette/safe": "^0.9",
"tracy/tracy": "^2.10.5"
},
"require-dev": {
"latte/latte": "^3.0.12",
"contributte/qa": "^0.4",
"contributte/tester": "^0.3",
"contributte/phpstan": "^0.1"
"contributte/phpstan": "^0.2.0",
"contributte/qa": "^0.4.0",
"contributte/tester": "^0.3.0",
"latte/latte": "^3.0.12"
},
"suggest": {
"tracy/tracy": "to enable asset debugging in the debug bar panel",
Expand All @@ -45,6 +44,11 @@
"Contributte\\Vite\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
Expand Down
4 changes: 1 addition & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:

parameters:
level: 9
phpVersion: 80100
phpVersion: 80200

scanDirectories:
- src
Expand All @@ -14,5 +14,3 @@ parameters:
paths:
- src
- .docs

ignoreErrors:
6 changes: 1 addition & 5 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Contributte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<!-- Rulesets -->
<rule ref="./vendor/contributte/qa/ruleset-8.0.xml"/>
<rule ref="./vendor/contributte/qa/ruleset-8.3.xml"/>

<!-- Rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
Expand All @@ -10,10 +10,6 @@
<element key="src" value="Contributte\Vite"/>
<element key="tests" value="Tests"/>
</property>
<property name="extensions" type="array">
<element key="php" value="php"/>
<element key="phpt" value="phpt"/>
</property>
</properties>
</rule>

Expand Down
5 changes: 2 additions & 3 deletions src/Nette/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Nette\DI\Definitions\FactoryDefinition;
use Nette\DI\Definitions\ServiceDefinition;
use Nette\DI\Definitions\Statement;
use Nette\Safe;
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use Nette\Utils\Finder;
Expand Down Expand Up @@ -120,13 +119,13 @@ private function prepareManifestPath(): string
$manifestFile = $newPath;
}

return Safe::realpath($manifestFile);
return (string) realpath($manifestFile);
}

private function prepareBasePath(string $manifestFile): string
{
if ($this->config->basePath === null) {
return str_replace(Safe::realpath($this->config->wwwDir), '', dirname($manifestFile)) . '/';
return str_replace((string) realpath($this->config->wwwDir), '', dirname($manifestFile)) . '/';
}

return $this->config->basePath;
Expand Down
37 changes: 18 additions & 19 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class Service

private IRequest $httpRequest;

/** @var array<array<mixed>> $manifest */
/** @var array<string, array{file?: string, css?: list<string>, imports?: list<string>, dynamicImports?: list<string>}> */
private array $manifest;

public function __construct(
Expand All @@ -46,26 +46,11 @@ public function __construct(
trigger_error('Missing manifest file: ' . $this->manifestFile, E_USER_WARNING);
}

/** @var array<array<mixed>> $manifest */
/** @var array<string, array{file?: string, css?: list<string>, imports?: list<string>, dynamicImports?: list<string>}> $manifest */
$manifest = json_decode(FileSystem::read($this->manifestFile), true);
$this->manifest = $manifest;
}

/**
* @return array<string, array<array<string, string>>>
*/
private function getEndpointManifest(string $entrypoint): array {
$entrypoint = ltrim($entrypoint, '/');
/** @var array<string, array<array<string, string>>> $manifest */
$manifest = $this->manifest[$entrypoint];

if ($manifest === null) {
throw new LogicalException('Invalid manifest');
}

return $manifest;
}

public function getAsset(string $entrypoint): string
{
if (str_starts_with($entrypoint, 'http')) {
Expand Down Expand Up @@ -105,7 +90,7 @@ public function getCssAssets(string $entrypoint, bool $withNestedCss = false): G
}

/**
* @return array<string, string>
* @return list<string>
*/
public function getImports(string $entrypoint): array
{
Expand All @@ -119,7 +104,7 @@ public function getImports(string $entrypoint): array
}

/**
* @return array<string, string>
* @return list<string>
*/
public function getDynamicImports(string $entrypoint): array
{
Expand Down Expand Up @@ -170,4 +155,18 @@ public function getViteCookie(): string
return $this->viteCookie;
}

/**
* @return array{file?: string, css?: list<string>, imports?: list<string>, dynamicImports?: list<string>}
*/
private function getEndpointManifest(string $entrypoint): array
{
$entrypoint = ltrim($entrypoint, '/');

if (!isset($this->manifest[$entrypoint])) {
throw new LogicalException('Invalid manifest');
}

return $this->manifest[$entrypoint];
}

}
3 changes: 1 addition & 2 deletions src/Tracy/VitePanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Contributte\Vite\Tracy;

use Contributte\Vite\Service;
use Nette\Safe;
use Tracy\IBarPanel;

final class VitePanel implements IBarPanel
Expand All @@ -18,7 +17,7 @@ public function __construct(Service $vite)

public function getTab(): string
{
$html = Safe::file_get_contents(__DIR__ . '/Vite.html');
$html = (string) file_get_contents(__DIR__ . '/Vite.html');

return str_replace('%viteCookie%', $this->vite->getViteCookie(), $html);
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Cases/DI/Extension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ use Nette\Bridges\ApplicationDI\LatteExtension;
use Nette\Bridges\ApplicationDI\RoutingExtension;
use Nette\Bridges\HttpDI\HttpExtension;
use Nette\DI\Compiler;
use Nette\Safe;
use Tester\Assert;

require_once __DIR__ . '/../../bootstrap.php';

Toolkit::test(static function (): void {
Safe::touch(Environment::getTestDir() . '/manifest.json');
file_put_contents(Environment::getTestDir() . '/manifest.json', '{}');

$container = ContainerBuilder::of()
->withCompiler(function (Compiler $compiler): void {
Expand Down