2021-11-08 15:35:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
set -x
|
|
|
|
|
2023-09-04 10:16:14 +00:00
|
|
|
CONVERSE_VERSION="v10.1.6"
|
2023-08-08 07:56:00 +00:00
|
|
|
CONVERSE_REPO="https://github.com/conversejs/converse.js.git"
|
|
|
|
|
2021-11-08 15:35:26 +00:00
|
|
|
rootdir="$(pwd)"
|
|
|
|
src_dir="$rootdir/conversejs"
|
2023-08-10 02:41:36 +00:00
|
|
|
converse_src_dir="$rootdir/vendor/conversejs-$CONVERSE_VERSION"
|
2023-08-08 07:56:00 +00:00
|
|
|
converse_build_dir="$rootdir/build/conversejs"
|
2021-11-08 15:35:26 +00:00
|
|
|
converse_destination_dir="$rootdir/dist/client/conversejs"
|
|
|
|
|
|
|
|
if [[ ! -d $src_dir ]]; then
|
2021-11-08 19:15:53 +00:00
|
|
|
echo "$0 must be called from the plugin livechat root dir."
|
2021-11-08 15:35:26 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d "$converse_src_dir" ]]; then
|
2023-08-08 07:56:00 +00:00
|
|
|
git clone --depth=1 --branch $CONVERSE_VERSION $CONVERSE_REPO $converse_src_dir
|
|
|
|
rm -rf "$converse_build_dir"
|
2021-11-08 15:35:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if cmp -s "$converse_src_dir/package.json" "$converse_build_dir/package.json"; then
|
2021-11-08 19:15:53 +00:00
|
|
|
echo "ConverseJS files are already up to date in the build directory."
|
2021-11-08 15:35:26 +00:00
|
|
|
else
|
2021-11-08 19:15:53 +00:00
|
|
|
echo "ConverseJS files are not up to date in the build directory, copying them..."
|
2021-11-08 15:35:26 +00:00
|
|
|
rm -rf "$converse_build_dir"
|
|
|
|
mkdir -p "$converse_build_dir"
|
|
|
|
cp -R $converse_src_dir/* "$converse_build_dir"
|
|
|
|
fi
|
|
|
|
|
2021-11-08 19:15:53 +00:00
|
|
|
echo "Removing existing custom files..."
|
2021-11-08 18:06:53 +00:00
|
|
|
rm -rf "$converse_build_dir/custom/"
|
|
|
|
|
2021-11-08 19:15:53 +00:00
|
|
|
echo "Adding the custom files..."
|
2021-11-08 18:06:53 +00:00
|
|
|
cp -r "$src_dir/custom/" "$converse_build_dir/custom/"
|
|
|
|
mv "$converse_build_dir/custom/webpack.livechat.js" "$converse_build_dir/"
|
|
|
|
|
|
|
|
if [[ ! -d "$converse_build_dir/node_modules" ]]; then
|
2021-11-08 19:15:53 +00:00
|
|
|
echo "Missing node_modules directory, seems we have to call the makefile..."
|
2021-11-08 18:06:53 +00:00
|
|
|
cd "$converse_build_dir"
|
2023-08-22 10:04:29 +00:00
|
|
|
make node_modules src/*
|
2021-11-08 18:06:53 +00:00
|
|
|
cd $rootdir
|
|
|
|
fi
|
|
|
|
|
2021-11-08 19:15:53 +00:00
|
|
|
echo "Building ConverseJS..."
|
2021-11-08 15:35:26 +00:00
|
|
|
cd "$converse_build_dir"
|
2021-11-08 18:06:53 +00:00
|
|
|
npx webpack --config webpack.livechat.js
|
2021-11-08 15:35:26 +00:00
|
|
|
cd $rootdir
|
|
|
|
|
2021-11-08 19:15:53 +00:00
|
|
|
echo "Copying ConverseJS dist files..."
|
2021-11-08 15:35:26 +00:00
|
|
|
mkdir -p "$converse_destination_dir" && cp -r $converse_build_dir/dist/* "$converse_destination_dir/"
|
|
|
|
|
2021-11-08 19:15:53 +00:00
|
|
|
echo "ConverseJS OK."
|
2021-11-08 15:35:26 +00:00
|
|
|
|
|
|
|
exit 0
|