From a46c4560930fcec405673993a58b16cde66c9814 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sun, 11 May 2025 18:24:52 +0900 Subject: [PATCH] [Toolkit] Remove Kit "authors" --- src/Toolkit/kits/shadcn/manifest.json | 1 - src/Toolkit/src/Command/CreateKitCommand.php | 12 ------------ src/Toolkit/src/Command/DebugKitCommand.php | 1 - src/Toolkit/src/Kit/Kit.php | 14 ++++++-------- src/Toolkit/src/Kit/KitFactory.php | 1 - src/Toolkit/tests/Command/DebugKitCommandTest.php | 1 - .../manifest.json | 3 +-- .../kits/with-stimulus-controllers/manifest.json | 3 +-- src/Toolkit/tests/Kit/KitTest.php | 12 ++++++------ 9 files changed, 14 insertions(+), 34 deletions(-) diff --git a/src/Toolkit/kits/shadcn/manifest.json b/src/Toolkit/kits/shadcn/manifest.json index 6a39b488b8d..0c8a4c4d353 100644 --- a/src/Toolkit/kits/shadcn/manifest.json +++ b/src/Toolkit/kits/shadcn/manifest.json @@ -3,6 +3,5 @@ "description": "Component based on the Shadcn UI library, one of the most popular design systems in JavaScript world.", "license": "MIT", "homepage": "https://ux.symfony.com/components", - "authors": ["Shadcn", "Symfony Community"], "ux-icon": "simple-icons:shadcnui" } diff --git a/src/Toolkit/src/Command/CreateKitCommand.php b/src/Toolkit/src/Command/CreateKitCommand.php index 604a88c0265..42f86014240 100644 --- a/src/Toolkit/src/Command/CreateKitCommand.php +++ b/src/Toolkit/src/Command/CreateKitCommand.php @@ -65,17 +65,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int }); $kitHomepage = $io->askQuestion($question); - // Get the kit author name - $question = new Question("What's the name of the author?"); - $question->setValidator(function (?string $value) { - if (empty($value)) { - throw new \Exception('The author name cannot be empty.'); - } - - return $value; - }); - $kitAuthorName = $io->askQuestion($question); - // Get the kit license $question = new Question('What is the license of your kit?'); $question->setValidator(function (string $value) { @@ -91,7 +80,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->filesystem->dumpFile('manifest.json', json_encode([ 'name' => $kitName, 'homepage' => $kitHomepage, - 'authors' => [$kitAuthorName], 'license' => $kitLicense, ], \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $this->filesystem->dumpFile('templates/components/Button.html.twig', <<definitionList( ['Name' => $kit->name], ['Homepage' => $kit->homepage], - ['Authors' => implode(', ', $kit->authors)], ['License' => $kit->license], new TableSeparator(), ['Path' => $kit->path], diff --git a/src/Toolkit/src/Kit/Kit.php b/src/Toolkit/src/Kit/Kit.php index 542d6b759d2..dcf69290581 100644 --- a/src/Toolkit/src/Kit/Kit.php +++ b/src/Toolkit/src/Kit/Kit.php @@ -24,19 +24,17 @@ final class Kit { /** - * @param non-empty-string $path - * @param non-empty-string $name - * @param non-empty-string|null $homepage - * @param list|null $authors - * @param non-empty-string|null $license - * @param list $components - * @param list $stimulusControllers + * @param non-empty-string $path + * @param non-empty-string $name + * @param non-empty-string|null $homepage + * @param non-empty-string|null $license + * @param list $components + * @param list $stimulusControllers */ public function __construct( public readonly string $path, public readonly string $name, public readonly ?string $homepage = null, - public readonly array $authors = [], public readonly ?string $license = null, public readonly ?string $description = null, public readonly ?string $uxIcon = null, diff --git a/src/Toolkit/src/Kit/KitFactory.php b/src/Toolkit/src/Kit/KitFactory.php index 6a1f5432b22..039258c2077 100644 --- a/src/Toolkit/src/Kit/KitFactory.php +++ b/src/Toolkit/src/Kit/KitFactory.php @@ -51,7 +51,6 @@ public function createKitFromAbsolutePath(string $absolutePath): Kit path: $absolutePath, name: $manifest['name'] ?? throw new \InvalidArgumentException('Manifest file is missing "name" key.'), homepage: $manifest['homepage'] ?? throw new \InvalidArgumentException('Manifest file is missing "homepage" key.'), - authors: $manifest['authors'] ?? throw new \InvalidArgumentException('Manifest file is missing "authors" key.'), license: $manifest['license'] ?? throw new \InvalidArgumentException('Manifest file is missing "license" key.'), description: $manifest['description'] ?? null, uxIcon: $manifest['ux-icon'] ?? null, diff --git a/src/Toolkit/tests/Command/DebugKitCommandTest.php b/src/Toolkit/tests/Command/DebugKitCommandTest.php index 4704b55df1d..e3f9d61e181 100644 --- a/src/Toolkit/tests/Command/DebugKitCommandTest.php +++ b/src/Toolkit/tests/Command/DebugKitCommandTest.php @@ -27,7 +27,6 @@ public function testShouldBeAbleToDebug(): void // Kit details ->assertOutputContains('Name Shadcn') ->assertOutputContains('Homepage https://ux.symfony.com/components') - ->assertOutputContains('Authors Shadcn, Symfony Community') ->assertOutputContains('License MIT') // A component details ->assertOutputContains(<<<'EOF' diff --git a/src/Toolkit/tests/Fixtures/kits/with-circular-components-dependencies/manifest.json b/src/Toolkit/tests/Fixtures/kits/with-circular-components-dependencies/manifest.json index 5a1be5a1daa..f23837787ff 100644 --- a/src/Toolkit/tests/Fixtures/kits/with-circular-components-dependencies/manifest.json +++ b/src/Toolkit/tests/Fixtures/kits/with-circular-components-dependencies/manifest.json @@ -2,6 +2,5 @@ "name": "With Circular Components Dependencies", "description": "Kit used as a test fixture.", "license": "MIT", - "homepage": "https://ux.symfony.com/", - "authors": ["Symfony UX Community"] + "homepage": "https://ux.symfony.com/" } diff --git a/src/Toolkit/tests/Fixtures/kits/with-stimulus-controllers/manifest.json b/src/Toolkit/tests/Fixtures/kits/with-stimulus-controllers/manifest.json index f8f4ff66455..4589ccfdc23 100644 --- a/src/Toolkit/tests/Fixtures/kits/with-stimulus-controllers/manifest.json +++ b/src/Toolkit/tests/Fixtures/kits/with-stimulus-controllers/manifest.json @@ -2,6 +2,5 @@ "name": "With Stimulus Controllers", "description": "Kit used as a test fixture.", "license": "MIT", - "homepage": "https://ux.symfony.com/", - "authors": ["Symfony UX Community"] + "homepage": "https://ux.symfony.com/" } diff --git a/src/Toolkit/tests/Kit/KitTest.php b/src/Toolkit/tests/Kit/KitTest.php index f9294020e3b..1696ba39c44 100644 --- a/src/Toolkit/tests/Kit/KitTest.php +++ b/src/Toolkit/tests/Kit/KitTest.php @@ -24,7 +24,7 @@ public function testShouldFailIfKitNameIsInvalid(): void $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid kit name "-foobar".'); - new Kit(__DIR__, '-foobar', 'https://example.com', [], 'MIT'); + new Kit(__DIR__, '-foobar', 'https://example.com', 'MIT'); } public function testShouldFailIfKitPathIsNotAbsolute(): void @@ -32,12 +32,12 @@ public function testShouldFailIfKitPathIsNotAbsolute(): void $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage(\sprintf('Kit path "./%s" is not absolute.', __DIR__)); - new Kit(\sprintf('./%s', __DIR__), 'foo', 'https://example.com', [], 'MIT'); + new Kit(\sprintf('./%s', __DIR__), 'foo', 'https://example.com', 'MIT'); } public function testCanAddComponentsToTheKit(): void { - $kit = new Kit(__DIR__, 'foo', 'https://example.com', [], 'MIT'); + $kit = new Kit(__DIR__, 'foo', 'https://example.com', 'MIT'); $kit->addComponent(new Component('Table', [new File(FileType::Twig, 'Table.html.twig', 'Table.html.twig')], null)); $kit->addComponent(new Component('Table:Row', [new File(FileType::Twig, 'Table/Row.html.twig', 'Table/Row.html.twig')], null)); @@ -49,14 +49,14 @@ public function testShouldFailIfComponentIsAlreadyRegisteredInTheKit(): void $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Component "Table" is already registered in the kit.'); - $kit = new Kit(__DIR__, 'foo', 'https://example.com', [], 'MIT'); + $kit = new Kit(__DIR__, 'foo', 'https://example.com', 'MIT'); $kit->addComponent(new Component('Table', [new File(FileType::Twig, 'Table.html.twig', 'Table.html.twig')], null)); $kit->addComponent(new Component('Table', [new File(FileType::Twig, 'Table.html.twig', 'Table.html.twig')], null)); } public function testCanGetComponentByName(): void { - $kit = new Kit(__DIR__, 'foo', 'https://example.com', [], 'MIT'); + $kit = new Kit(__DIR__, 'foo', 'https://example.com', 'MIT'); $kit->addComponent(new Component('Table', [new File(FileType::Twig, 'Table.html.twig', 'Table.html.twig')], null)); $kit->addComponent(new Component('Table:Row', [new File(FileType::Twig, 'Table/Row.html.twig', 'Table/Row.html.twig')], null)); @@ -66,7 +66,7 @@ public function testCanGetComponentByName(): void public function testShouldReturnNullIfComponentIsNotFound(): void { - $kit = new Kit(__DIR__, 'foo', 'https://example.com', [], 'MIT'); + $kit = new Kit(__DIR__, 'foo', 'https://example.com', 'MIT'); $this->assertNull($kit->getComponent('Table:Cell')); }