Skip to content

Commit a8c730c

Browse files
authored
Merge branch 'symfony:2.x' into main
2 parents 7467cee + 6a987eb commit a8c730c

File tree

160 files changed

+3181
-4114
lines changed

Some content is hidden

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

160 files changed

+3181
-4114
lines changed

.github/workflows/test.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,21 @@ jobs:
8080
- name: Chartjs
8181
run: |
8282
cd src/Chartjs
83-
composer config platform.php 7.4.99
8483
composer update --prefer-dist --no-interaction --no-ansi --no-progress
8584
php vendor/bin/simple-phpunit
8685
- name: Cropperjs
8786
run: |
8887
cd src/Cropperjs
89-
composer config platform.php 7.4.99
9088
composer update --prefer-dist --no-interaction --no-ansi --no-progress
9189
php vendor/bin/simple-phpunit
9290
- name: Dropzone
9391
run: |
9492
cd src/Dropzone
95-
composer config platform.php 7.4.99
9693
composer update --prefer-dist --no-interaction --no-ansi --no-progress
9794
php vendor/bin/simple-phpunit
9895
- name: LazyImage
9996
run: |
10097
cd src/LazyImage
101-
composer config platform.php 7.4.99
10298
composer update --prefer-dist --no-interaction --no-ansi --no-progress
10399
php vendor/bin/simple-phpunit
104100
- name: TwigComponent

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ to build the chart in PHP. The JavaScript is handled for you automatically.
1616

1717
[Read all the details about the Symfony UX initiative](https://symfony.com/ux)
1818

19+
Or watch the [Stimulus Screencast on SymfonyCasts](https://symfonycasts.com/screencast/stimulus).
20+
1921
## Components of UX
2022

2123
Symfony UX leverages [Stimulus](https://stimulus.hotwired.dev/) for JavaScript

babel.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', {targets: {node: 'current'}}],
4+
'@babel/preset-typescript',
5+
],
6+
};

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "symfony/ux",
33
"license": "MIT",
44
"require-dev": {
5-
"symfony/filesystem": "^5.2"
5+
"symfony/filesystem": "^5.2|^6.0"
66
}
77
}

jest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
testRegex: "test/.*\\.test.ts",
5+
testEnvironment: 'jsdom',
6+
setupFilesAfterEnv: [
7+
path.join(__dirname, 'test/setup.js'),
8+
],
9+
transform: {
10+
'\\.(j|t)s$': ['babel-jest', { configFile: path.join(__dirname, './babel.config.js') }]
11+
},
12+
}

package.json

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,56 @@
55
"src/**/assets"
66
],
77
"scripts": {
8-
"build": "yarn workspaces run build",
9-
"test": "yarn workspaces run test",
10-
"lint": "yarn workspaces run lint --fix",
11-
"format": "prettier src/*/Resources/assets/{src,test}/*.js {,src/*/}*.{json,md} --write",
8+
"build": "yarn rollup -c",
9+
"test": "yarn workspaces run jest",
10+
"lint": "yarn workspaces run eslint src test",
11+
"format": "prettier src/*/Resources/assets/src/*.ts src/*/Resources/assets/test/*.js {,src/*/}*.{json,md} --write",
1212
"check-lint": "yarn lint --no-fix",
1313
"check-format": "yarn format --no-write --check"
1414
},
1515
"devDependencies": {
16-
"@babel/eslint-parser": "^7.12.1",
17-
"eslint": "^7.15.0",
18-
"eslint-config-prettier": "^6.15.0",
19-
"eslint-plugin-jest": "^24.1.3",
20-
"prettier": "^2.2.1"
16+
"@babel/core": "^7.15.8",
17+
"@babel/preset-env": "^7.15.8",
18+
"@babel/preset-typescript": "^7.15.0",
19+
"@rollup/plugin-node-resolve": "^13.0.0",
20+
"@rollup/plugin-typescript": "^8.3.0",
21+
"@symfony/stimulus-testing": "^2.0.1",
22+
"@typescript-eslint/eslint-plugin": "^5.2.0",
23+
"@typescript-eslint/parser": "^5.2.0",
24+
"babel-jest": "^27.3.1",
25+
"eslint": "^8.1.0",
26+
"eslint-config-prettier": "^8.0.0",
27+
"eslint-plugin-jest": "^25.2.2",
28+
"jest": "^27.3.1",
29+
"pkg-up": "^3.1.0",
30+
"prettier": "^2.2.1",
31+
"rollup": "^2.52.2",
32+
"tslib": "^2.3.1",
33+
"typescript": "^4.4.4"
2134
},
2235
"eslintConfig": {
2336
"root": true,
24-
"parser": "@babel/eslint-parser",
37+
"parser": "@typescript-eslint/parser",
38+
"plugins": [
39+
"@typescript-eslint"
40+
],
2541
"extends": [
2642
"eslint:recommended",
27-
"prettier"
43+
"prettier",
44+
"plugin:@typescript-eslint/eslint-recommended",
45+
"plugin:@typescript-eslint/recommended"
2846
],
47+
"rules": {
48+
"@typescript-eslint/no-explicit-any": "off"
49+
},
2950
"env": {
3051
"browser": true
3152
},
3253
"overrides": [
3354
{
3455
"files": [
35-
"src/*/Resources/assets/test/*.js"
56+
"src/*/Resources/assets/test/**/*.ts",
57+
"src/*/assets/test/**/*.ts"
3658
],
3759
"extends": [
3860
"plugin:jest/recommended"

rollup.config.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import resolve from '@rollup/plugin-node-resolve';
2+
import typescript from '@rollup/plugin-typescript';
3+
import glob from 'glob';
4+
import path from 'path';
5+
import pkgUp from 'pkg-up';
6+
7+
/**
8+
* Guarantees that any files imported from a peer dependency are treated as an external.
9+
*
10+
* For example, if we import `chart.js/auto`, that would not normally
11+
* match the "chart.js" we pass to the "externals" config. This plugin
12+
* catches that case and adds it as an external.
13+
*
14+
* Inspired by https://github.com/oat-sa/rollup-plugin-wildcard-external
15+
*/
16+
const wildcardExternalsPlugin = (peerDependencies) => ({
17+
name: 'wildcard-externals',
18+
resolveId(source, importer) {
19+
if (importer) {
20+
let matchesExternal = false;
21+
peerDependencies.forEach((peerDependency) => {
22+
if (source.includes(`/${peerDependency}/`)) {
23+
matchesExternal = true;
24+
}
25+
});
26+
27+
if (matchesExternal) {
28+
return {
29+
id: source,
30+
external: true,
31+
moduleSideEffects: true
32+
};
33+
}
34+
}
35+
36+
return null; // other ids should be handled as usually
37+
}
38+
});
39+
40+
const files = glob.sync("src/**/assets/src/*controller.ts");
41+
const packages = files.map((file) => {
42+
const absolutePath = path.join(__dirname, file);
43+
const packageData = require(pkgUp.sync({ cwd: absolutePath }));
44+
const peerDependencies = [
45+
'@hotwired/stimulus',
46+
...(packageData.peerDependencies ? Object.keys(packageData.peerDependencies) : [])
47+
];
48+
49+
return {
50+
input: file,
51+
output: {
52+
file: path.join(absolutePath, '..', '..', 'dist', path.basename(file, '.ts') + '.js'),
53+
format: 'esm',
54+
},
55+
external: peerDependencies,
56+
plugins: [
57+
resolve(),
58+
typescript(),
59+
wildcardExternalsPlugin(peerDependencies)
60+
],
61+
};
62+
});
63+
64+
export default packages;

src/Chartjs/CHANGELOG.md

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

3+
## 2.0
4+
5+
- Support for `stimulus` version 2 was removed and support for `@hotwired/stimulus`
6+
version 3 was added. See the [@symfony/stimulus-bridge CHANGELOG](https://github.com/symfony/stimulus-bridge/blob/main/CHANGELOG.md#300)
7+
for more details.
8+
- Support added for Symfony 6
9+
- Upgrade Chart.js to version 3
10+
311
## 1.3
412

513
- [DEPENDENCY CHANGE] `chart.js` is no longer included automatically (#93)

src/Chartjs/DependencyInjection/ChartjsExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313

1414
use Symfony\Component\DependencyInjection\ContainerBuilder;
1515
use Symfony\Component\DependencyInjection\Definition;
16+
use Symfony\Component\DependencyInjection\Reference;
1617
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1718
use Symfony\UX\Chartjs\Builder\ChartBuilder;
1819
use Symfony\UX\Chartjs\Builder\ChartBuilderInterface;
1920
use Symfony\UX\Chartjs\Twig\ChartExtension;
21+
use Symfony\WebpackEncoreBundle\Twig\StimulusTwigExtension;
2022
use Twig\Environment;
2123

2224
/**
@@ -38,9 +40,10 @@ public function load(array $configs, ContainerBuilder $container)
3840
->setPublic(false)
3941
;
4042

41-
if (class_exists(Environment::class)) {
43+
if (class_exists(Environment::class) && class_exists(StimulusTwigExtension::class)) {
4244
$container
4345
->setDefinition('chartjs.twig_extension', new Definition(ChartExtension::class))
46+
->addArgument(new Reference('webpack_encore.twig_stimulus_extension'))
4447
->addTag('twig.extension')
4548
->setPublic(false)
4649
;

src/Chartjs/Model/Chart.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class Chart
2121
{
2222
public const TYPE_LINE = 'line';
2323
public const TYPE_BAR = 'bar';
24-
public const TYPE_BAR_HORIZONTAL = 'horizontalBar';
2524
public const TYPE_RADAR = 'radar';
2625
public const TYPE_PIE = 'pie';
2726
public const TYPE_DOUGHNUT = 'doughnut';

0 commit comments

Comments
 (0)