Compare commits

...

34 Commits

Author SHA1 Message Date
1fc85a2c89 update description 2024-05-29 14:12:29 +02:00
51aacbe7c4 switch to new org scheme 2023-07-10 02:48:31 +02:00
89164006ad 2.0.11 2018-04-12 19:29:28 +02:00
9c01368fe9 add topic oriented debugging selection 2018-04-12 19:29:24 +02:00
4cb7b82e0b 2.0.10 2018-04-12 19:12:07 +02:00
f282627b72 debugging is enabled 2018-04-12 19:12:03 +02:00
5424f20383 2.0.9 2018-04-12 18:29:02 +02:00
78956f8a5a update access level 2018-04-12 18:28:58 +02:00
4615a5e12f 2.0.8 2018-04-12 18:02:53 +02:00
d295b2e070 upgrade to latest standards 2018-04-12 18:02:48 +02:00
5f0a7ceaa3 2.0.7 2017-09-19 17:59:01 +02:00
b65a94b86c update 2017-09-19 17:58:59 +02:00
0248a23e7d 2.0.6 2017-09-19 17:48:58 +02:00
068c19704b use console.log as default 2017-09-19 17:48:56 +02:00
a8b760165d 2.0.5 2017-09-18 19:11:37 +02:00
b65c012779 fi ci 2017-09-18 19:11:34 +02:00
657f07120c 2.0.4 2017-09-18 19:10:29 +02:00
919a23cd09 test yml behaviour 2017-09-18 19:10:21 +02:00
d5a4a0f4ee 2.0.3 2017-09-18 18:22:50 +02:00
9e3ed92604 2.0.2 2017-09-18 17:53:28 +02:00
4dea1cfac2 now accepts third party debug function 2017-09-18 17:53:23 +02:00
8ab8a4f18b 2.0.1 2017-09-18 15:30:41 +02:00
f382892962 2.0.0 2017-09-18 15:19:27 +02:00
c269ac04cd initial 2017-09-18 15:19:18 +02:00
Philipp Kunz
1f09d67196 0.0.10 2015-12-02 14:01:54 +01:00
Philipp Kunz
bdf0c9b066 show Debug activated message by default 2015-12-02 14:01:47 +01:00
Philipp Kunz
1a3aa040e4 0.0.9 2015-11-28 22:48:46 +01:00
Philipp Kunz
79f97b504b small fix 2015-11-28 22:48:41 +01:00
Philipp Kunz
1d58aa38bd 0.0.8 2015-11-28 22:44:05 +01:00
Philipp Kunz
304f3801bd add smartdebug.run() function 2015-11-28 22:43:57 +01:00
Philipp Kunz
c87172ff1f 0.0.7 2015-11-22 07:59:42 +01:00
Philipp Kunz
c782b256c0 added getStatus function 2015-11-22 07:59:34 +01:00
Philipp Kunz
f78b0b6fb8 0.0.6 2015-11-17 02:39:46 +01:00
Philipp Kunz
5c8feb571c added dependency badge 2015-11-17 02:39:39 +01:00
28 changed files with 327 additions and 2411 deletions

13
.gitignore vendored
View File

@ -1,10 +1,5 @@
.nogit/
node_modules/
.settings/
.idea/
#npm devug
npm-debug.log
ts/*.js
ts/*.js.map
coverage/
public/
pages/

95
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,95 @@
# 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

View File

@ -1,16 +0,0 @@
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
View File

@ -1,22 +0,0 @@
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.

View File

@ -1,20 +0,0 @@
# smartdebug
works with gulp, but does nothing. Use it to bootstrap your own gulp plugin with TypeScript, Travis and npm.
### Buildstatus/Dependencies
[![Build Status](https://travis-ci.org/pushrocks/smartdebug.svg?branch=master)](https://travis-ci.org/pushrocks/smartdebug)
[![devDependency Status](https://david-dm.org/pushrocks/smartdebug/dev-status.svg)](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");
```
The above code produces debug messages like this:
![debugmessage.png](https://mediaserve.lossless.digital/github.com/pushrocks/smartdebug/debugmessage.png)

21
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
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 Normal file
View File

@ -0,0 +1,44 @@
"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 Normal file
View File

@ -0,0 +1 @@
export { };

3
dist/smartdebug.plugins.js vendored Normal file
View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRkZWJ1Zy5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRkZWJ1Zy5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==

View File

@ -1,15 +0,0 @@
/// <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;

11
npmextra.json Normal file
View File

@ -0,0 +1,11 @@
{
"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"
}
}

View File

@ -1,36 +1,21 @@
{
"name": "smartdebug",
"version": "0.0.5",
"description": "debug your JavaScript the smart way",
"main": "index.js",
"scripts": {
"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)"
},
"repository": {
"type": "git",
"url": "https://github.com/pushrocks/smartdebug.git"
},
"keywords": [
"json",
"jade",
"template"
],
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
"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",
"bugs": {
"url": "https://github.com/pushrocks/smartdebug/issues"
},
"homepage": "https://github.com/pushrocks/smartdebug",
"dependencies": {
"beautylog": "^1.0.3",
"colors": "^1.1.2"
"scripts": {
"test": "(npmts)"
},
"devDependencies": {
"gulp": "3.9.0",
"gulp-typescript": "2.9.2",
"pushrocks": "^1.0.22"
"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"
}
}
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

45
readme.md Normal file
View File

@ -0,0 +1,45 @@
# smartdebug
debug the smart way
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/@pushrocks/smartdebug)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartdebug)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartdebug)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartdebug/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartdebug/badges/master/build.svg)](https://GitLab.com/pushrocks/smartdebug/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartdebug/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartdebug/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartdebug.svg)](https://www.npmjs.com/package/@pushrocks/smartdebug)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartdebug/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartdebug/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartdebug/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartdebug)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartdebug/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartdebug)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](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 | **&copy;** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

View File

@ -1,7 +0,0 @@
/// <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 Normal file
View File

@ -0,0 +1,24 @@
// 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();

View File

@ -1,30 +0,0 @@
// 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']);

View File

@ -1,2 +0,0 @@
# How to compile.
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.

View File

@ -1,16 +0,0 @@
/// <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

View File

@ -1 +0,0 @@
{"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"}

View File

@ -1,17 +1,50 @@
/// <reference path="typings/tsd.d.ts" />
var beautylog = require("beautylog")("os");
var colors = require("colors");
import * as plugins from './smartdebug.plugins';
var debugActive:boolean = false;
var smartDebug = {
log: function(message:string){
if (debugActive) {
beautylog.log("###DEBUG:###".rainbow + ' ' + message);
}
},
activate: function(debugArg:boolean){
debugActive = debugArg;
export class SmartDebug {
private _debugEnabled: boolean = false;
constructor(debugTopic?: string) {
if (
process.env.SMARTDEBUG === 'true' ||
(debugTopic && process.env.SMARTDEBUG_TOPIC === debugTopic)
) {
this.enableDebugging();
}
};
}
module.exports = smartDebug;
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;
}
}

1
ts/smartdebug.plugins.ts Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -1,9 +0,0 @@
/// <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");

View File

@ -1,15 +0,0 @@
{
"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"
}
}
}

View File

@ -1,123 +0,0 @@
// 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;
}

File diff suppressed because it is too large Load Diff

2
ts/typings/tsd.d.ts vendored
View File

@ -1,2 +0,0 @@
/// <reference path="node/node.d.ts" />
/// <reference path="colors/colors.d.ts" />

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}