@@ -4,7 +4,13 @@ import { join } from "node:path";
4
4
import { argv } from "node:process" ;
5
5
import "@hyperjump/json-schema/draft-2020-12" ;
6
6
import "@hyperjump/json-schema/draft-04" ;
7
- import { compile , getSchema , interpret , Validation , BASIC } from "@hyperjump/json-schema/experimental" ;
7
+ import {
8
+ compile ,
9
+ getSchema ,
10
+ interpret ,
11
+ Validation ,
12
+ BASIC ,
13
+ } from "@hyperjump/json-schema/experimental" ;
8
14
import * as Instance from "@hyperjump/json-schema/instance/experimental" ;
9
15
10
16
/**
@@ -18,18 +24,24 @@ import { buildSchemaDocument } from "@hyperjump/json-schema/experimental";
18
24
19
25
addMediaTypePlugin ( "application/schema+yaml" , {
20
26
parse : async ( response ) => {
21
- const contentType = contentTypeParser . parse ( response . headers . get ( "content-type" ) ?? "" ) ;
22
- const contextDialectId = contentType . parameters . schema ?? contentType . parameters . profile ;
27
+ const contentType = contentTypeParser . parse (
28
+ response . headers . get ( "content-type" ) ?? "" ,
29
+ ) ;
30
+ const contextDialectId =
31
+ contentType . parameters . schema ?? contentType . parameters . profile ;
23
32
24
33
const foo = YAML . parse ( await response . text ( ) ) ;
25
34
return buildSchemaDocument ( foo , response . url , contextDialectId ) ;
26
35
} ,
27
- fileMatcher : ( path ) => path . endsWith ( ".yaml" )
36
+ fileMatcher : ( path ) => path . endsWith ( ".yaml" ) ,
28
37
} ) ;
29
38
30
39
/** @type (testDirectory: string) => AsyncGenerator<[string,Json]> */
31
40
const tests = async function * ( testDirectory ) {
32
- for ( const file of await readdir ( testDirectory , { recursive : true , withFileTypes : true } ) ) {
41
+ for ( const file of await readdir ( testDirectory , {
42
+ recursive : true ,
43
+ withFileTypes : true ,
44
+ } ) ) {
33
45
if ( ! file . isFile ( ) || ! file . name . endsWith ( ".yaml" ) ) {
34
46
continue ;
35
47
}
@@ -100,12 +112,21 @@ Validation.interpret = baseInterpret;
100
112
// console.log("Covered:", visitedLocations);
101
113
102
114
const allKeywords = keywordLocations ( compiled . ast ) ;
103
- const notCovered = allKeywords . filter ( ( location ) => ! visitedLocations . has ( location ) ) ;
104
- console . log ( "NOT Covered:" , notCovered . length , "of" , allKeywords . length , ) ;
105
-
106
- const maxNotCovered = 20 ;
107
- const firstNotCovered = notCovered . slice ( 0 , maxNotCovered ) ;
108
- if ( notCovered . length > maxNotCovered ) firstNotCovered . push ( "..." ) ;
109
- console . log ( firstNotCovered ) ;
110
-
111
- console . log ( "Covered:" , visitedLocations . size , "of" , allKeywords . length , "(" + Math . floor ( visitedLocations . size / allKeywords . length * 100 ) + "%)" ) ;
115
+ const notCovered = allKeywords . filter (
116
+ ( location ) => ! visitedLocations . has ( location ) ,
117
+ ) ;
118
+ if ( notCovered . length > 0 ) {
119
+ console . log ( "NOT Covered:" , notCovered . length , "of" , allKeywords . length ) ;
120
+ const maxNotCovered = 20 ;
121
+ const firstNotCovered = notCovered . slice ( 0 , maxNotCovered ) ;
122
+ if ( notCovered . length > maxNotCovered ) firstNotCovered . push ( "..." ) ;
123
+ console . log ( firstNotCovered ) ;
124
+ }
125
+
126
+ console . log (
127
+ "Covered:" ,
128
+ visitedLocations . size ,
129
+ "of" ,
130
+ allKeywords . length ,
131
+ "(" + Math . floor ( ( visitedLocations . size / allKeywords . length ) * 100 ) + "%)" ,
132
+ ) ;
0 commit comments