Split app and tests JS files, and simplified dependencies bundle
Cette révision appartient à :
Parent
29224113c9
révision
436e568a0e
|
@ -1,10 +1,12 @@
|
|||
.venv
|
||||
coverage
|
||||
/node_modules
|
||||
/out/vendor
|
||||
/out/assets
|
||||
/out/build.*
|
||||
/out/app.*
|
||||
/out/tests.*
|
||||
/out/dependencies.js
|
||||
/graphics/**/*.blend?*
|
||||
/graphics/**/output.png
|
||||
/typings/
|
||||
*.log
|
||||
*.tsbuildinfo
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"**/CVS": true,
|
||||
"**/.DS_Store": true,
|
||||
"node_modules": true,
|
||||
".env": true,
|
||||
"out": true
|
||||
".venv": true,
|
||||
"**/*.tsbuildinfo": true,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"extends": "./common.json",
|
||||
"compilerOptions": {
|
||||
"outFile": "../out/app.js",
|
||||
"rootDir": ".."
|
||||
},
|
||||
"include": [
|
||||
"../src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"../src/**/*.spec.ts"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "system",
|
||||
"composite": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
"removeComments": false,
|
||||
"preserveConstEnums": true,
|
||||
"strict": true,
|
||||
"sourceMap": true,
|
||||
"lib": [
|
||||
"dom",
|
||||
"es6",
|
||||
"scripthost"
|
||||
],
|
||||
"target": "es6"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"extends": "./common.json",
|
||||
"compilerOptions": {
|
||||
"outFile": "../out/tests.js",
|
||||
"rootDir": ".."
|
||||
},
|
||||
"include": [
|
||||
"../src/**/*.spec.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "./app.json"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -8,7 +8,7 @@ var Phaser = new Proxy(function () { }, handler);
|
|||
//var debug = console.log;
|
||||
var debug = function () { };
|
||||
|
||||
importScripts("build.js");
|
||||
importScripts("app.js");
|
||||
|
||||
onmessage = function (e) {
|
||||
debug("[AI Worker] Received", e.data.length);
|
||||
|
|
|
@ -41,9 +41,8 @@
|
|||
<div id="-space-tac" class="game"></div>
|
||||
<div class=".fontLoader">.</div>
|
||||
|
||||
<script src="vendor/parse/parse.min.js"></script>
|
||||
<script src="vendor/phaser/phaser.js"></script>
|
||||
<script src="build.js"></script>
|
||||
<script src="dependencies.js"></script>
|
||||
<script src="app.js"></script>
|
||||
|
||||
<script>
|
||||
window.onload = function () {
|
||||
|
|
|
@ -2,7 +2,7 @@ const Pool = require('process-pool').default;
|
|||
|
||||
const pool = new Pool({ processLimit: 8 });
|
||||
const work = pool.prepare(function () {
|
||||
const App = require("./build").TK.SpaceTac;
|
||||
const App = require("./app").TK.SpaceTac;
|
||||
|
||||
async function doOneBattle(i) {
|
||||
let ai1 = new App.TacticalAI();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<title>SpaceTac - Unit tests</title>
|
||||
|
||||
<link rel="stylesheet" href="vendor/jasmine/jasmine.css">
|
||||
<link rel="stylesheet" href="/jasmine/jasmine.css">
|
||||
<style>
|
||||
canvas {
|
||||
display: none;
|
||||
|
@ -22,12 +22,13 @@
|
|||
<div id="-space-tac" class="game"></div>
|
||||
</div>
|
||||
|
||||
<script src="vendor/jasmine/jasmine.js"></script>
|
||||
<script src="vendor/jasmine/jasmine-html.js"></script>
|
||||
<script src="vendor/jasmine/boot.js"></script>
|
||||
<script src="vendor/parse/parse.min.js"></script>
|
||||
<script src="vendor/phaser/phaser.min.js"></script>
|
||||
<script src="build.js"></script>
|
||||
<script src="/jasmine/jasmine.js"></script>
|
||||
<script src="/jasmine/jasmine-html.js"></script>
|
||||
<script src="/jasmine/boot.js"></script>
|
||||
|
||||
<script src="dependencies.js"></script>
|
||||
<script src="app.js"></script>
|
||||
<script src="tests.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -2499,7 +2499,8 @@
|
|||
"jasmine-core": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.4.0.tgz",
|
||||
"integrity": "sha512-HU/YxV4i6GcmiH4duATwAbJQMlE0MsDIR5XmSVxURxKHn3aGAdbY1/ZJFmVRbKtnLwIxxMJD7gYaPsypcbYimg=="
|
||||
"integrity": "sha512-HU/YxV4i6GcmiH4duATwAbJQMlE0MsDIR5XmSVxURxKHn3aGAdbY1/ZJFmVRbKtnLwIxxMJD7gYaPsypcbYimg==",
|
||||
"dev": true
|
||||
},
|
||||
"js-yaml": {
|
||||
"version": "3.13.1",
|
||||
|
@ -3418,6 +3419,13 @@
|
|||
"jsdoc": "^3.6.1",
|
||||
"path": "^0.12.7",
|
||||
"typescript": "^3.4.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": {
|
||||
"version": "3.4.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz",
|
||||
"integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"pify": {
|
||||
|
@ -4473,9 +4481,10 @@
|
|||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.4.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz",
|
||||
"integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw=="
|
||||
"version": "3.5.0-dev.20190516",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.0-dev.20190516.tgz",
|
||||
"integrity": "sha512-J+1tISjR4yCmZ3F2wWZDEMoocF4wdXsHf68ln6cb0gjm8VmSDUYSPOVbCJUJoLqjWaCEPs05O7eNrbTulo/4ew==",
|
||||
"dev": true
|
||||
},
|
||||
"uc.micro": {
|
||||
"version": "1.0.6",
|
||||
|
|
10
package.json
10
package.json
|
@ -21,6 +21,7 @@
|
|||
"glob": "^7.1.4",
|
||||
"glob-watcher": "^5.0.3",
|
||||
"jasmine": "^3.4.0",
|
||||
"jasmine-core": "^3.4.0",
|
||||
"karma": "^4.1.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-coverage": "^1.1.2",
|
||||
|
@ -31,12 +32,15 @@
|
|||
"remap-istanbul": "^0.13.0",
|
||||
"runjs": "^4.4.2",
|
||||
"shelljs": "^0.8.3",
|
||||
"typescript": "^3.4.5",
|
||||
"typescript": "^3.5.0-dev.20190516",
|
||||
"uglify-js": "^3.5.12"
|
||||
},
|
||||
"dependencies": {
|
||||
"jasmine-core": "^3.4.0",
|
||||
"parse": "^2.4.0",
|
||||
"phaser": "^3.17.0"
|
||||
},
|
||||
"dependenciesMap": {
|
||||
"parse": "dist/parse.min.js",
|
||||
"phaser": "dist/phaser.min.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
50
runfile.js
50
runfile.js
|
@ -35,16 +35,16 @@ async function exec(command) {
|
|||
/**
|
||||
* Build app from typescript sources
|
||||
*/
|
||||
async function ts(dist = false) {
|
||||
async function ts() {
|
||||
console.log("Building app...");
|
||||
await exec(`tsc --project ${dist ? "./tsconfig.dist.json" : "."}`);
|
||||
await exec(`tsc --build config/app.json config/tests.json`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start watching for typescript changes
|
||||
*/
|
||||
async function watch_ts() {
|
||||
await exec(`tsc --project . --watch --preserveWatchOutput`);
|
||||
await exec(`tsc --build config/app.json config/tests.json --watch --preserveWatchOutput`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,33 +135,32 @@ async function watch_data() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Copy the vendors from node_modules to dist directory
|
||||
* Copy and concatenate the vendors from node_modules to out/dependencies.js
|
||||
*/
|
||||
async function vendors() {
|
||||
console.log("Copying vendors...");
|
||||
shell.rm('-rf', 'out/vendor');
|
||||
shell.mkdir('-p', 'out/vendor');
|
||||
shell.cp('-R', 'node_modules/phaser/dist', 'out/vendor/phaser');
|
||||
shell.cp('-R', 'node_modules/parse/dist', 'out/vendor/parse');
|
||||
shell.cp('-R', 'node_modules/jasmine-core/lib/jasmine-core', 'out/vendor/jasmine');
|
||||
async function dependencies() {
|
||||
console.log("Bundling dependencies...");
|
||||
const self = JSON.parse(fs.readFileSync("package.json"));
|
||||
const deps = Object.keys(self["dependenciesMap"]).map(dependency => `node_modules/${dependency}/${self["dependenciesMap"][dependency]}`);
|
||||
const bundle = shell.cat(deps);
|
||||
fs.writeFileSync("out/dependencies.js", bundle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start watching for vendors changes
|
||||
* Start watching for dependencies changes
|
||||
*/
|
||||
async function watch_vendors() {
|
||||
watch(['package.json'], () => vendors());
|
||||
async function watch_dependencies() {
|
||||
watch(['package.json'], () => dependencies());
|
||||
await forever();
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger a single build
|
||||
*/
|
||||
async function build(dist = false) {
|
||||
async function build() {
|
||||
await Promise.all([
|
||||
ts(dist),
|
||||
ts(),
|
||||
data(),
|
||||
vendors()
|
||||
dependencies()
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -170,14 +169,14 @@ async function build(dist = false) {
|
|||
*/
|
||||
async function optimize() {
|
||||
// TODO do not overwrite dev build
|
||||
await exec("uglifyjs out/build.dist.js --source-map --ecma 6 --mangle --keep-classnames --compress --output out/build.js");
|
||||
await exec("uglifyjs out/app.js --source-map --ecma 6 --mangle --keep-classnames --compress --output out/app.js");
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy to production
|
||||
*/
|
||||
async function deploy(task, experimental = false) {
|
||||
await build(true);
|
||||
await build();
|
||||
await optimize();
|
||||
await exec(`rsync -avz --delete ./out/ hosting.thunderk.net:/srv/website/spacetac${experimental ? "x" : ""}/`);
|
||||
}
|
||||
|
@ -208,7 +207,7 @@ async function test(task) {
|
|||
* Run tests in karma when the build changes
|
||||
*/
|
||||
async function watch_test(task) {
|
||||
watch(["out/*.js", "out/*.html"], () => karma());
|
||||
watch(["out/*.js", "out/*.html", "spec/support/*"], () => karma());
|
||||
await forever();
|
||||
}
|
||||
|
||||
|
@ -216,7 +215,7 @@ async function watch_test(task) {
|
|||
* Run tests in karma, using freshly built app (for continuous integration)
|
||||
*/
|
||||
async function ci(task) {
|
||||
await Promise.all([ts(), vendors()]);
|
||||
await Promise.all([ts(), dependencies()]);
|
||||
await karma();
|
||||
await exec("remap-istanbul -i out/coverage/coverage.json -o out/coverage -t html");
|
||||
}
|
||||
|
@ -230,6 +229,9 @@ async function serve() {
|
|||
port: 8012,
|
||||
root: 'out',
|
||||
ignore: 'out/coverage',
|
||||
mount: [
|
||||
['/jasmine', './node_modules/jasmine-core/lib/jasmine-core']
|
||||
],
|
||||
wait: 500
|
||||
});
|
||||
await new Promise(() => null);
|
||||
|
@ -249,7 +251,7 @@ async function continuous() {
|
|||
serve(),
|
||||
watch_ts(),
|
||||
watch_data(),
|
||||
watch_vendors(),
|
||||
watch_dependencies(),
|
||||
watch_test(),
|
||||
]);
|
||||
}
|
||||
|
@ -281,8 +283,8 @@ module.exports = {
|
|||
watch_ts: command(watch_ts),
|
||||
data: command(data),
|
||||
watch_data: command(watch_data),
|
||||
vendors: command(vendors),
|
||||
watch_vendors: command(watch_vendors),
|
||||
dependencies: command(dependencies),
|
||||
watch_dependencies: command(watch_dependencies),
|
||||
build: command(build),
|
||||
test: command(test),
|
||||
watch_test: command(watch_test),
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports = function (config) {
|
|||
},
|
||||
|
||||
preprocessors: {
|
||||
'build.js': ['coverage']
|
||||
'app.js': ['coverage']
|
||||
},
|
||||
|
||||
coverageReporter: {
|
||||
|
@ -31,9 +31,9 @@ module.exports = function (config) {
|
|||
},
|
||||
|
||||
files: [
|
||||
'vendor/phaser/phaser.js',
|
||||
'vendor/parse/parse.min.js',
|
||||
'build.js'
|
||||
'dependencies.js',
|
||||
'app.js',
|
||||
'tests.js',
|
||||
]
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/// <reference path="ui/TestGame.ts" />
|
||||
/// <reference path="../node_modules/phaser/types/phaser.d.ts"/>
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
class FakeStorage {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="DiffLog.ts" />
|
||||
|
||||
module TK.Specs {
|
||||
class TestState {
|
||||
counter = 0
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="RObject.ts" />
|
||||
|
||||
module TK.Specs {
|
||||
export class TestRObject extends RObject {
|
||||
x: number
|
||||
|
|
|
@ -477,7 +477,7 @@ module TK {
|
|||
/**
|
||||
* Copy an object (only a shallow copy of immediate properties)
|
||||
*/
|
||||
export function copy<T>(object: T): T {
|
||||
export function copy<T extends Object>(object: T): T {
|
||||
let objectCopy = <T>Object.create(object.constructor.prototype);
|
||||
copyfields(object, objectCopy);
|
||||
return objectCopy;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="effects/BaseEffect.ts" />
|
||||
|
||||
module TK.SpaceTac {
|
||||
testing("Drone", test => {
|
||||
test.case("applies area effects when deployed", check => {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="PersonalityReactions.ts" />
|
||||
|
||||
module TK.SpaceTac.Specs {
|
||||
testing("PersonalityReactions", test => {
|
||||
function apply(pool: ReactionPool): PersonalityReaction | null {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="Maneuver.ts" />
|
||||
|
||||
module TK.SpaceTac.Specs {
|
||||
testing("TacticalAI", test => {
|
||||
class FixedManeuver extends Maneuver {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../../common/Testing.ts" />
|
||||
|
||||
module TK.SpaceTac.Specs {
|
||||
testing("ShipAttributeDiff", test => {
|
||||
test.case("applies and reverts", check => {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../../common/Testing.ts" />
|
||||
|
||||
module TK.SpaceTac.Specs {
|
||||
testing("ShipDeathDiff", test => {
|
||||
test.case("applies and reverts", check => {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../../common/Testing.ts" />
|
||||
|
||||
module TK.SpaceTac.Specs {
|
||||
testing("ShipValueDiff", test => {
|
||||
test.case("applies and reverts", check => {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="TestGame.ts" />
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("AssetLoading", test => {
|
||||
let testgame = setupSingleView(test, () => [new AssetLoading({}), []]);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="TestGame.ts" />
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("BaseView", test => {
|
||||
let testgame = setupEmptyView(test);
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/// <reference path="TestGame.ts" />
|
||||
/// <reference path="Router.ts" />
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("Router", test => {
|
||||
let testgame = setupSingleView(test, () => [new Router({}), {}]);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../TestGame.ts"/>
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("ActionBar", test => {
|
||||
let testgame = setupBattleview(test);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../TestGame.ts"/>
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("ActionIcon", test => {
|
||||
let testgame = setupBattleview(test);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../TestGame.ts"/>
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("ActionTooltip", test => {
|
||||
let testgame = setupEmptyView(test);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../TestGame.ts"/>
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("ArenaShip", test => {
|
||||
let testgame = setupBattleview(test);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../TestGame.ts"/>
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("BattleView", test => {
|
||||
let testgame = setupBattleview(test);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../TestGame.ts"/>
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("ShipList", test => {
|
||||
let testgame = setupEmptyView(test);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../TestGame.ts"/>
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("CharacterUpgrade", test => {
|
||||
let testgame = setupEmptyView(test);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../TestGame.ts"/>
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("FleetCreationView", test => {
|
||||
let testgame = setupSingleView(test, () => [new FleetCreationView({}), []]);
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/// <reference path="../TestGame.ts" />
|
||||
/// <reference path="MainMenu.ts" />
|
||||
|
||||
module TK.SpaceTac.UI.Specs {
|
||||
testing("InputInviteCode", test => {
|
||||
let testgame = setupEmptyView(test);
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig",
|
||||
"compilerOptions": {
|
||||
"outFile": "out/build.dist.js",
|
||||
"removeComments": true
|
||||
},
|
||||
"exclude": [
|
||||
"src/**/*.spec.ts"
|
||||
]
|
||||
}
|
|
@ -1,21 +1,5 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "system",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
"removeComments": false,
|
||||
"preserveConstEnums": true,
|
||||
"outFile": "out/build.js",
|
||||
"strict": true,
|
||||
"sourceMap": true,
|
||||
"lib": [
|
||||
"dom",
|
||||
"es6",
|
||||
"scripthost"
|
||||
],
|
||||
"target": "es6"
|
||||
},
|
||||
"extends": "./config/common.json",
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
]
|
||||
|
|
Chargement…
Référencer dans un nouveau ticket