Generate JS in addition to JSON defs

This commit is contained in:
tyeth 2025-04-03 02:43:20 +01:00
parent 2671e9e82a
commit 32cc01e827
2 changed files with 12 additions and 0 deletions

View file

@ -479,6 +479,12 @@ def convert_boards_to_json():
with open(OUTPUT_FILE, 'w') as f:
json.dump({"boards": boards}, f, indent=2)
# Write the consolidated JS file
with open(OUTPUT_FILE.replace('.json', '.js'), 'w') as f:
f.write("window.jsonBoardObject = ")
json.dump({"boards": boards}, f, indent=2)
f.write(";\n")
print(f"Successfully created {OUTPUT_FILE} with {len(boards)} boards")
return boards

View file

@ -180,6 +180,12 @@ def convert_components_to_json():
with open(OUTPUT_FILE, 'w') as f:
json.dump({"components": components}, f, indent=2)
# Write the consolidated JS file
with open(OUTPUT_FILE.replace('.json', '.js'), 'w') as f:
f.write("window.jsonComponentsObject = ")
json.dump({"components": components}, f, indent=2)
f.write(";\n")
print(f"Successfully created {OUTPUT_FILE}")
# Calculate component count