remove extra files from repo root and move package.json into etc

This commit is contained in:
Nick Sweeting 2024-10-05 03:51:47 -07:00
parent 00a91e09c6
commit db10a2142e
No known key found for this signature in database
17 changed files with 44 additions and 6370 deletions

View file

@ -79,9 +79,9 @@ SHELL ["/bin/bash", "-o", "pipefail", "-o", "errexit", "-o", "errtrace", "-o", "
######### System Environment #################################### ######### System Environment ####################################
# Detect ArchiveBox version number by reading package.json # Detect ArchiveBox version number by reading pyproject.toml
COPY --chown=root:root --chmod=755 package.json "$CODE_DIR/" COPY --chown=root:root --chmod=755 pyproject.toml "$CODE_DIR/"
RUN grep '"version": ' "${CODE_DIR}/package.json" | awk -F'"' '{print $4}' > /VERSION.txt RUN grep '^version = ' "${CODE_DIR}/pyproject.toml" | awk -F'"' '{print $2}' > /VERSION.txt
# Force apt to leave downloaded binaries in /var/cache/apt (massively speeds up Docker builds) # Force apt to leave downloaded binaries in /var/cache/apt (massively speeds up Docker builds)
RUN echo 'Binary::apt::APT::Keep-Downloaded-Packages "1";' > /etc/apt/apt.conf.d/99keep-cache \ RUN echo 'Binary::apt::APT::Keep-Downloaded-Packages "1";' > /etc/apt/apt.conf.d/99keep-cache \
@ -238,10 +238,10 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-$TARGETARCH$T
# Install Node dependencies # Install Node dependencies
WORKDIR "$CODE_DIR/lib/npm" WORKDIR "$CODE_DIR/lib/npm"
COPY --chown=root:root --chmod=755 "package.json" "package-lock.json" "$CODE_DIR/lib/npm" COPY --chown=root:root --chmod=755 "etc/package.json" "$CODE_DIR/lib/npm"
RUN --mount=type=cache,target=/root/.npm,sharing=locked,id=npm-$TARGETARCH$TARGETVARIANT \ RUN --mount=type=cache,target=/root/.npm,sharing=locked,id=npm-$TARGETARCH$TARGETVARIANT \
echo "[+] Installing NPM extractor dependencies from package.json..." \ echo "[+] Installing NPM extractor dependencies from package.json..." \
&& npm ci --prefix="$CODE_DIR/lib/npm" --prefer-offline --no-audit --cache /root/.npm \ && npm install --prefix="$CODE_DIR/lib/npm" --prefer-offline --no-fund --no-audit --cache /root/.npm \
&& chown -R "$DEFAULT_PUID:$DEFAULT_PGID" "$CODE_DIR/lib" \ && chown -R "$DEFAULT_PUID:$DEFAULT_PGID" "$CODE_DIR/lib" \
&& ( \ && ( \
which node && node --version \ which node && node --version \

View file

@ -1 +0,0 @@
../LICENSE

View file

@ -4,7 +4,6 @@ __package__ = 'archivebox.config'
import os import os
import re import re
import platform import platform
import machineid
import tempfile import tempfile
from typing import Dict from typing import Dict
@ -40,15 +39,6 @@ def _detect_installed_version(PACKAGE_DIR: Path):
# building docs, pyproject.toml is not available # building docs, pyproject.toml is not available
pass pass
try:
# if in dev but not in Git repo dir, fallback to using package.json file
package_json = (PACKAGE_DIR / 'package.json').read_text().split('\n')
for line in package_json:
if '"version": "' in line:
return line.replace('"', '').split(':')[-1].strip(',').strip()
except FileNotFoundError:
pass
# raise Exception('Failed to detect installed archivebox version!') # raise Exception('Failed to detect installed archivebox version!')
return 'dev' return 'dev'

View file

@ -74,7 +74,7 @@ class ShellConfig(BaseConfigSet):
docker_build_end_time = Path('/VERSION.txt').read_text().rsplit('BUILD_END_TIME=')[-1].split('\n', 1)[0] docker_build_end_time = Path('/VERSION.txt').read_text().rsplit('BUILD_END_TIME=')[-1].split('\n', 1)[0]
return docker_build_end_time return docker_build_end_time
src_last_modified_unix_timestamp = (PACKAGE_DIR / 'package.json').stat().st_mtime src_last_modified_unix_timestamp = (PACKAGE_DIR / 'README.md').stat().st_mtime
return datetime.fromtimestamp(src_last_modified_unix_timestamp).strftime('%Y-%m-%d %H:%M:%S %s') return datetime.fromtimestamp(src_last_modified_unix_timestamp).strftime('%Y-%m-%d %H:%M:%S %s')

File diff suppressed because it is too large Load diff

View file

@ -1,15 +0,0 @@
{
"name": "archivebox",
"version": "0.8.5rc1",
"description": "ArchiveBox: The self-hosted internet archive",
"author": "Nick Sweeting <archivebox-npm@sweeting.me>",
"repository": "github:ArchiveBox/ArchiveBox",
"license": "MIT",
"dependencies": {
"@postlight/parser": "^2.2.3",
"readability-extractor": "github:ArchiveBox/readability-extractor",
"single-file-cli": "^1.1.54",
"puppeteer": "^23.5.0",
"@puppeteer/browsers": "^2.4.0"
}
}

View file

@ -1,49 +0,0 @@
#!/usr/bin/env bash
# ./bin/build_docker.sh dev 'linux/arm/v7'
### 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"
which docker > /dev/null || exit 1
TAG_NAME="${1:-$(git rev-parse --abbrev-ref HEAD)}"
VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")"
SHORT_VERSION="$(echo "$VERSION" | perl -pe 's/(\d+)\.(\d+)\.(\d+)/$1.$2/g')"
REQUIRED_PLATFORMS="${2:-"linux/arm64,linux/amd64,linux/arm/v7"}"
# Build python package lists
# https://pdm-project.org/latest/usage/lockfile/
echo "[+] Generating requirements.txt and pdm.lock from pyproject.toml..."
pdm lock --group=':all' --production --lockfile pdm.lock --strategy="cross_platform"
pdm sync --group=':all' --production --lockfile pdm.lock --clean || pdm sync --group=':all' --production --lockfile pdm.lock --clean
pdm export --group=':all' --production --lockfile pdm.lock --without-hashes -o requirements.txt
pdm lock --group=':all' --dev --lockfile pdm.dev.lock --strategy="cross_platform"
pdm sync --group=':all' --dev --lockfile pdm.dev.lock --clean || 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
echo "[+] Building Docker image: tag=$TAG_NAME version=$SHORT_VERSION arch=$REQUIRED_PLATFORMS"
echo "[+] Building archivebox:$VERSION docker image..."
# docker builder prune
docker build . --no-cache -t archivebox-dev --load
# docker buildx build --platform "$REQUIRED_PLATFORMS" --load . \
# -t archivebox \
# -t archivebox:$TAG_NAME \
# -t archivebox:$VERSION \
# -t archivebox:$SHORT_VERSION

View file

@ -20,7 +20,7 @@ which jq > /dev/null || exit 1
declare -a TAG_NAMES="$*" declare -a TAG_NAMES="$*"
BRANCH_NAME="${1:-$(git rev-parse --abbrev-ref HEAD)}" BRANCH_NAME="${1:-$(git rev-parse --abbrev-ref HEAD)}"
VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" VERSION="$(grep '^version = ' "${REPO_DIR}/pyproject.toml" | awk -F'"' '{print $2}')"
GIT_SHA=sha-"$(git rev-parse --short HEAD)" GIT_SHA=sha-"$(git rev-parse --short HEAD)"
SELECTED_PLATFORMS="linux/amd64,linux/arm64" SELECTED_PLATFORMS="linux/amd64,linux/arm64"

View file

@ -30,9 +30,6 @@ function bump_semver {
echo "$1" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g' echo "$1" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g'
} }
OLD_VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" # OLD_VERSION="$(grep '^version = ' "${REPO_DIR}/pyproject.toml" | awk -F'"' '{print $2}')"
NEW_VERSION="$(bump_semver "$OLD_VERSION")" # NEW_VERSION="$(bump_semver "$OLD_VERSION")"
echo "[*] Bumping VERSION from $OLD_VERSION to $NEW_VERSION"
contents="$(jq ".version = \"$NEW_VERSION\"" "$REPO_DIR/package.json")" && \
echo "${contents}" > package.json

View file

@ -15,17 +15,17 @@ REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && p
cd "$REPO_DIR" cd "$REPO_DIR"
py_version="$(grep -E '^version = ' pyproject.toml | awk '{print $3}' | jq -r)" py_version="$(grep -E '^version = ' pyproject.toml | awk '{print $3}' | jq -r)"
js_version="$(jq -r '.version' package.json)" # js_version="$(jq -r '.version' ${REPO_DIR}/etc/package.json)"
if [[ "$py_version" != "$js_version" ]]; then # if [[ "$py_version" != "$js_version" ]]; then
echo "[❌] Version in pyproject.toml ($py_version) does not match version in package.json ($js_version)!" # echo "[❌] Version in pyproject.toml ($py_version) does not match version in etc/package.json ($js_version)!"
exit 1 # exit 1
fi # fi
echo "[🔒] Locking all ArchiveBox dependencies (pip, npm)" echo "[🔒] Locking all ArchiveBox dependencies (pip, npm)"
echo echo
echo "pyproject.toml: archivebox $py_version" echo "pyproject.toml: archivebox $py_version"
echo "package.json: archivebox $js_version" # echo "package.json: archivebox $js_version"
echo echo
echo echo
@ -34,9 +34,9 @@ deactivate 2>/dev/null || true
rm -Rf build dist rm -Rf build dist
rm -f uv.lock rm -f uv.lock
rm -f requirements.txt rm -f requirements.txt
rm -f package-lock.json # rm -f package-lock.json
rm -f archivebox/package.json # rm -f archivebox/package.json
rm -f archivebox/package-lock.json # rm -f archivebox/package-lock.json
# rm -Rf ./.venv # rm -Rf ./.venv
# rm -Rf ./node_modules # rm -Rf ./node_modules
# rm -Rf ./archivebox/node_modules # rm -Rf ./archivebox/node_modules
@ -59,23 +59,20 @@ uv lock
uv pip compile pyproject.toml --all-extras -o requirements.txt >/dev/null uv pip compile pyproject.toml --all-extras -o requirements.txt >/dev/null
uv sync --all-extras --frozen 2>/dev/null uv sync --all-extras --frozen 2>/dev/null
echo # echo
echo "[+] Generating package-lock.json from package.json..." # echo "[+] Generating package-lock.json from etc/package.json..."
npm install -g npm # npm install -g npm
npm config set fund false --location=global & # npm config set fund false --location=global
npm config set fund false & # npm config set audit false --location=global
npm config set audit false --location=global & # cd etc
npm config set audit false & # echo
echo # echo "etc/package.json: archivebox $(jq -r '.version' etc/package.json)"
echo "package.json: archivebox $(jq -r '.version' package.json)" # echo
echo # echo "$(which node): $(node --version | head -n 1)"
echo "$(which node): $(node --version | head -n 1)" # echo "$(which npm): $(npm --version | head -n 1)"
echo "$(which npm): $(npm --version | head -n 1)"
echo # echo
npm install --package-lock-only --prefer-offline # npm install --package-lock-only --prefer-offline
cp package.json archivebox/package.json
cp package-lock.json archivebox/package-lock.json
echo echo
echo "[√] Finished. Don't forget to commit the new lockfiles:" echo "[√] Finished. Don't forget to commit the new lockfiles:"
@ -83,8 +80,8 @@ echo
ls "pyproject.toml" | cat ls "pyproject.toml" | cat
ls "requirements.txt" | cat ls "requirements.txt" | cat
ls "uv.lock" | cat ls "uv.lock" | cat
echo # echo
ls "package.json" | cat # ls "package.json" | cat
ls "package-lock.json" | cat # ls "package-lock.json" | cat
ls "archivebox/package.json" | cat # ls "archivebox/package.json" | cat
ls "archivebox/package-lock.json" | cat # ls "archivebox/package-lock.json" | cat

View file

@ -30,5 +30,5 @@ cd "$REPO_DIR"
./bin/release_pip.sh ./bin/release_pip.sh
./bin/release_docker.sh ./bin/release_docker.sh
VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" VERSION="$(grep '^version = ' "${REPO_DIR}/pyproject.toml" | awk -F'"' '{print $2}')"
echo "[√] Done. Published version v$VERSION" echo "[√] Done. Published version v$VERSION"

View file

@ -15,7 +15,7 @@ cd "$REPO_DIR"
declare -a TAG_NAMES="$*" declare -a TAG_NAMES="$*"
BRANCH_NAME="${1:-$(git rev-parse --abbrev-ref HEAD)}" BRANCH_NAME="${1:-$(git rev-parse --abbrev-ref HEAD)}"
VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" VERSION="$(grep '^version = ' "${REPO_DIR}/pyproject.toml" | awk -F'"' '{print $2}')"
GIT_SHA=sha-"$(git rev-parse --short HEAD)" GIT_SHA=sha-"$(git rev-parse --short HEAD)"
SELECTED_PLATFORMS="linux/amd64,linux/arm64" SELECTED_PLATFORMS="linux/amd64,linux/arm64"

View file

@ -11,7 +11,7 @@ set -o pipefail
IFS=$'\n' IFS=$'\n'
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )"
VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" VERSION="$(grep '^version = ' "${REPO_DIR}/pyproject.toml" | awk -F'"' '{print $2}')"
cd "$REPO_DIR" cd "$REPO_DIR"

View file

@ -11,7 +11,7 @@ set -o pipefail
IFS=$'\n' IFS=$'\n'
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )"
VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" VERSION="$(grep '^version = ' "${REPO_DIR}/pyproject.toml" | awk -F'"' '{print $2}')"
cd "$REPO_DIR" cd "$REPO_DIR"

View file

@ -1,8 +1,6 @@
{ {
"name": "archivebox", "name": "archivebox",
"version": "0.8.5rc2", "version": "0.0.1",
"description": "ArchiveBox: The self-hosted internet archive",
"author": "Nick Sweeting <archivebox-npm@sweeting.me>",
"repository": "github:ArchiveBox/ArchiveBox", "repository": "github:ArchiveBox/ArchiveBox",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {

3120
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -41,7 +41,7 @@ wheels = [
[[package]] [[package]]
name = "archivebox" name = "archivebox"
version = "0.8.5rc1" version = "0.8.5rc2"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "atomicwrites" }, { name = "atomicwrites" },
@ -76,6 +76,7 @@ dependencies = [
{ name = "rich" }, { name = "rich" },
{ name = "rich-argparse" }, { name = "rich-argparse" },
{ name = "setuptools" }, { name = "setuptools" },
{ name = "sonic-client" },
{ name = "supervisor" }, { name = "supervisor" },
{ name = "typeid-python" }, { name = "typeid-python" },
{ name = "ulid-py" }, { name = "ulid-py" },
@ -87,15 +88,11 @@ dependencies = [
all = [ all = [
{ name = "django-auth-ldap" }, { name = "django-auth-ldap" },
{ name = "python-ldap" }, { name = "python-ldap" },
{ name = "sonic-client" },
] ]
ldap = [ ldap = [
{ name = "django-auth-ldap" }, { name = "django-auth-ldap" },
{ name = "python-ldap" }, { name = "python-ldap" },
] ]
sonic = [
{ name = "sonic-client" },
]
[package.dev-dependencies] [package.dev-dependencies]
dev = [ dev = [
@ -160,7 +157,7 @@ requires-dist = [
{ name = "rich", specifier = ">=13.8.0" }, { name = "rich", specifier = ">=13.8.0" },
{ name = "rich-argparse", specifier = ">=1.5.2" }, { name = "rich-argparse", specifier = ">=1.5.2" },
{ name = "setuptools", specifier = ">=74.1.0" }, { name = "setuptools", specifier = ">=74.1.0" },
{ name = "sonic-client", marker = "extra == 'sonic'", specifier = ">=1.0.0" }, { name = "sonic-client", specifier = ">=1.0.0" },
{ name = "supervisor", specifier = ">=4.2.5" }, { name = "supervisor", specifier = ">=4.2.5" },
{ name = "typeid-python", specifier = ">=0.3.1" }, { name = "typeid-python", specifier = ">=0.3.1" },
{ name = "ulid-py", specifier = ">=1.1.0" }, { name = "ulid-py", specifier = ">=1.1.0" },