| from pathlib import Path |
| import shutil, hashlib, json, re |
| root = Path(__file__).resolve().parent.parent |
| out = root / '.space-http' |
| if out.exists(): shutil.rmtree(out) |
| shutil.copytree(root / 'app/dist', out) |
| for name in ['README.md', 'LICENSE', 'NOTICE', '.gitattributes']: |
| source = root / name if (root / name).exists() else root / 'source-space' / name |
| shutil.copyfile(source, out / name) |
| shutil.copytree(root / 'app', out / 'app', ignore=shutil.ignore_patterns('node_modules', 'dist', '.env', '.env.*')) |
| shutil.copytree(root / 'scripts', out / 'scripts') |
| (out / 'validation').mkdir() |
| for path in (root / 'validation').glob('*'): |
| |
| if path.is_file() and path.name in ['source.json', 'deployment.json', 'http-shell-live.json', 'http-agent-live.json', 'http-final-smoke.json', 'http-embedded.json', 'http-any-https.json', 'REPORT.md', 'http-desktop.png', 'http-mobile.png', 'http-agent-fetch-count-write.png', 'LOCAL-FOLDER.md', 'local-folder-browser.json', 'local-folder-live.json', 'local-folder-agent-live.json', 'local-folder-native.png', 'local-folder-browser-review.png', 'local-folder-browser-390.png']: |
| destination = out / 'validation' / path.name |
| if path.suffix == '.json': |
| data = path.read_text() |
| data = re.sub(r'(?<![\d.])(?:\d{1,3}\.){3}\d{1,3}(?![\d.])', '<redacted IP>', data) |
| |
| data = re.sub(r'(https://[^"\s]*?(?:hf\.co|xethub[^/]*)/[^"\s?]*)\?[^"\s]*', r'\1', data) |
| destination.write_text(data) |
| else: shutil.copyfile(path, destination) |
| files = {str(p.relative_to(out)): hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(out.rglob('*')) if p.is_file()} |
| (out / 'deployment-manifest.json').write_text(json.dumps({'source': 'victor/MiniCPM5-2B-WebGPU-Pi', 'sourceRevision': '959e272adeb7931e32d3eb2177dc1d5e96c3e967', 'files': files}, indent=2)+'\n') |
| print(f'Staged {len(files)+1} files for Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP') |
|
|