Skip to content

Commit dabd1f8

Browse files
authored
Features/importmap (#409)
1 parent f705754 commit dabd1f8

31 files changed

+274
-118
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
* text=auto
22

33
/.github export-ignore
4+
/bin export-ignore
45
/tests export-ignore
56
/.editorconfig export-ignore
67
/.gitattributes export-ignore

.github/workflows/tweet.yml

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

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: mu
22
mu: vendor ## Mutation tests
3-
vendor/bin/infection -s --threads=$$(nproc) --min-msi=30 --min-covered-msi=50
3+
vendor/bin/infection -v -s --threads=$$(nproc) --min-msi=45 --min-covered-msi=60
44

55
.PHONY: tests
66
tests: vendor ## Run all tests
@@ -36,7 +36,7 @@ st: vendor ## Run static analyse
3636

3737
.PHONY: ci-mu
3838
ci-mu: vendor ## Mutation tests (for CI/CD only)
39-
vendor/bin/infection --logger-github -s --threads=$$(nproc) --min-msi=30 --min-covered-msi=50
39+
vendor/bin/infection --logger-github -s --threads=$$(nproc) --min-msi=45 --min-covered-msi=60
4040

4141
.PHONY: ci-cc
4242
ci-cc: vendor ## Show test coverage rates (for CI/CD only)

babel.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
presets: [
33
['@babel/preset-env', {targets: {node: 'current'}}],
4-
['@babel/preset-typescript', {allowDeclareFields: true}],
4+
'@babel/react',
5+
['@babel/preset-typescript', { allowDeclareFields: true }]
56
],
67
};

bin/build_javascript.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* This file is used to compile the TypeScript files in the assets/src directory
3+
* of each package.
4+
*
5+
* It allows each package to spawn its own rollup process, which is necessary
6+
* to keep memory usage down.
7+
*/
8+
const { spawnSync } = require('child_process');
9+
const glob = require('glob');
10+
11+
const files = [
12+
...glob.sync('src/*/assets/src/*controller.ts'),
13+
];
14+
15+
files.forEach((file) => {
16+
const result = spawnSync('node', [
17+
'node_modules/.bin/rollup',
18+
'-c',
19+
'--environment',
20+
`INPUT_FILE:${file}`,
21+
], {
22+
stdio: 'inherit',
23+
shell: true
24+
});
25+
26+
if (result.error) {
27+
console.error(`Error compiling ${file}:`, result.error);
28+
}
29+
});

bin/build_styles.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Script to "build" the source CSS files to their final destination.
3+
*/
4+
5+
const glob = require('glob');
6+
const { exec } = require('child_process');
7+
const path = require('path');
8+
const fs = require('fs');
9+
10+
let pattern = 'src/*/assets/package.json';
11+
12+
// Use glob to find all matching package.json files
13+
glob(pattern, function (err, files) {
14+
if (err) {
15+
console.error('Error while finding package.json files:', err);
16+
process.exit(1);
17+
}
18+
19+
// Loop over all files
20+
files.forEach(file => {
21+
// Read the package.json file
22+
const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
23+
24+
// Get the css source
25+
const cssSourceRelative = pkg.config && pkg.config.css_source;
26+
27+
if (!cssSourceRelative) {
28+
return;
29+
}
30+
// Construct the output path
31+
const cssSource = path.join(path.dirname(file), cssSourceRelative);
32+
const outputDir = path.join(path.dirname(file), 'dist');
33+
const outputFilename = path.basename(cssSource, '.css') + '.min.css';
34+
const output = path.join(outputDir, outputFilename);
35+
36+
// Run the clean-css-cli command
37+
exec(`yarn run cleancss -o ${output} ${cssSource}`, function (err) {
38+
if (err) {
39+
console.error(`Error while minifying ${cssSource}:`, err);
40+
return;
41+
}
42+
43+
console.log(`Minified ${cssSource} to ${output}`);
44+
});
45+
});
46+
});

composer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"psr-4": {
2020
"Webauthn\\": "src/webauthn/src/",
2121
"Webauthn\\Bundle\\": "src/symfony/src/",
22+
"Webauthn\\Stimulus\\": "src/stimulus/src/",
2223
"Webauthn\\MetadataService\\": "src/metadata-service/src/"
2324
}
2425
},
@@ -87,7 +88,6 @@
8788
"web-token/jwt-signature-algorithm-eddsa": "Recommended for the AndroidSafetyNet Attestation Statement support"
8889
},
8990
"require-dev": {
90-
"doctrine/annotations": "^1.13 || ^2.0",
9191
"doctrine/dbal": "^3.4",
9292
"doctrine/doctrine-bundle": "^2.7",
9393
"doctrine/orm": "^2.13",
@@ -105,8 +105,9 @@
105105
"phpunit/phpunit": "^10.1",
106106
"psr/log": "^3.0",
107107
"qossmic/deptrac-shim": "^1.0",
108-
"rector/rector": "^0.16",
108+
"rector/rector": "^0.17",
109109
"roave/security-advisories": "dev-latest",
110+
"symfony/asset-mapper": "^6.3",
110111
"symfony/browser-kit": "^6.1",
111112
"symfony/filesystem": "^6.1",
112113
"symfony/finder": "^6.1",
@@ -119,5 +120,11 @@
119120
"web-token/jwt-signature-algorithm-ecdsa": "^3.1",
120121
"web-token/jwt-signature-algorithm-eddsa": "^3.1",
121122
"web-token/jwt-signature-algorithm-rsa": "^3.1"
123+
},
124+
"extra": {
125+
"thanks": {
126+
"name": "web-auth/webauthn-framework",
127+
"url": "https://github.com/web-auth/webauthn-framework"
128+
}
122129
}
123130
}

deptrac.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ parameters:
3333
ruleset:
3434
MetadataService:
3535
- 'Vendors'
36-
UX: ~
36+
UX:
37+
- 'Vendors'
3738
Webauthn:
3839
- 'Vendors'
3940
- 'MetadataService'
4041
SymfonyBundle:
4142
- 'Vendors'
4243
- 'Webauthn'
4344
- 'MetadataService'
45+
StimulusBundle:
4446
skip_violations:
4547
Webauthn\Bundle\Service\AuthenticatorAssertionResponseValidator:
4648
- Webauthn\Util\CoseSignatureFixer

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module.exports = {
1111
path.join(__dirname, 'tests/setup.js'),
1212
],
1313
transform: {
14-
'\\.(j|t)s$': ['babel-jest', {configFile: path.join(__dirname, './babel.config.js')}]
14+
'\\.(j|t)s$': ['babel-jest', { configFile: path.join(__dirname, './babel.config.js') }]
1515
},
1616
"transformIgnorePatterns": [
1717
"node_modules/(?!@ngrx|(?!deck.gl)|ng-dynamic)"
1818
]
19-
}
19+
};

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"private": true,
33
"workspaces": [
4-
"src/**/Resources/assets"
4+
"src/*/assets"
55
],
66
"scripts": {
7-
"build": "yarn rollup -c",
7+
"build": "node bin/build_javascript.js && node bin/build_styles.js",
88
"test": "yarn workspaces run jest",
99
"lint": "yarn workspaces run eslint src test",
10-
"format": "prettier src/*/Resources/assets/src/*.ts src/*/Resources/assets/test/*.js {,src/*/}*.{json,md} --write",
10+
"format": "prettier src/*/assets/src/*.ts src/*/assets/test/*.js {,src/*/}*.{json,md} --write",
1111
"check-lint": "yarn lint --no-fix",
1212
"check-format": "yarn format --no-write --check"
1313
},
@@ -16,21 +16,23 @@
1616
"@babel/preset-env": "^7.15.8",
1717
"@babel/preset-react": "^7.15.8",
1818
"@babel/preset-typescript": "^7.15.8",
19+
"@rollup/plugin-commonjs": "^25.0.0",
1920
"@rollup/plugin-node-resolve": "^15.0.0",
20-
"@rollup/plugin-typescript": "^10.0.0",
21+
"@rollup/plugin-typescript": "^11.0.0",
2122
"@symfony/stimulus-testing": "^2.0.1",
2223
"@typescript-eslint/eslint-plugin": "^5.2.0",
2324
"@typescript-eslint/parser": "^5.2.0",
2425
"babel-jest": "^29.0",
26+
"clean-css-cli": "^5.6.2",
2527
"eslint": "^8.1.0",
2628
"eslint-config-prettier": "^8.0.0",
27-
"eslint-plugin-jest": "^27.0",
28-
"jest": "^29.0",
29+
"eslint-plugin-jest": "^27.0.0",
30+
"jest": "^29.0.0",
2931
"jest-environment-jsdom": "^29.0",
3032
"prettier": "^2.2.1",
3133
"rollup": "^3.7.0",
3234
"tslib": "^2.3.1",
33-
"typescript": "^4.4.4"
35+
"typescript": "^5.0.0"
3436
},
3537
"eslintConfig": {
3638
"root": true,
@@ -59,7 +61,7 @@
5961
"overrides": [
6062
{
6163
"files": [
62-
"src/*/Resources/assets/test/**/*.ts"
64+
"src/*/assets/test/**/*.ts"
6365
],
6466
"extends": [
6567
"plugin:jest/recommended"

0 commit comments

Comments
 (0)