rushabhcodes/wireless-split-keyboard
Wireless Split Keyboard — custom routed nRF52840 split PCBs with a printable enclosure
- Version
- 0.4.5
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone rushabhcodes/wireless-split-keyboard # download the package files into ./wireless-split-keyboard
tsci add rushabhcodes/wireless-split-keyboard # add it to your project as @tsci/rushabhcodes.wireless-split-keyboardIn a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
scripts/stage-registry.py
"""Stage source for `tsci push`, allowing tscircuit's server to build it."""
from pathlib import Path
import json,shutil,hashlib,subprocess
root=Path(__file__).resolve().parents[1]
report=json.loads((root/'outputs/validation-summary.json').read_text())
assert report['checksPass'] and report['artifactsMatchCurrentSource'], 'Run complete validation first'
bun=shutil.which('bun') or str(Path.home()/'.bun/bin/bun')
current=subprocess.check_output([bun,'-e','import {inputHash} from "./scripts/input-hash";console.log(inputHash().sha256)'],cwd=root,text=True).strip()
manifest=json.loads((root/'outputs/build-manifest.json').read_text())
assert current==manifest['inputs']['sha256'], 'Sources changed after validation'
for half in ['left','right']:
data=(root/f'outputs/{half}/keyboard.circuit.json').read_bytes()
assert hashlib.sha256(data).hexdigest()==report['halves'][half]['circuitJsonSha256'], 'Rebuild/recheck before publishing'
out=root/'.cache/cloud-publish';out.mkdir(parents=True,exist_ok=True)
for folder in ['src','imports','patches']:shutil.copytree(root/folder,out/folder,dirs_exist_ok=True)
(out/'scripts').mkdir(exist_ok=True)
shutil.copy2(root/'scripts/prepare-cloud-dependencies.ts',out/'scripts/prepare-cloud-dependencies.ts')
# No local build artifacts are uploaded. The registry worker builds these sources.
if (out/'dist').exists():shutil.rmtree(out/'dist')
for folder in ['src','imports']:
for file in (out/folder).rglob('*.json'):
file.write_text(json.dumps(json.loads(file.read_text()),separators=(',',':'),ensure_ascii=False)+'\n')
for file in ['package.json','bun.lock','tsconfig.json','tscircuit.config.json','index.tsx','left.circuit.tsx','right.circuit.tsx','stand.circuit.tsx','LICENSE']:
shutil.copy2(root/file,out/file)
config=json.loads((out/'tscircuit.config.json').read_text());config['mainEntrypoint']='left.circuit.tsx'
(out/'tscircuit.config.json').write_text(json.dumps(config,indent=2)+'\n')
# Keep the same shopping list and mechanical references on both public sites.
import re
readme=(root/'README.md').read_text()
def hosted_link(match):
image,label,target=match.groups()
if target.startswith(('https://','http://','#')):return match.group(0)
base='https://raw.githubusercontent.com/rushabhcodes/wireless-split-keyboard/main/' if image else 'https://github.com/rushabhcodes/wireless-split-keyboard/blob/main/'
return f'{image}[{label}]({base}{target})'
(out/'README.md').write_text(re.sub(r'(!?)\[([^\]]*)\]\(([^)\s]+)\)',hosted_link,readme))
print(out)