Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit a3e8716

Browse files
authored
fix: make plugin config schema generation compatible with upstream. (#2657)
Signed-off-by: David Festal <[email protected]>
1 parent f68b40b commit a3e8716

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

.changeset/odd-planes-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@janus-idp/cli": patch
3+
---
4+
5+
Prepare for better compatibility with the upstream dynamic plugins support, by generating the config schema for backend plugins in both `dist/configSchema.json` (for backward compatibility with RHDH) and `dist/.config-schema.json` for consistency and compatibility with upstream.

packages/cli/src/commands/export-dynamic-plugin/command.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ import { backend as backendEmbedAsDependencies } from './backend-embed-as-depend
3030
import { applyDevOptions } from './dev';
3131
import { frontend } from './frontend';
3232

33-
const saveSchema = async (packageName: string, destination: string) => {
34-
const configSchema = await getConfigSchema(packageName);
35-
await fs.writeJson(paths.resolveTarget(destination), configSchema, {
36-
encoding: 'utf8',
37-
spaces: 2,
38-
});
39-
};
40-
4133
export async function command(opts: OptionValues): Promise<void> {
4234
const rawPkg = await fs.readJson(paths.resolveTarget('package.json'));
4335
const role = PackageRoles.getRoleFromPackage(rawPkg);
@@ -47,28 +39,40 @@ export async function command(opts: OptionValues): Promise<void> {
4739

4840
let targetPath: string;
4941
const roleInfo = PackageRoles.getRoleInfo(role);
50-
let configSchemaPath: string;
42+
let configSchemaPaths: string[];
5143

5244
if (role === 'backend-plugin' || role === 'backend-plugin-module') {
5345
if (opts.embedAsDependencies) {
5446
targetPath = await backendEmbedAsDependencies(opts);
5547
} else {
5648
targetPath = await backendEmbedAsCode(roleInfo, opts);
5749
}
58-
configSchemaPath = path.join(targetPath, 'dist/configSchema.json');
50+
configSchemaPaths = [
51+
path.join(targetPath, 'dist/configSchema.json'),
52+
path.join(targetPath, 'dist/.config-schema.json'),
53+
];
5954
} else if (role === 'frontend-plugin' || role === 'frontend-plugin-module') {
6055
targetPath = await frontend(roleInfo, opts);
61-
configSchemaPath = path.join(targetPath, 'dist-scalprum/configSchema.json');
56+
configSchemaPaths = [
57+
path.join(targetPath, 'dist-scalprum/configSchema.json'),
58+
];
6259
} else {
6360
throw new Error(
6461
'Only packages with the "backend-plugin", "backend-plugin-module" or "frontend-plugin" roles can be exported as dynamic backend plugins',
6562
);
6663
}
6764

6865
Task.log(
69-
`Saving self-contained config schema in ${chalk.cyan(configSchemaPath)}`,
66+
`Saving self-contained config schema in ${chalk.cyan(configSchemaPaths.join(' and '))}`,
7067
);
71-
await saveSchema(rawPkg.name, configSchemaPath);
68+
69+
const configSchema = await getConfigSchema(rawPkg.name);
70+
for (const configSchemaPath of configSchemaPaths) {
71+
await fs.writeJson(paths.resolveTarget(configSchemaPath), configSchema, {
72+
encoding: 'utf8',
73+
spaces: 2,
74+
});
75+
}
7276

7377
await applyDevOptions(opts, rawPkg.name, roleInfo, targetPath);
7478
}

0 commit comments

Comments
 (0)