Versions 53 to 318
new file, 143 lines
1+// The --server flag (abso-core issue 10). Every command that talks to a server takes --server <url>, parsed and
3+// - A command that works on a joined folder ("folder") talks only to that folder's server. --server there must
4+// name that same server; another one is refused, never swapped in, so the folder's work and key never go to
5+// a server it wasn't joined on. Outside a joined folder it is refused too, with how to join one there.
6+// - A command that picks a server for itself ("chosen": join, init, login, whoami and the rest about this box)
9+// A value that isn't an http or https URL (a user name, a query or a fragment included) is refused before any
12+// When nothing names a server (abso-core issue 9), every command picks it in one order (chooseServer):
17+// Which servers this box is signed in to plays no part: signed in to staging and prod both, or to staging
18+// alone, a command with nothing named goes to prod, and staging is a deliberate --server, folder or ABSO_SERVER.
19+
25+
28+
31+
33+export const SERVER_ORDER = `--server <url>, else the server of the abso folder you're in, else ABSO_SERVER, else prod (${PROD_SERVER})`;
34+
36+ * The server a command goes to: `flag` (checked by serverFlag), else the joined folder's, else ABSO_SERVER
37+ * (checked here), else prod. An explicit choice is returned as given, never swapped for another.
48+ if (named !== undefined) return checkedServer(named, env.ABSO_SERVER ? "ABSO_SERVER" : "AVCS_SERVER");
51+
65+
67+const LOCAL: ReadonlySet<string> = new Set(["skill", "check-ignore", "pause", "resume", "fix-eol"]);
68+
73+
75+
82+ `${from} takes an http or https URL with no user name, query or fragment, like ${EXAMPLE} (got ${JSON.stringify(value)})`,
86+
92+
93+/** Whether two servers are the same one: the same scheme, host, port and path, ignoring case and a trailing slash. */
97+
98+/** The server in the .abso/config.json of the folder `cwd` is in, or undefined outside one (or when it can't be read). */
103+ const server = (JSON.parse(readFileSync(configPath(root), "utf8")) as { server?: unknown }).server;
109+
111+ * For a command that works on a joined folder: refuses a --server that isn't the folder's own server, and one
118+ `abso ${command} works on a joined folder, and ${cwd} isn't in one. To work with ${flag}: abso join <project> --server ${flag}, or abso init --server ${flag} for a new project.`,
122+ `this folder is joined on ${own}, not ${flag}, so abso ${command} won't send its work or key there. Run it in a folder joined on ${flag} (abso join <project> --server ${flag}).`,
125+
132+ return "--server <url>: this folder's own server, which it uses anyway. Another server is refused, never swapped in, so the folder's work and key go only to the server it was joined on.";
135+ ? "--server <url>: the server the key is for; without it, this folder's. It is used as given, never swapped for another."
136+ : `--server <url>: the server to use, as given, never swapped for another. The order: ${SERVER_ORDER}. This box's sign-in for one server is never sent to another.`;
139+
142+ return `abso ${command} works on this machine only and talks to no server, so it takes no --server`;
- MCP
- compare on this site's /mcp
- CLI
- abso diff 53 318 client/src/server-choice.ts --json
- JSON
- /christopher/abso-core/compare/53..318?file=client%2Fsrc%2Fserver-choice.ts&format=json