Compare commits

..

No commits in common. "master" and "v7.0.3" have entirely different histories.

23 changed files with 1676 additions and 5363 deletions

27
.gitignore vendored
View File

@ -1,20 +1,11 @@
dist/
node_modules/
coverage/
pages/
public/
npm-debug.log
.nogit/ .nogit/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,122 +1,131 @@
# gitzone ci_default # gitzone standard
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .npmci_cache/ - .npmci_cache/
key: '$CI_BUILD_STAGE' key: "$CI_BUILD_STAGE"
stages: stages:
- security - security
- test - test
- release - release
- metadata - metadata
before_script:
- pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ==================== # ====================
# security stage # security stage
# ==================== # ====================
# ==================== mirror:
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci command npm config set registry https://registry.npmjs.org - npmci git mirror
- npmci command pnpm audit --audit-level=high --prod
tags: tags:
- lossless - docker
- docker - notpriv
allow_failure: true
auditDevDependencies: snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci command npm config set registry https://registry.npmjs.org - npmci npm prepare
- npmci command pnpm audit --audit-level=high --dev - npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags: tags:
- lossless - docker
- docker - notpriv
allow_failure: true
# ==================== # ====================
# test stage # test stage
# ==================== # ====================
testLEGACY:
testStable:
stage: test stage: test
script: script:
- npmci node install stable - npmci npm prepare
- npmci npm install - npmci node install legacy
- npmci npm test - npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
allow_failure: true
testBuild: testLTS:
stage: test stage: test
script: script:
- npmci node install stable - npmci npm prepare
- npmci npm install - npmci node install lts
- npmci command npm run build - npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
testSTABLE:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release: release:
stage: release stage: release
script: script:
- npmci node install stable - npmci node install stable
- npmci npm publish - npmci npm publish
only: only:
- tags - tags
tags: tags:
- lossless - docker
- docker - notpriv
- notpriv
# ==================== # ====================
# metadata stage # metadata stage
# ==================== # ====================
codequality: codequality:
stage: metadata stage: metadata
image: docker:stable
allow_failure: true allow_failure: true
only: services:
- tags - docker:stable-dind
script: script:
- npmci command npm install -g typescript - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- npmci npm prepare - docker run
- npmci npm install --env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags: tags:
- lossless - docker
- docker - priv
- priv
trigger: trigger:
stage: metadata stage: metadata
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- lossless - docker
- docker - notpriv
- notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci node install stable - npmci command npm install -g typedoc typescript
- npmci npm prepare
- npmci npm install - npmci npm install
- npmci command npm run buildDocs - npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
only: only:
@ -124,5 +133,15 @@ pages:
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
- public - public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true allow_failure: true

4
.snyk Normal file
View File

@ -0,0 +1,4 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
ignore: {}
patch: {}

11
.vscode/launch.json vendored
View File

@ -1,11 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored
View File

@ -1,26 +0,0 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

33
README.md Normal file
View File

@ -0,0 +1,33 @@
# smartlog-destination-local
a smartlog destination targeting the local console
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/beautylog)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/beautylog)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/beautylog)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/beautylog/)
## Status for master
[![build status](https://GitLab.com/pushrocks/beautylog/badges/master/build.svg)](https://GitLab.com/pushrocks/beautylog/commits/master)
[![coverage report](https://GitLab.com/pushrocks/beautylog/badges/master/coverage.svg)](https://GitLab.com/pushrocks/beautylog/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/beautylog.svg)](https://www.npmjs.com/package/beautylog)
[![Dependency Status](https://david-dm.org/pushrocks/beautylog.svg)](https://david-dm.org/pushrocks/beautylog)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/beautylog/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/beautylog/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/beautylog/badges/code.svg)](https://www.bithound.io/github/pushrocks/beautylog)
[![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/)
## Quick Demo
[![asciicast](https://asciinema.org/a/46djsde96ecsho9wqibjx2zye.png)](https://asciinema.org/a/46djsde96ecsho9wqibjx2zye)
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [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

@ -57,7 +57,7 @@ Beautylog makes it easy to have all your node applications log to a remote locat
```javascript ```javascript
import { Loggly } from 'beautyremote'; import { Loggly } from 'beautyremote';
let myLogglyRemote = new Loggly({ let myLogglyRemote = new Loggly({
token: 'my_super_long_token_here', token: 'my_super_long_token_here'
}); });
beautylog.registerRemote(myLogglyRemote); beautylog.registerRemote(myLogglyRemote);
``` ```

View File

@ -2,27 +2,5 @@
"npmci": { "npmci": {
"globalNpmTools": [], "globalNpmTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartlog-destination-local",
"description": "a smartlog destination targeting the local console",
"npmPackagename": "@push.rocks/smartlog-destination-local",
"license": "MIT",
"keywords": [
"logging",
"console log",
"log management",
"developer tools",
"local logging",
"console output"
]
}
},
"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"
} }
} }

1379
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +1,45 @@
{ {
"name": "@push.rocks/smartlog-destination-local", "name": "@pushrocks/smartlog-destination-local",
"private": false, "private": false,
"version": "9.0.2", "version": "7.0.3",
"description": "a smartlog destination targeting the local console", "description": "a smartlog destination targeting the local console",
"main": "dist_ts/index.js", "main": "dist/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild --web)", "build": "(tsbuild)"
"buildDocs": "tsdoc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://code.foss.global/push.rocks/smartlog-destination-local.git" "url": "https://gitlab.com/pushrocks/beautylog.git"
}, },
"keywords": [ "keywords": [
"logging", "log",
"console log", "color",
"log management", "console",
"developer tools", "beautiful"
"local logging",
"console output"
], ],
"author": "Lossless GmbH <hello@lossless.com> (https://lossless.com)", "author": "Lossless GmbH <hello@lossless.com> (https://lossless.com)",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/beautylog/issues" "url": "https://gitlab.com/pushrocks/beautylog/issues"
}, },
"homepage": "https://code.foss.global/push.rocks/smartlog-destination-local", "homepage": "https://gitlab.com/pushrocks/beautylog",
"dependencies": { "dependencies": {
"@push.rocks/consolecolor": "^2.0.1", "@pushrocks/consolecolor": "^2.0.1",
"@push.rocks/smartlog-interfaces": "^3.0.0", "@pushrocks/smartlog-interfaces": "^2.0.1",
"@push.rocks/smartpromise": "^4.0.2" "@pushrocks/smartpromise": "^2.0.5",
"ora": "^3.0.0",
"smartenv": "^4.0.3"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.1.66", "@gitzone/tsbuild": "^2.0.22",
"@git.zone/tsrun": "^1.2.42", "@gitzone/tsrun": "^1.1.13",
"@git.zone/tstest": "^1.0.74", "@gitzone/tstest": "^1.0.15",
"@push.rocks/tapbundle": "^5.0.8", "@pushrocks/smartdelay": "^2.0.2",
"@types/node": "^20.4.1" "@pushrocks/tapbundle": "^3.0.7",
}, "@types/node": "^10.12.2",
"files": [ "tslint": "^5.11.0",
"ts/**/*", "tslint-config-prettier": "^1.15.0"
"ts_web/**/*", }
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"type": "module",
"browserslist": [
"last 1 chrome versions"
]
} }

5009
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@

111
readme.md
View File

@ -1,111 +0,0 @@
# @push.rocks/smartlog-destination-local
a smartlog destination targeting the local console
## Install
To use `@push.rocks/smartlog-destination-local` in your project, you need to install it via npm. You can do this by running:
```bash
npm install @push.rocks/smartlog-destination-local --save
```
This command adds `@push.rocks/smartlog-destination-local` to your project's dependencies and enables you to start implementing its features in your application.
## Usage
The `@push.rocks/smartlog-destination-local` package provides a way to easily log messages to the local console with support for color coding and structured message formats. It is especially useful when combined with the `@push.rocks/smartlog` package to create a powerful logging solution that is both visually informative and structured for better logging practices.
### Importing and Setting Up
First, make sure to import the package where you intend to use it:
```typescript
import { DestinationLocal } from '@push.rocks/smartlog-destination-local';
```
Next, create an instance of `DestinationLocal`:
```typescript
const localLogDestination = new DestinationLocal();
```
### Logging Messages
The primary feature of `@push.rocks/smartlog-destination-local` is to log messages to the console. This can be done by preparing a log package and using the `handleLog` method.
#### Example Log Message
```typescript
import type { ILogPackage } from '@push.rocks/smartlog-interfaces';
const logPackage: ILogPackage = {
timestamp: Date.now(),
type: 'log', // or 'error', 'warn', etc. depending on the nature of the message
level: 'info', // determines the visibility and importance of the log
context: {
company: 'Your Company',
companyunit: 'Your Unit',
containerName: 'Your Container',
environment: 'development',
runtime: 'node',
zone: 'Your Zone'
},
message: 'This is a test log message.', // the actual message
correlation: {
id: 'uniqueId', // useful for tracing logs
type: 'requestId'
},
};
// Using the instance to log the message
localLogDestination.handleLog(logPackage);
```
This will output a structured, color-coded log message to your console, making it easier to differentiate between various log levels and to understand the context of the log messages at a glance.
### Log Reduction
For scenarios where repeated log messages may clutter your log output, `@push.rocks/smartlog-destination-local` offers a `logReduced` method. This method will throttle the output of identical consecutive messages according to the settings you provide.
#### Reducing Log Output
```typescript
// Log a message repeatedly, e.g., in a loop
for (let i = 0; i < 100; i++) {
localLogDestination.logReduced('Repeated message', 5); // only logs every 5th identical message
}
```
### Adding New Lines
You may want to improve the readability of your logs by inserting blank lines. This can be easily achieved:
```typescript
localLogDestination.newLine(2); // Inserts two empty lines in the log output
```
### Advanced Use Cases
The `@push.rocks/smartlog-destination-local` package is flexible and integrates seamlessly with other logging and monitoring solutions. It can be extended or customized to fit more complex logging requirements, such as filtering logs based on environment, enhancing log messages with additional metadata, or integrating with remote logging services for centralized log management.
### Conclusion
`@push.rocks/smartlog-destination-local` serves as a robust, easy-to-use solution for enhancing your application's logging capabilities. By following the examples and using the provided methods, you can quickly implement effective logging practices that improve debugging, monitoring, and analysis of your application's behavior in development and production environments.
## License and Legal Information
This 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.
**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.
### Trademarks
This 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.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By 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.

View File

@ -1,35 +1,31 @@
import { tap, expect } from '@push.rocks/tapbundle'; import { tap, expect } from '@pushrocks/tapbundle';
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartlogDesinationLocal from '../ts/index.js'; import smartlogDesinationLocal = require('../ts/index');
import type { ILogContext } from '@push.rocks/smartlog-interfaces'; import { ILogContext } from '@pushrocks/smartlog-interfaces';
const testLogContext: ILogContext = { let testLogContext: ILogContext = {
company: 'Lossless GmbH', company: 'Lossless GmbH',
companyunit: 'Lossless.Cloud', companyunit: 'Lossless.Cloud',
containerName: 'gitlabci', containerName: 'gitlabci',
environment: 'staging', environment: 'staging',
runtime: 'node', runtime: 'node',
zone: 'shipzone', zone: 'shipzone'
}; };
let testLocalInstance: smartlogDesinationLocal.DestinationLocal; let testLocalInstance: smartlogDesinationLocal.DestinationLocal;
tap.test('should create a valid instance of DestinationLocal', async () => { tap.test('should create a valid instance of DestinationLocal', async () => {
testLocalInstance = new smartlogDesinationLocal.DestinationLocal(); testLocalInstance = new smartlogDesinationLocal.DestinationLocal();
expect(testLocalInstance).toBeInstanceOf(smartlogDesinationLocal.DestinationLocal); expect(testLocalInstance).to.be.instanceof(smartlogDesinationLocal.DestinationLocal);
}); });
tap.test('.log(message) should print a blue Dir message', async () => { tap.test('.log(message) should print a blue Dir message', async () => {
testLocalInstance.handleLog({ testLocalInstance.handleLog({
timestamp: Date.now(),
type: 'log', type: 'log',
level: 'info', level: 'info',
context: testLogContext, context: testLogContext,
message: 'this is a info log message', message: 'this is a info log message'
correlation: {
id: '123',
type: 'none',
},
}); });
}); });
@ -46,4 +42,19 @@ tap.test('.newLine(number) create specified amount of new lines', async () => {
testLocalInstance.newLine(1); testLocalInstance.newLine(1);
}); });
tap.test('.ora(text,color) should display, update, and end a message', async () => {
testLocalInstance.ora.start('This is a test text', 'green');
await smartdelay.delayFor(2000);
testLocalInstance.ora.text('updated text!');
await smartdelay.delayFor(2000);
await smartdelay.delayFor(2000);
testLocalInstance.ora.stop();
});
tap.test('.ora(text,color) should display an error message when ended with error', async () => {
testLocalInstance.ora.start('This is another test text', 'green');
await smartdelay.delayFor(2000);
testLocalInstance.ora.stop();
});
tap.start(); tap.start();

View File

@ -1,8 +0,0 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartlog-destination-local',
version: '9.0.2',
description: 'a smartlog destination targeting the local console'
}

View File

@ -1,2 +1,2 @@
// export classes // export classes
export { DestinationLocal } from './classes.destinationlocal.js'; export { DestinationLocal } from './sl.destlocal.classes.destinationlocal';

View File

@ -1,5 +0,0 @@
import * as consolecolor from '@push.rocks/consolecolor';
import * as smartlogInterfaces from '@push.rocks/smartlog-interfaces';
import * as smartpromise from '@push.rocks/smartpromise';
export { consolecolor, smartlogInterfaces, smartpromise };

View File

@ -1,18 +1,28 @@
import * as plugins from './plugins.js'; import * as plugins from './sl.destlocal.plugins';
import type { ILogDestination, ILogPackage, TLogLevel } from '@push.rocks/smartlog-interfaces'; import { ILogDestination, ILogPackage, TLogLevel } from '@pushrocks/smartlog-interfaces';
// other beautylog classes // other beautylog classes
import { type TColorName } from '@push.rocks/consolecolor'; import { Ora } from './sl.destlocal.classes.ora';
import { TColorName } from '@pushrocks/consolecolor';
export class DestinationLocal implements ILogDestination { export class DestinationLocal implements ILogDestination {
private oraInstance: Ora;
/** /**
* handles a log according to the smartlog standard * handles a log according to the smartlog standard
* @param logPackage * @param logPackage
*/ */
public async handleLog(logPackage: ILogPackage) { public handleLog(logPackage: ILogPackage) {
this.logToConsole(logPackage); this.logToConsole(logPackage);
} }
get ora(): Ora {
if (!this.oraInstance) {
this.oraInstance = new Ora(this);
}
return this.oraInstance;
}
/** /**
* creates a new empty line * creates a new empty line
* @param linesArg * @param linesArg
@ -37,7 +47,6 @@ export class DestinationLocal implements ILogDestination {
this.sameMessageCounter = 0; this.sameMessageCounter = 0;
this.previousMessage = logTextArg; this.previousMessage = logTextArg;
this.logToConsole({ this.logToConsole({
timestamp: Date.now(),
type: 'log', type: 'log',
level: 'info', level: 'info',
context: { context: {
@ -46,13 +55,9 @@ export class DestinationLocal implements ILogDestination {
containerName: 'undefined', containerName: 'undefined',
environment: 'test', environment: 'test',
runtime: 'node', runtime: 'node',
zone: 'undefined', zone: 'undefined'
},
message: logTextArg,
correlation: {
id: 'none',
type: 'none',
}, },
message: logTextArg
}); });
} }
} }
@ -60,7 +65,7 @@ export class DestinationLocal implements ILogDestination {
private sameMessageCounter: number = 0; private sameMessageCounter: number = 0;
// default logging // default logging
private logToConsole(logPackageArg: ILogPackage) { logToConsole(logPackageArg: ILogPackage) {
let logString: string; let logString: string;
try { try {
logString = logString =
@ -69,7 +74,14 @@ export class DestinationLocal implements ILogDestination {
logPackageArg.message, logPackageArg.message,
this.localBl[logPackageArg.level].textColor this.localBl[logPackageArg.level].textColor
); );
if (this.ora.state === 'running') {
this.ora.pause();
}
console.log(logString); console.log(logString);
if (this.ora.state === 'paused') {
this.ora.start();
}
return true; return true;
} catch (error) { } catch (error) {
console.log( console.log(
@ -87,49 +99,49 @@ export class DestinationLocal implements ILogDestination {
} = { } = {
silly: { silly: {
prefix: plugins.consolecolor.coloredString(' silly ', 'white', 'blue') + ' ', prefix: plugins.consolecolor.coloredString(' silly ', 'white', 'blue') + ' ',
textColor: 'blue', textColor: 'blue'
}, },
error: { error: {
prefix: prefix:
plugins.consolecolor.coloredString(' ', 'red', 'red') + plugins.consolecolor.coloredString(' ', 'red', 'red') +
plugins.consolecolor.coloredString(' ERROR! ', 'red', 'black') + plugins.consolecolor.coloredString(' ERROR! ', 'red', 'black') +
' ', ' ',
textColor: 'red', textColor: 'red'
}, },
info: { info: {
prefix: prefix:
plugins.consolecolor.coloredString(' ', 'blue', 'blue') + plugins.consolecolor.coloredString(' ', 'blue', 'blue') +
plugins.consolecolor.coloredString(' info: ', 'blue', 'black') + plugins.consolecolor.coloredString(' info: ', 'blue', 'black') +
' ', ' ',
textColor: 'white', textColor: 'white'
}, },
note: { note: {
prefix: prefix:
plugins.consolecolor.coloredString(' ', 'pink', 'pink') + plugins.consolecolor.coloredString(' ', 'pink', 'pink') +
plugins.consolecolor.coloredString(' note -> ', 'pink', 'black') + plugins.consolecolor.coloredString(' note -> ', 'pink', 'black') +
' ', ' ',
textColor: 'pink', textColor: 'pink'
}, },
ok: { ok: {
prefix: prefix:
plugins.consolecolor.coloredString(' ', 'green', 'green') + plugins.consolecolor.coloredString(' ', 'green', 'green') +
plugins.consolecolor.coloredString(' ok ', 'green', 'black') + plugins.consolecolor.coloredString(' ok ', 'green', 'black') +
' ', ' ',
textColor: 'green', textColor: 'green'
}, },
success: { success: {
prefix: prefix:
plugins.consolecolor.coloredString(' ', 'green', 'green') + plugins.consolecolor.coloredString(' ', 'green', 'green') +
plugins.consolecolor.coloredString(' SUCCESS! ', 'green', 'black') + plugins.consolecolor.coloredString(' SUCCESS! ', 'green', 'black') +
' ', ' ',
textColor: 'green', textColor: 'green'
}, },
warn: { warn: {
prefix: prefix:
plugins.consolecolor.coloredString(' ', 'orange', 'orange') + plugins.consolecolor.coloredString(' ', 'orange', 'orange') +
plugins.consolecolor.coloredString(' WARN -> ', 'orange', 'black') + plugins.consolecolor.coloredString(' WARN -> ', 'orange', 'black') +
' ', ' ',
textColor: 'orange', textColor: 'orange'
}, }
}; };
} }

View File

@ -0,0 +1,61 @@
import * as plugins from './sl.destlocal.plugins';
import { DestinationLocal } from './sl.destlocal.classes.destinationlocal';
export class Ora {
/**
* the destinationLocalInstance that ora talks to
*/
destinationLocalInstance: DestinationLocal;
/**
* the state of the current ora
*/
state: 'running' | 'stopped' | 'paused' = 'stopped';
/**
* the actual ora object
*/
private _oraObject;
constructor(destinationLocalInstanceArg: DestinationLocal = new DestinationLocal()) {
this.destinationLocalInstance = destinationLocalInstanceArg;
this._oraObject = plugins.ora({
spinner: 'dots',
text: '',
color: 'blue'
});
}
text(textArg) {
this._oraObject.text = textArg;
}
start(textArg?: string, colorArg?: string) {
if (textArg) {
this.text(textArg);
}
if (colorArg) {
this._oraObject.color = colorArg;
}
this.state = 'running';
this._oraObject.start();
}
end() {
this._oraObject.stop();
this._oraObject.clear();
this.state = 'stopped';
}
pause() {
this._oraObject.stop();
this.state = 'paused';
}
/**
* stop is an alias for end
*/
stop() {
this.end();
}
}

View File

@ -0,0 +1,7 @@
import * as consolecolor from '@pushrocks/consolecolor';
import * as smartenv from 'smartenv';
import * as smartlogInterfaces from '@pushrocks/smartlog-interfaces';
import * as smartpromise from '@pushrocks/smartpromise';
let ora = require('ora');
export { consolecolor, smartenv, smartlogInterfaces, smartpromise, ora };

View File

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

17
tslint.json Normal file
View File

@ -0,0 +1,17 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}