npm/images: add DFU Windows driver images

This will be used in Pybricks Code for Windows driver installation
instructions.
This commit is contained in:
David Lechner
2022-12-19 11:15:37 -06:00
parent 44c6191b2f
commit f14bbc3a36
2 changed files with 12 additions and 3 deletions
+3
View File
@@ -2,6 +2,9 @@
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
### Added
- Added DFU Windows driver images.
## 1.2.1 - 2022-11-08
### Changed
+9 -3
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
from glob import glob
import json
import pathlib
import shutil
@@ -21,6 +22,7 @@ package_json = {
"directory": "npm/images",
},
"publishConfig": {"registry": "https://registry.npmjs.org", "access": "public"},
"exports": {}, # dynamically filled below
}
# ensure empty build directory so we don't end up with stale files
@@ -30,12 +32,16 @@ BUILD_DIR.mkdir()
# copy the hub images
for h in HUBS:
shutil.copyfile(IMAGE_DIR / f"icon_{h}hub.png", BUILD_DIR / f"hub-{h}.png")
package_json["exports"][f"./hub-{h}.png"] = f"./hub-{h}.png"
# copy DFU Windows driver images
for path in glob("dfu_windows_*", root_dir=IMAGE_DIR):
file = pathlib.Path(path).name
shutil.copyfile(IMAGE_DIR / path, BUILD_DIR / file)
package_json["exports"][f"./{file}"] = f"./{file}"
# generate package.json file
# create "exports" item for hub images.
package_json["exports"] = {f"./hub-{h}.png": f"./hub-{h}.png" for h in HUBS}
with open(BUILD_DIR / "package.json", "w") as f:
json.dump(package_json, f, indent=2)