muse/book-reading-clip-lamp
A tscircuit package created by muse.
- Version
- 0.4.6
- License
- unset
- Stars
- 0
package-deliverables.py
from pathlib import Path
import shutil, json, hashlib, zipfile, sys
p=Path(__file__).parent
out=p.parents[1]/'outputs'/(sys.argv[1] if len(sys.argv)>1 else 'lamp-head-seeed')
out.mkdir(parents=True,exist_ok=True)
files=['render-pcb.cjs','render-sheets.cjs','render-overview.cjs','style-previews.py','verify-release.py','cloud-build-investigation.txt','reroute.circuit.tsx','camera-fpc-parts.tsx','camera-sourcing.txt','camera-pinout.csv','verify-camera-interface.py','bun.lock','component-provenance.csv','viewer-fix-notes.txt','index.circuit.tsx','routing-notes.txt','mcu-parts.tsx','power-parts.tsx','camera-audio-parts.tsx','controls-parts.tsx','indicator-parts.tsx','usb-connector.tsx','schematic-layout.tsx','package.json','tsconfig.json','tscircuit.config.json','.npmrc','.gitignore','README.md','bill-of-materials.csv','pin-map.csv','firmware-and-assembly.txt','power-audit.txt','usb-power-policy.txt','validation.txt','preview.html','assembly-map.svg','assembly-map.png','pcb-top.svg','pcb-bottom.svg','pcb-top.png','pcb-bottom.png','pcb-overview.png','schematic.svg']
files += ['enclosure-geometry.ts','lamp-enclosure.tsx','export-enclosure.ts','export-board-preview.mjs','extract-board-bounds.mjs','enclosure-viewer.html','enclosure-viewer.js','enclosure-viewer.bundle.js','serve-enclosure.mjs']
files += ['base-assembly-geometry.ts','base-cad-models.ts','base-controls-wiring.csv','verify-base-controls.py']
selected=[Path(name) for name in files]
for name in files: shutil.copy2(p/name,out/name)
shutil.copytree(p/'imports',out/'imports',dirs_exist_ok=True)
selected += [f.relative_to(p) for f in sorted((p/'imports').glob('*.tsx'))]
(out/'dist'/'index').mkdir(parents=True,exist_ok=True)
for name in ['circuit.json','pcb.png','schematic.png']:
shutil.copy2(p/'dist'/'index'/name,out/'dist'/'index'/name)
selected.append(Path('dist/index')/name)
shutil.copytree(p/'schematic-sheets',out/'schematic-sheets',dirs_exist_ok=True)
selected += [f.relative_to(p) for f in sorted((p/'schematic-sheets').glob('*')) if f.suffix in ['.svg','.png']]
(out/'reports').mkdir(exist_ok=True)
report_names=['checks-style-analysis.log','schematic-style-after.json','checks-style-regression.log','checks-style-shorts.log','checks-style-netlist.log','checks-style-schematic.log','checks-style-placement.log','build-style.log','checks-seeed-release.log','checks-seeed-netlist.log','checks-seeed-schematic.log','checks-seeed-placement.log','checks-seeed-shorts.log','checks-seeed-shorts-inner1.log','checks-seeed-shorts-inner2.log','build-seeed-final.log','build-seeed-routing.log','typecheck-seeed.log','checks-seeed-routing-guard.log']
for name in report_names:
shutil.copy2(p/name,out/'reports'/name)
selected.append(Path('reports')/name)
for folder in ['mechanical','mechanical-tools','work-routing-m3']:
for source in sorted((p/folder).rglob('*')):
if not source.is_file() or 'node_modules' in source.parts or 'switch-drawings' in source.parts: continue
if folder == 'work-routing-m3' and (source.name.startswith('style-') or source.name.startswith('check-style') or source.name == 'schematic-only.json'): continue
relative=source.relative_to(p)
(out/relative).parent.mkdir(parents=True,exist_ok=True)
shutil.copy2(source,out/relative)
selected.append(relative)
for name in ['checks-enclosure-typecheck.log','checks-enclosure-netlist.log','checks-enclosure-schematic.log','checks-enclosure-placement.log','build-enclosure.log','checks-enclosure-shorts.log','checks-enclosure-release.log','checks-enclosure-geometry.log','checks-enclosure-regression.log']:
shutil.copy2(p/name,out/'reports'/name)
selected.append(Path('reports')/name)
manifest={str(f):hashlib.sha256((out/f).read_bytes()).hexdigest() for f in sorted(set(selected))}
for source in sorted(p.glob('checks-product-*.log')) + sorted(p.glob('checks-base-controls-*.log')) + sorted(p.glob('build-base-controls-*.log')) + [p/'build-product.log']:
relative=Path('reports')/source.name
shutil.copy2(source,out/relative)
selected.append(relative)
manifest[str(relative)]=hashlib.sha256((out/relative).read_bytes()).hexdigest()
(out/'sha256.json').write_text(json.dumps(manifest,indent=2)+'\n')
archive=out.parent/(out.name+'-tscircuit.zip')
with zipfile.ZipFile(archive,'w',zipfile.ZIP_DEFLATED) as z:
for f in sorted(set(selected+[Path('sha256.json')])):
z.write(out/f,str(Path(out.name)/f))
with zipfile.ZipFile(archive) as z:
assert z.testzip() is None
print(out)
print(archive)
print(len(manifest),'files plus SHA256 manifest')