gerrit/contrib/mitm-ui/mitm-single-plugin.sh
Viktar Donich 508f81ddce Scripts for UI plugins development using mitmproxy
Starts a local proxy that rewrites prod server responses, adding new
plugins, serving local files, enabling or disabling assets bundles.

Prerequisite: Docker
Target platform: OS X

Change-Id: I9abd94c816f987bf43e4335aff5be7ad17dd0fde
2018-12-21 15:22:16 -08:00

32 lines
790 B
Bash
Executable File

#!/bin/sh
if [[ -z "$1" ]]; then
echo This script serves one plugin with the rest of static content.
echo Provide path to index plugin file, e.g. buildbucket.html for buildbucket plugin
exit 1
fi
realpath() {
OURPWD=$PWD
cd "$(dirname "$1")"
LINK=$(basename "$1")
while [ -L "$LINK" ]; do
LINK=$(readlink "$LINK")
cd "$(dirname "$LINK")"
LINK="$(basename "$1")"
done
REAL_DIR=`pwd -P`
RESULT=$REAL_DIR/$LINK
cd "$OURPWD"
echo "$RESULT"
}
plugin=$(realpath $1)
plugin_root=$(dirname ${plugin})
mitm_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
${mitm_dir}/dev-chrome.sh &
${mitm_dir}/mitm-docker.sh -v ${plugin_root}:${plugin_root} "serve-app-dev.py --plugins ${plugin} --strip_assets --plugin_root ${plugin_root}"