efabrica / neon-checker
在选定的路径中查找所有 neon 并尝试解码
0.3.1
2023-04-20 19:42 UTC
Requires
- php: >= 7.1.0
- nette/neon: ^2.4 | ^3.0
- symfony/console: ^4.2 | ^5.0
- symfony/finder: ^4.2 | ^5.0
This package is auto-updated.
Last update: 2024-09-20 23:08:43 UTC
README
这个库可以帮助找到 neon 文件中的错误,它可以用在 CI 工具中。
安装
Neon checker 需要 PHP 7.1.0 或更高版本。您可以通过 Composer 安装它。这个项目不打算作为一个依赖项运行,因此请全局安装
composer global require efabrica/neon-checker
或者作为一个独立项目
mkdir /var/www/neon-checker
cd /var/www/neon-checker
composer require efabrica/neon-checker
使用方法
这个库包含两个命令。这两个命令的返回值是找到的错误数,因此您可以在 CI 工具中使用它们。
echo $?
1
validate
neon-checker validate <dirs>...
注意:有关更多信息,请运行 neon-checker validate --help
命令的结果看起来像这样
Errors found: 1
使用详细输出,您将得到
Errors found: 1
Error: Unexpected ',' on line 23, column 10.
File: neons/subdir/test2.neon:23
使用非常详细输出时,还会包含部分文件内容以及错误。
Content:
18: b:
19: c:
20: d"
21:
22: aaa:
23: <error>bbb: ccc, ddd</error>
24:
25: a:
26: b:
27: c:
28: d"
disallowed
neon-checker disallowed [--disallowed-keys DISALLOWED-KEYS] [--disallowed-values DISALLOWED-VALUES] [--] <dirs>...
使用这个命令,您可以在 neon 配置中禁用一些键和/或值。
例如
要禁用键 http:frames
例如。
http: frames: someValue
neon-checker disallowed app/config/ --disallowed-keys="http:frames"
要禁用此键的具体值例如。
http: frames: yes
您可以通过带有选项 --disallowed-values 的命令运行它
neon-checker disallowed app/config/ --disallowed-values="http:frames:yes"
至少要设置 --disallowed-keys
和 --disallowed-values
选项之一,它们可以多次使用并且可以组合使用。例如
neon-checker disallowed app/config/ --disallowed-keys="session:expiration" --disallowed-keys="php:date.timezone" --disallowed-values="http:frames:yes"
命令的输出很简单
Errors found: 4
或者更详细地使用详细(-v
)选项
Errors found: 4
File app/config/config.neon
contains these disallowed keys:
- session:expiration
- php:date.timezone
contains these disallowed values:
- http:frames:yes
File app/config/config.local.neon
contains these disallowed keys:
- php:date.timezone