Skip to content

Commit c7090d4

Browse files
Replace JS toolchain by asset-mapper when testing ux-turbo
1 parent 623fe50 commit c7090d4

File tree

11 files changed

+49
-79
lines changed

11 files changed

+49
-79
lines changed

.github/workflows/test-turbo.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ jobs:
6565
- name: Checkout
6666
uses: actions/checkout@v4
6767

68-
- run: corepack enable
69-
7068
- name: Setup PHP
7169
uses: shivammathur/setup-php@v2
7270
with:
@@ -81,25 +79,9 @@ jobs:
8179
working-directory: src/Turbo
8280
dependency-versions: ${{ matrix.dependency-version }}
8381

84-
- name: Get yarn cache directory path
85-
id: yarn-cache-dir-path
86-
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
87-
88-
- uses: actions/cache@v4
89-
id: yarn-cache
90-
with:
91-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
92-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
93-
restore-keys: |
94-
${{ runner.os }}-yarn-
95-
9682
- name: Install JavaScript dependencies
9783
working-directory: src/Turbo/tests/app
98-
run: touch yarn.lock && yarn install --mode update-lockfile && yarn install
99-
100-
- name: Build JavaScript
101-
working-directory: src/Turbo/tests/app
102-
run: yarn build
84+
run: php public/index.php importmap:install
10385

10486
- name: Create DB
10587
working-directory: src/Turbo/tests/app

src/Turbo/.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
/composer.lock
66
/phpunit.xml
77
/vendor/
8-
/tests/app/var
8+
/tests/app/assets/vendor/
9+
/tests/app/var/
910
/tests/app/public/build/
1011
node_modules/
11-
package-lock.json
12-
yarn.lock

src/Turbo/composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,20 @@
4141
"doctrine/doctrine-bundle": "^2.4.3",
4242
"doctrine/orm": "^2.8 | 3.0",
4343
"phpstan/phpstan": "^1.10",
44+
"symfony/asset-mapper": "^6.4|^7.0",
4445
"symfony/debug-bundle": "^5.4|^6.0|^7.0",
4546
"symfony/form": "^5.4|^6.0|^7.0",
46-
"symfony/framework-bundle": "^5.4|^6.0|^7.0",
47+
"symfony/framework-bundle": "^6.4|^7.0",
4748
"symfony/mercure-bundle": "^0.3.7",
4849
"symfony/messenger": "^5.4|^6.0|^7.0",
49-
"symfony/panther": "^1.0|^2.0",
50+
"symfony/panther": "^2.1",
5051
"symfony/phpunit-bridge": "^5.4|^6.0|^7.0",
5152
"symfony/process": "^5.4|6.3.*|^7.0",
5253
"symfony/property-access": "^5.4|^6.0|^7.0",
5354
"symfony/security-core": "^5.4|^6.0|^7.0",
5455
"symfony/stopwatch": "^5.4|^6.0|^7.0",
5556
"symfony/ux-twig-component": "^2.21",
56-
"symfony/twig-bundle": "^5.4|^6.0|^7.0",
57+
"symfony/twig-bundle": "^6.4|^7.0",
5758
"symfony/web-profiler-bundle": "^5.4|^6.0|^7.0",
5859
"symfony/webpack-encore-bundle": "^2.1.1",
5960
"symfony/expression-language": "^5.4|^6.0|^7.0",

src/Turbo/tests/BroadcastTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class BroadcastTest extends PantherTestCase
2626

2727
protected function setUp(): void
2828
{
29-
if (!file_exists(__DIR__.'/app/public/build')) {
30-
throw new \Exception(\sprintf('Move into "%s" and execute Encore before running this test.', realpath(__DIR__.'/app')));
29+
if (!file_exists(__DIR__.'/app/assets/vendor/installed.php')) {
30+
throw new \Exception(\sprintf('Move into "%s" and execute `php public/index.php importmap:install` before running this test.', realpath(__DIR__.'/app')));
3131
}
3232

3333
parent::setUp();

src/Turbo/tests/app/Kernel.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ protected function configureContainer(ContainerConfigurator $container): void
6767
{
6868
$container->extension('framework', [
6969
'secret' => 'ChangeMe',
70-
'test' => 'test' === ($_SERVER['APP_ENV'] ?? 'dev'),
70+
'test' => 'test' === $this->environment,
7171
'router' => [
7272
'utf8' => true,
7373
],
74+
'asset_mapper' => [
75+
'paths' => ['assets/'],
76+
],
7477
'profiler' => [
7578
'only_exceptions' => false,
7679
],
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"controllers": {},
3+
"entrypoints": []
4+
}

src/Turbo/tests/app/assets/controllers/.gitignore

Whitespace-only changes.

src/Turbo/tests/app/importmap.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
return [
13+
'app' => [
14+
'path' => './assets/app.js',
15+
'entrypoint' => true,
16+
],
17+
'@hotwired/stimulus' => [
18+
'version' => '3.2.2',
19+
],
20+
'@symfony/stimulus-bundle' => [
21+
'path' => '../../vendor/symfony/stimulus-bundle/assets/dist/loader.js',
22+
],
23+
'@symfony/ux-turbo/dist/turbo_stream_controller' => [
24+
'path' => '../../assets/dist/turbo_stream_controller.js',
25+
],
26+
'@hotwired/turbo' => [
27+
'version' => '7.3.0',
28+
],
29+
];

src/Turbo/tests/app/package.json

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

src/Turbo/tests/app/templates/base.html.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
<meta charset="UTF-8">
55
<title>Symfony UX Turbo</title>
66
{% block stylesheets %}{% endblock %}
7-
{{ encore_entry_script_tags('app') }}
7+
{% block javascripts %}
8+
{% block importmap %}{{ importmap('app') }}{% endblock %}
9+
{% endblock %}
810
</head>
911
<body>
1012
<nav id="navigation">

src/Turbo/tests/app/webpack.config.js

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

0 commit comments

Comments
 (0)