<commit_before>#!/usr/bin/env bash
set -euo pipefail

MOCK_SERVER_VERSION="0.0.17"
MOCK_SERVER_BASE_URL="https://github.com/pact-foundation/pact-reference/releases/download/libpact_mock_server_ffi-v$MOCK_SERVER_VERSION"

VERIFIER_VERSION="0.0.4"
VERIFIER_BASE_URL="https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_ffi-v$VERIFIER_VERSION"

base_path=$(dirname "$0")

download_native() {
    base_url="$1"
    component="$2"
    file="$3"
    os="$4"
    platform="$5"
    extension="$6"

    url="$base_url/lib$component-$os-$platform.$extension.gz"
    sha="$url.sha256"

    path="$base_path/$os/$platform"
    mkdir -p "$path"

    echo "Downloading $component"
    echo "    Platform: $os/$platform"
    echo "    File: $file.$extension"
    echo "    URL: $url"

    echo -n "    Downloading... "
    curl --silent -L "$url" -o "$path/$file.$extension.gz"
    curl --silent -L "$sha" -o "$path/$file.$extension.gz.sha256"
    echo "OK"

    echo -n "    Verifying... "

    if [[ "$OSTYPE" == "darwin"* ]]; then
        # OSX requires an empty arg passed to -i, but this doesn't work on Lin/Win
        sed -Ei '' "s|../target/artifacts/.+$|$path/$file.$extension.gz|" "$path/$file.$extension.gz.sha256"
        shasum -a 256 --check --quiet "$path/$file.$extension.gz.sha256"
    else
        sed -Ei "s|../target/artifacts/.+$|$path/$file.$extension.gz|" "$path/$file.$extension.gz.sha256"
        sha256sum --check --quiet "$path/$file.$extension.gz.sha256"
    fi

    rm "$path/$file.$extension.gz.sha256"
    echo "OK"

    echo -n "    Extracting... "
    gunzip -f "$path/$file.$extension.gz"
    echo "OK"
}

download_native "$MOCK_SERVER_BASE_URL" "pact_mock_server_ffi" "pact_mock_server_ffi" "windows" "x86_64" "dll"
download_native "$MOCK_SERVER_BASE_URL" "pact_mock_server_ffi" "libpact_mock_server_ffi" "linux" "x86_64" "so"
download_native "$MOCK_SERVER_BASE_URL" "pact_mock_server_ffi" "pact_mock_server_ffi" "osx" "x86_64" "dylib"

download_native "$VERIFIER_BASE_URL" "pact_verifier_ffi" "pact_verifier_ffi" "windows" "x86_64" "dll"
download_native "$VERIFIER_BASE_URL" "pact_verifier_ffi" "libpact_verifier_ffi" "linux" "x86_64" "so"
download_native "$VERIFIER_BASE_URL" "pact_verifier_ffi" "pact_verifier_ffi" "osx" "x86_64" "dylib"
<commit_msg>feat!: Download new combined FFI library<commit_after>#!/usr/bin/env bash
set -euo pipefail

FFI_VERSION="0.0.0"
FFI_BASE_URL="https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v$FFI_VERSION"

base_path=$(dirname "$0")

download_native() {
    file="$1"
    os="$2"
    platform="$3"
    extension="$4"

    # e.g.
    #   pact_ffi-windows-x86_64.dll.gz
    #   libpact_ffi-linux-x86_64.so.gz
    #   libpact_ffi-osx-x86_64.dylib.gz
    src_file="$file-$os-$platform.$extension.gz"
    url="$FFI_BASE_URL/$src_file"
    sha="$url.sha256"

    path="$base_path/$os/$platform"
    dest_file="$file.$extension.gz"
    mkdir -p "$path"

    echo "Downloading FFI library for $os/$platform"
    echo "    Destination: $path/$dest_file"
    echo "    URL: $url"

    echo -n "    Downloading... "
    curl --silent -L "$url" -o "$path/$dest_file"
    curl --silent -L "$sha" -o "$path/$dest_file.sha256"
    echo "OK"

    echo -n "    Verifying... "

    if [[ "$OSTYPE" == "darwin"* ]]; then
        # OSX requires an empty arg passed to -i, but this doesn't work on Lin/Win
        sed -Ei '' "s|../target/artifacts/.+$|$path/$dest_file|" "$path/$dest_file.sha256"
        shasum -a 256 --check --quiet "$path/$dest_file.sha256"
    else
        sed -Ei "s|../target/artifacts/.+$|$path/$dest_file|" "$path/$dest_file.sha256"
        sha256sum --check --quiet "$path/$dest_file.sha256"
    fi

    rm "$path/$dest_file.sha256"
    echo "OK"

    echo -n "    Extracting... "
    gunzip -f "$path/$dest_file"
    echo "OK"
}

download_native "pact_ffi" "windows" "x86_64" "dll"
download_native "libpact_ffi" "linux" "x86_64" "so"
download_native "libpact_ffi" "osx" "x86_64" "dylib"

{'fraction_non_alphanumeric': 0.17347956131605186, 'fraction_numerical': 0.03090727816550349, 'mean_word_length': 3.3905908096280086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3924529', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1551, 'n_words': 276}