Skip to content

Commit

Permalink
Fix URL for Dev UI es-shims
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <phillip.kruger@gmail.com>
  • Loading branch information
phillip-kruger committed Oct 19, 2023
1 parent d35d52f commit 14bf544
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class BuildTimeContentProcessor {
private static final String SLASH = "/";
private static final String DEV_UI = "dev-ui";
private static final String BUILD_TIME_PATH = "dev-ui-templates/build-time";
private static final String ES_MODULE_SHIMS = "es-module-shims";

final Config config = ConfigProvider.getConfig();

Expand Down Expand Up @@ -294,11 +295,11 @@ QuteTemplateBuildItem createIndexHtmlTemplate(
QuteTemplateBuildItem.DEV_UI);

Aggregator aggregator = new Aggregator(mvnpmBuildItem.getMvnpmJars());

for (InternalImportMapBuildItem importMapBuildItem : internalImportMapBuildItems) {
Map<String, String> importMap = importMapBuildItem.getImportMap();
aggregator.addMappings(importMap);
}
String esModuleShimsVersion = extractEsModuleShimsVersion(mvnpmBuildItem.getMvnpmJars());
String importmap = aggregator.aggregateAsJson(nonApplicationRootPathBuildItem.getNonApplicationRootPath());
aggregator.reset();

Expand All @@ -310,7 +311,8 @@ QuteTemplateBuildItem createIndexHtmlTemplate(
"nonApplicationRoot", nonApplicationRoot,
"contextRoot", contextRoot,
"importmap", importmap,
"themeVars", themeVars);
"themeVars", themeVars,
"esModuleShimsVersion", esModuleShimsVersion);

quteTemplateBuildItem.add("index.html", data);

Expand Down Expand Up @@ -376,6 +378,18 @@ void createBuildTimeData(BuildProducer<BuildTimeConstBuildItem> buildTimeConstPr
buildTimeConstProducer.produce(internalBuildTimeData);
}

private String extractEsModuleShimsVersion(Set<URL> urls) {
for (URL u : urls) {
if (u.getPath().contains(ES_MODULE_SHIMS)) {
int i = u.getPath().indexOf(ES_MODULE_SHIMS) + ES_MODULE_SHIMS.length() + 1;
String versionOnward = u.getPath().substring(i);
String[] parts = versionOnward.split(SLASH);
return parts[0];
}
}
return "";
}

private void addThemeBuildTimeData(BuildTimeConstBuildItem internalBuildTimeData,
BuildProducer<ThemeVarsBuildItem> themeVarsProducer) {
// Theme details TODO: Allow configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/png" href="{contextRoot}favicon.ico">

<script async src="{nonApplicationRoot}_static/es-module-shims/dist/es-module-shims.js"></script>
<script async src="{nonApplicationRoot}_static/es-module-shims/{esModuleShimsVersion}/dist/es-module-shims.js"></script>

<script type="importmap">
{importmap}
Expand Down

0 comments on commit 14bf544

Please sign in to comment.