Skip to content

Commit dd0e161

Browse files
committed
feat: upgrade to @microfleet/validation
BREAKING CHANGE: uses @microfleet/validation
1 parent 25c4039 commit dd0e161

File tree

9 files changed

+5677
-1026
lines changed

9 files changed

+5677
-1026
lines changed

.babelrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"plugins": [
3-
"transform-strict-mode",
4-
"transform-class-properties"
3+
"@babel/plugin-transform-strict-mode",
4+
"@babel/plugin-proposal-class-properties"
55
]
6-
}
6+
}

.commitlintrc.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
rules: {
3+
'body-leading-blank': [1, 'always'],
4+
'footer-leading-blank': [1, 'always'],
5+
'header-max-length': [2, 'always', 72],
6+
'scope-case': [2, 'always', 'lower-case'],
7+
'subject-case': [
8+
2,
9+
'never',
10+
['sentence-case', 'start-case', 'pascal-case', 'upper-case']
11+
],
12+
'subject-empty': [2, 'never'],
13+
'subject-full-stop': [2, 'never', '.'],
14+
'type-case': [2, 'always', 'lower-case'],
15+
'type-empty': [2, 'never'],
16+
'type-enum': [2, 'always', [
17+
'build',
18+
'ci',
19+
'docs',
20+
'feat',
21+
'fix',
22+
'perf',
23+
'refactor',
24+
'revert',
25+
'style',
26+
'test',
27+
'major',
28+
'minor',
29+
'patch',
30+
'chore'
31+
]
32+
]
33+
}
34+
};

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"extends": "makeomatic"
2+
"extends": "makeomatic",
3+
"parser": "babel-eslint"
34
}

.npmignore

Lines changed: 0 additions & 31 deletions
This file was deleted.

.releaserc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"branch": "master",
3+
"analyzeCommits": {
4+
"preset": "angular",
5+
"releaseRules": [
6+
{ "type": "docs", "release": "patch" },
7+
{ "type": "refactor", "release": "patch" },
8+
{ "type": "style", "release": "patch" },
9+
{ "type": "minor", "release": "minor" },
10+
{ "type": "patch", "release": "patch" },
11+
{ "type": "major", "release": "major" },
12+
{ "type": "breaking", "release": "major" }
13+
]
14+
}
15+
}

package.json

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
"scripts": {
77
"compile": "babel -d ./lib ./src",
88
"prepublishOnly": "yarn compile",
9-
"postversion": "git push && npm publish && git push --tags",
109
"lint": "eslint ./src",
11-
"test": "yarn lint && mocha --require babel-register --bail --timeout 10000 -R spec"
10+
"test": "yarn lint && mocha --require @babel/register --bail --timeout 10000 -R spec",
11+
"semantic-release": "semantic-release"
1212
},
13+
"files": [
14+
"lib/",
15+
"src/"
16+
],
1317
"keywords": [
1418
"microservice",
1519
"amqp",
@@ -28,25 +32,34 @@
2832
},
2933
"homepage": "https://github.com/makeomatic/ms-mailer-client#readme",
3034
"devDependencies": {
31-
"babel-cli": "^6.26.0",
32-
"babel-eslint": "^8.2.1",
33-
"babel-plugin-transform-class-properties": "^6.19.0",
34-
"babel-plugin-transform-strict-mode": "^6.18.0",
35+
"@babel/cli": "^7.0.0",
36+
"@babel/core": "^7.0.0",
37+
"@babel/plugin-proposal-class-properties": "^7.0.0",
38+
"@babel/plugin-transform-strict-mode": "^7.0.0",
39+
"@babel/register": "^7.0.0",
40+
"@makeomatic/deploy": "^8.0.1",
41+
"@microfleet/validation": "^8.0.0",
42+
"babel-eslint": "^10.0.1",
3543
"common-errors": "^1.0.5",
36-
"eslint": "^4.15.0",
37-
"eslint-config-makeomatic": "^2.0.1",
38-
"eslint-plugin-import": "^2.8.0",
39-
"eslint-plugin-mocha": "^4.11.0",
40-
"eslint-plugin-promise": "^3.6.0",
41-
"mocha": "^5.0.0",
42-
"ms-validation": "^7.0.0"
44+
"eslint": "^5.7.0",
45+
"eslint-config-makeomatic": "^3.0.0",
46+
"eslint-plugin-import": "^2.14.0",
47+
"eslint-plugin-mocha": "^5.2.0",
48+
"eslint-plugin-promise": "^4.0.1",
49+
"mocha": "^5.2.0"
4350
},
4451
"peerDependencies": {
4552
"@microfleet/transport-amqp": ">= 12.x.x",
46-
"common-errors": "~1.x.x",
47-
"ms-validation": ">= 7.x.x"
53+
"@microfleet/validation": ">= 8.x.x",
54+
"common-errors": "~1.x.x"
4855
},
4956
"dependencies": {
50-
"lodash.merge": "^4.6.0"
57+
"lodash.merge": "^4.6.1"
58+
},
59+
"husky": {
60+
"hooks": {
61+
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS",
62+
"prepare-commit-msg": "./node_modules/@makeomatic/deploy/git-hooks/prepare-commit-msg $HUSKY_GIT_PARAMS"
63+
}
5164
}
5265
}

src/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const assert = require('assert');
22
const merge = require('lodash.merge');
3-
const Validator = require('ms-validation');
3+
const Validator = require('@microfleet/validation').default;
44

55
const { validateSync } = new Validator('../schemas');
66

@@ -24,10 +24,12 @@ module.exports = class MailerClient {
2424
* @return {MailerClient}
2525
*/
2626
constructor(amqp, opts = {}) {
27-
const config = this.config = merge({}, MailerClient.defaultOpts, opts);
27+
const config = merge({}, MailerClient.defaultOpts, opts);
2828

29-
// check configuration
30-
assert.ifError(validateSync('config', config).error);
29+
const { error, doc } = validateSync('config', config);
30+
assert(!error, error);
31+
32+
this.config = doc;
3133

3234
if (!amqp) {
3335
throw new Error('amqp client must be passed as a first argument');

test/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ describe('MailerClient', function testSuite() {
77
const FakeAMQP = {};
88
it('throws on invalid configuration', function test() {
99
assert.throws(
10-
() =>
11-
new MailerClient(FakeAMQP, { routes: 'no', prefix: 10 })
12-
, /ValidationError/
10+
() => new MailerClient(FakeAMQP, { routes: 'no', prefix: 10 }),
11+
/HttpStatusError/
1312
);
1413
});
1514

0 commit comments

Comments
 (0)