refactor: migrate to screeps-api v2 and update actions to node 22
This commit is contained in:
+8
-4
@@ -250,7 +250,7 @@ function sleep(ms) {
|
||||
* Calls `onProgress(elapsed, targetTicks)` on every poll so the caller can
|
||||
* log progress at whatever cadence it chooses.
|
||||
*
|
||||
* @param {import('screeps-api').ScreepsAPI} api
|
||||
* @param {import('screeps-api').ScreepsHttpClient} api
|
||||
* @param {number} startTick - Tick number recorded before monitoring started
|
||||
* @param {number} targetTicks - Stop when (currentTick - startTick) >= this
|
||||
* @param {string|undefined} shard - "shard0" for official, undefined for private
|
||||
@@ -270,7 +270,9 @@ export async function pollUntilDone(
|
||||
let elapsed = 0;
|
||||
while (elapsed < targetTicks && !shouldStop()) {
|
||||
await sleep(intervalMs);
|
||||
const { time } = await api.time(shard);
|
||||
const { time } = await (typeof api.gameTime === "function"
|
||||
? api.gameTime(shard)
|
||||
: api.time(shard));
|
||||
elapsed = time - startTick;
|
||||
onProgress(elapsed, targetTicks);
|
||||
}
|
||||
@@ -309,7 +311,7 @@ export async function pollUntilDone(
|
||||
* 6. If logToFile=true: write buffered stdout to a temp file and upload artifact.
|
||||
* 7. Return MonitorResult.
|
||||
*
|
||||
* @param {import('screeps-api').ScreepsAPI} api
|
||||
* @param {import('screeps-api').ScreepsHttpClient} api
|
||||
* @param {MonitorOptions} opts
|
||||
* @returns {Promise<MonitorResult>}
|
||||
*/
|
||||
@@ -337,7 +339,9 @@ export async function monitorConsole(api, opts) {
|
||||
let lastProgressTick = 0;
|
||||
|
||||
// Step 1: record starting tick
|
||||
const { time: startTick } = await api.time(shard);
|
||||
const { time: startTick } = await (typeof api.gameTime === "function"
|
||||
? api.gameTime(shard)
|
||||
: api.time(shard));
|
||||
|
||||
// Step 2: connect socket + subscribe
|
||||
await api.socket.connect();
|
||||
|
||||
Reference in New Issue
Block a user