@wuapidev/cli 0.1.1 → 0.2.0

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/paths.js CHANGED
@@ -1,7 +1,9 @@
1
1
  // Where the CLI keeps its files. packages/wuapi-mcp has a copy of
2
2
  // `configDir` and `credentialsPath` (src/login.ts there): keep both the same.
3
+ import { createHash } from "node:crypto";
4
+ import { realpathSync } from "node:fs";
3
5
  import { homedir } from "node:os";
4
- import { isAbsolute, join, posix, win32 } from "node:path";
6
+ import { isAbsolute, join, posix, resolve, win32 } from "node:path";
5
7
  /**
6
8
  * The CLI's config directory: `%APPDATA%\wuapi` on Windows,
7
9
  * `$XDG_CONFIG_HOME/wuapi` when set (an absolute path), else `~/.config/wuapi`.
@@ -19,9 +21,22 @@ export function credentialsPath(env = process.env, platform = process.platform,
19
21
  const dir = configDir(env, platform, home);
20
22
  return platform === "win32" ? win32.join(dir, "credentials.json") : join(dir, "credentials.json");
21
23
  }
22
- /** A device code waiting for `wuapi login --finish`. */
23
- export function pendingLoginPath(env = process.env, platform = process.platform, home = homedir()) {
24
+ /**
25
+ * A device code waiting for `wuapi login --finish`, one per working directory:
26
+ * `<configDir>/login-pending-<hash of realpath(cwd)>.json`. Two agent sessions
27
+ * in different folders (say OpenCode and Claude Code at once) each keep their
28
+ * own, and `--finish` in the same folder finds the one `--start` wrote.
29
+ */
30
+ export function pendingLoginPath(env = process.env, platform = process.platform, home = homedir(), cwd = process.cwd()) {
24
31
  const dir = configDir(env, platform, home);
25
- return platform === "win32" ? win32.join(dir, "login-pending.json") : join(dir, "login-pending.json");
32
+ let folder;
33
+ try {
34
+ folder = realpathSync(cwd);
35
+ }
36
+ catch {
37
+ folder = resolve(cwd);
38
+ }
39
+ const file = `login-pending-${createHash("sha256").update(folder).digest("hex").slice(0, 16)}.json`;
40
+ return platform === "win32" ? win32.join(dir, file) : join(dir, file);
26
41
  }
27
42
  //# sourceMappingURL=paths.js.map
package/dist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,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACxE,CAAC"}
package/dist/run.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { type Ctx } from "./context.js";
2
+ export declare function runCommand(ctx: Ctx): Promise<number>;
3
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAQA,OAAO,EAAe,KAAK,GAAG,EAAE,MAAM,cAAc,CAAC;AAGrD,wBAAsB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAc1D"}
package/dist/run.js ADDED
@@ -0,0 +1,29 @@
1
+ // `wuapi run -- <command> [args...]`: runs a command with the login's API key
2
+ // in its environment (WUAPI_API_KEY, plus WUAPI_PROJECT and WUAPI_BASE_URL
3
+ // when they apply), the way `op run` or `doppler run` do. The key reaches only
4
+ // the child process: it is never printed and never written to a file, so the
5
+ // person's app, dev server or tests get it without a .env in the project.
6
+ import { DEFAULT_BASE_URL } from "@wuapidev/sdk";
7
+ import { GLOBAL_FLAGS } from "./args.js";
8
+ import { resolveAuth } from "./context.js";
9
+ import { usage } from "./errors.js";
10
+ export async function runCommand(ctx) {
11
+ for (const name of ctx.args.flags.keys()) {
12
+ if (!GLOBAL_FLAGS.includes(name) || name === "json") {
13
+ throw usage(`Unknown flag --${name} for wuapi run. Put the command after --: wuapi run -- <command> [args...]`);
14
+ }
15
+ }
16
+ const [command, ...args] = ctx.args.positionals.slice(1);
17
+ if (!command)
18
+ throw usage("Usage: wuapi run [--profile <name>] -- <command> [args...]");
19
+ const auth = resolveAuth(ctx);
20
+ const env = { ...ctx.io.env, WUAPI_API_KEY: auth.apiKey };
21
+ if (auth.project)
22
+ env.WUAPI_PROJECT = auth.project;
23
+ else
24
+ delete env.WUAPI_PROJECT;
25
+ if (auth.baseUrl !== DEFAULT_BASE_URL)
26
+ env.WUAPI_BASE_URL = auth.baseUrl;
27
+ return ctx.io.exec(command, args, env);
28
+ }
29
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAC7E,0EAA0E;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAY,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAQ;IACvC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACzC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpD,MAAM,KAAK,CAAC,kBAAkB,IAAI,4EAA4E,CAAC,CAAC;QAClH,CAAC;IACH,CAAC;IACD,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzD,IAAI,CAAC,OAAO;QAAE,MAAM,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACxF,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAuC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC9F,IAAI,IAAI,CAAC,OAAO;QAAE,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC;;QAC9C,OAAO,GAAG,CAAC,aAAa,CAAC;IAC9B,IAAI,IAAI,CAAC,OAAO,KAAK,gBAAgB;QAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC;IACzE,OAAO,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** The package version. Bump it together with package.json (test/version.test.ts checks). */
2
- export declare const VERSION = "0.1.1";
2
+ export declare const VERSION = "0.2.0";
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /** The package version. Bump it together with package.json (test/version.test.ts checks). */
2
- export const VERSION = "0.1.1";
2
+ export const VERSION = "0.2.0";
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wuapidev/cli",
3
- "version": "0.1.1",
4
- "description": "The wuapi command line: log in from the browser, link a WhatsApp number by QR or pairing code, send messages, set up the MCP server and call every endpoint of the wuapi API from your terminal or your agent.",
3
+ "version": "0.2.0",
4
+ "description": "The wuapi command line: log in from the browser, link a WhatsApp number through a link the person opens (QR or pairing code), run your app with the key, send messages, set up the MCP server and call every endpoint of the wuapi API from your terminal or your agent.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",