Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
A few minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nwmac committed Dec 10, 2020
1 parent 9aa808e commit ee48bc5
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 78 deletions.
8 changes: 7 additions & 1 deletion electron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ You can also run the UI with `ng serve` from the top-level folder and then start

`./run.sh dev`

to load the UI from `https://127.0.0.1:4200`
to load the UI from `https://127.0.0.1:4200`

# Packaging

Packaging as a DMG file for Mac:

`./package.sh all`
66 changes: 66 additions & 0 deletions electron/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

# Script folder
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
STRATOS="`cd "${DIR}/..";pwd`"

BUILD_FRONTEND=false
BUILD_BACKEND=false
ARGS=""

if [ "$1" == "fe" ]; then
BUILD_FRONTEND=true
shift
elif [ "$1" == "be" ]; then
BUILD_BACKEND=true
shift
elif [ "$1" == "all" ]; then
BUILD_FRONTEND=true
BUILD_BACKEND=true
shift
fi

if [ "$1" == "dev" ]; then
ARGS="dev"
fi

pushd ${DIR} > /dev/null
# Checks for fresh run on checkout
if [ ! -d "./node_modules" ]; then
echo "Installing node modules ..."
npm install
fi
popd > /dev/null

pushd ${STRATOS} > /dev/null

cat ./package.json | jq -r .version > ${DIR}/version

if [ ! -d "./node_modules" ]; then
echo "Installing node modules in top-level folder ..."
npm install
fi

if [ "$1" != "be" ] && [ ! -d "./dist" ]; then
BUILD_FRONTEND=true
echo "Frontend has not been built - will build"
fi

if [ ! -f "./src/jetstream/jetstream" ]; then
BUILD_BACKEND=true
echo "Backend has not been built - will build"
fi

if [ "$BUILD_FRONTEND" == "true" ]; then
# Ensure the desktop-extendsions are included
STRATOS_YAML=./electron/stratos.yaml ng build --configuration=desktop
fi
if [ "$BUILD_BACKEND" == "true" ]; then
# Ensure we include the desktop backend plugin
STRATOS_YAML=./electron/stratos.yaml npm run prepare-backend
npm run build-backend
fi
cp ./src/jetstream/jetstream ./electron
cp -R ${STRATOS}/dist ${DIR}
cp -R ${STRATOS}/dev-ssl ${DIR}
popd > /dev/null
7 changes: 6 additions & 1 deletion electron/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ const isMac = process.platform === 'darwin'
let appMainWindow;
let appHomeUrl;

const version = fs.readFileSync('./version').toString();
// Read version file
const versionFile = path.join(__dirname, `./version`);
let version = 'dev';
if (fs.existsSync(versionFile)) {
version = fs.readFileSync(versionFile).toString();
}

function getMenu(mainWindow, homeUrl) {
appMainWindow = mainWindow;
Expand Down
15 changes: 1 addition & 14 deletions electron/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,7 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
STRATOS="`cd "${DIR}/..";pwd`"

pushd ${DIR} > /dev/null
rm -rf dist
rm -rf out
popd > /dev/null

pushd ${STRATOS} > /dev/null
rm -rf dist
ng build --configuration=desktop
npm run build-backend
cp ./src/jetstream/jetstream ./electron
cp -R ${STRATOS}/dist ${DIR}
cp -R ${STRATOS}/dev-ssl ${DIR}
popd > /dev/null

source "${DIR}/build.sh"

pushd ${DIR} > /dev/null
rm -rf dist/*es5*
Expand Down
64 changes: 2 additions & 62 deletions electron/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,7 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
STRATOS="`cd "${DIR}/..";pwd`"

BUILD_FRONTEND=false
BUILD_BACKEND=false
ARGS=""
source "${DIR}/build.sh"

if [ "$1" == "fe" ]; then
BUILD_FRONTEND=true
shift
elif [ "$1" == "be" ]; then
BUILD_BACKEND=true
shift
elif [ "$1" == "all" ]; then
BUILD_FRONTEND=true
BUILD_BACKEND=true
shift
fi

if [ "$1" == "dev" ]; then
ARGS="dev"
fi

pushd ${DIR} > /dev/null
# Checks for fresh run on checkout
if [ ! -d "./node_modules" ]; then
echo "Installing node modules ..."
npm install
fi
popd > /dev/null

pushd ${STRATOS} > /dev/null

cat ./package.json | jq -r .version > ${DIR}/version

if [ ! -d "./node_modules" ]; then
echo "Installing node modules in top-level folder ..."
npm install
fi

if [ "$1" != "be" ] && [ ! -d "./dist" ]; then
BUILD_FRONTEND=true
echo "Frontend has not been built - will build"
fi

if [ ! -f "./src/jetstream/jetstream" ]; then
BUILD_BACKEND=true
echo "Backend has not been built - will build"
fi

if [ "$BUILD_FRONTEND" == "true" ]; then
# Ensure the desktop-extendsions are included
STRATOS_YAML=./electron/stratos.yaml ng build --configuration=desktop
fi
if [ "$BUILD_BACKEND" == "true" ]; then
# Ensure we include the desktop backend plugin
STRATOS_YAML=./electron/stratos.yaml npm run prepare-backend
npm run build-backend
fi
cp ./src/jetstream/jetstream ./electron
cp -R ${STRATOS}/dist ${DIR}
cp -R ${STRATOS}/dev-ssl ${DIR}
popd > /dev/null


echo "Building ...."
echo "Running electron app ...."
npm run electron -- ${ARGS}

0 comments on commit ee48bc5

Please sign in to comment.