Skip to content

Commit 9e8890b

Browse files
committed
feat: codeflare launcher, bump to latest dev kui to pick up latest madwizard
1 parent d5aaef0 commit 9e8890b

File tree

11 files changed

+1494
-274
lines changed

11 files changed

+1494
-274
lines changed

bin/codeflare

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/usr/bin/env bash
2+
# -*- mode: shell-script
3+
4+
#export KUI_HEADLESS=true
5+
#export ELECTRON_RUN_AS_NODE=true
6+
7+
export NODE_NO_WARNINGS=1
8+
export NODE_OPTIONS="--no-warnings"
9+
10+
# use a special window sizing and positioning
11+
export KUI_POPUP_WINDOW_RESIZE=true
12+
13+
# This tells the core Kui plugin resolver that we are using webpack to
14+
# build our headless bundles, not the old headless hacks
15+
export KUI_HEADLESS_WEBPACK=true
16+
17+
SCRIPTDIR=$(cd $(dirname "$0") && pwd)
18+
19+
if [ -n "$NODE" ] && [ -n "$HEADLESS" ]; then
20+
# no-op; use built-in node
21+
______USING_BUILTIN=true # not needed, just making bash happy
22+
elif [ -f ${SCRIPTDIR}/../node_modules/electron/dist/Electron.app/Contents/MacOS/Electron ]; then
23+
# development mode on MacOS
24+
NODE=${SCRIPTDIR}/../node_modules/electron/dist/Electron.app/Contents/MacOS/Electron
25+
HEADLESS=${SCRIPTDIR}/../dist/headless
26+
elif [ -f ${SCRIPTDIR}/../node_modules/electron/dist/electron ]; then
27+
# development mode on Linux
28+
NODE=${SCRIPTDIR}/../node_modules/electron/dist/electron
29+
HEADLESS=${SCRIPTDIR}/../dist/headless
30+
elif [ -f /Applications/CodeFlare.app/Contents/MacOS/CodeFlare ]; then
31+
# CodeFlare installed in /Applications on macOS
32+
BASE=/Applications/CodeFlare.app
33+
NODE="$BASE/Contents/MacOS/CodeFlare"
34+
HEADLESS=$BASE/Contents/Resources/app/dist/headless
35+
elif [ -f ./CodeFlare.app/Contents/MacOS/CodeFlare ]; then
36+
# CodeFlare installed in CWD on macOS
37+
BASE="$PWD/CodeFlare.app"
38+
NODE="$BASE/Contents/MacOS/CodeFlare"
39+
HEADLESS="$BASE/Contents/Resources/app/dist/headless"
40+
elif [ -f /usr/local/bin/CodeFlare/CodeFlare ]; then
41+
# CodeFlare installed in /usr/local/bin on Linux or Windows
42+
BASE=/usr/local/bin/CodeFlare
43+
NODE="$BASE/CodeFlare"
44+
HEADLESS="$BASE/resources/headless"
45+
elif [ -f "$SCRIPTDIR/../CodeFlare.app/Contents/MacOS/CodeFlare" ]; then
46+
# CodeFlare installed in SCRIPTDIR on macOS
47+
BASE="$SCRIPTDIR/../CodeFlare.app"
48+
NODE="$BASE/Contents/MacOS/CodeFlare"
49+
HEADLESS="$BASE/Contents/Resources/app/dist/headless"
50+
elif [ -f "$SCRIPTDIR/../MacOS/CodeFlare" ]; then
51+
# CodeFlare installed inside of macOS Resources directory
52+
BASE="$SCRIPTDIR/../.."
53+
NODE="$BASE/Contents/MacOS/CodeFlare"
54+
HEADLESS="$BASE/Contents/Resources/app/dist/headless"
55+
elif [ -f "$SCRIPTDIR/../CodeFlare/CodeFlare" ]; then
56+
# CodeFlare installed in SCRIPTDIR on Linux or Windows
57+
BASE="$SCRIPTDIR/../CodeFlare"
58+
NODE="$BASE/CodeFlare"
59+
HEADLESS="$BASE/resources/headless"
60+
elif [ -f "$SCRIPTDIR/../CodeFlare" ]; then
61+
# CodeFlare installed in SCRIPTDIR on Linux or Windows (variant)
62+
BASE="$SCRIPTDIR/.."
63+
NODE="$BASE/CodeFlare"
64+
HEADLESS="$BASE/resources/headless"
65+
elif [ -f "$CODEFLARE_HOME/CodeFlare.app/Contents/MacOS/CodeFlare" ]; then
66+
# CodeFlare installed in CODEFLARE_HOME on macOS
67+
BASE="$CODEFLARE_HOME/CodeFlare.app"
68+
NODE="$BASE/Contents/MacOS/CodeFlare"
69+
HEADLESS="$BASE/Contents/Resources/app/dist/headless"
70+
elif [ -f "$CODEFLARE_HOME/CodeFlare" ]; then
71+
# CodeFlare installed in CODEFLARE_HOME on Linux or Windows
72+
BASE="$CODEFLARE_HOME"
73+
NODE="$BASE/CodeFlare"
74+
HEADLESS="$BASE/resources/headless"
75+
elif [ -f ./CodeFlare/CodeFlare ]; then
76+
# CodeFlare installed in CWD on Linux or Windows
77+
BASE="$PWD/CodeFlare"
78+
NODE="$BASE/CodeFlare"
79+
HEADLESS="$BASE/resources/headless"
80+
elif [ -f ./CodeFlare ]; then
81+
# CodeFlare installed in CWD on Linux or Windows (variant)
82+
# !! CAREFUL !! place this last, so we don't confuse CodeFlare and
83+
# codeflare on case-insensitive filesystems
84+
BASE="$PWD"
85+
NODE="$BASE/CodeFlare"
86+
HEADLESS="$BASE/resources/headless"
87+
else
88+
echo "Error: Could not find CodeFlare. Try setting CODEFLARE_HOME=/path/to/CodeFlare"
89+
exit 1
90+
fi
91+
92+
# This points the headless->electron launcher to our Electron
93+
export KUI_ELECTRON_HOME="${KUI_ELECTRON_HOME-$NODE}"
94+
95+
# Linux may not have the prereqs needed to run Electron
96+
if [ ! -f ~/.codeflare ] && [ $(uname) = Linux ]; then
97+
if [ $(grep '^ID_LIKE' /etc/os-release) = "ID_LIKE=debian" ]; then
98+
if [ $(apt -qq list sudo curl libx11-6 libglib2.0-0 libx11-xcb1 libxcb-dri3-0 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxi6 libxtst6 libnss3 libatk1.0-0 libdrm2 libgbm1 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libasound2 | grep installed 2> /dev/null | wc -l) != 20 ]; then
99+
# it's also possible we didn't see these in the list, because we have an out-of-date package list
100+
# so apt update to refresh that, then recheck
101+
apt update
102+
if [ $(apt -qq list sudo curl libx11-6 libglib2.0-0 libx11-xcb1 libxcb-dri3-0 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxi6 libxtst6 libnss3 libatk1.0-0 libdrm2 libgbm1 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libasound2 | grep installed 2> /dev/null | wc -l) != 20 ]; then
103+
# we really don't have them installed, so install them
104+
apt install -y sudo curl libx11-6 libglib2.0-0 libx11-xcb1 libxcb-dri3-0 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxi6 libxtst6 libnss3 libatk1.0-0 libdrm2 libgbm1 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libasound2
105+
touch ~/.codeflare
106+
else
107+
touch ~/.codeflare
108+
fi
109+
else
110+
touch ~/.codeflare
111+
fi
112+
else
113+
touch ~/.codeflare
114+
fi
115+
fi
116+
117+
if [ $# = 1 ] && [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
118+
shift
119+
args=(version)
120+
elif [ $# = 1 ] && [ "$1" = "-c" ] || [ "$1" = "--check" ]; then
121+
shift
122+
args=("help -c")
123+
else
124+
args=$@
125+
fi
126+
127+
export CODEFLARE_HEADLESS_ZIP=$HEADLESS/../headless.zip
128+
129+
exec "$NODE" "$HEADLESS"/codeflare.min.js -- $args

0 commit comments

Comments
 (0)