mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-31 09:41:46 +00:00
ea8d11b096
* chore(deps): update dependency @oxlint/plugins to v1.78.0 | datasource | package | from | to | | ---------- | --------------- | ------ | ------ | | npm | @oxlint/plugins | 1.72.0 | 1.78.0 | * chore(deps): update dependency oxlint to v1.78.0 Align oxlint with @oxlint/plugins so the plugin types match again, and replace the computed namespace access in validate-schemas.spec.ts that oxlint 1.78 flags via import/namespace. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: secustor <sebastian@poxhofer.at>
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import fs from 'fs-extra';
|
|
import upath from 'upath';
|
|
import { Json } from '../../lib/util/schema-utils/index.ts';
|
|
import { capitalize } from '../../lib/util/string.ts';
|
|
import {
|
|
Abandonments,
|
|
ChangelogUrls,
|
|
Monorepo,
|
|
Replacements,
|
|
SourceUrls,
|
|
} from '../../tools/schemas/schema.ts';
|
|
|
|
const Schemas = {
|
|
Abandonments,
|
|
ChangelogUrls,
|
|
Monorepo,
|
|
Replacements,
|
|
SourceUrls,
|
|
};
|
|
|
|
describe('other/validate-schemas', () => {
|
|
it('validate json files in lib/data against their schemas', async () => {
|
|
const dataFileDir = 'lib/data';
|
|
const schemaDir = 'tools/schemas';
|
|
const schemasAndJsonFiles: {
|
|
schemaName: keyof typeof Schemas;
|
|
dataFileName: string;
|
|
}[] = [];
|
|
|
|
const schemaFiles = (await fs.readdir(schemaDir)).filter(
|
|
(file) => upath.extname(file) === '.json',
|
|
);
|
|
|
|
for (const schemaFile of schemaFiles) {
|
|
const correspondingDataFileName = schemaFile.replace('-schema', '');
|
|
const schemaName = correspondingDataFileName
|
|
.replace('.json', '')
|
|
.split('-')
|
|
.map(capitalize)
|
|
.join('') as keyof typeof Schemas;
|
|
schemasAndJsonFiles.push({
|
|
schemaName,
|
|
dataFileName: correspondingDataFileName,
|
|
});
|
|
}
|
|
|
|
const settledPromises = await Promise.allSettled(
|
|
schemasAndJsonFiles.map(async ({ schemaName, dataFileName }) => {
|
|
const data = Json.parse(
|
|
await fs.readFile(upath.join(dataFileDir, dataFileName), 'utf8'),
|
|
);
|
|
|
|
// validate json data against schema: using parse here instead of safeParse so we throw
|
|
// this leads to a better error message when the assertion fails
|
|
Schemas[schemaName].parse(data);
|
|
}),
|
|
);
|
|
|
|
for (let i = 0; i < settledPromises.length; i++) {
|
|
const { schemaName, dataFileName } = schemasAndJsonFiles[i];
|
|
const res = {
|
|
schemaName,
|
|
dataFileName,
|
|
settledPromise: { reason: undefined, ...settledPromises[i] },
|
|
};
|
|
|
|
expect(res).toMatchObject({
|
|
schemaName,
|
|
dataFileName,
|
|
settledPromise: {
|
|
status: 'fulfilled',
|
|
reason: undefined,
|
|
},
|
|
});
|
|
}
|
|
});
|
|
});
|