Add lib skeleton command and sort config, spc_mode suuport, etc...

This commit is contained in:
crazywhalecc
2025-12-18 15:43:58 +08:00
parent 1707c679e8
commit dd5762fbd3
19 changed files with 866 additions and 109 deletions

View File

@@ -16,20 +16,24 @@ class PackageConfig
* Load package configurations from a specified directory.
* It will look for files matching the pattern 'pkg.*.json' and 'pkg.json'.
*/
public static function loadFromDir(string $dir, string $registry_name): void
public static function loadFromDir(string $dir, string $registry_name): array
{
if (!is_dir($dir)) {
throw new WrongUsageException("Directory {$dir} does not exist, cannot load pkg.json config.");
}
$loaded = [];
$files = glob("{$dir}/pkg.*.json");
if (is_array($files)) {
foreach ($files as $file) {
self::loadFromFile($file, $registry_name);
$loaded[] = $file;
}
}
if (file_exists("{$dir}/pkg.json")) {
self::loadFromFile("{$dir}/pkg.json", $registry_name);
$loaded[] = "{$dir}/pkg.json";
}
return $loaded;
}
/**
@@ -37,7 +41,7 @@ class PackageConfig
*
* @param string $file the path to the json package configuration file
*/
public static function loadFromFile(string $file, string $registry_name): void
public static function loadFromFile(string $file, string $registry_name): string
{
$content = file_get_contents($file);
if ($content === false) {
@@ -52,6 +56,7 @@ class PackageConfig
self::$package_configs[$pkg_name] = $config;
Registry::_bindPackageConfigFile($pkg_name, $registry_name, $file);
}
return $file;
}
/**