From 5af6dc5077152f89358329bb48ccec551e80f394 Mon Sep 17 00:00:00 2001 From: apemanzilla Date: Tue, 21 Nov 2017 12:55:36 -0500 Subject: [PATCH] Start on v3.0 --- .editorconfig | 18 ++++++++++ .gitattributes | 22 ++++++++++++ .gitignore | 84 +++++++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 12 +++++++ package.json | 29 +++++++++++++++ rollup.config.js | 39 ++++++++++++++++++++ src/main.ts | 3 ++ tsconfig.json | 24 +++++++++++++ tslint.json | 19 ++++++++++ 9 files changed, 250 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 package.json create mode 100644 rollup.config.js create mode 100644 src/main.ts create mode 100644 tsconfig.json create mode 100644 tslint.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a5f82df --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0cbba3d --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..67c701b --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a9021a7 --- /dev/null +++ b/.vscode/settings.json @@ -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" +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..8ae0861 --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..d4138da --- /dev/null +++ b/rollup.config.js @@ -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() + ] +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..4ac5de3 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,3 @@ +export function loop() { + console.log(`Current tick is ${Game.time}`); +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..3162d05 --- /dev/null +++ b/tsconfig.json @@ -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" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..465bae6 --- /dev/null +++ b/tslint.json @@ -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" + ] + } +}