diff --git a/dist/index.js b/dist/index.js index 452e6d1..ace70dd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -14180,6 +14180,7 @@ module.exports = { /* eslint-env node */ +const path = __webpack_require__(622); const core = __webpack_require__(470); const glob = __webpack_require__(281); const github = __webpack_require__(469); @@ -14214,11 +14215,14 @@ function getArrayInput(value) { } function parseFile(file) { - console.log("Parsing file:", file); + const relPath = path.relative(".", file); + console.log("Parsing file:", relPath); + const translation = po2json.parseFileSync(file); const language = translation[""].language.trim().toLowerCase(); const details = { language, + path: relPath, skipped: false, messageCount: 0, translatedMessageCount: 0, @@ -14229,9 +14233,9 @@ function parseFile(file) { (onlyLanguages.length > 0 && onlyLanguages.indexOf(language) === -1) || (ignoreLanguages.length > 0 && ignoreLanguages.indexOf(language) !== -1) ) { - console.log("Skipping file:", file); + console.log("Skipping file:", relPath); details.skipped = true; - details.summary = ` - "${file}" skipped`; + details.summary = ` - "${relPath}" skipped`; return details; } @@ -14245,7 +14249,7 @@ function parseFile(file) { (details.translatedMessageCount / details.messageCount) * 100 ).toFixed(2); - details.summary = ` - "${file}" translated ${details.coverage}% `; + details.summary = `${relPath} translated ${details.coverage}% `; details.summary += `(${details.translatedMessageCount} / ${details.messageCount} messages)`; console.log(details.summary); @@ -14255,13 +14259,14 @@ function parseFile(file) { async function main() { const globber = await glob.create(translationPath); - let allSummaries = []; + const perFileDetails = {}; let totalMessages = 0; let totalTranslatedMessages = 0; (await globber.glob()).forEach((file) => { const details = parseFile(file); - allSummaries.push(details.summary); + + perFileDetails[details.language] = details; totalMessages += details.messageCount; totalTranslatedMessages += details.translatedMessageCount; }); @@ -14299,7 +14304,20 @@ async function main() { output: { title: `${coverage.toFixed(0)}% i18n coverage.`, summary: summary + `, min-coverage: ${minCoverage}%`, - text: allSummaries.join("\n"), + text: Object.values(perFileDetails) + .map((details) => " - " + details.summary) + .join("\n"), + annotations: Object.values(perFileDetails) + .filter((details) => !details.skipped) + .map((details) => { + return { + path: details.path, + start_line: 0, + end_line: 0, + annotation_level: "notice", + message: details.summary, + }; + }), }, }); } diff --git a/package-lock.json b/package-lock.json index c84f52a..1a8c338 100644 --- a/package-lock.json +++ b/package-lock.json @@ -446,12 +446,6 @@ "strip-ansi": "~0.1.0" } }, - "chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true - }, "clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -521,12 +515,6 @@ } } }, - "cli-width": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", - "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==", - "dev": true - }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -660,9 +648,9 @@ "dev": true }, "eslint": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.2.0.tgz", - "integrity": "sha512-B3BtEyaDKC5MlfDa2Ha8/D6DsS4fju95zs0hjS3HdGazw+LNayai38A25qMppK37wWGWNYSPOR6oYzlz5MHsRQ==", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.3.0.tgz", + "integrity": "sha512-dJMVXwfU5PT1cj2Nv2VPPrKahKTGdX+5Dh0Q3YuKt+Y2UhdL2YbzsVaBMyG9HC0tBismlv/r1+eZqs6SMIV38Q==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -671,6 +659,7 @@ "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", + "enquirer": "^2.3.5", "eslint-scope": "^5.1.0", "eslint-utils": "^2.0.0", "eslint-visitor-keys": "^1.2.0", @@ -684,7 +673,6 @@ "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", @@ -923,17 +911,6 @@ "strip-eof": "^1.0.0" } }, - "external-editor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", - "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", - "dev": true, - "requires": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - } - }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1143,88 +1120,6 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "inquirer": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.2.0.tgz", - "integrity": "sha512-E0c4rPwr9ByePfNlTIB8z51kK1s2n6jrHuJeEHENl/sbq2G/S1auvibgEwNR4uSyiU+PiYHqSwsgGiXjG8p5ZQ==", - "dev": true, - "requires": { - "ansi-escapes": "^4.2.1", - "chalk": "^3.0.0", - "cli-cursor": "^3.1.0", - "cli-width": "^2.0.0", - "external-editor": "^3.0.3", - "figures": "^3.0.0", - "lodash": "^4.17.15", - "mute-stream": "0.0.8", - "run-async": "^2.4.0", - "rxjs": "^6.5.3", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -1753,12 +1648,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "mute-stream": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", - "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", - "dev": true - }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -1838,12 +1727,6 @@ "windows-release": "^3.1.0" } }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", @@ -1879,6 +1762,15 @@ "lines-and-columns": "^1.1.6" } }, + "path": { + "version": "0.12.7", + "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", + "requires": { + "process": "^0.11.1", + "util": "^0.10.3" + } + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -1947,6 +1839,11 @@ "fast-diff": "^1.1.2" } }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" + }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -2008,12 +1905,6 @@ "glob": "^7.1.3" } }, - "run-async": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", - "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", - "dev": true - }, "rxjs": { "version": "6.5.5", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.5.tgz", @@ -2231,15 +2122,6 @@ "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "~1.0.2" - } - }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -2303,6 +2185,21 @@ "punycode": "^2.1.0" } }, + "util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "requires": { + "inherits": "2.0.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + } + } + }, "v8-compile-cache": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", diff --git a/package.json b/package.json index 31fe3ef..bb12f02 100644 --- a/package.json +++ b/package.json @@ -40,12 +40,13 @@ "@actions/core": "^1.2.4", "@actions/github": "^3.0.0", "@actions/glob": "^0.1.0", + "path": "^0.12.7", "po2json": "^0.4.5" }, "devDependencies": { "@zeit/ncc": "^0.22.3", "babel-eslint": "^10.1.0", - "eslint": "^7.2.0", + "eslint": "^7.3.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-prettier": "^3.1.4", "lint-staged": "^10.2.11", diff --git a/src/index.js b/src/index.js index 2c7d4c4..9e82b3f 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ /* eslint-env node */ +const path = require("path"); const core = require("@actions/core"); const glob = require("@actions/glob"); const github = require("@actions/github"); @@ -34,11 +35,14 @@ function getArrayInput(value) { } function parseFile(file) { - console.log("Parsing file:", file); + const relPath = path.relative(".", file); + console.log("Parsing file:", relPath); + const translation = po2json.parseFileSync(file); const language = translation[""].language.trim().toLowerCase(); const details = { language, + path: relPath, skipped: false, messageCount: 0, translatedMessageCount: 0, @@ -49,9 +53,9 @@ function parseFile(file) { (onlyLanguages.length > 0 && onlyLanguages.indexOf(language) === -1) || (ignoreLanguages.length > 0 && ignoreLanguages.indexOf(language) !== -1) ) { - console.log("Skipping file:", file); + console.log("Skipping file:", relPath); details.skipped = true; - details.summary = ` - "${file}" skipped`; + details.summary = `${relPath} skipped`; return details; } @@ -65,7 +69,7 @@ function parseFile(file) { (details.translatedMessageCount / details.messageCount) * 100 ).toFixed(2); - details.summary = ` - "${file}" translated ${details.coverage}% `; + details.summary = `${relPath} translated ${details.coverage}% `; details.summary += `(${details.translatedMessageCount} / ${details.messageCount} messages)`; console.log(details.summary); @@ -75,13 +79,14 @@ function parseFile(file) { async function main() { const globber = await glob.create(translationPath); - let allSummaries = []; + const perFileDetails = {}; let totalMessages = 0; let totalTranslatedMessages = 0; (await globber.glob()).forEach((file) => { const details = parseFile(file); - allSummaries.push(details.summary); + + perFileDetails[details.language] = details; totalMessages += details.messageCount; totalTranslatedMessages += details.translatedMessageCount; }); @@ -119,7 +124,20 @@ async function main() { output: { title: `${coverage.toFixed(0)}% i18n coverage.`, summary: summary + `, min-coverage: ${minCoverage}%`, - text: allSummaries.join("\n"), + text: Object.values(perFileDetails) + .map((details) => " - " + details.summary) + .join("\n"), + annotations: Object.values(perFileDetails) + .filter((details) => !details.skipped) + .map((details) => { + return { + path: details.path, + start_line: 0, + end_line: 0, + annotation_level: "notice", + message: details.summary, + }; + }), }, }); } diff --git a/trigger.txt b/trigger.txt new file mode 100644 index 0000000..60fffd1 --- /dev/null +++ b/trigger.txt @@ -0,0 +1 @@ +date