diff --git a/dist/index.js b/dist/index.js index a7bcb428..0877a4b2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -40,8 +40,10 @@ module.exports = /******/ // the startup function /******/ function startup() { /******/ // Load entry module and return exports -/******/ return __webpack_require__(526); +/******/ return __webpack_require__(134); /******/ }; +/******/ // initialize runtime +/******/ runtime(__webpack_require__); /******/ /******/ // run startup /******/ return startup(); @@ -1052,16 +1054,6 @@ module.exports = require("tls"); module.exports = eval("require")("encoding"); -/***/ }), - -/***/ 32: -/***/ (function(module) { - -module.exports.PACKAGE_NAME = "ybiquitous/npm-audit-fix-action"; -module.exports.PACKAGE_URL = "https://github.com/ybiquitous/npm-audit-fix-action"; -module.exports.NPM_VERSION = "7"; - - /***/ }), /***/ 49: @@ -1111,55 +1103,6 @@ function onceStrict (fn) { } -/***/ }), - -/***/ 50: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const { exec } = __webpack_require__(986); -const npmArgs = __webpack_require__(510); - -/** - * @param {typeof exec} execFn - * @returns {Promise} - */ -module.exports = async function audit(execFn = exec) { - let report = ""; - await execFn("npm", npmArgs("audit", "--json"), { - listeners: { - stdout: (data) => { - report += data.toString(); - }, - }, - ignoreReturnCode: true, - }); - const { vulnerabilities } = JSON.parse(report); - - if (vulnerabilities != null && typeof vulnerabilities === "object") { - const map = /** @type {AuditReport} */ new Map(); - - Object.values(vulnerabilities).forEach(({ name, severity, via }) => { - if (Array.isArray(via)) { - const [viaFirst] = via; - if (typeof viaFirst.title === "string" && typeof viaFirst.url === "string") { - map.set(name, { name, severity, title: viaFirst.title, url: viaFirst.url }); - } else if (typeof viaFirst === "string") { - // ignore - } else { - throw new Error(`"via" of "${name}" is invalid: ${JSON.stringify(via)}`); - } - } else { - throw new Error('"via" is not an array'); - } - }); - - return map; - } - - throw new Error('"vulnerabilities" is missing'); -}; - - /***/ }), /***/ 68: @@ -1359,345 +1302,1083 @@ module.exports = require("child_process"); /***/ }), -/***/ 141: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/***/ 134: +/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) { "use strict"; +__webpack_require__.r(__webpack_exports__); +// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js +var core = __webpack_require__(470); -var net = __webpack_require__(631); -var tls = __webpack_require__(16); -var http = __webpack_require__(876); -var https = __webpack_require__(211); -var events = __webpack_require__(614); -var assert = __webpack_require__(357); -var util = __webpack_require__(669); - - -exports.httpOverHttp = httpOverHttp; -exports.httpsOverHttp = httpsOverHttp; -exports.httpOverHttps = httpOverHttps; -exports.httpsOverHttps = httpsOverHttps; +// EXTERNAL MODULE: ./node_modules/@actions/exec/lib/exec.js +var exec = __webpack_require__(986); +// EXTERNAL MODULE: ./node_modules/hosted-git-info/index.js +var hosted_git_info = __webpack_require__(190); -function httpOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - return agent; -} +// CONCATENATED MODULE: ./lib/packageRepoUrls.js -function httpsOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} -function httpOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - return agent; -} -function httpsOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} +/** + * @type {Map} + */ +const cache = new Map(); -function TunnelingAgent(options) { - var self = this; - self.options = options || {}; - self.proxyOptions = self.options.proxy || {}; - self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; - self.requests = []; - self.sockets = []; +/** + * @param {string} packageName + * @returns {Promise} + */ +async function fetchUrl(packageName) { + const cached = cache.get(packageName); + if (cached) { + return cached; + } - self.on('free', function onFree(socket, host, port, localAddress) { - var options = toOptions(host, port, localAddress); - for (var i = 0, len = self.requests.length; i < len; ++i) { - var pending = self.requests[i]; - if (pending.host === options.host && pending.port === options.port) { - // Detect the request to connect same origin server, - // reuse the connection. - self.requests.splice(i, 1); - pending.request.onSocket(socket); - return; - } + let stdout = ""; + let stderr = ""; + try { + await Object(exec.exec)("npm", ["view", packageName, "repository.url"], { + listeners: { + stdout: (data) => { + stdout += data.toString(); + }, + stderr: (data) => { + stderr += data.toString(); + }, + }, + silent: true, + }); + } catch (err) { + // code E404 means the package does not exist on npm + // which means it is a file: or git: dependency + // We are fine with 404 errors, but not with any other errors + if (!stderr.includes("code E404")) { + throw new Error(stderr); } - socket.destroy(); - self.removeSocket(socket); - }); -} -util.inherits(TunnelingAgent, events.EventEmitter); - -TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { - var self = this; - var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); + } + stdout = stdout.trim(); - if (self.sockets.length >= this.maxSockets) { - // We are over limit so we'll add it to the queue. - self.requests.push(options); - return; + if (!stdout) { + Object(core.info)(`No repository URL for '${packageName}'`); + return null; } - // If we are under maxSockets create a new one. - self.createSocket(options, function(socket) { - socket.on('free', onFree); - socket.on('close', onCloseOrRemove); - socket.on('agentRemove', onCloseOrRemove); - req.onSocket(socket); + const url = Object(hosted_git_info.fromUrl)(stdout); + if (!url) { + Object(core.info)(`No repository URL for '${packageName}'`); + return null; + } + const urlInfo = { name: packageName, url: url.browse(), type: url.type }; - function onFree() { - self.emit('free', socket, options); - } + cache.set(packageName, urlInfo); - function onCloseOrRemove(err) { - self.removeSocket(socket); - socket.removeListener('free', onFree); - socket.removeListener('close', onCloseOrRemove); - socket.removeListener('agentRemove', onCloseOrRemove); - } - }); -}; + return urlInfo; +} -TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { - var self = this; - var placeholder = {}; - self.sockets.push(placeholder); +/** + * @param {string[]} packageNames + * @returns {Promise>} + */ +async function packageRepoUrls(packageNames) { + const allUrls = await Promise.all(packageNames.map(fetchUrl)); - var connectOptions = mergeOptions({}, self.proxyOptions, { - method: 'CONNECT', - path: options.host + ':' + options.port, - agent: false, - headers: { - host: options.host + ':' + options.port + /** + * @type {Record} + */ + const map = {}; + for (const url of allUrls) { + if (url) { + map[url.name] = url; } - }); - if (options.localAddress) { - connectOptions.localAddress = options.localAddress; } - if (connectOptions.proxyAuth) { - connectOptions.headers = connectOptions.headers || {}; - connectOptions.headers['Proxy-Authorization'] = 'Basic ' + - new Buffer(connectOptions.proxyAuth).toString('base64'); + return map; +} + +// CONCATENATED MODULE: ./lib/utils/capitalize.js +/** + * @param {string} str + * @returns {string} + */ +function capitalize(str) { + if (typeof str === "string") { + return str.charAt(0).toUpperCase() + str.slice(1); } + return ""; +} - debug('making CONNECT request'); - var connectReq = self.request(connectOptions); - connectReq.useChunkedEncodingByDefault = false; // for v0.6 - connectReq.once('response', onResponse); // for v0.6 - connectReq.once('upgrade', onUpgrade); // for v0.6 - connectReq.once('connect', onConnect); // for v0.7 or later - connectReq.once('error', onError); - connectReq.end(); +// CONCATENATED MODULE: ./lib/utils/semverToNumber.js +/** + * @param {string} version + * @returns {number} + */ +function semverToNumber(version) { + return version + .split(".") + .slice(0, 3) + .reverse() + .map((str) => parseInt(str, 10)) + .reduce((sum, num, idx) => { + const added = num * 10 ** (idx * 2) || 0; + return sum + added; + }, 0); +} - function onResponse(res) { - // Very hacky. This is necessary to avoid http-parser leaks. - res.upgrade = true; - } +// CONCATENATED MODULE: ./lib/aggregateReport.js - function onUpgrade(res, socket, head) { - // Hacky. - process.nextTick(function() { - onConnect(res, socket, head); - }); - } - function onConnect(res, socket, head) { - connectReq.removeAllListeners(); - socket.removeAllListeners(); - if (res.statusCode !== 200) { - debug('tunneling socket could not be established, statusCode=%d', - res.statusCode); - socket.destroy(); - var error = new Error('tunneling socket could not be established, ' + - 'statusCode=' + res.statusCode); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - if (head.length > 0) { - debug('got illegal response body from proxy'); - socket.destroy(); - var error = new Error('got illegal response body from proxy'); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - debug('tunneling connection has established'); - self.sockets[self.sockets.indexOf(placeholder)] = socket; - return cb(socket); - } - - function onError(cause) { - connectReq.removeAllListeners(); - - debug('tunneling socket could not be established, cause=%s\n', - cause.message, cause.stack); - var error = new Error('tunneling socket could not be established, ' + - 'cause=' + cause.message); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - } -}; -TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { - var pos = this.sockets.indexOf(socket) - if (pos === -1) { - return; +/** + * @param {{ name: string, version: string }} a + * @param {{ name: string, version: string }} b + * @returns {number} + */ +const byNameAndVersion = (a, b) => { + const res = a.name.localeCompare(b.name); + if (res > 0) { + return 1; } - this.sockets.splice(pos, 1); - - var pending = this.requests.shift(); - if (pending) { - // If we have pending requests and a socket gets closed a new one - // needs to be created to take over in the pool for the one that closed. - this.createSocket(pending, function(socket) { - pending.request.onSocket(socket); - }); + if (res < 0) { + return -1; } + return semverToNumber(a.version) - semverToNumber(b.version); }; -function createSecureSocket(options, cb) { - var self = this; - TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { - var hostHeader = options.request.getHeader('host'); - var tlsOptions = mergeOptions({}, self.options, { - socket: socket, - servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host - }); +/** + * @param {AuditReport} audit + * @param {Map} beforePackages + * @param {Map} afterPackages + * @returns {Promise} + */ +async function aggregateReport(audit, beforePackages, afterPackages) { + /** @type {Report["added"]} */ + const added = []; + afterPackages.forEach((version, name) => { + if (!beforePackages.has(name)) { + added.push({ name, version }); + } + }); + added.sort(byNameAndVersion); - // 0 is dummy port for v0.6 - var secureSocket = tls.connect(0, tlsOptions); - self.sockets[self.sockets.indexOf(socket)] = secureSocket; - cb(secureSocket); + /** @type {Report["removed"]} */ + const removed = []; + beforePackages.forEach((version, name) => { + if (!afterPackages.has(name)) { + removed.push({ name, version }); + } }); -} + removed.sort(byNameAndVersion); + /** @type {Report["updated"]} */ + const updated = []; + afterPackages.forEach((version, name) => { + const previousVersion = beforePackages.get(name); + if (version !== previousVersion && previousVersion != null) { + const info = audit.get(name); + const severity = info == null ? null : capitalize(info.severity); + const title = info == null ? null : info.title; + const url = info == null ? null : info.url; + updated.push({ name, version, previousVersion, severity, title, url }); + } + }); + updated.sort(byNameAndVersion); -function toOptions(host, port, localAddress) { - if (typeof host === 'string') { // since v0.10 - return { - host: host, - port: port, - localAddress: localAddress - }; - } - return host; // for v0.11 or later -} + const allPackageNames = Array.from( + new Set([ + ...added.map((e) => e.name), + ...updated.map((e) => e.name), + ...removed.map((e) => e.name), + ]) + ); + const packageCount = allPackageNames.length; + const packageUrls = await packageRepoUrls(allPackageNames); -function mergeOptions(target) { - for (var i = 1, len = arguments.length; i < len; ++i) { - var overrides = arguments[i]; - if (typeof overrides === 'object') { - var keys = Object.keys(overrides); - for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { - var k = keys[j]; - if (overrides[k] !== undefined) { - target[k] = overrides[k]; - } - } - } - } - return target; + return { added, removed, updated, packageCount, packageUrls }; } - -var debug; -if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { - debug = function() { - var args = Array.prototype.slice.call(arguments); - if (typeof args[0] === 'string') { - args[0] = 'TUNNEL: ' + args[0]; - } else { - args.unshift('TUNNEL:'); - } - console.error.apply(console, args); - } -} else { - debug = function() {}; +// CONCATENATED MODULE: ./lib/npmArgs.js +/** + * @param {string[]} args + */ +function npmArgs(...args) { + return [...args, "--ignore-scripts", "--no-progress"]; } -exports.debug = debug; // for test +// CONCATENATED MODULE: ./lib/audit.js -/***/ }), -/***/ 190: -/***/ (function(module, __unusedexports, __webpack_require__) { -"use strict"; +/** + * @param {typeof exec} execFn + * @returns {Promise} + */ +async function audit_audit(execFn = exec.exec) { + let report = ""; + await execFn("npm", npmArgs("audit", "--json"), { + listeners: { + stdout: (data) => { + report += data.toString(); + }, + }, + ignoreReturnCode: true, + }); + const { vulnerabilities } = JSON.parse(report); -const url = __webpack_require__(835) -const gitHosts = __webpack_require__(813) -const GitHost = module.exports = __webpack_require__(982) -const LRU = __webpack_require__(702) -const cache = new LRU({ max: 1000 }) + if (vulnerabilities != null && typeof vulnerabilities === "object") { + const map = /** @type {AuditReport} */ new Map(); -const protocolToRepresentationMap = { - 'git+ssh:': 'sshurl', - 'git+https:': 'https', - 'ssh:': 'sshurl', - 'git:': 'git' -} + Object.values(vulnerabilities).forEach(({ name, severity, via }) => { + if (Array.isArray(via)) { + const [viaFirst] = via; + if (typeof viaFirst.title === "string" && typeof viaFirst.url === "string") { + map.set(name, { name, severity, title: viaFirst.title, url: viaFirst.url }); + } else if (typeof viaFirst === "string") { + // ignore + } else { + throw new Error(`"via" of "${name}" is invalid: ${JSON.stringify(via)}`); + } + } else { + throw new Error('"via" is not an array'); + } + }); -function protocolToRepresentation (protocol) { - return protocolToRepresentationMap[protocol] || protocol.slice(0, -1) -} + return map; + } -const authProtocols = { - 'git:': true, - 'https:': true, - 'git+https:': true, - 'http:': true, - 'git+http:': true + throw new Error('"vulnerabilities" is missing'); } -const knownProtocols = Object.keys(gitHosts.byShortcut).concat(['http:', 'https:', 'git:', 'git+ssh:', 'git+https:', 'ssh:']) +// CONCATENATED MODULE: ./lib/auditFix.js -module.exports.fromUrl = function (giturl, opts) { - if (typeof giturl !== 'string') { - return - } - const key = giturl + JSON.stringify(opts || {}) - if (!cache.has(key)) { - cache.set(key, fromUrl(giturl, opts)) - } - return cache.get(key) -} +async function auditFix() { + let error = ""; -function fromUrl (giturl, opts) { - if (!giturl) { - return - } + const returnCode = await Object(exec.exec)("npm", npmArgs("audit", "fix"), { + listeners: { + stderr: (data) => { + error += data.toString(); + }, + }, + ignoreReturnCode: true, + }); - const url = isGitHubShorthand(giturl) ? 'github:' + giturl : correctProtocol(giturl) - const parsed = parseGitUrl(url) - if (!parsed) { - return parsed + if (error.includes("npm ERR!")) { + throw new Error("Unexpected error occurred"); } - const gitHostShortcut = gitHosts.byShortcut[parsed.protocol] - const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith('www.') ? parsed.hostname.slice(4) : parsed.hostname] - const gitHostName = gitHostShortcut || gitHostDomain - if (!gitHostName) { - return + if (returnCode !== 0) { + Object(core.warning)(error); } +} - const gitHostInfo = gitHosts[gitHostShortcut || gitHostDomain] - let auth = null - if (authProtocols[parsed.protocol] && (parsed.username || parsed.password)) { +// CONCATENATED MODULE: ./lib/buildCommitBody.js +/** + * @param {Report} report + * @returns {string} + */ +function buildCommitBody(report) { + const lines = []; + + lines.push("Summary:"); + lines.push(`- Updated packages: ${report.updated.length}`); + lines.push(`- Added packages: ${report.added.length}`); + lines.push(`- Removed packages: ${report.removed.length}`); + + lines.push(""); + if (report.updated.length > 0) { + lines.push("Fixed vulnerabilities:"); + report.updated.forEach(({ name, severity, title, url }) => { + if (severity != null && title != null && url != null) { + lines.push(`- ${name}: "${title}" (${url})`); + } + }); + } else { + lines.push("No fixed vulnerabilities."); + } + + return lines.map((line) => `${line}\n`).join(""); +} + +// CONCATENATED MODULE: ./lib/constants.js +const PACKAGE_NAME = "ybiquitous/npm-audit-fix-action"; +const PACKAGE_URL = "https://github.com/ybiquitous/npm-audit-fix-action"; +const NPM_VERSION = "7"; + +// CONCATENATED MODULE: ./lib/buildPullRequestBody.js + + +const EMPTY = "-"; + +/** + * @param {Report} report + * @param {string} npmVersion + * @returns {string} + */ +function buildPullRequestBody(report, npmVersion) { + /** + * @param {string} name + * @param {string} version + */ + const npmPackage = (name, version) => + `[${name}](https://www.npmjs.com/package/${name}/v/${version})`; + + /** + * @param {...string} items + */ + const buildTableRow = (...items) => `| ${items.join(" | ")} |`; + + /** + * @param {string} name + * @returns {string} + */ + const repoLink = (name) => { + const url = report.packageUrls[name]; + return url ? `[${url.type}](${url.url})` : EMPTY; + }; + + /** + * @param {string} version + * @returns {string} + */ + const versionLabel = (version) => `\`${version}\``; + + const header = []; + header.push("| Package | Version | Source | Detail |"); + header.push("|:--------|:-------:|:------:|:-------|"); + + const lines = []; + lines.push( + `This pull request fixes the vulnerable packages via npm [${npmVersion}](https://github.com/npm/cli/releases/tag/v${npmVersion}).` + ); + + if (report.updated.length > 0) { + lines.push(""); + lines.push("
"); + lines.push(`Updated (${report.updated.length})`); + lines.push(""); + lines.push(...header); + + report.updated.forEach(({ name, version, previousVersion, severity, title, url }) => { + let extra = EMPTY; + if (severity != null && title != null && url != null) { + extra = `**[${severity}]** ${title} ([ref](${url}))`; + } + lines.push( + buildTableRow( + npmPackage(name, version), + `${versionLabel(previousVersion)} → ${versionLabel(version)}`, + repoLink(name), + extra + ) + ); + }); + + lines.push(""); + lines.push("
"); + } + + if (report.added.length > 0) { + lines.push(""); + lines.push("
"); + lines.push(`Added (${report.added.length})`); + lines.push(""); + lines.push(...header); + report.added.forEach(({ name, version }) => { + lines.push( + buildTableRow(npmPackage(name, version), versionLabel(version), repoLink(name), EMPTY) + ); + }); + lines.push(""); + lines.push("
"); + } + + if (report.removed.length > 0) { + lines.push(""); + lines.push("
"); + lines.push(`Removed (${report.removed.length})`); + lines.push(""); + lines.push(...header); + report.removed.forEach(({ name, version }) => { + lines.push( + buildTableRow(npmPackage(name, version), versionLabel(version), repoLink(name), EMPTY) + ); + }); + lines.push(""); + lines.push("
"); + } + + lines.push(""); + lines.push("***"); + lines.push(""); + lines.push(`Created by [${PACKAGE_NAME}](${PACKAGE_URL})`); + + return lines.join("\n").trim(); +} + +// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js +var github = __webpack_require__(469); + +// CONCATENATED MODULE: ./lib/utils/splitRepo.js +/** + * @param {string} repository + * @returns {{ owner: string, repo: string }} + */ +function splitRepo(repository) { + const [owner, repo] = repository.split("/"); + if (owner && repo) { + return { owner, repo }; + } + throw new TypeError(`invalid repository: "${repository}"`); +} + +// CONCATENATED MODULE: ./lib/createOrUpdatePullRequest.js + + + + + +/** + * @param {{ + * token: string, + * branch: string, + * baseBranch: string, + * title: string, + * pullBody: string, + * commitBody: string, + * repository: string, + * author: string, + * email: string, + * labels: string[], + * }} params + */ +async function createOrUpdatePullRequest({ + token, + branch, + baseBranch, + title, + pullBody, + commitBody, + repository, + author, + email, + labels, +}) { + const remote = `https://${author}:${token}@github.com/${repository}.git`; + const { owner, repo } = splitRepo(repository); + const octokit = Object(github.getOctokit)(token); + + // Find pull request + const pulls = await octokit.rest.pulls.list({ + owner, + repo, + state: "open", + base: baseBranch, + sort: "updated", + direction: "desc", + per_page: 100, + }); + const pull = pulls.data.find(({ head }) => head.ref === branch); + + await Object(exec.exec)("git", ["config", "user.name", author]); + await Object(exec.exec)("git", ["config", "user.email", email]); + await Object(exec.exec)("git", ["add", "package-lock.json"]); + await Object(exec.exec)("git", ["commit", "--message", `${title}\n\n${commitBody}`]); + await Object(exec.exec)("git", ["checkout", "-B", branch]); + await Object(exec.exec)("git", ["push", remote, `HEAD:${branch}`, ...(pull ? ["--force"] : [])]); + + if (pull) { + await octokit.rest.pulls.update({ + owner, + repo, + pull_number: pull.number, + title, + body: pullBody, + }); + Object(core.info)(`The pull request was updated successfully: ${pull.html_url}`); + } else { + const newPull = await octokit.rest.pulls.create({ + owner, + repo, + title, + body: pullBody, + head: branch, + base: baseBranch, + }); + Object(core.info)(`The pull request was created successfully: ${newPull.data.html_url}`); + + const newLabels = await octokit.rest.issues.addLabels({ + owner, + repo, + issue_number: newPull.data.number, + labels, + }); + Object(core.info)(`The labels were added successfully: ${newLabels.data.map((l) => l.name).join(", ")}`); + } +} + +// CONCATENATED MODULE: ./lib/getDefaultBranch.js + + + +/** + * @param {{token: string, repository: string}} params + * @returns {Promise} + */ +async function getDefaultBranch({ token, repository }) { + const octokit = Object(github.getOctokit)(token); + const res = await octokit.rest.repos.get(splitRepo(repository)); + return res.data.default_branch; +} + +// CONCATENATED MODULE: ./lib/listPackages.js + + + +/** + * @param {import("@actions/exec").ExecOptions?} options + * @returns {Promise>} + */ +async function listPackages(options = {}) { + let lines = ""; + let stderr = ""; + const returnCode = await Object(exec.exec)("npm", npmArgs("ls", "--parseable", "--long", "--all"), { + listeners: { + stdout: (data) => { + lines += data.toString(); + }, + stderr: (data) => { + stderr += data.toString(); + }, + }, + ignoreReturnCode: true, + ...options, + }); + + // NOTE: Ignore missing peer deps error. + if (returnCode !== 0 && !stderr.includes("npm ERR! missing:")) { + throw new Error(`"npm ls" failed`); + } + + const packages = /** @type {Map} */ new Map(); + lines + .split("\n") + .filter((line) => line.trim()) + .forEach((line) => { + const [, pkg] = line.split(":", 2); + if (pkg == null) { + throw new Error(`Invalid line: "${line}"`); + } + + const match = /^(?@?\S+)@(?\S+)$/u.exec(pkg); + if (match == null || match.groups == null) { + return; // skip + } + + /* eslint-disable dot-notation, prefer-destructuring -- Prevent TS4111 */ + const name = match.groups["name"]; + const version = match.groups["version"]; + /* eslint-enable */ + + if (name == null || version == null) { + throw new Error(`Invalid name and version: "${line}"`); + } + + packages.set(name.trim(), version.trim()); + }); + return packages; +} + +// CONCATENATED MODULE: ./lib/updateNpm.js + + + +/** + * @param {string} version + */ +async function updateNpm(version) { + await Object(exec.exec)("sudo", ["npm", ...npmArgs("install", "--global", `npm@${version}`)]); + + let actualVersion = ""; + await Object(exec.exec)("npm", ["--version"], { + listeners: { + stdout: (data) => { + actualVersion += data.toString(); + }, + }, + }); + + // HACK: Fix the error "npm update check failed". + // eslint-disable-next-line dot-notation -- Prevent TS4111 + await Object(exec.exec)("sudo", ["chown", "-R", `${process.env["USER"]}:`, `${process.env["HOME"]}/.config`]); + + return actualVersion.trim(); +} + +// CONCATENATED MODULE: ./lib/utils/commaSeparatedList.js +/** + * @param {string} str + * @returns {string[]} + */ +function commaSeparatedList(str) { + return str + .split(",") + .map((s) => s.trim()) + .filter(Boolean); +} + +// CONCATENATED MODULE: ./lib/index.js + + + + + + + + + + + + + + + +/** + * @returns {Promise} + */ +async function filesChanged() { + try { + const exitCode = await Object(exec.exec)("git", ["diff", "--exit-code"]); + return exitCode === 0; + } catch (err) { + return false; + } +} + +/** + * @param {string} name + * @returns {string} + */ +function getFromEnv(name) { + const value = process.env[name]; + if (value) { + return value; + } + throw new Error(`Not found '${name}' in the environment variables`); +} + +async function run() { + const npmVersion = await Object(core.group)(`Update npm to ${NPM_VERSION}`, () => updateNpm(NPM_VERSION)); + + await Object(core.group)("Install user packages", async () => { + await Object(exec.exec)("npm", npmArgs("ci")); + }); + + const auditReport = await Object(core.group)("Get audit report", async () => { + const res = await audit_audit(); + Object(core.info)(JSON.stringify(res, null, 2)); + return res; + }); + + const beforePackages = await Object(core.group)("List packages before", () => listPackages()); + + await Object(core.group)("Fix vulnerabilities", () => auditFix()); + + await Object(core.group)("Re-install user packages", async () => { + await Object(exec.exec)("npm", npmArgs("ci")); + }); + + const afterPackages = await Object(core.group)("List packages after", () => listPackages()); + + const report = await Object(core.group)("Aggregate report", () => + aggregateReport(auditReport, beforePackages, afterPackages) + ); + + if (report.packageCount === 0) { + Object(core.info)("No update."); + return; + } + + const changed = await Object(core.group)("Check file changes", filesChanged); + if (changed) { + Object(core.info)("No file changes."); + return; + } + + await Object(core.group)("Create or update a pull request", async () => { + const token = Object(core.getInput)("github_token"); + const repository = getFromEnv("GITHUB_REPOSITORY"); + + let baseBranch = Object(core.getInput)("default_branch"); + if (!baseBranch) { + baseBranch = await getDefaultBranch({ token, repository }); + } + + const author = getFromEnv("GITHUB_ACTOR"); + return createOrUpdatePullRequest({ + branch: Object(core.getInput)("branch"), + token, + baseBranch, + title: Object(core.getInput)("commit_title"), + pullBody: buildPullRequestBody(report, npmVersion), + commitBody: buildCommitBody(report), + repository, + author, + email: `${author}@users.noreply.github.com`, + labels: commaSeparatedList(Object(core.getInput)("labels")), + }); + }); +} + +run().catch((e) => Object(core.setFailed)(e.message)); + + +/***/ }), + +/***/ 141: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + + +var net = __webpack_require__(631); +var tls = __webpack_require__(16); +var http = __webpack_require__(605); +var https = __webpack_require__(211); +var events = __webpack_require__(614); +var assert = __webpack_require__(357); +var util = __webpack_require__(669); + + +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; + + +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; +} + +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} + +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; +} + +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} + + +function TunnelingAgent(options) { + var self = this; + self.options = options || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; + + self.on('free', function onFree(socket, host, port, localAddress) { + var options = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options.host && pending.port === options.port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } + } + socket.destroy(); + self.removeSocket(socket); + }); +} +util.inherits(TunnelingAgent, events.EventEmitter); + +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); + + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; + } + + // If we are under maxSockets create a new one. + self.createSocket(options, function(socket) { + socket.on('free', onFree); + socket.on('close', onCloseOrRemove); + socket.on('agentRemove', onCloseOrRemove); + req.onSocket(socket); + + function onFree() { + self.emit('free', socket, options); + } + + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; + +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); + + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: 'CONNECT', + path: options.host + ':' + options.port, + agent: false, + headers: { + host: options.host + ':' + options.port + } + }); + if (options.localAddress) { + connectOptions.localAddress = options.localAddress; + } + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64'); + } + + debug('making CONNECT request'); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; // for v0.6 + connectReq.once('response', onResponse); // for v0.6 + connectReq.once('upgrade', onUpgrade); // for v0.6 + connectReq.once('connect', onConnect); // for v0.7 or later + connectReq.once('error', onError); + connectReq.end(); + + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } + + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); + } + + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); + + if (res.statusCode !== 200) { + debug('tunneling socket could not be established, statusCode=%d', + res.statusCode); + socket.destroy(); + var error = new Error('tunneling socket could not be established, ' + + 'statusCode=' + res.statusCode); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + if (head.length > 0) { + debug('got illegal response body from proxy'); + socket.destroy(); + var error = new Error('got illegal response body from proxy'); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + debug('tunneling connection has established'); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + return cb(socket); + } + + function onError(cause) { + connectReq.removeAllListeners(); + + debug('tunneling socket could not be established, cause=%s\n', + cause.message, cause.stack); + var error = new Error('tunneling socket could not be established, ' + + 'cause=' + cause.message); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + } +}; + +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; + } + this.sockets.splice(pos, 1); + + var pending = this.requests.shift(); + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket); + }); + } +}; + +function createSecureSocket(options, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + var hostHeader = options.request.getHeader('host'); + var tlsOptions = mergeOptions({}, self.options, { + socket: socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host + }); + + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); +} + + +function toOptions(host, port, localAddress) { + if (typeof host === 'string') { // since v0.10 + return { + host: host, + port: port, + localAddress: localAddress + }; + } + return host; // for v0.11 or later +} + +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === 'object') { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== undefined) { + target[k] = overrides[k]; + } + } + } + } + return target; +} + + +var debug; +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0]; + } else { + args.unshift('TUNNEL:'); + } + console.error.apply(console, args); + } +} else { + debug = function() {}; +} +exports.debug = debug; // for test + + +/***/ }), + +/***/ 190: +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + +const url = __webpack_require__(835) +const gitHosts = __webpack_require__(813) +const GitHost = module.exports = __webpack_require__(599) +const LRU = __webpack_require__(702) +const cache = new LRU({ max: 1000 }) + +const protocolToRepresentationMap = { + 'git+ssh:': 'sshurl', + 'git+https:': 'https', + 'ssh:': 'sshurl', + 'git:': 'git' +} + +function protocolToRepresentation (protocol) { + return protocolToRepresentationMap[protocol] || protocol.slice(0, -1) +} + +const authProtocols = { + 'git:': true, + 'https:': true, + 'git+https:': true, + 'http:': true, + 'git+http:': true +} + +const knownProtocols = Object.keys(gitHosts.byShortcut).concat(['http:', 'https:', 'git:', 'git+ssh:', 'git+https:', 'ssh:']) + +module.exports.fromUrl = function (giturl, opts) { + if (typeof giturl !== 'string') { + return + } + + const key = giturl + JSON.stringify(opts || {}) + + if (!cache.has(key)) { + cache.set(key, fromUrl(giturl, opts)) + } + + return cache.get(key) +} + +function fromUrl (giturl, opts) { + if (!giturl) { + return + } + + const url = isGitHubShorthand(giturl) ? 'github:' + giturl : correctProtocol(giturl) + const parsed = parseGitUrl(url) + if (!parsed) { + return parsed + } + + const gitHostShortcut = gitHosts.byShortcut[parsed.protocol] + const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith('www.') ? parsed.hostname.slice(4) : parsed.hostname] + const gitHostName = gitHostShortcut || gitHostDomain + if (!gitHostName) { + return + } + + const gitHostInfo = gitHosts[gitHostShortcut || gitHostDomain] + let auth = null + if (authProtocols[parsed.protocol] && (parsed.username || parsed.password)) { auth = `${parsed.username}${parsed.password ? ':' + parsed.password : ''}` } @@ -1874,54 +2555,6 @@ const parseGitUrl = (giturl) => { } -/***/ }), - -/***/ 193: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const { exec } = __webpack_require__(986); -const npmArgs = __webpack_require__(510); - -/** - * @param {string} version - */ -module.exports = async function updateNpm(version) { - await exec("sudo", ["npm", ...npmArgs("install", "--global", `npm@${version}`)]); - - let actualVersion = ""; - await exec("npm", ["--version"], { - listeners: { - stdout: (data) => { - actualVersion += data.toString(); - }, - }, - }); - - // HACK: Fix the error "npm update check failed". - // eslint-disable-next-line dot-notation -- Prevent TS4111 - await exec("sudo", ["chown", "-R", `${process.env["USER"]}:`, `${process.env["HOME"]}/.config`]); - - return actualVersion.trim(); -}; - - -/***/ }), - -/***/ 203: -/***/ (function(module) { - -/** - * @param {string} str - * @returns {string} - */ -module.exports = function capitalize(str) { - if (typeof str === "string") { - return str.charAt(0).toUpperCase() + str.slice(1); - } - return ""; -}; - - /***/ }), /***/ 211: @@ -2176,69 +2809,6 @@ exports.paginatingEndpoints = paginatingEndpoints; //# sourceMappingURL=index.js.map -/***/ }), - -/***/ 302: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const { exec } = __webpack_require__(986); -const npmArgs = __webpack_require__(510); - -/** - * @param {import("@actions/exec").ExecOptions?} options - * @returns {Promise>} - */ -module.exports = async function listPackages(options = {}) { - let lines = ""; - let stderr = ""; - const returnCode = await exec("npm", npmArgs("ls", "--parseable", "--long", "--all"), { - listeners: { - stdout: (data) => { - lines += data.toString(); - }, - stderr: (data) => { - stderr += data.toString(); - }, - }, - ignoreReturnCode: true, - ...options, - }); - - // NOTE: Ignore missing peer deps error. - if (returnCode !== 0 && !stderr.includes("npm ERR! missing:")) { - throw new Error(`"npm ls" failed`); - } - - const packages = /** @type {Map} */ new Map(); - lines - .split("\n") - .filter((line) => line.trim()) - .forEach((line) => { - const [, pkg] = line.split(":", 2); - if (pkg == null) { - throw new Error(`Invalid line: "${line}"`); - } - - const match = /^(?@?\S+)@(?\S+)$/u.exec(pkg); - if (match == null || match.groups == null) { - return; // skip - } - - /* eslint-disable dot-notation, prefer-destructuring -- Prevent TS4111 */ - const name = match.groups["name"]; - const version = match.groups["version"]; - /* eslint-enable */ - - if (name == null || version == null) { - throw new Error(`Invalid name and version: "${line}"`); - } - - packages.set(name.trim(), version.trim()); - }); - return packages; -}; - - /***/ }), /***/ 357: @@ -2660,91 +3230,6 @@ module.exports = function (Yallist) { } -/***/ }), - -/***/ 405: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const { info } = __webpack_require__(470); -const { exec } = __webpack_require__(986); -const hostedGitInfo = __webpack_require__(190); - -/** - * @type {Map} - */ -const cache = new Map(); - -/** - * @param {string} packageName - * @returns {Promise} - */ -async function fetchUrl(packageName) { - const cached = cache.get(packageName); - if (cached) { - return cached; - } - - let stdout = ""; - let stderr = ""; - try { - await exec("npm", ["view", packageName, "repository.url"], { - listeners: { - stdout: (data) => { - stdout += data.toString(); - }, - stderr: (data) => { - stderr += data.toString(); - }, - }, - silent: true, - }); - } catch (err) { - // code E404 means the package does not exist on npm - // which means it is a file: or git: dependency - // We are fine with 404 errors, but not with any other errors - if (!stderr.includes("code E404")) { - throw new Error(stderr); - } - } - stdout = stdout.trim(); - - if (!stdout) { - info(`No repository URL for '${packageName}'`); - return null; - } - - const url = hostedGitInfo.fromUrl(stdout); - if (!url) { - info(`No repository URL for '${packageName}'`); - return null; - } - const urlInfo = { name: packageName, url: url.browse(), type: url.type }; - - cache.set(packageName, urlInfo); - - return urlInfo; -} - -/** - * @param {string[]} packageNames - * @returns {Promise>} - */ -module.exports = async function packageRepoUrls(packageNames) { - const allUrls = await Promise.all(packageNames.map(fetchUrl)); - - /** - * @type {Record} - */ - const map = {}; - for (const url of allUrls) { - if (url) { - map[url.name] = url; - } - } - return map; -}; - - /***/ }), /***/ 413: @@ -3048,7 +3533,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var Stream = _interopDefault(__webpack_require__(794)); -var http = _interopDefault(__webpack_require__(876)); +var http = _interopDefault(__webpack_require__(605)); var Url = _interopDefault(__webpack_require__(835)); var https = _interopDefault(__webpack_require__(211)); var zlib = _interopDefault(__webpack_require__(761)); @@ -4692,24 +5177,6 @@ exports.Response = Response; exports.FetchError = FetchError; -/***/ }), - -/***/ 461: -/***/ (function(module) { - -/** - * @param {string} repository - * @returns {{ owner: string, repo: string }} - */ -module.exports = function splitRepo(repository) { - const [owner, repo] = repository.split("/"); - if (owner && repo) { - return { owner, repo }; - } - throw new TypeError(`invalid repository: "${repository}"`); -}; - - /***/ }), /***/ 463: @@ -5107,12 +5574,52 @@ exports.getState = getState; /***/ 510: /***/ (function(module) { -/** - * @param {string[]} args - */ -module.exports = function npmArgs(...args) { - return [...args, "--ignore-scripts", "--no-progress"]; -}; +module.exports = addHook; + +function addHook(state, kind, name, hook) { + var orig = hook; + if (!state.registry[name]) { + state.registry[name] = []; + } + + if (kind === "before") { + hook = function (method, options) { + return Promise.resolve() + .then(orig.bind(null, options)) + .then(method.bind(null, options)); + }; + } + + if (kind === "after") { + hook = function (method, options) { + var result; + return Promise.resolve() + .then(method.bind(null, options)) + .then(function (result_) { + result = result_; + return orig(result, options); + }) + .then(function () { + return result; + }); + }; + } + + if (kind === "error") { + hook = function (method, options) { + return Promise.resolve() + .then(method.bind(null, options)) + .catch(function (error) { + return orig(error, options); + }); + }; + } + + state.registry[name].push({ + hook: hook, + orig: orig, + }); +} /***/ }), @@ -5182,7 +5689,7 @@ exports.getOctokitOptions = getOctokitOptions; /***/ (function(module, __unusedexports, __webpack_require__) { var register = __webpack_require__(280) -var addHook = __webpack_require__(838) +var addHook = __webpack_require__(510) var removeHook = __webpack_require__(866) // bind with array of arguments: https://stackoverflow.com/a/21792913 @@ -5240,117 +5747,6 @@ module.exports.Singular = Hook.Singular module.exports.Collection = Hook.Collection -/***/ }), - -/***/ 526: -/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) { - -const core = __webpack_require__(470); -const { exec } = __webpack_require__(986); - -const { NPM_VERSION } = __webpack_require__(32); -const audit = __webpack_require__(50); -const auditFix = __webpack_require__(905); -const npmArgs = __webpack_require__(510); -const updateNpm = __webpack_require__(193); -const listPackages = __webpack_require__(302); -const aggregateReport = __webpack_require__(599); -const buildPullRequestBody = __webpack_require__(603); -const buildCommitBody = __webpack_require__(605); -const createOrUpdatePullRequest = __webpack_require__(583); -const getDefaultBranch = __webpack_require__(686); -const commaSeparatedList = __webpack_require__(604); - -/** - * @returns {Promise} - */ -async function filesChanged() { - try { - const exitCode = await exec("git", ["diff", "--exit-code"]); - return exitCode === 0; - } catch (err) { - return false; - } -} - -/** - * @param {string} name - * @returns {string} - */ -function getFromEnv(name) { - const value = process.env[name]; - if (value) { - return value; - } - throw new Error(`Not found '${name}' in the environment variables`); -} - -async function run() { - const npmVersion = await core.group(`Update npm to ${NPM_VERSION}`, () => updateNpm(NPM_VERSION)); - - await core.group("Install user packages", async () => { - await exec("npm", npmArgs("ci")); - }); - - const auditReport = await core.group("Get audit report", async () => { - const res = await audit(); - core.info(JSON.stringify(res, null, 2)); - return res; - }); - - const beforePackages = await core.group("List packages before", () => listPackages()); - - await core.group("Fix vulnerabilities", () => auditFix()); - - await core.group("Re-install user packages", async () => { - await exec("npm", npmArgs("ci")); - }); - - const afterPackages = await core.group("List packages after", () => listPackages()); - - const report = await core.group("Aggregate report", () => - aggregateReport(auditReport, beforePackages, afterPackages) - ); - - if (report.packageCount === 0) { - core.info("No update."); - return; - } - - const changed = await core.group("Check file changes", filesChanged); - if (changed) { - core.info("No file changes."); - return; - } - - await core.group("Create or update a pull request", async () => { - const token = core.getInput("github_token"); - const repository = getFromEnv("GITHUB_REPOSITORY"); - - let baseBranch = core.getInput("default_branch"); - if (!baseBranch) { - baseBranch = await getDefaultBranch({ token, repository }); - } - - const author = getFromEnv("GITHUB_ACTOR"); - return createOrUpdatePullRequest({ - branch: core.getInput("branch"), - token, - baseBranch, - title: core.getInput("commit_title"), - pullBody: buildPullRequestBody(report, npmVersion), - commitBody: buildCommitBody(report), - repository, - author, - email: `${author}@users.noreply.github.com`, - labels: commaSeparatedList(core.getInput("labels")), - }); - }); -} - -run().catch((e) => core.setFailed(e.message)); - - /***/ }), /***/ 539: @@ -5359,7 +5755,7 @@ run().catch((e) => core.setFailed(e.message)); "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const http = __webpack_require__(876); +const http = __webpack_require__(605); const https = __webpack_require__(211); const pm = __webpack_require__(950); let tunnel; @@ -5853,382 +6249,173 @@ class HttpClient { let obj; let contents; // get the result from the body - try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; - } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null - } - // note that 3xx redirects are handled by the http layer. - if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = 'Failed request: (' + statusCode + ')'; - } - let err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); - } - else { - resolve(response); - } - }); - } -} -exports.HttpClient = HttpClient; - - -/***/ }), - -/***/ 583: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const { info } = __webpack_require__(470); -const { exec } = __webpack_require__(986); -const github = __webpack_require__(469); -const splitRepo = __webpack_require__(461); - -/** - * @param {{ - * token: string, - * branch: string, - * baseBranch: string, - * title: string, - * pullBody: string, - * commitBody: string, - * repository: string, - * author: string, - * email: string, - * labels: string[], - * }} params - */ -module.exports = async function createOrUpdatePullRequest({ - token, - branch, - baseBranch, - title, - pullBody, - commitBody, - repository, - author, - email, - labels, -}) { - const remote = `https://${author}:${token}@github.com/${repository}.git`; - const { owner, repo } = splitRepo(repository); - const octokit = github.getOctokit(token); - - // Find pull request - const pulls = await octokit.rest.pulls.list({ - owner, - repo, - state: "open", - base: baseBranch, - sort: "updated", - direction: "desc", - per_page: 100, - }); - const pull = pulls.data.find(({ head }) => head.ref === branch); - - await exec("git", ["config", "user.name", author]); - await exec("git", ["config", "user.email", email]); - await exec("git", ["add", "package-lock.json"]); - await exec("git", ["commit", "--message", `${title}\n\n${commitBody}`]); - await exec("git", ["checkout", "-B", branch]); - await exec("git", ["push", remote, `HEAD:${branch}`, ...(pull ? ["--force"] : [])]); - - if (pull) { - await octokit.rest.pulls.update({ - owner, - repo, - pull_number: pull.number, - title, - body: pullBody, - }); - info(`The pull request was updated successfully: ${pull.html_url}`); - } else { - const newPull = await octokit.rest.pulls.create({ - owner, - repo, - title, - body: pullBody, - head: branch, - base: baseBranch, - }); - info(`The pull request was created successfully: ${newPull.data.html_url}`); - - const newLabels = await octokit.rest.issues.addLabels({ - owner, - repo, - issue_number: newPull.data.number, - labels, - }); - info(`The labels were added successfully: ${newLabels.data.map((l) => l.name).join(", ")}`); - } -}; - - -/***/ }), - -/***/ 599: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const capitalize = __webpack_require__(203); -const semverToNumber = __webpack_require__(915); -const packageRepoUrls = __webpack_require__(405); - -/** - * @param {{ name: string, version: string }} a - * @param {{ name: string, version: string }} b - * @returns {number} - */ -const byNameAndVersion = (a, b) => { - const res = a.name.localeCompare(b.name); - if (res > 0) { - return 1; - } - if (res < 0) { - return -1; - } - return semverToNumber(a.version) - semverToNumber(b.version); -}; - -/** - * @param {AuditReport} audit - * @param {Map} beforePackages - * @param {Map} afterPackages - * @returns {Promise} - */ -module.exports = async function aggregateReport(audit, beforePackages, afterPackages) { - /** @type {Report["added"]} */ - const added = []; - afterPackages.forEach((version, name) => { - if (!beforePackages.has(name)) { - added.push({ name, version }); - } - }); - added.sort(byNameAndVersion); - - /** @type {Report["removed"]} */ - const removed = []; - beforePackages.forEach((version, name) => { - if (!afterPackages.has(name)) { - removed.push({ name, version }); - } - }); - removed.sort(byNameAndVersion); - - /** @type {Report["updated"]} */ - const updated = []; - afterPackages.forEach((version, name) => { - const previousVersion = beforePackages.get(name); - if (version !== previousVersion && previousVersion != null) { - const info = audit.get(name); - const severity = info == null ? null : capitalize(info.severity); - const title = info == null ? null : info.title; - const url = info == null ? null : info.url; - updated.push({ name, version, previousVersion, severity, title, url }); + try { + contents = await res.readBody(); + if (contents && contents.length > 0) { + if (options && options.deserializeDates) { + obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); + } + else { + obj = JSON.parse(contents); + } + response.result = obj; + } + response.headers = res.message.headers; + } + catch (err) { + // Invalid resource (contents not json); leaving result obj null + } + // note that 3xx redirects are handled by the http layer. + if (statusCode > 299) { + let msg; + // if exception/error in body, attempt to get better error + if (obj && obj.message) { + msg = obj.message; + } + else if (contents && contents.length > 0) { + // it may be the case that the exception is in the body message as string + msg = contents; + } + else { + msg = 'Failed request: (' + statusCode + ')'; + } + let err = new HttpClientError(msg, statusCode); + err.result = response.result; + reject(err); + } + else { + resolve(response); + } + }); } - }); - updated.sort(byNameAndVersion); - - const allPackageNames = Array.from( - new Set([ - ...added.map((e) => e.name), - ...updated.map((e) => e.name), - ...removed.map((e) => e.name), - ]) - ); - const packageCount = allPackageNames.length; - const packageUrls = await packageRepoUrls(allPackageNames); - - return { added, removed, updated, packageCount, packageUrls }; -}; +} +exports.HttpClient = HttpClient; /***/ }), -/***/ 603: +/***/ 599: /***/ (function(module, __unusedexports, __webpack_require__) { -const { PACKAGE_NAME, PACKAGE_URL } = __webpack_require__(32); - -const EMPTY = "-"; +"use strict"; -/** - * @param {Report} report - * @param {string} npmVersion - * @returns {string} - */ -module.exports = function buildPullRequestBody(report, npmVersion) { - /** - * @param {string} name - * @param {string} version - */ - const npmPackage = (name, version) => - `[${name}](https://www.npmjs.com/package/${name}/v/${version})`; +const gitHosts = __webpack_require__(813) - /** - * @param {...string} items - */ - const buildTableRow = (...items) => `| ${items.join(" | ")} |`; +class GitHost { + constructor (type, user, auth, project, committish, defaultRepresentation, opts = {}) { + Object.assign(this, gitHosts[type]) + this.type = type + this.user = user + this.auth = auth + this.project = project + this.committish = committish + this.default = defaultRepresentation + this.opts = opts + } - /** - * @param {string} name - * @returns {string} - */ - const repoLink = (name) => { - const url = report.packageUrls[name]; - return url ? `[${url.type}](${url.url})` : EMPTY; - }; + hash () { + return this.committish ? `#${this.committish}` : '' + } - /** - * @param {string} version - * @returns {string} - */ - const versionLabel = (version) => `\`${version}\``; + ssh (opts) { + return this._fill(this.sshtemplate, opts) + } - const header = []; - header.push("| Package | Version | Source | Detail |"); - header.push("|:--------|:-------:|:------:|:-------|"); + _fill (template, opts) { + if (typeof template === 'function') { + const options = { ...this, ...this.opts, ...opts } - const lines = []; - lines.push( - `This pull request fixes the vulnerable packages via npm [${npmVersion}](https://github.com/npm/cli/releases/tag/v${npmVersion}).` - ); + // the path should always be set so we don't end up with 'undefined' in urls + if (!options.path) { + options.path = '' + } - if (report.updated.length > 0) { - lines.push(""); - lines.push("
"); - lines.push(`Updated (${report.updated.length})`); - lines.push(""); - lines.push(...header); + // template functions will insert the leading slash themselves + if (options.path.startsWith('/')) { + options.path = options.path.slice(1) + } - report.updated.forEach(({ name, version, previousVersion, severity, title, url }) => { - let extra = EMPTY; - if (severity != null && title != null && url != null) { - extra = `**[${severity}]** ${title} ([ref](${url}))`; + if (options.noCommittish) { + options.committish = null } - lines.push( - buildTableRow( - npmPackage(name, version), - `${versionLabel(previousVersion)} → ${versionLabel(version)}`, - repoLink(name), - extra - ) - ); - }); - lines.push(""); - lines.push("
"); - } + const result = template(options) + return options.noGitPlus && result.startsWith('git+') ? result.slice(4) : result + } - if (report.added.length > 0) { - lines.push(""); - lines.push("
"); - lines.push(`Added (${report.added.length})`); - lines.push(""); - lines.push(...header); - report.added.forEach(({ name, version }) => { - lines.push( - buildTableRow(npmPackage(name, version), versionLabel(version), repoLink(name), EMPTY) - ); - }); - lines.push(""); - lines.push("
"); + return null } - if (report.removed.length > 0) { - lines.push(""); - lines.push("
"); - lines.push(`Removed (${report.removed.length})`); - lines.push(""); - lines.push(...header); - report.removed.forEach(({ name, version }) => { - lines.push( - buildTableRow(npmPackage(name, version), versionLabel(version), repoLink(name), EMPTY) - ); - }); - lines.push(""); - lines.push("
"); + sshurl (opts) { + return this._fill(this.sshurltemplate, opts) } - lines.push(""); - lines.push("***"); - lines.push(""); - lines.push(`Created by [${PACKAGE_NAME}](${PACKAGE_URL})`); - - return lines.join("\n").trim(); -}; + browse (path, fragment, opts) { + // not a string, treat path as opts + if (typeof path !== 'string') { + return this._fill(this.browsetemplate, path) + } + if (typeof fragment !== 'string') { + opts = fragment + fragment = null + } + return this._fill(this.browsefiletemplate, { ...opts, fragment, path }) + } -/***/ }), + docs (opts) { + return this._fill(this.docstemplate, opts) + } -/***/ 604: -/***/ (function(module) { + bugs (opts) { + return this._fill(this.bugstemplate, opts) + } -/** - * @param {string} str - * @returns {string[]} - */ -module.exports = function commaSeparatedList(str) { - return str - .split(",") - .map((s) => s.trim()) - .filter(Boolean); -}; + https (opts) { + return this._fill(this.httpstemplate, opts) + } + git (opts) { + return this._fill(this.gittemplate, opts) + } -/***/ }), + shortcut (opts) { + return this._fill(this.shortcuttemplate, opts) + } -/***/ 605: -/***/ (function(module) { + path (opts) { + return this._fill(this.pathtemplate, opts) + } -/** - * @param {Report} report - * @returns {string} - */ -module.exports = function buildCommitBody(report) { - const lines = []; + tarball (opts) { + return this._fill(this.tarballtemplate, { ...opts, noCommittish: false }) + } - lines.push("Summary:"); - lines.push(`- Updated packages: ${report.updated.length}`); - lines.push(`- Added packages: ${report.added.length}`); - lines.push(`- Removed packages: ${report.removed.length}`); + file (path, opts) { + return this._fill(this.filetemplate, { ...opts, path }) + } - lines.push(""); - if (report.updated.length > 0) { - lines.push("Fixed vulnerabilities:"); - report.updated.forEach(({ name, severity, title, url }) => { - if (severity != null && title != null && url != null) { - lines.push(`- ${name}: "${title}" (${url})`); - } - }); - } else { - lines.push("No fixed vulnerabilities."); + getDefaultRepresentation () { + return this.default } - return lines.map((line) => `${line}\n`).join(""); -}; + toString (opts) { + if (this.default && typeof this[this.default] === 'function') { + return this[this.default](opts) + } + + return this.sshurl(opts) + } +} +module.exports = GitHost + + +/***/ }), + +/***/ 605: +/***/ (function(module) { +module.exports = require("http"); /***/ }), @@ -6894,25 +7081,6 @@ function isUnixExecutable(stats) { } //# sourceMappingURL=io-util.js.map -/***/ }), - -/***/ 686: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const github = __webpack_require__(469); -const splitRepo = __webpack_require__(461); - -/** - * @param {{token: string, repository: string}} params - * @returns {Promise} - */ -module.exports = async function getDefaultBranch({ token, repository }) { - const octokit = github.getOctokit(token); - const res = await octokit.rest.repos.get(splitRepo(repository)); - return res.data.default_branch; -}; - - /***/ }), /***/ 692: @@ -7703,59 +7871,6 @@ module.exports = gitHosts module.exports = require("url"); -/***/ }), - -/***/ 838: -/***/ (function(module) { - -module.exports = addHook; - -function addHook(state, kind, name, hook) { - var orig = hook; - if (!state.registry[name]) { - state.registry[name] = []; - } - - if (kind === "before") { - hook = function (method, options) { - return Promise.resolve() - .then(orig.bind(null, options)) - .then(method.bind(null, options)); - }; - } - - if (kind === "after") { - hook = function (method, options) { - var result; - return Promise.resolve() - .then(method.bind(null, options)) - .then(function (result_) { - result = result_; - return orig(result, options); - }) - .then(function () { - return result; - }); - }; - } - - if (kind === "error") { - hook = function (method, options) { - return Promise.resolve() - .then(method.bind(null, options)) - .catch(function (error) { - return orig(error, options); - }); - }; - } - - state.registry[name].push({ - hook: hook, - orig: orig, - }); -} - - /***/ }), /***/ 842: @@ -9028,13 +9143,6 @@ function removeHook(state, name, method) { } -/***/ }), - -/***/ 876: -/***/ (function(module) { - -module.exports = require("http"); - /***/ }), /***/ 898: @@ -9159,59 +9267,6 @@ exports.withCustomRequest = withCustomRequest; //# sourceMappingURL=index.js.map -/***/ }), - -/***/ 905: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const { warning } = __webpack_require__(470); -const { exec } = __webpack_require__(986); -const npmArgs = __webpack_require__(510); - -module.exports = async function auditFix() { - let error = ""; - - const returnCode = await exec("npm", npmArgs("audit", "fix"), { - listeners: { - stderr: (data) => { - error += data.toString(); - }, - }, - ignoreReturnCode: true, - }); - - if (error.includes("npm ERR!")) { - throw new Error("Unexpected error occurred"); - } - - if (returnCode !== 0) { - warning(error); - } -}; - - -/***/ }), - -/***/ 915: -/***/ (function(module) { - -/** - * @param {string} version - * @returns {number} - */ -module.exports = function semverToNumber(version) { - return version - .split(".") - .slice(0, 3) - .reverse() - .map((str) => parseInt(str, 10)) - .reduce((sum, num, idx) => { - const added = num * 10 ** (idx * 2) || 0; - return sum + added; - }, 0); -}; - - /***/ }), /***/ 950: @@ -9277,124 +9332,6 @@ function checkBypass(reqUrl) { exports.checkBypass = checkBypass; -/***/ }), - -/***/ 982: -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - -const gitHosts = __webpack_require__(813) - -class GitHost { - constructor (type, user, auth, project, committish, defaultRepresentation, opts = {}) { - Object.assign(this, gitHosts[type]) - this.type = type - this.user = user - this.auth = auth - this.project = project - this.committish = committish - this.default = defaultRepresentation - this.opts = opts - } - - hash () { - return this.committish ? `#${this.committish}` : '' - } - - ssh (opts) { - return this._fill(this.sshtemplate, opts) - } - - _fill (template, opts) { - if (typeof template === 'function') { - const options = { ...this, ...this.opts, ...opts } - - // the path should always be set so we don't end up with 'undefined' in urls - if (!options.path) { - options.path = '' - } - - // template functions will insert the leading slash themselves - if (options.path.startsWith('/')) { - options.path = options.path.slice(1) - } - - if (options.noCommittish) { - options.committish = null - } - - const result = template(options) - return options.noGitPlus && result.startsWith('git+') ? result.slice(4) : result - } - - return null - } - - sshurl (opts) { - return this._fill(this.sshurltemplate, opts) - } - - browse (path, fragment, opts) { - // not a string, treat path as opts - if (typeof path !== 'string') { - return this._fill(this.browsetemplate, path) - } - - if (typeof fragment !== 'string') { - opts = fragment - fragment = null - } - return this._fill(this.browsefiletemplate, { ...opts, fragment, path }) - } - - docs (opts) { - return this._fill(this.docstemplate, opts) - } - - bugs (opts) { - return this._fill(this.bugstemplate, opts) - } - - https (opts) { - return this._fill(this.httpstemplate, opts) - } - - git (opts) { - return this._fill(this.gittemplate, opts) - } - - shortcut (opts) { - return this._fill(this.shortcuttemplate, opts) - } - - path (opts) { - return this._fill(this.pathtemplate, opts) - } - - tarball (opts) { - return this._fill(this.tarballtemplate, { ...opts, noCommittish: false }) - } - - file (path, opts) { - return this._fill(this.filetemplate, { ...opts, path }) - } - - getDefaultRepresentation () { - return this.default - } - - toString (opts) { - if (this.default && typeof this[this.default] === 'function') { - return this[this.default](opts) - } - - return this.sshurl(opts) - } -} -module.exports = GitHost - - /***/ }), /***/ 986: @@ -9448,4 +9385,62 @@ exports.exec = exec; /***/ }) -/******/ }); \ No newline at end of file +/******/ }, +/******/ function(__webpack_require__) { // webpackRuntimeModules +/******/ "use strict"; +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ !function() { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getter */ +/******/ !function() { +/******/ // define getter function for harmony exports +/******/ var hasOwnProperty = Object.prototype.hasOwnProperty; +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!hasOwnProperty.call(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/create fake namespace object */ +/******/ !function() { +/******/ // 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); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ } +); \ No newline at end of file diff --git a/lib/__tests__/aggregateReport.test.js b/lib/__tests__/aggregateReport.test.js index 83f3d1b8..b7b370a4 100644 --- a/lib/__tests__/aggregateReport.test.js +++ b/lib/__tests__/aggregateReport.test.js @@ -1,4 +1,4 @@ -const aggregateReport = require("../aggregateReport"); +import aggregateReport from "../aggregateReport.js"; test("aggregateReport()", async () => { const audit = new Map(); diff --git a/lib/__tests__/audit.test.js b/lib/__tests__/audit.test.js index d51bc1a4..52938cfd 100644 --- a/lib/__tests__/audit.test.js +++ b/lib/__tests__/audit.test.js @@ -1,9 +1,16 @@ -const audit = require("../audit"); -const auditJson = require("./fixtures/audit.json"); -const auditJson2 = require("./fixtures/audit-2.json"); +import { readFileSync } from "fs"; +import { jest } from "@jest/globals"; // eslint-disable-line import/no-extraneous-dependencies +import audit from "../audit.js"; + +// @ts-expect-error +const fixture = (path) => new URL(`./fixtures/${path}`, import.meta.url); + +const auditJson = JSON.parse(readFileSync(fixture("audit.json"), "utf8")); +const auditJson2 = JSON.parse(readFileSync(fixture("audit-2.json"), "utf8")); const mockExec = (/** @type {unknown} */ json) => jest.fn().mockImplementationOnce((_1, _2, options) => { + // @ts-expect-error options.listeners.stdout(JSON.stringify(json)); }); diff --git a/lib/__tests__/buildCommitBody.test.js b/lib/__tests__/buildCommitBody.test.js index 07282f82..72de18da 100644 --- a/lib/__tests__/buildCommitBody.test.js +++ b/lib/__tests__/buildCommitBody.test.js @@ -1,5 +1,8 @@ -const buildCommitBody = require("../buildCommitBody"); -const report = require("./fixtures/report.json"); +import { readFileSync } from "fs"; +import buildCommitBody from "../buildCommitBody.js"; + +// @ts-expect-error +const report = JSON.parse(readFileSync(new URL("./fixtures/report.json", import.meta.url), "utf8")); test("buildCommitBody()", () => { expect(buildCommitBody(report)).toEqual(`Summary: diff --git a/lib/__tests__/buildPullRequestBody.test.js b/lib/__tests__/buildPullRequestBody.test.js index 5207a472..3f5e113b 100644 --- a/lib/__tests__/buildPullRequestBody.test.js +++ b/lib/__tests__/buildPullRequestBody.test.js @@ -1,5 +1,8 @@ -const buildPullRequestBody = require("../buildPullRequestBody"); -const report = require("./fixtures/report.json"); +import { readFileSync } from "fs"; +import buildPullRequestBody from "../buildPullRequestBody.js"; + +// @ts-expect-error +const report = JSON.parse(readFileSync(new URL("./fixtures/report.json", import.meta.url), "utf8")); test("buildPullRequestBody()", () => { expect(buildPullRequestBody(report, "7.7.0")).toBe( diff --git a/lib/__tests__/listPackages.test.js b/lib/__tests__/listPackages.test.js index 21a3ebf9..194e9054 100644 --- a/lib/__tests__/listPackages.test.js +++ b/lib/__tests__/listPackages.test.js @@ -1,6 +1,8 @@ -const path = require("path"); +import path from "path"; +import listPackages from "../listPackages.js"; -const listPackages = require("../listPackages"); +// @ts-expect-error +const fixtures = new URL("./fixtures", import.meta.url).pathname; test("listPackages()", async () => { const packages = await listPackages({ silent: true }); @@ -12,7 +14,7 @@ test("listPackages()", async () => { test("listPackages() with an empty package.json", async () => { const packages = await listPackages({ silent: true, - cwd: path.join(__dirname, "fixtures", "empty_package.json"), + cwd: path.join(fixtures, "empty_package.json"), }); expect(packages.size).toEqual(0); }); @@ -20,7 +22,7 @@ test("listPackages() with an empty package.json", async () => { test("listPackages() with a package.json having no version", async () => { const packages = await listPackages({ silent: true, - cwd: path.join(__dirname, "fixtures", "noversion_package.json"), + cwd: path.join(fixtures, "noversion_package.json"), }); expect(packages.size).toEqual(0); }); diff --git a/lib/__tests__/npmArgs.test.js b/lib/__tests__/npmArgs.test.js index 62bb73e9..d3c1d2da 100644 --- a/lib/__tests__/npmArgs.test.js +++ b/lib/__tests__/npmArgs.test.js @@ -1,4 +1,4 @@ -const npmArgs = require("../npmArgs"); +import npmArgs from "../npmArgs.js"; test("npmArgs() without arguments", () => { expect(npmArgs()).toEqual(["--ignore-scripts", "--no-progress"]); diff --git a/lib/aggregateReport.js b/lib/aggregateReport.js index 328dd9c2..3ff97aa8 100644 --- a/lib/aggregateReport.js +++ b/lib/aggregateReport.js @@ -1,6 +1,6 @@ -const capitalize = require("./utils/capitalize"); -const semverToNumber = require("./utils/semverToNumber"); -const packageRepoUrls = require("./packageRepoUrls"); +import packageRepoUrls from "./packageRepoUrls.js"; +import capitalize from "./utils/capitalize.js"; +import semverToNumber from "./utils/semverToNumber.js"; /** * @param {{ name: string, version: string }} a @@ -24,7 +24,7 @@ const byNameAndVersion = (a, b) => { * @param {Map} afterPackages * @returns {Promise} */ -module.exports = async function aggregateReport(audit, beforePackages, afterPackages) { +export default async function aggregateReport(audit, beforePackages, afterPackages) { /** @type {Report["added"]} */ const added = []; afterPackages.forEach((version, name) => { @@ -68,4 +68,4 @@ module.exports = async function aggregateReport(audit, beforePackages, afterPack const packageUrls = await packageRepoUrls(allPackageNames); return { added, removed, updated, packageCount, packageUrls }; -}; +} diff --git a/lib/audit.js b/lib/audit.js index efd34ba6..6e08a396 100644 --- a/lib/audit.js +++ b/lib/audit.js @@ -1,11 +1,11 @@ -const { exec } = require("@actions/exec"); -const npmArgs = require("./npmArgs"); +import { exec } from "@actions/exec"; +import npmArgs from "./npmArgs.js"; /** * @param {typeof exec} execFn * @returns {Promise} */ -module.exports = async function audit(execFn = exec) { +export default async function audit(execFn = exec) { let report = ""; await execFn("npm", npmArgs("audit", "--json"), { listeners: { @@ -39,4 +39,4 @@ module.exports = async function audit(execFn = exec) { } throw new Error('"vulnerabilities" is missing'); -}; +} diff --git a/lib/auditFix.js b/lib/auditFix.js index f5e0db40..4a8663c3 100644 --- a/lib/auditFix.js +++ b/lib/auditFix.js @@ -1,8 +1,8 @@ -const { warning } = require("@actions/core"); -const { exec } = require("@actions/exec"); -const npmArgs = require("./npmArgs"); +import { warning } from "@actions/core"; +import { exec } from "@actions/exec"; +import npmArgs from "./npmArgs.js"; -module.exports = async function auditFix() { +export default async function auditFix() { let error = ""; const returnCode = await exec("npm", npmArgs("audit", "fix"), { @@ -21,4 +21,4 @@ module.exports = async function auditFix() { if (returnCode !== 0) { warning(error); } -}; +} diff --git a/lib/buildCommitBody.js b/lib/buildCommitBody.js index 4e15d95b..b5c60533 100644 --- a/lib/buildCommitBody.js +++ b/lib/buildCommitBody.js @@ -2,7 +2,7 @@ * @param {Report} report * @returns {string} */ -module.exports = function buildCommitBody(report) { +export default function buildCommitBody(report) { const lines = []; lines.push("Summary:"); @@ -23,4 +23,4 @@ module.exports = function buildCommitBody(report) { } return lines.map((line) => `${line}\n`).join(""); -}; +} diff --git a/lib/buildPullRequestBody.js b/lib/buildPullRequestBody.js index 9473db5f..7aa8f633 100644 --- a/lib/buildPullRequestBody.js +++ b/lib/buildPullRequestBody.js @@ -1,4 +1,4 @@ -const { PACKAGE_NAME, PACKAGE_URL } = require("./constants"); +import { PACKAGE_NAME, PACKAGE_URL } from "./constants.js"; const EMPTY = "-"; @@ -7,7 +7,7 @@ const EMPTY = "-"; * @param {string} npmVersion * @returns {string} */ -module.exports = function buildPullRequestBody(report, npmVersion) { +export default function buildPullRequestBody(report, npmVersion) { /** * @param {string} name * @param {string} version @@ -106,4 +106,4 @@ module.exports = function buildPullRequestBody(report, npmVersion) { lines.push(`Created by [${PACKAGE_NAME}](${PACKAGE_URL})`); return lines.join("\n").trim(); -}; +} diff --git a/lib/constants.js b/lib/constants.js index 6bcfa7d2..460b3532 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -1,3 +1,3 @@ -module.exports.PACKAGE_NAME = "ybiquitous/npm-audit-fix-action"; -module.exports.PACKAGE_URL = "https://github.com/ybiquitous/npm-audit-fix-action"; -module.exports.NPM_VERSION = "7"; +export const PACKAGE_NAME = "ybiquitous/npm-audit-fix-action"; +export const PACKAGE_URL = "https://github.com/ybiquitous/npm-audit-fix-action"; +export const NPM_VERSION = "7"; diff --git a/lib/createOrUpdatePullRequest.js b/lib/createOrUpdatePullRequest.js index 84d3be4f..c4b92396 100644 --- a/lib/createOrUpdatePullRequest.js +++ b/lib/createOrUpdatePullRequest.js @@ -1,7 +1,7 @@ -const { info } = require("@actions/core"); -const { exec } = require("@actions/exec"); -const github = require("@actions/github"); -const splitRepo = require("./utils/splitRepo"); +import { info } from "@actions/core"; +import { exec } from "@actions/exec"; +import * as github from "@actions/github"; +import splitRepo from "./utils/splitRepo.js"; /** * @param {{ @@ -17,7 +17,7 @@ const splitRepo = require("./utils/splitRepo"); * labels: string[], * }} params */ -module.exports = async function createOrUpdatePullRequest({ +export default async function createOrUpdatePullRequest({ token, branch, baseBranch, @@ -80,4 +80,4 @@ module.exports = async function createOrUpdatePullRequest({ }); info(`The labels were added successfully: ${newLabels.data.map((l) => l.name).join(", ")}`); } -}; +} diff --git a/lib/getDefaultBranch.js b/lib/getDefaultBranch.js index ac179a67..eb89003d 100644 --- a/lib/getDefaultBranch.js +++ b/lib/getDefaultBranch.js @@ -1,12 +1,12 @@ -const github = require("@actions/github"); -const splitRepo = require("./utils/splitRepo"); +import { getOctokit } from "@actions/github"; +import splitRepo from "./utils/splitRepo.js"; /** * @param {{token: string, repository: string}} params * @returns {Promise} */ -module.exports = async function getDefaultBranch({ token, repository }) { - const octokit = github.getOctokit(token); +export default async function getDefaultBranch({ token, repository }) { + const octokit = getOctokit(token); const res = await octokit.rest.repos.get(splitRepo(repository)); return res.data.default_branch; -}; +} diff --git a/lib/index.js b/lib/index.js index dad1f035..4e0e607b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,18 +1,17 @@ -const core = require("@actions/core"); -const { exec } = require("@actions/exec"); - -const { NPM_VERSION } = require("./constants"); -const audit = require("./audit"); -const auditFix = require("./auditFix"); -const npmArgs = require("./npmArgs"); -const updateNpm = require("./updateNpm"); -const listPackages = require("./listPackages"); -const aggregateReport = require("./aggregateReport"); -const buildPullRequestBody = require("./buildPullRequestBody"); -const buildCommitBody = require("./buildCommitBody"); -const createOrUpdatePullRequest = require("./createOrUpdatePullRequest"); -const getDefaultBranch = require("./getDefaultBranch"); -const commaSeparatedList = require("./utils/commaSeparatedList"); +import * as core from "@actions/core"; +import { exec } from "@actions/exec"; +import aggregateReport from "./aggregateReport.js"; +import audit from "./audit.js"; +import auditFix from "./auditFix.js"; +import buildCommitBody from "./buildCommitBody.js"; +import buildPullRequestBody from "./buildPullRequestBody.js"; +import { NPM_VERSION } from "./constants.js"; +import createOrUpdatePullRequest from "./createOrUpdatePullRequest.js"; +import getDefaultBranch from "./getDefaultBranch.js"; +import listPackages from "./listPackages.js"; +import npmArgs from "./npmArgs.js"; +import updateNpm from "./updateNpm.js"; +import commaSeparatedList from "./utils/commaSeparatedList.js"; /** * @returns {Promise} diff --git a/lib/listPackages.js b/lib/listPackages.js index 8073c82b..d637e235 100644 --- a/lib/listPackages.js +++ b/lib/listPackages.js @@ -1,11 +1,11 @@ -const { exec } = require("@actions/exec"); -const npmArgs = require("./npmArgs"); +import { exec } from "@actions/exec"; +import npmArgs from "./npmArgs.js"; /** * @param {import("@actions/exec").ExecOptions?} options * @returns {Promise>} */ -module.exports = async function listPackages(options = {}) { +export default async function listPackages(options = {}) { let lines = ""; let stderr = ""; const returnCode = await exec("npm", npmArgs("ls", "--parseable", "--long", "--all"), { @@ -53,4 +53,4 @@ module.exports = async function listPackages(options = {}) { packages.set(name.trim(), version.trim()); }); return packages; -}; +} diff --git a/lib/npmArgs.js b/lib/npmArgs.js index ad934022..9698c147 100644 --- a/lib/npmArgs.js +++ b/lib/npmArgs.js @@ -1,6 +1,6 @@ /** * @param {string[]} args */ -module.exports = function npmArgs(...args) { +export default function npmArgs(...args) { return [...args, "--ignore-scripts", "--no-progress"]; -}; +} diff --git a/lib/packageRepoUrls.js b/lib/packageRepoUrls.js index 9277167c..14a73bd0 100644 --- a/lib/packageRepoUrls.js +++ b/lib/packageRepoUrls.js @@ -1,6 +1,6 @@ -const { info } = require("@actions/core"); -const { exec } = require("@actions/exec"); -const hostedGitInfo = require("hosted-git-info"); +import { info } from "@actions/core"; +import { exec } from "@actions/exec"; +import * as hostedGitInfo from "hosted-git-info"; /** * @type {Map} @@ -62,7 +62,7 @@ async function fetchUrl(packageName) { * @param {string[]} packageNames * @returns {Promise>} */ -module.exports = async function packageRepoUrls(packageNames) { +export default async function packageRepoUrls(packageNames) { const allUrls = await Promise.all(packageNames.map(fetchUrl)); /** @@ -75,4 +75,4 @@ module.exports = async function packageRepoUrls(packageNames) { } } return map; -}; +} diff --git a/lib/updateNpm.js b/lib/updateNpm.js index 51d3b841..29ac5034 100644 --- a/lib/updateNpm.js +++ b/lib/updateNpm.js @@ -1,10 +1,10 @@ -const { exec } = require("@actions/exec"); -const npmArgs = require("./npmArgs"); +import { exec } from "@actions/exec"; +import npmArgs from "./npmArgs.js"; /** * @param {string} version */ -module.exports = async function updateNpm(version) { +export default async function updateNpm(version) { await exec("sudo", ["npm", ...npmArgs("install", "--global", `npm@${version}`)]); let actualVersion = ""; @@ -21,4 +21,4 @@ module.exports = async function updateNpm(version) { await exec("sudo", ["chown", "-R", `${process.env["USER"]}:`, `${process.env["HOME"]}/.config`]); return actualVersion.trim(); -}; +} diff --git a/lib/utils/__tests__/commaSeparatedList.test.js b/lib/utils/__tests__/commaSeparatedList.test.js index 520cd293..17428104 100644 --- a/lib/utils/__tests__/commaSeparatedList.test.js +++ b/lib/utils/__tests__/commaSeparatedList.test.js @@ -1,4 +1,4 @@ -const commaSeparatedList = require("../commaSeparatedList"); +import commaSeparatedList from "../commaSeparatedList.js"; test("commaSeparatedList()", () => { expect(commaSeparatedList("")).toEqual([]); diff --git a/lib/utils/__tests__/semverToNumber.test.js b/lib/utils/__tests__/semverToNumber.test.js index e604ec56..f7dfa928 100644 --- a/lib/utils/__tests__/semverToNumber.test.js +++ b/lib/utils/__tests__/semverToNumber.test.js @@ -1,4 +1,4 @@ -const semverToNumber = require("../semverToNumber"); +import semverToNumber from "../semverToNumber.js"; test("semverToNumber()", () => { expect(semverToNumber("1.2.3")).toEqual(10203); diff --git a/lib/utils/capitalize.js b/lib/utils/capitalize.js index 53f43ae0..ef6b5216 100644 --- a/lib/utils/capitalize.js +++ b/lib/utils/capitalize.js @@ -2,9 +2,9 @@ * @param {string} str * @returns {string} */ -module.exports = function capitalize(str) { +export default function capitalize(str) { if (typeof str === "string") { return str.charAt(0).toUpperCase() + str.slice(1); } return ""; -}; +} diff --git a/lib/utils/commaSeparatedList.js b/lib/utils/commaSeparatedList.js index e660e6ff..6068258c 100644 --- a/lib/utils/commaSeparatedList.js +++ b/lib/utils/commaSeparatedList.js @@ -2,9 +2,9 @@ * @param {string} str * @returns {string[]} */ -module.exports = function commaSeparatedList(str) { +export default function commaSeparatedList(str) { return str .split(",") .map((s) => s.trim()) .filter(Boolean); -}; +} diff --git a/lib/utils/semverToNumber.js b/lib/utils/semverToNumber.js index 1ed9e487..a5e8ab17 100644 --- a/lib/utils/semverToNumber.js +++ b/lib/utils/semverToNumber.js @@ -2,7 +2,7 @@ * @param {string} version * @returns {number} */ -module.exports = function semverToNumber(version) { +export default function semverToNumber(version) { return version .split(".") .slice(0, 3) @@ -12,4 +12,4 @@ module.exports = function semverToNumber(version) { const added = num * 10 ** (idx * 2) || 0; return sum + added; }, 0); -}; +} diff --git a/lib/utils/splitRepo.js b/lib/utils/splitRepo.js index e4d518b6..8c33e88b 100644 --- a/lib/utils/splitRepo.js +++ b/lib/utils/splitRepo.js @@ -2,10 +2,10 @@ * @param {string} repository * @returns {{ owner: string, repo: string }} */ -module.exports = function splitRepo(repository) { +export default function splitRepo(repository) { const [owner, repo] = repository.split("/"); if (owner && repo) { return { owner, repo }; } throw new TypeError(`invalid repository: "${repository}"`); -}; +} diff --git a/package-lock.json b/package-lock.json index 6346f6b4..1d89a0eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@typescript-eslint/eslint-plugin": "^4.24.0", "@zeit/ncc": "^0.22.3", "eslint": "^7.26.0", - "eslint-config-ybiquitous": "^13.2.0", + "eslint-config-ybiquitous": "^14.0.1", "eslint-plugin-jest": "^24.3.6", "jest": "^26.6.3", "remark-preset-ybiquitous": "0.0.4", @@ -3786,10 +3786,26 @@ } }, "node_modules/contains-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", - "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-1.0.0.tgz", + "integrity": "sha1-NFizMhhWA+ju0Y9RjUoQiIo6vJE=", + "dev": true, + "dependencies": { + "normalize-path": "^2.1.1", + "path-starts-with": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/contains-path/node_modules/normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, + "dependencies": { + "remove-trailing-separator": "^1.0.1" + }, "engines": { "node": ">=0.10.0" } @@ -3899,46 +3915,6 @@ "node": ">=10" } }, - "node_modules/conventional-changelog-core/node_modules/find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "dependencies": { - "locate-path": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "dependencies": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/conventional-changelog-core/node_modules/normalize-package-data": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.2.tgz", @@ -3954,136 +3930,6 @@ "node": ">=10" } }, - "node_modules/conventional-changelog-core/node_modules/p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "dependencies": { - "p-try": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "dependencies": { - "p-limit": "^1.1.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "dependencies": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "dev": true, - "dependencies": { - "pify": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "dev": true, - "dependencies": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "dev": true, - "dependencies": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/read-pkg/node_modules/hosted-git-info": { - "version": "2.8.9", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", - "dev": true - }, - "node_modules/conventional-changelog-core/node_modules/read-pkg/node_modules/normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "dev": true, - "dependencies": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "node_modules/conventional-changelog-core/node_modules/read-pkg/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, "node_modules/conventional-changelog-core/node_modules/semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -4988,26 +4834,26 @@ } }, "node_modules/eslint-config-ybiquitous": { - "version": "13.2.0", - "resolved": "https://registry.npmjs.org/eslint-config-ybiquitous/-/eslint-config-ybiquitous-13.2.0.tgz", - "integrity": "sha512-gSKMyTy48YS2cfbx6+COA6TE68akKGaPq6Ok0WjVmM3+8rMcks2sCrv98L4F/tLXrec3aavT48ISXkEfcDknFA==", + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/eslint-config-ybiquitous/-/eslint-config-ybiquitous-14.0.1.tgz", + "integrity": "sha512-4iOMv1llrB66s2y2HKiOUqWzyg5M/Va5dVumf6oNXZ3kjeZ89pZaQWs5rnyv7C1i/afH3bQ59DGibf+qmcwvzQ==", "dev": true, "dependencies": { "eslint-config-prettier": "^8.1.0", "eslint-plugin-compat": "^3.9.0", "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-import": "^2.22.1", + "eslint-plugin-import": "^2.23.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-react": "^7.23.1", "eslint-plugin-react-hooks": "^4.2.0" }, "engines": { - "node": ">=12.10.0" + "node": ">=12.20.0" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": "^4.21.0", - "eslint": "^7.24.0" + "@typescript-eslint/eslint-plugin": ">=4.24.0", + "eslint": ">=7.26.0" }, "peerDependenciesMeta": { "@typescript-eslint/eslint-plugin": { @@ -5026,18 +4872,27 @@ } }, "node_modules/eslint-module-utils": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz", - "integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.1.tgz", + "integrity": "sha512-ZXI9B8cxAJIH4nfkhTwcRTEAnrVfobYqwjWy/QMCZ8rHkZHFjf9yO4BzpiF9kCSfNlMG54eKigISHpX0+AaT4A==", "dev": true, "dependencies": { - "debug": "^2.6.9", + "debug": "^3.2.7", "pkg-dir": "^2.0.0" }, "engines": { "node": ">=4" } }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, "node_modules/eslint-module-utils/node_modules/find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", @@ -5063,6 +4918,12 @@ "node": ">=4" } }, + "node_modules/eslint-module-utils/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, "node_modules/eslint-module-utils/node_modules/p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -5199,23 +5060,26 @@ } }, "node_modules/eslint-plugin-import": { - "version": "2.22.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz", - "integrity": "sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==", + "version": "2.23.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.23.2.tgz", + "integrity": "sha512-LmNoRptHBxOP+nb0PIKz1y6OSzCJlB+0g0IGS3XV4KaKk2q4szqQ6s6F1utVf5ZRkxk/QOTjdxe7v4VjS99Bsg==", "dev": true, "dependencies": { - "array-includes": "^3.1.1", - "array.prototype.flat": "^1.2.3", - "contains-path": "^0.1.0", + "array-includes": "^3.1.3", + "array.prototype.flat": "^1.2.4", + "contains-path": "^1.0.0", "debug": "^2.6.9", - "doctrine": "1.5.0", + "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.4", - "eslint-module-utils": "^2.6.0", + "eslint-module-utils": "^2.6.1", + "find-up": "^2.0.0", "has": "^1.0.3", + "is-core-module": "^2.4.0", "minimatch": "^3.0.4", - "object.values": "^1.1.1", - "read-pkg-up": "^2.0.0", - "resolve": "^1.17.0", + "object.values": "^1.1.3", + "pkg-up": "^2.0.0", + "read-pkg-up": "^3.0.0", + "resolve": "^1.20.0", "tsconfig-paths": "^3.9.0" }, "engines": { @@ -5226,18 +5090,84 @@ } }, "node_modules/eslint-plugin-import/node_modules/doctrine": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", - "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "dependencies": { - "esutils": "^2.0.2", - "isarray": "^1.0.0" + "esutils": "^2.0.2" }, "engines": { "node": ">=0.10.0" } }, + "node_modules/eslint-plugin-import/node_modules/find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "dependencies": { + "locate-path": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint-plugin-import/node_modules/locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "dependencies": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint-plugin-import/node_modules/p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "dependencies": { + "p-try": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint-plugin-import/node_modules/p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "dependencies": { + "p-limit": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint-plugin-import/node_modules/p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint-plugin-import/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/eslint-plugin-jest": { "version": "24.3.6", "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-24.3.6.tgz", @@ -7247,12 +7177,15 @@ } }, "node_modules/is-core-module": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", - "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz", + "integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==", "dev": true, "dependencies": { "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/is-data-descriptor": { @@ -10093,20 +10026,42 @@ } }, "node_modules/load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", "dev": true, "dependencies": { "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", + "parse-json": "^4.0.0", + "pify": "^3.0.0", "strip-bom": "^3.0.0" }, "engines": { "node": ">=4" } }, + "node_modules/load-json-file/node_modules/parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "dependencies": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/load-json-file/node_modules/pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/load-plugin": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/load-plugin/-/load-plugin-3.0.0.tgz", @@ -11104,69 +11059,6 @@ "node": ">= 4" } }, - "node_modules/npm-run-all/node_modules/load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/npm-run-all/node_modules/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "dependencies": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/npm-run-all/node_modules/path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "dev": true, - "dependencies": { - "pify": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/npm-run-all/node_modules/pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/npm-run-all/node_modules/read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "dev": true, - "dependencies": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -11547,24 +11439,57 @@ "node": ">=4" } }, - "node_modules/path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, + "node_modules/path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "node_modules/path-starts-with": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/path-starts-with/-/path-starts-with-1.0.0.tgz", + "integrity": "sha1-soJDAV6LE43lcmgqxS2kLmRq2E4=", + "dev": true, + "dependencies": { + "normalize-path": "^2.1.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/path-starts-with/node_modules/normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "dependencies": { + "remove-trailing-separator": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", "dev": true, "dependencies": { - "pify": "^2.0.0" + "pify": "^3.0.0" }, "engines": { "node": ">=4" } }, + "node_modules/path-type/node_modules/pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -11649,6 +11574,85 @@ "node": ">=8" } }, + "node_modules/pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-2.0.0.tgz", + "integrity": "sha1-yBmscoBZpGHKscOImivjxJoATX8=", + "dev": true, + "dependencies": { + "find-up": "^2.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pkg-up/node_modules/find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "dependencies": { + "locate-path": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pkg-up/node_modules/locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "dependencies": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pkg-up/node_modules/p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "dependencies": { + "p-try": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pkg-up/node_modules/p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "dependencies": { + "p-limit": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pkg-up/node_modules/p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/pkg-up/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", @@ -11876,27 +11880,27 @@ "dev": true }, "node_modules/read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", "dev": true, "dependencies": { - "load-json-file": "^2.0.0", + "load-json-file": "^4.0.0", "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" + "path-type": "^3.0.0" }, "engines": { "node": ">=4" } }, "node_modules/read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", + "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", "dev": true, "dependencies": { "find-up": "^2.0.0", - "read-pkg": "^2.0.0" + "read-pkg": "^3.0.0" }, "engines": { "node": ">=4" @@ -18639,10 +18643,25 @@ } }, "contains-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", - "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", - "dev": true + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-1.0.0.tgz", + "integrity": "sha1-NFizMhhWA+ju0Y9RjUoQiIo6vJE=", + "dev": true, + "requires": { + "normalize-path": "^2.1.1", + "path-starts-with": "^1.0.0" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } }, "conventional-changelog": { "version": "3.1.24", @@ -18717,163 +18736,30 @@ "add-stream": "^1.0.0", "conventional-changelog-writer": "^4.0.18", "conventional-commits-parser": "^3.2.0", - "dateformat": "^3.0.0", - "get-pkg-repo": "^1.0.0", - "git-raw-commits": "^2.0.8", - "git-remote-origin-url": "^2.0.0", - "git-semver-tags": "^4.1.1", - "lodash": "^4.17.15", - "normalize-package-data": "^3.0.0", - "q": "^1.5.1", - "read-pkg": "^3.0.0", - "read-pkg-up": "^3.0.0", - "shelljs": "^0.8.3", - "through2": "^4.0.0" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "normalize-package-data": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.2.tgz", - "integrity": "sha512-6CdZocmfGaKnIHPVFhJJZ3GuR8SsLKvDANFp47Jmy51aKIr8akjAWTSxtpI+MBgBFdSMRyo4hMpDlT6dTffgZg==", - "dev": true, - "requires": { - "hosted-git-info": "^4.0.1", - "resolve": "^1.20.0", - "semver": "^7.3.4", - "validate-npm-package-license": "^3.0.1" - } - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "dev": true, - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "dev": true, - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - }, - "dependencies": { - "hosted-git-info": { - "version": "2.8.9", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", - "dev": true - }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "dev": true, - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } - } - }, - "read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", + "dateformat": "^3.0.0", + "get-pkg-repo": "^1.0.0", + "git-raw-commits": "^2.0.8", + "git-remote-origin-url": "^2.0.0", + "git-semver-tags": "^4.1.1", + "lodash": "^4.17.15", + "normalize-package-data": "^3.0.0", + "q": "^1.5.1", + "read-pkg": "^3.0.0", + "read-pkg-up": "^3.0.0", + "shelljs": "^0.8.3", + "through2": "^4.0.0" + }, + "dependencies": { + "normalize-package-data": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.2.tgz", + "integrity": "sha512-6CdZocmfGaKnIHPVFhJJZ3GuR8SsLKvDANFp47Jmy51aKIr8akjAWTSxtpI+MBgBFdSMRyo4hMpDlT6dTffgZg==", "dev": true, "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" + "hosted-git-info": "^4.0.1", + "resolve": "^1.20.0", + "semver": "^7.3.4", + "validate-npm-package-license": "^3.0.1" } }, "semver": { @@ -19823,15 +19709,15 @@ "requires": {} }, "eslint-config-ybiquitous": { - "version": "13.2.0", - "resolved": "https://registry.npmjs.org/eslint-config-ybiquitous/-/eslint-config-ybiquitous-13.2.0.tgz", - "integrity": "sha512-gSKMyTy48YS2cfbx6+COA6TE68akKGaPq6Ok0WjVmM3+8rMcks2sCrv98L4F/tLXrec3aavT48ISXkEfcDknFA==", + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/eslint-config-ybiquitous/-/eslint-config-ybiquitous-14.0.1.tgz", + "integrity": "sha512-4iOMv1llrB66s2y2HKiOUqWzyg5M/Va5dVumf6oNXZ3kjeZ89pZaQWs5rnyv7C1i/afH3bQ59DGibf+qmcwvzQ==", "dev": true, "requires": { "eslint-config-prettier": "^8.1.0", "eslint-plugin-compat": "^3.9.0", "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-import": "^2.22.1", + "eslint-plugin-import": "^2.23.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-react": "^7.23.1", @@ -19849,15 +19735,24 @@ } }, "eslint-module-utils": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz", - "integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.1.tgz", + "integrity": "sha512-ZXI9B8cxAJIH4nfkhTwcRTEAnrVfobYqwjWy/QMCZ8rHkZHFjf9yO4BzpiF9kCSfNlMG54eKigISHpX0+AaT4A==", "dev": true, "requires": { - "debug": "^2.6.9", + "debug": "^3.2.7", "pkg-dir": "^2.0.0" }, "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, "find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", @@ -19877,6 +19772,12 @@ "path-exists": "^3.0.0" } }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -19971,35 +19872,86 @@ } }, "eslint-plugin-import": { - "version": "2.22.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz", - "integrity": "sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==", + "version": "2.23.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.23.2.tgz", + "integrity": "sha512-LmNoRptHBxOP+nb0PIKz1y6OSzCJlB+0g0IGS3XV4KaKk2q4szqQ6s6F1utVf5ZRkxk/QOTjdxe7v4VjS99Bsg==", "dev": true, "requires": { - "array-includes": "^3.1.1", - "array.prototype.flat": "^1.2.3", - "contains-path": "^0.1.0", + "array-includes": "^3.1.3", + "array.prototype.flat": "^1.2.4", + "contains-path": "^1.0.0", "debug": "^2.6.9", - "doctrine": "1.5.0", + "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.4", - "eslint-module-utils": "^2.6.0", + "eslint-module-utils": "^2.6.1", + "find-up": "^2.0.0", "has": "^1.0.3", + "is-core-module": "^2.4.0", "minimatch": "^3.0.4", - "object.values": "^1.1.1", - "read-pkg-up": "^2.0.0", - "resolve": "^1.17.0", + "object.values": "^1.1.3", + "pkg-up": "^2.0.0", + "read-pkg-up": "^3.0.0", + "resolve": "^1.20.0", "tsconfig-paths": "^3.9.0" }, "dependencies": { "doctrine": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", - "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "dev": true, "requires": { - "esutils": "^2.0.2", - "isarray": "^1.0.0" + "p-limit": "^1.1.0" } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true } } }, @@ -21346,9 +21298,9 @@ } }, "is-core-module": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", - "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz", + "integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==", "dev": true, "requires": { "has": "^1.0.3" @@ -23573,15 +23525,33 @@ } }, "load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", "dev": true, "requires": { "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", + "parse-json": "^4.0.0", + "pify": "^3.0.0", "strip-bom": "^3.0.0" + }, + "dependencies": { + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } } }, "load-plugin": { @@ -24411,56 +24381,6 @@ "read-pkg": "^3.0.0", "shell-quote": "^1.6.1", "string.prototype.padend": "^3.0.0" - }, - "dependencies": { - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "dev": true, - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "dev": true, - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - } } }, "npm-run-path": { @@ -24755,13 +24675,41 @@ "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, + "path-starts-with": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/path-starts-with/-/path-starts-with-1.0.0.tgz", + "integrity": "sha1-soJDAV6LE43lcmgqxS2kLmRq2E4=", + "dev": true, + "requires": { + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, "path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", "dev": true, "requires": { - "pify": "^2.0.0" + "pify": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } } }, "performance-now": { @@ -24821,6 +24769,66 @@ "find-up": "^4.0.0" } }, + "pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-2.0.0.tgz", + "integrity": "sha1-yBmscoBZpGHKscOImivjxJoATX8=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + } + } + }, "please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", @@ -24993,24 +25001,24 @@ "dev": true }, "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", "dev": true, "requires": { - "load-json-file": "^2.0.0", + "load-json-file": "^4.0.0", "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" + "path-type": "^3.0.0" } }, "read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", + "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", "dev": true, "requires": { "find-up": "^2.0.0", - "read-pkg": "^2.0.0" + "read-pkg": "^3.0.0" }, "dependencies": { "find-up": { diff --git a/package.json b/package.json index f5589a6f..a6b3e3f1 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,13 @@ "node": ">=12.20.0", "npm": ">=7 <8" }, + "type": "module", "main": "lib/index.js", "scripts": { "prepare": "husky install && ncc build lib/index.js -o dist", - "test": "jest --testTimeout 30000", - "test:watch": "jest --testTimeout 30000 --watch", - "test:coverage": "jest --testTimeout 30000 --coverage", + "test": "NODE_OPTIONS=--experimental-vm-modules jest --testTimeout 30000", + "test:watch": "npm run test -- --watch", + "test:coverage": "npm run test --coverage", "prettier": "prettier .", "prettier:check": "npm run prettier -- --check", "prettier:write": "npm run prettier -- --write", @@ -49,7 +50,7 @@ "@typescript-eslint/eslint-plugin": "^4.24.0", "@zeit/ncc": "^0.22.3", "eslint": "^7.26.0", - "eslint-config-ybiquitous": "^13.2.0", + "eslint-config-ybiquitous": "^14.0.1", "eslint-plugin-jest": "^24.3.6", "jest": "^26.6.3", "remark-preset-ybiquitous": "0.0.4", diff --git a/scripts/bump-npm.js b/scripts/bump-npm.js index ca9d6ac6..98101302 100644 --- a/scripts/bump-npm.js +++ b/scripts/bump-npm.js @@ -1,7 +1,9 @@ -const { execFileSync } = require("child_process"); -const { readFileSync, writeFileSync } = require("fs"); -const { basename } = require("path"); -const pkg = require("../package.json"); +import { execFileSync } from "child_process"; +import { readFileSync, writeFileSync } from "fs"; +import { basename } from "path"; + +// @ts-expect-error +const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")); const [main, sub, newVersion] = process.argv; if (!newVersion) { diff --git a/tsconfig.json b/tsconfig.json index 626b314f..5669b035 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,9 @@ "noUnusedParameters": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true + "module": "ES2020", + "moduleResolution": "node", + "lib": ["ES2020"] }, "exclude": ["dist/**"] }