@lob-ox/core-darwin-x64 0.0.7 → 0.0.8
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/core.cjs +88 -8
- package/package.json +1 -1
package/core.cjs
CHANGED
|
@@ -306,6 +306,78 @@ var require_exec_path = __commonJS({
|
|
|
306
306
|
function dshJsIn(prefix) {
|
|
307
307
|
return path2.join(prefix, "node_modules", ...DSH_PKG, "lib", "bin.js");
|
|
308
308
|
}
|
|
309
|
+
function shimJsTarget(hit) {
|
|
310
|
+
if (!/\.(cmd|bat)$/i.test(hit)) return null;
|
|
311
|
+
let txt = null;
|
|
312
|
+
try {
|
|
313
|
+
txt = fs2.readFileSync(hit, "utf8");
|
|
314
|
+
} catch {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
const re = /"([^"]+\.(?:js|cjs|mjs))"|(\S+\.(?:js|cjs|mjs))(?=\s|$)/gi;
|
|
318
|
+
let m;
|
|
319
|
+
while (m = re.exec(txt)) {
|
|
320
|
+
const cand = m[1] || m[2];
|
|
321
|
+
try {
|
|
322
|
+
const rp = fs2.realpathSync(cand);
|
|
323
|
+
if (fs2.statSync(rp).isFile()) return rp;
|
|
324
|
+
} catch {
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
function harnessHome(env) {
|
|
330
|
+
const e = env || process.env;
|
|
331
|
+
const h = e.HOME || e.USERPROFILE || os2.homedir();
|
|
332
|
+
return path2.join(h, ".dsh-app");
|
|
333
|
+
}
|
|
334
|
+
function dshJsFromLive(pl, env) {
|
|
335
|
+
const pidlookup = require_pidlookup();
|
|
336
|
+
const isFile = (p) => {
|
|
337
|
+
try {
|
|
338
|
+
return fs2.statSync(p).isFile();
|
|
339
|
+
} catch {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
let port = null;
|
|
344
|
+
try {
|
|
345
|
+
const cfg = env && env.DSH_CONFIG && typeof env.DSH_CONFIG === "object" ? env.DSH_CONFIG : null;
|
|
346
|
+
if (cfg && Number.isInteger(cfg.targetPort) && cfg.targetPort > 0) port = cfg.targetPort;
|
|
347
|
+
else if (cfg && cfg.healthUrl) {
|
|
348
|
+
const u = new URL(cfg.healthUrl);
|
|
349
|
+
if (u.port) port = Number(u.port);
|
|
350
|
+
}
|
|
351
|
+
} catch {
|
|
352
|
+
}
|
|
353
|
+
if (!port) return null;
|
|
354
|
+
let pid = null;
|
|
355
|
+
try {
|
|
356
|
+
pid = pidlookup.findListeningPid(port);
|
|
357
|
+
} catch {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
if (!pid) return null;
|
|
361
|
+
let cmd2 = null;
|
|
362
|
+
try {
|
|
363
|
+
cmd2 = pidlookup.readCmdline(pid);
|
|
364
|
+
} catch {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
if (!cmd2) return null;
|
|
368
|
+
for (const part of cmd2.split(/\s+/).filter(Boolean)) {
|
|
369
|
+
try {
|
|
370
|
+
const rp = fs2.realpathSync(part);
|
|
371
|
+
if (isFile(rp) && /\.(js|cjs|mjs)$/i.test(rp)) {
|
|
372
|
+
const js = dshJsIn(path2.dirname(rp));
|
|
373
|
+
if (isFile(js)) return asJs(js, rp);
|
|
374
|
+
if (isFile(rp)) return asJs(rp, rp);
|
|
375
|
+
}
|
|
376
|
+
} catch {
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
309
381
|
function resolveDsh(opts) {
|
|
310
382
|
const o = opts || {};
|
|
311
383
|
const pl = o.platform || process.platform;
|
|
@@ -317,35 +389,43 @@ var require_exec_path = __commonJS({
|
|
|
317
389
|
return false;
|
|
318
390
|
}
|
|
319
391
|
};
|
|
320
|
-
const
|
|
392
|
+
const asJs2 = (bin, launcher) => ({ runtime: process.execPath, bin, isJs: true, launcher: launcher || null });
|
|
321
393
|
if (env.DSH_BIN) {
|
|
322
394
|
try {
|
|
323
395
|
const r = fs2.realpathSync(env.DSH_BIN);
|
|
324
|
-
if (isFile(r)) return
|
|
396
|
+
if (isFile(r)) return asJs2(r, env.DSH_BIN);
|
|
325
397
|
} catch {
|
|
326
398
|
}
|
|
327
399
|
}
|
|
328
400
|
const hit = resolveExecutable("dsh", { platform: pl, env });
|
|
329
401
|
if (hit) {
|
|
402
|
+
const shim = shimJsTarget(hit);
|
|
403
|
+
if (shim) return asJs2(shim, hit);
|
|
330
404
|
try {
|
|
331
405
|
const real = fs2.realpathSync(hit);
|
|
332
|
-
if (isFile(real) && /\.(js|cjs|mjs)$/i.test(real)) return
|
|
406
|
+
if (isFile(real) && /\.(js|cjs|mjs)$/i.test(real)) return asJs2(real, hit);
|
|
333
407
|
} catch {
|
|
334
408
|
}
|
|
335
409
|
const js = dshJsIn(path2.dirname(hit));
|
|
336
|
-
if (isFile(js)) return
|
|
337
|
-
if (isFile(hit) && !/\.(cmd|bat|exe)$/i.test(hit)) return
|
|
410
|
+
if (isFile(js)) return asJs2(js, hit);
|
|
411
|
+
if (isFile(hit) && !/\.(cmd|bat|exe)$/i.test(hit)) return asJs2(hit, hit);
|
|
338
412
|
return { runtime: null, bin: hit, isJs: false, launcher: hit };
|
|
339
413
|
}
|
|
340
414
|
if (o.npmRoot) {
|
|
341
415
|
const js = dshJsIn(o.npmRoot);
|
|
342
|
-
if (isFile(js)) return
|
|
416
|
+
if (isFile(js)) return asJs2(js, null);
|
|
343
417
|
}
|
|
344
418
|
const gRoot = globalInstallRoot(pl, void 0, env);
|
|
345
419
|
{
|
|
346
420
|
const js = dshJsIn(gRoot);
|
|
347
|
-
if (isFile(js)) return
|
|
421
|
+
if (isFile(js)) return asJs2(js, null);
|
|
422
|
+
}
|
|
423
|
+
{
|
|
424
|
+
const js = dshJsIn(harnessHome(env));
|
|
425
|
+
if (isFile(js)) return asJs2(js, null);
|
|
348
426
|
}
|
|
427
|
+
const live = dshJsFromLive(pl, env);
|
|
428
|
+
if (live) return live;
|
|
349
429
|
return null;
|
|
350
430
|
}
|
|
351
431
|
function knownDshEntries(opts) {
|
|
@@ -1403,7 +1483,7 @@ var require_version = __commonJS({
|
|
|
1403
1483
|
var fs2 = require("node:fs");
|
|
1404
1484
|
var path2 = require("node:path");
|
|
1405
1485
|
function guardVersion() {
|
|
1406
|
-
if (true) return String("0.0.
|
|
1486
|
+
if (true) return String("0.0.8");
|
|
1407
1487
|
try {
|
|
1408
1488
|
return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
|
|
1409
1489
|
} catch {
|