stim 1.10.1 → 1.12.0
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/{build-progress-BXx-ZBe4.mjs → activity-CCZJs__P.mjs} +9 -182
- package/dist/{android-787HhP5w.mjs → android-75Sk2rIR.mjs} +81 -19
- package/dist/{android-Bu4mbDzc.mjs → android-B7X-8H7h.mjs} +426 -106
- package/dist/{android-DPov-fv2.mjs → android-BQiKJYK0.mjs} +1 -1
- package/dist/{android-cas-CITmIeWY.mjs → android-cas-DzLPXiEn.mjs} +7 -7
- package/dist/{app-install-Cfmqr3TQ.mjs → app-install-CsZi0SAT.mjs} +1 -1
- package/dist/{workspaces-wrH6dXfu.mjs → budget-DbzW5VTD.mjs} +651 -32
- package/dist/{dev-client-DExzPiOa.mjs → build-plan-CqntbR7b.mjs} +514 -38
- package/dist/build-progress-h60GPV27.mjs +179 -0
- package/dist/{cache-manifest-Pubfp8wV.mjs → cache-manifest-DWPF4RKJ.mjs} +1 -1
- package/dist/cache-manifest.mjs +1 -1
- package/dist/cli.mjs +16 -16
- package/dist/collector-run.mjs +4 -4
- package/dist/{command-output-D5z2_bcF.mjs → command-output-BWCj5Vh-.mjs} +1 -1
- package/dist/{config-BEq0Qw_a.mjs → config-0jCcMM0E.mjs} +10 -1
- package/dist/{dependency-state-r9UesA9a.mjs → dependency-state-DNN0yfx6.mjs} +1 -1
- package/dist/{deps-DP4eWqea.mjs → deps-CO-_7UOm.mjs} +2 -2
- package/dist/{device-Czh5kO8A.mjs → device-9r9xRYDa.mjs} +49 -11
- package/dist/{device-lease-CbEaIk7b.mjs → device-lease-B9LAXIUH.mjs} +55 -55
- package/dist/{device-pool-BBWLAr55.mjs → device-pool-BoezJd-c.mjs} +4 -4
- package/dist/{device-remote-powUHdbK.mjs → device-remote-C0_o-tJH.mjs} +254 -579
- package/dist/{doctor-CmqK1LcQ.mjs → doctor-LfDlbR-N.mjs} +20 -19
- package/dist/{error-diagnostics-xxWKNO3-.mjs → error-diagnostics-CCxjn31V.mjs} +7 -7
- package/dist/{gc-zCDpmdHU.mjs → gc-C4nQFcTX.mjs} +220 -282
- package/dist/{guide-DwmaD_Wa.mjs → guide-BPBlh9ML.mjs} +512 -73
- package/dist/{guide-status-CWvti2Lg.mjs → guide-status-i9ogHt4v.mjs} +2 -2
- package/dist/{idle--jn7pBNe.mjs → idle-S3tFZ53_.mjs} +7 -6
- package/dist/{in-use-CNIWU-r-.mjs → in-use-D9XYEgFD.mjs} +7 -7
- package/dist/{ios-CbdqTqOc.mjs → ios-CDzWL1mj.mjs} +302 -88
- package/dist/{ios-COGcGEcN.mjs → ios-CZWOHTTc.mjs} +24 -19
- package/dist/{ios-device-DNjPXBnb.mjs → ios-device-D9cLxVr5.mjs} +1 -1
- package/dist/{launch-verify-BhgkYAws.mjs → launch-verify-B2oR_kFN.mjs} +2 -2
- package/dist/logs-SzuYudOj.mjs +485 -0
- package/dist/merge-state-ytFQCeh4.mjs +262 -0
- package/dist/{metro-BWLOJ_Wr.mjs → metro-Dzo30hvJ.mjs} +1 -1
- package/dist/{named-ports-DiTfSz6p.mjs → named-ports-Dn1o61D9.mjs} +3 -3
- package/dist/{ownership-BfPNRf3-.mjs → ownership-B8d4kXBx.mjs} +49 -16
- package/dist/{ownership-D2xbLVoz.mjs → ownership-Dqnrjrio.mjs} +2 -2
- package/dist/{ports-CLSSFOuz.mjs → ports-Dp_QTwTC.mjs} +3 -3
- package/dist/{project-BXZzOABt.mjs → project-B8rbutVC.mjs} +4 -72
- package/dist/{reload-CymyF6Kk.mjs → reload-nocmx8KB.mjs} +9 -9
- package/dist/remote-cache-BRsRZru5.mjs +526 -0
- package/dist/{server-bare-DVbb7kXH.mjs → server-bare-Gn3ssSdK.mjs} +1 -1
- package/dist/{server-expo-BvOCeakp.mjs → server-expo-CeT1nIIk.mjs} +2 -2
- package/dist/server-expo-eWi9Coof.mjs +2 -0
- package/dist/{settings-DOugPlPz.mjs → settings-BlyDn2Oz.mjs} +14 -5
- package/dist/{settings-EWYNwe72.mjs → settings-bE-Gu3Ti.mjs} +23 -11
- package/dist/settings.schema.json +73 -1
- package/dist/{simslim-DZUxzsjq.mjs → simslim-COtEEP7x.mjs} +152 -96
- package/dist/{slot-launch-Dk4oTREM.mjs → slot-launch-DIACGEfH.mjs} +4 -4
- package/dist/{spawn-claims-CUleC2cM.mjs → spawn-claims-PT8aQpCa.mjs} +25 -2
- package/dist/{start-qWapeB4W.mjs → start-BFstVBlx.mjs} +1 -1
- package/dist/{start-RbmFPeZ7.mjs → start-BboE1HIS.mjs} +108 -17
- package/dist/{state-WGdIbi_d.mjs → state-DcDgzfu3.mjs} +15 -3
- package/dist/{stats-BAgJaLA4.mjs → stats-D8rUTPHd.mjs} +1 -1
- package/dist/{stats-DBYJ5bxL.mjs → stats-DiCtmluY.mjs} +4 -4
- package/dist/{status-Dr4fRkym.mjs → status-BUASYyy_.mjs} +92 -33
- package/dist/{status-Zp8kvexe.mjs → status-DI9Tjo7T.mjs} +255 -38
- package/dist/stim-desktop-D0xhpZt8.mjs +29 -0
- package/dist/stop-BI7QY76M.mjs +3 -0
- package/dist/{stop-DcEv5sk-.mjs → stop-Bn6v-GvS.mjs} +205 -37
- package/dist/supervisor-run.mjs +11 -11
- package/dist/{workspace-process-lock-BXA96myD.mjs → workspace-process-lock-BvvJTfo_.mjs} +10 -5
- package/dist/{worktree-DEG2o9F8.mjs → worktree-B5sTRskL.mjs} +1 -1
- package/dist/{worktree-Bd4dRvx7.mjs → worktree-ChDL5fO1.mjs} +17 -16
- package/dist/{worktree-BlizKDpZ.mjs → worktree-DeBQSVtR.mjs} +3 -1
- package/dist/{xcode-B2tBkf0m.mjs → xcode-BzplpQzc.mjs} +7 -7
- package/package.json +5 -5
- package/dist/budget-nDCEwtJv.mjs +0 -620
- package/dist/logs-MARIy6m9.mjs +0 -209
- package/dist/server-expo-DBVTdult.mjs +0 -2
- package/dist/stop-DI4BG4Os.mjs +0 -3
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as volumeRootFor, U as projectDeviceSlots, _ as loadConfig$1, d as getConfigDir } from "./config-0jCcMM0E.mjs";
|
|
2
2
|
import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
|
|
3
3
|
import { a as parseNdjsonLine } from "./ndjson-CDY9IkVC.mjs";
|
|
4
|
-
import { A as workspaceLogErrorIndex, a as processCwd, j as workspaceLogsDir, l as isMetroRunning, m as readWorkspaceState$1, n as listeningPids, o as processCwds, r as listeningPidsByPort, s as resolveProjectMetro } from "./metro-
|
|
5
|
-
import { c as gitCommonDirOnDisk, p as linkedWorktreesOnDisk, s as gitCommonDir, y as repoRoot } from "./worktree-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { i as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { a as
|
|
15
|
-
import {
|
|
16
|
-
import { i as
|
|
17
|
-
import {
|
|
4
|
+
import { A as workspaceLogErrorIndex, a as processCwd, j as workspaceLogsDir, l as isMetroRunning, m as readWorkspaceState$1, n as listeningPids, o as processCwds, r as listeningPidsByPort, s as resolveProjectMetro } from "./metro-Dzo30hvJ.mjs";
|
|
5
|
+
import { c as gitCommonDirOnDisk, p as linkedWorktreesOnDisk, s as gitCommonDir, y as repoRoot } from "./worktree-DeBQSVtR.mjs";
|
|
6
|
+
import { i as findProjectRoot, s as projectShortcut } from "./project-B8rbutVC.mjs";
|
|
7
|
+
import { f as readWorkspaceLaunches, u as readRemoteSession } from "./state-DcDgzfu3.mjs";
|
|
8
|
+
import { i as formatDuration } from "./command-output-BWCj5Vh-.mjs";
|
|
9
|
+
import { i as listLeaseFiles } from "./device-lease-B9LAXIUH.mjs";
|
|
10
|
+
import { n as createActivityReader } from "./activity-CCZJs__P.mjs";
|
|
11
|
+
import { L as ownedAvdSerialResolver, N as ownedAvdDeviceProfile, u as androidToolPath } from "./android-75Sk2rIR.mjs";
|
|
12
|
+
import { b as readParked, h as POOL_SETTING_REMEDY, t as resolveSupervisorTarget, y as parkedMaxSetting } from "./ownership-B8d4kXBx.mjs";
|
|
13
|
+
import { _ as parseSimctlList, u as listAllIosSimsAsync } from "./ios-CZWOHTTc.mjs";
|
|
14
|
+
import { a as buildStatusLine, i as buildReport, r as activeBuildState, s as parseActiveBuild, t as ACTIVE_BUILD_KEY } from "./build-progress-h60GPV27.mjs";
|
|
15
|
+
import { T as readEasSessionLedger$1, w as easMachineStateRoot$1 } from "./device-remote-C0_o-tJH.mjs";
|
|
16
|
+
import { a as deviceLeaseStates, d as poolLine, f as remoteDeviceLine, h as unprovisionedWorktrees, i as deviceLeaseLines, l as gitSummaryText, m as tightVolumes, n as activityLabel, o as diskLine, p as remoteDeviceState, r as capacity, s as environmentState, u as parseDfFree } from "./status-BUASYyy_.mjs";
|
|
17
|
+
import { a as statsProjectKey, r as readStats } from "./stats-D8rUTPHd.mjs";
|
|
18
|
+
import { n as mergeState } from "./merge-state-ytFQCeh4.mjs";
|
|
19
|
+
import { i as readSupervisorState } from "./stop-Bn6v-GvS.mjs";
|
|
20
|
+
import { mkdirSync, readFileSync, readdirSync, renameSync, rmSync, watch, writeFileSync } from "node:fs";
|
|
18
21
|
import { closeSync as closeSync$1, existsSync as existsSync$1, fstatSync as fstatSync$1, openSync as openSync$1, readFileSync as readFileSync$1, readSync as readSync$1, renameSync as renameSync$1, rmSync as rmSync$1, writeFileSync as writeFileSync$1 } from "fs";
|
|
19
22
|
import { basename, dirname, join } from "path";
|
|
20
23
|
import { rotatedLogPath } from "@stim-cli/core";
|
|
21
|
-
import { ERROR_SOURCES, logFiles, queryLogs, readIdleStop, recordMatches } from "@stim-cli/core/state";
|
|
22
|
-
import { join as join$1 } from "node:path";
|
|
23
|
-
import {
|
|
24
|
+
import { ERROR_SOURCES, gitMergeCacheDir, logFiles, queryLogs, readIdleStop, readLastBuilds, recordMatches } from "@stim-cli/core/state";
|
|
25
|
+
import { join as join$1, posix } from "node:path";
|
|
26
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
27
|
+
import { homedir, totalmem } from "os";
|
|
24
28
|
import chalk from "chalk";
|
|
25
29
|
//#region src/status-watch.ts
|
|
26
30
|
const WATCH_FALLBACK_MS = 3e4;
|
|
@@ -406,21 +410,192 @@ function writeIndex(file, index) {
|
|
|
406
410
|
}
|
|
407
411
|
}
|
|
408
412
|
//#endregion
|
|
413
|
+
//#region src/workspace/git-summary.ts
|
|
414
|
+
const GIT_TIMEOUT_MS = 3e3;
|
|
415
|
+
const MERGE_BUDGET_MS = 250;
|
|
416
|
+
const ORIGIN_PREFIX = "refs/remotes/origin/";
|
|
417
|
+
/** Counts the entries of `git status --porcelain=v2 --branch` output. `head` is null on an unborn branch. */
|
|
418
|
+
function parseGitStatus(text) {
|
|
419
|
+
const summary = {
|
|
420
|
+
head: null,
|
|
421
|
+
changed: 0,
|
|
422
|
+
untracked: 0,
|
|
423
|
+
upstream: null,
|
|
424
|
+
ahead: null,
|
|
425
|
+
behind: null
|
|
426
|
+
};
|
|
427
|
+
for (const line of text.split("\n")) if (line.startsWith("# branch.oid ")) {
|
|
428
|
+
const oid = line.slice(13);
|
|
429
|
+
summary.head = /^[\da-f]{40,64}$/.test(oid) ? oid : null;
|
|
430
|
+
} else if (line.startsWith("# branch.upstream ")) summary.upstream = line.slice(18);
|
|
431
|
+
else if (line.startsWith("# branch.ab ")) {
|
|
432
|
+
const counts = /^\+(\d+) -(\d+)$/.exec(line.slice(12));
|
|
433
|
+
if (counts) {
|
|
434
|
+
summary.ahead = Number(counts[1]);
|
|
435
|
+
summary.behind = Number(counts[2]);
|
|
436
|
+
}
|
|
437
|
+
} else if (/^[12u] /.test(line)) summary.changed++;
|
|
438
|
+
else if (line.startsWith("? ")) summary.untracked++;
|
|
439
|
+
return summary;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Folders macOS guards with a privacy prompt (TCC) that names the app responsible for the reading process. Stim
|
|
443
|
+
* Desktop runs status as its child, so status opens a worktree there only when the user registered an environment in it.
|
|
444
|
+
*/
|
|
445
|
+
function inPrivacyProtectedFolder(path, home) {
|
|
446
|
+
return [...[
|
|
447
|
+
"Desktop",
|
|
448
|
+
"Documents",
|
|
449
|
+
"Downloads",
|
|
450
|
+
"Library/Mobile Documents",
|
|
451
|
+
"Library/CloudStorage"
|
|
452
|
+
].map((dir) => posix.join(home, dir)), "/Volumes"].some((dir) => path === dir || path.startsWith(`${dir}/`));
|
|
453
|
+
}
|
|
454
|
+
async function git(path, args) {
|
|
455
|
+
try {
|
|
456
|
+
return await getExecutor().runFileAsync("git", [
|
|
457
|
+
"--no-optional-locks",
|
|
458
|
+
"-C",
|
|
459
|
+
path,
|
|
460
|
+
...args
|
|
461
|
+
], { timeoutMs: GIT_TIMEOUT_MS });
|
|
462
|
+
} catch {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
async function defaultBranchOf(repository) {
|
|
467
|
+
const [ref, sha] = (await git(repository, [
|
|
468
|
+
"for-each-ref",
|
|
469
|
+
"--format=%(symref) %(objectname)",
|
|
470
|
+
"refs/remotes/origin/HEAD"
|
|
471
|
+
]) ?? "").split(" ");
|
|
472
|
+
if (!ref?.startsWith(ORIGIN_PREFIX) || !sha) return null;
|
|
473
|
+
return {
|
|
474
|
+
ref,
|
|
475
|
+
name: `origin/${ref.slice(20)}`,
|
|
476
|
+
sha
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
function mergeCacheFile(path) {
|
|
480
|
+
return join$1(gitMergeCacheDir(), `${createHash("sha256").update(path).digest("hex").slice(0, 32)}.json`);
|
|
481
|
+
}
|
|
482
|
+
function readMergeCache(path) {
|
|
483
|
+
try {
|
|
484
|
+
const entry = JSON.parse(readFileSync(mergeCacheFile(path), "utf-8"));
|
|
485
|
+
if (entry.path !== path || typeof entry.head !== "string" || typeof entry.target !== "string") return null;
|
|
486
|
+
return {
|
|
487
|
+
path,
|
|
488
|
+
head: entry.head,
|
|
489
|
+
target: entry.target,
|
|
490
|
+
mergedInto: entry.mergedInto ?? null
|
|
491
|
+
};
|
|
492
|
+
} catch {
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
function writeMergeCache(entry) {
|
|
497
|
+
const file = mergeCacheFile(entry.path);
|
|
498
|
+
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
499
|
+
try {
|
|
500
|
+
mkdirSync(gitMergeCacheDir(), { recursive: true });
|
|
501
|
+
writeFileSync(temporary, JSON.stringify(entry));
|
|
502
|
+
renameSync(temporary, file);
|
|
503
|
+
} catch {
|
|
504
|
+
rmSync(temporary, { force: true });
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function mergedInto(path, head, target, budget) {
|
|
508
|
+
const targetKey = `${target.ref} ${target.sha}`;
|
|
509
|
+
const cached = readMergeCache(path);
|
|
510
|
+
const known = cached?.head === head ? cached : null;
|
|
511
|
+
if (known?.target === targetKey) return known.mergedInto;
|
|
512
|
+
if (budget.deadline !== void 0 && Date.now() > budget.deadline) return known?.target.startsWith(`${target.ref} `) ? known.mergedInto : null;
|
|
513
|
+
budget.deadline ??= Date.now() + MERGE_BUDGET_MS;
|
|
514
|
+
const state = mergeState(path, target, { timeoutMs: GIT_TIMEOUT_MS });
|
|
515
|
+
if (!state.merged && state.timedOut) return null;
|
|
516
|
+
const verdict = state.merged ? state.into : null;
|
|
517
|
+
writeMergeCache({
|
|
518
|
+
path,
|
|
519
|
+
head,
|
|
520
|
+
target: targetKey,
|
|
521
|
+
mergedInto: verdict
|
|
522
|
+
});
|
|
523
|
+
return verdict;
|
|
524
|
+
}
|
|
525
|
+
const recent = /* @__PURE__ */ new Map();
|
|
526
|
+
/**
|
|
527
|
+
* Reads every worktree's git summary in parallel, each git call bounded by a timeout. A worktree `skip` rejects, or
|
|
528
|
+
* one git cannot answer in time, maps to null. After every read, merge verdicts missing from the cache are judged one
|
|
529
|
+
* at a time; no new judgement starts 250 ms after the first, and a verdict for the same HEAD judged at an older
|
|
530
|
+
* default-branch commit stands in, because a merged branch stays merged. With `maxAgeMs`, a summary read that
|
|
531
|
+
* recently in this process is reused.
|
|
532
|
+
*/
|
|
533
|
+
async function readWorktreeGit(worktrees, { skip, maxAgeMs = 0 }) {
|
|
534
|
+
const now = Date.now();
|
|
535
|
+
const targets = /* @__PURE__ */ new Map();
|
|
536
|
+
const reads = await Promise.all(worktrees.map(async (worktree) => {
|
|
537
|
+
const memo = recent.get(worktree.path);
|
|
538
|
+
if (memo && now - memo.at < maxAgeMs) return {
|
|
539
|
+
path: worktree.path,
|
|
540
|
+
memo: memo.git
|
|
541
|
+
};
|
|
542
|
+
if (skip(worktree)) return {
|
|
543
|
+
path: worktree.path,
|
|
544
|
+
memo: null
|
|
545
|
+
};
|
|
546
|
+
const repository = worktree.repository;
|
|
547
|
+
if (repository && !targets.has(repository)) targets.set(repository, defaultBranchOf(repository));
|
|
548
|
+
const [out, target] = await Promise.all([git(worktree.path, [
|
|
549
|
+
"status",
|
|
550
|
+
"--porcelain=v2",
|
|
551
|
+
"--branch",
|
|
552
|
+
"--untracked-files=normal"
|
|
553
|
+
]), repository ? targets.get(repository) : null]);
|
|
554
|
+
return {
|
|
555
|
+
path: worktree.path,
|
|
556
|
+
status: out === null ? null : parseGitStatus(out),
|
|
557
|
+
target
|
|
558
|
+
};
|
|
559
|
+
}));
|
|
560
|
+
const budget = {};
|
|
561
|
+
const summaries = /* @__PURE__ */ new Map();
|
|
562
|
+
for (const read of reads) {
|
|
563
|
+
if ("memo" in read || !read.status) {
|
|
564
|
+
summaries.set(read.path, "memo" in read ? read.memo ?? null : null);
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
const { head, ...counts } = read.status;
|
|
568
|
+
const summary = {
|
|
569
|
+
...counts,
|
|
570
|
+
mergedInto: head && read.target ? mergedInto(read.path, head, read.target, budget) : null
|
|
571
|
+
};
|
|
572
|
+
recent.set(read.path, {
|
|
573
|
+
at: now,
|
|
574
|
+
git: summary
|
|
575
|
+
});
|
|
576
|
+
summaries.set(read.path, summary);
|
|
577
|
+
}
|
|
578
|
+
return summaries;
|
|
579
|
+
}
|
|
580
|
+
//#endregion
|
|
409
581
|
//#region src/commands/status.ts
|
|
582
|
+
const WATCH_GIT_MAX_AGE_MS = 5e3;
|
|
410
583
|
function formatGb(mb) {
|
|
411
584
|
return `${(mb / 1024).toFixed(1)} GB`;
|
|
412
585
|
}
|
|
413
586
|
function statusCommand(program) {
|
|
414
587
|
program.command("status").description("Show every environment on this machine: devices, ports, what is actually running, and anything stuck.").option("--json", "print the state as JSON").option("--watch", "keep running and print the state again each time it changes").action(async (opts) => {
|
|
415
588
|
if (opts.watch) return watchStatus(Boolean(opts.json));
|
|
416
|
-
for (const line of await statusLines(Boolean(opts.json))) console.log(line);
|
|
589
|
+
for (const line of await statusLines(Boolean(opts.json), 0)) console.log(line);
|
|
417
590
|
});
|
|
418
591
|
}
|
|
419
|
-
async function statusLines(json) {
|
|
592
|
+
async function statusLines(json, gitMaxAgeMs) {
|
|
420
593
|
const out = [];
|
|
421
594
|
const cfg = loadConfig$1();
|
|
422
595
|
const projects = Object.entries(cfg?.projects || {});
|
|
423
596
|
const cwdRoot = findProjectRoot(process.cwd());
|
|
597
|
+
const worktrees = linkedWorktrees([process.cwd(), ...projects.map(([path]) => path)]);
|
|
598
|
+
const orphanWorktrees = unprovisionedWorktrees(worktrees, projects.map(([p]) => p));
|
|
424
599
|
const simsRead = listAllIosSimsAsync();
|
|
425
600
|
simsRead.catch(() => {});
|
|
426
601
|
const ports = await portLookup(projects.flatMap(([, proj]) => proj.metroPort ? [proj.metroPort] : []));
|
|
@@ -432,10 +607,13 @@ async function statusLines(json) {
|
|
|
432
607
|
};
|
|
433
608
|
}));
|
|
434
609
|
processes.catch(() => {});
|
|
610
|
+
const gitRead = readGitInto(worktrees, orphanWorktrees, gitMaxAgeMs);
|
|
435
611
|
const androidRuntimeOf = androidRuntimeReader();
|
|
436
612
|
const devices = projects.map(([, proj]) => ({
|
|
437
613
|
androidRuntimes: Object.fromEntries(projectDeviceSlots(proj).slice(1).map(({ slot, platforms }) => [slot, platforms.android?.owned && platforms.android.avdName ? androidRuntimeOf(platforms.android.avdName) : null])),
|
|
438
|
-
androidRuntime: proj.platforms?.android?.owned && proj.platforms.android.avdName ? androidRuntimeOf(proj.platforms.android.avdName) : null
|
|
614
|
+
androidRuntime: proj.platforms?.android?.owned && proj.platforms.android.avdName ? androidRuntimeOf(proj.platforms.android.avdName) : null,
|
|
615
|
+
androidDeviceProfiles: Object.fromEntries(projectDeviceSlots(proj).slice(1).map(({ slot, platforms }) => [slot, platforms.android?.owned && platforms.android.avdName ? ownedAvdDeviceProfile(platforms.android.avdName) : null])),
|
|
616
|
+
androidDeviceProfile: proj.platforms?.android?.owned && proj.platforms.android.avdName ? ownedAvdDeviceProfile(proj.platforms.android.avdName) : null
|
|
439
617
|
}));
|
|
440
618
|
const logs = projects.map(([path]) => logFacts(path));
|
|
441
619
|
const simsByUdid = {};
|
|
@@ -448,13 +626,21 @@ async function statusLines(json) {
|
|
|
448
626
|
simctlError = String(e?.message || e).split("\n")[0] ?? "";
|
|
449
627
|
}
|
|
450
628
|
const running = await processes;
|
|
451
|
-
|
|
629
|
+
await gitRead;
|
|
452
630
|
const history = readStats().record?.history;
|
|
453
631
|
const states = [];
|
|
454
632
|
const labelOnlyRoots = [];
|
|
455
633
|
const easLedger = readEasSessionLedger$1();
|
|
634
|
+
const leaseNow = Date.now();
|
|
635
|
+
const leaseFiles = listLeaseFiles();
|
|
636
|
+
const leases = deviceLeaseStates(leaseFiles, {
|
|
637
|
+
root: cwdRoot,
|
|
638
|
+
now: leaseNow
|
|
639
|
+
});
|
|
456
640
|
for (const [i, [path, proj]] of projects.entries()) {
|
|
457
641
|
const { metro, supervisor } = running[i];
|
|
642
|
+
const saved = readWorkspaceState$1(path);
|
|
643
|
+
const builds = workspaceBuilds(path, saved, history);
|
|
458
644
|
states.push(environmentState({
|
|
459
645
|
...proj,
|
|
460
646
|
__path: path
|
|
@@ -467,10 +653,16 @@ async function statusLines(json) {
|
|
|
467
653
|
supervisor,
|
|
468
654
|
logs: logs[i],
|
|
469
655
|
remote: remoteDeviceState(readRemoteSession(path), easLedger, path),
|
|
470
|
-
idleStop: readIdleStop(
|
|
656
|
+
idleStop: readIdleStop(saved),
|
|
657
|
+
launches: readWorkspaceLaunches(path),
|
|
658
|
+
leasedIds: new Set(deviceLeaseStates(leaseFiles, {
|
|
659
|
+
root: path,
|
|
660
|
+
now: leaseNow
|
|
661
|
+
}).flatMap((lease) => lease.mine && !lease.expired && lease.id ? [lease.id] : [])),
|
|
662
|
+
now: leaseNow
|
|
471
663
|
}));
|
|
472
664
|
const state = states[states.length - 1];
|
|
473
|
-
if (state)
|
|
665
|
+
if (state) Object.assign(state, builds);
|
|
474
666
|
labelOnlyRoots.push(Boolean(proj.worktreeRoot && !proj.bundleId && !state?.metro && !state?.ios && !state?.android));
|
|
475
667
|
}
|
|
476
668
|
const readActivity = createActivityReader();
|
|
@@ -494,14 +686,8 @@ async function statusLines(json) {
|
|
|
494
686
|
id: device.android.serial
|
|
495
687
|
});
|
|
496
688
|
}
|
|
497
|
-
const leaseNow = Date.now();
|
|
498
|
-
const leases = deviceLeaseStates(listLeaseFiles(), {
|
|
499
|
-
root: cwdRoot,
|
|
500
|
-
now: leaseNow
|
|
501
|
-
});
|
|
502
689
|
const totalMemoryMb = Math.round(totalmem() / 1048576);
|
|
503
690
|
const cap = capacity(states, totalMemoryMb);
|
|
504
|
-
const orphanWorktrees = unprovisionedWorktrees(worktrees, projects.map(([p]) => p));
|
|
505
691
|
const pools = ["ios", "android"].map((platform) => {
|
|
506
692
|
const { max, error } = parkedMaxSetting(platform);
|
|
507
693
|
return {
|
|
@@ -557,6 +743,8 @@ async function statusLines(json) {
|
|
|
557
743
|
const line = ` ${buildStatusLine(state.build, Date.now())}`;
|
|
558
744
|
out.push(state.build.state === "running" ? line : chalk.yellow(line));
|
|
559
745
|
}
|
|
746
|
+
out.push(...lastBuildsLines(state.lastBuilds));
|
|
747
|
+
if (state.worktree?.git) out.push(chalk.dim(` git: ${gitSummaryText(state.worktree.git)}`));
|
|
560
748
|
if (state.logs) {
|
|
561
749
|
const n = state.logs.errorsSinceMarker;
|
|
562
750
|
const errs = n > 0 ? chalk.yellow(` (${n} error${n === 1 ? "" : "s"} since the last marker)`) : "";
|
|
@@ -593,7 +781,7 @@ async function statusLines(json) {
|
|
|
593
781
|
}
|
|
594
782
|
if (orphanWorktrees.length) {
|
|
595
783
|
out.push(chalk.dim(`\nWorktrees with no environment (${orphanWorktrees.length}):`));
|
|
596
|
-
for (const w of orphanWorktrees) out.push(chalk.dim(` ${w
|
|
784
|
+
for (const w of orphanWorktrees) out.push(chalk.dim(` ${orphanWorktreeLine(w)}`));
|
|
597
785
|
}
|
|
598
786
|
out.push(chalk.dim(`\n${cap.liveCount} live environment(s), roughly ${formatGb(cap.committedMb)} of ${formatGb(cap.totalMemoryMb)} committed.`));
|
|
599
787
|
const volumes = readVolumes(cwdRoot || process.cwd());
|
|
@@ -616,7 +804,7 @@ async function watchStatus(json) {
|
|
|
616
804
|
run: async () => {
|
|
617
805
|
let text;
|
|
618
806
|
try {
|
|
619
|
-
text = (await statusLines(json)).join("\n");
|
|
807
|
+
text = (await statusLines(json, WATCH_GIT_MAX_AGE_MS)).join("\n");
|
|
620
808
|
} catch (error) {
|
|
621
809
|
console.error(chalk.red(String(error?.message || error)));
|
|
622
810
|
return;
|
|
@@ -645,6 +833,26 @@ async function watchStatus(json) {
|
|
|
645
833
|
scheduler.trigger(0);
|
|
646
834
|
await new Promise(() => {});
|
|
647
835
|
}
|
|
836
|
+
async function readGitInto(worktrees, orphans, maxAgeMs) {
|
|
837
|
+
const home = homedir();
|
|
838
|
+
const byPath = await readWorktreeGit(worktrees, {
|
|
839
|
+
maxAgeMs,
|
|
840
|
+
skip: (w) => process.platform === "darwin" && orphans.includes(w) && inPrivacyProtectedFolder(w.path, home)
|
|
841
|
+
});
|
|
842
|
+
for (const worktree of worktrees) worktree.git = byPath.get(worktree.path) ?? null;
|
|
843
|
+
}
|
|
844
|
+
function orphanWorktreeLine(w) {
|
|
845
|
+
return `${w.path}${w.branch ? ` [${w.branch}]` : ""}${w.git ? ` -- ${gitSummaryText(w.git)}` : ""}`;
|
|
846
|
+
}
|
|
847
|
+
function lastBuildsLines(reports) {
|
|
848
|
+
const texts = Object.values(reports ?? {}).map(lastBuildText);
|
|
849
|
+
return texts.length ? [chalk.dim(` last build: ${texts.join(", ")}`)] : [];
|
|
850
|
+
}
|
|
851
|
+
function lastBuildText(report) {
|
|
852
|
+
const source = report.cacheHit ? `${report.cacheHit} cache` : report.status === "ok" ? "compiled" : "no cache hit";
|
|
853
|
+
const took = report.durationMs === null ? "" : ` in ${formatDuration(report.durationMs)}`;
|
|
854
|
+
return `${report.platform} ${report.status === "ok" ? source : `failed (${report.errorCode ?? "error"}), ${source}`}${took}`;
|
|
855
|
+
}
|
|
648
856
|
function activitySuffix(activity) {
|
|
649
857
|
const label = activityLabel(activity, Date.now());
|
|
650
858
|
return label ? ` -- ${activity?.state === "driven" ? chalk.magenta(label) : chalk.dim(label)}` : "";
|
|
@@ -655,8 +863,15 @@ function linkedWorktrees(paths) {
|
|
|
655
863
|
return linkedWorktreesOnDisk(common).map((entry) => Object.assign(entry, { repository }));
|
|
656
864
|
});
|
|
657
865
|
}
|
|
658
|
-
function
|
|
659
|
-
const
|
|
866
|
+
function workspaceBuilds(path, saved, history) {
|
|
867
|
+
const lastBuilds = readLastBuilds(saved);
|
|
868
|
+
return {
|
|
869
|
+
build: workspaceBuild(path, saved, history),
|
|
870
|
+
...lastBuilds.ios || lastBuilds.android ? { lastBuilds } : {}
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
function workspaceBuild(path, saved, history) {
|
|
874
|
+
const record = parseActiveBuild(saved?.[ACTIVE_BUILD_KEY]);
|
|
660
875
|
if (!record) return null;
|
|
661
876
|
const projectKey = statsProjectKey({
|
|
662
877
|
root: path,
|
|
@@ -727,13 +942,14 @@ async function supervisorFacts(path, proj, metroResolution, lookup) {
|
|
|
727
942
|
const pid = state?.pid ?? record?.pid ?? null;
|
|
728
943
|
if (!pid) return null;
|
|
729
944
|
const port = state?.port ?? record?.port ?? null;
|
|
730
|
-
const
|
|
945
|
+
const target = resolveSupervisorTarget({
|
|
731
946
|
state,
|
|
732
947
|
record,
|
|
733
948
|
reservedPort: proj?.metroPort
|
|
734
|
-
})
|
|
949
|
+
});
|
|
950
|
+
const status = target.status === "ours" ? "ours" : target.status === "unverified" ? "unverified" : "stale";
|
|
735
951
|
let healthy = false;
|
|
736
|
-
if (
|
|
952
|
+
if (status === "ours" && port) {
|
|
737
953
|
const resolution = port === proj?.metroPort && metroResolution ? metroResolution : await resolveOnPort(port, path, lookup);
|
|
738
954
|
healthy = Boolean(resolution?.metro);
|
|
739
955
|
}
|
|
@@ -741,7 +957,8 @@ async function supervisorFacts(path, proj, metroResolution, lookup) {
|
|
|
741
957
|
pid,
|
|
742
958
|
mode: state?.mode ?? record?.mode ?? null,
|
|
743
959
|
startedAt: state?.startedAt ?? record?.startedAt ?? null,
|
|
744
|
-
|
|
960
|
+
status,
|
|
961
|
+
...target.reason ? { reason: target.reason } : {},
|
|
745
962
|
healthy
|
|
746
963
|
};
|
|
747
964
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
|
|
2
|
+
//#region src/devices/stim-desktop.ts
|
|
3
|
+
const LAUNCH_SERVICES_LOOKUP = `ObjC.import('AppKit'); const url = $.NSWorkspace.sharedWorkspace.URLForApplicationWithBundleIdentifier('dev.stim.desktop'); url.isNil() ? '' : url.path.js`;
|
|
4
|
+
const STIM_DESKTOP_INSTALLED = "Stim Desktop installed";
|
|
5
|
+
function stimDesktopInstalled(platform = process.platform) {
|
|
6
|
+
if (platform !== "darwin") return false;
|
|
7
|
+
const found = getExecutor().runFileQuiet("osascript", [
|
|
8
|
+
"-l",
|
|
9
|
+
"JavaScript",
|
|
10
|
+
"-e",
|
|
11
|
+
LAUNCH_SERVICES_LOOKUP
|
|
12
|
+
], {
|
|
13
|
+
timeoutMs: 5e3,
|
|
14
|
+
killSignal: "SIGKILL"
|
|
15
|
+
});
|
|
16
|
+
return Boolean(found);
|
|
17
|
+
}
|
|
18
|
+
function settingDefault(setting, desktopInstalled = stimDesktopInstalled) {
|
|
19
|
+
if (setting.desktopDefault !== void 0 && desktopInstalled()) return {
|
|
20
|
+
value: setting.desktopDefault,
|
|
21
|
+
reason: STIM_DESKTOP_INSTALLED
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
value: setting.default,
|
|
25
|
+
reason: null
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { stimDesktopInstalled as n, settingDefault as t };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { t as resolveSupervisorTarget } from "./ownership-B8d4kXBx.mjs";
|
|
2
|
+
import { a as resolveCollectorTargets, c as stopWorkspaceNow, i as readSupervisorState, n as clearSupervisorState, o as runStop, r as readCollectorState, s as stopCommand, t as clearCollectorState } from "./stop-Bn6v-GvS.mjs";
|
|
3
|
+
export { clearCollectorState, clearSupervisorState, stopCommand as default, readCollectorState, readSupervisorState, resolveCollectorTargets, resolveSupervisorTarget, runStop, stopWorkspaceNow };
|