File size: 1,524 Bytes
5240484
47b8a5f
5240484
 
47b8a5f
5240484
 
 
c3fdf10
794b22f
 
c3fdf10
5240484
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47b8a5f
 
 
5240484
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# Rebuild public/dssl-engine.zip and public/dssl-engine.tar.gz from the current engine + package texts.
# Usage: bash scripts/build-engine-package.sh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
STAGE=$(mktemp -d)
trap 'rm -rf "$STAGE"' EXIT

mkdir -p "$STAGE/dssl-engine/dssl" "$STAGE/dssl-engine/styles" "$STAGE/dssl-engine/examples" "$STAGE/dssl-engine/cli"
# every engine module, by glob: a new file under public/dssl/ can never be left out of the package
cp "$ROOT"/public/dssl/*.js "$STAGE/dssl-engine/dssl/"
cp "$ROOT/cli/dssl.mjs" "$STAGE/dssl-engine/cli/"
cp "$ROOT/public/styles/tokens.dssl" "$STAGE/dssl-engine/styles/"
cp "$ROOT/engine-package/USAGE.md" "$ROOT/engine-package/install.sh" "$STAGE/dssl-engine/"
cp "$ROOT/engine-package/hello.dssl" "$STAGE/dssl-engine/examples/hello.dssl"
cp "$ROOT/package/LICENSE" "$STAGE/dssl-engine/LICENSE"

rm -f "$ROOT/public/dssl-engine.zip"
python3 - "$STAGE" "$ROOT/public/dssl-engine.zip" <<'PY'
import os, sys, zipfile
stage, out = sys.argv[1], sys.argv[2]
with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as z:
    for base, _dirs, files in os.walk(stage):
        for f in files:
            full = os.path.join(base, f)
            z.write(full, os.path.relpath(full, stage))
PY
rm -f "$ROOT/public/dssl-engine.tar.gz"
tar -czf "$ROOT/public/dssl-engine.tar.gz" -C "$STAGE" dssl-engine
echo "built $ROOT/public/dssl-engine.tar.gz"
echo "built $ROOT/public/dssl-engine.zip:"
python3 -m zipfile -l "$ROOT/public/dssl-engine.zip"