@nourmohamed/vaultix-cli 1.0.0

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.
Files changed (2) hide show
  1. package/bin/cli.js +88 -0
  2. package/package.json +15 -0
package/bin/cli.js ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { Vaultix } = require('@nourmohamed/vaultix-sdk');
4
+
5
+ async function run() {
6
+ const args = process.argv.slice(2);
7
+ const command = args[0];
8
+ const target = args[1];
9
+
10
+ if (!command) {
11
+ console.error(`
12
+ Usage:
13
+ vaultix get <SECRET_NAME>
14
+ vaultix list
15
+ vaultix set <SECRET_NAME> <VALUE>
16
+ vaultix delete <SECRET_NAME>
17
+
18
+ Make sure VAULTIX_API_KEY environment variable is set.
19
+ `);
20
+ process.exit(1);
21
+ }
22
+
23
+ let vault;
24
+ try {
25
+ vault = new Vaultix();
26
+ } catch (err) {
27
+ console.error(`\x1b[31m[Error]\x1b[0m ${err.message}`);
28
+ process.exit(1);
29
+ }
30
+
31
+ if (command === 'get') {
32
+ if (!target) {
33
+ console.error('\x1b[31m[Error]\x1b[0m Please provide a secret name, e.g. "vaultix get STRIPE_KEY"');
34
+ process.exit(1);
35
+ }
36
+
37
+ try {
38
+ const value = await vault.get(target);
39
+ console.log(value); // output only the raw value so it can be piped into other tools
40
+ } catch (err) {
41
+ console.error(`\x1b[31m[Error]\x1b[0m ${err.message}`);
42
+ process.exit(1);
43
+ }
44
+ } else if (command === 'list') {
45
+ try {
46
+ const secrets = await vault.list();
47
+ console.log('\x1b[36m--- Active Secrets ---\x1b[0m');
48
+ secrets.forEach(s => {
49
+ console.log(`\x1b[32m${s.name}\x1b[0m (Service: ${s.service})`);
50
+ });
51
+ } catch (err) {
52
+ console.error(`\x1b[31m[Error]\x1b[0m ${err.message}`);
53
+ process.exit(1);
54
+ }
55
+ } else if (command === 'set') {
56
+ const value = args[2];
57
+ if (!target || !value) {
58
+ console.error('\x1b[31m[Error]\x1b[0m Please provide a secret name and value, e.g. "vaultix set STRIPE_KEY sk_live_123"');
59
+ process.exit(1);
60
+ }
61
+
62
+ try {
63
+ await vault.set(target, value);
64
+ console.log(`\x1b[32m[Success]\x1b[0m Secret '${target}' configured successfully.`);
65
+ } catch (err) {
66
+ console.error(`\x1b[31m[Error]\x1b[0m ${err.message}`);
67
+ process.exit(1);
68
+ }
69
+ } else if (command === 'delete') {
70
+ if (!target) {
71
+ console.error('\x1b[31m[Error]\x1b[0m Please provide a secret name, e.g. "vaultix delete STRIPE_KEY"');
72
+ process.exit(1);
73
+ }
74
+
75
+ try {
76
+ await vault.delete(target);
77
+ console.log(`\x1b[32m[Success]\x1b[0m Secret '${target}' deleted successfully.`);
78
+ } catch (err) {
79
+ console.error(`\x1b[31m[Error]\x1b[0m ${err.message}`);
80
+ process.exit(1);
81
+ }
82
+ } else {
83
+ console.error(`\x1b[31m[Error]\x1b[0m Unknown command: ${command}`);
84
+ process.exit(1);
85
+ }
86
+ }
87
+
88
+ run();
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@nourmohamed/vaultix-cli",
3
+ "version": "1.0.0",
4
+ "description": "Vaultix official CLI tool fetching secrets right from your terminal",
5
+ "main": "bin/cli.js",
6
+ "bin": {
7
+ "vaultix": "./bin/cli.js"
8
+ },
9
+ "dependencies": {
10
+ "@nourmohamed/vaultix-sdk": "^1.0.0"
11
+ },
12
+ "keywords": ["vaultix", "cli", "secrets", "api"],
13
+ "author": "Vaultix Team",
14
+ "license": "MIT"
15
+ }