Skip to content

Commit

Permalink
feat: #250 migrate from spring boot 2.7.3 to 3.3.1 and #269 update pi…
Browse files Browse the repository at this point in the history
…peline from java 17 to 21 (#271)

* feat: upgrade to Spring Boot 3.3.1, Java from 17 to 21, get rid of Lombok, improve Java code

* feat: nor arg ends up like --help arg

* chore: from java 17 to 21

* chore: from java 17 to 21

* chore: delete unused dependencies spring-framework-bom 5.3.22 & spring-cloud-dependencies 2021.0.4

* docs: Update doc after migrating to Java 21 and Spring Boot 3.3.1

* docs: delete graalvm section and update readme

* refactor: delete wildcard imports

* fix: scan core package to get beans

* fix: correct API tests by preventing bean methods to be proxied

* docs: update CLI docs with feature related to  #240 and querySelector option

* fix: API & Desktop spring boot autoconf

* docs: update API example

* feat: add jsgenerator-desktop banner

* docs: Add jsgenerator-desktop documentation

* docs: update jsgenerator-cli example's command with the current version

* refactoring: delete double columns before jsgenerator-cli launch command

* docs: update API documentation with curl

* docs: delete colon before jsgenerator-cli launch command

* docs: update API documentation with curl

* ci: Prevent Maven github action to run when changing Markdown files

* fix: Correct Swagger dependency not working with Spring Boot 3

---------

Co-authored-by: Fanon Jupkwo <[email protected]>
  • Loading branch information
SalathielGenese and FanJups authored Sep 23, 2024
1 parent 5518929 commit 11857a0
Show file tree
Hide file tree
Showing 50 changed files with 908 additions and 723 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
# Given the fact that this is a multimodule project, build process will take long time so we activate caching
# To know more: https://maven.apache.org/extensions/maven-build-cache-extension/cache.html
cache: 'maven'
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ name: Java CI with Maven
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'

permissions:
contents: read
Expand All @@ -19,11 +23,11 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
# Given the fact that this is a multimodule project, build process will take long time so we activate caching
# To know more: https://maven.apache.org/extensions/maven-build-cache-extension/cache.html
cache: 'maven'
Expand Down
217 changes: 152 additions & 65 deletions README.api.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,5 @@
# API

Using [`httpie`](https://httpie.io/):
```shell
# You can also pass as many HTML content as you want
# Response will be of 'application/json' content type
http -vf :8080/convert \
extension='.js' \
contents[]='<hr/>' \
contents[]='<button disabled>click me, please :sob:</button>'

HTTP/1.1 200
Content-Type: application/json

{
"status": "SUCCESS"
"content": [
{
"content": "const targetElement_000 = document.querySelector(`:root > body`);\r\n\r\n\r\nconst hr_000 = document.createElement('hr');\r\ntargetElement_000.appendChild(hr_000);\r\n",
"filename": "inline.0.js"
},
{
"content": "const targetElement_001 = document.querySelector(`:root > body`);\r\n\r\n\r\nconst button_000 = document.createElement('button');\r\nbutton_000.setAttribute(`disabled`, `true`);\r\nconst text_000 = document.createTextNode(`click me, please :sob:`);\r\nbutton_000.appendChild(text_000);\r\ntargetElement_001.appendChild(button_000);\r\n",
"filename": "inline.1.js"
}
]
}
```

Or, give the following two files contents:
> ```json
> { "extension": ".js" } // ./multipart-options.json
> ```
>
> ```html
> <!DOCTYPE html>
> <!-- ./sample.html -->
> <html>
> <head>
> ...
> ...
> ...
> ```
```shell
# You can call the API with multiple **files** and at most one **options**
# Response will be of 'multipart/form-data' content type
http -vf :8080/convert/files \
'files@./sample.html;type=multipart/form-data' \
'[email protected];type=application/json'
HTTP/1.1 200
Content-Type: multipart/form-data;boundary=3N0wqEqnb7AC3WD8M1cYYG-vLfHDND_JdE90
--3N0wqEqnb7AC3WD8M1cYYG-vLfHDND_JdE90
Content-Disposition: form-data; name="0.sample.html.js"
Content-Type: application/octet-stream
Content-Length: 4156
const targetElement_000 = document.querySelector(`:root > body`);
[... truncated for brievity]
```
---

After starting the `jsgenerator-api` as described in the [README.md](./README.md), you can read:

+ OpenAPI spec. at: [http://localhost:8080/openapi.yaml](http://localhost:8080/openapi.yaml)
Expand All @@ -79,10 +16,160 @@ Both accept options as follow:
"pattern": "inline-filename-pattern",
"variableNameStrategy": "TYPE_BASED",
"variableDeclaration": "LET",
"extension": ".extension",
"extension": ".jsgenerator.js",
"commentConversionModeActivated": true,
"querySelectorAdded": true,
"contents": [
"string"
]
}
```
> **NOTE:** The `"content"` field is mandatory for `POST /convert` and forbidden for `POST /convert/files`
> **NOTE:** The `"contents"` field is mandatory for `POST /convert` and forbidden for `POST /convert/files`

---

Using [`curl`](https://curl.se/):

+ `POST /convert`
```shell
# You can also pass as many HTML content as you want
# Response will be of 'application/json' content type
curl -H 'content-type: application/json' -X POST --data '{"contents": ["<div>js-jsgenerator</div>"]}' http://localhost:8080/convert

#Response
{"content":[{"filename":"inline.0.jsgenerator.js","content":"let targetElement_001 = document.querySelector(`:root > body`);\r\n\r\n\r\nlet div_001 = document.createElement('div');\r\nlet text_001 = document.createTextNode(`js-generator`);\r\ndiv_001.appendChild(text_001);\r\ntargetElement_001.appendChild(div_001);\r\n"}],"status":"SUCCESS"}
```

+ `POST /convert/files`
```shell
# You can call the API with multiple **files** and at most one **options**
# Response will be of 'multipart/form-data' content type
curl -s -X POST -H 'content-type: multipart/form-data' -F files=@illustrations/sample.html -F "options={ \"querySelectorAdded\": true, \"variableDeclaration\": \"VAR\" }; type=application/json" http://localhost:8080/convert/files

# -s flag is added in order to prevent curl to mix response and progress meter
#if not added, this will happen: 100 5280 100 4275 100 1005 117k 28194 --:--:-- --:--:-- --:--:-- 147kment.createTextNode(` `);

#Response

--d2a-7NlH3rlmcFC3loiJxDxom6iojCunhkzzH
Content-Disposition: form-data; name="inline.0.jsgenerator.js"
Content-Type: application/octet-stream
Content-Length: 4069

var targetElement_001 = document.querySelector(`:root > body`);


var html_001 = document.createElement('html');
var text_001 = document.createTextNode(` `);
html_001.appendChild(text_001);

var head_001 = document.createElement('head');
var text_002 = document.createTextNode(` `);
head_001.appendChild(text_002);

var meta_001 = document.createElement('meta');
meta_001.setAttribute(`charset`, `utf-8`);
head_001.appendChild(meta_001);
var text_003 = document.createTextNode(` `);
head_001.appendChild(text_003);

var title_001 = document.createElement('title');
var text_004 = document.createTextNode(`Sample`);
title_001.appendChild(text_004);
head_001.appendChild(title_001);
var text_005 = document.createTextNode(` `);
head_001.appendChild(text_005);

var link_001 = document.createElement('link');
link_001.setAttribute(`rel`, `stylesheet`);
link_001.setAttribute(`href`, ``);
head_001.appendChild(link_001);
var text_006 = document.createTextNode(` `);
head_001.appendChild(text_006);
html_001.appendChild(head_001);
var text_007 = document.createTextNode(` `);
html_001.appendChild(text_007);

var body_001 = document.createElement('body');
var text_008 = document.createTextNode(` `);
body_001.appendChild(text_008);

var div_001 = document.createElement('div');
div_001.setAttribute(`id`, `container`);
var text_009 = document.createTextNode(` `);
div_001.appendChild(text_009);

var div_002 = document.createElement('div');
div_002.setAttribute(`id`, `header`);
var text_010 = document.createTextNode(` `);
div_002.appendChild(text_010);

var h1_001 = document.createElement('h1');
var text_011 = document.createTextNode(`Sample`);
h1_001.appendChild(text_011);
div_002.appendChild(h1_001);
var text_012 = document.createTextNode(` `);
div_002.appendChild(text_012);

var img_001 = document.createElement('img');
img_001.setAttribute(`src`, `kanye.jpg`);
img_001.setAttribute(`alt`, `kanye`);
div_002.appendChild(img_001);
var text_013 = document.createTextNode(` `);
div_002.appendChild(text_013);
div_001.appendChild(div_002);
var text_014 = document.createTextNode(` `);
div_001.appendChild(text_014);

var div_003 = document.createElement('div');
div_003.setAttribute(`id`, `main`);
var text_015 = document.createTextNode(` `);
div_003.appendChild(text_015);

var h2_001 = document.createElement('h2');
var text_016 = document.createTextNode(`Main`);
h2_001.appendChild(text_016);
div_003.appendChild(h2_001);
var text_017 = document.createTextNode(` `);
div_003.appendChild(text_017);

var p_001 = document.createElement('p');
var text_018 = document.createTextNode(`This is the main content.`);
p_001.appendChild(text_018);
div_003.appendChild(p_001);
var text_019 = document.createTextNode(` `);
div_003.appendChild(text_019);

var img_002 = document.createElement('img');
img_002.setAttribute(`src`, ``);
img_002.setAttribute(`alt`, ``);
div_003.appendChild(img_002);
var text_020 = document.createTextNode(` `);
div_003.appendChild(text_020);
div_001.appendChild(div_003);
var text_021 = document.createTextNode(` `);
div_001.appendChild(text_021);

var div_004 = document.createElement('div');
div_004.setAttribute(`id`, `footer`);
var text_022 = document.createTextNode(` `);
div_004.appendChild(text_022);

var p_002 = document.createElement('p');
var text_023 = document.createTextNode(`Copyright - 2019`);
p_002.appendChild(text_023);
div_004.appendChild(p_002);
var text_024 = document.createTextNode(` `);
div_004.appendChild(text_024);
div_001.appendChild(div_004);
var text_025 = document.createTextNode(` `);
div_001.appendChild(text_025);
body_001.appendChild(div_001);
var text_026 = document.createTextNode(` `);
body_001.appendChild(text_026);
html_001.appendChild(body_001);
targetElement_001.appendChild(html_001);

--d2a-7NlH3rlmcFC3loiJxDxom6iojCunhkzzH--
```
41 changes: 30 additions & 11 deletions README.cli.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
# Command Line Interface

```shell
let targetElement_000 = document.querySelector(`:root > body`);
let targetElement_001 = document.querySelector(`:root > body`);


let div_000 = document.createElement('div');
let text_000 = document.createTextNode(`I am a `);
div_000.appendChild(text_000);
let div_001 = document.createElement('div');
let text_001 = document.createTextNode(`I am a `);
div_001.appendChild(text_001);

let strong_000 = document.createElement('strong');
let text_001 = document.createTextNode(`tea pot`);
strong_000.appendChild(text_001);
div_000.appendChild(strong_000);
targetElement_000.appendChild(div_000);
let strong_001 = document.createElement('strong');
let text_002 = document.createTextNode(`tea pot`);
strong_001.appendChild(text_002);
div_001.appendChild(strong_001);
targetElement_001.appendChild(div_001);
```

---

`jsgenerator` has several options that can be used in a console here is an example of use below

```text
Usage: jsgenerator [-htV] [-e=<extension>] [--inline-pattern=<inlinePattern>]
Usage: jsgenerator [-chtV] [-qs] [-e=<extension>]
[--inline-pattern=<inlinePattern>]
[-k=<variableDeclaration>] [--path-pattern=<pathPattern>]
[-s=<targetElementSelector>]
[--stdin-pattern=<stdinPattern>]
[--variable-name-generation-strategy=<builtinVariableNameStra
tegy>] [-i=<inlineContents>...]... [<paths>...]
Translating files, stdin or inline from HTML to JS
[<paths>...] file paths to translate content, parsed as HTML
-c, --comment optional comments
-e, --ext=<extension> output files' extension
-h, --help Show this help message and exit.
-i, --inline=<inlineContents>...
Expand All @@ -38,6 +40,23 @@ Translating files, stdin or inline from HTML to JS
variable declaration keyword
--path-pattern=<pathPattern>
pattern for path-based output filenames
-qs, --query-selector
What the browser renders depends on whether "document.
querySelector(':root > body')" is added to the
output. If added, the browser will render the
output successfully, it is useful for debugging
purpose,
to verify that the js output matches what the
html input does.
If not, if the user tries to run the output as
it is then the browser will not be able to render,
it will show a blank page.
So, it depends on what the user wants to do with
the output.
"https://jsfiddle.net/", "https://codepen.
io/pen/" and Browser Console help to give a quick
feedback.
-s, --selector=<targetElementSelector>
Target element selector
--stdin-pattern=<stdinPattern>
Expand All @@ -46,4 +65,4 @@ Translating files, stdin or inline from HTML to JS
-V, --version Print version information and exit.
--variable-name-generation-strategy=<builtinVariableNameStrategy>
Variable names generation strategy
```
```
3 changes: 3 additions & 0 deletions README.desktop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> Screenshot of the current desktop version:
>
> ![Screenshot of the current desktop version](illustrations/screenshot_current_desktop_version.png)
Loading

0 comments on commit 11857a0

Please sign in to comment.