@adaptic/utils 0.0.901 → 0.0.903
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.cjs +83 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +72 -28
- package/dist/index.mjs.map +1 -1
- package/dist/test.js +56 -12
- package/dist/test.js.map +1 -1
- package/dist/types/display-manager.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -14,33 +14,12 @@ var require$$0$3 = require('stream');
|
|
|
14
14
|
var require$$7 = require('url');
|
|
15
15
|
var require$$0$1 = require('zlib');
|
|
16
16
|
var require$$0$2 = require('buffer');
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var path = require('path');
|
|
17
|
+
var require$$0$5 = require('fs');
|
|
18
|
+
var require$$1$2 = require('path');
|
|
20
19
|
var require$$4$1 = require('assert');
|
|
21
|
-
var require$$1$
|
|
22
|
-
var require$$1$
|
|
23
|
-
var require$$0$
|
|
24
|
-
|
|
25
|
-
function _interopNamespaceDefault(e) {
|
|
26
|
-
var n = Object.create(null);
|
|
27
|
-
if (e) {
|
|
28
|
-
Object.keys(e).forEach(function (k) {
|
|
29
|
-
if (k !== 'default') {
|
|
30
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
31
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () { return e[k]; }
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
n.default = e;
|
|
39
|
-
return Object.freeze(n);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
43
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
20
|
+
var require$$1$3 = require('tty');
|
|
21
|
+
var require$$1$4 = require('util');
|
|
22
|
+
var require$$0$6 = require('os');
|
|
44
23
|
|
|
45
24
|
/**
|
|
46
25
|
* Configurable logger interface compatible with Pino and other logging libraries.
|
|
@@ -12156,6 +12135,33 @@ Object.defineProperties(createChalk.prototype, styles);
|
|
|
12156
12135
|
const chalk = createChalk();
|
|
12157
12136
|
createChalk({level: stderrColor ? stderrColor.level : 0});
|
|
12158
12137
|
|
|
12138
|
+
// Detect whether we are running in a Node.js environment with a real stdout.
|
|
12139
|
+
// In browsers (or environments without process.stdout) all terminal / fs
|
|
12140
|
+
// operations become no-ops so the library can be safely imported client-side.
|
|
12141
|
+
const isNode = typeof process !== "undefined" &&
|
|
12142
|
+
typeof process.stdout !== "undefined" &&
|
|
12143
|
+
typeof process.stdout.write === "function";
|
|
12144
|
+
// Lazy-load Node-only dependencies so bundlers can tree-shake / stub them.
|
|
12145
|
+
// chalk is kept as a static import (ESM-only in v5) — Rollup handles it.
|
|
12146
|
+
// readline, fs, and path are loaded at runtime only in Node.
|
|
12147
|
+
let clearLine;
|
|
12148
|
+
let cursorTo;
|
|
12149
|
+
let fs;
|
|
12150
|
+
let path;
|
|
12151
|
+
if (isNode) {
|
|
12152
|
+
try {
|
|
12153
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
12154
|
+
const readline = require("readline");
|
|
12155
|
+
clearLine = readline.clearLine;
|
|
12156
|
+
cursorTo = readline.cursorTo;
|
|
12157
|
+
fs = require("fs");
|
|
12158
|
+
path = require("path");
|
|
12159
|
+
/* eslint-enable @typescript-eslint/no-require-imports */
|
|
12160
|
+
}
|
|
12161
|
+
catch {
|
|
12162
|
+
// Silently degrade — all operations will be no-ops.
|
|
12163
|
+
}
|
|
12164
|
+
}
|
|
12159
12165
|
class DisplayManager {
|
|
12160
12166
|
static instance;
|
|
12161
12167
|
promptText = "";
|
|
@@ -12173,9 +12179,19 @@ class DisplayManager {
|
|
|
12173
12179
|
* Logs a message while preserving the prompt at the bottom
|
|
12174
12180
|
*/
|
|
12175
12181
|
log(message, options) {
|
|
12182
|
+
if (!isNode) {
|
|
12183
|
+
// In browser environments, fall back to console
|
|
12184
|
+
const level = options?.type === "error"
|
|
12185
|
+
? "error"
|
|
12186
|
+
: options?.type === "warn"
|
|
12187
|
+
? "warn"
|
|
12188
|
+
: "log";
|
|
12189
|
+
console[level](message);
|
|
12190
|
+
return;
|
|
12191
|
+
}
|
|
12176
12192
|
// Clear the current prompt line
|
|
12177
|
-
|
|
12178
|
-
|
|
12193
|
+
clearLine?.(process.stdout, 0);
|
|
12194
|
+
cursorTo?.(process.stdout, 0);
|
|
12179
12195
|
// Format the timestamp
|
|
12180
12196
|
const date = new Date();
|
|
12181
12197
|
const timestamp = date.toLocaleString("en-US", {
|
|
@@ -12186,11 +12202,13 @@ class DisplayManager {
|
|
|
12186
12202
|
// Build the log message
|
|
12187
12203
|
let logMessage = `[${timestamp}]${options?.source ? ` [${options.source}] ` : ""}${account ? ` [${account}] ` : ""}${symbol ? ` [${symbol}] ` : ""}${message}`;
|
|
12188
12204
|
// Add color based on type
|
|
12189
|
-
if (
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12205
|
+
if (chalk) {
|
|
12206
|
+
if (options?.type === "error") {
|
|
12207
|
+
logMessage = chalk.red(logMessage);
|
|
12208
|
+
}
|
|
12209
|
+
else if (options?.type === "warn") {
|
|
12210
|
+
logMessage = chalk.yellow(logMessage);
|
|
12211
|
+
}
|
|
12194
12212
|
}
|
|
12195
12213
|
// Write the log message
|
|
12196
12214
|
process.stdout.write(logMessage + "\n");
|
|
@@ -12210,10 +12228,12 @@ class DisplayManager {
|
|
|
12210
12228
|
* Writes a log entry to a symbol-specific log file
|
|
12211
12229
|
*/
|
|
12212
12230
|
writeSymbolLog(symbol, date, logMessage, options) {
|
|
12231
|
+
if (!fs || !path)
|
|
12232
|
+
return;
|
|
12213
12233
|
try {
|
|
12214
12234
|
// Create logs directory if it doesn't exist
|
|
12215
|
-
if (!
|
|
12216
|
-
|
|
12235
|
+
if (!fs.existsSync("logs")) {
|
|
12236
|
+
fs.mkdirSync("logs", { recursive: true });
|
|
12217
12237
|
}
|
|
12218
12238
|
// Format date for filename: YYYY-MM-DD
|
|
12219
12239
|
const year = date.getFullYear();
|
|
@@ -12221,11 +12241,11 @@ class DisplayManager {
|
|
|
12221
12241
|
const day = String(date.getDate()).padStart(2, "0");
|
|
12222
12242
|
// Create filename: SYM-YYYY-MM-DD.log
|
|
12223
12243
|
const filename = `${symbol}-${year}-${month}-${day}.log`;
|
|
12224
|
-
const filePath =
|
|
12244
|
+
const filePath = path.join("logs", filename);
|
|
12225
12245
|
// Strip ANSI color codes from log message
|
|
12226
12246
|
const plainLogMessage = logMessage.replace(/\x1B\[\d+m/g, "");
|
|
12227
12247
|
// Write to file (append if exists, create if not)
|
|
12228
|
-
|
|
12248
|
+
fs.appendFileSync(filePath, plainLogMessage + "\n");
|
|
12229
12249
|
}
|
|
12230
12250
|
catch (error) {
|
|
12231
12251
|
// Only log to console - don't try to log to file again to avoid potential infinite loop
|
|
@@ -12236,10 +12256,12 @@ class DisplayManager {
|
|
|
12236
12256
|
* Writes a log entry to a generic log file when no symbol is provided
|
|
12237
12257
|
*/
|
|
12238
12258
|
writeGenericLog(date, logMessage, options) {
|
|
12259
|
+
if (!fs || !path)
|
|
12260
|
+
return;
|
|
12239
12261
|
try {
|
|
12240
12262
|
// Create logs directory if it doesn't exist
|
|
12241
|
-
if (!
|
|
12242
|
-
|
|
12263
|
+
if (!fs.existsSync("logs")) {
|
|
12264
|
+
fs.mkdirSync("logs", { recursive: true });
|
|
12243
12265
|
}
|
|
12244
12266
|
// Format date for filename: YYYY-MM-DD
|
|
12245
12267
|
const year = date.getFullYear();
|
|
@@ -12248,11 +12270,11 @@ class DisplayManager {
|
|
|
12248
12270
|
// Create filename: system-YYYY-MM-DD.log
|
|
12249
12271
|
const source = options?.source?.toLowerCase().replace(/\s+/g, "-") || "system";
|
|
12250
12272
|
const filename = `${source}-${year}-${month}-${day}.log`;
|
|
12251
|
-
const filePath =
|
|
12273
|
+
const filePath = path.join("logs", filename);
|
|
12252
12274
|
// Strip ANSI color codes from log message
|
|
12253
12275
|
const plainLogMessage = logMessage.replace(/\x1B\[\d+m/g, "");
|
|
12254
12276
|
// Write to file (append if exists, create if not)
|
|
12255
|
-
|
|
12277
|
+
fs.appendFileSync(filePath, plainLogMessage + "\n");
|
|
12256
12278
|
}
|
|
12257
12279
|
catch (error) {
|
|
12258
12280
|
// Only log to console - don't try to log to file again to avoid potential infinite loop
|
|
@@ -12260,11 +12282,15 @@ class DisplayManager {
|
|
|
12260
12282
|
}
|
|
12261
12283
|
}
|
|
12262
12284
|
writePrompt() {
|
|
12285
|
+
if (!isNode)
|
|
12286
|
+
return;
|
|
12263
12287
|
process.stdout.write(this.promptText);
|
|
12264
12288
|
}
|
|
12265
12289
|
clearPrompt() {
|
|
12266
|
-
|
|
12267
|
-
|
|
12290
|
+
if (!isNode)
|
|
12291
|
+
return;
|
|
12292
|
+
clearLine?.(process.stdout, 0);
|
|
12293
|
+
cursorTo?.(process.stdout, 0);
|
|
12268
12294
|
}
|
|
12269
12295
|
restorePrompt() {
|
|
12270
12296
|
this.writePrompt();
|
|
@@ -15237,8 +15263,8 @@ function requireMain () {
|
|
|
15237
15263
|
|
|
15238
15264
|
*/
|
|
15239
15265
|
|
|
15240
|
-
const fs
|
|
15241
|
-
const path
|
|
15266
|
+
const fs = require$$0$5;
|
|
15267
|
+
const path = require$$1$2;
|
|
15242
15268
|
|
|
15243
15269
|
function log (message /*: string */) {
|
|
15244
15270
|
console.log(`[dotenv][DEBUG] ${message}`);
|
|
@@ -15280,7 +15306,7 @@ function requireMain () {
|
|
|
15280
15306
|
|
|
15281
15307
|
// Populates process.env from .env file
|
|
15282
15308
|
function config (options /*: ?DotenvConfigOptions */) /*: DotenvConfigOutput */ {
|
|
15283
|
-
let dotenvPath = path
|
|
15309
|
+
let dotenvPath = path.resolve(process.cwd(), '.env');
|
|
15284
15310
|
let encoding /*: string */ = 'utf8';
|
|
15285
15311
|
let debug = false;
|
|
15286
15312
|
|
|
@@ -15298,7 +15324,7 @@ function requireMain () {
|
|
|
15298
15324
|
|
|
15299
15325
|
try {
|
|
15300
15326
|
// specifying an encoding returns a string instead of a buffer
|
|
15301
|
-
const parsed = parse(fs
|
|
15327
|
+
const parsed = parse(fs.readFileSync(dotenvPath, { encoding }), { debug });
|
|
15302
15328
|
|
|
15303
15329
|
Object.keys(parsed).forEach(function (key) {
|
|
15304
15330
|
if (!process.env.hasOwnProperty(key)) {
|
|
@@ -17046,8 +17072,8 @@ var hasRequiredSupportsColor;
|
|
|
17046
17072
|
function requireSupportsColor () {
|
|
17047
17073
|
if (hasRequiredSupportsColor) return supportsColor_1;
|
|
17048
17074
|
hasRequiredSupportsColor = 1;
|
|
17049
|
-
const os = require$$0$
|
|
17050
|
-
const tty = require$$1$
|
|
17075
|
+
const os = require$$0$6;
|
|
17076
|
+
const tty = require$$1$3;
|
|
17051
17077
|
const hasFlag = requireHasFlag();
|
|
17052
17078
|
|
|
17053
17079
|
const {env} = process;
|
|
@@ -17193,8 +17219,8 @@ function requireNode$1 () {
|
|
|
17193
17219
|
if (hasRequiredNode$1) return node$1.exports;
|
|
17194
17220
|
hasRequiredNode$1 = 1;
|
|
17195
17221
|
(function (module, exports$1) {
|
|
17196
|
-
const tty = require$$1$
|
|
17197
|
-
const util = require$$1$
|
|
17222
|
+
const tty = require$$1$3;
|
|
17223
|
+
const util = require$$1$4;
|
|
17198
17224
|
|
|
17199
17225
|
/**
|
|
17200
17226
|
* This is the Node.js implementation of `debug()`.
|
|
@@ -19540,7 +19566,7 @@ function requireUrljoin () {
|
|
|
19540
19566
|
|
|
19541
19567
|
var extend = requireExtend();
|
|
19542
19568
|
var url = require$$7;
|
|
19543
|
-
var path
|
|
19569
|
+
var path = require$$1$2;
|
|
19544
19570
|
|
|
19545
19571
|
/**
|
|
19546
19572
|
* Join two or more url pieces into one.
|
|
@@ -19585,7 +19611,7 @@ function requireUrljoin () {
|
|
|
19585
19611
|
|
|
19586
19612
|
delete first.search; //we use query instead of search
|
|
19587
19613
|
first.query = query;
|
|
19588
|
-
first.pathname = path
|
|
19614
|
+
first.pathname = path.join.apply(path, paths).replace(new RegExp('\\' + path.sep, 'g'), '/');
|
|
19589
19615
|
return url.format(first);
|
|
19590
19616
|
};
|
|
19591
19617
|
return urljoin;
|
|
@@ -47179,7 +47205,7 @@ function requireBuffer_list () {
|
|
|
47179
47205
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (String )(input); }
|
|
47180
47206
|
var _require = require$$0$2,
|
|
47181
47207
|
Buffer = _require.Buffer;
|
|
47182
|
-
var _require2 = require$$1$
|
|
47208
|
+
var _require2 = require$$1$4,
|
|
47183
47209
|
inspect = _require2.inspect;
|
|
47184
47210
|
var custom = inspect && inspect.custom || 'inspect';
|
|
47185
47211
|
function copyBuffer(src, target, offset) {
|
|
@@ -47678,7 +47704,7 @@ function requireNode () {
|
|
|
47678
47704
|
* For Node.js, simply re-export the core `util.deprecate` function.
|
|
47679
47705
|
*/
|
|
47680
47706
|
|
|
47681
|
-
node = require$$1$
|
|
47707
|
+
node = require$$1$4.deprecate;
|
|
47682
47708
|
return node;
|
|
47683
47709
|
}
|
|
47684
47710
|
|
|
@@ -49064,7 +49090,7 @@ function require_stream_readable () {
|
|
|
49064
49090
|
}
|
|
49065
49091
|
|
|
49066
49092
|
/*<replacement>*/
|
|
49067
|
-
var debugUtil = require$$1$
|
|
49093
|
+
var debugUtil = require$$1$4;
|
|
49068
49094
|
var debug;
|
|
49069
49095
|
if (debugUtil && debugUtil.debuglog) {
|
|
49070
49096
|
debug = debugUtil.debuglog('stream');
|
|
@@ -50916,7 +50942,7 @@ function requireHelpers () {
|
|
|
50916
50942
|
if (hasRequiredHelpers) return helpers;
|
|
50917
50943
|
hasRequiredHelpers = 1;
|
|
50918
50944
|
|
|
50919
|
-
const util = require$$1$
|
|
50945
|
+
const util = require$$1$4;
|
|
50920
50946
|
|
|
50921
50947
|
helpers.IncompleteBufferError = IncompleteBufferError;
|
|
50922
50948
|
|