bitfab 0.54.0 → 0.54.2
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/{chunk-CLYCJGJE.js → chunk-ELGX3GWC.js} +193 -2
- package/dist/chunk-ELGX3GWC.js.map +1 -0
- package/dist/{chunk-SEHWHFUY.js → chunk-GMHABKGI.js} +194 -2
- package/dist/chunk-GMHABKGI.js.map +1 -0
- package/dist/{chunk-JAXMD6AP.js → chunk-SMNXZVSZ.js} +7 -7
- package/dist/chunk-SMNXZVSZ.js.map +1 -0
- package/dist/{chunk-VQB5RCFD.js → chunk-V6A3A6PF.js} +3 -3
- package/dist/{chunk-O2OJIGL3.js → chunk-YGVEPWC5.js} +3 -103
- package/dist/chunk-YGVEPWC5.js.map +1 -0
- package/dist/{http-RXH2N5BB.js → http-5PXP5N7O.js} +2 -2
- package/dist/{http-G43RIR7E.js → http-JD44RSQN.js} +2 -2
- package/dist/index.cjs +225 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -3
- package/dist/node.cjs +225 -126
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-XQITDIRJ.js → replay-3KZRKPX2.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-CLYCJGJE.js.map +0 -1
- package/dist/chunk-JAXMD6AP.js.map +0 -1
- package/dist/chunk-O2OJIGL3.js.map +0 -1
- package/dist/chunk-SEHWHFUY.js.map +0 -1
- /package/dist/{chunk-VQB5RCFD.js.map → chunk-V6A3A6PF.js.map} +0 -0
- /package/dist/{http-G43RIR7E.js.map → http-5PXP5N7O.js.map} +0 -0
- /package/dist/{http-RXH2N5BB.js.map → http-JD44RSQN.js.map} +0 -0
- /package/dist/{replay-XQITDIRJ.js.map → replay-3KZRKPX2.js.map} +0 -0
|
@@ -94,7 +94,7 @@ function encodeRequestBody(body) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// src/version.generated.ts
|
|
97
|
-
var __version__ = "0.54.
|
|
97
|
+
var __version__ = "0.54.2";
|
|
98
98
|
var __packageName__ = "bitfab";
|
|
99
99
|
|
|
100
100
|
// src/errors.ts
|
|
@@ -108,6 +108,193 @@ var BitfabError = class extends Error {
|
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
// src/gitCommand.ts
|
|
112
|
+
var EXIT_GRACE_MS = 500;
|
|
113
|
+
function isUnrefable(value) {
|
|
114
|
+
return typeof value === "object" && value !== null && "unref" in value && typeof value.unref === "function";
|
|
115
|
+
}
|
|
116
|
+
function unrefStream(stream) {
|
|
117
|
+
if (isUnrefable(stream)) {
|
|
118
|
+
stream.unref();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function terminate(child) {
|
|
122
|
+
if (child.pid && process.platform !== "win32") {
|
|
123
|
+
try {
|
|
124
|
+
process.kill(-child.pid, "SIGTERM");
|
|
125
|
+
return;
|
|
126
|
+
} catch {
|
|
127
|
+
child.kill("SIGTERM");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
child.kill("SIGTERM");
|
|
132
|
+
}
|
|
133
|
+
async function gitRunner(options) {
|
|
134
|
+
let spawn;
|
|
135
|
+
try {
|
|
136
|
+
;
|
|
137
|
+
({ spawn } = await import("child_process"));
|
|
138
|
+
} catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
return (dir, args, env) => new Promise((resolve) => {
|
|
142
|
+
let child;
|
|
143
|
+
try {
|
|
144
|
+
child = spawn("git", args, {
|
|
145
|
+
cwd: dir,
|
|
146
|
+
detached: process.platform !== "win32",
|
|
147
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
148
|
+
...env ? { env: { ...process.env, ...env } } : {}
|
|
149
|
+
});
|
|
150
|
+
} catch {
|
|
151
|
+
resolve(null);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const chunks = [];
|
|
155
|
+
let size = 0;
|
|
156
|
+
let overflow = false;
|
|
157
|
+
let exitCode = null;
|
|
158
|
+
let done = false;
|
|
159
|
+
const timers = [];
|
|
160
|
+
const schedule = (callback, ms) => {
|
|
161
|
+
const timer = setTimeout(callback, ms);
|
|
162
|
+
if (!options.keepProcessAlive) {
|
|
163
|
+
timer.unref();
|
|
164
|
+
}
|
|
165
|
+
timers.push(timer);
|
|
166
|
+
};
|
|
167
|
+
const finish = () => {
|
|
168
|
+
if (done) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
done = true;
|
|
172
|
+
for (const timer of timers) {
|
|
173
|
+
clearTimeout(timer);
|
|
174
|
+
}
|
|
175
|
+
child.stdout?.destroy();
|
|
176
|
+
child.stderr?.destroy();
|
|
177
|
+
resolve(
|
|
178
|
+
exitCode === 0 && !overflow ? Buffer.concat(chunks).toString("utf8") : null
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
child.stdout?.on("data", (chunk) => {
|
|
182
|
+
size += chunk.length;
|
|
183
|
+
if (size > options.maxBuffer) {
|
|
184
|
+
overflow = true;
|
|
185
|
+
terminate(child);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
chunks.push(chunk);
|
|
189
|
+
});
|
|
190
|
+
child.stderr?.resume();
|
|
191
|
+
child.on("error", () => {
|
|
192
|
+
exitCode = null;
|
|
193
|
+
finish();
|
|
194
|
+
});
|
|
195
|
+
child.on("exit", (code) => {
|
|
196
|
+
exitCode = code;
|
|
197
|
+
schedule(finish, EXIT_GRACE_MS);
|
|
198
|
+
});
|
|
199
|
+
child.on("close", (code) => {
|
|
200
|
+
exitCode = code ?? exitCode;
|
|
201
|
+
finish();
|
|
202
|
+
});
|
|
203
|
+
schedule(() => terminate(child), options.timeoutMs);
|
|
204
|
+
if (!options.keepProcessAlive) {
|
|
205
|
+
child.unref();
|
|
206
|
+
unrefStream(child.stdout);
|
|
207
|
+
unrefStream(child.stderr);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/gitState.ts
|
|
213
|
+
var GIT_TIMEOUT_MS = 3e4;
|
|
214
|
+
var GIT_MAX_BUFFER = 1024 * 1024;
|
|
215
|
+
var DISABLE_ENV = "BITFAB_DISABLE_GIT_STATE";
|
|
216
|
+
var SHA_PATTERN = /^[0-9a-f]{40}$/;
|
|
217
|
+
function sha(value) {
|
|
218
|
+
const trimmed = value?.trim();
|
|
219
|
+
return trimmed && SHA_PATTERN.test(trimmed) ? trimmed : null;
|
|
220
|
+
}
|
|
221
|
+
function text(value) {
|
|
222
|
+
const trimmed = value?.trim();
|
|
223
|
+
return trimmed ? trimmed : null;
|
|
224
|
+
}
|
|
225
|
+
function isEmptyGitState(state) {
|
|
226
|
+
return Object.values(state).every((value) => value === null);
|
|
227
|
+
}
|
|
228
|
+
async function resolveGitState(cwd) {
|
|
229
|
+
const git = await gitRunner({
|
|
230
|
+
timeoutMs: GIT_TIMEOUT_MS,
|
|
231
|
+
maxBuffer: GIT_MAX_BUFFER,
|
|
232
|
+
keepProcessAlive: true
|
|
233
|
+
});
|
|
234
|
+
if (!git) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
const run = async (args, env) => (await git(cwd, args, env))?.trim() ?? null;
|
|
238
|
+
const [refs, email, branch] = await Promise.all([
|
|
239
|
+
run(["rev-parse", "--show-toplevel", "HEAD", "HEAD^{tree}"]),
|
|
240
|
+
run(["config", "user.email"]),
|
|
241
|
+
run(["symbolic-ref", "--short", "-q", "HEAD"])
|
|
242
|
+
]);
|
|
243
|
+
const [root, commitSha, baseSha] = (refs ?? "").split("\n");
|
|
244
|
+
if (!root) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
const state = {
|
|
248
|
+
githubEmail: text(email),
|
|
249
|
+
branch: text(branch),
|
|
250
|
+
commitSha: sha(commitSha),
|
|
251
|
+
baseSha: sha(baseSha),
|
|
252
|
+
experimentSha: await resolveWorkingTreeSha(run, root.trim())
|
|
253
|
+
};
|
|
254
|
+
return isEmptyGitState(state) ? null : state;
|
|
255
|
+
}
|
|
256
|
+
async function resolveWorkingTreeSha(run, root) {
|
|
257
|
+
let indexPath;
|
|
258
|
+
let cleanup;
|
|
259
|
+
try {
|
|
260
|
+
const { mkdtemp, rm } = await import("fs/promises");
|
|
261
|
+
const { join } = await import("path");
|
|
262
|
+
const { tmpdir } = await import("os");
|
|
263
|
+
const dir = await mkdtemp(join(tmpdir(), "bitfab-git-"));
|
|
264
|
+
indexPath = join(dir, "index");
|
|
265
|
+
cleanup = () => rm(dir, { recursive: true, force: true });
|
|
266
|
+
} catch {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
try {
|
|
270
|
+
const env = { GIT_INDEX_FILE: indexPath };
|
|
271
|
+
if (await run(["read-tree", "HEAD"], env) === null) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
if (await run(["add", "-A", "--", root], env) === null) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
return sha(await run(["write-tree"], env));
|
|
278
|
+
} catch {
|
|
279
|
+
return null;
|
|
280
|
+
} finally {
|
|
281
|
+
await cleanup().catch(() => {
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function resolvedGitState() {
|
|
286
|
+
if (typeof process === "undefined" || process.env?.[DISABLE_ENV]) {
|
|
287
|
+
return Promise.resolve(null);
|
|
288
|
+
}
|
|
289
|
+
let cwd;
|
|
290
|
+
try {
|
|
291
|
+
cwd = process.cwd?.() ?? ".";
|
|
292
|
+
} catch {
|
|
293
|
+
return Promise.resolve(null);
|
|
294
|
+
}
|
|
295
|
+
return resolveGitState(cwd).catch(() => null);
|
|
296
|
+
}
|
|
297
|
+
|
|
111
298
|
// src/asyncStorage.ts
|
|
112
299
|
var AsyncLocalStorageClass = null;
|
|
113
300
|
var initDone = false;
|
|
@@ -1906,6 +2093,10 @@ var HttpClient = class {
|
|
|
1906
2093
|
if (onlyWithAssertions) {
|
|
1907
2094
|
payload.onlyWithAssertions = true;
|
|
1908
2095
|
}
|
|
2096
|
+
const git = await resolvedGitState();
|
|
2097
|
+
if (git && !isEmptyGitState(git)) {
|
|
2098
|
+
payload.git = git;
|
|
2099
|
+
}
|
|
1909
2100
|
const timeout = includeDbBranchLease ? REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS : 3e4;
|
|
1910
2101
|
return this.request("/api/sdk/replay/start", payload, {
|
|
1911
2102
|
timeout
|
|
@@ -2073,4 +2264,4 @@ export {
|
|
|
2073
2264
|
parseRetryAfterMs,
|
|
2074
2265
|
HttpClient
|
|
2075
2266
|
};
|
|
2076
|
-
//# sourceMappingURL=chunk-
|
|
2267
|
+
//# sourceMappingURL=chunk-ELGX3GWC.js.map
|