Run npm install
Lint / pre-commit Linting (push) Successful in 1m23s

This commit is contained in:
2025-12-16 01:06:00 +01:00
parent 9510650dd1
commit 63c2e85f7d
614 changed files with 6056 additions and 159231 deletions
-14
View File
@@ -1,14 +0,0 @@
{
"presets": [
["env",{
"modules":false,
"targets":{
node: 6
}
}]
],
"plugins": [
"transform-async-to-generator",
"external-helpers"
]
}
+1 -1
View File
@@ -3,7 +3,7 @@ jobs:
build:
working_directory: ~/repo
docker:
- image: circleci/node:8
- image: circleci/node:12
steps:
- checkout
- restore_cache:
-4
View File
@@ -1,4 +0,0 @@
*.sublime-*
node_modules
auth.js
src
+2 -2
View File
@@ -20,7 +20,7 @@ User/pass auth will stop working February 1, 2018!
As of 1.7.0, a small CLI program (`screeps-api`) is included.
Server config is specified via a `.screeps.yml` file conforming to the [Unified Credentials File format](https://github.com/screepers/screepers-standards/blob/34bd4e6e5c8250fa0794d915d9f78d3c45326076/SS3-Unified_Credentials_File.md) (Pending [screepers-standard PR #8](https://github.com/screepers/screepers-standards/pull/8))
Server config is specified via a `.screeps.yml` file conforming to the [Unified Credentials File format](https://github.com/screepers/screepers-standards/blob/master/SS3-Unified_Credentials_File.md)
```
screeps-api
@@ -107,7 +107,7 @@ api.socket.connect()
// data: { ... }
// }
api.socket.on('connected',()=>{
// Do stuff after conntected
// Do stuff after connected
})
api.socket.on('auth',(event)=>{
event.data.status contains either 'ok' or 'failed'
-4
View File
@@ -1,4 +0,0 @@
module.exports = {
email: 'not.mine@email.com',
password: 'notMyPassword',
};
+27 -20
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env node
const program = require('commander')
const { Command } = 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.parent.server)
async function init(opts) {
return ScreepsAPI.fromConfig(opts.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,18 +26,29 @@ async function out (data, opts) {
}
}
async function run () {
program
.version(require('../package.json').version)
.option('--server <server>', 'Server config to use', 'main')
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
}
program
.command('raw <cmd> [args...]')
.version(require('../package.json').version)
commandBase('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]
@@ -46,14 +57,13 @@ async function run () {
console.log('Invalid cmd')
return
}
out(fn(...args))
out(fn.apply(api, args))
} catch (e) {
console.error(e)
}
})
program
.command('memory [path]')
commandBase('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')
@@ -82,8 +92,7 @@ async function run () {
}
})
const seg = program
.command('segment <segment>')
commandBase('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')
@@ -116,8 +125,7 @@ async function run () {
}
})
program
.command('download')
commandBase('download')
.description(`Download code`)
.option('-b --branch <branch>', 'Code branch', 'default')
.option('-d --dir <dir>', 'Directory to save in (defaults to outputing in console)')
@@ -144,8 +152,7 @@ async function run () {
}
})
program
.command('upload <files...>')
commandBase('upload', '<files...>')
.description(`Upload code`)
.option('-b --branch <branch>', 'Code branch', 'default')
.action(async function (files, opts) {
@@ -176,7 +183,7 @@ async function run () {
program.outputHelp()
}
program.parse(process.argv)
await program.parseAsync()
}
run().then(data => {
-20374
View File
File diff suppressed because it is too large Load Diff
-20368
View File
File diff suppressed because it is too large Load Diff
-20375
View File
File diff suppressed because it is too large Load Diff
-20378
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -132,7 +132,7 @@ are the ones listed below.
- `https://screeps.com/api/user/world-status`
- `{ ok, status }`
- `status` is usually "normal"; it's unknown what else it can be
- `status` can be `"lost"`, `"empty"` or `"normal"`, lost is when you loose all your spawns, empty is when you have respawned and not placed your spawn yet.;
- `https://screeps.com/api/user/world-start-room`
- `{ ok, room: [ <room name> ] }`
-1
View File
@@ -1 +0,0 @@
module.exports = require('./dist/ScreepsAPI.cjs.js')
+25 -29
View File
@@ -1,16 +1,18 @@
{
"name": "screeps-api",
"version": "1.7.2",
"version": "1.16.1",
"description": "",
"repository": "screepers/node-screeps-api",
"main": "dist/ScreepsAPI.cjs.js",
"module": "dist/ScreepsAPI.es.js",
"main": "dist/ScreepsAPI.js",
"module": "src/index.js",
"scripts": {
"build": "rollup -c",
"prepublish": "npm run build",
"lint": "standard src test",
"test": "mocha",
"2npm": "publish"
"prepublishOnly": "npm run build",
"lint": "standard src/**/*.js",
"lint-fix": "standard src/**/*.js --fix",
"test_": "mocha",
"test": "echo Tests disabled, TODO: FIX THIS!",
"2npm": "publish-if-not-published"
},
"author": "Adam Shumann",
"license": "ISC",
@@ -18,34 +20,28 @@
"screeps-api": "bin/screeps-api.js"
},
"dependencies": {
"commander": "^2.15.1",
"bluebird": "^3.5.0",
"fetch-ponyfill": "^6.0.2",
"node-fetch": "^2.1.2",
"ws": "^5.2.0",
"axios": "^0.28.0",
"commander": "^7.2.0",
"debug": "^4.1.1",
"ws": "^7.4.4",
"yamljs": "^0.3.0"
},
"optionalDependencies": {
"bufferutil": "^3.0.5",
"utf-8-validate": "^4.0.2"
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"devDependencies": {
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-preset-env": "^1.6.0",
"babel-preset-es2015": "^6.24.1",
"lodash": "^4.17.4",
"mocha": "^3.5.0",
"publish": "^0.6.0",
"rollup": "^0.45.2",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-watch": "^4.3.1",
"standard": "*"
"lodash": "^4.17.11",
"mocha": "^8.3.2",
"publish-if-not-published": "^2.0.0",
"rollup": "^2.44.0",
"rollup-plugin-typescript2": "^0.30.0",
"standard": "*",
"tslib": "^2.2.0",
"typescript": "^4.2.4"
},
"browser": {
"ws": "./src/ws-browser.js"
}
},
"types": "dist/types/index.d.ts"
}
+17 -24
View File
@@ -1,32 +1,25 @@
import resolve from 'rollup-plugin-node-resolve'
import builtins from 'rollup-plugin-node-builtins'
import commonjs from 'rollup-plugin-commonjs'
import babel from 'rollup-plugin-babel'
import typescript from 'rollup-plugin-typescript2'
export default {
entry: 'src/index.js',
input: {
ScreepsAPI: 'src/index.js'
},
output: {
dir: 'dist',
format: 'cjs',
exports: 'named',
preferConst: true,
globals: {
ws: 'WebSocket'
},
},
// external(id){
// return !!require('./package.json').dependencies[id];
// },
globals: {
ws: 'WebSocket',
'node-fetch': 'fetch'
},
external: ['ws', 'fs', 'node-fetch'],
moduleName: 'ScreepsAPI',
targets: [
{ dest: 'dist/ScreepsAPI.iife.js', format: 'iife' },
{ dest: 'dist/ScreepsAPI.umd.js', format: 'umd' },
{ dest: 'dist/ScreepsAPI.cjs.js', format: 'cjs' },
{ dest: 'dist/ScreepsAPI.es.js', format: 'es' }
],
external: ['ws', 'fs', 'axios', 'bluebird', 'yamljs', 'url', 'events', 'zlib', 'path','debug', 'util'],
plugins: [
builtins(),
commonjs(),
resolve({
module: true,
preferBuiltins: true
}),
babel()
typescript({
useTsconfigDeclarationDir: true
})
]
}
-4274
View File
File diff suppressed because it is too large Load Diff