add webxdc build script

This commit is contained in:
WofWca 2023-03-26 16:11:32 +04:00
parent 1352a82c8c
commit bcd1528faa
3 changed files with 36 additions and 0 deletions

27
create-xdc.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
case "$1" in
"-h" | "--help")
echo "usage: ${0##*/} [PACKAGE_NAME]"
exit
;;
"")
PACKAGE_NAME=${PWD##*/} # '##*/' removes everything before the last slash and the last slash
;;
*)
PACKAGE_NAME=${1%.xdc} # '%.xdc' removes the extension and allows PACKAGE_NAME to be given with or without extension
;;
esac
rm "$PACKAGE_NAME.xdc" 2> /dev/null
zip -9 --recurse-paths "$PACKAGE_NAME.xdc" --exclude LICENSE README.md webxdc.js webxdc.d.ts "./*.sh" "./*.xdc" -- *
echo "success, archive contents:"
unzip -l "$PACKAGE_NAME.xdc"
# check package size
MAXSIZE=655360
size=$(wc -c < "$PACKAGE_NAME.xdc")
if [ "$size" -ge $MAXSIZE ]; then
echo "WARNING: package size exceeded the limit ($size > $MAXSIZE)"
fi

7
generate-webxdc-manifest.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
echo -n 'name = "'
# Get the contents of the `<title>` element of `index.html`
grep -oP "(?<=<title>).*?(?=</title>)" index.html | tr -d '\n' \
&& echo '"' \
&& echo -n 'source_code_url = "https://github.com/WofWca/vikunja-frontend"'

View File

@ -27,6 +27,8 @@
"preview": "vite preview --port 4173",
"preview:dev": "vite preview --outDir dist-dev --mode development --port 4173",
"build": "vite build && workbox copyLibraries dist/",
"build-webxdc": "pnpm run build && pnpm run pack-webxdc",
"pack-webxdc": "./generate-webxdc-manifest.sh > dist/manifest.toml && cd dist && cp images/icons/icon-maskable.png icon.png && ../create-xdc.sh",
"build:modern-only": "BUILD_MODERN_ONLY=true vite build && workbox copyLibraries dist/",
"build:dev": "vite build --mode development --outDir dist-dev/",
"lint": "eslint --ignore-pattern '*.test.*' ./src --ext .vue,.js,.ts",