From 93537211275a4c6b5b9092210b7f48441e999094 Mon Sep 17 00:00:00 2001 From: brisberg Date: Wed, 12 Feb 2020 11:48:31 -0800 Subject: [PATCH 01/13] Fixed Mocha from exiting before reporter has a chance to print stack traces --- test/integration/helper.ts | 4 ---- test/mocha.opts | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/test/integration/helper.ts b/test/integration/helper.ts index 8d9c28e..bb8e162 100644 --- a/test/integration/helper.ts +++ b/test/integration/helper.ts @@ -56,8 +56,4 @@ before(() => { stdHooks.hookWrite(); }); -after(() => { - process.exit(); -}); - export const helper = new IntegrationTestHelper(); diff --git a/test/mocha.opts b/test/mocha.opts index e94ac68..c3478c9 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -10,3 +10,4 @@ --recursive --timeout 5000 +--exit From 9c25e720ad7b6d7d1c750b88f6f6ea909202b356 Mon Sep 17 00:00:00 2001 From: Skyler Kehren Date: Wed, 26 Feb 2020 08:02:12 +0200 Subject: [PATCH 02/13] Cleanup integration testing docs Removes `test-integration` script Removes integration from `test` script Add installation instructions for `screeps-server-mockup` in docs --- README.md | 4 +--- docs/in-depth/testing.md | 24 +++++++++++++++++++++++- package.json | 3 +-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e00e06b..b28fc33 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,7 @@ 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) - + - 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. diff --git a/docs/in-depth/testing.md b/docs/in-depth/testing.md index 37582b9..3de0d15 100644 --- a/docs/in-depth/testing.md +++ b/docs/in-depth/testing.md @@ -42,13 +42,35 @@ 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. + +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 +[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 diff --git a/package.json b/package.json index 9f61cab..40bc813 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,8 @@ "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", "watch-main": "rollup -cw --environment DEST:main", "watch-pserver": "rollup -cw --environment DEST:pserver", "watch-sim": "rollup -cw --environment DEST:sim" From de4b19b2deae537a1b485ce320a10b965c6f78d0 Mon Sep 17 00:00:00 2001 From: Skyler Kehren Date: Wed, 26 Feb 2020 08:07:17 +0200 Subject: [PATCH 03/13] Fix codeblock formatting --- docs/in-depth/testing.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/in-depth/testing.md b/docs/in-depth/testing.md index 3de0d15..2d2f033 100644 --- a/docs/in-depth/testing.md +++ b/docs/in-depth/testing.md @@ -53,10 +53,8 @@ In `package.json`, add a new `test-integration` script and add the new integrati ```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", - ... } ``` From 67bc4a7eaf44eed2d383634a463f537a2695e53f Mon Sep 17 00:00:00 2001 From: Caleb Lovell Date: Mon, 23 Mar 2020 23:36:10 -0600 Subject: [PATCH 04/13] add brief instructions for deploying to a private server --- docs/getting-started/deploying.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/getting-started/deploying.md b/docs/getting-started/deploying.md index 40353ca..35583bb 100644 --- a/docs/getting-started/deploying.md +++ b/docs/getting-started/deploying.md @@ -22,5 +22,27 @@ You're done! Now go to your Screeps client and make sure your code is deployed p ![deploying-2](../.gitbook/assets/deploying-2.png) +## 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) From b13fb751cc7522d9f9e921630de24a4d1aad7c00 Mon Sep 17 00:00:00 2001 From: brisberg Date: Mon, 30 Mar 2020 17:21:06 -0700 Subject: [PATCH 05/13] Specified Node 10.x as engine for project, as screeps now runs on Node 10 --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f61cab..c1b2581 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,14 @@ "url": "https://github.com/screepers/screeps-typescript-starter/issues" }, "homepage": "https://github.com/screepers/screeps-typescript-starter#readme", + "engines": { + "node": "10.x" + }, "devDependencies": { "@types/chai": "^4.1.6", "@types/lodash": "^3.10.1", "@types/mocha": "^5.2.5", - "@types/node": "^10.5.5", + "@types/node": "^10.17.18", "@types/screeps": "^3.0.0", "@types/sinon": "^5.0.5", "@types/sinon-chai": "^3.2.0", From b0225d47329dbd2c2c87ab8a9ff47d678fca93fe Mon Sep 17 00:00:00 2001 From: brisberg Date: Mon, 30 Mar 2020 17:36:34 -0700 Subject: [PATCH 06/13] Updated rollup to 1.32 and plugin deps --- package.json | 10 +++++----- rollup.config.js | 10 +++++----- rollup.test-integration-config.js | 10 +++++----- rollup.test-unit-config.js | 10 +++++----- test/integration/helper.ts | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 9f61cab..155d917 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,9 @@ }, "homepage": "https://github.com/screepers/screeps-typescript-starter#readme", "devDependencies": { + "@rollup/plugin-commonjs": "^11.0.2", + "@rollup/plugin-multi-entry": "^3.0.0", + "@rollup/plugin-node-resolve": "^7.1.1", "@types/chai": "^4.1.6", "@types/lodash": "^3.10.1", "@types/mocha": "^5.2.5", @@ -39,15 +42,12 @@ "lodash": "^3.10.1", "mocha": "^5.2.0", "prettier": "^1.14.0", - "rollup": "^0.63.4", + "rollup": "^1.32.1", "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-typescript2": "^0.27.0", "sinon": "^6.3.5", "sinon-chai": "^3.2.0", "ts-node": "^7.0.1", diff --git a/rollup.config.js b/rollup.config.js index 9d47d4e..b0ea090 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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; diff --git a/rollup.test-integration-config.js b/rollup.test-integration-config.js index 556bdf7..5493f10 100644 --- a/rollup.test-integration-config.js +++ b/rollup.test-integration-config.js @@ -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 { diff --git a/rollup.test-unit-config.js b/rollup.test-unit-config.js index fc8c095..4cea680 100644 --- a/rollup.test-unit-config.js +++ b/rollup.test-unit-config.js @@ -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', diff --git a/test/integration/helper.ts b/test/integration/helper.ts index bb8e162..18bc749 100644 --- a/test/integration/helper.ts +++ b/test/integration/helper.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; From 3fbd0064f9031fe9bc7d5b1ce404237cae492006 Mon Sep 17 00:00:00 2001 From: "J. Schreuders" <3071062+99linesofcode@users.noreply.github.com> Date: Mon, 6 Apr 2020 00:23:52 +0200 Subject: [PATCH 07/13] Fix broken link to docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e00e06b..e88f4cf 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,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 From b5771202e86978fb943a149b0d456a1fa4a6aea0 Mon Sep 17 00:00:00 2001 From: Skyler Kehren Date: Sat, 11 Apr 2020 09:50:32 +0300 Subject: [PATCH 08/13] Update @types/screeps to 3.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e7bde24..52c7d79 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@types/lodash": "^3.10.1", "@types/mocha": "^5.2.5", "@types/node": "^10.17.18", - "@types/screeps": "^3.0.0", + "@types/screeps": "^3.1.0", "@types/sinon": "^5.0.5", "@types/sinon-chai": "^3.2.0", "chai": "^4.2.0", From 7907d3c819d1eb70ac6f2a35db42b79d1ef22fd3 Mon Sep 17 00:00:00 2001 From: Skyler Kehren Date: Mon, 20 Apr 2020 19:38:02 +0300 Subject: [PATCH 09/13] Update Node,TypeScript,Rollup dependencies @types/lodash@3.10.3 broke the template since lodash is assumed to be global. Adds a shim to types file to allow continued use of a global lodash since the game provides 3.10 automatically. Update rollup to 2.0, and associated rollup plugins --- package.json | 26 +++++++++++++------------- src/types.d.ts | 7 +++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 52c7d79..a6dc1f5 100644 --- a/package.json +++ b/package.json @@ -31,33 +31,33 @@ "node": "10.x" }, "devDependencies": { - "@rollup/plugin-commonjs": "^11.0.2", + "@rollup/plugin-commonjs": "^11.1.0", "@rollup/plugin-multi-entry": "^3.0.0", - "@rollup/plugin-node-resolve": "^7.1.1", + "@rollup/plugin-node-resolve": "^7.1.3", "@types/chai": "^4.1.6", - "@types/lodash": "^3.10.1", + "@types/lodash": "^3.10.3", "@types/mocha": "^5.2.5", - "@types/node": "^10.17.18", + "@types/node": "^13.13.1", "@types/screeps": "^3.1.0", "@types/sinon": "^5.0.5", "@types/sinon-chai": "^3.2.0", "chai": "^4.2.0", "lodash": "^3.10.1", "mocha": "^5.2.0", - "prettier": "^1.14.0", - "rollup": "^1.32.1", - "rollup-plugin-buble": "^0.19.4", + "prettier": "^2.0.4", + "rollup": "^2.6.1", + "rollup-plugin-buble": "^0.19.8", "rollup-plugin-clear": "^2.0.7", "rollup-plugin-nodent": "^0.2.2", - "rollup-plugin-screeps": "^0.1.2", + "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", - "tslint": "^5.9.1", - "tslint-config-prettier": "^1.14.0", - "tslint-plugin-prettier": "^1.3.0", - "typescript": "^2.9.2" + "ts-node": "^8.8.2", + "tslint": "^6.1.1", + "tslint-config-prettier": "^1.18.0", + "tslint-plugin-prettier": "^2.3.0", + "typescript": "^3.8.3" }, "dependencies": { "source-map": "~0.6.1" diff --git a/src/types.d.ts b/src/types.d.ts index 00727b9..6e34eff 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,5 +1,12 @@ // example declaration file - remove these and add your own custom typings +// Shim to allow continued use of global lodash without having to explicitley import in every file. +// as of @types/lodash@3.10.3 +import _ from "lodash"; +declare global { + const _: typeof _; +} + // memory extension samples interface CreepMemory { role: string; From bfb6d298577d85765600c7cc4c83ab3f0a327799 Mon Sep 17 00:00:00 2001 From: Skyler Kehren Date: Wed, 22 Apr 2020 20:46:19 +0300 Subject: [PATCH 10/13] Pin @types/lodash to 3.10.2 Revert workaround for @types/lodash 3.10.3 and pin version to 3.10.2 until more research can be done. --- package.json | 2 +- src/types.d.ts | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/package.json b/package.json index a6dc1f5..f5fa816 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@rollup/plugin-multi-entry": "^3.0.0", "@rollup/plugin-node-resolve": "^7.1.3", "@types/chai": "^4.1.6", - "@types/lodash": "^3.10.3", + "@types/lodash": "3.10.2", "@types/mocha": "^5.2.5", "@types/node": "^13.13.1", "@types/screeps": "^3.1.0", diff --git a/src/types.d.ts b/src/types.d.ts index 6e34eff..00727b9 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,12 +1,5 @@ // example declaration file - remove these and add your own custom typings -// Shim to allow continued use of global lodash without having to explicitley import in every file. -// as of @types/lodash@3.10.3 -import _ from "lodash"; -declare global { - const _: typeof _; -} - // memory extension samples interface CreepMemory { role: string; From b3d7bda215d1b3de14f9ae7d370b58d1c9797a1b Mon Sep 17 00:00:00 2001 From: Skyler Kehren Date: Sat, 2 May 2020 12:51:58 +0300 Subject: [PATCH 11/13] Fixing PR review comments Adds direct example for installing screeps-server-mockup Adds test-integration script that prints where to find more info Fixes typo in integration: testing docs --- docs/in-depth/testing.md | 9 ++++++++- package.json | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/in-depth/testing.md b/docs/in-depth/testing.md index 2d2f033..a115e82 100644 --- a/docs/in-depth/testing.md +++ b/docs/in-depth/testing.md @@ -47,6 +47,13 @@ magnitude, it is recommended to prefer unit tests wherever possible. 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. @@ -67,7 +74,7 @@ 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 +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. diff --git a/package.json b/package.json index 40bc813..9348485 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "push-sim": "rollup -c --environment DEST:sim", "test": "npm run test-unit", "test-unit": "rollup -c rollup.test-unit-config.js && mocha dist/test-unit.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" From 77f8ed969c31a1ee5fb1f9aa186a24a7df879156 Mon Sep 17 00:00:00 2001 From: "Dr. Derek Austin" <53202242+djD-REK@users.noreply.github.com> Date: Sat, 2 May 2020 10:54:55 -0400 Subject: [PATCH 12/13] Update node version to 10.x in README (#136) * Corrects version numbering on README.md regarding Node dependency * 1) Updated .gitignore to exclude build/* --- .gitignore | 1 + README.md | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c3d567f..ce84fb9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /tsc-out /node_modules /_book +/build/* # TypeScript definitions installed by Typings /typings diff --git a/README.md b/README.md index 7fc2213..04591aa 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ 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`) +- [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. From 3a585095a50a987c7b3d4c7fe43cf320f95bb70e Mon Sep 17 00:00:00 2001 From: Bredor <40574176+freedan42x@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:52:42 +0300 Subject: [PATCH 13/13] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04591aa..96af3eb 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ You will need: 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