|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -DOCS=www/src/content/docs/01-get-started/01-installation.md |
| 3 | +JSON=www/src/data/integrity.json |
4 | 4 |
|
5 | 5 | # Calculate SHAs |
6 | 6 | MINIFIED_SHA=$(cat dist/htmx.min.js | openssl dgst -sha384 -binary | openssl base64 -A) |
7 | 7 | FULL_SHA=$(cat dist/htmx.js | openssl dgst -sha384 -binary | openssl base64 -A) |
8 | 8 | ESM_MIN_SHA=$(cat dist/htmx.esm.min.js | openssl dgst -sha384 -binary | openssl base64 -A) |
9 | 9 | ESM_SHA=$(cat dist/htmx.esm.js | openssl dgst -sha384 -binary | openssl base64 -A) |
10 | 10 |
|
11 | | -echo "Updating $DOCS with new SHAs..." |
| 11 | +echo "Updating $JSON with new SHAs..." |
12 | 12 | echo "htmx.min.js: sha384-$MINIFIED_SHA" |
13 | 13 | echo "htmx.js: sha384-$FULL_SHA" |
14 | 14 | echo "htmx.esm.min.js: sha384-$ESM_MIN_SHA" |
15 | 15 | echo "htmx.esm.js: sha384-$ESM_SHA" |
16 | 16 |
|
17 | | -awk -v minified="sha384-$MINIFIED_SHA" -v full="sha384-$FULL_SHA" \ |
18 | | - -v esm_min="sha384-$ESM_MIN_SHA" -v esm="sha384-$ESM_SHA" ' |
19 | | -/integrity="sha384-[^"]*"/ && /htmx\.esm\.min\.js/ { sub(/sha384-[^"]*/, esm_min) } |
20 | | -/integrity="sha384-[^"]*"/ && /htmx\.esm\.js/ && !/htmx\.esm\.min\.js/ { sub(/sha384-[^"]*/, esm) } |
21 | | -/integrity="sha384-[^"]*"/ && /htmx\.min\.js/ && !/htmx\.esm/ { sub(/sha384-[^"]*/, minified) } |
22 | | -/integrity="sha384-[^"]*"/ && /htmx\.js/ && !/htmx\.min\.js/ && !/htmx\.esm/ { sub(/sha384-[^"]*/, full) } |
23 | | -/integrity="sha384-[^"]*"/ && /htmx\.org@/ && !/dist\// { sub(/sha384-[^"]*/, minified) } |
24 | | -{print} |
25 | | -' "$DOCS" > "$DOCS.tmp" && mv "$DOCS.tmp" "$DOCS" |
| 17 | +cat > "$JSON" <<EOF |
| 18 | +{ |
| 19 | + "min": "sha384-$MINIFIED_SHA", |
| 20 | + "full": "sha384-$FULL_SHA", |
| 21 | + "esmMin": "sha384-$ESM_MIN_SHA", |
| 22 | + "esm": "sha384-$ESM_SHA" |
| 23 | +} |
| 24 | +EOF |
26 | 25 |
|
27 | | -echo "✓ $DOCS updated successfully" |
| 26 | +echo "✓ $JSON updated successfully" |
0 commit comments