diff --git a/.changeset/rare-pens-exist.md b/.changeset/rare-pens-exist.md new file mode 100644 index 0000000000..7363f5033a --- /dev/null +++ b/.changeset/rare-pens-exist.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Enable to print the config schema not merged with the `--no-merge` flag diff --git a/packages/cli/cli-report.md b/packages/cli/cli-report.md index 4cf5c6329c..e20634df4e 100644 --- a/packages/cli/cli-report.md +++ b/packages/cli/cli-report.md @@ -97,6 +97,8 @@ Usage: backstage-cli config:schema [options] Options: --package --format + --merge + --no-merge -h, --help ``` diff --git a/packages/cli/src/commands/config/schema.ts b/packages/cli/src/commands/config/schema.ts index f9e6573be6..08bc46d1cc 100644 --- a/packages/cli/src/commands/config/schema.ts +++ b/packages/cli/src/commands/config/schema.ts @@ -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`); } }; diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 1fa7fe2964..a7f65588a5 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -365,6 +365,8 @@ export function registerCommands(program: Command) { '--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)));