Skip to content

Commit c7c6397

Browse files
committed
Merge branch 'release/0.0.4'
# Conflicts: # README.md
2 parents 36789de + 7c2c0df commit c7c6397

File tree

9 files changed

+184
-27
lines changed

9 files changed

+184
-27
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,5 @@ fabric.properties
156156

157157
# End of https://www.gitignore.io/api/node,macos,typings,webstorm
158158
/dist/
159+
/build/
160+
/coverage/

.travis.yml

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
# You can use any Docker image from Docker Hub or your own container registry
1+
sudo: false
22
language: node_js
33
node_js:
44
- "7.7.1"
55

6-
env:
7-
- CXX=g++-4.8
8-
addons:
9-
apt:
10-
sources:
11-
- ubuntu-toolchain-r-test
12-
packages:
13-
- g++-4.8
14-
156
branches:
167
only:
178
- master
9+
- develop
1810

1911
before_install:
2012
- npm config set spin false
@@ -32,4 +24,7 @@ before_script:
3224
- tsc
3325

3426
script:
35-
- npm test
27+
- npm test
28+
29+
after_success:
30+
- bash <(curl -s https://codecov.io/bash)

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
[![npm version](https://badge.fury.io/js/winston-decorator.svg)](https://badge.fury.io/js/winston-decorator)
44
[![Build Status](https://travis-ci.org/marmos91/winston-decorator.svg?branch=master)](https://travis-ci.org/marmos91/winston-decorator)
5-
[![Test Coverage](https://codeclimate.com/github/marmos91/winston-decorator/badges/coverage.svg)](https://codeclimate.com/github/marmos91/winston-decorator/coverage)
6-
[![Code Climate](https://codeclimate.com/github/marmos91/winston-decorator/badges/gpa.svg)](https://codeclimate.com/github/marmos91/winston-decorator)
5+
[![codecov](https://codecov.io/gh/marmos91/winston-decorator/branch/master/graph/badge.svg)](https://codecov.io/gh/marmos91/winston-decorator)
76
[![Dependencies](https://david-dm.org/marmos91/winston-decorator.svg)](https://david-dm.org/marmos91/winston-decorator.svg)
87

98
A decorator version of the winston logger written completely in Typescript.

codecov.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
comment: off

gulpfile.ts

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import {Gulpclass, Task, MergedTask, SequenceTask} from "gulpclass";
2+
3+
const gulp = require("gulp");
4+
const del = require("del");
5+
const mocha = require("gulp-mocha");
6+
const shell = require("gulp-shell");
7+
const istanbul = require("gulp-istanbul");
8+
const sourcemaps = require("gulp-sourcemaps");
9+
const ts = require("gulp-typescript");
10+
11+
@Gulpclass()
12+
export class GulpFile
13+
{
14+
// -------------------------------------------------------------------------
15+
// Build and packaging
16+
// -------------------------------------------------------------------------
17+
/**
18+
* Cleans build folder.
19+
*/
20+
@Task()
21+
clean(cb: Function)
22+
{
23+
return del(["./build/**"], cb);
24+
}
25+
26+
/**
27+
* Runs typescript files compilation.
28+
*/
29+
@Task()
30+
compile()
31+
{
32+
return gulp.src("package.json", { read: false })
33+
.pipe(shell(["tsc"]));
34+
}
35+
36+
// -------------------------------------------------------------------------
37+
// Main Packaging and Publishing tasks
38+
// -------------------------------------------------------------------------
39+
40+
/**
41+
* Publishes a package to npm from ./build/package directory.
42+
*/
43+
@Task()
44+
packagePublish()
45+
{
46+
return gulp.src("package.json", { read: false })
47+
.pipe(shell([
48+
"cd ./build/package && npm publish"
49+
]));
50+
}
51+
52+
/**
53+
* Copies all sources to the package directory.
54+
*/
55+
@MergedTask()
56+
packageCompile()
57+
{
58+
const tsProject = ts.createProject("tsconfig.json", { typescript: require("typescript") });
59+
const tsResult = gulp.src(["./src/**/*.ts", "./node_modules/@types/**/*.ts"])
60+
.pipe(sourcemaps.init())
61+
.pipe(tsProject());
62+
63+
return [
64+
tsResult.dts.pipe(gulp.dest("./build/package")),
65+
tsResult.js
66+
.pipe(sourcemaps.write(".", { sourceRoot: "", includeContent: true }))
67+
.pipe(gulp.dest("./build/package"))
68+
];
69+
}
70+
71+
/**
72+
* Change the "private" state of the packaged package.json file to public.
73+
*/
74+
@Task()
75+
packagePreparePackageFile()
76+
{
77+
return gulp.src("./package.json")
78+
.pipe(gulp.dest("./build/package"));
79+
}
80+
81+
/**
82+
* Copies README.md into the package.
83+
*/
84+
@Task()
85+
packageCopyReadme()
86+
{
87+
return gulp.src("./README.md")
88+
.pipe(gulp.dest("./build/package"));
89+
}
90+
91+
/**
92+
* Creates a package that can be published to npm.
93+
*/
94+
@SequenceTask()
95+
package()
96+
{
97+
return [
98+
"clean",
99+
"packageCompile",
100+
"packagePreparePackageFile",
101+
"packageCopyReadme"
102+
];
103+
}
104+
105+
/**
106+
* Creates a package and publishes it to npm.
107+
*/
108+
@SequenceTask()
109+
publish()
110+
{
111+
return ["package", "packagePublish"];
112+
}
113+
114+
// -------------------------------------------------------------------------
115+
// Run tests tasks
116+
// -------------------------------------------------------------------------
117+
118+
@Task()
119+
coverage()
120+
{
121+
return gulp.src(['src/**/*.js'])
122+
.pipe(istanbul())
123+
.pipe(istanbul.hookRequire());
124+
}
125+
126+
@Task()
127+
mocha()
128+
{
129+
return gulp.src ('build/test/**/*.js', {read: false})
130+
.pipe (mocha ({noDeprecation: true}))
131+
.pipe(istanbul.writeReports())
132+
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
133+
}
134+
135+
/**
136+
* Compiles the code and runs tests + makes coverage report.
137+
*/
138+
@SequenceTask()
139+
tests()
140+
{
141+
return ["compile", "mocha"];
142+
}
143+
}

package.json

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"name": "winston-decorator",
3-
"version": "0.0.1",
3+
"version": "0.0.4",
44
"description": "A decorator version of the winston logger written completely in Typescript.",
5-
"main": "dist/index.js",
65
"scripts": {
7-
"test": "mocha dist/test/**/*.js"
6+
"test": "node_modules/.bin/gulp tests"
87
},
98
"repository": {
109
"type": "git",
@@ -14,7 +13,7 @@
1413
"logger",
1514
"winston"
1615
],
17-
"author": "Cubbit srls",
16+
"author": "Marco Moschettini Alessandro Petraro",
1817
"license": "MIT",
1918
"bugs": {
2019
"url": "https://github.com/marmos91/winston-decorator/issues"
@@ -23,12 +22,23 @@
2322
"dependencies": {
2423
"@types/node": "^7.0.12",
2524
"@types/winston": "^2.3.0",
26-
"winston": "^2.3.1"
25+
"winston": "^2.3.1",
26+
"reflect-metadata": "^0.1.9"
2727
},
2828
"devDependencies": {
2929
"@types/chai": "^3.5.0",
3030
"@types/mocha": "^2.2.40",
3131
"chai": "^3.5.0",
32-
"mocha": "^3.2.0"
32+
"del": "^2.2.2",
33+
"gulp": "^3.9.1",
34+
"gulp-istanbul": "^1.1.1",
35+
"gulp-mocha": "^3.0.1",
36+
"gulp-shell": "^0.6.1",
37+
"gulp-sourcemaps": "^2.4.1",
38+
"gulp-typescript": "^3.1.5",
39+
"gulpclass": "0.1.1",
40+
"mocha": "^3.2.0",
41+
"ts-node": "^2.1.0",
42+
"typescript": "^2.2.1"
3343
}
3444
}

src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as winston from 'winston';
22
import {LoggerInstance} from 'winston';
33
import {type} from 'os';
4-
import set = Reflect.set;
54

65
/**
76
* Options interface for the logger decorator

test/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('logger', function()
2727
private _logger: LoggerInstance;
2828
constructor()
2929
{
30-
expect(this._logger.transports.console['label']).to.be.equal(this.constructor.name);
30+
expect(this._logger.transports.console['label']).to.be.equal(this.constructor['name']);
3131
}
3232
}
3333

@@ -39,7 +39,7 @@ describe('logger', function()
3939
let test_label = 'test_label';
4040
class test_class
4141
{
42-
@logger(null, {label: test_label})
42+
@logger(undefined, {label: test_label})
4343
private _logger: LoggerInstance;
4444
constructor()
4545
{
@@ -87,7 +87,7 @@ describe('logger', function()
8787

8888
class test_class
8989
{
90-
@logger(null, {test_environment: 'testing_purpose'})
90+
@logger(undefined, {test_environment: 'testing_purpose'})
9191
private _logger: LoggerInstance;
9292
constructor()
9393
{

tsconfig.json

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
{
22
"compilerOptions": {
33
"module": "commonjs",
4-
"outDir": "dist/",
5-
"target": "es6",
6-
"declaration": true,
4+
"outDir": "build/",
5+
"target": "es5",
6+
"moduleResolution": "node",
7+
"emitDecoratorMetadata": true,
78
"experimentalDecorators": true,
8-
"sourceMap": true
9+
"sourceMap": true,
10+
"declaration": true,
11+
"noFallthroughCasesInSwitch": true,
12+
"noImplicitReturns": true,
13+
"stripInternal": true,
14+
"pretty": true,
15+
"strictNullChecks": true
916
},
1017
"exclude": [
18+
"build",
1119
"node_modules"
1220
]
1321
}

0 commit comments

Comments
 (0)