feat(cli): enable to print the config schema non merged
Signed-off-by: djamaile <rdjamaile@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Enable to print the config schema non merged with the `non-merged` flag
|
||||
@@ -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`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user