Skip to content

Commit

Permalink
feat: upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
AVVS committed Jan 22, 2019
1 parent 4656216 commit e67ce66
Show file tree
Hide file tree
Showing 15 changed files with 5,109 additions and 2,307 deletions.
6 changes: 4 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"plugins": [
"transform-strict-mode"
"@babel/plugin-transform-strict-mode"
],
"env": {
"test": {
"plugins": [ "istanbul" ]
"plugins": [
"istanbul"
]
}
}
}
34 changes: 34 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
rules: {
'body-leading-blank': [1, 'always'],
'footer-leading-blank': [1, 'always'],
'header-max-length': [2, 'always', 72],
'scope-case': [2, 'always', 'lower-case'],
'subject-case': [
2,
'never',
['sentence-case', 'start-case', 'pascal-case', 'upper-case']
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [2, 'always', [
'build',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
'major',
'minor',
'patch',
'chore'
]
]
}
};
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "makeomatic"
}
"extends": "makeomatic",
"parser": "babel-eslint"
}
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"src/**/*.spec.js"
],
"require": [
"babel-register"
"@babel/register"
],
"sourceMap": false,
"instrument": false,
Expand Down
15 changes: 15 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"branch": "master",
"analyzeCommits": {
"preset": "angular",
"releaseRules": [
{ "type": "docs", "release": "patch" },
{ "type": "refactor", "release": "patch" },
{ "type": "style", "release": "patch" },
{ "type": "minor", "release": "minor" },
{ "type": "patch", "release": "patch" },
{ "type": "major", "release": "major" },
{ "type": "breaking", "release": "major" }
]
}
}
2 changes: 1 addition & 1 deletion bin/ms-cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

try {
require('babel-register');
require('@babel/register');
require('../src/index.js');
} catch (e) {
require('../lib/index.js');
Expand Down
71 changes: 29 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
"mcli": "./bin/ms-cli.js"
},
"scripts": {
"test": "npm run lint && npm run test:e2e",
"test": "yarn lint && yarn test:e2e",
"test:e2e": "mdep test run",
"lint": "eslint .",
"commit": "simple-commit-message",
"prepublishOnly": "babel -d ./lib ./src",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"semantic-release": "semantic-release"
},
"publishConfig": {
"access": "public"
"registry": "https://registry.npmjs.org"
},
"repository": {
"type": "git",
Expand All @@ -32,48 +31,36 @@
},
"homepage": "https://github.com/microfleet/cli#readme",
"dependencies": {
"@microfleet/transport-amqp": "^12.1.3",
"bluebird": "^3.4.6",
"@microfleet/transport-amqp": "^13.1.3",
"bluebird": "^3.5.3",
"bunyan": "^1.8.12",
"ms-conf": "^3.1.2",
"stdout-stream": "^1.4.0",
"yargs": "^8.0.2"
"common-errors": "^1.0.5",
"ms-conf": "^3.3.3",
"stdout-stream": "^1.4.1",
"yargs": "^12.0.5"
},
"devDependencies": {
"@makeomatic/deploy": "^4.1.3",
"babel-cli": "^6.16.0",
"babel-eslint": "^7.0.0",
"babel-plugin-istanbul": "^4.1.4",
"babel-plugin-transform-strict-mode": "^6.11.3",
"babel-register": "^6.16.3",
"codecov": "^2.2.0",
"cross-env": "^5.0.2",
"diff": "^3.3.0",
"eslint": "^4.3.0",
"eslint-config-makeomatic": "^1.0.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-promise": "^3.5.0",
"mocha": "^3.5.0",
"nyc": "^11.1.0"
},
"release": {
"analyzeCommits": "simple-commit-message",
"generateNotes": "github-post-release",
"verifyConditions": "@makeomatic/condition-semaphore",
"getLastRelease": "@makeomatic/last-release-npm",
"branch": "master"
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-transform-strict-mode": "^7.0.0",
"@babel/register": "^7.0.0",
"@makeomatic/deploy": "^8.3.1",
"babel-eslint": "^10.0.1",
"babel-plugin-istanbul": "^5.1.0",
"codecov": "^3.1.0",
"cross-env": "^5.2.0",
"diff": "^4.0.1",
"eslint": "^5.12.1",
"eslint-config-makeomatic": "^3.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-promise": "^4.0.1",
"mocha": "^5.2.0",
"nyc": "^13.1.0"
},
"config": {
"pre-git": {
"commit-msg": "simple",
"pre-commit": [],
"pre-push": [],
"post-commit": [],
"post-checkout": [],
"post-merge": []
"husky": {
"hooks": {
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS",
"prepare-commit-msg": "./node_modules/@makeomatic/deploy/git-hooks/prepare-commit-msg $HUSKY_GIT_PARAMS"
}
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
}
}
9 changes: 4 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const Promise = require('bluebird');
const bunyan = require('bunyan');
const conf = require('ms-conf');
const getTransport = require('./transport');

// set default namespace
process.env.NCONF_NAMESPACE = process.env.NCONF_NAMESPACE || 'MS_CLI';
Expand All @@ -15,7 +14,7 @@ const log = bunyan.createLogger({

log.trace({ config }, 'default amqp config');

const argv = require('yargs')
const { argv } = require('yargs')
.usage('Usage: $0 --q.offset=0 --q.limit=10 -r payments.transactions.common')
.option('port', {
alias: 'p',
Expand Down Expand Up @@ -53,23 +52,23 @@ const argv = require('yargs')
default: 15000,
})
.config(config)
.help('help')
.argv;
.help('help');

// parse to JSON
if (typeof argv.q === 'string') {
argv.q = JSON.parse(argv.q);
}

log.trace('sending data with', argv);
const getTransport = require('./transport');

// issue command
Promise.using(getTransport(argv), amqp => (
amqp
.publishAndWait(argv.route, argv.q, { timeout: argv.timeout })
.then((response) => {
// eslint-disable-next-line no-console
console.log('%j', response);
console.info('%j', response);
return null;
})
.catch((err) => {
Expand Down
1 change: 1 addition & 0 deletions src/transport.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const AMQPTransport = require('@microfleet/transport-amqp');

// eslint-disable-next-line object-curly-newline
module.exports = function disposer({ host, port, login, password }) {
return AMQPTransport
.connect({
Expand Down
4 changes: 2 additions & 2 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
hostname: rabbitmq

html-to-pdf:
image: microfleet/html-to-pdf:8.2.1-1.1.0
image: microfleet/html-to-pdf
container_name: html-to-pdf
links:
- rabbitmq
Expand All @@ -22,7 +22,7 @@ services:
NCONF_FILE_PATH: '["/configs"]'

tester:
image: makeomatic/node:8.2.1-tester
image: makeomatic/node
container_name: tester
working_dir: /src
volumes:
Expand Down
2 changes: 1 addition & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--timeout 30000
--timeout 45000
Binary file added test/sample-fail.pdf
Binary file not shown.
Binary file modified test/sample.pdf
Binary file not shown.
76 changes: 33 additions & 43 deletions test/suites/ms-cli.spec.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,59 @@
const Promise = require('bluebird');
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const fs = require('fs').promises;
const diff = require('diff');
const spawn = require('child_process').execFile;
const spawn = require('util').promisify(require('child_process').execFile);

describe('ms-cli', () => {
const binaryPath = path.resolve(__dirname, '../../bin/ms-cli.js');

function exec(args = []) {
return Promise.fromNode(next => (
spawn(binaryPath, [...args], {
timeout: 20000,
env: process.env,
cwd: process.cwd(),
}, (err, stdout, stderr) => {
if (err) {
return next(err);
}
async function exec(args = []) {
const { stdout, stderr } = await spawn(binaryPath, [...args], {
timeout: 20000,
env: process.env,
cwd: process.cwd(),
});

assert.equal(stderr, '');
const lines = stdout.split('\n');
return next(null, lines.slice(0, -1));
})
));
assert.equal(stderr, '');
const lines = stdout.split('\n');
return lines.slice(0, -1);
}

it('performs sample request', () => {
return exec(['-r', 'pdf.ping']).then((lines) => {
assert.equal(lines.length, 1);
assert.equal(lines[0], '"pong"');
return null;
});
it('performs sample request', async () => {
const lines = await exec(['-r', 'pdf.ping']);
assert.equal(lines.length, 1);
assert.equal(lines[0], '"pong"');
});

it('prints complex object', () => {
return exec(['-r', 'pdf.json']).then((out) => {
assert(JSON.parse(out[0]));
return null;
});
it('prints complex object', async () => {
const [out] = await exec(['-r', 'pdf.json']);
assert(JSON.parse(out));
});

it('performs pdf rendering request', () => {
it('performs pdf rendering request', async () => {
const q = {
template: 'sample',
context: {},
meta: false,
};

const sample = fs.readFileSync(path.resolve(`${__dirname}/../sample.pdf`)).toString('base64');
const sample = await fs.readFile(path.resolve(`${__dirname}/../sample.pdf`), 'base64');
const lines = await exec(['-r', 'pdf.render', '-q', JSON.stringify(q)]);

return exec(['-r', 'pdf.render', '-q', JSON.stringify(q)])
.then((lines) => {
assert.equal(lines.length, 1);
assert.equal(lines.length, 1);

const generatedPDFInBase64 = lines[0].slice(1, -1);
const diffChars = diff.diffChars(generatedPDFInBase64, sample);
const generatedPDFInBase64 = lines[0].slice(1, -1);
const diffChars = diff.diffChars(generatedPDFInBase64, sample);

let chars = Math.abs(generatedPDFInBase64.length - sample.length);
diffChars.forEach((state) => {
if (state.removed) chars += state.count;
});
let chars = Math.abs(generatedPDFInBase64.length - sample.length);
diffChars.forEach((state) => {
if (state.removed) chars += state.count;
});

assert.ok(chars / sample.length < 0.003, 'generated files differ too much');
return null;
});
try {
assert.ok(chars / sample.length < 0.003, `generated files differ too much: ${chars} / ${sample.length}`);
} finally {
await fs.writeFile(path.resolve(`${__dirname}/../sample-fail.pdf`), generatedPDFInBase64, 'base64');
}
});
});
Loading

0 comments on commit e67ce66

Please sign in to comment.