Skip to content

Commit

Permalink
Merge pull request #20 from jitesoft/develop
Browse files Browse the repository at this point in the history
Dependencies and workflow.
  • Loading branch information
Johannestegner authored Nov 25, 2019
2 parents 942cd06 + 6d4c442 commit 9d813ac
Show file tree
Hide file tree
Showing 9 changed files with 1,021 additions and 898 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
steps:
- uses: toolmantim/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ deploy:
- npm publish --access public
only:
- tags
tags:
- protected

include:
- https://gitlab.com/jitesoft/gitlab-ci-lib/raw/master/dependency_scanning.yml
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Yolog have three base files which you can make use of when it is compiled:
* node.js
* browser.js

The `index.js` is only the API (contains the `Yolog` and `Plugin` interfaces and such) and could possibly be useful
The `index.js` is only the API (contains the `Yolog` and `YologPlugin` interfaces and such) and could possibly be useful
if you wish to create your own plugin but don't care about the other stuff.

The `browser.js` file contains the same code as the `index.js` and an extra `ConsolePlugin` which is pre-initialized if
Expand All @@ -44,7 +44,7 @@ using the `default` value from the package.

When including the script, there will be a global `Yolog` object containing `logger` (which is an instance of yolog
ready to use with the console plugin), `Yolog` which is the logger itself, if you wish to create a new instance yourself.
`ConsolePlugin`, which is a plugin that produces output to the console and the `Plugin` class (which is used to create new plugins)
`ConsolePlugin`, which is a plugin that produces output to the console and the `YologPlugin` class (which is used to create new plugins)

Simply put:

Expand Down Expand Up @@ -143,9 +143,9 @@ When writing a new plugin, the `Plugin` class in the base lib is used as a base
the only method that really have to be implemented is the `log` method, the base class takes care of the rest!

```js
import {Plugin} from '@jitesoft/yolog';
import { YologPlugin } from '@jitesoft/yolog';

export default class MyPlugin extends Plugin {
export default class MyPlugin extends YologPlugin {
/**
* Method called when a log message is intercepted and the plugin is listening to the given tag.
*
Expand All @@ -165,7 +165,7 @@ export default class MyPlugin extends Plugin {
Plugin interface:

```typescript
interface PluginInterface {
interface YologPluginInterface {
log (tag: string, timestamp: number, message: string, error): Promise<void>; /*Abstract, only method required to be implemented. */
set (tag: string, state: boolean|null): void;
get (tag: string): boolean|undefined;
Expand Down Expand Up @@ -235,9 +235,9 @@ used for this:

```typescript
interface Yolog {
addPlugin(plugin: Plugin): Yolog;
removePlugin(plugin: Plugin): Yolog;
readonly plugins: Plugin[];
addPlugin(plugin: YologPlugin): Yolog;
removePlugin(plugin: YologPlugin): Yolog;
readonly plugins: YologPlugin[];
}
```

Expand Down Expand Up @@ -316,7 +316,7 @@ The `available` and `active` getters works as with the yolog class, the first re
the `active` returns which are turned on.

```typescript
interface Plugin {
interface YologPlugin {
readonly available: string[];
readonly active: string[];
}
Expand Down
1,862 changes: 991 additions & 871 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@
]
},
"dependencies": {
"@jitesoft/events": "^1.3.14",
"@jitesoft/sprintf": "^1.0.2"
"@jitesoft/events": "^1.3.16",
"@jitesoft/sprintf": "^1.0.5"
},
"devDependencies": {
"@babel/core": "^7.7.0",
"@jitesoft/babel-preset-main": "^1.7.3",
"@jitesoft/eslint-config": "^1.7.2",
"@babel/core": "^7.7.4",
"@jitesoft/babel-preset-main": "^1.8.1",
"@jitesoft/eslint-config": "^1.8.1",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"core-js": "^3.3.6",
"core-js": "^3.4.2",
"cross-env": "^6.0.3",
"eslint": "^6.6.0",
"eslint": "^6.7.1",
"jest": "^24.9.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
Expand Down
10 changes: 5 additions & 5 deletions src/Yolog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Plugin from './Plugin';
import YologPlugin from './YologPlugin';
import { EventHandler, Event } from '@jitesoft/events';
import sprintf from '@jitesoft/sprintf';

Expand All @@ -10,7 +10,7 @@ import sprintf from '@jitesoft/sprintf';
export default class Yolog {
#eventHandler;

/** @type {Array<Plugin>} */
/** @type {Array<YologPlugin>} */
#plugins;

/** @type {Object} */
Expand Down Expand Up @@ -130,7 +130,7 @@ export default class Yolog {
/**
* Add a plugin to the current Yolog instance.
*
* @param {Plugin} plugin
* @param {YologPlugin} plugin
* @return {Yolog} self
*/
addPlugin (plugin) {
Expand All @@ -142,7 +142,7 @@ export default class Yolog {
/**
* Remove a plugin from current Yolog instance.
*
* @param {Plugin} plugin
* @param {YologPlugin} plugin
* @return {Yolog} self
*/
removePlugin (plugin) {
Expand Down Expand Up @@ -271,5 +271,5 @@ export default class Yolog {

const logger = new Yolog();
export {
Yolog, Plugin, logger
Yolog, YologPlugin, logger, YologPlugin as Plugin
};
6 changes: 3 additions & 3 deletions src/Plugin.js → src/YologPlugin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @abstract */
export default class Plugin {
export default class YologPlugin {
static id = 0;

#id = Plugin.id++;
#id = YologPlugin.id++;

get id () {
return this.#id;
Expand Down Expand Up @@ -42,7 +42,7 @@ export default class Plugin {
*
* @param {String} tag
* @param {Boolean} [state]
* @return {Plugin} Self.
* @return {YologPlugin} Self.
*/
set (tag, state = null) {
this.#tags[tag.toLowerCase()] = state !== null ? state : !this.get(tag);
Expand Down
2 changes: 1 addition & 1 deletion tests/Yolog.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Yolog from '../src/Yolog';
import Plugin from '../src/Plugin';
import Plugin from '../src/YologPlugin';

class TestPlugin extends Plugin {
constructor (inner) {
Expand Down
3 changes: 2 additions & 1 deletion tests/Plugin.test.js → tests/YologPlugin.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Plugin from '../src/Plugin';
import Plugin from '../src/YologPlugin';

describe('Tests for plugin class.', () => {
let plugin = null;
Expand All @@ -13,6 +13,7 @@ describe('Tests for plugin class.', () => {
];

beforeEach(() => {
// noinspection JSClosureCompilerSyntax
plugin = new Plugin(); // Abstract I know, I don't care! :P
});

Expand Down

0 comments on commit 9d813ac

Please sign in to comment.