Переглянути джерело

feat: Add shellcheck to musare.sh

Owen Diffey 1 тиждень тому
батько
коміт
f3d1fa457d
4 змінених файлів з 12 додано та 5 видалено
  1. 2 0
      .github/workflows/lint.yml
  2. 1 1
      backend/entrypoint.dev.sh
  3. 1 1
      frontend/entrypoint.dev.sh
  4. 8 3
      musare.sh

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

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

+ 1 - 1
backend/entrypoint.dev.sh

@@ -7,7 +7,7 @@ if [ ! -d node_modules ]; then
     npm install
 fi
 
-if [[ "${APP_ENV}" == "development" ]]; then
+if [ "${APP_ENV}" = "development" ]; then
     npm run dev
 else
     npm run prod

+ 1 - 1
frontend/entrypoint.dev.sh

@@ -7,7 +7,7 @@ if [ ! -d node_modules ]; then
     npm install
 fi
 
-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

@@ -282,9 +282,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
@@ -306,6 +306,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
@@ -536,7 +541,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