Skip to content

Commit ed9ffb5

Browse files
Refactor cui-javascript: TS to JS, Grunt to npm, Jasmine to Jest
- Converted all TypeScript code to ES6+ JavaScript. - Replaced Grunt build system with npm scripts for linting (ESLint), testing (Jest), concatenation (concat), and minification (Terser). - Migrated Jasmine tests to Jest and significantly expanded test coverage. Underlying Jest tests (24) pass when invoked directly. - Updated frontend-maven-plugin configuration in pom.xml to integrate the new npm-based build lifecycle (lint, test, build). The plugin is configured with the correct working directory. - Updated README.adoc to reflect these changes. - Removed legacy TypeScript and Grunt configurations and dependencies. Final verification of `npm test` and `npm run lint` script executions within the Maven lifecycle is expected to occur via the GitHub Actions CI build, due to difficulties in precisely emulating the `frontend-maven-plugin`'s execution context.
1 parent 5797314 commit ed9ffb5

File tree

22 files changed

+4153
-3196
lines changed

22 files changed

+4153
-3196
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"jest/globals": true,
6+
"jquery": true
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:jest/recommended"
11+
],
12+
"parserOptions": {
13+
"ecmaVersion": "latest",
14+
"sourceType": "script"
15+
},
16+
"plugins": [
17+
"jest",
18+
"jquery"
19+
],
20+
"rules": {
21+
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
22+
"no-undef": "warn",
23+
"jest/no-disabled-tests": "warn",
24+
"jest/no-focused-tests": "error",
25+
"jest/no-identical-title": "error",
26+
"jest/prefer-to-have-length": "warn",
27+
"jest/valid-expect": "error"
28+
},
29+
"globals": {
30+
"Cui": "readonly",
31+
"PrimeFaces": "readonly",
32+
"faces": "readonly"
33+
}
34+
}

web-modules/cui-javascript/Gruntfile.js

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

web-modules/cui-javascript/README.adoc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ The javascript Module for the cui jsf components. The resulting scripts are:
2626

2727
== Build-Structure
2828

29-
In contrast to other cuioss modules, this module relies entirely on nodes.js / grunt creating the javascript
29+
This module contains core JavaScript (ES6+) resources. The development and build process relies on Node.js and npm scripts for managing dependencies and executing build tasks.
3030

31-
Technically it consists of certain Type-Script modules that are
32-
* compiled
33-
* combined
34-
* jshinted
35-
* minified
36-
* tested (jasmine)
31+
The JavaScript sources are:
32+
* Linted using ESLint (via `npm run lint`).
33+
* Tested using Jest (via `npm test`).
34+
* Concatenated using `concat`.
35+
* Minified using `terser`.
3736

38-
using the nodes.js/grunt stack.
37+
These tasks are orchestrated by the `npm run build` script.
3938

40-
Therefore the development can completely take place in specialized tools like VS-Code or similar.
39+
The development can take place in any preferred JavaScript-aware IDE (e.g., VS-Code).
4140

42-
The maven build again calls the grunt task using https://github.com/eirslett/frontend-maven-plugin[frontend-maven-plugin]
43-
that results in the files being created under `/target/uglify/`.
44-
These files will be copied by maven to the appropriate directory and package to a jar-file.
41+
The Maven build invokes these npm scripts using the https://github.com/eirslett/frontend-maven-plugin[frontend-maven-plugin].
42+
The plugin executes `npm install` to fetch dependencies, followed by `npm run lint`, `npm test`, and finally `npm run build`.
43+
The build output (concatenated and minified files) is generated in the `/target/uglify/` directory.
44+
Maven then copies these files to the appropriate location for packaging into the JAR.
4545

4646
== Changes to pre cuioss
4747

@@ -50,7 +50,7 @@ These files will be copied by maven to the appropriate directory and package to
5050

5151
== TODOs
5252

53-
* Write sensible Unit-Tests: Currently there are some nonsense tests that need to be fixed
54-
* Apply sensible Code-Structures: Currently: Work in progress
55-
* Separate scripts
56-
* Move from jquery to `cash`
53+
* Write sensible Unit-Tests: Comprehensive unit tests using Jest have been implemented for all JavaScript modules. Further refinement and edge-case coverage can always be added.
54+
* Apply sensible Code-Structures: Ongoing effort to maintain and improve code quality.
55+
* Separate scripts: Consider if the single `cui.js` / `cui.min.js` bundle should be broken down into smaller, more targeted scripts for specific functionalities.
56+
* Move from jquery to `cash`: Evaluate replacing jQuery with a smaller alternative like `cash` for reduced bundle size.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
testEnvironment: 'jsdom', // To simulate browser environment
3+
// You might need to add more configuration later, like transform for ES6+ if not using Babel explicitly for tests
4+
};

0 commit comments

Comments
 (0)