Dependency update

This commit is contained in:
2025-04-08 22:04:41 +02:00
committed by Philipp Horstenkamp
parent 78549e06b4
commit f7b40cb8dd
492 changed files with 7483 additions and 47496 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env node
const { Command } = require('commander')
const program = require('commander')
const { ScreepsAPI } = require('../')
const fs = require('fs')
const util = require('util')
@ -8,15 +8,15 @@ const path = require('path')
const readFile = util.promisify(fs.readFile)
const writeFile = util.promisify(fs.writeFile)
async function init(opts) {
return ScreepsAPI.fromConfig(opts.server)
async function init (opts) {
return ScreepsAPI.fromConfig(opts.parent.server)
}
async function json(data) {
async function json (data) {
process.stdout.write(JSON.stringify(data))
}
async function out(data, opts) {
async function out (data, opts) {
data = await data
data = (data && data.data) || data
if (process.stdout.isTTY) {
@ -26,29 +26,18 @@ async function out(data, opts) {
}
}
async function run() {
const program = new Command()
/** @param {string} name */
const commandBase = (name, args = '') => {
const command = new Command(name)
command
.arguments(args)
.option('--server <server>', 'Server config to use', 'main')
program.addCommand(command)
return command
}
async function run () {
program
.version(require('../package.json').version)
.option('--server <server>', 'Server config to use', 'main')
commandBase('raw', '<cmd> [args...]')
program
.command('raw <cmd> [args...]')
.description('Execute raw API call')
.action(async function (cmd, args, opts) {
try {
const api = await init(opts)
const path = cmd.split('.')
/** @type {function} */
let fn = api.raw
for (const part of path) {
fn = fn[part]
@ -57,13 +46,14 @@ async function run() {
console.log('Invalid cmd')
return
}
out(fn.apply(api, args))
out(fn(...args))
} catch (e) {
console.error(e)
}
})
commandBase('memory', '[path]')
program
.command('memory [path]')
.description(`Get Memory contents`)
.option('--set <file>', 'Sets the memory path to the contents of file')
.option('--allow-root', 'Allows writing without path')
@ -92,7 +82,8 @@ async function run() {
}
})
commandBase('segment', '<segment>')
const seg = program
.command('segment <segment>')
.description(`Get segment contents. Use 'all' to get all)`)
.option('--set <file>', 'Sets the segment content to the contents of file')
.option('-s --shard <shard>', 'Shard to read from', 'shard0')
@ -125,7 +116,8 @@ async function run() {
}
})
commandBase('download')
program
.command('download')
.description(`Download code`)
.option('-b --branch <branch>', 'Code branch', 'default')
.option('-d --dir <dir>', 'Directory to save in (defaults to outputing in console)')
@ -152,7 +144,8 @@ async function run() {
}
})
commandBase('upload', '<files...>')
program
.command('upload <files...>')
.description(`Upload code`)
.option('-b --branch <branch>', 'Code branch', 'default')
.action(async function (files, opts) {
@ -183,7 +176,7 @@ async function run() {
program.outputHelp()
}
await program.parseAsync()
program.parse(process.argv)
}
run().then(data => {