-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KH-572: Build OpenMRS frontend with core version
5.6.1-pre.1857
(#370)
- Loading branch information
1 parent
53feb62
commit 34ed432
Showing
4 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
base/configs/openmrs/frontend_assembly/spa-assemble-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
{ | ||
"coreVersion": "5.6.1-pre.1857", | ||
"frontendModules": { | ||
"@openmrs/esm-form-entry-app": "8.0.0" | ||
}, | ||
"__comment": "We exclude the React Form Engine app in favor of the Angular Form Engine.", | ||
"frontendModuleExcludes": [ | ||
"@openmrs/esm-form-engine-app" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
base/scripts/openmrs/frontend_assembly/build-openmrs-frontend.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import java.nio.file.Paths | ||
|
||
log.info("Checking for frontend customizations in ${Paths.get("${project.build.directory}", "openmrs_frontend", "spa-assemble-config.json").toString()}") | ||
|
||
def refAppConfigFile = Paths.get("${project.build.directory}", "openmrs_frontend", "reference-application-spa-assemble-config.json").toFile() | ||
def slurper = new groovy.json.JsonSlurper() | ||
def refAppConfig = slurper.parse(refAppConfigFile) | ||
def openmrsVersion = refAppConfig["coreVersion"] ?: "next" | ||
def outputDirectory = "${project.groupId}" == "com.ozonehis" && "${project.artifactId}" == "ozone-distro" ? | ||
"${project.build.directory}/${project.artifactId}-${project.version}/binaries/openmrs/frontend" : | ||
"${project.build.directory}/${project.artifactId}-${project.version}/distro/binaries/openmrs/frontend" | ||
|
||
def outputDirectoryFile = new File(outputDirectory) | ||
|
||
def assembleCommand = "npx --legacy-peer-deps openmrs@${openmrsVersion} assemble --manifest --mode config --target ${outputDirectory} --config ${refAppConfigFile.getAbsolutePath()}" | ||
log.info("Project: ${project.groupId}:${project.artifactId}") | ||
// by default, we build the frontend as part of Ozone and only rebuild if there are local customizations | ||
def shouldBuildFrontend = "${project.groupId}" == "com.ozonehis" && "${project.artifactId}" == "ozone-distro" | ||
|
||
if (!shouldBuildFrontend) { | ||
frontendCustomizationsFile = Paths.get("${project.build.directory}", "openmrs_frontend", "spa-assemble-config.json").toFile() | ||
if (frontendCustomizationsFile.exists()) { | ||
log.info("Found frontend customizations. Rebuilding frontend...") | ||
|
||
assembleCommand += " --config ${frontendCustomizationsFile.getAbsolutePath()}" | ||
shouldBuildFrontend = true | ||
// Update the openmrs version to the one specified in the customizations file if it exists. | ||
openmrsVersion = slurper.parse(frontendCustomizationsFile)["coreVersion"] ?: openmrsVersion | ||
log.info("Using OpenMRS Frontend Core Version: ${openmrsVersion}") | ||
} | ||
} | ||
|
||
if (shouldBuildFrontend) { | ||
log.info("Cleaning ${outputDirectory}...") | ||
if (outputDirectoryFile.exists()) { | ||
outputDirectoryFile.eachFile(it -> it.delete()) | ||
outputDirectoryFile.eachDir(it -> { if (it.getName() != "ozone") { it.deleteDir() } }) | ||
} | ||
|
||
log.info("Running assemble command...") | ||
|
||
def assembleProcess = assembleCommand.execute() | ||
assembleProcess.consumeProcessOutput(System.out, System.err) | ||
assembleProcess.waitFor() | ||
|
||
if (assembleProcess.exitValue() != 0) { | ||
throw new RuntimeException("'openmrs assemble' step failed. See previous messages for details.") | ||
} | ||
|
||
log.info("Running build command...") | ||
|
||
def buildProcess = "npx --legacy-peer-deps openmrs@${openmrsVersion} build --config-url \$SPA_CONFIG_URLS --default-locale \$SPA_DEFAULT_LOCALE --target ${outputDirectory}".execute() | ||
buildProcess.consumeProcessOutput(System.out, System.err) | ||
buildProcess.waitFor() | ||
|
||
if (buildProcess.exitValue() != 0) { | ||
throw new RuntimeException("'openmrs build' step failed. See previous messages for details.") | ||
} | ||
} else { | ||
log.info("No need to re-build the frontend detected") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters