Skip to content

Commit 921c7d4

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

File tree

33 files changed

+48
-823
lines changed

33 files changed

+48
-823
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: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,23 @@
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;
1819
use Symfony\Component\Finder\Finder;
1920
use Symfony\UX\Toolkit\Kit\Kit;
2021
use Symfony\UX\Toolkit\Kit\KitContextRunner;
2122
use Symfony\UX\Toolkit\Kit\KitFactory;
23+
use Symfony\UX\Toolkit\Kit\KitSynchronizer;
2224
use Symfony\UX\Toolkit\Recipe\Recipe;
25+
use Symfony\UX\Toolkit\Recipe\RecipeSynchronizer;
26+
use Symfony\UX\Toolkit\Recipe\RecipeType;
2327
use Symfony\UX\Toolkit\Registry\LocalRegistry;
28+
use Symfony\UX\Toolkit\Tests\TestHelperTrait;
2429

2530
class ComponentsRenderingTest extends WebTestCase
2631
{
2732
use MatchesSnapshots;
33+
use TestHelperTrait;
2834

2935
private const KITS_DIR = __DIR__.'/../../kits';
3036

@@ -33,20 +39,24 @@ class ComponentsRenderingTest extends WebTestCase
3339
*/
3440
public static function provideTestComponentRendering(): iterable
3541
{
42+
$filesystem = new Filesystem();
43+
$kitSynchronizer = new KitSynchronizer($filesystem, new RecipeSynchronizer());
44+
3645
foreach (LocalRegistry::getAvailableKitsName() as $kitName) {
37-
$kitDir = Path::join(__DIR__, '../../kits', $kitName);
38-
$docsFinder = (new Finder())->files()->name('EXAMPLES.md')->in($kitDir)->depth(1);
46+
$kit = self::createLocalKit($kitName);
47+
$kitSynchronizer->synchronize($kit);
3948

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

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

57+
4858
foreach ($codeBlockMatches['code'] as $i => $code) {
49-
yield \sprintf('Kit %s, component %s, code #%d', $kitName, $componentName, $i + 1) => [$kitName, $componentName, $code];
59+
yield \sprintf('Kit %s, component %s, code #%d', $kitName, $recipe->manifest->name, $i + 1) => [$kitName, $recipe->manifest->name, $code];
5060
}
5161
}
5262
}
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)