@devdogsuga/devtools 0.1.18 → 0.1.19

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/bws/bw.d.ts CHANGED
@@ -1,3 +1,12 @@
1
+ /**
2
+ * The `[command, args]` pair that runs the bundled Bitwarden CLI.
3
+ *
4
+ * Runs `build/bw.js` under this Node rather than through a shim, so it works
5
+ * the same wherever devtools is installed. Falls back to `bw` on PATH when the
6
+ * package cannot be resolved, which keeps a missing install surfacing as the
7
+ * ENOENT every caller already handles.
8
+ */
9
+ export declare function bwCommand(args: string[]): [string, string[]];
1
10
  /**
2
11
  * Runs the Bitwarden CLI with `args`, then exits with its status.
3
12
  *
package/dist/bws/bw.js CHANGED
@@ -12,12 +12,33 @@
12
12
  * `pnpm --filter @devdogsuga/devtools exec bw`, the last script at the
13
13
  * workspace root whose whole job was to reach into this package.
14
14
  *
15
- * ⚠️ `cwd` is deliberately NOT overridden, unlike the pnpm spawn in
16
- * `run/pick.ts`. pnpm puts this package's `node_modules/.bin` on PATH as a
17
- * relative entry, so moving the working directory would make `bw` unresolvable
18
- * from the very place it is installed. Bitwarden does not care where it runs.
15
+ * ⚠️ The binary is resolved from `@bitwarden/cli` itself, never looked up on
16
+ * PATH. A dependency's bin is only linked into the `node_modules/.bin` of the
17
+ * package that depends on it, so under `pnpm dlx`, or with devtools installed
18
+ * in a clone, nothing puts `bw` on PATH and a bare `spawn("bw")` is ENOENT.
19
19
  */
20
20
  import { spawn } from "node:child_process";
21
+ import { createRequire } from "node:module";
22
+ import { dirname, join } from "node:path";
23
+ /**
24
+ * The `[command, args]` pair that runs the bundled Bitwarden CLI.
25
+ *
26
+ * Runs `build/bw.js` under this Node rather than through a shim, so it works
27
+ * the same wherever devtools is installed. Falls back to `bw` on PATH when the
28
+ * package cannot be resolved, which keeps a missing install surfacing as the
29
+ * ENOENT every caller already handles.
30
+ */
31
+ export function bwCommand(args) {
32
+ try {
33
+ const require_ = createRequire(import.meta.url);
34
+ const pkgPath = require_.resolve("@bitwarden/cli/package.json");
35
+ const pkg = require_(pkgPath);
36
+ return [process.execPath, [join(dirname(pkgPath), pkg.bin.bw), ...args]];
37
+ }
38
+ catch {
39
+ return ["bw", args];
40
+ }
41
+ }
21
42
  /**
22
43
  * Runs the Bitwarden CLI with `args`, then exits with its status.
23
44
  *
@@ -28,7 +49,7 @@ import { spawn } from "node:child_process";
28
49
  */
29
50
  export function runBw(args) {
30
51
  return new Promise(() => {
31
- const child = spawn("bw", args, { stdio: "inherit" });
52
+ const child = spawn(...bwCommand(args), { stdio: "inherit" });
32
53
  child.on("error", (err) => {
33
54
  // ENOENT here means the dependency is not installed rather than that the
34
55
  // user mistyped, so say the thing that fixes it.
package/dist/bws/vault.js CHANGED
@@ -21,6 +21,7 @@ import { execFile, spawn } from "node:child_process";
21
21
  import { promisify } from "node:util";
22
22
  import { confirm, log, spinner } from "@clack/prompts";
23
23
  import { unwrap } from "../ui.js";
24
+ import { bwCommand } from "./bw.js";
24
25
  const run = promisify(execFile);
25
26
  /**
26
27
  * The item this looks for, and creates.
@@ -33,7 +34,7 @@ export const VAULT_ITEM_NAME = "DevDogs Secrets Manager access token (admin)";
33
34
  /** `bw status`, or `unavailable` when the CLI is not installed. */
34
35
  export async function vaultStatus() {
35
36
  try {
36
- const { stdout } = await run("bw", bwArgs(["status", "--response"]), {
37
+ const { stdout } = await run(...bwCommand(bwArgs(["status", "--response"])), {
37
38
  shell: false,
38
39
  });
39
40
  // `--response` wraps the payload; the bare form is also accepted, so read
@@ -80,7 +81,7 @@ async function session(status) {
80
81
  return new Promise((resolve) => {
81
82
  // stdin inherited so the master password goes to `bw` and not through here;
82
83
  // stdout piped so the session key can be captured rather than printed.
83
- const child = spawn("bw", ["unlock", "--raw"], {
84
+ const child = spawn(...bwCommand(["unlock", "--raw"]), {
84
85
  stdio: ["inherit", "pipe", "inherit"],
85
86
  shell: false,
86
87
  });
@@ -127,7 +128,7 @@ export async function readTokenFromVault() {
127
128
  const s = spinner();
128
129
  s.start("Looking in your Bitwarden vault");
129
130
  try {
130
- const { stdout } = await run("bw", bwArgs(["get", "password", VAULT_ITEM_NAME, "--raw"], key), { shell: false });
131
+ const { stdout } = await run(...bwCommand(bwArgs(["get", "password", VAULT_ITEM_NAME, "--raw"], key)), { shell: false });
131
132
  const token = stdout.trim();
132
133
  if (token === "") {
133
134
  s.stop("Nothing stored in the vault yet");
@@ -172,7 +173,7 @@ export async function saveTokenToVault(token) {
172
173
  login: { username: null, password: token, totp: null },
173
174
  };
174
175
  return new Promise((resolve) => {
175
- const child = spawn("bw", bwArgs(["create", "item"], key), {
176
+ const child = spawn(...bwCommand(bwArgs(["create", "item"], key)), {
176
177
  stdio: ["pipe", "ignore", "pipe"],
177
178
  shell: false,
178
179
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devdogsuga/devtools",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Contributor CLI for a DevDogsUGA checkout: database, env, images, emails, cron, deploy. Ships built JS; run via `pnpm dlx @devdogsuga/devtools` (or the `devtools`/`devtools-ci` bins once installed) from inside a DevDogsUGA clone.",
@@ -66,11 +66,11 @@
66
66
  "@vitest/coverage-v8": "^4.1.11",
67
67
  "react": "^19.2.8",
68
68
  "vitest": "^4.1.11",
69
- "@devdogsuga/db": "0.1.1",
70
- "@devdogsuga/brand": "0.1.2",
71
69
  "@devdogsuga/config": "0.1.1",
70
+ "@devdogsuga/db": "0.1.1",
72
71
  "@devdogsuga/env": "0.1.2",
73
- "@devdogsuga/events": "0.1.3"
72
+ "@devdogsuga/events": "0.1.3",
73
+ "@devdogsuga/brand": "0.1.2"
74
74
  },
75
75
  "scripts": {
76
76
  "build": "tsc && node scripts/write-build-info.mjs",