@polka-codes/cli 0.3.2 → 0.3.4
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/README.md +3 -3
- package/cli.mjs +2 -0
- package/dist/index.js +344 -334
- package/dist/pino-file.js +4250 -0
- package/dist/pino-pretty.js +3245 -0
- package/dist/pino-worker.js +4594 -0
- package/dist/thread-stream-worker.js +211 -0
- package/package.json +3 -6
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
3
|
+
var __require = import.meta.require;
|
|
4
|
+
|
|
5
|
+
// node_modules/real-require/src/index.js
|
|
6
|
+
var require_src = __commonJS((exports, module) => {
|
|
7
|
+
var realImport = new Function("modulePath", "return import(modulePath)");
|
|
8
|
+
function realRequire(modulePath) {
|
|
9
|
+
if (typeof __non_webpack__require__ === "function") {
|
|
10
|
+
return __non_webpack__require__(modulePath);
|
|
11
|
+
}
|
|
12
|
+
return __require(modulePath);
|
|
13
|
+
}
|
|
14
|
+
module.exports = { realImport, realRequire };
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// node_modules/thread-stream/lib/indexes.js
|
|
18
|
+
var require_indexes = __commonJS((exports, module) => {
|
|
19
|
+
var WRITE_INDEX = 4;
|
|
20
|
+
var READ_INDEX = 8;
|
|
21
|
+
module.exports = {
|
|
22
|
+
WRITE_INDEX,
|
|
23
|
+
READ_INDEX
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// node_modules/thread-stream/lib/wait.js
|
|
28
|
+
var require_wait = __commonJS((exports, module) => {
|
|
29
|
+
var MAX_TIMEOUT = 1000;
|
|
30
|
+
function wait(state, index, expected, timeout, done) {
|
|
31
|
+
const max = Date.now() + timeout;
|
|
32
|
+
let current = Atomics.load(state, index);
|
|
33
|
+
if (current === expected) {
|
|
34
|
+
done(null, "ok");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let prior = current;
|
|
38
|
+
const check = (backoff) => {
|
|
39
|
+
if (Date.now() > max) {
|
|
40
|
+
done(null, "timed-out");
|
|
41
|
+
} else {
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
prior = current;
|
|
44
|
+
current = Atomics.load(state, index);
|
|
45
|
+
if (current === prior) {
|
|
46
|
+
check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : backoff * 2);
|
|
47
|
+
} else {
|
|
48
|
+
if (current === expected)
|
|
49
|
+
done(null, "ok");
|
|
50
|
+
else
|
|
51
|
+
done(null, "not-equal");
|
|
52
|
+
}
|
|
53
|
+
}, backoff);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
check(1);
|
|
57
|
+
}
|
|
58
|
+
function waitDiff(state, index, expected, timeout, done) {
|
|
59
|
+
const max = Date.now() + timeout;
|
|
60
|
+
let current = Atomics.load(state, index);
|
|
61
|
+
if (current !== expected) {
|
|
62
|
+
done(null, "ok");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const check = (backoff) => {
|
|
66
|
+
if (Date.now() > max) {
|
|
67
|
+
done(null, "timed-out");
|
|
68
|
+
} else {
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
current = Atomics.load(state, index);
|
|
71
|
+
if (current !== expected) {
|
|
72
|
+
done(null, "ok");
|
|
73
|
+
} else {
|
|
74
|
+
check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : backoff * 2);
|
|
75
|
+
}
|
|
76
|
+
}, backoff);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
check(1);
|
|
80
|
+
}
|
|
81
|
+
module.exports = { wait, waitDiff };
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// node_modules/thread-stream/lib/worker.js
|
|
85
|
+
var require_worker = __commonJS(() => {
|
|
86
|
+
var { realImport, realRequire } = require_src();
|
|
87
|
+
var { workerData, parentPort } = __require("worker_threads");
|
|
88
|
+
var { WRITE_INDEX, READ_INDEX } = require_indexes();
|
|
89
|
+
var { waitDiff } = require_wait();
|
|
90
|
+
var {
|
|
91
|
+
dataBuf,
|
|
92
|
+
filename,
|
|
93
|
+
stateBuf
|
|
94
|
+
} = workerData;
|
|
95
|
+
var destination;
|
|
96
|
+
var state = new Int32Array(stateBuf);
|
|
97
|
+
var data = Buffer.from(dataBuf);
|
|
98
|
+
async function start() {
|
|
99
|
+
let worker;
|
|
100
|
+
try {
|
|
101
|
+
if (filename.endsWith(".ts") || filename.endsWith(".cts")) {
|
|
102
|
+
if (!process[Symbol.for("ts-node.register.instance")]) {
|
|
103
|
+
realRequire("ts-node/register");
|
|
104
|
+
} else if (process.env.TS_NODE_DEV) {
|
|
105
|
+
realRequire("ts-node-dev");
|
|
106
|
+
}
|
|
107
|
+
worker = realRequire(decodeURIComponent(filename.replace(process.platform === "win32" ? "file:///" : "file://", "")));
|
|
108
|
+
} else {
|
|
109
|
+
worker = await realImport(filename);
|
|
110
|
+
}
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if ((error.code === "ENOTDIR" || error.code === "ERR_MODULE_NOT_FOUND") && filename.startsWith("file://")) {
|
|
113
|
+
worker = realRequire(decodeURIComponent(filename.replace("file://", "")));
|
|
114
|
+
} else if (error.code === undefined || error.code === "ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING") {
|
|
115
|
+
try {
|
|
116
|
+
worker = realRequire(decodeURIComponent(filename.replace(process.platform === "win32" ? "file:///" : "file://", "")));
|
|
117
|
+
} catch {
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (typeof worker === "object")
|
|
125
|
+
worker = worker.default;
|
|
126
|
+
if (typeof worker === "object")
|
|
127
|
+
worker = worker.default;
|
|
128
|
+
destination = await worker(workerData.workerData);
|
|
129
|
+
destination.on("error", function(err) {
|
|
130
|
+
Atomics.store(state, WRITE_INDEX, -2);
|
|
131
|
+
Atomics.notify(state, WRITE_INDEX);
|
|
132
|
+
Atomics.store(state, READ_INDEX, -2);
|
|
133
|
+
Atomics.notify(state, READ_INDEX);
|
|
134
|
+
parentPort.postMessage({
|
|
135
|
+
code: "ERROR",
|
|
136
|
+
err
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
destination.on("close", function() {
|
|
140
|
+
const end = Atomics.load(state, WRITE_INDEX);
|
|
141
|
+
Atomics.store(state, READ_INDEX, end);
|
|
142
|
+
Atomics.notify(state, READ_INDEX);
|
|
143
|
+
setImmediate(() => {
|
|
144
|
+
process.exit(0);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
start().then(function() {
|
|
149
|
+
parentPort.postMessage({
|
|
150
|
+
code: "READY"
|
|
151
|
+
});
|
|
152
|
+
process.nextTick(run);
|
|
153
|
+
});
|
|
154
|
+
function run() {
|
|
155
|
+
const current = Atomics.load(state, READ_INDEX);
|
|
156
|
+
const end = Atomics.load(state, WRITE_INDEX);
|
|
157
|
+
if (end === current) {
|
|
158
|
+
if (end === data.length) {
|
|
159
|
+
waitDiff(state, READ_INDEX, end, Infinity, run);
|
|
160
|
+
} else {
|
|
161
|
+
waitDiff(state, WRITE_INDEX, end, Infinity, run);
|
|
162
|
+
}
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (end === -1) {
|
|
166
|
+
destination.end();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const toWrite = data.toString("utf8", current, end);
|
|
170
|
+
const res = destination.write(toWrite);
|
|
171
|
+
if (res) {
|
|
172
|
+
Atomics.store(state, READ_INDEX, end);
|
|
173
|
+
Atomics.notify(state, READ_INDEX);
|
|
174
|
+
setImmediate(run);
|
|
175
|
+
} else {
|
|
176
|
+
destination.once("drain", function() {
|
|
177
|
+
Atomics.store(state, READ_INDEX, end);
|
|
178
|
+
Atomics.notify(state, READ_INDEX);
|
|
179
|
+
run();
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
process.on("unhandledRejection", function(err) {
|
|
184
|
+
parentPort.postMessage({
|
|
185
|
+
code: "ERROR",
|
|
186
|
+
err
|
|
187
|
+
});
|
|
188
|
+
process.exit(1);
|
|
189
|
+
});
|
|
190
|
+
process.on("uncaughtException", function(err) {
|
|
191
|
+
parentPort.postMessage({
|
|
192
|
+
code: "ERROR",
|
|
193
|
+
err
|
|
194
|
+
});
|
|
195
|
+
process.exit(1);
|
|
196
|
+
});
|
|
197
|
+
process.once("exit", (exitCode) => {
|
|
198
|
+
if (exitCode !== 0) {
|
|
199
|
+
process.exit(exitCode);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (destination?.writableNeedDrain && !destination?.writableEnded) {
|
|
203
|
+
parentPort.postMessage({
|
|
204
|
+
code: "WARNING",
|
|
205
|
+
err: new Error("ThreadStream: process exited before destination stream was drained. this may indicate that the destination stream try to write to a another missing stream")
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
process.exit(0);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
export default require_worker();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -12,12 +12,9 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "bun build src/index.ts --outdir dist --target node"
|
|
17
|
-
},
|
|
18
15
|
"dependencies": {
|
|
19
16
|
"@inquirer/prompts": "^7.2.3",
|
|
20
|
-
"@polka-codes/core": "0.3.
|
|
17
|
+
"@polka-codes/core": "0.3.3",
|
|
21
18
|
"commander": "^13.0.0",
|
|
22
19
|
"dotenv": "^16.4.7",
|
|
23
20
|
"ignore": "^7.0.3",
|
|
@@ -26,7 +23,7 @@
|
|
|
26
23
|
"yaml": "^2.7.0",
|
|
27
24
|
"zod": "^3.24.1"
|
|
28
25
|
},
|
|
29
|
-
"files": ["dist", "cli.
|
|
26
|
+
"files": ["dist", "cli.mjs"],
|
|
30
27
|
"devDependencies": {
|
|
31
28
|
"@types/lodash": "^4.17.14"
|
|
32
29
|
}
|