@dbx-tools/cli 0.1.104 → 0.1.105
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/bin/dbxtools.js +1 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +102 -2
- package/dist/{verify-C3bNbiXe.js → verify-ZnM5Gb2r.js} +1 -1
- package/package.json +1 -1
package/dist/bin/dbxtools.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { C as codegen, S as build, b as resolveAgentPrompt, d as release, f as format, g as agent, l as notesSinceRequested, n as forwardedUpdateArgs, p as create, s as update, t as verify, u as tag } from "../verify-
|
|
2
|
+
import { C as codegen, S as build, b as resolveAgentPrompt, d as release, f as format, g as agent, l as notesSinceRequested, n as forwardedUpdateArgs, p as create, s as update, t as verify, u as tag } from "../verify-ZnM5Gb2r.js";
|
|
3
3
|
import { Command, InvalidArgumentError } from "commander";
|
|
4
4
|
|
|
5
5
|
//#region packages/cli/bin/dbxtools.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,39 @@ import { FileSystemProject, Workspace } from "pacwich";
|
|
|
4
4
|
/** Compile every publishable package with the shared tsdown config. */
|
|
5
5
|
declare function build(): Promise<void>;
|
|
6
6
|
//#endregion
|
|
7
|
+
//#region packages/cli/src/exec.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Subprocess helper with optional per-line stdout/stderr callbacks.
|
|
10
|
+
*
|
|
11
|
+
* Defaults to `Bun.spawn` so line callbacks stream as output arrives. Set
|
|
12
|
+
* `shell: true` to use Bun's cross-platform `$` shell (PATH resolution,
|
|
13
|
+
* Windows `.cmd` handling) when you do not need streaming line handlers.
|
|
14
|
+
*
|
|
15
|
+
* For capture-and-throw semantics, prefer {@link sh} / {@link bunx}.
|
|
16
|
+
*/
|
|
17
|
+
type BunSpawnOptions = NonNullable<Parameters<typeof Bun.spawn>[1]>;
|
|
18
|
+
type ExecOptions = Omit<BunSpawnOptions, "stdin" | "stdout" | "stderr" | "stdio"> & {
|
|
19
|
+
stdin?: BunSpawnOptions["stdin"];
|
|
20
|
+
stdout?: BunSpawnOptions["stdout"] | ((line: string) => void);
|
|
21
|
+
stderr?: BunSpawnOptions["stderr"] | ((line: string) => void);
|
|
22
|
+
/**
|
|
23
|
+
* Run through Bun's `$` shell instead of `Bun.spawn`. Cross-platform
|
|
24
|
+
* command resolution; stdout/stderr echo to the terminal by default.
|
|
25
|
+
* Line callbacks are satisfied from buffered output after exit (Bun
|
|
26
|
+
* shell does not stream `.lines()` while the process runs).
|
|
27
|
+
*/
|
|
28
|
+
shell?: boolean; /** Shell only: suppress live stdout/stderr echo (output is still buffered). */
|
|
29
|
+
quiet?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Spawn a subprocess and wait for exit.
|
|
33
|
+
*
|
|
34
|
+
* Unset stdio fds default to `"inherit"`. Pass a function as `stdout` or
|
|
35
|
+
* `stderr` to receive each line; with the default `Bun.spawn` path that fd
|
|
36
|
+
* is piped and lines stream as they arrive.
|
|
37
|
+
*/
|
|
38
|
+
declare function exec(command: string, args: string[], options?: ExecOptions): Promise<number>;
|
|
39
|
+
//#endregion
|
|
7
40
|
//#region packages/cli/src/agent.d.ts
|
|
8
41
|
/**
|
|
9
42
|
* Run Codex headlessly via `ucode codex exec` for `dbxtools agent` and
|
|
@@ -253,4 +286,4 @@ interface VerifyOptions {
|
|
|
253
286
|
/** Workspace verify pass (optional implicit-dependency scan). */
|
|
254
287
|
declare function verify(options?: VerifyOptions): Promise<void>;
|
|
255
288
|
//#endregion
|
|
256
|
-
export { AGENT_DEFAULT_TIMEOUT_MS, type AgentCommandOptions, type AgentOptions, type AgentResult, type Bump, type CreateOptions, type DbxtoolsConfig, type PackageJson, type ReleaseOptions, type ShellResult, type TagOptions, type VerifyOptions, WorkspacePackage, agent, agentAvailable, agentTimedOut, build, bunx, codegen, create, discoverPackageJsons, discoverPackages, errorMessage, fail, format, forwardedUpdateArgs, getDbxtoolsConfig, getProject, git, isStableVersion, latestStableInRange, nonEmptyLines, parseCodexStdout, release, resolveAgentPrompt, runAgent, runBunUpdate, sh, stableCaretRange, tag, toAbsolute, toRelative, update, updateCatalog, verify, writeJson };
|
|
289
|
+
export { AGENT_DEFAULT_TIMEOUT_MS, type AgentCommandOptions, type AgentOptions, type AgentResult, type Bump, type CreateOptions, type DbxtoolsConfig, type ExecOptions, type PackageJson, type ReleaseOptions, type ShellResult, type TagOptions, type VerifyOptions, WorkspacePackage, agent, agentAvailable, agentTimedOut, build, bunx, codegen, create, discoverPackageJsons, discoverPackages, errorMessage, exec, fail, format, forwardedUpdateArgs, getDbxtoolsConfig, getProject, git, isStableVersion, latestStableInRange, nonEmptyLines, parseCodexStdout, release, resolveAgentPrompt, runAgent, runBunUpdate, sh, stableCaretRange, tag, toAbsolute, toRelative, update, updateCatalog, verify, writeJson };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
import { A as git, C as codegen, D as toAbsolute, E as discoverPackages, F as nonEmptyLines, I as getProject, M as sh, N as errorMessage, O as toRelative, P as fail, S as build, T as discoverPackageJsons, _ as agentAvailable, a as runBunUpdate, b as resolveAgentPrompt, c as updateCatalog, d as release, f as format, g as agent, h as AGENT_DEFAULT_TIMEOUT_MS, i as latestStableInRange, j as bunx, k as writeJson, m as getDbxtoolsConfig, n as forwardedUpdateArgs, o as stableCaretRange, p as create, r as isStableVersion, s as update, t as verify, u as tag, v as agentTimedOut, w as WorkspacePackage, x as runAgent, y as parseCodexStdout } from "./verify-
|
|
1
|
+
import { A as git, C as codegen, D as toAbsolute, E as discoverPackages, F as nonEmptyLines, I as getProject, M as sh, N as errorMessage, O as toRelative, P as fail, S as build, T as discoverPackageJsons, _ as agentAvailable, a as runBunUpdate, b as resolveAgentPrompt, c as updateCatalog, d as release, f as format, g as agent, h as AGENT_DEFAULT_TIMEOUT_MS, i as latestStableInRange, j as bunx, k as writeJson, m as getDbxtoolsConfig, n as forwardedUpdateArgs, o as stableCaretRange, p as create, r as isStableVersion, s as update, t as verify, u as tag, v as agentTimedOut, w as WorkspacePackage, x as runAgent, y as parseCodexStdout } from "./verify-ZnM5Gb2r.js";
|
|
2
|
+
import { $ } from "bun";
|
|
3
|
+
import * as readline from "node:readline";
|
|
4
|
+
import { Readable } from "node:stream";
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
//#region packages/cli/src/exec.ts
|
|
7
|
+
/**
|
|
8
|
+
* Subprocess helper with optional per-line stdout/stderr callbacks.
|
|
9
|
+
*
|
|
10
|
+
* Defaults to `Bun.spawn` so line callbacks stream as output arrives. Set
|
|
11
|
+
* `shell: true` to use Bun's cross-platform `$` shell (PATH resolution,
|
|
12
|
+
* Windows `.cmd` handling) when you do not need streaming line handlers.
|
|
13
|
+
*
|
|
14
|
+
* For capture-and-throw semantics, prefer {@link sh} / {@link bunx}.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Spawn a subprocess and wait for exit.
|
|
18
|
+
*
|
|
19
|
+
* Unset stdio fds default to `"inherit"`. Pass a function as `stdout` or
|
|
20
|
+
* `stderr` to receive each line; with the default `Bun.spawn` path that fd
|
|
21
|
+
* is piped and lines stream as they arrive.
|
|
22
|
+
*/
|
|
23
|
+
async function exec(command, args, options = {}) {
|
|
24
|
+
if (options.shell) return execShell(command, args, options);
|
|
25
|
+
return execSpawn(command, args, options);
|
|
26
|
+
}
|
|
27
|
+
async function execSpawn(command, args, options) {
|
|
28
|
+
const { stdin, stdout, stderr, shell: _shell, quiet: _quiet, ...spawnOpts } = options;
|
|
29
|
+
const onStdout = typeof stdout === "function" ? stdout : void 0;
|
|
30
|
+
const onStderr = typeof stderr === "function" ? stderr : void 0;
|
|
31
|
+
const stdoutMode = typeof stdout === "function" ? "pipe" : stdout ?? "inherit";
|
|
32
|
+
const stderrMode = typeof stderr === "function" ? "pipe" : stderr ?? "inherit";
|
|
33
|
+
const proc = Bun.spawn([command, ...args], {
|
|
34
|
+
...spawnOpts,
|
|
35
|
+
stdin: stdin ?? "inherit",
|
|
36
|
+
stdout: stdoutMode,
|
|
37
|
+
stderr: stderrMode
|
|
38
|
+
});
|
|
39
|
+
const reads = [];
|
|
40
|
+
if (onStdout && isReadableStream(proc.stdout)) reads.push(readLines(proc.stdout, onStdout));
|
|
41
|
+
if (onStderr && isReadableStream(proc.stderr)) reads.push(readLines(proc.stderr, onStderr));
|
|
42
|
+
try {
|
|
43
|
+
const exitCode = await proc.exited;
|
|
44
|
+
await Promise.all(reads);
|
|
45
|
+
return exitCode;
|
|
46
|
+
} catch (err) {
|
|
47
|
+
await Promise.allSettled(reads);
|
|
48
|
+
throw err;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function execShell(command, args, options) {
|
|
52
|
+
const { cwd, env, quiet, stdout, stderr, stdin, shell: _shell, ..._spawnOnly } = options;
|
|
53
|
+
const onStdout = typeof stdout === "function" ? stdout : void 0;
|
|
54
|
+
const onStderr = typeof stderr === "function" ? stderr : void 0;
|
|
55
|
+
const argv = [command, ...args];
|
|
56
|
+
let cmd = typeof stdin === "string" ? $`${argv} < ${new Response(stdin)}`.nothrow() : $`${argv}`.nothrow();
|
|
57
|
+
if (cwd) cmd = cmd.cwd(cwd);
|
|
58
|
+
if (env) cmd = cmd.env(env);
|
|
59
|
+
if (quiet) cmd = cmd.quiet();
|
|
60
|
+
if (onStdout) {
|
|
61
|
+
const [res] = await Promise.all([cmd, (async () => {
|
|
62
|
+
for await (const line of cmd.lines()) onStdout(line);
|
|
63
|
+
})()]);
|
|
64
|
+
if (onStderr) emitBufferedLines(res.stderr.toString(), onStderr);
|
|
65
|
+
return res.exitCode;
|
|
66
|
+
}
|
|
67
|
+
const res = await cmd;
|
|
68
|
+
if (onStderr) emitBufferedLines(res.stderr.toString(), onStderr);
|
|
69
|
+
return res.exitCode;
|
|
70
|
+
}
|
|
71
|
+
function isReadableStream(value) {
|
|
72
|
+
return typeof value === "object" && value !== null && "getReader" in value;
|
|
73
|
+
}
|
|
74
|
+
async function readLines(stream, onLine) {
|
|
75
|
+
const rl = readline.createInterface({
|
|
76
|
+
input: Readable.fromWeb(stream),
|
|
77
|
+
crlfDelay: Infinity
|
|
78
|
+
});
|
|
79
|
+
for await (const line of rl) onLine(line);
|
|
80
|
+
}
|
|
81
|
+
function emitBufferedLines(text, onLine) {
|
|
82
|
+
if (text.length === 0) return;
|
|
83
|
+
const body = text.endsWith("\n") ? text.slice(0, -1) : text;
|
|
84
|
+
for (const line of body.split("\n")) onLine(line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
85
|
+
}
|
|
86
|
+
if (import.meta.main) {
|
|
87
|
+
const useShell = process.argv.includes("--shell");
|
|
88
|
+
const [command, ...args] = process.argv.slice(2).filter((arg) => arg !== "--shell");
|
|
89
|
+
if (!command) {
|
|
90
|
+
console.error("Usage: exec [--shell] <command> [args...]");
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
const exitCode = await exec(command, args, {
|
|
94
|
+
shell: useShell,
|
|
95
|
+
stdout: (line) => console.log(line),
|
|
96
|
+
stderr: (line) => console.error(line)
|
|
97
|
+
});
|
|
98
|
+
console.log(`Exit code: ${exitCode}`);
|
|
99
|
+
process.exit(exitCode);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
export { AGENT_DEFAULT_TIMEOUT_MS, WorkspacePackage, agent, agentAvailable, agentTimedOut, build, bunx, codegen, create, discoverPackageJsons, discoverPackages, errorMessage, exec, fail, format, forwardedUpdateArgs, getDbxtoolsConfig, getProject, git, isStableVersion, latestStableInRange, nonEmptyLines, parseCodexStdout, release, resolveAgentPrompt, runAgent, runBunUpdate, sh, stableCaretRange, tag, toAbsolute, toRelative, update, updateCatalog, verify, writeJson };
|
|
@@ -1372,7 +1372,7 @@ async function tag(opts = {}) {
|
|
|
1372
1372
|
consola.log("Refreshing bun.lock to the bumped versions before local publish...");
|
|
1373
1373
|
if ((await sh(["bun", "install"], { nothrow: true })).exitCode !== 0) consola.warn("bun install failed; skipping local publish so stale sibling pins aren't shipped. CI will publish from the tag.");
|
|
1374
1374
|
else {
|
|
1375
|
-
consola.log("Publishing packages to the local registry (bun
|
|
1375
|
+
consola.log("Publishing packages to the local registry (bun dbxtools release)...");
|
|
1376
1376
|
await sh([
|
|
1377
1377
|
"bun",
|
|
1378
1378
|
"run",
|