mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 14:36:25 +00:00
parent
5c9c527f38
commit
8124634b6a
3 changed files with 1149 additions and 0 deletions
94
bin/create-json-schema.js
Normal file
94
bin/create-json-schema.js
Normal file
|
@ -0,0 +1,94 @@
|
|||
const fs = require('fs');
|
||||
const upath = require('upath');
|
||||
const { getOptions } = require('../lib/config/definitions');
|
||||
|
||||
const types = {
|
||||
list: 'array',
|
||||
json: 'object',
|
||||
object: 'object',
|
||||
integer: 'integer',
|
||||
string: 'string',
|
||||
boolean: 'boolean',
|
||||
};
|
||||
|
||||
const schema = {
|
||||
title: 'JSON schema for Renovate config files (https://renovatebot.com/)',
|
||||
$schema: 'http://json-schema.org/draft-04/schema#',
|
||||
type: 'object',
|
||||
properties: {},
|
||||
};
|
||||
const options = getOptions();
|
||||
const properties = {};
|
||||
|
||||
function createSingleConfig(option) {
|
||||
const temp = {};
|
||||
temp.type = types[option.type];
|
||||
if (temp.type === 'object') {
|
||||
temp.$ref = '#';
|
||||
}
|
||||
if (temp.type === 'array' && option.subType) {
|
||||
temp.items = {
|
||||
type: types[option.subType],
|
||||
};
|
||||
}
|
||||
if (option.format) {
|
||||
temp.format = option.format;
|
||||
}
|
||||
if (option.description) {
|
||||
temp.description = option.description;
|
||||
}
|
||||
if (option.default) {
|
||||
temp.default = option.default;
|
||||
}
|
||||
if (option.allowedValues) {
|
||||
temp.enum = option.allowedValues;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
function createSchemaForParentConfigs() {
|
||||
for (const option of options) {
|
||||
if (!option.parent) {
|
||||
properties[option.name] = createSingleConfig(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addChildrenArrayInParents() {
|
||||
for (const option of options) {
|
||||
if (option.parent) {
|
||||
properties[option.parent].items = {
|
||||
allOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createSchemaForChildConfigs() {
|
||||
for (const option of options) {
|
||||
if (option.parent) {
|
||||
properties[option.parent].items.allOf[0].properties[
|
||||
option.name
|
||||
] = createSingleConfig(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generateSchema() {
|
||||
createSchemaForParentConfigs();
|
||||
addChildrenArrayInParents();
|
||||
createSchemaForChildConfigs();
|
||||
schema.properties = properties;
|
||||
fs.writeFileSync(
|
||||
upath.join(__dirname, '../renovate-schema.json'),
|
||||
JSON.stringify(schema, null, 2),
|
||||
'utf-8'
|
||||
);
|
||||
}
|
||||
|
||||
generateSchema();
|
|
@ -11,6 +11,7 @@ const options = [
|
|||
'Configuration presets to use/extend. Note: does not work if configured in config.js',
|
||||
stage: 'package',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
cli: false,
|
||||
},
|
||||
|
@ -20,6 +21,7 @@ const options = [
|
|||
'A list of presets to ignore, including nested ones inside `extends`',
|
||||
stage: 'package',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
cli: false,
|
||||
},
|
||||
|
@ -27,6 +29,7 @@ const options = [
|
|||
name: 'description',
|
||||
description: 'Plain text description for a config or preset',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
stage: 'repository',
|
||||
allowString: true,
|
||||
mergeable: true,
|
||||
|
@ -176,6 +179,7 @@ const options = [
|
|||
name: 'schedule',
|
||||
description: 'Times of day/week to limit branch creation to',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
cli: true,
|
||||
env: false,
|
||||
|
@ -408,6 +412,7 @@ const options = [
|
|||
description:
|
||||
'List of languages to match (e.g. ["python"]). Valid only within `packageRules` object',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
parent: 'packageRules',
|
||||
stage: 'package',
|
||||
|
@ -420,6 +425,7 @@ const options = [
|
|||
description:
|
||||
'List of branches to match (e.g. ["master"]). Valid only within `packageRules` object',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
parent: 'packageRules',
|
||||
stage: 'package',
|
||||
|
@ -432,6 +438,7 @@ const options = [
|
|||
description:
|
||||
'List of package managers to match (e.g. ["pipenv"]). Valid only within `packageRules` object',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
parent: 'packageRules',
|
||||
stage: 'package',
|
||||
|
@ -444,6 +451,7 @@ const options = [
|
|||
description:
|
||||
'List of datasources to match (e.g. ["orb"]). Valid only within `packageRules` object',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
parent: 'packageRules',
|
||||
stage: 'package',
|
||||
|
@ -456,6 +464,7 @@ const options = [
|
|||
description:
|
||||
'List of depTypes to match (e.g. [`peerDependencies`]). Valid only within `packageRules` object',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
parent: 'packageRules',
|
||||
stage: 'package',
|
||||
|
@ -468,6 +477,7 @@ const options = [
|
|||
description:
|
||||
'Package names to match. Valid only within `packageRules` object',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
stage: 'package',
|
||||
parent: 'packageRules',
|
||||
|
@ -480,6 +490,7 @@ const options = [
|
|||
description:
|
||||
'Package names to exclude. Valid only within `packageRules` object',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
stage: 'package',
|
||||
parent: 'packageRules',
|
||||
|
@ -492,6 +503,7 @@ const options = [
|
|||
description:
|
||||
'Package name patterns to match. Valid only within `packageRules` object.',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
stage: 'package',
|
||||
parent: 'packageRules',
|
||||
|
@ -504,6 +516,7 @@ const options = [
|
|||
description:
|
||||
'Package name patterns to exclude. Valid only within `packageRules` object.',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
stage: 'package',
|
||||
parent: 'packageRules',
|
||||
|
@ -527,6 +540,7 @@ const options = [
|
|||
description:
|
||||
'A list of source URL prefixes to match against, commonly used for grouping of monorepos or packages from the same organization.',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
stage: 'package',
|
||||
parent: 'packageRules',
|
||||
|
@ -539,6 +553,7 @@ const options = [
|
|||
description:
|
||||
'Update types to match against (major, minor, pin, etc). Valid only within `packageRules` object.',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
allowString: true,
|
||||
stage: 'package',
|
||||
parent: 'packageRules',
|
||||
|
@ -613,6 +628,7 @@ const options = [
|
|||
description: 'Regex for identifying unstable versions (docker only)',
|
||||
stage: 'package',
|
||||
type: 'string',
|
||||
format: 'regex',
|
||||
cli: false,
|
||||
env: false,
|
||||
},
|
||||
|
@ -1021,6 +1037,8 @@ const options = [
|
|||
name: 'fileMatch',
|
||||
description: 'JS RegExp pattern for matching manager files',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
format: 'regex',
|
||||
stage: 'repository',
|
||||
allowString: true,
|
||||
mergeable: true,
|
||||
|
@ -1190,6 +1208,7 @@ const options = [
|
|||
description:
|
||||
'Dependency support policy, e.g. used for LTS vs non-LTS etc (node-only)',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
stage: 'package',
|
||||
allowString: true,
|
||||
},
|
||||
|
@ -1534,6 +1553,7 @@ const options = [
|
|||
description:
|
||||
'List of additional notes/templates to be included in the Pull Request bodies.',
|
||||
type: 'list',
|
||||
subType: 'string',
|
||||
default: [],
|
||||
allowString: true,
|
||||
mergeable: true,
|
||||
|
|
1035
renovate-schema.json
Normal file
1035
renovate-schema.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue