@canopycanopycanopy/b-ber-logger 3.0.8-next.61 → 3.0.8-next.96

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/dist/index.js CHANGED
@@ -1,131 +1,621 @@
1
- "use strict";
2
-
3
- var _bindInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/bind");
4
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
5
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
- _Object$defineProperty(exports, "__esModule", {
7
- value: true
8
- });
9
- exports.default = void 0;
10
- var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/bind"));
11
- var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
12
- var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
13
- var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
15
- var _has = _interopRequireDefault(require("lodash/has"));
16
- var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
17
- var _Timer = _interopRequireDefault(require("./Timer"));
18
- var _printer = require("./printer");
19
- var _indenter = require("./indenter");
20
- var _listeners = require("./listeners");
21
- var _events = require("./events");
22
- var _warn = require("./warn");
23
- var _info = require("./info");
24
- var _error = require("./error");
25
- var _debug = require("./debug");
26
- var _trace = require("./trace");
27
- var _notice = require("./notice");
28
- var _inspect = require("./inspect");
29
- var _summary = require("./summary");
30
- var _configure = require("./configure");
31
- var _printVersion = require("./print-version");
32
- var _register = require("./register");
33
- var _format = require("./format");
34
- var _context4 = require("./context");
35
- var _compose = require("./compose");
36
- var _reset = require("./reset");
37
- class Logger extends _Timer.default {
38
- constructor() {
39
- var _context, _context2, _context3;
40
- super();
41
- this.logLevel = Logger.defaults.logLevel;
42
- this.boringOutput = Logger.defaults.boringOutput;
43
- this.command = Logger.defaults.command;
44
- this.consoleWidth = Logger.defaults.consoleWidth;
45
- this.errors = Logger.defaults.errors;
46
- this.warnings = Logger.defaults.warnings;
47
- this.taskWarnings = Logger.defaults.taskWarnings;
48
- this.taskErrors = Logger.defaults.taskErrors;
49
- this.whitespace = Logger.defaults.whitespace;
50
- this.increment = Logger.defaults.increment;
51
- this.indentLevel = Logger.defaults.indentLevel;
52
- this.taskCounter = Logger.defaults.taskCounter;
53
- this.context = Logger.defaults.context;
54
-
55
- // options
56
- this.settings = {
57
- quiet: false,
58
- verbose: false,
59
- debug: false,
60
- summary: Logger.defaults.summary,
61
- 'no-color': Logger.defaults.boringOutput,
62
- 'log-level': Logger.defaults.logLevel
63
- };
64
-
65
- // bindings
66
- this.printWarnings = (0, _bind.default)(_printer.printWarnings).call(_printer.printWarnings, this);
67
- this.printErrors = (0, _bind.default)(_printer.printErrors).call(_printer.printErrors, this);
68
- this.indent = (0, _bind.default)(_indenter.indent).call(_indenter.indent, this);
69
- this.incrementIndent = (0, _bind.default)(_indenter.incrementIndent).call(_indenter.incrementIndent, this);
70
- this.decrementIndent = (0, _bind.default)(_indenter.decrementIndent).call(_indenter.decrementIndent, this);
71
- this.incrementCounter = (0, _bind.default)(_indenter.incrementCounter).call(_indenter.incrementCounter, this);
72
- this.decrementCounter = (0, _bind.default)(_indenter.decrementCounter).call(_indenter.decrementCounter, this);
73
- this.bind = (0, _bind.default)(_bindInstanceProperty2(_listeners)).call(_bindInstanceProperty2(_listeners), this);
74
- this.notify = (0, _bind.default)(_events.notify).call(_events.notify, this);
75
- this.warn = (0, _bind.default)(_warn.warn).call(_warn.warn, this);
76
- this.info = (0, _bind.default)(_info.info).call(_info.info, this);
77
- this.error = (0, _bind.default)(_error.error).call(_error.error, this);
78
- this.debug = (0, _bind.default)(_debug.debug).call(_debug.debug, this);
79
- this.trace = (0, _bind.default)(_trace.trace).call(_trace.trace, this);
80
- this.notice = (0, _bind.default)(_notice.notice).call(_notice.notice, this);
81
- this.inspect = (0, _bind.default)(_inspect.inspect).call(_inspect.inspect, this);
82
- this.printSummary = (0, _bind.default)(_summary.printSummary).call(_summary.printSummary, this);
83
- this.configure = (0, _bind.default)(_configure.configure).call(_configure.configure, this);
84
- this.printVersion = (0, _bind.default)(_printVersion.printVersion).call(_printVersion.printVersion, this);
85
- this.registerSequence = (0, _bind.default)(_register.registerSequence).call(_register.registerSequence, this);
86
- this.wrap = (0, _bind.default)(_format.wrap).call(_format.wrap, this);
87
- this.decorate = (0, _bind.default)(_format.decorate).call(_format.decorate, this);
88
- this.floatFormat = (0, _bind.default)(_format.floatFormat).call(_format.floatFormat, this);
89
- this.counter = (0, _bind.default)(_context4.counter).call(_context4.counter, this);
90
- this.getContext = (0, _bind.default)(_context4.getContext).call(_context4.getContext, this);
91
- this.composeMessage = (0, _bind.default)(_compose.composeMessage).call(_compose.composeMessage, this);
92
- this.reset = (0, _bind.default)(_reset.reset).call(_reset.reset, this);
93
-
94
- // parse args
95
- const argv = (0, _reduce.default)(_context = process.argv).call(_context, (acc, curr) => {
96
- const [k, v] = curr.split('=');
97
- // eslint-disable-next-line no-restricted-globals
98
- acc[k] = (0, _isUndefined.default)(v) ? true : !isNaN(v) ? Number(v) : v;
99
- return acc;
100
- }, {});
101
- (0, _forEach.default)(_context2 = (0, _keys.default)(this.settings)).call(_context2, a => {
102
- const opt = `--${a}`;
103
- if ((0, _has.default)(argv, opt)) this.settings[a] = argv[opt];
104
- });
105
- this.configure();
106
- (0, _bind.default)(_context3 = this).call(_context3);
107
- }
108
-
109
- // eslint-disable-next-line class-methods-use-this
110
- newLine() {
111
- process.stdout.write('\n');
112
- }
113
- }
114
- (0, _defineProperty2.default)(Logger, "defaults", {
115
- logLevel: 2,
116
- boringOutput: false,
117
- summary: false,
118
- command: null,
119
- consoleWidth: 70,
120
- errors: [],
121
- warnings: [],
122
- taskWarnings: 0,
123
- taskErrors: 0,
124
- whitespace: ' ',
125
- increment: 0,
126
- indentLevel: 0,
127
- taskCounter: -1,
128
- context: null
129
- });
130
- const log = new Logger();
131
- var _default = exports.default = log;
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ let util = require("util");
24
+ util = __toESM(util);
25
+ let events = require("events");
26
+ let chalk = require("chalk");
27
+ chalk = __toESM(chalk);
28
+ //#region src/compose.ts
29
+ function composeMessage(args) {
30
+ return util.default.format.call(util.default, ...args).split("\n").map((a) => a.trim()).join(`\n${" ".repeat(6)}`).replace(/\{(\d+)\}/g, (_, d) => this.decorate(String(this.floatFormat(d)), "blueBright")).replace(/\[([^\]]+)\]/g, (_, s) => this.decorate(s, "blueBright"));
31
+ }
32
+ //#endregion
33
+ //#region src/configure.ts
34
+ function configure() {
35
+ let logLevel;
36
+ logLevel = this.settings["log-level"];
37
+ logLevel = this.settings.quiet ? 0 : logLevel;
38
+ logLevel = this.settings.verbose ? 4 : logLevel;
39
+ logLevel = this.settings.debug ? 5 : logLevel;
40
+ this.logLevel = logLevel;
41
+ this.boringOutput = this.settings["no-color"] || this.boringOutput;
42
+ this.summary = this.settings.summary || this.summary;
43
+ }
44
+ //#endregion
45
+ //#region src/Timer.ts
46
+ var Timer = class Timer extends events.EventEmitter {
47
+ static dateFormattingOptions = {
48
+ day: "numeric",
49
+ month: "short",
50
+ year: "numeric",
51
+ hour: "numeric",
52
+ minute: "numeric",
53
+ second: "numeric"
54
+ };
55
+ static timeFormat(t) {
56
+ const s = t[0] * 1e3 + t[1] / 1e6;
57
+ return `${String(s).slice(0, -3)}ms`;
58
+ }
59
+ static dateFormat() {
60
+ return new Date(Date.now()).toLocaleString();
61
+ }
62
+ taskBegin = null;
63
+ taskEnd = null;
64
+ sequenceBegin;
65
+ formattedStartDate;
66
+ taskTimes;
67
+ constructor() {
68
+ super();
69
+ this.prepare();
70
+ }
71
+ prepare() {
72
+ this.sequenceBegin = process.hrtime();
73
+ this.formattedStartDate = (/* @__PURE__ */ new Date()).toLocaleDateString("en-CA", Timer.dateFormattingOptions);
74
+ this.taskTimes = [];
75
+ }
76
+ start(task) {
77
+ this.taskBegin = process.hrtime(this.sequenceBegin);
78
+ this.emit("begin", {
79
+ task,
80
+ begin: this.taskBegin
81
+ });
82
+ }
83
+ stop(task) {
84
+ this.taskEnd = process.hrtime(this.sequenceBegin);
85
+ const beginMs = Timer.timeFormat(this.taskBegin);
86
+ const endMs = Timer.timeFormat(this.taskEnd);
87
+ const totalMs = `${(parseFloat(endMs) - parseFloat(beginMs)).toFixed(3)}ms`;
88
+ const taskTime = {
89
+ taskName: task,
90
+ beginHrtime: this.taskBegin,
91
+ endHrtime: this.taskEnd,
92
+ beginMs,
93
+ endMs,
94
+ totalMs
95
+ };
96
+ this.taskTimes.push(taskTime);
97
+ this.emit("end", {
98
+ task,
99
+ taskTime
100
+ });
101
+ }
102
+ done({ state }) {
103
+ const { taskTimes, formattedStartDate } = this;
104
+ const formattedEndDate = (/* @__PURE__ */ new Date()).toLocaleDateString("en-CA", Timer.dateFormattingOptions);
105
+ const sequenceEnd = Timer.timeFormat(process.hrtime(this.sequenceBegin));
106
+ this.emit("done", {
107
+ state,
108
+ taskTimes,
109
+ formattedStartDate,
110
+ formattedEndDate,
111
+ sequenceEnd
112
+ });
113
+ }
114
+ };
115
+ //#endregion
116
+ //#region src/context.ts
117
+ function ctx(fileName) {
118
+ return fileName;
119
+ }
120
+ function counter() {
121
+ this.incrementCounter();
122
+ return this.decorate(`[${Timer.dateFormat()}]`);
123
+ }
124
+ function getContext() {
125
+ const { stack } = /* @__PURE__ */ new Error();
126
+ const context = stack.split("\n")[3].replace(/^\s+at[^/]+(\/[^:]+):.+$/, (_, m) => ctx(m));
127
+ if (context !== this.context) this.context = context;
128
+ else return "";
129
+ return context;
130
+ }
131
+ //#endregion
132
+ //#region src/debug.ts
133
+ function debug() {}
134
+ //#endregion
135
+ //#region src/error.ts
136
+ function error(_args) {
137
+ const args = Array.isArray(_args) ? _args : [_args];
138
+ if (this.logLevel < 1) return;
139
+ const errCode = 1;
140
+ let message;
141
+ let stack;
142
+ let err;
143
+ let formatted;
144
+ while (err = args.shift()) {
145
+ if (err instanceof Error) {
146
+ message = this.composeMessage([err.message]);
147
+ stack = err.stack;
148
+ } else {
149
+ message = this.composeMessage([err]);
150
+ stack = (/* @__PURE__ */ new Error()).stack;
151
+ }
152
+ let prefix = "";
153
+ prefix += this.decorate("b-ber", "whiteBright", "bgBlack");
154
+ prefix += " ";
155
+ prefix += this.decorate("ERR!", "whiteBright", "bgRed");
156
+ formatted = util.default.format.apply(util.default, [
157
+ "%s %s",
158
+ prefix,
159
+ message
160
+ ]);
161
+ this.taskErrors += 1;
162
+ this.errors.push({
163
+ stack,
164
+ message,
165
+ formatted
166
+ });
167
+ }
168
+ this.errors.forEach((processedErr) => {
169
+ process.stdout.write(processedErr.formatted);
170
+ this.newLine();
171
+ if (this.logLevel > 3) {
172
+ process.stdout.write(util.default.format.call(util.default, processedErr.stack));
173
+ this.newLine();
174
+ }
175
+ });
176
+ process.stdout.write(this.decorate(`b-ber exited with code ${errCode}`, "whiteBright", "bgRed"));
177
+ this.newLine();
178
+ process.exit(errCode);
179
+ }
180
+ //#endregion
181
+ //#region src/events.ts
182
+ function notify(event, data) {
183
+ this[event].call(this, data);
184
+ }
185
+ //#endregion
186
+ //#region src/format.ts
187
+ function wrap(arr, space) {
188
+ return arr.reduce((acc, curr) => {
189
+ const a = acc.split("\n");
190
+ const l = a[a.length - 1].length;
191
+ return acc.concat(l > this.consoleWidth ? `\n${space}${curr}, ` : `${curr}, `);
192
+ }, "").slice(0, -2);
193
+ }
194
+ function floatFormat(_n) {
195
+ const n = Number(_n);
196
+ const pows = {
197
+ 1: {
198
+ text: "B",
199
+ pow: 0
200
+ },
201
+ 2: {
202
+ text: "B",
203
+ pow: 0
204
+ },
205
+ 3: {
206
+ text: "B",
207
+ pow: 0
208
+ },
209
+ 4: {
210
+ text: "Kb",
211
+ pow: 3
212
+ },
213
+ 5: {
214
+ text: "Kb",
215
+ pow: 3
216
+ },
217
+ 6: {
218
+ text: "Kb",
219
+ pow: 3
220
+ },
221
+ 7: {
222
+ text: "Mb",
223
+ pow: 6
224
+ },
225
+ 8: {
226
+ text: "Mb",
227
+ pow: 6
228
+ },
229
+ 9: {
230
+ text: "Mb",
231
+ pow: 6
232
+ },
233
+ 10: {
234
+ text: "Gb",
235
+ pow: 9
236
+ },
237
+ 11: {
238
+ text: "Gb",
239
+ pow: 9
240
+ }
241
+ };
242
+ const len = String(n).length;
243
+ return `${(n / Number(`1e${pows[len].pow}`)).toFixed(2)} ${pows[len].text}`;
244
+ }
245
+ function decorate(_args, ...props) {
246
+ const args = _args && Array.isArray(_args) ? _args : [_args];
247
+ let message = util.default.format.call(util.default, ...args);
248
+ if (this.boringOutput === false) for (let i = props.length - 1; i >= 0; i--) {
249
+ const chalkFn = chalk.default[props[i]];
250
+ if (chalkFn) message = chalkFn(message);
251
+ else message = chalk.default`${message}`;
252
+ }
253
+ return message;
254
+ }
255
+ //#endregion
256
+ //#region src/indenter.ts
257
+ function indent() {
258
+ return this.whitespace.repeat(this.indentLevel);
259
+ }
260
+ function incrementIndent() {
261
+ this.indentLevel += this.increment;
262
+ }
263
+ function decrementIndent() {
264
+ this.indentLevel -= this.increment;
265
+ }
266
+ function incrementCounter() {
267
+ this.taskCounter += 1;
268
+ }
269
+ function decrementCounter() {
270
+ this.taskCounter -= 1;
271
+ }
272
+ //#endregion
273
+ //#region src/info.ts
274
+ function info(...args) {
275
+ if (this.logLevel < 4) return;
276
+ const message = this.decorate(this.composeMessage(args));
277
+ let prefix = "";
278
+ if (this.logLevel > 2) {
279
+ prefix += this.decorate(`[${(/* @__PURE__ */ new Date()).toISOString()}]`, "gray");
280
+ prefix += " ";
281
+ }
282
+ prefix += this.decorate("b-ber", "whiteBright", "bgBlack");
283
+ prefix += " ";
284
+ prefix += this.decorate("info", "green");
285
+ prefix += " ";
286
+ process.stdout.write(`${prefix}${message}`);
287
+ this.newLine();
288
+ if (this.logLevel > 4) {
289
+ const { stack } = /* @__PURE__ */ new Error();
290
+ process.stdout.write(util.default.format.call(util.default, stack.replace(/^Error\s+/, "Info ")));
291
+ this.newLine();
292
+ this.newLine();
293
+ }
294
+ }
295
+ //#endregion
296
+ //#region src/inspect.ts
297
+ function inspect(_args) {
298
+ console.log(util.default.inspect(_args, true, null, true));
299
+ }
300
+ //#endregion
301
+ //#region src/listeners.ts
302
+ function bind() {
303
+ this.on("begin", ({ task }) => {
304
+ this.task = task;
305
+ this.taskWarnings = 0;
306
+ this.taskErrors = 0;
307
+ if (this.logLevel < 3) {
308
+ this.incrementIndent();
309
+ return;
310
+ }
311
+ this.incrementIndent();
312
+ });
313
+ this.on("end", ({ task, taskTime }) => {
314
+ this.decrementIndent();
315
+ if (this.logLevel < 3) return;
316
+ const { totalMs } = taskTime;
317
+ process.stdout.clearLine(0);
318
+ process.stdout.cursorTo(0);
319
+ const message = util.default.format.call(util.default, "%s%s %s %s %s done (%s)", this.indent(), this.decorate(`[${(/* @__PURE__ */ new Date()).toISOString()}]`, "gray"), this.decorate("b-ber", "whiteBright", "bgBlack"), this.decorate("info", "green"), this.decorate(task), totalMs);
320
+ process.stdout.write(message);
321
+ this.newLine();
322
+ if (this.logLevel > 4) {
323
+ const { stack } = /* @__PURE__ */ new Error();
324
+ process.stdout.write(util.default.format.call(util.default, stack.replace(/^Error\s+/, "Info ")));
325
+ this.newLine();
326
+ }
327
+ });
328
+ this.on("done", (data) => {
329
+ if (this.logLevel < 1) return;
330
+ const message = util.default.format.call(util.default, "%s%s %s %s", this.indent(), this.decorate("b-ber", "whiteBright", "bgBlack"), this.decorate("info", "green"), this.decorate("Build succeeded", "green"));
331
+ process.stdout.write(message);
332
+ this.newLine();
333
+ if (this.summary) this.printSummary(data);
334
+ });
335
+ }
336
+ //#endregion
337
+ //#region src/notice.ts
338
+ function notice(...args) {
339
+ const message = this.decorate(this.composeMessage(args));
340
+ let prefix = "";
341
+ if (this.logLevel > 2) {
342
+ prefix += this.decorate(`[${(/* @__PURE__ */ new Date()).toISOString()}]`, "gray");
343
+ prefix += " ";
344
+ }
345
+ prefix += this.decorate("b-ber", "whiteBright", "bgBlack");
346
+ prefix += " ";
347
+ prefix += this.decorate("info", "green");
348
+ prefix += " ";
349
+ process.stdout.write(`${prefix}${message}`);
350
+ this.newLine();
351
+ }
352
+ //#endregion
353
+ //#region src/print-version.ts
354
+ function printVersion(version) {
355
+ const message = util.default.format.call(util.default, "%s%s %s %s", this.indent(), this.decorate("b-ber", "whiteBright", "bgBlack"), this.decorate("version"), this.decorate(version, "blueBright"));
356
+ process.stdout.write(message);
357
+ this.newLine();
358
+ }
359
+ //#endregion
360
+ //#region src/printer.ts
361
+ function printNotices(type, task = "b-ber") {
362
+ const notices = this[type];
363
+ const leader = type === "warnings" ? "WARN" : "ERR!";
364
+ const color = type === "warnings" ? "bgYellowBright" : "bgRed";
365
+ const message = util.default.format.call(util.default, "%s%s %s task %s - %s %s", this.indent(), this.decorate("b-ber", "whiteBright", "bgBlack"), this.decorate(leader, color), this.decorate(task), this.decorate(notices.length), this.decorate(type));
366
+ if (this.logLevel > 2) process.stdout.write(message);
367
+ }
368
+ function printWarnings(task) {
369
+ printNotices.call(this, "warnings", task);
370
+ }
371
+ function printErrors(task) {
372
+ printNotices.call(this, "errors", task);
373
+ }
374
+ //#endregion
375
+ //#region src/register.ts
376
+ function registerSequence(_state, _command, sequence) {
377
+ if (this.logLevel < 1) return;
378
+ const message = this.decorate(this.composeMessage([
379
+ "Preparing to run",
380
+ sequence.length,
381
+ `task${sequence.length > 1 ? "s" : ""}`
382
+ ]));
383
+ let prefix = "";
384
+ if (this.logLevel > 2) {
385
+ prefix += this.decorate(`[${(/* @__PURE__ */ new Date()).toISOString()}]`, "gray");
386
+ prefix += " ";
387
+ }
388
+ prefix += this.decorate("b-ber", "whiteBright", "bgBlack");
389
+ prefix += " ";
390
+ prefix += this.decorate("info", "green");
391
+ prefix += " ";
392
+ process.stdout.write(`${prefix}${message}`);
393
+ this.newLine();
394
+ }
395
+ //#endregion
396
+ //#region src/reset.ts
397
+ function reset() {
398
+ this.errors = [];
399
+ this.warnings = [];
400
+ }
401
+ //#endregion
402
+ //#region src/summary.ts
403
+ const INDENTATION = " ";
404
+ function isPlainObject(v) {
405
+ return typeof v === "object" && v !== null && Object.getPrototypeOf(v) === Object.prototype;
406
+ }
407
+ function write(msgs, context) {
408
+ const len = msgs.length - 1;
409
+ const esses = " %s".repeat(len);
410
+ const msgs_ = msgs.map(([text, color]) => color ? context.decorate(text, color) : context.decorate(text));
411
+ const message = util.default.format.call(util.default, `%s%s %s${esses}`, context.indent(), context.decorate("b-ber", "whiteBright", "bgBlack"), ...msgs_);
412
+ process.stdout.write(message);
413
+ context.newLine();
414
+ }
415
+ function printNavigation(data, context, indent = 0) {
416
+ const indent_ = INDENTATION.repeat(indent);
417
+ function render(_data, _context) {
418
+ _data.forEach((item) => {
419
+ write.call(_context, [[`${indent_}${item.title || "[no title]"}: ${item.name}`]], _context);
420
+ if (item.nodes && item.nodes.length) render(item.nodes, _context);
421
+ });
422
+ }
423
+ render(data, context);
424
+ }
425
+ function writeMetadata(data, context) {
426
+ Object.entries(data).forEach(([, v]) => {
427
+ if (isPlainObject(v)) write.call(context, [[`${v.term}: ${v.value}`]], context);
428
+ });
429
+ }
430
+ function writeConfig(data, context, indent = 0) {
431
+ const indent_ = INDENTATION.repeat(indent);
432
+ Object.entries(data).forEach(([k, v]) => {
433
+ if (typeof v === "string") write.call(context, [[`${indent_}${k}: ${v}`]], context);
434
+ if (isPlainObject(v)) {
435
+ write.call(context, [[`${indent_}${k}`]], context);
436
+ writeConfig(v, context, indent + 1);
437
+ }
438
+ });
439
+ }
440
+ function printSummary({ state, formattedStartDate, formattedEndDate, sequenceEnd }) {
441
+ this.newLine();
442
+ write.call(this, [["Stats", "blueBright"]], this);
443
+ write.call(this, [["Build Start:"], [formattedStartDate]], this);
444
+ write.call(this, [["Build End:"], [formattedEndDate]], this);
445
+ write.call(this, [["Elapsed:"], [sequenceEnd]], this);
446
+ this.newLine();
447
+ write.call(this, [["Configuration", "blueBright"]], this);
448
+ writeConfig(state.config, this);
449
+ this.newLine();
450
+ write.call(this, [["Metadata", "blueBright"]], this);
451
+ writeMetadata(state.metadata.json(), this);
452
+ this.newLine();
453
+ write.call(this, [["Navigation", "blueBright"]], this);
454
+ printNavigation(state.toc, this);
455
+ }
456
+ //#endregion
457
+ //#region src/trace.ts
458
+ function trace() {}
459
+ //#endregion
460
+ //#region src/warn.ts
461
+ function warn(...args) {
462
+ if (this.logLevel < 2) return;
463
+ let message;
464
+ message = this.composeMessage(args);
465
+ message = args[0] instanceof Error ? this.composeMessage([args[0].message]) : this.composeMessage(args);
466
+ const { stack } = /* @__PURE__ */ new Error();
467
+ let prefix = "";
468
+ if (this.logLevel > 2) {
469
+ prefix += this.decorate(`[${(/* @__PURE__ */ new Date()).toISOString()}]`, "gray");
470
+ prefix += " ";
471
+ }
472
+ prefix += this.decorate("b-ber", "whiteBright", "bgBlack");
473
+ prefix += " ";
474
+ prefix += this.decorate("WARN", "black", "bgYellowBright");
475
+ const formatted = util.default.format.apply(util.default, [
476
+ "%s %s",
477
+ prefix,
478
+ message
479
+ ]);
480
+ this.taskWarnings += 1;
481
+ this.warnings.push({
482
+ stack,
483
+ message,
484
+ formatted
485
+ });
486
+ process.stdout.write(formatted);
487
+ this.newLine();
488
+ if (this.logLevel > 3) {
489
+ process.stdout.write(util.default.format.call(util.default, stack.replace(/^Error\s+/, "Warning ")));
490
+ this.newLine();
491
+ if (this.logLevel > 4) this.newLine();
492
+ }
493
+ }
494
+ const log = new class Logger extends Timer {
495
+ static defaults = {
496
+ logLevel: 2,
497
+ boringOutput: false,
498
+ summary: false,
499
+ command: null,
500
+ consoleWidth: 70,
501
+ errors: [],
502
+ warnings: [],
503
+ taskWarnings: 0,
504
+ taskErrors: 0,
505
+ whitespace: " ",
506
+ increment: 0,
507
+ indentLevel: 0,
508
+ taskCounter: -1,
509
+ context: null
510
+ };
511
+ logLevel;
512
+ boringOutput;
513
+ command;
514
+ consoleWidth;
515
+ errors;
516
+ warnings;
517
+ taskWarnings;
518
+ taskErrors;
519
+ whitespace;
520
+ increment;
521
+ indentLevel;
522
+ taskCounter;
523
+ context;
524
+ summary;
525
+ task;
526
+ settings;
527
+ printWarnings;
528
+ printErrors;
529
+ indent;
530
+ incrementIndent;
531
+ decrementIndent;
532
+ incrementCounter;
533
+ decrementCounter;
534
+ bind;
535
+ notify;
536
+ warn;
537
+ info;
538
+ error;
539
+ debug;
540
+ trace;
541
+ notice;
542
+ inspect;
543
+ printSummary;
544
+ configure;
545
+ printVersion;
546
+ registerSequence;
547
+ wrap;
548
+ decorate;
549
+ floatFormat;
550
+ counter;
551
+ getContext;
552
+ composeMessage;
553
+ reset;
554
+ constructor() {
555
+ super();
556
+ this.logLevel = Logger.defaults.logLevel;
557
+ this.boringOutput = Logger.defaults.boringOutput;
558
+ this.command = Logger.defaults.command;
559
+ this.consoleWidth = Logger.defaults.consoleWidth;
560
+ this.errors = [];
561
+ this.warnings = [];
562
+ this.taskWarnings = Logger.defaults.taskWarnings;
563
+ this.taskErrors = Logger.defaults.taskErrors;
564
+ this.whitespace = Logger.defaults.whitespace;
565
+ this.increment = Logger.defaults.increment;
566
+ this.indentLevel = Logger.defaults.indentLevel;
567
+ this.taskCounter = Logger.defaults.taskCounter;
568
+ this.context = Logger.defaults.context;
569
+ this.settings = {
570
+ quiet: false,
571
+ verbose: false,
572
+ debug: false,
573
+ summary: Logger.defaults.summary,
574
+ "no-color": Logger.defaults.boringOutput,
575
+ "log-level": Logger.defaults.logLevel
576
+ };
577
+ this.printWarnings = printWarnings.bind(this);
578
+ this.printErrors = printErrors.bind(this);
579
+ this.indent = indent.bind(this);
580
+ this.incrementIndent = incrementIndent.bind(this);
581
+ this.decrementIndent = decrementIndent.bind(this);
582
+ this.incrementCounter = incrementCounter.bind(this);
583
+ this.decrementCounter = decrementCounter.bind(this);
584
+ this.bind = bind.bind(this);
585
+ this.notify = notify.bind(this);
586
+ this.warn = warn.bind(this);
587
+ this.info = info.bind(this);
588
+ this.error = error.bind(this);
589
+ this.debug = debug.bind(this);
590
+ this.trace = trace.bind(this);
591
+ this.notice = notice.bind(this);
592
+ this.inspect = inspect.bind(this);
593
+ this.printSummary = printSummary.bind(this);
594
+ this.configure = configure.bind(this);
595
+ this.printVersion = printVersion.bind(this);
596
+ this.registerSequence = registerSequence.bind(this);
597
+ this.wrap = wrap.bind(this);
598
+ this.decorate = decorate.bind(this);
599
+ this.floatFormat = floatFormat.bind(this);
600
+ this.counter = counter.bind(this);
601
+ this.getContext = getContext.bind(this);
602
+ this.composeMessage = composeMessage.bind(this);
603
+ this.reset = reset.bind(this);
604
+ const argv = process.argv.reduce((acc, curr) => {
605
+ const [k, v] = curr.split("=");
606
+ acc[k] = v === void 0 ? true : !Number.isNaN(Number(v)) ? Number(v) : v;
607
+ return acc;
608
+ }, {});
609
+ Object.keys(this.settings).forEach((a) => {
610
+ const opt = `--${a}`;
611
+ if (Object.hasOwn(argv, opt)) this.settings[a] = argv[opt];
612
+ });
613
+ this.configure();
614
+ this.bind();
615
+ }
616
+ newLine() {
617
+ process.stdout.write("\n");
618
+ }
619
+ }();
620
+ //#endregion
621
+ module.exports = log;