aptunnel 1.0.2 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptunnel",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Cross-platform Aptible tunnel manager — multi-tunnel, auto-discovery, background process management",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,10 +12,10 @@
12
12
  },
13
13
  "scripts": {
14
14
  "start": "node bin/aptunnel.js",
15
- "test": "node --test test/lib/platform.test.js test/lib/config-manager.test.js test/lib/process-manager.test.js test/lib/aptible.test.js test/lib/completions.test.js test/commands/config.test.js test/commands/help.test.js test/commands/status.test.js",
15
+ "test": "node --test test/lib/platform.test.js test/lib/config-manager.test.js test/lib/process-manager.test.js test/lib/aptible.test.js test/lib/completions.test.js test/commands/config.test.js test/commands/help.test.js test/commands/status.test.js test/commands/dbs.test.js",
16
16
  "test:integration": "node --test test/integration/cli.test.js",
17
- "test:all": "node --test test/lib/platform.test.js test/lib/config-manager.test.js test/lib/process-manager.test.js test/lib/aptible.test.js test/lib/completions.test.js test/commands/config.test.js test/commands/help.test.js test/commands/status.test.js test/integration/cli.test.js",
18
- "test:watch": "node --test --watch test/lib/platform.test.js test/lib/config-manager.test.js test/lib/process-manager.test.js test/lib/aptible.test.js test/lib/completions.test.js test/commands/config.test.js test/commands/help.test.js test/commands/status.test.js"
17
+ "test:all": "node --test test/lib/platform.test.js test/lib/config-manager.test.js test/lib/process-manager.test.js test/lib/aptible.test.js test/lib/completions.test.js test/commands/config.test.js test/commands/help.test.js test/commands/status.test.js test/commands/dbs.test.js test/integration/cli.test.js",
18
+ "test:watch": "node --test --watch test/lib/platform.test.js test/lib/config-manager.test.js test/lib/process-manager.test.js test/lib/aptible.test.js test/lib/completions.test.js test/commands/config.test.js test/commands/help.test.js test/commands/status.test.js test/commands/dbs.test.js"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -0,0 +1,66 @@
1
+ import chalk from 'chalk';
2
+ import { logger } from '../lib/logger.js';
3
+ import { exists, getAllDatabases } from '../lib/config-manager.js';
4
+
5
+ export function runDbs(args) {
6
+ if (!exists()) {
7
+ logger.warn('No config found. Run `aptunnel init` to set up.');
8
+ return;
9
+ }
10
+
11
+ // Optional filter: --env=ALIAS
12
+ const envFlag = args.find(a => a.startsWith('--env='))?.slice(6) ?? null;
13
+
14
+ let dbs = getAllDatabases();
15
+
16
+ if (envFlag) {
17
+ dbs = dbs.filter(d => d.envAlias === envFlag || d.environment === envFlag);
18
+ if (dbs.length === 0) {
19
+ logger.warn(`No databases found for environment: ${envFlag}`);
20
+ return;
21
+ }
22
+ }
23
+
24
+ if (dbs.length === 0) {
25
+ logger.dim(' No databases configured.');
26
+ return;
27
+ }
28
+
29
+ console.log('');
30
+
31
+ // Compute column widths
32
+ const cols = {
33
+ alias: Math.max(5, ...dbs.map(d => d.alias.length)),
34
+ handle: Math.max(8, ...dbs.map(d => d.handle.length)),
35
+ type: Math.max(4, ...dbs.map(d => d.type.length)),
36
+ port: Math.max(4, ...dbs.map(d => String(d.port).length)),
37
+ env: Math.max(11, ...dbs.map(d => d.envAlias.length)),
38
+ };
39
+
40
+ const header = [
41
+ 'ALIAS'.padEnd(cols.alias),
42
+ 'DATABASE'.padEnd(cols.handle),
43
+ 'TYPE'.padEnd(cols.type),
44
+ 'PORT'.padEnd(cols.port),
45
+ 'ENVIRONMENT',
46
+ ].join(' ');
47
+
48
+ console.log(chalk.bold(header));
49
+ console.log(chalk.dim('─'.repeat(header.length)));
50
+
51
+ for (const db of dbs) {
52
+ const row = [
53
+ chalk.cyan(db.alias.padEnd(cols.alias)),
54
+ db.handle.padEnd(cols.handle),
55
+ chalk.yellow(db.type.padEnd(cols.type)),
56
+ String(db.port).padEnd(cols.port),
57
+ chalk.dim(db.envAlias),
58
+ ].join(' ');
59
+
60
+ console.log(row);
61
+ }
62
+
63
+ console.log('');
64
+ console.log(chalk.dim(` ${dbs.length} database(s) configured. Use \`aptunnel <alias>\` to open a tunnel.`));
65
+ console.log('');
66
+ }
@@ -36,6 +36,7 @@ export function runHelp() {
36
36
  cmd('aptunnel init', 'Setup wizard (login, discover environments & databases)');
37
37
  cmd('aptunnel login [--status]', 'Login to Aptible or show token status');
38
38
  cmd('aptunnel status', 'Show all tunnel statuses and login info');
39
+ cmd('aptunnel dbs [--env=ALIAS]', 'List all configured databases');
39
40
  cmd('aptunnel config', 'View or modify configuration');
40
41
  cmd('aptunnel completions <bash|zsh|fish>', 'Print shell completion script');
41
42
  cmd('aptunnel <db-alias> [--port=N]', 'Open a tunnel to a database');
@@ -68,7 +68,7 @@ export async function runInit(args) {
68
68
  console.log('');
69
69
 
70
70
  const selection = await ask(
71
- `Select environments to configure (comma-separated numbers, or "all") [all]: `
71
+ `Select environments (comma-separated numbers, "all", or press Enter for all): `
72
72
  );
73
73
 
74
74
  let selectedEnvs;
@@ -273,8 +273,9 @@ function closeRL() {
273
273
  _rl.close();
274
274
  _rl = null;
275
275
  }
276
- // Ensure stdin is resumed so child processes can read from it (e.g. aptible 2FA)
277
- process.stdin.resume();
276
+ // Do NOT call process.stdin.resume() here. Flowing mode with no listener
277
+ // discards keystrokes. Child processes (aptible) read from fd 0 directly
278
+ // at OS level regardless of Node.js stream state.
278
279
  }
279
280
 
280
281
  function ask(prompt) {
@@ -93,7 +93,6 @@ function getRL() {
93
93
  }
94
94
  function closeRL() {
95
95
  if (_rl) { _rl.close(); _rl = null; }
96
- process.stdin.resume();
97
96
  }
98
97
 
99
98
  function ask(prompt) {
package/src/index.js CHANGED
@@ -83,6 +83,12 @@ try {
83
83
  break;
84
84
  }
85
85
 
86
+ case 'dbs': {
87
+ const { runDbs } = await import('./commands/dbs.js');
88
+ runDbs(rest);
89
+ break;
90
+ }
91
+
86
92
  case 'completions': {
87
93
  const { runCompletions } = await import('./commands/completions.js');
88
94
  await runCompletions(rest);