From 6402fc0bfd531fb7eb4b534b3fced59ea247874d Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:27:05 +1000 Subject: [PATCH 01/66] add-all-frontmatter-validator --- .../workflows/validate-frontmatter-all.yml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/validate-frontmatter-all.yml diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml new file mode 100644 index 00000000000..953ba847672 --- /dev/null +++ b/.github/workflows/validate-frontmatter-all.yml @@ -0,0 +1,47 @@ +name: Validate-Frontmatter-in-All-Rules + +on: + push: + branches: [main] + paths: + - 'rules/**/*.md' # Adjust this path to match your rules directory + workflow_dispatch: + +jobs: + validate-all-frontmatter: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Node.js + uses: actions/setup-node@v3 + + - name: Find all Markdown files in rules + run: | + find rules -name '*.md' > all_rules_files.txt + echo "RULE_FILES=$(cat all_rules_files.txt)" >> $GITHUB_ENV + + - name: Install dependencies + run: | + cd scripts/frontmatter-validator + npm install + + - name: Validate Frontmatter in Rule Files + run: | + cd scripts/frontmatter-validator + node frontmatter-validator.js "${{ env.RULE_FILES }}" > validation_output.txt + cat validation_output.txt >> $GITHUB_STEP_SUMMARY + + - name: Create Job Summary + run: | + echo "## Frontmatter Validation Results" >> $GITHUB_STEP_SUMMARY + cat validation_output.txt >> $GITHUB_STEP_SUMMARY + + # Additional steps for error handling or reporting if necessary From 0e0d2be59cf2a18b353422485999be5eea98790f Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:32:32 +1000 Subject: [PATCH 02/66] testing - add to on PR --- .github/workflows/validate-frontmatter-all.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 953ba847672..1aa0b4a9706 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -1,10 +1,13 @@ name: Validate-Frontmatter-in-All-Rules + on: push: branches: [main] paths: - 'rules/**/*.md' # Adjust this path to match your rules directory + pull_request: + branches: [ main ] workflow_dispatch: jobs: From 58f931a4d2f6f6378e7fe0e868704295ff99c1df Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:40:42 +1000 Subject: [PATCH 03/66] update --- .../workflows/validate-frontmatter-all.yml | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 1aa0b4a9706..ae99bacfa57 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -1,13 +1,12 @@ name: Validate-Frontmatter-in-All-Rules - on: push: branches: [main] paths: - - 'rules/**/*.md' # Adjust this path to match your rules directory + - 'rules/**/rule.md' pull_request: - branches: [ main ] + branches: [main] workflow_dispatch: jobs: @@ -29,7 +28,16 @@ jobs: - name: Find all Markdown files in rules run: | find rules -name '*.md' > all_rules_files.txt - echo "RULE_FILES=$(cat all_rules_files.txt)" >> $GITHUB_ENV + + - name: Read file list and process + id: file_list + run: | + FILE_LIST=$(cat all_rules_files.txt) + echo "Found Markdown files:" + echo "$FILE_LIST" + echo "FILE_LIST<> $GITHUB_ENV + echo "$FILE_LIST" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV - name: Install dependencies run: | @@ -39,12 +47,12 @@ jobs: - name: Validate Frontmatter in Rule Files run: | cd scripts/frontmatter-validator - node frontmatter-validator.js "${{ env.RULE_FILES }}" > validation_output.txt + for file in $FILE_LIST; do + node frontmatter-validator.js "$file" + done > validation_output.txt cat validation_output.txt >> $GITHUB_STEP_SUMMARY - name: Create Job Summary run: | echo "## Frontmatter Validation Results" >> $GITHUB_STEP_SUMMARY cat validation_output.txt >> $GITHUB_STEP_SUMMARY - - # Additional steps for error handling or reporting if necessary From af5f9e4257d03e324a35bf71ef990946881d169b Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:44:26 +1000 Subject: [PATCH 04/66] another attempt --- .../workflows/validate-frontmatter-all.yml | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index ae99bacfa57..ebbc3527138 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -4,7 +4,7 @@ on: push: branches: [main] paths: - - 'rules/**/rule.md' + - 'rules/**/*.md' pull_request: branches: [main] workflow_dispatch: @@ -26,18 +26,7 @@ jobs: uses: actions/setup-node@v3 - name: Find all Markdown files in rules - run: | - find rules -name '*.md' > all_rules_files.txt - - - name: Read file list and process - id: file_list - run: | - FILE_LIST=$(cat all_rules_files.txt) - echo "Found Markdown files:" - echo "$FILE_LIST" - echo "FILE_LIST<> $GITHUB_ENV - echo "$FILE_LIST" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV + run: find rules -name '*.md' > all_rules_files.txt - name: Install dependencies run: | @@ -47,12 +36,10 @@ jobs: - name: Validate Frontmatter in Rule Files run: | cd scripts/frontmatter-validator - for file in $FILE_LIST; do - node frontmatter-validator.js "$file" - done > validation_output.txt - cat validation_output.txt >> $GITHUB_STEP_SUMMARY + node frontmatter-validator.js all_rules_files.txt > validation_issues.txt + cat validation_issues.txt >> $GITHUB_STEP_SUMMARY - name: Create Job Summary run: | - echo "## Frontmatter Validation Results" >> $GITHUB_STEP_SUMMARY - cat validation_output.txt >> $GITHUB_STEP_SUMMARY + echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY + cat validation_issues.txt >> $GITHUB_STEP_SUMMARY From a1c1f138782a72f966f17c8ef38d95e9e382f35a Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:46:57 +1000 Subject: [PATCH 05/66] test --- .github/workflows/validate-frontmatter-all.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index ebbc3527138..3b1cb3792de 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -37,9 +37,15 @@ jobs: run: | cd scripts/frontmatter-validator node frontmatter-validator.js all_rules_files.txt > validation_issues.txt - cat validation_issues.txt >> $GITHUB_STEP_SUMMARY + echo "Validation complete. Contents of validation_issues.txt:" + cat validation_issues.txt # for debugging + mv validation_issues.txt ../../ # Move the file to the root of the workspace - name: Create Job Summary run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - cat validation_issues.txt >> $GITHUB_STEP_SUMMARY + if [ -f validation_issues.txt ]; then + cat validation_issues.txt >> $GITHUB_STEP_SUMMARY + else + echo "No validation issues file found or no issues detected." >> $GITHUB_STEP_SUMMARY + fi \ No newline at end of file From e667f97030ab945a8d6e36518c4a93a1b1351eb4 Mon Sep 17 00:00:00 2001 From: JackDevAU Date: Thu, 7 Dec 2023 10:30:27 +1000 Subject: [PATCH 06/66] update script to allow multiple errors --- .../frontmatter-validator.js | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index e507a78e231..eb90b856de0 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -42,7 +42,7 @@ function validateFrontmatter(filePath) { if (filePath.indexOf('.github') !== -1) { return } - + if (!fs.existsSync(filePath)) { console.error(`File ${filePath} does not exist.`); return @@ -57,21 +57,23 @@ function validateFrontmatter(filePath) { if (!isValid && validate.errors) { const errorList = validate.errors.filter(error => { return error.keyword === 'errorMessage' || error.keyword === 'required' - }) + }); if (errorList.length >= 1) { - console.log(`Invalid Frontmatter detected in ${filePath.replaceAll('../', '')}, please fix the following issues:`); + const errors = [`Invalid Frontmatter detected in ${filePath.replaceAll('../', '')}, please fix the following issues:`]; errorList.forEach((error, index) => { - console.log(`${index + 1}. ${error.message}`); - }) - process.exit(1); + errors.push(`${index + 1}. ${error.message}`); + }); + return errors; // Return the list of errors } } + + return []; // Return an empty array if there are no errors } function parseFrontmatter(filePath, fileContents) { if (!fileContents) return {} - + try { const frontmatterMatch = /^---([\s\S]*?)---/.exec(fileContents); const frontmatterString = frontmatterMatch[1]; @@ -86,20 +88,30 @@ function parseFrontmatter(filePath, fileContents) { } function main() { - const eventType = process.env.GITHUB_EVENT_NAME; - if (eventType === 'pull_request') { - const filesChanged = process.argv[2]; + const filesChanged = process.argv[2]; - if (filesChanged) { - const folders = filesChanged - .split(',') - .filter((file) => file.endsWith('.md')) - .map((file) => `../../${file}`); + let allErrors = []; - folders.forEach((file) => validateFrontmatter(file)); + if (filesChanged) { + const folders = filesChanged + .split(',') + .filter((file) => file.endsWith('.md')) + .map((file) => `../../${file}`); + + folders.forEach((file) => { + const fileErrors = validateFrontmatter(file); + if (fileErrors.length > 0) { + allErrors = allErrors.concat(fileErrors); + } + }); + + if (allErrors.length > 0) { + allErrors.forEach(error => console.log(error)); + process.exit(1); } } } + main(); From ebe74823a7d4062557d0c379627a5c56a253dd14 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 10:58:13 +1000 Subject: [PATCH 07/66] x --- .github/workflows/validate-frontmatter-all.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 3b1cb3792de..97617bb706d 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -26,7 +26,10 @@ jobs: uses: actions/setup-node@v3 - name: Find all Markdown files in rules - run: find rules -name '*.md' > all_rules_files.txt + run: | + find rules -type f -name '*.md' > all_rules_files.txt + echo "Found Markdown files:" + cat all_rules_files.txt - name: Install dependencies run: | From b33c615f2a9f536deaab0cafba165c71c7e02f19 Mon Sep 17 00:00:00 2001 From: JackDevAU Date: Thu, 7 Dec 2023 11:29:26 +1000 Subject: [PATCH 08/66] allow file as input --- .../frontmatter-validator.js | 54 +++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index eb90b856de0..19b56d94bd5 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -87,30 +87,54 @@ function parseFrontmatter(filePath, fileContents) { } } -function main() { - - const filesChanged = process.argv[2]; - +function validateFiles(fileListPath) { + const fileContents = fs.readFileSync(fileListPath, 'utf8'); + const filePaths = fileContents.trim().split('\n'); let allErrors = []; - if (filesChanged) { - const folders = filesChanged - .split(',') - .filter((file) => file.endsWith('.md')) - .map((file) => `../../${file}`); - - folders.forEach((file) => { - const fileErrors = validateFrontmatter(file); + filePaths + .filter(file => file.endsWith('.md')) + .map(file => `../../${file}`) // Adjust the path as necessary + .forEach(filePath => { + const fileErrors = validateFrontmatter(filePath.trim()); if (fileErrors.length > 0) { allErrors = allErrors.concat(fileErrors); } }); - if (allErrors.length > 0) { - allErrors.forEach(error => console.log(error)); - process.exit(1); + return allErrors; +} + + +function main() { + const args = process.argv.slice(2); + let allErrors = []; + + if (args.includes('--file')) { + const fileListIndex = args.indexOf('--file') + 1; + const fileListPath = args[fileListIndex]; + allErrors = validateFiles(fileListPath); + } else { + const filesChanged = args[0]; + if (filesChanged) { + const folders = filesChanged + .split(',') + .filter(file => file.endsWith('.md')) + .map(file => `../../${file}`); + + folders.forEach(file => { + const fileErrors = validateFrontmatter(file); + if (fileErrors.length > 0) { + allErrors = allErrors.concat(fileErrors); + } + }); } } + + if (allErrors.length > 0) { + allErrors.forEach(error => console.log(error)); + process.exit(1); + } } From 2085085ea1f9ab8f5212b637600d3c7c588ee712 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:32:28 +1000 Subject: [PATCH 09/66] x --- .github/workflows/validate-frontmatter-all.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 97617bb706d..e80c355b33a 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,11 +39,18 @@ jobs: - name: Validate Frontmatter in Rule Files run: | cd scripts/frontmatter-validator - node frontmatter-validator.js all_rules_files.txt > validation_issues.txt - echo "Validation complete. Contents of validation_issues.txt:" - cat validation_issues.txt # for debugging + echo "Running validation script..." + node frontmatter-validator.js --file all_rules_files.txt > validation_issues.txt + echo "Validation script completed." + if [ -f validation_issues.txt ]; then + echo "Validation issues file found. Contents:" + cat validation_issues.txt # Display the contents for debugging + else + echo "No validation issues file found." + fi mv validation_issues.txt ../../ # Move the file to the root of the workspace + - name: Create Job Summary run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY From c5b6591b09edab78767991e7e15db3b86937541a Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:33:53 +1000 Subject: [PATCH 10/66] x --- .github/workflows/validate-frontmatter-all.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index e80c355b33a..263a1d5616d 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -31,6 +31,16 @@ jobs: echo "Found Markdown files:" cat all_rules_files.txt + - name: Check if File List is Created + run: | + if [ -f all_rules_files.txt ]; then + echo "all_rules_files.txt exists. Contents:" + cat all_rules_files.txt + else + echo "all_rules_files.txt does not exist." + exit 1 + fi + - name: Install dependencies run: | cd scripts/frontmatter-validator From a27bd39a38ccb9700501e434b2d449eac4045394 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:37:15 +1000 Subject: [PATCH 11/66] x --- .github/workflows/validate-frontmatter-all.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 263a1d5616d..c13ac1fae77 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -48,18 +48,11 @@ jobs: - name: Validate Frontmatter in Rule Files run: | - cd scripts/frontmatter-validator - echo "Running validation script..." - node frontmatter-validator.js --file all_rules_files.txt > validation_issues.txt - echo "Validation script completed." - if [ -f validation_issues.txt ]; then - echo "Validation issues file found. Contents:" - cat validation_issues.txt # Display the contents for debugging - else - echo "No validation issues file found." - fi - mv validation_issues.txt ../../ # Move the file to the root of the workspace - + node scripts/frontmatter-validator/frontmatter-validator.js all_rules_files.txt > validation_issues.txt + echo "Validation complete. Contents of validation_issues.txt:" + cat validation_issues.txt # for debugging + mv validation_issues.txt ../ # Move the file up one directory level + working-directory: . # Set the working directory to the repository root - name: Create Job Summary run: | From da88d8f71f179a0489bbc5aac9d740460b8c5f8f Mon Sep 17 00:00:00 2001 From: JackDevAU Date: Thu, 7 Dec 2023 11:42:54 +1000 Subject: [PATCH 12/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 19b56d94bd5..0c7aec490f8 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -87,6 +87,13 @@ function parseFrontmatter(filePath, fileContents) { } } +function adjustSchemaPaths() { + const basePath = 'scripts/frontmatter-validator/'; + schemas.rule = loadSchema(basePath + 'schema/rule-schema.json'); + schemas.category = loadSchema(basePath + 'schema/category-schema.json'); + schemas.top_category = loadSchema(basePath + 'schema/top-category-schema.json'); +} + function validateFiles(fileListPath) { const fileContents = fs.readFileSync(fileListPath, 'utf8'); const filePaths = fileContents.trim().split('\n'); @@ -111,6 +118,7 @@ function main() { let allErrors = []; if (args.includes('--file')) { + adjustSchemaPaths(); const fileListIndex = args.indexOf('--file') + 1; const fileListPath = args[fileListIndex]; allErrors = validateFiles(fileListPath); From 78a7c4e99f2d4a100538fba9372da9b1888d4d9a Mon Sep 17 00:00:00 2001 From: JackDevAU Date: Thu, 7 Dec 2023 11:50:02 +1000 Subject: [PATCH 13/66] x --- .../frontmatter-validator.js | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 0c7aec490f8..53df960cf20 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -4,11 +4,15 @@ const yaml = require('js-yaml'); const addFormats = require('ajv-formats'); const ajvErrors = require('ajv-errors'); +const args = process.argv.slice(2); +const isFileInput = args.includes('--file'); +const basePath = isFileInput ? 'scripts/frontmatter-validator/' : ''; + const schemas = { - rule: loadSchema('./schema/rule-schema.json'), - category: loadSchema('./schema/category-schema.json'), - top_category: loadSchema('./schema/top-category-schema.json'), -} + rule: loadSchema(basePath + 'schema/rule-schema.json'), + category: loadSchema(basePath + 'schema/category-schema.json'), + top_category: loadSchema(basePath + 'schema/top-category-schema.json'), +}; const validator = initializeValidator(); @@ -87,13 +91,6 @@ function parseFrontmatter(filePath, fileContents) { } } -function adjustSchemaPaths() { - const basePath = 'scripts/frontmatter-validator/'; - schemas.rule = loadSchema(basePath + 'schema/rule-schema.json'); - schemas.category = loadSchema(basePath + 'schema/category-schema.json'); - schemas.top_category = loadSchema(basePath + 'schema/top-category-schema.json'); -} - function validateFiles(fileListPath) { const fileContents = fs.readFileSync(fileListPath, 'utf8'); const filePaths = fileContents.trim().split('\n'); @@ -118,7 +115,6 @@ function main() { let allErrors = []; if (args.includes('--file')) { - adjustSchemaPaths(); const fileListIndex = args.indexOf('--file') + 1; const fileListPath = args[fileListIndex]; allErrors = validateFiles(fileListPath); From c82214b624cbc2ea4930c4ec190a5515e424cd03 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:52:07 +1000 Subject: [PATCH 14/66] x --- .github/workflows/validate-frontmatter-all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index c13ac1fae77..d3e6777b4b4 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -48,7 +48,7 @@ jobs: - name: Validate Frontmatter in Rule Files run: | - node scripts/frontmatter-validator/frontmatter-validator.js all_rules_files.txt > validation_issues.txt + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_issues.txt echo "Validation complete. Contents of validation_issues.txt:" cat validation_issues.txt # for debugging mv validation_issues.txt ../ # Move the file up one directory level From 1f81c2433c816dfe8907d1906907152020f03844 Mon Sep 17 00:00:00 2001 From: JackDevAU Date: Thu, 7 Dec 2023 11:54:24 +1000 Subject: [PATCH 15/66] x --- .../frontmatter-validator/frontmatter-validator.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 53df960cf20..19b56d94bd5 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -4,15 +4,11 @@ const yaml = require('js-yaml'); const addFormats = require('ajv-formats'); const ajvErrors = require('ajv-errors'); -const args = process.argv.slice(2); -const isFileInput = args.includes('--file'); -const basePath = isFileInput ? 'scripts/frontmatter-validator/' : ''; - const schemas = { - rule: loadSchema(basePath + 'schema/rule-schema.json'), - category: loadSchema(basePath + 'schema/category-schema.json'), - top_category: loadSchema(basePath + 'schema/top-category-schema.json'), -}; + rule: loadSchema('./schema/rule-schema.json'), + category: loadSchema('./schema/category-schema.json'), + top_category: loadSchema('./schema/top-category-schema.json'), +} const validator = initializeValidator(); From c2c35fd7afff4d50b6e2ae0e105954937010eeaf Mon Sep 17 00:00:00 2001 From: JackDevAU Date: Thu, 7 Dec 2023 11:56:37 +1000 Subject: [PATCH 16/66] x --- .../frontmatter-validator/frontmatter-validator.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 19b56d94bd5..a29a2abf3da 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -4,11 +4,15 @@ const yaml = require('js-yaml'); const addFormats = require('ajv-formats'); const ajvErrors = require('ajv-errors'); +const args = process.argv.slice(2); +const isFileInput = args.includes('--file'); +const basePath = isFileInput ? 'scripts/frontmatter-validator/' : ''; + const schemas = { - rule: loadSchema('./schema/rule-schema.json'), - category: loadSchema('./schema/category-schema.json'), - top_category: loadSchema('./schema/top-category-schema.json'), -} + rule: loadSchema(basePath + 'schema/rule-schema.json'), + category: loadSchema(basePath + 'schema/category-schema.json'), + top_category: loadSchema(basePath + 'schema/top-category-schema.json'), +}; const validator = initializeValidator(); @@ -94,7 +98,7 @@ function validateFiles(fileListPath) { filePaths .filter(file => file.endsWith('.md')) - .map(file => `../../${file}`) // Adjust the path as necessary + .map(file => `${file}`) // Adjust the path as necessary .forEach(filePath => { const fileErrors = validateFrontmatter(filePath.trim()); if (fileErrors.length > 0) { From e2d9ac227c6c2076be8fcf5711875177caf7ca7a Mon Sep 17 00:00:00 2001 From: JackDevAU Date: Thu, 7 Dec 2023 12:01:05 +1000 Subject: [PATCH 17/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index a29a2abf3da..e0343224957 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -6,7 +6,7 @@ const ajvErrors = require('ajv-errors'); const args = process.argv.slice(2); const isFileInput = args.includes('--file'); -const basePath = isFileInput ? 'scripts/frontmatter-validator/' : ''; +const basePath = ''; const schemas = { rule: loadSchema(basePath + 'schema/rule-schema.json'), @@ -98,7 +98,7 @@ function validateFiles(fileListPath) { filePaths .filter(file => file.endsWith('.md')) - .map(file => `${file}`) // Adjust the path as necessary + .map(file => `../../${file}`) // Adjust the path as necessary .forEach(filePath => { const fileErrors = validateFrontmatter(filePath.trim()); if (fileErrors.length > 0) { From 9ab6a2eae7807f5a7a38869f0c6c54cdd0a00e0a Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:03:18 +1000 Subject: [PATCH 18/66] x --- .github/workflows/validate-frontmatter-all.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index d3e6777b4b4..d5985416145 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -48,11 +48,10 @@ jobs: - name: Validate Frontmatter in Rule Files run: | - node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_issues.txt + node frontmatter-validator.js --file ../../all_rules_files.txt > ../../validation_issues.txt echo "Validation complete. Contents of validation_issues.txt:" cat validation_issues.txt # for debugging mv validation_issues.txt ../ # Move the file up one directory level - working-directory: . # Set the working directory to the repository root - name: Create Job Summary run: | From 0b3812ad4ad6a4c75cc10ee9ae8397051d7099ac Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:05:05 +1000 Subject: [PATCH 19/66] x --- .github/workflows/validate-frontmatter-all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index d5985416145..2eba66bb496 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -48,7 +48,7 @@ jobs: - name: Validate Frontmatter in Rule Files run: | - node frontmatter-validator.js --file ../../all_rules_files.txt > ../../validation_issues.txt + node scripts/frontmatter-validator/frontmatter-validator.js --file ../../all_rules_files.txt > ../../validation_issues.txt echo "Validation complete. Contents of validation_issues.txt:" cat validation_issues.txt # for debugging mv validation_issues.txt ../ # Move the file up one directory level From 30f714730d02b1d27699083cbcded94af121f5cc Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:09:14 +1000 Subject: [PATCH 20/66] x --- .github/workflows/validate-frontmatter-all.yml | 13 +------------ .../frontmatter-validator/frontmatter-validator.js | 13 +++++-------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 2eba66bb496..f93f7133838 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -31,16 +31,6 @@ jobs: echo "Found Markdown files:" cat all_rules_files.txt - - name: Check if File List is Created - run: | - if [ -f all_rules_files.txt ]; then - echo "all_rules_files.txt exists. Contents:" - cat all_rules_files.txt - else - echo "all_rules_files.txt does not exist." - exit 1 - fi - - name: Install dependencies run: | cd scripts/frontmatter-validator @@ -48,10 +38,9 @@ jobs: - name: Validate Frontmatter in Rule Files run: | - node scripts/frontmatter-validator/frontmatter-validator.js --file ../../all_rules_files.txt > ../../validation_issues.txt + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_issues.txt echo "Validation complete. Contents of validation_issues.txt:" cat validation_issues.txt # for debugging - mv validation_issues.txt ../ # Move the file up one directory level - name: Create Job Summary run: | diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index e0343224957..2b793d8e12f 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -4,14 +4,10 @@ const yaml = require('js-yaml'); const addFormats = require('ajv-formats'); const ajvErrors = require('ajv-errors'); -const args = process.argv.slice(2); -const isFileInput = args.includes('--file'); -const basePath = ''; - const schemas = { - rule: loadSchema(basePath + 'schema/rule-schema.json'), - category: loadSchema(basePath + 'schema/category-schema.json'), - top_category: loadSchema(basePath + 'schema/top-category-schema.json'), + rule: loadSchema('schema/rule-schema.json'), + category: loadSchema('schema/category-schema.json'), + top_category: loadSchema('schema/top-category-schema.json'), }; const validator = initializeValidator(); @@ -29,7 +25,8 @@ function initializeValidator() { } function loadSchema(schemaPath) { - return JSON.parse(fs.readFileSync(schemaPath, 'utf8')); + const fullPath = `scripts/frontmatter-validator/${schemaPath}`; // Correct the path + return JSON.parse(fs.readFileSync(fullPath, 'utf8')); } function matchSchema(filePath) { From babc2d4c70cbddab09c1bcac254a35fc54a9c19b Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:12:15 +1000 Subject: [PATCH 21/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 2b793d8e12f..c2a674890e9 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -46,7 +46,7 @@ function validateFrontmatter(filePath) { if (!fs.existsSync(filePath)) { console.error(`File ${filePath} does not exist.`); - return + return []; // Return an empty array } const fileContents = fs.readFileSync(filePath, 'utf8'); @@ -95,7 +95,7 @@ function validateFiles(fileListPath) { filePaths .filter(file => file.endsWith('.md')) - .map(file => `../../${file}`) // Adjust the path as necessary + .map(file => `${file}`) // Adjust the path as necessary .forEach(filePath => { const fileErrors = validateFrontmatter(filePath.trim()); if (fileErrors.length > 0) { From 5d66f49a6c03b425d9df915982634a2ee7f8b665 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:15:31 +1000 Subject: [PATCH 22/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index c2a674890e9..0206053cb31 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -40,15 +40,15 @@ function matchSchema(filePath) { } function validateFrontmatter(filePath) { - if (filePath.indexOf('.github') !== -1) { - return - } - if (!fs.existsSync(filePath)) { console.error(`File ${filePath} does not exist.`); return []; // Return an empty array } + if (filePath.indexOf('.github') !== -1) { + return [] + } + const fileContents = fs.readFileSync(filePath, 'utf8'); const frontmatter = parseFrontmatter(filePath, fileContents); From 0c8a55b22b576bf1a1ba51684eeab0a2ea9c4f63 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:16:42 +1000 Subject: [PATCH 23/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 0206053cb31..9e03ad933ae 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -49,6 +49,7 @@ function validateFrontmatter(filePath) { return [] } + console.log(filePath); const fileContents = fs.readFileSync(filePath, 'utf8'); const frontmatter = parseFrontmatter(filePath, fileContents); From 8a2f70cd26d58efe9e1686d69fb5214be320f4d8 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:19:05 +1000 Subject: [PATCH 24/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 9e03ad933ae..030b399bc12 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -26,7 +26,9 @@ function initializeValidator() { function loadSchema(schemaPath) { const fullPath = `scripts/frontmatter-validator/${schemaPath}`; // Correct the path - return JSON.parse(fs.readFileSync(fullPath, 'utf8')); + const json = JSON.parse(fs.readFileSync(fullPath, 'utf8')) + console.log(json); + return json; } function matchSchema(filePath) { @@ -90,8 +92,10 @@ function parseFrontmatter(filePath, fileContents) { } function validateFiles(fileListPath) { + console.log(fileListPath, "File Found"); const fileContents = fs.readFileSync(fileListPath, 'utf8'); const filePaths = fileContents.trim().split('\n'); + console.log(filePaths); let allErrors = []; filePaths From f1db8c43bcf861617ec97047054d798b15535e1f Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:21:00 +1000 Subject: [PATCH 25/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 030b399bc12..4d56466b5cd 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -116,9 +116,11 @@ function main() { const args = process.argv.slice(2); let allErrors = []; + console.log(args, "MAIN"); if (args.includes('--file')) { const fileListIndex = args.indexOf('--file') + 1; const fileListPath = args[fileListIndex]; + console.log(fileListPath, "MAIN"); allErrors = validateFiles(fileListPath); } else { const filesChanged = args[0]; From c8ce77dccadf6ce32098262ef8c981b31796efd3 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:23:28 +1000 Subject: [PATCH 26/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 4d56466b5cd..ac6cd9b7ffc 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -116,11 +116,11 @@ function main() { const args = process.argv.slice(2); let allErrors = []; - console.log(args, "MAIN"); + console.error(args, "MAIN"); if (args.includes('--file')) { const fileListIndex = args.indexOf('--file') + 1; const fileListPath = args[fileListIndex]; - console.log(fileListPath, "MAIN"); + console.error(fileListPath, "MAIN"); allErrors = validateFiles(fileListPath); } else { const filesChanged = args[0]; From 2da095a5e37af8e6b67fe6e2de95413930581a20 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:26:47 +1000 Subject: [PATCH 27/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index ac6cd9b7ffc..bff4392cc99 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -51,13 +51,13 @@ function validateFrontmatter(filePath) { return [] } - console.log(filePath); + console.error(filePath); const fileContents = fs.readFileSync(filePath, 'utf8'); const frontmatter = parseFrontmatter(filePath, fileContents); const validate = matchSchema(filePath); const isValid = validate(frontmatter); - + console.error(isValid, "VALIDATE"); if (!isValid && validate.errors) { const errorList = validate.errors.filter(error => { return error.keyword === 'errorMessage' || error.keyword === 'required' @@ -92,10 +92,10 @@ function parseFrontmatter(filePath, fileContents) { } function validateFiles(fileListPath) { - console.log(fileListPath, "File Found"); + console.error(fileListPath, "File Found"); const fileContents = fs.readFileSync(fileListPath, 'utf8'); const filePaths = fileContents.trim().split('\n'); - console.log(filePaths); + console.error(filePaths); let allErrors = []; filePaths From a4bf177b9cd8e0b34c5184ba541449c5e3157cff Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:30:39 +1000 Subject: [PATCH 28/66] x --- .github/workflows/validate-frontmatter-all.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index f93f7133838..7ba7cd064c5 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -37,15 +37,14 @@ jobs: npm install - name: Validate Frontmatter in Rule Files + id: validate_frontmatter # Adding an ID to this step run: | - node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_issues.txt - echo "Validation complete. Contents of validation_issues.txt:" - cat validation_issues.txt # for debugging + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt - name: Create Job Summary run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - if [ -f validation_issues.txt ]; then + if [ -s validation_issues.txt ]; then # Check if file is not empty cat validation_issues.txt >> $GITHUB_STEP_SUMMARY else echo "No validation issues file found or no issues detected." >> $GITHUB_STEP_SUMMARY From 88cc1eea0f943e2864765681f56c265ad233df9e Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:36:35 +1000 Subject: [PATCH 29/66] x --- .github/workflows/validate-frontmatter-all.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 7ba7cd064c5..f2f01abe58c 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -41,11 +41,14 @@ jobs: run: | node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt - - name: Create Job Summary + - name: Create Job Summary with errors + if: failure() run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - if [ -s validation_issues.txt ]; then # Check if file is not empty - cat validation_issues.txt >> $GITHUB_STEP_SUMMARY - else - echo "No validation issues file found or no issues detected." >> $GITHUB_STEP_SUMMARY - fi \ No newline at end of file + echo "${{ steps.validate_frontmatter.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY + + - name: Create Job Summary with no errors + if: success() + run: | + echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY + echo "No validation issues file found or no issues detected." >> $GITHUB_STEP_SUMMARY \ No newline at end of file From 7db5462aef5cec21e73bebc73fb369524b0dcfc9 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:39:50 +1000 Subject: [PATCH 30/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index bff4392cc99..5375c4971dc 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -27,7 +27,6 @@ function initializeValidator() { function loadSchema(schemaPath) { const fullPath = `scripts/frontmatter-validator/${schemaPath}`; // Correct the path const json = JSON.parse(fs.readFileSync(fullPath, 'utf8')) - console.log(json); return json; } @@ -43,7 +42,6 @@ function matchSchema(filePath) { function validateFrontmatter(filePath) { if (!fs.existsSync(filePath)) { - console.error(`File ${filePath} does not exist.`); return []; // Return an empty array } @@ -51,13 +49,11 @@ function validateFrontmatter(filePath) { return [] } - console.error(filePath); const fileContents = fs.readFileSync(filePath, 'utf8'); const frontmatter = parseFrontmatter(filePath, fileContents); const validate = matchSchema(filePath); const isValid = validate(frontmatter); - console.error(isValid, "VALIDATE"); if (!isValid && validate.errors) { const errorList = validate.errors.filter(error => { return error.keyword === 'errorMessage' || error.keyword === 'required' @@ -92,10 +88,8 @@ function parseFrontmatter(filePath, fileContents) { } function validateFiles(fileListPath) { - console.error(fileListPath, "File Found"); const fileContents = fs.readFileSync(fileListPath, 'utf8'); const filePaths = fileContents.trim().split('\n'); - console.error(filePaths); let allErrors = []; filePaths @@ -116,11 +110,9 @@ function main() { const args = process.argv.slice(2); let allErrors = []; - console.error(args, "MAIN"); if (args.includes('--file')) { const fileListIndex = args.indexOf('--file') + 1; const fileListPath = args[fileListIndex]; - console.error(fileListPath, "MAIN"); allErrors = validateFiles(fileListPath); } else { const filesChanged = args[0]; @@ -139,6 +131,7 @@ function main() { } } + console.error(allErrors, "ERRORS"); if (allErrors.length > 0) { allErrors.forEach(error => console.log(error)); process.exit(1); From 78d57e383fb93048c5e811461fa612c1b0aa6dd9 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:44:44 +1000 Subject: [PATCH 31/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 5375c4971dc..c21d728e57e 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -83,7 +83,6 @@ function parseFrontmatter(filePath, fileContents) { return frontmatter; } catch (error) { console.log(`Invalid Frontmatter detected in ${filePath.replaceAll('../', '')}: missing '---'`); - process.exit(1); } } From 139821e5ab34ad082903534b2115a2ef157a31e7 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:50:29 +1000 Subject: [PATCH 32/66] x --- .github/workflows/validate-frontmatter-all.yml | 3 ++- scripts/frontmatter-validator/frontmatter-validator.js | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index f2f01abe58c..d721e4778d6 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,7 +39,8 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter # Adding an ID to this step run: | - node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt + output=$(node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt) + echo "::set-output name=result::$output" - name: Create Job Summary with errors if: failure() diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index c21d728e57e..cacd70887c1 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -130,7 +130,6 @@ function main() { } } - console.error(allErrors, "ERRORS"); if (allErrors.length > 0) { allErrors.forEach(error => console.log(error)); process.exit(1); From b30955e7dfa7badf6ac1248bafbc79b9e4e7e63b Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:54:07 +1000 Subject: [PATCH 33/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index cacd70887c1..6bcd689ce07 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -131,7 +131,7 @@ function main() { } if (allErrors.length > 0) { - allErrors.forEach(error => console.log(error)); + allErrors.forEach(error => console.error(error)); process.exit(1); } } From a508438d2a64c8bf92adfbcd2c76dcc92706c5e8 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:00:39 +1000 Subject: [PATCH 34/66] x --- .github/workflows/validate-frontmatter-all.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index d721e4778d6..f2f01abe58c 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,8 +39,7 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter # Adding an ID to this step run: | - output=$(node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt) - echo "::set-output name=result::$output" + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt - name: Create Job Summary with errors if: failure() From ab67e324e81a82407ccd7623f96af9489a1c81be Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:04:48 +1000 Subject: [PATCH 35/66] x --- .github/workflows/validate-frontmatter-all.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index f2f01abe58c..2906bcf54a7 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -37,9 +37,10 @@ jobs: npm install - name: Validate Frontmatter in Rule Files - id: validate_frontmatter # Adding an ID to this step + id: validate_frontmatter run: | - node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_results.txt + echo "::set-output name=results::$(cat validation_results.txt)" - name: Create Job Summary with errors if: failure() From 14174e048f31e7f59a351aaa38a7f19db6545ea9 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:06:48 +1000 Subject: [PATCH 36/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 6bcd689ce07..cacd70887c1 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -131,7 +131,7 @@ function main() { } if (allErrors.length > 0) { - allErrors.forEach(error => console.error(error)); + allErrors.forEach(error => console.log(error)); process.exit(1); } } From 45d13ee9b73862b2593112607c87a1a4690d15c0 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:09:03 +1000 Subject: [PATCH 37/66] x --- .github/workflows/validate-frontmatter-all.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 2906bcf54a7..50b240ed92d 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,8 +39,7 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter run: | - node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_results.txt - echo "::set-output name=results::$(cat validation_results.txt)" + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt - name: Create Job Summary with errors if: failure() From 09b3e704c68a92f6e90394918b52ae93fb7a5fb4 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:13:47 +1000 Subject: [PATCH 38/66] x --- .github/workflows/validate-frontmatter-all.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 50b240ed92d..466d018dfb0 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,14 +39,15 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter run: | - node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt + result=$(node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt) + echo "validation_results=${result}" >> $GITHUB_OUTPUT - name: Create Job Summary with errors if: failure() run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - echo "${{ steps.validate_frontmatter.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY - + echo "${{ steps.validate_frontmatter.outputs.validation_results }}" >> $GITHUB_STEP_SUMMARY + - name: Create Job Summary with no errors if: success() run: | From 05a250f7f60b2be3781eac0631cd62119fab3948 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:17:12 +1000 Subject: [PATCH 39/66] x --- .github/workflows/validate-frontmatter-all.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 466d018dfb0..a382f29676a 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,14 +39,13 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter run: | - result=$(node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt) - echo "validation_results=${result}" >> $GITHUB_OUTPUT + echo node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt >> "$GITHUB_OUTPUT" - name: Create Job Summary with errors if: failure() run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - echo "${{ steps.validate_frontmatter.outputs.validation_results }}" >> $GITHUB_STEP_SUMMARY + echo "${{ steps.validate_frontmatter.outputs }}" >> $GITHUB_STEP_SUMMARY - name: Create Job Summary with no errors if: success() From 6f3b6a06e28545a9068076c2b16741cb06bab7f5 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:21:40 +1000 Subject: [PATCH 40/66] x --- .github/workflows/validate-frontmatter-all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index a382f29676a..24fa955732c 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -45,7 +45,7 @@ jobs: if: failure() run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - echo "${{ steps.validate_frontmatter.outputs }}" >> $GITHUB_STEP_SUMMARY + echo "${{ steps.validate_frontmatter.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY - name: Create Job Summary with no errors if: success() From b5f878ef65f71244e094ad25b4f56b6b54884458 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:23:51 +1000 Subject: [PATCH 41/66] x --- .github/workflows/validate-frontmatter-all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 24fa955732c..a271ce48da9 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,7 +39,7 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter run: | - echo node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt >> "$GITHUB_OUTPUT" + echo node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt >> $GITHUB_OUTPUT - name: Create Job Summary with errors if: failure() From a8a9cd39197c8efa655f6037772ddfe39ed27314 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:28:30 +1000 Subject: [PATCH 42/66] x --- .github/workflows/validate-frontmatter-all.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index a271ce48da9..8fc610992af 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,13 +39,14 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter run: | - echo node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt >> $GITHUB_OUTPUT + output=$(node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt) + echo "::set-output name=results::$output" - name: Create Job Summary with errors if: failure() run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - echo "${{ steps.validate_frontmatter.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY + echo "${{ steps.validate_frontmatter.outputs.results }}" >> $GITHUB_STEP_SUMMARY - name: Create Job Summary with no errors if: success() From 013b4db0ff07fb3af28613855d0dca4fe3c02608 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:30:49 +1000 Subject: [PATCH 43/66] x --- .github/workflows/validate-frontmatter-all.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 8fc610992af..281babfa9c0 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,14 +39,16 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter run: | - output=$(node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt) - echo "::set-output name=results::$output" + echo "results<> $GITHUB_ENV + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt + echo "EOF" >> $GITHUB_ENV - name: Create Job Summary with errors if: failure() run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - echo "${{ steps.validate_frontmatter.outputs.results }}" >> $GITHUB_STEP_SUMMARY + echo "${{ env.results }}" >> $GITHUB_STEP_SUMMARY + - name: Create Job Summary with no errors if: success() From d06485d8ee06781683ec06e87f0bfc206dfe8ee4 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:34:54 +1000 Subject: [PATCH 44/66] x --- .../workflows/validate-frontmatter-all.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 281babfa9c0..7c245b609ee 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -40,18 +40,15 @@ jobs: id: validate_frontmatter run: | echo "results<> $GITHUB_ENV - node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt || true echo "EOF" >> $GITHUB_ENV - name: Create Job Summary with errors - if: failure() + if: always() run: | - echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - echo "${{ env.results }}" >> $GITHUB_STEP_SUMMARY - - - - name: Create Job Summary with no errors - if: success() - run: | - echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY - echo "No validation issues file found or no issues detected." >> $GITHUB_STEP_SUMMARY \ No newline at end of file + if [ -s validation_results.txt ]; then + echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY + cat validation_results.txt >> $GITHUB_STEP_SUMMARY + else + echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY + echo "No validation issues detected." >> $GITHUB_STEP_SUMMARY From 23f2b775b409c0478331bb9825bd0fff63a48238 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:37:01 +1000 Subject: [PATCH 45/66] x --- .github/workflows/validate-frontmatter-all.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 7c245b609ee..b0271f4bf74 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -46,9 +46,10 @@ jobs: - name: Create Job Summary with errors if: always() run: | + echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY if [ -s validation_results.txt ]; then - echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY cat validation_results.txt >> $GITHUB_STEP_SUMMARY else - echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY echo "No validation issues detected." >> $GITHUB_STEP_SUMMARY + fi + From 6dc70212f4eafe2f8d74dfefad1ce37f4215a754 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:40:08 +1000 Subject: [PATCH 46/66] x --- .github/workflows/validate-frontmatter-all.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index b0271f4bf74..e4dc8084a72 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,17 +39,14 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter run: | - echo "results<> $GITHUB_ENV - node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt || true - echo "EOF" >> $GITHUB_ENV + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_results.txt || true - name: Create Job Summary with errors if: always() run: | - echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY if [ -s validation_results.txt ]; then + echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY cat validation_results.txt >> $GITHUB_STEP_SUMMARY else + echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY echo "No validation issues detected." >> $GITHUB_STEP_SUMMARY - fi - From 494564d899cb43b60fc1dc4e7a3760fbfc99a2ee Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:42:50 +1000 Subject: [PATCH 47/66] x --- .github/workflows/validate-frontmatter-all.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index e4dc8084a72..634d6e67257 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -44,9 +44,10 @@ jobs: - name: Create Job Summary with errors if: always() run: | + echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY if [ -s validation_results.txt ]; then - echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY cat validation_results.txt >> $GITHUB_STEP_SUMMARY else - echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY echo "No validation issues detected." >> $GITHUB_STEP_SUMMARY + fi + From 79d96359f44a8c6d227a83d7ab980511654e6cfa Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:52:43 +1000 Subject: [PATCH 48/66] x --- .../frontmatter-validator.js | 104 ++++++++++-------- 1 file changed, 61 insertions(+), 43 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index cacd70887c1..2d8b1fab57a 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -1,13 +1,13 @@ -const fs = require('fs'); -const ajv = require('ajv'); -const yaml = require('js-yaml'); -const addFormats = require('ajv-formats'); -const ajvErrors = require('ajv-errors'); +const fs = require("fs"); +const ajv = require("ajv"); +const yaml = require("js-yaml"); +const addFormats = require("ajv-formats"); +const ajvErrors = require("ajv-errors"); const schemas = { - rule: loadSchema('schema/rule-schema.json'), - category: loadSchema('schema/category-schema.json'), - top_category: loadSchema('schema/top-category-schema.json'), + rule: loadSchema("schema/rule-schema.json"), + category: loadSchema("schema/category-schema.json"), + top_category: loadSchema("schema/top-category-schema.json"), }; const validator = initializeValidator(); @@ -26,17 +26,23 @@ function initializeValidator() { function loadSchema(schemaPath) { const fullPath = `scripts/frontmatter-validator/${schemaPath}`; // Correct the path - const json = JSON.parse(fs.readFileSync(fullPath, 'utf8')) + const json = JSON.parse(fs.readFileSync(fullPath, "utf8")); return json; } function matchSchema(filePath) { - if (filePath.endsWith('rule.md')) { - return validator.getSchema('rule'); - } else if (filePath.indexOf('/categories') !== -1 && !filePath.endsWith('index.md')) { - return validator.getSchema('category'); - } else if (filePath.indexOf('/categories') !== -1 && filePath.endsWith('index.md')) { - return validator.getSchema('top_category'); + if (filePath.endsWith("rule.md")) { + return validator.getSchema("rule"); + } else if ( + filePath.indexOf("/categories") !== -1 && + !filePath.endsWith("index.md") + ) { + return validator.getSchema("category"); + } else if ( + filePath.indexOf("/categories") !== -1 && + filePath.endsWith("index.md") + ) { + return validator.getSchema("top_category"); } } @@ -45,34 +51,34 @@ function validateFrontmatter(filePath) { return []; // Return an empty array } - if (filePath.indexOf('.github') !== -1) { - return [] + if (filePath.indexOf(".github") !== -1) { + return []; } - const fileContents = fs.readFileSync(filePath, 'utf8'); + const fileContents = fs.readFileSync(filePath, "utf8"); const frontmatter = parseFrontmatter(filePath, fileContents); const validate = matchSchema(filePath); const isValid = validate(frontmatter); + if (!isValid && validate.errors) { - const errorList = validate.errors.filter(error => { - return error.keyword === 'errorMessage' || error.keyword === 'required' + let fileErrors = []; + validate.errors.forEach(error => { + if (error.keyword === 'errorMessage' || error.keyword === 'required') { + fileErrors.push(error.message); + } }); - if (errorList.length >= 1) { - const errors = [`Invalid Frontmatter detected in ${filePath.replaceAll('../', '')}, please fix the following issues:`]; - errorList.forEach((error, index) => { - errors.push(`${index + 1}. ${error.message}`); - }); - return errors; // Return the list of errors + if (fileErrors.length > 0) { + allErrors.push({ filePath, fileErrors }); } } - return []; // Return an empty array if there are no errors + return []; } function parseFrontmatter(filePath, fileContents) { - if (!fileContents) return {} + if (!fileContents) return {}; try { const frontmatterMatch = /^---([\s\S]*?)---/.exec(fileContents); @@ -82,19 +88,24 @@ function parseFrontmatter(filePath, fileContents) { }); return frontmatter; } catch (error) { - console.log(`Invalid Frontmatter detected in ${filePath.replaceAll('../', '')}: missing '---'`); + console.log( + `Invalid Frontmatter detected in ${filePath.replaceAll( + "../", + "" + )}: missing '---'` + ); } } function validateFiles(fileListPath) { - const fileContents = fs.readFileSync(fileListPath, 'utf8'); - const filePaths = fileContents.trim().split('\n'); + const fileContents = fs.readFileSync(fileListPath, "utf8"); + const filePaths = fileContents.trim().split("\n"); let allErrors = []; filePaths - .filter(file => file.endsWith('.md')) - .map(file => `${file}`) // Adjust the path as necessary - .forEach(filePath => { + .filter((file) => file.endsWith(".md")) + .map((file) => `${file}`) // Adjust the path as necessary + .forEach((filePath) => { const fileErrors = validateFrontmatter(filePath.trim()); if (fileErrors.length > 0) { allErrors = allErrors.concat(fileErrors); @@ -104,24 +115,23 @@ function validateFiles(fileListPath) { return allErrors; } - function main() { const args = process.argv.slice(2); let allErrors = []; - if (args.includes('--file')) { - const fileListIndex = args.indexOf('--file') + 1; + if (args.includes("--file")) { + const fileListIndex = args.indexOf("--file") + 1; const fileListPath = args[fileListIndex]; allErrors = validateFiles(fileListPath); } else { const filesChanged = args[0]; if (filesChanged) { const folders = filesChanged - .split(',') - .filter(file => file.endsWith('.md')) - .map(file => `../../${file}`); + .split(",") + .filter((file) => file.endsWith(".md")) + .map((file) => `../../${file}`); - folders.forEach(file => { + folders.forEach((file) => { const fileErrors = validateFrontmatter(file); if (fileErrors.length > 0) { allErrors = allErrors.concat(fileErrors); @@ -131,10 +141,18 @@ function main() { } if (allErrors.length > 0) { - allErrors.forEach(error => console.log(error)); + console.log("Invalid Frontmatter Detected!\n"); + allErrors.forEach(({ filePath, fileErrors }) => { + console.log(`<${filePath}>\n`); + console.log("| Issue |"); + console.log("| ----- |"); + fileErrors.forEach((issue) => { + console.log(`| ${issue} |`); + }); + console.log("\n"); // New line for spacing between entries + }); process.exit(1); } } - main(); From e295f4565da098057c574a9436213ccd02569b81 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:55:40 +1000 Subject: [PATCH 49/66] x --- .../frontmatter-validator.js | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 2d8b1fab57a..c82f4441ae9 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -140,19 +140,21 @@ function main() { } } - if (allErrors.length > 0) { - console.log("Invalid Frontmatter Detected!\n"); - allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`<${filePath}>\n`); - console.log("| Issue |"); - console.log("| ----- |"); - fileErrors.forEach((issue) => { - console.log(`| ${issue} |`); - }); - console.log("\n"); // New line for spacing between entries - }); - process.exit(1); + if (!(allErrors.length > 0)) { + return; } + + console.log("Invalid Frontmatter Detected!\n"); + allErrors.forEach(({ filePath, fileErrors }) => { + console.log(`<${filePath}>\n`); + console.log("| Issue |"); + console.log("| ----- |"); + fileErrors.forEach((issue) => { + console.log(`| ${issue} |`); + }); + console.log("\n"); // New line for spacing between entries + }); + process.exit(1); } main(); From 47273755bb24c91c3ad678cae538f34f64d3dd47 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:56:50 +1000 Subject: [PATCH 50/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index c82f4441ae9..4ed9630db1d 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -70,7 +70,7 @@ function validateFrontmatter(filePath) { }); if (fileErrors.length > 0) { - allErrors.push({ filePath, fileErrors }); + fileErrors.push({ filePath, fileErrors }); } } @@ -143,7 +143,7 @@ function main() { if (!(allErrors.length > 0)) { return; } - + console.log("Invalid Frontmatter Detected!\n"); allErrors.forEach(({ filePath, fileErrors }) => { console.log(`<${filePath}>\n`); From 7ff321fb94b711640fdf76b61f64454a50db67a2 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:01:29 +1000 Subject: [PATCH 51/66] x --- .../frontmatter-validator.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 4ed9630db1d..2eccb1045d2 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -4,6 +4,8 @@ const yaml = require("js-yaml"); const addFormats = require("ajv-formats"); const ajvErrors = require("ajv-errors"); +let allErrors = []; + const schemas = { rule: loadSchema("schema/rule-schema.json"), category: loadSchema("schema/category-schema.json"), @@ -62,21 +64,19 @@ function validateFrontmatter(filePath) { const isValid = validate(frontmatter); if (!isValid && validate.errors) { - let fileErrors = []; - validate.errors.forEach(error => { - if (error.keyword === 'errorMessage' || error.keyword === 'required') { - fileErrors.push(error.message); - } - }); + let fileErrors = validate.errors + .filter(error => error.keyword === 'errorMessage' || error.keyword === 'required') + .map(error => error.message); if (fileErrors.length > 0) { - fileErrors.push({ filePath, fileErrors }); + allErrors.push({ filePath, fileErrors }); // Correctly add to allErrors } } - return []; + return []; // Return an empty array if there are no errors } + function parseFrontmatter(filePath, fileContents) { if (!fileContents) return {}; @@ -117,7 +117,6 @@ function validateFiles(fileListPath) { function main() { const args = process.argv.slice(2); - let allErrors = []; if (args.includes("--file")) { const fileListIndex = args.indexOf("--file") + 1; From e206cf03b54b2795d761bcceaa32c496489979d8 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:07:21 +1000 Subject: [PATCH 52/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 2eccb1045d2..afdf58d7b48 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -139,7 +139,7 @@ function main() { } } - if (!(allErrors.length > 0)) { + if (allErrors.length <= 0) { return; } From a1f3cdcd2ebe7589793ceaa5f567d14f5dd5470a Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:11:22 +1000 Subject: [PATCH 53/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index afdf58d7b48..7c2a5ca86bc 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -140,6 +140,7 @@ function main() { } if (allErrors.length <= 0) { + console.log("No frontmatter validation errors found."); return; } From 6aac6d9eda4060d54a8aade76ec02bc23d281080 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:14:07 +1000 Subject: [PATCH 54/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 7c2a5ca86bc..881a9364b14 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -4,7 +4,7 @@ const yaml = require("js-yaml"); const addFormats = require("ajv-formats"); const ajvErrors = require("ajv-errors"); -let allErrors = []; +const allErrors = []; const schemas = { rule: loadSchema("schema/rule-schema.json"), From 4e30123d42d557caa53ad06c0df3830ee69c8230 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:22:56 +1000 Subject: [PATCH 55/66] x --- .../frontmatter-validator.js | 66 +++++++------------ 1 file changed, 23 insertions(+), 43 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 881a9364b14..51e6e74dc51 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -4,7 +4,7 @@ const yaml = require("js-yaml"); const addFormats = require("ajv-formats"); const ajvErrors = require("ajv-errors"); -const allErrors = []; +let allErrors = []; const schemas = { rule: loadSchema("schema/rule-schema.json"), @@ -49,34 +49,29 @@ function matchSchema(filePath) { } function validateFrontmatter(filePath) { - if (!fs.existsSync(filePath)) { - return []; // Return an empty array - } - - if (filePath.indexOf(".github") !== -1) { - return []; + if (!fs.existsSync(filePath) || filePath.indexOf(".github") !== -1) { + return; // Skip if file does not exist or is in .github directory } const fileContents = fs.readFileSync(filePath, "utf8"); const frontmatter = parseFrontmatter(filePath, fileContents); - const validate = matchSchema(filePath); const isValid = validate(frontmatter); - + if (!isValid && validate.errors) { let fileErrors = validate.errors - .filter(error => error.keyword === 'errorMessage' || error.keyword === 'required') - .map(error => error.message); + .filter( + (error) => + error.keyword === "errorMessage" || error.keyword === "required" + ) + .map((error) => error.message); if (fileErrors.length > 0) { - allErrors.push({ filePath, fileErrors }); // Correctly add to allErrors + allErrors.push({ filePath, fileErrors }); // Add errors directly to allErrors } } - - return []; // Return an empty array if there are no errors } - function parseFrontmatter(filePath, fileContents) { if (!fileContents) return {}; @@ -100,19 +95,12 @@ function parseFrontmatter(filePath, fileContents) { function validateFiles(fileListPath) { const fileContents = fs.readFileSync(fileListPath, "utf8"); const filePaths = fileContents.trim().split("\n"); - let allErrors = []; - - filePaths - .filter((file) => file.endsWith(".md")) - .map((file) => `${file}`) // Adjust the path as necessary - .forEach((filePath) => { - const fileErrors = validateFrontmatter(filePath.trim()); - if (fileErrors.length > 0) { - allErrors = allErrors.concat(fileErrors); - } - }); - return allErrors; + filePaths.forEach((file) => { + if (file.endsWith(".md")) { + validateFrontmatter(file); // Call validateFrontmatter for each file + } + }); } function main() { @@ -121,40 +109,32 @@ function main() { if (args.includes("--file")) { const fileListIndex = args.indexOf("--file") + 1; const fileListPath = args[fileListIndex]; - allErrors = validateFiles(fileListPath); + validateFiles(fileListPath); // Validate files listed in the file } else { const filesChanged = args[0]; if (filesChanged) { - const folders = filesChanged + const filePaths = filesChanged .split(",") .filter((file) => file.endsWith(".md")) .map((file) => `../../${file}`); - - folders.forEach((file) => { - const fileErrors = validateFrontmatter(file); - if (fileErrors.length > 0) { - allErrors = allErrors.concat(fileErrors); - } - }); + filePaths.forEach(validateFrontmatter); // Validate each changed file } } - if (allErrors.length <= 0) { + if (allErrors.length === 0) { console.log("No frontmatter validation errors found."); return; } console.log("Invalid Frontmatter Detected!\n"); allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`<${filePath}>\n`); + console.log(`### ${filePath}\n`); // Use markdown heading for the file path console.log("| Issue |"); console.log("| ----- |"); - fileErrors.forEach((issue) => { - console.log(`| ${issue} |`); - }); - console.log("\n"); // New line for spacing between entries + fileErrors.forEach((issue) => console.log(`| ${issue} |`)); + console.log("\n"); // New line for spacing between tables }); - process.exit(1); + process.exit(1); // Exit with error if there are any validation issues } main(); From 53edb2b0a4d08f001f68b1127f7a7fe303e4d07b Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:29:48 +1000 Subject: [PATCH 56/66] x --- .../frontmatter-validator.js | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 51e6e74dc51..78ee877929e 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -27,7 +27,7 @@ function initializeValidator() { } function loadSchema(schemaPath) { - const fullPath = `scripts/frontmatter-validator/${schemaPath}`; // Correct the path + const fullPath = `scripts/frontmatter-validator/${schemaPath}`; // todo fix for non file input const json = JSON.parse(fs.readFileSync(fullPath, "utf8")); return json; } @@ -67,7 +67,7 @@ function validateFrontmatter(filePath) { .map((error) => error.message); if (fileErrors.length > 0) { - allErrors.push({ filePath, fileErrors }); // Add errors directly to allErrors + allErrors.push({ filePath, fileErrors }); } } } @@ -83,12 +83,10 @@ function parseFrontmatter(filePath, fileContents) { }); return frontmatter; } catch (error) { - console.log( - `Invalid Frontmatter detected in ${filePath.replaceAll( - "../", - "" - )}: missing '---'` - ); + allErrors.push({ + filePath, + fileErrors: ["missing '---'"], + }); } } @@ -98,7 +96,7 @@ function validateFiles(fileListPath) { filePaths.forEach((file) => { if (file.endsWith(".md")) { - validateFrontmatter(file); // Call validateFrontmatter for each file + validateFrontmatter(file); } }); } @@ -109,7 +107,7 @@ function main() { if (args.includes("--file")) { const fileListIndex = args.indexOf("--file") + 1; const fileListPath = args[fileListIndex]; - validateFiles(fileListPath); // Validate files listed in the file + validateFiles(fileListPath); } else { const filesChanged = args[0]; if (filesChanged) { @@ -117,7 +115,7 @@ function main() { .split(",") .filter((file) => file.endsWith(".md")) .map((file) => `../../${file}`); - filePaths.forEach(validateFrontmatter); // Validate each changed file + filePaths.forEach(validateFrontmatter); } } @@ -126,15 +124,14 @@ function main() { return; } - console.log("Invalid Frontmatter Detected!\n"); + console.log("### Invalid Frontmatter Detected!\n"); allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`### ${filePath}\n`); // Use markdown heading for the file path - console.log("| Issue |"); - console.log("| ----- |"); - fileErrors.forEach((issue) => console.log(`| ${issue} |`)); - console.log("\n"); // New line for spacing between tables + console.log(`#### Rule: ${filePath}\n`); + console.log("Issues:"); + fileErrors.forEach((issue) => console.log(`- ${issue}`)); + console.log("\n"); }); - process.exit(1); // Exit with error if there are any validation issues + process.exit(1); } main(); From 6b25397fa201e33766975dd8ae8b9f92cb283196 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:35:20 +1000 Subject: [PATCH 57/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 78ee877929e..d34f0d89e06 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -126,11 +126,13 @@ function main() { console.log("### Invalid Frontmatter Detected!\n"); allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`#### Rule: ${filePath}\n`); - console.log("Issues:"); - fileErrors.forEach((issue) => console.log(`- ${issue}`)); + console.log(`| Rule: ${filePath} |`); + console.log("| --- |"); + console.log("| **Issues** |"); + fileErrors.forEach((issue) => console.log(`| - ${issue} |`)); console.log("\n"); }); + process.exit(1); } From 1106019df6aaebc1c3d00b496a6d70044f8a49f0 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:37:20 +1000 Subject: [PATCH 58/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index d34f0d89e06..12f01d4317f 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -126,13 +126,12 @@ function main() { console.log("### Invalid Frontmatter Detected!\n"); allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`| Rule: ${filePath} |`); - console.log("| --- |"); - console.log("| **Issues** |"); - fileErrors.forEach((issue) => console.log(`| - ${issue} |`)); + console.log(`| Rule | filePath |`); + console.log("| --- | --- |"); + console.log(`| Issues: | |`); + fileErrors.forEach((issue) => console.log(`| | - ${issue} |`)); console.log("\n"); }); - process.exit(1); } From 7c9c1a9abddf8e0f0a387eec5f56612a71e08556 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:38:00 +1000 Subject: [PATCH 59/66] x --- .github/workflows/validate-frontmatter-all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 634d6e67257..1abeee89ae0 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -39,7 +39,7 @@ jobs: - name: Validate Frontmatter in Rule Files id: validate_frontmatter run: | - node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_results.txt || true + node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_results.txt - name: Create Job Summary with errors if: always() From 936593dca40df513968ff7d397563c6e11323a40 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:39:01 +1000 Subject: [PATCH 60/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 12f01d4317f..d2945579df9 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -126,7 +126,7 @@ function main() { console.log("### Invalid Frontmatter Detected!\n"); allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`| Rule | filePath |`); + console.log(`| Rule | ${filePath} |`); console.log("| --- | --- |"); console.log(`| Issues: | |`); fileErrors.forEach((issue) => console.log(`| | - ${issue} |`)); From e564c264a6fb4617646f9448123a1d97007ca5e3 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:42:27 +1000 Subject: [PATCH 61/66] x --- .../frontmatter-validator/frontmatter-validator.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index d2945579df9..872437ff5f8 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -126,12 +126,13 @@ function main() { console.log("### Invalid Frontmatter Detected!\n"); allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`| Rule | ${filePath} |`); - console.log("| --- | --- |"); - console.log(`| Issues: | |`); - fileErrors.forEach((issue) => console.log(`| | - ${issue} |`)); - console.log("\n"); + console.log(`#### Rule: ${filePath}\n`); + console.log("Issues:"); + fileErrors.forEach(issue => console.log(`- **${issue}**`)); + console.log("\n"); }); + process.exit(1); + process.exit(1); } From 77d2d78d8026b5f226d306a9251facac488ae6a5 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:44:37 +1000 Subject: [PATCH 62/66] x --- .../frontmatter-validator.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 872437ff5f8..81caeac7c7c 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -27,7 +27,13 @@ function initializeValidator() { } function loadSchema(schemaPath) { - const fullPath = `scripts/frontmatter-validator/${schemaPath}`; // todo fix for non file input + const args = process.argv.slice(2); + let fullPath = `scripts/frontmatter-validator/${schemaPath}`; + fullPath = args.includes("--file") + ? `scripts/frontmatter-validator/${schemaPath}` + : schemaPath; + + // todo fix for non file input const json = JSON.parse(fs.readFileSync(fullPath, "utf8")); return json; } @@ -126,13 +132,13 @@ function main() { console.log("### Invalid Frontmatter Detected!\n"); allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`#### Rule: ${filePath}\n`); - console.log("Issues:"); - fileErrors.forEach(issue => console.log(`- **${issue}**`)); - console.log("\n"); + console.log(`#### Rule: ${filePath}\n`); + console.log("Issues:"); + fileErrors.forEach((issue) => console.log(`- **${issue}**`)); + console.log("\n"); }); - process.exit(1); - + process.exit(1); + process.exit(1); } From 59191549a921904815c8c1a26e52cc1fd3902019 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:46:21 +1000 Subject: [PATCH 63/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 81caeac7c7c..eec654bf9f7 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -132,10 +132,12 @@ function main() { console.log("### Invalid Frontmatter Detected!\n"); allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`#### Rule: ${filePath}\n`); + console.log(`#### Rule: ${filePath}\n`); console.log("Issues:"); fileErrors.forEach((issue) => console.log(`- **${issue}**`)); console.log("\n"); + console.log('---') + console.log("\n"); }); process.exit(1); From 19d51110a48c91b6786d48438f803a92c5aebcb9 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:47:53 +1000 Subject: [PATCH 64/66] x --- scripts/frontmatter-validator/frontmatter-validator.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index eec654bf9f7..99f73a641b0 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -130,13 +130,12 @@ function main() { return; } - console.log("### Invalid Frontmatter Detected!\n"); + allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`#### Rule: ${filePath}\n`); + console.log(`## Rule: ${filePath}\n`); console.log("Issues:"); fileErrors.forEach((issue) => console.log(`- **${issue}**`)); console.log("\n"); - console.log('---') console.log("\n"); }); process.exit(1); From b24e926c31512787d42d9d9f10399dec32fea98f Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:51:23 +1000 Subject: [PATCH 65/66] x --- .github/workflows/validate-frontmatter-all.yml | 2 +- scripts/frontmatter-validator/frontmatter-validator.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 1abeee89ae0..4ce24646ace 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -41,7 +41,7 @@ jobs: run: | node scripts/frontmatter-validator/frontmatter-validator.js --file all_rules_files.txt > validation_results.txt - - name: Create Job Summary with errors + - name: Create Job Summary if: always() run: | echo "## Frontmatter Validation Issues" >> $GITHUB_STEP_SUMMARY diff --git a/scripts/frontmatter-validator/frontmatter-validator.js b/scripts/frontmatter-validator/frontmatter-validator.js index 99f73a641b0..ca220f19987 100644 --- a/scripts/frontmatter-validator/frontmatter-validator.js +++ b/scripts/frontmatter-validator/frontmatter-validator.js @@ -132,7 +132,7 @@ function main() { allErrors.forEach(({ filePath, fileErrors }) => { - console.log(`## Rule: ${filePath}\n`); + console.log(`## Rule: [${filePath}](https://github.com/SSWConsulting/SSW.Rules.Content/tree/main/${filePath})\n`); console.log("Issues:"); fileErrors.forEach((issue) => console.log(`- **${issue}**`)); console.log("\n"); From d9aeb6e6221b11e56e7029cc9569b515ee9078b4 Mon Sep 17 00:00:00 2001 From: "Jack Pettit [SSW]" <57518417+JackDevAU@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:53:38 +1000 Subject: [PATCH 66/66] x --- .github/workflows/validate-frontmatter-all.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/validate-frontmatter-all.yml b/.github/workflows/validate-frontmatter-all.yml index 4ce24646ace..774c954a059 100644 --- a/.github/workflows/validate-frontmatter-all.yml +++ b/.github/workflows/validate-frontmatter-all.yml @@ -3,10 +3,6 @@ name: Validate-Frontmatter-in-All-Rules on: push: branches: [main] - paths: - - 'rules/**/*.md' - pull_request: - branches: [main] workflow_dispatch: jobs: