← Commit history

v0.11.1: lazy gltf-transform — install.sh no longer runs a silent unbounded npm install (it could stall a cold dock install for a publish-only tool); deps fetch bounded (120s) on first --render-board use, falling back to the un-optimized GLB

John Lauer ·3dd840f9ad ·1mo ago ·parent a1e7a22
6 files changed +27−12
Cargo.lock+1−1
@@ -4,7 +4,7 @@ version = 4  [[package]] name = "adom-project-manager"-version = "0.11.0"+version = "0.11.1" dependencies = [  "altium-codec",  "anyhow",
Cargo.toml+1−1
@@ -1,6 +1,6 @@ [package] name = "adom-project-manager"-version = "0.11.0"+version = "0.11.1" edition = "2021" description = "Adom Project Manager — the central hub for navigating wiki boards, molecules, and libraries into Hydrogen: browse your wiki boards/projects, view symbol + footprint + 3D and the footprint layer stackup, add components to your KiCad/Altium libraries, and deliver self-contained KiCad projects. Built on adom-lbr." 
bin/adom-project-manager
⋯ 1 unchanged line ⋯
install.sh+5−9
@@ -8,17 +8,13 @@ rm -f "$BIN/adom-nucleus" # Board-GLB optimizer: --render-board shrinks the raw kicad-cli board GLB (merge # primitives, quantize) before publishing. It shells to `node <script>` using # @gltf-transform; both are OPTIONAL — without them --render-board just publishes-# the un-optimized GLB. Install the script + its deps best-effort next to the bin.+# the un-optimized GLB. Only the script is installed here; its npm deps are+# fetched LAZILY on first --render-board use. The npm step used to run right+# here, silently and unbounded, which could stall a cold dock install for+# minutes on a tool no dock user ever runs (--render-board is publish-flow only). if [ -f "$DIR/glb_optimize.mjs" ]; then   install -m 0644 "$DIR/glb_optimize.mjs" "$BIN/glb_optimize.mjs"-  if command -v npm >/dev/null 2>&1; then-    ( cd "$BIN" && npm install --no-save --no-audit --no-fund \-        @gltf-transform/core @gltf-transform/functions @gltf-transform/extensions >/dev/null 2>&1 ) \-      && echo "Installed board-GLB optimizer (gltf-transform)" \-      || echo "Note: gltf-transform deps not installed; --render-board will publish un-optimized GLBs"-  else-    echo "Note: npm not found; --render-board will publish un-optimized GLBs (install node+npm to enable optimization)"-  fi+  echo "Installed board-GLB optimizer script (npm deps fetched on first --render-board use)" fi  # 0.5.0 bundled the deprecated publish-board skill; molecule-publish replaces it
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "adom-project-manager",-  "version": "0.11.0",+  "version": "0.11.1",   "type": "app",   "description": "Adom Project Manager — the central hub for navigating wiki boards, molecules and libraries into Hydrogen: browse your wiki boards/projects (Personal / Organization / Public), view symbol + footprint + 3D and the per-EDA footprint layer stackup, explore the board and schematic in INTERACTIVE cross-probing viewers (click a net, hover a part for stock and price), add components to your KiCad/Altium libraries, and deliver self-contained KiCad projects. Built on adom-lbr. (Formerly Adom Project Manager / adom-project-manager.)",   "dependencies": {
src/main.rs+19
@@ -2684,6 +2684,25 @@ fn optimize_glb(bytes: &[u8], key: &str) -> Vec<u8> {     let opt = match cands.into_iter().find(|p| std::path::Path::new(p).exists()) {         Some(p) => p, None => return bytes.to_vec(),     };+    // Lazy dep fetch: install.sh deliberately does NOT npm-install @gltf-transform+    // (it stalled cold dock installs on a tool only the publish flow uses). Fetch+    // it here, bounded, the first time --render-board actually needs it.+    if let Some(dir) = std::path::Path::new(&opt).parent() {+        if !dir.join("node_modules/@gltf-transform/core").exists() {+            eprintln!("fetching gltf-transform (first --render-board use) …");+            let done = Command::new("timeout")+                .args(["120", "npm", "install", "--no-save", "--no-audit", "--no-fund",+                       "@gltf-transform/core", "@gltf-transform/functions", "@gltf-transform/extensions"])+                .current_dir(dir)+                .status()+                .map(|s| s.success())+                .unwrap_or(false);+            if !done {+                eprintln!("gltf-transform install failed or timed out; publishing un-optimized GLB");+                return bytes.to_vec();+            }+        }+    }     let tin = format!("{SCRATCH}/glbopt-{key}-in.glb");     let tout = format!("{SCRATCH}/glbopt-{key}-out.glb");     if std::fs::write(&tin, bytes).is_err() { return bytes.to_vec(); }