Start on v3.0

This commit is contained in:
apemanzilla
2017-11-21 12:55:36 -05:00
commit 5af6dc5077
9 changed files with 250 additions and 0 deletions

18
.editorconfig Normal file
View File

@@ -0,0 +1,18 @@
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.py]
indent_style = space
indent_size = 4
[*.rb]
indent_style = space
indent_size = 4

22
.gitattributes vendored Normal file
View File

@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

84
.gitignore vendored Normal file
View File

@@ -0,0 +1,84 @@
# yarn lock file
/yarn.lock
# npm lock file (v5.0.0+)
/package-lock.json
# Ignore basic folders
/dist
/.rpt2_cache
/tsc-out
/node_modules
# TypeScript definitions installed by Typings
/typings
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.zip
*.vi
*~
# Editor folders
.cache
.project
.settings
.tmproj
*.esproj
nbproject
*.sublime-project
*.sublime-workspace
.idea
# =========================
# Operating System Files
# =========================
# OSX
# =========================
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk

12
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"editor.renderWhitespace": "boundary",
"files.encoding": "utf8",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"search.exclude": {
"dist/**": true,
"node_modules/**": true,
"typings/**": true
},
"typescript.tsdk": "./node_modules/typescript/lib"
}

29
package.json Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "screeps-typescript-starter",
"version": "3.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/screepers/screeps-typescript-starter.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/screepers/screeps-typescript-starter/issues"
},
"homepage": "https://github.com/screepers/screeps-typescript-starter#readme",
"devDependencies": {
"@types/lodash": "^4.14.85",
"rollup": "^0.51.8",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-typescript2": "^0.8.1",
"tslint": "^5.8.0",
"typed-screeps": "^1.0.4",
"typescript": "^2.6.1"
}
}

39
rollup.config.js Normal file
View File

@@ -0,0 +1,39 @@
"use strict";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
// In Screeps, require only works for exported content
// This "plugin" prepends an export to source maps so that it can be loaded in screeps via require`
function exportSourceMaps() {
return {
name: "export-source-maps",
ongenerate: function (options, bundle) {
let tmp = bundle.map.toString;
delete bundle.map.sourcesContent;
bundle.map.toString = function () {
return "module.exports = " + tmp.apply(this, arguments) + ";";
}
}
}
}
export default {
input: "src/main.ts",
output: {
file: "dist/main.js",
format: "cjs"
},
sourcemap: true,
plugins: [
resolve(),
commonjs(),
typescript({tsconfig: "./tsconfig.json"}),
exportSourceMaps()
]
}

3
src/main.ts Normal file
View File

@@ -0,0 +1,3 @@
export function loop() {
console.log(`Current tick is ${Game.time}`);
}

24
tsconfig.json Normal file
View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"outDir": "dist",
"baseUrl": "src/",
"sourceMap": true,
"alwaysStrict": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"structNullChecks": true,
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"types": [
"lodash",
"typed-screeps"
]
},
"exclude": [
"node_modules"
]
}

19
tslint.json Normal file
View File

@@ -0,0 +1,19 @@
{
"extends" : [
"tslint:recommended"
],
"rules": {
"forin": false,
"interface-name": ["never-prefix"],
"no-console": [false],
"no-namespace": [true, "allow-declarations"],
"trailing-comma": [true, {"multiline": "never", "singleline": "never"}],
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-pascal-case",
"allow-leading-underscore"
]
}
}