@drisp/cli 0.4.4 → 0.4.7

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.
@@ -1,115 +1,20 @@
1
1
  import {
2
- acquirePidLock,
3
2
  ensureDaemonStateDir,
4
3
  runDashboardRuntimeDaemon,
5
4
  startUdsServer
6
- } from "./chunk-JAPBSL7D.js";
5
+ } from "./chunk-TQKNZNDP.js";
7
6
  import "./chunk-BTKQ67RE.js";
7
+ import {
8
+ openDaemonLog
9
+ } from "./chunk-2OJ3GGIP.js";
10
+ import {
11
+ acquirePidLock
12
+ } from "./chunk-ZVOGOZNT.js";
8
13
  import {
9
14
  readDashboardClientConfig,
10
15
  refreshDashboardAccessToken
11
- } from "./chunk-4CRZXLIP.js";
12
- import "./chunk-5VK2ZMVV.js";
13
-
14
- // src/infra/daemon/logFile.ts
15
- import fs from "fs";
16
- import path from "path";
17
- var DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
18
- var DEFAULT_MAX_FILES = 5;
19
- function openDaemonLog(logPath, options = {}) {
20
- const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
21
- const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
22
- const now = options.now ?? (() => /* @__PURE__ */ new Date());
23
- fs.mkdirSync(path.dirname(logPath), { recursive: true, mode: 448 });
24
- let fd = fs.openSync(logPath, "a", 384);
25
- if (process.platform !== "win32") {
26
- try {
27
- fs.chmodSync(logPath, 384);
28
- } catch {
29
- }
30
- }
31
- function rotate() {
32
- try {
33
- fs.closeSync(fd);
34
- } catch {
35
- }
36
- for (let i = maxFiles - 1; i >= 1; i -= 1) {
37
- const src = `${logPath}.${i}`;
38
- const dst = `${logPath}.${i + 1}`;
39
- try {
40
- fs.renameSync(src, dst);
41
- } catch (err) {
42
- if (err.code !== "ENOENT") {
43
- }
44
- }
45
- }
46
- try {
47
- fs.renameSync(logPath, `${logPath}.1`);
48
- } catch (err) {
49
- if (err.code !== "ENOENT") {
50
- }
51
- }
52
- fd = fs.openSync(logPath, "a", 384);
53
- if (process.platform !== "win32") {
54
- try {
55
- fs.chmodSync(logPath, 384);
56
- } catch {
57
- }
58
- }
59
- }
60
- function write(level, message) {
61
- const line = `${now().toISOString()} ${level.toUpperCase()} ${redactSecrets(message)}
62
- `;
63
- const buf = Buffer.from(line, "utf-8");
64
- let stat = null;
65
- try {
66
- stat = fs.fstatSync(fd);
67
- } catch {
68
- }
69
- if (stat && stat.size + buf.length > maxBytes) {
70
- rotate();
71
- }
72
- try {
73
- fs.writeSync(fd, buf);
74
- } catch {
75
- try {
76
- fs.closeSync(fd);
77
- } catch {
78
- }
79
- try {
80
- fd = fs.openSync(logPath, "a", 384);
81
- fs.writeSync(fd, buf);
82
- } catch {
83
- }
84
- }
85
- }
86
- function close() {
87
- try {
88
- fs.closeSync(fd);
89
- } catch {
90
- }
91
- }
92
- return { write, close, path: logPath };
93
- }
94
- var SECRET_PATTERNS = [
95
- [/Bearer\s+[A-Za-z0-9._\-+/=]+/g, "Bearer ***"],
96
- [
97
- /(["']?(?:access|refresh)_?token["']?\s*[:=]\s*)["']?[A-Za-z0-9._\-+/=]+/gi,
98
- '$1"***"'
99
- ],
100
- [/(Sec-WebSocket-Protocol:\s*)\S+/gi, "$1***"],
101
- [
102
- /eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}/g,
103
- "***.***.***"
104
- ]
105
- ];
106
- function redactSecrets(message) {
107
- let out = message;
108
- for (const [pattern, replacement] of SECRET_PATTERNS) {
109
- out = out.replace(pattern, replacement);
110
- }
111
- return out;
112
- }
16
+ } from "./chunk-WRHKXH5M.js";
17
+ import "./chunk-A54HGVML.js";
113
18
 
114
19
  // src/app/entry/dashboardDaemon.ts
115
20
  async function runDashboardDaemonEntry() {
@@ -155,9 +60,6 @@ async function runDashboardDaemonEntry() {
155
60
  return 1;
156
61
  }
157
62
  const handler = (req) => {
158
- if (!daemonHandle) {
159
- return { ok: false, error: "daemon shutting down" };
160
- }
161
63
  switch (req.cmd) {
162
64
  case "status": {
163
65
  const snap = daemonHandle.snapshot();