Files
cloudron-box/scripts/create-release-tarball
Girish Ramakrishnan a79486275e tldjs: update rules using --tldjs-update-rules
the rules we use are 6 years old! we still need to use the public
suffix list to figure out the zone name by default for ease of use.

Domains like co.uk will only appear in the suffix list and not in the
tld list (https://www.iana.org/domains/root/db)

To verify if the list is updated:

node -e "console.log(require('tldjs').getDomain('whatever.framer.ai'))"

The above will output "whatever.framer.ai"
2024-04-11 18:28:52 +02:00

74 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
set -eu
# Only GNU getopt supports long options. OS X comes bundled with the BSD getopt
# brew install gnu-getopt to get the GNU getopt on OS X
[[ $(uname -s) == "Darwin" ]] && GNU_GETOPT="/usr/local/opt/gnu-getopt/bin/getopt" || GNU_GETOPT="getopt"
readonly GNU_GETOPT
args=$(${GNU_GETOPT} -o "" -l "output:,version:" -n "$0" -- "$@")
eval set -- "${args}"
readonly SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
bundle_file=""
version=""
while true; do
case "$1" in
--output) bundle_file="$2"; shift 2;;
--version) version="$2"; shift 2;;
--) break;;
*) echo "Unknown option $1"; exit 1;;
esac
done
if [[ -z "${version}" ]]; then
echo "--version is required"
exit 1
fi
readonly TMPDIR=${TMPDIR:-/tmp} # why is this not set on mint?
if ! $(cd "${SOURCE_DIR}" && git diff --exit-code >/dev/null); then
echo "You have local changes, stash or commit them to proceed"
exit 1
fi
if [[ "$(node --version)" != "v18.16.0" ]]; then
echo "This script requires node 18.16.0"
exit 1
fi
box_version=$(cd "${SOURCE_DIR}" && git rev-parse "HEAD")
bundle_dir=$(mktemp -d -t box 2>/dev/null || mktemp -d box-XXXXXXXXXX --tmpdir=$TMPDIR)
[[ -z "$bundle_file" ]] && bundle_file="${TMPDIR}/box-${box_version:0:10}-${box_version:0:10}-${version}.tar.gz"
chmod "o+rx,g+rx" "${bundle_dir}" # otherwise extracted tarball director won't be readable by others/group
echo "==> Checking out code box version [${box_version}] into ${bundle_dir}"
(cd "${SOURCE_DIR}" && git archive --format=tar ${box_version} | (cd "${bundle_dir}" && tar xf -))
echo "${version}" > "${bundle_dir}/VERSION"
echo "==> Building dashboard assets"
(cd "${bundle_dir}/dashboard" && npm ci --omit=dev)
(cd "${bundle_dir}/dashboard" && ./node_modules/.bin/gulp --revision ${box_version})
rm -rf "${bundle_dir}/dashboard/node_modules"
echo "==> Building new frontend assets"
(cd "${bundle_dir}/frontend" && npm ci)
(cd "${bundle_dir}/frontend" && ./node_modules/.bin/vite build --base=/frontend/)
mv "${bundle_dir}/frontend/dist" "${bundle_dir}/dashboard/dist/frontend"
rm -rf "${bundle_dir}/frontend"
echo "==> Installing toplevel node modules"
(cd "${bundle_dir}" && npm ci --omit=dev --omit=optional --tldjs-update-rules)
echo "==> Create final tarball"
(cd "${bundle_dir}" && tar czf "${bundle_file}" .)
echo "==> Cleaning up ${bundle_dir}"
rm -rf "${bundle_dir}"
echo "==> Tarball saved at ${bundle_file}"