Skip to content

Commit eea527f

Browse files
committed
fix: codeflare launcher fixes for store location
1) was not finding mirrored/packaged store for production builds 2) production builds not located in /Applications or /usr/local would default to those locations 3) -c -> -u i.e. default to CLI operation
1 parent defc0a6 commit eea527f

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

bin/codeflare

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ export NODE_NO_WARNINGS=1
88
# export NODE_OPTIONS="--no-warnings"
99

1010
# use a special window sizing and positioning
11-
export KUI_POPUP_WINDOW_RESIZE=true
11+
# export KUI_POPUP_WINDOW_RESIZE=true
12+
13+
# use a fixed popup window sizing of our choosing
14+
export WINDOW_WIDTH=1024
15+
export WIDTH_HEIGHT=768
1216

1317
# This tells the core Kui plugin resolver that we are using webpack to
1418
# build our headless bundles, not the old headless hacks
@@ -27,21 +31,11 @@ elif [ -f ${SCRIPTDIR}/../node_modules/electron/dist/electron ]; then
2731
# development mode on Linux
2832
NODE=${SCRIPTDIR}/../node_modules/electron/dist/electron
2933
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
3534
elif [ -f ./CodeFlare.app/Contents/MacOS/CodeFlare ]; then
3635
# CodeFlare installed in CWD on macOS
3736
BASE="$PWD/CodeFlare.app"
3837
NODE="$BASE/Contents/MacOS/CodeFlare"
3938
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"
4539
elif [ -f "$SCRIPTDIR/../CodeFlare.app/Contents/MacOS/CodeFlare" ]; then
4640
# CodeFlare installed in SCRIPTDIR on macOS
4741
BASE="$SCRIPTDIR/../CodeFlare.app"
@@ -84,30 +78,35 @@ elif [ -f ./CodeFlare ]; then
8478
BASE="$PWD"
8579
NODE="$BASE/CodeFlare"
8680
HEADLESS="$BASE/resources/headless"
81+
elif [ -f /Applications/CodeFlare.app/Contents/MacOS/CodeFlare ]; then
82+
# CodeFlare installed in /Applications on macOS
83+
BASE=/Applications/CodeFlare.app
84+
NODE="$BASE/Contents/MacOS/CodeFlare"
85+
HEADLESS=$BASE/Contents/Resources/app/dist/headless
86+
elif [ -f /usr/local/bin/CodeFlare/CodeFlare ]; then
87+
# CodeFlare installed in /usr/local/bin on Linux or Windows
88+
BASE=/usr/local/bin/CodeFlare
89+
NODE="$BASE/CodeFlare"
90+
HEADLESS="$BASE/resources/headless"
8791
else
8892
echo "Error: Could not find CodeFlare. Try setting CODEFLARE_HOME=/path/to/CodeFlare"
8993
exit 1
9094
fi
9195

9296
# This points the headless->electron launcher to our Electron
9397
export KUI_ELECTRON_HOME="${KUI_ELECTRON_HOME-$NODE}"
94-
95-
if [ $# = 1 ] && [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
96-
shift
97-
args=(version)
98-
elif [ $# = 1 ] && [ "$1" = "-c" ] || [ "$1" = "--check" ]; then
99-
shift
100-
args=("help -c")
101-
else
102-
args=$@
103-
fi
104-
10598
export CODEFLARE_HEADLESS_ZIP=$HEADLESS/../headless.zip
10699

107100
SCRIPTDIR=$(cd $(dirname "$0") && pwd)
108101
if [ -d "$SCRIPTDIR"/../store ]; then
102+
# development builds
109103
export GUIDEBOOK_STORE="$SCRIPTDIR"/../store
104+
elif [ -d "$SCRIPTDIR"/app/store ]; then
105+
# production builds
106+
export GUIDEBOOK_STORE="$SCRIPTDIR"/app/store
110107
else
108+
# otherwise, we can't find a local mirror, so pull directly from
109+
# git (network transfers!)
111110
export GUIDEBOOK_STORE=git
112111
fi
113112

@@ -117,10 +116,15 @@ do_cli=1
117116
while getopts "u" opt
118117
do
119118
case $opt in
120-
(u) do_cli=0; shift; continue;;
119+
(u) do_cli=0; shift; continue;;
121120
esac
122121
done
123122

123+
if [ $# = 1 ]; then
124+
# use the "guide" command if none was given
125+
EXTRAPREFIX="guide"
126+
fi
127+
124128
if [ "$do_cli" = "1" ]; then
125129
# launch headless version; here, we use madwizard directly, but
126130
# using electron as the nodejs binary (this is what
@@ -131,6 +135,9 @@ if [ "$do_cli" = "1" ]; then
131135
--experimental-specifier-resolution=node --no-warnings --experimental-import-meta-resolve \
132136
"$HEADLESS"/../../node_modules/madwizard/bin/madwizard.js \
133137
$*
138+
else
139+
# tell the command handlers to run in UI mode
140+
EXTRAPREFIX="$EXTRAPREFIX -u"
134141
fi
135142

136143
# Linux may not have the prereqs needed to run Electron
@@ -156,4 +163,4 @@ if [ ! -f ~/.codeflare ] && [ $(uname) = Linux ]; then
156163
fi
157164

158165
# otherwise, we launch the UI version
159-
exec "$NODE" "$HEADLESS"/codeflare.min.js -- $args 3>&1 1>&2 2>&3 3>&- | grep -v WebSwapCGLLayer
166+
exec "$NODE" "$HEADLESS"/codeflare.min.js -- $EXTRAPREFIX $* 3>&1 1>&2 2>&3 3>&- | grep -v WebSwapCGLLayer

plugins/plugin-madwizard/src/plugin.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Arguments, ParsedOptions, ReactResponse, Registrar, Tab } from "@kui-sh
1818
import { setTabReadonly } from "./util"
1919

2020
interface Options extends ParsedOptions {
21-
c: boolean
21+
u: boolean
2222
}
2323

2424
// TODO export this from madwizard
@@ -32,9 +32,8 @@ function withFilepath(
3232
return async ({ tab, argvNoOptions, parsedOptions }: Arguments<Options>) => {
3333
if (!parsedOptions.u) {
3434
// CLI path
35-
await import("madwizard").then((_) =>
36-
_.CLI.cli(["madwizard", task, ...argvNoOptions.slice(1)], undefined, { store: process.env.GUIDEBOOK_STORE })
37-
)
35+
const { CLI } = await import("madwizard")
36+
await CLI.cli(["madwizard", task, ...argvNoOptions.slice(1)], undefined, { store: process.env.GUIDEBOOK_STORE })
3837
return true
3938
}
4039

0 commit comments

Comments
 (0)