-
Notifications
You must be signed in to change notification settings - Fork 432
Expand file tree
/
Copy pathquarto
More file actions
executable file
·196 lines (170 loc) · 7.08 KB
/
quarto
File metadata and controls
executable file
·196 lines (170 loc) · 7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env bash
# Determine the path to this script (we'll use this to figure out relative positions of other files)
SOURCE="${BASH_SOURCE[0]}"
if [ -h "$SOURCE" ]; then
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
PREV_DIR="$(dirname "$SOURCE")"
SOURCE="$(readlink "$SOURCE")"
SOURCE_NAME="$(basename "$SOURCE")"
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
if [[ $SOURCE != /* ]]; then
SCRIPT_PATH="$( cd -P "${PREV_DIR}/$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$SCRIPT_PATH/$SOURCE_NAME"
else
SCRIPT_PATH="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
fi
done
else
SCRIPT_PATH="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
fi
# Check if we are running 'Dev Mode' and if so, override values for devs
SCRIPT_BASENAME=$(basename "$SCRIPT_PATH")
if [ "${SCRIPT_BASENAME}" == "bin" ]; then
# we can be running dev mode with a symlink to the package/dist/bin folder. In this case, our relative path is two levels up.
export QUARTO_ROOT="`cd "$SCRIPT_PATH/../../.." > /dev/null 2>&1 && pwd`"
elif [ "${SCRIPT_BASENAME}" == "common" ]; then
# we can run this script directly in the source tree. In this case, our relative path is three levels up.
export QUARTO_ROOT="`cd "$SCRIPT_PATH/../../.." > /dev/null 2>&1 && pwd`"
else
echo "ERROR: Cannot determine the Quarto source path. This script must be run from the bin or common folder."
exit 1
fi
QUARTO_SRC_PATH="$QUARTO_ROOT/src"
DEV_PATH=$QUARTO_SRC_PATH/quarto.ts
if [ -f "$DEV_PATH" ]; then
if [ "$1" == "--version" ] || [ "$1" == "-v" ]; then
if [ "$QUARTO_FORCE_VERSION" != "" ]; then
echo $QUARTO_FORCE_VERSION
exit 0
fi
echo "99.9.9"
exit 0
fi
# Caller can point deno at another entry point (e.g. the typescript file)
if [ -z ${QUARTO_ACTION+x} ]; then
QUARTO_ACTION=run
fi
# Local import map
QUARTO_IMPORT_MAP_ARG=--importmap=$QUARTO_SRC_PATH/import_map.json
# Turn on type checking for dev version
if [ -z ${QUARTO_NO_TYPECHECK+x} ]; then
QUARTO_DENO_OPTIONS=--check
fi
# Allow calls to override the target
if [ -z ${QUARTO_TARGET+x} ]; then
QUARTO_TARGET=$DEV_PATH
fi
export QUARTO_BIN_PATH=$SCRIPT_PATH
export QUARTO_SHARE_PATH="${QUARTO_SHARE_PATH=$QUARTO_SRC_PATH/resources/}"
if [ -z ${QUARTO_DEBUG+x} ]; then
export QUARTO_DEBUG=true
fi
# QUARTO_CACHE_OPTIONS="--cached-only"
# Check for deno update
QUARTO_DIST_CONFIG=$QUARTO_BIN_PATH/../config
mkdir -p $QUARTO_DIST_CONFIG
DENO_VERSION_FILE=$QUARTO_DIST_CONFIG/deno-version
DENO_SOURCE_VERSION="`(cd "$QUARTO_ROOT" && source ./configuration && echo $DENO)`"
if [ -f "$DENO_VERSION_FILE" ]; then
# echo is to trim whitespace to avoid version comparison issues
DENO_INSTALLED_VERSION=$(echo `cat "$DENO_VERSION_FILE"`)
if [ "${DENO_SOURCE_VERSION}" != "${DENO_INSTALLED_VERSION}" ]; then
# configure will call back into this script so we need to update the
# version so that the check will pass next time through
(cd "$QUARTO_ROOT" && ./configure.sh)
echo ""
printf "\\033[0;31mQuarto required reconfiguration to install Deno. Had ${DENO_INSTALLED_VERSION}, needed ${DENO_SOURCE_VERSION}. Please try command again.\\033[0m\n\n"
exit 1
fi
fi
else
QUARTO_ACTION=run
QUARTO_TARGET=${SCRIPT_PATH}/quarto.js
export QUARTO_BIN_PATH=$SCRIPT_PATH
QUARTO_CACHE_OPTIONS=""
# Turn off type checking for bundled version
QUARTO_DENO_OPTIONS=--no-check
# If Quarto is bundled into an `.app` file, it will be looking for the
# share directory over in the resources folder.
if [ -z "${QUARTO_SHARE_PATH+x}" ]; then
if [[ $SCRIPT_PATH == *"/Contents/MacOS/quarto/bin" ]]; then
export QUARTO_SHARE_PATH="`cd "$SCRIPT_PATH/../../../Resources/quarto/share";pwd`"
elif [[ $SCRIPT_PATH == *"/usr/local/bin/quarto" ]]; then
export QUARTO_SHARE_PATH="`cd "$SCRIPT_PATH/../../share/quarto";pwd`"
else
export QUARTO_SHARE_PATH="`cd "$SCRIPT_PATH/../share";pwd`"
fi
fi
# release vendored import map
QUARTO_IMPORT_MAP_ARG=--importmap=$SCRIPT_PATH/vendor/import_map.json
if [ "$1" == "--version" ] || [ "$1" == "-v" ]; then
if [ "$QUARTO_FORCE_VERSION" != "" ]; then
echo $QUARTO_FORCE_VERSION
exit 0
fi
echo `cat "$QUARTO_SHARE_PATH/version"`
exit 0
fi
fi
if [ "$1" == "--paths" ]; then
echo "$QUARTO_BIN_PATH"
echo "$QUARTO_SHARE_PATH"
exit 0
fi
if [[ $OSTYPE == 'darwin'* ]]; then
# We cannot use uname to determine the _machine_ architecture:
# https://github.com/quarto-dev/quarto-cli/issues/2420#issuecomment-1245768732
FULLARCH="$(/usr/sbin/sysctl machdep.cpu.brand_string)"
if [[ $FULLARCH == *"Intel"* ]]; then
ARCH_DIR=x86_64
elif [[ $FULLARCH == *"Apple"* ]]; then
ARCH_DIR=aarch64
else
echo "quarto script failed: unrecognized architecture " ${FULLARCH}
exit 1
fi
else
NIXARCH=$(uname -m)
if [[ $NIXARCH == "x86_64" ]]; then
ARCH_DIR=x86_64
elif [[ $NIXARCH == "aarch64" ]]; then
ARCH_DIR=aarch64
else
echo "configure script failed: unrecognized architecture " ${NIXARCH}
exit 1
fi
fi
if [ "$QUARTO_DENO_DOM" != "" ]; then
export DENO_DOM_PLUGIN=$QUARTO_DENO_DOM
elif [ "$(uname)" = "Darwin" ]; then
export DENO_DOM_PLUGIN=$QUARTO_BIN_PATH/tools/${ARCH_DIR}/deno_dom/libplugin.dylib
else
export DENO_DOM_PLUGIN=$QUARTO_BIN_PATH/tools/${ARCH_DIR}/deno_dom/libplugin.so
fi
if [ "$QUARTO_DENO" == "" ]; then
DENO_ARCH_DIR=$ARCH_DIR
export QUARTO_DENO="${SCRIPT_PATH}/tools/${DENO_ARCH_DIR}/deno"
fi
export DENO_TLS_CA_STORE=system,mozilla
export DENO_NO_UPDATE_CHECK=1
# Be sure to include any already defined QUARTO_DENO_OPTIONS
## Using --allow-all as there is otherwise an issue in Deno 1.46.3 with --allow-read and --allow-write with network drives
## https://github.com/quarto-dev/quarto-cli/issues/11332
QUARTO_DENO_OPTIONS="--unstable-ffi --unstable-kv --no-config --no-lock ${QUARTO_CACHE_OPTIONS} --allow-all ${QUARTO_DENO_OPTIONS}"
# --enable-experimental-regexp-engine is required for /regex/l, https://github.com/quarto-dev/quarto-cli/issues/9737
if [ "$QUARTO_DENO_V8_OPTIONS" != "" ]; then
QUARTO_DENO_V8_OPTIONS="--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192,${QUARTO_DENO_V8_OPTIONS}"
else
QUARTO_DENO_V8_OPTIONS="--enable-experimental-regexp-engine,--max-old-space-size=8192,--max-heap-size=8192"
fi
if [ "$QUARTO_DENO_EXTRA_OPTIONS" == "" ]; then
QUARTO_DENO_EXTRA_OPTIONS="--v8-flags=${QUARTO_DENO_V8_OPTIONS}"
else
QUARTO_DENO_EXTRA_OPTIONS="--v8-flags=${QUARTO_DENO_V8_OPTIONS} ${QUARTO_DENO_EXTRA_OPTIONS}"
fi
if [ "$QUARTO_TS_PROFILE" != "" ]; then
QUARTO_DENO_EXTRA_OPTIONS="--inspect-brk ${QUARTO_DENO_EXTRA_OPTIONS}"
QUARTO_TS_PROFILE=true "${QUARTO_DENO}" ${QUARTO_ACTION} ${QUARTO_DENO_OPTIONS} ${QUARTO_DENO_EXTRA_OPTIONS} "${QUARTO_IMPORT_MAP_ARG}" "${QUARTO_TARGET}" "$@"
else
"${QUARTO_DENO}" ${QUARTO_ACTION} ${QUARTO_DENO_OPTIONS} ${QUARTO_DENO_EXTRA_OPTIONS} "${QUARTO_IMPORT_MAP_ARG}" "${QUARTO_TARGET}" "$@"
fi