Skip to content

Commit

Permalink
refactor: config/definitions -> config/options
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Aug 17, 2021
1 parent bb37aa8 commit 750bc16
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion bin/create-json-schema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const upath = require('upath');
const { getOptions } = require('../lib/config/definitions');
const { getOptions } = require('../lib/config/options');

const schema = {
title: 'JSON schema for Renovate config files (https://renovatebot.com/)',
Expand Down
4 changes: 2 additions & 2 deletions docs/development/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The above are listed in **_reverse order_** of preference. e.g. CLI values will

### Default Configuration

The default configuration values can be found in [lib/config/definitions.ts](../../lib/config/definitions.ts).
The default configuration values can be found in [lib/config/options/index.ts](../../lib/config/options/index.ts).
Options which have `"admin": true` are reserved only for bot admin configuration and cannot be configured within repository config files.

### Configuration File
Expand Down Expand Up @@ -75,4 +75,4 @@ If you add configuration options to your `package.json` then these will override

Please see [https://docs.renovatebot.com/configuration-options/](https://docs.renovatebot.com/configuration-options/) for a list of user-facing configuration options.

For further options when running your own instance of Renovate, please see the full config definitions file at `lib/config/definitions.ts`.
For further options when running your own instance of Renovate, please see the full config options file at `lib/config/options/index.ts`.
2 changes: 1 addition & 1 deletion docs/development/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ The example command will delete any existing `debug.log` and then save Renovate'
We want stay backwards-compatible as much as possible, as well as make the code configurable.
So most new functionality should be controllable via configuration options.

Create your new configuration option in the `lib/config/definitions.ts` file.
Create your new configuration option in the `lib/config/options/index.ts` file.
Also create documentation for the option in the `website/docs/configuration-options.md` file.

## Debugging
Expand Down
2 changes: 1 addition & 1 deletion lib/config/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getOptions } from './definitions';
import { getOptions } from './options';
import type { AllConfig, RenovateOptions } from './types';

const defaultValues = {
Expand Down
4 changes: 2 additions & 2 deletions lib/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logger } from '../logger';
import { get, getLanguageList, getManagerList } from '../manager';
import * as definitions from './definitions';
import * as options from './options';
import type {
AllConfig,
ManagerConfig,
Expand Down Expand Up @@ -41,7 +41,7 @@ export function filterConfig(
const outputConfig: RenovateConfig = { ...inputConfig };
const stages = ['global', 'repository', 'package', 'branch', 'pr'];
const targetIndex = stages.indexOf(targetStage);
for (const option of definitions.getOptions()) {
for (const option of options.getOptions()) {
const optionIndex = stages.indexOf(option.stage);
if (optionIndex !== -1 && optionIndex < targetIndex) {
delete outputConfig[option.name];
Expand Down
2 changes: 1 addition & 1 deletion lib/config/massage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import is from '@sindresorhus/is';
import { clone } from '../util/clone';
import { getOptions } from './definitions';
import { getOptions } from './options';
import type { PackageRule, RenovateConfig, UpdateType } from './types';

const options = getOptions();
Expand Down
2 changes: 1 addition & 1 deletion lib/config/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { dequal } from 'dequal';
import { logger } from '../logger';
import { clone } from '../util/clone';
import { getAdminConfig } from './admin';
import { getOptions } from './definitions';
import { getOptions } from './options';
import { removedPresets } from './presets/common';
import type {
MigratedConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getName } from '../../test/util';
import { getOptions } from './definitions';
import { getName } from '../../../test/util';
import { getOptions } from '.';

jest.mock('../manager', () => ({
jest.mock('../../manager', () => ({
getManagers: jest.fn(() => new Map().set('testManager', {})),
}));

Expand Down
14 changes: 7 additions & 7 deletions lib/config/definitions.ts → lib/config/options/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PLATFORM_TYPE_GITHUB } from '../constants/platforms';
import { getManagers } from '../manager';
import { getPlatformList } from '../platform';
import { getVersioningList } from '../versioning';
import * as dockerVersioning from '../versioning/docker';
import * as pep440Versioning from '../versioning/pep440';
import type { RenovateOptions } from './types';
import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms';
import { getManagers } from '../../manager';
import { getPlatformList } from '../../platform';
import { getVersioningList } from '../../versioning';
import * as dockerVersioning from '../../versioning/docker';
import * as pep440Versioning from '../../versioning/pep440';
import type { RenovateOptions } from '../types';

const options: RenovateOptions[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions lib/config/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logger } from '../logger';
import { clone } from '../util/clone';
import * as definitions from './definitions';
import * as options from './options';
import type { RenovateConfig } from './types';

export function mergeChildConfig<T, TChild>(
Expand All @@ -14,7 +14,7 @@ export function mergeChildConfig<T, TChild>(
const parentConfig = clone(parent);
const childConfig = clone(child);
const config: Record<string, any> = { ...parentConfig, ...childConfig };
for (const option of definitions.getOptions()) {
for (const option of options.getOptions()) {
if (
option.mergeable &&
childConfig[option.name] &&
Expand Down
2 changes: 1 addition & 1 deletion lib/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { getLanguageList, getManagerList } from '../manager';
import { configRegexPredicate, isConfigRegex, regEx } from '../util/regex';
import * as template from '../util/template';
import { hasValidSchedule, hasValidTimezone } from '../workers/branch/schedule';
import { getOptions } from './definitions';
import { migrateConfig } from './migration';
import { getOptions } from './options';
import { resolveConfigPresets } from './presets';
import type {
RenovateConfig,
Expand Down
2 changes: 1 addition & 1 deletion lib/util/template/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getName } from '../../../test/util';
import { getOptions } from '../../config/definitions';
import { getOptions } from '../../config/options';
import * as template from '.';

describe(getName(), () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/versioning/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getOptions } from '../config/definitions';
import { getOptions } from '../config/options';
import { loadModules } from '../util/modules';
import { isVersioningApiConstructor } from './common';
import { GenericVersion, GenericVersioningApi } from './loose/generic';
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/global/config/parse/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command } from 'commander';
import { version } from '../../../../../package.json';
import { getOptions } from '../../../../config/definitions';
import { getOptions } from '../../../../config/options';
import type { AllConfig, RenovateOptions } from '../../../../config/types';

export function getCliName(option: Partial<RenovateOptions>): string {
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/global/config/parse/env.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import is from '@sindresorhus/is';

import { getOptions } from '../../../../config/definitions';
import { getOptions } from '../../../../config/options';
import type { AllConfig, RenovateOptions } from '../../../../config/types';
import { PLATFORM_TYPE_GITHUB } from '../../../../constants/platforms';
import { getDatasourceList } from '../../../../datasource';
Expand Down
8 changes: 4 additions & 4 deletions test/website-docs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import { getOptions } from '../lib/config/definitions';
import { getOptions } from '../lib/config/options';

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('docs', () => {
expect(headers3).toEqual(expectedOptions3);
});

// Checking relatedOptions field in definitions
// Checking relatedOptions field in options
const relatedOptionsMatrix = options
.filter((option) => option.relatedOptions)
.map((option) => option.relatedOptions)
Expand All @@ -89,13 +89,13 @@ describe('docs', () => {
if (received.includes(argument)) {
return {
message: (): string =>
`Option "${argument}" should be within definitions`,
`Option "${argument}" should be within options`,
pass: true,
};
}
return {
message: (): string =>
`Option "${argument}" doesn't exist within definitions`,
`Option "${argument}" doesn't exist within options`,
pass: false,
};
},
Expand Down

0 comments on commit 750bc16

Please sign in to comment.