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/recover-stencil-upload.mjs

/** Recover the exact frozen 0.4.52 upload, without creating another release. */
import fs from "node:fs"
import path from "node:path"
import os from "node:os"
import crypto from "node:crypto"
import { gzipSync } from "node:zlib"
import assert from "node:assert/strict"

const read = p => JSON.parse(fs.readFileSync(p, "utf8"))
const manifest = read("reports/stencil-publish-manifest.json")
assert.equal(manifest.version, "0.4.52")
const token = process.env.TSCIRCUIT_TOKEN ?? read(path.join(os.homedir(), "Library/Preferences/tscircuit-nodejs/config.json")).sessionToken
assert.ok(token)
const selected = process.argv.includes("--repair-text")
  ? manifest.files.filter(file => file.file === "scripts/recover-review-upload.mjs")
  : manifest.files
const files = selected.map(file => {
  const bytes = fs.readFileSync(path.join(manifest.destination, file.file))
  assert.equal(crypto.createHash("sha256").update(bytes).digest("hex"), file.sha256, file.file)
  const binary = bytes.subarray(0, 8192).includes(0) || !Buffer.from(bytes.toString("utf8")).equals(bytes)
  return binary ? { file_path: file.file, content_base64: bytes.toString("base64") } : { file_path: file.file, content_text: bytes.toString("utf8") }
})
const archive = gzipSync(JSON.stringify({ files }), { level: 9 })
const payload = JSON.stringify({ package_name_with_version: `${manifest.packageName}@${manifest.version}`, archive_base64: archive.toString("base64") })
console.log(JSON.stringify({ phase: "recovering-same-release", files: files.length, gzipBytes: archive.length }))
const response = await fetch("https://registry-api.tscircuit.com/package_files/upload_archive", {
  method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
  body: payload, signal: AbortSignal.timeout(180000),
})
const result = await response.json().catch(() => ({}))
if (!response.ok) throw new Error(`Archive upload HTTP ${response.status}: ${result.error?.error_code ?? result.error?.message ?? "failed"}`)
fs.writeFileSync("reports/stencil-upload-response.json", JSON.stringify({ checkedAt: new Date().toISOString(), http: response.status, result }, null, 2) + "\n")
console.log(JSON.stringify({ phase: "uploaded", http: response.status, files: files.length }))