From c7db305ed292b072027d09962b34bc23be8e4c8a Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Wed, 10 Jun 2020 13:13:14 +0900 Subject: [PATCH] feat: improve pull request body (#130) - Improve the footer format. - Add the used npm version. --- dist/index.js | 25 ++++++++++++++++------ lib/__tests__/buildPullRequestBody.test.js | 4 +++- lib/buildPullRequestBody.js | 6 +++++- lib/constants.js | 3 +++ lib/npmArgs.js | 4 +--- lib/updateNpm.js | 3 +-- 6 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 lib/constants.js diff --git a/dist/index.js b/dist/index.js index e1557cc3..74797473 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1107,6 +1107,16 @@ module.exports._parse = parse; module.exports._enoent = enoent; +/***/ }), + +/***/ 32: +/***/ (function(module) { + +module.exports.PACKAGE_NAME = "npm-audit-fix-action"; +module.exports.PACKAGE_URL = "https://github.com/ybiquitous/npm-audit-fix-action"; +module.exports.NPM_VERSION = "6.14.5"; + + /***/ }), /***/ 39: @@ -1915,8 +1925,7 @@ function parseGitUrl (giturl) { const { exec } = __webpack_require__(986); const npmArgs = __webpack_require__(510); - -const NPM_VERSION = "6.14.5"; +const { NPM_VERSION } = __webpack_require__(32); module.exports = async function updateNpm() { await exec("sudo", ["npm", ...npmArgs("install", "--global", `npm@${NPM_VERSION}`)]); @@ -6959,13 +6968,11 @@ module.exports = resolveCommand; /***/ 510: /***/ (function(module) { -const DEFAULT_OPTIONS = Object.freeze(["--ignore-scripts", "--no-progress"]); - /** * @param {string[]} args */ module.exports = function npmArgs(...args) { - return [...args, ...DEFAULT_OPTIONS]; + return [...args, "--ignore-scripts", "--no-progress"]; }; @@ -8190,7 +8197,9 @@ module.exports = async function aggregateReport(audit, fix) { /***/ }), /***/ 603: -/***/ (function(module) { +/***/ (function(module, __unusedexports, __webpack_require__) { + +const { PACKAGE_NAME, PACKAGE_URL, NPM_VERSION } = __webpack_require__(32); /** * @param {Report} report @@ -8266,9 +8275,11 @@ module.exports = function buildPullRequestBody(report) { }); } + lines.push(""); + lines.push("***"); lines.push(""); lines.push( - "*This pull request is created by [npm-audit-fix-action](https://github.com/ybiquitous/npm-audit-fix-action).*" + `This pull request is created by [${PACKAGE_NAME}](${PACKAGE_URL}). The used npm version is **${NPM_VERSION}**.` ); return lines.join("\n").trim(); diff --git a/lib/__tests__/buildPullRequestBody.test.js b/lib/__tests__/buildPullRequestBody.test.js index cb7877e8..c9aef4e6 100644 --- a/lib/__tests__/buildPullRequestBody.test.js +++ b/lib/__tests__/buildPullRequestBody.test.js @@ -23,7 +23,9 @@ test("buildPullRequestBody()", () => { |:--------|:-------:|:-------| | [@gitlab/ui](https://npm.im/@gitlab/ui) ([gitlab](https://gitlab.com/gitlab-org/gitlab-ui)) | \`1.2.3\` | - | -*This pull request is created by [npm-audit-fix-action](https://github.com/ybiquitous/npm-audit-fix-action).* +*** + +This pull request is created by [npm-audit-fix-action](https://github.com/ybiquitous/npm-audit-fix-action). The used npm version is **6.14.5**. `.trim() ); }); diff --git a/lib/buildPullRequestBody.js b/lib/buildPullRequestBody.js index b0fe286d..f30e1eb6 100644 --- a/lib/buildPullRequestBody.js +++ b/lib/buildPullRequestBody.js @@ -1,3 +1,5 @@ +const { PACKAGE_NAME, PACKAGE_URL, NPM_VERSION } = require("./constants"); + /** * @param {Report} report * @returns {String} @@ -72,9 +74,11 @@ module.exports = function buildPullRequestBody(report) { }); } + lines.push(""); + lines.push("***"); lines.push(""); lines.push( - "*This pull request is created by [npm-audit-fix-action](https://github.com/ybiquitous/npm-audit-fix-action).*" + `This pull request is created by [${PACKAGE_NAME}](${PACKAGE_URL}). The used npm version is **${NPM_VERSION}**.` ); return lines.join("\n").trim(); diff --git a/lib/constants.js b/lib/constants.js new file mode 100644 index 00000000..495ce314 --- /dev/null +++ b/lib/constants.js @@ -0,0 +1,3 @@ +module.exports.PACKAGE_NAME = "npm-audit-fix-action"; +module.exports.PACKAGE_URL = "https://github.com/ybiquitous/npm-audit-fix-action"; +module.exports.NPM_VERSION = "6.14.5"; diff --git a/lib/npmArgs.js b/lib/npmArgs.js index 3044459a..ad934022 100644 --- a/lib/npmArgs.js +++ b/lib/npmArgs.js @@ -1,8 +1,6 @@ -const DEFAULT_OPTIONS = Object.freeze(["--ignore-scripts", "--no-progress"]); - /** * @param {string[]} args */ module.exports = function npmArgs(...args) { - return [...args, ...DEFAULT_OPTIONS]; + return [...args, "--ignore-scripts", "--no-progress"]; }; diff --git a/lib/updateNpm.js b/lib/updateNpm.js index ea63619b..0e42578d 100644 --- a/lib/updateNpm.js +++ b/lib/updateNpm.js @@ -1,7 +1,6 @@ const { exec } = require("@actions/exec"); const npmArgs = require("./npmArgs"); - -const NPM_VERSION = "6.14.5"; +const { NPM_VERSION } = require("./constants"); module.exports = async function updateNpm() { await exec("sudo", ["npm", ...npmArgs("install", "--global", `npm@${NPM_VERSION}`)]);