@voxli/cli 0.6.1 → 0.6.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.
@@ -1,6 +1,7 @@
1
1
  import { createInterface } from "node:readline/promises";
2
2
  import { stdin, stdout } from "node:process";
3
- import { writeConfig } from "../lib/config.js";
3
+ import { join } from "node:path";
4
+ import { findLocalConfigDir, writeConfig } from "../lib/config.js";
4
5
  import { register, ApiError } from "../lib/api.js";
5
6
  import { getStableHostname } from "../lib/hostname.js";
6
7
  import { browserAuth } from "../lib/browser-auth.js";
@@ -37,12 +38,30 @@ async function validateAndSave(token, extra, opts) {
37
38
  // Network error or other — warn but still save
38
39
  console.warn("Warning: could not validate token (network error). Saving anyway.");
39
40
  }
40
- const target = opts?.local ? "local" : "global";
41
+ // Target selection:
42
+ // - --local: force cwd/.voxli (creates if missing).
43
+ // - default: reuse an existing local config in the cwd ancestor chain so
44
+ // the listener (which reads local first) picks up the new credentials.
45
+ // Falls back to the global config if no local one exists.
46
+ let writeOpts;
47
+ if (opts?.local) {
48
+ writeOpts = { configDir: join(process.cwd(), ".voxli") };
49
+ }
50
+ else {
51
+ const existingLocal = await findLocalConfigDir();
52
+ if (existingLocal) {
53
+ console.log(`Detected local config at ${existingLocal}; saving there.`);
54
+ writeOpts = { configDir: existingLocal };
55
+ }
56
+ else {
57
+ writeOpts = { target: "global" };
58
+ }
59
+ }
41
60
  const savedPath = await writeConfig({
42
61
  accessToken: token,
43
62
  refreshToken: extra?.refreshToken,
44
63
  clientId: extra?.clientId,
45
- }, { target });
64
+ }, writeOpts);
46
65
  console.log(`${label} saved to ${savedPath}`);
47
66
  }
48
67
  export async function authCommand(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxli/cli",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "CLI agent for running Voxli test scenarios locally",
5
5
  "type": "module",
6
6
  "bin": {