Merge pull request #18786 from backstage/djam/non-merged

feat(cli): enable to print the config schema non merged
This commit is contained in:
Djam
2023-07-25 13:19:22 +02:00
committed by GitHub
4 changed files with 24 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Enable to print the config schema not merged with the `--no-merge` flag
+2
View File
@@ -97,6 +97,8 @@ Usage: backstage-cli config:schema [options]
Options:
--package <name>
--format <format>
--merge
--no-merge
-h, --help
```
+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.merge) {
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`);
}
};
+2
View File
@@ -365,6 +365,8 @@ export function registerCommands(program: Command) {
'--format <format>',
'Format to print the schema in, either json or yaml [yaml]',
)
.option('--merge', 'Print the config schemas merged', true)
.option('--no-merge', 'Print the config schemas not merged')
.description('Print configuration schema')
.action(lazy(() => import('./config/schema').then(m => m.default)));