@ubercode/channelvault 0.3.0-rc.5 → 0.3.0-rc.6

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/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to `@ubercode/channelvault` are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the version follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
4
 
5
+ ## [0.3.0-rc.6] — 2026-11-27
6
+
7
+ Release candidate, published under the npm `next` tag.
8
+
9
+ ### Security
10
+
11
+ - **Configuration-map values that Mirth returns as booleans or numbers are now secrets too** ([#30](https://github.com/MichaelLeeHobbs/channelvault/issues/30)). Mirth's JSON answers a stored value such as `true` or `1234` as a JSON boolean or number, and `pull` used to write those into `server/configuration.json` as literals, so a numeric PIN or password landed in git. A key Mirth answers as a number or boolean (`8443`) had the same problem for its value, whatever that value's type, and could not be named in `push --config-map-key`. They now become `{{env:CONFIG_MAP__…}}` placeholders with the value in the env file, `diff` redacts them, and a key push followed by `diff` is clean without a re-pull. Re-pull a tree pulled before this change to move such values out of it, and check your git history for any that were committed.
12
+
13
+ ### Added
14
+
15
+ - **`profile set <name>`** changes a saved profile's `--dotenv`, `--user` or `--port` without hand-editing `profiles.json` ([#29](https://github.com/MichaelLeeHobbs/channelvault/issues/29)). It runs only at a terminal, checks the env file as `profile add` does, logs in before saving a new user (asking for its password) or port, and never changes `serverId` or the TLS pin.
16
+ - **`profile remove <name>`** removes a profile and its line in the credentials file after you confirm, at a terminal. The profile's env file is kept.
17
+
18
+ ### Changed
19
+
20
+ - `profile add` and `profile set` refuse a `--dotenv` that git would commit (inside a repository and not ignored, including in a folder that doesn't exist yet) or that is a folder; `[profile-invalid]`.
21
+ - The `[profile-exists]` hint names `profile set` and `profile remove` instead of editing `profiles.json`. `diff`'s `[env-missing]`/`[env-incomplete]` hint names `profile set <name> --dotenv`, and a `pull` with a profile that has no `dotenv` into a tree with no `.env` says so and names the same command.
22
+
5
23
  ## [0.3.0-rc.5] — 2026-11-27
6
24
 
7
25
  Release candidate, published under the npm `next` tag.
@@ -138,6 +156,7 @@ First release. Tested against Mirth Connect 4.5.2; the offline round trip is als
138
156
  - `backup` / `restore`: the server's own configuration XML saved as `.backup/<server>-<UTC time>.xml`, identified by Mirth's server ID, restored with a preview, an undo backup and a version check. `push` backs up first unless `--no-backup`.
139
157
  - `diff` exits 0 when the tree matches the server, 1 when it differs, 2 on error.
140
158
 
159
+ [0.3.0-rc.6]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.3.0-rc.6
141
160
  [0.3.0-rc.5]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.3.0-rc.5
142
161
  [0.3.0-rc.4]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.3.0-rc.4
143
162
  [0.3.0-rc.3]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.3.0-rc.3
package/README.md CHANGED
@@ -77,7 +77,7 @@ channelvault diff <dir> # tree vs live server
77
77
  channelvault status <dir> # summary of a tree
78
78
  channelvault backup # live server -> ~/.channelvault/backups/<server>-<UTC time>.xml
79
79
  channelvault restore [file] # backup -> live server (default: newest of this server)
80
- channelvault profile list|add|set-password|check|repin # saved connections (see Connection profiles)
80
+ channelvault profile list|add|set|set-password|remove|check|repin # saved connections (see Connection profiles)
81
81
  ```
82
82
 
83
83
  `channelvault <command> --help` lists the flags. The server connection comes from a saved profile (`--profile`, `MIRTH_PROFILE`, or the profile matching the tree), or from the login flags and `MIRTH_HOST`, `MIRTH_PORT`, `MIRTH_USER`, `MIRTH_PASS`; see [Connection profiles](#connection-profiles). Errors start with a reason code in brackets, such as `error: [profile-not-typed] …`, for scripts and agents to route on.
@@ -107,7 +107,8 @@ channelvault push ./mirth --profile gov # writes: the profile must be typ
107
107
  ```
108
108
 
109
109
  - **Files.** `~/.channelvault/profiles.json` holds `host`, `port`, `user`, `https`, `insecure`, `tlsFingerprint`, `serverId` and `dotenv` (an absolute path) for each named profile, and no secrets. `~/.channelvault/credentials` holds one `name=password` line per profile, readable by its owner only; nothing in the process environment can override it. `CHANNELVAULT_CONFIG_DIR` moves the folder, but is refused inside a git work tree. Unknown fields are refused by name, and a `password` field is refused with a pointer to `profile set-password`.
110
- - **Adding one.** `profile add` runs only at a terminal. It shows the host and the certificate's SHA-256 fingerprint, asks you to confirm them, asks for the password (8 characters at least, never echoed), logs in, and records the server's installation ID as `serverId`. `profile set-password <name>` changes the password after logging in with it, `profile list [--json]` shows the profiles without passwords, and `profile check [name] [--json]` logs in with each one and verifies its certificate and installation (exit 1 if any fails).
110
+ - **Adding one.** `profile add` runs only at a terminal. It shows the host and the certificate's SHA-256 fingerprint, asks you to confirm them, asks for the password (8 characters at least, never echoed), logs in, and records the server's installation ID as `serverId`. A `--dotenv` must be absolute after resolving, not shared with another profile, and ignored by git if it is inside a repository. `profile set-password <name>` changes the password after logging in with it, `profile list [--json]` shows the profiles without passwords, and `profile check [name] [--json]` logs in with each one and verifies its certificate and installation (exit 1 if any fails).
111
+ - **Changing or removing one.** Don't edit `profiles.json` by hand: it also holds the pin and the installation. `profile set <name> --dotenv <path>` gives a profile an env file, with the same checks as `profile add`; it doesn't move values from another env file, so move them yourself. `--user` or `--port` log in before saving, so the profile must still reach the same installation and certificate: `--user` asks for that user's password, and so does `--port` on a profile that doesn't check certificates (plain http or `insecure`), so a different local server never receives the stored one. `profile set` never changes `serverId` or the pin: `profile repin` and a new `profile add` do. `profile remove <name>` asks for confirmation, then removes the profile and its line in the credentials file; its env file is kept. `profile set` and `profile remove` run only at a terminal, and save nothing if another process changed the profile meanwhile (`[profile-changed]`). A pull with a profile that has no `dotenv` into a tree with no `.env` names `profile set <name> --dotenv`, because the values then live only in that checkout.
111
112
  - **Which connection a command uses.** Exactly one source, never fields mixed from several, in this order:
112
113
  1. `--profile <name>`. Login or TLS flags beside it are refused.
113
114
  2. The login flags, starting with `--host`, with `MIRTH_*` filling what is not typed. A typed `--host` never borrows `MIRTH_PORT`, `MIRTH_USER`, `MIRTH_PASS` or `MIRTH_TLS_FINGERPRINT` exported for a different `MIRTH_HOST` (`[env-conflict]`). `--port`, `--user` or `--pass` without `--host` still reach `MIRTH_HOST`'s server, so they count as step 4.
package/dist/cli.js CHANGED
@@ -3,12 +3,13 @@
3
3
  // src/cli.ts
4
4
  import { spawnSync as spawnSync2 } from "child_process";
5
5
  import { cp, lstat as lstat4, mkdir as mkdir7, mkdtemp, readdir as readdir6, readFile as readFile6, rm as rm4, writeFile as writeFile6 } from "fs/promises";
6
- import { existsSync as existsSync9 } from "fs";
6
+ import { existsSync as existsSync9, statSync } from "fs";
7
7
  import { tmpdir } from "os";
8
8
  import { createRequire } from "module";
9
9
  import * as path10 from "path";
10
10
  import { createInterface } from "readline/promises";
11
11
  import { Writable } from "stream";
12
+ import { isDeepStrictEqual } from "util";
12
13
  import { Command, CommanderError } from "commander";
13
14
 
14
15
  // src/explode/index.ts
@@ -1021,15 +1022,20 @@ function elementSegment(el, index) {
1021
1022
  return `[${index}]`;
1022
1023
  }
1023
1024
  function configMapKeyOf(entry) {
1024
- const key = entry["string"];
1025
- if (typeof key === "string") return key;
1026
- return Array.isArray(key) && typeof key[0] === "string" ? key[0] : void 0;
1025
+ const raw = entry["string"];
1026
+ const key = Array.isArray(raw) ? raw[0] : raw;
1027
+ return typeof key === "string" || typeof key === "number" || typeof key === "boolean" ? String(key) : void 0;
1027
1028
  }
1028
1029
  function mapLeaves(config, visit) {
1029
1030
  const walk = (node, key, path11, labels, section, cmKey) => {
1030
1031
  if (typeof node === "string") {
1031
1032
  return visit(node, { location: path11.join("/"), key, labels, section, configMapKey: cmKey });
1032
1033
  }
1034
+ if ((typeof node === "number" || typeof node === "boolean") && cmKey !== void 0 && key === "value") {
1035
+ const text = String(node);
1036
+ const out = visit(text, { location: path11.join("/"), key, labels, section, configMapKey: cmKey });
1037
+ return out === text ? node : out;
1038
+ }
1033
1039
  if (Array.isArray(node)) {
1034
1040
  return node.map((el, i) => walk(el, key, [...path11.slice(0, -1), `${path11[path11.length - 1]}${elementSegment(el, i)}`], labels, section, cmKey));
1035
1041
  }
@@ -2034,7 +2040,8 @@ async function updateEnvFile(file, updates) {
2034
2040
  const opens = (q === '"' || q === "'" || q === "`") && m[2].lastIndexOf(q) === 0 ? q : null;
2035
2041
  if (m && Object.prototype.hasOwnProperty.call(updates, m[1])) {
2036
2042
  if (!written.has(m[1])) {
2037
- out.push(`${m[1]}=${formatValue(updates[m[1]])}`);
2043
+ const value = updates[m[1]];
2044
+ if (value !== null) out.push(`${m[1]}=${formatValue(value)}`);
2038
2045
  written.add(m[1]);
2039
2046
  }
2040
2047
  if (opens) [inQuote, dropping] = [opens, true];
@@ -2044,12 +2051,13 @@ async function updateEnvFile(file, updates) {
2044
2051
  if (opens) inQuote = opens;
2045
2052
  }
2046
2053
  for (const name of names) {
2047
- if (!written.has(name)) out.push(`${name}=${formatValue(updates[name])}`);
2054
+ const value = updates[name];
2055
+ if (!written.has(name) && value !== null) out.push(`${name}=${formatValue(value)}`);
2048
2056
  }
2049
- const text = `${out.join("\n")}
2057
+ const text = out.length === 0 ? "" : `${out.join("\n")}
2050
2058
  `;
2051
2059
  const readBack = parseEnv(text);
2052
- const wrong = names.filter((n) => readBack[n] !== updates[n]);
2060
+ const wrong = names.filter((n) => readBack[n] !== (updates[n] ?? void 0));
2053
2061
  if (wrong.length > 0) throw new Error(`env file update would not read back correctly for ${wrong.join(", ")}; nothing written`);
2054
2062
  const target = existsSync4(file) ? await realpath3(file) : file;
2055
2063
  const temp = `${target}.${process.pid}-${randomBytes2(4).toString("hex")}.tmp`;
@@ -2222,12 +2230,15 @@ async function saveProfiles(profiles) {
2222
2230
  `);
2223
2231
  }
2224
2232
  async function readCredentials() {
2225
- return readEnvFile(credentialsFile());
2233
+ return Object.assign(/* @__PURE__ */ Object.create(null), await readEnvFile(credentialsFile()));
2226
2234
  }
2227
2235
  async function setCredential(name, password) {
2228
2236
  await ensureConfigDir();
2229
2237
  await updateEnvFile(credentialsFile(), { [name]: password });
2230
2238
  }
2239
+ async function removeCredential(name) {
2240
+ if (existsSync5(credentialsFile())) await updateEnvFile(credentialsFile(), { [name]: null });
2241
+ }
2231
2242
 
2232
2243
  // src/connection.ts
2233
2244
  var SOURCE_LABEL = {
@@ -3626,7 +3637,7 @@ async function renderedTree(root, envFile) {
3626
3637
  var knownSecrets = /* @__PURE__ */ new Set();
3627
3638
  var everywhereSecrets = /* @__PURE__ */ new Set();
3628
3639
  function rememberSecret(value, opts = {}) {
3629
- if (value === void 0 || value.length < 4) return;
3640
+ if (value === void 0 || value.length < 4 || /^(true|false)$/i.test(value)) return;
3630
3641
  knownSecrets.add(value);
3631
3642
  if (opts.stdout && value.length >= 8) everywhereSecrets.add(value);
3632
3643
  }
@@ -3638,7 +3649,7 @@ function assertEnvComplete(tree, server, env, envFile, conn) {
3638
3649
  const unset = (names) => [...names].filter((name) => env[name] === void 0).sort();
3639
3650
  const missing = unset(compared);
3640
3651
  if (missing.length > 0) {
3641
- const fix = conn.dotenv && samePath(envFile, conn.dotenv) ? `set them in profile ${conn.profile}'s env file, or pass --dotenv <file>` : `pass --dotenv <file>, or ${conn.profile ? `set profile ${conn.profile}'s dotenv` : "use a connection profile with a dotenv"}`;
3652
+ const fix = conn.dotenv && samePath(envFile, conn.dotenv) ? `set them in profile ${conn.profile}'s env file, or pass --dotenv <file>` : conn.dotenv ? `drop --dotenv to use profile ${conn.profile}'s env file ${conn.dotenv}` : `pass --dotenv <file>, or ${conn.profile ? `give profile ${conn.profile} one at a terminal with \`channelvault profile set ${conn.profile} --dotenv <absolute path>\`` : "use a connection profile with a dotenv"}`;
3642
3653
  const what = `no value for ${missing.join(", ")}, so those secrets can't be compared`;
3643
3654
  if (!existsSync9(envFile)) fail(`there is no env file at ${envFile}: ${what}; ${fix}`, "env-missing");
3644
3655
  fail(`${envFile} has ${what}; add them, or ${fix}`, "env-incomplete");
@@ -3734,7 +3745,10 @@ Rerun with --extract-secrets to move them to ${envFile}, or list false positives
3734
3745
  }
3735
3746
  }
3736
3747
  function gitWouldCommit(file) {
3737
- const r = spawnSync2("git", ["check-ignore", "-q", path10.basename(file)], { cwd: path10.dirname(file) });
3748
+ const target = path10.resolve(file);
3749
+ let dir = path10.dirname(target);
3750
+ while (!existsSync9(dir) && path10.dirname(dir) !== dir) dir = path10.dirname(dir);
3751
+ const r = spawnSync2("git", ["check-ignore", "-q", path10.relative(dir, target).split(path10.sep).join("/")], { cwd: dir });
3738
3752
  return r.status === 1;
3739
3753
  }
3740
3754
  async function preflightTree(root, envFile) {
@@ -4197,7 +4211,12 @@ addExtractFlag(addEnvFlag(addConnectionFlags(
4197
4211
  if (await client.getServerId() !== serverId2) fail("the installation changed while pulling; nothing was written");
4198
4212
  return { config: config2, serverId: serverId2 };
4199
4213
  }, { envFile });
4214
+ const envFileExisted = existsSync9(envFile);
4200
4215
  await writeTree(root, config, urlOf(conn), flags, envFile, serverId);
4216
+ if (conn.profile && !conn.dotenv && !flags.dotenv && !envFileExisted && existsSync9(envFile)) {
4217
+ process.stderr.write(`note: profile ${conn.profile} has no env file of its own, so these values are only in ${envFile}, in this checkout; other checkouts and worktrees of this tree won't have them. To keep them in one place, run \`channelvault profile set ${conn.profile} --dotenv <absolute path>\` at a terminal, then move ${envFile} to that path
4218
+ `);
4219
+ }
4201
4220
  const s = summarize(config);
4202
4221
  process.stdout.write(`pulled ${s.channels} channels, ${s.codeTemplates} code templates -> ${root}
4203
4222
  `);
@@ -4641,10 +4660,24 @@ async function loginCheck(conn) {
4641
4660
  return withClient(conn, async (_client, serverId) => serverId, { quiet: true });
4642
4661
  }
4643
4662
  function existingProfile(profiles, name) {
4644
- const profile = profiles[name];
4663
+ const profile = Object.hasOwn(profiles, name) ? profiles[name] : void 0;
4645
4664
  if (!profile) fail(`no profile named ${name} (${Object.keys(profiles).join(", ") || "none saved"})`, "profile-unknown");
4646
4665
  return profile;
4647
4666
  }
4667
+ function assertProfileValid(profiles, name, profile) {
4668
+ const problems = profileProblems({ ...profiles, [name]: profile });
4669
+ if (profile.dotenv && existsSync9(profile.dotenv) && statSync(profile.dotenv).isDirectory()) {
4670
+ problems.push(`profile ${name}: dotenv ${profile.dotenv} is a folder; name the env file inside it`);
4671
+ } else if (profile.dotenv && gitWouldCommit(profile.dotenv)) {
4672
+ problems.push(`profile ${name}: git does not ignore ${profile.dotenv}, which will hold secret values; add it to .gitignore, or choose a file outside every repository`);
4673
+ }
4674
+ if (problems.length > 0) fail(problems.join("\n"), "profile-invalid");
4675
+ }
4676
+ async function profilesUnchanged(name, expected) {
4677
+ const latest = await loadProfiles();
4678
+ if (!isDeepStrictEqual(Object.hasOwn(latest, name) ? latest[name] : void 0, expected)) fail(`profile ${name} was changed meanwhile; nothing was saved`, "profile-changed");
4679
+ return latest;
4680
+ }
4648
4681
  var profileCommand = program.command("profile").description(`Manage connection profiles (${path10.join("~", ".channelvault", "profiles.json")}; passwords in its credentials file)`);
4649
4682
  addJsonFlag(profileCommand.command("list").description("List the saved profiles (never their passwords)")).action(async (flags) => {
4650
4683
  const profiles = await loadProfiles();
@@ -4678,7 +4711,9 @@ profileCommand.command("add").description("Add a profile at a terminal: confirm
4678
4711
  needTerminal("profile add");
4679
4712
  if (!PROFILE_NAME.test(name)) fail(`profile names are letters, digits, '.', '_' and '-', starting with a letter or digit: ${name}`, "profile-invalid");
4680
4713
  const profiles = await loadProfiles();
4681
- if (profiles[name]) fail(`profile ${name} already exists; change its password with \`channelvault profile set-password ${name}\`, or edit ${profilesFile()}`, "profile-exists");
4714
+ if (Object.hasOwn(profiles, name)) {
4715
+ fail(`profile ${name} already exists; change it with \`channelvault profile set ${name}\` (env file, user, port) or \`channelvault profile set-password ${name}\`, or remove it with \`channelvault profile remove ${name}\``, "profile-exists");
4716
+ }
4682
4717
  const port = Number(flags.port);
4683
4718
  const profile = { host: flags.host, port, user: flags.user };
4684
4719
  if (flags.https === false) profile.https = false;
@@ -4689,8 +4724,7 @@ profileCommand.command("add").description("Add a profile at a terminal: confirm
4689
4724
  if (!pin) fail("--tls-fingerprint must be a SHA-256 certificate fingerprint: 64 hex digits, colons allowed", "bad-fingerprint");
4690
4725
  profile.tlsFingerprint = pin;
4691
4726
  }
4692
- const problems = profileProblems({ ...profiles, [name]: profile });
4693
- if (problems.length > 0) fail(problems.join("\n"), "profile-invalid");
4727
+ assertProfileValid(profiles, name, profile);
4694
4728
  const conn = connectionOfProfile(name, profile, "");
4695
4729
  process.stdout.write(`Add profile ${name}: ${urlOf(conn)} as ${profile.user}
4696
4730
  `);
@@ -4711,7 +4745,7 @@ channelvault will accept only this certificate from this server. Compare it with
4711
4745
  const password = await askPassword(`Password for ${profile.user}: `);
4712
4746
  profile.serverId = await loginCheck(connectionOfProfile(name, profile, password));
4713
4747
  const latest = await loadProfiles();
4714
- if (latest[name]) fail(`profile ${name} was added meanwhile; nothing was saved`, "profile-exists");
4748
+ if (Object.hasOwn(latest, name)) fail(`profile ${name} was added meanwhile; nothing was saved`, "profile-exists");
4715
4749
  await saveProfiles({ ...latest, [name]: profile });
4716
4750
  await setCredential(name, password);
4717
4751
  process.stdout.write(`added profile ${name} (installation ${profile.serverId}); password stored in ${credentialsFile()}
@@ -4728,6 +4762,73 @@ profileCommand.command("set-password").description("Change a profile's stored pa
4728
4762
  process.stdout.write(`stored the password for profile ${name}
4729
4763
  `);
4730
4764
  });
4765
+ profileCommand.command("set").description("Change a profile's env file, user or port at a terminal; never its installation or certificate pin").argument("<name>", "profile name").option("--dotenv <path>", "env file for this server's trees, used when a tree has no .env of its own").option("--user <user>", "username; asks for that user's password and logs in before saving").option("--port <port>", "Mirth server port; logs in before saving, so it must reach the same installation and certificate").action(async (name, flags) => {
4766
+ needTerminal("profile set");
4767
+ const profiles = await loadProfiles();
4768
+ const profile = existingProfile(profiles, name);
4769
+ if (flags.dotenv === void 0 && flags.user === void 0 && flags.port === void 0) {
4770
+ fail("nothing to change: pass --dotenv, --user or --port", "profile-invalid");
4771
+ }
4772
+ const updated = { ...profile };
4773
+ if (flags.dotenv !== void 0) updated.dotenv = path10.resolve(flags.dotenv);
4774
+ if (flags.user !== void 0) updated.user = flags.user;
4775
+ if (flags.port !== void 0) updated.port = Number(flags.port);
4776
+ assertProfileValid(profiles, name, updated);
4777
+ const changes = ["dotenv", "user", "port"].filter((field) => updated[field] !== profile[field]).map((field) => `${field} ${profile[field] ?? "(none)"} -> ${updated[field]}`);
4778
+ if (changes.length === 0) {
4779
+ process.stdout.write(`profile ${name} already has those settings
4780
+ `);
4781
+ return;
4782
+ }
4783
+ process.stdout.write(`Profile ${name}: ${changes.join(", ")}
4784
+ `);
4785
+ const loginNeeded = updated.user !== profile.user || updated.port !== profile.port;
4786
+ if (loginNeeded && !profile.serverId) {
4787
+ fail(`profile ${name} has no recorded installation to check a new user or port against; remove it and add it again`, "profile-invalid");
4788
+ }
4789
+ const verifiesServer = updated.https !== false && !updated.insecure;
4790
+ let newPassword;
4791
+ if (updated.user !== profile.user || updated.port !== profile.port && !verifiesServer) {
4792
+ newPassword = await askPassword(`Password for ${updated.user}: `);
4793
+ await loginCheck(connectionOfProfile(name, updated, newPassword));
4794
+ } else if (updated.port !== profile.port) {
4795
+ const password = (await readCredentials())[name];
4796
+ if (password === void 0) fail(`profile ${name} has no password yet; run \`channelvault profile set-password ${name}\` first`, "no-password");
4797
+ await loginCheck(connectionOfProfile(name, updated, password));
4798
+ }
4799
+ const latest = await profilesUnchanged(name, profile);
4800
+ assertProfileValid(latest, name, updated);
4801
+ await saveProfiles({ ...latest, [name]: updated });
4802
+ if (newPassword !== void 0) {
4803
+ try {
4804
+ await setCredential(name, newPassword);
4805
+ } catch (err) {
4806
+ await saveProfiles({ ...latest, [name]: profile });
4807
+ throw err;
4808
+ }
4809
+ }
4810
+ process.stdout.write(`updated profile ${name}: ${changes.join(", ")}
4811
+ ` + (flags.dotenv !== void 0 ? `values already in another env file are not moved; move them to ${updated.dotenv} yourself
4812
+ ` : ""));
4813
+ });
4814
+ profileCommand.command("remove").description("Remove a profile and its stored password, at a terminal, after confirming").argument("<name>", "profile name").action(async (name) => {
4815
+ needTerminal("profile remove");
4816
+ const profile = existingProfile(await loadProfiles(), name);
4817
+ process.stdout.write(`Profile ${name}: ${urlOf(connectionOfProfile(name, profile, ""))} as ${profile.user}, installation ${profile.serverId ?? "(not recorded)"}
4818
+ ` + (profile.dotenv ? `Its env file ${profile.dotenv} is kept.
4819
+ ` : ""));
4820
+ if (!await confirm(`Remove profile ${name} and its stored password?`)) {
4821
+ process.stdout.write("aborted.\n");
4822
+ return;
4823
+ }
4824
+ const latest = await profilesUnchanged(name, profile);
4825
+ const rest = Object.fromEntries(Object.entries(latest).filter(([n]) => n !== name));
4826
+ const hadPassword = Object.hasOwn(await readCredentials(), name);
4827
+ await removeCredential(name);
4828
+ await saveProfiles(rest);
4829
+ process.stdout.write(`removed profile ${name}${hadPassword ? ` and its password from ${credentialsFile()}` : ""}
4830
+ `);
4831
+ });
4731
4832
  addJsonFlag(profileCommand.command("check").description("Log in with each profile (or the one named) and verify its certificate and installation").argument("[name]", "profile name")).action(async (name, flags) => {
4732
4833
  const profiles = await loadProfiles();
4733
4834
  const credentials = await readCredentials();