feat(cli): enable to print the config schema non merged

Signed-off-by: djamaile <rdjamaile@gmail.com>
This commit is contained in:
djamaile
2023-07-24 20:53:02 +02:00
parent 639bbea9f0
commit cebbf8a27f
3 changed files with 21 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Enable to print the config schema non merged with the `non-merged` flag
+15 -11
View File
@@ -28,19 +28,23 @@ export default async (opts: OptionValues) => {
mockEnv: true,
});
const merged = mergeConfigSchemas(
(schema.serialize().schemas as JsonObject[]).map(
_ => _.value as JSONSchema,
),
);
merged.title = 'Application Configuration Schema';
merged.description =
'This is the schema describing the structure of the app-config.yaml configuration file.';
let configSchema: JsonObject | JSONSchema;
if (!opts.nonMerged) {
configSchema = mergeConfigSchemas(
(schema.serialize().schemas as JsonObject[]).map(
_ => _.value as JSONSchema,
),
);
configSchema.title = 'Application Configuration Schema';
configSchema.description =
'This is the schema describing the structure of the app-config.yaml configuration file.';
} else {
configSchema = schema.serialize();
}
if (opts.format === 'json') {
process.stdout.write(`${JSON.stringify(merged, null, 2)}\n`);
process.stdout.write(`${JSON.stringify(configSchema, null, 2)}\n`);
} else {
process.stdout.write(`${stringifyYaml(merged)}\n`);
process.stdout.write(`${stringifyYaml(configSchema)}\n`);
}
};
+1
View File
@@ -365,6 +365,7 @@ export function registerCommands(program: Command) {
'--format <format>',
'Format to print the schema in, either json or yaml [yaml]',
)
.option('--non-merged', 'Enable to print the config schema non merged')
.description('Print configuration schema')
.action(lazy(() => import('./config/schema').then(m => m.default)));