From 31330a133de73932f6721aa8d4f3158a07c30295 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Mon, 5 Feb 2024 17:16:38 +0100 Subject: [PATCH 1/6] Update all dependencies --- package.json | 18 +++++++++--------- rollup.config.js | 17 +++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 1892287f2..21e60b4de 100644 --- a/package.json +++ b/package.json @@ -28,23 +28,23 @@ "node": "^20.11" }, "devDependencies": { - "@rollup/plugin-commonjs": "^11.0.2", - "@rollup/plugin-node-resolve": "^7.1.1", + "@rollup/plugin-commonjs": "^25.0.3", + "@rollup/plugin-node-resolve": "^15.1.0", "@types/lodash": "3.10.2", "@types/node": "^20.11.16", "@types/screeps": "^3.3.7", "javascript-obfuscator": "^4.1.0", - "rollup": "^2.6.0", - "rollup-plugin-progress": "^1.1.1", - "rollup-plugin-screeps": "^1.0.0", - "rollup-plugin-typescript2": "^0.27.0", - "tslint": "^5.20.0", - "typedoc": "^0.14.2", + "rollup": "^3.27.1", + "rollup-plugin-progress": "^1.1.2", + "rollup-plugin-screeps": "^1.0.1", + "rollup-plugin-typescript2": "^0.35.0", + "tslint": "^6.1.3", + "typedoc": "^0.25.7", "typescript": "5.3.3" }, "dependencies": { "@tensorflow/tfjs": "^1.2.11", - "columnify": "1.5.4", + "columnify": "^1.6.0", "onnxjs": "^0.1.6", "source-map": "0.7.3" } diff --git a/rollup.config.js b/rollup.config.js index 5ebeaa6ed..295e1278d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,14 +5,17 @@ import commonjs from '@rollup/plugin-commonjs'; import progress from "rollup-plugin-progress"; import typescript from "rollup-plugin-typescript2"; import screeps from "rollup-plugin-screeps"; +import { readFileSync } from 'fs'; let cfg; const dest = process.env.DEST; if (!dest) { console.log('\x1b[46m%s\x1b[0m \x1b[36m%s\x1b[0m', 'Compiling Overmind...', '(deploy destination: none)'); -} else if ((cfg = require("./screeps")[dest]) == null) { - throw new Error("Invalid upload destination"); } else { + cfg = JSON.parse(readFileSync("./screeps.json"))[dest]; + if (!cfg) { + throw new Error("Invalid upload destination"); + } console.log('\x1b[46m%s\x1b[0m \x1b[36m%s\x1b[0m', 'Compiling Overmind...', `(deploy destination: ${dest})`); console.log(`Pushing at time: ${new Date()})`); } @@ -28,13 +31,7 @@ export default { plugins: [ progress({clearLine: true}), resolve(), - commonjs({ - namedExports: { - 'src/Overmind_obfuscated': ['_Overmind'], - 'screeps-profiler': ['profiler'], - 'columnify': ['columnify'] - } - }), + commonjs(), typescript({tsconfig: "./tsconfig.json"}), screeps({config: cfg, dryRun: cfg == null}) ], @@ -70,4 +67,4 @@ export default { '//\n' }, -} \ No newline at end of file +} From 90e16c8645aec2e7dde3e29f522adfce51663dbc Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Mon, 5 Feb 2024 17:17:04 +0100 Subject: [PATCH 2/6] Load the typings for columnify --- package.json | 1 + src/declarations/index.d.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 21e60b4de..47f5fb939 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "devDependencies": { "@rollup/plugin-commonjs": "^25.0.3", "@rollup/plugin-node-resolve": "^15.1.0", + "@types/columnify": "^1.5.1", "@types/lodash": "3.10.2", "@types/node": "^20.11.16", "@types/screeps": "^3.3.7", diff --git a/src/declarations/index.d.ts b/src/declarations/index.d.ts index 51b024a8a..2cdf20a20 100644 --- a/src/declarations/index.d.ts +++ b/src/declarations/index.d.ts @@ -45,7 +45,6 @@ type Omit = Pick>; // declare module 'screeps-profiler'; // I stopped using the typings for this because it was fucking up the Game typings -declare module 'columnify'; // If TS2451 gets thrown, change "declare let Game: Game;" to "declare var Game: Game;" // in typed-screeps index.d.ts file. (See issue #61 until the package is updated) From 1e32f53762c782db69894e0f5e3688962f925c4c Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Mon, 5 Feb 2024 17:18:12 +0100 Subject: [PATCH 3/6] Declare that we're using Node 20 This makes the shell environment automatically switch to the correct version, provided someone is using asdf (or any of the equivalents) --- .tool-versions | 1 + 1 file changed, 1 insertion(+) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 000000000..557ea46d2 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nodejs 20.11.0 From d185d75df0664082479caeb1fd29e368f3941c65 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Mon, 5 Feb 2024 17:18:52 +0100 Subject: [PATCH 4/6] Move the obfuscator configuration in its own file --- obfuscator.config.json | 28 ++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 obfuscator.config.json diff --git a/obfuscator.config.json b/obfuscator.config.json new file mode 100644 index 000000000..794f01290 --- /dev/null +++ b/obfuscator.config.json @@ -0,0 +1,28 @@ +{ + "compact": false, + "controlFlowFlattening": false, + "deadCodeInjection": false, + "debugProtection": false, + "debugProtectionInterval": 0, + "disableConsoleOutput": false, + "identifierNamesGenerator": "hexadecimal", + "log": false, + "numbersToExpressions": false, + "renameGlobals": false, + "selfDefending": true, + "simplify": true, + "splitStrings": false, + "stringArray": true, + "stringArrayCallsTransform": false, + "stringArrayCallsTransformThreshold": 0.5, + "stringArrayEncoding": ["rc4"], + "stringArrayIndexShift": true, + "stringArrayRotate": true, + "stringArrayShuffle": true, + "stringArrayWrappersCount": 1, + "stringArrayWrappersChainedCalls": true, + "stringArrayWrappersParametersMaxCount": 2, + "stringArrayWrappersType": "variable", + "stringArrayThreshold": 1, + "unicodeEscapeSequence": false +} diff --git a/package.json b/package.json index 47f5fb939..d91479822 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "build": "tsc -p .", "lint": "tslint \"src/**/*.ts\"", "clean": "rm -rf tsc-out && rm -rf dist", - "obfuscate": "tsc && javascript-obfuscator tsc-out/Overmind.js --output src/Overmind_obfuscated.js --compact false --self-defending true --string-array true --string-array-threshold 1 --string-array-encoding rc4 && javascript-obfuscator tsc-out/assimilation/Assimilator.js --output src/assimilation/Assimilator_obfuscated.js --compact false --self-defending true --string-array true --string-array-threshold 1 --string-array-encoding rc4", + "obfuscate": "tsc && javascript-obfuscator --config obfuscator.config.json tsc-out/Overmind.js --output src/Overmind_obfuscated.js && javascript-obfuscator --config obfuscator.config.json tsc-out/assimilation/Assimilator.js --output src/assimilation/Assimilator_obfuscated.js", "compile": "rollup -c", "push-main": "rollup -c --environment DEST:main", "push-seasonal": "rollup -c --environment DEST:seasonal", From ae7c6ff6409a1819c382a61b75cc3a5a7f92fb32 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Mon, 5 Feb 2024 17:20:31 +0100 Subject: [PATCH 5/6] Fix the package name Otherwise VSCode reports `String does not match the pattern of "^(?:(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)?/[a-z0-9-._~])|[a-z0-9-~])[a-z0-9-._~]*$"`. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d91479822..c2e6fdeb2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "Overmind", + "name": "overmind", "version": "0.6.0", "description": "Overmind Screeps AI", "author": "Ben Bartlett", From 7beff739583e7d0b084f7a0bf0acfdfba507805a Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Mon, 5 Feb 2024 17:21:35 +0100 Subject: [PATCH 6/6] Update .editorconfig with the correct line-endings and whitespace-trimming --- .editorconfig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 02ff606f3..ca2573dc0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,6 @@ [*] charset=utf-8 -end_of_line=crlf +end_of_line=lf insert_final_newline=false indent_style=space indent_size=4 @@ -8,12 +8,17 @@ indent_size=4 [{.babelrc,.stylelintrc,.eslintrc,jest.config,*.json,*.jsb3,*.jsb2,*.bowerrc}] indent_style=space indent_size=2 +end_of_line=lf +trim_trailing_whitespace=true -[{*.ats,*.ts}] +[{*.ats,*.ts,*.js}] indent_style=tab tab_width=4 +end_of_line=lf +trim_trailing_whitespace=true [tslint.json] indent_style=space indent_size=2 - +end_of_line=lf +trim_trailing_whitespace=true