Skip to content

Commit 9b9ebad

Browse files
committed
1.1.4
- removes babel-register, ships a pre-compiled bundle
1 parent e1de012 commit 9b9ebad

File tree

6 files changed

+168
-149
lines changed

6 files changed

+168
-149
lines changed

.npmignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.storybook
2+
/bin
3+
/dist
4+
/docs
5+
/lib
6+
/src
7+
/stories
8+
/test
9+
/coverage
10+
.babelrc
11+
.eslintignore
12+
.eslintrc
13+
.gitignore
14+
.travis.yml
15+
CHANGELOG.md
16+
index.js
17+
jsdoc.json
18+
tryitout.js
19+
webpack.config.js
20+
packed
21+
.nyc_output
22+
package-lock.json

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.1.4 (10/24/2017)
2+
3+
- removes babel-register, ships a pre-compiled bundle
4+
15
# 1.1.3 (10/24/2017)
26

37
- fixes compatibility with older versions of node <8

bin/index.js

-133
This file was deleted.

bin/lcov-server.js

+132-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,137 @@
11
#!/usr/bin/env node
22

3-
const semver = require('semver');
3+
require('babel-polyfill');
44

5-
if (semver.lt(process.version, '8.5.0')) {
6-
// only shim pre 8 binaries
7-
require('babel-polyfill');
8-
require('babel-register');
5+
const program = require('commander');
6+
const http = require('http');
7+
const https = require('https');
8+
const fs = require('fs');
9+
const Path = require('path');
10+
const Url = require('url');
11+
const updateNotifier = require('update-notifier');
12+
13+
const lcov = require('../lib/lcov');
14+
const cobertura = require('../lib/cobertura');
15+
const golang = require('../lib/golang');
16+
const jacoco = require('../lib/jacoco');
17+
18+
const git = require('../lib/git');
19+
const ci = require('../lib/ci');
20+
21+
const pkg = require('../package.json');
22+
23+
updateNotifier({pkg}).notify();
24+
25+
program
26+
.version(pkg.version)
27+
.option('-u, --upload [server]', 'Set the url to upload lcov data too', 'http://localhost:8080')
28+
.option('-s, --serve', 'Pass this option to startup a lcov-server instance')
29+
.option('-d, --db [db]', 'Set the db connection', 'mongodb://localhost:32768/lcov-server')
30+
.option('-p, --parser <parser>', 'Set the parser value [lcov, cobertura, golang, jacoco], defaults to lcov', 'lcov')
31+
.option('-bp, --basePath <path>', 'The path that defines the base directory where the files that were covered will be located')
32+
.parse(process.argv);
33+
34+
const { parser, upload, serve, db, basePath } = program;
35+
36+
if(parser && ['lcov', 'cobertura', 'golang', 'jacoco'].indexOf(parser) === -1) {
37+
console.error(`parser ${parser} not supported`); // eslint-disable-line
38+
process.exit(1);
939
}
1040

11-
require('./index.js');
41+
if(serve) {
42+
process.env.MONGO_URL = process.env.MONGO_URL || db;
43+
44+
require('../index');
45+
} else {
46+
const parsedUrl = Url.parse(upload);
47+
48+
let input = '';
49+
process.stdin.resume();
50+
process.stdin.setEncoding('utf8');
51+
process.stdin.on('data', (chunk) => {
52+
input += chunk;
53+
});
54+
process.stdin.on('end', (async () => {
55+
const env = ci();
56+
const output = {
57+
service_job_id: env.service_job_id,
58+
service_pull_request: env.service_pull_request,
59+
service_name: env.service_name,
60+
source_files: [],
61+
git: {
62+
commit: env.commit,
63+
branch: env.branch,
64+
message: env.message,
65+
committer_name: env.committer_name,
66+
committer_email: env.committer_email
67+
},
68+
run_at: new Date()
69+
};
70+
71+
let _lcov = {};
72+
switch(parser) {
73+
case 'lcov':
74+
_lcov = await lcov.parse(input);
75+
break;
76+
case 'cobertura':
77+
_lcov = await cobertura.parse(input);
78+
break;
79+
case 'golang':
80+
_lcov = await golang.parse(input);
81+
break;
82+
case 'jacoco':
83+
_lcov = await jacoco.parse(input);
84+
break;
85+
}
86+
87+
const _git = await git.parse();
88+
89+
// Go through and set the file contents
90+
for (let i = 0; i < _lcov.length; i++) {
91+
let path = basePath ? Path.resolve(process.cwd(), basePath, _lcov[i].file) : _lcov[i].file;
92+
93+
_lcov[i].source = fs.readFileSync(path).toString('utf8');
94+
_lcov[i].title = _lcov[i].file.substring(_lcov[i].file.lastIndexOf('/') + 1, _lcov[i].file.length);
95+
}
96+
97+
output['source_files'] = _lcov;
98+
output['git'] = Object.assign(output['git'], _git);
99+
100+
const options = {
101+
hostname: parsedUrl.hostname,
102+
port: parsedUrl.port || 80,
103+
path: '/api/upload',
104+
method: 'POST',
105+
headers: {
106+
'Content-Type': 'application/json',
107+
}
108+
};
109+
let operation = http;
110+
let data = '';
111+
112+
if(parsedUrl.protocol == 'https:') {
113+
options.port = 443;
114+
operation = https;
115+
}
116+
117+
let req = operation.request(options, (res) => {
118+
res.on('data', (chunk) => {
119+
data += chunk;
120+
});
121+
res.on('end', () => {
122+
try {
123+
const response = JSON.parse(data);
124+
if(response.error) {
125+
console.error(response.error); // eslint-disable-line
126+
} else {
127+
console.log(`\n coverage sent successfully 💚 \n`); // eslint-disable-line
128+
}
129+
} catch(ex) {
130+
console.log(`\n uhoh something went wrong, ${ex.toString()}`); // eslint-disable-line
131+
}
132+
});
133+
});
134+
req.write(JSON.stringify(output));
135+
req.end();
136+
}));
137+
}

dist/bundle.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lcov-server",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "🎯 A simple lcov server & cli parser",
55
"main": "index.js",
66
"homepage": "https://github.com/gabrielcsapo/lcov-server#readme",
@@ -18,7 +18,9 @@
1818
"lint": "eslint .",
1919
"test": "tape test/lib/**/*.js test/index.js",
2020
"coverage": "tap test/lib/**.js --coverage --coverage-report=lcov",
21-
"build": "NODE_ENV=production webpack --progress",
21+
"build": "npm run build:client && npm run build:server",
22+
"build:server": "babel index.js --out-dir ./distributed && babel lib --out-dir ./distributed/lib && babel bin --out-dir ./distributed/bin && cp package.json ./distributed/ && cp -r dist ./distributed",
23+
"build:client": "NODE_ENV=production webpack --progress",
2224
"start": "./bin/lcov-server.js --serve",
2325
"dev": "NODE_ENV=development webpack-dev-server --hot --port 5000",
2426
"pack": "pkg bin/lcov-server.js -c package.json -o packed/lcov-server",
@@ -28,7 +30,7 @@
2830
},
2931
"author": "Gabriel J. Csapo <[email protected]>",
3032
"bin": {
31-
"lcov-server": "./bin/lcov-server.js"
33+
"lcov-server": "./distributed/bin/lcov-server.js"
3234
},
3335
"pkg": {
3436
"scripts": [
@@ -43,33 +45,31 @@
4345
],
4446
"targets": [
4547
"node8-macos-x64",
46-
"node8-alpine-x64",
4748
"node8-linux-x64",
4849
"node8-win-x64"
4950
]
5051
},
5152
"license": "Apache-2.0",
5253
"dependencies": {
5354
"babel-polyfill": "^6.26.0",
54-
"babel-preset-env": "^1.6.1",
55-
"babel-register": "^6.26.0",
5655
"commander": "^2.11.0",
5756
"compression": "^1.7.1",
5857
"express": "^4.16.2",
5958
"git-url-parse": "^7.0.1",
6059
"mongoose": "^4.12.1",
6160
"openbadge": "^1.0.4",
62-
"semver": "^5.4.1",
6361
"serve-static": "^1.13.1",
6462
"update-notifier": "^2.3.0",
6563
"xml2js": "^0.4.19"
6664
},
6765
"devDependencies": {
6866
"@storybook/addon-knobs": "^3.2.12",
6967
"@storybook/react": "^3.2.12",
68+
"babel-cli": "^6.26.0",
7069
"babel-core": "^6.26.0",
7170
"babel-loader": "^7.1.2",
7271
"babel-minify-webpack-plugin": "^0.2.0",
72+
"babel-preset-env": "^1.6.1",
7373
"babel-preset-react": "^6.24.1",
7474
"body-parser": "^1.18.2",
7575
"css-loader": "^0.28.7",

0 commit comments

Comments
 (0)