Browse Source

feat(musare.sh): Added lint command for markdown files

Owen Diffey 1 year ago
parent
commit
4abece631c
3 changed files with 21 additions and 13 deletions
  1. 8 6
      .github/workflows/build-lint.yml
  2. 1 1
      .wiki/Utility_Script.md
  3. 12 6
      musare.sh

+ 8 - 6
.github/workflows/build-eslint.yml → .github/workflows/build-lint.yml

@@ -1,4 +1,4 @@
-name: Musare Build and ESLint
+name: Musare Build and Lint
 
 on: [ push, pull_request, workflow_dispatch ]
 
@@ -24,7 +24,7 @@ env:
     REDIS_DATA_LOCATION: .redis
 
 jobs:
-    build-eslint:
+    build-lint:
         runs-on: ubuntu-latest
         steps:
             - uses: actions/checkout@v2
@@ -36,7 +36,9 @@ jobs:
                   ./musare.sh build
             - name: Start Musare
               run: ./musare.sh start
-            - name: ESlint Backend
-              run: ./musare.sh eslint backend
-            - name: ESLint Frontend
-              run: ./musare.sh eslint frontend
+            - name: Backend Lint
+              run: ./musare.sh lint backend
+            - name: Frontend Lint
+              run: ./musare.sh lint frontend
+            - name: Docs Lint
+              run: ./musare.sh lint docs

+ 1 - 1
.wiki/Utility_Script.md

@@ -20,7 +20,7 @@ Linux (Bash):
 | `update` | `[auto]` | Update Musare. When auto is specified the update will be cancelled if there are any changes requiring manual intervention, allowing you to run this unattended. |
 | `attach` | `<backend,mongo,redis>` | Attach to backend server, mongodb or redis shell. |
 | `build` | `[frontend backend]` | Build service(s). |
-| `eslint` | `[frontend backend] [fix]` | Run eslint on frontend and/or backend. Specify fix to auto fix issues where possible. |
+| `lint` | `[frontend backend docs] [fix]` | Run lint on frontend, backend and/or docs. Specify fix to auto fix issues where possible. |
 | `backup` | | Backup database data to file. Configured in .env file. |
 | `restore` | `[file]` | Restore database from file. If file is not specified you will be prompted. |
 | `reset` | `[frontend backend redis mongo]` | Reset all data for service(s). |

+ 12 - 6
musare.sh

@@ -245,8 +245,8 @@ case $1 in
         fi
         ;;
 
-    eslint)
-        echo -e "${CYAN}Musare | ESLint${NC}"
+    lint|eslint)
+        echo -e "${CYAN}Musare | Lint${NC}"
         fix=""
         if [[ $2 == "fix" || $3 == "fix" || $2 == "--fix" || $3 == "--fix" ]]; then
             fix="--fix"
@@ -261,19 +261,25 @@ case $1 in
                 ${dockerCompose} exec -T backend npx eslint logic $fix
                 exitValue=$?
                 ;;
+            docs)
+                ${docker} run -v "${scriptLocation}":/workdir ghcr.io/igorshubovych/markdownlint-cli:latest ".wiki" "*.md" $fix
+                exitValue=$?
+                ;;
             ""|fix|--fix)
                 ${dockerCompose} exec -T frontend npx eslint src --ext .js,.vue $fix
                 frontendExitValue=$?
                 ${dockerCompose} exec -T backend npx eslint logic $fix
                 backendExitValue=$?
-                if [[ ${frontendExitValue} -gt 0 || ${backendExitValue} -gt 0 ]]; then
+                ${docker} run -v "${scriptLocation}":/workdir ghcr.io/igorshubovych/markdownlint-cli:latest ".wiki" "*.md" $fix
+                docsExitValue=$?
+                if [[ ${frontendExitValue} -gt 0 || ${backendExitValue} -gt 0 || ${docsExitValue} -gt 0 ]]; then
                     exitValue=1
                 else
                     exitValue=0
                 fi
                 ;;
             *)
-                echo -e "${RED}Invalid service $2\n${YELLOW}Usage: $(basename "$0") eslint [backend, frontend] [fix]${NC}"
+                echo -e "${RED}Invalid service $2\n${YELLOW}Usage: $(basename "$0") lint [backend, frontend, docs] [fix]${NC}"
                 exitValue=1
                 ;;
         esac
@@ -422,7 +428,7 @@ case $1 in
         echo -e "${YELLOW}update - Update Musare${NC}"
         echo -e "${YELLOW}attach [backend,mongo,redis] - Attach to backend service, mongo or redis shell${NC}"
         echo -e "${YELLOW}build - Build services${NC}"
-        echo -e "${YELLOW}eslint - Run eslint on frontend and/or backend${NC}"
+        echo -e "${YELLOW}lint - Run lint on frontend, backend and/or docs${NC}"
         echo -e "${YELLOW}backup - Backup database data to file${NC}"
         echo -e "${YELLOW}restore - Restore database data from backup file${NC}"
         echo -e "${YELLOW}reset - Reset service data${NC}"
@@ -441,7 +447,7 @@ case $1 in
         echo -e "${YELLOW}update - Update Musare${NC}"
         echo -e "${YELLOW}attach [backend,mongo,redis] - Attach to backend service, mongo or redis shell${NC}"
         echo -e "${YELLOW}build - Build services${NC}"
-        echo -e "${YELLOW}eslint - Run eslint on frontend and/or backend${NC}"
+        echo -e "${YELLOW}lint - Run lint on frontend, backend and/or docs${NC}"
         echo -e "${YELLOW}backup - Backup database data to file${NC}"
         echo -e "${YELLOW}restore - Restore database data from backup file${NC}"
         echo -e "${YELLOW}reset - Reset service data${NC}"