mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
55a7341be2
* test(manager): close azure-pipelines, bundler and cocoapods gaps Adds a pipeline whose step task is not versioned, so nothing is extracted, and a gem lock line carrying no version, which is skipped. Marks four guards that cannot be false: `extractContainer()` always returns a dep, `getLockFilePath()` always returns a path, and the cocoapods dep name, spec name and git account all derive from values their enclosing check already proved present. Co-Authored-By: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(manager): close cargo, composer and cpanfile gaps Adds a composer repository map that disables something other than packagist, which is dropped rather than recorded. Marks five guards: the cargo warning only fires for a crate dep and its retry only runs when a dep was already current, a gitlab rule without a token never passes the auth check, and both cpanfile handlers run only once their match produced a value. Two implicit elses stay counted, in the cargo version resolver and the composer repository mapper, since a coverage-ignore hint does not attach to an `else if`. Co-Authored-By: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(manager): close deps-edn, docker-compose and dockerfile gaps Adds three extractions: a deps.edn alias whose value is not a map, a compose extension carrying no image, and a dockerfile escape directive naming a character other than a backtick, which leaves the default in place. Marks the deps-edn repository name check, since object keys are always strings, and notes the repository spec chain, where a coverage-ignore hint does not attach to an `else if`. Co-Authored-By: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(manager/flux): close the flux coverage gaps Adds two GitRepository resources whose url is ssh rather than http, one pinned to a tag and one to a commit. Neither yields a source url, since only http urls can be turned into one. Marks the Kustomization image guard: the schema rejects an image without a name, so `extractImage()` cannot return null there. Co-Authored-By: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(manager): mark github-actions, gitlabci and glasskube guards None of these six needs a test. A parsed action ref is either a docker or a repository ref, `getDep()` always returns a dep for a job container and a service, and the remaining three need a listed file that cannot be read, a listed file that yields no deps, or a manifest whose repositories match no name. The glasskube resource kind chain stays counted, since a coverage-ignore hint does not attach to an `else if`. Co-Authored-By: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(manager): mark gomod and gradle-wrapper guards Four guards that need setups no test provides: a removed dep that is not added back, a go.mod the replace massaging leaves unchanged, and a daemon-jvm file carrying no toolchain version. A parsed go directive always yields a version. The additional-dependency count chain stays counted, since a coverage-ignore hint does not attach to an `else if`. Co-Authored-By: Claude Opus 5 <michael.kriese+claude-code@mend.io> --------- Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io>
157 lines
3.9 KiB
TypeScript
157 lines
3.9 KiB
TypeScript
import { query as q } from '@renovatebot/good-enough-parser';
|
|
import { regEx } from '../../../util/regex.ts';
|
|
import { CpanDatasource } from '../../datasource/cpan/index.ts';
|
|
import { GithubTagsDatasource } from '../../datasource/github-tags/index.ts';
|
|
import * as perlVersioning from '../../versioning/perl/index.ts';
|
|
import type { PackageDependency } from '../types.ts';
|
|
import { cpanfile } from './language.ts';
|
|
|
|
interface Ctx {
|
|
deps: PackageDependency[];
|
|
|
|
perlVersion?: string;
|
|
|
|
phase?: string;
|
|
tempPhase?: string;
|
|
|
|
depName?: string;
|
|
currentValue?: string;
|
|
}
|
|
|
|
// requires perl, '5.36.1';
|
|
// requires 'perl' => 5.036001;
|
|
const perlVersionMatch = q
|
|
.sym<Ctx>('requires')
|
|
.alt(q.sym('perl'), q.str('perl'))
|
|
.alt(q.op(','), q.op('=>'))
|
|
.alt(
|
|
q.num<Ctx>((ctx, { value: perlVersion }) => ({ ...ctx, perlVersion })),
|
|
q.str<Ctx>((ctx, { value: perlVersion }) => ({ ...ctx, perlVersion })),
|
|
)
|
|
.op(';')
|
|
.handler((ctx) => {
|
|
// v8 ignore else -- the matched alternatives above always set it
|
|
if (ctx.perlVersion) {
|
|
ctx.deps.push({
|
|
depName: 'perl',
|
|
packageName: 'Perl/perl5',
|
|
currentValue: ctx.perlVersion,
|
|
datasource: GithubTagsDatasource.id,
|
|
versioning: perlVersioning.id,
|
|
extractVersion: '^v(?<version>\\S+)',
|
|
});
|
|
}
|
|
return ctx;
|
|
});
|
|
|
|
const requirementMatch = q.sym<Ctx>(
|
|
regEx(/^(?:requires|recommends|suggests)$/),
|
|
);
|
|
|
|
const phasedRequiresMatch = q.sym<Ctx>(
|
|
regEx(/^(?:configure|build|test|author)_requires$/),
|
|
(ctx, { value: phase }) => {
|
|
ctx.tempPhase = phase
|
|
.replace(regEx(/_requires/), '')
|
|
.replace(regEx(/author/), 'develop');
|
|
return ctx;
|
|
},
|
|
);
|
|
|
|
// requires 'Foo::Bar';
|
|
//
|
|
// requires 'Foo::Bar', '1.23';
|
|
// recommends 'Foo::Bar', '1.23';
|
|
// suggests 'Foo::Bar', '1.23';
|
|
//
|
|
// configure_requires 'Foo::Bar' => 1.023;
|
|
// build_requires 'Foo::Bar' => 1.023;
|
|
// test_requires 'Foo::Bar' => 1.023;
|
|
// author_requires 'Foo::Bar' => 1.023;
|
|
const moduleMatch = q
|
|
.alt(requirementMatch, phasedRequiresMatch)
|
|
.str((ctx, { value: depName }) => ({ ...ctx, depName }))
|
|
.opt(
|
|
q.alt<Ctx>(q.op(','), q.op('=>')).alt(
|
|
q.num<Ctx>((ctx, { value: currentValue }) => ({ ...ctx, currentValue })),
|
|
q.str<Ctx>((ctx, { value }) => {
|
|
const currentValue = value.replace(
|
|
regEx(/^(?:\s*(?:==|>=|>))?\s*v?/),
|
|
'',
|
|
);
|
|
return { ...ctx, currentValue };
|
|
}),
|
|
),
|
|
)
|
|
.op(';')
|
|
.handler((ctx) => {
|
|
const { phase, tempPhase, depName, currentValue } = ctx;
|
|
|
|
delete ctx.tempPhase;
|
|
delete ctx.depName;
|
|
delete ctx.currentValue;
|
|
|
|
// v8 ignore else -- the handler only runs once a module name matched
|
|
if (depName) {
|
|
const dep: PackageDependency = {
|
|
depName,
|
|
};
|
|
if (currentValue) {
|
|
dep.currentValue = currentValue;
|
|
} else {
|
|
dep.skipReason = 'unspecified-version';
|
|
}
|
|
if (phase) {
|
|
dep.depType = phase;
|
|
} else if (tempPhase) {
|
|
dep.depType = tempPhase;
|
|
}
|
|
|
|
dep.datasource = CpanDatasource.id;
|
|
ctx.deps.push(dep);
|
|
}
|
|
|
|
return ctx;
|
|
});
|
|
|
|
const phaseRegex = regEx(/^(?:configure|build|test|runtime|develop)/);
|
|
|
|
const phaseMatch = q.alt<Ctx>(
|
|
q.sym(phaseRegex, (ctx, { value: phase }) => ({ ...ctx, phase })),
|
|
q.str(phaseRegex, (ctx, { value: phase }) => ({ ...ctx, phase })),
|
|
);
|
|
|
|
// on 'configure' => sub {
|
|
// on build => sub {
|
|
// on 'test' => sub {
|
|
// on runtime => sub {
|
|
// on 'develop' => sub {
|
|
const onMatch = q
|
|
.sym<Ctx>('on')
|
|
.join(phaseMatch)
|
|
.op('=>')
|
|
.sym('sub')
|
|
.tree({
|
|
type: 'wrapped-tree',
|
|
maxDepth: 1,
|
|
search: moduleMatch,
|
|
})
|
|
.handler((ctx) => {
|
|
delete ctx.phase;
|
|
return ctx;
|
|
});
|
|
|
|
const query = q.tree<Ctx>({
|
|
type: 'root-tree',
|
|
maxDepth: 4,
|
|
search: q.alt<Ctx>(perlVersionMatch, moduleMatch, onMatch),
|
|
});
|
|
|
|
export function parse(
|
|
content: string,
|
|
): Pick<Ctx, 'deps' | 'perlVersion'> | null {
|
|
return cpanfile.query(content, query, {
|
|
deps: [],
|
|
});
|
|
}
|