feat(commands): describe catalog rows per component with package fallback

This commit is contained in:
kj
2026-10-05 18:10:30 -03:00
parent 40d853b2b0
commit 90e800ba1f
6 changed files with 83 additions and 10 deletions
+25
View File
@@ -121,3 +121,28 @@ Harness::it('ciclo de dependencias se detecta', function () {
rrmdir($dir);
});
Harness::it('la descripcion del componente prevalece y hereda del paquete', function () {
$m = Manifest::fromArray([
'name' => 'pkg',
'version' => '1.0.0',
'description' => 'Resumen del paquete',
'components' => [
'a' => ['files' => ['src/A.php'], 'description' => 'Componente A'],
'b' => ['files' => ['src/B.php']],
],
]);
eq('Componente A', $m->descriptionOf('a'), 'descripción propia gana');
eq('Resumen del paquete', $m->descriptionOf('b'), 'sin descripción propia hereda del paquete');
eq('Resumen del paquete', $m->descriptionOf(), 'sin componente: la del paquete');
$m2 = Manifest::fromArray(['name' => 'x', 'version' => '1.0.0', 'components' => ['c' => ['files' => ['c.php']]]]);
eq('', $m2->descriptionOf('c'), 'paquete sin texto produce cadena vacía (no null)');
throws(fn () => Manifest::fromArray([
'name' => 'y',
'version' => '1.0.0',
'components' => ['c' => ['files' => ['c.php'], 'description' => 7]],
]), 'description no-string es inválida');
});
+24
View File
@@ -238,3 +238,27 @@ Harness::it('--force resuelve drift pero no salta avisos de compatibilidad', fun
rrmdir($proj);
rrmdir($tool);
});
Harness::it('el catálogo describe cada componente con su texto propio o heredado', function () {
$toolbox = g7_toolbox();
$manifest = json_decode((string) file_get_contents($toolbox . '/packages/http/duckbrain.json'), true);
$manifest['components']['curlRequest']['description'] = 'Cliente HTTP sobre cURL';
write_file($toolbox . '/packages/http/duckbrain.json', json_encode($manifest, JSON_PRETTY_PRINT));
$proj = tmpdir('proj');
$out = fopen('php://memory', 'rw');
$code = (new Toolbox\Commands\CatalogCommand(new Console($out)))->run(
['--root=' . $proj, '--toolbox=' . $toolbox]
);
rewind($out);
$text = (string) stream_get_contents($out);
eq(0, $code, 'catalog termina bien');
ok((bool) preg_match('/curlRequest.*Cliente HTTP sobre cURL/', $text), 'fila propia con su texto');
ok((bool) preg_match('/aria2.*Utilidades HTTP/', $text), 'fila sin texto hereda el del paquete');
ok((bool) preg_match('/compreFace.*Utilidades HTTP/', $text), 'vecino heredando igual');
ok(!preg_match('/aria2.*cURL/', $text), 'los textos no se mezclan entre filas');
rrmdir($toolbox);
rrmdir($proj);
});