From 338012ec7ee36c79ba96037a3db23e564d3aa9ba Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 20 Jul 2024 16:48:41 +0300 Subject: [PATCH] build: Bring update script for better-sqlite3 --- bin/better-sqlite3/update.sh | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 bin/better-sqlite3/update.sh diff --git a/bin/better-sqlite3/update.sh b/bin/better-sqlite3/update.sh new file mode 100755 index 0000000000..74dbeb01b7 --- /dev/null +++ b/bin/better-sqlite3/update.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +ELECTRON_VERSION="electron-v125" +NODE_VERSION="node-v115" + +if ! command -v jq &> /dev/null; then + echo "Missing command: jq" + exit 1 +fi + +script_dir=$(realpath $(dirname $0)) +cd "$script_dir" +BETTER_SQLITE3_VERSION=$(jq -r '.dependencies.["better-sqlite3"]' ../../package.json | grep -oP "\d+\.\d+\.\d+") + +if [ -z $BETTER_SQLITE3_VERSION ]; then + echo "Unable to determine better-sqlite3 version." + exit 2 +fi + +echo "Version: $BETTER_SQLITE3_VERSION" + +function download() { + version="$1" + platform="$2" + dest_name="$3" + url=https://github.com/WiseLibs/better-sqlite3/releases/download/v${BETTER_SQLITE3_VERSION}/better-sqlite3-v${BETTER_SQLITE3_VERSION}-${version}-${platform}.tar.gz + temp_file="temp.tar.gz" + curl -L "$url" -o "$temp_file" + tar -xzvf "$temp_file" + mv build/Release/better_sqlite3.node "$dest_name-better_sqlite3.node" + rm -rf build + rm -f "$temp_file" +} + +download $NODE_VERSION "linux-x64" "linux-server" +download $ELECTRON_VERSION "linux-x64" "linux-desktop" +download $ELECTRON_VERSION "win32-x64" "win" +download $ELECTRON_VERSION "darwin-x64" "mac-x64" +download $ELECTRON_VERSION "darwin-arm64" "mac-arm64" \ No newline at end of file