bod-cli 0.7.2 → 0.7.4
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/cli.js +21 -7
- package/package.json +1 -1
- package/src/cli.ts +12 -2
- package/src/commands/db.ts +22 -11
package/dist/cli.js
CHANGED
|
@@ -20152,12 +20152,15 @@ function directTarget(port, token, label) {
|
|
|
20152
20152
|
};
|
|
20153
20153
|
}
|
|
20154
20154
|
async function resolveDbTarget(appArg) {
|
|
20155
|
-
const
|
|
20156
|
-
if (
|
|
20157
|
-
|
|
20158
|
-
|
|
20159
|
-
|
|
20160
|
-
|
|
20155
|
+
const explicitInstance = !!(process.env._BOD_INSTANCE_OVERRIDE || process.env.BOD_INSTANCE);
|
|
20156
|
+
if (!explicitInstance) {
|
|
20157
|
+
const info = readServeInfo();
|
|
20158
|
+
if (info)
|
|
20159
|
+
return directTarget(info.dbPort, info.dbAdminPassword, "local serve");
|
|
20160
|
+
const envPw = readDotEnv("BODDB_ADMIN_PASSWORD");
|
|
20161
|
+
if (envPw)
|
|
20162
|
+
return directTarget(readDbPortFromYaml(), envPw, "direct via .env");
|
|
20163
|
+
}
|
|
20161
20164
|
const { url, apiKey } = getResolvedInstance(loadConfig());
|
|
20162
20165
|
const client = new BodClient(url, apiKey);
|
|
20163
20166
|
const appId = await resolveAppId(client, resolveAppName(appArg));
|
|
@@ -20419,7 +20422,18 @@ var db_default = defineCommand2({
|
|
|
20419
20422
|
});
|
|
20420
20423
|
|
|
20421
20424
|
// src/cli.ts
|
|
20422
|
-
|
|
20425
|
+
function parseInstanceFlag() {
|
|
20426
|
+
const argv2 = process.argv;
|
|
20427
|
+
for (let i2 = 0;i2 < argv2.length; i2++) {
|
|
20428
|
+
const a2 = argv2[i2];
|
|
20429
|
+
if (a2.startsWith("--instance="))
|
|
20430
|
+
return a2.slice("--instance=".length);
|
|
20431
|
+
if (a2 === "--instance" && i2 + 1 < argv2.length)
|
|
20432
|
+
return argv2[i2 + 1];
|
|
20433
|
+
}
|
|
20434
|
+
return;
|
|
20435
|
+
}
|
|
20436
|
+
var instanceFlag = parseInstanceFlag();
|
|
20423
20437
|
var isLocal = process.argv.includes("--local") || process.argv.includes("-l");
|
|
20424
20438
|
if (instanceFlag)
|
|
20425
20439
|
setInstanceOverride(instanceFlag);
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -17,8 +17,18 @@ import sshCmd from './commands/ssh'
|
|
|
17
17
|
import publishCmd from './commands/publish'
|
|
18
18
|
import dbCmd from './commands/db'
|
|
19
19
|
|
|
20
|
-
// Parse --instance / --local / -l early so it's set before citty dispatches subcommands
|
|
21
|
-
|
|
20
|
+
// Parse --instance / --local / -l early so it's set before citty dispatches subcommands.
|
|
21
|
+
// Supports both `--instance=NAME` and `--instance NAME` forms.
|
|
22
|
+
function parseInstanceFlag(): string | undefined {
|
|
23
|
+
const argv = process.argv
|
|
24
|
+
for (let i = 0; i < argv.length; i++) {
|
|
25
|
+
const a = argv[i]
|
|
26
|
+
if (a.startsWith('--instance=')) return a.slice('--instance='.length)
|
|
27
|
+
if (a === '--instance' && i + 1 < argv.length) return argv[i + 1]
|
|
28
|
+
}
|
|
29
|
+
return undefined
|
|
30
|
+
}
|
|
31
|
+
const instanceFlag = parseInstanceFlag()
|
|
22
32
|
const isLocal = process.argv.includes('--local') || process.argv.includes('-l')
|
|
23
33
|
if (instanceFlag) setInstanceOverride(instanceFlag)
|
|
24
34
|
else if (isLocal) setInstanceOverride('local')
|
package/src/commands/db.ts
CHANGED
|
@@ -80,19 +80,30 @@ function directTarget(port: number, token: string, label: string): DbTarget {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* Resolve a target for DB commands.
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
83
|
+
* Resolve a target for DB commands.
|
|
84
|
+
*
|
|
85
|
+
* Precedence:
|
|
86
|
+
* 1. Explicit `--instance <name>` / `BOD_INSTANCE` → always the Bodify agent
|
|
87
|
+
* proxy for that instance. Local shortcuts are skipped so the flag isn't
|
|
88
|
+
* silently ignored while `bod serve` runs in the same dir.
|
|
89
|
+
* 2. Otherwise, prefer direct-to-BodDB if we can discover the port + admin
|
|
90
|
+
* password locally (`.bodify/serve.info.json` from `bod serve`, or
|
|
91
|
+
* `.env BODDB_ADMIN_PASSWORD` + `bodify.yaml database.port`).
|
|
92
|
+
* 3. Fall back to the Bodify agent proxy for the default instance.
|
|
87
93
|
*/
|
|
88
94
|
async function resolveDbTarget(appArg: string | undefined): Promise<DbTarget> {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
const explicitInstance = !!(process.env._BOD_INSTANCE_OVERRIDE || process.env.BOD_INSTANCE)
|
|
96
|
+
|
|
97
|
+
if (!explicitInstance) {
|
|
98
|
+
// 1. Live `bod serve` info file — authoritative (correct port even if scanned).
|
|
99
|
+
const info = readServeInfo()
|
|
100
|
+
if (info) return directTarget(info.dbPort, info.dbAdminPassword, 'local serve')
|
|
101
|
+
// 2. .env BODDB_ADMIN_PASSWORD + bodify.yaml database.port — works without restarting serve.
|
|
102
|
+
const envPw = readDotEnv('BODDB_ADMIN_PASSWORD')
|
|
103
|
+
if (envPw) return directTarget(readDbPortFromYaml(), envPw, 'direct via .env')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 3. Bodify agent proxy (deployed apps — or explicitly-requested instance).
|
|
96
107
|
const { url, apiKey } = getResolvedInstance(loadConfig())
|
|
97
108
|
const client = new BodClient(url, apiKey)
|
|
98
109
|
const appId = await resolveAppId(client, resolveAppName(appArg))
|