From c29be1f3b6756a9f09a00473506297bc8f387b67 Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sat, 11 Jan 2025 09:48:49 +0545 Subject: [PATCH 01/12] static-file-name-checker --- .github/workflows/main.yml | 53 +++++++++---------- .../{create-a-document.md => ABCef.md} | 0 .../{create-a-blog-post.md => anc.md} | 0 ...atulations.md => congratulations-intro.md} | 0 4 files changed, 26 insertions(+), 27 deletions(-) rename docs/tutorial-basics/{create-a-document.md => ABCef.md} (100%) rename docs/tutorial-basics/{create-a-blog-post.md => anc.md} (100%) rename docs/tutorial-basics/{congratulations.md => congratulations-intro.md} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index efd4629..9fb334b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,9 @@ -name: Check Kebab Case for Markdown Files in PR Commits +name: MarkDown filename validation on: - pull_request: # Trigger on PR events + pull_request: paths: - - '**/*.md' # Trigger only when .md files are changed + - '**/*.md' jobs: kebab-case-check: @@ -12,31 +12,30 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - - - name: Get list of changed Markdown files - id: changed-files - run: | - # Get the list of added or modified .md files in the PR - git diff --name-only --diff-filter=AM origin/main | grep '\.md$' > changed_files.txt || true - if [ ! -s changed_files.txt ]; then - echo "No Markdown files to check." - exit 0 - fi + with: + fetch-depth: 2 - name: Check filenames for kebab case run: | - # Find all .md files excluding node_modules, README.md, and CONTRIBUTING.md, and check filenames for kebab case - invalid_files=$(find . -type f -name '*.md' \ - -not -path "./node_modules/*" \ - -not -name "README.md" \ - -not -name "CONTRIBUTING.md" \ - -exec basename {} \; | grep -vE '^[a-z0-9]+(-[a-z0-9]+)*\.md$') - - if [ -n "$invalid_files" ]; then - echo "The following Markdown filenames are not in kebab case:" - echo "$invalid_files" - - else - echo "All Markdown filenames are in kebab case." - fi + Red='\033[0;31m' # Red + Green='\033[0;32m' # Green + Yellow='\033[0;33m' # Yellow + Blue='\033[0;34m' # Blue + Reset='\033[0m' # Reset + echo -e "${Blue} Checking all changed Markdown files ..." + + changed_files=$(git diff --name-only HEAD^1 HEAD | xargs -n1 basename | grep '\.md$') + + if [ -z "$changed_files" ]; then + echo -e "${Green} No changed Markdown files in this PR.${Reset}" + exit 0 + fi + x=1 + echo -e "${Blue} Changed Markdown files are :.${Reset}" + echo "$changed_files" | while read -r file; do + dir=$(dirname "$file") + base=$(basename "$file") + echo -e "${Yellow} $x. File: $base, Folder: $dir${Reset}" + x=$((x + 1)) + done diff --git a/docs/tutorial-basics/create-a-document.md b/docs/tutorial-basics/ABCef.md similarity index 100% rename from docs/tutorial-basics/create-a-document.md rename to docs/tutorial-basics/ABCef.md diff --git a/docs/tutorial-basics/create-a-blog-post.md b/docs/tutorial-basics/anc.md similarity index 100% rename from docs/tutorial-basics/create-a-blog-post.md rename to docs/tutorial-basics/anc.md diff --git a/docs/tutorial-basics/congratulations.md b/docs/tutorial-basics/congratulations-intro.md similarity index 100% rename from docs/tutorial-basics/congratulations.md rename to docs/tutorial-basics/congratulations-intro.md From 936fe58075683505060b277de67dd4680c3aa82d Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sat, 11 Jan 2025 09:52:17 +0545 Subject: [PATCH 02/12] static-file-name-checker --- .github/workflows/main.yml | 6 +++++- docs/tutorial-basics/ABCef.md | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9fb334b..6f15216 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,6 +36,10 @@ jobs: echo "$changed_files" | while read -r file; do dir=$(dirname "$file") base=$(basename "$file") - echo -e "${Yellow} $x. File: $base, Folder: $dir${Reset}" + parent_folder=$(basename "$dir") + if [ "$dir" = "." ]; then + parent_folder="(root)" + fi + echo -e "${Yellow} $x. File: $base, Folder: $parent_folder${Reset}" x=$((x + 1)) done diff --git a/docs/tutorial-basics/ABCef.md b/docs/tutorial-basics/ABCef.md index c22fe29..0448a37 100644 --- a/docs/tutorial-basics/ABCef.md +++ b/docs/tutorial-basics/ABCef.md @@ -55,3 +55,7 @@ export default { ], }; ``` + +git add . +git commit -m "static-file-name-checker" +git push \ No newline at end of file From b7e9c93caf016feb693dc7b04f4ecdad3e4e6a58 Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sat, 11 Jan 2025 09:55:01 +0545 Subject: [PATCH 03/12] static-file-name-checker --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6f15216..77a6e09 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,12 +33,12 @@ jobs: fi x=1 echo -e "${Blue} Changed Markdown files are :.${Reset}" - echo "$changed_files" | while read -r file; do + echo "$changed_files" | while read -r file; do dir=$(dirname "$file") base=$(basename "$file") parent_folder=$(basename "$dir") - if [ "$dir" = "." ]; then - parent_folder="(root)" + if [ "$parent_folder" = "." ]; then + parent_folder="root" fi echo -e "${Yellow} $x. File: $base, Folder: $parent_folder${Reset}" x=$((x + 1)) From 7c35af7b276e8cc14e85939aba8fdeed5dd2011c Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sun, 12 Jan 2025 15:31:45 +0545 Subject: [PATCH 04/12] static-file-name-checker --- .github/workflows/main.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 77a6e09..44dc26f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,17 +23,18 @@ jobs: Blue='\033[0;34m' # Blue Reset='\033[0m' # Reset - echo -e "${Blue} Checking all changed Markdown files ..." + echo -e "${Blue} Checking all changed Markdown files ..." - changed_files=$(git diff --name-only HEAD^1 HEAD | xargs -n1 basename | grep '\.md$') + changed_files=$(git diff --name-only HEAD^1 HEAD | grep '\.md$') if [ -z "$changed_files" ]; then echo -e "${Green} No changed Markdown files in this PR.${Reset}" exit 0 fi + x=1 - echo -e "${Blue} Changed Markdown files are :.${Reset}" - echo "$changed_files" | while read -r file; do + echo -e "${Blue} Changed Markdown files are :${Reset}" + echo "$changed_files" | while read -r file; do dir=$(dirname "$file") base=$(basename "$file") parent_folder=$(basename "$dir") From ca5a70691f1f613f5cb709c72b04cd32b0fcc00e Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sun, 12 Jan 2025 15:36:47 +0545 Subject: [PATCH 05/12] static-file-name-checker --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44dc26f..e556a69 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,6 +41,7 @@ jobs: if [ "$parent_folder" = "." ]; then parent_folder="root" fi - echo -e "${Yellow} $x. File: $base, Folder: $parent_folder${Reset}" + combined_info="$parent_folder/$base" # Treat folder name as part of the file name + echo -e "${Yellow} $x. $combined_info${Reset}" x=$((x + 1)) done From 6f08dbe322b550ceec589eb008019e840d00410f Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sun, 12 Jan 2025 15:39:23 +0545 Subject: [PATCH 06/12] static-file-name-checker --- .github/workflows/main.yml | 10 +++++++--- ...cusaurus-social-card.jpg => docusaurus-card.jpg} | Bin .../{undraw_docusaurus_tree.svg => undrawTtree.svg} | 0 3 files changed, 7 insertions(+), 3 deletions(-) rename static/img/{docusaurus-social-card.jpg => docusaurus-card.jpg} (100%) rename static/img/{undraw_docusaurus_tree.svg => undrawTtree.svg} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e556a69..4ba0ce3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,10 @@ on: pull_request: paths: - '**/*.md' + - '**/*.jpg' + - '**/*.png' + - '**/*.jpeg' + - '**/*.svg' jobs: kebab-case-check: @@ -25,15 +29,15 @@ jobs: echo -e "${Blue} Checking all changed Markdown files ..." - changed_files=$(git diff --name-only HEAD^1 HEAD | grep '\.md$') + changed_files=$(git diff --name-only HEAD^1 HEAD | grep -E '\.(md|jpg|png|jpeg|svg)$') if [ -z "$changed_files" ]; then - echo -e "${Green} No changed Markdown files in this PR.${Reset}" + echo -e "${Green} No changed files in this PR.${Reset}" exit 0 fi x=1 - echo -e "${Blue} Changed Markdown files are :${Reset}" + echo -e "${Blue} Changed static files are :${Reset}" echo "$changed_files" | while read -r file; do dir=$(dirname "$file") base=$(basename "$file") diff --git a/static/img/docusaurus-social-card.jpg b/static/img/docusaurus-card.jpg similarity index 100% rename from static/img/docusaurus-social-card.jpg rename to static/img/docusaurus-card.jpg diff --git a/static/img/undraw_docusaurus_tree.svg b/static/img/undrawTtree.svg similarity index 100% rename from static/img/undraw_docusaurus_tree.svg rename to static/img/undrawTtree.svg From 4326ea1b9c8a8f4e4a99034e405732d605228318 Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sun, 12 Jan 2025 15:42:57 +0545 Subject: [PATCH 07/12] static-file-name-checker --- .github/workflows/main.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ba0ce3..714317b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,3 +49,22 @@ jobs: echo -e "${Yellow} $x. $combined_info${Reset}" x=$((x + 1)) done + + # Find invalid filenames + invalid_kebab_case=$(echo "$changed_files" | grep -vE '^[a-z0-9]+(-[a-z0-9]+)*\.(md|jpg|png|jpeg|svg)$' || true) + # Find long filenames + long_files=$(echo "$changed_files" | awk 'length > 100') + failure_flag=0 + + # Check for filenames that are not in kebab case + if [ -n "$invalid_kebab_case" ]; then + echo -e "${Blue} The following filenames are not in kebab case:${Reset}" + x=1 + echo "$invalid_kebab_case" | while read -r file; do + echo -e "${Red}$x. $file${Reset}" + x=$((x + 1)) + done + failure_flag=1 + else + echo -e "${Green} All changed filenames are in kebab case." + fi From 8ad5514fa8240d5352b4d661693bc102ba21ae06 Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sun, 12 Jan 2025 15:49:35 +0545 Subject: [PATCH 08/12] static-file-name-checker --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 714317b..fb67df0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,7 +51,7 @@ jobs: done # Find invalid filenames - invalid_kebab_case=$(echo "$changed_files" | grep -vE '^[a-z0-9]+(-[a-z0-9]+)*\.(md|jpg|png|jpeg|svg)$' || true) + invalid_kebab_case=$(echo "$changed_files" | grep -vE '^([a-z0-9]+(-[a-z0-9]+)*)(/([a-z0-9]+(-[a-z0-9]+)*))*\.(md|jpg|png|jpeg|svg)$' || true)) # Find long filenames long_files=$(echo "$changed_files" | awk 'length > 100') failure_flag=0 From 2755166b9d72626c3d427d798bbf54d1b8386254 Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sun, 12 Jan 2025 15:51:08 +0545 Subject: [PATCH 09/12] static-file-name-checker --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fb67df0..69ea52f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,7 +51,7 @@ jobs: done # Find invalid filenames - invalid_kebab_case=$(echo "$changed_files" | grep -vE '^([a-z0-9]+(-[a-z0-9]+)*)(/([a-z0-9]+(-[a-z0-9]+)*))*\.(md|jpg|png|jpeg|svg)$' || true)) + invalid_kebab_case=$(echo "$changed_files" | grep -vE '^([a-z0-9]+(-[a-z0-9]+)*)(/([a-z0-9]+(-[a-z0-9]+)*))*\.(md|jpg|png|jpeg|svg)$' || true) # Find long filenames long_files=$(echo "$changed_files" | awk 'length > 100') failure_flag=0 From 855880524d1570e4a2b910f342412f9aa83d7176 Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sun, 12 Jan 2025 15:57:34 +0545 Subject: [PATCH 10/12] static-file-name-checker --- .github/workflows/main.yml | 27 +++++++++++++++--- .../_category_.json | 0 .../img/docsVersionDropdown.png | Bin .../img/localeDropdown.png | Bin .../manage-docs-versions.md | 0 .../translate-your-site.md | 0 6 files changed, 23 insertions(+), 4 deletions(-) rename docs/{tutorial-extras => tutorial-extrasABC}/_category_.json (100%) rename docs/{tutorial-extras => tutorial-extrasABC}/img/docsVersionDropdown.png (100%) rename docs/{tutorial-extras => tutorial-extrasABC}/img/localeDropdown.png (100%) rename docs/{tutorial-extras => tutorial-extrasABC}/manage-docs-versions.md (100%) rename docs/{tutorial-extras => tutorial-extrasABC}/translate-your-site.md (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 69ea52f..1ef6b57 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,13 +52,10 @@ jobs: # Find invalid filenames invalid_kebab_case=$(echo "$changed_files" | grep -vE '^([a-z0-9]+(-[a-z0-9]+)*)(/([a-z0-9]+(-[a-z0-9]+)*))*\.(md|jpg|png|jpeg|svg)$' || true) - # Find long filenames - long_files=$(echo "$changed_files" | awk 'length > 100') - failure_flag=0 # Check for filenames that are not in kebab case if [ -n "$invalid_kebab_case" ]; then - echo -e "${Blue} The following filenames are not in kebab case:${Reset}" + echo -e "${Blue} The following path is not in kebab case:${Reset}" x=1 echo "$invalid_kebab_case" | while read -r file; do echo -e "${Red}$x. $file${Reset}" @@ -68,3 +65,25 @@ jobs: else echo -e "${Green} All changed filenames are in kebab case." fi + + changed_files=$(git diff --name-only HEAD^1 HEAD | grep -E '\.(md|jpg|png|jpeg|svg)$') + long_files=$(echo "$changed_files" | awk 'length > 100') + # Check for Markdown filenames that are not long + if [ -n "$long_files" ]; then + echo -e "${Blue} The following Markdown filenames exceed 100 characters:${Reset}" + x=1 + echo "$long_files$" | while read -r file; do + echo -e "${Red}$x. $long_files${Reset}" + x=$((x + 1)) + done + failure_flag=1 + else + echo -e "${Green} All changed Markdown filenames are of valid length.${Reset}" + fi + if [ "$failure_flag" -eq 0 ]; then + echo -e "${Green} All changed Markdown filenames passed validation.${Reset}" + exit 0 + else + echo -e "${Red} The check has failed.${Reset}" + exit 1 + fi \ No newline at end of file diff --git a/docs/tutorial-extras/_category_.json b/docs/tutorial-extrasABC/_category_.json similarity index 100% rename from docs/tutorial-extras/_category_.json rename to docs/tutorial-extrasABC/_category_.json diff --git a/docs/tutorial-extras/img/docsVersionDropdown.png b/docs/tutorial-extrasABC/img/docsVersionDropdown.png similarity index 100% rename from docs/tutorial-extras/img/docsVersionDropdown.png rename to docs/tutorial-extrasABC/img/docsVersionDropdown.png diff --git a/docs/tutorial-extras/img/localeDropdown.png b/docs/tutorial-extrasABC/img/localeDropdown.png similarity index 100% rename from docs/tutorial-extras/img/localeDropdown.png rename to docs/tutorial-extrasABC/img/localeDropdown.png diff --git a/docs/tutorial-extras/manage-docs-versions.md b/docs/tutorial-extrasABC/manage-docs-versions.md similarity index 100% rename from docs/tutorial-extras/manage-docs-versions.md rename to docs/tutorial-extrasABC/manage-docs-versions.md diff --git a/docs/tutorial-extras/translate-your-site.md b/docs/tutorial-extrasABC/translate-your-site.md similarity index 100% rename from docs/tutorial-extras/translate-your-site.md rename to docs/tutorial-extrasABC/translate-your-site.md From 97a108c71b298932673e9fd2a55b80a9099d79fe Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Sun, 12 Jan 2025 16:00:21 +0545 Subject: [PATCH 11/12] static-file-name-checker --- .github/workflows/main.yml | 8 ++++---- ...rusdocusaurusdocusaurusdocusaurusdocusaurus.png} | Bin 2 files changed, 4 insertions(+), 4 deletions(-) rename static/img/{docusaurus.png => docusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurus.png} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1ef6b57..a126fba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,9 +68,9 @@ jobs: changed_files=$(git diff --name-only HEAD^1 HEAD | grep -E '\.(md|jpg|png|jpeg|svg)$') long_files=$(echo "$changed_files" | awk 'length > 100') - # Check for Markdown filenames that are not long + # Check for filenames that are not long if [ -n "$long_files" ]; then - echo -e "${Blue} The following Markdown filenames exceed 100 characters:${Reset}" + echo -e "${Blue} The following filenames exceed 100 characters:${Reset}" x=1 echo "$long_files$" | while read -r file; do echo -e "${Red}$x. $long_files${Reset}" @@ -78,10 +78,10 @@ jobs: done failure_flag=1 else - echo -e "${Green} All changed Markdown filenames are of valid length.${Reset}" + echo -e "${Green} All changed filenames are of valid length.${Reset}" fi if [ "$failure_flag" -eq 0 ]; then - echo -e "${Green} All changed Markdown filenames passed validation.${Reset}" + echo -e "${Green} All changed filenames passed validation.${Reset}" exit 0 else echo -e "${Red} The check has failed.${Reset}" diff --git a/static/img/docusaurus.png b/static/img/docusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurus.png similarity index 100% rename from static/img/docusaurus.png rename to static/img/docusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurusdocusaurus.png From 2f428bb10a2f1522a0550b14bfdec0668eea0f35 Mon Sep 17 00:00:00 2001 From: Rohan Maharjan Date: Mon, 13 Jan 2025 20:14:29 +0545 Subject: [PATCH 12/12] static-file-name-checker --- .github/workflows/main.yml | 22 ------------------- ...{_category_.json => _categorydasdsa_.json} | 0 2 files changed, 22 deletions(-) rename docs/tutorial-extrasABC/{_category_.json => _categorydasdsa_.json} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a126fba..999bd32 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,25 +65,3 @@ jobs: else echo -e "${Green} All changed filenames are in kebab case." fi - - changed_files=$(git diff --name-only HEAD^1 HEAD | grep -E '\.(md|jpg|png|jpeg|svg)$') - long_files=$(echo "$changed_files" | awk 'length > 100') - # Check for filenames that are not long - if [ -n "$long_files" ]; then - echo -e "${Blue} The following filenames exceed 100 characters:${Reset}" - x=1 - echo "$long_files$" | while read -r file; do - echo -e "${Red}$x. $long_files${Reset}" - x=$((x + 1)) - done - failure_flag=1 - else - echo -e "${Green} All changed filenames are of valid length.${Reset}" - fi - if [ "$failure_flag" -eq 0 ]; then - echo -e "${Green} All changed filenames passed validation.${Reset}" - exit 0 - else - echo -e "${Red} The check has failed.${Reset}" - exit 1 - fi \ No newline at end of file diff --git a/docs/tutorial-extrasABC/_category_.json b/docs/tutorial-extrasABC/_categorydasdsa_.json similarity index 100% rename from docs/tutorial-extrasABC/_category_.json rename to docs/tutorial-extrasABC/_categorydasdsa_.json