generic-static-generator
Description
Simple extensible generic static generator.
ContextContributor must implement io.yupiik.tools.generator.generic.contributor.ContextContributor interface and register itself in Yupiik Fusion IoC using a FusionModule ServiceLoader registration. Similarly, io.yupiik.tools.generator.generic.helper.Helper can be registered as a fusion bean to add helpers to the rendering context in addition to the default ones.
|
TIP
|
it can also be used to generate a static javascript site dataset - the site being built elsewhere with |
Contributors
gitlab-commit
Calls a gitlab instance to fetch commits based on a project and branches list. The resulting object is an object keyed by the project id with the commits as value.
Configuration
-
branches(env:COMMIT_BRANCHES) -
Branches to fetch (ref name). If set to
all, it just fetches all commits from the repository. Default:java.util.List.of("main"). -
cacheProjects(env:COMMIT_CACHEPROJECTS) -
Should projects be cached - in memory - when
topicsis set, useful if multiple contributors the same request. Enable when multiple contributors do the same request to do it only once. Default:false. -
gitlab.baseUrl(env:COMMIT_GITLAB_BASEURL) -
Base URL. Default:
https://gitlab.com. -
gitlab.headers(env:COMMIT_GITLAB_HEADERS) -
HTTP headers to use as
key=valueform. Default:java.util.Map.of(). -
gitlab.timeout(env:COMMIT_GITLAB_TIMEOUT) -
Request timeout in java
Durationformat. Default:PT30S. -
since(env:COMMIT_SINCE) -
If set a starting date for commits to not fetch the while dataset (
YYYY-MM-DDTHH:MM:SSZformat). If starting withnow-the end of the string is treated as aPeriodto parse and date is computed. Default:now-P6M. -
statistics(env:COMMIT_STATISTICS) -
Should statistics be fetched. Default:
true. -
topics(env:COMMIT_TOPICS) -
Topics to filter when fetching commits based on a project filter. Default:
java.util.List.of().gitlab-environment
Calls a gitlab instance to fetch environments based on a project list. The resulting object is an object keyed by the project id with the environment as value.
Configuration
-
cacheProjects(env:ENVIRONMENT_CACHEPROJECTS) -
Should projects be cached - in memory - when
topicsis set, useful if multiple contributors the same request. Enable when multiple contributors do the same request to do it only once. Default:false. -
details(env:ENVIRONMENT_DETAILS) -
Should details be fetched or just environment index is sufficient. Default:
false. -
gitlab.baseUrl(env:ENVIRONMENT_GITLAB_BASEURL) -
Base URL. Default:
https://gitlab.com. -
gitlab.headers(env:ENVIRONMENT_GITLAB_HEADERS) -
HTTP headers to use as
key=valueform. Default:java.util.Map.of(). -
gitlab.timeout(env:ENVIRONMENT_GITLAB_TIMEOUT) -
Request timeout in java
Durationformat. Default:PT30S. -
topics(env:ENVIRONMENT_TOPICS) -
Topics to filter when fetching environments based on a project filter. Default:
java.util.List.of().gitlab-project
Calls a gitlab instance using its REST API to fetch a list of project.
Configuration
-
cache(env:PROJECT_CACHE) -
Should projects be cached - in memory, useful if multiple contributors the same request. Enable when multiple contributors do the same request to do it only once. Default:
false. -
gitlab.baseUrl(env:PROJECT_GITLAB_BASEURL) -
Base URL. Default:
https://gitlab.com. -
gitlab.headers(env:PROJECT_GITLAB_HEADERS) -
HTTP headers to use as
key=valueform. Default:java.util.Map.of(). -
gitlab.timeout(env:PROJECT_GITLAB_TIMEOUT) -
Request timeout in java
Durationformat. Default:PT30S. -
topics(env:PROJECT_TOPICS) -
Topics to filter when fetching projects. Default:
java.util.List.of().http
Enable to call a HTTP method to get a JSON response and map the result to contributed data.
Configuration
-
request.headers(env:REQUEST_HEADERS) -
HTTP request headers in properties syntax. Default:
java.util.Map.of(). -
request.httpVersion(env:REQUEST_HTTPVERSION) -
HTTP version - as in
java.net.http.HttpClient.Version. Default:HTTP_1_1. -
request.method(env:REQUEST_METHOD) -
HTTP verb. Default:
GET. -
request.payload(env:REQUEST_PAYLOAD) -
HTTP request payload. Default:
. -
request.timeout(env:REQUEST_TIMEOUT) -
HTTP request timeout in java
Durationformat. Default:PT30S. -
request.uri(env:REQUEST_URI) -
HTTP endpoint.
-
response.dataJsonPointer(env:RESPONSE_DATAJSONPOINTER) -
JSON Pointer to extract data to contribute to the rendering context.If extracted value is not an object it will be wrapped in an object with
valuekey. Note that if it point on nothing then an empty context is returned. Default:. -
response.expectedStatus(env:RESPONSE_EXPECTEDSTATUS) -
HTTP response list of status (comma separated) which are valid. Default:
java.util.List.of(200).java
|
WARNING
|
requires a JDK and not a simple JRE. |
Enable to inject plain Java code to implement dynamically a contributor.
This is quite neat when dealing with complex logic and default contributors are not sufficient.
Configuration
-
code(env:CODE) -
Code of the contributor
contributemethod. There are three implicit variables:configurationwhich is aMap<String, String>with the contributor configuration,executorwhich is the thread pool to use if needed andcontainerwhich is Yupiik Fusion IoC if some other beans are needed. It must end with areturn xxxwithxxxaCompletionStage<Map<String, Object>>. For convenience,completedFutureis implicitly available as well asjava.util. If it starts withfile:the end of the string is a file path. -
compilationClasspath(env:COMPILATIONCLASSPATH) -
Enable to set the compilation classpath (for 3rd parties). If not set we try to inherit from current classloader one.
-
imports(env:IMPORTS) -
Enable to set global imports to the generated class.
-
packageName(env:PACKAGENAME) -
Package name override - else an internal package is used. Mainly useful to access package scope classes.
json
Simple contributor which loads some content from a JSON inline data or a file. If content is an array it is wrapped in a {value:...} object.
Configuration
-
data(env:DATA) -
JSON content or a file path starting with
file:(ex:file:/my/path.json).
Helpers
lowercase
Type: inline.
Lowercase the passed parameter (stringified using toString or null).
toJson
Type: inline.
Converts the passed parameter to a JSON string.
truncate
Type: inline.
Truncate a string based on a length. It takes two parameters, the value to truncate and the desired length (>=3).
uppercase
Type: inline.
Uppercase the passed parameter (stringified using toString or null).
Synopsis
java ... io.yupiik.fusion.framework.api.main.Launcher \
generic-static-generator \
--contributors-$index-configuration ...\
--contributors-$index-context-name ...\
--contributors-$index-name ...\
--output ...\
--partials ...\
--template ...\
--threads ...
Parameters
- --contributors-$index-configuration
-
Configuration to pass to the contributor.
- --contributors-$index-context-name
-
Context name where the result will be available, if not set or empty contributor name is reused.
- --contributors-$index-name
-
Name of the contributor to use.
- --output
-
Where to write the output.
STDOUTandSTDERRare two specific values for the standard outputs.
- --partials
-
Partials handlebars. If a value is starting with
file:the end of the path is a file path used as source. If a key ends with/*.hb, all files in the directory are loaded as this - value is ignored.
- --template
-
Handlebars template to render once the context is built. If starting with
file:the end of the path is a file path used as source.
- --threads
-
Size of the thread pool to run contribution in. Note that it is a scheduled executor so if executors use scheduled tasks it can need > 1.