All checks were successful
PR Checks / plugin-checks (pull_request) Successful in -1m44s
The repository RunicNPC is built in (docs/runicnpc/PLAN.md §9, stage 0): - plugin/RunicNPC.cs: `// Requires: Kits` (D217), `[Info]` with the 0.0.0 placeholder the release stamps, `RunicNpc_ApiVersion()` (API 1), and `rnpc.status`, which reports the version and which hooks have fired. It spawns nothing. - plugin.toml: the API version, the framework floors it was loaded on (Oxide 2.0.7726, Carbon 2.0.259) and requires_plugins = ["Kits"]. - scripts/checkPlugin.js, adapted from Rust-Plugins': every hook listed and void unless written down; chat-command signatures; every RunicNpc_ call reachable by Call (the HumanNPC trap, PLAN.md §1.2); ApiVersion, `// Requires:` and [Info] agreeing with plugin.toml. 23 self-tests, including the real plugin and a CRLF checkout. - PR Checks on PRs into main and edge; the release workflow on main, with Rust-Plugins' release engine unchanged and an adapter that ships runicnpc-<ver>.tar.gz (runicnpc/RunicNPC.cs + manifest.json) and SHA256SUMS. No bundle dispatch until stage 4. - tools/: the rig panel scripts, with the panel and server ids moved into a git-ignored tools/rigs.json. `con.js` became `console.js`: CON is a reserved device name on Windows, and git there cannot open the file. - README, CONTRIBUTING (edge-based flow, AI disclosure, borrow-not-copy), SECURITY, the code of conduct, issue and PR templates. `feat:` so the cutover to main cuts the first release, 0.1.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
53 lines
2.0 KiB
JavaScript
53 lines
2.0 KiB
JavaScript
// The Pterodactyl panel the test rigs run on, shared by rig.js and console.js.
|
|
//
|
|
// Nothing here is shipped: tools/ is developer scaffolding (docs/runicnpc/PLAN.md §9, stage 0).
|
|
// Where the panel is and which servers are the rigs is local knowledge, so it lives in
|
|
// tools/rigs.json (git-ignored; copy tools/rigs.example.json). The panel's client API key is read
|
|
// at call time from the file rigs.json names, and is never printed.
|
|
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const CONFIG = path.join(__dirname, 'rigs.json')
|
|
|
|
function load() {
|
|
if (!fs.existsSync(CONFIG)) {
|
|
console.error(`No ${CONFIG}. Copy tools/rigs.example.json to tools/rigs.json and fill it in.`)
|
|
process.exit(2)
|
|
}
|
|
const config = JSON.parse(fs.readFileSync(CONFIG, 'utf8'))
|
|
|
|
// The key file holds `name: value` lines; the panel's client key is `user`.
|
|
const keys = Object.fromEntries(
|
|
fs
|
|
.readFileSync(config.tokenFile, 'utf8')
|
|
.split(/\r?\n/)
|
|
.filter((l) => l.includes(':'))
|
|
.map((l) => [l.slice(0, l.indexOf(':')).trim(), l.slice(l.indexOf(':') + 1).trim()])
|
|
)
|
|
if (!keys.user) {
|
|
console.error(`${config.tokenFile} has no "user:" line (the panel's client API key).`)
|
|
process.exit(2)
|
|
}
|
|
|
|
return { panel: config.panel.replace(/\/+$/, ''), rigs: config.rigs, key: keys.user }
|
|
}
|
|
|
|
/** The server id of a rig by name, or exit with the names there are. */
|
|
function serverId(config, rig) {
|
|
const id = config.rigs[rig]
|
|
if (!id) {
|
|
console.error(`Unknown rig "${rig}". Known: ${Object.keys(config.rigs).join(', ')}`)
|
|
process.exit(2)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// Git Bash (MSYS) rewrites an argument starting with / into C:/Program Files/Git/...; undo it, so
|
|
// a mangled path never reaches the server. On 2026-09-29 every rig file call failed this way and
|
|
// looked like an outage of the panel's file API.
|
|
const unmsys = (x) =>
|
|
typeof x === 'string' ? x.replace(/^[A-Za-z]:\/Program Files\/Git(?=\/|$)/, '') || '/' : x
|
|
|
|
module.exports = { load, serverId, unmsys }
|