Skip to content

Commit

Permalink
fix: build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamiell committed Aug 17, 2022
1 parent eba6865 commit 1cc54ab
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 66 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM node:16-buster

RUN mkdir -p /root/hanabi-live
WORKDIR /root/hanabi-live
COPY .env_template .env
COPY .env.example .env
COPY tsconfig.json tsconfig.json
COPY package.json package.json
COPY package-lock.json package-lock.json
Expand All @@ -21,7 +21,7 @@ FROM golang:1.17-buster

RUN mkdir -p /root/hanabi-live
WORKDIR /root/hanabi-live
COPY .env_template .env
COPY .env.example .env
COPY server server

RUN server/build_server.sh
Expand Down
2 changes: 1 addition & 1 deletion install/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ REPO_ROOT="$DIR/.."

# Ensure that the ".env" file exists
if [[ ! -f "$REPO_ROOT/.env" ]]; then
cp "$REPO_ROOT/.env_template" "$REPO_ROOT/.env"
cp "$REPO_ROOT/.env.example" "$REPO_ROOT/.env"
fi

# Install the JavaScript/TypeScript dependencies and build the client
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
"license": "GPL-3.0",
"author": "Zamiell",
"scripts": {
"test": "jest",
"variants": "npm run variants --workspace @hanabi/data"
"test": "jest"
},
"dependencies": {
"@sentry/browser": "^7.11.0",
"@sentry/browser": "^7.11.1",
"fast-deep-equal": "^3.1.3",
"immer": "8.0.4",
"interactjs": "^1.10.17",
Expand Down
8 changes: 6 additions & 2 deletions packages/client/build_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cd "$DIR"
# We need to pack it into one JavaScript file before sending it to end-users
echo "Packing the TypeScript using WebPack..."
echo
npm run webpack
npx webpack
echo

# Create a file that informs the server that the bundled JavaScript & CSS will not be available for
Expand All @@ -87,14 +87,18 @@ echo $(git rev-parse HEAD) > "$JS_BUNDLES_DIR/git_revision.txt"
if [[ $1 == "crit" ]]; then
echo "Packing the CSS and generating critical CSS using Grunt..."
echo
npm init --yes # Grunt needs a package.json to exist for some reason.
npx grunt critical --url="http://localhost:$PORT"
rm -f "$DIR/package.json"
echo
echo "Remember to commit critical.min.css if it had any changes."
echo
else
echo "Packing the CSS using Grunt..."
echo
npm run grunt
npm init --yes # Grunt needs a package.json to exist for some reason.
npx grunt
rm -f "$DIR/package.json"
echo
fi
GRUNT_OUTPUT_DIR="$DIR/grunt_output"
Expand Down
50 changes: 24 additions & 26 deletions packages/client/test/loadGameJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,38 +63,36 @@ export default function loadGameJSON(gameJSON: JSONGame): State {
(action.type === "discard" || action.type === "play")
) {
actions.push(drawCard(currentPlayerIndex, topOfDeck, gameJSON.deck));
topOfDeck += 1;
topOfDeck++;
}
}

turn += 1;
turn++;
currentPlayerIndex = (currentPlayerIndex + 1) % numPlayers;
});

// If the game was exported from the server and it ended in a specific way,
// the final action will be a "gameOver" action
// Otherwise, we need to insert one at the end,
// which matches what the server would do when emulating all of the database actions
const finalGameJSONAction = gameJSON.actions[gameJSON.actions.length - 1];
// If the game was exported from the server and it ended in a specific way, the final action will
// be a "gameOver" action. Otherwise, we need to insert one at the end, which matches what the
// server would do when emulating all of the database actions.
const finalGameJSONAction = gameJSON.actions[gameJSON.actions.length - 1]!;
// eslint-disable-next-line isaacscript/strict-enums
if (finalGameJSONAction.type !== ActionType.GameOver) {
actions.push({
type: "gameOver",
// Assume that the game ended normally;
// this is not necessarily the case and will break if a test game is added with a strikeout,
// a termination, etc.
// Assume that the game ended normally; this is not necessarily the case and will break if a
// test game is added with a strikeout, a termination, etc.
endCondition: 1,
playerIndex: currentPlayerIndex,
votes: [],
});
}

// Run the list of states through the state reducer
// We need to fix the list of cards touched in a clue, since that is not saved in the JSON
// We also need to figure out if plays are successful or not,
// since they both show up as plays in the JSON
// Run the list of states through the state reducer We need to fix the list of cards touched in a
// clue, since that is not saved in the JSON. We also need to figure out if plays are successful
// or not, since they both show up as plays in the JSON.
const state = initialState(metadata);

// Calculate all the intermediate states
// Calculate all the intermediate states.
const states: GameState[] = [state.ongoingGame];

const game = actions.reduce((s: GameState, a: GameAction) => {
Expand All @@ -103,9 +101,9 @@ export default function loadGameJSON(gameJSON: JSONGame): State {

switch (a.type) {
case "clue": {
// Fix the list of touched cards
const list: number[] = s.hands[a.target].filter((order) => {
const jsonCard = gameJSON.deck[order];
// Fix the list of touched cards.
const list: number[] = s.hands[a.target]!.filter((order) => {
const jsonCard = gameJSON.deck[order]!;
return cluesRules.touchesCard(
variant,
cluesRules.msgClueToClue(a.clue, variant),
Expand All @@ -118,21 +116,21 @@ export default function loadGameJSON(gameJSON: JSONGame): State {
}

case "play": {
// Check if this is actually a play or a misplay
const jsonCard: CardIdentity = gameJSON.deck[a.order];
// Check if this is actually a play or a misplay.
const jsonCard: CardIdentity = gameJSON.deck[a.order]!;
if (jsonCard.suitIndex === null || jsonCard.rank === null) {
throw new Error(
`Failed to get the rank or the suit for card ${a.order} in the JSON deck.`,
);
}

const nextRanks = playStacksRules.nextRanks(
s.playStacks[jsonCard.suitIndex],
s.playStackDirections[jsonCard.suitIndex],
s.playStacks[jsonCard.suitIndex]!,
s.playStackDirections[jsonCard.suitIndex]!,
s.deck,
);
if (!nextRanks.includes(jsonCard.rank)) {
// Send a discard and a strike
// Send a discard and a strike.
action = {
type: "discard",
playerIndex: a.playerIndex,
Expand Down Expand Up @@ -248,7 +246,7 @@ function dealInitialCards(
for (let player = 0; player < numPlayers; player++) {
for (let card = 0; card < cardsPerHand; card++) {
actions.push(drawCard(player, topOfDeck, deck));
topOfDeck += 1;
topOfDeck++;
}
}
return topOfDeck;
Expand All @@ -268,8 +266,8 @@ function parseJSONAction(
type: isPlay ? "play" : "discard",
playerIndex: currentPlayer,
order: a.target,
suitIndex: deck[a.target].suitIndex,
rank: deck[a.target].rank,
suitIndex: deck[a.target]!.suitIndex,
rank: deck[a.target]!.rank,
};
return isPlay ? (action as ActionPlay) : (action as ActionDiscard);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/client/test/testActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Helper functions to build actions with a compact syntax
// For use in tests
// Helper functions to build actions with a compact syntax. For use in tests.

import {
ActionCardIdentity,
Expand Down
60 changes: 30 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -951,14 +951,14 @@
dependencies:
"@types/node" "^10.0.3"

"@sentry/browser@^7.11.0":
version "7.11.0"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.11.0.tgz#9bdf4109839a272fac53a3af33b92840cb42f1e4"
integrity sha512-HgDoee4zj7Z2L0LsChS8BUT+KrlFcDaURA8nzTq3aNU6zYTpxunsbOSjOM2JYo/5B0AKWLw/l8IHgL/BPSuImg==
dependencies:
"@sentry/core" "7.11.0"
"@sentry/types" "7.11.0"
"@sentry/utils" "7.11.0"
"@sentry/browser@^7.11.1":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.11.1.tgz#377d417e833ef54c78a93ef720a742bda5022625"
integrity sha512-k2XHuzPfnm8VJPK5eWd1+Y5VCgN42sLveb8Qxc3prb5PSL416NWMLZaoB7RMIhy430fKrSFiosnm6QDk2M6pbA==
dependencies:
"@sentry/core" "7.11.1"
"@sentry/types" "7.11.1"
"@sentry/utils" "7.11.1"
tslib "^1.9.3"

"@sentry/cli@^1.74.4":
Expand All @@ -974,36 +974,36 @@
proxy-from-env "^1.1.0"
which "^2.0.2"

"@sentry/core@7.11.0":
version "7.11.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.11.0.tgz#c1ff437e77ce4e6047240a020dcec279a0be55a9"
integrity sha512-W4/Klb5CbpH8C/bvRAsNx0w6I7XoIMf8US79aSAwykhQRrhGSo7bwKOk1dPEMbEg6jbNWDNeTGnZUeYrDNkpUw==
"@sentry/core@7.11.1":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.11.1.tgz#d68e796f3b6428aefd6086a1db00118df7a9a9e4"
integrity sha512-kaDSZ6VNuO4ZZdqUOOX6XM6x+kjo2bMnDQ3IJG51FPvVjr8lXYhXj1Ccxcot3pBYAIWPPby2+vNDOXllmXqoBA==
dependencies:
"@sentry/hub" "7.11.0"
"@sentry/types" "7.11.0"
"@sentry/utils" "7.11.0"
"@sentry/hub" "7.11.1"
"@sentry/types" "7.11.1"
"@sentry/utils" "7.11.1"
tslib "^1.9.3"

"@sentry/hub@7.11.0":
version "7.11.0"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.11.0.tgz#94801dfc5b07660a463a3eeb66b2bc210d4cb10b"
integrity sha512-bNOKpifRRSdYmqltiwKVtEaG/vv/ArKLgCrWNGeQ22yBbKFCWHG2nulHqiN0rjbptRdG0VhKtbm4t5WnYEVjrg==
"@sentry/hub@7.11.1":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.11.1.tgz#1749b2b102ea1892ff388d65d66d3b402b393958"
integrity sha512-M6ClgdXdptS0lUBKB5KpXXe2qMQhsoiEN2pEGRI6+auqhfHCUQB1ZXsfjiOYexKC9fwx7TyFyZ9Jcaf2DTxEhw==
dependencies:
"@sentry/types" "7.11.0"
"@sentry/utils" "7.11.0"
"@sentry/types" "7.11.1"
"@sentry/utils" "7.11.1"
tslib "^1.9.3"

"@sentry/types@7.11.0":
version "7.11.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.11.0.tgz#d66101924f8a5f0c347f448dd34bb9d7aa84ae41"
integrity sha512-0xhfH9nHi68fstZpEGBS/q7a4hRRb99shh2EmP6KSM+eGkjLsr89XXBoI0NZzoHDsu0WsM9Ygpdu9wuXXBJ8CQ==
"@sentry/types@7.11.1":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.11.1.tgz#06e2827f6ba37159c33644208a0453b86d25e232"
integrity sha512-gIEhOPxC2cjrxQ0+K2SFJ1P6e/an5osSxVc9OOtekN28eHtVsXFCLB8XVWeNQnS7N2VkrVrkqORMBz1kvIcvVQ==

"@sentry/utils@7.11.0":
version "7.11.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.11.0.tgz#41ae6d0644d7e00b7f302f02e81296a3d49d97d6"
integrity sha512-c24q0JGxphvrwHQ7TJNH30bmLzGc3VeD8idtM5pcakmrZbOtXtL+HGoLIxd6YAyNNh3frKdqFHJnaQ3lN6gv3g==
"@sentry/utils@7.11.1":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.11.1.tgz#1635c5b223369d9428bc83c9b8908c9c3287ee10"
integrity sha512-tRVXNT5O9ilkV31pyHeTqA1PcPQfMV/2OR6yUYM4ah+QVISovC0f0ybhByuH5nYg6x/Gsnx1o7pc8L1GE3+O7A==
dependencies:
"@sentry/types" "7.11.0"
"@sentry/types" "7.11.1"
tslib "^1.9.3"

"@sentry/webpack-plugin@^1.19.0":
Expand Down

0 comments on commit 1cc54ab

Please sign in to comment.