Commit Graph

36 Commits

Author SHA1 Message Date
Sebastian Poxhofer 3412de84ce refactor(linters): enable oxlint rule prefer-named-capture-group (#44714)
* refactor(lint): enable oxlint prefer-named-capture-group at error

Numbered capture groups (m[1], $1) break silently when a regex is
edited and group order shifts. Named groups (?<name>...) make intent
explicit and accesses (m.groups.name) resilient to reordering.

This enables the built-in eslint rule prefer-named-capture-group,
surfacing 321 pre-existing unnamed-group violations across ~121
files to be burned down incrementally in follow-up commits.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(versioning): name capture groups for prefer-named-capture-group

Burns down all prefer-named-capture-group violations in
lib/modules/versioning/. Unused capture groups (only reachable via
.test() or whole-match) become non-capturing (?:...); groups whose
value is read become named (?<name>...), with accesses rewritten to
match.groups!.<name> (or destructured from .groups!) instead of
positional match[n]/$n so a future edit that reorders groups cannot
silently break the reader.

Two cases needed extra care to preserve behavior:
- semver/common.ts and poetry/patterns.ts split() on a regex whose
  capture group is relied upon by String.prototype.split to keep the
  separator in the output array; the group is kept capturing and
  named, not converted to non-capturing.
- hashicorp/convertor.ts's semverRegex is only ever embedded via
  .source into a named `(?<version>...)` group elsewhere and never
  matched directly, so its internal groups are safe to make
  non-capturing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(datasource): name capture groups for prefer-named-capture-group

Burns down all prefer-named-capture-group violations under
lib/modules/datasource/. Same treatment as the versioning module:
unused groups become non-capturing, used groups get names, and
positional match[n] reads move to match.groups!.<name>.

docker/ecr.ts and pypi/common.ts keep their positional destructuring
(`const [, region] = ...`, `!!m &&`) working unchanged since a named
capture group is still addressable by its numeric index in
JavaScript — only pypi/common.ts's access was rewritten to
m.groups!.owner for clarity since it read a single group directly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(platform): name capture groups for prefer-named-capture-group

Burns down all prefer-named-capture-group violations under
lib/modules/platform/. Uses the repo's established idiom of
`match.groups?.<name>` after an optional-chained exec()/match() (see
bitbucket/index.ts hostnameWithoutApiPrefix, gerrit/utils.ts
extractSourceBranch) and `$<name>` in String.replace replacement
strings. Unused groups (markdown/HTML massaging regexes matched only
to be stripped) become non-capturing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(manager): name capture groups in ansible-galaxy for prefer-named-capture-group

Burns down prefer-named-capture-group violations in
lib/modules/manager/ansible-galaxy/. newBlockRegEx and blockLineRegEx
dropped their unused outer wrapping group (only the inner key/value
groups were ever read) and named the key/value groups; nameMatchRegex's
remaining unused groups (protocol/user-info/port alternatives) become
non-capturing since only source/hostname/depName/version are read via
.groups. Accesses in collections.ts and roles.ts move from
lineMatch[2]/lineMatch[3] to lineMatch.groups!.key/value.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(manager): name capture groups for prefer-named-capture-group (batch 1)

Burns down prefer-named-capture-group violations across the first
alphabetical slice of lib/modules/manager/ (ansible through mix).
Used groups get names with accesses rewritten to match.groups!.<name>
(or $<name> in replacement strings); groups whose value is never read
become non-capturing (?:...). Two String.split() call sites
(git-submodules/extract.ts, meteor/extract.ts) keep the established
"named group still readable positionally from the split() result
array" idiom instead of restructuring the destructuring.

bazel/rules/go.ts and buildpacks/extract.ts dockerRef verified
byte-for-byte equivalent before/after via a quick node script since
several nested groups collapsed to non-capturing at once.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(manager): name capture groups for prefer-named-capture-group (batch 2)

Burns down prefer-named-capture-group violations across the remaining
alphabetical slice of lib/modules/manager/ (npm through terragrunt).
Same treatment as batch 1: used groups get names with accesses moved
to match.groups!.<name> or $<name> replacement strings; unused groups
(wrapping alternations, quantifier repetition groups only consumed via
.test(), or values never read from a match) become non-capturing.

terraform/extractors/others/modules.ts and terragrunt/modules.ts share
near-identical URL-parsing regexes (github/bitbucket/git/azure-devops
ref matchers) — the same set of always-unused `depth=`/`&depth=`
query-string groups is converted to non-capturing in both files.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(config): name capture groups for prefer-named-capture-group

Burns down prefer-named-capture-group violations in lib/config/.
Used groups get names with replacement strings switched from $1/$2 to
$<name>; the unused separator group in schedule-migration.ts's
afterBeforeRegex becomes non-capturing. presets/parse.ts keeps
assigning through the already-declared `repo` variable rather than
array-destructuring the exec() result, matching this file's existing
style for the other named-group regexes just above it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(util): name capture groups for prefer-named-capture-group

Burns down prefer-named-capture-group violations across lib/util/ and
lib/logger/. Same treatment as previous batches: named groups for
values that are read (via $<name> replacement strings, .groups!.<name>,
or destructured from .groups), non-capturing groups where nothing reads
the captured value (e.g. semantic.ts's angular-commit .test()-only
regex). www-authenticate.ts's tokenizer entries each get their own
named group but keep accessing the match generically via match[1],
since a positionally-indexed named group is still readable by index.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(workers): name capture groups for prefer-named-capture-group

Burns down prefer-named-capture-group violations in lib/workers/.
Used groups get names with $<name> replacement strings; unused
wrapper/alternation groups (e.g. semantic-commit-message.ts's optional
scope/issue wrappers, release-notes.ts's date-heading and
horizontal-rule matchers that are only probed with .search()/replaced
wholesale) become non-capturing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* refactor(test,tools): name capture groups for prefer-named-capture-group

Finishes the prefer-named-capture-group burndown: test/, tools/, and
vitest.config.mts. Groups whose value is read get names ($<name>
replacement strings or .groups.<name> access); groups only used via
.test()/.search() or that feed a .match(/…/g) call (whose return value
is the array of whole matches, not captured groups) become
non-capturing.

This is the last remaining slice of pre-existing violations, so the
rule (already enabled at error repo-wide) now passes with zero
findings across the whole codebase.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RxHFNsSworLcv23xXk9Hk

* fix prettier failure

* refactor(lint): use a named capture group in `v8-ignore-no-count`

New rule from main trips the newly enabled `prefer-named-capture-group` oxlint rule.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-03 09:54:40 +00:00
Felipe Santos 2606ae2bd3 feat(pypi): add support for JSON-based Simple API (PEP 691) (#44222)
* feat(pypi): add support for JSON-based Simple API (PEP 691)

* Fix some stuff

* Clean some things up

* Fix coverage

* Simplify JSON parse

* Remove useless tests

* Align terminology

* Incorporate some changes from PR #44182

Co-authored-by: Andreas Hippler <andreas.hippler@goto.com>

* Use isNonEmptyString to filter requires_python

* Address review feedback

* Warn once actually

* fixup! review comments

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

* fixup! fixup! review comments

Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>

* fixup! review comments

As the list of status codes we retry on was based on an unverified
claim that Artifactory, Nexus and devpi answer a rejected `Accept`
header with `400`/`403`/`415`, we should only retry on `406`, which is
what RFC 9110 specifies for a request whose `Accept` cannot be
satisfied.

Our `Accept` header ends with `text/html; q=0.01`, so any conforming
registry can satisfy it, `415` refers to the request body's
`Content-Type` rather than `Accept`, and retrying on `403` doubles the
requests for a registry we're not authenticated against.

The unwrapping of `ExternalHostError` is unaffected, as that's needed
for the `abortOnError` case regardless of which status codes we retry.

Co-Authored-By: Claude Opus 5 <claude-code@jamietanna.co.uk>

* fixup! review comments

As the note about `upload-time` sat in the paragraph about the Simple
API, it read as if `minimumReleaseAge` needs a registry which supports
the JSON-based Simple API (PEP 691).

That's only true of the Simple API. The JSON API has always exposed
`upload_time`, and as the default registry of `https://pypi.org/pypi/`
doesn't end in `/simple/`, that's the lookup most users get, so
`minimumReleaseAge` already works for them.

We can split the two apart, so that the guarantee for each API is
stated separately.

Co-Authored-By: Claude Opus 5 <claude-code@jamietanna.co.uk>

* reword

* fixup! review comments

As the JSON-based Simple API's release timestamps were only covered by
hand-written responses, we didn't have the equivalent of the real world
coverage added for the JSON API in
e942788539.

We can add a `numpy` fixture from PyPI's JSON-based Simple API, trimmed
to 1.5.0 and 1.5.1, so we assert against a response a registry has
actually served. 1.5.1 is the interesting case, as it was released in
2010 but gained a wheel in 2014 which PyPI lists first.

This also covers the `upload-time` format the Simple API uses, of
`2010-11-18T14:16:58.801332Z`, rather than the JSON API's
`2010-11-18T14:16:58`, so that we know `asTimestamp` normalises both.

Unlike the JSON API, there's no previous behaviour to characterise
first, as before these changes the Simple API exposed no timestamps at
all.

Co-Authored-By: Claude Opus 5 <claude-code@jamietanna.co.uk>

* fixup! fixup! review comments

* fixups

* fixups

Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>

* fixup! comments

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

---------

Co-authored-by: Andreas Hippler <andreas.hippler@goto.com>
Co-authored-by: Jamie Tanna <jamie.tanna@mend.io>
Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
Co-authored-by: Claude Opus 5 <claude-code@jamietanna.co.uk>
2026-08-18 09:03:12 +00:00
Jamie Tanna e942788539 fix(datasource/pypi): use the earliest upload_time of a version (#45313)
* test(datasource/pypi): cover which `upload_time` a version reports

As part of future changes to how we calculate the `releaseTimestamp`, it
was clear we don't have as much coverage of this logic.

To make this more explicit, we can add new test coverage.

Additionally, we can introduce a new example from a package to guide
this.

Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>

* fix(datasource/pypi): use the earliest `upload_time` of a version

When calculating the `releaseTimestamp` for the PyPI datasource, we've
been looking at the first entry in the response, which isn't always
the first time this package existed.

In the case that a Wheel is uploaded after the package first was
released - for instance, to support a new version of Python, at an
existing pinned version of the package - this would lead to a
potentially incorrect calculation for the `releaseTimestamp`.

This can lead to Renovate seeing a package as newer than it is, which
can mean that i.e. `minimumReleaseAge` can show as pending for a package
that shouldn't be.

As part of upstream changes[0], this should be less frequent in the
ecosystem, but existing packages still exist with this behaviour.

To fix this, we can make sure that we filter a given Release's
to find the earliest `upload_time`.

Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>

[0]: https://blog.pypi.org/posts/2026-07-22-releases-now-reject-new-files-after-14-days/

---------

Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
2026-08-17 11:01:26 +00:00
Sebastian Poxhofer 5835388020 fix(conda/pypi): allow nullable strings (#43834)
* fix(conda/pypi): allow nullable strings

* fix failing tests from main
2026-06-05 15:46:24 +00:00
Sebastian Poxhofer c908d078ef fix(datasource): replace getJsonUnchecked in npm/Node/PyPI/Go (#43699)
* fix(datasource): replace getJsonUnchecked with validated getJson in npm/Node/PyPI/Go

Replace all getJsonUnchecked calls in npm, Node.js, PyPI, and Go datasources
with Zod-validated getJson calls:

- datasource/npm: add NpmResponseSchema to schema.ts (shared with presets)
- config/presets/npm: migrate to NpmResponseSchema with passthrough version fields
- datasource/node-version: add NodeReleasesSchema using LooseArray
- datasource/pypi: add PypiJSONSchema (nullable+catch for lenient empty-body handling)
- datasource/go: add VersionInfoSchema for both versionInfo and getLatestVersion calls

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* some manual cleaning up

* removing schema level catch

* removing some more types

* refactor: rename schema

* fix linter errors

* remove schema suffix which hasn't been catched by linter

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-03 19:14:50 +00:00
Maxime Brunet 459db80b94 fix(datasource/pypi): sanitize GAR userinfo for authenticated lookups (#42541)
* fix(datasource/pypi): sanitize GAR userinfo for authenticated lookups

Strip URL userinfo from Google Artifact Registry PyPI lookup URLs only when
Google auth is being applied. This avoids got-derived Basic auth conflicts for
uv-style index URLs while keeping the change narrowly scoped to authenticated
datasource requests.

* Test getAuthHeaders with invalid URL

* Parse the URL once

* Remove cast and ignore error

* Remove test and add v8 ignore comment

---------

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2026-04-21 06:19:56 +00:00
Michael Bruns dc4d997aa2 docs: clarify pypi simple registry release timestamp behaviour (#40916) 2026-02-11 21:31:20 +00:00
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00
RahulGautamSingh 18bd32166b chore: replace URL.resolve (#40702)
replace URL.resolve
2026-01-26 18:59:54 +00:00
RahulGautamSingh 76f911041a refactor: use named exports (#39196)
* use named exports

* fix test

* add missing imnport

* fix prettier
2025-11-10 12:00:35 +00:00
RahulGautamSingh c2dbf0b287 docs(pypi): clarify minimumReleaseAge is supported (#38717)
fix(docs/pypi): correct minimumReleaseAge support status
2025-10-20 16:53:04 +00:00
RahulGautamSingh 49fa1be464 feat(util): getEnv (#35161)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-05-06 18:37:28 +00:00
Michael Kriese 593a92655e feat: refactor http (#34550) 2025-02-28 14:40:04 +00:00
Sergei Zharinov a33d3eab9e feat: Switch to Timestamp type (#33648) 2025-01-22 20:15:25 +00:00
Sergei Zharinov 9b4e515024 refactor(http): Separate getJson and getJsonUnchecked (#33651) 2025-01-17 14:18:00 +00:00
Rhys Arkins c868ed0634 feat(datasource/pypi): always fallback to try simple endpoints (#32024) 2024-11-27 08:57:59 +00:00
Maxime Brunet 0049a94180 feat(pypi): support GCloud credentials for Google Artifact Registry (#31262) 2024-09-14 05:59:16 +00:00
Tobias 5ff077854b fix(datasource/pypi): handle non-normalized package names for pypi simple lookup (#30716)
Co-authored-by: Norbert Szulc <norbert@not7cd.net>
2024-08-14 14:16:40 +00:00
Rhys Arkins 6d30cc9680 fix(pypi): add .tgz extension (#29956) 2024-07-01 06:18:32 +00:00
Rhys Arkins eaaeb47b59 fix(pypi): support additional file name extensions (#29839)
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
2024-06-25 12:13:35 +00:00
RahulGautamSingh d0b77e584a feat(datasource): sourceUrl & releaseTimestamp support (#29122) 2024-05-21 07:04:12 +00:00
Rhys Arkins abc61d644f fix(pypi): filter string only and deduplicate (#28865) 2024-05-06 11:31:06 +00:00
Norbert Szulc dbd17ed1d7 refactor(datasource/pypi): rename normalization function (#28584) 2024-04-22 15:37:37 +00:00
Norbert Szulc 0ba9e35fcc feat(manager/pip-compile): Add lockedVersion to package file deps (#27242)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-02-15 12:07:20 +00:00
Maksym Romanowski a025178e71 fix(pypi): trim simple repo markup with extra whitespaces and new lines (#27013)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-02-02 10:15:28 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Michael Kriese 2431c5a6b6 fix: better branch code coverage (#24274) 2023-09-06 13:35:52 +00:00
Rhys Arkins 36e2b328bb chore: update types reference 2023-08-15 11:31:15 +02:00
Sebastian Poxhofer 019c75caab feat(manager/pep621): implement manager (#22082)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2023-05-15 07:51:05 +00:00
Jamie Magee 176282e65f chore: use node: protocol imports (#21181) 2023-03-28 21:05:36 +00:00
Gabriel-Ladzaretti dc11e26c37 fix(datasource/pypi): use pypi.org/pypi registry instead of pypi.org/simple (#16293)
* fix(datasource/pypi): use pypi api instead of the simple variant

* fix(datasource/pypi): use pypi api instead of the simple variant

* fix(datasource/pypi): use pypi api instead of the simple variant

* fix(datasource/pypi): use pypi api instead of the simple variant

* Update lib/modules/datasource/pypi/index.ts

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-06-29 07:26:46 +02:00
Michael Kriese 10302eba68 refactor: fix prefer-nullish-coalescing (#16171) 2022-06-21 12:02:49 +00:00
wwuck df70d37141 fix(pypi): package name with periods (#15867) 2022-06-18 06:15:10 +00:00
Michael Kriese 02838fbc07 refactor(datasources): strict null checks done (#15144) 2022-04-16 12:57:12 +01:00
Rhys Arkins 143c9a6751 refactor: rename lookupName -> packageName (#14494)
Renames `lookupName` to be `packageName`.

BREAKING CHANGE: Use `packageName` instead of `lookupName` if interacting with Renovate datasources directly.
2022-03-04 09:04:02 +01:00
Rhys Arkins dca3418bbd refactor: lib/modules (#14488)
Moves datasource, manager, platform and versioning code from lib/ into new lib/modules/

BREAKING CHANGE: External tools must update paths to datasource, manager, platform and versioning
2022-03-04 09:04:02 +01:00