Skip to content

Commit 3e60904

Browse files
authored
fix trunk issues (#69)
1 parent e71d914 commit 3e60904

File tree

2 files changed

+53
-47
lines changed

2 files changed

+53
-47
lines changed

.trunk/trunk.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ runtimes:
1818
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
1919
lint:
2020
enabled:
21-
22-
21+
22+
2323
2424
- git-diff-check
2525
2626
2727
28-
- renovate@39.90.2
28+
- renovate@39.100.2
2929
3030
31-
31+
3232
3333
actions:
3434
enabled:

install.sh

+49-43
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ VERSION="latest"
1818
INSTALLER_VERSION="0.1.1"
1919

2020
NODE_MIN=22
21-
NODE_PATH="$(which node)"
22-
NPM_PATH="$(which npm)"
21+
NODE_PATH="$(command -v node)"
22+
NPM_PATH="$(command -v npm)"
2323

2424
# Properties
2525
ARCH="$(uname -m)"
@@ -48,7 +48,6 @@ get_latest_version() {
4848
npm show ${PACKAGE_ORG:+${PACKAGE_ORG}/}"${PACKAGE_NAME}" version
4949
}
5050

51-
ARCHIVE_URL=""
5251
download_from_npm() {
5352
local tmpdir="$1"
5453
local url="$2"
@@ -57,12 +56,11 @@ download_from_npm() {
5756

5857
mkdir -p "${tmpdir}"
5958

60-
curl --progress-bar --show-error --location --fail "${url}" --output "${download_file}"
61-
if [[ $? != 0 ]]; then
59+
if ! curl --progress-bar --show-error --location --fail "${url}" --output "${download_file}"; then
6260
return 1
6361
fi
6462

65-
printf "${CLEAR_LINE}" >&2
63+
printf %b "${CLEAR_LINE}" >&2
6664
echo "${download_file}"
6765
}
6866

@@ -126,7 +124,7 @@ build_path_str() {
126124

127125
cli_dir_valid() {
128126
if [[ -n ${HYP_CLI-} ]] && [[ -e ${HYP_CLI} ]] && ! [[ -d ${HYP_CLI} ]]; then
129-
printf "\$HYP_CLI is set but is not a directory (${HYP_CLI}).\n" >&2
127+
printf "\$HYP_CLI is set but is not a directory (%s).\n" "${HYP_CLI}" >&2
130128
printf "Please check your profile scripts and environment.\n" >&2
131129
exit 1
132130
fi
@@ -136,28 +134,34 @@ cli_dir_valid() {
136134
update_profile() {
137135
local install_dir="$1"
138136
if [[ ":${PATH}:" == *":${install_dir}:"* ]]; then
139-
printf "[3/4] ${DIM}The ${CLI_NAME} is already in \$PATH${RESET}\n" >&2
137+
printf "[3/4] %sThe %s is already in \$PATH%s\n" "${DIM}" "${CLI_NAME}" "${RESET}" >&2
140138
return 0
141139
fi
142140

143-
local profile="$(detect_profile $(basename "${SHELL}") $(uname -s))"
141+
local shell os profile
142+
shell="$(basename "${SHELL}")"
143+
os="$(uname -s)"
144+
profile="$(detect_profile "${shell}" "${os}")"
144145
if [[ -z ${profile} ]]; then
145146
printf "No user shell profile found.\n" >&2
146147
return 1
147148
fi
148149

149150
export SHOW_RESET_PROFILE=1
150-
export PROFILE="~/$(basename "${profile}")"
151+
152+
PROFILE="${HOME}/$(basename "${profile}")"
153+
export PROFILE
151154

152155
if grep -q 'HYP_CLI' "${profile}"; then
153-
printf "[3/4] ${DIM}The ${CLI_NAME} has already been configured in ${PROFILE}${RESET}\n" >&2
156+
printf %b "[3/4] ${DIM}The ${CLI_NAME} has already been configured in ${PROFILE}${RESET}\n" >&2
154157
return 0
155158
fi
156159

157-
local path_str="$(build_path_str "${profile}" "${install_dir}")"
160+
local path_str
161+
path_str="$(build_path_str "${profile}" "${install_dir}")"
158162
echo "${path_str}" >>"${profile}"
159163

160-
printf "[3/4] ${DIM}Added the ${CLI_NAME} to the PATH in ${PROFILE}${RESET}\n" >&2
164+
printf %b "[3/4] ${DIM}Added the ${CLI_NAME} to the PATH in ${PROFILE}${RESET}\n" >&2
161165
}
162166

163167
install_version() {
@@ -172,14 +176,13 @@ install_version() {
172176
*) ;;
173177
esac
174178

175-
install_release
176-
if [[ $? == 0 ]]; then
177-
update_profile "${INSTALL_DIR}" && printf "[4/4] ${DIM}Installed the ${CLI_NAME}${RESET}\n" >&2
179+
if ! install_release; then
180+
update_profile "${INSTALL_DIR}" && printf %b "[4/4] ${DIM}Installed the ${CLI_NAME}${RESET}\n" >&2
178181
fi
179182
}
180183

181184
install_release() {
182-
printf "[1/4] ${DIM}Downloading the ${CLI_NAME} from NPM${RESET}\n"
185+
printf %b "[1/4] ${DIM}Downloading the ${CLI_NAME} from NPM${RESET}\n"
183186

184187
local url="https://registry.npmjs.org/${PACKAGE_ORG:+${PACKAGE_ORG}/}${PACKAGE_NAME}/-/${PACKAGE_NAME}-${VERSION}.tgz"
185188

@@ -189,27 +192,29 @@ install_release() {
189192
)"
190193
exit_status="$?"
191194
if [[ ${exit_status} != 0 ]]; then
192-
printf "Could not download the ${CLI_NAME} version '${VERSION}' from\n${url}\n" >&2
195+
printf %b "Could not download the ${CLI_NAME} version '${VERSION}' from\n${url}\n" >&2
193196
exit 1
194197
fi
195198

196-
printf "${CLEAR_LINE}" >&2
197-
printf "[1/4] ${DIM}Downloaded latest ${CLI_NAME} v${VERSION}${RESET}\n" >&2
199+
printf %b "${CLEAR_LINE}" >&2
200+
printf %b "[1/4] ${DIM}Downloaded latest ${CLI_NAME} v${VERSION}${RESET}\n" >&2
198201

199202
install_from_file "${download_archive}"
200203
}
201204

202205
download_release() {
203-
local url="$1"
204-
local download_dir="$(mktemp -d)"
206+
local url download_dir
207+
url="$1"
208+
download_dir="$(mktemp -d)"
205209
download_from_npm "${download_dir}" "${url}"
206210
}
207211

208212
install_from_file() {
209-
local archive="$1"
210-
local extract_to="$(dirname "${archive}")"
213+
local archive extract_to
214+
archive="$1"
215+
extract_to="$(dirname "${archive}")"
211216

212-
printf "[2/4] ${DIM}Unpacking archive${RESET}\n" >&2
217+
printf %b "[2/4] ${DIM}Unpacking archive${RESET}\n" >&2
213218

214219
tar -xf "${archive}" -C "${extract_to}"
215220

@@ -221,12 +226,12 @@ install_from_file() {
221226

222227
ln -s "${INSTALL_DIR}/bin/run.js" "${INSTALL_DIR}/bin/hyp"
223228

224-
printf "${CLEAR_LINE}" >&2
225-
printf "[2/4] ${DIM}Installing dependencies${RESET}\n" >&2
229+
printf %b "${CLEAR_LINE}" >&2
230+
printf %b "[2/4] ${DIM}Installing dependencies${RESET}\n" >&2
226231
(cd "${INSTALL_DIR}" && "${NPM_PATH}" install --omit=dev --silent && find . -type d -empty -delete)
227232

228-
printf "${CLEAR_LINE}" >&2
229-
printf "[2/4] ${DIM}Unpacked archive${RESET}\n" >&2
233+
printf %b "${CLEAR_LINE}" >&2
234+
printf %b "[2/4] ${DIM}Unpacked archive${RESET}\n" >&2
230235
}
231236

232237
check_platform() {
@@ -239,51 +244,52 @@ check_platform() {
239244
case "${ARCH}/${OS}" in
240245
x64/Linux | arm64/Linux | x64/Darwin | arm64/Darwin) return 0 ;;
241246
*)
242-
printf "Unsupported os ${OS} ${ARCH}\n" >&2
247+
printf "Unsupported os %s %s\n" "${OS}" "${ARCH}" >&2
243248
exit 1
244249
;;
245250
esac
246251
}
247252

248253
check_node() {
249254
if [[ -z ${NODE_PATH} ]]; then
250-
printf "${RED}Node.js is not installed.${RESET}\n" >&2
251-
printf "${RED}Please install Node.js ${NODE_WANTED} or later and try again.${RESET}\n" >&2
255+
printf %b "${RED}Node.js is not installed.${RESET}\n" >&2
256+
printf %b "${RED}Please install Node.js ${NODE_WANTED} or later and try again.${RESET}\n" >&2
252257
exit 1
253258
fi
254259

255260
# check node version
256-
local node_version="$("${NODE_PATH}" --version)"
257-
local node_major="${node_version%%.*}"
261+
local node_version node_major
262+
node_version="$("${NODE_PATH}" --version)"
263+
node_major="${node_version%%.*}"
258264
node_major="${node_major#v}"
259265
if [[ ${node_major} -lt ${NODE_MIN} ]]; then
260-
printf "${RED}Node.js ${NODE_MIN} or later is required. You have ${node_version}.${RESET}\n" >&2
261-
printf "${RED}Please update and try again${RESET}\n" >&2
266+
printf %b "${RED}Node.js ${NODE_MIN} or later is required. You have ${node_version}.${RESET}\n" >&2
267+
printf %b "${RED}Please update and try again${RESET}\n" >&2
262268
exit 1
263269
fi
264270

265271
# make sure npm can be found too
266272
if [[ -z ${NPM_PATH} ]]; then
267-
printf "${RED}npm is not installed. Please install npm and try again.${RESET}\n" >&2
273+
printf %b "${RED}npm is not installed. Please install npm and try again.${RESET}\n" >&2
268274
exit 1
269275
fi
270276
}
271277

272278
# This is the entry point
273-
printf "\n${BOLD}${BLUE}${CLI_NAME}${RESET} Installer ${DIM}v${INSTALLER_VERSION}${RESET}\n\n" >&2
279+
printf %b "\n${BOLD}${BLUE}Modus${RESET} Installer ${DIM}v${INSTALLER_VERSION}${RESET}\n\n" >&2
274280

275281
check_platform
276282
check_node
277283
install_version
278284

279-
printf "\nThe ${CLI_NAME} has been installed! 🎉\n" >&2
285+
printf "\nThe Modus CLI has been installed! 🎉\n" >&2
280286

281287
if [[ -n ${SHOW_RESET_PROFILE-} ]]; then
282-
printf "\n${YELLOW}Please restart your terminal or run:${RESET}\n" >&2
283-
printf " ${DIM}source ${PROFILE}${RESET}\n" >&2
284-
printf "\nThen, run ${DIM}hyp${RESET} to get started${RESET}\n" >&2
288+
printf %b "\n${YELLOW}Please restart your terminal or run:${RESET}\n" >&2
289+
printf %b " ${DIM}source ${PROFILE}${RESET}\n" >&2
290+
printf %b "\nThen, run ${DIM}modus${RESET} to get started${RESET}\n" >&2
285291
else
286-
printf "\nRun ${DIM}hyp${RESET} to get started${RESET}\n" >&2
292+
printf %b "\nRun ${DIM}modus${RESET} to get started${RESET}\n" >&2
287293
fi
288294

289295
printf "\n" >&2

0 commit comments

Comments
 (0)