Wikum Weerakutti

GSOC-2023: Coding Week 10

This week I hit a milestone in my GSOC project. I have created pull requests for all the initial project objectives. So I had a discussion with my mentor about what my next objective should be. He pointed me to a bug we have in the SDK.

Setting up O3 with the SDK is problematic when the file path contains spaces, triggering the following error: https://pastebin.com/cRQHHmgU. This becomes problematic when usernames or server names involve spaces. This error is caused by the following lines of codes that are used to build the front end.

nodeHelper.runNpx(String.format("%s build --target %s --build-config %s", program, buildTargetDir, spaConfigFile), legacyPeerDeps);

So the first solution that came to my mind was to add an escape character before the space. So I changed the code like this:

nodeHelper.runNpx(String.format("%s build --target %s --build-config %s", program, buildTargetDir.getAbsolutePath().replace(" ", "\\ "), spaConfigFile.getAbsolutePath().replace(" ", "\\ ")), legacyPeerDeps);

This generates a command like the one below:

npm --cache=/tmp/openmrs-sdk-node12429853391947426928/npm-cache exec -- openmrs@next build --target /home/wikum/openmrs/server\ 20/frontend --build-config /home/wikum/openmrs/server\ 20/spa-build-config.json

Unfortunately, this didn't work as I expected. The '' to escape spaces is not well-handled outside shell contexts. So I got the following error: https://pastebin.com/t8d1KV04

So I decided to wrap the paths with quotes. So I changed the code.

nodeHelper.runNpx(String.format("%s build --target \"%s\" --build-config \"%s\"", program, buildTargetDir, spaConfigFile), legacyPeerDeps);

So this generates a command similar to this:

Running 'npm --cache=/tmp/openmrs-sdk-node5415753394153803303/npm-cache exec -- openmrs@next build --target "/home/wikum/openmrs/server 20/frontend" --build-config "/home/wikum/openmrs/server 20/spa-build-config.json"' in /home/wikum/Documents/GSOC/OpenMRS/GSOC-2023/openmrs-sdk

This method also didn't work as expected. This gave the following error:

[INFO] [openmrs] ENOENT: no such file or directory, open '/home/wikum/Documents/GSOC/OpenMRS/GSOC-2023/openmrs-sdk/"/home/wikum/openmrs/server 20/spa-build-config.json"'

My mentor suggested I update the version of frontend-maven-plugin. So I updated it to the latest versions: https://mvnrepository.com/artifact/com.github.eirslett/frontend-maven-plugin This didn't fix the error either.

I am hoping to discuss this further with my mentors and solve this within the next week. I am also having the midterm evaluation next week. So I plan to first create a short demo video showcasing the work I have done so far and share it with the OpenMRS community.

Thank you for reading. See you next week!!