vaulter-cli 2.3.3 → 2.3.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": "vaulter-cli",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "CLI tool for Vaulter - Secure API Key Manager",
5
5
  "author": "faris-sait",
6
6
  "repository": {
@@ -12,26 +12,48 @@ export async function showHelp() {
12
12
  console.log(status);
13
13
  console.log('');
14
14
 
15
- console.log(purple.bold(' COMMANDS'));
16
- console.log('');
17
-
18
- const commands = [
19
- { name: 'init', desc: 'Initialize current directory as a Vaulter project' },
20
- { name: 'sign-in', desc: 'Authenticate with Vaulter via browser' },
21
- { name: 'sign-out', desc: 'Sign out and clear saved credentials' },
22
- { name: 'ls', desc: 'List all API keys in your vault' },
23
- { name: 'add <name>', desc: 'Add a new API key to your vault' },
24
- { name: 'remove <name-or-id>', desc: 'Remove an API key from your vault' },
25
- { name: 'view [key_names...]', desc: 'Decrypt and display one or more API keys in your terminal' },
26
- { name: 'make [file]', desc: 'Generate a .env file from your vault keys' },
27
- { name: 'save [file]', desc: 'Upload a local .env file to your vault' },
28
- { name: 'web-app', desc: 'Open the Vaulter web app in your browser' },
29
- { name: 'help', desc: 'Show this help message' },
15
+ const sections = [
16
+ {
17
+ label: 'SETUP',
18
+ commands: [
19
+ { name: 'init', desc: 'Initialize current directory as a Vaulter project' },
20
+ { name: 'sign-in', desc: 'Authenticate with Vaulter via browser' },
21
+ { name: 'sign-out', desc: 'Sign out and clear saved credentials' },
22
+ ],
23
+ },
24
+ {
25
+ label: 'VAULT KEYS',
26
+ commands: [
27
+ { name: 'ls', desc: 'List all API keys in your vault' },
28
+ { name: 'add <name>', desc: 'Add a new API key to your vault' },
29
+ { name: 'remove <name-or-id>', desc: 'Remove an API key from your vault' },
30
+ { name: 'view [key_names...]', desc: 'Decrypt and display keys in your terminal' },
31
+ ],
32
+ },
33
+ {
34
+ label: 'FILES',
35
+ commands: [
36
+ { name: 'make [file]', desc: 'Generate a .env file from your vault keys' },
37
+ { name: 'save [file]', desc: 'Upload a local .env file to your vault' },
38
+ ],
39
+ },
40
+ {
41
+ label: 'MORE',
42
+ commands: [
43
+ { name: 'web-app', desc: 'Open the Vaulter web app in your browser' },
44
+ { name: 'help', desc: 'Show this help message' },
45
+ ],
46
+ },
30
47
  ];
31
48
 
32
- for (const cmd of commands) {
33
- const padded = cmd.name.padEnd(22);
34
- console.log(` ${white.bold(padded)} ${dim(cmd.desc)}`);
49
+ for (const section of sections) {
50
+ console.log(purple.bold(' ' + section.label));
51
+ console.log('');
52
+ for (const cmd of section.commands) {
53
+ const padded = cmd.name.padEnd(22);
54
+ console.log(` ${white.bold(padded)} ${dim(cmd.desc)}`);
55
+ }
56
+ console.log('');
35
57
  }
36
58
 
37
59
  console.log('');
@@ -43,21 +43,23 @@ export async function listKeys() {
43
43
  for (const key of keys) {
44
44
  const tags = (key.tags || []).join(', ') || dim('none');
45
45
  const created = new Date(key.created_at).toLocaleDateString();
46
- const usage = key.usage_count || 0;
46
+ const usageCount = key.usage_count || 0;
47
+ const usage = usageCount > 0 ? dim(`${usageCount}x`) : dim('—');
47
48
 
48
49
  table.push([
49
50
  chalk.white(key.name),
50
51
  chalk.hex('#a78bfa')(key.masked_key),
51
52
  dim(tags),
52
53
  dim(created),
53
- dim(`${usage}x`),
54
+ usage,
54
55
  ]);
55
56
  }
56
57
 
57
58
  console.log('');
58
59
  console.log(table.toString());
59
60
  console.log('');
60
- console.log(dim(` ${keys.length} key(s) in your vault`));
61
+ const label = keys.length === 1 ? '1 key in your vault' : `${keys.length} keys in your vault`;
62
+ console.log(dim(` ${label}`));
61
63
  tip('Run `vaulter make .env` to export keys to a .env file.');
62
64
  console.log('');
63
65
  } catch (err) {
@@ -3,7 +3,7 @@ import ora from 'ora';
3
3
  import chalk from 'chalk';
4
4
  import clipboardy from 'clipboardy';
5
5
  import { apiFetch } from '../lib/api.js';
6
- import { purple, dim, error, warn, green } from '../lib/ui.js';
6
+ import { purple, dim, error, warn, success, tip } from '../lib/ui.js';
7
7
 
8
8
  const DIVIDER_WIDTH = 60;
9
9
  const divider = chalk.dim('─'.repeat(DIVIDER_WIDTH));
@@ -96,6 +96,9 @@ export async function viewKeys(names) {
96
96
 
97
97
  decryptSpinner.stop();
98
98
 
99
+ const failed = rows.filter(r => r.value === null);
100
+ failed.forEach(r => warn(`Failed to decrypt "${r.name}"`));
101
+
99
102
  // Display cards
100
103
  console.log('');
101
104
  console.log(` ${chalk.dim('━'.repeat(DIVIDER_WIDTH))}`);
@@ -143,7 +146,7 @@ export async function viewKeys(names) {
143
146
  } else {
144
147
  try {
145
148
  await clipboardy.write(toCopy.value);
146
- console.log(` ${green('✔')} ${chalk.white(toCopy.name)} copied to clipboard.`);
149
+ success(`${chalk.white(toCopy.name)} copied to clipboard.`);
147
150
  console.log('');
148
151
  } catch {
149
152
  warn('Could not access clipboard. Copy the value manually from above.');
@@ -152,5 +155,6 @@ export async function viewKeys(names) {
152
155
  }
153
156
  }
154
157
 
158
+ tip('Run `clear` to wipe your terminal and protect these values.');
155
159
  console.log('');
156
160
  }
package/src/lib/ui.js CHANGED
@@ -11,11 +11,11 @@ export const yellow = chalk.yellow;
11
11
  export const cyan = chalk.cyan;
12
12
 
13
13
  export function success(msg) {
14
- console.log(green(' ' + msg));
14
+ console.log(green(' ' + msg));
15
15
  }
16
16
 
17
17
  export function error(msg) {
18
- console.log(red(' ' + msg));
18
+ console.log(red(' ' + msg));
19
19
  }
20
20
 
21
21
  export function info(msg) {
@@ -23,7 +23,7 @@ export function info(msg) {
23
23
  }
24
24
 
25
25
  export function warn(msg) {
26
- console.log(yellow(' ' + msg));
26
+ console.log(yellow(' ' + msg));
27
27
  }
28
28
 
29
29
  export function tip(msg) {