sort pkg.json

This commit is contained in:
crazywhalecc 2024-02-18 14:02:34 +08:00 committed by Jerry Ma
parent a30e054d7d
commit 8376122634
3 changed files with 46 additions and 32 deletions

View File

@ -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"
}
}
{
"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"
}
}
}

View File

@ -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('<error>Write file pkg.json failed!</error>');
return static::FAILURE;
}
break;
default:
$this->output->writeln("<error>invalid config name: {$name}</error>");
return 1;

View File

@ -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');
}
}