Skip to content

Commit

Permalink
add select object query helper class (#143)
Browse files Browse the repository at this point in the history
* add select object query helper class

* validate results

* require dotenv

* remove dotenv config

* bump @themost/query@2.5.9 to  @themost/query@2.5.22

* 2.6.47
  • Loading branch information
kbarbounakis committed Mar 26, 2024
1 parent 9ad4a57 commit b017458
Show file tree
Hide file tree
Showing 7 changed files with 13,655 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
- run: npm publish --tag lts
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
106 changes: 4 additions & 102 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,105 +1,7 @@
const { TraceUtils } = require('@themost/common');
const moment = require('moment');
const {inspect} = require('util');

class JestLogger {

/**
* @param {{dateFormat:string=,logLevel:string=,format:raw=}=} options
*/
constructor(options) {
this.options = Object.assign({}, {
dateFormat: 'DD/MMM/YYYY:HH:mm:ss Z',
logLevel: 'info',
format: 'raw'
}, options);
if (options == null) {
// validate NODE_ENV environment variable
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
this.options.logLevel = 'debug';
}
}
this.level = JestLogger.Levels.info;
if (Object.prototype.hasOwnProperty.call(JestLogger.Levels), this.options.logLevel) {
this.level = JestLogger.Levels[this.options.logLevel];
}

}

static get Levels() {
return {
error: 0,
warn: 1,
info: 2,
verbose: 3,
debug: 4
};
}

log() {
if (this.level < JestLogger.Levels.info) {
return;
}
this.write.apply(this, ['log'].concat(Array.from(arguments)));
}

info() {
if (this.level < JestLogger.Levels.info) {
return;
}
this.write.apply(this, ['info'].concat(Array.from(arguments)));
}

warn() {
if (this.level < JestLogger.Levels.warn) {
return;
}
this.write.apply(this, ['warn'].concat(Array.from(arguments)));
}

error() {
if (this.level < JestLogger.Levels.error) {
return;
}
this.write.apply(this, ['error'].concat(Array.from(arguments)));
}

verbose() {
if (this.level < JestLogger.Levels.verbose) {
return;
}
this.write.apply(this, ['verbose'].concat(Array.from(arguments)));
}

debug() {
if (this.level < JestLogger.Levels.debug) {
return;
}
this.write.apply(this, ['debug'].concat(Array.from(arguments)));
}

/**
* @param {string} level
* @param {...*} arg
*/
// eslint-disable-next-line no-unused-vars
write(level, arg) {
const args = Array.from(arguments);
const log = (level === 'error') ? process.stderr : process.stdout
if (args.length > 1) {
if (args[args.length - 1] == null) {
args.pop();
}
}
// add timestamp
args.unshift(moment().format(this.options.dateFormat || 'DD/MMM/YYYY:HH:mm:ss Z'));
log.write(args.map((arg) => inspect(arg)).map(
(arg) => arg.replace(/^'/, '').replace(/'$/, '')
).join(',') + '\n');
}
}

TraceUtils.useLogger(new JestLogger());

const { JsonLogger } = require('@themost/json-logger');
TraceUtils.useLogger(new JsonLogger({
format: 'raw'
}));
/* global jest */
jest.setTimeout(30000);

0 comments on commit b017458

Please sign in to comment.