From ba976648edef075de21ae91fc3c648eed572249c Mon Sep 17 00:00:00 2001 From: "Joseph C. Sible" Date: Sat, 17 Aug 2024 13:48:10 -0400 Subject: [PATCH 1/9] Fix #1641: be resilient to WURFL failing to load --- web/js/codeworld.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/js/codeworld.js b/web/js/codeworld.js index ecb95885..e4a5a904 100644 --- a/web/js/codeworld.js +++ b/web/js/codeworld.js @@ -334,7 +334,7 @@ function initCodeworld() { lineNumbers: true, autofocus: true, matchBrackets: true, - styleActiveLine: !WURFL || !WURFL.is_mobile, + styleActiveLine: !window.WURFL || !window.WURFL.is_mobile, showTrailingSpace: true, indentWithTabs: false, indentUnit: 2, From 27f7deeb84ef4c6168962106757f2d115b321bd2 Mon Sep 17 00:00:00 2001 From: alphamoris Date: Fri, 14 Feb 2025 16:53:11 +0000 Subject: [PATCH 2/9] Some minor fixation to solve the dependency issues --- codeworld-account/codeworld-account.cabal | 2 +- codeworld-auth/codeworld-auth.cabal | 4 ++-- codeworld-server/codeworld-server.cabal | 2 +- install.sh | 9 ++++++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/codeworld-account/codeworld-account.cabal b/codeworld-account/codeworld-account.cabal index 3bf0247d..48296422 100644 --- a/codeworld-account/codeworld-account.cabal +++ b/codeworld-account/codeworld-account.cabal @@ -26,7 +26,7 @@ library , bytestring , directory , hashable - , sqlite-simple + , sqlite-simple == 0.4.18.0 , text , transformers exposed-modules: CodeWorld.Account diff --git a/codeworld-auth/codeworld-auth.cabal b/codeworld-auth/codeworld-auth.cabal index 077e2fe8..1d0ac8ab 100644 --- a/codeworld-auth/codeworld-auth.cabal +++ b/codeworld-auth/codeworld-auth.cabal @@ -21,7 +21,7 @@ library ghc-options: -W -Wall -fwarn-unused-imports - build-depends: aeson + build-depends: aeson < 2.0.0 , base >= 4.7 && < 5 , base64-bytestring , bytestring @@ -31,7 +31,7 @@ library , directory , filepath , http-conduit - , jwt >= 0.10.0 + , jwt == 0.10.1 , snap-core , split , text diff --git a/codeworld-server/codeworld-server.cabal b/codeworld-server/codeworld-server.cabal index 035e6a68..c331a335 100644 --- a/codeworld-server/codeworld-server.cabal +++ b/codeworld-server/codeworld-server.cabal @@ -40,7 +40,7 @@ Executable codeworld-server filelock, filepath, haskell-src-exts < 1.21, - http-conduit, + http-conduit >= 2.3.0 && < 2.3.9, lifted-base, memory, mtl, diff --git a/install.sh b/install.sh index dbb578a7..8e13b86d 100755 --- a/install.sh +++ b/install.sh @@ -76,7 +76,7 @@ if [ ! -f $BUILD/progress/system-pkgs ]; then run . sudo apt-get install -y psmisc run . sudo apt-get install -y zlib1g-dev - run . sudo apt-get install -y libncurses5{,-dev} + run . sudo apt-get install -y libncurses-dev # Needed for GHC run . sudo apt-get install -y make @@ -86,6 +86,13 @@ if [ ! -f $BUILD/progress/system-pkgs ]; then # Needed for GHCJS run . sudo apt-get install -y gnupg + # If there is version depreciation warning for nodejs, + # Feel free to ignore the below two commands and install nodejs manually in root directory + # Install Node 12 -> $nvm install 12.22.12 + # Install specific npm version -> $npm install -g npm@6.14.16 + # Verify versions + # $node --version Should show v12.22.12 + # $npm --version Should show 6.14.16 run --quiet . curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - run . sudo apt-get install -y nodejs From 1b0eeeb314c4b92b30aede8db01eb5b9d42e8657 Mon Sep 17 00:00:00 2001 From: Bill Napier Date: Wed, 26 Mar 2025 22:25:28 +0000 Subject: [PATCH 3/9] Update runners to ubuntu-24.04 from deprecated ubuntu-20.04 label --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 106b8adc..258fc871 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ on: jobs: linux: - runs-on: ubuntu-20.04 + runs-on: 'ubuntu-24.04' strategy: fail-fast: false matrix: From f085ffa368c6f271b5ab9e429699c68a6e43947b Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 25 Jan 2026 07:49:28 -0500 Subject: [PATCH 4/9] auto-restart server on crash --- run.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 68051ddd..472904ca 100755 --- a/run.sh +++ b/run.sh @@ -29,5 +29,25 @@ mkdir -p data/blocklyXML/projects mkdir -p log -codeworld-game-server +RTS -T & -run . codeworld-server -p 8080 --no-access-log +# Run a server in a loop, restarting on crash +run_server() { + local name=$1 + shift + while true; do + echo "$(date): Starting $name" >> log/server-restarts.log + "$@" + exit_code=$? + echo "$(date): $name exited with code $exit_code" >> log/server-restarts.log + + # Exit codes: 0=clean, 137=SIGKILL (from fuser -k), 143=SIGTERM + # Only restart on unexpected crashes (like 139=SIGSEGV) + if [ $exit_code -eq 0 ] || [ $exit_code -eq 137 ] || [ $exit_code -eq 143 ]; then + break + fi + + sleep 2 + done +} + +run_server codeworld-game-server codeworld-game-server +RTS -T & +run_server codeworld-server codeworld-server -p 8080 --no-access-log From e9fc563f2510a114754ae2bea5f707aed3c62fe3 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 26 Jun 2024 18:35:13 +0000 Subject: [PATCH 5/9] Swap to fastly for polyfill --- web/blocks.html | 2 +- web/doc.html | 2 +- web/env.html | 2 +- web/gallery.html | 2 +- web/run.html | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/blocks.html b/web/blocks.html index 0997608b..0c8d97f7 100644 --- a/web/blocks.html +++ b/web/blocks.html @@ -143,7 +143,7 @@ - + + + CodeWorld diff --git a/web/gallery.html b/web/gallery.html index b9f565f2..fc8a1325 100644 --- a/web/gallery.html +++ b/web/gallery.html @@ -1,7 +1,7 @@ - + CodeWorld Gallery diff --git a/web/run.html b/web/run.html index 2b544017..13b98dc1 100644 --- a/web/run.html +++ b/web/run.html @@ -2,7 +2,7 @@ CodeWorld - + From e66959197c10c79ff7da9c83e8de91752a0d82b1 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 26 Jun 2024 18:35:47 +0000 Subject: [PATCH 6/9] Remove prehook formatter that is failing --- .githooks/pre-commit | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 786cf949..ae804470 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -12,12 +12,12 @@ FILES_ORMOLU=$(git diff --cached --name-only --diff-filter=ACMR "*.hs" | \ set -euo pipefail -if [ -n "$FILES_PRETTIER" ] -then - echo "Reprinting staged JS, CSS and HTML files with Prettier ..." - echo "$FILES_PRETTIER" | xargs npx prettier --write - echo "Reprinting complete." -fi +# if [ -n "$FILES_PRETTIER" ] +# then +# echo "Reprinting staged JS, CSS and HTML files with Prettier ..." +# echo "$FILES_PRETTIER" | xargs npx prettier --write +# echo "Reprinting complete." +# fi if [ -n "$FILES_ESLINT" ]; then From bd2bbf1223327f1b7112f2c642359e5446bf3959 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 25 Jan 2026 14:28:47 +0000 Subject: [PATCH 7/9] Update auth to be compatible with newer version --- codeworld-auth/codeworld-auth.cabal | 2 +- .../src/CodeWorld/Auth/LocalAuth.hs | 48 +++++++++++-------- codeworld-auth/src/CodeWorld/Auth/Token.hs | 15 +++--- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/codeworld-auth/codeworld-auth.cabal b/codeworld-auth/codeworld-auth.cabal index 1d0ac8ab..2a429b40 100644 --- a/codeworld-auth/codeworld-auth.cabal +++ b/codeworld-auth/codeworld-auth.cabal @@ -31,7 +31,7 @@ library , directory , filepath , http-conduit - , jwt == 0.10.1 + , jwt >= 0.11.0 , snap-core , split , text diff --git a/codeworld-auth/src/CodeWorld/Auth/LocalAuth.hs b/codeworld-auth/src/CodeWorld/Auth/LocalAuth.hs index a7115308..5d485836 100644 --- a/codeworld-auth/src/CodeWorld/Auth/LocalAuth.hs +++ b/codeworld-auth/src/CodeWorld/Auth/LocalAuth.hs @@ -129,15 +129,18 @@ import Snap.Core ) import System.Directory (doesFileExist) import System.FilePath (()) -import Web.JWT (Signer (..)) +import Web.JWT (EncodeSigner (..), VerifySigner (..)) -data AuthConfig = AuthConfig Signer Store +data AuthConfig = AuthConfig EncodeSigner VerifySigner Store codeWorldIssuer :: Issuer codeWorldIssuer = Issuer "https://code.world/" -jwtSigner :: Secret -> Signer -jwtSigner (Secret bytes) = HMACSecret bytes +jwtEncodeSigner :: Secret -> EncodeSigner +jwtEncodeSigner (Secret bytes) = EncodeHMACSecret bytes + +jwtVerifySigner :: Secret -> VerifySigner +jwtVerifySigner (Secret bytes) = VerifyHMACSecret bytes jwtAuthType :: ByteString jwtAuthType = "Bearer" @@ -152,14 +155,16 @@ configureAuth appDir = do putStrLn $ "Secret key file not found at " ++ secretPath ++ ": skipping configuration of local authentication" pure Nothing True -> do - signer <- jwtSigner <$> readSecret secretPath + secret <- readSecret secretPath + let encodeSigner = jwtEncodeSigner secret + let verifySigner = jwtVerifySigner secret let store = Store storePath storeExists_ <- storeExists store case storeExists_ of False -> do putStrLn $ "Account store database file not found at " ++ storePath ++ ": skipping configuration of local authentication" pure Nothing - True -> pure $ Just (AuthConfig signer store) + True -> pure $ Just (AuthConfig encodeSigner verifySigner store) authRoutes :: AuthConfig -> [(ByteString, Snap ())] authRoutes authConfig = @@ -183,10 +188,10 @@ optionallyAuthenticated handler authConfig = do Just authHeaderBS -> authenticatedHelper authConfig (\userId -> handler $ Just userId) authHeaderBS True authenticatedHelper :: AuthConfig -> (UserId -> Snap ()) -> ByteString -> Bool -> Snap () -authenticatedHelper (AuthConfig signer _) handler authHeaderBS checkExpiry = withSnapExcept $ do +authenticatedHelper (AuthConfig _ verifySigner _) handler authHeaderBS checkExpiry = withSnapExcept $ do AccessToken issuer _ expiresAt userId <- hoistMaybe (finishWith forbidden403) $ do j <- parseBearerAuthHeader authHeaderBS - parseAccessToken signer j + parseAccessToken verifySigner j when (issuer /= codeWorldIssuer) @@ -201,11 +206,11 @@ authenticatedHelper (AuthConfig signer _) handler authHeaderBS checkExpiry = wit lift $ handler userId refreshTokenHandler :: AuthConfig -> Snap () -refreshTokenHandler authConfig@(AuthConfig signer store) = do +refreshTokenHandler authConfig@(AuthConfig _ verifySigner store) = do j <- Text.pack . Char8.unpack <$> getRequiredParam "refreshToken" withSnapExcept $ do -- 1. Parse refresh token - RefreshToken issuer _ expiresAt userId tokenId <- hoistMaybe (finishWith forbidden403) $ parseRefreshToken signer j + RefreshToken issuer _ expiresAt userId tokenId <- hoistMaybe (finishWith forbidden403) $ parseRefreshToken verifySigner j -- 2. Check issuer when @@ -226,7 +231,7 @@ refreshTokenHandler authConfig@(AuthConfig signer store) = do lift $ generateTokenJson authConfig userId now signInHandler :: AuthConfig -> Snap () -signInHandler authConfig@(AuthConfig _ store) = withSnapExcept $ do +signInHandler authConfig@(AuthConfig _ _ store) = withSnapExcept $ do req <- lift getRequest (userId, password) <- hoistMaybe (finishWith (unauthorized401 jwtAuthType)) $ do authHeader <- getHeader "Authorization" req @@ -261,10 +266,10 @@ signInHandler authConfig@(AuthConfig _ store) = withSnapExcept $ do generateTokenJson authConfig userId now signOutHandler :: AuthConfig -> Snap () -signOutHandler (AuthConfig signer store) = do +signOutHandler (AuthConfig _ verifySigner store) = do j <- Text.pack . Char8.unpack <$> getRequiredParam "refreshToken" withSnapExcept $ do - RefreshToken issuer _ _ userId tokenId <- hoistMaybe (finishWith forbidden403) $ parseRefreshToken signer j + RefreshToken issuer _ _ userId tokenId <- hoistMaybe (finishWith forbidden403) $ parseRefreshToken verifySigner j when (issuer /= codeWorldIssuer) @@ -278,7 +283,7 @@ signOutHandler (AuthConfig signer store) = do lift $ finishWith ok200 generateTokenJson :: AuthConfig -> UserId -> UTCTime -> Snap () -generateTokenJson (AuthConfig signer store) userId now = withSnapExcept $ do +generateTokenJson (AuthConfig encodeSigner _ store) userId now = withSnapExcept $ do -- 1. Generate new token ID mbNewTokenId <- liftIO $ incrementTokenId store userId newTokenId <- @@ -291,19 +296,20 @@ generateTokenJson (AuthConfig signer store) userId now = withSnapExcept $ do atJson <- hoistMaybe (finishWith internalServerError500) - (renderAccessToken signer at) + (renderAccessToken encodeSigner at) let rt = refreshToken codeWorldIssuer now userId newTokenId rtJson <- hoistMaybe (finishWith internalServerError500) - (renderRefreshToken signer rt) + (renderRefreshToken encodeSigner rt) -- 7. HTTP 200 response with tokens - lift $ ok200Json $ - m - [ ("accessToken", Text.unpack atJson), - ("refreshToken", Text.unpack rtJson) - ] + lift $ + ok200Json $ + m + [ ("accessToken", Text.unpack atJson), + ("refreshToken", Text.unpack rtJson) + ] satisfiesPasswordPolicy :: Password -> Password -> Bool satisfiesPasswordPolicy (Password passwordRaw) (Password newPasswordRaw) diff --git a/codeworld-auth/src/CodeWorld/Auth/Token.hs b/codeworld-auth/src/CodeWorld/Auth/Token.hs index df4c0489..6a377f4a 100644 --- a/codeworld-auth/src/CodeWorld/Auth/Token.hs +++ b/codeworld-auth/src/CodeWorld/Auth/Token.hs @@ -45,9 +45,10 @@ import Data.Time.Clock import Text.Read (readMaybe) import Web.JWT ( ClaimsMap (..), + EncodeSigner (..), JWTClaimsSet (..), - Signer (..), StringOrURI, + VerifySigner (..), claims, decodeAndVerifySignature, encodeSigned, @@ -96,17 +97,17 @@ refreshToken issuer issuedAt userId tokenId = let expiresAt = addUTCTime refreshTokenExpiryPeriod issuedAt in RefreshToken issuer issuedAt expiresAt userId tokenId -renderAccessToken :: Signer -> AccessToken -> Maybe Text +renderAccessToken :: EncodeSigner -> AccessToken -> Maybe Text renderAccessToken signer (AccessToken issuer issuedAt expiresAt userId) = renderHelper signer issuer issuedAt expiresAt userId $ Map.fromList [("token-type", String "access")] -renderRefreshToken :: Signer -> RefreshToken -> Maybe Text +renderRefreshToken :: EncodeSigner -> RefreshToken -> Maybe Text renderRefreshToken signer (RefreshToken issuer issuedAt expiresAt userId (TokenId tokenId)) = renderHelper signer issuer issuedAt expiresAt userId $ Map.fromList [("token-type", String "refresh"), ("token-id", String $ (Text.pack . show) tokenId)] -renderHelper :: Signer -> Issuer -> UTCTime -> UTCTime -> UserId -> Map Text Value -> Maybe Text +renderHelper :: EncodeSigner -> Issuer -> UTCTime -> UTCTime -> UserId -> Map Text Value -> Maybe Text renderHelper signer issuer issuedAt expiresAt (UserId userIdRaw) extraClaims = do issuedAtNum <- utcTimeToNumericDate issuedAt expiresAtNum <- utcTimeToNumericDate expiresAt @@ -120,14 +121,14 @@ renderHelper signer issuer issuedAt expiresAt (UserId userIdRaw) extraClaims = d } return $ encodeSigned signer mempty claimsSet -parseAccessToken :: Signer -> Text -> Maybe AccessToken +parseAccessToken :: VerifySigner -> Text -> Maybe AccessToken parseAccessToken signer j = do (tokenType, issuer, issuedAt, expiresAt, userId, _) <- parseHelper signer j case tokenType of Access -> Just $ AccessToken issuer issuedAt expiresAt userId _ -> Nothing -parseRefreshToken :: Signer -> Text -> Maybe RefreshToken +parseRefreshToken :: VerifySigner -> Text -> Maybe RefreshToken parseRefreshToken signer j = do (tokenType, issuer, issuedAt, expiresAt, userId, extraClaims) <- parseHelper signer j case tokenType of @@ -138,7 +139,7 @@ parseRefreshToken signer j = do Just $ RefreshToken issuer issuedAt expiresAt userId tokenId _ -> Nothing -parseHelper :: Signer -> Text -> Maybe (TokenType, Issuer, UTCTime, UTCTime, UserId, Map Text Value) +parseHelper :: VerifySigner -> Text -> Maybe (TokenType, Issuer, UTCTime, UTCTime, UserId, Map Text Value) parseHelper signer j = do jwt <- decodeAndVerifySignature signer j let c = claims jwt From 347fb522ff71e49dfa67b449bcb167cfd52d7906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janis=20Voigtl=C3=A4nder?= Date: Thu, 16 Apr 2026 20:21:18 +0200 Subject: [PATCH 8/9] Fix typo Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 8e13b86d..307918c4 100755 --- a/install.sh +++ b/install.sh @@ -86,7 +86,7 @@ if [ ! -f $BUILD/progress/system-pkgs ]; then # Needed for GHCJS run . sudo apt-get install -y gnupg - # If there is version depreciation warning for nodejs, + # If there is a Node.js version deprecation warning, # Feel free to ignore the below two commands and install nodejs manually in root directory # Install Node 12 -> $nvm install 12.22.12 # Install specific npm version -> $npm install -g npm@6.14.16 From 72e6971a228595d33f87e8fa6489726b8b5e9f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janis=20Voigtl=C3=A4nder?= Date: Fri, 17 Apr 2026 16:00:32 +0200 Subject: [PATCH 9/9] remove script files not used in this repo fork --- build.sh | 108 --------------------- install.sh | 268 ----------------------------------------------------- test.sh | 31 ------- 3 files changed, 407 deletions(-) delete mode 100755 build.sh delete mode 100755 install.sh delete mode 100755 test.sh diff --git a/build.sh b/build.sh deleted file mode 100755 index 3d3cad78..00000000 --- a/build.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash - -# Copyright 2020 The CodeWorld Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cwd=$(pwd) - -source base.sh - -# Locally mirror various third-party JavaScript, CSS, etc, so that we don't -# have to have user's browsers retrieve code from random remote locations. - -run . mirror/get_mirrored - -# Install the codeworld-base and codeworld-api packages -run . cabal_install --ghcjs ./codeworld-prediction \ - ./codeworld-error-sanitizer \ - ./codeworld-api \ - ./codeworld-base \ - ./codeworld-game-api \ - ./codeworld-available-pkgs - -# Hide packages that conflict with modules in more popular choices. -run . ghcjs-pkg hide base-compat # Use base-compat-batteries -run . ghcjs-pkg hide ghcjs-dom-jsffi # Use ghcjs-dom -run . ghcjs-pkg hide matrices # Conflicts with matrix -run . ghcjs-pkg hide simple-affine-space # Conflicts with vector-space -run . ghcjs-pkg hide newtype # Replaced by newtype-generics -run . ghcjs-pkg hide non-empty # Conflicts with semialign -run . ghcjs-pkg hide hgeometry-combinatorial # Conflicts with random-shuffle -run . ghcjs-pkg hide Cabal # Conflicts between multiple versions -run . ghcjs-pkg hide cabal-doctest # Conflicts between multiple versions -run . ghcjs-pkg hide some # Conflicts with dependent-sum - -# Check for duplicate modules. Fail the build if so, since that's a -# poor user experience. -run . nodejs build/bin/find-dup-modules.jsexe/all.js \ - ~/.ghcjs/x86_64-linux-8.6.0.1-8.6.5/ghcjs/package.conf.d/package.cache - -run codeworld-base cabal configure --ghcjs -run codeworld-base cabal haddock --html -run codeworld-base cabal haddock --hoogle - -# Work-around for haddock dropping pattern synonyms in hoogle output. -grep -r -s -h 'pattern\s*[A-Za-z_0-9]*\s*::.*' codeworld-base/ \ - >> web/codeworld-base.txt - -run codeworld-api cabal configure --ghcjs -run codeworld-api cabal haddock --html -run codeworld-api cabal haddock --hoogle - -# Build codeworld-server from this project. - -run . cabal_install ./codeworld-server \ - ./codeworld-error-sanitizer \ - ./codeworld-compiler \ - ./codeworld-requirements \ - ./codeworld-game-api \ - ./codeworld-prediction \ - ./codeworld-api \ - ./codeworld-game-server \ - ./codeworld-account \ - ./codeworld-auth - -# Build the JavaScript client code for FunBlocks, the block-based UI. -run . cabal_install --ghcjs ./funblocks-client - -# Build the CodeMirror JavaScript bundle. -function build_codemirror { - node_modules/uglify-js/bin/uglifyjs \ - lib/codemirror.js \ - addon/dialog/dialog.js \ - addon/display/placeholder.js \ - addon/display/rulers.js \ - addon/edit/matchbrackets.js \ - addon/hint/show-hint.js \ - addon/lint/lint.js \ - addon/runmode/runmode.js \ - addon/scroll/annotatescrollbar.js \ - addon/search/match-highlighter.js \ - addon/search/matchesonscrollbar.js \ - addon/search/search.js \ - addon/search/searchcursor.js \ - addon/selection/active-line.js \ - mode/haskell/haskell.js \ - node_modules/codemirror-extension/addon/hover/text-hover.js \ - -c -m \ - > codemirror-compressed.js - exitcode=$? - if [ $exitcode -ne 0 ]; then - cat codemirror-compressed.js - rm codemirror-compressed.js - fi - return $exitcode -} - -run $BUILD/CodeMirror build_codemirror diff --git a/install.sh b/install.sh deleted file mode 100755 index 307918c4..00000000 --- a/install.sh +++ /dev/null @@ -1,268 +0,0 @@ -#!/bin/bash - -# Copyright 2020 The CodeWorld Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -euo pipefail - -source base.sh - -mkdir -p $BUILD/downloads -mkdir -p $BUILD/bin -mkdir -p $BUILD/progress - -# Determine which package management tool is installed, and install -# necessary system packages. - -if [ ! -f $BUILD/progress/system-pkgs ]; then - if type yum > /dev/null 2> /dev/null - then - echo Detected 'yum': Installing packages from there. - echo - - # Update and install basic dependencies - - run . sudo yum update -y - - run . sudo yum install -y git - run . sudo yum install -y curl - run . sudo yum install -y wget - run . sudo yum install -y bzip2 - run . sudo yum install -y zlib-devel - run . sudo yum install -y ncurses-devel - - # Needed for GHC - run . sudo yum install -y gcc - run . sudo yum install -y gcc-c++ - run . sudo yum install -y gmp-devel - - # Needed for GHCJS - run --quiet . curl --silent --location https://rpm.nodesource.com/setup_8.x | run . sudo bash - - run . sudo yum install -y nodejs - - # Needed for ghcjs-boot --dev - run . sudo yum install -y patch - run . sudo yum install -y autoconf - run . sudo yum install -y automake - - # Needed for codeworld-auth - run . sudo yum install -y openssl-devel - elif type apt-get > /dev/null 2> /dev/null - then - echo Detected 'apt-get': Installing packages from there. - echo - - # Update and install basic dependencies - - run . sudo apt-get update -y - - run . sudo apt-get install -y pkg-config - run . sudo apt-get install -y git - run . sudo apt-get install -y curl - run . sudo apt-get install -y wget - run . sudo apt-get install -y bzip2 - run . sudo apt-get install -y xz-utils - run . sudo apt-get install -y psmisc - - run . sudo apt-get install -y zlib1g-dev - run . sudo apt-get install -y libncurses-dev - - # Needed for GHC - run . sudo apt-get install -y make - run . sudo apt-get install -y gcc - run . sudo apt-get install -y g++ - run . sudo apt-get install -y libgmp-dev - - # Needed for GHCJS - run . sudo apt-get install -y gnupg - # If there is a Node.js version deprecation warning, - # Feel free to ignore the below two commands and install nodejs manually in root directory - # Install Node 12 -> $nvm install 12.22.12 - # Install specific npm version -> $npm install -g npm@6.14.16 - # Verify versions - # $node --version Should show v12.22.12 - # $npm --version Should show 6.14.16 - run --quiet . curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - - run . sudo apt-get install -y nodejs - - # Needed for ghcjs-boot --dev - run . sudo apt-get install -y patch - run . sudo apt-get install -y autoconf - run . sudo apt-get install -y automake - run . sudo apt-get install -y libtinfo-dev - - # Needed for codeworld-auth - run . sudo apt-get install -y libssl-dev - elif type zypper > /dev/null 2> /dev/null - then - echo Detected 'zypper': Installing packages from there. - echo - - # Update and install basic dependencies - - run . sudo zypper -n refresh - - run . sudo zypper -n install git - run . sudo zypper -n install curl - run . sudo zypper -n install wget - run . sudo zypper -n install bzip2 - run . sudo zypper -n install psmisc - - run . sudo zypper -n install zlib-devel - run . sudo zypper -n install ncurses-devel - - # Needed for GHC - run . sudo zypper -n install make - run . sudo zypper -n install gcc - run . sudo zypper -n install gmp-devel - - # Needed for GHCJS - run . sudo zypper -n install nodejs6 - - # Needed for ghcjs-boot --dev - run . sudo zypper -n install patch - run . sudo zypper -n install autoconf - run . sudo zypper -n install automake - - # Needed for codeworld-auth - run . sudo zypper -n install libopenssl-devel - elif type brew > /dev/null 2> /dev/null - then - echo Detected 'brew': Installing packages from there. - echo - - # install missing packages -- don't try to upgrade already installed packages - function brew_install { - if ! brew ls $1 > /dev/null 2> /dev/null - then - run . brew install $1 - fi - } - - # Update and install basic dependencies - xcode-select --install - - brew_install git - brew_install curl - brew_install wget - brew_install bzip2 - - # Needed for GHC - brew_install make - brew_install gcc - - # Needed for GHCJS - brew_install node@6 - brew_install gnu-tar - - # Needed for ghcjs-boot --dev - brew_install autoconf - brew_install automake - - # Needed for codeworld-auth - brew_install openssl - else - echo "WARNING: Could not find package manager." - echo "Make sure necessary packages are installed." - fi - - touch $BUILD/progress/system-pkgs -fi - -# Install ghcup, a minimal tool for installing GHC. - -if [ ! -f $BUILD/progress/ghcup ]; then - run . mkdir -p $BUILD/.ghcup/bin - run $BUILD/.ghcup/bin wget https://gitlab.haskell.org/haskell/ghcup/raw/master/ghcup - run . chmod +x $BUILD/.ghcup/bin/ghcup - run . ghcup upgrade - - touch $BUILD/progress/ghcup -fi - -# Install GHC. - -if [ ! -f $BUILD/progress/ghc ]; then - run . ghcup install 8.6.5 - run . ghcup set 8.6.5 - - touch $BUILD/progress/ghc -fi - -if [ ! -f $BUILD/progress/cabal-install ]; then - run . ghcup install-cabal 2.4.1.0 - run . cabal update --index-state='2023-02-09T01:33:22Z' - - touch $BUILD/progress/cabal-install -fi - -# Install GHCJS itself (https://github.com/ghcjs/ghcjs), which depends on happy and alex. - -function fix_libexec_binary { - # Work-around for https://github.com/ghcjs/ghcjs/issues/740 - # Should be run from $BUILD/bin - - if [ ! -e $BUILD/bin/$1 ]; then - ln -s $(dirname $(dirname $(readlink $1)))/libexec/$1 $1-new - mv $1-new $1 - fi -} - -if [ ! -f $BUILD/progress/ghcjs ]; then - run . cabal v2-install alex --symlink-bindir=$BUILD/bin - # Forces re-install an older buggy version of happy required to build ghc - # older than 8.8.1: https://gitlab.haskell.org/ghc/ghc/issues/16652 - run . cabal v2-install happy-1.19.9 --symlink-bindir=$BUILD/bin --overwrite-policy=always - run $BUILD rm -rf ghcjs - run $BUILD git clone --recurse-submodules --branch ghc-8.6 --single-branch https://github.com/ghcjs/ghcjs.git - # The following two commands can be combined in git 2.13 using --recurse-submodules. - run $BUILD/ghcjs git checkout eeeb0cde48e093e278fc1a4f418b48a2d23aa08c - run $BUILD/ghcjs git submodule update --init - run . patch -p0 -u -d $BUILD < ghc-artifacts/ghcjs-8.6-default-main.patch - run . patch -p0 -u -d $BUILD < ghc-artifacts/ghcjs-8.6-dedup-fix.patch - run $BUILD/ghcjs ./utils/makePackages.sh - run $BUILD/ghcjs cabal v2-install . --symlink-bindir=$BUILD/bin -j1 --disable-documentation --overwrite-policy=always - - run $BUILD/bin fix_libexec_binary ghcjs-boot - run $BUILD/bin fix_libexec_binary ghcjs-run - run $BUILD/bin fix_libexec_binary ghcjs-dumparchive - - touch $BUILD/progress/ghcjs -fi - -if [ ! -f $BUILD/progress/ghcjs-boot ]; then - run $BUILD/ghcjs ghcjs-boot -j$NPROC --no-prof --no-haddock -s lib/boot - touch $BUILD/progress/ghcjs-boot -fi - -# Install tools to build CodeMirror editor. - -if [ ! -f $BUILD/progress/codemirror ]; then - run $BUILD rm -rf $BUILD/CodeMirror - run $BUILD git clone https://github.com/codemirror/CodeMirror.git - run $BUILD/CodeMirror git checkout dde0e5cb51b243c61de9c43405b60c69a86dfb24 - run $BUILD/CodeMirror npm install - run $BUILD/CodeMirror npm install -s uglify-js https://github.com/angelozerr/CodeMirror-Extension - - touch $BUILD/progress/codemirror -fi - -# Fetch third_party/blockly submodule -run . git submodule init -run . git submodule update - -run . git config core.hooksPath .githooks - -# Go ahead and run a first build, which installs more local packages. -./build.sh diff --git a/test.sh b/test.sh deleted file mode 100755 index 07fc2b6d..00000000 --- a/test.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# Copyright 2020 The CodeWorld Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -source base.sh - -for i in $(grep -l -i Test-Suite */*.cabal | grep -v ghcjs); do - TARGET=$(dirname $i) - - run $TARGET cabal_install --enable-tests --only-dependencies - run $TARGET cabal_configure --enable-tests - run $TARGET cabal test - - if [ $TARGET == "codeworld-api" ]; then - run $TARGET cabal_install --ghcjs --enable-tests --only-dependencies - run $TARGET cabal_configure --ghcjs --enable-tests - run $TARGET cabal test - fi -done