abse/smartwatch-flex-top-only
Three-panel flex smartwatch with two parallel R3.9 bends, all components flat-top, low-profile JST connector harnesses, split heartbeat optical windows and screw-retained PCB mounting. Modeled 39 × 50.5 × 14.5mm prototype; 100% routing, zero native DRC and shorts. Hardware qualification pending.
- Version
- 0.2.20
- License
- unset
- Stars
- 0
scripts/cloud-run.mjs
// Keep full diagnostics on disk so cloud log transport cannot block the CLI.
import fs from 'node:fs'
import {spawn} from 'node:child_process'
import {cachePreviews} from './cloud-preview-cache.mjs'
import {compactCloudCircuits} from './compact-cloud-circuits.mjs'
import {publishDisplayUpPreview} from './publish-display-up-preview.mjs'
import {restoreCloudTransports} from './restore-cloud-transports.mjs'
const phase=process.argv[2]
if(!['install','build'].includes(phase))throw Error('Expected install or build')
restoreCloudTransports()
if(phase==='build')cachePreviews()
fs.mkdirSync('reports',{recursive:true})
const logPath=`reports/cloud-${phase}.log`
const fd=fs.openSync(logPath,'w')
const command=phase==='install'?'npm':'bun'
const args=phase==='install'?['ci','--legacy-peer-deps']:['run','build:site']
console.log(`Starting ${phase}; full diagnostics: ${logPath}`)
const child=spawn(command,args,{stdio:['ignore',fd,fd]})
const timer=setInterval(()=>console.log(`${phase} is running; full diagnostics are retained on disk`),30000)
let code
try{
code=await new Promise((resolve,reject)=>{child.once('error',reject);child.once('exit',resolve)})
}finally{clearInterval(timer);fs.closeSync(fd)}
const log=fs.readFileSync(logPath,'utf8').replace(/\u001b\[[0-9;]*m/g,'')
if(phase==='build'){
fs.mkdirSync('dist',{recursive:true})
fs.copyFileSync(logPath,'dist/cloud-build.log')
if(fs.existsSync('reports/cloud-install.log'))fs.copyFileSync('reports/cloud-install.log','dist/cloud-install.log')
const lines=log.split('\n')
const count=JSON.parse(fs.readFileSync('tscircuit.config.json','utf8')).includeBoardFiles.length
const summary=lines.find(line=>new RegExp(`Circuits\\s+${count} passed`).test(line))
const finish=lines.find(line=>line.includes('Build exiting with code 0: build finished successfully'))
if(code===0&&summary&&finish){cachePreviews(true);compactCloudCircuits();publishDisplayUpPreview();console.log(summary);console.log(finish)}
else if(code===0){console.error(`Missing expected ${count}-entry build summary; see the full build log`);code=1}
}
if(code!==0){console.error(log.split('\n').slice(-60).join('\n'));process.exitCode=code??1}
else console.log(`${phase} completed successfully`)