ShiboSoftwareDev/mspm0g3507-gameboy-handheld

An AO3400A N-channel MOSFET for power switching and an AP2112K-3.3TRG1 LDO regulator providing a regulated 3.3 V output, both in compact SMD packages.

Version
1.2.1
License
unset
Stars
0

scripts/sync-gerber-assembly.mjs

import { copyFileSync, mkdtempSync, rmSync } from "node:fs"
import { tmpdir } from "node:os"
import { basename, join, resolve } from "node:path"
import { execFileSync } from "node:child_process"

const zipPath = resolve("outputs/MSPM0G3507_GAMEBOY_JLCPCB_Gerbers.zip")
const bomPath = resolve("outputs/MSPM0G3507_GAMEBOY_JLCPCB_BOM.csv")
const cplPath = resolve("outputs/MSPM0G3507_GAMEBOY_JLCPCB_CPL.csv")
const stagingDirectory = mkdtempSync(join(tmpdir(), "mspm0-gerber-assembly-"))

try {
  const stagedBom = join(stagingDirectory, "bom.csv")
  const stagedCpl = join(stagingDirectory, "pick_and_place.csv")
  copyFileSync(bomPath, stagedBom)
  copyFileSync(cplPath, stagedCpl)
  execFileSync("zip", ["-d", zipPath, basename(stagedBom), basename(stagedCpl)], {
    stdio: "ignore",
  })
  execFileSync("zip", ["-j", zipPath, stagedBom, stagedCpl], { stdio: "ignore" })
  console.log("Synchronized manufacturer-rich BOM and CPL into the Gerber ZIP")
} finally {
  rmSync(stagingDirectory, { recursive: true, force: true })
}