Skip to content

Commit 82d6afc

Browse files
committed
chore: add banner to the merged schema file
1 parent 9602bbc commit 82d6afc

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

packages/live-status-gateway-api/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"homepage": "https://github.com/nrkno/sofie-core/blob/master/packages/live-status-gateway-api#readme",
1717
"scripts": {
18-
"build": "yarn resolve-nested-examples && yarn generate-schema-types && run -T rimraf dist && run build:main",
18+
"build": "yarn generate-schema-types && run -T rimraf dist && run build:main",
1919
"build:main": "run -T tsc -p tsconfig.build.json",
2020
"lint:raw": "run -T eslint",
2121
"lint": "run lint:raw .",
@@ -27,11 +27,11 @@
2727
"validate:dependencies": "yarn npm audit --environment production && run license-validate",
2828
"validate:dev-dependencies": "yarn npm audit --environment development",
2929
"license-validate": "run -T sofie-licensecheck",
30-
"gendocs": "yarn resolve-nested-examples && ag ./dist/api/asyncapi.yaml @asyncapi/html-template -o docs -p singleFile=true -p outFilename=liveStatus.html",
31-
"genserver": "yarn resolve-nested-examples && ag ./dist/api/asyncapi.yaml @asyncapi/nodejs-ws-template -o server -p server=development",
32-
"generate-schema-types": "yarn resolve-nested-examples && node scripts/generate-schema-types.mjs",
33-
"resolve-nested-examples": "node scripts/resolve-nested-examples.mjs && yarn merge-schemas",
34-
"merge-schemas": "node scripts/merge-schemas.mjs"
30+
"gendocs": "yarn merge-schemas && ag ./src/generated/asyncapi.yaml @asyncapi/html-template -o docs -p singleFile=true -p outFilename=liveStatus.html",
31+
"genserver": "yarn merge-schemas && ag ./src/generated/asyncapi.yaml @asyncapi/nodejs-ws-template -o server -p server=development",
32+
"generate-schema-types": "yarn merge-schemas && node scripts/generate-schema-types.mjs",
33+
"resolve-nested-examples": "node scripts/resolve-nested-examples.mjs",
34+
"merge-schemas": "yarn resolve-nested-examples && node scripts/merge-schemas.mjs"
3535
},
3636
"engines": {
3737
"node": ">=14.19"

packages/live-status-gateway-api/scripts/merge-schemas.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { fromFile, Parser } from '@asyncapi/parser'
66
const ROOT_FILE = './temp/api/asyncapi.yaml'
77
const OUTPUT_FILE = './src/generated/asyncapi.yaml'
88

9+
const BANNER =
10+
'# This file was automatically generated using @asyncapi/parser\n' +
11+
'# DO NOT MODIFY IT BY HAND. Instead, modify the source AsyncAPI schema files,\n' +
12+
'# and run "yarn merge-schemas" to regenerate this file.\n'
13+
914
async function main() {
1015
try {
1116
const parser = new Parser()
@@ -15,14 +20,12 @@ async function main() {
1520
throw new Error('Failed to parse the AsyncAPI document.')
1621
}
1722

18-
// Convert the resolved document to JS object
1923
const resolved = document.json()
20-
21-
// Ensure output directory exists
2224
fs.mkdirSync(path.dirname(OUTPUT_FILE), { recursive: true })
2325

24-
// Write out single YAML file
25-
fs.writeFileSync(OUTPUT_FILE, YAML.stringify(resolved), 'utf-8')
26+
// Prepend banner to YAML output
27+
const yamlContent = BANNER + YAML.stringify(resolved)
28+
fs.writeFileSync(OUTPUT_FILE, yamlContent, 'utf-8')
2629

2730
console.log(`Fully resolved AsyncAPI schema written to: ${OUTPUT_FILE}`)
2831
} catch (err) {

packages/live-status-gateway-api/src/generated/asyncapi.yaml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This file was automatically generated using @asyncapi/parser
2+
# DO NOT MODIFY IT BY HAND. Instead, modify the source AsyncAPI schema files,
3+
# and run "yarn merge-schemas" to regenerate this file.
14
asyncapi: 2.6.0
25
id: sofie:live-status-gateway:server
36
info:
@@ -15,7 +18,7 @@ servers:
1518
url: localhost
1619
description: Server available without authorization
1720
protocol: ws
18-
protocolVersion: "13"
21+
protocolVersion: '13'
1922
defaultContentType: application/json
2023
tags:
2124
- name: sofie
@@ -305,7 +308,7 @@ channels:
305308
oneOf:
306309
- type: string
307310
x-parser-schema-id: <anonymous-schema-24>
308-
- type: "null"
311+
- type: 'null'
309312
x-parser-schema-id: <anonymous-schema-25>
310313
x-parser-schema-id: <anonymous-schema-23>
311314
name:
@@ -408,15 +411,15 @@ channels:
408411
oneOf:
409412
- type: string
410413
x-parser-schema-id: <anonymous-schema-36>
411-
- type: "null"
414+
- type: 'null'
412415
x-parser-schema-id: <anonymous-schema-37>
413416
x-parser-schema-id: <anonymous-schema-35>
414417
externalId:
415418
description: Id normally sourced from the ingest system
416419
oneOf:
417420
- type: string
418421
x-parser-schema-id: <anonymous-schema-39>
419-
- type: "null"
422+
- type: 'null'
420423
x-parser-schema-id: <anonymous-schema-40>
421424
x-parser-schema-id: <anonymous-schema-38>
422425
name:
@@ -611,7 +614,7 @@ channels:
611614
startTime: 1600000060000
612615
projectedEndTime: 1600000075000
613616
x-parser-schema-id: <anonymous-schema-45>
614-
- type: "null"
617+
- type: 'null'
615618
x-parser-schema-id: <anonymous-schema-70>
616619
x-parser-schema-id: <anonymous-schema-44>
617620
currentSegment:
@@ -655,8 +658,8 @@ channels:
655658
countdownType:
656659
type: string
657660
title: SegmentCountdownType
658-
description: "Countdown type within the segment. Default:
659-
`part_expected_duration`"
661+
description: 'Countdown type within the segment. Default:
662+
`part_expected_duration`'
660663
enum:
661664
- part_expected_duration
662665
- segment_budget_duration
@@ -738,13 +741,13 @@ channels:
738741
timing:
739742
expectedDurationMs: 15000
740743
x-parser-schema-id: <anonymous-schema-72>
741-
- type: "null"
744+
- type: 'null'
742745
x-parser-schema-id: <anonymous-schema-86>
743746
x-parser-schema-id: <anonymous-schema-71>
744747
nextPart:
745748
oneOf:
746749
- *a6
747-
- type: "null"
750+
- type: 'null'
748751
x-parser-schema-id: <anonymous-schema-88>
749752
x-parser-schema-id: <anonymous-schema-87>
750753
publicData:
@@ -1032,7 +1035,7 @@ channels:
10321035
oneOf:
10331036
- type: string
10341037
x-parser-schema-id: <anonymous-schema-107>
1035-
- type: "null"
1038+
- type: 'null'
10361039
x-parser-schema-id: <anonymous-schema-108>
10371040
x-parser-schema-id: <anonymous-schema-106>
10381041
activePieces:
@@ -1093,7 +1096,7 @@ channels:
10931096
oneOf:
10941097
- type: string
10951098
x-parser-schema-id: <anonymous-schema-113>
1096-
- type: "null"
1099+
- type: 'null'
10971100
x-parser-schema-id: <anonymous-schema-114>
10981101
x-parser-schema-id: <anonymous-schema-112>
10991102
segments:
@@ -1206,7 +1209,7 @@ channels:
12061209
- type: string
12071210
title: Unique id of the rundown playlist
12081211
x-parser-schema-id: <anonymous-schema-125>
1209-
- type: "null"
1212+
- type: 'null'
12101213
title: Null if no playlist is active
12111214
x-parser-schema-id: <anonymous-schema-126>
12121215
x-parser-schema-id: <anonymous-schema-124>
@@ -1546,7 +1549,7 @@ channels:
15461549
oneOf:
15471550
- type: string
15481551
x-parser-schema-id: <anonymous-schema-150>
1549-
- type: "null"
1552+
- type: 'null'
15501553
x-parser-schema-id: <anonymous-schema-151>
15511554
x-parser-schema-id: <anonymous-schema-149>
15521555
packages:

0 commit comments

Comments
 (0)