fixed sh file, replaced ' with " and removed the bun lock from the repo

This commit is contained in:
creations 2024-08-21 10:20:49 -04:00
parent 95608fc0a5
commit ce303ef231
No known key found for this signature in database
GPG key ID: E72D9705669A90C2
4 changed files with 71 additions and 77 deletions

1
.gitignore vendored
View file

@ -174,3 +174,4 @@ dist
# Finder (MacOS) folder config # Finder (MacOS) folder config
.DS_Store .DS_Store
/.vscode /.vscode
bun.lockb

BIN
bun.lockb

Binary file not shown.

View file

@ -87,10 +87,10 @@ class FastifyManager {
routePath = routePath === "/" ? prefix : join(prefix, routePath); routePath = routePath === "/" ? prefix : join(prefix, routePath);
} }
routePath = routePath.replace(/\\/g, '/'); routePath = routePath.replace(/\\/g, "/");
if (!routePath.startsWith('/')) { if (!routePath.startsWith("/")) {
routePath = '/' + routePath; routePath = "/" + routePath;
} }
routePath = routePath.replace(/\/+/g, "/"); routePath = routePath.replace(/\/+/g, "/");

107
start.sh
View file

@ -1,10 +1,9 @@
#!/bin/bash #!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR" cd "$SCRIPT_DIR"
if [ ! -f package.json ]; then if [ ! -f "package.json" ]; then
echo "package.json not found in $SCRIPT_DIR" echo "package.json not found in $SCRIPT_DIR"
exit 1 exit 1
fi fi
@ -12,60 +11,59 @@ fi
PKG_MANAGER="bun" PKG_MANAGER="bun"
MODE="dev" MODE="dev"
while [[ "$#" -gt 0 ]]; do next_is_value=0
arg="$1" last_key=""
shift
if [[ "$next_is_value" == "1" ]]; then for arg in "$@"; do
if [[ "$last_key" == "manager" ]]; then if [ "$next_is_value" == "1" ]; then
if [ "$last_key" == "manager" ]; then
PKG_MANAGER="$arg" PKG_MANAGER="$arg"
elif [[ "$last_key" == "mode" ]]; then fi
if [ "$last_key" == "mode" ]; then
MODE="$arg" MODE="$arg"
fi fi
next_is_value=0 next_is_value=0
fi fi
case "$arg" in if [ "$arg" == "clean" ] || [ "$arg" == "cleanup" ]; then
clean|cleanup) goto_cleanup=1
cleanup=true fi
;;
manager) if [ "$arg" == "manager" ]; then
last_key="manager" last_key="manager"
next_is_value=1 next_is_value=1
;; fi
mode)
if [ "$arg" == "mode" ]; then
last_key="mode" last_key="mode"
next_is_value=1 next_is_value=1
;; fi
esac
done done
ALLOWED_MANAGERS="bun npm yarn pnpm" ALLOWED_MANAGERS=("bun" "npm" "yarn" "pnpm")
ALLOWED_MODES="dev prod development production" ALLOWED_MODES=("dev" "prod" "development" "production")
manager_allowed=0 manager_allowed=0
for allowed in $ALLOWED_MANAGERS; do for allowed_manager in "${ALLOWED_MANAGERS[@]}"; do
if [[ "$PKG_MANAGER" == "$allowed" ]]; then if [ "$PKG_MANAGER" == "$allowed_manager" ]; then
manager_allowed=1 manager_allowed=1
break
fi fi
done done
mode_allowed=0 mode_allowed=0
for allowed in $ALLOWED_MODES; do for allowed_mode in "${ALLOWED_MODES[@]}"; do
if [[ "$MODE" == "$allowed" ]]; then if [ "$MODE" == "$allowed_mode" ]; then
mode_allowed=1 mode_allowed=1
break
fi fi
done done
if [[ "$manager_allowed" == "0" ]]; then if [ "$manager_allowed" == "0" ]; then
echo "$PKG_MANAGER is not a valid package manager, please use one of the following: $ALLOWED_MANAGERS" echo "$PKG_MANAGER is not a valid package manager, please use one of the following: ${ALLOWED_MANAGERS[@]}"
exit 1 exit 1
fi fi
if [[ "$mode_allowed" == "0" ]]; then if [ "$mode_allowed" == "0" ]; then
echo "$MODE is not a valid mode, please use one of the following: $ALLOWED_MODES" echo "$MODE is not a valid mode, please use one of the following: ${ALLOWED_MODES[@]}"
exit 1 exit 1
fi fi
@ -77,65 +75,60 @@ YARN_MARKER="node_modules/.yarn_used"
PNPM_MARKER="node_modules/.pnpm_used" PNPM_MARKER="node_modules/.pnpm_used"
BUN_MARKER="node_modules/.bun_used" BUN_MARKER="node_modules/.bun_used"
case "$PKG_MANAGER" in if [ "$PKG_MANAGER" == "npm" ]; then
npm)
INSTALL_CMD="npm install" INSTALL_CMD="npm install"
RUN_CMD="npm run $MODE" RUN_CMD="npm run $MODE"
CURRENT_MARKER="$NPM_MARKER" CURRENT_MARKER="$NPM_MARKER"
;; elif [ "$PKG_MANAGER" == "yarn" ]; then
yarn)
INSTALL_CMD="yarn" INSTALL_CMD="yarn"
RUN_CMD="yarn $MODE" RUN_CMD="yarn $MODE"
CURRENT_MARKER="$YARN_MARKER" CURRENT_MARKER="$YARN_MARKER"
;; elif [ "$PKG_MANAGER" == "pnpm" ]; then
pnpm)
INSTALL_CMD="pnpm install" INSTALL_CMD="pnpm install"
RUN_CMD="pnpm $MODE" RUN_CMD="pnpm $MODE"
CURRENT_MARKER="$PNPM_MARKER" CURRENT_MARKER="$PNPM_MARKER"
;; elif [ "$PKG_MANAGER" == "bun" ]; then
bun)
INSTALL_CMD="bun install" INSTALL_CMD="bun install"
RUN_CMD="bun $MODE" RUN_CMD="bun $MODE"
CURRENT_MARKER="$BUN_MARKER" CURRENT_MARKER="$BUN_MARKER"
;;
esac
if [[ -f "$NPM_MARKER" && "$CURRENT_MARKER" != "$NPM_MARKER" ]] || \
[[ -f "$YARN_MARKER" && "$CURRENT_MARKER" != "$YARN_MARKER" ]] || \
[[ -f "$PNPM_MARKER" && "$CURRENT_MARKER" != "$PNPM_MARKER" ]] || \
[[ -f "$BUN_MARKER" && "$CURRENT_MARKER" != "$BUN_MARKER" ]]; then
cleanup=true
fi fi
if [[ "$cleanup" == "true" ]]; then if [ -f "$NPM_MARKER" ] && [ "$CURRENT_MARKER" != "$NPM_MARKER" ]; then goto_cleanup=1; fi
files_to_delete="package-lock.json yarn.lock pnpm-lock.yaml bun.lockb" if [ -f "$YARN_MARKER" ] && [ "$CURRENT_MARKER" != "$YARN_MARKER" ]; then goto_cleanup=1; fi
folders_to_delete="node_modules dist logs" if [ -f "$PNPM_MARKER" ] && [ "$CURRENT_MARKER" != "$PNPM_MARKER" ]; then goto_cleanup=1; fi
markers_to_delete="$NPM_MARKER $YARN_MARKER $PNPM_MARKER $BUN_MARKER" if [ -f "$BUN_MARKER" ] && [ "$CURRENT_MARKER" != "$BUN_MARKER" ]; then goto_cleanup=1; fi
if [ "$goto_cleanup" == "1" ]; then
files_to_delete=("package-lock.json" "yarn.lock" "pnpm-lock.yaml" "bun.lockb")
folders_to_delete=("node_modules" "dist" "logs")
markers_to_delete=("$NPM_MARKER" "$YARN_MARKER" "$PNPM_MARKER" "$BUN_MARKER")
echo "Cleaning up files and folders..." echo "Cleaning up files and folders..."
for file in $files_to_delete; do for file in "${files_to_delete[@]}"; do
if [[ -f "$file" ]]; then if [ -f "$file" ]; then
echo "Found $file in $SCRIPT_DIR - deleting..." echo "Found $file in $SCRIPT_DIR - deleting..."
rm -f "$file" rm -f "$file"
fi fi
done done
for folder in $folders_to_delete; do for folder in "${folders_to_delete[@]}"; do
if [[ -d "$folder" ]]; then if [ -d "$folder" ]; then
echo "Found $folder in $SCRIPT_DIR - deleting..." echo "Found $folder in $SCRIPT_DIR - deleting..."
rm -rf "$folder" rm -rf "$folder"
fi fi
done done
for marker in $markers_to_delete; do for marker in "${markers_to_delete[@]}"; do
if [[ -f "$marker" ]]; then if [ -f "$marker" ]; then
rm -f "$marker" rm -f "$marker"
fi fi
done done
exit 0
fi fi
if [[ -n "$RUN_CMD" ]]; then if [ -n "$RUN_CMD" ]; then
echo "Running $RUN_CMD..." echo "Running $RUN_CMD..."
$INSTALL_CMD $INSTALL_CMD
$RUN_CMD $RUN_CMD