@tablation/crew 0.150.0 → 0.150.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +195 -62
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -71,12 +71,12 @@ function routePeriscopeProblems(o) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
if (o.tablePresent === false) {
|
|
74
|
+
if (o.tablePresent === false && !o.snapshotStale) {
|
|
75
75
|
out.push({
|
|
76
76
|
severity: "blocker",
|
|
77
77
|
kind: "periscopes_table_missing",
|
|
78
78
|
route: o.route,
|
|
79
|
-
message: `${o.route}: hostPeriscopes is on but this workspace has no Periscopes table \u2014
|
|
79
|
+
message: `${o.route}: hostPeriscopes is on but this workspace has no Periscopes table (confirmed against the workspace) \u2014 a workspace admin updates the Issues app to add it, then run \`crew connect\``
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
return out;
|
|
@@ -4418,6 +4418,7 @@ function parseResolved(raw, m, where) {
|
|
|
4418
4418
|
holds: holds2,
|
|
4419
4419
|
contract: raw.contract ?? void 0,
|
|
4420
4420
|
...typeof raw.releaseSeat === "string" && raw.releaseSeat ? { releaseSeat: raw.releaseSeat } : {},
|
|
4421
|
+
...typeof raw.connectedAt === "string" && raw.connectedAt ? { connectedAt: raw.connectedAt } : {},
|
|
4421
4422
|
...typeof raw.releaseAgentId === "string" && raw.releaseAgentId ? { releaseAgentId: raw.releaseAgentId } : {},
|
|
4422
4423
|
...typeof raw.role === "string" && raw.role ? { role: raw.role } : {},
|
|
4423
4424
|
...Array.isArray(raw.capabilityMisses) && raw.capabilityMisses.length > 0 ? { capabilityMisses: raw.capabilityMisses.filter((x) => typeof x === "string") } : {},
|
|
@@ -5680,13 +5681,17 @@ function runAll(commands, cwd, log) {
|
|
|
5680
5681
|
}
|
|
5681
5682
|
async function applyInstall(plan, crewHome, dryRun, log) {
|
|
5682
5683
|
let changed2 = plan.crontabLine !== null;
|
|
5684
|
+
let replaced = false;
|
|
5683
5685
|
for (const path of plan.unitPaths) {
|
|
5684
5686
|
if (dryRun) {
|
|
5685
5687
|
log.emit(`would write ${path}`);
|
|
5686
5688
|
continue;
|
|
5687
5689
|
}
|
|
5688
5690
|
const before = existsSync16(path) ? readFileSync17(path, "utf8") : null;
|
|
5689
|
-
if (before !== plan.unitContent[path])
|
|
5691
|
+
if (before !== plan.unitContent[path]) {
|
|
5692
|
+
changed2 = true;
|
|
5693
|
+
if (before !== null) replaced = true;
|
|
5694
|
+
}
|
|
5690
5695
|
mkdirSync12(dirname9(path), { recursive: true });
|
|
5691
5696
|
writeFileSync13(path, plan.unitContent[path]);
|
|
5692
5697
|
log.emit(`wrote ${path}`);
|
|
@@ -5703,7 +5708,7 @@ async function applyInstall(plan, crewHome, dryRun, log) {
|
|
|
5703
5708
|
if (dryRun) {
|
|
5704
5709
|
for (const c of plan.preLoadCommands) log.emit(`would run: ${c.join(" ")}`);
|
|
5705
5710
|
} else {
|
|
5706
|
-
const ok = runAll(plan.preLoadCommands, crewHome, log);
|
|
5711
|
+
const ok = runAll(plan.preLoadCommands, crewHome, { emit: log.emit.bind(log), warn: (m) => log.emit(m) });
|
|
5707
5712
|
if (!ok) log.emit("unload before reload failed \u2014 likely not loaded yet, continuing");
|
|
5708
5713
|
}
|
|
5709
5714
|
}
|
|
@@ -5727,19 +5732,20 @@ async function applyInstall(plan, crewHome, dryRun, log) {
|
|
|
5727
5732
|
}
|
|
5728
5733
|
log.emit(`crew's own log: ${plan.crewLog}`);
|
|
5729
5734
|
log.emit(`scheduler log (only what escapes the crew, e.g. a crash before it starts): ${plan.schedulerLog}`);
|
|
5730
|
-
return { changed: changed2 };
|
|
5735
|
+
return { changed: changed2, action: !changed2 ? "unchanged" : replaced ? "replaced" : "installed" };
|
|
5731
5736
|
}
|
|
5732
5737
|
async function applyUninstall(plan, crewHome, dryRun, log) {
|
|
5738
|
+
let changed2 = false;
|
|
5733
5739
|
if (plan.mechanism === "none") {
|
|
5734
5740
|
log.emit("nothing to uninstall on this platform");
|
|
5735
|
-
return;
|
|
5741
|
+
return { changed: changed2 };
|
|
5736
5742
|
}
|
|
5737
5743
|
if (plan.unloadCommands.length) {
|
|
5738
5744
|
if (dryRun) {
|
|
5739
5745
|
for (const c of plan.unloadCommands) log.emit(`would run: ${c.join(" ")}`);
|
|
5740
5746
|
} else {
|
|
5741
|
-
const ok = runAll(plan.unloadCommands, crewHome, log);
|
|
5742
|
-
if (!ok) log.
|
|
5747
|
+
const ok = runAll(plan.unloadCommands, crewHome, { emit: log.emit.bind(log), warn: (m) => log.emit(m) });
|
|
5748
|
+
if (!ok) log.emit("unload command failed \u2014 it may not have been loaded; continuing to remove files");
|
|
5743
5749
|
}
|
|
5744
5750
|
}
|
|
5745
5751
|
if (plan.removeLabel) {
|
|
@@ -5747,6 +5753,7 @@ async function applyUninstall(plan, crewHome, dryRun, log) {
|
|
|
5747
5753
|
log.emit(`would run: launchctl remove ${plan.removeLabel}`);
|
|
5748
5754
|
} else {
|
|
5749
5755
|
if (spawnSync5("launchctl", ["remove", plan.removeLabel], { encoding: "utf8" }).status === 0) {
|
|
5756
|
+
changed2 = true;
|
|
5750
5757
|
log.emit(`removed loaded job ${plan.removeLabel}`);
|
|
5751
5758
|
}
|
|
5752
5759
|
}
|
|
@@ -5758,6 +5765,7 @@ async function applyUninstall(plan, crewHome, dryRun, log) {
|
|
|
5758
5765
|
continue;
|
|
5759
5766
|
}
|
|
5760
5767
|
unlinkSync2(path);
|
|
5768
|
+
changed2 = true;
|
|
5761
5769
|
log.emit(`removed ${path}`);
|
|
5762
5770
|
}
|
|
5763
5771
|
if (plan.crontabLine) {
|
|
@@ -5765,9 +5773,11 @@ async function applyUninstall(plan, crewHome, dryRun, log) {
|
|
|
5765
5773
|
log.emit("would remove crontab entry");
|
|
5766
5774
|
} else {
|
|
5767
5775
|
removeCrontabLine(plan.crontabLine);
|
|
5776
|
+
changed2 = true;
|
|
5768
5777
|
log.emit("removed crontab entry");
|
|
5769
5778
|
}
|
|
5770
5779
|
}
|
|
5780
|
+
return { changed: changed2 };
|
|
5771
5781
|
}
|
|
5772
5782
|
var CREW_LAUNCHD_PREFIX = "com.tablation.crew";
|
|
5773
5783
|
function launchAgentsDir() {
|
|
@@ -5835,8 +5845,8 @@ function clearForeignLaunchdUnits(crewHome, replace, dryRun, log, dir, loaded) {
|
|
|
5835
5845
|
}
|
|
5836
5846
|
for (const unit of foreign) {
|
|
5837
5847
|
const why = unit.orphan ? "removing a loaded job whose plist is gone" : unit.program === null ? "replacing a unit with no readable ProgramArguments" : unit.programExists ? "replacing a live other install" : "removing a stale unit whose program is gone";
|
|
5838
|
-
log.emit(`${why}: ${unit.label}`);
|
|
5839
|
-
removeLaunchdUnit(unit, dryRun, log);
|
|
5848
|
+
log.emit(`${why}: ${unit.label}${dryRun ? " (dry run, not applied)" : ""}`);
|
|
5849
|
+
removeLaunchdUnit(unit, dryRun, { emit: () => void 0, warn: log.warn.bind(log) });
|
|
5840
5850
|
}
|
|
5841
5851
|
return true;
|
|
5842
5852
|
}
|
|
@@ -17224,6 +17234,9 @@ var sound = (r) => r.hasRepos && r.problems.length === 0;
|
|
|
17224
17234
|
function planFix(f) {
|
|
17225
17235
|
const actions = [];
|
|
17226
17236
|
const notes = [];
|
|
17237
|
+
for (const r of f.routes) {
|
|
17238
|
+
if (r.snapshotStale) actions.push({ kind: "refresh-snapshot", route: r.route });
|
|
17239
|
+
}
|
|
17227
17240
|
for (const r of f.routes) {
|
|
17228
17241
|
if (!r.enabled && sound(r)) {
|
|
17229
17242
|
actions.push({ kind: "enable", route: r.route });
|
|
@@ -17244,14 +17257,18 @@ function planFix(f) {
|
|
|
17244
17257
|
async function gatherHealth(c, check) {
|
|
17245
17258
|
let problems;
|
|
17246
17259
|
let readiness = [];
|
|
17260
|
+
let snapshotStale = false;
|
|
17247
17261
|
try {
|
|
17248
17262
|
const r = await check();
|
|
17249
17263
|
if (Array.isArray(r)) problems = r;
|
|
17250
|
-
else
|
|
17264
|
+
else {
|
|
17265
|
+
({ problems, readiness } = r);
|
|
17266
|
+
snapshotStale = r.snapshotStale === true;
|
|
17267
|
+
}
|
|
17251
17268
|
} catch (e) {
|
|
17252
17269
|
problems = [`checks could not run: ${e instanceof Error ? e.message : String(e)}`];
|
|
17253
17270
|
}
|
|
17254
|
-
return { route: c.route, enabled: c.enabled, hasRepos: c.hasRepos, problems, readiness };
|
|
17271
|
+
return { route: c.route, enabled: c.enabled, hasRepos: c.hasRepos, problems, readiness, ...snapshotStale ? { snapshotStale } : {} };
|
|
17255
17272
|
}
|
|
17256
17273
|
function routesInScope(routes, named) {
|
|
17257
17274
|
return named ? routes.filter((r) => r.route === named) : routes;
|
|
@@ -19667,8 +19684,8 @@ function failureComparison(b, previousNote) {
|
|
|
19667
19684
|
if (!before.length || !now.length) {
|
|
19668
19685
|
lines2.push("- Same failure both times? Unknown: the output of at least one run names no file.");
|
|
19669
19686
|
} else {
|
|
19670
|
-
const
|
|
19671
|
-
lines2.push(
|
|
19687
|
+
const same2 = now.filter((f) => before.includes(f));
|
|
19688
|
+
lines2.push(same2.length ? `- Same failure both times: yes, ${same2.map((f) => `\`${f}\``).join(", ")} fails in both.` : `- Same failure both times: **no**. First ${before.slice(0, 3).map((f) => `\`${f}\``).join(", ")}, now ${now.slice(0, 3).map((f) => `\`${f}\``).join(", ")}. Two different failures look like a flake, not a branch that keeps breaking.`);
|
|
19672
19689
|
}
|
|
19673
19690
|
lines2.push(b.inBranch == null ? "- Failing files among the branch's changes? Unknown: the failure names no file." : b.inBranch ? "- Failing files among the branch's changes: yes." : "- Failing files among the branch's changes: **no**, none of them. Not proof, but the branch probably did not break it.");
|
|
19674
19691
|
return lines2.join("\n");
|
|
@@ -24331,11 +24348,11 @@ function readStartFailure(stateDir) {
|
|
|
24331
24348
|
function noteStartFailure(stateDir, reason, nowMs = Date.now()) {
|
|
24332
24349
|
const previous = readStartFailure(stateDir);
|
|
24333
24350
|
const nowIso = new Date(nowMs).toISOString();
|
|
24334
|
-
const
|
|
24351
|
+
const same2 = previous?.reason === reason;
|
|
24335
24352
|
const record = {
|
|
24336
24353
|
reason,
|
|
24337
|
-
count:
|
|
24338
|
-
firstAt:
|
|
24354
|
+
count: same2 ? previous.count + 1 : 1,
|
|
24355
|
+
firstAt: same2 ? previous.firstAt : nowIso,
|
|
24339
24356
|
lastAt: nowIso
|
|
24340
24357
|
};
|
|
24341
24358
|
mkdirSync37(stateDir, { recursive: true });
|
|
@@ -25793,6 +25810,23 @@ function summarizeOutcomes(outcomes, describe2, isRoutine, noun, verbose) {
|
|
|
25793
25810
|
function withFix(message, fix) {
|
|
25794
25811
|
return `${message.replace(/[.\s]+$/, "")} \u2014 try: ${fix}`;
|
|
25795
25812
|
}
|
|
25813
|
+
function summarizeJobs(results, o) {
|
|
25814
|
+
const state = o.uninstall ? "not installed" : "installed";
|
|
25815
|
+
const mark3 = o.dryRun ? " (dry run, not applied)" : "";
|
|
25816
|
+
const line = (r) => {
|
|
25817
|
+
if (o.dryRun) return `would ${o.uninstall ? "remove" : "install"} ${r.job} via ${r.mechanism} for ${o.host}${mark3}`;
|
|
25818
|
+
if (r.action === "unchanged") return `${r.job} already ${state} (${r.mechanism})`;
|
|
25819
|
+
return `${r.action} ${r.job} via ${r.mechanism} for ${o.host}`;
|
|
25820
|
+
};
|
|
25821
|
+
if (o.dryRun || o.verbose) return results.map(line);
|
|
25822
|
+
const lines2 = results.filter((r) => r.action !== "unchanged").map(line);
|
|
25823
|
+
const same2 = results.filter((r) => r.action === "unchanged");
|
|
25824
|
+
if (same2.length > 0) {
|
|
25825
|
+
const names = same2.map((r) => r.job).join(", ");
|
|
25826
|
+
lines2.push(same2.length === results.length ? `all ${same2.length} jobs already ${state} (${names})` : `${same2.length} job${same2.length === 1 ? "" : "s"} already ${state} (${names})`);
|
|
25827
|
+
}
|
|
25828
|
+
return lines2;
|
|
25829
|
+
}
|
|
25796
25830
|
|
|
25797
25831
|
// src/agents-sync-run.ts
|
|
25798
25832
|
async function runAgentsSync(target, o) {
|
|
@@ -26554,6 +26588,59 @@ function planSampleTicket(i) {
|
|
|
26554
26588
|
};
|
|
26555
26589
|
}
|
|
26556
26590
|
|
|
26591
|
+
// src/snapshot-staleness.ts
|
|
26592
|
+
var SNAPSHOT_TABLES = [
|
|
26593
|
+
{ key: "periscopesModelId", name: "Periscopes" },
|
|
26594
|
+
{ key: "shipsModelId", name: "Ships" },
|
|
26595
|
+
{ key: "epicsModelId", name: "Epics" },
|
|
26596
|
+
{ key: "locksModelId", name: "Locks" },
|
|
26597
|
+
{ key: "reposModelId", name: "Repos" },
|
|
26598
|
+
{ key: "areaModelId", name: "Projects" }
|
|
26599
|
+
];
|
|
26600
|
+
var same = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
26601
|
+
function liveReleaseSeat(crew, shipRowId) {
|
|
26602
|
+
if (!shipRowId) return void 0;
|
|
26603
|
+
const idOf = (v) => typeof v === "string" ? v : v && typeof v === "object" ? v.id : void 0;
|
|
26604
|
+
return crew.find((r) => idOf(r.ship_id) === shipRowId && (r.name ?? "").toLowerCase().includes("release"))?.id;
|
|
26605
|
+
}
|
|
26606
|
+
function compareSnapshot(resolved, live2) {
|
|
26607
|
+
const added = [];
|
|
26608
|
+
const removed = [];
|
|
26609
|
+
for (const t of SNAPSHOT_TABLES) {
|
|
26610
|
+
const have = resolved[t.key];
|
|
26611
|
+
const now = live2.models.find((m) => same(m.name, t.name))?.id;
|
|
26612
|
+
if (now && !have) added.push(t.name);
|
|
26613
|
+
else if (have && now !== have) removed.push(t.name);
|
|
26614
|
+
}
|
|
26615
|
+
return {
|
|
26616
|
+
added,
|
|
26617
|
+
removed,
|
|
26618
|
+
releaseSeatNew: !resolved.releaseSeat && !!live2.releaseSeat,
|
|
26619
|
+
shipRowLacksMachineId: live2.shipRowHasMachineId === false
|
|
26620
|
+
};
|
|
26621
|
+
}
|
|
26622
|
+
var isStale = (d) => d.added.length > 0 || d.removed.length > 0 || d.releaseSeatNew || d.shipRowLacksMachineId;
|
|
26623
|
+
function snapshotAge(connectedAt, now = /* @__PURE__ */ new Date()) {
|
|
26624
|
+
if (!connectedAt) return "unknown (connected before connectedAt was recorded)";
|
|
26625
|
+
const ms3 = now.getTime() - Date.parse(connectedAt);
|
|
26626
|
+
if (!Number.isFinite(ms3) || ms3 < 0) return "unknown";
|
|
26627
|
+
const units = [["day", 864e5], ["hour", 36e5], ["minute", 6e4]];
|
|
26628
|
+
for (const [u, size] of units) {
|
|
26629
|
+
const n = Math.floor(ms3 / size);
|
|
26630
|
+
if (n >= 1) return `${n} ${u}${n === 1 ? "" : "s"}`;
|
|
26631
|
+
}
|
|
26632
|
+
return "just now";
|
|
26633
|
+
}
|
|
26634
|
+
function staleSnapshotMessage(route2, d) {
|
|
26635
|
+
if (!isStale(d)) return void 0;
|
|
26636
|
+
const parts = [];
|
|
26637
|
+
if (d.added.length) parts.push(`new in the workspace: ${d.added.join(", ")}`);
|
|
26638
|
+
if (d.removed.length) parts.push(`no longer in the workspace: ${d.removed.join(", ")}`);
|
|
26639
|
+
if (d.releaseSeatNew) parts.push("this ship's Release seat row exists");
|
|
26640
|
+
if (d.shipRowLacksMachineId) parts.push("the Ships row has no machine_id (it predates machine ids; connect writes it)");
|
|
26641
|
+
return `${route2}: the connect snapshot for this route is out of date (${parts.join("; ")}) \u2014 run \`crew connect ${route2}\` then \`crew reload\` (or \`crew doctor ${route2} --fix\`)`;
|
|
26642
|
+
}
|
|
26643
|
+
|
|
26557
26644
|
// src/doctor-report.ts
|
|
26558
26645
|
var DOCTOR_SECTIONS = [
|
|
26559
26646
|
{ id: "ship", title: "Ship" },
|
|
@@ -27159,7 +27246,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
27159
27246
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
27160
27247
|
import { join as join58 } from "path";
|
|
27161
27248
|
function builtVersion() {
|
|
27162
|
-
return true ? "0.150.
|
|
27249
|
+
return true ? "0.150.2" : null;
|
|
27163
27250
|
}
|
|
27164
27251
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
27165
27252
|
function newestMtime(path) {
|
|
@@ -30252,33 +30339,33 @@ if (command === "passenger-sync-daemon") {
|
|
|
30252
30339
|
async function installScheduler(opts = {}) {
|
|
30253
30340
|
const host = hostPlatform();
|
|
30254
30341
|
if (host === "windows") {
|
|
30255
|
-
|
|
30256
|
-
process.exit(2);
|
|
30342
|
+
die("crew install", "no scheduler support yet for Windows (Task Scheduler is planned, not built)", "run `crew daemon` in a terminal instead");
|
|
30257
30343
|
}
|
|
30344
|
+
const installLog = {
|
|
30345
|
+
emit: (m) => emit.note(m),
|
|
30346
|
+
warn: (m) => emit.warn(withFix(`crew install: ${m}`, "`crew doctor`"))
|
|
30347
|
+
};
|
|
30258
30348
|
if (host === "macos") {
|
|
30259
30349
|
const ok = clearForeignLaunchdUnits(CREW_HOME, !!opts.replace, dryRun, {
|
|
30260
|
-
|
|
30261
|
-
|
|
30262
|
-
warn: (m) =>
|
|
30263
|
-
`)
|
|
30350
|
+
// A removed foreign unit is a real change, so it is shown by default.
|
|
30351
|
+
emit: (m) => emit.emit(m),
|
|
30352
|
+
warn: (m) => emit.warn(withFix(`crew install: ${m}`, "`crew install --replace`"))
|
|
30264
30353
|
}, void 0, loadedCrewLabels());
|
|
30265
30354
|
if (!ok) return false;
|
|
30266
30355
|
}
|
|
30267
30356
|
const installPathProblem = cfg.routes.some((r) => r.enabled && r.hostPassengers) ? dockerPathProblem(cfg.ship) : void 0;
|
|
30268
30357
|
if (installPathProblem) {
|
|
30269
|
-
|
|
30270
|
-
`);
|
|
30358
|
+
emit.error(withFix(`crew install: Host Passengers is on but ${installPathProblem}`, "`crew doctor`"));
|
|
30271
30359
|
process.exitCode = 1;
|
|
30272
30360
|
} else if (!dryRun && cfg.routes.some((r) => r.enabled && r.hostPassengers) && dockerAvailable()) {
|
|
30273
30361
|
const image = passengerImageRef(cfg);
|
|
30274
30362
|
if (imagePresent(image)) {
|
|
30275
|
-
|
|
30276
|
-
`);
|
|
30363
|
+
emit.note(`Host Passengers image ${image} is already present`);
|
|
30277
30364
|
} else {
|
|
30278
|
-
|
|
30279
|
-
`);
|
|
30365
|
+
emit.note(`pulling Host Passengers image ${image}`);
|
|
30280
30366
|
try {
|
|
30281
30367
|
ensureImage(image);
|
|
30368
|
+
emit.emit(`pulled Host Passengers image ${image}`);
|
|
30282
30369
|
} catch (e) {
|
|
30283
30370
|
emit.warn(withFix(`crew install: could not pull Host Passengers image ${image}: ${e.message}`, "`crew doctor`"));
|
|
30284
30371
|
process.exitCode = 1;
|
|
@@ -30286,24 +30373,24 @@ if (command === "passenger-sync-daemon") {
|
|
|
30286
30373
|
}
|
|
30287
30374
|
}
|
|
30288
30375
|
const hasSystemd = detectSystemd();
|
|
30376
|
+
const results = [];
|
|
30289
30377
|
for (const job of ["run", "release", "passengers"]) {
|
|
30290
30378
|
const plan = planInstall(cfg.ship, CREW_HOME, host, hasSystemd, job, installContext());
|
|
30291
|
-
|
|
30292
|
-
|
|
30293
|
-
|
|
30294
|
-
|
|
30295
|
-
|
|
30296
|
-
|
|
30297
|
-
|
|
30298
|
-
});
|
|
30379
|
+
emit.note(`installing ${job} via ${plan.mechanism} for ${host}${dryRun ? " (dry run)" : ""}`);
|
|
30380
|
+
try {
|
|
30381
|
+
const { action } = await applyInstall(plan, CREW_HOME, dryRun, installLog);
|
|
30382
|
+
results.push({ job, mechanism: plan.mechanism, action });
|
|
30383
|
+
} catch (e) {
|
|
30384
|
+
return die("crew install", e.message.replace(/^crew install:\s*/, ""), "`crew doctor`", 1);
|
|
30385
|
+
}
|
|
30299
30386
|
}
|
|
30387
|
+
for (const l of summarizeJobs(results, { dryRun, verbose: flag("verbose"), host })) emit.emit(l);
|
|
30300
30388
|
if (host === "linux" && hasSystemd) {
|
|
30301
30389
|
const label = labelFor(CREW_HOME, "run");
|
|
30302
30390
|
const staleTimer = join64(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
30303
30391
|
if (existsSync60(staleTimer)) {
|
|
30304
|
-
|
|
30305
|
-
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
|
|
30306
|
-
`
|
|
30392
|
+
emit.emit(
|
|
30393
|
+
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run, not applied)" : ""}`
|
|
30307
30394
|
);
|
|
30308
30395
|
if (!dryRun) {
|
|
30309
30396
|
spawnSync14("systemctl", ["--user", "disable", "--now", `${label}.timer`], { cwd: CREW_HOME, env: withUserBusEnv() });
|
|
@@ -30316,6 +30403,27 @@ if (command === "passenger-sync-daemon") {
|
|
|
30316
30403
|
}
|
|
30317
30404
|
return true;
|
|
30318
30405
|
}
|
|
30406
|
+
async function snapshotDiffFor(c) {
|
|
30407
|
+
const r = c.resolved;
|
|
30408
|
+
if (!r?.projectId || flag("offline")) return void 0;
|
|
30409
|
+
try {
|
|
30410
|
+
const models = await get(
|
|
30411
|
+
{ baseUrl: c.baseUrl, apiKey: resolveApiKey(c), userAgent: cfg.ship.userAgent },
|
|
30412
|
+
`/data-models?projectId=${r.projectId}`
|
|
30413
|
+
);
|
|
30414
|
+
const tracker = new Tracker(c, cfg.ship);
|
|
30415
|
+
const [ships, crew] = await Promise.all([tracker.shipRows(), tracker.crewRows()]);
|
|
30416
|
+
const matched = matchShipRows(ships, cfg.ship.name, doctorMachineId(cfg.ship.stateDir));
|
|
30417
|
+
const row = matched.rows.length === 1 ? matched.rows[0] : void 0;
|
|
30418
|
+
return compareSnapshot(r, {
|
|
30419
|
+
models,
|
|
30420
|
+
releaseSeat: liveReleaseSeat(crew, row?.id),
|
|
30421
|
+
shipRowHasMachineId: row && matched.hasColumn ? matched.by === "machine_id" : void 0
|
|
30422
|
+
});
|
|
30423
|
+
} catch {
|
|
30424
|
+
return void 0;
|
|
30425
|
+
}
|
|
30426
|
+
}
|
|
30319
30427
|
async function routeProblems(c) {
|
|
30320
30428
|
const host = hostPlatform();
|
|
30321
30429
|
const problems = [];
|
|
@@ -30352,7 +30460,8 @@ if (command === "passenger-sync-daemon") {
|
|
|
30352
30460
|
problems.push(`tracker unreachable: ${e instanceof Error ? e.message : String(e)}`);
|
|
30353
30461
|
}
|
|
30354
30462
|
if (await tracker.eventLogTracksStatus() === false) problems.push(EVENT_LOG_STATUS_UNTRACKED(tracker.contract.columns.status));
|
|
30355
|
-
|
|
30463
|
+
const diff = await snapshotDiffFor(c);
|
|
30464
|
+
return { problems, readiness, snapshotStale: !!diff && isStale(diff) };
|
|
30356
30465
|
}
|
|
30357
30466
|
async function doctorShipKind(route3, ship) {
|
|
30358
30467
|
try {
|
|
@@ -30381,7 +30490,19 @@ if (command === "passenger-sync-daemon") {
|
|
|
30381
30490
|
const enabledSound = new Set(routes.filter((r) => r.enabled && r.hasRepos && r.problems.length === 0).map((r) => r.route));
|
|
30382
30491
|
try {
|
|
30383
30492
|
for (const a of plan.actions) {
|
|
30384
|
-
if (a.kind === "
|
|
30493
|
+
if (a.kind === "refresh-snapshot") {
|
|
30494
|
+
if (prompter && !await prompter.confirm(`${a.route}: the connect snapshot is out of date \u2014 run \`crew connect ${a.route}\` and reload the daemon?`, true)) continue;
|
|
30495
|
+
const self = selfLaunch();
|
|
30496
|
+
const run4 = (args) => spawnSync14(self.command, [...self.args, ...args], { stdio: "inherit", cwd: process.cwd(), env: process.env });
|
|
30497
|
+
const conn = run4(["connect", a.route]);
|
|
30498
|
+
if (conn.status !== 0) {
|
|
30499
|
+
process.stdout.write(`fix: crew connect ${a.route} exited ${conn.status ?? "abnormally"} \u2014 snapshot not refreshed
|
|
30500
|
+
`);
|
|
30501
|
+
continue;
|
|
30502
|
+
}
|
|
30503
|
+
const rel = run4(["reload"]);
|
|
30504
|
+
changed2.push(`refreshed the connect snapshot for ${a.route} (\`crew connect\`)${rel.status === 0 ? " and reloaded the daemon" : "; `crew reload` failed \u2014 run it by hand"}`);
|
|
30505
|
+
} else if (a.kind === "enable") {
|
|
30385
30506
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
30386
30507
|
writeFileSync44(cfg.configFile, planEnable(readFileSync56(cfg.configFile, "utf8"), a.route));
|
|
30387
30508
|
enabledSound.add(a.route);
|
|
@@ -33131,6 +33252,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
33131
33252
|
seats: found.seats,
|
|
33132
33253
|
holds: found.holds.map((h) => ({ id: h.id, role: h.name })),
|
|
33133
33254
|
...found.releaseSeat ? { releaseSeat: found.releaseSeat } : {},
|
|
33255
|
+
connectedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
33134
33256
|
...found.role ?? previous?.role ? { role: found.role ?? previous?.role } : {},
|
|
33135
33257
|
...capabilityMisses.length > 0 ? { capabilityMisses } : {},
|
|
33136
33258
|
...operator ? { operator } : {},
|
|
@@ -34617,28 +34739,26 @@ ${where.join("\n")}`);
|
|
|
34617
34739
|
case "uninstall": {
|
|
34618
34740
|
const host = hostPlatform();
|
|
34619
34741
|
if (host === "windows") {
|
|
34620
|
-
|
|
34742
|
+
emit.emit("nothing installed on Windows");
|
|
34621
34743
|
break;
|
|
34622
34744
|
}
|
|
34745
|
+
const uninstallLog = {
|
|
34746
|
+
emit: (m) => emit.note(m),
|
|
34747
|
+
warn: (m) => emit.warn(withFix(`crew uninstall: ${m}`, "`crew doctor`"))
|
|
34748
|
+
};
|
|
34749
|
+
const results = [];
|
|
34623
34750
|
for (const job of ["run", "release", "passengers"]) {
|
|
34624
34751
|
const plan = planUninstall(cfg.ship, CREW_HOME, host, detectSystemd(), job);
|
|
34625
|
-
|
|
34626
|
-
|
|
34627
|
-
|
|
34628
|
-
emit: (m) => process.stdout.write(`${m}
|
|
34629
|
-
`),
|
|
34630
|
-
warn: (m) => process.stderr.write(`crew uninstall: ${m}
|
|
34631
|
-
`)
|
|
34632
|
-
});
|
|
34752
|
+
emit.note(`uninstalling ${job} ${plan.mechanism} for ${host}${dryRun ? " (dry run)" : ""}`);
|
|
34753
|
+
const { changed: changed2 } = await applyUninstall(plan, CREW_HOME, dryRun, uninstallLog);
|
|
34754
|
+
results.push({ job, mechanism: plan.mechanism, action: changed2 ? "removed" : "unchanged" });
|
|
34633
34755
|
}
|
|
34756
|
+
for (const l of summarizeJobs(results, { uninstall: true, dryRun, verbose: flag("verbose"), host })) emit.emit(l);
|
|
34634
34757
|
if (flag("all") && host === "macos") {
|
|
34635
|
-
|
|
34636
|
-
`);
|
|
34758
|
+
emit.note(`uninstalling every crew launchd unit${dryRun ? " (dry run)" : ""}`);
|
|
34637
34759
|
removeAllLaunchdUnits(dryRun, {
|
|
34638
|
-
emit: (m) =>
|
|
34639
|
-
|
|
34640
|
-
warn: (m) => process.stderr.write(`crew uninstall: ${m}
|
|
34641
|
-
`)
|
|
34760
|
+
emit: (m) => emit.emit(m),
|
|
34761
|
+
warn: uninstallLog.warn
|
|
34642
34762
|
}, void 0, loadedCrewLabels());
|
|
34643
34763
|
}
|
|
34644
34764
|
break;
|
|
@@ -35256,10 +35376,13 @@ ${where.join("\n")}`);
|
|
|
35256
35376
|
}
|
|
35257
35377
|
const previewProblem2 = await previewHostProblem(cfg);
|
|
35258
35378
|
if (previewProblem2) problems.push(previewHostFinding(previewProblem2));
|
|
35379
|
+
const jsonDiff = await snapshotDiffFor(route2);
|
|
35380
|
+
const jsonStale = jsonDiff ? staleSnapshotMessage(route2.route, jsonDiff) : void 0;
|
|
35381
|
+
if (jsonStale) problems.push({ severity: "attention", kind: "connect_snapshot_stale", route: route2.route, message: jsonStale, remedy: `crew connect ${route2.route} && crew reload` });
|
|
35259
35382
|
if (cfg.routes.some((x) => x.route === route2.route && x.enabled && x.hostPeriscopes)) {
|
|
35260
35383
|
const { settled } = await settleRepos(reposOf(route2), (t) => t.name, (t) => resolveOneRepo(route2, t));
|
|
35261
35384
|
const tablePresent = flag("offline") ? void 0 : (await new Tracker(route2, cfg.ship).periscopesStatus().catch(() => ({ present: true }))).present;
|
|
35262
|
-
problems.push(...routePeriscopeProblems({ route: route2.route, hosts: true, repos: settled.map((r) => ({ name: r.name, hasPreviewHook: !!r.config.hooks.preview })), tablePresent }));
|
|
35385
|
+
problems.push(...routePeriscopeProblems({ route: route2.route, hosts: true, repos: settled.map((r) => ({ name: r.name, hasPreviewHook: !!r.config.hooks.preview })), tablePresent, snapshotStale: !!jsonDiff && isStale(jsonDiff) }));
|
|
35263
35386
|
if (!flag("offline")) problems.push(...await duplicateLivePeriscopeProblems(route2, cfg.ship));
|
|
35264
35387
|
}
|
|
35265
35388
|
problems.push(...attentionProblems(openShipAttention(state), problems));
|
|
@@ -35471,12 +35594,20 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
35471
35594
|
`
|
|
35472
35595
|
);
|
|
35473
35596
|
const periscopes = await tracker.periscopesStatus();
|
|
35597
|
+
const snapDiff = await snapshotDiffFor(route2);
|
|
35598
|
+
const snapStale = !!snapDiff && isStale(snapDiff);
|
|
35599
|
+
const offlineNote = flag("offline") ? " (from the last connect; not checked against the workspace under --offline)" : "";
|
|
35600
|
+
if (flag("verbose")) R.line(`connect snapshot: taken ${snapshotAge(route2.resolved?.connectedAt)} ago${offlineNote}
|
|
35601
|
+
`);
|
|
35602
|
+
if (snapDiff && snapStale) R.line(`connect snapshot: WARN ${staleSnapshotMessage(route2.route, snapDiff)}
|
|
35603
|
+
`);
|
|
35474
35604
|
if (cfg.routes.some((x) => x.route === route2.route && x.enabled && x.hostPeriscopes)) {
|
|
35475
35605
|
const { settled } = await settleRepos(reposOf(route2), (t) => t.name, (t) => resolveOneRepo(route2, t));
|
|
35476
35606
|
for (const f of routePeriscopeProblems({
|
|
35477
35607
|
route: route2.route,
|
|
35478
35608
|
hosts: true,
|
|
35479
|
-
tablePresent: periscopes.present,
|
|
35609
|
+
tablePresent: flag("offline") ? void 0 : periscopes.present,
|
|
35610
|
+
snapshotStale: snapStale,
|
|
35480
35611
|
repos: settled.map((r) => ({ name: r.name, hasPreviewHook: !!r.config.hooks.preview }))
|
|
35481
35612
|
})) {
|
|
35482
35613
|
R.line(`periscopes: ${f.severity.toUpperCase()} ${f.message}
|
|
@@ -35490,12 +35621,14 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
35490
35621
|
}
|
|
35491
35622
|
}
|
|
35492
35623
|
R.line(
|
|
35493
|
-
|
|
35624
|
+
snapStale && snapDiff.added.includes("Periscopes") ? "periscopes: Periscopes table is in the workspace but not in the connect snapshot \u2014 see the connect snapshot line above\n" : !periscopes.present ? `periscopes: ${flag("offline") ? `no Periscopes table in the snapshot${offlineNote}` : "Periscopes table absent \u2014 this workspace cannot host periscopes"}
|
|
35625
|
+
` : periscopes.missing.length === 0 ? `periscopes: Periscopes table present (${periscopes.modelId})
|
|
35494
35626
|
` : `periscopes: Periscopes table present (${periscopes.modelId}) but missing ${periscopes.missing.join(", ")} \u2014 update the Issues template
|
|
35495
35627
|
`
|
|
35496
35628
|
);
|
|
35497
35629
|
R.line(
|
|
35498
|
-
route2.resolved?.releaseSeat ? "release seat: this ship has its own Release Crew row\n" : "release seat:
|
|
35630
|
+
route2.resolved?.releaseSeat ? "release seat: this ship has its own Release Crew row\n" : snapDiff?.releaseSeatNew ? "release seat: the workspace has this ship's Release row but the connect snapshot does not \u2014 see the connect snapshot line above\n" : flag("offline") ? `release seat: none in the snapshot${offlineNote}
|
|
35631
|
+
` : "release seat: none \u2014 release comments are credited to the dev seat; run `crew connect` once the Crew table has this ship's row\n"
|
|
35499
35632
|
);
|
|
35500
35633
|
const keyRole = route2.resolved?.role ?? await fetchKeyRole(route2, cfg.ship.userAgent);
|
|
35501
35634
|
const roleRoute = route2.resolved && keyRole ? { ...route2, resolved: { ...route2.resolved, role: keyRole } } : route2;
|
package/package.json
CHANGED