1- const $RefParser = require ( '@apidevtools/json-schema-ref-parser' ) ;
2- const fs = require ( 'fs' ) ;
1+ import $RefParser from "@apidevtools/json-schema-ref-parser" ;
32
43async function bundleSchemas ( ) {
5- try {
6- const inputFile = 'ruleset.json' ; // The ruleset generated in your workflow
7- const outputFile = 'bundled-ruleset.json' ; // The output file after bundling
4+ try {
5+ const inputFile = 'ruleset.json' ; // The ruleset generated in your workflow
6+ const outputFile = 'bundled-ruleset.json' ; // The output file after bundling
87
9- // Load and bundle the JSON Schema
10- const bundled = await $RefParser . bundle ( inputFile ) ;
8+ // if you want to avoid modifying the original schema, you can disable the `mutateInputSchema` option
9+ let bundled = await $RefParser . dereference ( mySchema , { mutateInputSchema : false } ) ;
1110
12- // Save the bundled schema to a file
13- fs . writeFileSync ( outputFile , JSON . stringify ( bundled , null , 2 ) ) ;
11+ fs . writeFileSync ( outputFile , JSON . stringify ( bundled , null , 2 ) ) ;
12+ console . log ( `Bundled schema written to ${ outputFile } ` ) ;
1413
15- console . log ( `Bundled schema written to ${ outputFile } ` ) ;
16- } catch ( error ) {
17- console . error ( 'Error bundling schemas:' , error ) ;
18- process . exit ( 1 ) ; // Exit with an error code if something fails
19- }
14+ } catch ( error ) {
15+ console . error ( 'Error bundling schemas:' , error ) ;
16+ process . exit ( 1 ) ; // Exit with an error code if something fails
17+ }
2018}
21-
2219bundleSchemas ( ) ;
0 commit comments