From 2e5ae859b79076b2c8dccce8590b8e96f246019d Mon Sep 17 00:00:00 2001 From: Edd Date: Tue, 20 Aug 2024 13:05:57 +0100 Subject: [PATCH] fix: re enable csv output which is used in some repos --- package-lock.json | 4 ++-- package.json | 2 +- src/check-references.js | 50 ++++++++++++++++++++++++----------------- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd8115d..2d946bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@vegaprotocol/approbation", - "version": "4.9.2", + "version": "4.9.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@vegaprotocol/approbation", - "version": "4.9.2", + "version": "4.9.3", "license": "Unlicense", "dependencies": { "console-table-printer": "^2.12.1", diff --git a/package.json b/package.json index ddf6ccb..fd63d8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vegaprotocol/approbation", - "version": "4.9.2", + "version": "4.9.3", "description": "Match Acceptance Criteria Codes with the tests that test them", "engine": ">= 18", "bin": "./bin/approbation.js", diff --git a/src/check-references.js b/src/check-references.js index ba0c84e..c6758cc 100644 --- a/src/check-references.js +++ b/src/check-references.js @@ -321,28 +321,38 @@ function checkReferences(specsGlob, testsGlob, ignoreGlob, featuresPath, current console.log(tableOutput) } - if (!fs.existsSync(outputPath)) { - fs.mkdirSync(outputPath, { recursive: true }) - } + if (!fs.existsSync(outputPath)) { + fs.mkdirSync(outputPath, { recursive: true }) + } - let cm - // If current milestone is set by parameter, use it - if (currentMilestone) { - cm = totals.find(t => t.Milestone === currentMilestone) - } - // If not, use the most recent - if (!cm) { - cm = totals && totals.length > 0 ? totals.pop() : false - } - - let jenkinsLine = `Total ACs: ${criteriaTotal}, Referenced ACs: ${criteriaReferencedTotal}, Unreferenced ACs: ${criteriaUnreferencedTotal}, Coverage: ${criteriaReferencedPercent}%` - if (cm && cm.Milestone && cm.Coverage) { - jenkinsLine += `\r\nCurrent milestone ACs: *${cm.Milestone}*: ${cm.Coverage}` - } - - fs.writeFileSync(`${outputPath}/jenkins.txt`, jenkinsLine) + /* + * Output files + */ + let cm + // If current milestone is set by parameter, use it + if (currentMilestone) { + cm = totals.find(t => t.Milestone === currentMilestone) + } + // If not, use the most recent + if (!cm) { + cm = totals && totals.length > 0 ? totals.pop() : false + } + + let jenkinsLine = `Total ACs: ${criteriaTotal}, Referenced ACs: ${criteriaReferencedTotal}, Unreferenced ACs: ${criteriaUnreferencedTotal}, Coverage: ${criteriaReferencedPercent}%` + if (cm && cm.Milestone && cm.Coverage) { + jenkinsLine += `\r\nCurrent milestone ACs: *${cm.Milestone}*: ${cm.Coverage}` + } + + fs.writeFileSync(`${outputPath}/jenkins.txt`, jenkinsLine) - console.groupEnd() + + let csvOutputFiles = Object.keys(specsTableRows[0]).join(',') + specsTableRows.forEach(c => { + csvOutputFiles += `\r\n${Object.values(c).join(',')}` + }) + fs.writeFileSync(`${outputPath}/approbation-files.csv`, csvOutputFiles) + + console.groupEnd() return { exitCode,