[docs] add more sections

This commit is contained in:
Resi Respati
2017-11-28 13:05:07 +07:00
parent b068c6bb78
commit 6e9088c7ca
10 changed files with 117 additions and 51 deletions

View File

@@ -0,0 +1,40 @@
# Configuration variables
The `screeps.json` file is a JSON configuration file separated into multiple environments. We've given you three primary environments by default.
```json
{
// Used for deploying to the main world
"main": {
"email": "you@provider.tld",
"password": "Password",
"protocol": "https",
"hostname": "screeps.com",
"port": 443,
"path": "/",
"branch": "main"
},
// Used for deploying to Simulation mode
"sim": {
"email": "you@provider.tld",
"password": "Password",
"protocol": "https",
"hostname": "screeps.com",
"port": 443,
"path": "/",
"branch": "sim"
},
// Used for deploying to a private server
"pserver": {
"email": "username",
"password": "Password",
"protocol": "http",
"hostname": "1.2.3.4",
"port": 21025,
"path": "/",
"branch": "main"
}
}
```
[TODO: running environments]

View File

@@ -0,0 +1,3 @@
# Cookbook
This section provides some slightly more advanced tips and tricks to help better improve your Screeps AI development workflow with TypeScript.

View File

@@ -0,0 +1,25 @@
# Module bundling
Bundling your Screeps codebase using module bundlers like [Webpack](https://webpack.js.org/) or [Rollup](https://rollupjs.org/) allows you to improve your Screeps AI development workflow.
For instance, it allows you to easily include third-party libraries, like [screeps-profiler](https://github.com/screepers/screeps-profiler) and [Traveler](https://github.com/bonzaiferroni/Traveler). Instead of manually copy-pasting these libraries into your code, you can simply install it as an `npm` module:
```bash
npm install screeps-profiler
```
Then you can import these libraries just like you would any other `npm` module. When you run the module bundler, it will bundle up all your files and third-party modules into one single JS file.
Some module bundlers even support performing further optimisations like eliminating unused module functions from your final bundled code (aka. _tree-shaking_), reducing the size of your final bundled JS even further.
[TODO: more advantages of bundling code, if any]
## Rollup
From version 3.0 onwards, the starter kit uses Rollup as its main module bundler. Some useful features of Rollup include:
* Bundled modules are entirely flat (no weird boilerplate code emitted like in Webpack)
* Advanced tree-shaking (eliminates unused modules from the final bundle)
* Simpler configuration (compared to Webpack)
If you're still comfortable with using Webpack, the old version of the starter kit is available here (**TODO:** legacy branch link), but moving forward, no new features will be added to the Webpack version.

View File

@@ -0,0 +1,33 @@
# TypeScript
This section provides TypeScript-specific tips & tricks for you to make the best out of the ecosystem.
## Strict mode
The `--strict` compiler flag was introduced in TypeScript 2.3 which activates TypeScript's "strict mode". The strict mode sets all strict typechecking options to `true` by default.
As of TypeScript 2.6, the affected options are:
* `--noImplicitAny`
* `--noImplicitThis`
* `--alwaysStrict`
* `--strictNullChecks`
* `--strictFunctionTypes`
Starting from version 2.0 of the starter kit, we've enabled the `--strict` flag in `tsconfig.json`. If this gives you compile time errors, you can try setting `"strict"` to `false`, or by overriding one or more of the options listed above.
**For more info:** https://blog.mariusschulz.com/2017/06/09/typescript-2-3-the-strict-compiler-option
## TSLint
TSLint checks your TypeScript code for readability, maintainability, and functionality errors, and can also enforce coding style standards.
[TODO: describe TSlint rules used in brief]
### Customising TSLint
You can also customise your `tslint.json` file to match the preferences of your codebase. Click [here](https://palantir.github.io/tslint/usage/configuration/), to find out how, and click [here](https://palantir.github.io/tslint/rules/) for a complete list of rules available.
If you believe that some rules should not apply to a part of your code (e.g. for one-off cases like having to use `require()` to include a module), you can use flags to let TSLint know about it: https://palantir.github.io/tslint/usage/rule-flags/
**More info about TSLint:** https://palantir.github.io/tslint/