Merge branch 'master' of github.com:ornicar/lila

* 'master' of github.com:ornicar/lila:
  use build stages
  encrypt (a new) slack token
  convert atomic to typescript
  convert title to typescript
  convert cevalSub to typescript
This commit is contained in:
Thibault Duplessis 2017-05-19 14:38:20 +02:00
commit a29caa121b
7 changed files with 119 additions and 123 deletions

View file

@ -1,7 +1,5 @@
sudo: false
language: scala
# https://docs.travis-ci.com/user/notifications/#IRC-notification
notifications:
irc:
channels:
@ -12,50 +10,51 @@ notifications:
skip_join: true
slack:
rooms:
- lichess:sVTqlE0OQNMPq1n6qRnVnfrz
- secure: "LdcLNNeKKSOlHzX8n2+hqFZw6QqnKBfP+/BFtgEYe4QPb25sKxlxwnf28T7AVkf1F+/OA9KMcL+ZsCcXS6kB/0mI3P49hJfQT9XyUSvfpI81196oiEkCM5I+xDuzi5ejR0Sxt80OUOqw+vHOZYzGVtlfxtTbNxcT94V8j141hwY="
on_success: change
on_failure: always
email: false
# https://docs.travis-ci.com/user/languages/java/#Testing-Against-Multiple-JDKs
jdk:
- oraclejdk8
env:
global:
- secure: "VkgJ78marLdG8JQrWV3UhcxXyWmdy6BV3gYLTyXpK2ltPA4vGkFilZDc8hMx2VhYeeTXyvXB+PM4xkB40PUnDlmNXIWQlG7IxKIb/zxwUVS+WcvAzM6yqEV9B/UbZO+Mgp2Hl4/F1lMoIpdQ0tkRvHmfw01L9VDrQs4Otdmd38o="
- secure: "VkgJ78marLdG8JQrWV3UhcxXyWmdy6BV3gYLTyXpK2ltPA4vGkFilZDc8hMx2VhYeeTXyvXB+PM4xkB40PUnDlmNXIWQlG7IxKIb/zxwUVS+WcvAzM6yqEV9B/UbZO+Mgp2Hl4/F1lMoIpdQ0tkRvHmfw01L9VDrQs4Otdmd38o=" # GITHUB_API_TOKEN
- TRAVIS_NODE_VERSION="4.0.0"
git:
depth: 3
submodules: false
install:
# http://austinpray.com/ops/2015/09/20/change-travis-node-version.html
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install "$TRAVIS_NODE_VERSION"
- npm install -g gulp
install: ./bin/submodule-setup.sh
- ./bin/submodule-setup.sh
jobs:
include:
# Build server
- stage: test
language: scala
jdk: oraclejdk8
script: sbt test
after_success:
- sbt stage
- git log -n 1 --pretty=oneline > commit.txt
- tar -zcf "lila-server-${TRAVIS_BRANCH}.tar.gz" target/universal/stage LICENSE COPYING.md README.md commit.txt
before_cache:
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete
- find $HOME/.sbt -name "*.lock" -delete
- rm -rf $HOME/.sbt/0.13/dependency/module/dynamic
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt
script:
- ./ui/build prod
- sbt test
after_success:
- sbt stage
- git log -n 1 --pretty=oneline > commit.txt
- tar -zcf "lila-${TRAVIS_BRANCH}.tar.gz" target/universal/stage public LICENSE COPYING.md README.md commit.txt
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.ivy2/local
- $HOME/.sbt
before_cache:
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete
- find $HOME/.sbt -name "*.lock" -delete
- rm -rf $HOME/.sbt/0.13/dependency/module/dynamic
# Build assets
- stage: test
language: node_js
node_js: "4"
before_install: npm install -g gulp-cli
script: ./ui/build prod
after_success:
- git log -n 1 --pretty=oneline > commit.txt
- tar -zcf "lila-assets-${TRAVIS_BRANCH}.tar.gz" public LICENSE COPYING.md README.md commit.txt
addons:
artifacts:

View file

@ -1,7 +1,8 @@
var util = require('chessground/util');
import * as util from 'chessground/util';
import * as cg from 'chessground/types';
function capture(ctrl, key) {
var exploding = [];
export function capture(ctrl, key: cg.Key) {
var exploding: cg.Key[] = [];
var diff = {};
var orig = util.key2pos(key);
var minX = Math.max(1, orig[0] - 1),
@ -24,13 +25,8 @@ function capture(ctrl, key) {
}
// needs to explicitly destroy the capturing pawn
function enpassant(ctrl, key, color) {
var pos = util.key2pos(key);
var pawnPos = [pos[0], pos[1] + (color === 'white' ? -1 : 1)];
export function enpassant(ctrl, key: cg.Key, color: cg.Color) {
const pos = util.key2pos(key);
const pawnPos: cg.Pos = [pos[0], pos[1] + (color === 'white' ? -1 : 1)];
capture(ctrl, util.pos2key(pawnPos));
}
module.exports = {
capture: capture,
enpassant: enpassant
};

View file

@ -1,28 +0,0 @@
var plyStep = require('./round').plyStep;
var playable = require('game').game.playable;
var found = false;
function truncateFen(fen) {
return fen.split(' ')[0];
}
module.exports = {
subscribe: function(ctrl) {
// allow everyone to cheat against the AI
if (ctrl.data.opponent.ai) return;
// allow registered players to use assistance in casual games
if (!ctrl.data.game.rated && ctrl.userId) return;
lichess.storage.make('ceval.fen').listen(function(ev) {
var d = ctrl.data;
if (!found && ev.newValue && ctrl.vm.ply > 14 && playable(d) &&
truncateFen(plyStep(d, ctrl.vm.ply).fen) === truncateFen(ev.newValue)) {
$.post('/jslog/' + d.game.id + d.player.id + '?n=ceval');
found = true;
}
});
},
publish: function(ctrl, move) {
if (ctrl.data.opponent.ai) lichess.storage.set('ceval.fen', move.fen);
}
};

27
ui/round2/src/cevalSub.ts Normal file
View file

@ -0,0 +1,27 @@
import { plyStep } from './round';
import { game } from 'game';
var found = false;
function truncateFen(fen) {
return fen.split(' ')[0];
}
export function subscribe(ctrl) {
// allow everyone to cheat against the AI
if (ctrl.data.opponent.ai) return;
// allow registered players to use assistance in casual games
if (!ctrl.data.game.rated && ctrl.userId) return;
window.lichess.storage.make('ceval.fen').listen(function(ev) {
var d = ctrl.data;
if (!found && ev.newValue && ctrl.vm.ply > 14 && game.playable(d) &&
truncateFen(plyStep(d, ctrl.vm.ply).fen) === truncateFen(ev.newValue)) {
$.post('/jslog/' + d.game.id + d.player.id + '?n=ceval');
found = true;
}
});
}
export function publish(ctrl, move) {
if (ctrl.data.opponent.ai) window.lichess.storage.set('ceval.fen', move.fen);
}

View file

@ -1,3 +1,4 @@
/// <reference types="types/lichess" />
/// <reference types="types/lichess-jquery" />
import makeCtrl = require('./ctrl');

View file

@ -1,52 +0,0 @@
var game = require('game').game;
var status = require('game').status;
var initialTitle = document.title;
var curFaviconIdx = 0;
var F = [
'/assets/images/favicon-32-white.png',
'/assets/images/favicon-32-black.png'
].map(function(path, i) {
return function() {
if (curFaviconIdx !== i) {
document.getElementById('favicon').href = path;
curFaviconIdx = i;
}
};
});
var tickerTimer = undefined;
function resetTicker() {
tickerTimer = clearTimeout(tickerTimer);
F[0]();
}
function startTicker() {
function tick() {
if (!document.hasFocus()) {
F[1 - curFaviconIdx]();
tickerTimer = setTimeout(tick, 1000);
}
}
if (!tickerTimer) tickerTimer = setTimeout(tick, 200);
};
module.exports = {
init: function(ctrl) { window.addEventListener('focus', resetTicker); },
set: function(ctrl, text) {
if (ctrl.data.player.spectator) return;
if (!text) {
if (status.finished(ctrl.data)) {
text = ctrl.trans('gameOver');
} else if (game.isPlayerTurn(ctrl.data)) {
text = ctrl.trans('yourTurn');
if (!document.hasFocus()) startTicker();
} else {
text = ctrl.trans('waitingForOpponent');
resetTicker();
}
}
document.title = text + " - " + initialTitle;
}
};

53
ui/round2/src/title.ts Normal file
View file

@ -0,0 +1,53 @@
import { game, status } from 'game';
const initialTitle = document.title;
var curFaviconIdx = 0;
const F = [
'/assets/images/favicon-32-white.png',
'/assets/images/favicon-32-black.png'
].map(function(path, i) {
return function() {
if (curFaviconIdx !== i) {
const favicon = document.getElementById('favicon') as HTMLAnchorElement;
favicon.href = path;
curFaviconIdx = i;
}
};
});
var tickerTimer;
function resetTicker() {
tickerTimer = clearTimeout(tickerTimer);
F[0]();
}
function startTicker() {
function tick() {
if (!document.hasFocus()) {
F[1 - curFaviconIdx]();
tickerTimer = setTimeout(tick, 1000);
}
}
if (!tickerTimer) tickerTimer = setTimeout(tick, 200);
}
export function init() {
window.addEventListener('focus', resetTicker);
}
export function set(ctrl, text) {
if (ctrl.data.player.spectator) return;
if (!text) {
if (status.finished(ctrl.data)) {
text = ctrl.trans('gameOver');
} else if (game.isPlayerTurn(ctrl.data)) {
text = ctrl.trans('yourTurn');
if (!document.hasFocus()) startTicker();
} else {
text = ctrl.trans('waitingForOpponent');
resetTicker();
}
}
document.title = text + " - " + initialTitle;
}