Add a linter for the Twig templates
Uses symfony/twig-bridge v4.4. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
d04c98353b
commit
168cf0555b
@ -50,6 +50,7 @@ jobs:
|
||||
- composer phpcs
|
||||
- yarn run js-lint --quiet
|
||||
- yarn run css-lint
|
||||
- php scripts/console lint:twig templates --show-deprecations
|
||||
|
||||
- stage: "Lint and analyse code"
|
||||
name: "Run phpstan"
|
||||
|
||||
@ -89,7 +89,9 @@
|
||||
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.0",
|
||||
"pragmarx/google2fa-qrcode": "^1.0.1",
|
||||
"samyoul/u2f-php-server": "^1.1",
|
||||
"symfony/console": "^4.3",
|
||||
"symfony/console": "^4.4",
|
||||
"symfony/finder": "^4.4",
|
||||
"symfony/twig-bridge": "^4.4",
|
||||
"tecnickcom/tcpdf": "^6.3",
|
||||
"vimeo/psalm": "^3.11"
|
||||
},
|
||||
|
||||
@ -3,7 +3,24 @@
|
||||
|
||||
use PhpMyAdmin\Command\AdvisoryRulesCommand;
|
||||
use PhpMyAdmin\Command\CacheWarmupCommand;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PhpMyAdmin\Twig\CoreExtension;
|
||||
use PhpMyAdmin\Twig\I18nExtension;
|
||||
use PhpMyAdmin\Twig\MessageExtension;
|
||||
use PhpMyAdmin\Twig\PluginsExtension;
|
||||
use PhpMyAdmin\Twig\RelationExtension;
|
||||
use PhpMyAdmin\Twig\SanitizeExtension;
|
||||
use PhpMyAdmin\Twig\TableExtension;
|
||||
use PhpMyAdmin\Twig\TrackerExtension;
|
||||
use PhpMyAdmin\Twig\TransformationsExtension;
|
||||
use PhpMyAdmin\Twig\UrlExtension;
|
||||
use PhpMyAdmin\Twig\UtilExtension;
|
||||
use Symfony\Bridge\Twig\Command\LintCommand;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
|
||||
@ -19,9 +36,36 @@ if (! class_exists(Application::class)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$cfg['environment'] = 'production';
|
||||
$PMA_Config = new Config(CONFIG_FILE);
|
||||
$PMA_Config->set('environment', $cfg['environment']);
|
||||
$dbi = new DatabaseInterface(new DbiDummy());
|
||||
$tplDir = ROOT_PATH . 'templates';
|
||||
$tmpDir = ROOT_PATH . 'twig-templates';
|
||||
|
||||
$loader = new FilesystemLoader($tplDir);
|
||||
$twig = new Environment($loader, [
|
||||
'auto_reload' => true,
|
||||
'cache' => $tmpDir,
|
||||
]);
|
||||
$twig->setExtensions([
|
||||
new CoreExtension(),
|
||||
new I18nExtension(),
|
||||
new MessageExtension(),
|
||||
new PluginsExtension(),
|
||||
new RelationExtension(),
|
||||
new SanitizeExtension(),
|
||||
new TableExtension(),
|
||||
new TrackerExtension(),
|
||||
new TransformationsExtension(),
|
||||
new UrlExtension(),
|
||||
new UtilExtension(),
|
||||
]);
|
||||
|
||||
$application = new Application('phpMyAdmin Console Tool');
|
||||
|
||||
$application->add(new AdvisoryRulesCommand());
|
||||
$application->add(new CacheWarmupCommand());
|
||||
$application->add(new LintCommand($twig));
|
||||
|
||||
$application->run();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user