@sprucelabs/spruce-skill-utils 33.2.0 → 33.4.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.
@@ -7,15 +7,16 @@ export declare class Logger implements Log {
7
7
  private readonly colors;
8
8
  private readonly pre;
9
9
  private readonly shouldUseColors;
10
- private history;
11
- private historyLimit;
10
+ private static history;
11
+ private static historyLimit;
12
12
  constructor(prefix?: string | undefined, options?: LogOptions);
13
- startTrackingHistory(limit: number): void;
14
13
  info(...args: LoggableType[]): string;
15
14
  warn(...args: LoggableType[]): string;
16
15
  error(...args: LoggableType[]): string;
17
16
  buildLog(prefix?: string | undefined, options?: LogOptions): Log;
18
- getHistory(): string[];
17
+ private get history();
18
+ private get historyLimit();
19
+ static getHistory(): string[];
19
20
  private write;
20
21
  private shouldLog;
21
22
  private resolveChalk;
@@ -39,6 +40,10 @@ export declare class Logger implements Log {
39
40
  private get shouldLogTime();
40
41
  private formatArg;
41
42
  protected isMainModule(): boolean;
43
+ static startTrackingHistory(limit: number): void;
44
+ static stopTrackingHistory(): void;
45
+ static getIsTrackingHistory(): boolean;
46
+ static getHistoryLimit(): number;
42
47
  }
43
48
  export default function buildLog(prefix?: string | undefined, options?: LogOptions): Log;
44
49
  export declare const testLog: Log;
@@ -58,8 +63,6 @@ export type LoggableType = Anything | Anything[] | Record<string, Anything>;
58
63
  export type LogTransport = (...messageParts: string[]) => void;
59
64
  type TransportMap = Record<Level, LogTransport | LogTransport[] | null | undefined>;
60
65
  export interface Log {
61
- startTrackingHistory(limit: number): void;
62
- getHistory(): string[];
63
66
  readonly prefix: string | undefined;
64
67
  info: (...args: LoggableType[]) => string;
65
68
  error: (...args: LoggableType[]) => string;
@@ -2,8 +2,6 @@ import chalk from 'chalk';
2
2
  export class Logger {
3
3
  constructor(prefix = undefined, options) {
4
4
  var _a, _b, _c;
5
- this.history = [];
6
- this.historyLimit = 0;
7
5
  const { colors = {}, log, useColors, transportsByLevel } = options !== null && options !== void 0 ? options : {};
8
6
  const { info = 'yellow', error = 'red' } = colors;
9
7
  this.prefix = prefix;
@@ -19,9 +17,6 @@ export class Logger {
19
17
  const isInteractive = (_c = (_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.stdout) === null || _b === void 0 ? void 0 : _b.isTTY) !== null && _c !== void 0 ? _c : false;
20
18
  this.shouldUseColors = useColors !== false && isInteractive;
21
19
  }
22
- startTrackingHistory(limit) {
23
- this.historyLimit = limit;
24
- }
25
20
  info(...args) {
26
21
  return this.write(this.resolveChalk('green', this.colors.info), args, 'INFO');
27
22
  }
@@ -35,7 +30,13 @@ export class Logger {
35
30
  const childPrefix = this.combinePrefixes(prefix);
36
31
  return new Logger(childPrefix, Object.assign({ log: this.baseLog, useColors: this.useColorsOption, transportsByLevel: this.transports }, options));
37
32
  }
38
- getHistory() {
33
+ get history() {
34
+ return Logger.history;
35
+ }
36
+ get historyLimit() {
37
+ return Logger.historyLimit;
38
+ }
39
+ static getHistory() {
39
40
  return this.history;
40
41
  }
41
42
  write(chalkMethod, rawArgs, level) {
@@ -234,7 +235,21 @@ export class Logger {
234
235
  isMainModule() {
235
236
  return true;
236
237
  }
238
+ static startTrackingHistory(limit) {
239
+ this.historyLimit = limit;
240
+ }
241
+ static stopTrackingHistory() {
242
+ this.historyLimit = 0;
243
+ }
244
+ static getIsTrackingHistory() {
245
+ return this.historyLimit > 0;
246
+ }
247
+ static getHistoryLimit() {
248
+ return this.historyLimit;
249
+ }
237
250
  }
251
+ Logger.history = [];
252
+ Logger.historyLimit = 0;
238
253
  export default function buildLog(prefix = undefined, options) {
239
254
  return new Logger(prefix, options);
240
255
  }
@@ -7,15 +7,16 @@ export declare class Logger implements Log {
7
7
  private readonly colors;
8
8
  private readonly pre;
9
9
  private readonly shouldUseColors;
10
- private history;
11
- private historyLimit;
10
+ private static history;
11
+ private static historyLimit;
12
12
  constructor(prefix?: string | undefined, options?: LogOptions);
13
- startTrackingHistory(limit: number): void;
14
13
  info(...args: LoggableType[]): string;
15
14
  warn(...args: LoggableType[]): string;
16
15
  error(...args: LoggableType[]): string;
17
16
  buildLog(prefix?: string | undefined, options?: LogOptions): Log;
18
- getHistory(): string[];
17
+ private get history();
18
+ private get historyLimit();
19
+ static getHistory(): string[];
19
20
  private write;
20
21
  private shouldLog;
21
22
  private resolveChalk;
@@ -39,6 +40,10 @@ export declare class Logger implements Log {
39
40
  private get shouldLogTime();
40
41
  private formatArg;
41
42
  protected isMainModule(): boolean;
43
+ static startTrackingHistory(limit: number): void;
44
+ static stopTrackingHistory(): void;
45
+ static getIsTrackingHistory(): boolean;
46
+ static getHistoryLimit(): number;
42
47
  }
43
48
  export default function buildLog(prefix?: string | undefined, options?: LogOptions): Log;
44
49
  export declare const testLog: Log;
@@ -58,8 +63,6 @@ export type LoggableType = Anything | Anything[] | Record<string, Anything>;
58
63
  export type LogTransport = (...messageParts: string[]) => void;
59
64
  type TransportMap = Record<Level, LogTransport | LogTransport[] | null | undefined>;
60
65
  export interface Log {
61
- startTrackingHistory(limit: number): void;
62
- getHistory(): string[];
63
66
  readonly prefix: string | undefined;
64
67
  info: (...args: LoggableType[]) => string;
65
68
  error: (...args: LoggableType[]) => string;
@@ -8,8 +8,6 @@ exports.default = buildLog;
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  class Logger {
10
10
  constructor(prefix = undefined, options) {
11
- this.history = [];
12
- this.historyLimit = 0;
13
11
  const { colors = {}, log, useColors, transportsByLevel } = options ?? {};
14
12
  const { info = 'yellow', error = 'red' } = colors;
15
13
  this.prefix = prefix;
@@ -25,9 +23,6 @@ class Logger {
25
23
  const isInteractive = getProcess()?.stdout?.isTTY ?? false;
26
24
  this.shouldUseColors = useColors !== false && isInteractive;
27
25
  }
28
- startTrackingHistory(limit) {
29
- this.historyLimit = limit;
30
- }
31
26
  info(...args) {
32
27
  return this.write(this.resolveChalk('green', this.colors.info), args, 'INFO');
33
28
  }
@@ -46,7 +41,13 @@ class Logger {
46
41
  ...options,
47
42
  });
48
43
  }
49
- getHistory() {
44
+ get history() {
45
+ return Logger.history;
46
+ }
47
+ get historyLimit() {
48
+ return Logger.historyLimit;
49
+ }
50
+ static getHistory() {
50
51
  return this.history;
51
52
  }
52
53
  write(chalkMethod, rawArgs, level) {
@@ -241,8 +242,22 @@ class Logger {
241
242
  isMainModule() {
242
243
  return true;
243
244
  }
245
+ static startTrackingHistory(limit) {
246
+ this.historyLimit = limit;
247
+ }
248
+ static stopTrackingHistory() {
249
+ this.historyLimit = 0;
250
+ }
251
+ static getIsTrackingHistory() {
252
+ return this.historyLimit > 0;
253
+ }
254
+ static getHistoryLimit() {
255
+ return this.historyLimit;
256
+ }
244
257
  }
245
258
  exports.Logger = Logger;
259
+ Logger.history = [];
260
+ Logger.historyLimit = 0;
246
261
  function buildLog(prefix = undefined, options) {
247
262
  return new Logger(prefix, options);
248
263
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "33.2.0",
6
+ "version": "33.4.0",
7
7
  "skill": {
8
8
  "namespace": "skill-utils",
9
9
  "upgradeIgnoreList": [
@@ -19,6 +19,18 @@
19
19
  "types": "./build/index.d.ts",
20
20
  "module": "./build/esm/index.js",
21
21
  "sideEffects": false,
22
+ "exports": {
23
+ ".": {
24
+ "import": {
25
+ "types": "./build/esm/index.d.ts",
26
+ "default": "./build/esm/index.js"
27
+ },
28
+ "require": {
29
+ "types": "./build/index.d.ts",
30
+ "default": "./build/index.js"
31
+ }
32
+ }
33
+ },
22
34
  "license": "MIT",
23
35
  "description": "Loosely coupled classes and functions to make skill development faster! 🏎",
24
36
  "keywords": [