Skip to content

Commit b8aae1d

Browse files
committed
1.1.0
- adds the ability to parse , and - packages entire application as global executable using pkg - instantly fails the process if process can't connect to mongo - adds a limit option to coverage.get to speed up badge generation - utilizes async await in main router - utilizes async await in tests - moved from to - uses the right environment variables for travis-ci - compiles module with babel, allowing it to be used over multiple versions of node (previously older versions were not supported) - sets a limit to only retrieve 10 builds on the list-item view (reduces data on the wire) - adds viewport meta tag to scale on multiple devices - adds other meta tags to ensure SEO - moves version of release to the footer
1 parent 35641e3 commit b8aae1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+7193
-396
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"browser": true
1010
},
1111
"parserOptions": {
12-
"ecmaVersion": 6,
12+
"ecmaVersion": "2017",
1313
"sourceType": "module",
1414
"ecmaFeatures": {
1515
"jsx": true

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ node_modules
44
.DS_Store
55
npm-debug.log
66
package-lock.json
7+
packed
8+
distributed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ script:
88
- npm run coverage
99
- cat coverage/lcov.info | lcov-server --upload https://lcov-server.gabrielcsapo.com
1010
node_js:
11-
- "6"
1211
- "8"
1312
os:
1413
- linux

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# 1.1.0 (10/24/2017)
2+
3+
- adds the ability to parse `cobertura`, `golang` and `jacoco`
4+
- packages entire application as global executable using pkg
5+
- instantly fails the process if process can't connect to mongo
6+
- adds a limit option to coverage.get to speed up badge generation
7+
- utilizes async await in main router
8+
- utilizes async await in tests
9+
- moved from `psychic-ui` to `psychic.css`
10+
- uses the right environment variables for travis-ci
11+
- compiles module with babel, allowing it to be used over multiple versions of node (previously older versions were not supported)
12+
- sets a limit to only retrieve 10 builds on the list-item view (reduces data on the wire)
13+
- adds viewport meta tag to scale on multiple devices
14+
- adds other meta tags to ensure SEO
15+
- moves version of release to the footer
16+
117
# 1.0.6 (10/23/2017)
218

319
- adds monospace font-family to fileView

README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ Usage: lcov-server [options]
4545
4646
Options:
4747
48-
-V, --version output the version number
49-
-u, --upload [server] Set the url to upload lcov data too
50-
-s, --serve Pass this option to startup a lcov-server instance
51-
-d, --db [db] Set the db connection
52-
-h, --help output usage information
48+
-V, --version output the version number
49+
-u, --upload [server] Set the url to upload lcov data too
50+
-s, --serve Pass this option to startup a lcov-server instance
51+
-d, --db [db] Set the db connection
52+
-p, --parser <parser> Set the parser value [lcov, cobertura, golang, jacoco], defaults to lcov
53+
-bp, --basePath <path> The path that defines the base directory where the files that were covered will be located
54+
-h, --help output usage information
5355
```
5456

5557
## Upload

TODO.md

-4
This file was deleted.

bin/index.js

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
const program = require('commander');
2+
const http = require('http');
3+
const https = require('https');
4+
const fs = require('fs');
5+
const Path = require('path');
6+
const Url = require('url');
7+
const updateNotifier = require('update-notifier');
8+
9+
const lcov = require('../lib/lcov');
10+
const cobertura = require('../lib/cobertura');
11+
const golang = require('../lib/golang');
12+
const jacoco = require('../lib/jacoco');
13+
14+
const git = require('../lib/git');
15+
const ci = require('../lib/ci');
16+
17+
const pkg = require('../package.json');
18+
19+
updateNotifier({pkg}).notify();
20+
21+
program
22+
.version(pkg.version)
23+
.option('-u, --upload [server]', 'Set the url to upload lcov data too', 'http://localhost:8080')
24+
.option('-s, --serve', 'Pass this option to startup a lcov-server instance')
25+
.option('-d, --db [db]', 'Set the db connection', 'mongodb://localhost:32768/lcov-server')
26+
.option('-p, --parser <parser>', 'Set the parser value [lcov, cobertura, golang, jacoco], defaults to lcov', 'lcov')
27+
.option('-bp, --basePath <path>', 'The path that defines the base directory where the files that were covered will be located')
28+
.parse(process.argv);
29+
30+
const { parser, upload, serve, db, basePath } = program;
31+
32+
if(parser && ['lcov', 'cobertura', 'golang', 'jacoco'].indexOf(parser) === -1) {
33+
console.error(`parser ${parser} not supported`); // eslint-disable-line
34+
process.exit(1);
35+
}
36+
37+
if(serve) {
38+
process.env.MONGO_URL = process.env.MONGO_URL || db;
39+
40+
require('../index');
41+
} else {
42+
const parsedUrl = Url.parse(upload);
43+
44+
let input = '';
45+
process.stdin.resume();
46+
process.stdin.setEncoding('utf8');
47+
process.stdin.on('data', (chunk) => {
48+
input += chunk;
49+
});
50+
process.stdin.on('end', (async () => {
51+
const env = ci();
52+
const output = {
53+
service_job_id: env.service_job_id,
54+
service_pull_request: env.service_pull_request,
55+
service_name: env.service_name,
56+
source_files: [],
57+
git: {
58+
commit: env.commit,
59+
branch: env.branch,
60+
message: env.message,
61+
committer_name: env.committer_name,
62+
committer_email: env.committer_email
63+
},
64+
run_at: new Date()
65+
};
66+
67+
let _lcov = {};
68+
switch(parser) {
69+
case 'lcov':
70+
_lcov = await lcov.parse(input);
71+
break;
72+
case 'cobertura':
73+
_lcov = await cobertura.parse(input);
74+
break;
75+
case 'golang':
76+
_lcov = await golang.parse(input);
77+
break;
78+
case 'jacoco':
79+
_lcov = await jacoco.parse(input);
80+
break;
81+
}
82+
83+
const _git = await git.parse();
84+
85+
// Go through and set the file contents
86+
for (let i = 0; i < _lcov.length; i++) {
87+
let path = basePath ? Path.resolve(process.cwd(), basePath, _lcov[i].file) : _lcov[i].file;
88+
89+
_lcov[i].source = fs.readFileSync(path).toString('utf8');
90+
_lcov[i].title = _lcov[i].file.substring(_lcov[i].file.lastIndexOf('/') + 1, _lcov[i].file.length);
91+
}
92+
93+
output['source_files'] = _lcov;
94+
output['git'] = Object.assign(output['git'], _git);
95+
96+
const options = {
97+
hostname: parsedUrl.hostname,
98+
port: parsedUrl.port || 80,
99+
path: '/api/upload',
100+
method: 'POST',
101+
headers: {
102+
'Content-Type': 'application/json',
103+
}
104+
};
105+
let operation = http;
106+
let data = '';
107+
108+
if(parsedUrl.protocol == 'https:') {
109+
options.port = 443;
110+
operation = https;
111+
}
112+
113+
let req = operation.request(options, (res) => {
114+
res.on('data', (chunk) => {
115+
data += chunk;
116+
});
117+
res.on('end', () => {
118+
try {
119+
const response = JSON.parse(data);
120+
if(response.error) {
121+
console.error(response.error); // eslint-disable-line
122+
} else {
123+
console.log(`\n coverage sent successfully 💚 \n`); // eslint-disable-line
124+
}
125+
} catch(ex) {
126+
console.log(`\n uhoh something went wrong, ${ex.toString()}`); // eslint-disable-line
127+
}
128+
});
129+
});
130+
req.write(JSON.stringify(output));
131+
req.end();
132+
}));
133+
}

bin/lcov-server.js

+7-114
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,11 @@
11
#!/usr/bin/env node
22

3-
const program = require('commander');
4-
const http = require('http');
5-
const https = require('https');
6-
const fs = require('fs');
7-
const Url = require('url');
8-
const updateNotifier = require('update-notifier');
3+
const semver = require('semver');
94

10-
const lcov = require('../lib/lcov');
11-
const git = require('../lib/git');
12-
const ci = require('../lib/ci');
13-
14-
const pkg = require('../package.json');
15-
16-
updateNotifier({pkg}).notify();
17-
18-
program
19-
.version(pkg.version)
20-
.option('-u, --upload [server]', 'Set the url to upload lcov data too', 'http://localhost:8080')
21-
.option('-s, --serve', 'Pass this option to startup a lcov-server instance')
22-
.option('-d, --db [db]', 'Set the db connection', 'mongodb://localhost:32768/lcov-server')
23-
.parse(process.argv);
24-
25-
const { upload, serve, db } = program;
26-
27-
if(serve) {
28-
process.env.MONGO_URL = process.env.MONGO_URL || db;
29-
30-
require('../index');
31-
} else {
32-
const parsedUrl = Url.parse(upload);
33-
34-
let input = '';
35-
process.stdin.resume();
36-
process.stdin.setEncoding('utf8');
37-
process.stdin.on('data', (chunk) => {
38-
input += chunk;
39-
});
40-
process.stdin.on('end', () => {
41-
const env = ci();
42-
const output = {
43-
service_job_id: env.service_job_id,
44-
service_pull_request: env.service_pull_request,
45-
service_name: env.service_name,
46-
source_files: [],
47-
git: {
48-
commit: env.commit,
49-
branch: env.branch,
50-
message: env.message,
51-
committer_name: env.committer_name,
52-
committer_email: env.committer_email
53-
},
54-
run_at: new Date()
55-
};
56-
57-
lcov.parse(input)
58-
.then((_lcov) => {
59-
// Go through and set the file contents
60-
for (let i = 0; i < _lcov.length; i++) {
61-
_lcov[i].source = fs.readFileSync(_lcov[i].file).toString('utf8');
62-
_lcov[i].title = _lcov[i].file.substring(_lcov[i].file.lastIndexOf('/') + 1, _lcov[i].file.length);
63-
}
64-
output['source_files'] = _lcov;
65-
66-
git.parse()
67-
.then(function(_git) {
68-
output['git'] = Object.assign(output['git'], _git);
69-
70-
const options = {
71-
hostname: parsedUrl.hostname,
72-
port: parsedUrl.port || 80,
73-
path: '/api/upload',
74-
method: 'POST',
75-
headers: {
76-
'Content-Type': 'application/json',
77-
}
78-
};
79-
80-
let req, operation, data = '';
81-
if(parsedUrl.protocol == 'https:') {
82-
options.port = 443;
83-
operation = https;
84-
} else {
85-
operation = http;
86-
}
87-
88-
req = operation.request(options, (res) => {
89-
res.on('data', (chunk) => {
90-
data += chunk;
91-
});
92-
res.on('end', () => {
93-
try {
94-
const response = JSON.parse(data);
95-
if(response.error) {
96-
console.error(response.error); // eslint-disable-line
97-
} else {
98-
console.log(`\n coverage sent successfully 💚 \n`); // eslint-disable-line
99-
}
100-
} catch(ex) {
101-
console.log(`\n uhoh something went wrong, ${ex.toString()}`); // eslint-disable-line
102-
}
103-
});
104-
});
105-
req.write(JSON.stringify(output));
106-
req.end();
107-
})
108-
.catch((err) => {
109-
console.log(err); // eslint-disable-line
110-
process.exit(1);
111-
});
112-
})
113-
.catch((err) => {
114-
console.log(`could not parse lcov report correctly: ${err}`); // eslint-disable-line
115-
process.exit(1);
116-
});
117-
});
5+
if (semver.lt(process.version, '8.5.0')) {
6+
// only shim pre 8 binaries
7+
require('babel-register');
8+
require('babel-polyfill');
1189
}
10+
11+
require('./index.js');

0 commit comments

Comments
 (0)