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 CHANGED
@@ -20152,12 +20152,15 @@ function directTarget(port, token, label) {
20152
20152
  };
20153
20153
  }
20154
20154
  async function resolveDbTarget(appArg) {
20155
- const info = readServeInfo();
20156
- if (info)
20157
- return directTarget(info.dbPort, info.dbAdminPassword, "local serve");
20158
- const envPw = readDotEnv("BODDB_ADMIN_PASSWORD");
20159
- if (envPw)
20160
- return directTarget(readDbPortFromYaml(), envPw, "direct via .env");
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
- var instanceFlag = process.argv.find((a2) => a2.startsWith("--instance="))?.split("=").slice(1).join("=");
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bod-cli",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "bod": "./dist/cli.js"
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
- const instanceFlag = process.argv.find(a => a.startsWith('--instance='))?.split('=').slice(1).join('=')
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')
@@ -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. Direct-to-BodDB takes precedence when we
84
- * can discover the port + admin password locally — this covers `bod serve`
85
- * running in the same dir (via `.bodify/serve.info.json` or `.env`). Falls
86
- * back to the Bodify agent proxy for deployed apps.
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
- // 1. Live `bod serve` info file — authoritative (correct port even if scanned).
90
- const info = readServeInfo()
91
- if (info) return directTarget(info.dbPort, info.dbAdminPassword, 'local serve')
92
- // 2. .env BODDB_ADMIN_PASSWORD + bodify.yaml database.port — works without restarting serve.
93
- const envPw = readDotEnv('BODDB_ADMIN_PASSWORD')
94
- if (envPw) return directTarget(readDbPortFromYaml(), envPw, 'direct via .env')
95
- // 3. Bodify agent proxy (deployed apps).
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))