@prisma/composer-prisma-cloud 0.2.0-dev.14 → 0.2.0-dev.16
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/buckets-main.mjs +1 -1
- package/dist/compute-main.mjs +1 -1
- package/dist/postgres-main.mjs +196 -113
- package/dist/postgres-main.mjs.map +1 -1
- package/dist/{segments-NpKN-46R-B01DmCqy.mjs → segments-NpKN-46R-C_LQ2urs.mjs} +15 -2
- package/dist/{segments-NpKN-46R-B01DmCqy.mjs.map → segments-NpKN-46R-C_LQ2urs.mjs.map} +1 -1
- package/package.json +17 -17
package/dist/buckets-main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as readOwnVersion, i as readJsonFile, r as isValidSegment, t as StateFile } from "./segments-NpKN-46R-C_LQ2urs.mjs";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as fs$1 from "node:fs/promises";
|
|
4
4
|
import * as path from "node:path";
|
package/dist/compute-main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as readOwnVersion, i as readJsonFile, r as isValidSegment, t as StateFile } from "./segments-NpKN-46R-C_LQ2urs.mjs";
|
|
2
2
|
import { n as portNumbers, t as getPorts } from "./get-port-BYnpbW5H.mjs";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { spawn } from "node:child_process";
|
package/dist/postgres-main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as readOwnVersion, i as readJsonFile, n as isPidAlive, r as isValidSegment, t as StateFile } from "./segments-NpKN-46R-C_LQ2urs.mjs";
|
|
2
2
|
import { n as portNumbers, t as getPorts } from "./get-port-BYnpbW5H.mjs";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import * as path from "node:path";
|
|
@@ -58,6 +58,16 @@ const MAX_DATABASE_PORT = 65535;
|
|
|
58
58
|
const APPS_STATE_MODE = 384;
|
|
59
59
|
/** Spec § 2 step 5's pattern, applied to a fresh database-port allocation. */
|
|
60
60
|
const MAX_FRESH_PORT_CANDIDATES = 5;
|
|
61
|
+
/**
|
|
62
|
+
* A name refused as "already running" is retried a few times, each attempt
|
|
63
|
+
* first waiting out the holder: a cold server boot takes seconds, and a
|
|
64
|
+
* crashed holder's lock is only released once proper-lockfile's ~10s stale
|
|
65
|
+
* threshold passes. Bounded so a genuinely stuck name still fails visibly
|
|
66
|
+
* inside the dev command's own startup budget.
|
|
67
|
+
*/
|
|
68
|
+
const MAX_ALREADY_RUNNING_RETRIES = 2;
|
|
69
|
+
const ALREADY_RUNNING_POLLS = 24;
|
|
70
|
+
const ALREADY_RUNNING_POLL_MS = 500;
|
|
61
71
|
const NOT_INSTALLED_MESSAGE = "local dev needs @prisma/dev for its local Postgres emulator — add \"prisma\" to your app's devDependencies.";
|
|
62
72
|
function maskCredentials(text) {
|
|
63
73
|
return text.replace(/:\/\/([^:@/\s]+):[^@/\s]+@/g, "://$1:***@");
|
|
@@ -105,32 +115,6 @@ function portConflictOf(err, ports) {
|
|
|
105
115
|
const port = err.port;
|
|
106
116
|
return typeof port === "number" && ports.includes(port) ? port : void 0;
|
|
107
117
|
}
|
|
108
|
-
function isPrismaDevServer(value) {
|
|
109
|
-
if (!isStringKeyedRecord(value) || typeof value["close"] !== "function") return false;
|
|
110
|
-
const database = value["database"];
|
|
111
|
-
return isStringKeyedRecord(database) && typeof database["connectionString"] === "string";
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* The live server behind a "name is already running" refusal, when there is
|
|
115
|
-
* one. A start that fails mid-boot (e.g. on a port another server's
|
|
116
|
-
* registry claims) can leave its state entry behind, so OUR OWN next
|
|
117
|
-
* attempt for the same name is refused. `@prisma/dev`'s
|
|
118
|
-
* `ServerAlreadyRunningError` carries the running server as a `.server`
|
|
119
|
-
* getter (duck-typed — `instanceof` fails across the dynamic-import
|
|
120
|
-
* boundary); its parent class (state entry exists but nothing actually
|
|
121
|
-
* runs) has no such getter, and a dead ghost resolves to null — both mean
|
|
122
|
-
* "nothing to adopt".
|
|
123
|
-
*/
|
|
124
|
-
async function adoptableServerOf(err) {
|
|
125
|
-
if (!isStringKeyedRecord(err) || !("server" in err)) return void 0;
|
|
126
|
-
if (err["name"] !== "ServerAlreadyRunningError") return void 0;
|
|
127
|
-
try {
|
|
128
|
-
const server = await err["server"];
|
|
129
|
-
return isPrismaDevServer(server) ? server : void 0;
|
|
130
|
-
} catch {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
118
|
function isNameAlreadyTaken(err) {
|
|
135
119
|
return isStringKeyedRecord(err) && (err["name"] === "ServerAlreadyRunningError" || err["name"] === "ServerStateAlreadyExistsError");
|
|
136
120
|
}
|
|
@@ -169,7 +153,93 @@ function isStringKeyedRecord(value) {
|
|
|
169
153
|
return typeof value === "object" && value !== null;
|
|
170
154
|
}
|
|
171
155
|
function isPrismaDevInternalStateModule(value) {
|
|
172
|
-
return isStringKeyedRecord(value) && typeof value["deleteServer"] === "function";
|
|
156
|
+
return isStringKeyedRecord(value) && typeof value["deleteServer"] === "function" && typeof value["killServer"] === "function" && typeof value["getServerStatus"] === "function";
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Every port any `@prisma/dev` server RECORD on this machine claims —
|
|
160
|
+
* database, http, shadow, and streams. `startPrismaDevServer` validates a
|
|
161
|
+
* requested port against these records (`ServerState.scan`) and refuses one
|
|
162
|
+
* that any record claims, even when nothing has it bound — and a record's
|
|
163
|
+
* aux ports are picked by `@prisma/dev`'s own walking-upward picker, which
|
|
164
|
+
* over enough servers climbs into this daemon's database range. A fresh
|
|
165
|
+
* database-port pick that only probed the OS would collide with such a
|
|
166
|
+
* claim, so fresh picks exclude these too. Best-effort: `scan` is the same
|
|
167
|
+
* internal surface the rest of this module already binds to, but absent or
|
|
168
|
+
* failing it degrades to the OS probe alone.
|
|
169
|
+
*/
|
|
170
|
+
async function registryClaimedPorts(internalState) {
|
|
171
|
+
const ports = /* @__PURE__ */ new Set();
|
|
172
|
+
const scanHost = isStringKeyedRecord(internalState) ? internalState["ServerState"] : void 0;
|
|
173
|
+
const scan = isStringKeyedRecord(scanHost) ? scanHost["scan"] : void 0;
|
|
174
|
+
if (!isStringKeyedRecord(scanHost) || typeof scan !== "function") return ports;
|
|
175
|
+
try {
|
|
176
|
+
const records = await scan.call(scanHost, { onlyMetadata: true });
|
|
177
|
+
if (!Array.isArray(records)) return ports;
|
|
178
|
+
for (const record of records) {
|
|
179
|
+
if (!isStringKeyedRecord(record)) continue;
|
|
180
|
+
for (const key of [
|
|
181
|
+
"databasePort",
|
|
182
|
+
"port",
|
|
183
|
+
"shadowDatabasePort",
|
|
184
|
+
"streamsPort"
|
|
185
|
+
]) {
|
|
186
|
+
const port = record[key];
|
|
187
|
+
if (typeof port === "number" && Number.isInteger(port) && port > 0) ports.add(port);
|
|
188
|
+
}
|
|
189
|
+
const experimental = record["experimental"];
|
|
190
|
+
const streams = isStringKeyedRecord(experimental) ? experimental["streams"] : void 0;
|
|
191
|
+
const streamsUrl = isStringKeyedRecord(streams) ? streams["serverUrl"] : void 0;
|
|
192
|
+
if (typeof streamsUrl === "string") {
|
|
193
|
+
const port = databasePortOf(streamsUrl);
|
|
194
|
+
if (port !== void 0) ports.add(port);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
} catch {}
|
|
198
|
+
return ports;
|
|
199
|
+
}
|
|
200
|
+
function readServerStatus(status) {
|
|
201
|
+
if (!isStringKeyedRecord(status)) return {
|
|
202
|
+
live: false,
|
|
203
|
+
recordExists: true,
|
|
204
|
+
pid: void 0,
|
|
205
|
+
url: void 0,
|
|
206
|
+
databasePort: void 0
|
|
207
|
+
};
|
|
208
|
+
const exports = status["exports"];
|
|
209
|
+
const database = isStringKeyedRecord(exports) ? exports["database"] : void 0;
|
|
210
|
+
const url = isStringKeyedRecord(database) ? database["connectionString"] : void 0;
|
|
211
|
+
const pid = status["pid"];
|
|
212
|
+
const databasePort = status["databasePort"];
|
|
213
|
+
return {
|
|
214
|
+
live: status["status"] === "running" || status["status"] === "starting_up",
|
|
215
|
+
recordExists: status["status"] !== "no_such_server",
|
|
216
|
+
pid: typeof pid === "number" ? pid : void 0,
|
|
217
|
+
url: typeof url === "string" ? url : void 0,
|
|
218
|
+
databasePort: typeof databasePort === "number" ? databasePort : void 0
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
async function serverStatusOf(internalState, instanceName) {
|
|
222
|
+
try {
|
|
223
|
+
return readServerStatus(await internalState.getServerStatus(instanceName));
|
|
224
|
+
} catch {
|
|
225
|
+
return {
|
|
226
|
+
live: false,
|
|
227
|
+
recordExists: true,
|
|
228
|
+
pid: void 0,
|
|
229
|
+
url: void 0,
|
|
230
|
+
databasePort: void 0
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const CLOSE_SETTLE_ATTEMPTS = 40;
|
|
235
|
+
const CLOSE_SETTLE_DELAY_MS = 250;
|
|
236
|
+
/** True once the named server's persisted state no longer claims it is live — the precondition for `deleteServer`, whose kill path targets the pid in that state, which for an in-daemon server is THIS DAEMON's own pid. */
|
|
237
|
+
async function settledAfterClose(internalState, instanceName) {
|
|
238
|
+
for (let attempt = 1; attempt <= CLOSE_SETTLE_ATTEMPTS; attempt += 1) {
|
|
239
|
+
if (!(await serverStatusOf(internalState, instanceName)).live) return true;
|
|
240
|
+
if (attempt < CLOSE_SETTLE_ATTEMPTS) await new Promise((resolve) => setTimeout(resolve, CLOSE_SETTLE_DELAY_MS));
|
|
241
|
+
}
|
|
242
|
+
return false;
|
|
173
243
|
}
|
|
174
244
|
/**
|
|
175
245
|
* `@prisma/dev`'s own package.json declares `./internal/state`, whose
|
|
@@ -237,11 +307,22 @@ function main() {
|
|
|
237
307
|
const stateFile = new StateFile(appsJsonPath, APPS_STATE_MODE);
|
|
238
308
|
let state = {};
|
|
239
309
|
const runtimes = /* @__PURE__ */ new Map();
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
310
|
+
/**
|
|
311
|
+
* Server starts run ONE AT A TIME. `@prisma/dev`'s start is not
|
|
312
|
+
* concurrency-safe within a process: two simultaneous calls pick their
|
|
313
|
+
* ports without seeing each other and one fails with a port refusal
|
|
314
|
+
* (verified directly — two concurrent starts with distinct, pinned
|
|
315
|
+
* database ports fail; the same two started in sequence both succeed).
|
|
316
|
+
* The daemon issues concurrent starts whenever an app converges more than
|
|
317
|
+
* one database, which is what produced the port refusals, the retries
|
|
318
|
+
* whose half-started servers held their own name's lock, and every
|
|
319
|
+
* "already running" failure downstream of that.
|
|
320
|
+
*/
|
|
321
|
+
let startQueue = Promise.resolve();
|
|
322
|
+
function serializeStart(run) {
|
|
323
|
+
const next = startQueue.then(run, run);
|
|
324
|
+
startQueue = next.then(() => void 0, () => void 0);
|
|
325
|
+
return next;
|
|
245
326
|
}
|
|
246
327
|
function schedulePersist() {
|
|
247
328
|
stateFile.write(state);
|
|
@@ -265,33 +346,19 @@ function main() {
|
|
|
265
346
|
exclude: [...usedDatabasePorts(), ...alsoExclude]
|
|
266
347
|
});
|
|
267
348
|
}
|
|
268
|
-
/** Three fresh, mutually distinct ports for a server's own HTTP/shadow-database/streams listeners — never persisted, only unique right now. */
|
|
269
|
-
async function allocateAuxPorts(excluding) {
|
|
270
|
-
const taken = /* @__PURE__ */ new Set([
|
|
271
|
-
...usedDatabasePorts(),
|
|
272
|
-
...liveAuxPorts,
|
|
273
|
-
...excluding
|
|
274
|
-
]);
|
|
275
|
-
const httpPort = await getPorts({
|
|
276
|
-
port: portNumbers(MIN_DATABASE_PORT, MAX_DATABASE_PORT),
|
|
277
|
-
exclude: taken
|
|
278
|
-
});
|
|
279
|
-
taken.add(httpPort);
|
|
280
|
-
const shadowDatabasePort = await getPorts({
|
|
281
|
-
port: portNumbers(MIN_DATABASE_PORT, MAX_DATABASE_PORT),
|
|
282
|
-
exclude: taken
|
|
283
|
-
});
|
|
284
|
-
taken.add(shadowDatabasePort);
|
|
285
|
-
return {
|
|
286
|
-
httpPort,
|
|
287
|
-
shadowDatabasePort,
|
|
288
|
-
streamsPort: await getPorts({
|
|
289
|
-
port: portNumbers(MIN_DATABASE_PORT, MAX_DATABASE_PORT),
|
|
290
|
-
exclude: taken
|
|
291
|
-
})
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
349
|
const inflightEnsures = /* @__PURE__ */ new Map();
|
|
350
|
+
/**
|
|
351
|
+
* Names whose `startPrismaDevServer` call failed in THIS process for any
|
|
352
|
+
* reason other than "already running". `@prisma/dev` acquires the name's
|
|
353
|
+
* lock before it validates the requested ports, and a failure after that
|
|
354
|
+
* point (a port refusal) propagates WITHOUT releasing the lock — so the
|
|
355
|
+
* very next start of the same name in this process is refused as "already
|
|
356
|
+
* running" by a holder that is this daemon's own dead attempt, and no
|
|
357
|
+
* amount of waiting frees it. Membership here is what makes deleting that
|
|
358
|
+
* lock provably safe: a name this process leaked cannot have been
|
|
359
|
+
* acquired by anyone else since (the leak never releases).
|
|
360
|
+
*/
|
|
361
|
+
const leakedStartNames = /* @__PURE__ */ new Set();
|
|
295
362
|
/** Concurrent PUTs for the same database coalesce onto one start — a second `startPrismaDevServer` for a name whose first start is still booting fails as "already running". */
|
|
296
363
|
function ensureDatabase(app, id, prismaDevModulePath) {
|
|
297
364
|
const instanceName = instanceNameFor(app, id);
|
|
@@ -309,71 +376,79 @@ function main() {
|
|
|
309
376
|
const runningServer = runtimes.get(instanceName);
|
|
310
377
|
if (existingRecord && runningServer) return { url: existingRecord.url };
|
|
311
378
|
const prismaDev = await importPrismaDev(prismaDevModulePath);
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const aux = await allocateAuxPorts(/* @__PURE__ */ new Set([dbPort, ...conflicted]));
|
|
317
|
-
try {
|
|
318
|
-
const server = await prismaDev.startPrismaDevServer({
|
|
319
|
-
name: instanceName,
|
|
320
|
-
databasePort: dbPort,
|
|
321
|
-
port: aux.httpPort,
|
|
322
|
-
shadowDatabasePort: aux.shadowDatabasePort,
|
|
323
|
-
streamsPort: aux.streamsPort,
|
|
324
|
-
persistenceMode: "stateful"
|
|
325
|
-
});
|
|
326
|
-
const url = server.database.connectionString;
|
|
327
|
-
runtimes.set(instanceName, server);
|
|
328
|
-
liveAuxPorts.add(aux.httpPort);
|
|
329
|
-
liveAuxPorts.add(aux.shadowDatabasePort);
|
|
330
|
-
liveAuxPorts.add(aux.streamsPort);
|
|
331
|
-
auxPortsByInstance.set(instanceName, [
|
|
332
|
-
aux.httpPort,
|
|
333
|
-
aux.shadowDatabasePort,
|
|
334
|
-
aux.streamsPort
|
|
335
|
-
]);
|
|
379
|
+
const internalState = await importPrismaDevInternalState(prismaDevModulePath);
|
|
380
|
+
const recorded = await serverStatusOf(internalState, instanceName);
|
|
381
|
+
if (recorded.live && recorded.pid !== void 0 && isPidAlive(recorded.pid)) {
|
|
382
|
+
if (recorded.url !== void 0) {
|
|
336
383
|
appRec.databases[id] = {
|
|
337
384
|
id,
|
|
338
385
|
instanceName,
|
|
339
|
-
databasePort:
|
|
340
|
-
url
|
|
386
|
+
databasePort: recorded.databasePort ?? databasePortOf(recorded.url) ?? MIN_DATABASE_PORT,
|
|
387
|
+
url: recorded.url
|
|
341
388
|
};
|
|
342
389
|
schedulePersist();
|
|
343
|
-
return { url };
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
390
|
+
return { url: recorded.url };
|
|
391
|
+
}
|
|
392
|
+
} else if (recorded.live) await internalState.killServer(instanceName).catch(() => void 0);
|
|
393
|
+
const isFreshAllocation = existingRecord === void 0;
|
|
394
|
+
const registryPorts = isFreshAllocation ? await registryClaimedPorts(internalState) : /* @__PURE__ */ new Set();
|
|
395
|
+
let dbPort = existingRecord?.databasePort ?? await smallestUnusedDatabasePort(MIN_DATABASE_PORT, registryPorts);
|
|
396
|
+
const conflicted = /* @__PURE__ */ new Set();
|
|
397
|
+
let alreadyRunningRetries = 0;
|
|
398
|
+
for (let attempt = 1;; attempt++) try {
|
|
399
|
+
const server = await serializeStart(() => prismaDev.startPrismaDevServer({
|
|
400
|
+
name: instanceName,
|
|
401
|
+
databasePort: dbPort,
|
|
402
|
+
persistenceMode: "stateful"
|
|
403
|
+
}));
|
|
404
|
+
const url = server.database.connectionString;
|
|
405
|
+
leakedStartNames.delete(instanceName);
|
|
406
|
+
runtimes.set(instanceName, server);
|
|
407
|
+
appRec.databases[id] = {
|
|
408
|
+
id,
|
|
409
|
+
instanceName,
|
|
410
|
+
databasePort: dbPort,
|
|
411
|
+
url
|
|
412
|
+
};
|
|
413
|
+
schedulePersist();
|
|
414
|
+
return { url };
|
|
415
|
+
} catch (err) {
|
|
416
|
+
if (isNameAlreadyTaken(err) && alreadyRunningRetries < MAX_ALREADY_RUNNING_RETRIES) {
|
|
417
|
+
alreadyRunningRetries += 1;
|
|
418
|
+
if (leakedStartNames.has(instanceName)) {
|
|
419
|
+
if (!(await serverStatusOf(internalState, instanceName)).recordExists) {
|
|
420
|
+
await internalState.deleteServer(instanceName).catch(() => void 0);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
for (let poll = 1; poll <= ALREADY_RUNNING_POLLS; poll += 1) {
|
|
425
|
+
const now = await serverStatusOf(internalState, instanceName);
|
|
426
|
+
if (now.live && now.pid !== void 0 && isPidAlive(now.pid) && now.url !== void 0) {
|
|
350
427
|
appRec.databases[id] = {
|
|
351
428
|
id,
|
|
352
429
|
instanceName,
|
|
353
|
-
databasePort: databasePortOf(url) ?? dbPort,
|
|
354
|
-
url
|
|
430
|
+
databasePort: now.databasePort ?? databasePortOf(now.url) ?? dbPort,
|
|
431
|
+
url: now.url
|
|
355
432
|
};
|
|
356
433
|
schedulePersist();
|
|
357
|
-
return { url };
|
|
434
|
+
return { url: now.url };
|
|
358
435
|
}
|
|
359
|
-
if (
|
|
360
|
-
await (
|
|
361
|
-
|
|
436
|
+
if (now.live && (now.pid === void 0 || !isPidAlive(now.pid))) {
|
|
437
|
+
await internalState.killServer(instanceName).catch(() => void 0);
|
|
438
|
+
break;
|
|
362
439
|
}
|
|
440
|
+
await new Promise((resolve) => setTimeout(resolve, ALREADY_RUNNING_POLL_MS));
|
|
363
441
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
372
|
-
throw new Error(`postgres emulator failed to start database "${instanceName}" on port ${String(dbPort)}: ${maskCredentials(firstLine(reason))}`);
|
|
373
|
-
}
|
|
374
|
-
conflicted.add(conflictPort);
|
|
375
|
-
if (conflictPort === dbPort) dbPort = await smallestUnusedDatabasePort(dbPort + 1, conflicted);
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (!isNameAlreadyTaken(err)) leakedStartNames.add(instanceName);
|
|
445
|
+
const conflictPort = portConflictOf(err, [dbPort]);
|
|
446
|
+
if (!(conflictPort !== void 0 && attempt < MAX_FRESH_PORT_CANDIDATES && (conflictPort !== dbPort || isFreshAllocation))) {
|
|
447
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
448
|
+
throw new Error(`postgres emulator failed to start database "${instanceName}" on port ${String(dbPort)}: ${maskCredentials(firstLine(reason))}`);
|
|
376
449
|
}
|
|
450
|
+
conflicted.add(conflictPort);
|
|
451
|
+
if (conflictPort === dbPort) dbPort = await smallestUnusedDatabasePort(dbPort + 1, /* @__PURE__ */ new Set([...conflicted, ...registryPorts]));
|
|
377
452
|
}
|
|
378
453
|
}
|
|
379
454
|
async function deleteApp(app, prismaDevModulePathHint) {
|
|
@@ -385,12 +460,20 @@ function main() {
|
|
|
385
460
|
if (server) {
|
|
386
461
|
await server.close().catch(() => void 0);
|
|
387
462
|
runtimes.delete(db.instanceName);
|
|
388
|
-
releaseAuxPorts(db.instanceName);
|
|
389
463
|
}
|
|
390
464
|
}
|
|
391
465
|
if (entries.length > 0 && prismaDevModulePathHint) {
|
|
392
|
-
const
|
|
393
|
-
for (const db of entries)
|
|
466
|
+
const internalState = await importPrismaDevInternalState(prismaDevModulePathHint);
|
|
467
|
+
for (const db of entries) {
|
|
468
|
+
if (!runtimes.has(db.instanceName)) {
|
|
469
|
+
if ((await serverStatusOf(internalState, db.instanceName)).pid !== process.pid) await internalState.killServer(db.instanceName).catch(() => void 0);
|
|
470
|
+
}
|
|
471
|
+
if (!await settledAfterClose(internalState, db.instanceName)) {
|
|
472
|
+
console.error(`postgres-main: server "${db.instanceName}" still reports running after close — leaving its persisted data in place instead of risking a self-kill.`);
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
await internalState.deleteServer(db.instanceName);
|
|
476
|
+
}
|
|
394
477
|
}
|
|
395
478
|
delete state[app];
|
|
396
479
|
schedulePersist();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-main.mjs","names":["getPort"],"sources":["../../../1-prisma-cloud/0-lowering/dev-emulators/dist/instance-name-BF6J_weL.mjs","../../../1-prisma-cloud/0-lowering/dev-emulators/dist/postgres-main.mjs"],"sourcesContent":["//#region src/instance-name.ts\n/**\n* `pcdev-<app>-<database-id>` instance-name derivation (local-dev spec § 2\n* `postgres-main.ts`): each half lowercased, every char outside `[a-z0-9]`\n* replaced by `-`, runs collapsed, the combined name trimmed to 63 chars.\n*\n* A separate, side-effect-free module (not defined inline in\n* `postgres-main.ts`) so it can be imported directly by tests without also\n* running that file's own `main()` — `postgres-main.ts` is a daemon\n* entrypoint script, always invoked as a subprocess, and calls `main()`\n* unconditionally at module load.\n*/\n/**\n* Deliberately linear, no ambiguous quantifiers: a per-character replace\n* (no `+`, so no run-length backtracking surface), a bounded-quantifier\n* collapse (`{2,}`, not alternation-with-quantifiers), and plain\n* index-walking for the leading/trailing trim instead of a regex — a\n* combined `+`-plus-alternation trim (`/^-+|-+$/g`) is exactly the shape\n* CodeQL's polynomial-ReDoS check flags, whether or not this particular\n* instance is provably safe.\n*/\nfunction slug(segment) {\n\tconst collapsed = segment.toLowerCase().replace(/[^a-z0-9]/g, \"-\").replace(/-{2,}/g, \"-\");\n\tlet start = 0;\n\tlet end = collapsed.length;\n\twhile (start < end && collapsed[start] === \"-\") start++;\n\twhile (end > start && collapsed[end - 1] === \"-\") end--;\n\treturn collapsed.slice(start, end);\n}\nfunction instanceNameFor(app, id) {\n\treturn `pcdev-${slug(app)}-${slug(id)}`.slice(0, 63);\n}\n//#endregion\nexport { slug as n, instanceNameFor as t };\n\n//# sourceMappingURL=instance-name-BF6J_weL.mjs.map","import { c as readOwnVersion, f as StateFile, p as readJsonFile, t as isValidSegment } from \"./segments-NpKN-46R.mjs\";\nimport { t as instanceNameFor } from \"./instance-name-BF6J_weL.mjs\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport getPort, { portNumbers } from \"get-port\";\nimport * as http from \"node:http\";\n//#region src/postgres-main.ts\n/**\n* The Postgres emulator daemon (local-dev spec § 2 `postgres-main.ts`): a\n* small local counterpart of hosted Postgres, hosting `@prisma/dev`'s\n* `startPrismaDevServer()` — one named, persistent server per `Database`\n* resource, several servers in this one daemon process. Loopback\n* `node:http` JSON admin API; state under its `--state-dir`.\n*\n* `@prisma/dev` is imported dynamically from a CALLER-RESOLVED path (each\n* admin request that needs it carries `prismaDevModulePath`) so the app\n* owns its own Prisma version — this daemon has no `@prisma/dev` dependency\n* of its own.\n*\n* Runs as its own OS process, started by `daemon.ts`'s `ensureDaemon` via\n* `process.execPath <this file> --port <n> --state-dir <dir>`.\n*/\nconst MIN_DATABASE_PORT = 51300;\nconst MAX_DATABASE_PORT = 65535;\nconst APPS_STATE_MODE = 384;\n/** Spec § 2 step 5's pattern, applied to a fresh database-port allocation. */\nconst MAX_FRESH_PORT_CANDIDATES = 5;\nconst NOT_INSTALLED_MESSAGE = \"local dev needs @prisma/dev for its local Postgres emulator — add \\\"prisma\\\" to your app's devDependencies.\";\nfunction maskCredentials(text) {\n\treturn text.replace(/:\\/\\/([^:@/\\s]+):[^@/\\s]+@/g, \"://$1:***@\");\n}\nfunction firstLine(text) {\n\treturn (text.split(\"\\n\")[0] ?? text).trim();\n}\nfunction isDatabaseRecord(value) {\n\treturn typeof value === \"object\" && value !== null && \"id\" in value && typeof value.id === \"string\" && \"instanceName\" in value && typeof value.instanceName === \"string\" && \"databasePort\" in value && typeof value.databasePort === \"number\" && \"url\" in value && typeof value.url === \"string\";\n}\nfunction isAppRecord(value) {\n\treturn typeof value === \"object\" && value !== null && \"databases\" in value && typeof value.databases === \"object\" && value.databases !== null && Object.values(value.databases).every(isDatabaseRecord);\n}\nfunction isAppsState(value) {\n\treturn typeof value === \"object\" && value !== null && Object.values(value).every(isAppRecord);\n}\nfunction isDatabaseBody(value) {\n\treturn typeof value === \"object\" && value !== null && \"prismaDevModulePath\" in value && typeof value.prismaDevModulePath === \"string\";\n}\nfunction isPrismaDevModule(value) {\n\treturn typeof value === \"object\" && value !== null && \"startPrismaDevServer\" in value && typeof value.startPrismaDevServer === \"function\";\n}\n/**\n* `@prisma/dev` exports a `PortNotAvailableError` class with a `readonly\n* port: number`, but the daemon dynamically imports the module from a\n* caller-given path while the class identity checked here would come from\n* whatever module graph THIS file's own bundle produced — two separate\n* instantiations of the same logical class, so `instanceof` doesn't match\n* across them (confirmed empirically: a real port conflict's `err\n* instanceof mod.PortNotAvailableError` is `false` even though the error IS\n* the port-conflict one). Duck-typing the documented shape — a `port`\n* number matching the candidate we just tried — is what actually survives\n* that boundary.\n*/\n/**\n* The port a start refusal is about, when it is one of THIS attempt's ports.\n* Duck-typed (`instanceof` fails across the dynamic-import boundary): every\n* `@prisma/dev` port refusal — not-available, requested-twice, and\n* belongs-to-another-server (its registry can claim a port no bind probe\n* sees) — carries the offending port as `.port`, and any of the four ports\n* we requested (database + the three aux listeners) can be the one refused.\n*/\nfunction portConflictOf(err, ports) {\n\tif (typeof err !== \"object\" || err === null || !(\"port\" in err)) return void 0;\n\tconst port = err.port;\n\treturn typeof port === \"number\" && ports.includes(port) ? port : void 0;\n}\nfunction isPrismaDevServer(value) {\n\tif (!isStringKeyedRecord(value) || typeof value[\"close\"] !== \"function\") return false;\n\tconst database = value[\"database\"];\n\treturn isStringKeyedRecord(database) && typeof database[\"connectionString\"] === \"string\";\n}\n/**\n* The live server behind a \"name is already running\" refusal, when there is\n* one. A start that fails mid-boot (e.g. on a port another server's\n* registry claims) can leave its state entry behind, so OUR OWN next\n* attempt for the same name is refused. `@prisma/dev`'s\n* `ServerAlreadyRunningError` carries the running server as a `.server`\n* getter (duck-typed — `instanceof` fails across the dynamic-import\n* boundary); its parent class (state entry exists but nothing actually\n* runs) has no such getter, and a dead ghost resolves to null — both mean\n* \"nothing to adopt\".\n*/\nasync function adoptableServerOf(err) {\n\tif (!isStringKeyedRecord(err) || !(\"server\" in err)) return void 0;\n\tif (err[\"name\"] !== \"ServerAlreadyRunningError\") return void 0;\n\ttry {\n\t\tconst server = await err[\"server\"];\n\t\treturn isPrismaDevServer(server) ? server : void 0;\n\t} catch {\n\t\treturn;\n\t}\n}\nfunction isNameAlreadyTaken(err) {\n\treturn isStringKeyedRecord(err) && (err[\"name\"] === \"ServerAlreadyRunningError\" || err[\"name\"] === \"ServerStateAlreadyExistsError\");\n}\n/** The port of a postgres connection URL, when it parses as one. */\nfunction databasePortOf(connectionString) {\n\ttry {\n\t\tconst port = Number(new URL(connectionString).port);\n\t\treturn Number.isInteger(port) && port > 0 ? port : void 0;\n\t} catch {\n\t\treturn;\n\t}\n}\n/**\n* A dynamic `import()` failure's own message routinely names a SECOND path\n* (e.g. bun's \"Cannot find module '<target>' from '<importer>'\") — the\n* importer half is this daemon's own internal location, not anything the\n* caller gave us, and has no business in a response body. Rather than try\n* to scrub an arbitrary underlying message for every runtime's own error\n* phrasing, the resolution-failure case names only what the caller\n* supplied — the pinned message plus the given `prismaDevModulePath`, and\n* nothing else. (A DIFFERENT case — a module that resolves fine but whose\n* `startPrismaDevServer()` call itself fails — still surfaces its\n* underlying text verbatim, credential-masked, per spec § 2.)\n*/\nasync function importPrismaDev(prismaDevModulePath) {\n\tlet mod;\n\ttry {\n\t\tmod = await import(pathToFileURL(prismaDevModulePath).href);\n\t} catch {\n\t\tthrow new Error(`${NOT_INSTALLED_MESSAGE} (could not resolve \"${prismaDevModulePath}\")`);\n\t}\n\tif (!isPrismaDevModule(mod)) throw new Error(`${NOT_INSTALLED_MESSAGE} (\"${prismaDevModulePath}\" is not a @prisma/dev module)`);\n\treturn mod;\n}\nfunction isStringKeyedRecord(value) {\n\treturn typeof value === \"object\" && value !== null;\n}\nfunction isPrismaDevInternalStateModule(value) {\n\treturn isStringKeyedRecord(value) && typeof value[\"deleteServer\"] === \"function\";\n}\n/**\n* `@prisma/dev`'s own package.json declares `./internal/state`, whose\n* `deleteServer(name)` actually removes a stateful server's persisted PGlite\n* data — `startPrismaDevServer`'s public surface only starts/closes a live\n* server, never deletes what a closed one left on disk. Resolved by reading\n* the SAME package's own `exports` map (walked up from the caller-given\n* entry path to find `@prisma/dev`'s `package.json`), never by guessing at\n* `dist/` file layout.\n*/\nasync function importPrismaDevInternalState(prismaDevModulePath) {\n\tlet dir = path.dirname(prismaDevModulePath);\n\tfor (;;) {\n\t\tconst pkgPath = path.join(dir, \"package.json\");\n\t\tif (fs.existsSync(pkgPath)) {\n\t\t\tconst pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n\t\t\tif (isStringKeyedRecord(pkg) && pkg[\"name\"] === \"@prisma/dev\" && isStringKeyedRecord(pkg[\"exports\"])) {\n\t\t\t\tconst entry = pkg[\"exports\"][\"./internal/state\"];\n\t\t\t\tconst target = resolveExportTarget(entry);\n\t\t\t\tif (target === void 0) throw new Error(`\"@prisma/dev\" at \"${dir}\" does not declare an \"./internal/state\" export — cannot delete its persisted database data.`);\n\t\t\t\tconst mod = await import(pathToFileURL(path.join(dir, target)).href);\n\t\t\t\tif (isPrismaDevInternalStateModule(mod)) return mod;\n\t\t\t\tthrow new Error(`\"@prisma/dev\"'s \"./internal/state\" export at \"${dir}\" has no deleteServer.`);\n\t\t\t}\n\t\t}\n\t\tconst parent = path.dirname(dir);\n\t\tif (parent === dir) throw new Error(`could not find \"@prisma/dev\"'s package.json above \"${prismaDevModulePath}\".`);\n\t\tdir = parent;\n\t}\n}\nfunction resolveExportTarget(entry) {\n\tif (typeof entry === \"string\") return entry;\n\tif (!isStringKeyedRecord(entry)) return void 0;\n\tconst nested = entry[\"import\"] ?? entry[\"require\"] ?? entry[\"default\"];\n\tif (typeof nested === \"string\") return nested;\n\tif (isStringKeyedRecord(nested)) {\n\t\tconst def = nested[\"default\"];\n\t\tif (typeof def === \"string\") return def;\n\t}\n}\nfunction parseArgs(argv) {\n\tlet port;\n\tlet stateDir;\n\tfor (let i = 0; i < argv.length; i++) if (argv[i] === \"--port\") port = Number(argv[i + 1]);\n\telse if (argv[i] === \"--state-dir\") stateDir = argv[i + 1];\n\tif (port === void 0 || Number.isNaN(port)) throw new Error(\"postgres-main: --port <n> is required\");\n\tif (stateDir === void 0) throw new Error(\"postgres-main: --state-dir <dir> is required\");\n\treturn {\n\t\tport,\n\t\tstateDir\n\t};\n}\nfunction readBody(req) {\n\treturn new Promise((resolve, reject) => {\n\t\tconst chunks = [];\n\t\treq.on(\"data\", (chunk) => chunks.push(chunk));\n\t\treq.on(\"end\", () => resolve(Buffer.concat(chunks)));\n\t\treq.on(\"error\", reject);\n\t});\n}\nfunction main() {\n\tconst { port, stateDir } = parseArgs(process.argv.slice(2));\n\tconst ownVersion = readOwnVersion();\n\tconst appsJsonPath = path.join(stateDir, \"apps.json\");\n\tconst stateFile = new StateFile(appsJsonPath, APPS_STATE_MODE);\n\tlet state = {};\n\tconst runtimes = /* @__PURE__ */ new Map();\n\tconst liveAuxPorts = /* @__PURE__ */ new Set();\n\tconst auxPortsByInstance = /* @__PURE__ */ new Map();\n\tfunction releaseAuxPorts(instanceName) {\n\t\tfor (const p of auxPortsByInstance.get(instanceName) ?? []) liveAuxPorts.delete(p);\n\t\tauxPortsByInstance.delete(instanceName);\n\t}\n\tfunction schedulePersist() {\n\t\tstateFile.write(state);\n\t}\n\tfunction getOrCreateApp(app) {\n\t\tlet appRec = state[app];\n\t\tif (!appRec) {\n\t\t\tappRec = { databases: {} };\n\t\t\tstate[app] = appRec;\n\t\t}\n\t\treturn appRec;\n\t}\n\tfunction usedDatabasePorts() {\n\t\tconst ports = /* @__PURE__ */ new Set();\n\t\tfor (const appRec of Object.values(state)) for (const db of Object.values(appRec.databases)) ports.add(db.databasePort);\n\t\treturn ports;\n\t}\n\tasync function smallestUnusedDatabasePort(min, alsoExclude = /* @__PURE__ */ new Set()) {\n\t\treturn getPort({\n\t\t\tport: portNumbers(min, MAX_DATABASE_PORT),\n\t\t\texclude: [...usedDatabasePorts(), ...alsoExclude]\n\t\t});\n\t}\n\t/** Three fresh, mutually distinct ports for a server's own HTTP/shadow-database/streams listeners — never persisted, only unique right now. */\n\tasync function allocateAuxPorts(excluding) {\n\t\tconst taken = /* @__PURE__ */ new Set([\n\t\t\t...usedDatabasePorts(),\n\t\t\t...liveAuxPorts,\n\t\t\t...excluding\n\t\t]);\n\t\tconst httpPort = await getPort({\n\t\t\tport: portNumbers(MIN_DATABASE_PORT, MAX_DATABASE_PORT),\n\t\t\texclude: taken\n\t\t});\n\t\ttaken.add(httpPort);\n\t\tconst shadowDatabasePort = await getPort({\n\t\t\tport: portNumbers(MIN_DATABASE_PORT, MAX_DATABASE_PORT),\n\t\t\texclude: taken\n\t\t});\n\t\ttaken.add(shadowDatabasePort);\n\t\treturn {\n\t\t\thttpPort,\n\t\t\tshadowDatabasePort,\n\t\t\tstreamsPort: await getPort({\n\t\t\t\tport: portNumbers(MIN_DATABASE_PORT, MAX_DATABASE_PORT),\n\t\t\t\texclude: taken\n\t\t\t})\n\t\t};\n\t}\n\tconst inflightEnsures = /* @__PURE__ */ new Map();\n\t/** Concurrent PUTs for the same database coalesce onto one start — a second `startPrismaDevServer` for a name whose first start is still booting fails as \"already running\". */\n\tfunction ensureDatabase(app, id, prismaDevModulePath) {\n\t\tconst instanceName = instanceNameFor(app, id);\n\t\tconst inflight = inflightEnsures.get(instanceName);\n\t\tif (inflight) return inflight;\n\t\tconst run = ensureDatabaseSerialized(app, id, prismaDevModulePath, instanceName).finally(() => {\n\t\t\tinflightEnsures.delete(instanceName);\n\t\t});\n\t\tinflightEnsures.set(instanceName, run);\n\t\treturn run;\n\t}\n\tasync function ensureDatabaseSerialized(app, id, prismaDevModulePath, instanceName) {\n\t\tconst appRec = getOrCreateApp(app);\n\t\tconst existingRecord = appRec.databases[id];\n\t\tconst runningServer = runtimes.get(instanceName);\n\t\tif (existingRecord && runningServer) return { url: existingRecord.url };\n\t\tconst prismaDev = await importPrismaDev(prismaDevModulePath);\n\t\tconst isFreshAllocation = existingRecord === void 0;\n\t\tlet dbPort = existingRecord?.databasePort ?? await smallestUnusedDatabasePort(MIN_DATABASE_PORT);\n\t\tconst conflicted = /* @__PURE__ */ new Set();\n\t\tfor (let attempt = 1;; attempt++) {\n\t\t\tconst aux = await allocateAuxPorts(/* @__PURE__ */ new Set([dbPort, ...conflicted]));\n\t\t\ttry {\n\t\t\t\tconst server = await prismaDev.startPrismaDevServer({\n\t\t\t\t\tname: instanceName,\n\t\t\t\t\tdatabasePort: dbPort,\n\t\t\t\t\tport: aux.httpPort,\n\t\t\t\t\tshadowDatabasePort: aux.shadowDatabasePort,\n\t\t\t\t\tstreamsPort: aux.streamsPort,\n\t\t\t\t\tpersistenceMode: \"stateful\"\n\t\t\t\t});\n\t\t\t\tconst url = server.database.connectionString;\n\t\t\t\truntimes.set(instanceName, server);\n\t\t\t\tliveAuxPorts.add(aux.httpPort);\n\t\t\t\tliveAuxPorts.add(aux.shadowDatabasePort);\n\t\t\t\tliveAuxPorts.add(aux.streamsPort);\n\t\t\t\tauxPortsByInstance.set(instanceName, [\n\t\t\t\t\taux.httpPort,\n\t\t\t\t\taux.shadowDatabasePort,\n\t\t\t\t\taux.streamsPort\n\t\t\t\t]);\n\t\t\t\tappRec.databases[id] = {\n\t\t\t\t\tid,\n\t\t\t\t\tinstanceName,\n\t\t\t\t\tdatabasePort: dbPort,\n\t\t\t\t\turl\n\t\t\t\t};\n\t\t\t\tschedulePersist();\n\t\t\t\treturn { url };\n\t\t\t} catch (err) {\n\t\t\t\tif (isNameAlreadyTaken(err)) {\n\t\t\t\t\tconst ghost = await adoptableServerOf(err);\n\t\t\t\t\tif (ghost !== void 0) {\n\t\t\t\t\t\tconst url = ghost.database.connectionString;\n\t\t\t\t\t\truntimes.set(instanceName, ghost);\n\t\t\t\t\t\tappRec.databases[id] = {\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tinstanceName,\n\t\t\t\t\t\t\tdatabasePort: databasePortOf(url) ?? dbPort,\n\t\t\t\t\t\t\turl\n\t\t\t\t\t\t};\n\t\t\t\t\t\tschedulePersist();\n\t\t\t\t\t\treturn { url };\n\t\t\t\t\t}\n\t\t\t\t\tif (attempt < MAX_FRESH_PORT_CANDIDATES) {\n\t\t\t\t\t\tawait (await importPrismaDevInternalState(prismaDevModulePath)).deleteServer(instanceName);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst conflictPort = portConflictOf(err, [\n\t\t\t\t\tdbPort,\n\t\t\t\t\taux.httpPort,\n\t\t\t\t\taux.shadowDatabasePort,\n\t\t\t\t\taux.streamsPort\n\t\t\t\t]);\n\t\t\t\tif (!(conflictPort !== void 0 && attempt < MAX_FRESH_PORT_CANDIDATES && (conflictPort !== dbPort || isFreshAllocation))) {\n\t\t\t\t\tconst reason = err instanceof Error ? err.message : String(err);\n\t\t\t\t\tthrow new Error(`postgres emulator failed to start database \"${instanceName}\" on port ${String(dbPort)}: ${maskCredentials(firstLine(reason))}`);\n\t\t\t\t}\n\t\t\t\tconflicted.add(conflictPort);\n\t\t\t\tif (conflictPort === dbPort) dbPort = await smallestUnusedDatabasePort(dbPort + 1, conflicted);\n\t\t\t}\n\t\t}\n\t}\n\tasync function deleteApp(app, prismaDevModulePathHint) {\n\t\tconst appRec = state[app];\n\t\tif (!appRec) return;\n\t\tconst entries = Object.values(appRec.databases);\n\t\tfor (const db of entries) {\n\t\t\tconst server = runtimes.get(db.instanceName);\n\t\t\tif (server) {\n\t\t\t\tawait server.close().catch(() => void 0);\n\t\t\t\truntimes.delete(db.instanceName);\n\t\t\t\treleaseAuxPorts(db.instanceName);\n\t\t\t}\n\t\t}\n\t\tif (entries.length > 0 && prismaDevModulePathHint) {\n\t\t\tconst { deleteServer } = await importPrismaDevInternalState(prismaDevModulePathHint);\n\t\t\tfor (const db of entries) await deleteServer(db.instanceName);\n\t\t}\n\t\tdelete state[app];\n\t\tschedulePersist();\n\t}\n\tfunction json(res, status, body) {\n\t\tres.writeHead(status, { \"content-type\": \"application/json\" });\n\t\tres.end(JSON.stringify(body));\n\t}\n\tfunction text(res, status, body) {\n\t\tres.writeHead(status, { \"content-type\": \"text/plain; charset=utf-8\" });\n\t\tres.end(body);\n\t}\n\tfunction badSegment(res, segment) {\n\t\ttext(res, 400, `invalid path segment \"${segment}\": must match /^[a-z0-9][a-z0-9-]*$/ and be at most 63 characters`);\n\t}\n\tfunction databaseView(db) {\n\t\treturn {\n\t\t\tid: db.id,\n\t\t\turl: db.url,\n\t\t\tinstanceName: db.instanceName,\n\t\t\tdatabasePort: db.databasePort\n\t\t};\n\t}\n\t/** The most recently observed `prismaDevModulePath` for any database of `app` — DELETE has no body of its own to carry one. */\n\tconst recentPrismaDevModulePath = /* @__PURE__ */ new Map();\n\tfunction lastKnownPrismaDevModulePath(app) {\n\t\treturn recentPrismaDevModulePath.get(app);\n\t}\n\tasync function handleRequest(req, res) {\n\t\tconst url = new URL(req.url ?? \"/\", `http://127.0.0.1:${String(port)}`);\n\t\tconst method = req.method ?? \"GET\";\n\t\tconst segments = url.pathname.split(\"/\").filter((s) => s.length > 0).map((s) => decodeURIComponent(s));\n\t\tif (method === \"GET\" && segments.length === 1 && segments[0] === \"health\") return json(res, 200, { version: ownVersion });\n\t\tif (segments[0] === \"apps\" && segments.length >= 2) {\n\t\t\tconst app = segments[1];\n\t\t\tif (app === void 0 || !isValidSegment(app)) return badSegment(res, app ?? \"\");\n\t\t\tif (method === \"PUT\" && segments.length === 4 && segments[2] === \"databases\") {\n\t\t\t\tconst id = segments[3];\n\t\t\t\tif (id === void 0 || !isValidSegment(id)) return badSegment(res, id ?? \"\");\n\t\t\t\tconst raw = await readBody(req);\n\t\t\t\tlet parsed;\n\t\t\t\ttry {\n\t\t\t\t\tparsed = JSON.parse(raw.toString(\"utf8\"));\n\t\t\t\t} catch {\n\t\t\t\t\treturn text(res, 400, \"malformed JSON body\");\n\t\t\t\t}\n\t\t\t\tif (!isDatabaseBody(parsed)) return text(res, 400, \"malformed database body: expected { \\\"prismaDevModulePath\\\": string }\");\n\t\t\t\trecentPrismaDevModulePath.set(app, parsed.prismaDevModulePath);\n\t\t\t\treturn json(res, 200, await ensureDatabase(app, id, parsed.prismaDevModulePath));\n\t\t\t}\n\t\t\tif (method === \"GET\" && segments.length === 3 && segments[2] === \"databases\") {\n\t\t\t\tconst appRec = state[app];\n\t\t\t\treturn json(res, 200, appRec ? Object.values(appRec.databases).map(databaseView) : []);\n\t\t\t}\n\t\t\tif (method === \"DELETE\" && segments.length === 2) {\n\t\t\t\tawait deleteApp(app, lastKnownPrismaDevModulePath(app));\n\t\t\t\tres.writeHead(204);\n\t\t\t\tres.end();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tres.writeHead(404);\n\t\tres.end();\n\t}\n\tconst server = http.createServer((req, res) => {\n\t\thandleRequest(req, res).catch((err) => {\n\t\t\tif (!res.headersSent) res.writeHead(500, { \"content-type\": \"text/plain\" });\n\t\t\tres.end(err instanceof Error ? maskCredentials(err.message) : String(err));\n\t\t});\n\t});\n\tasync function shutdown() {\n\t\tfor (const server of runtimes.values()) await server.close().catch(() => void 0);\n\t\tawait stateFile.flush();\n\t\tserver.close();\n\t\tprocess.exit(0);\n\t}\n\tprocess.on(\"SIGTERM\", () => void shutdown());\n\tprocess.on(\"SIGINT\", () => void shutdown());\n\tprocess.on(\"unhandledRejection\", (reason) => {\n\t\tconsole.error(\"postgres-main: unhandled rejection from background work:\", reason instanceof Error ? maskCredentials(reason.stack ?? reason.message) : reason);\n\t});\n\tprocess.on(\"uncaughtException\", (err) => {\n\t\tconsole.error(\"postgres-main: uncaught exception from background work:\", err instanceof Error ? maskCredentials(err.stack ?? err.message) : err);\n\t});\n\treadJsonFile(appsJsonPath, isAppsState).then((loaded) => {\n\t\tif (loaded) state = loaded;\n\t\tserver.listen(port, \"127.0.0.1\", () => {\n\t\t\tconsole.log(`[dev-emulators] postgres-main listening on 127.0.0.1:${String(port)}`);\n\t\t});\n\t}).catch((err) => {\n\t\tconsole.error(\"postgres-main: failed to load state\", err);\n\t\tprocess.exit(1);\n\t});\n}\nmain();\n//#endregion\nexport {};\n\n//# sourceMappingURL=postgres-main.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAS,KAAK,SAAS;CACtB,MAAM,YAAY,QAAQ,YAAY,CAAC,CAAC,QAAQ,cAAc,GAAG,CAAC,CAAC,QAAQ,UAAU,GAAG;CACxF,IAAI,QAAQ;CACZ,IAAI,MAAM,UAAU;CACpB,OAAO,QAAQ,OAAO,UAAU,WAAW,KAAK;CAChD,OAAO,MAAM,SAAS,UAAU,MAAM,OAAO,KAAK;CAClD,OAAO,UAAU,MAAM,OAAO,GAAG;AAClC;AACA,SAAS,gBAAgB,KAAK,IAAI;CACjC,OAAO,SAAS,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,IAAI,MAAM,GAAG,EAAE;AACpD;;;;;;;;;;;;;;;;;;ACRA,MAAM,oBAAoB;AAC1B,MAAM,oBA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OAAO,OAAO,MAAM,mBAAmB;GACtC,QAAQ,IAAI,wDAAwD,OAAO,IAAI,GAAG;EACnF,CAAC;CACF,CAAC,CAAC,CAAC,OAAO,QAAQ;EACjB,QAAQ,MAAM,uCAAuC,GAAG;EACxD,QAAQ,KAAK,CAAC;CACf,CAAC;AACF;AACA,KAAK"}
|
|
1
|
+
{"version":3,"file":"postgres-main.mjs","names":["getPort"],"sources":["../../../1-prisma-cloud/0-lowering/dev-emulators/dist/instance-name-BF6J_weL.mjs","../../../1-prisma-cloud/0-lowering/dev-emulators/dist/postgres-main.mjs"],"sourcesContent":["//#region src/instance-name.ts\n/**\n* `pcdev-<app>-<database-id>` instance-name derivation (local-dev spec § 2\n* `postgres-main.ts`): each half lowercased, every char outside `[a-z0-9]`\n* replaced by `-`, runs collapsed, the combined name trimmed to 63 chars.\n*\n* A separate, side-effect-free module (not defined inline in\n* `postgres-main.ts`) so it can be imported directly by tests without also\n* running that file's own `main()` — `postgres-main.ts` is a daemon\n* entrypoint script, always invoked as a subprocess, and calls `main()`\n* unconditionally at module load.\n*/\n/**\n* Deliberately linear, no ambiguous quantifiers: a per-character replace\n* (no `+`, so no run-length backtracking surface), a bounded-quantifier\n* collapse (`{2,}`, not alternation-with-quantifiers), and plain\n* index-walking for the leading/trailing trim instead of a regex — a\n* combined `+`-plus-alternation trim (`/^-+|-+$/g`) is exactly the shape\n* CodeQL's polynomial-ReDoS check flags, whether or not this particular\n* instance is provably safe.\n*/\nfunction slug(segment) {\n\tconst collapsed = segment.toLowerCase().replace(/[^a-z0-9]/g, \"-\").replace(/-{2,}/g, \"-\");\n\tlet start = 0;\n\tlet end = collapsed.length;\n\twhile (start < end && collapsed[start] === \"-\") start++;\n\twhile (end > start && collapsed[end - 1] === \"-\") end--;\n\treturn collapsed.slice(start, end);\n}\nfunction instanceNameFor(app, id) {\n\treturn `pcdev-${slug(app)}-${slug(id)}`.slice(0, 63);\n}\n//#endregion\nexport { slug as n, instanceNameFor as t };\n\n//# sourceMappingURL=instance-name-BF6J_weL.mjs.map","import { c as readOwnVersion, f as StateFile, p as readJsonFile, s as isPidAlive, t as isValidSegment } from \"./segments-NpKN-46R.mjs\";\nimport { t as instanceNameFor } from \"./instance-name-BF6J_weL.mjs\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport getPort, { portNumbers } from \"get-port\";\nimport * as http from \"node:http\";\n//#region src/postgres-main.ts\n/**\n* The Postgres emulator daemon (local-dev spec § 2 `postgres-main.ts`): a\n* small local counterpart of hosted Postgres, hosting `@prisma/dev`'s\n* `startPrismaDevServer()` — one named, persistent server per `Database`\n* resource, several servers in this one daemon process. Loopback\n* `node:http` JSON admin API; state under its `--state-dir`.\n*\n* `@prisma/dev` is imported dynamically from a CALLER-RESOLVED path (each\n* admin request that needs it carries `prismaDevModulePath`) so the app\n* owns its own Prisma version — this daemon has no `@prisma/dev` dependency\n* of its own.\n*\n* Runs as its own OS process, started by `daemon.ts`'s `ensureDaemon` via\n* `process.execPath <this file> --port <n> --state-dir <dir>`.\n*/\nconst MIN_DATABASE_PORT = 51300;\nconst MAX_DATABASE_PORT = 65535;\nconst APPS_STATE_MODE = 384;\n/** Spec § 2 step 5's pattern, applied to a fresh database-port allocation. */\nconst MAX_FRESH_PORT_CANDIDATES = 5;\n/**\n* A name refused as \"already running\" is retried a few times, each attempt\n* first waiting out the holder: a cold server boot takes seconds, and a\n* crashed holder's lock is only released once proper-lockfile's ~10s stale\n* threshold passes. Bounded so a genuinely stuck name still fails visibly\n* inside the dev command's own startup budget.\n*/\nconst MAX_ALREADY_RUNNING_RETRIES = 2;\nconst ALREADY_RUNNING_POLLS = 24;\nconst ALREADY_RUNNING_POLL_MS = 500;\nconst NOT_INSTALLED_MESSAGE = \"local dev needs @prisma/dev for its local Postgres emulator — add \\\"prisma\\\" to your app's devDependencies.\";\nfunction maskCredentials(text) {\n\treturn text.replace(/:\\/\\/([^:@/\\s]+):[^@/\\s]+@/g, \"://$1:***@\");\n}\nfunction firstLine(text) {\n\treturn (text.split(\"\\n\")[0] ?? text).trim();\n}\nfunction isDatabaseRecord(value) {\n\treturn typeof value === \"object\" && value !== null && \"id\" in value && typeof value.id === \"string\" && \"instanceName\" in value && typeof value.instanceName === \"string\" && \"databasePort\" in value && typeof value.databasePort === \"number\" && \"url\" in value && typeof value.url === \"string\";\n}\nfunction isAppRecord(value) {\n\treturn typeof value === \"object\" && value !== null && \"databases\" in value && typeof value.databases === \"object\" && value.databases !== null && Object.values(value.databases).every(isDatabaseRecord);\n}\nfunction isAppsState(value) {\n\treturn typeof value === \"object\" && value !== null && Object.values(value).every(isAppRecord);\n}\nfunction isDatabaseBody(value) {\n\treturn typeof value === \"object\" && value !== null && \"prismaDevModulePath\" in value && typeof value.prismaDevModulePath === \"string\";\n}\nfunction isPrismaDevModule(value) {\n\treturn typeof value === \"object\" && value !== null && \"startPrismaDevServer\" in value && typeof value.startPrismaDevServer === \"function\";\n}\n/**\n* `@prisma/dev` exports a `PortNotAvailableError` class with a `readonly\n* port: number`, but the daemon dynamically imports the module from a\n* caller-given path while the class identity checked here would come from\n* whatever module graph THIS file's own bundle produced — two separate\n* instantiations of the same logical class, so `instanceof` doesn't match\n* across them (confirmed empirically: a real port conflict's `err\n* instanceof mod.PortNotAvailableError` is `false` even though the error IS\n* the port-conflict one). Duck-typing the documented shape — a `port`\n* number matching the candidate we just tried — is what actually survives\n* that boundary.\n*/\n/**\n* The port a start refusal is about, when it is one of THIS attempt's ports.\n* Duck-typed (`instanceof` fails across the dynamic-import boundary): every\n* `@prisma/dev` port refusal — not-available, requested-twice, and\n* belongs-to-another-server (its registry can claim a port no bind probe\n* sees) — carries the offending port as `.port`, and any of the four ports\n* we requested (database + the three aux listeners) can be the one refused.\n*/\nfunction portConflictOf(err, ports) {\n\tif (typeof err !== \"object\" || err === null || !(\"port\" in err)) return void 0;\n\tconst port = err.port;\n\treturn typeof port === \"number\" && ports.includes(port) ? port : void 0;\n}\nfunction isNameAlreadyTaken(err) {\n\treturn isStringKeyedRecord(err) && (err[\"name\"] === \"ServerAlreadyRunningError\" || err[\"name\"] === \"ServerStateAlreadyExistsError\");\n}\n/** The port of a postgres connection URL, when it parses as one. */\nfunction databasePortOf(connectionString) {\n\ttry {\n\t\tconst port = Number(new URL(connectionString).port);\n\t\treturn Number.isInteger(port) && port > 0 ? port : void 0;\n\t} catch {\n\t\treturn;\n\t}\n}\n/**\n* A dynamic `import()` failure's own message routinely names a SECOND path\n* (e.g. bun's \"Cannot find module '<target>' from '<importer>'\") — the\n* importer half is this daemon's own internal location, not anything the\n* caller gave us, and has no business in a response body. Rather than try\n* to scrub an arbitrary underlying message for every runtime's own error\n* phrasing, the resolution-failure case names only what the caller\n* supplied — the pinned message plus the given `prismaDevModulePath`, and\n* nothing else. (A DIFFERENT case — a module that resolves fine but whose\n* `startPrismaDevServer()` call itself fails — still surfaces its\n* underlying text verbatim, credential-masked, per spec § 2.)\n*/\nasync function importPrismaDev(prismaDevModulePath) {\n\tlet mod;\n\ttry {\n\t\tmod = await import(pathToFileURL(prismaDevModulePath).href);\n\t} catch {\n\t\tthrow new Error(`${NOT_INSTALLED_MESSAGE} (could not resolve \"${prismaDevModulePath}\")`);\n\t}\n\tif (!isPrismaDevModule(mod)) throw new Error(`${NOT_INSTALLED_MESSAGE} (\"${prismaDevModulePath}\" is not a @prisma/dev module)`);\n\treturn mod;\n}\nfunction isStringKeyedRecord(value) {\n\treturn typeof value === \"object\" && value !== null;\n}\nfunction isPrismaDevInternalStateModule(value) {\n\treturn isStringKeyedRecord(value) && typeof value[\"deleteServer\"] === \"function\" && typeof value[\"killServer\"] === \"function\" && typeof value[\"getServerStatus\"] === \"function\";\n}\n/**\n* Every port any `@prisma/dev` server RECORD on this machine claims —\n* database, http, shadow, and streams. `startPrismaDevServer` validates a\n* requested port against these records (`ServerState.scan`) and refuses one\n* that any record claims, even when nothing has it bound — and a record's\n* aux ports are picked by `@prisma/dev`'s own walking-upward picker, which\n* over enough servers climbs into this daemon's database range. A fresh\n* database-port pick that only probed the OS would collide with such a\n* claim, so fresh picks exclude these too. Best-effort: `scan` is the same\n* internal surface the rest of this module already binds to, but absent or\n* failing it degrades to the OS probe alone.\n*/\nasync function registryClaimedPorts(internalState) {\n\tconst ports = /* @__PURE__ */ new Set();\n\tconst scanHost = isStringKeyedRecord(internalState) ? internalState[\"ServerState\"] : void 0;\n\tconst scan = isStringKeyedRecord(scanHost) ? scanHost[\"scan\"] : void 0;\n\tif (!isStringKeyedRecord(scanHost) || typeof scan !== \"function\") return ports;\n\ttry {\n\t\tconst records = await scan.call(scanHost, { onlyMetadata: true });\n\t\tif (!Array.isArray(records)) return ports;\n\t\tfor (const record of records) {\n\t\t\tif (!isStringKeyedRecord(record)) continue;\n\t\t\tfor (const key of [\n\t\t\t\t\"databasePort\",\n\t\t\t\t\"port\",\n\t\t\t\t\"shadowDatabasePort\",\n\t\t\t\t\"streamsPort\"\n\t\t\t]) {\n\t\t\t\tconst port = record[key];\n\t\t\t\tif (typeof port === \"number\" && Number.isInteger(port) && port > 0) ports.add(port);\n\t\t\t}\n\t\t\tconst experimental = record[\"experimental\"];\n\t\t\tconst streams = isStringKeyedRecord(experimental) ? experimental[\"streams\"] : void 0;\n\t\t\tconst streamsUrl = isStringKeyedRecord(streams) ? streams[\"serverUrl\"] : void 0;\n\t\t\tif (typeof streamsUrl === \"string\") {\n\t\t\t\tconst port = databasePortOf(streamsUrl);\n\t\t\t\tif (port !== void 0) ports.add(port);\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn ports;\n}\nfunction readServerStatus(status) {\n\tif (!isStringKeyedRecord(status)) return {\n\t\tlive: false,\n\t\trecordExists: true,\n\t\tpid: void 0,\n\t\turl: void 0,\n\t\tdatabasePort: void 0\n\t};\n\tconst exports = status[\"exports\"];\n\tconst database = isStringKeyedRecord(exports) ? exports[\"database\"] : void 0;\n\tconst url = isStringKeyedRecord(database) ? database[\"connectionString\"] : void 0;\n\tconst pid = status[\"pid\"];\n\tconst databasePort = status[\"databasePort\"];\n\treturn {\n\t\tlive: status[\"status\"] === \"running\" || status[\"status\"] === \"starting_up\",\n\t\trecordExists: status[\"status\"] !== \"no_such_server\",\n\t\tpid: typeof pid === \"number\" ? pid : void 0,\n\t\turl: typeof url === \"string\" ? url : void 0,\n\t\tdatabasePort: typeof databasePort === \"number\" ? databasePort : void 0\n\t};\n}\nasync function serverStatusOf(internalState, instanceName) {\n\ttry {\n\t\treturn readServerStatus(await internalState.getServerStatus(instanceName));\n\t} catch {\n\t\treturn {\n\t\t\tlive: false,\n\t\t\trecordExists: true,\n\t\t\tpid: void 0,\n\t\t\turl: void 0,\n\t\t\tdatabasePort: void 0\n\t\t};\n\t}\n}\nconst CLOSE_SETTLE_ATTEMPTS = 40;\nconst CLOSE_SETTLE_DELAY_MS = 250;\n/** True once the named server's persisted state no longer claims it is live — the precondition for `deleteServer`, whose kill path targets the pid in that state, which for an in-daemon server is THIS DAEMON's own pid. */\nasync function settledAfterClose(internalState, instanceName) {\n\tfor (let attempt = 1; attempt <= CLOSE_SETTLE_ATTEMPTS; attempt += 1) {\n\t\tif (!(await serverStatusOf(internalState, instanceName)).live) return true;\n\t\tif (attempt < CLOSE_SETTLE_ATTEMPTS) await new Promise((resolve) => setTimeout(resolve, CLOSE_SETTLE_DELAY_MS));\n\t}\n\treturn false;\n}\n/**\n* `@prisma/dev`'s own package.json declares `./internal/state`, whose\n* `deleteServer(name)` actually removes a stateful server's persisted PGlite\n* data — `startPrismaDevServer`'s public surface only starts/closes a live\n* server, never deletes what a closed one left on disk. Resolved by reading\n* the SAME package's own `exports` map (walked up from the caller-given\n* entry path to find `@prisma/dev`'s `package.json`), never by guessing at\n* `dist/` file layout.\n*/\nasync function importPrismaDevInternalState(prismaDevModulePath) {\n\tlet dir = path.dirname(prismaDevModulePath);\n\tfor (;;) {\n\t\tconst pkgPath = path.join(dir, \"package.json\");\n\t\tif (fs.existsSync(pkgPath)) {\n\t\t\tconst pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n\t\t\tif (isStringKeyedRecord(pkg) && pkg[\"name\"] === \"@prisma/dev\" && isStringKeyedRecord(pkg[\"exports\"])) {\n\t\t\t\tconst entry = pkg[\"exports\"][\"./internal/state\"];\n\t\t\t\tconst target = resolveExportTarget(entry);\n\t\t\t\tif (target === void 0) throw new Error(`\"@prisma/dev\" at \"${dir}\" does not declare an \"./internal/state\" export — cannot delete its persisted database data.`);\n\t\t\t\tconst mod = await import(pathToFileURL(path.join(dir, target)).href);\n\t\t\t\tif (isPrismaDevInternalStateModule(mod)) return mod;\n\t\t\t\tthrow new Error(`\"@prisma/dev\"'s \"./internal/state\" export at \"${dir}\" has no deleteServer.`);\n\t\t\t}\n\t\t}\n\t\tconst parent = path.dirname(dir);\n\t\tif (parent === dir) throw new Error(`could not find \"@prisma/dev\"'s package.json above \"${prismaDevModulePath}\".`);\n\t\tdir = parent;\n\t}\n}\nfunction resolveExportTarget(entry) {\n\tif (typeof entry === \"string\") return entry;\n\tif (!isStringKeyedRecord(entry)) return void 0;\n\tconst nested = entry[\"import\"] ?? entry[\"require\"] ?? entry[\"default\"];\n\tif (typeof nested === \"string\") return nested;\n\tif (isStringKeyedRecord(nested)) {\n\t\tconst def = nested[\"default\"];\n\t\tif (typeof def === \"string\") return def;\n\t}\n}\nfunction parseArgs(argv) {\n\tlet port;\n\tlet stateDir;\n\tfor (let i = 0; i < argv.length; i++) if (argv[i] === \"--port\") port = Number(argv[i + 1]);\n\telse if (argv[i] === \"--state-dir\") stateDir = argv[i + 1];\n\tif (port === void 0 || Number.isNaN(port)) throw new Error(\"postgres-main: --port <n> is required\");\n\tif (stateDir === void 0) throw new Error(\"postgres-main: --state-dir <dir> is required\");\n\treturn {\n\t\tport,\n\t\tstateDir\n\t};\n}\nfunction readBody(req) {\n\treturn new Promise((resolve, reject) => {\n\t\tconst chunks = [];\n\t\treq.on(\"data\", (chunk) => chunks.push(chunk));\n\t\treq.on(\"end\", () => resolve(Buffer.concat(chunks)));\n\t\treq.on(\"error\", reject);\n\t});\n}\nfunction main() {\n\tconst { port, stateDir } = parseArgs(process.argv.slice(2));\n\tconst ownVersion = readOwnVersion();\n\tconst appsJsonPath = path.join(stateDir, \"apps.json\");\n\tconst stateFile = new StateFile(appsJsonPath, APPS_STATE_MODE);\n\tlet state = {};\n\tconst runtimes = /* @__PURE__ */ new Map();\n\t/**\n\t* Server starts run ONE AT A TIME. `@prisma/dev`'s start is not\n\t* concurrency-safe within a process: two simultaneous calls pick their\n\t* ports without seeing each other and one fails with a port refusal\n\t* (verified directly — two concurrent starts with distinct, pinned\n\t* database ports fail; the same two started in sequence both succeed).\n\t* The daemon issues concurrent starts whenever an app converges more than\n\t* one database, which is what produced the port refusals, the retries\n\t* whose half-started servers held their own name's lock, and every\n\t* \"already running\" failure downstream of that.\n\t*/\n\tlet startQueue = Promise.resolve();\n\tfunction serializeStart(run) {\n\t\tconst next = startQueue.then(run, run);\n\t\tstartQueue = next.then(() => void 0, () => void 0);\n\t\treturn next;\n\t}\n\tfunction schedulePersist() {\n\t\tstateFile.write(state);\n\t}\n\tfunction getOrCreateApp(app) {\n\t\tlet appRec = state[app];\n\t\tif (!appRec) {\n\t\t\tappRec = { databases: {} };\n\t\t\tstate[app] = appRec;\n\t\t}\n\t\treturn appRec;\n\t}\n\tfunction usedDatabasePorts() {\n\t\tconst ports = /* @__PURE__ */ new Set();\n\t\tfor (const appRec of Object.values(state)) for (const db of Object.values(appRec.databases)) ports.add(db.databasePort);\n\t\treturn ports;\n\t}\n\tasync function smallestUnusedDatabasePort(min, alsoExclude = /* @__PURE__ */ new Set()) {\n\t\treturn getPort({\n\t\t\tport: portNumbers(min, MAX_DATABASE_PORT),\n\t\t\texclude: [...usedDatabasePorts(), ...alsoExclude]\n\t\t});\n\t}\n\tconst inflightEnsures = /* @__PURE__ */ new Map();\n\t/**\n\t* Names whose `startPrismaDevServer` call failed in THIS process for any\n\t* reason other than \"already running\". `@prisma/dev` acquires the name's\n\t* lock before it validates the requested ports, and a failure after that\n\t* point (a port refusal) propagates WITHOUT releasing the lock — so the\n\t* very next start of the same name in this process is refused as \"already\n\t* running\" by a holder that is this daemon's own dead attempt, and no\n\t* amount of waiting frees it. Membership here is what makes deleting that\n\t* lock provably safe: a name this process leaked cannot have been\n\t* acquired by anyone else since (the leak never releases).\n\t*/\n\tconst leakedStartNames = /* @__PURE__ */ new Set();\n\t/** Concurrent PUTs for the same database coalesce onto one start — a second `startPrismaDevServer` for a name whose first start is still booting fails as \"already running\". */\n\tfunction ensureDatabase(app, id, prismaDevModulePath) {\n\t\tconst instanceName = instanceNameFor(app, id);\n\t\tconst inflight = inflightEnsures.get(instanceName);\n\t\tif (inflight) return inflight;\n\t\tconst run = ensureDatabaseSerialized(app, id, prismaDevModulePath, instanceName).finally(() => {\n\t\t\tinflightEnsures.delete(instanceName);\n\t\t});\n\t\tinflightEnsures.set(instanceName, run);\n\t\treturn run;\n\t}\n\tasync function ensureDatabaseSerialized(app, id, prismaDevModulePath, instanceName) {\n\t\tconst appRec = getOrCreateApp(app);\n\t\tconst existingRecord = appRec.databases[id];\n\t\tconst runningServer = runtimes.get(instanceName);\n\t\tif (existingRecord && runningServer) return { url: existingRecord.url };\n\t\tconst prismaDev = await importPrismaDev(prismaDevModulePath);\n\t\tconst internalState = await importPrismaDevInternalState(prismaDevModulePath);\n\t\tconst recorded = await serverStatusOf(internalState, instanceName);\n\t\tif (recorded.live && recorded.pid !== void 0 && isPidAlive(recorded.pid)) {\n\t\t\tif (recorded.url !== void 0) {\n\t\t\t\tappRec.databases[id] = {\n\t\t\t\t\tid,\n\t\t\t\t\tinstanceName,\n\t\t\t\t\tdatabasePort: recorded.databasePort ?? databasePortOf(recorded.url) ?? MIN_DATABASE_PORT,\n\t\t\t\t\turl: recorded.url\n\t\t\t\t};\n\t\t\t\tschedulePersist();\n\t\t\t\treturn { url: recorded.url };\n\t\t\t}\n\t\t} else if (recorded.live) await internalState.killServer(instanceName).catch(() => void 0);\n\t\tconst isFreshAllocation = existingRecord === void 0;\n\t\tconst registryPorts = isFreshAllocation ? await registryClaimedPorts(internalState) : /* @__PURE__ */ new Set();\n\t\tlet dbPort = existingRecord?.databasePort ?? await smallestUnusedDatabasePort(MIN_DATABASE_PORT, registryPorts);\n\t\tconst conflicted = /* @__PURE__ */ new Set();\n\t\tlet alreadyRunningRetries = 0;\n\t\tfor (let attempt = 1;; attempt++) try {\n\t\t\tconst server = await serializeStart(() => prismaDev.startPrismaDevServer({\n\t\t\t\tname: instanceName,\n\t\t\t\tdatabasePort: dbPort,\n\t\t\t\tpersistenceMode: \"stateful\"\n\t\t\t}));\n\t\t\tconst url = server.database.connectionString;\n\t\t\tleakedStartNames.delete(instanceName);\n\t\t\truntimes.set(instanceName, server);\n\t\t\tappRec.databases[id] = {\n\t\t\t\tid,\n\t\t\t\tinstanceName,\n\t\t\t\tdatabasePort: dbPort,\n\t\t\t\turl\n\t\t\t};\n\t\t\tschedulePersist();\n\t\t\treturn { url };\n\t\t} catch (err) {\n\t\t\tif (isNameAlreadyTaken(err) && alreadyRunningRetries < MAX_ALREADY_RUNNING_RETRIES) {\n\t\t\t\talreadyRunningRetries += 1;\n\t\t\t\tif (leakedStartNames.has(instanceName)) {\n\t\t\t\t\tif (!(await serverStatusOf(internalState, instanceName)).recordExists) {\n\t\t\t\t\t\tawait internalState.deleteServer(instanceName).catch(() => void 0);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (let poll = 1; poll <= ALREADY_RUNNING_POLLS; poll += 1) {\n\t\t\t\t\tconst now = await serverStatusOf(internalState, instanceName);\n\t\t\t\t\tif (now.live && now.pid !== void 0 && isPidAlive(now.pid) && now.url !== void 0) {\n\t\t\t\t\t\tappRec.databases[id] = {\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tinstanceName,\n\t\t\t\t\t\t\tdatabasePort: now.databasePort ?? databasePortOf(now.url) ?? dbPort,\n\t\t\t\t\t\t\turl: now.url\n\t\t\t\t\t\t};\n\t\t\t\t\t\tschedulePersist();\n\t\t\t\t\t\treturn { url: now.url };\n\t\t\t\t\t}\n\t\t\t\t\tif (now.live && (now.pid === void 0 || !isPidAlive(now.pid))) {\n\t\t\t\t\t\tawait internalState.killServer(instanceName).catch(() => void 0);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, ALREADY_RUNNING_POLL_MS));\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!isNameAlreadyTaken(err)) leakedStartNames.add(instanceName);\n\t\t\tconst conflictPort = portConflictOf(err, [dbPort]);\n\t\t\tif (!(conflictPort !== void 0 && attempt < MAX_FRESH_PORT_CANDIDATES && (conflictPort !== dbPort || isFreshAllocation))) {\n\t\t\t\tconst reason = err instanceof Error ? err.message : String(err);\n\t\t\t\tthrow new Error(`postgres emulator failed to start database \"${instanceName}\" on port ${String(dbPort)}: ${maskCredentials(firstLine(reason))}`);\n\t\t\t}\n\t\t\tconflicted.add(conflictPort);\n\t\t\tif (conflictPort === dbPort) dbPort = await smallestUnusedDatabasePort(dbPort + 1, /* @__PURE__ */ new Set([...conflicted, ...registryPorts]));\n\t\t}\n\t}\n\tasync function deleteApp(app, prismaDevModulePathHint) {\n\t\tconst appRec = state[app];\n\t\tif (!appRec) return;\n\t\tconst entries = Object.values(appRec.databases);\n\t\tfor (const db of entries) {\n\t\t\tconst server = runtimes.get(db.instanceName);\n\t\t\tif (server) {\n\t\t\t\tawait server.close().catch(() => void 0);\n\t\t\t\truntimes.delete(db.instanceName);\n\t\t\t}\n\t\t}\n\t\tif (entries.length > 0 && prismaDevModulePathHint) {\n\t\t\tconst internalState = await importPrismaDevInternalState(prismaDevModulePathHint);\n\t\t\tfor (const db of entries) {\n\t\t\t\tif (!runtimes.has(db.instanceName)) {\n\t\t\t\t\tif ((await serverStatusOf(internalState, db.instanceName)).pid !== process.pid) await internalState.killServer(db.instanceName).catch(() => void 0);\n\t\t\t\t}\n\t\t\t\tif (!await settledAfterClose(internalState, db.instanceName)) {\n\t\t\t\t\tconsole.error(`postgres-main: server \"${db.instanceName}\" still reports running after close — leaving its persisted data in place instead of risking a self-kill.`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tawait internalState.deleteServer(db.instanceName);\n\t\t\t}\n\t\t}\n\t\tdelete state[app];\n\t\tschedulePersist();\n\t}\n\tfunction json(res, status, body) {\n\t\tres.writeHead(status, { \"content-type\": \"application/json\" });\n\t\tres.end(JSON.stringify(body));\n\t}\n\tfunction text(res, status, body) {\n\t\tres.writeHead(status, { \"content-type\": \"text/plain; charset=utf-8\" });\n\t\tres.end(body);\n\t}\n\tfunction badSegment(res, segment) {\n\t\ttext(res, 400, `invalid path segment \"${segment}\": must match /^[a-z0-9][a-z0-9-]*$/ and be at most 63 characters`);\n\t}\n\tfunction databaseView(db) {\n\t\treturn {\n\t\t\tid: db.id,\n\t\t\turl: db.url,\n\t\t\tinstanceName: db.instanceName,\n\t\t\tdatabasePort: db.databasePort\n\t\t};\n\t}\n\t/** The most recently observed `prismaDevModulePath` for any database of `app` — DELETE has no body of its own to carry one. */\n\tconst recentPrismaDevModulePath = /* @__PURE__ */ new Map();\n\tfunction lastKnownPrismaDevModulePath(app) {\n\t\treturn recentPrismaDevModulePath.get(app);\n\t}\n\tasync function handleRequest(req, res) {\n\t\tconst url = new URL(req.url ?? \"/\", `http://127.0.0.1:${String(port)}`);\n\t\tconst method = req.method ?? \"GET\";\n\t\tconst segments = url.pathname.split(\"/\").filter((s) => s.length > 0).map((s) => decodeURIComponent(s));\n\t\tif (method === \"GET\" && segments.length === 1 && segments[0] === \"health\") return json(res, 200, { version: ownVersion });\n\t\tif (segments[0] === \"apps\" && segments.length >= 2) {\n\t\t\tconst app = segments[1];\n\t\t\tif (app === void 0 || !isValidSegment(app)) return badSegment(res, app ?? \"\");\n\t\t\tif (method === \"PUT\" && segments.length === 4 && segments[2] === \"databases\") {\n\t\t\t\tconst id = segments[3];\n\t\t\t\tif (id === void 0 || !isValidSegment(id)) return badSegment(res, id ?? \"\");\n\t\t\t\tconst raw = await readBody(req);\n\t\t\t\tlet parsed;\n\t\t\t\ttry {\n\t\t\t\t\tparsed = JSON.parse(raw.toString(\"utf8\"));\n\t\t\t\t} catch {\n\t\t\t\t\treturn text(res, 400, \"malformed JSON body\");\n\t\t\t\t}\n\t\t\t\tif (!isDatabaseBody(parsed)) return text(res, 400, \"malformed database body: expected { \\\"prismaDevModulePath\\\": string }\");\n\t\t\t\trecentPrismaDevModulePath.set(app, parsed.prismaDevModulePath);\n\t\t\t\treturn json(res, 200, await ensureDatabase(app, id, parsed.prismaDevModulePath));\n\t\t\t}\n\t\t\tif (method === \"GET\" && segments.length === 3 && segments[2] === \"databases\") {\n\t\t\t\tconst appRec = state[app];\n\t\t\t\treturn json(res, 200, appRec ? Object.values(appRec.databases).map(databaseView) : []);\n\t\t\t}\n\t\t\tif (method === \"DELETE\" && segments.length === 2) {\n\t\t\t\tawait deleteApp(app, lastKnownPrismaDevModulePath(app));\n\t\t\t\tres.writeHead(204);\n\t\t\t\tres.end();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tres.writeHead(404);\n\t\tres.end();\n\t}\n\tconst server = http.createServer((req, res) => {\n\t\thandleRequest(req, res).catch((err) => {\n\t\t\tif (!res.headersSent) res.writeHead(500, { \"content-type\": \"text/plain\" });\n\t\t\tres.end(err instanceof Error ? maskCredentials(err.message) : String(err));\n\t\t});\n\t});\n\tasync function shutdown() {\n\t\tfor (const server of runtimes.values()) await server.close().catch(() => void 0);\n\t\tawait stateFile.flush();\n\t\tserver.close();\n\t\tprocess.exit(0);\n\t}\n\tprocess.on(\"SIGTERM\", () => void shutdown());\n\tprocess.on(\"SIGINT\", () => void shutdown());\n\tprocess.on(\"unhandledRejection\", (reason) => {\n\t\tconsole.error(\"postgres-main: unhandled rejection from background work:\", reason instanceof Error ? maskCredentials(reason.stack ?? reason.message) : reason);\n\t});\n\tprocess.on(\"uncaughtException\", (err) => {\n\t\tconsole.error(\"postgres-main: uncaught exception from background work:\", err instanceof Error ? maskCredentials(err.stack ?? err.message) : err);\n\t});\n\treadJsonFile(appsJsonPath, isAppsState).then((loaded) => {\n\t\tif (loaded) state = loaded;\n\t\tserver.listen(port, \"127.0.0.1\", () => {\n\t\t\tconsole.log(`[dev-emulators] postgres-main listening on 127.0.0.1:${String(port)}`);\n\t\t});\n\t}).catch((err) => {\n\t\tconsole.error(\"postgres-main: failed to load state\", err);\n\t\tprocess.exit(1);\n\t});\n}\nmain();\n//#endregion\nexport {};\n\n//# sourceMappingURL=postgres-main.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAS,KAAK,SAAS;CACtB,MAAM,YAAY,QAAQ,YAAY,CAAC,CAAC,QAAQ,cAAc,GAAG,CAAC,CAAC,QAAQ,UAAU,GAAG;CACxF,IAAI,QAAQ;CACZ,IAAI,MAAM,UAAU;CACpB,OAAO,QAAQ,OAAO,UAAU,WAAW,KAAK;CAChD,OAAO,MAAM,SAAS,UAAU,MAAM,OAAO,KAAK;CAClD,OAAO,UAAU,MAAM,OAAO,GAAG;AAClC;AACA,SAAS,gBAAgB,KAAK,IAAI;CACjC,OAAO,SAAS,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,IAAI,MAAM,GAAG,EAAE;AACpD;;;;;;;;;;;;;;;;;;ACRA,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;;AAExB,MAAM,4BAA4B;;;;;;;;AAQlC,MAAM,8BAA8B;AACpC,MAAM,wBAAwB;AAC9B,MAAM,0BAA0B;AAChC,MAAM,wBAAwB;AAC9B,SAAS,gBAAgB,MAAM;CAC9B,OAAO,KAAK,QAAQ,+BAA+B,YAAY;AAChE;AACA,SAAS,UAAU,MAAM;CACxB,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,KAAA,CAAM,KAAK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gBAAgB,aAAa,CAAC;GACzE,IAAI,IAAI,eAAe,QAAQ,gBAAgB,IAAI,OAAO,IAAI,OAAO,GAAG,CAAC;EAC1E,CAAC;CACF,CAAC;CACD,eAAe,WAAW;EACzB,KAAK,MAAM,UAAU,SAAS,OAAO,GAAG,MAAM,OAAO,MAAM,CAAC,CAAC,YAAY,KAAK,CAAC;EAC/E,MAAM,UAAU,MAAM;EACtB,OAAO,MAAM;EACb,QAAQ,KAAK,CAAC;CACf;CACA,QAAQ,GAAG,iBAAiB,KAAK,SAAS,CAAC;CAC3C,QAAQ,GAAG,gBAAgB,KAAK,SAAS,CAAC;CAC1C,QAAQ,GAAG,uBAAuB,WAAW;EAC5C,QAAQ,MAAM,4DAA4D,kBAAkB,QAAQ,gBAAgB,OAAO,SAAS,OAAO,OAAO,IAAI,MAAM;CAC7J,CAAC;CACD,QAAQ,GAAG,sBAAsB,QAAQ;EACxC,QAAQ,MAAM,2DAA2D,eAAe,QAAQ,gBAAgB,IAAI,SAAS,IAAI,OAAO,IAAI,GAAG;CAChJ,CAAC;CACD,aAAa,cAAc,WAAW,CAAC,CAAC,MAAM,WAAW;EACxD,IAAI,QAAQ,QAAQ;EACpB,OAAO,OAAO,MAAM,mBAAmB;GACtC,QAAQ,IAAI,wDAAwD,OAAO,IAAI,GAAG;EACnF,CAAC;CACF,CAAC,CAAC,CAAC,OAAO,QAAQ;EACjB,QAAQ,MAAM,uCAAuC,GAAG;EACxD,QAAQ,KAAK,CAAC;CACf,CAAC;AACF;AACA,KAAK"}
|
|
@@ -1414,6 +1414,9 @@ async function readJsonFile(filePath, isValid) {
|
|
|
1414
1414
|
}
|
|
1415
1415
|
return isValid(parsed) ? parsed : void 0;
|
|
1416
1416
|
}
|
|
1417
|
+
function isErrnoException(err) {
|
|
1418
|
+
return err instanceof Error && "code" in err;
|
|
1419
|
+
}
|
|
1417
1420
|
function isPackageJson(value) {
|
|
1418
1421
|
return typeof value === "object" && value !== null && "version" in value && typeof value.version === "string";
|
|
1419
1422
|
}
|
|
@@ -1426,6 +1429,16 @@ function readOwnVersion() {
|
|
|
1426
1429
|
if (!isPackageJson(parsed)) throw new Error(`could not read a version string from ${pkgPath}`);
|
|
1427
1430
|
return parsed.version;
|
|
1428
1431
|
}
|
|
1432
|
+
/** `process.kill(pid, 0)` existence probe — true unless the pid is provably gone (ESRCH). */
|
|
1433
|
+
function isPidAlive(pid) {
|
|
1434
|
+
try {
|
|
1435
|
+
process.kill(pid, 0);
|
|
1436
|
+
return true;
|
|
1437
|
+
} catch (err) {
|
|
1438
|
+
if (isErrnoException(err) && err.code === "EPERM") return true;
|
|
1439
|
+
return false;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1429
1442
|
/**
|
|
1430
1443
|
* API hygiene shared by both daemons (local-dev spec § 2): every `<app>`,
|
|
1431
1444
|
* `<id>`, and `<name>` path segment must match this shape or the request is
|
|
@@ -1436,6 +1449,6 @@ function isValidSegment(segment) {
|
|
|
1436
1449
|
return segment.length <= 63 && SEGMENT_RE.test(segment);
|
|
1437
1450
|
}
|
|
1438
1451
|
//#endregion
|
|
1439
|
-
export { readOwnVersion as i,
|
|
1452
|
+
export { readOwnVersion as a, readJsonFile as i, isPidAlive as n, isValidSegment as r, StateFile as t };
|
|
1440
1453
|
|
|
1441
|
-
//# sourceMappingURL=segments-NpKN-46R-
|
|
1454
|
+
//# sourceMappingURL=segments-NpKN-46R-C_LQ2urs.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segments-NpKN-46R-B01DmCqy.mjs","names":["fs","path"],"sources":["../../../../node_modules/graceful-fs/polyfills.js","../../../../node_modules/graceful-fs/legacy-streams.js","../../../../node_modules/graceful-fs/clone.js","../../../../node_modules/graceful-fs/graceful-fs.js","../../../../node_modules/retry/lib/retry_operation.js","../../../../node_modules/retry/lib/retry.js","../../../../node_modules/retry/index.js","../../../../node_modules/signal-exit/signals.js","../../../../node_modules/signal-exit/index.js","../../../../node_modules/proper-lockfile/lib/mtime-precision.js","../../../../node_modules/proper-lockfile/lib/lockfile.js","../../../../node_modules/proper-lockfile/lib/adapter.js","../../../../node_modules/proper-lockfile/index.js","../../../1-prisma-cloud/0-lowering/dev-emulators/dist/segments-NpKN-46R.mjs"],"sourcesContent":["var constants = require('constants')\n\nvar origCwd = process.cwd\nvar cwd = null\n\nvar platform = process.env.GRACEFUL_FS_PLATFORM || process.platform\n\nprocess.cwd = function() {\n if (!cwd)\n cwd = origCwd.call(process)\n return cwd\n}\ntry {\n process.cwd()\n} catch (er) {}\n\n// This check is needed until node.js 12 is required\nif (typeof process.chdir === 'function') {\n var chdir = process.chdir\n process.chdir = function (d) {\n cwd = null\n chdir.call(process, d)\n }\n if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir)\n}\n\nmodule.exports = patch\n\nfunction patch (fs) {\n // (re-)implement some things that are known busted or missing.\n\n // lchmod, broken prior to 0.6.2\n // back-port the fix here.\n if (constants.hasOwnProperty('O_SYMLINK') &&\n process.version.match(/^v0\\.6\\.[0-2]|^v0\\.5\\./)) {\n patchLchmod(fs)\n }\n\n // lutimes implementation, or no-op\n if (!fs.lutimes) {\n patchLutimes(fs)\n }\n\n // https://github.com/isaacs/node-graceful-fs/issues/4\n // Chown should not fail on einval or eperm if non-root.\n // It should not fail on enosys ever, as this just indicates\n // that a fs doesn't support the intended operation.\n\n fs.chown = chownFix(fs.chown)\n fs.fchown = chownFix(fs.fchown)\n fs.lchown = chownFix(fs.lchown)\n\n fs.chmod = chmodFix(fs.chmod)\n fs.fchmod = chmodFix(fs.fchmod)\n fs.lchmod = chmodFix(fs.lchmod)\n\n fs.chownSync = chownFixSync(fs.chownSync)\n fs.fchownSync = chownFixSync(fs.fchownSync)\n fs.lchownSync = chownFixSync(fs.lchownSync)\n\n fs.chmodSync = chmodFixSync(fs.chmodSync)\n fs.fchmodSync = chmodFixSync(fs.fchmodSync)\n fs.lchmodSync = chmodFixSync(fs.lchmodSync)\n\n fs.stat = statFix(fs.stat)\n fs.fstat = statFix(fs.fstat)\n fs.lstat = statFix(fs.lstat)\n\n fs.statSync = statFixSync(fs.statSync)\n fs.fstatSync = statFixSync(fs.fstatSync)\n fs.lstatSync = statFixSync(fs.lstatSync)\n\n // if lchmod/lchown do not exist, then make them no-ops\n if (fs.chmod && !fs.lchmod) {\n fs.lchmod = function (path, mode, cb) {\n if (cb) process.nextTick(cb)\n }\n fs.lchmodSync = function () {}\n }\n if (fs.chown && !fs.lchown) {\n fs.lchown = function (path, uid, gid, cb) {\n if (cb) process.nextTick(cb)\n }\n fs.lchownSync = function () {}\n }\n\n // on Windows, A/V software can lock the directory, causing this\n // to fail with an EACCES or EPERM if the directory contains newly\n // created files. Try again on failure, for up to 60 seconds.\n\n // Set the timeout this long because some Windows Anti-Virus, such as Parity\n // bit9, may lock files for up to a minute, causing npm package install\n // failures. Also, take care to yield the scheduler. Windows scheduling gives\n // CPU to a busy looping process, which can cause the program causing the lock\n // contention to be starved of CPU by node, so the contention doesn't resolve.\n if (platform === \"win32\") {\n fs.rename = typeof fs.rename !== 'function' ? fs.rename\n : (function (fs$rename) {\n function rename (from, to, cb) {\n var start = Date.now()\n var backoff = 0;\n fs$rename(from, to, function CB (er) {\n if (er\n && (er.code === \"EACCES\" || er.code === \"EPERM\" || er.code === \"EBUSY\")\n && Date.now() - start < 60000) {\n setTimeout(function() {\n fs.stat(to, function (stater, st) {\n if (stater && stater.code === \"ENOENT\")\n fs$rename(from, to, CB);\n else\n cb(er)\n })\n }, backoff)\n if (backoff < 100)\n backoff += 10;\n return;\n }\n if (cb) cb(er)\n })\n }\n if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename)\n return rename\n })(fs.rename)\n }\n\n // if read() returns EAGAIN, then just try it again.\n fs.read = typeof fs.read !== 'function' ? fs.read\n : (function (fs$read) {\n function read (fd, buffer, offset, length, position, callback_) {\n var callback\n if (callback_ && typeof callback_ === 'function') {\n var eagCounter = 0\n callback = function (er, _, __) {\n if (er && er.code === 'EAGAIN' && eagCounter < 10) {\n eagCounter ++\n return fs$read.call(fs, fd, buffer, offset, length, position, callback)\n }\n callback_.apply(this, arguments)\n }\n }\n return fs$read.call(fs, fd, buffer, offset, length, position, callback)\n }\n\n // This ensures `util.promisify` works as it does for native `fs.read`.\n if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read)\n return read\n })(fs.read)\n\n fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync\n : (function (fs$readSync) { return function (fd, buffer, offset, length, position) {\n var eagCounter = 0\n while (true) {\n try {\n return fs$readSync.call(fs, fd, buffer, offset, length, position)\n } catch (er) {\n if (er.code === 'EAGAIN' && eagCounter < 10) {\n eagCounter ++\n continue\n }\n throw er\n }\n }\n }})(fs.readSync)\n\n function patchLchmod (fs) {\n fs.lchmod = function (path, mode, callback) {\n fs.open( path\n , constants.O_WRONLY | constants.O_SYMLINK\n , mode\n , function (err, fd) {\n if (err) {\n if (callback) callback(err)\n return\n }\n // prefer to return the chmod error, if one occurs,\n // but still try to close, and report closing errors if they occur.\n fs.fchmod(fd, mode, function (err) {\n fs.close(fd, function(err2) {\n if (callback) callback(err || err2)\n })\n })\n })\n }\n\n fs.lchmodSync = function (path, mode) {\n var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)\n\n // prefer to return the chmod error, if one occurs,\n // but still try to close, and report closing errors if they occur.\n var threw = true\n var ret\n try {\n ret = fs.fchmodSync(fd, mode)\n threw = false\n } finally {\n if (threw) {\n try {\n fs.closeSync(fd)\n } catch (er) {}\n } else {\n fs.closeSync(fd)\n }\n }\n return ret\n }\n }\n\n function patchLutimes (fs) {\n if (constants.hasOwnProperty(\"O_SYMLINK\") && fs.futimes) {\n fs.lutimes = function (path, at, mt, cb) {\n fs.open(path, constants.O_SYMLINK, function (er, fd) {\n if (er) {\n if (cb) cb(er)\n return\n }\n fs.futimes(fd, at, mt, function (er) {\n fs.close(fd, function (er2) {\n if (cb) cb(er || er2)\n })\n })\n })\n }\n\n fs.lutimesSync = function (path, at, mt) {\n var fd = fs.openSync(path, constants.O_SYMLINK)\n var ret\n var threw = true\n try {\n ret = fs.futimesSync(fd, at, mt)\n threw = false\n } finally {\n if (threw) {\n try {\n fs.closeSync(fd)\n } catch (er) {}\n } else {\n fs.closeSync(fd)\n }\n }\n return ret\n }\n\n } else if (fs.futimes) {\n fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }\n fs.lutimesSync = function () {}\n }\n }\n\n function chmodFix (orig) {\n if (!orig) return orig\n return function (target, mode, cb) {\n return orig.call(fs, target, mode, function (er) {\n if (chownErOk(er)) er = null\n if (cb) cb.apply(this, arguments)\n })\n }\n }\n\n function chmodFixSync (orig) {\n if (!orig) return orig\n return function (target, mode) {\n try {\n return orig.call(fs, target, mode)\n } catch (er) {\n if (!chownErOk(er)) throw er\n }\n }\n }\n\n\n function chownFix (orig) {\n if (!orig) return orig\n return function (target, uid, gid, cb) {\n return orig.call(fs, target, uid, gid, function (er) {\n if (chownErOk(er)) er = null\n if (cb) cb.apply(this, arguments)\n })\n }\n }\n\n function chownFixSync (orig) {\n if (!orig) return orig\n return function (target, uid, gid) {\n try {\n return orig.call(fs, target, uid, gid)\n } catch (er) {\n if (!chownErOk(er)) throw er\n }\n }\n }\n\n function statFix (orig) {\n if (!orig) return orig\n // Older versions of Node erroneously returned signed integers for\n // uid + gid.\n return function (target, options, cb) {\n if (typeof options === 'function') {\n cb = options\n options = null\n }\n function callback (er, stats) {\n if (stats) {\n if (stats.uid < 0) stats.uid += 0x100000000\n if (stats.gid < 0) stats.gid += 0x100000000\n }\n if (cb) cb.apply(this, arguments)\n }\n return options ? orig.call(fs, target, options, callback)\n : orig.call(fs, target, callback)\n }\n }\n\n function statFixSync (orig) {\n if (!orig) return orig\n // Older versions of Node erroneously returned signed integers for\n // uid + gid.\n return function (target, options) {\n var stats = options ? orig.call(fs, target, options)\n : orig.call(fs, target)\n if (stats) {\n if (stats.uid < 0) stats.uid += 0x100000000\n if (stats.gid < 0) stats.gid += 0x100000000\n }\n return stats;\n }\n }\n\n // ENOSYS means that the fs doesn't support the op. Just ignore\n // that, because it doesn't matter.\n //\n // if there's no getuid, or if getuid() is something other\n // than 0, and the error is EINVAL or EPERM, then just ignore\n // it.\n //\n // This specific case is a silent failure in cp, install, tar,\n // and most other unix tools that manage permissions.\n //\n // When running as root, or if other types of errors are\n // encountered, then it's strict.\n function chownErOk (er) {\n if (!er)\n return true\n\n if (er.code === \"ENOSYS\")\n return true\n\n var nonroot = !process.getuid || process.getuid() !== 0\n if (nonroot) {\n if (er.code === \"EINVAL\" || er.code === \"EPERM\")\n return true\n }\n\n return false\n }\n}\n","var Stream = require('stream').Stream\n\nmodule.exports = legacy\n\nfunction legacy (fs) {\n return {\n ReadStream: ReadStream,\n WriteStream: WriteStream\n }\n\n function ReadStream (path, options) {\n if (!(this instanceof ReadStream)) return new ReadStream(path, options);\n\n Stream.call(this);\n\n var self = this;\n\n this.path = path;\n this.fd = null;\n this.readable = true;\n this.paused = false;\n\n this.flags = 'r';\n this.mode = 438; /*=0666*/\n this.bufferSize = 64 * 1024;\n\n options = options || {};\n\n // Mixin options into this\n var keys = Object.keys(options);\n for (var index = 0, length = keys.length; index < length; index++) {\n var key = keys[index];\n this[key] = options[key];\n }\n\n if (this.encoding) this.setEncoding(this.encoding);\n\n if (this.start !== undefined) {\n if ('number' !== typeof this.start) {\n throw TypeError('start must be a Number');\n }\n if (this.end === undefined) {\n this.end = Infinity;\n } else if ('number' !== typeof this.end) {\n throw TypeError('end must be a Number');\n }\n\n if (this.start > this.end) {\n throw new Error('start must be <= end');\n }\n\n this.pos = this.start;\n }\n\n if (this.fd !== null) {\n process.nextTick(function() {\n self._read();\n });\n return;\n }\n\n fs.open(this.path, this.flags, this.mode, function (err, fd) {\n if (err) {\n self.emit('error', err);\n self.readable = false;\n return;\n }\n\n self.fd = fd;\n self.emit('open', fd);\n self._read();\n })\n }\n\n function WriteStream (path, options) {\n if (!(this instanceof WriteStream)) return new WriteStream(path, options);\n\n Stream.call(this);\n\n this.path = path;\n this.fd = null;\n this.writable = true;\n\n this.flags = 'w';\n this.encoding = 'binary';\n this.mode = 438; /*=0666*/\n this.bytesWritten = 0;\n\n options = options || {};\n\n // Mixin options into this\n var keys = Object.keys(options);\n for (var index = 0, length = keys.length; index < length; index++) {\n var key = keys[index];\n this[key] = options[key];\n }\n\n if (this.start !== undefined) {\n if ('number' !== typeof this.start) {\n throw TypeError('start must be a Number');\n }\n if (this.start < 0) {\n throw new Error('start must be >= zero');\n }\n\n this.pos = this.start;\n }\n\n this.busy = false;\n this._queue = [];\n\n if (this.fd === null) {\n this._open = fs.open;\n this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);\n this.flush();\n }\n }\n}\n","'use strict'\n\nmodule.exports = clone\n\nvar getPrototypeOf = Object.getPrototypeOf || function (obj) {\n return obj.__proto__\n}\n\nfunction clone (obj) {\n if (obj === null || typeof obj !== 'object')\n return obj\n\n if (obj instanceof Object)\n var copy = { __proto__: getPrototypeOf(obj) }\n else\n var copy = Object.create(null)\n\n Object.getOwnPropertyNames(obj).forEach(function (key) {\n Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))\n })\n\n return copy\n}\n","var fs = require('fs')\nvar polyfills = require('./polyfills.js')\nvar legacy = require('./legacy-streams.js')\nvar clone = require('./clone.js')\n\nvar util = require('util')\n\n/* istanbul ignore next - node 0.x polyfill */\nvar gracefulQueue\nvar previousSymbol\n\n/* istanbul ignore else - node 0.x polyfill */\nif (typeof Symbol === 'function' && typeof Symbol.for === 'function') {\n gracefulQueue = Symbol.for('graceful-fs.queue')\n // This is used in testing by future versions\n previousSymbol = Symbol.for('graceful-fs.previous')\n} else {\n gracefulQueue = '___graceful-fs.queue'\n previousSymbol = '___graceful-fs.previous'\n}\n\nfunction noop () {}\n\nfunction publishQueue(context, queue) {\n Object.defineProperty(context, gracefulQueue, {\n get: function() {\n return queue\n }\n })\n}\n\nvar debug = noop\nif (util.debuglog)\n debug = util.debuglog('gfs4')\nelse if (/\\bgfs4\\b/i.test(process.env.NODE_DEBUG || ''))\n debug = function() {\n var m = util.format.apply(util, arguments)\n m = 'GFS4: ' + m.split(/\\n/).join('\\nGFS4: ')\n console.error(m)\n }\n\n// Once time initialization\nif (!fs[gracefulQueue]) {\n // This queue can be shared by multiple loaded instances\n var queue = global[gracefulQueue] || []\n publishQueue(fs, queue)\n\n // Patch fs.close/closeSync to shared queue version, because we need\n // to retry() whenever a close happens *anywhere* in the program.\n // This is essential when multiple graceful-fs instances are\n // in play at the same time.\n fs.close = (function (fs$close) {\n function close (fd, cb) {\n return fs$close.call(fs, fd, function (err) {\n // This function uses the graceful-fs shared queue\n if (!err) {\n resetQueue()\n }\n\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n })\n }\n\n Object.defineProperty(close, previousSymbol, {\n value: fs$close\n })\n return close\n })(fs.close)\n\n fs.closeSync = (function (fs$closeSync) {\n function closeSync (fd) {\n // This function uses the graceful-fs shared queue\n fs$closeSync.apply(fs, arguments)\n resetQueue()\n }\n\n Object.defineProperty(closeSync, previousSymbol, {\n value: fs$closeSync\n })\n return closeSync\n })(fs.closeSync)\n\n if (/\\bgfs4\\b/i.test(process.env.NODE_DEBUG || '')) {\n process.on('exit', function() {\n debug(fs[gracefulQueue])\n require('assert').equal(fs[gracefulQueue].length, 0)\n })\n }\n}\n\nif (!global[gracefulQueue]) {\n publishQueue(global, fs[gracefulQueue]);\n}\n\nmodule.exports = patch(clone(fs))\nif (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {\n module.exports = patch(fs)\n fs.__patched = true;\n}\n\nfunction patch (fs) {\n // Everything that references the open() function needs to be in here\n polyfills(fs)\n fs.gracefulify = patch\n\n fs.createReadStream = createReadStream\n fs.createWriteStream = createWriteStream\n var fs$readFile = fs.readFile\n fs.readFile = readFile\n function readFile (path, options, cb) {\n if (typeof options === 'function')\n cb = options, options = null\n\n return go$readFile(path, options, cb)\n\n function go$readFile (path, options, cb, startTime) {\n return fs$readFile(path, options, function (err) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n var fs$writeFile = fs.writeFile\n fs.writeFile = writeFile\n function writeFile (path, data, options, cb) {\n if (typeof options === 'function')\n cb = options, options = null\n\n return go$writeFile(path, data, options, cb)\n\n function go$writeFile (path, data, options, cb, startTime) {\n return fs$writeFile(path, data, options, function (err) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n var fs$appendFile = fs.appendFile\n if (fs$appendFile)\n fs.appendFile = appendFile\n function appendFile (path, data, options, cb) {\n if (typeof options === 'function')\n cb = options, options = null\n\n return go$appendFile(path, data, options, cb)\n\n function go$appendFile (path, data, options, cb, startTime) {\n return fs$appendFile(path, data, options, function (err) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n var fs$copyFile = fs.copyFile\n if (fs$copyFile)\n fs.copyFile = copyFile\n function copyFile (src, dest, flags, cb) {\n if (typeof flags === 'function') {\n cb = flags\n flags = 0\n }\n return go$copyFile(src, dest, flags, cb)\n\n function go$copyFile (src, dest, flags, cb, startTime) {\n return fs$copyFile(src, dest, flags, function (err) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n var fs$readdir = fs.readdir\n fs.readdir = readdir\n var noReaddirOptionVersions = /^v[0-5]\\./\n function readdir (path, options, cb) {\n if (typeof options === 'function')\n cb = options, options = null\n\n var go$readdir = noReaddirOptionVersions.test(process.version)\n ? function go$readdir (path, options, cb, startTime) {\n return fs$readdir(path, fs$readdirCallback(\n path, options, cb, startTime\n ))\n }\n : function go$readdir (path, options, cb, startTime) {\n return fs$readdir(path, options, fs$readdirCallback(\n path, options, cb, startTime\n ))\n }\n\n return go$readdir(path, options, cb)\n\n function fs$readdirCallback (path, options, cb, startTime) {\n return function (err, files) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([\n go$readdir,\n [path, options, cb],\n err,\n startTime || Date.now(),\n Date.now()\n ])\n else {\n if (files && files.sort)\n files.sort()\n\n if (typeof cb === 'function')\n cb.call(this, err, files)\n }\n }\n }\n }\n\n if (process.version.substr(0, 4) === 'v0.8') {\n var legStreams = legacy(fs)\n ReadStream = legStreams.ReadStream\n WriteStream = legStreams.WriteStream\n }\n\n var fs$ReadStream = fs.ReadStream\n if (fs$ReadStream) {\n ReadStream.prototype = Object.create(fs$ReadStream.prototype)\n ReadStream.prototype.open = ReadStream$open\n }\n\n var fs$WriteStream = fs.WriteStream\n if (fs$WriteStream) {\n WriteStream.prototype = Object.create(fs$WriteStream.prototype)\n WriteStream.prototype.open = WriteStream$open\n }\n\n Object.defineProperty(fs, 'ReadStream', {\n get: function () {\n return ReadStream\n },\n set: function (val) {\n ReadStream = val\n },\n enumerable: true,\n configurable: true\n })\n Object.defineProperty(fs, 'WriteStream', {\n get: function () {\n return WriteStream\n },\n set: function (val) {\n WriteStream = val\n },\n enumerable: true,\n configurable: true\n })\n\n // legacy names\n var FileReadStream = ReadStream\n Object.defineProperty(fs, 'FileReadStream', {\n get: function () {\n return FileReadStream\n },\n set: function (val) {\n FileReadStream = val\n },\n enumerable: true,\n configurable: true\n })\n var FileWriteStream = WriteStream\n Object.defineProperty(fs, 'FileWriteStream', {\n get: function () {\n return FileWriteStream\n },\n set: function (val) {\n FileWriteStream = val\n },\n enumerable: true,\n configurable: true\n })\n\n function ReadStream (path, options) {\n if (this instanceof ReadStream)\n return fs$ReadStream.apply(this, arguments), this\n else\n return ReadStream.apply(Object.create(ReadStream.prototype), arguments)\n }\n\n function ReadStream$open () {\n var that = this\n open(that.path, that.flags, that.mode, function (err, fd) {\n if (err) {\n if (that.autoClose)\n that.destroy()\n\n that.emit('error', err)\n } else {\n that.fd = fd\n that.emit('open', fd)\n that.read()\n }\n })\n }\n\n function WriteStream (path, options) {\n if (this instanceof WriteStream)\n return fs$WriteStream.apply(this, arguments), this\n else\n return WriteStream.apply(Object.create(WriteStream.prototype), arguments)\n }\n\n function WriteStream$open () {\n var that = this\n open(that.path, that.flags, that.mode, function (err, fd) {\n if (err) {\n that.destroy()\n that.emit('error', err)\n } else {\n that.fd = fd\n that.emit('open', fd)\n }\n })\n }\n\n function createReadStream (path, options) {\n return new fs.ReadStream(path, options)\n }\n\n function createWriteStream (path, options) {\n return new fs.WriteStream(path, options)\n }\n\n var fs$open = fs.open\n fs.open = open\n function open (path, flags, mode, cb) {\n if (typeof mode === 'function')\n cb = mode, mode = null\n\n return go$open(path, flags, mode, cb)\n\n function go$open (path, flags, mode, cb, startTime) {\n return fs$open(path, flags, mode, function (err, fd) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n return fs\n}\n\nfunction enqueue (elem) {\n debug('ENQUEUE', elem[0].name, elem[1])\n fs[gracefulQueue].push(elem)\n retry()\n}\n\n// keep track of the timeout between retry() calls\nvar retryTimer\n\n// reset the startTime and lastTime to now\n// this resets the start of the 60 second overall timeout as well as the\n// delay between attempts so that we'll retry these jobs sooner\nfunction resetQueue () {\n var now = Date.now()\n for (var i = 0; i < fs[gracefulQueue].length; ++i) {\n // entries that are only a length of 2 are from an older version, don't\n // bother modifying those since they'll be retried anyway.\n if (fs[gracefulQueue][i].length > 2) {\n fs[gracefulQueue][i][3] = now // startTime\n fs[gracefulQueue][i][4] = now // lastTime\n }\n }\n // call retry to make sure we're actively processing the queue\n retry()\n}\n\nfunction retry () {\n // clear the timer and remove it to help prevent unintended concurrency\n clearTimeout(retryTimer)\n retryTimer = undefined\n\n if (fs[gracefulQueue].length === 0)\n return\n\n var elem = fs[gracefulQueue].shift()\n var fn = elem[0]\n var args = elem[1]\n // these items may be unset if they were added by an older graceful-fs\n var err = elem[2]\n var startTime = elem[3]\n var lastTime = elem[4]\n\n // if we don't have a startTime we have no way of knowing if we've waited\n // long enough, so go ahead and retry this item now\n if (startTime === undefined) {\n debug('RETRY', fn.name, args)\n fn.apply(null, args)\n } else if (Date.now() - startTime >= 60000) {\n // it's been more than 60 seconds total, bail now\n debug('TIMEOUT', fn.name, args)\n var cb = args.pop()\n if (typeof cb === 'function')\n cb.call(null, err)\n } else {\n // the amount of time between the last attempt and right now\n var sinceAttempt = Date.now() - lastTime\n // the amount of time between when we first tried, and when we last tried\n // rounded up to at least 1\n var sinceStart = Math.max(lastTime - startTime, 1)\n // backoff. wait longer than the total time we've been retrying, but only\n // up to a maximum of 100ms\n var desiredDelay = Math.min(sinceStart * 1.2, 100)\n // it's been long enough since the last retry, do it again\n if (sinceAttempt >= desiredDelay) {\n debug('RETRY', fn.name, args)\n fn.apply(null, args.concat([startTime]))\n } else {\n // if we can't do this job yet, push it to the end of the queue\n // and let the next iteration check again\n fs[gracefulQueue].push(elem)\n }\n }\n\n // schedule our next run if one isn't already scheduled\n if (retryTimer === undefined) {\n retryTimer = setTimeout(retry, 0)\n }\n}\n","function RetryOperation(timeouts, options) {\n // Compatibility for the old (timeouts, retryForever) signature\n if (typeof options === 'boolean') {\n options = { forever: options };\n }\n\n this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));\n this._timeouts = timeouts;\n this._options = options || {};\n this._maxRetryTime = options && options.maxRetryTime || Infinity;\n this._fn = null;\n this._errors = [];\n this._attempts = 1;\n this._operationTimeout = null;\n this._operationTimeoutCb = null;\n this._timeout = null;\n this._operationStart = null;\n\n if (this._options.forever) {\n this._cachedTimeouts = this._timeouts.slice(0);\n }\n}\nmodule.exports = RetryOperation;\n\nRetryOperation.prototype.reset = function() {\n this._attempts = 1;\n this._timeouts = this._originalTimeouts;\n}\n\nRetryOperation.prototype.stop = function() {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n\n this._timeouts = [];\n this._cachedTimeouts = null;\n};\n\nRetryOperation.prototype.retry = function(err) {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n\n if (!err) {\n return false;\n }\n var currentTime = new Date().getTime();\n if (err && currentTime - this._operationStart >= this._maxRetryTime) {\n this._errors.unshift(new Error('RetryOperation timeout occurred'));\n return false;\n }\n\n this._errors.push(err);\n\n var timeout = this._timeouts.shift();\n if (timeout === undefined) {\n if (this._cachedTimeouts) {\n // retry forever, only keep last error\n this._errors.splice(this._errors.length - 1, this._errors.length);\n this._timeouts = this._cachedTimeouts.slice(0);\n timeout = this._timeouts.shift();\n } else {\n return false;\n }\n }\n\n var self = this;\n var timer = setTimeout(function() {\n self._attempts++;\n\n if (self._operationTimeoutCb) {\n self._timeout = setTimeout(function() {\n self._operationTimeoutCb(self._attempts);\n }, self._operationTimeout);\n\n if (self._options.unref) {\n self._timeout.unref();\n }\n }\n\n self._fn(self._attempts);\n }, timeout);\n\n if (this._options.unref) {\n timer.unref();\n }\n\n return true;\n};\n\nRetryOperation.prototype.attempt = function(fn, timeoutOps) {\n this._fn = fn;\n\n if (timeoutOps) {\n if (timeoutOps.timeout) {\n this._operationTimeout = timeoutOps.timeout;\n }\n if (timeoutOps.cb) {\n this._operationTimeoutCb = timeoutOps.cb;\n }\n }\n\n var self = this;\n if (this._operationTimeoutCb) {\n this._timeout = setTimeout(function() {\n self._operationTimeoutCb();\n }, self._operationTimeout);\n }\n\n this._operationStart = new Date().getTime();\n\n this._fn(this._attempts);\n};\n\nRetryOperation.prototype.try = function(fn) {\n console.log('Using RetryOperation.try() is deprecated');\n this.attempt(fn);\n};\n\nRetryOperation.prototype.start = function(fn) {\n console.log('Using RetryOperation.start() is deprecated');\n this.attempt(fn);\n};\n\nRetryOperation.prototype.start = RetryOperation.prototype.try;\n\nRetryOperation.prototype.errors = function() {\n return this._errors;\n};\n\nRetryOperation.prototype.attempts = function() {\n return this._attempts;\n};\n\nRetryOperation.prototype.mainError = function() {\n if (this._errors.length === 0) {\n return null;\n }\n\n var counts = {};\n var mainError = null;\n var mainErrorCount = 0;\n\n for (var i = 0; i < this._errors.length; i++) {\n var error = this._errors[i];\n var message = error.message;\n var count = (counts[message] || 0) + 1;\n\n counts[message] = count;\n\n if (count >= mainErrorCount) {\n mainError = error;\n mainErrorCount = count;\n }\n }\n\n return mainError;\n};\n","var RetryOperation = require('./retry_operation');\n\nexports.operation = function(options) {\n var timeouts = exports.timeouts(options);\n return new RetryOperation(timeouts, {\n forever: options && options.forever,\n unref: options && options.unref,\n maxRetryTime: options && options.maxRetryTime\n });\n};\n\nexports.timeouts = function(options) {\n if (options instanceof Array) {\n return [].concat(options);\n }\n\n var opts = {\n retries: 10,\n factor: 2,\n minTimeout: 1 * 1000,\n maxTimeout: Infinity,\n randomize: false\n };\n for (var key in options) {\n opts[key] = options[key];\n }\n\n if (opts.minTimeout > opts.maxTimeout) {\n throw new Error('minTimeout is greater than maxTimeout');\n }\n\n var timeouts = [];\n for (var i = 0; i < opts.retries; i++) {\n timeouts.push(this.createTimeout(i, opts));\n }\n\n if (options && options.forever && !timeouts.length) {\n timeouts.push(this.createTimeout(i, opts));\n }\n\n // sort the array numerically ascending\n timeouts.sort(function(a,b) {\n return a - b;\n });\n\n return timeouts;\n};\n\nexports.createTimeout = function(attempt, opts) {\n var random = (opts.randomize)\n ? (Math.random() + 1)\n : 1;\n\n var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));\n timeout = Math.min(timeout, opts.maxTimeout);\n\n return timeout;\n};\n\nexports.wrap = function(obj, options, methods) {\n if (options instanceof Array) {\n methods = options;\n options = null;\n }\n\n if (!methods) {\n methods = [];\n for (var key in obj) {\n if (typeof obj[key] === 'function') {\n methods.push(key);\n }\n }\n }\n\n for (var i = 0; i < methods.length; i++) {\n var method = methods[i];\n var original = obj[method];\n\n obj[method] = function retryWrapper(original) {\n var op = exports.operation(options);\n var args = Array.prototype.slice.call(arguments, 1);\n var callback = args.pop();\n\n args.push(function(err) {\n if (op.retry(err)) {\n return;\n }\n if (err) {\n arguments[0] = op.mainError();\n }\n callback.apply(this, arguments);\n });\n\n op.attempt(function() {\n original.apply(obj, args);\n });\n }.bind(obj, original);\n obj[method].options = options;\n }\n};\n","module.exports = require('./lib/retry');","// This is not the set of all possible signals.\n//\n// It IS, however, the set of all signals that trigger\n// an exit on either Linux or BSD systems. Linux is a\n// superset of the signal names supported on BSD, and\n// the unknown signals just fail to register, so we can\n// catch that easily enough.\n//\n// Don't bother with SIGKILL. It's uncatchable, which\n// means that we can't fire any callbacks anyway.\n//\n// If a user does happen to register a handler on a non-\n// fatal signal like SIGWINCH or something, and then\n// exit, it'll end up firing `process.emit('exit')`, so\n// the handler will be fired anyway.\n//\n// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised\n// artificially, inherently leave the process in a\n// state from which it is not safe to try and enter JS\n// listeners.\nmodule.exports = [\n 'SIGABRT',\n 'SIGALRM',\n 'SIGHUP',\n 'SIGINT',\n 'SIGTERM'\n]\n\nif (process.platform !== 'win32') {\n module.exports.push(\n 'SIGVTALRM',\n 'SIGXCPU',\n 'SIGXFSZ',\n 'SIGUSR2',\n 'SIGTRAP',\n 'SIGSYS',\n 'SIGQUIT',\n 'SIGIOT'\n // should detect profiler and enable/disable accordingly.\n // see #21\n // 'SIGPROF'\n )\n}\n\nif (process.platform === 'linux') {\n module.exports.push(\n 'SIGIO',\n 'SIGPOLL',\n 'SIGPWR',\n 'SIGSTKFLT',\n 'SIGUNUSED'\n )\n}\n","// Note: since nyc uses this module to output coverage, any lines\n// that are in the direct sync flow of nyc's outputCoverage are\n// ignored, since we can never get coverage for them.\n// grab a reference to node's real process object right away\nvar process = global.process\n\nconst processOk = function (process) {\n return process &&\n typeof process === 'object' &&\n typeof process.removeListener === 'function' &&\n typeof process.emit === 'function' &&\n typeof process.reallyExit === 'function' &&\n typeof process.listeners === 'function' &&\n typeof process.kill === 'function' &&\n typeof process.pid === 'number' &&\n typeof process.on === 'function'\n}\n\n// some kind of non-node environment, just no-op\n/* istanbul ignore if */\nif (!processOk(process)) {\n module.exports = function () {\n return function () {}\n }\n} else {\n var assert = require('assert')\n var signals = require('./signals.js')\n var isWin = /^win/i.test(process.platform)\n\n var EE = require('events')\n /* istanbul ignore if */\n if (typeof EE !== 'function') {\n EE = EE.EventEmitter\n }\n\n var emitter\n if (process.__signal_exit_emitter__) {\n emitter = process.__signal_exit_emitter__\n } else {\n emitter = process.__signal_exit_emitter__ = new EE()\n emitter.count = 0\n emitter.emitted = {}\n }\n\n // Because this emitter is a global, we have to check to see if a\n // previous version of this library failed to enable infinite listeners.\n // I know what you're about to say. But literally everything about\n // signal-exit is a compromise with evil. Get used to it.\n if (!emitter.infinite) {\n emitter.setMaxListeners(Infinity)\n emitter.infinite = true\n }\n\n module.exports = function (cb, opts) {\n /* istanbul ignore if */\n if (!processOk(global.process)) {\n return function () {}\n }\n assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')\n\n if (loaded === false) {\n load()\n }\n\n var ev = 'exit'\n if (opts && opts.alwaysLast) {\n ev = 'afterexit'\n }\n\n var remove = function () {\n emitter.removeListener(ev, cb)\n if (emitter.listeners('exit').length === 0 &&\n emitter.listeners('afterexit').length === 0) {\n unload()\n }\n }\n emitter.on(ev, cb)\n\n return remove\n }\n\n var unload = function unload () {\n if (!loaded || !processOk(global.process)) {\n return\n }\n loaded = false\n\n signals.forEach(function (sig) {\n try {\n process.removeListener(sig, sigListeners[sig])\n } catch (er) {}\n })\n process.emit = originalProcessEmit\n process.reallyExit = originalProcessReallyExit\n emitter.count -= 1\n }\n module.exports.unload = unload\n\n var emit = function emit (event, code, signal) {\n /* istanbul ignore if */\n if (emitter.emitted[event]) {\n return\n }\n emitter.emitted[event] = true\n emitter.emit(event, code, signal)\n }\n\n // { <signal>: <listener fn>, ... }\n var sigListeners = {}\n signals.forEach(function (sig) {\n sigListeners[sig] = function listener () {\n /* istanbul ignore if */\n if (!processOk(global.process)) {\n return\n }\n // If there are no other listeners, an exit is coming!\n // Simplest way: remove us and then re-send the signal.\n // We know that this will kill the process, so we can\n // safely emit now.\n var listeners = process.listeners(sig)\n if (listeners.length === emitter.count) {\n unload()\n emit('exit', null, sig)\n /* istanbul ignore next */\n emit('afterexit', null, sig)\n /* istanbul ignore next */\n if (isWin && sig === 'SIGHUP') {\n // \"SIGHUP\" throws an `ENOSYS` error on Windows,\n // so use a supported signal instead\n sig = 'SIGINT'\n }\n /* istanbul ignore next */\n process.kill(process.pid, sig)\n }\n }\n })\n\n module.exports.signals = function () {\n return signals\n }\n\n var loaded = false\n\n var load = function load () {\n if (loaded || !processOk(global.process)) {\n return\n }\n loaded = true\n\n // This is the number of onSignalExit's that are in play.\n // It's important so that we can count the correct number of\n // listeners on signals, and don't wait for the other one to\n // handle it instead of us.\n emitter.count += 1\n\n signals = signals.filter(function (sig) {\n try {\n process.on(sig, sigListeners[sig])\n return true\n } catch (er) {\n return false\n }\n })\n\n process.emit = processEmit\n process.reallyExit = processReallyExit\n }\n module.exports.load = load\n\n var originalProcessReallyExit = process.reallyExit\n var processReallyExit = function processReallyExit (code) {\n /* istanbul ignore if */\n if (!processOk(global.process)) {\n return\n }\n process.exitCode = code || /* istanbul ignore next */ 0\n emit('exit', process.exitCode, null)\n /* istanbul ignore next */\n emit('afterexit', process.exitCode, null)\n /* istanbul ignore next */\n originalProcessReallyExit.call(process, process.exitCode)\n }\n\n var originalProcessEmit = process.emit\n var processEmit = function processEmit (ev, arg) {\n if (ev === 'exit' && processOk(global.process)) {\n /* istanbul ignore else */\n if (arg !== undefined) {\n process.exitCode = arg\n }\n var ret = originalProcessEmit.apply(this, arguments)\n /* istanbul ignore next */\n emit('exit', process.exitCode, null)\n /* istanbul ignore next */\n emit('afterexit', process.exitCode, null)\n /* istanbul ignore next */\n return ret\n } else {\n return originalProcessEmit.apply(this, arguments)\n }\n }\n}\n","'use strict';\n\nconst cacheSymbol = Symbol();\n\nfunction probe(file, fs, callback) {\n const cachedPrecision = fs[cacheSymbol];\n\n if (cachedPrecision) {\n return fs.stat(file, (err, stat) => {\n /* istanbul ignore if */\n if (err) {\n return callback(err);\n }\n\n callback(null, stat.mtime, cachedPrecision);\n });\n }\n\n // Set mtime by ceiling Date.now() to seconds + 5ms so that it's \"not on the second\"\n const mtime = new Date((Math.ceil(Date.now() / 1000) * 1000) + 5);\n\n fs.utimes(file, mtime, mtime, (err) => {\n /* istanbul ignore if */\n if (err) {\n return callback(err);\n }\n\n fs.stat(file, (err, stat) => {\n /* istanbul ignore if */\n if (err) {\n return callback(err);\n }\n\n const precision = stat.mtime.getTime() % 1000 === 0 ? 's' : 'ms';\n\n // Cache the precision in a non-enumerable way\n Object.defineProperty(fs, cacheSymbol, { value: precision });\n\n callback(null, stat.mtime, precision);\n });\n });\n}\n\nfunction getMtime(precision) {\n let now = Date.now();\n\n if (precision === 's') {\n now = Math.ceil(now / 1000) * 1000;\n }\n\n return new Date(now);\n}\n\nmodule.exports.probe = probe;\nmodule.exports.getMtime = getMtime;\n","'use strict';\n\nconst path = require('path');\nconst fs = require('graceful-fs');\nconst retry = require('retry');\nconst onExit = require('signal-exit');\nconst mtimePrecision = require('./mtime-precision');\n\nconst locks = {};\n\nfunction getLockFile(file, options) {\n return options.lockfilePath || `${file}.lock`;\n}\n\nfunction resolveCanonicalPath(file, options, callback) {\n if (!options.realpath) {\n return callback(null, path.resolve(file));\n }\n\n // Use realpath to resolve symlinks\n // It also resolves relative paths\n options.fs.realpath(file, callback);\n}\n\nfunction acquireLock(file, options, callback) {\n const lockfilePath = getLockFile(file, options);\n\n // Use mkdir to create the lockfile (atomic operation)\n options.fs.mkdir(lockfilePath, (err) => {\n if (!err) {\n // At this point, we acquired the lock!\n // Probe the mtime precision\n return mtimePrecision.probe(lockfilePath, options.fs, (err, mtime, mtimePrecision) => {\n // If it failed, try to remove the lock..\n /* istanbul ignore if */\n if (err) {\n options.fs.rmdir(lockfilePath, () => {});\n\n return callback(err);\n }\n\n callback(null, mtime, mtimePrecision);\n });\n }\n\n // If error is not EEXIST then some other error occurred while locking\n if (err.code !== 'EEXIST') {\n return callback(err);\n }\n\n // Otherwise, check if lock is stale by analyzing the file mtime\n if (options.stale <= 0) {\n return callback(Object.assign(new Error('Lock file is already being held'), { code: 'ELOCKED', file }));\n }\n\n options.fs.stat(lockfilePath, (err, stat) => {\n if (err) {\n // Retry if the lockfile has been removed (meanwhile)\n // Skip stale check to avoid recursiveness\n if (err.code === 'ENOENT') {\n return acquireLock(file, { ...options, stale: 0 }, callback);\n }\n\n return callback(err);\n }\n\n if (!isLockStale(stat, options)) {\n return callback(Object.assign(new Error('Lock file is already being held'), { code: 'ELOCKED', file }));\n }\n\n // If it's stale, remove it and try again!\n // Skip stale check to avoid recursiveness\n removeLock(file, options, (err) => {\n if (err) {\n return callback(err);\n }\n\n acquireLock(file, { ...options, stale: 0 }, callback);\n });\n });\n });\n}\n\nfunction isLockStale(stat, options) {\n return stat.mtime.getTime() < Date.now() - options.stale;\n}\n\nfunction removeLock(file, options, callback) {\n // Remove lockfile, ignoring ENOENT errors\n options.fs.rmdir(getLockFile(file, options), (err) => {\n if (err && err.code !== 'ENOENT') {\n return callback(err);\n }\n\n callback();\n });\n}\n\nfunction updateLock(file, options) {\n const lock = locks[file];\n\n // Just for safety, should never happen\n /* istanbul ignore if */\n if (lock.updateTimeout) {\n return;\n }\n\n lock.updateDelay = lock.updateDelay || options.update;\n lock.updateTimeout = setTimeout(() => {\n lock.updateTimeout = null;\n\n // Stat the file to check if mtime is still ours\n // If it is, we can still recover from a system sleep or a busy event loop\n options.fs.stat(lock.lockfilePath, (err, stat) => {\n const isOverThreshold = lock.lastUpdate + options.stale < Date.now();\n\n // If it failed to update the lockfile, keep trying unless\n // the lockfile was deleted or we are over the threshold\n if (err) {\n if (err.code === 'ENOENT' || isOverThreshold) {\n return setLockAsCompromised(file, lock, Object.assign(err, { code: 'ECOMPROMISED' }));\n }\n\n lock.updateDelay = 1000;\n\n return updateLock(file, options);\n }\n\n const isMtimeOurs = lock.mtime.getTime() === stat.mtime.getTime();\n\n if (!isMtimeOurs) {\n return setLockAsCompromised(\n file,\n lock,\n Object.assign(\n new Error('Unable to update lock within the stale threshold'),\n { code: 'ECOMPROMISED' }\n ));\n }\n\n const mtime = mtimePrecision.getMtime(lock.mtimePrecision);\n\n options.fs.utimes(lock.lockfilePath, mtime, mtime, (err) => {\n const isOverThreshold = lock.lastUpdate + options.stale < Date.now();\n\n // Ignore if the lock was released\n if (lock.released) {\n return;\n }\n\n // If it failed to update the lockfile, keep trying unless\n // the lockfile was deleted or we are over the threshold\n if (err) {\n if (err.code === 'ENOENT' || isOverThreshold) {\n return setLockAsCompromised(file, lock, Object.assign(err, { code: 'ECOMPROMISED' }));\n }\n\n lock.updateDelay = 1000;\n\n return updateLock(file, options);\n }\n\n // All ok, keep updating..\n lock.mtime = mtime;\n lock.lastUpdate = Date.now();\n lock.updateDelay = null;\n updateLock(file, options);\n });\n });\n }, lock.updateDelay);\n\n // Unref the timer so that the nodejs process can exit freely\n // This is safe because all acquired locks will be automatically released\n // on process exit\n\n // We first check that `lock.updateTimeout.unref` exists because some users\n // may be using this module outside of NodeJS (e.g., in an electron app),\n // and in those cases `setTimeout` return an integer.\n /* istanbul ignore else */\n if (lock.updateTimeout.unref) {\n lock.updateTimeout.unref();\n }\n}\n\nfunction setLockAsCompromised(file, lock, err) {\n // Signal the lock has been released\n lock.released = true;\n\n // Cancel lock mtime update\n // Just for safety, at this point updateTimeout should be null\n /* istanbul ignore if */\n if (lock.updateTimeout) {\n clearTimeout(lock.updateTimeout);\n }\n\n if (locks[file] === lock) {\n delete locks[file];\n }\n\n lock.options.onCompromised(err);\n}\n\n// ----------------------------------------------------------\n\nfunction lock(file, options, callback) {\n /* istanbul ignore next */\n options = {\n stale: 10000,\n update: null,\n realpath: true,\n retries: 0,\n fs,\n onCompromised: (err) => { throw err; },\n ...options,\n };\n\n options.retries = options.retries || 0;\n options.retries = typeof options.retries === 'number' ? { retries: options.retries } : options.retries;\n options.stale = Math.max(options.stale || 0, 2000);\n options.update = options.update == null ? options.stale / 2 : options.update || 0;\n options.update = Math.max(Math.min(options.update, options.stale / 2), 1000);\n\n // Resolve to a canonical file path\n resolveCanonicalPath(file, options, (err, file) => {\n if (err) {\n return callback(err);\n }\n\n // Attempt to acquire the lock\n const operation = retry.operation(options.retries);\n\n operation.attempt(() => {\n acquireLock(file, options, (err, mtime, mtimePrecision) => {\n if (operation.retry(err)) {\n return;\n }\n\n if (err) {\n return callback(operation.mainError());\n }\n\n // We now own the lock\n const lock = locks[file] = {\n lockfilePath: getLockFile(file, options),\n mtime,\n mtimePrecision,\n options,\n lastUpdate: Date.now(),\n };\n\n // We must keep the lock fresh to avoid staleness\n updateLock(file, options);\n\n callback(null, (releasedCallback) => {\n if (lock.released) {\n return releasedCallback &&\n releasedCallback(Object.assign(new Error('Lock is already released'), { code: 'ERELEASED' }));\n }\n\n // Not necessary to use realpath twice when unlocking\n unlock(file, { ...options, realpath: false }, releasedCallback);\n });\n });\n });\n });\n}\n\nfunction unlock(file, options, callback) {\n options = {\n fs,\n realpath: true,\n ...options,\n };\n\n // Resolve to a canonical file path\n resolveCanonicalPath(file, options, (err, file) => {\n if (err) {\n return callback(err);\n }\n\n // Skip if the lock is not acquired\n const lock = locks[file];\n\n if (!lock) {\n return callback(Object.assign(new Error('Lock is not acquired/owned by you'), { code: 'ENOTACQUIRED' }));\n }\n\n lock.updateTimeout && clearTimeout(lock.updateTimeout); // Cancel lock mtime update\n lock.released = true; // Signal the lock has been released\n delete locks[file]; // Delete from locks\n\n removeLock(file, options, callback);\n });\n}\n\nfunction check(file, options, callback) {\n options = {\n stale: 10000,\n realpath: true,\n fs,\n ...options,\n };\n\n options.stale = Math.max(options.stale || 0, 2000);\n\n // Resolve to a canonical file path\n resolveCanonicalPath(file, options, (err, file) => {\n if (err) {\n return callback(err);\n }\n\n // Check if lockfile exists\n options.fs.stat(getLockFile(file, options), (err, stat) => {\n if (err) {\n // If does not exist, file is not locked. Otherwise, callback with error\n return err.code === 'ENOENT' ? callback(null, false) : callback(err);\n }\n\n // Otherwise, check if lock is stale by analyzing the file mtime\n return callback(null, !isLockStale(stat, options));\n });\n });\n}\n\nfunction getLocks() {\n return locks;\n}\n\n// Remove acquired locks on exit\n/* istanbul ignore next */\nonExit(() => {\n for (const file in locks) {\n const options = locks[file].options;\n\n try { options.fs.rmdirSync(getLockFile(file, options)); } catch (e) { /* Empty */ }\n }\n});\n\nmodule.exports.lock = lock;\nmodule.exports.unlock = unlock;\nmodule.exports.check = check;\nmodule.exports.getLocks = getLocks;\n","'use strict';\n\nconst fs = require('graceful-fs');\n\nfunction createSyncFs(fs) {\n const methods = ['mkdir', 'realpath', 'stat', 'rmdir', 'utimes'];\n const newFs = { ...fs };\n\n methods.forEach((method) => {\n newFs[method] = (...args) => {\n const callback = args.pop();\n let ret;\n\n try {\n ret = fs[`${method}Sync`](...args);\n } catch (err) {\n return callback(err);\n }\n\n callback(null, ret);\n };\n });\n\n return newFs;\n}\n\n// ----------------------------------------------------------\n\nfunction toPromise(method) {\n return (...args) => new Promise((resolve, reject) => {\n args.push((err, result) => {\n if (err) {\n reject(err);\n } else {\n resolve(result);\n }\n });\n\n method(...args);\n });\n}\n\nfunction toSync(method) {\n return (...args) => {\n let err;\n let result;\n\n args.push((_err, _result) => {\n err = _err;\n result = _result;\n });\n\n method(...args);\n\n if (err) {\n throw err;\n }\n\n return result;\n };\n}\n\nfunction toSyncOptions(options) {\n // Shallow clone options because we are oging to mutate them\n options = { ...options };\n\n // Transform fs to use the sync methods instead\n options.fs = createSyncFs(options.fs || fs);\n\n // Retries are not allowed because it requires the flow to be sync\n if (\n (typeof options.retries === 'number' && options.retries > 0) ||\n (options.retries && typeof options.retries.retries === 'number' && options.retries.retries > 0)\n ) {\n throw Object.assign(new Error('Cannot use retries with the sync api'), { code: 'ESYNC' });\n }\n\n return options;\n}\n\nmodule.exports = {\n toPromise,\n toSync,\n toSyncOptions,\n};\n","'use strict';\n\nconst lockfile = require('./lib/lockfile');\nconst { toPromise, toSync, toSyncOptions } = require('./lib/adapter');\n\nasync function lock(file, options) {\n const release = await toPromise(lockfile.lock)(file, options);\n\n return toPromise(release);\n}\n\nfunction lockSync(file, options) {\n const release = toSync(lockfile.lock)(file, toSyncOptions(options));\n\n return toSync(release);\n}\n\nfunction unlock(file, options) {\n return toPromise(lockfile.unlock)(file, options);\n}\n\nfunction unlockSync(file, options) {\n return toSync(lockfile.unlock)(file, toSyncOptions(options));\n}\n\nfunction check(file, options) {\n return toPromise(lockfile.check)(file, options);\n}\n\nfunction checkSync(file, options) {\n return toSync(lockfile.check)(file, toSyncOptions(options));\n}\n\nmodule.exports = lock;\nmodule.exports.lock = lock;\nmodule.exports.unlock = unlock;\nmodule.exports.lockSync = lockSync;\nmodule.exports.unlockSync = unlockSync;\nmodule.exports.check = check;\nmodule.exports.checkSync = checkSync;\n","import * as fs from \"node:fs\";\nimport { spawn } from \"node:child_process\";\nimport * as fs$1 from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport getPort, { portNumbers } from \"get-port\";\nimport * as properLockfile from \"proper-lockfile\";\nimport { randomUUID } from \"node:crypto\";\n//#region src/state-file.ts\n/**\n* Temp-then-rename JSON state-file writes behind one in-process queue (spec\n* local-dev § 2, \"API hygiene, both daemons\"): each daemon is single-process,\n* so concurrent HTTP handlers mutating the same state file serialize their\n* writes through a `StateFile` instance instead of racing each other on disk.\n*/\nvar StateFile = class {\n\tfilePath;\n\tmode;\n\tqueue = Promise.resolve();\n\tconstructor(filePath, mode) {\n\t\tthis.filePath = filePath;\n\t\tthis.mode = mode;\n\t}\n\t/** Serializes `value` to disk, temp-then-rename, behind this file's write queue. */\n\twrite(value) {\n\t\tconst next = this.queue.then(() => this.writeNow(value));\n\t\tthis.queue = next.catch(() => void 0);\n\t\treturn next;\n\t}\n\t/** Resolves once every write() call made so far has landed on disk — for graceful shutdown, so a SIGTERM can't race an in-flight write and lose it. */\n\tflush() {\n\t\treturn this.queue;\n\t}\n\tasync writeNow(value) {\n\t\tconst dir = path.dirname(this.filePath);\n\t\tawait fs$1.mkdir(dir, { recursive: true });\n\t\tconst tmpPath = path.join(dir, `.${path.basename(this.filePath)}.${randomUUID()}.tmp`);\n\t\tconst json = `${JSON.stringify(value, null, 2)}\\n`;\n\t\tawait fs$1.writeFile(tmpPath, json, this.mode !== void 0 ? { mode: this.mode } : void 0);\n\t\tawait fs$1.rename(tmpPath, this.filePath);\n\t\tif (this.mode !== void 0) await fs$1.chmod(this.filePath, this.mode);\n\t}\n};\nfunction isEnoent$1(err) {\n\treturn err instanceof Error && \"code\" in err && err.code === \"ENOENT\";\n}\n/**\n* Reads and parses a JSON state file, narrowing the parsed value with\n* `isValid` (a real type predicate, not a cast — the file's shape is only\n* trustworthy because this daemon is its only writer, but a foreign or\n* corrupt file on disk must not be treated as valid state). `undefined` when\n* absent, unreadable, or shaped wrong.\n*/\nasync function readJsonFile(filePath, isValid) {\n\tlet raw;\n\ttry {\n\t\traw = await fs$1.readFile(filePath, \"utf8\");\n\t} catch (err) {\n\t\tif (isEnoent$1(err)) return void 0;\n\t\tthrow err;\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn;\n\t}\n\treturn isValid(parsed) ? parsed : void 0;\n}\n//#endregion\n//#region src/daemon.ts\n/**\n* The shared daemon layer (local-dev spec § 2): a machine-scoped registry of\n* running emulator daemons (`compute`, `buckets`), and `ensureDaemon` /\n* `stopDaemon` to start, adopt, or replace them. Every daemon is a detached,\n* `unref()`'d child process that outlives whatever called `ensureDaemon` —\n* the registry is how a later call finds it again.\n*\n* `registryRoot` defaults to `~/.prisma-composer/emulators/` and governs\n* every path this module manages for a given daemon: the registry JSON\n* itself, the daemon's own state directory, and its stdio log file. The\n* `{ registryRoot }` override exists solely so tests never touch the real\n* home directory; production code never passes it.\n*/\nconst MIN_PORT = 4300;\nconst MAX_PORT = 65535;\nconst EXISTING_HEALTH_TIMEOUT_MS = 2e3;\nconst START_HEALTH_BUDGET_MS = 1e4;\nconst HEALTH_POLL_INTERVAL_MS = 200;\nconst TERMINATE_GRACE_MS = 5e3;\nconst TERMINATE_POLL_INTERVAL_MS = 150;\nconst LOCK_RETRY_INTERVAL_MS = 250;\nconst LOCK_WAIT_BUDGET_MS = 1e4;\nconst LOCK_STALE_MS = 1e4;\n/** Spec § 2 step 5: a FRESH allocation (no persisted port) tries at most this many distinct port candidates before the pinned failure error. */\nconst MAX_FRESH_PORT_CANDIDATES = 5;\nfunction isErrnoException(err) {\n\treturn err instanceof Error && \"code\" in err;\n}\nfunction isEnoent(err) {\n\treturn isErrnoException(err) && err.code === \"ENOENT\";\n}\nfunction isRegistryEntry(value) {\n\treturn typeof value === \"object\" && value !== null && \"pid\" in value && typeof value.pid === \"number\" && \"port\" in value && typeof value.port === \"number\" && \"version\" in value && typeof value.version === \"string\" && \"logPath\" in value && typeof value.logPath === \"string\";\n}\nfunction isHealthBody(value) {\n\treturn typeof value === \"object\" && value !== null && \"version\" in value && typeof value.version === \"string\";\n}\nfunction isPackageJson(value) {\n\treturn typeof value === \"object\" && value !== null && \"version\" in value && typeof value.version === \"string\";\n}\nfunction sleep(ms) {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n/** `~/.prisma-composer/emulators/` — `registryRoot`'s default. */\nfunction defaultRegistryRoot() {\n\treturn path.join(os.homedir(), \".prisma-composer\", \"emulators\");\n}\n/** `<registryRoot>/<name>.json`. */\nfunction registryFilePath(registryRoot, name) {\n\treturn path.join(registryRoot, `${name}.json`);\n}\n/** `<registryRoot>/<name>/` — the daemon's own `--state-dir`. */\nfunction daemonStateDir(registryRoot, name) {\n\treturn path.join(registryRoot, name);\n}\n/** `<registryRoot>/<name>.log` — the daemon's stdio log. */\nfunction daemonLogPath(registryRoot, name) {\n\treturn path.join(registryRoot, `${name}.log`);\n}\n/** Compute's and postgres's root namespace is their own JSON admin API; buckets' root namespace is the S3 wire, so its health lives under `/_pcdev/`. */\nfunction healthPathFor(name) {\n\treturn name === \"buckets\" ? \"/_pcdev/health\" : \"/health\";\n}\n/** `@internal/dev-emulators`'s own `package.json` version — what \"version\" means everywhere in this package. */\nfunction readOwnVersion() {\n\tconst here = path.dirname(fileURLToPath(import.meta.url));\n\tconst pkgPath = path.join(here, \"..\", \"package.json\");\n\tconst raw = fs.readFileSync(pkgPath, \"utf8\");\n\tconst parsed = JSON.parse(raw);\n\tif (!isPackageJson(parsed)) throw new Error(`could not read a version string from ${pkgPath}`);\n\treturn parsed.version;\n}\n/** `process.kill(pid, 0)` existence probe — true unless the pid is provably gone (ESRCH). */\nfunction isPidAlive(pid) {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch (err) {\n\t\tif (isErrnoException(err) && err.code === \"EPERM\") return true;\n\t\treturn false;\n\t}\n}\nasync function readRegistryEntry(registryRoot, name) {\n\treturn readJsonFile(registryFilePath(registryRoot, name), isRegistryEntry);\n}\nasync function probeHealth(port, healthPath, timeoutMs) {\n\ttry {\n\t\tconst res = await fetch(`http://127.0.0.1:${port}${healthPath}`, { signal: AbortSignal.timeout(timeoutMs) });\n\t\tif (!res.ok) return void 0;\n\t\tconst body = await res.json();\n\t\treturn isHealthBody(body) ? body : void 0;\n\t} catch {\n\t\treturn;\n\t}\n}\n/**\n* Polls the health path up to `budgetMs`, but returns immediately once the\n* child exits — a dead child can never become healthy, and the port-retry\n* protocol (spec § 2 step 5) needs to move to the next candidate right\n* away rather than exhausting a live-process budget on one that isn't\n* live. Only a child that stays alive without becoming healthy consumes\n* the full budget.\n*\n* Verifies the health response's OWN version, not just that something\n* answered: if our child failed to bind (a foreign process already held\n* the port) that foreign process may itself answer `/health` successfully\n* — a version mismatch there is exactly the \"port taken\" case, not a false\n* \"healthy\", and must not be reported as such.\n*/\nasync function awaitHealthy(child, port, healthPath, ownVersion, budgetMs) {\n\tlet exited = false;\n\tchild.once(\"exit\", () => {\n\t\texited = true;\n\t});\n\tconst deadline = Date.now() + budgetMs;\n\tdo {\n\t\tif (exited) return {\n\t\t\thealthy: false,\n\t\t\texitedBeforeHealthy: true\n\t\t};\n\t\tconst remaining = deadline - Date.now();\n\t\tconst health = await probeHealth(port, healthPath, Math.max(200, Math.min(1e3, remaining)));\n\t\tif (health && health.version === ownVersion) return {\n\t\t\thealthy: true,\n\t\t\texitedBeforeHealthy: false\n\t\t};\n\t\tif (exited) return {\n\t\t\thealthy: false,\n\t\t\texitedBeforeHealthy: true\n\t\t};\n\t\tawait sleep(HEALTH_POLL_INTERVAL_MS);\n\t} while (Date.now() < deadline);\n\treturn {\n\t\thealthy: false,\n\t\texitedBeforeHealthy: exited\n\t};\n}\n/** SIGTERM, wait up to `graceMs` for the pid to exit, then SIGKILL. A no-op if the pid is already gone. */\nasync function terminate(pid, graceMs) {\n\tif (!isPidAlive(pid)) return;\n\ttry {\n\t\tprocess.kill(pid, \"SIGTERM\");\n\t} catch {\n\t\treturn;\n\t}\n\tconst deadline = Date.now() + graceMs;\n\twhile (Date.now() < deadline) {\n\t\tif (!isPidAlive(pid)) return;\n\t\tawait sleep(TERMINATE_POLL_INTERVAL_MS);\n\t}\n\tif (isPidAlive(pid)) try {\n\t\tprocess.kill(pid, \"SIGKILL\");\n\t} catch {}\n}\n/** Every port recorded by any registry entry under `registryRoot` — the two daemons share one port pool. */\nasync function usedPorts(registryRoot) {\n\tlet names;\n\ttry {\n\t\tnames = await fs$1.readdir(registryRoot);\n\t} catch (err) {\n\t\tif (isEnoent(err)) return /* @__PURE__ */ new Set();\n\t\tthrow err;\n\t}\n\tconst ports = /* @__PURE__ */ new Set();\n\tfor (const fname of names) {\n\t\tif (!fname.endsWith(\".json\")) continue;\n\t\tconst entry = await readJsonFile(path.join(registryRoot, fname), isRegistryEntry);\n\t\tif (entry) ports.add(entry.port);\n\t}\n\treturn ports;\n}\n/**\n* The smallest genuinely free port at or above `min`, skipping every port\n* already recorded in the registry — persistence and the range policy\n* (`min`, \"skip registry-used ports\") stay ours; whether a given candidate\n* is actually bindable is `get-port`'s (spec § 2's dependency razor — a\n* hand-rolled probe already produced a real cross-platform bug: a Linux-only\n* self-collision from checking two bind scopes concurrently).\n*/\nasync function smallestUnused(used, min) {\n\treturn getPort({\n\t\tport: portNumbers(min, MAX_PORT),\n\t\texclude: used\n\t});\n}\n/** Spawns the daemon binary detached, stdio appended to `logPath`. Doesn't wait for health. */\nfunction spawnDaemonProcess(entryPath, port, stateDir, logPath) {\n\tconst logFd = fs.openSync(logPath, \"a\");\n\tlet child;\n\ttry {\n\t\tchild = spawn(process.execPath, [\n\t\t\tentryPath,\n\t\t\t\"--port\",\n\t\t\tString(port),\n\t\t\t\"--state-dir\",\n\t\t\tstateDir\n\t\t], {\n\t\t\tdetached: true,\n\t\t\tstdio: [\n\t\t\t\t\"ignore\",\n\t\t\t\tlogFd,\n\t\t\t\tlogFd\n\t\t\t]\n\t\t});\n\t} finally {\n\t\tfs.closeSync(logFd);\n\t}\n\tchild.unref();\n\treturn child;\n}\n/**\n* Reads the registry entry and classifies it. \"dead-or-unhealthy\" covers\n* both a provably dead pid AND a live pid that fails health — the latter\n* can't be confirmed as our daemon (a reused pid after a reboot, a hung\n* foreign process), so it is never signaled, only dropped.\n*/\nasync function observeExisting(registryFile, healthPath, ownVersion) {\n\tconst entry = await readJsonFile(registryFile, isRegistryEntry);\n\tif (!entry) return { kind: \"absent\" };\n\tif (!isPidAlive(entry.pid)) return {\n\t\tkind: \"dead-or-unhealthy\",\n\t\tentry\n\t};\n\tconst health = await probeHealth(entry.port, healthPath, EXISTING_HEALTH_TIMEOUT_MS);\n\tif (health && health.version === ownVersion) return {\n\t\tkind: \"healthy\",\n\t\tentry\n\t};\n\tif (health && health.version !== ownVersion) return {\n\t\tkind: \"stale-version\",\n\t\tentry\n\t};\n\treturn {\n\t\tkind: \"dead-or-unhealthy\",\n\t\tentry\n\t};\n}\n/**\n* `<registryRoot>/.<name>.lock-target` — the file `proper-lockfile` locks\n* for the concurrent-ensure protocol (it marks the lock as a sibling\n* `<file>.lock` directory it manages itself). A stable, never-deleted file:\n* unlike the registry JSON, which this module removes and rewrites\n* repeatedly while ensuring, the lock target must exist continuously for\n* `proper-lockfile`'s `realpath` resolution.\n*/\nfunction lockFilePath(registryRoot, name) {\n\treturn path.join(registryRoot, `.${name}.lock-target`);\n}\n/**\n* Acquires the concurrent-ensure protocol's inter-process lock (spec § 2)\n* via `proper-lockfile` — its staleness/compromise semantics are adopted\n* wholesale rather than re-implementing pid liveness checking on top (the\n* dependency razor: commodity locking is exactly where unforeseen edge\n* cases hide). Polls roughly every 250 ms for up to a 10 s budget; on\n* exhaustion (`ELOCKED`, meaning a live, non-stale holder never let go),\n* throws the pinned timeout error. Any other failure propagates as-is.\n*/\nasync function acquireLock(registryRoot, name) {\n\tawait fs$1.mkdir(registryRoot, { recursive: true });\n\tconst target = lockFilePath(registryRoot, name);\n\tawait fs$1.writeFile(target, \"\", { flag: \"a\" });\n\tconst retries = Math.max(1, Math.floor(LOCK_WAIT_BUDGET_MS / LOCK_RETRY_INTERVAL_MS));\n\ttry {\n\t\treturn await properLockfile.lock(target, {\n\t\t\tstale: LOCK_STALE_MS,\n\t\t\tretries: {\n\t\t\t\tretries,\n\t\t\t\tminTimeout: LOCK_RETRY_INTERVAL_MS,\n\t\t\t\tmaxTimeout: LOCK_RETRY_INTERVAL_MS,\n\t\t\t\tfactor: 1\n\t\t\t}\n\t\t});\n\t} catch (err) {\n\t\tif (isErrnoException(err) && err.code === \"ELOCKED\") throw new Error(`timed out waiting for another process ensuring the ${name} emulator — remove ${target}.lock if stale.`);\n\t\tthrow err;\n\t}\n}\n/**\n* Ensure the named daemon is running and healthy at this package's version,\n* starting or replacing it as needed (spec § 2 `daemon.ts`). Idempotent —\n* safe to call repeatedly, including across unrelated processes on the same\n* machine, and safe under concurrent callers across processes: the\n* observe→spawn→persist critical section is serialized per daemon name by\n* an inter-process lock (the \"Concurrent-ensure protocol\").\n*\n* `entry` is the resolved absolute path to the daemon program to spawn —\n* the CALLER resolves it (local-dev spec § 2's publish note). This module\n* used to resolve it itself via `import.meta.resolve('@internal/dev-emulators/…')`,\n* which only works in-repo: `@internal/*` are private workspace packages a\n* published npm consumer never receives. In-repo callers (including tests)\n* still resolve `@internal/dev-emulators/*-main` the same way; a published\n* consumer resolves its own public subpaths instead.\n*/\nasync function ensureDaemon(name, entry, opts = {}) {\n\tconst registryRoot = opts.registryRoot ?? defaultRegistryRoot();\n\tconst registryFile = registryFilePath(registryRoot, name);\n\tconst healthPath = healthPathFor(name);\n\tconst ownVersion = readOwnVersion();\n\tconst quick = await observeExisting(registryFile, healthPath, ownVersion);\n\tif (quick.kind === \"healthy\") return { url: `http://127.0.0.1:${quick.entry.port}` };\n\tconst release = await acquireLock(registryRoot, name);\n\ttry {\n\t\tconst observed = await observeExisting(registryFile, healthPath, ownVersion);\n\t\tif (observed.kind === \"healthy\") return { url: `http://127.0.0.1:${observed.entry.port}` };\n\t\tlet reusablePort;\n\t\tif (observed.kind === \"stale-version\") {\n\t\t\treusablePort = observed.entry.port;\n\t\t\tawait terminate(observed.entry.pid, TERMINATE_GRACE_MS);\n\t\t\tawait fs$1.rm(registryFile, { force: true });\n\t\t} else if (observed.kind === \"dead-or-unhealthy\") {\n\t\t\treusablePort = observed.entry.port;\n\t\t\tawait fs$1.rm(registryFile, { force: true });\n\t\t}\n\t\tconst isFreshAllocation = reusablePort === void 0;\n\t\tconst maxAttempts = isFreshAllocation ? MAX_FRESH_PORT_CANDIDATES : 1;\n\t\tlet port = reusablePort ?? await smallestUnused(await usedPorts(registryRoot), MIN_PORT);\n\t\tconst stateDir = daemonStateDir(registryRoot, name);\n\t\tconst logPath = daemonLogPath(registryRoot, name);\n\t\tawait fs$1.mkdir(stateDir, { recursive: true });\n\t\tawait fs$1.mkdir(path.dirname(logPath), { recursive: true });\n\t\tfor (let attempt = 1;; attempt++) {\n\t\t\tconst child = spawnDaemonProcess(entry, port, stateDir, logPath);\n\t\t\tif (child.pid === void 0) throw new Error(`failed to spawn the ${name} emulator — see ${logPath}.`);\n\t\t\tawait new StateFile(registryFile).write({\n\t\t\t\tpid: child.pid,\n\t\t\t\tport,\n\t\t\t\tversion: ownVersion,\n\t\t\t\tlogPath\n\t\t\t});\n\t\t\tconst outcome = await awaitHealthy(child, port, healthPath, ownVersion, START_HEALTH_BUDGET_MS);\n\t\t\tif (outcome.healthy) return { url: `http://127.0.0.1:${port}` };\n\t\t\tif (!(isFreshAllocation && outcome.exitedBeforeHealthy && attempt < maxAttempts)) {\n\t\t\t\tawait terminate(child.pid, TERMINATE_GRACE_MS);\n\t\t\t\tawait fs$1.rm(registryFile, { force: true });\n\t\t\t\tthrow new Error(`${name} emulator failed to start on port ${port} — see ${logPath}.`);\n\t\t\t}\n\t\t\tawait fs$1.rm(registryFile, { force: true });\n\t\t\tport = await smallestUnused(await usedPorts(registryRoot), port + 1);\n\t\t}\n\t} finally {\n\t\tawait release();\n\t}\n}\n/** SIGTERM/SIGKILL + registry cleanup. Not called by any v1 command — an operator escape hatch, exported for tests. */\nasync function stopDaemon(name, opts = {}) {\n\tconst registryFile = registryFilePath(opts.registryRoot ?? defaultRegistryRoot(), name);\n\tconst entry = await readJsonFile(registryFile, isRegistryEntry);\n\tif (entry) await terminate(entry.pid, TERMINATE_GRACE_MS);\n\tawait fs$1.rm(registryFile, { force: true });\n}\n//#endregion\n//#region src/segments.ts\n/**\n* API hygiene shared by both daemons (local-dev spec § 2): every `<app>`,\n* `<id>`, and `<name>` path segment must match this shape or the request is\n* a 400 naming the segment.\n*/\nconst SEGMENT_RE = /^[a-z0-9][a-z0-9-]*$/;\nfunction isValidSegment(segment) {\n\treturn segment.length <= 63 && SEGMENT_RE.test(segment);\n}\n//#endregion\nexport { ensureDaemon as a, readOwnVersion as c, stopDaemon as d, StateFile as f, defaultRegistryRoot as i, readRegistryEntry as l, daemonLogPath as n, healthPathFor as o, readJsonFile as p, daemonStateDir as r, isPidAlive as s, isValidSegment as t, registryFilePath as u };\n\n//# sourceMappingURL=segments-NpKN-46R.mjs.map"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12],"mappings":";;;;;;;;;;;;CAAA,IAAI,YAAA,UAAoB,WAAW;CAEnC,IAAI,UAAU,QAAQ;CACtB,IAAI,MAAM;CAEV,IAAI,WAAW,QAAQ,IAAI,wBAAwB,QAAQ;CAE3D,QAAQ,MAAM,WAAW;EACvB,IAAI,CAAC,KACH,MAAM,QAAQ,KAAK,OAAO;EAC5B,OAAO;CACT;CACA,IAAI;EACF,QAAQ,IAAI;CACd,SAAS,IAAI,CAAC;CAGd,IAAI,OAAO,QAAQ,UAAU,YAAY;EACvC,IAAI,QAAQ,QAAQ;EACpB,QAAQ,QAAQ,SAAU,GAAG;GAC3B,MAAM;GACN,MAAM,KAAK,SAAS,CAAC;EACvB;EACA,IAAI,OAAO,gBAAgB,OAAO,eAAe,QAAQ,OAAO,KAAK;CACvE;CAEA,OAAO,UAAU;CAEjB,SAAS,MAAO,IAAI;EAKlB,IAAI,UAAU,eAAe,WAAW,KACpC,QAAQ,QAAQ,MAAM,wBAAwB,GAChD,YAAY,EAAE;EAIhB,IAAI,CAAC,GAAG,SACN,aAAa,EAAE;EAQjB,GAAG,QAAQ,SAAS,GAAG,KAAK;EAC5B,GAAG,SAAS,SAAS,GAAG,MAAM;EAC9B,GAAG,SAAS,SAAS,GAAG,MAAM;EAE9B,GAAG,QAAQ,SAAS,GAAG,KAAK;EAC5B,GAAG,SAAS,SAAS,GAAG,MAAM;EAC9B,GAAG,SAAS,SAAS,GAAG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,cAAc,OAAO,KAAK,GAAG,CAAC;CACxD,MAAM,UAAU,KAAK,KAAK,MAAM,MAAM,cAAc;CACpD,MAAM,MAAM,GAAG,aAAa,SAAS,MAAM;CAC3C,MAAM,SAAS,KAAK,MAAM,GAAG;CAC7B,IAAI,CAAC,cAAc,MAAM,GAAG,MAAM,IAAI,MAAM,wCAAwC,SAAS;CAC7F,OAAO,OAAO;AACf;;;;;;AA8RA,MAAM,aAAa;AACnB,SAAS,eAAe,SAAS;CAChC,OAAO,QAAQ,UAAU,MAAM,WAAW,KAAK,OAAO;AACvD"}
|
|
1
|
+
{"version":3,"file":"segments-NpKN-46R-C_LQ2urs.mjs","names":["fs","path"],"sources":["../../../../node_modules/graceful-fs/polyfills.js","../../../../node_modules/graceful-fs/legacy-streams.js","../../../../node_modules/graceful-fs/clone.js","../../../../node_modules/graceful-fs/graceful-fs.js","../../../../node_modules/retry/lib/retry_operation.js","../../../../node_modules/retry/lib/retry.js","../../../../node_modules/retry/index.js","../../../../node_modules/signal-exit/signals.js","../../../../node_modules/signal-exit/index.js","../../../../node_modules/proper-lockfile/lib/mtime-precision.js","../../../../node_modules/proper-lockfile/lib/lockfile.js","../../../../node_modules/proper-lockfile/lib/adapter.js","../../../../node_modules/proper-lockfile/index.js","../../../1-prisma-cloud/0-lowering/dev-emulators/dist/segments-NpKN-46R.mjs"],"sourcesContent":["var constants = require('constants')\n\nvar origCwd = process.cwd\nvar cwd = null\n\nvar platform = process.env.GRACEFUL_FS_PLATFORM || process.platform\n\nprocess.cwd = function() {\n if (!cwd)\n cwd = origCwd.call(process)\n return cwd\n}\ntry {\n process.cwd()\n} catch (er) {}\n\n// This check is needed until node.js 12 is required\nif (typeof process.chdir === 'function') {\n var chdir = process.chdir\n process.chdir = function (d) {\n cwd = null\n chdir.call(process, d)\n }\n if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir)\n}\n\nmodule.exports = patch\n\nfunction patch (fs) {\n // (re-)implement some things that are known busted or missing.\n\n // lchmod, broken prior to 0.6.2\n // back-port the fix here.\n if (constants.hasOwnProperty('O_SYMLINK') &&\n process.version.match(/^v0\\.6\\.[0-2]|^v0\\.5\\./)) {\n patchLchmod(fs)\n }\n\n // lutimes implementation, or no-op\n if (!fs.lutimes) {\n patchLutimes(fs)\n }\n\n // https://github.com/isaacs/node-graceful-fs/issues/4\n // Chown should not fail on einval or eperm if non-root.\n // It should not fail on enosys ever, as this just indicates\n // that a fs doesn't support the intended operation.\n\n fs.chown = chownFix(fs.chown)\n fs.fchown = chownFix(fs.fchown)\n fs.lchown = chownFix(fs.lchown)\n\n fs.chmod = chmodFix(fs.chmod)\n fs.fchmod = chmodFix(fs.fchmod)\n fs.lchmod = chmodFix(fs.lchmod)\n\n fs.chownSync = chownFixSync(fs.chownSync)\n fs.fchownSync = chownFixSync(fs.fchownSync)\n fs.lchownSync = chownFixSync(fs.lchownSync)\n\n fs.chmodSync = chmodFixSync(fs.chmodSync)\n fs.fchmodSync = chmodFixSync(fs.fchmodSync)\n fs.lchmodSync = chmodFixSync(fs.lchmodSync)\n\n fs.stat = statFix(fs.stat)\n fs.fstat = statFix(fs.fstat)\n fs.lstat = statFix(fs.lstat)\n\n fs.statSync = statFixSync(fs.statSync)\n fs.fstatSync = statFixSync(fs.fstatSync)\n fs.lstatSync = statFixSync(fs.lstatSync)\n\n // if lchmod/lchown do not exist, then make them no-ops\n if (fs.chmod && !fs.lchmod) {\n fs.lchmod = function (path, mode, cb) {\n if (cb) process.nextTick(cb)\n }\n fs.lchmodSync = function () {}\n }\n if (fs.chown && !fs.lchown) {\n fs.lchown = function (path, uid, gid, cb) {\n if (cb) process.nextTick(cb)\n }\n fs.lchownSync = function () {}\n }\n\n // on Windows, A/V software can lock the directory, causing this\n // to fail with an EACCES or EPERM if the directory contains newly\n // created files. Try again on failure, for up to 60 seconds.\n\n // Set the timeout this long because some Windows Anti-Virus, such as Parity\n // bit9, may lock files for up to a minute, causing npm package install\n // failures. Also, take care to yield the scheduler. Windows scheduling gives\n // CPU to a busy looping process, which can cause the program causing the lock\n // contention to be starved of CPU by node, so the contention doesn't resolve.\n if (platform === \"win32\") {\n fs.rename = typeof fs.rename !== 'function' ? fs.rename\n : (function (fs$rename) {\n function rename (from, to, cb) {\n var start = Date.now()\n var backoff = 0;\n fs$rename(from, to, function CB (er) {\n if (er\n && (er.code === \"EACCES\" || er.code === \"EPERM\" || er.code === \"EBUSY\")\n && Date.now() - start < 60000) {\n setTimeout(function() {\n fs.stat(to, function (stater, st) {\n if (stater && stater.code === \"ENOENT\")\n fs$rename(from, to, CB);\n else\n cb(er)\n })\n }, backoff)\n if (backoff < 100)\n backoff += 10;\n return;\n }\n if (cb) cb(er)\n })\n }\n if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename)\n return rename\n })(fs.rename)\n }\n\n // if read() returns EAGAIN, then just try it again.\n fs.read = typeof fs.read !== 'function' ? fs.read\n : (function (fs$read) {\n function read (fd, buffer, offset, length, position, callback_) {\n var callback\n if (callback_ && typeof callback_ === 'function') {\n var eagCounter = 0\n callback = function (er, _, __) {\n if (er && er.code === 'EAGAIN' && eagCounter < 10) {\n eagCounter ++\n return fs$read.call(fs, fd, buffer, offset, length, position, callback)\n }\n callback_.apply(this, arguments)\n }\n }\n return fs$read.call(fs, fd, buffer, offset, length, position, callback)\n }\n\n // This ensures `util.promisify` works as it does for native `fs.read`.\n if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read)\n return read\n })(fs.read)\n\n fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync\n : (function (fs$readSync) { return function (fd, buffer, offset, length, position) {\n var eagCounter = 0\n while (true) {\n try {\n return fs$readSync.call(fs, fd, buffer, offset, length, position)\n } catch (er) {\n if (er.code === 'EAGAIN' && eagCounter < 10) {\n eagCounter ++\n continue\n }\n throw er\n }\n }\n }})(fs.readSync)\n\n function patchLchmod (fs) {\n fs.lchmod = function (path, mode, callback) {\n fs.open( path\n , constants.O_WRONLY | constants.O_SYMLINK\n , mode\n , function (err, fd) {\n if (err) {\n if (callback) callback(err)\n return\n }\n // prefer to return the chmod error, if one occurs,\n // but still try to close, and report closing errors if they occur.\n fs.fchmod(fd, mode, function (err) {\n fs.close(fd, function(err2) {\n if (callback) callback(err || err2)\n })\n })\n })\n }\n\n fs.lchmodSync = function (path, mode) {\n var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)\n\n // prefer to return the chmod error, if one occurs,\n // but still try to close, and report closing errors if they occur.\n var threw = true\n var ret\n try {\n ret = fs.fchmodSync(fd, mode)\n threw = false\n } finally {\n if (threw) {\n try {\n fs.closeSync(fd)\n } catch (er) {}\n } else {\n fs.closeSync(fd)\n }\n }\n return ret\n }\n }\n\n function patchLutimes (fs) {\n if (constants.hasOwnProperty(\"O_SYMLINK\") && fs.futimes) {\n fs.lutimes = function (path, at, mt, cb) {\n fs.open(path, constants.O_SYMLINK, function (er, fd) {\n if (er) {\n if (cb) cb(er)\n return\n }\n fs.futimes(fd, at, mt, function (er) {\n fs.close(fd, function (er2) {\n if (cb) cb(er || er2)\n })\n })\n })\n }\n\n fs.lutimesSync = function (path, at, mt) {\n var fd = fs.openSync(path, constants.O_SYMLINK)\n var ret\n var threw = true\n try {\n ret = fs.futimesSync(fd, at, mt)\n threw = false\n } finally {\n if (threw) {\n try {\n fs.closeSync(fd)\n } catch (er) {}\n } else {\n fs.closeSync(fd)\n }\n }\n return ret\n }\n\n } else if (fs.futimes) {\n fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }\n fs.lutimesSync = function () {}\n }\n }\n\n function chmodFix (orig) {\n if (!orig) return orig\n return function (target, mode, cb) {\n return orig.call(fs, target, mode, function (er) {\n if (chownErOk(er)) er = null\n if (cb) cb.apply(this, arguments)\n })\n }\n }\n\n function chmodFixSync (orig) {\n if (!orig) return orig\n return function (target, mode) {\n try {\n return orig.call(fs, target, mode)\n } catch (er) {\n if (!chownErOk(er)) throw er\n }\n }\n }\n\n\n function chownFix (orig) {\n if (!orig) return orig\n return function (target, uid, gid, cb) {\n return orig.call(fs, target, uid, gid, function (er) {\n if (chownErOk(er)) er = null\n if (cb) cb.apply(this, arguments)\n })\n }\n }\n\n function chownFixSync (orig) {\n if (!orig) return orig\n return function (target, uid, gid) {\n try {\n return orig.call(fs, target, uid, gid)\n } catch (er) {\n if (!chownErOk(er)) throw er\n }\n }\n }\n\n function statFix (orig) {\n if (!orig) return orig\n // Older versions of Node erroneously returned signed integers for\n // uid + gid.\n return function (target, options, cb) {\n if (typeof options === 'function') {\n cb = options\n options = null\n }\n function callback (er, stats) {\n if (stats) {\n if (stats.uid < 0) stats.uid += 0x100000000\n if (stats.gid < 0) stats.gid += 0x100000000\n }\n if (cb) cb.apply(this, arguments)\n }\n return options ? orig.call(fs, target, options, callback)\n : orig.call(fs, target, callback)\n }\n }\n\n function statFixSync (orig) {\n if (!orig) return orig\n // Older versions of Node erroneously returned signed integers for\n // uid + gid.\n return function (target, options) {\n var stats = options ? orig.call(fs, target, options)\n : orig.call(fs, target)\n if (stats) {\n if (stats.uid < 0) stats.uid += 0x100000000\n if (stats.gid < 0) stats.gid += 0x100000000\n }\n return stats;\n }\n }\n\n // ENOSYS means that the fs doesn't support the op. Just ignore\n // that, because it doesn't matter.\n //\n // if there's no getuid, or if getuid() is something other\n // than 0, and the error is EINVAL or EPERM, then just ignore\n // it.\n //\n // This specific case is a silent failure in cp, install, tar,\n // and most other unix tools that manage permissions.\n //\n // When running as root, or if other types of errors are\n // encountered, then it's strict.\n function chownErOk (er) {\n if (!er)\n return true\n\n if (er.code === \"ENOSYS\")\n return true\n\n var nonroot = !process.getuid || process.getuid() !== 0\n if (nonroot) {\n if (er.code === \"EINVAL\" || er.code === \"EPERM\")\n return true\n }\n\n return false\n }\n}\n","var Stream = require('stream').Stream\n\nmodule.exports = legacy\n\nfunction legacy (fs) {\n return {\n ReadStream: ReadStream,\n WriteStream: WriteStream\n }\n\n function ReadStream (path, options) {\n if (!(this instanceof ReadStream)) return new ReadStream(path, options);\n\n Stream.call(this);\n\n var self = this;\n\n this.path = path;\n this.fd = null;\n this.readable = true;\n this.paused = false;\n\n this.flags = 'r';\n this.mode = 438; /*=0666*/\n this.bufferSize = 64 * 1024;\n\n options = options || {};\n\n // Mixin options into this\n var keys = Object.keys(options);\n for (var index = 0, length = keys.length; index < length; index++) {\n var key = keys[index];\n this[key] = options[key];\n }\n\n if (this.encoding) this.setEncoding(this.encoding);\n\n if (this.start !== undefined) {\n if ('number' !== typeof this.start) {\n throw TypeError('start must be a Number');\n }\n if (this.end === undefined) {\n this.end = Infinity;\n } else if ('number' !== typeof this.end) {\n throw TypeError('end must be a Number');\n }\n\n if (this.start > this.end) {\n throw new Error('start must be <= end');\n }\n\n this.pos = this.start;\n }\n\n if (this.fd !== null) {\n process.nextTick(function() {\n self._read();\n });\n return;\n }\n\n fs.open(this.path, this.flags, this.mode, function (err, fd) {\n if (err) {\n self.emit('error', err);\n self.readable = false;\n return;\n }\n\n self.fd = fd;\n self.emit('open', fd);\n self._read();\n })\n }\n\n function WriteStream (path, options) {\n if (!(this instanceof WriteStream)) return new WriteStream(path, options);\n\n Stream.call(this);\n\n this.path = path;\n this.fd = null;\n this.writable = true;\n\n this.flags = 'w';\n this.encoding = 'binary';\n this.mode = 438; /*=0666*/\n this.bytesWritten = 0;\n\n options = options || {};\n\n // Mixin options into this\n var keys = Object.keys(options);\n for (var index = 0, length = keys.length; index < length; index++) {\n var key = keys[index];\n this[key] = options[key];\n }\n\n if (this.start !== undefined) {\n if ('number' !== typeof this.start) {\n throw TypeError('start must be a Number');\n }\n if (this.start < 0) {\n throw new Error('start must be >= zero');\n }\n\n this.pos = this.start;\n }\n\n this.busy = false;\n this._queue = [];\n\n if (this.fd === null) {\n this._open = fs.open;\n this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);\n this.flush();\n }\n }\n}\n","'use strict'\n\nmodule.exports = clone\n\nvar getPrototypeOf = Object.getPrototypeOf || function (obj) {\n return obj.__proto__\n}\n\nfunction clone (obj) {\n if (obj === null || typeof obj !== 'object')\n return obj\n\n if (obj instanceof Object)\n var copy = { __proto__: getPrototypeOf(obj) }\n else\n var copy = Object.create(null)\n\n Object.getOwnPropertyNames(obj).forEach(function (key) {\n Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))\n })\n\n return copy\n}\n","var fs = require('fs')\nvar polyfills = require('./polyfills.js')\nvar legacy = require('./legacy-streams.js')\nvar clone = require('./clone.js')\n\nvar util = require('util')\n\n/* istanbul ignore next - node 0.x polyfill */\nvar gracefulQueue\nvar previousSymbol\n\n/* istanbul ignore else - node 0.x polyfill */\nif (typeof Symbol === 'function' && typeof Symbol.for === 'function') {\n gracefulQueue = Symbol.for('graceful-fs.queue')\n // This is used in testing by future versions\n previousSymbol = Symbol.for('graceful-fs.previous')\n} else {\n gracefulQueue = '___graceful-fs.queue'\n previousSymbol = '___graceful-fs.previous'\n}\n\nfunction noop () {}\n\nfunction publishQueue(context, queue) {\n Object.defineProperty(context, gracefulQueue, {\n get: function() {\n return queue\n }\n })\n}\n\nvar debug = noop\nif (util.debuglog)\n debug = util.debuglog('gfs4')\nelse if (/\\bgfs4\\b/i.test(process.env.NODE_DEBUG || ''))\n debug = function() {\n var m = util.format.apply(util, arguments)\n m = 'GFS4: ' + m.split(/\\n/).join('\\nGFS4: ')\n console.error(m)\n }\n\n// Once time initialization\nif (!fs[gracefulQueue]) {\n // This queue can be shared by multiple loaded instances\n var queue = global[gracefulQueue] || []\n publishQueue(fs, queue)\n\n // Patch fs.close/closeSync to shared queue version, because we need\n // to retry() whenever a close happens *anywhere* in the program.\n // This is essential when multiple graceful-fs instances are\n // in play at the same time.\n fs.close = (function (fs$close) {\n function close (fd, cb) {\n return fs$close.call(fs, fd, function (err) {\n // This function uses the graceful-fs shared queue\n if (!err) {\n resetQueue()\n }\n\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n })\n }\n\n Object.defineProperty(close, previousSymbol, {\n value: fs$close\n })\n return close\n })(fs.close)\n\n fs.closeSync = (function (fs$closeSync) {\n function closeSync (fd) {\n // This function uses the graceful-fs shared queue\n fs$closeSync.apply(fs, arguments)\n resetQueue()\n }\n\n Object.defineProperty(closeSync, previousSymbol, {\n value: fs$closeSync\n })\n return closeSync\n })(fs.closeSync)\n\n if (/\\bgfs4\\b/i.test(process.env.NODE_DEBUG || '')) {\n process.on('exit', function() {\n debug(fs[gracefulQueue])\n require('assert').equal(fs[gracefulQueue].length, 0)\n })\n }\n}\n\nif (!global[gracefulQueue]) {\n publishQueue(global, fs[gracefulQueue]);\n}\n\nmodule.exports = patch(clone(fs))\nif (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {\n module.exports = patch(fs)\n fs.__patched = true;\n}\n\nfunction patch (fs) {\n // Everything that references the open() function needs to be in here\n polyfills(fs)\n fs.gracefulify = patch\n\n fs.createReadStream = createReadStream\n fs.createWriteStream = createWriteStream\n var fs$readFile = fs.readFile\n fs.readFile = readFile\n function readFile (path, options, cb) {\n if (typeof options === 'function')\n cb = options, options = null\n\n return go$readFile(path, options, cb)\n\n function go$readFile (path, options, cb, startTime) {\n return fs$readFile(path, options, function (err) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n var fs$writeFile = fs.writeFile\n fs.writeFile = writeFile\n function writeFile (path, data, options, cb) {\n if (typeof options === 'function')\n cb = options, options = null\n\n return go$writeFile(path, data, options, cb)\n\n function go$writeFile (path, data, options, cb, startTime) {\n return fs$writeFile(path, data, options, function (err) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n var fs$appendFile = fs.appendFile\n if (fs$appendFile)\n fs.appendFile = appendFile\n function appendFile (path, data, options, cb) {\n if (typeof options === 'function')\n cb = options, options = null\n\n return go$appendFile(path, data, options, cb)\n\n function go$appendFile (path, data, options, cb, startTime) {\n return fs$appendFile(path, data, options, function (err) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n var fs$copyFile = fs.copyFile\n if (fs$copyFile)\n fs.copyFile = copyFile\n function copyFile (src, dest, flags, cb) {\n if (typeof flags === 'function') {\n cb = flags\n flags = 0\n }\n return go$copyFile(src, dest, flags, cb)\n\n function go$copyFile (src, dest, flags, cb, startTime) {\n return fs$copyFile(src, dest, flags, function (err) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n var fs$readdir = fs.readdir\n fs.readdir = readdir\n var noReaddirOptionVersions = /^v[0-5]\\./\n function readdir (path, options, cb) {\n if (typeof options === 'function')\n cb = options, options = null\n\n var go$readdir = noReaddirOptionVersions.test(process.version)\n ? function go$readdir (path, options, cb, startTime) {\n return fs$readdir(path, fs$readdirCallback(\n path, options, cb, startTime\n ))\n }\n : function go$readdir (path, options, cb, startTime) {\n return fs$readdir(path, options, fs$readdirCallback(\n path, options, cb, startTime\n ))\n }\n\n return go$readdir(path, options, cb)\n\n function fs$readdirCallback (path, options, cb, startTime) {\n return function (err, files) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([\n go$readdir,\n [path, options, cb],\n err,\n startTime || Date.now(),\n Date.now()\n ])\n else {\n if (files && files.sort)\n files.sort()\n\n if (typeof cb === 'function')\n cb.call(this, err, files)\n }\n }\n }\n }\n\n if (process.version.substr(0, 4) === 'v0.8') {\n var legStreams = legacy(fs)\n ReadStream = legStreams.ReadStream\n WriteStream = legStreams.WriteStream\n }\n\n var fs$ReadStream = fs.ReadStream\n if (fs$ReadStream) {\n ReadStream.prototype = Object.create(fs$ReadStream.prototype)\n ReadStream.prototype.open = ReadStream$open\n }\n\n var fs$WriteStream = fs.WriteStream\n if (fs$WriteStream) {\n WriteStream.prototype = Object.create(fs$WriteStream.prototype)\n WriteStream.prototype.open = WriteStream$open\n }\n\n Object.defineProperty(fs, 'ReadStream', {\n get: function () {\n return ReadStream\n },\n set: function (val) {\n ReadStream = val\n },\n enumerable: true,\n configurable: true\n })\n Object.defineProperty(fs, 'WriteStream', {\n get: function () {\n return WriteStream\n },\n set: function (val) {\n WriteStream = val\n },\n enumerable: true,\n configurable: true\n })\n\n // legacy names\n var FileReadStream = ReadStream\n Object.defineProperty(fs, 'FileReadStream', {\n get: function () {\n return FileReadStream\n },\n set: function (val) {\n FileReadStream = val\n },\n enumerable: true,\n configurable: true\n })\n var FileWriteStream = WriteStream\n Object.defineProperty(fs, 'FileWriteStream', {\n get: function () {\n return FileWriteStream\n },\n set: function (val) {\n FileWriteStream = val\n },\n enumerable: true,\n configurable: true\n })\n\n function ReadStream (path, options) {\n if (this instanceof ReadStream)\n return fs$ReadStream.apply(this, arguments), this\n else\n return ReadStream.apply(Object.create(ReadStream.prototype), arguments)\n }\n\n function ReadStream$open () {\n var that = this\n open(that.path, that.flags, that.mode, function (err, fd) {\n if (err) {\n if (that.autoClose)\n that.destroy()\n\n that.emit('error', err)\n } else {\n that.fd = fd\n that.emit('open', fd)\n that.read()\n }\n })\n }\n\n function WriteStream (path, options) {\n if (this instanceof WriteStream)\n return fs$WriteStream.apply(this, arguments), this\n else\n return WriteStream.apply(Object.create(WriteStream.prototype), arguments)\n }\n\n function WriteStream$open () {\n var that = this\n open(that.path, that.flags, that.mode, function (err, fd) {\n if (err) {\n that.destroy()\n that.emit('error', err)\n } else {\n that.fd = fd\n that.emit('open', fd)\n }\n })\n }\n\n function createReadStream (path, options) {\n return new fs.ReadStream(path, options)\n }\n\n function createWriteStream (path, options) {\n return new fs.WriteStream(path, options)\n }\n\n var fs$open = fs.open\n fs.open = open\n function open (path, flags, mode, cb) {\n if (typeof mode === 'function')\n cb = mode, mode = null\n\n return go$open(path, flags, mode, cb)\n\n function go$open (path, flags, mode, cb, startTime) {\n return fs$open(path, flags, mode, function (err, fd) {\n if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))\n enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()])\n else {\n if (typeof cb === 'function')\n cb.apply(this, arguments)\n }\n })\n }\n }\n\n return fs\n}\n\nfunction enqueue (elem) {\n debug('ENQUEUE', elem[0].name, elem[1])\n fs[gracefulQueue].push(elem)\n retry()\n}\n\n// keep track of the timeout between retry() calls\nvar retryTimer\n\n// reset the startTime and lastTime to now\n// this resets the start of the 60 second overall timeout as well as the\n// delay between attempts so that we'll retry these jobs sooner\nfunction resetQueue () {\n var now = Date.now()\n for (var i = 0; i < fs[gracefulQueue].length; ++i) {\n // entries that are only a length of 2 are from an older version, don't\n // bother modifying those since they'll be retried anyway.\n if (fs[gracefulQueue][i].length > 2) {\n fs[gracefulQueue][i][3] = now // startTime\n fs[gracefulQueue][i][4] = now // lastTime\n }\n }\n // call retry to make sure we're actively processing the queue\n retry()\n}\n\nfunction retry () {\n // clear the timer and remove it to help prevent unintended concurrency\n clearTimeout(retryTimer)\n retryTimer = undefined\n\n if (fs[gracefulQueue].length === 0)\n return\n\n var elem = fs[gracefulQueue].shift()\n var fn = elem[0]\n var args = elem[1]\n // these items may be unset if they were added by an older graceful-fs\n var err = elem[2]\n var startTime = elem[3]\n var lastTime = elem[4]\n\n // if we don't have a startTime we have no way of knowing if we've waited\n // long enough, so go ahead and retry this item now\n if (startTime === undefined) {\n debug('RETRY', fn.name, args)\n fn.apply(null, args)\n } else if (Date.now() - startTime >= 60000) {\n // it's been more than 60 seconds total, bail now\n debug('TIMEOUT', fn.name, args)\n var cb = args.pop()\n if (typeof cb === 'function')\n cb.call(null, err)\n } else {\n // the amount of time between the last attempt and right now\n var sinceAttempt = Date.now() - lastTime\n // the amount of time between when we first tried, and when we last tried\n // rounded up to at least 1\n var sinceStart = Math.max(lastTime - startTime, 1)\n // backoff. wait longer than the total time we've been retrying, but only\n // up to a maximum of 100ms\n var desiredDelay = Math.min(sinceStart * 1.2, 100)\n // it's been long enough since the last retry, do it again\n if (sinceAttempt >= desiredDelay) {\n debug('RETRY', fn.name, args)\n fn.apply(null, args.concat([startTime]))\n } else {\n // if we can't do this job yet, push it to the end of the queue\n // and let the next iteration check again\n fs[gracefulQueue].push(elem)\n }\n }\n\n // schedule our next run if one isn't already scheduled\n if (retryTimer === undefined) {\n retryTimer = setTimeout(retry, 0)\n }\n}\n","function RetryOperation(timeouts, options) {\n // Compatibility for the old (timeouts, retryForever) signature\n if (typeof options === 'boolean') {\n options = { forever: options };\n }\n\n this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));\n this._timeouts = timeouts;\n this._options = options || {};\n this._maxRetryTime = options && options.maxRetryTime || Infinity;\n this._fn = null;\n this._errors = [];\n this._attempts = 1;\n this._operationTimeout = null;\n this._operationTimeoutCb = null;\n this._timeout = null;\n this._operationStart = null;\n\n if (this._options.forever) {\n this._cachedTimeouts = this._timeouts.slice(0);\n }\n}\nmodule.exports = RetryOperation;\n\nRetryOperation.prototype.reset = function() {\n this._attempts = 1;\n this._timeouts = this._originalTimeouts;\n}\n\nRetryOperation.prototype.stop = function() {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n\n this._timeouts = [];\n this._cachedTimeouts = null;\n};\n\nRetryOperation.prototype.retry = function(err) {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n\n if (!err) {\n return false;\n }\n var currentTime = new Date().getTime();\n if (err && currentTime - this._operationStart >= this._maxRetryTime) {\n this._errors.unshift(new Error('RetryOperation timeout occurred'));\n return false;\n }\n\n this._errors.push(err);\n\n var timeout = this._timeouts.shift();\n if (timeout === undefined) {\n if (this._cachedTimeouts) {\n // retry forever, only keep last error\n this._errors.splice(this._errors.length - 1, this._errors.length);\n this._timeouts = this._cachedTimeouts.slice(0);\n timeout = this._timeouts.shift();\n } else {\n return false;\n }\n }\n\n var self = this;\n var timer = setTimeout(function() {\n self._attempts++;\n\n if (self._operationTimeoutCb) {\n self._timeout = setTimeout(function() {\n self._operationTimeoutCb(self._attempts);\n }, self._operationTimeout);\n\n if (self._options.unref) {\n self._timeout.unref();\n }\n }\n\n self._fn(self._attempts);\n }, timeout);\n\n if (this._options.unref) {\n timer.unref();\n }\n\n return true;\n};\n\nRetryOperation.prototype.attempt = function(fn, timeoutOps) {\n this._fn = fn;\n\n if (timeoutOps) {\n if (timeoutOps.timeout) {\n this._operationTimeout = timeoutOps.timeout;\n }\n if (timeoutOps.cb) {\n this._operationTimeoutCb = timeoutOps.cb;\n }\n }\n\n var self = this;\n if (this._operationTimeoutCb) {\n this._timeout = setTimeout(function() {\n self._operationTimeoutCb();\n }, self._operationTimeout);\n }\n\n this._operationStart = new Date().getTime();\n\n this._fn(this._attempts);\n};\n\nRetryOperation.prototype.try = function(fn) {\n console.log('Using RetryOperation.try() is deprecated');\n this.attempt(fn);\n};\n\nRetryOperation.prototype.start = function(fn) {\n console.log('Using RetryOperation.start() is deprecated');\n this.attempt(fn);\n};\n\nRetryOperation.prototype.start = RetryOperation.prototype.try;\n\nRetryOperation.prototype.errors = function() {\n return this._errors;\n};\n\nRetryOperation.prototype.attempts = function() {\n return this._attempts;\n};\n\nRetryOperation.prototype.mainError = function() {\n if (this._errors.length === 0) {\n return null;\n }\n\n var counts = {};\n var mainError = null;\n var mainErrorCount = 0;\n\n for (var i = 0; i < this._errors.length; i++) {\n var error = this._errors[i];\n var message = error.message;\n var count = (counts[message] || 0) + 1;\n\n counts[message] = count;\n\n if (count >= mainErrorCount) {\n mainError = error;\n mainErrorCount = count;\n }\n }\n\n return mainError;\n};\n","var RetryOperation = require('./retry_operation');\n\nexports.operation = function(options) {\n var timeouts = exports.timeouts(options);\n return new RetryOperation(timeouts, {\n forever: options && options.forever,\n unref: options && options.unref,\n maxRetryTime: options && options.maxRetryTime\n });\n};\n\nexports.timeouts = function(options) {\n if (options instanceof Array) {\n return [].concat(options);\n }\n\n var opts = {\n retries: 10,\n factor: 2,\n minTimeout: 1 * 1000,\n maxTimeout: Infinity,\n randomize: false\n };\n for (var key in options) {\n opts[key] = options[key];\n }\n\n if (opts.minTimeout > opts.maxTimeout) {\n throw new Error('minTimeout is greater than maxTimeout');\n }\n\n var timeouts = [];\n for (var i = 0; i < opts.retries; i++) {\n timeouts.push(this.createTimeout(i, opts));\n }\n\n if (options && options.forever && !timeouts.length) {\n timeouts.push(this.createTimeout(i, opts));\n }\n\n // sort the array numerically ascending\n timeouts.sort(function(a,b) {\n return a - b;\n });\n\n return timeouts;\n};\n\nexports.createTimeout = function(attempt, opts) {\n var random = (opts.randomize)\n ? (Math.random() + 1)\n : 1;\n\n var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));\n timeout = Math.min(timeout, opts.maxTimeout);\n\n return timeout;\n};\n\nexports.wrap = function(obj, options, methods) {\n if (options instanceof Array) {\n methods = options;\n options = null;\n }\n\n if (!methods) {\n methods = [];\n for (var key in obj) {\n if (typeof obj[key] === 'function') {\n methods.push(key);\n }\n }\n }\n\n for (var i = 0; i < methods.length; i++) {\n var method = methods[i];\n var original = obj[method];\n\n obj[method] = function retryWrapper(original) {\n var op = exports.operation(options);\n var args = Array.prototype.slice.call(arguments, 1);\n var callback = args.pop();\n\n args.push(function(err) {\n if (op.retry(err)) {\n return;\n }\n if (err) {\n arguments[0] = op.mainError();\n }\n callback.apply(this, arguments);\n });\n\n op.attempt(function() {\n original.apply(obj, args);\n });\n }.bind(obj, original);\n obj[method].options = options;\n }\n};\n","module.exports = require('./lib/retry');","// This is not the set of all possible signals.\n//\n// It IS, however, the set of all signals that trigger\n// an exit on either Linux or BSD systems. Linux is a\n// superset of the signal names supported on BSD, and\n// the unknown signals just fail to register, so we can\n// catch that easily enough.\n//\n// Don't bother with SIGKILL. It's uncatchable, which\n// means that we can't fire any callbacks anyway.\n//\n// If a user does happen to register a handler on a non-\n// fatal signal like SIGWINCH or something, and then\n// exit, it'll end up firing `process.emit('exit')`, so\n// the handler will be fired anyway.\n//\n// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised\n// artificially, inherently leave the process in a\n// state from which it is not safe to try and enter JS\n// listeners.\nmodule.exports = [\n 'SIGABRT',\n 'SIGALRM',\n 'SIGHUP',\n 'SIGINT',\n 'SIGTERM'\n]\n\nif (process.platform !== 'win32') {\n module.exports.push(\n 'SIGVTALRM',\n 'SIGXCPU',\n 'SIGXFSZ',\n 'SIGUSR2',\n 'SIGTRAP',\n 'SIGSYS',\n 'SIGQUIT',\n 'SIGIOT'\n // should detect profiler and enable/disable accordingly.\n // see #21\n // 'SIGPROF'\n )\n}\n\nif (process.platform === 'linux') {\n module.exports.push(\n 'SIGIO',\n 'SIGPOLL',\n 'SIGPWR',\n 'SIGSTKFLT',\n 'SIGUNUSED'\n )\n}\n","// Note: since nyc uses this module to output coverage, any lines\n// that are in the direct sync flow of nyc's outputCoverage are\n// ignored, since we can never get coverage for them.\n// grab a reference to node's real process object right away\nvar process = global.process\n\nconst processOk = function (process) {\n return process &&\n typeof process === 'object' &&\n typeof process.removeListener === 'function' &&\n typeof process.emit === 'function' &&\n typeof process.reallyExit === 'function' &&\n typeof process.listeners === 'function' &&\n typeof process.kill === 'function' &&\n typeof process.pid === 'number' &&\n typeof process.on === 'function'\n}\n\n// some kind of non-node environment, just no-op\n/* istanbul ignore if */\nif (!processOk(process)) {\n module.exports = function () {\n return function () {}\n }\n} else {\n var assert = require('assert')\n var signals = require('./signals.js')\n var isWin = /^win/i.test(process.platform)\n\n var EE = require('events')\n /* istanbul ignore if */\n if (typeof EE !== 'function') {\n EE = EE.EventEmitter\n }\n\n var emitter\n if (process.__signal_exit_emitter__) {\n emitter = process.__signal_exit_emitter__\n } else {\n emitter = process.__signal_exit_emitter__ = new EE()\n emitter.count = 0\n emitter.emitted = {}\n }\n\n // Because this emitter is a global, we have to check to see if a\n // previous version of this library failed to enable infinite listeners.\n // I know what you're about to say. But literally everything about\n // signal-exit is a compromise with evil. Get used to it.\n if (!emitter.infinite) {\n emitter.setMaxListeners(Infinity)\n emitter.infinite = true\n }\n\n module.exports = function (cb, opts) {\n /* istanbul ignore if */\n if (!processOk(global.process)) {\n return function () {}\n }\n assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')\n\n if (loaded === false) {\n load()\n }\n\n var ev = 'exit'\n if (opts && opts.alwaysLast) {\n ev = 'afterexit'\n }\n\n var remove = function () {\n emitter.removeListener(ev, cb)\n if (emitter.listeners('exit').length === 0 &&\n emitter.listeners('afterexit').length === 0) {\n unload()\n }\n }\n emitter.on(ev, cb)\n\n return remove\n }\n\n var unload = function unload () {\n if (!loaded || !processOk(global.process)) {\n return\n }\n loaded = false\n\n signals.forEach(function (sig) {\n try {\n process.removeListener(sig, sigListeners[sig])\n } catch (er) {}\n })\n process.emit = originalProcessEmit\n process.reallyExit = originalProcessReallyExit\n emitter.count -= 1\n }\n module.exports.unload = unload\n\n var emit = function emit (event, code, signal) {\n /* istanbul ignore if */\n if (emitter.emitted[event]) {\n return\n }\n emitter.emitted[event] = true\n emitter.emit(event, code, signal)\n }\n\n // { <signal>: <listener fn>, ... }\n var sigListeners = {}\n signals.forEach(function (sig) {\n sigListeners[sig] = function listener () {\n /* istanbul ignore if */\n if (!processOk(global.process)) {\n return\n }\n // If there are no other listeners, an exit is coming!\n // Simplest way: remove us and then re-send the signal.\n // We know that this will kill the process, so we can\n // safely emit now.\n var listeners = process.listeners(sig)\n if (listeners.length === emitter.count) {\n unload()\n emit('exit', null, sig)\n /* istanbul ignore next */\n emit('afterexit', null, sig)\n /* istanbul ignore next */\n if (isWin && sig === 'SIGHUP') {\n // \"SIGHUP\" throws an `ENOSYS` error on Windows,\n // so use a supported signal instead\n sig = 'SIGINT'\n }\n /* istanbul ignore next */\n process.kill(process.pid, sig)\n }\n }\n })\n\n module.exports.signals = function () {\n return signals\n }\n\n var loaded = false\n\n var load = function load () {\n if (loaded || !processOk(global.process)) {\n return\n }\n loaded = true\n\n // This is the number of onSignalExit's that are in play.\n // It's important so that we can count the correct number of\n // listeners on signals, and don't wait for the other one to\n // handle it instead of us.\n emitter.count += 1\n\n signals = signals.filter(function (sig) {\n try {\n process.on(sig, sigListeners[sig])\n return true\n } catch (er) {\n return false\n }\n })\n\n process.emit = processEmit\n process.reallyExit = processReallyExit\n }\n module.exports.load = load\n\n var originalProcessReallyExit = process.reallyExit\n var processReallyExit = function processReallyExit (code) {\n /* istanbul ignore if */\n if (!processOk(global.process)) {\n return\n }\n process.exitCode = code || /* istanbul ignore next */ 0\n emit('exit', process.exitCode, null)\n /* istanbul ignore next */\n emit('afterexit', process.exitCode, null)\n /* istanbul ignore next */\n originalProcessReallyExit.call(process, process.exitCode)\n }\n\n var originalProcessEmit = process.emit\n var processEmit = function processEmit (ev, arg) {\n if (ev === 'exit' && processOk(global.process)) {\n /* istanbul ignore else */\n if (arg !== undefined) {\n process.exitCode = arg\n }\n var ret = originalProcessEmit.apply(this, arguments)\n /* istanbul ignore next */\n emit('exit', process.exitCode, null)\n /* istanbul ignore next */\n emit('afterexit', process.exitCode, null)\n /* istanbul ignore next */\n return ret\n } else {\n return originalProcessEmit.apply(this, arguments)\n }\n }\n}\n","'use strict';\n\nconst cacheSymbol = Symbol();\n\nfunction probe(file, fs, callback) {\n const cachedPrecision = fs[cacheSymbol];\n\n if (cachedPrecision) {\n return fs.stat(file, (err, stat) => {\n /* istanbul ignore if */\n if (err) {\n return callback(err);\n }\n\n callback(null, stat.mtime, cachedPrecision);\n });\n }\n\n // Set mtime by ceiling Date.now() to seconds + 5ms so that it's \"not on the second\"\n const mtime = new Date((Math.ceil(Date.now() / 1000) * 1000) + 5);\n\n fs.utimes(file, mtime, mtime, (err) => {\n /* istanbul ignore if */\n if (err) {\n return callback(err);\n }\n\n fs.stat(file, (err, stat) => {\n /* istanbul ignore if */\n if (err) {\n return callback(err);\n }\n\n const precision = stat.mtime.getTime() % 1000 === 0 ? 's' : 'ms';\n\n // Cache the precision in a non-enumerable way\n Object.defineProperty(fs, cacheSymbol, { value: precision });\n\n callback(null, stat.mtime, precision);\n });\n });\n}\n\nfunction getMtime(precision) {\n let now = Date.now();\n\n if (precision === 's') {\n now = Math.ceil(now / 1000) * 1000;\n }\n\n return new Date(now);\n}\n\nmodule.exports.probe = probe;\nmodule.exports.getMtime = getMtime;\n","'use strict';\n\nconst path = require('path');\nconst fs = require('graceful-fs');\nconst retry = require('retry');\nconst onExit = require('signal-exit');\nconst mtimePrecision = require('./mtime-precision');\n\nconst locks = {};\n\nfunction getLockFile(file, options) {\n return options.lockfilePath || `${file}.lock`;\n}\n\nfunction resolveCanonicalPath(file, options, callback) {\n if (!options.realpath) {\n return callback(null, path.resolve(file));\n }\n\n // Use realpath to resolve symlinks\n // It also resolves relative paths\n options.fs.realpath(file, callback);\n}\n\nfunction acquireLock(file, options, callback) {\n const lockfilePath = getLockFile(file, options);\n\n // Use mkdir to create the lockfile (atomic operation)\n options.fs.mkdir(lockfilePath, (err) => {\n if (!err) {\n // At this point, we acquired the lock!\n // Probe the mtime precision\n return mtimePrecision.probe(lockfilePath, options.fs, (err, mtime, mtimePrecision) => {\n // If it failed, try to remove the lock..\n /* istanbul ignore if */\n if (err) {\n options.fs.rmdir(lockfilePath, () => {});\n\n return callback(err);\n }\n\n callback(null, mtime, mtimePrecision);\n });\n }\n\n // If error is not EEXIST then some other error occurred while locking\n if (err.code !== 'EEXIST') {\n return callback(err);\n }\n\n // Otherwise, check if lock is stale by analyzing the file mtime\n if (options.stale <= 0) {\n return callback(Object.assign(new Error('Lock file is already being held'), { code: 'ELOCKED', file }));\n }\n\n options.fs.stat(lockfilePath, (err, stat) => {\n if (err) {\n // Retry if the lockfile has been removed (meanwhile)\n // Skip stale check to avoid recursiveness\n if (err.code === 'ENOENT') {\n return acquireLock(file, { ...options, stale: 0 }, callback);\n }\n\n return callback(err);\n }\n\n if (!isLockStale(stat, options)) {\n return callback(Object.assign(new Error('Lock file is already being held'), { code: 'ELOCKED', file }));\n }\n\n // If it's stale, remove it and try again!\n // Skip stale check to avoid recursiveness\n removeLock(file, options, (err) => {\n if (err) {\n return callback(err);\n }\n\n acquireLock(file, { ...options, stale: 0 }, callback);\n });\n });\n });\n}\n\nfunction isLockStale(stat, options) {\n return stat.mtime.getTime() < Date.now() - options.stale;\n}\n\nfunction removeLock(file, options, callback) {\n // Remove lockfile, ignoring ENOENT errors\n options.fs.rmdir(getLockFile(file, options), (err) => {\n if (err && err.code !== 'ENOENT') {\n return callback(err);\n }\n\n callback();\n });\n}\n\nfunction updateLock(file, options) {\n const lock = locks[file];\n\n // Just for safety, should never happen\n /* istanbul ignore if */\n if (lock.updateTimeout) {\n return;\n }\n\n lock.updateDelay = lock.updateDelay || options.update;\n lock.updateTimeout = setTimeout(() => {\n lock.updateTimeout = null;\n\n // Stat the file to check if mtime is still ours\n // If it is, we can still recover from a system sleep or a busy event loop\n options.fs.stat(lock.lockfilePath, (err, stat) => {\n const isOverThreshold = lock.lastUpdate + options.stale < Date.now();\n\n // If it failed to update the lockfile, keep trying unless\n // the lockfile was deleted or we are over the threshold\n if (err) {\n if (err.code === 'ENOENT' || isOverThreshold) {\n return setLockAsCompromised(file, lock, Object.assign(err, { code: 'ECOMPROMISED' }));\n }\n\n lock.updateDelay = 1000;\n\n return updateLock(file, options);\n }\n\n const isMtimeOurs = lock.mtime.getTime() === stat.mtime.getTime();\n\n if (!isMtimeOurs) {\n return setLockAsCompromised(\n file,\n lock,\n Object.assign(\n new Error('Unable to update lock within the stale threshold'),\n { code: 'ECOMPROMISED' }\n ));\n }\n\n const mtime = mtimePrecision.getMtime(lock.mtimePrecision);\n\n options.fs.utimes(lock.lockfilePath, mtime, mtime, (err) => {\n const isOverThreshold = lock.lastUpdate + options.stale < Date.now();\n\n // Ignore if the lock was released\n if (lock.released) {\n return;\n }\n\n // If it failed to update the lockfile, keep trying unless\n // the lockfile was deleted or we are over the threshold\n if (err) {\n if (err.code === 'ENOENT' || isOverThreshold) {\n return setLockAsCompromised(file, lock, Object.assign(err, { code: 'ECOMPROMISED' }));\n }\n\n lock.updateDelay = 1000;\n\n return updateLock(file, options);\n }\n\n // All ok, keep updating..\n lock.mtime = mtime;\n lock.lastUpdate = Date.now();\n lock.updateDelay = null;\n updateLock(file, options);\n });\n });\n }, lock.updateDelay);\n\n // Unref the timer so that the nodejs process can exit freely\n // This is safe because all acquired locks will be automatically released\n // on process exit\n\n // We first check that `lock.updateTimeout.unref` exists because some users\n // may be using this module outside of NodeJS (e.g., in an electron app),\n // and in those cases `setTimeout` return an integer.\n /* istanbul ignore else */\n if (lock.updateTimeout.unref) {\n lock.updateTimeout.unref();\n }\n}\n\nfunction setLockAsCompromised(file, lock, err) {\n // Signal the lock has been released\n lock.released = true;\n\n // Cancel lock mtime update\n // Just for safety, at this point updateTimeout should be null\n /* istanbul ignore if */\n if (lock.updateTimeout) {\n clearTimeout(lock.updateTimeout);\n }\n\n if (locks[file] === lock) {\n delete locks[file];\n }\n\n lock.options.onCompromised(err);\n}\n\n// ----------------------------------------------------------\n\nfunction lock(file, options, callback) {\n /* istanbul ignore next */\n options = {\n stale: 10000,\n update: null,\n realpath: true,\n retries: 0,\n fs,\n onCompromised: (err) => { throw err; },\n ...options,\n };\n\n options.retries = options.retries || 0;\n options.retries = typeof options.retries === 'number' ? { retries: options.retries } : options.retries;\n options.stale = Math.max(options.stale || 0, 2000);\n options.update = options.update == null ? options.stale / 2 : options.update || 0;\n options.update = Math.max(Math.min(options.update, options.stale / 2), 1000);\n\n // Resolve to a canonical file path\n resolveCanonicalPath(file, options, (err, file) => {\n if (err) {\n return callback(err);\n }\n\n // Attempt to acquire the lock\n const operation = retry.operation(options.retries);\n\n operation.attempt(() => {\n acquireLock(file, options, (err, mtime, mtimePrecision) => {\n if (operation.retry(err)) {\n return;\n }\n\n if (err) {\n return callback(operation.mainError());\n }\n\n // We now own the lock\n const lock = locks[file] = {\n lockfilePath: getLockFile(file, options),\n mtime,\n mtimePrecision,\n options,\n lastUpdate: Date.now(),\n };\n\n // We must keep the lock fresh to avoid staleness\n updateLock(file, options);\n\n callback(null, (releasedCallback) => {\n if (lock.released) {\n return releasedCallback &&\n releasedCallback(Object.assign(new Error('Lock is already released'), { code: 'ERELEASED' }));\n }\n\n // Not necessary to use realpath twice when unlocking\n unlock(file, { ...options, realpath: false }, releasedCallback);\n });\n });\n });\n });\n}\n\nfunction unlock(file, options, callback) {\n options = {\n fs,\n realpath: true,\n ...options,\n };\n\n // Resolve to a canonical file path\n resolveCanonicalPath(file, options, (err, file) => {\n if (err) {\n return callback(err);\n }\n\n // Skip if the lock is not acquired\n const lock = locks[file];\n\n if (!lock) {\n return callback(Object.assign(new Error('Lock is not acquired/owned by you'), { code: 'ENOTACQUIRED' }));\n }\n\n lock.updateTimeout && clearTimeout(lock.updateTimeout); // Cancel lock mtime update\n lock.released = true; // Signal the lock has been released\n delete locks[file]; // Delete from locks\n\n removeLock(file, options, callback);\n });\n}\n\nfunction check(file, options, callback) {\n options = {\n stale: 10000,\n realpath: true,\n fs,\n ...options,\n };\n\n options.stale = Math.max(options.stale || 0, 2000);\n\n // Resolve to a canonical file path\n resolveCanonicalPath(file, options, (err, file) => {\n if (err) {\n return callback(err);\n }\n\n // Check if lockfile exists\n options.fs.stat(getLockFile(file, options), (err, stat) => {\n if (err) {\n // If does not exist, file is not locked. Otherwise, callback with error\n return err.code === 'ENOENT' ? callback(null, false) : callback(err);\n }\n\n // Otherwise, check if lock is stale by analyzing the file mtime\n return callback(null, !isLockStale(stat, options));\n });\n });\n}\n\nfunction getLocks() {\n return locks;\n}\n\n// Remove acquired locks on exit\n/* istanbul ignore next */\nonExit(() => {\n for (const file in locks) {\n const options = locks[file].options;\n\n try { options.fs.rmdirSync(getLockFile(file, options)); } catch (e) { /* Empty */ }\n }\n});\n\nmodule.exports.lock = lock;\nmodule.exports.unlock = unlock;\nmodule.exports.check = check;\nmodule.exports.getLocks = getLocks;\n","'use strict';\n\nconst fs = require('graceful-fs');\n\nfunction createSyncFs(fs) {\n const methods = ['mkdir', 'realpath', 'stat', 'rmdir', 'utimes'];\n const newFs = { ...fs };\n\n methods.forEach((method) => {\n newFs[method] = (...args) => {\n const callback = args.pop();\n let ret;\n\n try {\n ret = fs[`${method}Sync`](...args);\n } catch (err) {\n return callback(err);\n }\n\n callback(null, ret);\n };\n });\n\n return newFs;\n}\n\n// ----------------------------------------------------------\n\nfunction toPromise(method) {\n return (...args) => new Promise((resolve, reject) => {\n args.push((err, result) => {\n if (err) {\n reject(err);\n } else {\n resolve(result);\n }\n });\n\n method(...args);\n });\n}\n\nfunction toSync(method) {\n return (...args) => {\n let err;\n let result;\n\n args.push((_err, _result) => {\n err = _err;\n result = _result;\n });\n\n method(...args);\n\n if (err) {\n throw err;\n }\n\n return result;\n };\n}\n\nfunction toSyncOptions(options) {\n // Shallow clone options because we are oging to mutate them\n options = { ...options };\n\n // Transform fs to use the sync methods instead\n options.fs = createSyncFs(options.fs || fs);\n\n // Retries are not allowed because it requires the flow to be sync\n if (\n (typeof options.retries === 'number' && options.retries > 0) ||\n (options.retries && typeof options.retries.retries === 'number' && options.retries.retries > 0)\n ) {\n throw Object.assign(new Error('Cannot use retries with the sync api'), { code: 'ESYNC' });\n }\n\n return options;\n}\n\nmodule.exports = {\n toPromise,\n toSync,\n toSyncOptions,\n};\n","'use strict';\n\nconst lockfile = require('./lib/lockfile');\nconst { toPromise, toSync, toSyncOptions } = require('./lib/adapter');\n\nasync function lock(file, options) {\n const release = await toPromise(lockfile.lock)(file, options);\n\n return toPromise(release);\n}\n\nfunction lockSync(file, options) {\n const release = toSync(lockfile.lock)(file, toSyncOptions(options));\n\n return toSync(release);\n}\n\nfunction unlock(file, options) {\n return toPromise(lockfile.unlock)(file, options);\n}\n\nfunction unlockSync(file, options) {\n return toSync(lockfile.unlock)(file, toSyncOptions(options));\n}\n\nfunction check(file, options) {\n return toPromise(lockfile.check)(file, options);\n}\n\nfunction checkSync(file, options) {\n return toSync(lockfile.check)(file, toSyncOptions(options));\n}\n\nmodule.exports = lock;\nmodule.exports.lock = lock;\nmodule.exports.unlock = unlock;\nmodule.exports.lockSync = lockSync;\nmodule.exports.unlockSync = unlockSync;\nmodule.exports.check = check;\nmodule.exports.checkSync = checkSync;\n","import * as fs from \"node:fs\";\nimport { spawn } from \"node:child_process\";\nimport * as fs$1 from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport getPort, { portNumbers } from \"get-port\";\nimport * as properLockfile from \"proper-lockfile\";\nimport { randomUUID } from \"node:crypto\";\n//#region src/state-file.ts\n/**\n* Temp-then-rename JSON state-file writes behind one in-process queue (spec\n* local-dev § 2, \"API hygiene, both daemons\"): each daemon is single-process,\n* so concurrent HTTP handlers mutating the same state file serialize their\n* writes through a `StateFile` instance instead of racing each other on disk.\n*/\nvar StateFile = class {\n\tfilePath;\n\tmode;\n\tqueue = Promise.resolve();\n\tconstructor(filePath, mode) {\n\t\tthis.filePath = filePath;\n\t\tthis.mode = mode;\n\t}\n\t/** Serializes `value` to disk, temp-then-rename, behind this file's write queue. */\n\twrite(value) {\n\t\tconst next = this.queue.then(() => this.writeNow(value));\n\t\tthis.queue = next.catch(() => void 0);\n\t\treturn next;\n\t}\n\t/** Resolves once every write() call made so far has landed on disk — for graceful shutdown, so a SIGTERM can't race an in-flight write and lose it. */\n\tflush() {\n\t\treturn this.queue;\n\t}\n\tasync writeNow(value) {\n\t\tconst dir = path.dirname(this.filePath);\n\t\tawait fs$1.mkdir(dir, { recursive: true });\n\t\tconst tmpPath = path.join(dir, `.${path.basename(this.filePath)}.${randomUUID()}.tmp`);\n\t\tconst json = `${JSON.stringify(value, null, 2)}\\n`;\n\t\tawait fs$1.writeFile(tmpPath, json, this.mode !== void 0 ? { mode: this.mode } : void 0);\n\t\tawait fs$1.rename(tmpPath, this.filePath);\n\t\tif (this.mode !== void 0) await fs$1.chmod(this.filePath, this.mode);\n\t}\n};\nfunction isEnoent$1(err) {\n\treturn err instanceof Error && \"code\" in err && err.code === \"ENOENT\";\n}\n/**\n* Reads and parses a JSON state file, narrowing the parsed value with\n* `isValid` (a real type predicate, not a cast — the file's shape is only\n* trustworthy because this daemon is its only writer, but a foreign or\n* corrupt file on disk must not be treated as valid state). `undefined` when\n* absent, unreadable, or shaped wrong.\n*/\nasync function readJsonFile(filePath, isValid) {\n\tlet raw;\n\ttry {\n\t\traw = await fs$1.readFile(filePath, \"utf8\");\n\t} catch (err) {\n\t\tif (isEnoent$1(err)) return void 0;\n\t\tthrow err;\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn;\n\t}\n\treturn isValid(parsed) ? parsed : void 0;\n}\n//#endregion\n//#region src/daemon.ts\n/**\n* The shared daemon layer (local-dev spec § 2): a machine-scoped registry of\n* running emulator daemons (`compute`, `buckets`), and `ensureDaemon` /\n* `stopDaemon` to start, adopt, or replace them. Every daemon is a detached,\n* `unref()`'d child process that outlives whatever called `ensureDaemon` —\n* the registry is how a later call finds it again.\n*\n* `registryRoot` defaults to `~/.prisma-composer/emulators/` and governs\n* every path this module manages for a given daemon: the registry JSON\n* itself, the daemon's own state directory, and its stdio log file. The\n* `{ registryRoot }` override exists solely so tests never touch the real\n* home directory; production code never passes it.\n*/\nconst MIN_PORT = 4300;\nconst MAX_PORT = 65535;\nconst EXISTING_HEALTH_TIMEOUT_MS = 2e3;\nconst START_HEALTH_BUDGET_MS = 1e4;\nconst HEALTH_POLL_INTERVAL_MS = 200;\nconst TERMINATE_GRACE_MS = 5e3;\nconst TERMINATE_POLL_INTERVAL_MS = 150;\nconst LOCK_RETRY_INTERVAL_MS = 250;\nconst LOCK_WAIT_BUDGET_MS = 1e4;\nconst LOCK_STALE_MS = 1e4;\n/** Spec § 2 step 5: a FRESH allocation (no persisted port) tries at most this many distinct port candidates before the pinned failure error. */\nconst MAX_FRESH_PORT_CANDIDATES = 5;\nfunction isErrnoException(err) {\n\treturn err instanceof Error && \"code\" in err;\n}\nfunction isEnoent(err) {\n\treturn isErrnoException(err) && err.code === \"ENOENT\";\n}\nfunction isRegistryEntry(value) {\n\treturn typeof value === \"object\" && value !== null && \"pid\" in value && typeof value.pid === \"number\" && \"port\" in value && typeof value.port === \"number\" && \"version\" in value && typeof value.version === \"string\" && \"logPath\" in value && typeof value.logPath === \"string\";\n}\nfunction isHealthBody(value) {\n\treturn typeof value === \"object\" && value !== null && \"version\" in value && typeof value.version === \"string\";\n}\nfunction isPackageJson(value) {\n\treturn typeof value === \"object\" && value !== null && \"version\" in value && typeof value.version === \"string\";\n}\nfunction sleep(ms) {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n/** `~/.prisma-composer/emulators/` — `registryRoot`'s default. */\nfunction defaultRegistryRoot() {\n\treturn path.join(os.homedir(), \".prisma-composer\", \"emulators\");\n}\n/** `<registryRoot>/<name>.json`. */\nfunction registryFilePath(registryRoot, name) {\n\treturn path.join(registryRoot, `${name}.json`);\n}\n/** `<registryRoot>/<name>/` — the daemon's own `--state-dir`. */\nfunction daemonStateDir(registryRoot, name) {\n\treturn path.join(registryRoot, name);\n}\n/** `<registryRoot>/<name>.log` — the daemon's stdio log. */\nfunction daemonLogPath(registryRoot, name) {\n\treturn path.join(registryRoot, `${name}.log`);\n}\n/** Compute's and postgres's root namespace is their own JSON admin API; buckets' root namespace is the S3 wire, so its health lives under `/_pcdev/`. */\nfunction healthPathFor(name) {\n\treturn name === \"buckets\" ? \"/_pcdev/health\" : \"/health\";\n}\n/** `@internal/dev-emulators`'s own `package.json` version — what \"version\" means everywhere in this package. */\nfunction readOwnVersion() {\n\tconst here = path.dirname(fileURLToPath(import.meta.url));\n\tconst pkgPath = path.join(here, \"..\", \"package.json\");\n\tconst raw = fs.readFileSync(pkgPath, \"utf8\");\n\tconst parsed = JSON.parse(raw);\n\tif (!isPackageJson(parsed)) throw new Error(`could not read a version string from ${pkgPath}`);\n\treturn parsed.version;\n}\n/** `process.kill(pid, 0)` existence probe — true unless the pid is provably gone (ESRCH). */\nfunction isPidAlive(pid) {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch (err) {\n\t\tif (isErrnoException(err) && err.code === \"EPERM\") return true;\n\t\treturn false;\n\t}\n}\nasync function readRegistryEntry(registryRoot, name) {\n\treturn readJsonFile(registryFilePath(registryRoot, name), isRegistryEntry);\n}\nasync function probeHealth(port, healthPath, timeoutMs) {\n\ttry {\n\t\tconst res = await fetch(`http://127.0.0.1:${port}${healthPath}`, { signal: AbortSignal.timeout(timeoutMs) });\n\t\tif (!res.ok) return void 0;\n\t\tconst body = await res.json();\n\t\treturn isHealthBody(body) ? body : void 0;\n\t} catch {\n\t\treturn;\n\t}\n}\n/**\n* Polls the health path up to `budgetMs`, but returns immediately once the\n* child exits — a dead child can never become healthy, and the port-retry\n* protocol (spec § 2 step 5) needs to move to the next candidate right\n* away rather than exhausting a live-process budget on one that isn't\n* live. Only a child that stays alive without becoming healthy consumes\n* the full budget.\n*\n* Verifies the health response's OWN version, not just that something\n* answered: if our child failed to bind (a foreign process already held\n* the port) that foreign process may itself answer `/health` successfully\n* — a version mismatch there is exactly the \"port taken\" case, not a false\n* \"healthy\", and must not be reported as such.\n*/\nasync function awaitHealthy(child, port, healthPath, ownVersion, budgetMs) {\n\tlet exited = false;\n\tchild.once(\"exit\", () => {\n\t\texited = true;\n\t});\n\tconst deadline = Date.now() + budgetMs;\n\tdo {\n\t\tif (exited) return {\n\t\t\thealthy: false,\n\t\t\texitedBeforeHealthy: true\n\t\t};\n\t\tconst remaining = deadline - Date.now();\n\t\tconst health = await probeHealth(port, healthPath, Math.max(200, Math.min(1e3, remaining)));\n\t\tif (health && health.version === ownVersion) return {\n\t\t\thealthy: true,\n\t\t\texitedBeforeHealthy: false\n\t\t};\n\t\tif (exited) return {\n\t\t\thealthy: false,\n\t\t\texitedBeforeHealthy: true\n\t\t};\n\t\tawait sleep(HEALTH_POLL_INTERVAL_MS);\n\t} while (Date.now() < deadline);\n\treturn {\n\t\thealthy: false,\n\t\texitedBeforeHealthy: exited\n\t};\n}\n/** SIGTERM, wait up to `graceMs` for the pid to exit, then SIGKILL. A no-op if the pid is already gone. */\nasync function terminate(pid, graceMs) {\n\tif (!isPidAlive(pid)) return;\n\ttry {\n\t\tprocess.kill(pid, \"SIGTERM\");\n\t} catch {\n\t\treturn;\n\t}\n\tconst deadline = Date.now() + graceMs;\n\twhile (Date.now() < deadline) {\n\t\tif (!isPidAlive(pid)) return;\n\t\tawait sleep(TERMINATE_POLL_INTERVAL_MS);\n\t}\n\tif (isPidAlive(pid)) try {\n\t\tprocess.kill(pid, \"SIGKILL\");\n\t} catch {}\n}\n/** Every port recorded by any registry entry under `registryRoot` — the two daemons share one port pool. */\nasync function usedPorts(registryRoot) {\n\tlet names;\n\ttry {\n\t\tnames = await fs$1.readdir(registryRoot);\n\t} catch (err) {\n\t\tif (isEnoent(err)) return /* @__PURE__ */ new Set();\n\t\tthrow err;\n\t}\n\tconst ports = /* @__PURE__ */ new Set();\n\tfor (const fname of names) {\n\t\tif (!fname.endsWith(\".json\")) continue;\n\t\tconst entry = await readJsonFile(path.join(registryRoot, fname), isRegistryEntry);\n\t\tif (entry) ports.add(entry.port);\n\t}\n\treturn ports;\n}\n/**\n* The smallest genuinely free port at or above `min`, skipping every port\n* already recorded in the registry — persistence and the range policy\n* (`min`, \"skip registry-used ports\") stay ours; whether a given candidate\n* is actually bindable is `get-port`'s (spec § 2's dependency razor — a\n* hand-rolled probe already produced a real cross-platform bug: a Linux-only\n* self-collision from checking two bind scopes concurrently).\n*/\nasync function smallestUnused(used, min) {\n\treturn getPort({\n\t\tport: portNumbers(min, MAX_PORT),\n\t\texclude: used\n\t});\n}\n/** Spawns the daemon binary detached, stdio appended to `logPath`. Doesn't wait for health. */\nfunction spawnDaemonProcess(entryPath, port, stateDir, logPath) {\n\tconst logFd = fs.openSync(logPath, \"a\");\n\tlet child;\n\ttry {\n\t\tchild = spawn(process.execPath, [\n\t\t\tentryPath,\n\t\t\t\"--port\",\n\t\t\tString(port),\n\t\t\t\"--state-dir\",\n\t\t\tstateDir\n\t\t], {\n\t\t\tdetached: true,\n\t\t\tstdio: [\n\t\t\t\t\"ignore\",\n\t\t\t\tlogFd,\n\t\t\t\tlogFd\n\t\t\t]\n\t\t});\n\t} finally {\n\t\tfs.closeSync(logFd);\n\t}\n\tchild.unref();\n\treturn child;\n}\n/**\n* Reads the registry entry and classifies it. \"dead-or-unhealthy\" covers\n* both a provably dead pid AND a live pid that fails health — the latter\n* can't be confirmed as our daemon (a reused pid after a reboot, a hung\n* foreign process), so it is never signaled, only dropped.\n*/\nasync function observeExisting(registryFile, healthPath, ownVersion) {\n\tconst entry = await readJsonFile(registryFile, isRegistryEntry);\n\tif (!entry) return { kind: \"absent\" };\n\tif (!isPidAlive(entry.pid)) return {\n\t\tkind: \"dead-or-unhealthy\",\n\t\tentry\n\t};\n\tconst health = await probeHealth(entry.port, healthPath, EXISTING_HEALTH_TIMEOUT_MS);\n\tif (health && health.version === ownVersion) return {\n\t\tkind: \"healthy\",\n\t\tentry\n\t};\n\tif (health && health.version !== ownVersion) return {\n\t\tkind: \"stale-version\",\n\t\tentry\n\t};\n\treturn {\n\t\tkind: \"dead-or-unhealthy\",\n\t\tentry\n\t};\n}\n/**\n* `<registryRoot>/.<name>.lock-target` — the file `proper-lockfile` locks\n* for the concurrent-ensure protocol (it marks the lock as a sibling\n* `<file>.lock` directory it manages itself). A stable, never-deleted file:\n* unlike the registry JSON, which this module removes and rewrites\n* repeatedly while ensuring, the lock target must exist continuously for\n* `proper-lockfile`'s `realpath` resolution.\n*/\nfunction lockFilePath(registryRoot, name) {\n\treturn path.join(registryRoot, `.${name}.lock-target`);\n}\n/**\n* Acquires the concurrent-ensure protocol's inter-process lock (spec § 2)\n* via `proper-lockfile` — its staleness/compromise semantics are adopted\n* wholesale rather than re-implementing pid liveness checking on top (the\n* dependency razor: commodity locking is exactly where unforeseen edge\n* cases hide). Polls roughly every 250 ms for up to a 10 s budget; on\n* exhaustion (`ELOCKED`, meaning a live, non-stale holder never let go),\n* throws the pinned timeout error. Any other failure propagates as-is.\n*/\nasync function acquireLock(registryRoot, name) {\n\tawait fs$1.mkdir(registryRoot, { recursive: true });\n\tconst target = lockFilePath(registryRoot, name);\n\tawait fs$1.writeFile(target, \"\", { flag: \"a\" });\n\tconst retries = Math.max(1, Math.floor(LOCK_WAIT_BUDGET_MS / LOCK_RETRY_INTERVAL_MS));\n\ttry {\n\t\treturn await properLockfile.lock(target, {\n\t\t\tstale: LOCK_STALE_MS,\n\t\t\tretries: {\n\t\t\t\tretries,\n\t\t\t\tminTimeout: LOCK_RETRY_INTERVAL_MS,\n\t\t\t\tmaxTimeout: LOCK_RETRY_INTERVAL_MS,\n\t\t\t\tfactor: 1\n\t\t\t}\n\t\t});\n\t} catch (err) {\n\t\tif (isErrnoException(err) && err.code === \"ELOCKED\") throw new Error(`timed out waiting for another process ensuring the ${name} emulator — remove ${target}.lock if stale.`);\n\t\tthrow err;\n\t}\n}\n/**\n* Ensure the named daemon is running and healthy at this package's version,\n* starting or replacing it as needed (spec § 2 `daemon.ts`). Idempotent —\n* safe to call repeatedly, including across unrelated processes on the same\n* machine, and safe under concurrent callers across processes: the\n* observe→spawn→persist critical section is serialized per daemon name by\n* an inter-process lock (the \"Concurrent-ensure protocol\").\n*\n* `entry` is the resolved absolute path to the daemon program to spawn —\n* the CALLER resolves it (local-dev spec § 2's publish note). This module\n* used to resolve it itself via `import.meta.resolve('@internal/dev-emulators/…')`,\n* which only works in-repo: `@internal/*` are private workspace packages a\n* published npm consumer never receives. In-repo callers (including tests)\n* still resolve `@internal/dev-emulators/*-main` the same way; a published\n* consumer resolves its own public subpaths instead.\n*/\nasync function ensureDaemon(name, entry, opts = {}) {\n\tconst registryRoot = opts.registryRoot ?? defaultRegistryRoot();\n\tconst registryFile = registryFilePath(registryRoot, name);\n\tconst healthPath = healthPathFor(name);\n\tconst ownVersion = readOwnVersion();\n\tconst quick = await observeExisting(registryFile, healthPath, ownVersion);\n\tif (quick.kind === \"healthy\") return { url: `http://127.0.0.1:${quick.entry.port}` };\n\tconst release = await acquireLock(registryRoot, name);\n\ttry {\n\t\tconst observed = await observeExisting(registryFile, healthPath, ownVersion);\n\t\tif (observed.kind === \"healthy\") return { url: `http://127.0.0.1:${observed.entry.port}` };\n\t\tlet reusablePort;\n\t\tif (observed.kind === \"stale-version\") {\n\t\t\treusablePort = observed.entry.port;\n\t\t\tawait terminate(observed.entry.pid, TERMINATE_GRACE_MS);\n\t\t\tawait fs$1.rm(registryFile, { force: true });\n\t\t} else if (observed.kind === \"dead-or-unhealthy\") {\n\t\t\treusablePort = observed.entry.port;\n\t\t\tawait fs$1.rm(registryFile, { force: true });\n\t\t}\n\t\tconst isFreshAllocation = reusablePort === void 0;\n\t\tconst maxAttempts = isFreshAllocation ? MAX_FRESH_PORT_CANDIDATES : 1;\n\t\tlet port = reusablePort ?? await smallestUnused(await usedPorts(registryRoot), MIN_PORT);\n\t\tconst stateDir = daemonStateDir(registryRoot, name);\n\t\tconst logPath = daemonLogPath(registryRoot, name);\n\t\tawait fs$1.mkdir(stateDir, { recursive: true });\n\t\tawait fs$1.mkdir(path.dirname(logPath), { recursive: true });\n\t\tfor (let attempt = 1;; attempt++) {\n\t\t\tconst child = spawnDaemonProcess(entry, port, stateDir, logPath);\n\t\t\tif (child.pid === void 0) throw new Error(`failed to spawn the ${name} emulator — see ${logPath}.`);\n\t\t\tawait new StateFile(registryFile).write({\n\t\t\t\tpid: child.pid,\n\t\t\t\tport,\n\t\t\t\tversion: ownVersion,\n\t\t\t\tlogPath\n\t\t\t});\n\t\t\tconst outcome = await awaitHealthy(child, port, healthPath, ownVersion, START_HEALTH_BUDGET_MS);\n\t\t\tif (outcome.healthy) return { url: `http://127.0.0.1:${port}` };\n\t\t\tif (!(isFreshAllocation && outcome.exitedBeforeHealthy && attempt < maxAttempts)) {\n\t\t\t\tawait terminate(child.pid, TERMINATE_GRACE_MS);\n\t\t\t\tawait fs$1.rm(registryFile, { force: true });\n\t\t\t\tthrow new Error(`${name} emulator failed to start on port ${port} — see ${logPath}.`);\n\t\t\t}\n\t\t\tawait fs$1.rm(registryFile, { force: true });\n\t\t\tport = await smallestUnused(await usedPorts(registryRoot), port + 1);\n\t\t}\n\t} finally {\n\t\tawait release();\n\t}\n}\n/** SIGTERM/SIGKILL + registry cleanup. Not called by any v1 command — an operator escape hatch, exported for tests. */\nasync function stopDaemon(name, opts = {}) {\n\tconst registryFile = registryFilePath(opts.registryRoot ?? defaultRegistryRoot(), name);\n\tconst entry = await readJsonFile(registryFile, isRegistryEntry);\n\tif (entry) await terminate(entry.pid, TERMINATE_GRACE_MS);\n\tawait fs$1.rm(registryFile, { force: true });\n}\n//#endregion\n//#region src/segments.ts\n/**\n* API hygiene shared by both daemons (local-dev spec § 2): every `<app>`,\n* `<id>`, and `<name>` path segment must match this shape or the request is\n* a 400 naming the segment.\n*/\nconst SEGMENT_RE = /^[a-z0-9][a-z0-9-]*$/;\nfunction isValidSegment(segment) {\n\treturn segment.length <= 63 && SEGMENT_RE.test(segment);\n}\n//#endregion\nexport { ensureDaemon as a, readOwnVersion as c, stopDaemon as d, StateFile as f, defaultRegistryRoot as i, readRegistryEntry as l, daemonLogPath as n, healthPathFor as o, readJsonFile as p, daemonStateDir as r, isPidAlive as s, isValidSegment as t, registryFilePath as u };\n\n//# sourceMappingURL=segments-NpKN-46R.mjs.map"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12],"mappings":";;;;;;;;;;;;CAAA,IAAI,YAAA,UAAoB,WAAW;CAEnC,IAAI,UAAU,QAAQ;CACtB,IAAI,MAAM;CAEV,IAAI,WAAW,QAAQ,IAAI,wBAAwB,QAAQ;CAE3D,QAAQ,MAAM,WAAW;EACvB,IAAI,CAAC,KACH,MAAM,Q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AAO,QAAQ,UAAU,MAAM,WAAW,KAAK,OAAO;AACvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/composer-prisma-cloud",
|
|
3
|
-
"version": "0.2.0-dev.
|
|
3
|
+
"version": "0.2.0-dev.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The Prisma Cloud target for Prisma Composer: compute(), postgres(), the target extension, and first-party modules realized on Prisma Cloud (cron).",
|
|
6
6
|
"exports": {
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@effect/platform-bun": "4.0.0-beta.97",
|
|
34
34
|
"@effect/platform-node": "4.0.0-beta.92",
|
|
35
|
-
"@internal/dev-emulators": "0.2.0-dev.
|
|
35
|
+
"@internal/dev-emulators": "0.2.0-dev.16",
|
|
36
36
|
"@prisma-next/cli": "0.16.0",
|
|
37
37
|
"@prisma-next/config-loader": "0.16.0",
|
|
38
38
|
"@prisma-next/contract": "0.16.0",
|
|
39
39
|
"@prisma-next/migration-tools": "0.16.0",
|
|
40
40
|
"@prisma-next/postgres": "0.16.0",
|
|
41
41
|
"@prisma-next/sql-contract": "0.16.0",
|
|
42
|
-
"@prisma/composer": "0.2.0-dev.
|
|
42
|
+
"@prisma/composer": "0.2.0-dev.16",
|
|
43
43
|
"@prisma/management-api-sdk": "^1.50.0",
|
|
44
44
|
"@standard-schema/spec": "^1.1.0",
|
|
45
45
|
"alchemy": "2.0.0-beta.59",
|
|
@@ -51,20 +51,20 @@
|
|
|
51
51
|
"tsdown": "^0.22.7"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@internal/core": "0.2.0-dev.
|
|
55
|
-
"@internal/cron": "0.2.0-dev.
|
|
56
|
-
"@internal/email": "0.2.0-dev.
|
|
57
|
-
"@internal/foundation": "0.2.0-dev.
|
|
58
|
-
"@internal/local-target": "0.2.0-dev.
|
|
59
|
-
"@internal/lowering": "0.2.0-dev.
|
|
60
|
-
"@internal/nextjs": "0.2.0-dev.
|
|
61
|
-
"@internal/node": "0.2.0-dev.
|
|
62
|
-
"@internal/prisma-cloud": "0.2.0-dev.
|
|
63
|
-
"@internal/s3-protocol": "0.2.0-dev.
|
|
64
|
-
"@internal/service-rpc": "0.2.0-dev.
|
|
65
|
-
"@internal/storage": "0.2.0-dev.
|
|
66
|
-
"@internal/streams": "0.2.0-dev.
|
|
67
|
-
"@internal/tsdown-config": "0.2.0-dev.
|
|
54
|
+
"@internal/core": "0.2.0-dev.16",
|
|
55
|
+
"@internal/cron": "0.2.0-dev.16",
|
|
56
|
+
"@internal/email": "0.2.0-dev.16",
|
|
57
|
+
"@internal/foundation": "0.2.0-dev.16",
|
|
58
|
+
"@internal/local-target": "0.2.0-dev.16",
|
|
59
|
+
"@internal/lowering": "0.2.0-dev.16",
|
|
60
|
+
"@internal/nextjs": "0.2.0-dev.16",
|
|
61
|
+
"@internal/node": "0.2.0-dev.16",
|
|
62
|
+
"@internal/prisma-cloud": "0.2.0-dev.16",
|
|
63
|
+
"@internal/s3-protocol": "0.2.0-dev.16",
|
|
64
|
+
"@internal/service-rpc": "0.2.0-dev.16",
|
|
65
|
+
"@internal/storage": "0.2.0-dev.16",
|
|
66
|
+
"@internal/streams": "0.2.0-dev.16",
|
|
67
|
+
"@internal/tsdown-config": "0.2.0-dev.16",
|
|
68
68
|
"@types/node": "^25.9.3",
|
|
69
69
|
"typescript": "^6.0.3"
|
|
70
70
|
},
|