Skip to content

Commit

Permalink
Merge pull request #558 from kuhiga/joi-upgrade
Browse files Browse the repository at this point in the history
chore: upgrade @hapi/joi to joi
  • Loading branch information
horike37 authored Apr 17, 2023
2 parents 6696431 + 75de507 commit baf6764
Show file tree
Hide file tree
Showing 8 changed files with 592 additions and 17,232 deletions.
3 changes: 1 addition & 2 deletions lib/deploy/stepFunctions/compileAlarms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const _ = require('lodash');
const BbPromise = require('bluebird');
const Joi = require('@hapi/joi');
const schema = require('./compileAlarms.schema');
const logger = require('../../utils/logger');

Expand Down Expand Up @@ -142,7 +141,7 @@ function validateConfig(serverless, stateMachineName, alarmsObj) {
return false;
}

const { error } = Joi.validate(alarmsObj, schema, { allowUnknown: false });
const { error } = schema.validate(alarmsObj, { allowUnknown: false });

if (error) {
logger.log(
Expand Down
10 changes: 5 additions & 5 deletions lib/deploy/stepFunctions/compileAlarms.schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Joi = require('@hapi/joi');
const Joi = require('joi');

const arn = Joi.alternatives().try(
Joi.string(),
Expand All @@ -15,15 +15,15 @@ const arn = Joi.alternatives().try(
),
}),
Joi.object().keys({
'Fn::Join': Joi.array().items([
'Fn::Join': Joi.array().items(
Joi.string(),
Joi.array().items([
Joi.array().items(
Joi.string(),
Joi.object().keys({
Ref: Joi.string(),
}),
]),
]),
),
),
}),
);

Expand Down
5 changes: 2 additions & 3 deletions lib/deploy/stepFunctions/compileNotifications.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const _ = require('lodash');
const Joi = require('@hapi/joi');
const crypto = require('crypto');
const BbPromise = require('bluebird');
const schema = require('./compileNotifications.schema');
Expand Down Expand Up @@ -326,8 +325,8 @@ function validateConfig(serverless, stateMachineName, stateMachineObj, notificat
return false;
}

const { error } = Joi.validate(
notificationsObj, schema, { allowUnknown: false },
const { error } = schema.validate(
notificationsObj, { allowUnknown: false },
);

if (error) {
Expand Down
10 changes: 5 additions & 5 deletions lib/deploy/stepFunctions/compileNotifications.schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Joi = require('@hapi/joi');
const Joi = require('joi');

const arn = Joi.alternatives().try(
Joi.string(),
Expand All @@ -9,15 +9,15 @@ const arn = Joi.alternatives().try(
'Fn::GetAtt': Joi.array().items(Joi.string()),
}),
Joi.object().keys({
'Fn::Join': Joi.array().items([
'Fn::Join': Joi.array().items(
Joi.string(),
Joi.array().items([
Joi.array().items(
Joi.string(),
Joi.object().keys({
Ref: Joi.string(),
}),
]),
]),
),
),
}),
);

Expand Down
4 changes: 1 addition & 3 deletions lib/deploy/stepFunctions/compileStateMachines.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const _ = require('lodash');
const Joi = require('@hapi/joi');
const aslValidator = require('asl-validator');
const BbPromise = require('bluebird');
const crypto = require('crypto');
Expand Down Expand Up @@ -107,8 +106,7 @@ module.exports = {
} else {
Tags = toTags(this.serverless.service.provider.tags);
}

const { error, value } = Joi.validate(stateMachineObj, schema, { allowUnknown: false });
const { error, value } = schema.validate(stateMachineObj, { allowUnknown: false });
if (error) {
const errorMessage = `State machine [${stateMachineName}] is malformed. `
+ 'Please check the README for more info. '
Expand Down
10 changes: 5 additions & 5 deletions lib/deploy/stepFunctions/compileStateMachines.schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Joi = require('@hapi/joi');
const Joi = require('joi');

const arn = Joi.alternatives().try(
Joi.string().regex(/^arn:aws/, 'ARN'),
Expand All @@ -15,15 +15,15 @@ const arn = Joi.alternatives().try(
),
}),
Joi.object().keys({
'Fn::Join': Joi.array().items([
'Fn::Join': Joi.array().items(
Joi.string(),
Joi.array().items([
Joi.array().items(
Joi.string(),
Joi.object().keys({
Ref: Joi.string(),
}),
]),
]),
),
),
}),
);

Expand Down
Loading

0 comments on commit baf6764

Please sign in to comment.