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-04-24 00:43:01 +00:00
|
|
|
js_version="$(jq -r '.version' package.json)"
|
|
|
|
|
|
|
|
if [[ "$py_version" != "$js_version" ]]; then
|
|
|
|
echo "[❌] Version in pyproject.toml ($py_version) does not match version in package.json ($js_version)!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "[🔒] Locking all ArchiveBox dependencies (pip, npm)"
|
|
|
|
echo
|
|
|
|
echo "pyproject.toml: archivebox $py_version"
|
|
|
|
echo "package.json: archivebox $js_version"
|
|
|
|
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
|
|
|
|
rm -f pdm.lock
|
|
|
|
rm -f pdm.dev.lock
|
|
|
|
rm -f requirements.txt
|
|
|
|
rm -f requirements-dev.txt
|
|
|
|
rm -f package-lock.json
|
|
|
|
rm -f archivebox/package.json
|
|
|
|
rm -f archivebox/package-lock.json
|
|
|
|
rm -Rf ./.venv
|
|
|
|
rm -Rf ./node_modules
|
|
|
|
rm -Rf ./archivebox/node_modules
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo "[+] Generating dev & prod requirements.txt & pdm.lock from pyproject.toml..."
|
|
|
|
pip install --upgrade pip setuptools
|
2024-04-25 11:19:16 +00:00
|
|
|
pdm self update >/dev/null 2>&1 || true
|
2024-09-06 10:49:10 +00:00
|
|
|
pdm venv create 3.11
|
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)"
|
|
|
|
echo "$(which pdm): $(pdm --version | head -n 1)"
|
|
|
|
pdm info --env
|
|
|
|
pdm info
|
|
|
|
|
|
|
|
echo
|
|
|
|
# https://pdm-project.org/latest/usage/lockfile/
|
|
|
|
# prod
|
2024-09-06 10:49:10 +00:00
|
|
|
pdm lock --group=':all' --production --lockfile pdm.lock --python="==3.11.*" --platform=linux
|
|
|
|
pdm lock --group=':all' --production --lockfile pdm.lock --python="==3.11.*" --platform=macos --append
|
2024-04-24 00:43:01 +00:00
|
|
|
pdm sync --group=':all' --production --lockfile pdm.lock --clean
|
|
|
|
pdm export --group=':all' --production --lockfile pdm.lock --without-hashes -o requirements.txt
|
2024-06-03 02:18:24 +00:00
|
|
|
# cp ./pdm.lock ./pip_dist/
|
|
|
|
# cp ./requirements.txt ./pip_dist/
|
|
|
|
|
2024-04-24 00:43:01 +00:00
|
|
|
# dev
|
2024-09-06 10:49:10 +00:00
|
|
|
pdm lock --group=':all' --dev --lockfile pdm.dev.lock --python="==3.11.*" --platform=linux
|
|
|
|
pdm lock --group=':all' --dev --lockfile pdm.dev.lock --python="==3.11.*" --platform=macos --append
|
2024-04-24 00:43:01 +00:00
|
|
|
pdm sync --group=':all' --dev --lockfile pdm.dev.lock --clean
|
|
|
|
pdm export --group=':all' --dev --lockfile pdm.dev.lock --without-hashes -o requirements-dev.txt
|
2024-06-03 02:18:24 +00:00
|
|
|
# cp ./pdm.dev.lock ./pip_dist/
|
|
|
|
# cp ./requirements-dev.txt ./pip_dist/
|
2024-04-24 00:43:01 +00:00
|
|
|
|
|
|
|
echo
|
2024-04-25 11:19:16 +00:00
|
|
|
echo "[+] Generating package-lock.json from package.json..."
|
2024-04-24 00:43:01 +00:00
|
|
|
npm install -g npm
|
|
|
|
echo
|
|
|
|
echo "package.json: archivebox $(jq -r '.version' package.json)"
|
|
|
|
echo
|
|
|
|
echo "$(which node): $(node --version | head -n 1)"
|
|
|
|
echo "$(which npm): $(npm --version | head -n 1)"
|
|
|
|
|
|
|
|
echo
|
|
|
|
npm install --package-lock-only
|
|
|
|
cp package.json archivebox/package.json
|
|
|
|
cp package-lock.json archivebox/package-lock.json
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "[√] Finished. Don't forget to commit the new lockfiles:"
|
|
|
|
echo
|
|
|
|
ls "pyproject.toml" | cat
|
|
|
|
ls "pdm.lock" | cat
|
|
|
|
ls "pdm.dev.lock" | cat
|
|
|
|
ls "requirements.txt" | cat
|
|
|
|
ls "requirements-dev.txt" | cat
|
|
|
|
echo
|
|
|
|
ls "package.json" | cat
|
|
|
|
ls "package-lock.json" | cat
|
|
|
|
ls "archivebox/package.json" | cat
|
|
|
|
ls "archivebox/package-lock.json" | cat
|