aptunnel 1.0.3 → 1.0.5
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 +4 -4
- package/src/commands/dbs.js +66 -0
- package/src/commands/help.js +1 -0
- package/src/commands/init.js +14 -9
- package/src/index.js +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aptunnel",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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
|
+
}
|
package/src/commands/help.js
CHANGED
|
@@ -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');
|
package/src/commands/init.js
CHANGED
|
@@ -68,7 +68,7 @@ export async function runInit(args) {
|
|
|
68
68
|
console.log('');
|
|
69
69
|
|
|
70
70
|
const selection = await ask(
|
|
71
|
-
`Select environments
|
|
71
|
+
`Select environments (comma-separated numbers, "all", or press Enter for all): `
|
|
72
72
|
);
|
|
73
73
|
|
|
74
74
|
let selectedEnvs;
|
|
@@ -87,12 +87,17 @@ export async function runInit(args) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// 7. Set default environment
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
console.log('');
|
|
91
|
+
console.log('Set a default environment (used when no --env flag is given):');
|
|
92
|
+
selectedEnvs.forEach((env, i) => console.log(` [${i + 1}] ${env.handle}`));
|
|
93
|
+
console.log(' [0] None (no default)');
|
|
94
|
+
const defChoice = await ask(`Default environment (0 to skip) [1]: `);
|
|
95
|
+
const defTrimmed = defChoice.trim();
|
|
96
|
+
let defaultEnvHandle = null;
|
|
97
|
+
if (defTrimmed === '0') {
|
|
98
|
+
defaultEnvHandle = null;
|
|
99
|
+
} else {
|
|
100
|
+
const defIdx = parseInt(defTrimmed || '1', 10) - 1;
|
|
96
101
|
if (defIdx >= 0 && defIdx < selectedEnvs.length) {
|
|
97
102
|
defaultEnvHandle = selectedEnvs[defIdx].handle;
|
|
98
103
|
}
|
|
@@ -166,8 +171,8 @@ export async function runInit(args) {
|
|
|
166
171
|
version: 1,
|
|
167
172
|
credentials: { email },
|
|
168
173
|
defaults: {
|
|
169
|
-
environment: defaultEnvHandle,
|
|
170
|
-
lifetime:
|
|
174
|
+
...(defaultEnvHandle ? { environment: defaultEnvHandle } : {}),
|
|
175
|
+
lifetime: '7d',
|
|
171
176
|
},
|
|
172
177
|
environments: configEnvironments,
|
|
173
178
|
tunnel_defaults: {
|
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);
|