Browse Source

feat: Add shellcheck to musare.sh

Owen Diffey 1 month ago
parent
commit
2924cc0727
4 changed files with 13 additions and 6 deletions
  1. 2 0
      .github/workflows/build-lint.yml
  2. 2 2
      backend/entrypoint.dev.sh
  3. 1 1
      frontend/entrypoint.dev.sh
  4. 8 3
      musare.sh

+ 2 - 0
.github/workflows/build-lint.yml

@@ -42,3 +42,5 @@ jobs:
 #              run: ./musare.sh typescript frontend
             - name: Docs Lint
               run: ./musare.sh lint docs
+            - name: Shell Lint
+              run: ./musare.sh lint shell

+ 2 - 2
backend/entrypoint.dev.sh

@@ -2,13 +2,13 @@
 
 set -e
 
-if [[ "${BACKEND_DEBUG}" == "true" ]]; then
+if [ "${BACKEND_DEBUG}" = "true" ]; then
     export INSPECT_BRK="--inspect-brk=0.0.0.0:${BACKEND_DEBUG_PORT:-9229}"
 else
     export INSPECT_BRK=""
 fi
 
-if [[ "${APP_ENV}" == "development" ]]; then
+if [ "${APP_ENV}" = "development" ]; then
     npm run dev
 else
     npm run prod

+ 1 - 1
frontend/entrypoint.dev.sh

@@ -2,7 +2,7 @@
 
 set -e
 
-if [ "${APP_ENV}" == "development" ]; then
+if [ "${APP_ENV}" = "development" ]; then
     ln -sf /opt/app/nginx.dev.conf /etc/nginx/http.d/default.conf
     nginx
 

+ 8 - 3
musare.sh

@@ -297,9 +297,9 @@ handleLinting()
     set -e
 
     # shellcheck disable=SC2068
-    servicesString=$(handleServices "backend frontend docs" ${services[@]})
+    servicesString=$(handleServices "backend frontend docs shell" ${services[@]})
     if [[ ${servicesString:0:1} != 1 ]]; then
-        throw "${servicesString:2}\n${YELLOW}Usage: ${1} [backend, frontend, docs] [fix]"
+        throw "${servicesString:2}\n${YELLOW}Usage: ${1} [backend, frontend, docs, shell] [fix]"
     fi
 
     set +e
@@ -318,6 +318,11 @@ handleLinting()
         ${docker} run --rm -v "${scriptLocation}":/workdir ghcr.io/igorshubovych/markdownlint-cli:latest ".wiki" "*.md" "${fix}"
         docsExitValue=$?
     fi
+    if [[ ${servicesString:2:4} == "all" || "${servicesString:2}" == *shell* ]]; then
+        echo -e "${CYAN}Running shell lint...${NC}"
+        ${docker} run --rm -v "${scriptLocation}":/mnt koalaman/shellcheck:stable ./*.sh ./**/*.sh
+        shellExitValue=$?
+    fi
     set -e
     if [[ ${frontendExitValue} -gt 0 || ${backendExitValue} -gt 0 || ${docsExitValue} -gt 0 || ${shellExitValue} -gt 0 ]]; then
         exit 1
@@ -551,7 +556,7 @@ logs - View logs for services
 update - Update Musare
 attach [backend,mongo,redis] - Attach to backend service, mongo or redis shell
 build - Build services
-lint - Run lint on frontend, backend, and/or docs
+lint - Run lint on frontend, backend, docs and/or shell
 backup - Backup database data to file
 restore - Restore database data from backup file
 reset - Reset service data