shibosoftwaredev/f1c100s-linux-nema8-stepper-controller

Restores component part numbers and CAD models, removes test-point 3D bodies, and validates that solder paste exists only on top-side SMT pads without altering copper or DRC.

Version
0.3.5
License
unset
Stars
0

scripts/push-release-archive.mjs

import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import { gzipSync } from "node:zlib"

const [releaseDir, packageNameWithVersion] = process.argv.slice(2)
if (!releaseDir || !packageNameWithVersion) {
  throw new Error("usage: node push-release-archive.mjs RELEASE_DIR PACKAGE@VERSION")
}

const npmrc = fs.readFileSync(path.resolve(".npmrc"), "utf8")
const configPath = path.join(os.homedir(), "Library", "Preferences", "tscircuit-nodejs", "config.json")
const config = fs.existsSync(configPath) ? JSON.parse(fs.readFileSync(configPath, "utf8")) : {}
const token = npmrc.match(/:_authToken=(.+)$/m)?.[1]?.trim() ?? config.sessionToken
if (!token) throw new Error("tscircuit registry token not found")

const binaryExtensions = new Set([
  ".glb", ".gltf", ".obj", ".stl", ".png", ".jpg", ".jpeg", ".gif",
  ".webp", ".zip", ".gz", ".tar",
])

function listFiles(directory, base = directory) {
  return fs.readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
    if (entry.name.startsWith(".")) return []
    const absolute = path.join(directory, entry.name)
    return entry.isDirectory() ? listFiles(absolute, base) : [
      { absolute, relative: path.relative(base, absolute) },
    ]
  })
}

const files = listFiles(path.resolve(releaseDir)).map(({ absolute, relative }) => {
  const content = fs.readFileSync(absolute)
  const binary = binaryExtensions.has(path.extname(relative).toLowerCase()) ||
    content.subarray(0, 8192).includes(0)
  return binary
    ? { file_path: relative, content_base64: content.toString("base64") }
    : { file_path: relative, content_text: content.toString("utf8") }
})

const archive = gzipSync(JSON.stringify({ files }), { level: 9 })
console.log(`Uploading ${files.length} files (${archive.length} compressed bytes)`) 

async function post(endpoint, body) {
  const response = await fetch(`https://registry-api.tscircuit.com/${endpoint}`, {
    method: "POST",
    headers: {
      authorization: `Bearer ${token}`,
      "content-type": "application/json",
    },
    body: JSON.stringify(body),
  })
  const text = await response.text()
  if (!response.ok) throw new Error(`${endpoint}: HTTP ${response.status}: ${text.slice(0, 500)}`)
  return text
}

await post("package_files/upload_archive", {
  package_name_with_version: packageNameWithVersion,
  archive_base64: archive.toString("base64"),
})
await post("package_releases/update", {
  package_name_with_version: packageNameWithVersion,
  ready_to_build: true,
})
console.log(`Published ${packageNameWithVersion}`)