Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK-312: Allow overriding openmrs assemble and build tool versions #228

Merged
merged 1 commit into from
Jun 26, 2023

Conversation

wikumChamith
Copy link
Contributor

@wikumChamith wikumChamith commented Jun 26, 2023

This allows users to override the default OpenMRS SPA core version using the maven parameter: spaCoreVersion.

Jira ticket: https://issues.openmrs.org/browse/SDK-312

@dkayiwa
Copy link
Member

dkayiwa commented Jun 26, 2023

@wikumChamith can you add this to the documentation?

@dkayiwa
Copy link
Member

dkayiwa commented Jun 26, 2023

And will this replace latest in what i have in the log as Running 'npm exec -- openmrs@latest build --target.....

@wikumChamith
Copy link
Contributor Author

Yes.

public void installFromDistroProperties(File appDataDir, DistroProperties distroProperties)
throws MojoExecutionException {
// We find all the lines in distro properties beginning with `spa` and convert these
// into a JSON structure. This is passed to the frontend build tool.
// If no SPA elements are present in the distro properties, the SPA is not installed.
Map<String, String> spaProperties = distroProperties.getSpaProperties(distroHelper, appDataDir);
// Three of these properties are not passed to the build tool, but are used to specify the build execution itself
String coreVersion = spaProperties.remove("core");
if (coreVersion == null) {
coreVersion = "latest";
}
String nodeVersion = spaProperties.remove("node");
if (nodeVersion == null) {
nodeVersion = NODE_VERSION;
}
String npmVersion = spaProperties.remove("npm");
if (npmVersion == null) {
npmVersion = NPM_VERSION;
}
if (!spaProperties.isEmpty()) {
Map<String, Object> spaConfigJson = convertPropertiesToJSON(spaProperties);
File spaConfigFile = new File(appDataDir, "spa-build-config.json");
writeJSONObject(spaConfigFile, spaConfigJson);
nodeHelper.installNodeAndNpm(nodeVersion, npmVersion);
File buildTargetDir = new File(appDataDir, BUILD_TARGET_DIR);
String program = "openmrs@" + coreVersion;
// print frontend tool version number
nodeHelper.runNpx(String.format("%s --version", program));
nodeHelper.runNpx(
String.format("%s build --target %s --build-config %s", program, buildTargetDir, spaConfigFile));
nodeHelper.runNpx(
String.format("%s assemble --target %s --mode config --config %s", program, buildTargetDir, spaConfigFile));
}
}

@wikumChamith
Copy link
Contributor Author

wikumChamith commented Jun 26, 2023

Yes.

public void installFromDistroProperties(File appDataDir, DistroProperties distroProperties)
throws MojoExecutionException {
// We find all the lines in distro properties beginning with `spa` and convert these
// into a JSON structure. This is passed to the frontend build tool.
// If no SPA elements are present in the distro properties, the SPA is not installed.
Map<String, String> spaProperties = distroProperties.getSpaProperties(distroHelper, appDataDir);
// Three of these properties are not passed to the build tool, but are used to specify the build execution itself
String coreVersion = spaProperties.remove("core");
if (coreVersion == null) {
coreVersion = "latest";
}
String nodeVersion = spaProperties.remove("node");
if (nodeVersion == null) {
nodeVersion = NODE_VERSION;
}
String npmVersion = spaProperties.remove("npm");
if (npmVersion == null) {
npmVersion = NPM_VERSION;
}
if (!spaProperties.isEmpty()) {
Map<String, Object> spaConfigJson = convertPropertiesToJSON(spaProperties);
File spaConfigFile = new File(appDataDir, "spa-build-config.json");
writeJSONObject(spaConfigFile, spaConfigJson);
nodeHelper.installNodeAndNpm(nodeVersion, npmVersion);
File buildTargetDir = new File(appDataDir, BUILD_TARGET_DIR);
String program = "openmrs@" + coreVersion;
// print frontend tool version number
nodeHelper.runNpx(String.format("%s --version", program));
nodeHelper.runNpx(
String.format("%s build --target %s --build-config %s", program, buildTargetDir, spaConfigFile));
nodeHelper.runNpx(
String.format("%s assemble --target %s --mode config --config %s", program, buildTargetDir, spaConfigFile));
}
}

I tested this. The value we passed gets set in String coreVersion = spaProperties.remove("core"); .

@wikumChamith
Copy link
Contributor Author

@dkayiwa
Copy link
Member

dkayiwa commented Jun 26, 2023

Should the default be latest or next?

@wikumChamith
Copy link
Contributor Author

Should the default be latest or next?

By default in other spa modules, we use the 'next' version. Using the latest version for spa core was added in this issues: https://issues.openmrs.org/browse/SDK-290

What do you recommend??

@wikumChamith
Copy link
Contributor Author

Should the default be latest or next?

By default in other spa modules, we use the 'next' version. Using the latest version for spa core was added in this issues: https://issues.openmrs.org/browse/SDK-290

What do you recommend??

Pr: #197

@dkayiwa
Copy link
Member

dkayiwa commented Jun 26, 2023

Shouldn't we be consistent?

@wikumChamith
Copy link
Contributor Author

Shouldn't we be consistent?

Yeah. I'll change the default version to next.

@wikumChamith
Copy link
Contributor Author

wikumChamith commented Jun 26, 2023

@dkayiwa I changed the default version to next. I also updated the documentation.

@dkayiwa dkayiwa merged commit 49e79ad into openmrs:master Jun 26, 2023
2 checks passed
wikumChamith added a commit to wikumChamith/openmrs-sdk that referenced this pull request Jun 29, 2023
wikumChamith added a commit to wikumChamith/openmrs-sdk that referenced this pull request Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants