2021-04-29 11:56:06 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Copy wasm javascript to match the go version
|
|
|
|
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./static/wasm
|
|
|
|
|
|
|
|
# Compress wasm javascript using brotli
|
|
|
|
brotli -k -f ./static/wasm/wasm_exec.js
|
|
|
|
|
|
|
|
# Build wasm code
|
|
|
|
GOOS=js GOARCH=wasm go build -o ./static/wasm/access.wasm storj.io/storj/satellite/console/wasm
|
|
|
|
|
2023-10-18 18:54:28 +01:00
|
|
|
# Take a hash of generated wasm code
|
|
|
|
if command -v sha256sum > /dev/null; then
|
|
|
|
hash=$(sha256sum ./static/wasm/access.wasm | awk '{print $1}')
|
|
|
|
else
|
|
|
|
hash=$(shasum -a 256 ./static/wasm/access.wasm | awk '{print $1}')
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Define new file name
|
|
|
|
filename="access.${hash:0:8}.wasm"
|
|
|
|
|
|
|
|
# Rename the file to include the hash
|
|
|
|
mv ./static/wasm/access.wasm ./static/wasm/$filename
|
|
|
|
|
2021-04-29 11:56:06 +01:00
|
|
|
# Compress wasm code using brotli
|
2023-10-18 18:54:28 +01:00
|
|
|
brotli -k -f ./static/wasm/$filename
|
|
|
|
|
|
|
|
# Generate the manifest which would contain our new file name
|
|
|
|
echo "{\"fileName\": \"$filename\"}" > ./static/wasm/wasm-manifest.json
|