imrishabh18/corne-keyboard
The code defines and renders two surface-mount chip components with SMT pads, silkscreen outlines, and 3D CAD models (OBJ and STEP) for PCB assembly.
- Version
- 2.0.21
- License
- unset
- Stars
- 1
scripts/patch-autorouter.mjs
import fs from 'node:fs'
import { normalizeViaTransitions } from './normalize-via-transitions.mjs'
const base = new URL('../node_modules/@tscircuit/capacity-autorouter/', import.meta.url)
const pkg = JSON.parse(fs.readFileSync(new URL('package.json',base),'utf8'))
if (pkg.version !== '0.0.887') throw Error('Review the via normalization patch before upgrading the autorouter')
const file = new URL('dist/index.js',base)
let code = fs.readFileSync(file,'utf8')
const marker = '/* corne-via-transition-normalization */'
if (code.includes(marker)) process.exit(0)
const needle = '(({originalSrj:t,routes:e,syntheticConnectionNames:n,drcEvaluator:o})=>{'
if (code.split(needle).length !== 2) throw Error('Unexpected router bundle: refusing to patch')
code = marker + '\n' + normalizeViaTransitions.toString() + '\n' +
code.replace(needle, needle + 'e=normalizeViaTransitions(e);')
// Atomic replacement avoids modifying a shared package-cache inode.
fs.writeFileSync(new URL('dist/index.js.corne-patched',base),code)
fs.renameSync(new URL('dist/index.js.corne-patched',base),file)
console.log('Applied bounded via-coordinate normalization to capacity-autorouter 0.0.887')