@join-pantheon/cli 0.33.3 → 0.33.4-rc.1
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/accounts.js +53 -0
- package/dist/board.js +1 -2
- package/dist/cli.js +183 -22
- package/dist/config.js +2 -1
- package/dist/disk-writer.js +404 -0
- package/dist/doctor.js +6 -3
- package/dist/ledger.js +31 -14
- package/dist/notifier.js +1 -1
- package/dist/quickstart.js +18 -6
- package/dist/recover-offer.js +125 -0
- package/dist/relay.js +258 -74
- package/dist/roster-file.js +11 -6
- package/dist/store.js +28 -7
- package/dist/team-name.js +58 -0
- package/dist/tray.js +5 -0
- package/dist/worker.js +5 -3
- package/helper/macos/main.swift +5 -3
- package/helper/macos/prebuilt/manifest.json +3 -3
- package/helper/macos/prebuilt/pantheon-hud +0 -0
- package/installer/install.ps1 +12 -2
- package/installer/install.sh +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { pantheonCommand } from "./onboard-defaults.js";
|
|
2
|
+
import { CMD_SPECIAL, looksLikePlaceholder, shellArg, TEAM_NAME } from "./team-name.js";
|
|
3
|
+
export const RECOVER_WAITING_EXIT = 3;
|
|
4
|
+
let lines = { launcher: null, platform: process.platform };
|
|
5
|
+
export function configureLines(o) {
|
|
6
|
+
lines = { launcher: o.launcher ?? null, platform: o.platform ?? process.platform };
|
|
7
|
+
}
|
|
8
|
+
const movable = (s) => s.state === "movable" || s.state === "ready";
|
|
9
|
+
export function seatsToMove(seats) {
|
|
10
|
+
return seats.filter((s) => movable(s) && s.in_use !== true && !looksLikePlaceholder(s.space));
|
|
11
|
+
}
|
|
12
|
+
export function strayTeamSeats(seats) {
|
|
13
|
+
return seats.filter((s) => movable(s) && s.in_use !== true && looksLikePlaceholder(s.space));
|
|
14
|
+
}
|
|
15
|
+
export function strayLine(s) {
|
|
16
|
+
return `You also have a seat in ${s.space}, a team named like an example's placeholder — likely made by mistake. To clear it: ${recoverCommand(s.space)}, then ${pantheonCommand(lines.launcher, `space delete ${shellArg(s.space, lines.platform)} --yes`, lines.platform)}`;
|
|
17
|
+
}
|
|
18
|
+
export function seatsForTeam(seats, team) {
|
|
19
|
+
return seats.filter((s) => s.space.toLowerCase() === team.toLowerCase());
|
|
20
|
+
}
|
|
21
|
+
export function seatsInUse(seats) {
|
|
22
|
+
return seats.filter((s) => movable(s) && s.in_use === true);
|
|
23
|
+
}
|
|
24
|
+
export function inUseLine(s) {
|
|
25
|
+
return `Your seat in ${s.space} is in use on another machine${s.in_use_label ? ` ("${s.in_use_label}")` : ""} right now. If you meant to move it here: ${recoverCommand(s.space)}`;
|
|
26
|
+
}
|
|
27
|
+
export const recoverCommand = (team) => {
|
|
28
|
+
const line = pantheonCommand(lines.launcher, `recover ${shellArg(team, lines.platform)}`, lines.platform);
|
|
29
|
+
return lines.platform === "win32" && !TEAM_NAME.test(team) && CMD_SPECIAL.test(team)
|
|
30
|
+
? `${line} (or use: ${pantheonCommand(lines.launcher, "recover", lines.platform)} — it lists your teams and asks which, by number)`
|
|
31
|
+
: line;
|
|
32
|
+
};
|
|
33
|
+
export const askedLine = (team) => `Asked: your seat in ${team} moves when a teammate confirms it (or in a day if nobody cancels). Then run ${recoverCommand(team)} here again to save it.`;
|
|
34
|
+
export function seatLine(s) {
|
|
35
|
+
return s.state === "ready"
|
|
36
|
+
? `Your seat in ${s.space} has moved to this machine and is not saved here yet. Save it: ${recoverCommand(s.space)}`
|
|
37
|
+
: `You already have a seat in ${s.space}, on another of your devices (${s.fp})${s.founder ? " — you founded it" : ""}. Move it to this machine: ${recoverCommand(s.space)}` +
|
|
38
|
+
(s.alone ? "" : " (a teammate confirms it, or it moves after a day)");
|
|
39
|
+
}
|
|
40
|
+
export const alreadyMemberLine = (team) => `You're already a member of ${team}. On this machine run: ${recoverCommand(team)}`;
|
|
41
|
+
export async function fetchSeats(get) {
|
|
42
|
+
try {
|
|
43
|
+
const r = await get();
|
|
44
|
+
if (r.status !== 200 || !Array.isArray(r.j.seats))
|
|
45
|
+
return null;
|
|
46
|
+
return r.j.seats.filter((x) => !!x && typeof x.space === "string" && typeof x.state === "string");
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export async function offerSeats(seats, deps) {
|
|
53
|
+
const offered = seatsToMove(seats);
|
|
54
|
+
const inUse = seatsInUse(seats);
|
|
55
|
+
const stray = strayTeamSeats(seats);
|
|
56
|
+
const out = { offered, inUse, stray, moved: [], asked: [], declined: [] };
|
|
57
|
+
if (!offered.length && !inUse.length && !stray.length)
|
|
58
|
+
return out;
|
|
59
|
+
deps.log("");
|
|
60
|
+
for (const s of inUse)
|
|
61
|
+
deps.log(` ${inUseLine(s)}`);
|
|
62
|
+
for (const s of stray)
|
|
63
|
+
deps.log(` ${strayLine(s)}`);
|
|
64
|
+
if (!offered.length)
|
|
65
|
+
return out;
|
|
66
|
+
for (const s of offered)
|
|
67
|
+
deps.log(` ${seatLine(s)}`);
|
|
68
|
+
if (!deps.tty) {
|
|
69
|
+
deps.log(` A coding agent setting Pantheon up here runs ${offered.length === 1 ? "that" : "those"} before \`pantheon start\`, never a new team in ${offered.length === 1 ? "its" : "their"} place.`);
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
for (const s of offered) {
|
|
73
|
+
const a = ((await deps.ask(` Move your seat in ${s.space} to this machine now? [Y/n] `)) ?? "n").trim().toLowerCase();
|
|
74
|
+
if (a === "" || a === "y" || a === "yes") {
|
|
75
|
+
const code = await deps.recover(s.space);
|
|
76
|
+
if (code === 0)
|
|
77
|
+
out.moved.push(s.space);
|
|
78
|
+
else if (code === RECOVER_WAITING_EXIT) {
|
|
79
|
+
out.asked.push(s.space);
|
|
80
|
+
deps.log(` ${askedLine(s.space)}`);
|
|
81
|
+
}
|
|
82
|
+
else
|
|
83
|
+
out.declined.push(s.space);
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
out.declined.push(s.space);
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
export async function startGate(o) {
|
|
91
|
+
const asked = o.asked ?? [];
|
|
92
|
+
const waiting = seatsToMove(o.seats).filter((s) => !o.moved.includes(s.space) && !asked.includes(s.space));
|
|
93
|
+
if (o.named) {
|
|
94
|
+
const mine = o.seats.find((s) => s.space.toLowerCase() === o.named.toLowerCase());
|
|
95
|
+
if (mine && o.moved.includes(mine.space))
|
|
96
|
+
return { go: false, code: 0, lines: [`${mine.space} is on this machine now — no new team was created.`] };
|
|
97
|
+
if (mine && asked.includes(mine.space))
|
|
98
|
+
return { go: false, code: RECOVER_WAITING_EXIT, lines: [`${askedLine(mine.space)} No new team was created.`] };
|
|
99
|
+
if (mine)
|
|
100
|
+
return { go: false, code: 1, lines: [alreadyMemberLine(mine.space)] };
|
|
101
|
+
return { go: true };
|
|
102
|
+
}
|
|
103
|
+
if ((o.moved.length || asked.length) && !waiting.length) {
|
|
104
|
+
return { go: false, code: o.moved.length ? 0 : RECOVER_WAITING_EXIT, lines: [
|
|
105
|
+
...(o.moved.length ? [`${o.moved.join(", ")} ${o.moved.length === 1 ? "is" : "are"} on this machine now.`] : []),
|
|
106
|
+
...asked.map(askedLine),
|
|
107
|
+
`No new team was created. To make one as well: pantheon start --space <its-real-name>`,
|
|
108
|
+
] };
|
|
109
|
+
}
|
|
110
|
+
if (!waiting.length || o.newTeam)
|
|
111
|
+
return { go: true };
|
|
112
|
+
const how = waiting.map((s) => ` ${recoverCommand(s.space)}`);
|
|
113
|
+
if (!o.tty) {
|
|
114
|
+
return { go: false, code: 1, lines: [
|
|
115
|
+
`not creating a new team: this account already has a seat in ${waiting.map((s) => s.space).join(", ")}. Bring it to this machine instead:`,
|
|
116
|
+
...how,
|
|
117
|
+
` A new team as well, on purpose: pantheon start --space <its-real-name> --new-team (ask the person for the name — never make one up)`,
|
|
118
|
+
] };
|
|
119
|
+
}
|
|
120
|
+
const a = ((await o.ask(` Create a new team anyway, instead of moving ${waiting.length === 1 ? "that seat" : "those seats"}? [y/N] `)) ?? "").trim().toLowerCase();
|
|
121
|
+
if (a === "y" || a === "yes")
|
|
122
|
+
return { go: true };
|
|
123
|
+
return { go: false, code: 0, lines: ["no new team was created. When you're ready:", ...how] };
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=recover-offer.js.map
|