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
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3a847a3
(feat) O3-3443 Command in the OpenMRS CLI to package up a configuratio
suubi-joshua Jun 24, 2024
0f32a94
Attemped codeql cheak
suubi-joshua Jun 24, 2024
590c84e
trying to fix codeQL failed test
suubi-joshua Jun 24, 2024
01c7bb0
Clean Path
suubi-joshua Jun 24, 2024
938cacd
CodeQL
suubi-joshua Jun 25, 2024
e5d82cb
Removed server side environment
suubi-joshua Jun 25, 2024
24a1420
Removed port number from args
suubi-joshua Jun 25, 2024
8ee14ce
Added ending colon
suubi-joshua Jun 25, 2024
85c6899
Merge remote-tracking branch 'upstream/main' into O3-3443
suubi-joshua Jun 25, 2024
417c5ed
Removed port number from MergeConfigArgs
suubi-joshua Jun 25, 2024
44109f9
Trying to integrate CLI command
suubi-joshua Jun 27, 2024
217310c
Removed args dependency
suubi-joshua Jun 27, 2024
3dc93c7
Added script merge-congigs
suubi-joshua Jun 27, 2024
99698b9
Pulled new changes from Upstream
suubi-joshua Jun 27, 2024
917c6e5
Added type
suubi-joshua Jun 27, 2024
5267e44
Changed read files from ts to JSON
suubi-joshua Jun 27, 2024
1463eb4
Removed inline markings from WorspaceContainerProps
suubi-joshua Jun 27, 2024
29e1615
Removed more inline marks
suubi-joshua Jun 27, 2024
a532438
Testing logic
suubi-joshua Jul 1, 2024
9cb2b4f
Pulled changes from upstream
suubi-joshua Jul 1, 2024
950aa60
Fuction runMergeConfig returns promise
suubi-joshua Jul 1, 2024
0f62144
Trying to add the merge-config in assemble
suubi-joshua Jul 2, 2024
fbc311d
Upstream changes
suubi-joshua Jul 2, 2024
c675229
Edits
suubi-joshua Jul 2, 2024
621c8f2
Changed naming
suubi-joshua Jul 3, 2024
2e08f68
Added Logic to return combinedConfig as AssembleConfig format
suubi-joshua Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"ci:publish": "yarn workspaces foreach --all --topological --exclude @openmrs/esm-core npm publish --access public --tag latest",
"release": "yarn workspaces foreach --all --topological version",
"build": "turbo run build",
"assemble": "openmrs assemble",
"build:apps": "turbo run build --filter='@openmrs/*-app'",
"setup": "yarn install && turbo run build",
"merge-configs": "openmrs merge-configs",
"start": "openmrs develop",
"verify": "turbo run lint test typescript",
"postinstall": "husky install",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,4 @@ ___
• `Optional` **showSiderailAndBottomNav**: `boolean`

#### Defined in


[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L19)

[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:18](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L18)
29 changes: 2 additions & 27 deletions packages/tooling/openmrs/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

function runCommand<T extends CommandNames>(type: T, args: Parameters<Commands[T]>[0]) {
const ps = fork(runner, [], { cwd: type === 'runBuild' ? root : process.cwd() })
console.log(`These are the args received by the runner: ${args}`);

Check failure on line 18 in packages/tooling/openmrs/src/cli.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

ps.send({
type,
Expand Down Expand Up @@ -290,10 +290,10 @@
type: 'boolean',
})
.option('mode', {
choices: ['config', 'survey'],
choices: ['config', 'configFile', 'survey'],
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`. `configFile packages up configurations from file specified cia `--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)

Expand Down Expand Up @@ -324,31 +324,6 @@
...args,
}),
);

yargs.command(
'merge-configs',
'Merges configuration files from multiple directories into a single output file',
(argv) =>
argv
.option('directoriesPath', {
alias: 'd',
describe: 'Directories to read config files from',
type: 'string',
demandOption: true,
})
.option('outputPath', {
alias: 'o',
describe: 'Output file path',
type: 'string',
demandOption: true,
})
.help()
.argv,
(args) => runCommand('runMergeConfig', {
directoriesPath: args.directoriesPath as string,
outputPath: args.outputPath as string,
})
);
yargs
.epilog(
'The SPA build config JSON is a JSON file, typically `frontend.json`, which defines parameters for the `build` and `assemble` ' +
Expand Down
34 changes: 33 additions & 1 deletion packages/tooling/openmrs/src/commands/assemble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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

registry?: string;
hashImportmap: boolean;
fresh: boolean;
Expand All @@ -43,6 +44,7 @@
async function readConfig(
mode: string,
configs: Array<string>,
myConfigs: Array<string>,
fetchOptions: npmRegistryFetch.Options,
): Promise<AssembleConfig> {
switch (mode) {
Expand Down Expand Up @@ -101,7 +103,33 @@
return config;
});
}
case 'myConfigs':{
if (!myConfigs.length) {
throw new Error('Please specify config files using the --config-file option.');
}

const results: {
myConfigs: Array<AssembleConfig>;
errors: Array<Error>;
} = {
myConfigs: [],
errors: [],
};

for (const config of myConfigs) {
if (!existsSync(config)) {
results.errors.push(new Error(`Could not find the config file "${config}".`));
continue;
}

logInfo(`Reading configuration ${config} ...`);

results.myConfigs.push({
...JSON.parse(await readFile(config, 'utf8')),
});
}
}
case 'survey': {

Check failure on line 132 in packages/tooling/openmrs/src/commands/assemble.ts

View workflow job for this annotation

GitHub Actions / build

Expected a 'break' statement before 'case'
logInfo(`Loading available frontend modules ...`);

const packages = await npmRegistryFetch
Expand Down Expand Up @@ -230,7 +258,7 @@

export async function runAssemble(args: AssembleArgs) {
const npmConf = getNpmRegistryConfiguration(args.registry);
const config = await readConfig(args.mode, args.config, npmConf);
const config = await readConfig(args.mode, args.config, args.myConfigs, npmConf);

const importmap = {
imports: {},
Expand Down Expand Up @@ -303,5 +331,9 @@
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

}

logInfo(`Finished assembling frontend distribution`);
}
1 change: 0 additions & 1 deletion packages/tooling/openmrs/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export * from './build';
export * from './debug';
export * from './develop';
export * from './start';
export * from './merge-configs';
83 changes: 0 additions & 83 deletions packages/tooling/openmrs/src/commands/merge-configs.ts

This file was deleted.

Loading