Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies #174

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// More details: https://codefresh-io.atlassian.net/wiki/display/COD/Code+Style+Guide
{

"extends": "airbnb",
"extends": "airbnb-base",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "script",
Expand Down
2 changes: 1 addition & 1 deletion __tests__/push-tag.validator.unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Validate Codefresh YAML', () => {
}

}
}, '"0" must be a string. Current value: 1 \n"1" must be a string. Current value: 2 \n"2" must be a string. Current value: 3 \n', done); // eslint-disable-line
}, '"\\[0\\]" must be a string. Current value: 1 \n"\\[1\\]" must be a string. Current value: 2 \n"\\[2\\]" must be a string. Current value: 3 \n', done); // eslint-disable-line
});

it('Invalid push-tag image-name', (done) => {
Expand Down
5 changes: 3 additions & 2 deletions __tests__/schemas.unit.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
/* eslint-env node, mocha */
/* eslint-disable no-unused-expressions,no-template-curly-in-string */

Expand All @@ -10,12 +11,12 @@ const { expect } = chai;

function expectValid(schema, value) {
const result = schema.validate(value);
expect(result.error).to.be.null;
expect(result.error).to.not.exist;
}

function expectInvalid(schema, value) {
const result = schema.validate(value);
expect(result.error).not.to.be.null;
expect(result.error).to.exist;
}

describe('schemas validation check', () => {
Expand Down
192 changes: 78 additions & 114 deletions __tests__/validator.unit.spec.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions codefresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ steps:

install_dependencies:
title: 'Installing testing dependencies'
image: node:12.22.8
image: node:14.21.3
commands:
- yarn install --frozen-lockfile

Expand All @@ -35,13 +35,13 @@ steps:
steps:
eslint:
title: 'Running linting logic'
image: node:12.22.8
image: node:14.21.3
commands:
- yarn eslint

unit_tests:
title: 'Running unit-tests'
image: node:12.22.8
image: node:14.21.3
commands:
- yarn test

Expand Down
23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,32 @@
"bin": {
"cyv": "./index.js"
},
"version": "0.33.3",
"version": "1.0.0",
"main": "./validator.js",
"scripts": {
"test": "jest --coverage --runInBand",
"test:watch": "jest --watch",
"eslint": "eslint schema/** __tests__/**/*.js validator.js validator-error.js"
},
"dependencies": {
"cli-table3": "^0.6.0",
"colors": "^1.3.3",
"joi": "^9.2.0",
"joi-to-json-schema": "^5.0.0",
"@colors/colors": "^1.6.0",
"cli-table3": "^0.6.3",
"joi": "^17.11.0",
"joi-to-json": "^4.1.0",
"js-levenshtein": "^1.1.6",
"lodash": "^4.17.21"
},
"devDependencies": {
"chai": "^3.0.0",
"@types/jest": "^29.5.7",
"chai": "^4.3.10",
"eslint": "^5.12.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-jsx-a11y": "^6.2.0",
"eslint-plugin-mocha": "^5.2.1",
"eslint-plugin-react": "^7.12.4",
"jest": "^24.0.0",
"jest": "^29.7.0",
"js-yaml": "^4.1.0",
"mustache": "^4.2.0",
"sinon": "^1.17.6",
"sinon-chai": "^2.8.0"
"sinon": "^17.0.1",
"sinon-chai": "^3.7.0"
},
"jest": {
"testPathIgnorePatterns": [
Expand Down
50 changes: 22 additions & 28 deletions schema/1.0/base-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//------------------------------------------------------------------------------
const _ = require('lodash');
const Joi = require('joi');
const convert = require('joi-to-json-schema');
const parse = require('joi-to-json');

class BaseSchema {

Expand Down Expand Up @@ -44,7 +44,7 @@ class BaseSchema {
name: Joi.string().required(),
on: Joi.array().items(
Joi.string()
.valid([
.valid(
'success',
'running',
'failure',
Expand All @@ -55,7 +55,7 @@ class BaseSchema {
'finished',
'approved',
'denied',
])
)
)
.min(1)
});
Expand Down Expand Up @@ -83,18 +83,16 @@ class BaseSchema {
'title': Joi.string(),
'fail_fast': Joi.boolean(),
'docker_machine': Joi.alternatives().try(
[
Joi.object({
create: Joi.object({
provider: Joi.string()
})
}),
Joi.object({
use: Joi.object({
node: Joi.string()
})
Joi.object({
create: Joi.object({
provider: Joi.string()
})
]
}),
Joi.object({
use: Joi.object({
node: Joi.string()
})
}),
),
'arguments': Joi.object(),
'when': BaseSchema._getWhenSchema(),
Expand Down Expand Up @@ -134,12 +132,10 @@ class BaseSchema {

static _getAnnotationObjAlternative() {
return Joi.object().pattern(/^[A-Za-z0-9_]+$/, Joi.alternatives().try(
[
Joi.string(),
Joi.boolean(),
Joi.number(),
Joi.object({ evaluate: Joi.string().required() })
]
Joi.string(),
Joi.boolean(),
Joi.number(),
Joi.object({ evaluate: Joi.string().required() }),
));
}

Expand Down Expand Up @@ -183,12 +179,10 @@ class BaseSchema {
return Joi.array().items(
Joi.alternatives().try(
Joi.object().pattern(/^[A-Za-z0-9_]+$/, Joi.alternatives().try(
[
Joi.string(),
Joi.boolean(),
Joi.number(),
Joi.object({ evaluate: Joi.string().required() })
]
Joi.string(),
Joi.boolean(),
Joi.number(),
Joi.object({ evaluate: Joi.string().required() }),
)), Joi.string().regex(/^[A-Za-z0-9_]+$/)
)
);
Expand Down Expand Up @@ -274,7 +268,7 @@ class BaseSchema {
name: Joi.string(),
url: Joi.string(),
})),
type: Joi.string().valid(['kubernetes', 'helm-release']),
type: Joi.string().valid('kubernetes', 'helm-release'),
change: Joi.string(),
filters: Joi.array().items(Joi.object().keys({
cluster: Joi.string(),
Expand All @@ -298,7 +292,7 @@ class BaseSchema {
}

getJsonSchema() {
return convert(this.getSchema());
return parse(this.getSchema(), 'json-draft-04');
}

static getSuccessCriteriaSchema() {
Expand Down
2 changes: 1 addition & 1 deletion schema/1.0/steps/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Build extends BaseSchema {

static _getProviderSchema() {
return Joi.object({
type: Joi.string().valid(PROVIDERS),
type: Joi.string().valid(...PROVIDERS),
arguments: Joi.when('type', {
is: 'gcb',
then: Joi.object({
Expand Down
8 changes: 3 additions & 5 deletions schema/1.0/steps/integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IntegrationTest extends BaseSchema {
getSchema() {

const preconfiguredServicesArray = Joi.array().items(
Joi.string().valid([
Joi.string().valid(
'mysql',
'postgresql',
'mariadb',
Expand All @@ -39,7 +39,7 @@ class IntegrationTest extends BaseSchema {
'neo4j',
'elasticsearch',
'rethinkdb'
])
)
);

const environmentAsObject = Joi.object({})
Expand All @@ -50,9 +50,7 @@ class IntegrationTest extends BaseSchema {

const serviceObject = Joi.object({
image: Joi.string().required(),
ports: Joi.array(
Joi.number()
),
ports: Joi.array().items(Joi.number()),
environment: Joi.alternatives(
environmentAsArray,
environmentAsObject
Expand Down
8 changes: 4 additions & 4 deletions schema/1.0/steps/pending-approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ class PendingApproval extends BaseSchema {
type: Joi.string().valid(PendingApproval.getType()),
timeout: Joi.object({
timeUnit: Joi.string()
.valid([
.valid(
'hours',
'minutes'
]).default('hours'),
).default('hours'),
duration: Joi.number().positive(),
finalState: Joi.string()
.valid([
.valid(
'terminated',
'approved',
'denied',
]),
),
}),
};
return this._createSchema(pendingApprovalProperties);
Expand Down
4 changes: 2 additions & 2 deletions schema/1.0/steps/simple_travis.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Travis extends BaseSchema {
}).required();

const servicesArray = Joi.array().items(
Joi.string().valid([
Joi.string().valid(
'mysql',
'postgresql',
'mariadb',
Expand All @@ -45,7 +45,7 @@ class Travis extends BaseSchema {
'neo4j',
'elasticsearch',
'rethinkdb'
])
)
).required();

const compositionProperties = {
Expand Down
4 changes: 1 addition & 3 deletions schema/1.0/steps/travis.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class Travis extends BaseSchema {

const serviceObject = Joi.object({
image: Joi.string().required(),
ports: Joi.array(
Joi.number()
),
ports: Joi.array().items(Joi.number()),
environment: Joi.alternatives(
environmentAsArray,
environmentAsObject
Expand Down
11 changes: 4 additions & 7 deletions schema/1.0/validations/suggest-argument.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ class SuggestArgumentValidation {
return this._getNearestMatchingProperty(stepSchemeProperties, argument);
}


static _getStepSchemeProperties(stepSchema, path) {
const { children } = stepSchema.describe();
const { keys: keysDescriptions } = stepSchema.describe();

if (path.length) {
const pathString = `${path.join('.children.')}.children`;

return _.keys(_.get(children, pathString, []));
const pathString = `${path.join('.keys.')}.keys`;
return _.keys(_.get(keysDescriptions, pathString, []));
}

return _.keys(children);
return Object.keys(keysDescriptions);
}


Expand Down
Loading