diff --git a/config/pkg.json b/config/pkg.json
index a7d1d0c8..db7cfe84 100644
--- a/config/pkg.json
+++ b/config/pkg.json
@@ -1,32 +1,32 @@
-{
- "upx-x86_64-linux": {
- "type": "url",
- "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-amd64_linux.tar.xz",
- "extract-files": {
- "upx": "{pkg_root_path}/bin/upx"
- }
- },
- "upx-aarch64-linux": {
- "type": "url",
- "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-arm64_linux.tar.xz",
- "extract-files": {
- "upx": "{pkg_root_path}/bin/upx"
- }
- },
- "nasm-x86_64-win": {
- "type": "url",
- "url": "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip",
- "extract-files": {
- "nasm-2.16.01/nasm.exe": "{php_sdk_path}/bin/nasm.exe",
- "nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe"
- }
- },
- "strawberry-perl-x86_64-win": {
- "type": "url",
- "url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip"
- },
- "musl-toolchain-x86_64-linux": {
- "type": "url",
- "url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/x86_64-musl-toolchain.tgz"
- }
-}
\ No newline at end of file
+{
+ "musl-toolchain-x86_64-linux": {
+ "type": "url",
+ "url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/x86_64-musl-toolchain.tgz"
+ },
+ "nasm-x86_64-win": {
+ "type": "url",
+ "url": "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip",
+ "extract-files": {
+ "nasm-2.16.01/nasm.exe": "{php_sdk_path}/bin/nasm.exe",
+ "nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe"
+ }
+ },
+ "strawberry-perl-x86_64-win": {
+ "type": "url",
+ "url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip"
+ },
+ "upx-aarch64-linux": {
+ "type": "url",
+ "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-arm64_linux.tar.xz",
+ "extract-files": {
+ "upx": "{pkg_root_path}/bin/upx"
+ }
+ },
+ "upx-x86_64-linux": {
+ "type": "url",
+ "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-amd64_linux.tar.xz",
+ "extract-files": {
+ "upx": "{pkg_root_path}/bin/upx"
+ }
+ }
+}
diff --git a/src/SPC/command/dev/SortConfigCommand.php b/src/SPC/command/dev/SortConfigCommand.php
index 8eb7680a..bc29ed13 100644
--- a/src/SPC/command/dev/SortConfigCommand.php
+++ b/src/SPC/command/dev/SortConfigCommand.php
@@ -57,6 +57,15 @@ class SortConfigCommand extends BaseCommand
return static::FAILURE;
}
break;
+ case 'pkg':
+ $file = json_decode(FileSystem::readFile(ROOT_DIR . '/config/pkg.json'), true);
+ ConfigValidator::validatePkgs($file);
+ ksort($file);
+ if (!file_put_contents(ROOT_DIR . '/config/pkg.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n")) {
+ $this->output->writeln('Write file pkg.json failed!');
+ return static::FAILURE;
+ }
+ break;
default:
$this->output->writeln("invalid config name: {$name}");
return 1;
diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php
index 0126ddf9..ba1d6815 100644
--- a/src/SPC/util/ConfigValidator.php
+++ b/src/SPC/util/ConfigValidator.php
@@ -70,4 +70,9 @@ class ConfigValidator
{
is_array($data) || throw new ValidationException('ext.json is broken');
}
+
+ public static function validatePkgs(mixed $data): void
+ {
+ is_array($data) || throw new \_PHPStan_c997ea9ee\Nette\Schema\ValidationException('pkg.json is broken');
+ }
}