2024-04-24 00:43:01 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
### Bash Environment Setup
|
|
|
|
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
|
|
|
|
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
|
|
|
|
# set -o xtrace
|
|
|
|
set -o errexit
|
|
|
|
set -o errtrace
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
IFS=$'\n'
|
|
|
|
|
|
|
|
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )"
|
|
|
|
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
|
2024-09-06 09:59:14 +00:00
|
|
|
py_version="$(grep -E '^version = ' pyproject.toml | awk '{print $3}' | jq -r)"
|
2024-10-05 10:51:47 +00:00
|
|
|
# js_version="$(jq -r '.version' ${REPO_DIR}/etc/package.json)"
|
2024-04-24 00:43:01 +00:00
|
|
|
|
2024-10-05 10:51:47 +00:00
|
|
|
# if [[ "$py_version" != "$js_version" ]]; then
|
|
|
|
# echo "[❌] Version in pyproject.toml ($py_version) does not match version in etc/package.json ($js_version)!"
|
|
|
|
# exit 1
|
|
|
|
# fi
|
2024-04-24 00:43:01 +00:00
|
|
|
|
|
|
|
echo "[🔒] Locking all ArchiveBox dependencies (pip, npm)"
|
|
|
|
echo
|
|
|
|
echo "pyproject.toml: archivebox $py_version"
|
2024-10-05 10:51:47 +00:00
|
|
|
# echo "package.json: archivebox $js_version"
|
2024-04-24 00:43:01 +00:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo "[*] Cleaning up old lockfiles and build files"
|
2024-04-24 21:38:21 +00:00
|
|
|
deactivate 2>/dev/null || true
|
2024-04-24 00:43:01 +00:00
|
|
|
rm -Rf build dist
|
2024-10-05 08:17:23 +00:00
|
|
|
rm -f uv.lock
|
2024-04-24 00:43:01 +00:00
|
|
|
rm -f requirements.txt
|
2024-10-05 10:51:47 +00:00
|
|
|
# rm -f package-lock.json
|
|
|
|
# rm -f archivebox/package.json
|
|
|
|
# rm -f archivebox/package-lock.json
|
2024-10-05 08:17:23 +00:00
|
|
|
# rm -Rf ./.venv
|
|
|
|
# rm -Rf ./node_modules
|
|
|
|
# rm -Rf ./archivebox/node_modules
|
2024-04-24 00:43:01 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo "[+] Generating dev & prod requirements.txt & pdm.lock from pyproject.toml..."
|
2024-10-08 06:49:30 +00:00
|
|
|
uv venv --allow-existing --python 3.12
|
2024-10-05 08:17:23 +00:00
|
|
|
source .venv/bin/activate
|
2024-04-24 00:43:01 +00:00
|
|
|
echo
|
|
|
|
echo "pyproject.toml: archivebox $(grep 'version = ' pyproject.toml | awk '{print $3}' | jq -r)"
|
|
|
|
echo "$(which python): $(python --version | head -n 1)"
|
2024-10-05 08:17:23 +00:00
|
|
|
echo "$(which uv): $(uv --version | head -n 1)"
|
2024-04-24 00:43:01 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
# https://pdm-project.org/latest/usage/lockfile/
|
|
|
|
# prod
|
2024-10-05 08:17:23 +00:00
|
|
|
uv lock
|
|
|
|
uv pip compile pyproject.toml --all-extras -o requirements.txt >/dev/null
|
|
|
|
uv sync --all-extras --frozen 2>/dev/null
|
2024-04-24 00:43:01 +00:00
|
|
|
|
2024-10-05 10:51:47 +00:00
|
|
|
# echo
|
|
|
|
# echo "[+] Generating package-lock.json from etc/package.json..."
|
|
|
|
# npm install -g npm
|
|
|
|
# npm config set fund false --location=global
|
|
|
|
# npm config set audit false --location=global
|
|
|
|
# cd etc
|
|
|
|
# echo
|
|
|
|
# echo "etc/package.json: archivebox $(jq -r '.version' etc/package.json)"
|
|
|
|
# echo
|
|
|
|
# echo "$(which node): $(node --version | head -n 1)"
|
|
|
|
# echo "$(which npm): $(npm --version | head -n 1)"
|
2024-04-24 00:43:01 +00:00
|
|
|
|
2024-10-05 10:51:47 +00:00
|
|
|
# echo
|
|
|
|
# npm install --package-lock-only --prefer-offline
|
2024-04-24 00:43:01 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "[√] Finished. Don't forget to commit the new lockfiles:"
|
|
|
|
echo
|
|
|
|
ls "pyproject.toml" | cat
|
|
|
|
ls "requirements.txt" | cat
|
2024-10-05 08:17:23 +00:00
|
|
|
ls "uv.lock" | cat
|
2024-10-05 10:51:47 +00:00
|
|
|
# echo
|
|
|
|
# ls "package.json" | cat
|
|
|
|
# ls "package-lock.json" | cat
|
|
|
|
# ls "archivebox/package.json" | cat
|
|
|
|
# ls "archivebox/package-lock.json" | cat
|