@@ -11,23 +11,33 @@ const ECOSYSTEM_DATA_TYPES_PATH = "./src/assets/data/ecosystemTypes.ts";
11
11
/**
12
12
* This script synchronizes the in-repo ecosystem schema JSON to the latest
13
13
* version and generates matching TypeScript types.
14
+ *
15
+ * To only generate the TypeScript types without syncing with the
16
+ * Thunderstore API, use `yarn sync -- --types-only`
14
17
*/
15
18
async function updateSchema ( ) {
16
- console . log ( "Updating ecosystem.json..." ) ;
17
- const response = await fetch ( ECOSYSTEM_DATA_URL ) ;
18
- if ( response . status !== 200 ) {
19
- throw new Error ( `Received non-200 status from schema API: ${ response . status } ` ) ;
20
- }
21
- const data = Buffer . from ( await response . arrayBuffer ( ) ) ;
22
- fs . writeFileSync ( ECOSYSTEM_DATA_PATH , data ) ;
19
+ let schema : Buffer ;
20
+
21
+ if ( process . argv . includes ( '--types-only' ) ) {
22
+ console . log ( "Skipping API update, reading JSON schema from disk..." ) ;
23
+ schema = fs . readFileSync ( ECOSYSTEM_JSON_SCHEMA_PATH ) ;
24
+ } else {
25
+ console . log ( "Updating ecosystem.json..." ) ;
26
+ const response = await fetch ( ECOSYSTEM_DATA_URL ) ;
27
+ if ( response . status !== 200 ) {
28
+ throw new Error ( `Received non-200 status from schema API: ${ response . status } ` ) ;
29
+ }
30
+ const data = Buffer . from ( await response . arrayBuffer ( ) ) ;
31
+ fs . writeFileSync ( ECOSYSTEM_DATA_PATH , data ) ;
23
32
24
- console . log ( "Updating ecosystemJsonSchema.json..." ) ;
25
- const schemaResponse = await fetch ( ECOSYSTEM_JSON_SCHEMA_URL ) ;
26
- if ( schemaResponse . status !== 200 ) {
27
- throw new Error ( `Received non-200 status from schema API: ${ schemaResponse . status } ` ) ;
33
+ console . log ( "Updating ecosystemJsonSchema.json..." ) ;
34
+ const schemaResponse = await fetch ( ECOSYSTEM_JSON_SCHEMA_URL ) ;
35
+ if ( schemaResponse . status !== 200 ) {
36
+ throw new Error ( `Received non-200 status from schema API: ${ schemaResponse . status } ` ) ;
37
+ }
38
+ schema = Buffer . from ( await schemaResponse . arrayBuffer ( ) ) ;
39
+ fs . writeFileSync ( ECOSYSTEM_JSON_SCHEMA_PATH , schema ) ;
28
40
}
29
- const schema = Buffer . from ( await schemaResponse . arrayBuffer ( ) ) ;
30
- fs . writeFileSync ( ECOSYSTEM_JSON_SCHEMA_PATH , schema ) ;
31
41
32
42
console . log ( "Updating ecosystemTypes.ts..." ) ;
33
43
const schemaInput = new JSONSchemaInput ( new FetchingJSONSchemaStore ( ) ) ;
0 commit comments