Skip to content

Commit

Permalink
1.3.0
Browse files Browse the repository at this point in the history
- cleans up cli logic (ensures async block runs and catches)
- updates dependencies
  • Loading branch information
gabrielcsapo committed May 15, 2019
1 parent d3797ea commit 9b0a414
Show file tree
Hide file tree
Showing 21 changed files with 196 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["env"]
"presets": ["@babel/env", "@babel/react"]
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.3.0 (05/14/2019)

- cleans up cli logic (ensures async block runs and catches)
- updates dependencies

# 1.2.6 (01/12/2018)

- fixes linting
Expand Down
7 changes: 4 additions & 3 deletions bin/lcov-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ if(serve) {
});
process.stdin.on('end', (async () => {
try {
let response = cli({ parser, input, url: upload, basePath });
let response = await cli({ parser, input, url: upload, basePath });

if(response.error) {
console.error(`coverage not sent with reason:\n ${response.error}`); // eslint-disable-line
console.error(`\n coverage not sent with reason:\n ${response.error}\n`); // eslint-disable-line
} else {
console.log('\n coverage sent successfully 💚 \n'); // eslint-disable-line
}
} catch(ex) {
console.error(`coverage could not be parsed with reason:\n ${ex.toString()}`); // eslint-disable-line
console.error(`\n coverage could not be parsed with reason:\n ${ex.toString()}\n`); // eslint-disable-line
}
}));
}
1 change: 1 addition & 0 deletions dist/app.js

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions dist/bundle.js

This file was deleted.

5 changes: 3 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<body>
<div id="root"></div>

<script src="/vendor.bundle.js"></script>
<script src="/bundle.js"></script>
<script src="/app.js"></script>
<script src="/vendor.js"></script>
<script src="/vendors.js"></script>
</body>
</html>
19 changes: 0 additions & 19 deletions dist/vendor.bundle.js

This file was deleted.

1 change: 1 addition & 0 deletions dist/vendor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions dist/vendors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const mongoose = require('mongoose');

mongoose.Promise = global.Promise;
mongoose.connect(process.env.MONGO_URL, { useMongoClient: true }, function(error) {
mongoose.connect(process.env.MONGO_URL, {}, function(error) {
if(error) {
console.error(error.message); // eslint-disable-line
process.exit(1);
Expand Down
166 changes: 85 additions & 81 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const Url = require('url');
const http = require('http');
const https = require('https');

const lcov = require('../lib/lcov');
const cobertura = require('../lib/cobertura');
const golang = require('../lib/golang');
const jacoco = require('../lib/jacoco');
const lcov = require('../lib/parsers/lcov');
const cobertura = require('../lib/parsers/cobertura');
const golang = require('../lib/parsers/golang');
const jacoco = require('../lib/parsers/jacoco');

const git = require('../lib/git');
const ci = require('../lib/ci');
Expand All @@ -16,90 +16,94 @@ module.exports = function cli({ parser, input, url, basePath }) {
const parsedUrl = Url.parse(url);

return new Promise(async function(resolve, reject) {
const info = await git.parse();
const env = ci();
const output = {
service_job_id: env.service_job_id,
service_pull_request: env.service_pull_request,
service_name: env.service_name,
source_files: [],
git: {
author_date: info.author_date,
author_email: info.author_email,
author_name: info.author_name,
committer_date: info.committer_date,
commit: env.commit || info.commit,
branch: env.branch || info.branch,
message: env.message || info.message,
committer_name: env.committer_name || info.committer_name,
committer_email: env.committer_email || info.committer_email,
remotes: info.remotes
},
run_at: new Date()
};
try {
const info = await git.parse();
const env = ci();
const output = {
service_job_id: env.service_job_id,
service_pull_request: env.service_pull_request,
service_name: env.service_name,
source_files: [],
git: {
author_date: info.author_date,
author_email: info.author_email,
author_name: info.author_name,
committer_date: info.committer_date,
commit: env.commit || info.commit,
branch: env.branch || info.branch,
message: env.message || info.message,
committer_name: env.committer_name || info.committer_name,
committer_email: env.committer_email || info.committer_email,
remotes: info.remotes
},
run_at: new Date()
};

switch(parser) {
case 'cobertura':
output['source_files'] = await cobertura.parse(input);
break;
case 'golang':
output['source_files'] = await golang.parse(input);
break;
case 'jacoco':
output['source_files'] = await jacoco.parse(input);
break;
default:
output['source_files'] = await lcov.parse(input);
break;
}
switch(parser) {
case 'cobertura':
output['source_files'] = await cobertura.parse(input);
break;
case 'golang':
output['source_files'] = await golang.parse(input);
break;
case 'jacoco':
output['source_files'] = await jacoco.parse(input);
break;
default:
output['source_files'] = await lcov.parse(input);
break;
}

// Go through and set the file contents
for (let i = 0; i < output['source_files'].length; i++) {
let path = basePath ? Path.resolve(process.cwd(), basePath, output['source_files'][i].file) : output['source_files'][i].file;
// Go through and set the file contents
for (let i = 0; i < output['source_files'].length; i++) {
let path = basePath ? Path.resolve(process.cwd(), basePath, output['source_files'][i].file) : output['source_files'][i].file;

if(fs.existsSync(path)) {
output['source_files'][i].source = fs.readFileSync(path).toString('utf8');
output['source_files'][i].title = output['source_files'][i].file.substring(output['source_files'][i].file.lastIndexOf('/') + 1, output['source_files'][i].file.length);
} else {
return reject(`can not find file at ${path}`);
}
}
if(fs.existsSync(path)) {
output['source_files'][i].source = fs.readFileSync(path).toString('utf8');
output['source_files'][i].title = output['source_files'][i].file.substring(output['source_files'][i].file.lastIndexOf('/') + 1, output['source_files'][i].file.length);
} else {
return reject(`can not find file at ${path}`);
}
}

const options = {
hostname: parsedUrl.hostname,
port: parsedUrl.port || 80,
path: '/api/upload',
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
};
let operation = http;
let data = '';
const options = {
hostname: parsedUrl.hostname,
port: parsedUrl.port || 80,
path: '/api/upload',
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
};
let operation = http;
let data = '';

if(parsedUrl.protocol == 'https:') {
options.port = 443;
operation = https;
}
if(parsedUrl.protocol == 'https:') {
options.port = 443;
operation = https;
}

let req = operation.request(options, (res) => {
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
try {
const response = JSON.parse(data);
if(response.error) {
return reject(response.error); // eslint-disable-line
} else {
return resolve(response);
let req = operation.request(options, (res) => {
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
try {
const response = JSON.parse(data);
if(response.error) {
return reject(response.error); // eslint-disable-line
} else {
return resolve(response);
}
} catch(ex) {
return reject(ex);
}
} catch(ex) {
return reject(ex);
}
});
});
});
req.write(JSON.stringify(output));
req.end();
req.write(JSON.stringify(output));
req.end();
} catch(ex) {
return reject(ex);
}
});
};
2 changes: 1 addition & 1 deletion lib/cobertura.js → lib/parsers/cobertura.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module lib/cobertura
* @module lib/parsers/cobertura
*/

var fs = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion lib/golang.js → lib/parsers/golang.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module lib/golang
* @module lib/parsers/golang
*/

var fs = require("fs");
Expand Down
2 changes: 1 addition & 1 deletion lib/jacoco.js → lib/parsers/jacoco.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module lib/jacoco
* @module lib/parsers/jacoco
*/

const fs = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion lib/lcov.js → lib/parsers/lcov.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module lib/lcov
* @module lib/parsers/lcov
*/

const fs = require('fs');
Expand Down
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lcov-server",
"version": "1.2.6",
"version": "1.3.0",
"description": "🎯 A simple lcov server & cli parser",
"main": "index.js",
"homepage": "https://github.com/gabrielcsapo/lcov-server#readme",
Expand Down Expand Up @@ -45,56 +45,56 @@
"node_modules/openbadge/**/**"
],
"targets": [
"node8-macos-x64",
"node8-linux-x64",
"node8-win-x64"
"node12-macos-x64",
"node12-linux-x64",
"node12-win-x64"
]
},
"license": "Apache-2.0",
"dependencies": {
"babel-polyfill": "^6.26.0",
"badgeit": "0.0.2",
"badgeit": "^0.1.1",
"compression": "^1.7.1",
"express": "^4.16.2",
"git-url-parse": "^7.0.2",
"git-url-parse": "^11.1.2",
"moment": "^2.20.1",
"mongoose": "^4.13.9",
"mongoose": "^5.5.8",
"openbadge": "^1.0.4",
"serve-static": "^1.13.1",
"update-notifier": "^2.3.0",
"update-notifier": "^3.0.0",
"xml2js": "^0.4.19"
},
"devDependencies": {
"@storybook/addon-knobs": "^3.3.8",
"@storybook/react": "^3.3.8",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-minify-webpack-plugin": "^0.2.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"body-parser": "^1.18.2",
"css-loader": "^0.28.8",
"docdash": "^0.4.0",
"eslint": "^4.15.0",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"@storybook/addon-knobs": "^5.0.11",
"@storybook/react": "^5.0.11",
"babel-loader": "^8.0.6",
"babel-minify-webpack-plugin": "^0.3.1",
"body-parser": "^1.19.0",
"css-loader": "^2.1.1",
"docdash": "^1.1.0",
"eslint": "^5.16.0",
"eslint-plugin-react": "^7.5.1",
"getstorybook": "^1.7.0",
"highlight.js": "^9.12.0",
"jsdoc": "^3.5.4",
"pkg": "^4.2.6",
"prop-types": "^15.6.0",
"psychic.css": "0.0.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"react-select": "^1.2.1",
"react-router-dom": "^5.0.0",
"react-select": "^2.4.3",
"shelljs": "^0.8.0",
"style-loader": "^0.19.1",
"tap": "^11.0.1",
"style-loader": "^0.23.1",
"tap": "^13.1.9",
"tape": "^4.8.0",
"tryitout": "^2.0.6",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.9.7",
"whatwg-fetch": "^2.0.3"
"webpack": "^4.31.0",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.3.1",
"whatwg-fetch": "^3.0.0"
}
}
2 changes: 1 addition & 1 deletion src/coverage/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Coverage extends React.Component {
<a href={`/coverage/${source.replace(/\./g, '%2E')}/${owner}/`}>{owner}</a> / <a href={`/coverage/${source.replace(/\./g, '%2E')}/${owner}/${name}`}>{name}</a>
</h3>
<p>
<a className="coverage-commit-message" href={commitUrl} target="_blank"> {message} </a>
<a className="coverage-commit-message" href={commitUrl} target="_blank" rel="noopener noreferrer"> {message} </a>
on branch
<b> {branch || git_branch} </b>
{Moment(author_date * 1000).fromNow()}
Expand Down
2 changes: 1 addition & 1 deletion src/coverage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class File extends React.Component {
<div style={{float: 'left', textAlign: 'left'}}>
<h3> <a href={`/coverage/${source.replace(/\./g, '%2E')}/${owner}/`}>{owner}</a> / <a href={`/coverage/${source.replace(/\./g, '%2E')}/${owner}/${name}`}>{name}</a> / <a href={`/coverage/${source.replace(/\./g, '%2E')}/${owner}/${name}/${encodeURIComponent(file).replace(/\./g, '$2E')}`}>{file}</a> </h3>
<p>
<a className="coverage-commit-message" href={commitUrl} target="_blank"> {message} </a>
<a className="coverage-commit-message" href={commitUrl} target="_blank" rel="noopener noreferrer"> {message} </a>
on branch
<b> {branch} </b>
{moment(author_date * 1000).fromNow()}
Expand Down
2 changes: 1 addition & 1 deletion src/coverage/list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ListItem extends React.Component {
<div style={{float: 'left', textAlign: 'left'}}>
<h3> <a href={`/coverage/${resource.replace(/\./g, '%2E').replace(`.${protocol}`, '')}/${owner}/`}>{owner}</a> / <a href={`/coverage/${resource.replace(/\./g, '%2E').replace(`.${protocol}`, '')}/${owner}/${name}`}>{name}</a> </h3>
<p>
<a className="coverage-commit-message" href={commitUrl} target="_blank"> {message} </a>
<a className="coverage-commit-message" href={commitUrl} target="_blank" rel="noopener noreferrer"> {message} </a>
on branch
<b> {branch || git_branch} </b>
{moment(author_date * 1000).fromNow()}
Expand Down
2 changes: 0 additions & 2 deletions src/coverage/list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'react-select/dist/react-select.css';

import React from 'react';
import PropTypes from 'prop-types';
import Select from 'react-select';
Expand Down
Loading

0 comments on commit 9b0a414

Please sign in to comment.