From c4c8f32204de2abef73a286c9b41fa7ff498ccd7 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Tue, 11 Jan 2022 16:54:58 -0500 Subject: [PATCH] move to joi package --- package-lock.json | 66 +---------------------------------------------- package.json | 2 +- scripts/utils.js | 20 +++++++------- 3 files changed, 12 insertions(+), 76 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6dcdef1e..d79de10f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,6 @@ "@babel/core": "^7.16.7", "@babel/eslint-parser": "^7.16.5", "@babel/preset-react": "^7.16.7", - "@hapi/joi": "^17.0.2", "@types/node": "^16.11.19", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", @@ -31,6 +30,7 @@ "gatsby-plugin-web-font-loader": "^1.0.4", "gatsby-source-filesystem": "^2.1.40", "gatsby-transformer-sharp": "^2.3.7", + "joi": "^17.5.0", "normalize.css": "^8.0.1", "prop-types": "^15.7.2", "react": "^16.12.0", @@ -2193,51 +2193,17 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz", "integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==" }, - "node_modules/@hapi/address": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@hapi/address/-/address-4.1.0.tgz", - "integrity": "sha512-SkszZf13HVgGmChdHo/PxchnSaCJ6cetVqLzyciudzZRT0jcOouIF/Q93mgjw8cce+D+4F4C1Z/WrfFN+O3VHQ==", - "deprecated": "Moved to 'npm install @sideway/address'", - "dependencies": { - "@hapi/hoek": "^9.0.0" - } - }, "node_modules/@hapi/bourne": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-1.3.2.tgz", "integrity": "sha512-1dVNHT76Uu5N3eJNTYcvxee+jzX4Z9lfciqRRHCU27ihbUcYi+iSc2iml5Ke1LXe1SyJCLA0+14Jh4tXJgOppA==", "deprecated": "This version has been deprecated and is no longer supported or maintained" }, - "node_modules/@hapi/formula": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@hapi/formula/-/formula-2.0.0.tgz", - "integrity": "sha512-V87P8fv7PI0LH7LiVi8Lkf3x+KCO7pQozXRssAHNXXL9L1K+uyu4XypLXwxqVDKgyQai6qj3/KteNlrqDx4W5A==", - "deprecated": "Moved to 'npm install @sideway/formula'" - }, "node_modules/@hapi/hoek": { "version": "9.2.1", "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.2.1.tgz", "integrity": "sha512-gfta+H8aziZsm8pZa0vj04KO6biEiisppNgA1kbJvFrrWu9Vm7eaUEy76DIxsuTaWvti5fkJVhllWc6ZTE+Mdw==" }, - "node_modules/@hapi/joi": { - "version": "17.1.1", - "resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-17.1.1.tgz", - "integrity": "sha512-p4DKeZAoeZW4g3u7ZeRo+vCDuSDgSvtsB/NpfjXEHTUjSeINAi/RrVOWiVQ1isaoLzMvFEhe8n5065mQq1AdQg==", - "deprecated": "Switch to 'npm install joi'", - "dependencies": { - "@hapi/address": "^4.0.1", - "@hapi/formula": "^2.0.0", - "@hapi/hoek": "^9.0.0", - "@hapi/pinpoint": "^2.0.0", - "@hapi/topo": "^5.0.0" - } - }, - "node_modules/@hapi/pinpoint": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@hapi/pinpoint/-/pinpoint-2.0.0.tgz", - "integrity": "sha512-vzXR5MY7n4XeIvLpfl3HtE3coZYO4raKXW766R6DZw/6aLqR26iuZ109K7a0NtF2Db0jxqh7xz2AxkUwpUFybw==", - "deprecated": "Moved to 'npm install @sideway/pinpoint'" - }, "node_modules/@hapi/topo": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz", @@ -29425,46 +29391,16 @@ } } }, - "@hapi/address": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@hapi/address/-/address-4.1.0.tgz", - "integrity": "sha512-SkszZf13HVgGmChdHo/PxchnSaCJ6cetVqLzyciudzZRT0jcOouIF/Q93mgjw8cce+D+4F4C1Z/WrfFN+O3VHQ==", - "requires": { - "@hapi/hoek": "^9.0.0" - } - }, "@hapi/bourne": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-1.3.2.tgz", "integrity": "sha512-1dVNHT76Uu5N3eJNTYcvxee+jzX4Z9lfciqRRHCU27ihbUcYi+iSc2iml5Ke1LXe1SyJCLA0+14Jh4tXJgOppA==" }, - "@hapi/formula": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@hapi/formula/-/formula-2.0.0.tgz", - "integrity": "sha512-V87P8fv7PI0LH7LiVi8Lkf3x+KCO7pQozXRssAHNXXL9L1K+uyu4XypLXwxqVDKgyQai6qj3/KteNlrqDx4W5A==" - }, "@hapi/hoek": { "version": "9.2.1", "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.2.1.tgz", "integrity": "sha512-gfta+H8aziZsm8pZa0vj04KO6biEiisppNgA1kbJvFrrWu9Vm7eaUEy76DIxsuTaWvti5fkJVhllWc6ZTE+Mdw==" }, - "@hapi/joi": { - "version": "17.1.1", - "resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-17.1.1.tgz", - "integrity": "sha512-p4DKeZAoeZW4g3u7ZeRo+vCDuSDgSvtsB/NpfjXEHTUjSeINAi/RrVOWiVQ1isaoLzMvFEhe8n5065mQq1AdQg==", - "requires": { - "@hapi/address": "^4.0.1", - "@hapi/formula": "^2.0.0", - "@hapi/hoek": "^9.0.0", - "@hapi/pinpoint": "^2.0.0", - "@hapi/topo": "^5.0.0" - } - }, - "@hapi/pinpoint": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@hapi/pinpoint/-/pinpoint-2.0.0.tgz", - "integrity": "sha512-vzXR5MY7n4XeIvLpfl3HtE3coZYO4raKXW766R6DZw/6aLqR26iuZ109K7a0NtF2Db0jxqh7xz2AxkUwpUFybw==" - }, "@hapi/topo": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz", diff --git a/package.json b/package.json index 3b6ddcfc..ac51a84b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "@babel/core": "^7.16.7", "@babel/eslint-parser": "^7.16.5", "@babel/preset-react": "^7.16.7", - "@hapi/joi": "^17.0.2", "@types/node": "^16.11.19", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", @@ -35,6 +34,7 @@ "gatsby-plugin-web-font-loader": "^1.0.4", "gatsby-source-filesystem": "^2.1.40", "gatsby-transformer-sharp": "^2.3.7", + "joi": "^17.5.0", "normalize.css": "^8.0.1", "prop-types": "^15.7.2", "react": "^16.12.0", diff --git a/scripts/utils.js b/scripts/utils.js index 69af3ce0..9088ead8 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -1,7 +1,7 @@ const exec = require('@actions/exec'); const core = require('@actions/core'); const github = require('@actions/github'); -const Joi = require('@hapi/joi'); +const Joi = require('joi'); const http = require('http'); const https = require('https'); const flags = require('./flags.js'); @@ -13,8 +13,8 @@ async function getCurrentBranchName() { const options = { silent: true, listeners: { - stdout: data => (myOutput += data.toString()), - stderr: data => (myError += data.toString()), + stdout: (data) => (myOutput += data.toString()), + stderr: (data) => (myError += data.toString()), }, }; @@ -23,7 +23,7 @@ async function getCurrentBranchName() { } /** on master branch will return an empty array */ -module.exports.getMasterData = async function() { +module.exports.getMasterData = async function () { const options = { silent: true }; const curentBranchName = await getCurrentBranchName(); // when on a branch/PR different from master @@ -67,7 +67,7 @@ module.exports.Schema = Joi.object({ tags: Joi.array().items(Joi.string()), }); -module.exports.getStatusCode = function(url) { +module.exports.getStatusCode = function (url) { const client = url.startsWith('https') ? https : http; return new Promise((resolve, reject) => { const REQUEST_TIMEOUT = 10000; @@ -78,17 +78,17 @@ module.exports.getStatusCode = function(url) { ); client - .get(url, res => { + .get(url, (res) => { clearTimeout(timeoutId); resolve(res.statusCode); }) - .on('error', err => reject(err)); + .on('error', (err) => reject(err)); }); }; // If there are errors, will fail the action & add a comment detailing the issues // If there are no errors, will leave an "all-clear" comment with relevant URLs (to ease a potential manual check) -module.exports.communicateValidationOutcome = async function( +module.exports.communicateValidationOutcome = async function ( errors, failedUrls, changedData @@ -99,8 +99,8 @@ module.exports.communicateValidationOutcome = async function( comment += [ '🚨 We have detected the following issues, let us (contributors) know if you need support or clarifications:', - ...errors.map(e => `- ${e.message}`), - ...failedUrls.map(url => `- URL is invalid: ${url}`), + ...errors.map((e) => `- ${e.message}`), + ...failedUrls.map((url) => `- URL is invalid: ${url}`), ].join('\n'); } else { comment += [