diff --git a/package.json b/package.json index 85d6682..3f9c262 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,11 @@ "version": "3.0.0", "description": "", "main": "index.js", + "//": "If you add or change the names of destinations in screeps.json, make sure you update these scripts to reflect the changes", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "push-main": "rollup -c --dest main", + "push-sim": "rollup -c --dest sim", + "push-pserver": "rollup -c --dest pserver" }, "repository": { "type": "git", diff --git a/rollup.config.js b/rollup.config.js index d582e94..2e45137 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,6 +6,16 @@ import commonjs from "rollup-plugin-commonjs"; import screeps from "rollup-plugin-screeps"; import typescript from "rollup-plugin-typescript2"; +const config = require("./screeps"); + +let cfg; +const i = process.argv.indexOf("--dest") + 1; +if (i == 0) { + console.log("No destination specified - code will be compiled but not uploaded"); +} else if (i >= process.argv.length || (cfg = config[process.argv[i]]) == null) { + throw new Error("Invalid upload destination"); +} + export default { input: "src/main.ts", output: { @@ -20,6 +30,6 @@ export default { resolve(), commonjs(), typescript({tsconfig: "./tsconfig.json"}), - screeps({configFile: "./screeps.json"}) + screeps({config: cfg, dryRun: cfg == null}) ] } diff --git a/screeps.sample.json b/screeps.sample.json index 3faceb0..94be95b 100644 --- a/screeps.sample.json +++ b/screeps.sample.json @@ -1,9 +1,29 @@ { - "email": "you@provider.tld", - "password": "Password", - "protocol": "https", - "hostname": "screeps.com", - "port": 443, - "path": "/", - "branch": "auto" + "main": { + "email": "you@provider.tld", + "password": "Password", + "protocol": "https", + "hostname": "screeps.com", + "port": 443, + "path": "/", + "branch": "main" + }, + "sim": { + "email": "you@provider.tld", + "password": "Password", + "protocol": "https", + "hostname": "screeps.com", + "port": 443, + "path": "/", + "branch": "sim" + }, + "pserver": { + "email": "username", + "password": "Password", + "protocol": "http", + "hostname": "1.2.3.4", + "port": 21025, + "path": "/", + "branch": "main" + } }