Merge pull request #6884 from backstage/rugvip/wide

config-loader: broaden search for backstage packages in config schema collection
This commit is contained in:
Patrik Oldsberg
2021-08-19 11:04:35 +02:00
committed by GitHub
7 changed files with 49 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/config-loader': patch
---
Include `devDependencies` and `optionalDependencies` in the detection of Backstage packages when collecting configuration schema.
@@ -87,6 +87,8 @@ describe('collectConfigSchemas', () => {
dependencies: {
c1: '0.0.0',
c2: '0.0.0',
},
devDependencies: {
'@backstage/mock': '0.0.0',
},
configSchema: { ...mockSchema, title: 'b' },
@@ -74,6 +74,8 @@ export async function collectConfigSchemas(
const pkg = await fs.readJson(pkgPath);
const depNames = [
...Object.keys(pkg.dependencies ?? {}),
...Object.keys(pkg.devDependencies ?? {}),
...Object.keys(pkg.optionalDependencies ?? {}),
...Object.keys(pkg.peerDependencies ?? {}),
];
+10 -1
View File
@@ -30,9 +30,18 @@ describe('readAzureIntegrationConfig', () => {
async function buildFrontendConfig(
data: Partial<AzureIntegrationConfig>,
): Promise<Config> {
const schema = await loadConfigSchema({
const fullSchema = await loadConfigSchema({
dependencies: [require('../../package.json').name],
});
const serializedSchema = fullSchema.serialize() as {
schemas: { path: string }[];
};
const schema = await loadConfigSchema({
serialized: {
...serializedSchema, // grab the schema from this package only
schemas: serializedSchema.schemas.filter(s => s.path === 'config.d.ts'),
},
});
const processed = schema.process(
[{ data: { integrations: { azure: [data] } }, context: 'app' }],
{ visibility: ['frontend'] },
@@ -30,9 +30,18 @@ describe('readBitbucketIntegrationConfig', () => {
async function buildFrontendConfig(
data: Partial<BitbucketIntegrationConfig>,
): Promise<Config> {
const schema = await loadConfigSchema({
const fullSchema = await loadConfigSchema({
dependencies: [require('../../package.json').name],
});
const serializedSchema = fullSchema.serialize() as {
schemas: { path: string }[];
};
const schema = await loadConfigSchema({
serialized: {
...serializedSchema, // grab the schema from this package only
schemas: serializedSchema.schemas.filter(s => s.path === 'config.d.ts'),
},
});
const processed = schema.process(
[{ data: { integrations: { bitbucket: [data] } }, context: 'app' }],
{ visibility: ['frontend'] },
+10 -1
View File
@@ -30,9 +30,18 @@ describe('readGitHubIntegrationConfig', () => {
async function buildFrontendConfig(
data: Partial<GitHubIntegrationConfig>,
): Promise<Config> {
const schema = await loadConfigSchema({
const fullSchema = await loadConfigSchema({
dependencies: [require('../../package.json').name],
});
const serializedSchema = fullSchema.serialize() as {
schemas: { path: string }[];
};
const schema = await loadConfigSchema({
serialized: {
...serializedSchema, // grab the schema from this package only
schemas: serializedSchema.schemas.filter(s => s.path === 'config.d.ts'),
},
});
const processed = schema.process(
[{ data: { integrations: { github: [data] } }, context: 'app' }],
{ visibility: ['frontend'] },
+10 -1
View File
@@ -30,9 +30,18 @@ describe('readGitLabIntegrationConfig', () => {
async function buildFrontendConfig(
data: Partial<GitLabIntegrationConfig>,
): Promise<Config> {
const schema = await loadConfigSchema({
const fullSchema = await loadConfigSchema({
dependencies: [require('../../package.json').name],
});
const serializedSchema = fullSchema.serialize() as {
schemas: { path: string }[];
};
const schema = await loadConfigSchema({
serialized: {
...serializedSchema, // grab the schema from this package only
schemas: serializedSchema.schemas.filter(s => s.path === 'config.d.ts'),
},
});
const processed = schema.process(
[{ data: { integrations: { gitlab: [data] } }, context: 'app' }],
{ visibility: ['frontend'] },