Skip to content

renovate.star

Edit Renovate configs: presets, package rules, schedules and other settings.

Works on JSON configs (renovate.json, .github/renovate.json, .renovaterc and .renovaterc.json), keeping key order and indentation. JSON5 configs can't be edited this way and are skipped by find.

load("@fleet//renovate.star", "find", "add_preset", "remove_preset", "replace_preset", "add_package_rule", "set_option")
Function What it does
find Finds the repo's Renovate config.
add_preset Adds a preset to extends unless it is already there.
remove_preset Removes a preset from extends, such as a retired config:base.
replace_preset Replaces a preset in extends where it is, such as config:base with config:recommended.
add_package_rule Appends a rule to packageRules unless an identical rule is already there.
set_option Sets a top-level or nested option, such as schedule or lockFileMaintenance.enabled.

find

find(repo)

Finds the repo's Renovate config.

Arguments

Name Description
repo The repo passed to change(repo).

Returns: The path of the first JSON config that exists, or None.

Example

find(repo)
# returns ".github/renovate.json"

.github/renovate.json

{}

Source

add_preset

add_preset(repo, preset)

Adds a preset to extends unless it is already there.

Arguments

Name Description
repo The repo passed to change(repo).
preset The preset, such as config:recommended or github>acme/renovate-config.

Returns: True when the file changed.

Example

add_preset(repo, "github>acme/renovate-config")
# returns True

renovate.json

{
  "extends": ["config:recommended"]
}

renovate.json

{
  "extends": ["config:recommended", "github>acme/renovate-config"]
}

Source

remove_preset

remove_preset(repo, preset)

Removes a preset from extends, such as a retired config:base.

Arguments

Name Description
repo The repo passed to change(repo).
preset The preset to remove.

Returns: True when the file changed.

Example

remove_preset(repo, "config:base")
# returns True

renovate.json

{"extends": ["config:base", ":semanticCommits"]}

renovate.json

{"extends": [":semanticCommits"]}

Source

replace_preset

replace_preset(repo, old, new)

Replaces a preset in extends where it is, such as config:base with config:recommended.

When new is already there too, old is just removed.

Arguments

Name Description
repo The repo passed to change(repo).
old The preset to replace.
new The preset to put in its place.

Returns: True when the file changed.

Example

replace_preset(repo, "config:base", "config:recommended")
# returns True

renovate.json

{
  "extends": ["config:base", ":semanticCommits"]
}

renovate.json

{
  "extends": ["config:recommended", ":semanticCommits"]
}

Used in: renovate-automerge

Source

add_package_rule

add_package_rule(repo, rule)

Appends a rule to packageRules unless an identical rule is already there.

Arguments

Name Description
repo The repo passed to change(repo).
rule The rule, a dict such as {"matchUpdateTypes": ["patch"], "automerge": True}.

Returns: True when the file changed.

Example

add_package_rule(repo, {"matchDepTypes": ["devDependencies"], "automerge": True})
# returns True

renovate.json

{
  "extends": ["config:recommended"]
}

renovate.json

{
  "extends": ["config:recommended"],
  "packageRules": [
    {
      "matchDepTypes": ["devDependencies"],
      "automerge": true
    }
  ]
}

Used in: renovate-automerge

Source

set_option

set_option(repo, key, value)

Sets a top-level or nested option, such as schedule or lockFileMaintenance.enabled.

Arguments

Name Description
repo The repo passed to change(repo).
key The dotted option path.
value Any JSON value.

Returns: True when the file changed; False when the repo has no config.

Example

set_option(repo, "schedule", ["before 6am on monday"])
# returns True

renovate.json

{
  "extends": ["config:recommended"],
  "schedule": ["at any time"]
}

renovate.json

{
  "extends": ["config:recommended"],
  "schedule": ["before 6am on monday"]
}

Source