| 42 | |
| 43 | |
| 44 | def collect(ui_dir, dep_tree, out): |
| 45 | for name, info in (dep_tree or {}).items(): |
| 46 | version = info.get("version") |
| 47 | if not version: |
| 48 | continue |
| 49 | pkg_dir = os.path.join(ui_dir, "node_modules", *name.split("/")) |
| 50 | try: |
| 51 | with open(os.path.join(pkg_dir, "package.json"), encoding="utf-8") as fh: |
| 52 | meta = json.load(fh) |
| 53 | except (OSError, ValueError): |
| 54 | continue |
| 55 | if meta.get("os") or meta.get("cpu"): |
| 56 | continue # platform-restricted native build tooling, not bundled |
| 57 | lic = meta.get("license", "") |
| 58 | if isinstance(lic, dict): |
| 59 | lic = lic.get("type", "") |
| 60 | out[(name, version)] = (str(lic or ""), pkg_dir) |
| 61 | collect(ui_dir, info.get("dependencies"), out) |
| 62 | |
| 63 | |
| 64 | def main(): |