#!/bin/bash echo "This script will remove / overwrite the content of some \"dist/\" directories." read -p "Do you want to continue ? [y/N]: " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]] then echo "Aborted" exit 1 fi function clean { rm -rf ./frontend/dist && \ rm -rf ./backend/dist && \ rm -rf ./backend/npm && \ rm -rf ./dist && \ true } function build_backend_npm_package { deno run --allow-env --allow-read --allow-write=./backend/npm --allow-run=npm ./backend/build-for-npm.ts ./backend/npm 1.0.0 } function build_frontend { dir=$(pwd) cd frontend npm run build cd "$dir" } function bundle_frontend_files_info_single_json_file { deno run --allow-read=./frontend/dist,./dist --allow-write=./dist ./bundle.ts ./frontend/dist ./dist/bundled-view-files.json cp ./dist/bundled-view-files.json ./backend/src/modules/view/bundled-view-files.json } function compile_for { target=$1 mkdir -p "./dist/bin" deno compile --config "./backend/deno.json" --target "$target" --output "./dist/bin/$target" --allow-net --allow-read --allow-write --allow-sys --allow-run ./backend/src/main.ts } function compile_all { compile_for x86_64-unknown-linux-gnu compile_for aarch64-unknown-linux-gnu compile_for x86_64-pc-windows-msvc compile_for x86_64-apple-darwin compile_for aarch64-apple-darwin } clean build_backend_npm_package build_frontend bundle_frontend_files_info_single_json_file compile_all