@protoqol/vivid-log 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CHANGELOG +12 -0
- package/.github/LICENSE +21 -0
- package/.github/workflows/publish.yml +38 -0
- package/README.md +201 -0
- package/dist/lib/ansi.d.ts +25 -0
- package/dist/lib/ansi.js +49 -0
- package/dist/lib/ansi.js.map +1 -0
- package/dist/lib/config/config.d.ts +18 -0
- package/dist/lib/config/config.js +44 -0
- package/dist/lib/config/config.js.map +1 -0
- package/dist/lib/enums.d.ts +13 -0
- package/dist/lib/enums.js +29 -0
- package/dist/lib/enums.js.map +1 -0
- package/dist/lib/methods.d.ts +3 -0
- package/dist/lib/methods.js +35 -0
- package/dist/lib/methods.js.map +1 -0
- package/dist/lib/utils.d.ts +34 -0
- package/dist/lib/utils.js +224 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/vividLog.d.ts +51 -0
- package/dist/lib/vividLog.js +116 -0
- package/dist/lib/vividLog.js.map +1 -0
- package/dist/test/test.d.ts +1 -0
- package/dist/test/test.js +112 -0
- package/dist/test/test.js.map +1 -0
- package/dist/vividLog.js +2 -0
- package/dist/vividLog.js.map +1 -0
- package/lib/ansi.ts +47 -0
- package/lib/config/config.ts +68 -0
- package/lib/enums.ts +35 -0
- package/lib/methods.ts +32 -0
- package/lib/utils.ts +271 -0
- package/lib/vividLog.ts +134 -0
- package/package.json +42 -0
- package/test/test.ts +88 -0
- package/tsconfig.json +25 -0
- package/webpack.config.js +29 -0
package/test/test.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as assert from "assert";
|
|
2
|
+
import {Utils} from "../lib/utils";
|
|
3
|
+
import {LogSize} from "../lib/enums";
|
|
4
|
+
import vividLog from "../lib/vividLog";
|
|
5
|
+
|
|
6
|
+
describe("Vivid Log | Testing Suite", function () {
|
|
7
|
+
let v: any;
|
|
8
|
+
let ENUM: typeof LogSize;
|
|
9
|
+
|
|
10
|
+
before(function () {
|
|
11
|
+
v = vividLog;
|
|
12
|
+
ENUM = LogSize;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe("vividLog.methods.takeOver()", function () {
|
|
16
|
+
it("should return true when native error log has been taken over", function () {
|
|
17
|
+
assert.strictEqual(v.takeOver(true), undefined);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe("vividLog.util.createTime()", function () {
|
|
22
|
+
it("should return a timestamp (string)", function () {
|
|
23
|
+
assert.ok(Utils.createTime("h:m:s"));
|
|
24
|
+
assert.strictEqual(typeof Utils.createTime("h:m:s"), "string");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("vividLog.util.getType()", function () {
|
|
29
|
+
it("should return a string[9] with getType('testValue')", function () {
|
|
30
|
+
assert.strictEqual(Utils.getType("testValue"), "string[9]");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should return integer[3] with getType(124)", function () {
|
|
34
|
+
assert.strictEqual(Utils.getType(124), "integer[3]");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should return boolean with getType(true)", function () {
|
|
38
|
+
assert.strictEqual(Utils.getType(true), "boolean");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should return object[2] with getType({t: 'test', s: 'stest'})", function () {
|
|
42
|
+
assert.strictEqual(Utils.getType({
|
|
43
|
+
test : "object",
|
|
44
|
+
second: "object",
|
|
45
|
+
}), "object[2]");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should return array[3] with getType([1, 2, 3])", function () {
|
|
49
|
+
assert.strictEqual(Utils.getType([1, 2, 3]), "array[3]");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should return null with getType(null)", function () {
|
|
53
|
+
assert.strictEqual(Utils.getType(null), "null");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should return error with getType(new Error())", function () {
|
|
57
|
+
assert.strictEqual(Utils.getType(new Error("test")), "error");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should return a function with getType(function)", function () {
|
|
61
|
+
assert.strictEqual(Utils.getType(function test() {
|
|
62
|
+
var testval = "val";
|
|
63
|
+
}), "function");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should return undefined with getType()", function () {
|
|
67
|
+
assert.strictEqual(Utils.getType(true), "boolean");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("Terminal logging", function () {
|
|
72
|
+
it("should log to terminal without crashing", function () {
|
|
73
|
+
v.log("Test terminal log");
|
|
74
|
+
v.done("Test success");
|
|
75
|
+
v.warn("Test warning");
|
|
76
|
+
v.err("Test error");
|
|
77
|
+
v.info("Test info");
|
|
78
|
+
v.debug("Test debug");
|
|
79
|
+
v.say("Test say", "CUSTOM", "#ff00ff");
|
|
80
|
+
v.fireLabel("TEST LABEL");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should log complex objects to terminal without crashing", function () {
|
|
84
|
+
v.log({a: 1, b: 2});
|
|
85
|
+
v.err(new Error("Test Error Object"));
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target" : "ES2022",
|
|
4
|
+
"module" : "CommonJS",
|
|
5
|
+
"moduleResolution" : "node",
|
|
6
|
+
"lib" : [
|
|
7
|
+
"ESNext",
|
|
8
|
+
"DOM"
|
|
9
|
+
],
|
|
10
|
+
"strict" : true,
|
|
11
|
+
"esModuleInterop" : true,
|
|
12
|
+
"skipLibCheck" : true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"outDir" : "./dist",
|
|
15
|
+
"declaration" : true,
|
|
16
|
+
"sourceMap" : true
|
|
17
|
+
},
|
|
18
|
+
"include" : [
|
|
19
|
+
"lib/**/*",
|
|
20
|
+
"test/**/*"
|
|
21
|
+
],
|
|
22
|
+
"exclude" : [
|
|
23
|
+
"node_modules"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode : "production",
|
|
5
|
+
entry : "./lib/vividLog.ts",
|
|
6
|
+
devtool: "source-map",
|
|
7
|
+
output : {
|
|
8
|
+
filename : "vividLog.js",
|
|
9
|
+
path : path.resolve(__dirname, "dist"),
|
|
10
|
+
library : {
|
|
11
|
+
name: "vividLog",
|
|
12
|
+
type: "umd",
|
|
13
|
+
},
|
|
14
|
+
globalObject: "this",
|
|
15
|
+
},
|
|
16
|
+
resolve: {
|
|
17
|
+
extensions: [".ts", ".js"],
|
|
18
|
+
},
|
|
19
|
+
module : {
|
|
20
|
+
rules: [
|
|
21
|
+
{
|
|
22
|
+
test : /\.ts$/,
|
|
23
|
+
exclude: /node_modules/,
|
|
24
|
+
use : "ts-loader",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
plugins: [],
|
|
29
|
+
};
|