Merge branch 'master' into migrate-to-eslint
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,7 @@
|
||||
/tsc-out
|
||||
/node_modules
|
||||
/_book
|
||||
/build/*
|
||||
|
||||
# TypeScript definitions installed by Typings
|
||||
/typings
|
||||
|
||||
12
README.md
12
README.md
@@ -6,15 +6,13 @@ Screeps Typescript Starter is a starting point for a Screeps AI written in Types
|
||||
|
||||
You will need:
|
||||
|
||||
- [Node.JS](https://nodejs.org/en/download) (>= 8.0.0)
|
||||
- A Package Manager ([Yarn](https://yarnpkg.com/en/docs/getting-started) or [npm](https://docs.npmjs.com/getting-started/installing-node))
|
||||
- Rollup CLI (Optional, install via `npm install -g rollup`)
|
||||
- Build tools (`apt install build-essential` for Ubuntu, [Visual Studio](https://www.visualstudio.com/vs/) for Windows, etc)
|
||||
|
||||
- [Node.JS](https://nodejs.org/en/download) (10.x)
|
||||
- A Package Manager ([Yarn](https://yarnpkg.com/en/docs/getting-started) or [npm](https://docs.npmjs.com/getting-started/installing-node))
|
||||
- Rollup CLI (Optional, install via `npm install -g rollup`)
|
||||
|
||||
Download the latest source [here](https://github.com/screepers/screeps-typescript-starter/archive/master.zip) and extract it to a folder.
|
||||
|
||||
Open the folder in your terminal and run your package manager to install install the required packages and TypeScript declaration files:
|
||||
Open the folder in your terminal and run your package manager to install the required packages and TypeScript declaration files:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
@@ -50,7 +48,7 @@ We've also spent some time reworking the documentation from the ground-up, which
|
||||
|
||||
Maintaining the docs will also become a more community-focused effort, which means you too, can take part in improving the docs for this starter kit.
|
||||
|
||||
To visit the docs, [click here](https://screepers.gitbooks.io/screeps-typescript-starter/).
|
||||
To visit the docs, [click here](https://screepers.gitbook.io/screeps-typescript-starter/).
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -22,5 +22,27 @@ You're done! Now go to your Screeps client and make sure your code is deployed p
|
||||
|
||||

|
||||
|
||||
## Deploying to a private server
|
||||
|
||||
Screeps also lets you run your own private server. This can be a great way to test your code in a safe environment, and you can add mods that allow you to customize your server as well, such as drastically increasing the tickrate.
|
||||
|
||||
To find out more about how to use or run your own private server, see the official server repository [here](https://github.com/screeps/screeps).
|
||||
|
||||
To deploy to a private server, run the following command:
|
||||
|
||||
```bash
|
||||
npm run push-pserver
|
||||
```
|
||||
|
||||
If you are having trouble pushing your code, make sure to check your `screeps.json`.
|
||||
|
||||
For `"pserver"` the json properties are a little confusing:
|
||||
|
||||
- `"email"` should actually contain the username of your account on the private server you are trying to connect to, __which may be different from your account on the official Screeps shards!__
|
||||
|
||||
- `"password"` will need to be set for that account manually on the private server, [see here](https://github.com/screeps/screeps#authentication)
|
||||
|
||||
- `"hostname"` is the IP address of the server. If you are hosting your own server locally, the default localhost IP for most networks is `127.0.0.1`
|
||||
|
||||
Ready for something extra? [Read on.](../in-depth/module-bundling.md)
|
||||
|
||||
|
||||
@@ -42,13 +42,40 @@ magnitude, it is recommended to prefer unit tests wherever possible.
|
||||
|
||||
## Integration Testing
|
||||
|
||||
### Installing Screeps Server Mockup
|
||||
|
||||
Before starting to use integration testing, you must install [screeps-server-mockup](https://github.com/screepers/screeps-server-mockup) to your project.
|
||||
Please view that repository for more instruction on installation.
|
||||
|
||||
```bash
|
||||
# Using yarn:
|
||||
yarn add -D screeps-server-mockup
|
||||
# Using npm
|
||||
npm install --save-dev screeps-server-mockup
|
||||
```
|
||||
|
||||
You will also need to add scripts to run integration tests.
|
||||
|
||||
In `package.json`, add a new `test-integration` script and add the new integration testing to the main `test` script.
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"test": "npm run test-unit && npm run test-integration",
|
||||
"test-integration": "npm run build && rollup -c rollup.test-integration-config.js && mocha dist/test-integration.bundle.js",
|
||||
}
|
||||
```
|
||||
|
||||
Now you can run integration tests by using the `test-integration` script or run both unit and integration tests using the `test` script.
|
||||
|
||||
### Integration Testing with Screeps Server Mockup
|
||||
|
||||
Integration testing is for code that depends heavily on having a full game
|
||||
environment. Integration tests are completely representative of the real game
|
||||
(in fact they run with an actual Screeps server). This comes at the cost of
|
||||
performance and very involved setup when creating specific scenarios.
|
||||
|
||||
Server testing support is implmented via
|
||||
[screeps-server-mockup](https://github.com/Hiryus/screeps-server-mockup). View
|
||||
Server testing support is implemented via
|
||||
[screeps-server-mockup](https://github.com/screepers/screeps-server-mockup). View
|
||||
this repository for more information on the API.
|
||||
|
||||
By default the test helper will create a "stub" world with a 3x3 grid of rooms
|
||||
|
||||
23
package.json
23
package.json
@@ -10,9 +10,9 @@
|
||||
"push-main": "rollup -c --environment DEST:main",
|
||||
"push-pserver": "rollup -c --environment DEST:pserver",
|
||||
"push-sim": "rollup -c --environment DEST:sim",
|
||||
"test": "npm run test-unit && npm run test-integration",
|
||||
"test": "npm run test-unit",
|
||||
"test-unit": "rollup -c rollup.test-unit-config.js && mocha dist/test-unit.bundle.js",
|
||||
"test-integration": "npm run build && rollup -c rollup.test-integration-config.js && mocha dist/test-integration.bundle.js",
|
||||
"test-integration": "echo 'See docs/in-depth/testing.md for instructions on enabling integration tests'",
|
||||
"watch-main": "rollup -cw --environment DEST:main",
|
||||
"watch-pserver": "rollup -cw --environment DEST:pserver",
|
||||
"watch-sim": "rollup -cw --environment DEST:sim"
|
||||
@@ -27,12 +27,18 @@
|
||||
"url": "https://github.com/screepers/screeps-typescript-starter/issues"
|
||||
},
|
||||
"homepage": "https://github.com/screepers/screeps-typescript-starter#readme",
|
||||
"engines": {
|
||||
"node": "10.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^11.1.0",
|
||||
"@rollup/plugin-multi-entry": "^3.0.0",
|
||||
"@rollup/plugin-node-resolve": "^7.1.3",
|
||||
"@types/chai": "^4.1.6",
|
||||
"@types/lodash": "^3.10.1",
|
||||
"@types/lodash": "3.10.2",
|
||||
"@types/mocha": "^5.2.5",
|
||||
"@types/node": "^10.5.5",
|
||||
"@types/screeps": "^3.0.0",
|
||||
"@types/node": "^13.13.1",
|
||||
"@types/screeps": "^3.1.0",
|
||||
"@types/sinon": "^5.0.5",
|
||||
"@types/sinon-chai": "^3.2.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.6.1",
|
||||
@@ -49,12 +55,9 @@
|
||||
"rollup": "^0.63.4",
|
||||
"rollup-plugin-buble": "^0.19.4",
|
||||
"rollup-plugin-clear": "^2.0.7",
|
||||
"rollup-plugin-commonjs": "^9.1.4",
|
||||
"rollup-plugin-multi-entry": "^2.0.2",
|
||||
"rollup-plugin-node-resolve": "^3.3.0",
|
||||
"rollup-plugin-nodent": "^0.2.2",
|
||||
"rollup-plugin-screeps": "^0.1.2",
|
||||
"rollup-plugin-typescript2": "^0.16.1",
|
||||
"rollup-plugin-screeps": "^1.0.0",
|
||||
"rollup-plugin-typescript2": "^0.27.0",
|
||||
"sinon": "^6.3.5",
|
||||
"sinon-chai": "^3.2.0",
|
||||
"ts-node": "^7.0.1",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
import clear from "rollup-plugin-clear";
|
||||
import resolve from "rollup-plugin-node-resolve";
|
||||
import commonjs from "rollup-plugin-commonjs";
|
||||
import typescript from "rollup-plugin-typescript2";
|
||||
import screeps from "rollup-plugin-screeps";
|
||||
import clear from 'rollup-plugin-clear';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
import screeps from 'rollup-plugin-screeps';
|
||||
|
||||
let cfg;
|
||||
const dest = process.env.DEST;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
import clear from "rollup-plugin-clear";
|
||||
import resolve from "rollup-plugin-node-resolve";
|
||||
import commonjs from "rollup-plugin-commonjs";
|
||||
import typescript from "rollup-plugin-typescript2";
|
||||
import clear from 'rollup-plugin-clear';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
import buble from 'rollup-plugin-buble';
|
||||
import multiEntry from 'rollup-plugin-multi-entry';
|
||||
import multiEntry from '@rollup/plugin-multi-entry';
|
||||
import nodent from 'rollup-plugin-nodent';
|
||||
|
||||
export default {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
import clear from "rollup-plugin-clear";
|
||||
import resolve from "rollup-plugin-node-resolve";
|
||||
import commonjs from "rollup-plugin-commonjs";
|
||||
import typescript from "rollup-plugin-typescript2";
|
||||
import clear from 'rollup-plugin-clear';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
import buble from 'rollup-plugin-buble';
|
||||
import multiEntry from 'rollup-plugin-multi-entry';
|
||||
import multiEntry from '@rollup/plugin-multi-entry';
|
||||
|
||||
export default {
|
||||
input: 'test/unit/**/*.test.ts',
|
||||
|
||||
@@ -9,8 +9,8 @@ const DIST_MAIN_JS = 'dist/main.js';
|
||||
* manipulating the terrain and game state.
|
||||
*/
|
||||
class IntegrationTestHelper {
|
||||
private _server;
|
||||
private _player;
|
||||
private _server: any;
|
||||
private _player: any;
|
||||
|
||||
get server() {
|
||||
return this._server;
|
||||
@@ -56,8 +56,4 @@ before(() => {
|
||||
stdHooks.hookWrite();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
process.exit();
|
||||
});
|
||||
|
||||
export const helper = new IntegrationTestHelper();
|
||||
|
||||
@@ -10,3 +10,4 @@
|
||||
|
||||
--recursive
|
||||
--timeout 5000
|
||||
--exit
|
||||
|
||||
Reference in New Issue
Block a user