shibosoftwaredev/f1c100s-linux-nema17-stepper-controller
A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.
- Version
- 0.4.56
- License
- unset
- Stars
- 0
scripts/restore-main-release.mjs
import fs from "node:fs"
import path from "node:path"
import os from "node:os"
import assert from "node:assert/strict"
const base = "https://registry-api.tscircuit.com/"
const name = "shibosoftwaredev/f1c100s-linux-nema17-stepper-controller"
const draftId = "6497458e-86d0-4a55-90f8-6585015e25f3"
const before = JSON.parse(fs.readFileSync("reports/remote-before-checkpoint.json", "utf8")).package
assert.equal(before.name, name)
assert.equal(before.latest_version, "0.4.46")
async function request(endpoint, { body, token } = {}) {
const response = await fetch(base + endpoint, {
method: "POST", headers: { "content-type": "application/json",
...(token ? { authorization: `Bearer ${token}` } : {}) },
body: JSON.stringify(body), signal: AbortSignal.timeout(30000),
})
if (!response.ok) throw new Error(`${endpoint}: HTTP ${response.status}`)
return response.json()
}
const current = (await request("packages/get", { body: { name } })).package
assert.ok([draftId, before.latest_package_release_id].includes(current.latest_package_release_id),
"stop if another release has replaced either our checkpoint or the original main")
let changed = false
if (current.latest_package_release_id === draftId) {
const config = process.env.TSCIRCUIT_TOKEN ? null : JSON.parse(fs.readFileSync(
path.join(os.homedir(), "Library/Preferences/tscircuit-nodejs/config.json"), "utf8"))
const token = process.env.TSCIRCUIT_TOKEN ?? config.sessionToken
assert.ok(token, "existing tscircuit authentication required")
await request("package_releases/update", { body: {
package_release_id: before.latest_package_release_id, is_latest: true,
}, token })
changed = true
}
const after = (await request("packages/get", { body: { name } })).package
const draft = (await request("package_releases/get", { body: {
package_name_with_version: `${name}@0.4.46-checkpoint-20261019-current-sense`,
} })).package_release
assert.equal(after.latest_package_release_id, before.latest_package_release_id)
assert.equal(after.latest_version, before.latest_version)
assert.equal(draft.is_latest, false)
const result = { checkedAt: new Date().toISOString(), restored: true, changed,
mainVersion: after.latest_version, mainReleaseId: after.latest_package_release_id,
checkpointReleaseId: draft.package_release_id, checkpointIsLatest: draft.is_latest,
reason: "CLI non-latest tag was unexpectedly promoted; restored exact previous main release without deleting checkpoint or changing its source." }
fs.writeFileSync("reports/checkpoint-main-restoration.json", JSON.stringify(result, null, 2) + "\n")
console.log(JSON.stringify(result, null, 2))