From f14bbc3a36e6975887271f8488fde994a6dd5434 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Mon, 19 Dec 2022 11:15:37 -0600 Subject: [PATCH] npm/images: add DFU Windows driver images This will be used in Pybricks Code for Windows driver installation instructions. --- npm/images/CHANGELOG.md | 3 +++ npm/images/build.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/npm/images/CHANGELOG.md b/npm/images/CHANGELOG.md index e246afa..10f422b 100644 --- a/npm/images/CHANGELOG.md +++ b/npm/images/CHANGELOG.md @@ -2,6 +2,9 @@ +### Added +- Added DFU Windows driver images. + ## 1.2.1 - 2022-11-08 ### Changed diff --git a/npm/images/build.py b/npm/images/build.py index fd5639f..5876f31 100755 --- a/npm/images/build.py +++ b/npm/images/build.py @@ -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)