@akc42/server-utils 1.2.1 → 1.4.1

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.
Files changed (3) hide show
  1. package/logger.js +21 -16
  2. package/package.json +3 -4
  3. package/version.js +2 -1
package/logger.js CHANGED
@@ -24,7 +24,7 @@
24
24
  (function() {
25
25
  'use strict';
26
26
 
27
- const chalk = require('chalk');
27
+ const chalkPromise = import('chalk');
28
28
  const { isIP } = require('net');
29
29
  let cyrb53;
30
30
 
@@ -43,25 +43,30 @@
43
43
  return 4294967296 * (2097151 & h2) + (h1 >>> 0);
44
44
  };
45
45
  }
46
- const COLOURS = {
47
- app: chalk.rgb(255, 136, 0).bold, //orange,
48
- db: chalk.greenBright,
49
- api: chalk.magentaBright,
50
- client: chalk.redBright,
51
- log: chalk.yellowBright,
52
- mail:chalk.cyanBright,
53
- //error like have backGround colouring
54
- auth: chalk.black.bgCyan,
55
- err: chalk.white.bgBlue,
56
- error: chalk.white.bgRed
57
- };
46
+ const COLOURPromise = new Promise(async accept => {
47
+ const {default: chalk} = await import('chalk');
48
+ accept({
49
+ app: chalk.rgb(255, 136, 0).bold, //orange,
50
+ db: chalk.greenBright,
51
+ api: chalk.magentaBright,
52
+ client: chalk.redBright,
53
+ log: chalk.yellowBright,
54
+ mail: chalk.cyanBright,
55
+ //error like have backGround colouring
56
+ auth: chalk.black.bgCyan,
57
+ err: chalk.white.bgBlue,
58
+ error: chalk.white.bgRed
59
+ });
60
+ });
58
61
 
59
- function logger(ip,level, ...messages) {
62
+
63
+ async function logger(ip,level, ...messages) {
60
64
  if (process.env.LOG_NONE === undefined) {
65
+ COLOURS = await COLOURPromise;
61
66
  let logLine = '';
62
67
  if (process.env.LOG_NO_DATE === undefined) logLine += new Date().toISOString() + ': ';
63
68
  let message;
64
- let logcolor
69
+ let logcolor;
65
70
  if (isIP(ip) === 0 ) {
66
71
  logcolor = ip;
67
72
  message = level + messages.join(' ');
@@ -73,7 +78,7 @@
73
78
  }
74
79
  logLine += COLOURS[logcolor](message);
75
80
  //eslint-disable-next-line no-console
76
- console.log(logLine.trim());
81
+ console.log(logLine.trim());
77
82
  }
78
83
  }
79
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akc42/server-utils",
3
- "version": "1.2.1",
3
+ "version": "1.4.1",
4
4
  "description": "A Set of Utilities to use on the Server Side of a Project",
5
5
  "main": "utils.js",
6
6
  "scripts": {
@@ -22,8 +22,7 @@
22
22
  "homepage": "https://github.com/akc42/server-utils#readme",
23
23
  "dependencies": {
24
24
  "app-root-path": "^3.0.0",
25
-
26
- "chalk": "^4.1.0",
27
- "debug": "^4.2.0"
25
+ "chalk": "^5.0.0",
26
+ "debug": "^4.3.3"
28
27
  }
29
28
  }
package/version.js CHANGED
@@ -86,9 +86,10 @@
86
86
  }
87
87
  }
88
88
  } finally {
89
+ const finalversion = version.replace(/\s+/g, ' ').trim(); //trim out new lines and multiple spaces just one.
89
90
  const copyrightTime = new Date(vtime);
90
91
  debug('Resolving with Git copyright Year is ', copyrightTime.getUTCFullYear());
91
- resolve({ version: version, year: copyrightTime.getUTCFullYear() });
92
+ resolve({ version: finalversion, year: copyrightTime.getUTCFullYear() });
92
93
  }
93
94
  });
94
95
  module.exports = releaseVersion;