Skip to content

Commit 8ccb3fc

Browse files
author
Jean-François Lépine
committed
Command for generate registry
1 parent 68f86ce commit 8ccb3fc

File tree

18 files changed

+476
-106
lines changed

18 files changed

+476
-106
lines changed

src/Toolkit/bin/build-registry.php

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
#!/usr/bin/env php
22
<?php
33

4-
require_once __DIR__ . '/../vendor/autoload.php';
4+
/*
5+
* This file is part of the Symfony package.
6+
*
7+
* (c) Fabien Potencier <[email protected]>
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
512

6-
use Symfony\Component\Filesystem\Filesystem;
7-
use Symfony\Component\Finder\Finder;
8-
use Symfony\UX\Toolkit\Registry\Registry;
9-
use Symfony\UX\Toolkit\Registry\RegistryItem;
13+
require_once __DIR__.'/../vendor/autoload.php';
1014

11-
// --- Configuration
12-
$templateDir = __DIR__ . '/../templates';
13-
$registryDir = __DIR__ . '/../registry';
14-
// --- End of Configuration
15-
16-
$registry = Registry::empty();
17-
$filesystem = new Filesystem();
18-
19-
$finderTemplates = Finder::create()
20-
->files()
21-
->in($templateDir)
22-
->name('*.html.twig')
23-
->sortByName();
24-
25-
foreach ($finderTemplates as $file) {
26-
$registry->add(RegistryItem::fromFile($file));
27-
}
28-
29-
$registry->save($registryDir, $filesystem);
15+
$app = new Symfony\Component\Console\Application('Symfony UX Toolkit Builder', '0.1');
16+
$compiler = new Symfony\UX\Toolkit\Compiler\RegistryCompiler(new Symfony\Component\Filesystem\Filesystem());
17+
$app->add(new Symfony\UX\Toolkit\Command\BuildRegistryCommand($compiler));
18+
$app->setDefaultCommand('ux:toolkit:build-registry', true);
19+
$app->run();
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "Alert",
3-
"theme": "default",
3+
"theme": "",
44
"type": "component",
55
"code": "<div {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n <twig:Button>Dependency test</twig:Button>\n {% block content %}Alert{% endblock %}\n</div>\n",
6-
"dependencies": ["Button"]
6+
"fingerprint": "9d173046a7c64cfc696f1a89aaac82a6",
7+
"dependencies": []
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "Card",
3-
"theme": "default",
3+
"theme": "",
44
"type": "component",
55
"code": "<div {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n {% block content %}{% endblock %}\n</div>\n",
6+
"fingerprint": "b5033826eca1935e4055bf8e4d192a81",
67
"dependencies": []
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "Navbar",
3-
"theme": "default",
3+
"theme": "",
44
"type": "component",
55
"code": "<nav {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n {% block content %}{% endblock %}\n</nav>\n",
6+
"fingerprint": "213add68cdffa8aa3a270d7629bb489b",
67
"dependencies": []
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "Table",
3-
"theme": "default",
3+
"theme": "",
44
"type": "component",
55
"code": "{# ux:with{Row, Button} #}\n<table {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n {% block content %}{% endblock %}\n</table>\n",
6+
"fingerprint": "60ec2663e1ba9c92b59d57935e565b2e",
67
"dependencies": ["Row"]
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "Row",
3-
"theme": "default",
3+
"theme": "",
44
"type": "component",
55
"code": "<tr {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n {% block content %}Row{% endblock %}\n</tr>\n",
6+
"fingerprint": "0fded51fb960081206bbb62d932951a0",
67
"dependencies": []
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "Badge",
3-
"theme": "default",
3+
"theme": "",
44
"type": "example",
55
"code": "<twig:Badge>Badge</twig:Badge>\n",
6+
"fingerprint": "6eeb538fce2bda2152dd7af729d01253",
67
"dependencies": []
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "BadgeOutline",
3-
"theme": "default",
3+
"theme": "",
44
"type": "example",
55
"code": "<twig:Badge outline>Badge</twig:Badge>\n<twig:Badge variant=\"primary\" outline>Badge</twig:Badge>\n<twig:Badge variant=\"secondary\" outline>Badge</twig:Badge>\n",
6+
"fingerprint": "ed027eb6cb73152ed3e7291fc39f6c07",
67
"dependencies": []
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "Button",
3-
"theme": "default",
3+
"theme": "",
44
"type": "example",
55
"code": "<twig:Button>Click me</twig:Button>\n",
6+
"fingerprint": "6449c62a6ead499bd1402d6b8506e45d",
67
"dependencies": []
78
}
Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,62 @@
11
{
22
"$schema": "https://ui.shadcn.com/schema/registry.json",
3-
"name": "symfony",
4-
"homepage": "https://symfony.com",
3+
"homepage": "https://...",
54
"items": [
65
{
7-
"name": "badge",
8-
"manifest": "components/Badge.json",
9-
"type": "registry:component",
10-
"title": "Badge",
11-
"description": "A simple badge component",
12-
"registryDependencies": [],
13-
"files": []
6+
"name": "Alert",
7+
"theme": "",
8+
"type": "component",
9+
"fingerprint": "9d173046a7c64cfc696f1a89aaac82a6",
10+
"dependencies": []
1411
},
1512
{
16-
"name": "button",
17-
"manifest": "components/Button.json",
18-
"type": "registry:component",
19-
"title": "Button",
20-
"description": "A Button component",
21-
"registryDependencies": [],
22-
"files": []
13+
"name": "Badge",
14+
"theme": "",
15+
"type": "example",
16+
"fingerprint": "6eeb538fce2bda2152dd7af729d01253",
17+
"dependencies": []
18+
},
19+
{
20+
"name": "Button",
21+
"theme": "",
22+
"type": "example",
23+
"fingerprint": "6449c62a6ead499bd1402d6b8506e45d",
24+
"dependencies": []
25+
},
26+
{
27+
"name": "Card",
28+
"theme": "",
29+
"type": "component",
30+
"fingerprint": "b5033826eca1935e4055bf8e4d192a81",
31+
"dependencies": []
32+
},
33+
{
34+
"name": "Navbar",
35+
"theme": "",
36+
"type": "component",
37+
"fingerprint": "213add68cdffa8aa3a270d7629bb489b",
38+
"dependencies": []
39+
},
40+
{
41+
"name": "Table",
42+
"theme": "",
43+
"type": "component",
44+
"fingerprint": "60ec2663e1ba9c92b59d57935e565b2e",
45+
"dependencies": ["Row"]
46+
},
47+
{
48+
"name": "Row",
49+
"theme": "",
50+
"type": "component",
51+
"fingerprint": "0fded51fb960081206bbb62d932951a0",
52+
"dependencies": []
53+
},
54+
{
55+
"name": "BadgeOutline",
56+
"theme": "",
57+
"type": "example",
58+
"fingerprint": "ed027eb6cb73152ed3e7291fc39f6c07",
59+
"dependencies": []
2360
}
2461
]
2562
}

0 commit comments

Comments
 (0)