Skip to content

Commit 5deb7d9

Browse files
committed
feat: upgrade to node 8.9.0
BREAKING CHANGE: similar API, but uses async/await heavily. Updated tests, setup automatic release
1 parent 16aec9d commit 5deb7d9

20 files changed

+6571
-2606
lines changed

.babelrc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
{
22
"plugins": [
3-
"transform-strict-mode",
4-
"transform-class-properties",
5-
["transform-object-rest-spread", { "useBuiltIns": true }]
3+
"@babel/plugin-transform-strict-mode",
4+
"@babel/plugin-proposal-class-properties",
5+
[
6+
"@babel/plugin-proposal-object-rest-spread",
7+
{
8+
"useBuiltIns": true
9+
}
10+
]
611
],
712
"env": {
813
"test": {
9-
"plugins": [ "istanbul" ]
14+
"plugins": [
15+
"istanbul"
16+
]
1017
}
1118
}
1219
}

.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: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,7 @@
11
{
2-
"extends": "airbnb-base",
2+
"extends": "makeomatic",
33
"parser": "babel-eslint",
4-
"plugins": [
5-
"mocha",
6-
"promise"
7-
],
8-
"env": {
9-
"mocha": true
10-
},
114
"rules": {
12-
"prefer-arrow-callback": 0,
13-
"max-len": [2, 150],
14-
"newline-per-chained-call": 0,
15-
"no-param-reassign": [2, {"props": false}],
16-
"arrow-body-style": 0,
17-
"no-underscore-dangle": 0,
18-
"global-require": 0,
19-
"import/no-extraneous-dependencies": 0,
20-
"promise/param-names": 2,
21-
"promise/always-return": 2,
22-
"promise/catch-or-return": 2,
23-
"promise/no-native": 2,
24-
"comma-dangle": ["error", {
25-
"arrays": "always-multiline",
26-
"objects": "always-multiline",
27-
"imports": "never",
28-
"exports": "never",
29-
"functions": "never",
30-
}],
31-
"no-multi-assign": 0
32-
},
33-
"root": true,
34-
"globals": {
35-
"inspectPromise": 0
36-
}
5+
"object-curly-newline": 0
6+
}
377
}

.mdeprc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"node": "10.13.0"
3+
}

.npmignore

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

.nycrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"src/**/*.spec.js"
77
],
88
"require": [
9-
"babel-register"
9+
"@babel/register"
1010
],
1111
"sourceMap": false,
1212
"instrument": false,

.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: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"description": "utils for makeomatic mservice for encoding/decoding various token types and storing associated metadata with them",
55
"main": "./lib/index.js",
66
"scripts": {
7-
"test": "npm run lint && npm run test-unit && npm run test-integration",
7+
"test": "yarn lint && yarn test-unit && yarn test-integration",
88
"test-unit": "mocha test/unit.js",
9-
"test-integration": "mdep test run --node 7.9.0 -t ./test/integration.js",
9+
"test-integration": "mdep test run -t ./test/integration.js",
1010
"lint": "eslint ./src",
1111
"compile": "babel ./src -d ./lib --copy-files",
12-
"preversion": "npm run compile",
13-
"postversion": "git push && npm publish && git push --tags"
12+
"prepublishOnly": "yarn compile",
13+
"semantic-release": "semantic-release"
1414
},
1515
"repository": {
1616
"type": "git",
@@ -30,39 +30,51 @@
3030
},
3131
"homepage": "https://github.com/makeomatic/ms-token#readme",
3232
"peerDependencies": {
33-
"ioredis": "^2.2.0 || 3.x.x"
33+
"ioredis": "3.x.x || 4.x.x"
3434
},
3535
"engine": {
36-
"node": ">= 7.6.0"
36+
"node": ">= 8.9.0"
3737
},
3838
"devDependencies": {
39-
"@makeomatic/deploy": "^1.4.0",
40-
"babel-cli": "^6.24.1",
41-
"babel-eslint": "^7.2.3",
42-
"babel-plugin-istanbul": "^4.1.3",
43-
"babel-plugin-transform-class-properties": "^6.24.1",
44-
"babel-plugin-transform-object-rest-spread": "^6.23.0",
45-
"babel-plugin-transform-strict-mode": "^6.24.1",
46-
"babel-register": "^6.24.1",
47-
"codecov": "^2.1.0",
48-
"cross-env": "^4.0.0",
49-
"eslint": "^3.19.0",
50-
"eslint-config-makeomatic": "^1.0.1",
51-
"eslint-plugin-import": "^2.2.0",
52-
"eslint-plugin-mocha": "^4.9.0",
53-
"eslint-plugin-promise": "^3.5.0",
54-
"ioredis": "^2.4.3",
55-
"mocha": "^3.3.0",
56-
"nyc": "^10.3.2",
57-
"rimraf": "^2.6.1"
39+
"@babel/cli": "^7.0.0",
40+
"@babel/core": "^7.0.0",
41+
"@babel/plugin-proposal-class-properties": "^7.0.0",
42+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
43+
"@babel/plugin-transform-strict-mode": "^7.0.0",
44+
"@babel/register": "^7.0.0",
45+
"@makeomatic/deploy": "^8.2.3",
46+
"babel-eslint": "^10.0.1",
47+
"babel-plugin-istanbul": "^5.1.0",
48+
"codecov": "^3.1.0",
49+
"cross-env": "^5.2.0",
50+
"eslint": "^5.9.0",
51+
"eslint-config-makeomatic": "^3.0.0",
52+
"eslint-plugin-import": "^2.14.0",
53+
"eslint-plugin-mocha": "^5.2.0",
54+
"eslint-plugin-promise": "^4.0.1",
55+
"ioredis": "^4.2.0",
56+
"mocha": "^5.2.0",
57+
"nyc": "^13.1.0",
58+
"rimraf": "^2.6.2"
5859
},
5960
"dependencies": {
60-
"base64-url": "^1.3.3",
61-
"chance": "^1.0.8",
62-
"glob": "^7.1.1",
61+
"base64-url": "^2.2.0",
62+
"chance": "^1.0.16",
63+
"glob": "^7.1.3",
6364
"is": "^3.2.1",
64-
"joi": "^10.4.1",
65-
"lodash": "^4.17.2",
66-
"uuid": "^3.0.1"
65+
"joi": "^14.0.6",
66+
"lodash": "^4.17.11",
67+
"uuid": "^3.3.2"
68+
},
69+
"files": [
70+
"src/",
71+
"lib/",
72+
"bin/"
73+
],
74+
"husky": {
75+
"hooks": {
76+
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS",
77+
"prepare-commit-msg": "./node_modules/@makeomatic/deploy/git-hooks/prepare-commit-msg $HUSKY_GIT_PARAMS"
78+
}
6779
}
6880
}

src/actions/create.js

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const Promise = require('bluebird');
21
const Joi = require('joi');
32
const uuid = require('uuid');
43
const crypto = require('../utils/crypto');
@@ -94,44 +93,42 @@ function getSecret(_secret) {
9493
return secret;
9594
}
9695

97-
module.exports = function create(args) {
98-
return Promise
99-
.try(() => Joi.attempt(args, schema))
100-
.then((opts) => {
101-
const { action, id, ttl, metadata } = opts;
102-
const throttle = getThrottle(opts.throttle, ttl);
103-
const uid = opts.regenerate ? uuid.v4() : false;
104-
const secret = getSecret(opts.secret);
105-
106-
const settings = {
107-
id,
108-
action,
109-
ttl,
110-
throttle,
111-
created: Date.now(),
112-
};
113-
114-
const output = {
115-
id,
116-
action,
117-
};
118-
119-
if (uid) {
120-
settings.uid = uid;
121-
output.uid = uid;
122-
}
123-
124-
if (metadata) {
125-
settings.metadata = metadata;
126-
}
127-
128-
if (secret) {
129-
settings.secret = secret;
130-
output.secret = crypto.secret(this.encrypt, secret, { id, action, uid });
131-
}
132-
133-
return this.backend
134-
.create(settings, output)
135-
.return(output);
136-
});
96+
module.exports = async function create(args) {
97+
const opts = Joi.attempt(args, schema);
98+
99+
const { action, id, ttl, metadata } = opts;
100+
const throttle = getThrottle(opts.throttle, ttl);
101+
const uid = opts.regenerate ? uuid.v4() : false;
102+
const secret = getSecret(opts.secret);
103+
104+
const settings = {
105+
id,
106+
action,
107+
ttl,
108+
throttle,
109+
created: Date.now(),
110+
};
111+
112+
const output = {
113+
id,
114+
action,
115+
};
116+
117+
if (uid) {
118+
settings.uid = uid;
119+
output.uid = uid;
120+
}
121+
122+
if (metadata) {
123+
settings.metadata = metadata;
124+
}
125+
126+
if (secret) {
127+
settings.secret = secret;
128+
output.secret = crypto.secret(this.encrypt, secret, { id, action, uid });
129+
}
130+
131+
await this.backend.create(settings, output);
132+
133+
return output;
137134
};

0 commit comments

Comments
 (0)