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

(feat) O3-3443 Command in the OpenMRS CLI to package up configurations #1052

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

suubi-joshua
Copy link
Contributor

@suubi-joshua suubi-joshua commented Jun 24, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. Ensure your PR title includes a conventional commit label (such as feat, fix, or chore, among others). See existing PR titles for inspiration.

For changes to apps

If applicable

  • My work includes tests or is validated by existing tests.
  • I have updated the esm-framework mock to reflect any API changes I have made.

Summary

This script automatically merges configuration files from multiple directories into a single file. It simplifies managing app-specific configurations and reduces manual maintenance.

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-3443

Other

@suubi-joshua suubi-joshua changed the title (feat) O3-3443 Command in the OpenMRS CLI to package up a configuration (feat) O3-3443 Command in the OpenMRS CLI to package up configurations Jun 25, 2024
@gracepotma
Copy link
Contributor

@wikumChamith does this look to you like what @ibacher had in mind for https://openmrs.atlassian.net/browse/O3-3443?

@ibacher
Copy link
Member

ibacher commented Jun 26, 2024

No, it does not. I think this does something else. @suubi-joshua How can I test this? What does it do? Why is there anything about config schemas in this? The goal of the ticket was solely to allow a user to specify some JSON files and merge those into a single thing.

@suubi-joshua
Copy link
Contributor Author

suubi-joshua commented Jun 27, 2024

Thanks for the clarity @ibacher @wikumChamith . The script i have provided allows user to specify directories pointing to ts files containing custom configSchemas then merges them into one file. I assumed that configs are an object format in typescript format just like here configschemas not json files but will change this to read json files. When working proper this script writes the combined configs as an object in a ts file (working on testing this in cli).

I am working on the testing it in the CLI.

@suubi-joshua
Copy link
Contributor Author

suubi-joshua commented Jun 27, 2024

No, it does not. I think this does something else. @suubi-joshua How can I test this? What does it do? Why is there anything about config schemas in this? The goal of the ticket was solely to allow a user to specify some JSON files and merge those into a single thing.

@ibacher @wikumChamith With testing the command to use in the cli is yarn merge-config -d directories to config files -o directory to output file

@ibacher
Copy link
Member

ibacher commented Jun 28, 2024

@suubi-joshua I think that it's preferable that this all gets wrapped up into the "assemble" command. I don't not want to add more steps that implementers need to run, just more options to the steps they can run.

@ibacher
Copy link
Member

ibacher commented Jun 28, 2024

Also, it's better to allow users to specify files rather than directories. We can always make --config-file configs/* work, but we cannot make --config-file my-config.json --config-file my-config-2.json work.

@ibacher
Copy link
Member

ibacher commented Jun 28, 2024

Similarly, the output file name shouldn't be required to be specified, but have a sane default.

@gracepotma gracepotma removed the request for review from wikumChamith June 30, 2024 19:34
@gracepotma
Copy link
Contributor

(Removed Wikum as he explained to me this is outside his familiarity area at this time.)

@@ -17,6 +17,7 @@ export interface AssembleArgs {
target: string;
mode: string;
config: Array<string>;
myConfigs: Array<string>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better naming suggestion:

Suggested change
myConfigs: Array<string>;
configFiles: Array<string>;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay will work on this

@@ -303,5 +331,9 @@ export async function runAssemble(args: AssembleArgs) {
await writeFile(resolve(args.target, 'spa-assemble-config.json'), JSON.stringify(versionManifest), 'utf8');
}

if(args.mode === 'myConfigs'){
await writeFile(resolve(args.target, 'My-Merged-configs.json'), JSON.stringify(config), 'utf8');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filename should be spa-config.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

default: 'survey',
description:
'The source of the frontend modules to assemble. `config` uses a configuration file specified via `--config`. `survey` starts an interactive command-line survey.',
'The source of the frontend modules to assemble. `config` uses a configuration file specified via `--config`. `configFiles` packages up configurations from file specified via `--config-file`. `survey` starts an interactive command-line survey.',
type: 'string',
}),
(args) => runCommand('runAssemble', args),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @ibacher I am facing a blocker. After making the changes I want to test them but there is a persistent error in cli.ts file on the args, somehow the new argument of configFiles is missing from the args in the cli yet its exported in the AssembleArgs interface. Also when I edit the mode option to put another choice ie configFiles it does not seem to get added (How do I know this, when i run yarn assemble --help my edits for choices dont show even for the description)

@ibacher ibacher force-pushed the main branch 2 times, most recently from 8f994a6 to 9cee659 Compare July 22, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants