From 679992146b56eb01db1b5b78022ed51c43189220 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Mon, 8 Nov 2021 16:35:26 +0100 Subject: [PATCH] Building ConverseJS ourself. --- .eslintrc.json | 2 +- .gitignore | 1 + .gitmodules | 3 +++ conversejs/build-conversejs.sh | 41 ++++++++++++++++++++++++++++++++++ package-lock.json | 6 ----- package.json | 8 +++---- vendor/converse.js | 1 + 7 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 .gitmodules create mode 100644 conversejs/build-conversejs.sh create mode 160000 vendor/converse.js diff --git a/.eslintrc.json b/.eslintrc.json index b3555b29..40ad1516 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,6 +4,6 @@ "extends": [], "globals": {}, "plugins": [], - "ignorePatterns": ["node_modules/", "dist/", "webpack.config.js"], + "ignorePatterns": ["node_modules/", "dist/", "webpack.config.js", "build/", "vendor/"], "rules": {} } diff --git a/.gitignore b/.gitignore index d9897013..d7674e6d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .cache dist .vscode +build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..50180060 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/converse.js"] + path = vendor/converse.js + url = https://github.com/conversejs/converse.js.git diff --git a/conversejs/build-conversejs.sh b/conversejs/build-conversejs.sh new file mode 100644 index 00000000..6fc435f4 --- /dev/null +++ b/conversejs/build-conversejs.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +set -euo pipefail +set -x + +rootdir="$(pwd)" +src_dir="$rootdir/conversejs" +converse_src_dir="$rootdir/vendor/converse.js" +converse_build_dir="$rootdir/build/converse.js" +converse_destination_dir="$rootdir/dist/client/conversejs" + +if [[ ! -d $src_dir ]]; then + echo "$0 must be called from the plugin livechat root dir.\n" + exit 1 +fi + +if [[ ! -d "$converse_src_dir" ]]; then + echo "ConverseJS sources are not here. Please be sure to have all the submodules downloaded ('git pull --recurse-submodules').\n" + exit 1 +fi + +if cmp -s "$converse_src_dir/package.json" "$converse_build_dir/package.json"; then + echo "ConverseJS files are already up to date in the build directory.\n" +else + echo "ConverseJS files are not up to date in the build directory, copying them...\n" + rm -rf "$converse_build_dir" + mkdir -p "$converse_build_dir" + cp -R $converse_src_dir/* "$converse_build_dir" +fi + +echo "Building ConverseJS" +cd "$converse_build_dir" +make dist +cd $rootdir + +echo "Copying ConverseJS dist files...\n" +mkdir -p "$converse_destination_dir" && cp -r $converse_build_dir/dist/* "$converse_destination_dir/" + +echo "ConverseJS OK.\n" + +exit 0 diff --git a/package-lock.json b/package-lock.json index 0bfdeb21..16c2874e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1744,12 +1744,6 @@ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" }, - "converse.js": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/converse.js/-/converse.js-7.0.6.tgz", - "integrity": "sha512-fcuj6H44F4RTg+WTpX6gsuSfARxL/lXlISeHBJfYfevOD+mFHOgN0tfI7PvoC25DmKCiZRXhm1iIdpfoiKvM3A==", - "dev": true - }, "copy-concurrently": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", diff --git a/package.json b/package.json index 28a3fe6f..16b5597b 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "@types/winston": "^2.4.4", "@typescript-eslint/eslint-plugin": "^4.29.0", "@typescript-eslint/parser": "^4.29.0", - "converse.js": "^7.0.6", "eslint": "^7.32.0", "eslint-config-standard": "^16.0.3", "eslint-config-standard-with-typescript": "^20.0.0", @@ -75,15 +74,16 @@ ], "library": "./dist/server/main.js", "scripts": { - "clean": "rm -rf dist/*", + "clean": "rm -rf dist/* build/*", + "clean:light": "rm -rf dist/*", "prepare": "npm run build", - "build:converse": "mkdir -p dist/client/conversejs && cp -r node_modules/converse.js/dist/* dist/client/conversejs/", + "build:converse": "bash conversejs/build-conversejs.sh", "build:images": "mkdir -p dist/client/images && npx svgo -f public/images/ -o dist/client/images/", "build:webpack": "webpack --mode=production", "build:server": "npx tsc --build server/tsconfig.json", "build:serverconverse": "mkdir -p dist/server/conversejs && cp conversejs/index.html dist/server/conversejs/", "build:prosodymodules": "mkdir -p dist/server/prosody-modules && cp -r prosody-modules/* dist/server/prosody-modules/", - "build": "npm-run-all -s clean -p build:converse build:images build:webpack build:server build:serverconverse build:prosodymodules", + "build": "npm-run-all -s clean:light -p build:converse build:images build:webpack build:server build:serverconverse build:prosodymodules", "lint": "npx eslint --ext .js --ext .ts ." }, "staticDirs": { diff --git a/vendor/converse.js b/vendor/converse.js new file mode 160000 index 00000000..e9967882 --- /dev/null +++ b/vendor/converse.js @@ -0,0 +1 @@ +Subproject commit e9967882a94ee48667d6d1aac33118dd32edebbb