From a369905535f4a57ed228a2818eb276d7d9bfeada Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Mon, 26 Oct 2020 22:55:47 +0100 Subject: [PATCH] Add option to verify SVG --- action.yml | 6 +++ action/dist/index.js | 99 +++++++++++++++++++++++++++++++++++++++++++- action/index.mjs | 11 +++++ 3 files changed, 115 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c30ca5fc..2f181aae 100644 --- a/action.yml +++ b/action.yml @@ -174,6 +174,12 @@ inputs: description: Enable debug logs default: no + # Verify SVG after generation + # It tests whether SVG can be correctly parsed (used for testing) + verify: + description: Verify SVG after genaration + default: no + # Enable dry-run mode # Generate image but does not push it (used for testing) dryrun: diff --git a/action/dist/index.js b/action/dist/index.js index 793369c9..7d07eb0c 100644 --- a/action/dist/index.js +++ b/action/dist/index.js @@ -910,6 +910,17 @@ var E_Users_lecoq_Documents_GitHub_gitstats_node_modules_actions_github_lib_gith const rendered = await metrics({login:user, q}, {graphql, rest, plugins, conf, die}) console.log(`Render | complete`) + //Verify svg + const verify = bool(core.getInput("verify")) + console.log(`Verify SVG | ${verify}`) + if (verify) { + const [libxmljs] = [await __webpack_require__.e(/* import() */ 344).then(__webpack_require__.t.bind(__webpack_require__, 53344, 3))].map(m => (m && m.default) ? m.default : m) + const parsed = libxmljs.parseXml(rendered) + if (parsed.errors.length) + throw new Error(`Malformed SVG : \n${parsed.errors.join("\n")}`) + console.log(`SVG valid | yes`) + } + //Commit to repository const dryrun = bool(core.getInput("dryrun")) if (dryrun) @@ -94334,6 +94345,9 @@ module.exports = require("zlib"); /******/ return module.exports; /******/ } /******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ /************************************************************************/ /******/ /* webpack/runtime/compat get default export */ /******/ (() => { @@ -94347,6 +94361,29 @@ module.exports = require("zlib"); /******/ }; /******/ })(); /******/ +/******/ /* webpack/runtime/create fake namespace object */ +/******/ (() => { +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = this(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ var def = {}; +/******/ if(mode & 2 && typeof value == 'object' && value) { +/******/ for(const key in value) def[key] = () => value[key]; +/******/ } +/******/ def['default'] = () => value; +/******/ __webpack_require__.d(ns, def); +/******/ return ns; +/******/ }; +/******/ })(); +/******/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports @@ -94359,6 +94396,28 @@ module.exports = require("zlib"); /******/ }; /******/ })(); /******/ +/******/ /* webpack/runtime/ensure chunk */ +/******/ (() => { +/******/ __webpack_require__.f = {}; +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = (chunkId) => { +/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => { +/******/ __webpack_require__.f[key](chunkId, promises); +/******/ return promises; +/******/ }, [])); +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/get javascript chunk filename */ +/******/ (() => { +/******/ // This function allow to reference async chunks +/******/ __webpack_require__.u = (chunkId) => { +/******/ // return url for filenames based on template +/******/ return "" + chunkId + ".index.js"; +/******/ }; +/******/ })(); +/******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop) @@ -94377,7 +94436,45 @@ module.exports = require("zlib"); /******/ /******/ /* webpack/runtime/compat */ /******/ -/******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/ +/******/ __webpack_require__.ab = __dirname + "/";/* webpack/runtime/require chunk loading */ +/******/ (() => { +/******/ // object to store loaded chunks +/******/ // "1" means "loaded", otherwise not loaded yet +/******/ var installedChunks = { +/******/ 179: 1 +/******/ }; +/******/ +/******/ var installChunk = (chunk) => { +/******/ var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime; +/******/ for(var moduleId in moreModules) { +/******/ if(__webpack_require__.o(moreModules, moduleId)) { +/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(runtime) runtime(__webpack_require__); +/******/ for(var i = 0; i < chunkIds.length; i++) +/******/ installedChunks[chunkIds[i]] = 1; +/******/ }; +/******/ +/******/ // require() chunk loading for javascript +/******/ __webpack_require__.f.require = function(chunkId, promises) { +/******/ +/******/ // "1" is the signal for "already loaded" +/******/ if(!installedChunks[chunkId]) { +/******/ if(true) { // all chunks have JS +/******/ installChunk(require("./" + __webpack_require__.u(chunkId))); +/******/ } else installedChunks[chunkId] = 1; +/******/ } +/******/ }; +/******/ +/******/ // no external install chunk +/******/ +/******/ // no HMR +/******/ +/******/ // no HMR manifest +/******/ })(); +/******/ +/************************************************************************/ /******/ // module exports must be returned from runtime so entry inlining is disabled /******/ // startup /******/ // Load entry module and return exports diff --git a/action/index.mjs b/action/index.mjs index 30b7bb04..71745c4e 100644 --- a/action/index.mjs +++ b/action/index.mjs @@ -116,6 +116,17 @@ const rendered = await metrics({login:user, q}, {graphql, rest, plugins, conf, die}) console.log(`Render | complete`) + //Verify svg + const verify = bool(core.getInput("verify")) + console.log(`Verify SVG | ${verify}`) + if (verify) { + const [libxmljs] = [await import("libxmljs")].map(m => (m && m.default) ? m.default : m) + const parsed = libxmljs.parseXml(rendered) + if (parsed.errors.length) + throw new Error(`Malformed SVG : \n${parsed.errors.join("\n")}`) + console.log(`SVG valid | yes`) + } + //Commit to repository const dryrun = bool(core.getInput("dryrun")) if (dryrun)