Compare commits
No commits in common. "master" and "v0.0.4" have entirely different histories.
13
.gitignore
vendored
13
.gitignore
vendored
@ -1,5 +1,10 @@
|
||||
.nogit/
|
||||
node_modules/
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
.settings/
|
||||
.idea/
|
||||
|
||||
|
||||
#npm devug
|
||||
npm-debug.log
|
||||
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
|
@ -1,95 +0,0 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .yarn/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- docker
|
||||
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci command yarn global add snyk
|
||||
- npmci command yarn install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
script:
|
||||
- npmci command yarn global add npmpage
|
||||
- npmci command npmpage
|
||||
tags:
|
||||
- docker
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
16
.travis.yml
Normal file
16
.travis.yml
Normal file
@ -0,0 +1,16 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '4.1'
|
||||
before_install:
|
||||
- npm install -g tsd
|
||||
deploy:
|
||||
provider: npm
|
||||
email: npm@smart-coordination.com
|
||||
api_key:
|
||||
secure: CDLSxeLMcoLU1E2EVxx9Ti7XIy6uKxvu3IE54NbMOTtLLQdz7cE8VEOfLSu1FZw3mU0iZNw+f3OR8QANnfhmWb5y+gWQlcTl0BZV6vvM/G2SnyQBoKJX4qo8PkRvKWV5ReYD94uVlo5/yRb1beC+FGCAUcPE09vtACPrq2XALVfS0+FrNv7hQO+B8ZV+fKpxEPhgIaZZu2iBexdtU0yvIA7nw8DrcM88PG8YU0fs6S4aDk9qnxcjnmImZENcsvC5htaAckvNtpuhLW+EaT9RjJgqLRuayFFl2OYLRCUzgMGar4I5IBVCBOnA2sWmAquGYfGP0vm0zXg/mi++JQVrPRUZbXo0GVHpFkqV7XzS/daTjg7oV6KUgUp+RzpxTitDr3Wshj+3aLHjxNk3OhuddOC1LStp3NOukMkTo4n4NSf1ja8UtIfjy0NI4+D9aycUAmo6Elpj0QpqIYwjOAWiRJpvaKmxqouk1St1YeMqMN0Xx37xkqieRmVZbH0j7CypdWFicVWQdBE7yp45vAPae5/qDikTgbIrnPZvBPADQi5tJfth2+K8Hi8Twzj+8OjFr4iWAXnWM641jUyLvC4tFlxuOBmomUQ30F/zhWUvFipzyX1LOzYhoqIPwWWTFFTs6IqcWq6OLG86c92c2UdmUvMBUM2gbtGoP7GcXzIz34I=
|
||||
on:
|
||||
tags: true
|
||||
repo: pushrocks/smartdebug
|
||||
notifications:
|
||||
slack:
|
||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Push.Rocks
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# smartdebug
|
||||
works with gulp, but does nothing. Use it to bootstrap your own gulp plugin with TypeScript, Travis and npm.
|
||||
|
||||
### Buildstatus/Dependencies
|
||||
[](https://travis-ci.org/pushrocks/smartdebug)
|
||||
[](https://david-dm.org/pushrocks/smartdebug#info=devDependencies)
|
||||
|
||||
### Usage
|
||||
This plugin is thought for easy debug logging.
|
||||
|
||||
```javascript
|
||||
var smartDebug = require("smartdebug");
|
||||
|
||||
smartDebug.log("This message is not shown");
|
||||
smartDebug.activate(true);
|
||||
smartDebug.log("This debug message is shown");
|
||||
```
|
||||
|
21
dist/index.d.ts
vendored
21
dist/index.d.ts
vendored
@ -1,21 +0,0 @@
|
||||
export declare class SmartDebug {
|
||||
private _debugEnabled;
|
||||
constructor(debugTopic?: string);
|
||||
readonly debugEnabled: boolean;
|
||||
/**
|
||||
* enables debugging output
|
||||
*/
|
||||
enableDebugging(): void;
|
||||
/**
|
||||
* disables debugging
|
||||
*/
|
||||
disableDebugging(): void;
|
||||
/**
|
||||
* logs a message based on the contraints of the SmartDebug instance
|
||||
*/
|
||||
log(logObject: any): void;
|
||||
/**
|
||||
* a function returning
|
||||
*/
|
||||
isDebugMode(): boolean;
|
||||
}
|
44
dist/index.js
vendored
44
dist/index.js
vendored
@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class SmartDebug {
|
||||
constructor(debugTopic) {
|
||||
this._debugEnabled = false;
|
||||
if (process.env.SMARTDEBUG === 'true' ||
|
||||
(debugTopic && process.env.SMARTDEBUG_TOPIC === debugTopic)) {
|
||||
this.enableDebugging();
|
||||
}
|
||||
}
|
||||
get debugEnabled() {
|
||||
return this._debugEnabled;
|
||||
}
|
||||
/**
|
||||
* enables debugging output
|
||||
*/
|
||||
enableDebugging() {
|
||||
console.log('Enabled Debugging!');
|
||||
this._debugEnabled = true;
|
||||
}
|
||||
/**
|
||||
* disables debugging
|
||||
*/
|
||||
disableDebugging() {
|
||||
this._debugEnabled = false;
|
||||
}
|
||||
/**
|
||||
* logs a message based on the contraints of the SmartDebug instance
|
||||
*/
|
||||
log(logObject) {
|
||||
if (this._debugEnabled) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log(logObject);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* a function returning
|
||||
*/
|
||||
isDebugMode() {
|
||||
return this._debugEnabled;
|
||||
}
|
||||
}
|
||||
exports.SmartDebug = SmartDebug;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBO0lBR0UsWUFBWSxVQUFtQjtRQUZ2QixrQkFBYSxHQUFZLEtBQUssQ0FBQztRQUdyQyxJQUNFLE9BQU8sQ0FBQyxHQUFHLENBQUMsVUFBVSxLQUFLLE1BQU07WUFDakMsQ0FBQyxVQUFVLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxnQkFBZ0IsS0FBSyxVQUFVLENBQUMsRUFDM0Q7WUFDQSxJQUFJLENBQUMsZUFBZSxFQUFFLENBQUM7U0FDeEI7SUFDSCxDQUFDO0lBRUQsSUFBSSxZQUFZO1FBQ2QsT0FBTyxJQUFJLENBQUMsYUFBYSxDQUFDO0lBQzVCLENBQUM7SUFFRDs7T0FFRztJQUNJLGVBQWU7UUFDcEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO1FBQ2xDLElBQUksQ0FBQyxhQUFhLEdBQUcsSUFBSSxDQUFDO0lBQzVCLENBQUM7SUFFRDs7T0FFRztJQUNJLGdCQUFnQjtRQUNyQixJQUFJLENBQUMsYUFBYSxHQUFHLEtBQUssQ0FBQztJQUM3QixDQUFDO0lBRUQ7O09BRUc7SUFDSSxHQUFHLENBQUMsU0FBYztRQUN2QixJQUFJLElBQUksQ0FBQyxhQUFhLEVBQUU7WUFDdEIsc0NBQXNDO1lBQ3RDLE9BQU8sQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLENBQUM7U0FDeEI7SUFDSCxDQUFDO0lBRUQ7O09BRUc7SUFDSSxXQUFXO1FBQ2hCLE9BQU8sSUFBSSxDQUFDLGFBQWEsQ0FBQztJQUM1QixDQUFDO0NBQ0Y7QUEvQ0QsZ0NBK0NDIn0=
|
1
dist/smartdebug.plugins.d.ts
vendored
1
dist/smartdebug.plugins.d.ts
vendored
@ -1 +0,0 @@
|
||||
export { };
|
3
dist/smartdebug.plugins.js
vendored
3
dist/smartdebug.plugins.js
vendored
@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRkZWJ1Zy5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRkZWJ1Zy5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
15
index.js
Normal file
15
index.js
Normal file
@ -0,0 +1,15 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var beautylog = require("beautylog")("os");
|
||||
var colors = require("colors");
|
||||
var debugActive = false;
|
||||
var smartDebug = {
|
||||
log: function (message) {
|
||||
if (debugActive) {
|
||||
beautylog.log("###DEBUG:###".rainbow + ' ' + message);
|
||||
}
|
||||
},
|
||||
activate: function (debugArg) {
|
||||
debugActive = debugArg;
|
||||
}
|
||||
};
|
||||
module.exports = smartDebug;
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [
|
||||
"npmts"
|
||||
],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
43
package.json
43
package.json
@ -1,21 +1,36 @@
|
||||
{
|
||||
"name": "@push.rocks/smartdebug",
|
||||
"version": "2.0.11",
|
||||
"description": "debug the smart way",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"name": "smartdebug",
|
||||
"version": "0.0.4",
|
||||
"description": "debug your JavaScript the smart way",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(cd ts/compile && node compile.js) && (node test.js)",
|
||||
"reinstall": "(rm -r node_modules && npm install)",
|
||||
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
|
||||
"startdev": "(git checkout master && git pull origin master)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tapbundle": "^2.0.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"homepage": "https://code.foss.global/push.rocks/smartdebug",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://code.foss.global/push.rocks/smartdebug.git"
|
||||
"url": "https://github.com/pushrocks/smartdebug.git"
|
||||
},
|
||||
"keywords": [
|
||||
"json",
|
||||
"jade",
|
||||
"template"
|
||||
],
|
||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/smartdebug/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/smartdebug",
|
||||
"dependencies": {
|
||||
"beautylog": "^1.0.3",
|
||||
"colors": "^1.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "3.9.0",
|
||||
"gulp-typescript": "2.9.2",
|
||||
"pushrocks": "^1.0.22"
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
|
45
readme.md
45
readme.md
@ -1,45 +0,0 @@
|
||||
# smartdebug
|
||||
|
||||
debug the smart way
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/@pushrocks/smartdebug)
|
||||
[](https://GitLab.com/pushrocks/smartdebug)
|
||||
[](https://github.com/pushrocks/smartdebug)
|
||||
[](https://pushrocks.gitlab.io/smartdebug/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/smartdebug/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smartdebug/commits/master)
|
||||
[](https://www.npmjs.com/package/@pushrocks/smartdebug)
|
||||
[](https://www.bithound.io/github/pushrocks/smartdebug/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartdebug)
|
||||
[](https://snyk.io/test/npm/@pushrocks/smartdebug)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
```typescript
|
||||
import * as smartdebug from '@pushrocks/smartdebug';
|
||||
|
||||
smartdebug.log('a cool message'); // won't log
|
||||
smartdebug.enableDebugging();
|
||||
smartdebug.log('another cool message'); // this message will log
|
||||
|
||||
if (smartdebug.debugEnabled) {
|
||||
console.log('Hi there!'); // will also log since debugging is enabled
|
||||
}
|
||||
```
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
7
test.js
Normal file
7
test.js
Normal file
@ -0,0 +1,7 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var smartDebug = require("./index.js");
|
||||
var bl = require("beautylog")("os");
|
||||
smartDebug.log("This message is not shown");
|
||||
smartDebug.activate(true);
|
||||
smartDebug.log("This debug message is shown");
|
||||
bl.success("Test successfull");
|
24
test/test.ts
24
test/test.ts
@ -1,24 +0,0 @@
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import { expect, tap } from 'tapbundle';
|
||||
import * as smartdebug from '../ts/index';
|
||||
|
||||
let testSmartDebug: smartdebug.SmartDebug;
|
||||
|
||||
tap.test('should create a valid instance of SmartDebug', async () => {
|
||||
testSmartDebug = new smartdebug.SmartDebug();
|
||||
});
|
||||
|
||||
tap.test('should not log a message, if debugEnabled = false', async () => {
|
||||
testSmartDebug.log('should not log to console');
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testSmartDebug.debugEnabled).to.be.false;
|
||||
});
|
||||
|
||||
tap.test('should log to console, if enabled', async () => {
|
||||
testSmartDebug.enableDebugging();
|
||||
testSmartDebug.log('should log to console');
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testSmartDebug.debugEnabled).to.be.true;
|
||||
});
|
||||
|
||||
tap.start();
|
30
ts/compile/compile.js
Normal file
30
ts/compile/compile.js
Normal file
@ -0,0 +1,30 @@
|
||||
// import gulp
|
||||
var gulp = require("gulp")
|
||||
var gulpTypescript = require("gulp-typescript");
|
||||
var pr = require("pushrocks");
|
||||
|
||||
gulp.task('compileTS', function() {
|
||||
var stream = gulp.src('../index.ts')
|
||||
.pipe(gulpTypescript({
|
||||
out: "index.js"
|
||||
}))
|
||||
.pipe(gulp.dest("../../"));
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task('compileTSTest', function() {
|
||||
var stream = gulp.src('../test.ts')
|
||||
.pipe(gulpTypescript({
|
||||
out: "test.js"
|
||||
}))
|
||||
.pipe(gulp.dest("../../"));
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task('default',['compileTS','compileTSTest'], function() {
|
||||
pr.beautylog.success('Typescript compiled');
|
||||
});
|
||||
|
||||
//lets tell gulp to start with the default task.
|
||||
pr.beautylog.log('Starting Gulp to compile TypeScript');
|
||||
gulp.start.apply(gulp, ['default']);
|
2
ts/compile/readme.md
Normal file
2
ts/compile/readme.md
Normal file
@ -0,0 +1,2 @@
|
||||
# How to compile.
|
||||
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.
|
16
ts/index.js
Normal file
16
ts/index.js
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var beautylog = require("beautylog");
|
||||
var colors = require("colors");
|
||||
var debugActive = false;
|
||||
var debugsmart = {
|
||||
log: function (message) {
|
||||
if (debugActive) {
|
||||
beautylog.log("Debug:".zebra + ' ' + message);
|
||||
}
|
||||
},
|
||||
activate: function (debugArg) {
|
||||
debugActive = debugArg;
|
||||
}
|
||||
};
|
||||
module.exports = debugsmart;
|
||||
//# sourceMappingURL=index.js.map
|
1
ts/index.js.map
Normal file
1
ts/index.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE/B,IAAI,WAAW,GAAW,KAAK,CAAC;AAChC,IAAI,UAAU,GAAG;IACb,GAAG,EAAE,UAAS,OAAc;QACxB,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;YACd,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,GAAG,GAAG,GAAG,OAAO,CAAC,CAAC;QAClD,CAAC;IACL,CAAC;IACD,QAAQ,EAAE,UAAS,QAAgB;QAC/B,WAAW,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACJ,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC"}
|
61
ts/index.ts
61
ts/index.ts
@ -1,50 +1,17 @@
|
||||
import * as plugins from './smartdebug.plugins';
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var beautylog = require("beautylog")("os");
|
||||
var colors = require("colors");
|
||||
|
||||
export class SmartDebug {
|
||||
private _debugEnabled: boolean = false;
|
||||
|
||||
constructor(debugTopic?: string) {
|
||||
if (
|
||||
process.env.SMARTDEBUG === 'true' ||
|
||||
(debugTopic && process.env.SMARTDEBUG_TOPIC === debugTopic)
|
||||
) {
|
||||
this.enableDebugging();
|
||||
var debugActive:boolean = false;
|
||||
var smartDebug = {
|
||||
log: function(message:string){
|
||||
if (debugActive) {
|
||||
beautylog.log("###DEBUG:###".rainbow + ' ' + message);
|
||||
}
|
||||
},
|
||||
activate: function(debugArg:boolean){
|
||||
debugActive = debugArg;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
get debugEnabled() {
|
||||
return this._debugEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* enables debugging output
|
||||
*/
|
||||
public enableDebugging() {
|
||||
console.log('Enabled Debugging!');
|
||||
this._debugEnabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* disables debugging
|
||||
*/
|
||||
public disableDebugging() {
|
||||
this._debugEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* logs a message based on the contraints of the SmartDebug instance
|
||||
*/
|
||||
public log(logObject: any) {
|
||||
if (this._debugEnabled) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log(logObject);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* a function returning
|
||||
*/
|
||||
public isDebugMode() {
|
||||
return this._debugEnabled;
|
||||
}
|
||||
}
|
||||
module.exports = smartDebug;
|
||||
|
@ -1 +0,0 @@
|
||||
export {};
|
9
ts/test.ts
Normal file
9
ts/test.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var smartDebug = require("./index.js");
|
||||
var bl = require("beautylog")("os");
|
||||
|
||||
smartDebug.log("This message is not shown");
|
||||
smartDebug.activate(true);
|
||||
smartDebug.log("This debug message is shown");
|
||||
|
||||
bl.success("Test successfull");
|
15
ts/tsd.json
Normal file
15
ts/tsd.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"version": "v4",
|
||||
"repo": "borisyankov/DefinitelyTyped",
|
||||
"ref": "master",
|
||||
"path": "typings",
|
||||
"bundle": "typings/tsd.d.ts",
|
||||
"installed": {
|
||||
"node/node.d.ts": {
|
||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
||||
},
|
||||
"colors/colors.d.ts": {
|
||||
"commit": "aed176536a202b9a2475ce1989ea6d2d0226a185"
|
||||
}
|
||||
}
|
||||
}
|
123
ts/typings/colors/colors.d.ts
vendored
Normal file
123
ts/typings/colors/colors.d.ts
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
// Type definitions for Colors.js 0.6.0-1
|
||||
// Project: https://github.com/Marak/colors.js
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "colors" {
|
||||
interface Color {
|
||||
(text: string): string;
|
||||
|
||||
black: Color;
|
||||
red: Color;
|
||||
green: Color;
|
||||
yellow: Color;
|
||||
blue: Color;
|
||||
magenta: Color;
|
||||
cyan: Color;
|
||||
white: Color;
|
||||
gray: Color;
|
||||
grey: Color;
|
||||
|
||||
bgBlack: Color;
|
||||
bgRed: Color;
|
||||
bgGreen: Color;
|
||||
bgYellow: Color;
|
||||
bgBlue: Color;
|
||||
bgMagenta: Color;
|
||||
bgCyan: Color;
|
||||
bgWhite: Color;
|
||||
|
||||
reset: Color;
|
||||
bold: Color;
|
||||
dim: Color;
|
||||
italic: Color;
|
||||
underline: Color;
|
||||
inverse: Color;
|
||||
hidden: Color;
|
||||
strikethrough: Color;
|
||||
|
||||
rainbow: Color;
|
||||
zebra: Color;
|
||||
america: Color;
|
||||
trap: Color;
|
||||
random: Color;
|
||||
}
|
||||
|
||||
module e {
|
||||
export function setTheme(theme:any): void;
|
||||
|
||||
export var black: Color;
|
||||
export var red: Color;
|
||||
export var green: Color;
|
||||
export var yellow: Color;
|
||||
export var blue: Color;
|
||||
export var magenta: Color;
|
||||
export var cyan: Color;
|
||||
export var white: Color;
|
||||
export var gray: Color;
|
||||
export var grey: Color;
|
||||
|
||||
export var bgBlack: Color;
|
||||
export var bgRed: Color;
|
||||
export var bgGreen: Color;
|
||||
export var bgYellow: Color;
|
||||
export var bgBlue: Color;
|
||||
export var bgMagenta: Color;
|
||||
export var bgCyan: Color;
|
||||
export var bgWhite: Color;
|
||||
|
||||
export var reset: Color;
|
||||
export var bold: Color;
|
||||
export var dim: Color;
|
||||
export var italic: Color;
|
||||
export var underline: Color;
|
||||
export var inverse: Color;
|
||||
export var hidden: Color;
|
||||
export var strikethrough: Color;
|
||||
|
||||
export var rainbow: Color;
|
||||
export var zebra: Color;
|
||||
export var america: Color;
|
||||
export var trap: Color;
|
||||
export var random: Color;
|
||||
}
|
||||
|
||||
export = e;
|
||||
}
|
||||
|
||||
interface String {
|
||||
black: string;
|
||||
red: string;
|
||||
green: string;
|
||||
yellow: string;
|
||||
blue: string;
|
||||
magenta: string;
|
||||
cyan: string;
|
||||
white: string;
|
||||
gray: string;
|
||||
grey: string;
|
||||
|
||||
bgBlack: string;
|
||||
bgRed: string;
|
||||
bgGreen: string;
|
||||
bgYellow: string;
|
||||
bgBlue: string;
|
||||
bgMagenta: string;
|
||||
bgCyan: string;
|
||||
bgWhite: string;
|
||||
|
||||
reset: string;
|
||||
bold: string;
|
||||
dim: string;
|
||||
italic: string;
|
||||
underline: string;
|
||||
inverse: string;
|
||||
hidden: string;
|
||||
strikethrough: string;
|
||||
|
||||
rainbow: string;
|
||||
zebra: string;
|
||||
america: string;
|
||||
trap: string;
|
||||
random: string;
|
||||
}
|
2079
ts/typings/node/node.d.ts
vendored
Normal file
2079
ts/typings/node/node.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
ts/typings/tsd.d.ts
vendored
Normal file
2
ts/typings/tsd.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/// <reference path="node/node.d.ts" />
|
||||
/// <reference path="colors/colors.d.ts" />
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user