From 0056e779f14f12b7f21f2bb6c3cc73db8e6b1255 Mon Sep 17 00:00:00 2001 From: ppaul Date: Wed, 19 Aug 2020 00:34:56 -0400 Subject: [PATCH 1/2] feat(1958): hapiv19.x.x upgrade --- index.js | 17 ++++++----------- package.json | 12 ++++++------ screwdriver.yaml | 2 +- test/index.test.js | 2 +- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index 4f51712..10fd4a3 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,5 @@ 'use strict'; -const Joi = require('joi'); const SCHEMA_CONFIG = require('screwdriver-data-schema').config.command.schemaCommand; const Yaml = require('js-yaml'); @@ -20,18 +19,14 @@ function loadCommandSpecYaml(yamlString) { * @param {Object} commandObj Configuration object that represents the command * @return {Promise} Promise that resolves to the passed-in config object */ -function validateCommand(commandObj) { - return new Promise((resolve, reject) => { - Joi.validate(commandObj, SCHEMA_CONFIG, { +async function validateCommand(commandObj) { + try { + return await SCHEMA_CONFIG.validateAsync(commandObj, { abortEarly: false - }, (err, data) => { - if (err) { - return reject(err); - } - - return resolve(data); }); - }); + } catch (err) { + throw err; + } } /** diff --git a/package.json b/package.json index 3035839..9d9da90 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "screwdriver-command-validator", - "version": "1.0.0", + "version": "2.0.0", "description": "A module for validating a Screwdriver Command file", "main": "index.js", "scripts": { "pretest": "eslint .", - "test": "jenkins-mocha --recursive", + "test": "mocha --recursive", "semantic-release": "semantic-release pre && npm publish && semantic-release post" }, "repository": { @@ -34,17 +34,17 @@ "Tiffany Kyi " ], "devDependencies": { + "@hapi/hoek": "^9.0.4", "chai": "^3.5.0", "eslint": "^4.3.0", "eslint-config-screwdriver": "^3.0.0", - "hoek": "^4.1.0", - "jenkins-mocha": "^6.0.0" + "mocha": "^8.1.1" }, "dependencies": { "commander": "^2.12.2", - "joi": "^13.0.0", + "joi": "^17.2.0", "js-yaml": "^3.8.1", - "screwdriver-data-schema": "^19.1.1" + "screwdriver-data-schema": "git://github.com/screwdriver-cd/data-schema.git#hapi-v19" }, "release": { "debug": false, diff --git a/screwdriver.yaml b/screwdriver.yaml index 9e3cad4..d18d1c1 100644 --- a/screwdriver.yaml +++ b/screwdriver.yaml @@ -1,5 +1,5 @@ shared: - image: node:8 + image: node:12 jobs: main: diff --git a/test/index.test.js b/test/index.test.js index c81f5a1..da40b1e 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -2,7 +2,7 @@ const assert = require('chai').assert; const fs = require('fs'); -const hoek = require('hoek'); +const hoek = require('@hapi/hoek'); const path = require('path'); const validator = require('../index.js'); From 17f1aa0d9fb0e950726ef97a312af04aa02b814b Mon Sep 17 00:00:00 2001 From: ppaul Date: Wed, 26 Aug 2020 13:56:39 -0400 Subject: [PATCH 2/2] feat: publish major version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d9da90..a99942a 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "commander": "^2.12.2", "joi": "^17.2.0", "js-yaml": "^3.8.1", - "screwdriver-data-schema": "git://github.com/screwdriver-cd/data-schema.git#hapi-v19" + "screwdriver-data-schema": "^20.0.0" }, "release": { "debug": false,