From b74df6d0080ddb564b68f112cf267178749e61d6 Mon Sep 17 00:00:00 2001 From: Javier Mendiara Date: Tue, 30 Aug 2016 15:30:54 +0200 Subject: [PATCH] [[CHORE]] Improve TS definition and processes (#32) --- .gitignore | 1 + .npmignore | 5 ++++ lib/logops.d.ts | 2 +- package.json | 6 +++-- test/logops.typings.js | 54 ------------------------------------------ test/logops.typings.ts | 2 +- tsconfig.json | 11 +++++++++ typings.json | 5 ++++ 8 files changed, 28 insertions(+), 58 deletions(-) delete mode 100644 test/logops.typings.js create mode 100644 tsconfig.json create mode 100644 typings.json diff --git a/.gitignore b/.gitignore index 47f6456..2f87469 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ typings/ benchmark/out.log npm-debug.log +test/logops.typings.js *.bak *.orig diff --git a/.npmignore b/.npmignore index 64aa76d..d609f1b 100644 --- a/.npmignore +++ b/.npmignore @@ -14,5 +14,10 @@ typings/ .istanbul.yml .travis.yml +tsconfig.json +typings.json +tslint.json +release.json + npm-debug.log CONTRIBUTING.md diff --git a/lib/logops.d.ts b/lib/logops.d.ts index cc2ceff..c466ccd 100644 --- a/lib/logops.d.ts +++ b/lib/logops.d.ts @@ -4,7 +4,7 @@ * The NODEJS stream where the logger will write string traces * Defaults to process.stdout */ -export let stream: any; +export let stream: NodeJS.WritableStream; /** * Gets the current log level. The default level is INFO diff --git a/package.json b/package.json index 080332e..9e00aac 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "scripts": { "travis": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec test/environment.js test/*.spec.js && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", "coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- -R dot test/environment.js test/*.spec.js", - "lint": "jscs lib && eslint lib && tslint './{lib,test}/**/*.ts'", + "lint": "jscs lib && eslint lib && tslint './{lib,test}/**/*.ts' && tsc", "test": "mocha -R spec test/environment.js test/*.spec.js", "changelog": "conventional-changelog -p jshint", "release": "release-it" @@ -40,7 +40,9 @@ "sinon": "^1.15.0", "sinon-chai": "^2.8.0", "tslint": "^3.14.0", - "tslint-config-typings": "^0.2.3" + "tslint-config-typings": "^0.2.3", + "typescript": "^1.8.10", + "typings": "^1.3.3" }, "keywords": [ "logger", diff --git a/test/logops.typings.js b/test/logops.typings.js deleted file mode 100644 index 7080714..0000000 --- a/test/logops.typings.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -var logops = require('../lib/logops'); -var lvl = logops.getLevel(); -logops.setLevel(lvl); -logops.getContext = function () { - return { a: 1 }; -}; -logops.stream = process.stderr; -logops.format = logops.formatters.dev; -logops.format = logops.formatters.json; -logops.format = logops.formatters.pipe; -logops.formatters.dev.omit = ['a']; -logops.formatters.stacktracesWith = ['DEBUG']; -logops.formatters.setNotAvailable('nope'); -logops.debug({ a: 1 }); -logops.debug({ a: 1 }, 'Some'); -logops.debug({ a: 1 }, 'Some %d', 1); -logops.debug(new Error('Error')); -logops.debug(new Error('Error'), 'Some'); -logops.debug(new Error('Error'), 'Some %d', 1); -logops.debug('Some'); -logops.debug('Some %d', 1); -logops.info({ a: 1 }); -logops.info({ a: 1 }, 'Some'); -logops.info({ a: 1 }, 'Some %d', 1); -logops.info(new Error('Error')); -logops.info(new Error('Error'), 'Some'); -logops.info(new Error('Error'), 'Some %d', 1); -logops.info('Some'); -logops.info('Some %d', 1); -logops.warn({ a: 1 }); -logops.warn({ a: 1 }, 'Some'); -logops.warn({ a: 1 }, 'Some %d', 1); -logops.warn(new Error('Error')); -logops.warn(new Error('Error'), 'Some'); -logops.warn(new Error('Error'), 'Some %d', 1); -logops.warn('Some'); -logops.warn('Some %d', 1); -logops.error({ a: 1 }); -logops.error({ a: 1 }, 'Some'); -logops.error({ a: 1 }, 'Some %d', 1); -logops.error(new Error('Error')); -logops.error(new Error('Error'), 'Some'); -logops.error(new Error('Error'), 'Some %d', 1); -logops.error('Some'); -logops.error('Some %d', 1); -logops.fatal({ a: 1 }); -logops.fatal({ a: 1 }, 'Some'); -logops.fatal({ a: 1 }, 'Some %d', 1); -logops.fatal(new Error('Error')); -logops.fatal(new Error('Error'), 'Some'); -logops.fatal(new Error('Error'), 'Some %d', 1); -logops.fatal('Some'); -logops.fatal('Some %d', 1); diff --git a/test/logops.typings.ts b/test/logops.typings.ts index bd86f9a..4a508f9 100644 --- a/test/logops.typings.ts +++ b/test/logops.typings.ts @@ -1,5 +1,5 @@ -import logops = require('../lib/logops'); +import * as logops from '../lib/logops'; let lvl: string = logops.getLevel(); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4f71392 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false + }, + "exclude": [ + "node_modules" + ] +} diff --git a/typings.json b/typings.json new file mode 100644 index 0000000..81733cb --- /dev/null +++ b/typings.json @@ -0,0 +1,5 @@ +{ + "globalDependencies": { + "node": "registry:dt/node#6.0.0+20160826120425" + } +}