refactor: move JS vendors to vendor/ with versioned filenames
Vendor JS files to vendor/ with versioned names, symlinks in webui/static/ select active version. Update update-vendor.sh and AGENTS.md.
This commit is contained in:
@@ -26,10 +26,10 @@ Project uses `.venv`. Install deps with `pip install -e .` (from `pyproject.toml
|
||||
|
||||
**No CDN packages.** All frontend libraries (JS and CSS) must be vendored in `webui/static/`. Never reference `unpkg.com`, `cdn.jsdelivr.net`, or similar. To add/update a library, edit the version in `scripts/update-vendor.sh` and run it.
|
||||
|
||||
| Library | Version | Local file | CDN source |
|
||||
| ------- | ------- | ----------------------------------- | ---------- |
|
||||
| htmx | 2.0.4 | `webui/static/htmx.min.js` | `npm:htmx.org@2.0.4` |
|
||||
| htmx-ext-json-enc | 2.0.0 | `webui/static/json-enc.js` | `npm:htmx-ext-json-enc@2.0.0` |
|
||||
| Library | Version | Vendor file | Symlink (active) | CDN source |
|
||||
| ------- | ------- | ------------------------------------|--------------------------------| ---------- |
|
||||
| htmx | 2.0.4 | `vendor/htmx-2.0.4.min.js` | `webui/static/htmx.min.js` | `npm:htmx.org@2.0.4` |
|
||||
| htmx-ext-json-enc | 2.0.0 | `vendor/json-enc-2.0.0.js` | `webui/static/json-enc.js` | `npm:htmx-ext-json-enc@2.0.0` |
|
||||
|
||||
## Deployment
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Download and vendor frontend JS libraries into webui/static/
|
||||
# and backend binaries into vendor/.
|
||||
# Download and vendor libraries into vendor/.
|
||||
# Run from the project root after updating the VERSION variables below.
|
||||
set -euo pipefail
|
||||
|
||||
@@ -9,7 +8,8 @@ HTMX_VERSION="2.0.4"
|
||||
HTMX_JSON_ENC_VERSION="2.0.0"
|
||||
ACME_VERSION="3.1.3"
|
||||
|
||||
STATIC_DIR="webui/static"
|
||||
VENDOR="vendor"
|
||||
STATIC="webui/static"
|
||||
|
||||
download() {
|
||||
local name="$1" url="$2" dest="$3"
|
||||
@@ -23,16 +23,20 @@ download() {
|
||||
|
||||
download "htmx@${HTMX_VERSION}" \
|
||||
"https://unpkg.com/htmx.org@${HTMX_VERSION}/dist/htmx.min.js" \
|
||||
"${STATIC_DIR}/htmx.min.js"
|
||||
"${VENDOR}/htmx-${HTMX_VERSION}.min.js"
|
||||
|
||||
download "htmx-ext-json-enc@${HTMX_JSON_ENC_VERSION}" \
|
||||
"https://unpkg.com/htmx-ext-json-enc@${HTMX_JSON_ENC_VERSION}/json-enc.js" \
|
||||
"${STATIC_DIR}/json-enc.js"
|
||||
"${VENDOR}/json-enc-${HTMX_JSON_ENC_VERSION}.js"
|
||||
|
||||
download "acme.sh@${ACME_VERSION}" \
|
||||
"https://raw.githubusercontent.com/acmesh-official/acme.sh/${ACME_VERSION}/acme.sh" \
|
||||
"vendor/acme.sh"
|
||||
"${VENDOR}/acme.sh"
|
||||
|
||||
chmod +x "vendor/acme.sh"
|
||||
chmod +x "${VENDOR}/acme.sh"
|
||||
|
||||
# Symlinks in webui/static/ select the active version
|
||||
ln -sf "../../vendor/htmx-${HTMX_VERSION}.min.js" "${STATIC}/htmx.min.js"
|
||||
ln -sf "../../vendor/json-enc-${HTMX_JSON_ENC_VERSION}.js" "${STATIC}/json-enc.js"
|
||||
|
||||
echo "[done] All libraries vendored."
|
||||
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
htmx.defineExtension('json-enc', {
|
||||
onEvent: function(name, evt) {
|
||||
if (name === 'htmx:configRequest') {
|
||||
evt.detail.headers['Content-Type'] = 'application/json'
|
||||
}
|
||||
},
|
||||
|
||||
encodeParameters: function(xhr, parameters, elt) {
|
||||
xhr.overrideMimeType('text/json')
|
||||
return (JSON.stringify(parameters))
|
||||
}
|
||||
})
|
||||
Vendored
-1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
../../vendor/htmx-2.0.4.min.js
|
||||
@@ -1,12 +0,0 @@
|
||||
htmx.defineExtension('json-enc', {
|
||||
onEvent: function(name, evt) {
|
||||
if (name === 'htmx:configRequest') {
|
||||
evt.detail.headers['Content-Type'] = 'application/json'
|
||||
}
|
||||
},
|
||||
|
||||
encodeParameters: function(xhr, parameters, elt) {
|
||||
xhr.overrideMimeType('text/json')
|
||||
return (JSON.stringify(parameters))
|
||||
}
|
||||
})
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../vendor/json-enc-2.0.0.js
|
||||
Reference in New Issue
Block a user