11cb0ef41Sopenharmony_ciconst NPMLOG = require('npmlog') 21cb0ef41Sopenharmony_ciconst PROCLOG = require('proc-log') 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci// Sets getter and optionally a setter 51cb0ef41Sopenharmony_ci// otherwise setting should throw 61cb0ef41Sopenharmony_ciconst accessors = (obj, set) => (k) => ({ 71cb0ef41Sopenharmony_ci get: () => obj[k], 81cb0ef41Sopenharmony_ci set: set ? (v) => (obj[k] = v) : () => { 91cb0ef41Sopenharmony_ci throw new Error(`Cant set ${k}`) 101cb0ef41Sopenharmony_ci }, 111cb0ef41Sopenharmony_ci}) 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci// Set the value to a bound function on the object 141cb0ef41Sopenharmony_ciconst value = (obj) => (k) => ({ 151cb0ef41Sopenharmony_ci value: (...args) => obj[k].apply(obj, args), 161cb0ef41Sopenharmony_ci}) 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciconst properties = { 191cb0ef41Sopenharmony_ci // npmlog getters/setters 201cb0ef41Sopenharmony_ci level: accessors(NPMLOG, true), 211cb0ef41Sopenharmony_ci heading: accessors(NPMLOG, true), 221cb0ef41Sopenharmony_ci levels: accessors(NPMLOG), 231cb0ef41Sopenharmony_ci gauge: accessors(NPMLOG), 241cb0ef41Sopenharmony_ci stream: accessors(NPMLOG), 251cb0ef41Sopenharmony_ci tracker: accessors(NPMLOG), 261cb0ef41Sopenharmony_ci progressEnabled: accessors(NPMLOG), 271cb0ef41Sopenharmony_ci // npmlog methods 281cb0ef41Sopenharmony_ci useColor: value(NPMLOG), 291cb0ef41Sopenharmony_ci enableColor: value(NPMLOG), 301cb0ef41Sopenharmony_ci disableColor: value(NPMLOG), 311cb0ef41Sopenharmony_ci enableUnicode: value(NPMLOG), 321cb0ef41Sopenharmony_ci disableUnicode: value(NPMLOG), 331cb0ef41Sopenharmony_ci enableProgress: value(NPMLOG), 341cb0ef41Sopenharmony_ci disableProgress: value(NPMLOG), 351cb0ef41Sopenharmony_ci clearProgress: value(NPMLOG), 361cb0ef41Sopenharmony_ci showProgress: value(NPMLOG), 371cb0ef41Sopenharmony_ci newItem: value(NPMLOG), 381cb0ef41Sopenharmony_ci newGroup: value(NPMLOG), 391cb0ef41Sopenharmony_ci // proclog methods 401cb0ef41Sopenharmony_ci notice: value(PROCLOG), 411cb0ef41Sopenharmony_ci error: value(PROCLOG), 421cb0ef41Sopenharmony_ci warn: value(PROCLOG), 431cb0ef41Sopenharmony_ci info: value(PROCLOG), 441cb0ef41Sopenharmony_ci verbose: value(PROCLOG), 451cb0ef41Sopenharmony_ci http: value(PROCLOG), 461cb0ef41Sopenharmony_ci silly: value(PROCLOG), 471cb0ef41Sopenharmony_ci pause: value(PROCLOG), 481cb0ef41Sopenharmony_ci resume: value(PROCLOG), 491cb0ef41Sopenharmony_ci} 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ciconst descriptors = Object.entries(properties).reduce((acc, [k, v]) => { 521cb0ef41Sopenharmony_ci acc[k] = { enumerable: true, ...v(k) } 531cb0ef41Sopenharmony_ci return acc 541cb0ef41Sopenharmony_ci}, {}) 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci// Create an object with the allowed properties rom npm log and all 571cb0ef41Sopenharmony_ci// the logging methods from proc log 581cb0ef41Sopenharmony_ci// XXX: this should go away and requires of this should be replaced with proc-log + new display 591cb0ef41Sopenharmony_cimodule.exports = Object.freeze(Object.defineProperties({}, descriptors)) 60