Skip to content

Commit 982a21e

Browse files
committed
[Toolkit] Big refactoring about the registry & kits system, kits architecture, and value-objects
- The registry system and JSON serialization were fully reworked, no more useless compilation to JSON - Rename "default" theme to "shadcn" - The "theme" term is now known as "kit" useless JSON serialization - Abuse ValueObjects usage for File, Example, Dependency, ... - Add binary for vendors
1 parent 0536dd4 commit 982a21e

File tree

184 files changed

+3532
-3044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+3532
-3044
lines changed

.github/workflows/test.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,20 @@ jobs:
7878
dependency-version: 'highest'
7979
- php-version: '8.4'
8080
dependency-version: 'highest'
81+
- php-version: '8.2'
82+
minimum-stability: stable
83+
component: Toolkit
84+
- php-version: '8.2'
85+
minimum-stability: dev
86+
component: Toolkit
8187
component: ${{ fromJson(needs.tests-php-components.outputs.components )}}
8288
exclude:
8389
- php-version: '8.1'
8490
minimum-stability: 'dev'
8591
- php-version: '8.3'
8692
minimum-stability: 'dev'
93+
- component: Toolkit # does not support PHP 8.1
94+
php-version: '8.1'
8795
- component: Swup # has no tests
8896
- component: Turbo # has its own workflow (test-turbo.yml)
8997
- component: Typed # has no tests

biome.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@
1515
"src/*/src/Bridge/*/assets/src/**",
1616
"src/*/src/Bridge/*/assets/test/**"
1717
],
18-
"ignore": [
19-
"**/composer.json",
20-
"**/vendor",
21-
"**/package.json",
22-
"**/node_modules",
23-
"**/var",
24-
"**/registry/default/**"
25-
]
18+
"ignore": ["**/composer.json", "**/vendor", "**/package.json", "**/node_modules", "**/var"]
2619
},
2720
"linter": {
2821
"rules": {

src/Toolkit/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# CHANGELOG
22

3-
## 2.23
3+
## 2.25
44

5-
- Component added
5+
- Package added

src/Toolkit/Makefile

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

src/Toolkit/bin/build-registry.php

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

src/Toolkit/bin/ux-toolkit-kit-create

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env php
2+
<?php
3+
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+
*/
12+
13+
if ('cli' !== \PHP_SAPI) {
14+
throw new Exception('This script must be run from the command line.');
15+
}
16+
17+
use Symfony\Component\Console\Application;
18+
use Symfony\Component\Filesystem\Filesystem;
19+
use Symfony\UX\Toolkit\Command\CreateKitCommand;
20+
21+
function includeIfExists(string $file): bool
22+
{
23+
return file_exists($file) && include $file;
24+
}
25+
26+
if (
27+
!includeIfExists(__DIR__ . '/../../../autoload.php') &&
28+
!includeIfExists(__DIR__ . '/../vendor/autoload.php')
29+
) {
30+
fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL);
31+
exit(1);
32+
}
33+
34+
if (!class_exists(Application::class)) {
35+
fwrite(STDERR, 'You need the "symfony/console" component in order to run the UX Toolkit kit linter.'.PHP_EOL);
36+
exit(1);
37+
}
38+
39+
$filesystem = new Filesystem();
40+
41+
(new Application())->add($command = new CreateKitCommand($filesystem))
42+
->getApplication()
43+
->setDefaultCommand($command->getName(), true)
44+
->run()
45+
;

src/Toolkit/bin/ux-toolkit-kit-debug

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env php
2+
<?php
3+
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+
*/
12+
13+
if ('cli' !== \PHP_SAPI) {
14+
throw new Exception('This script must be run from the command line.');
15+
}
16+
17+
use Symfony\Component\Console\Application;
18+
use Symfony\Component\Filesystem\Filesystem;
19+
use Symfony\Component\HttpClient\HttpClient;
20+
use Symfony\Contracts\Service\ServiceLocatorTrait;
21+
use Symfony\Contracts\Service\ServiceProviderInterface;
22+
use Symfony\UX\Toolkit\Command\DebugKitCommand;
23+
use Symfony\UX\Toolkit\Dependency\DependenciesResolver;
24+
use Symfony\UX\Toolkit\Kit\KitFactory;
25+
use Symfony\UX\Toolkit\Registry\GitHubRegistry;
26+
use Symfony\UX\Toolkit\Registry\LocalRegistry;
27+
use Symfony\UX\Toolkit\Registry\RegistryFactory;
28+
use Symfony\UX\Toolkit\Registry\Type;
29+
30+
function includeIfExists(string $file): bool
31+
{
32+
return file_exists($file) && include $file;
33+
}
34+
35+
if (
36+
!includeIfExists(__DIR__ . '/../../../autoload.php') &&
37+
!includeIfExists(__DIR__ . '/../vendor/autoload.php')
38+
) {
39+
fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL);
40+
exit(1);
41+
}
42+
43+
if (!class_exists(Application::class)) {
44+
fwrite(STDERR, 'You need the "symfony/console" component in order to run the UX Toolkit kit linter.'.PHP_EOL);
45+
exit(1);
46+
}
47+
48+
$filesystem = new Filesystem();
49+
$kitFactory = new KitFactory($filesystem, new DependenciesResolver($filesystem));
50+
$registryFactory = new RegistryFactory(new class([
51+
Type::Local->value => fn () => new LocalRegistry($kitFactory, $filesystem, getcwd() ?? throw new \RuntimeException('The current working directory could not be determined.')),
52+
Type::GitHub->value => fn () => new GitHubRegistry($kitFactory, $filesystem, class_exists(HttpClient::class) ? HttpClient::create() : null),
53+
]) implements ServiceProviderInterface {
54+
use ServiceLocatorTrait;
55+
});
56+
57+
(new Application())->add($command = new DebugKitCommand($registryFactory))
58+
->getApplication()
59+
->setDefaultCommand($command->getName(), true)
60+
->run()
61+
;

src/Toolkit/bin/ux-toolkit-kit-lint

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env php
2+
<?php
3+
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+
*/
12+
13+
if ('cli' !== \PHP_SAPI) {
14+
throw new Exception('This script must be run from the command line.');
15+
}
16+
17+
use Symfony\Component\Console\Application;
18+
use Symfony\Component\Filesystem\Filesystem;
19+
use Symfony\Component\HttpClient\HttpClient;
20+
use Symfony\Contracts\Service\ServiceLocatorTrait;
21+
use Symfony\Contracts\Service\ServiceProviderInterface;
22+
use Symfony\UX\Toolkit\Command\LintKitCommand;
23+
use Symfony\UX\Toolkit\Dependency\DependenciesResolver;
24+
use Symfony\UX\Toolkit\Kit\KitFactory;
25+
use Symfony\UX\Toolkit\Registry\GitHubRegistry;
26+
use Symfony\UX\Toolkit\Registry\LocalRegistry;
27+
use Symfony\UX\Toolkit\Registry\RegistryFactory;
28+
use Symfony\UX\Toolkit\Registry\Type;
29+
30+
function includeIfExists(string $file): bool
31+
{
32+
return file_exists($file) && include $file;
33+
}
34+
35+
if (
36+
!includeIfExists(__DIR__ . '/../../../autoload.php') &&
37+
!includeIfExists(__DIR__ . '/../vendor/autoload.php')
38+
) {
39+
fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL);
40+
exit(1);
41+
}
42+
43+
if (!class_exists(Application::class)) {
44+
fwrite(STDERR, 'You need the "symfony/console" component in order to run the UX Toolkit kit linter.'.PHP_EOL);
45+
exit(1);
46+
}
47+
48+
$filesystem = new Filesystem();
49+
$kitFactory = new KitFactory($filesystem, new DependenciesResolver($filesystem));
50+
$registryFactory = new RegistryFactory(new class([
51+
Type::Local->value => fn () => new LocalRegistry($kitFactory, $filesystem, getcwd() ?? throw new \RuntimeException('The current working directory could not be determined.')),
52+
Type::GitHub->value => fn () => new GitHubRegistry($kitFactory, $filesystem, class_exists(HttpClient::class) ? HttpClient::create() : null),
53+
]) implements ServiceProviderInterface {
54+
use ServiceLocatorTrait;
55+
});
56+
57+
(new Application())->add($command = new LintKitCommand($registryFactory))
58+
->getApplication()
59+
->setDefaultCommand($command->getName(), true)
60+
->run()
61+
;

src/Toolkit/composer.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "symfony/ux-toolkit",
33
"type": "symfony-bundle",
4-
"description": "Twig Toolkit for Symfony",
4+
"description": "A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components",
55
"keywords": [
66
"symfony-ux",
77
"twig",
@@ -28,13 +28,14 @@
2828
}
2929
],
3030
"require": {
31-
"php": ">=8.3",
32-
"twig/twig": "^2.12|^3.0",
31+
"php": ">=8.2",
32+
"twig/twig": "^3.0",
3333
"symfony/console": "^6.4|^7.0",
34+
"symfony/filesystem": "^6.4|^7.0",
3435
"symfony/framework-bundle": "^6.4|^7.0",
3536
"symfony/twig-bundle": "^6.4|^7.0",
3637
"symfony/ux-twig-component": "^2.23",
37-
"symfony/filesystem": "^6.4|^7.0"
38+
"symfony/yaml": "^6.4|^7.0"
3839
},
3940
"require-dev": {
4041
"symfony/finder": "6.4|^7.0",
@@ -46,6 +47,11 @@
4647
"symfony/stopwatch": "^6.4|^7.0",
4748
"symfony/phpunit-bridge": "^6.4|^7.0"
4849
},
50+
"bin": [
51+
"bin/ux-toolkit-kit-create",
52+
"bin/ux-toolkit-kit-lint",
53+
"bin/ux-toolkit-kit-debug"
54+
],
4955
"autoload": {
5056
"psr-4": {
5157
"Symfony\\UX\\Toolkit\\": "src"

0 commit comments

Comments
 (0)