@@ -5,10 +5,50 @@ const UrlSchema = z.record(
5
5
z . union ( [ z . string ( ) , z . array ( z . string ( ) ) ] ) ,
6
6
) ;
7
7
8
- const MonorepoSchema = z . object ( {
8
+ export const MonorepoSchema = z . object ( {
9
9
repoGroups : UrlSchema ,
10
10
orgGroups : UrlSchema ,
11
11
patternGroups : UrlSchema ,
12
12
} ) ;
13
13
14
- export { MonorepoSchema } ;
14
+ const PackageRuleSchema = z . object ( {
15
+ matchCurrentVersion : z . string ( ) . optional ( ) ,
16
+ matchDatasources : z . array ( z . string ( ) ) ,
17
+ matchPackageNames : z . array ( z . string ( ) ) ,
18
+ replacementName : z . string ( ) . optional ( ) ,
19
+ replacementVersion : z . string ( ) . optional ( ) ,
20
+ description : z . string ( ) . optional ( ) ,
21
+ replacementNameTemplate : z . string ( ) . optional ( ) ,
22
+ } ) ;
23
+
24
+ const RuleSetSchema = z . object ( {
25
+ description : z . string ( ) ,
26
+ packageRules : z
27
+ . array ( PackageRuleSchema )
28
+ . min ( 1 )
29
+ . refine (
30
+ ( rules ) =>
31
+ rules . some (
32
+ ( rule ) =>
33
+ rule . replacementName !== undefined ||
34
+ rule . replacementNameTemplate !== undefined ,
35
+ ) ,
36
+ {
37
+ message :
38
+ 'At least one package rule must use either the replacementName config option, or the replacementNameTemplate config option' ,
39
+ } ,
40
+ ) ,
41
+ } ) ;
42
+
43
+ const AllSchema = z . object ( {
44
+ description : z . string ( ) ,
45
+ extends : z . array ( z . string ( ) ) ,
46
+ ignoreDeps : z . array ( z . string ( ) ) . optional ( ) ,
47
+ } ) ;
48
+
49
+ export const ReplacementsSchema = z
50
+ . object ( {
51
+ $schema : z . string ( ) ,
52
+ all : AllSchema ,
53
+ } )
54
+ . catchall ( RuleSetSchema ) ;
0 commit comments