Repository: symfony/ux
Pull request #2310 (2024-10-31 00:17:17)

[Site] Update `bin/link-locally`
Add missing packages
* stimulus-bundle
* ux-map bridges

Remove yarn evocation



Patch:
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
deleted file mode 100644
index 6b7e9370..00000000
--- a/.github/CODEOWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-src/LazyImage @Kocal
-src/Map @Kocal
-src/Translator @Kocal
diff --git a/src/StimulusBundle/doc/index.rst b/src/StimulusBundle/doc/index.rst
index 745c19bc..07702d2d 100644
--- a/src/StimulusBundle/doc/index.rst
+++ b/src/StimulusBundle/doc/index.rst
@@ -576,4 +576,4 @@ it will normalize it:
 .. _`stimulus-components`: https://stimulus-components.netlify.app/
 .. _`TypeScript`: https://www.typescriptlang.org/
 .. _`sensiolabs/typescript-bundle`: https://github.com/sensiolabs/AssetMapperTypeScriptBundle
-.. _`Stimulus plugin`: https://plugins.jetbrains.com/plugin/24562-stimulus
+.. _`Stimulus plugin`: https://plugins.jetbrains.com/plugin/18940-stimulus
diff --git a/src/StimulusBundle/src/AssetMapper/ControllersMapGenerator.php b/src/StimulusBundle/src/AssetMapper/ControllersMapGenerator.php
index b99f5ffb..4eb66984 100644
--- a/src/StimulusBundle/src/AssetMapper/ControllersMapGenerator.php
+++ b/src/StimulusBundle/src/AssetMapper/ControllersMapGenerator.php
@@ -77,7 +77,7 @@ class ControllersMapGenerator
             $name = str_replace(['_', '/', '\\'], ['-', '--', '--'], $name);
 
             $asset = $this->assetMapper->getAssetFromSourcePath($file->getRealPath());
-            $content = file_get_contents($asset->sourcePath);
+            $content = $asset->content ?: file_get_contents($asset->sourcePath);
             $isLazy = preg_match('/\/\*\s*stimulusFetch:\s*\'lazy\'\s*\*\//i', $content);
 
             $controllersMap[$name] = new MappedControllerAsset($asset, $isLazy);
diff --git a/src/Turbo/CHANGELOG.md b/src/Turbo/CHANGELOG.md
index 872b9430..df89967e 100644
--- a/src/Turbo/CHANGELOG.md
+++ b/src/Turbo/CHANGELOG.md
@@ -1,10 +1,5 @@
 # CHANGELOG
 
-## 2.22.0
-
--   Add `<twig:Turbo:Stream>` component
--   Add `<twig:Turbo:Frame>` component
-
 ## 2.21.0
 
 -   Add `Helper/TurboStream::append()` et al. methods
diff --git a/src/Turbo/doc/index.rst b/src/Turbo/doc/index.rst
index 4618bd70..c6e4ecfc 100644
--- a/src/Turbo/doc/index.rst
+++ b/src/Turbo/doc/index.rst
@@ -250,44 +250,6 @@ a Turbo Frame, and retrieve the ID of this frame::
         }
     }
 
-<twig:Turbo:Frame> Twig Component
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-.. versionadded:: 2.22
-
-    The ``<twig:Turbo:Frame>`` Twig Component was added in Turbo 2.22.
-
-Simple example:
-
-.. code-block:: html+twig
-
-    <twig:Turbo:Frame id="the_frame_id" />
-
-    {# renders as: #}
-    <turbo-frame id="the_frame_id"></turbo-frame>
-
-With a HTML attribute:
-
-.. code-block:: html+twig
-
-    <twig:Turbo:Frame id="the_frame_id" loading="lazy" src="{{ path('block') }}" />
-
-    {# renders as: #}
-    <turbo-frame id="the_frame_id" loading="lazy" src="https://example.com/block"></turbo-frame>
-
-With content:
-
-.. code-block:: html+twig
-
-    <twig:Turbo:Frame id="the_frame_id" src="{{ path('block') }}">
-        A placeholder.
-    </twig:Turbo:Frame>
-
-    {# renders as: #}
-    <turbo-frame id="the_frame_id" src="https://example.com/block">
-        A placeholder.
-    </turbo-frame>
-
 Writing Tests
 ^^^^^^^^^^^^^
 
diff --git a/src/Turbo/templates/components/Frame.html.twig b/src/Turbo/templates/components/Frame.html.twig
deleted file mode 100644
index bd39367c..00000000
--- a/src/Turbo/templates/components/Frame.html.twig
+++ /dev/null
@@ -1,5 +0,0 @@
-{% props id -%}
-
-<turbo-frame id="{{ id }}" {{- attributes }}>
-    {%- block content %}{% endblock -%}
-</turbo-frame>
diff --git a/src/Turbo/templates/components/Stream.html.twig b/src/Turbo/templates/components/Stream.html.twig
deleted file mode 100644
index 69805a8e..00000000
--- a/src/Turbo/templates/components/Stream.html.twig
+++ /dev/null
@@ -1,3 +0,0 @@
-{% props action -%}
-
-<turbo-stream action="{{ action }}" {{- attributes }}></turbo-stream>
diff --git a/src/Turbo/templates/components/Stream/After.html.twig b/src/Turbo/templates/components/Stream/After.html.twig
index 0257dfc6..3105a376 100644
--- a/src/Turbo/templates/components/Stream/After.html.twig
+++ b/src/Turbo/templates/components/Stream/After.html.twig
@@ -1,5 +1,5 @@
 {% props target -%}
 
-<turbo-stream action="after" targets="{{ target }}" {{- attributes }}>
+<turbo-stream action="after" targets="{{ target }}" {{ attributes }}>
     <template>{% block content %}{% endblock %}</template>
 </turbo-stream>
diff --git a/src/Turbo/templates/components/Stream/Append.html.twig b/src/Turbo/templates/components/Stream/Append.html.twig
index 98b90b93..aea22f28 100644
--- a/src/Turbo/templates/components/Stream/Append.html.twig
+++ b/src/Turbo/templates/components/Stream/Append.html.twig
@@ -1,5 +1,5 @@
 {% props target -%}
 
-<turbo-stream action="append" targets="{{ target }}" {{- attributes }}>
+<turbo-stream action="append" targets="{{ target }}" {{ attributes }}>
     <template>{% block content %}{% endblock %}</template>
 </turbo-stream>
diff --git a/src/Turbo/templates/components/Stream/Before.html.twig b/src/Turbo/templates/components/Stream/Before.html.twig
index 2a150629..3ffdeded 100644
--- a/src/Turbo/templates/components/Stream/Before.html.twig
+++ b/src/Turbo/templates/components/Stream/Before.html.twig
@@ -1,5 +1,5 @@
 {% props target -%}
 
-<turbo-stream action="before" targets="{{ target }}" {{- attributes }}>
+<turbo-stream action="before" targets="{{ target }}" {{ attributes }}>
     <template>{% block content %}{% endblock %}</template>
 </turbo-stream>
diff --git a/src/Turbo/templates/components/Stream/Prepend.html.twig b/src/Turbo/templates/components/Stream/Prepend.html.twig
index 5b0d92b3..b75d3534 100644
--- a/src/Turbo/templates/components/Stream/Prepend.html.twig
+++ b/src/Turbo/templates/components/Stream/Prepend.html.twig
@@ -1,5 +1,5 @@
 {% props target -%}
 
-<turbo-stream action="prepend" targets="{{ target }}" {{- attributes }}>
+<turbo-stream action="prepend" targets="{{ target }}" {{ attributes }}>
     <template>{% block content %}{% endblock %}</template>
 </turbo-stream>
diff --git a/src/Turbo/templates/components/Stream/Refresh.html.twig b/src/Turbo/templates/components/Stream/Refresh.html.twig
index 11ed9270..182129e6 100644
--- a/src/Turbo/templates/components/Stream/Refresh.html.twig
+++ b/src/Turbo/templates/components/Stream/Refresh.html.twig
@@ -1,3 +1,3 @@
 {% props requestId = null -%}
 
-<turbo-stream action="refresh"{% if requestId is not null %} request-id="{{ requestId }}"{% endif %} {{- attributes }}></turbo-stream>
+<turbo-stream action="refresh"{% if requestId is not null %} request-id="{{ requestId }}"{% endif %} {{ attributes }}></turbo-stream>
diff --git a/src/Turbo/templates/components/Stream/Remove.html.twig b/src/Turbo/templates/components/Stream/Remove.html.twig
index aa5e24e4..9e3c0234 100644
--- a/src/Turbo/templates/components/Stream/Remove.html.twig
+++ b/src/Turbo/templates/components/Stream/Remove.html.twig
@@ -1,3 +1,3 @@
 {% props target -%}
 
-<turbo-stream action="remove" targets="{{ target }}" {{- attributes }}></turbo-stream>
+<turbo-stream action="remove" targets="{{ target }}" {{ attributes }}></turbo-stream>
diff --git a/src/Turbo/templates/components/Stream/Replace.html.twig b/src/Turbo/templates/components/Stream/Replace.html.twig
index 5f9b4557..d11598f6 100644
--- a/src/Turbo/templates/components/Stream/Replace.html.twig
+++ b/src/Turbo/templates/components/Stream/Replace.html.twig
@@ -1,5 +1,5 @@
 {% props target, morph = false -%}
 
-<turbo-stream action="replace" targets="{{ target }}"{% if morph %} method="morph"{% endif %} {{- attributes }}>
+<turbo-stream action="replace" targets="{{ target }}"{% if morph %} method="morph"{% endif %} {{ attributes }}>
     <template>{% block content %}{% endblock %}</template>
 </turbo-stream>
diff --git a/src/Turbo/templates/components/Stream/Update.html.twig b/src/Turbo/templates/components/Stream/Update.html.twig
index 23c52150..f15fbfc0 100644
--- a/src/Turbo/templates/components/Stream/Update.html.twig
+++ b/src/Turbo/templates/components/Stream/Update.html.twig
@@ -1,5 +1,5 @@
 {% props target, morph = false -%}
 
-<turbo-stream action="update" targets="{{ target }}"{% if morph %} method="morph"{% endif %} {{- attributes }}>
+<turbo-stream action="update" targets="{{ target }}"{% if morph %} method="morph"{% endif %} {{ attributes }}>
     <template>{% block content %}{% endblock %}</template>
 </turbo-stream>
diff --git a/ux.symfony.com/bin/link-locally b/ux.symfony.com/bin/link-locally
index 300e9d17..83b7a076 100644
--- a/ux.symfony.com/bin/link-locally
+++ b/ux.symfony.com/bin/link-locally
@@ -1,33 +1,41 @@
 #!/usr/bin/env php
 <?php
 
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
 use Symfony\Component\Finder\Finder;
 
 require __DIR__.'/../vendor/autoload.php';
+
 $composerData = json_decode(file_get_contents(__DIR__.'/../composer.json'), true);
 
-$finder = new Finder();
-$finder->in(__DIR__.'/../../src')
+$packageDirectories = (new Finder())
+    ->in([
+        __DIR__.'/../../src',
+        __DIR__.'/../../src/Map/src/Bridge',
+    ])
     ->depth('== 0')
     ->directories();
 
-$repositories = [];
-foreach ($finder as $packageDirectory) {
-    $repositories[] = [
-        'type' => 'path',
-        'url' => $packageDirectory->getRealPath()
-    ];
-}
-$composerData['repositories'] = $repositories;
+$composerData['repositories'] = array_map(
+    fn ($directory) => ['type' => 'path', 'url' => $directory->getRealPath()],
+    iterator_to_array($packageDirectories),
+);
 
 foreach ($composerData['require'] as $package => $version) {
-    if (!str_starts_with($package, 'symfony/ux-')) {
-        continue;
+    if (str_starts_with($package, 'symfony/ux-') || 'symfony/stimulus-bundle' === $package) {
+        $composerData['require'][$package] = '2.x-dev';
     }
-
-    $composerData['require'][$package] = '2.x-dev';
 }
 
-file_put_contents(__DIR__.'/../composer.json', json_encode($composerData, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
-echo "composer.json updatded to point to local UX packages\n";
-echo "Run 'composer update' then 'yarn install --force'\n";
+file_put_contents(__DIR__.'/../composer.json', json_encode($composerData, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
+
+echo "composer.json updated to point to local UX packages\n\n";
+echo "Run 'composer update'\n\n";
diff --git a/ux.symfony.com/compose.override.yml b/ux.symfony.com/docker-compose.override.yml
similarity index 88%
rename from ux.symfony.com/compose.override.yml
rename to ux.symfony.com/docker-compose.override.yml
index ab4d2054..50f0fab6 100644
--- a/ux.symfony.com/compose.override.yml
+++ b/ux.symfony.com/docker-compose.override.yml
@@ -1,3 +1,5 @@
+version: '3'
+
 services:
 ###> symfony/mercure-bundle ###
   mercure:
diff --git a/ux.symfony.com/compose.yml b/ux.symfony.com/docker-compose.yml
similarity index 82%
rename from ux.symfony.com/compose.yml
rename to ux.symfony.com/docker-compose.yml
index 7484a1fc..c04df4d6 100644
--- a/ux.symfony.com/compose.yml
+++ b/ux.symfony.com/docker-compose.yml
@@ -1,3 +1,5 @@
+version: '3'
+
 services:
 ###> symfony/mercure-bundle ###
   mercure:
@@ -10,6 +12,8 @@ services:
       # Set the URL of your Symfony project (without trailing slash!) as value of the cors_origins directive
       MERCURE_EXTRA_DIRECTIVES: |
         cors_origins https://127.0.0.1:9044
+    # Comment the following line to disable the development mode
+    command: /usr/bin/caddy run --config /etc/caddy/Caddyfile.dev
     volumes:
       - mercure_data:/data
       - mercure_config:/config


Test patch:
diff --git a/src/StimulusBundle/tests/AssetMapper/ControllersMapGeneratorTest.php b/src/StimulusBundle/tests/AssetMapper/ControllerMapGeneratorTest.php
similarity index 89%
rename from src/StimulusBundle/tests/AssetMapper/ControllersMapGeneratorTest.php
rename to src/StimulusBundle/tests/AssetMapper/ControllerMapGeneratorTest.php
index 21277b28..11cbfe42 100644
--- a/src/StimulusBundle/tests/AssetMapper/ControllersMapGeneratorTest.php
+++ b/src/StimulusBundle/tests/AssetMapper/ControllerMapGeneratorTest.php
@@ -20,7 +20,7 @@ use Symfony\UX\StimulusBundle\AssetMapper\ControllersMapGenerator;
 use Symfony\UX\StimulusBundle\AssetMapper\MappedControllerAutoImport;
 use Symfony\UX\StimulusBundle\Ux\UxPackageReader;
 
-class ControllersMapGeneratorTest extends TestCase
+class ControllerMapGeneratorTest extends TestCase
 {
     public function testGetControllersMap()
     {
@@ -41,12 +41,7 @@ class ControllersMapGeneratorTest extends TestCase
                     $logicalPath = substr($path, $assetsPosition + 1);
                 }
 
-                $content = null;
-                if (str_ends_with($path, 'minified-controller.js')) {
-                    $content = 'import{Controller}from"@hotwired/stimulus";export default class extends Controller{}';
-                }
-
-                return new MappedAsset($logicalPath, $path, content: $content);
+                return new MappedAsset($logicalPath, $path, content: file_get_contents($path));
             });
 
         $packageReader = new UxPackageReader(__DIR__.'/../fixtures');
@@ -78,8 +73,8 @@ class ControllersMapGeneratorTest extends TestCase
         $map = $generator->getControllersMap();
         // + 3 controller.json UX controllers
         // - 1 controllers.json UX controller is disabled
-        // + 10 custom controllers (1 file is not a controller & 1 is overridden)
-        $this->assertCount(12, $map);
+        // + 9 custom controllers (1 file is not a controller & 1 is overridden)
+        $this->assertCount(11, $map);
         $packageNames = array_keys($map);
         sort($packageNames);
         $this->assertSame([
@@ -89,7 +84,6 @@ class ControllersMapGeneratorTest extends TestCase
             'hello',
             'hello-with-dashes',
             'hello-with-underscores',
-            'minified',
             'other',
             'subdir--deeper',
             'subdir--deeper-with-dashes',
@@ -121,8 +115,5 @@ class ControllersMapGeneratorTest extends TestCase
 
         $otherController = $map['other'];
         $this->assertTrue($otherController->isLazy);
-
-        $minifiedController = $map['minified'];
-        $this->assertTrue($minifiedController->isLazy);
     }
 }
diff --git a/src/StimulusBundle/tests/AssetMapper/StimulusControllerLoaderFunctionalTest.php b/src/StimulusBundle/tests/AssetMapper/StimulusControllerLoaderFunctionalTest.php
index 58bb6c8c..877073ff 100644
--- a/src/StimulusBundle/tests/AssetMapper/StimulusControllerLoaderFunctionalTest.php
+++ b/src/StimulusBundle/tests/AssetMapper/StimulusControllerLoaderFunctionalTest.php
@@ -63,9 +63,8 @@ class StimulusControllerLoaderFunctionalTest extends WebTestCase
                 // 2x from UX packages, which are enabled in controllers.json
                 '/assets/fake-vendor/ux-package1/package-controller-second.js',
                 '/assets/fake-vendor/ux-package2/package-hello-controller.js',
-                // 3x from more-controllers
+                // 2x from more-controllers
                 '/assets/more-controllers/hello-controller.js',
-                '/assets/more-controllers/minified-controller.js',
                 '/assets/more-controllers/other-controller.js',
                 // 5x from importmap.php
                 '@hotwired/stimulus',
diff --git a/src/StimulusBundle/tests/fixtures/assets/more-controllers/minified-controller.js b/src/StimulusBundle/tests/fixtures/assets/more-controllers/minified-controller.js
deleted file mode 100644
index 2eb85a71..00000000
--- a/src/StimulusBundle/tests/fixtures/assets/more-controllers/minified-controller.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// minified-controller.js
-import { Controller } from '@hotwired/stimulus';
-
-/* stimulusFetch: 'lazy' */
-export default class extends Controller {
-}