Skip to content

Commit 5d18e80

Browse files
committed
[Toolkit] Delay/hide the "Community Kits" feature, minor fixes
1 parent b45d8b0 commit 5d18e80

File tree

34 files changed

+48
-825
lines changed

34 files changed

+48
-825
lines changed

src/Toolkit/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ https://github.com/symfony/ux to create issues or submit pull requests.
1010

1111
## Resources
1212

13-
- [Documentation](https://symfony.com/bundles/ux-toolkit/current/index.html)
13+
- [Documentation](https://ux.symfony.com/bundles/toolkit)
1414
- [Report issues](https://github.com/symfony/ux/issues) and
1515
[send Pull Requests](https://github.com/symfony/ux/pulls)
1616
in the [main Symfony UX repository](https://github.com/symfony/ux)

src/Toolkit/doc/index.rst

Lines changed: 0 additions & 172 deletions
This file was deleted.

src/Toolkit/kits/shadcn/AlertDialog/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "../../../schema-kit-recipe-v1.json",
33
"type": "component",
4-
"name": "AlertDialog",
4+
"name": "Alert Dialog",
55
"description": "A modal dialog that interrupts the user with important content and expects a response.",
66
"copy-files": {
77
"assets/": "assets/",

src/Toolkit/kits/shadcn/AspectRatio/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "../../../schema-kit-recipe-v1.json",
33
"type": "component",
4-
"name": "AspectRatio",
4+
"name": "Aspect Ratio",
55
"description": "A container that maintains a specific width-to-height ratio for its content.",
66
"copy-files": {
77
"templates/": "templates/"

src/Toolkit/kits/shadcn/INSTALL.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,3 @@ In your `assets/styles/app.css`, after the TailwindCSS imports, add the followin
9898
}
9999
}
100100
```
101-
102-
And voilà! You are now ready to use Shadcn components in your Symfony project.

src/Toolkit/src/Command/InstallCommand.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
106106
}
107107
// If more than one kit is available, we ask the user which one to use
108108
if (($availableKitsCount = \count($availableKits)) > 1) {
109-
$kitName = $io->choice(null === $recipeName ? 'Which kit do you want to use?' : \sprintf('The recipe "%s" exists in multiple kits. Which one do you want to use?', $recipeName), array_map(fn (Kit $kit) => $kit->manifest->name, $availableKits));
109+
$kitName = $io->choice(null === $recipeName ? 'Which Kit do you want to use?' : \sprintf('The recipe "%s" exists in multiple Kits. Which one do you want to use?', $recipeName), array_map(fn (Kit $kit) => $kit->manifest->name, $availableKits));
110110

111111
foreach ($availableKits as $availableKit) {
112112
if ($availableKit->manifest->name === $kitName) {
@@ -117,11 +117,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
117117
} elseif (1 === $availableKitsCount) {
118118
$kit = $availableKits[0];
119119
} else {
120-
$io->error(
121-
null === $recipeName
122-
? 'It seems that no local kits are available and it should not happens. Please open an issue on https://github.com/symfony/ux to report this.'
123-
: \sprintf("The recipe \"%s\" does not exist in any official kits.\n\nYou can try to run one of the following commands to interactively install recipes:\n%s\n\nOr you can try one of the community kits https://github.com/search?q=topic:ux-toolkit&type=repositories", $recipeName, implode("\n", array_map(fn (string $availableKitName) => \sprintf('$ bin/console %s --kit %s', $this->getName(), $availableKitName), $availableKitNames)))
124-
);
120+
if (null === $recipeName) {
121+
$io->error('It seems that no official kits are available and it should not happens. Please open an issue on https://github.com/symfony/ux to report this.');
122+
} else {
123+
$io->error(\sprintf('The recipe "%s" does not exist in any official kits.', $recipeName));
124+
// $io->error(\sprintf("The recipe \"%s\" does not exist in any official kits.\n\nYou can try to run one of the following commands to interactively install recipes:\n%s\n\nOr you can try one of the community kits https://github.com/search?q=topic:ux-toolkit&type=repositories", $recipeName, implode("\n", array_map(fn (string $availableKitName) => \sprintf('$ bin/console %s --kit %s', $this->getName(), $availableKitName), $availableKitNames))));
125+
}
125126

126127
return Command::FAILURE;
127128
}

src/Toolkit/tests/Command/InstallCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testShouldFailAndSuggestAlternativeRecipesWhenKitIsExplicit()
7676
->execute()
7777
->assertFaulty()
7878
->assertOutputContains('[WARNING] The recipe "A" does not exist')
79-
->assertOutputContains('Possible alternatives: "Alert", "AlertDialog", "AspectRatio"')
79+
->assertOutputContains('Possible alternatives: "Alert", "Alert Dialog", "Aspect Ratio"')
8080
;
8181
}
8282

src/Toolkit/tests/Functional/ComponentsRenderingTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,22 @@
1414
use Spatie\Snapshots\Drivers\HtmlDriver;
1515
use Spatie\Snapshots\MatchesSnapshots;
1616
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
17+
use Symfony\Component\Filesystem\Filesystem;
1718
use Symfony\Component\Filesystem\Path;
18-
use Symfony\Component\Finder\Finder;
1919
use Symfony\UX\Toolkit\Kit\Kit;
2020
use Symfony\UX\Toolkit\Kit\KitContextRunner;
2121
use Symfony\UX\Toolkit\Kit\KitFactory;
22+
use Symfony\UX\Toolkit\Kit\KitSynchronizer;
2223
use Symfony\UX\Toolkit\Recipe\Recipe;
24+
use Symfony\UX\Toolkit\Recipe\RecipeSynchronizer;
25+
use Symfony\UX\Toolkit\Recipe\RecipeType;
2326
use Symfony\UX\Toolkit\Registry\LocalRegistry;
27+
use Symfony\UX\Toolkit\Tests\TestHelperTrait;
2428

2529
class ComponentsRenderingTest extends WebTestCase
2630
{
2731
use MatchesSnapshots;
32+
use TestHelperTrait;
2833

2934
private const KITS_DIR = __DIR__.'/../../kits';
3035

@@ -33,20 +38,23 @@ class ComponentsRenderingTest extends WebTestCase
3338
*/
3439
public static function provideTestComponentRendering(): iterable
3540
{
41+
$filesystem = new Filesystem();
42+
$kitSynchronizer = new KitSynchronizer($filesystem, new RecipeSynchronizer());
43+
3644
foreach (LocalRegistry::getAvailableKitsName() as $kitName) {
37-
$kitDir = Path::join(__DIR__, '../../kits', $kitName);
38-
$docsFinder = (new Finder())->files()->name('EXAMPLES.md')->in($kitDir)->depth(1);
45+
$kit = self::createLocalKit($kitName);
46+
$kitSynchronizer->synchronize($kit);
3947

40-
foreach ($docsFinder as $docFile) {
41-
$componentName = $docFile->getRelativePath();
48+
foreach ($kit->getRecipes(RecipeType::Component) as $recipe) {
49+
$examplesFilePath = Path::join($recipe->absolutePath, 'EXAMPLES.md');
4250

43-
$codeBlockMatchesResult = preg_match_all('/```twig.*?\n(?P<code>.+?)```/s', $docFile->getContents(), $codeBlockMatches);
51+
$codeBlockMatchesResult = preg_match_all('/```twig.*?\n(?P<code>.+?)```/s', file_get_contents($examplesFilePath), $codeBlockMatches);
4452
if (false === $codeBlockMatchesResult || 0 === $codeBlockMatchesResult) {
45-
throw new \RuntimeException(\sprintf('No Twig code blocks found in file "%s"', $docFile->getRelativePathname()));
53+
throw new \RuntimeException(\sprintf('No Twig code blocks found in file "%s"', $examplesFilePath));
4654
}
4755

4856
foreach ($codeBlockMatches['code'] as $i => $code) {
49-
yield \sprintf('Kit %s, component %s, code #%d', $kitName, $componentName, $i + 1) => [$kitName, $componentName, $code];
57+
yield \sprintf('Kit %s, component %s, code #%d', $kitName, $recipe->manifest->name, $i + 1) => [$kitName, $recipe->manifest->name, $code];
5058
}
5159
}
5260
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
- Kit: Shadcn UI
3-
- Component: AlertDialog
3+
- Component: Alert Dialog
44
- Code:
55
```twig
66
<twig:AlertDialog id="delete_account">
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
- Kit: Shadcn UI
3-
- Component: AlertDialog
3+
- Component: Alert Dialog
44
- Code:
55
```twig
66
<twig:AlertDialog id="delete_account" open>

0 commit comments

Comments
 (0)