forked from renovatebot/renovate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugins.ts
49 lines (48 loc) · 1.33 KB
/
plugins.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { query as q } from 'good-enough-parser';
import { regEx } from '../../../../util/regex';
import type { Ctx } from '../types';
import {
cleanupTempVars,
qStringValue,
qVersion,
storeInTokenMap,
storeVarToken,
} from './common';
import { handlePlugin } from './handlers';
export const qPlugins = q
.sym(regEx(/^(?:id|kotlin)$/), storeVarToken)
.handler((ctx) => storeInTokenMap(ctx, 'methodName'))
.alt(
// id "foo.bar" version "1.2.3"
qStringValue
.handler((ctx: Ctx) => storeInTokenMap(ctx, 'pluginName'))
.sym('version')
.join(qVersion),
// kotlin("jvm") version "1.3.71"
q
.tree({
type: 'wrapped-tree',
maxDepth: 1,
startsWith: '(',
endsWith: ')',
search: q.begin<Ctx>().join(qStringValue).end(),
})
.handler((ctx) => storeInTokenMap(ctx, 'pluginName'))
.alt(
// id("foo.bar") version "1.2.3"
q.sym<Ctx>('version').join(qVersion),
// id("foo.bar").version("1.2.3")
// id("foo.bar") version("1.2.3")
q
.opt(q.op<Ctx>('.'))
.sym('version')
.tree({
maxDepth: 1,
startsWith: '(',
endsWith: ')',
search: q.begin<Ctx>().join(qVersion).end(),
}),
),
)
.handler(handlePlugin)
.handler(cleanupTempVars);