diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 402e53e9..de768a58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] browser: [electron, chrome] steps: - name: Checkout repository diff --git a/Projects/MathlibDemo/build.cmd b/Projects/MathlibDemo/build.cmd new file mode 100644 index 00000000..6f669155 --- /dev/null +++ b/Projects/MathlibDemo/build.cmd @@ -0,0 +1,22 @@ +REM @echo off +setlocal enabledelayedexpansion + +REM Operate in the directory where this file is located +cd /d "%~dp0" + +REM Updating Mathlib: We follow the instructions at +REM https://github.com/leanprover-community/mathlib4/wiki/Using-mathlib4-as-a-dependency#updating-mathlib4 + +REM Note: we had once problems with the `lake-manifest` when a new dependency got added +REM to `mathlib`, we may need to add `rm lake-manifest.json` again if that's still a problem. + +REM currently the mathlib post-update-hook is not good enough to update the lean-toolchain. +REM things break if the new lakefile is not valid in the old lean version +curl -L https://raw.githubusercontent.com/leanprover-community/mathlib4/master/lean-toolchain -o lean-toolchain + +REM note: mathlib has now a post-update hook that modifies the `lean-toolchain` +REM and calls `lake exe cache get`. + +lake update -R +lake build +lake build Batteries diff --git a/Projects/MathlibDemo/build.sh b/Projects/MathlibDemo/build.sh deleted file mode 100755 index 4ddc624d..00000000 --- a/Projects/MathlibDemo/build.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -# Operate in the directory where this file is located -cd $(dirname $0) - -# Updating Mathlib: We follow the instructions at -# https://github.com/leanprover-community/mathlib4/wiki/Using-mathlib4-as-a-dependency#updating-mathlib4 - -# Note: we had once problems with the `lake-manifest` when a new dependency got added -# to `mathlib`, we may need to add `rm lake-manifest.json` again if that's still a problem. - -# currently the mathlib post-update-hook is not good enough to update the lean-toolchain. -# things break if the new lakefile is not valid in the old lean version -curl -L https://raw.githubusercontent.com/leanprover-community/mathlib4/master/lean-toolchain -o lean-toolchain - -# note: mathlib has now a post-update hook that modifies the `lean-toolchain` -# and calls `lake exe cache get`. - -lake update -R -lake build -lake build Batteries diff --git a/Projects/Stable/build.sh b/Projects/Stable/build old mode 100755 new mode 100644 similarity index 100% rename from Projects/Stable/build.sh rename to Projects/Stable/build diff --git a/Projects/Stable/build.cmd b/Projects/Stable/build.cmd new file mode 100644 index 00000000..4f99756b --- /dev/null +++ b/Projects/Stable/build.cmd @@ -0,0 +1,8 @@ +@echo off +setlocal enabledelayedexpansion + +REM Operate in the directory where this file is located +cd /d "%~dp0" + +lake update -R +lake build diff --git a/package-lock.json b/package-lock.json index c8acee13..d4b4daf4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,7 @@ "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", "@vitejs/plugin-react-swc": "^3.8.0", + "cross-env": "^7.0.3", "cypress": "^13.17.0", "cypress-iframe": "^1.0.1", "cypress-real-events": "^1.14.0", @@ -4331,6 +4332,25 @@ "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", "license": "MIT" }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", diff --git a/package.json b/package.json index 48b7ada6..25921321 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,12 @@ ], "scripts": { "start": "concurrently -n server,client -c blue,green \"npm run start:server\" \"npm run start:client\"", - "start:server": "cd server && NODE_ENV=development nodemon ./index.mjs", - "start:client": "NODE_ENV=development vite --host", + "start:server": "cd server && cross-env NODE_ENV=development nodemon ./index.mjs", + "start:client": "cross-env NODE_ENV=development vite --host", "build": "npm run build:server && npm run build:client", - "build:server": "server/build.sh", - "build:client": "tsc -b && NODE_ENV=production vite build", - "production": "NODE_ENV=production node server/index.mjs", + "build:server": "node server/build.cjs", + "build:client": "tsc -b && cross-env NODE_ENV=production vite build", + "production": "cross-env NODE_ENV=production node server/index.mjs", "dev": "vite", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview", @@ -55,6 +55,7 @@ "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", "@vitejs/plugin-react-swc": "^3.8.0", + "cross-env": "^7.0.3", "cypress": "^13.17.0", "cypress-iframe": "^1.0.1", "cypress-real-events": "^1.14.0", @@ -65,7 +66,7 @@ "vite-plugin-svgr": "^4.3.0", "wait-on": "^8.0.2" }, - "engines" : { - "node" : ">=22.0.0" + "engines": { + "node": ">=22.0.0" } } diff --git a/server/build.cjs b/server/build.cjs new file mode 100755 index 00000000..f2464fcf --- /dev/null +++ b/server/build.cjs @@ -0,0 +1,44 @@ +#!/usr/bin/env node + +const fs = require('fs'); +const path = require('path'); +const { spawnSync } = require('child_process'); + +// Change to ../Projects directory relative to this script +const baseDir = path.resolve(__dirname, '../Projects'); +process.chdir(baseDir); +const isWin = process.platform === 'win32'; +const buildScriptName = isWin ? 'build.cmd' : 'build.sh'; + +// Iterate over subfolders in Projects +fs.readdirSync('.').forEach(folder => { + const folderPath = path.join(baseDir, folder); + + if (fs.lstatSync(folderPath).isDirectory()) { + + const buildScriptPath = path.join(folderPath, buildScriptName); + + if (fs.existsSync(buildScriptPath)) { + const start = Date.now(); + + console.log(`Start building ${folder}`); + if (!isWin) { + spawnSync('logger', ['-t', 'lean4web', `Start building ${folder}`]); + } + + // Run the build script + const result = spawnSync('bash', [buildScriptPath], { stdio: 'inherit' }); + + const duration = Math.floor((Date.now() - start) / 1000); + const minutes = Math.floor(duration / 60); + const seconds = duration % 60; + + console.log(`Finished ${folder} in ${minutes}:${seconds < 10 ? '0' : ''}${seconds} min`); + if (!isWin) { + spawnSync('logger', ['-t', 'lean4web', `Finished ${folder} in ${minutes}:${seconds < 10 ? '0' : ''}${seconds} min`]); + } + } else { + console.log(`Skipping ${folder}: ${buildScriptName} missing`); + } + } +}); \ No newline at end of file diff --git a/server/build.sh b/server/build.sh deleted file mode 100755 index 0c52385c..00000000 --- a/server/build.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -cd "$(dirname $0)/../Projects" - -# Iterate over subfolders in Projects and look for a build file `build.sh` -for folder in "."/*; do - if [ -d "$folder" ]; then - build_script="$folder/build.sh" - if [ -f "$build_script" ]; then - SECONDS=0 - echo "Start building $folder" - echo "Start building $folder" | logger -t lean4web - - "$build_script" - - duration=$SECONDS - echo "Finished $folder in $(($duration / 60)):$(($duration % 60)) min" - echo "Finished $folder in $(($duration / 60)):$(($duration % 60)) min" | logger -t lean4web - else - echo "Skipping $folder: build.sh missing" - fi - - fi -done